<AWT Dev> [9] Review Request: 8076264 [macosx] Launching app on MacOSX requires enclosing class

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Fri Apr 10 16:36:48 UTC 2015


On 10.04.15 19:20, Martin Buchholz wrote:
> I don't get it.  Either providing this information (what "java 
> program" is running - main class and/or command line) is generally 
> useful or it is not.  There's nothing macosx-specific about it.  
> Either provide a clean blessed api (i.e. not an environment variable) 
> and have AWT etc use it on every platform or do not provide it at all.
API for what? This is internal implementation of argument passing from 
launcher to some known UI library, inside one particular jdk 
implementation. It would be good if some public api will be added for 
this(as requested in [1]) in jdk9, but it is not required for this 
functionality.
> Hmmm... come to think of it, "jps" gives a list of java processes and 
> tries to identify them using their main class, so there's 
> cross-platform precedent.
>
> So please just figure out how to stop setting this environment 
> variable at all.
>
> On Fri, Apr 10, 2015 at 8:02 AM, Kumar Srinivasan 
> <kumar.x.srinivasan at oracle.com <mailto:kumar.x.srinivasan at oracle.com>> 
> wrote:
>
>     and it looks like sun.java.command is no longer exported to Java.
>
>     /*
>      * inject the -Dsun.java.command pseudo property into the args
>     structure
>      * this pseudo property is used in the HotSpot VM to expose the
>      * Java class name and arguments to the main method to the VM. The
>      * HotSpot VM uses this pseudo property to store the Java class name
>      * (or jar file name) and the arguments to the class's main method
>      * to the instrumentation memory region. The sun.java.command pseudo
>      * property is not exported by HotSpot to the Java layer.
>      */
>
>     I guess you could get it from the intrumentation or serviceability
>     layer, that may likely be an additional overhead.
>
>     Kumar
>
>     On 4/10/2015 6:47 AM, Sergey Bylokhov wrote:
>
>         On 10.04.15 15:28, Martin Buchholz wrote:
>
>
>             My biggest gripe about the Mac behavior was that java
>             startup was doing AWT-specific initialization even though
>             there is no AWT code here.  Figure out how to move this
>             code into the AWT module somehow?  Isn't this sort of
>             thing one of the goals of jigsaw?
>
>             But looking at SetMainClassForAWT I see that this is hard
>             to change.  It's a mess.  Why does AWT, SWT and JavaFX
>             want to get the name of the main class, but ... only on Mac?!
>
>         It is used to initialize the name of the application during
>         start of UI library. Since there is no public way to take the
>         mainclass from the launcher(see [1] and [2]) we need to pass
>         this value ourself. I suppose such functionality is missing(or
>         not implemented) on other platforms.
>
>         [1] https://bugs.openjdk.java.net/browse/JDK-4827318
>         [2]
>         http://stackoverflow.com/questions/939932/how-to-determine-main-class-at-runtime-in-threaded-java-application
>
>
>               969      * WARNING: This environment variable is an
>             implementation detail and
>               970      * isn't meant for use outside of the core
>             platform. The mechanism for
>               971      * passing this information from Java launcher
>             to other modules may
>               972      * change drastically between update release,
>             and it may even be
>               973      * removed or replaced with another mechanism.
>               974      *
>               975      * NOTE: It is used by SWT, and JavaFX.
>
>
>             On Wed, Apr 8, 2015 at 6:29 AM, Sergey Bylokhov
>             <Sergey.Bylokhov at oracle.com
>             <mailto:Sergey.Bylokhov at oracle.com>
>             <mailto:Sergey.Bylokhov at oracle.com
>             <mailto:Sergey.Bylokhov at oracle.com>>> wrote:
>
>                 Hello.
>                 Please review the fix for jdk 9.
>                 After the fix we clear all errors caused by
>             getCanonicalName() on
>                 the mainclass and leave JAVA_MAIN_CLASS_ empty. This
>             empty case
>                 will be handled in the NSApplicationAWT.m.
>                 Plus small cleanup suggested in the bug
>             report(jstring->jclass).
>
>                 Bug: https://bugs.openjdk.java.net/browse/JDK-8076264
>                 Webrev can be found at:
>             http://cr.openjdk.java.net/~serb/8076264/webrev.01
>             <http://cr.openjdk.java.net/%7Eserb/8076264/webrev.01>
>                 <http://cr.openjdk.java.net/%7Eserb/8076264/webrev.01>
>
>                 --     Best regards, Sergey.
>
>
>
>
>
>


-- 
Best regards, Sergey.




More information about the core-libs-dev mailing list