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

Andrew Haley aph at redhat.com
Fri May 22 09:30:27 UTC 2020


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.

Anyway, never mind, it's not worth spending any more time thinking about.

Your patch is OK, thanks.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



More information about the jdk8u-dev mailing list