David,

In src/share/native/java/lang/java_props.h the new field should really also be in ifdef MACOSX.

The change to System.c allays my concerns there.

You can also consider the hotspot changes Reviewed.

Thanks,
David H.

On 24/10/2013 1:52 PM, David DeHaven wrote:

Another option (I think would make everyone happy) would be to add a native 
method to LWCToolkit.{java,m} that implements isAquaSession and returns a 
boolean. Call this new method in the static initializer and use it's return 
value to set java.awt.headless before calling initIDs. This will still be done 
early enough that Toolkit.java will end up wrapping LWCToolkit in a 
HeadlessToolkit, since it first initializes the wrapped toolkit *then* checks 
to see if it needs to be wrapped. Then all that code in java_props* and 
System.c could be removed.

I like this idea. But it needs testing.

Cool, I'll poke at it when I get a chance.

Doesn't work in LWCToolkit, GraphicsEnvironment gets initialized first which 
messes things up.

It sort of works in CGraphicsEnvironment. The problem there is 
GraphicsEnvironment.isHeadless() is called at least once prior to 
CGraphicsEnvironment being loaded which then caches the value (false) so just 
changing the system property doesn't do anything. I added a protected method to 
change headless and it works, but I'm not entirely happy with that approach and 
I'm not convinced there won't be other side effects. For one thing, what is 
calling isHeadless before CGE gets loaded and will it cope with the mode 
changing? I don't think we have time to chase down all the issues that might 
manifest from that change, when we know for certain the setting the property in 
System.c works fine.

I think the safest bet at this point is to move all the java_props.awt_headless 
field related code into #ifdef blocks so they only exist on Mac OS X. That will 
address the cross-platform concern and fix this issue. I just thought it would 
be useful for other platforms (especially embedded) to be able to poll their 
environment and set themselves up accordingly...


Updated (hopefully final...) webrev:
http://cr.openjdk.java.net/~ddehaven/8025673/jdk.3/

Changes from last version:
http://cr.openjdk.java.net/~ddehaven/8025673/jdk.3/webrev.delta/index.html

(src/windows/native/java/lang/java_props_md.c only shows up because of the 
delta webrev, it gets reverted back to the way it was)


As a side note, SplashScreen calls isHeadless and dumps a nice ugly stack trace 
in a non-GUI session. It does this in the existing code so that's something 
that'll need to be addressed as a separate issue. Also, the message returned by 
GraphicsEnvironment.getHeadlessMessage() isn't correct for Mac, that should 
either be made more generic or let the platform impl class return that string 
(if it's even known or loaded at the time...).

-DrD-

Reply via email to