JDK-8222819 : Remove setting of headless property on MacOS from launcher code.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 11,13
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-04-22
  • Updated: 2019-05-20
  • Resolved: 2019-05-04
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.
JDK 13
13 b21Fixed
Related Reports
Relates :  
Relates :  
Description
There is a variable awt_headless in the native system props
structure used to populate system properties.

This was added relatively recently in bringing in the MacOS port.
Specifically it was added by this fix : 
https://bugs.openjdk.java.net/browse/JDK-8025673
Reviewed here : https://mail.openjdk.java.net/pipermail/awt-dev/2013-October/006114.html
Where since the fix was removing some macos specific code to select the toolkit class, it probably
didn't unreasonable to be setting this property as a better alternative
I think this email https://mail.openjdk.java.net/pipermail/awt-dev/2013-October/006132.html
started the discussion that lead to the result and conclusion we needed to use the
IsInAquaSession check to make sure we don't try to launch in headful mode if we can't.

Since then we've had another fix :
https://bugs.openjdk.java.net/browse/JDK-8208702
https://mail.openjdk.java.net/pipermail/awt-dev/2018-October/014534.html
which copied the isInAquaSession() code into the desktop module.

I think it should be possible to figure out entirely in the desktop module
code if we want to default to a headless session, as we already do for X11.

See java/awt/GraphicsEnvironment.java's getHeadlessProperty() method.
Is it as simple as calling isInAquaSession() for the macos case there ?

Then that launcher code can be removed.

Can getHeadlessProperty() be refactored so we don't have all the platform knowledge there?
Since you don't want to instantiate the platform classes of GE
we'd have to create some small helper class per-platform to give the answer.
It might not have been worth it before, but maybe is if we want to call MacOS native
code on MacOS ..