< prev index next >

modules/javafx.graphics/src/main/java/javafx/application/Application.java

Print this page
rev 10404 : 8178015: Clarify requirement for app modules to export/open packages to javafx modules
Reviewed-by:

@@ -23,12 +23,11 @@
  * questions.
  */
 
 package javafx.application;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
+import java.lang.module.ModuleDescriptor;
 import java.util.List;
 import java.util.Map;
 
 import javafx.application.Preloader.PreloaderNotification;
 import javafx.scene.Scene;

@@ -64,14 +63,12 @@
  * <li>Calls the {@link #stop} method</li>
  * </ol>
  * <p>Note that the {@code start} method is abstract and must be overridden.
  * The {@code init} and {@code stop} methods have concrete implementations
  * that do nothing.</p>
- * <p>The {@code Application} subclass must be declared public, must have a
- * public no-argument constructor, and the
- * containing package must be exported (see {@code Module.isExported(String,Module)})
- * to the {@code javafx.graphics} module.</p>
+ * <p>The {@code Application} subclass must be declared public and must have a
+ * public no-argument constructor.</p>
  *
  * <p>Calling {@link Platform#exit} is the preferred way to explicitly terminate
  * a JavaFX Application. Directly calling {@link System#exit} is
  * an acceptable alternative, but doesn't allow the Application {@link #stop}
  * method to run.

@@ -80,10 +77,28 @@
  * <p>A JavaFX Application should not attempt to use JavaFX after the
  * FX toolkit has terminated or from a ShutdownHook, that is, after the
  * {@link #stop} method returns or {@link System#exit} is called.
  * </p>
  *
+ * <p><b>Applications in a Module</b></p>
+ * <p>
+ * If the {@code Application} subclass is in a named module then that class
+ * must be accessible by the {@code javafx.graphics} module. This means that
+ * in addition to the class itself being public, the module must
+ * {@link Module#isExported(String,Module) export} the containing package to
+ * at least the {@code javafx.graphics} module, either in its
+ * {@link ModuleDescriptor} (e.g., in its module-info.class) or by calling
+ * {@link Module#addExports}. Alternatively, the module can
+ * {@link Module#isOpen(String,Module) open} the containing package to the
+ * {@code javafx.graphics} module.
+ * </p>
+ * <p>
+ * If the class is not accessible by
+ * the {@code javafx.graphics} module, then an exception will be thrown when
+ * the application is launched.
+ * </p>
+ *
  * <p><b>Parameters</b></p>
  * <p>
  * Application parameters are available by calling the {@link #getParameters}
  * method from the {@link #init} method, or any time after the {@code init}
  * method has been called.

@@ -209,12 +224,13 @@
      * from the main method(). It must not be called more than once or an
      * exception will be thrown.
      * This is equivalent to launch(TheClass.class, args) where TheClass is the
      * immediately enclosing class of the method that called launch. It must
      * be a public subclass of Application with a public no-argument
-     * constructor, in a package that is exported
-     * (see {@code Module.isExported(String,Module)}) to at least the
+     * constructor, in a package that is
+     * {@link Module#isExported(String,Module) exported}
+     * (or {@link Module#isOpen(String,Module) opened}) to at least the
      * {@code javafx.graphics} module, or a RuntimeException will be thrown.
      *
      * <p>
      * The launch method does not return until the application has exited,
      * either via a call to Platform.exit or all of the application windows
< prev index next >