RFR : 8195857 : Posix platforms : move os::is_headless_jre check coding to os::Posix and remove test for libmawt

David Holmes david.holmes at oracle.com
Thu Jan 25 11:56:53 UTC 2018


On 25/01/2018 7:15 PM, Lindenmaier, Goetz wrote:
> Hi,
> 
> Change looks good :)

+1 - thanks Matthias!

> Would it make sense to rename the bug to "Remove os::is_headless_jre"?

+1 on that too!

David
------

> Best regards,
>    Goetz.
> 
> -----Original Message-----
> From: Baesken, Matthias
> Sent: Thursday, January 25, 2018 8:49 AM
> To: David Holmes <david.holmes at oracle.com>; Bob Vandette <bob.vandette at oracle.com>
> Cc: hotspot-dev at openjdk.java.net; Lindenmaier, Goetz <goetz.lindenmaier at sap.com>
> Subject: RE: RFR : 8195857 : Posix platforms : move os::is_headless_jre check coding to os::Posix and remove test for libmawt
> 
> Hi David,  I created a new webrev :
> 
> http://cr.openjdk.java.net/~mbaesken/webrevs/8195857.1/
> 
> This one removes  os::is_headless_jre()  .
> 
> Please review.
> 
> Thanks, Matthias
> 
> 
>> -----Original Message-----
>> From: David Holmes [mailto:david.holmes at oracle.com]
>> Sent: Donnerstag, 25. Januar 2018 07:39
>> To: Baesken, Matthias <matthias.baesken at sap.com>; Bob Vandette
>> <bob.vandette at oracle.com>
>> Cc: hotspot-dev at openjdk.java.net
>> Subject: Re: RFR : 8195857 : Posix platforms : move os::is_headless_jre check
>> coding to os::Posix and remove test for libmawt
>>
>> Hi Matthias,
>>
>> On 25/01/2018 4:36 PM, Baesken, Matthias wrote:
>>>>
>>>> Bottom line: os::is_headless_jre() is dead code as far as I can see.
>>>>
>>>
>>> Hi David,  so do you suggest I prepare a new webrev  where
>> os::is_headless_jre()  is  completely removed ?
>>>
>>> What about the code block in  hotspot/share/runtime/arguments.cpp  ,  do
>> you think this can be completely removed as well ?
>>
>> Yes - everything pertaining to os::is_headless_jre() can be removed.
>>
>> Thanks,
>> David
>> -----
>>
>>>
>>> 3495  if (os::is_headless_jre()) {
>>> 3496    const char* headless =
>> Arguments::get_property("java.awt.headless");
>>> 3497    if (headless == NULL) {
>>> 3498      const char *headless_env = ::getenv("JAVA_AWT_HEADLESS");
>>> 3499      if (headless_env == NULL) {
>>> 3500        if (!add_property("java.awt.headless=true")) {
>>> 3501          return JNI_ENOMEM;
>>> 3502        }
>>> 3503      } else {
>>> 3504        char buffer[256];
>>> 3505        jio_snprintf(buffer, sizeof(buffer), "java.awt.headless=%s",
>> headless_env);
>>> 3506        if (!add_property(buffer)) {
>>> 3507          return JNI_ENOMEM;
>>> 3508        }
>>> 3509      }
>>> 3510    }
>>> 3511  }
>>>
>>> Best regards, Matthias
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: David Holmes [mailto:david.holmes at oracle.com]
>>>> Sent: Donnerstag, 25. Januar 2018 02:16
>>>> To: Bob Vandette <bob.vandette at oracle.com>
>>>> Cc: Baesken, Matthias <matthias.baesken at sap.com>; hotspot-
>>>> dev at openjdk.java.net
>>>> Subject: Re: RFR : 8195857 : Posix platforms : move os::is_headless_jre
>> check
>>>> coding to os::Posix and remove test for libmawt
>>>>
>>>> On 24/01/2018 11:16 PM, Bob Vandette wrote:
>>>>>> On Jan 23, 2018, at 5:50 PM, David Holmes <david.holmes at oracle.com>
>>>> wrote:
>>>>>>
>>>>>> Hi Bob,
>>>>>>
>>>>>> On 24/01/2018 1:25 AM, Bob Vandette wrote:
>>>>>>> If we are going to preserve this functionality and make alterations, I
>>>> suggest that
>>>>>>> we try to move this into the desktop module and remove it from the
>>>> hotspot sources.
>>>>>>> Other than finding an appropriate path at startup to initialize the
>>>> property, there is
>>>>>>> no reason why this check can’t be written in Java.   This functionality
>> has
>>>> nothing to
>>>>>>> do with Hotspot or VMs.  (I should have probably done this when I
>> first
>>>> added this check).
>>>>>>
>>>>>> Well we hacked it into the SE Embedded builds so we knew what lib
>> was
>>>> missing.
>>>>>>
>>>>>> I don't think what you suggest really makes sense in a modular world
>>>> because I don't think we expect to have java.desktop but not some of its
>>>> native parts - so there would be no trigger to force into headless mode.
>>>> More likely there is simply no java.desktop module at all.
>>>>> The automatic setting of java.awt.headless has nothing to do with
>> compact
>>>> profiles.  This support was available in JDK 7 before profiles even existed.
>>>> This
>>>>> automatic headless detection was added in order to allow Java to be
>>>> ported to platforms that do not have a native windowing toolkit available.
>>>> This was
>>>>> used in embedded to also reduce the size of the binary by removing this
>>>> big library.  A configuration that contains java.desktop can absolutely be
>>>> supported
>>>>> and the JCK can be passed without this native library.
>>>>>
>>>>> This Java property is only referenced by the desktop module.  This is why
>> I
>>>> suggested that this functionality be moved out of the hotspot VM.
>>>>
>>>> Yes we forced the AWT into headless mode if there was no native
>> graphics
>>>> library support available. For some of those platforms we even did this
>>>> at build time, not via a runtime check. For SE Embedded support we
>> would
>>>> strip the library out at image build time, and so the runtime check
>>>> would force AWT into headless mode. For compact profiles there is no
>> AWT
>>>> at all, and no native library in the built image so the runtime check
>>>> still (vacuously) sets the property for headless mode.
>>>>
>>>> If you have the java.desktop module, then you have everything - there is
>>>> no fragmentation of that module that I am aware of, that would allow you
>>>> strip out the library that triggers os::is_headless_jre() or some other
>>>> check that forces the AWT into headless mode. If you have java.desktop
>>>> and you want headless mode then you have to ask for it explicitly.
>>>>
>>>> Bottom line: os::is_headless_jre() is dead code as far as I can see.
>>>>
>>>> Separately I'll file a bug to remove the compact profile builds.
>>>>
>>>> David
>>>> -----
>>>>
>>>>> Bob.
>>>>>
>>>>>
>>>>>>
>>>>>> That said I was reminded that this is also used by the Compact Profiles
>>>> that were added in Java 8, but for which support was removed as from
>> Java 9
>>>> (and modules). However the build logic is still present, and they still use
>> this
>>>> functionality. I think we can remove compact profiles completely in JDK
>> 11,
>>>> but that's a seperate tasks.
>>>>>>
>>>>>> Meanwhile if we kill off the os::is_headless_jre() logic then the
>> compact
>>>> profiles would not default to headless mode even though they can't run
>>>> headful (due to the missing native library as well as other Java APIs). But
>> the
>>>> only impact I can see there would be for running tests - and we're not
>> testing
>>>> compact profiles. So ... I still think this can be removed, but want to do a
>>>> couple more checks.
>>>>>>
>>>>>> Cheers,
>>>>>> David
>>>>>>
>>>>>>> Bob.
>>>>>>>> On Jan 23, 2018, at 5:57 AM, Baesken, Matthias
>>>> <matthias.baesken at sap.com> wrote:
>>>>>>>>
>>>>>>>> Hi David, thanks for the comments.
>>>>>>>>
>>>>>>>>> I'd need to do some checking but I think this may all be effectively
>>>>>>>>> dead code.
>>>>>>>>
>>>>>>>> Please do the checking, maybe we can completely remove it.
>>>>>>>>
>>>>>>>> Best Regards, Matthias
>>>>>>>>
>>>>>>>>
>>>>>>>>> -----Original Message-----
>>>>>>>>> From: David Holmes [mailto:david.holmes at oracle.com]
>>>>>>>>> Sent: Dienstag, 23. Januar 2018 11:30
>>>>>>>>> To: Baesken, Matthias <matthias.baesken at sap.com>; 'hotspot-
>>>>>>>>> dev at openjdk.java.net' <hotspot-dev at openjdk.java.net>
>>>>>>>>> Subject: Re: RFR : 8195857 : Posix platforms : move
>>>> os::is_headless_jre check
>>>>>>>>> coding to os::Posix and remove test for libmawt
>>>>>>>>>
>>>>>>>>> Hi Matthias,
>>>>>>>>>
>>>>>>>>> Some preliminary comments ...
>>>>>>>>>
>>>>>>>>> On 23/01/2018 6:24 PM, Baesken, Matthias wrote:
>>>>>>>>>> Hello,  I  noticed that  os::is_headless_jre()  still checks  on the
>> Posix
>>>>>>>>> platforms  for libmawt  which is not present any longer.
>>>>>>>>>
>>>>>>>>> I wonder why that comment was put in but the code not changed
>> ...
>>>>>>>>>
>>>>>>>>>> Additionally the  os::is_headless_jre()   function could be  put in a
>>>> central
>>>>>>>>> place at os_posix  to avoid code duplication.
>>>>>>>>>
>>>>>>>>> I think you could simplify further and just define in os.cpp with
>> three
>>>>>>>>> cases: windows, OS X, posix. I normally wouldn't suggest that but
>>>> given
>>>>>>>>> Windows and OS X are always false, it's quite trivial.
>>>>>>>>>
>>>>>>>>> That said this may simplify even further because I don't know if the
>>>>>>>>> concept of a headless JRE is even meaningful anymore. This what
>> put
>>>> in
>>>>>>>>> place in 2010 to support Java SE Embedded. We had a special build
>>>>>>>>> process that would remove the library from the JRE image, then a
>>>> runtime
>>>>>>>>> check os::is_headless_jre() run during argument processing, that if
>>>>>>>>> true, caused the java.awt.headless property to be set to true
>> (unless
>>>>>>>>> already set). I don't think we can even build a "headless JRE" any
>>>> more.
>>>>>>>>>
>>>>>>>>> I'd need to do some checking but I think this may all be effectively
>>>>>>>>> dead code.
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> David
>>>>>>>>> -------
>>>>>>>>>
>>>>>>>>>> Could you please review my change .
>>>>>>>>>>
>>>>>>>>>> Webrev :
>>>>>>>>>>
>>>>>>>>>> http://cr.openjdk.java.net/~mbaesken/webrevs/8195857/
>>>>>>>>>>
>>>>>>>>>> Bug :
>>>>>>>>>>
>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8195857
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks, Matthias
>>>>>>>>>>
>>>>>


More information about the hotspot-dev mailing list