Skip to content
Permalink
Browse files

8256362: JavaFX must warn when the javafx.* modules are loaded from t…

…he classpath

Reviewed-by: arapte, pbansal, jvos
  • Loading branch information
kevinrushforth committed Jan 12, 2021
1 parent 9dd2058 commit 1d4599735cbd130ea6abf624f70961fe16d60edd
@@ -31,8 +31,10 @@
import com.sun.javafx.tk.TKListener;
import com.sun.javafx.tk.TKStage;
import com.sun.javafx.tk.Toolkit;
import com.sun.javafx.util.Logging;
import com.sun.javafx.util.ModuleHelper;

import java.lang.module.ModuleDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessControlContext;
@@ -187,6 +189,23 @@ public static void startup(final Runnable r, boolean preventDuplicateCalls) {
return;
}

final Module module = PlatformImpl.class.getModule();
final ModuleDescriptor moduleDesc = module.getDescriptor();
if (!module.isNamed()
|| !"javafx.graphics".equals(module.getName())
|| moduleDesc == null
|| moduleDesc.isAutomatic()
|| moduleDesc.isOpen()) {

String warningStr = "Unsupported JavaFX configuration: "
+ "classes were loaded from '" + module + "'";
if (moduleDesc != null) {
warningStr += ", isAutomatic: " + moduleDesc.isAutomatic();
warningStr += ", isOpen: " + moduleDesc.isOpen();
}
Logging.getJavaFXLogger().warning(warningStr);
}

AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
applicationType = System.getProperty("com.sun.javafx.application.type");
if (applicationType == null) applicationType = "";
@@ -80,6 +80,12 @@
* {@link #stop} method returns or {@link System#exit} is called.
* </p>
*
* <p><b>Note:</b> The JavaFX classes must be loaded from a set of
* named {@code javafx.*} modules on the <em>module path</em>.
* Loading the JavaFX classes from the classpath is not supported.
* See {@link Platform#startup(Runnable) Platform.startup}
* for more information.
*
* <p><b>Deploying an Application as a Module</b></p>
* <p>
* If the {@code Application} subclass is in a named module then that class
@@ -90,6 +90,14 @@ private Platform() {
* that the JavaFX runtime be started once.
* </p>
*
* <p><b>Note:</b> The JavaFX classes must be loaded from a set of
* named {@code javafx.*} modules on the <em>module path</em>.
* Loading the JavaFX classes from the classpath is not supported.
* A warning is logged when the JavaFX runtime is started if the JavaFX
* classes are not loaded from the expected named module.
* This warning is logged regardless of whether the JavaFX runtime was
* started by calling this method or automatically as described above.
*
* @throws IllegalStateException if the JavaFX runtime is already running
*
* @param runnable the Runnable whose run method will be executed on the
@@ -30,6 +30,12 @@
* as well as APIs for animation, css, concurrency, geometry, printing, and
* windowing.
*
* <p><b>Note:</b> The JavaFX classes must be loaded from a set of
* named {@code javafx.*} modules on the <em>module path</em>.
* Loading the JavaFX classes from the classpath is not supported.
* See {@link javafx.application.Platform#startup(Runnable) Platform.startup}
* for more information.
*
* @moduleGraph
* @since 9
*/

0 comments on commit 1d45997

Please sign in to comment.