diff options
Diffstat (limited to 'jvmfwk/source/framework.cxx')
-rw-r--r-- | jvmfwk/source/framework.cxx | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index 63d5733f445a..0dd643d92d45 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -384,35 +384,28 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo) // query PATH for Java installations if (!bInfoFound) { - std::vector<JavaInfo*> vecJavaInfosFromPath; + std::vector<std::unique_ptr<JavaInfo>> vecJavaInfosFromPath; if (jfw_plugin_getJavaInfosFromPath( versionInfos, vecJavaInfosFromPath, infos) == javaPluginError::NONE) { - std::vector<JavaInfo*>::const_iterator it = vecJavaInfosFromPath.begin(); - while(it != vecJavaInfosFromPath.end() && !bInfoFound) + for (auto & pJInfo: vecJavaInfosFromPath) { - JavaInfo* pJInfo = *it; - if (pJInfo != nullptr) + // if the current Java installation implements all required features: use it + if ((pJInfo->nFeatures & nFeatureFlags) == nFeatureFlags) { - // if the current Java installation implements all required features: use it - if ((pJInfo->nFeatures & nFeatureFlags) == nFeatureFlags) - { - aCurrentInfo.reset(pJInfo); - bInfoFound = true; - } - else if (!aCurrentInfo) - { - // current Java installation does not provide all features - // but no Java installation has been detected before - // -> remember the current one until one is found - // that provides all features - aCurrentInfo.reset(pJInfo); - } - else - delete pJInfo; + aCurrentInfo = std::move(pJInfo); + bInfoFound = true; + break; + } + else if (!aCurrentInfo) + { + // current Java installation does not provide all features + // but no Java installation has been detected before + // -> remember the current one until one is found + // that provides all features + aCurrentInfo = std::move(pJInfo); } - ++it; } } } |