8208531: -javafx mode should be on by default when JavaFX is available

Reviewed-by: jjg
This commit is contained in:
Priya Lakshmi Muthuswamy 2018-10-03 11:43:39 +05:30
parent 8e53d1b5dc
commit 5cfc3bbdd4
2 changed files with 117 additions and 0 deletions

View file

@ -399,6 +399,10 @@ public abstract class BaseConfiguration {
// Utils needs docEnv, safe to init now.
utils = new Utils(this);
if (!javafx) {
javafx = isJavaFXMode();
}
// Once docEnv and Utils have been initialized, others should be safe.
cmtUtils = new CommentUtils(this);
workArounds = new WorkArounds(this);
@ -1347,4 +1351,19 @@ public abstract class BaseConfiguration {
public synchronized VisibleMemberTable getVisibleMemberTable(TypeElement te) {
return visibleMemberCache.getVisibleMemberTable(te);
}
/**
* Determines if JavaFX is available in the compilation environment.
* @return true if JavaFX is available
*/
public boolean isJavaFXMode() {
TypeElement observable = utils.elementUtils.getTypeElement("javafx.beans.Observable");
if (observable != null) {
ModuleElement javafxModule = utils.elementUtils.getModuleOf(observable);
if (javafxModule == null || javafxModule.isUnnamed() || javafxModule.getQualifiedName().contentEquals("javafx.base")) {
return true;
}
}
return false;
}
}