[8u] RFR(XS) 8245617: ObjectSizeCalculator is not supported on OpenJDK

Yangfei (Felix) felix.yang at huawei.com
Sat May 23 01:31:46 UTC 2020



> -----Original Message-----
> From: Andrew Haley [mailto:aph at redhat.com]
> Sent: Friday, May 22, 2020 5:30 PM
> To: Yangfei (Felix) <felix.yang at huawei.com>; 'jdk8u-dev at openjdk.java.net'
> <jdk8u-dev at openjdk.java.net>
> Subject: Re: [8u] RFR(XS) 8245617: ObjectSizeCalculator is not supported on
> OpenJDK
> 
> On 5/22/20 9:36 AM, Yangfei (Felix) wrote:
> 
> > 8u-specific bug: https://bugs.openjdk.java.net/browse/JDK-8245617
> > ObjectSizeCalculator is not supported for the latest openjdk 8u release, as
> indicated by the test case.
> > Method getEffectiveMemoryLayoutSpecification in
> ObjectSizeCalculator.java is expecting a vmName which starts with "Java
> HotSpot(TM) ".
> > For openjdk 8u release, we have a vmName like: "OpenJDK 64-Bit Server
> VM".
> >
> > Fix is trivial:
> > diff -r f5a3d8f60cf5
> src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java
> > --- a/src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java       Tue
> May 19 05:11:20 2020 +0100
> > +++ b/src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java       Fri
> May 22 15:50:37 2020 +0800
> > @@ -396,7 +396,8 @@
> >       */
> >      public static MemoryLayoutSpecification
> getEffectiveMemoryLayoutSpecification() {
> >          final String vmName = System.getProperty("java.vm.name");
> > -        if (vmName == null || !vmName.startsWith("Java HotSpot(TM) ")) {
> > +        if (vmName == null
> > +            || (!vmName.startsWith("OpenJDK ") &&
> > + !vmName.startsWith("Java HotSpot(TM) "))) {
> >              throw new UnsupportedOperationException(
> >                      "ObjectSizeCalculator only supported on HotSpot VM");
> >          }
> 
> This code looks almost absurdly fragile. Does it do anything useful at all?
> I suppose it'd give you an error message if you tried to run it on J9.

Indeed.  The code is there since 2013.

> Anyway, never mind, it's not worth spending any more time thinking about.
> 
> Your patch is OK, thanks.

Thanks for the quick review.  Will push this trivial change.

Felix


More information about the jdk8u-dev mailing list