JDK-7131021 : [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-01-18
  • Updated: 2017-05-17
  • Resolved: 2012-05-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
7u6 b08Fixed 8Fixed
On the Mac the following environment variables can be set by the launcher code:

JAVA_MAIN_CLASS_<pid> - a string containing the class name which main() methods is called.
JAVA_STARTED_ON_FIRST_THREAD_<pid> - set when the -XstartOnFirstThread is specified on the command line.
APP_ICON_<pid>, APP_NAME_<pid> - set when the corresponding -Xdock:icon or name are specified on the command line.

These variables were first introduced in Apple JDK. Oracle JDK for the Mac continues to use them. The variables are used from libosxapp dynamic library to initialize an instance of the NSApplicationAWT class properly.

While the APP_* and JAVA_STARTED_* are conditional, the JAVA_MAIN_CLASS is set unconditionally. This may cause problems with tests or applications that start another process from the currently running Java app, and want to be able to specify an empty or custom environment for the newly started app.

EVALUATION The proposed fix: http://cr.openjdk.java.net/~anthony/7u6-2-keepEnvVars-7131021.1/

EVALUATION We must write a regression test to check that launcher correctly sets the environment variables on the Mac.

EVALUATION ###@###.###: SWT relies on APP_NAME and APP_ICON. We should not drop support for these variables.

EVALUATION We could use a JVM system property instead of the JAVA_MAIN_CLASS_<pid> variable. E.g. sun.awt.mainClassName. Note that actually all of these parameters are used only after the JVM is started, and as such we could turn all of them into system properties. However, other software may rely on the existing environment variables. For instance, JavaFX relies on the APP_ICON_<pid> environment variable in order to set a dock icon for an FX app. We need to make sure these apps aren't broken if we replace the env. variables with system properties.