Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8152163

Java 9 build 110 breaks java.lang.management.ManagementFactory's static getters

    XMLWordPrintable

Details

    Description

      FULL PRODUCT VERSION :
      java version "9-ea"
      Java(TM) SE Runtime Environment (build 9-ea+110)
      Java HotSpot(TM) 64-Bit Server VM (build 9-ea+110, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Fails on any operating system. Tested was:
      - Windows 7 64bits
      - Ubuntu Linux 14.04 64bits (including 32bits JDK)

      A DESCRIPTION OF THE PROBLEM :
      Any program making use of java.lang.management.ManagementFactory's static getters to get runtime, hotspot, garbage collector,.. beans fails because of a ServiceConfigurationError.

      This is most likely a packaging bug in build 110: The META-INF/services/sun.management.spi.PlatformMBeanProvider file contains calsses which are missing in the jimage.

      This bug is serious, because many projects fail, especially projects build by gradle: The build system does not boot up.

      The following problems have seen:
      - Gradle fails to start because the RuntimeMXBean cannot be used (to get PID of Java process). Elasticsearch cannot build because of that, so we are unable to test.
      - Apache Lucene fails some tests, because it detects Hotpot, but fails to get the HotspotMXBean. This is not fatal, because we work around non-existing hotpot bean.
      - Apache Lucene's test framework cannot print the PID of test runner processes (ManagementFactory.getRuntimeMXBean().getName() contains PID)
      - Elasticsearch does not start because it cannot get its own PID. It can also not monitor garbage collection

      REGRESSION. Last worked in version 9

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the attached source code with Java 9 build 110 and run the program.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Code should compile and later run without any output.
      ACTUAL -
      The following error message occurs. Any try to use ManagementFactory after this error leads to NoClassDefFoundError inside PlatformMBeanFinder (because static initializer failed).

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.util.ServiceConfigurationError: sun.management.spi.PlatformMBeanProvider: Provider jdk.management.cmm.internal.PlatformMBeanProviderImpl not found
              at java.util.ServiceLoader.fail(ServiceLoader.java:237)
              at java.util.ServiceLoader.access$300(ServiceLoader.java:183)
              at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:370)
              at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:402)
              at java.util.ServiceLoader$1.next(ServiceLoader.java:478)
              at java.lang.Iterable.forEach(Iterable.java:74)
              at java.lang.management.ManagementFactory$PlatformMBeanFinder.lambda$static$0(ManagementFactory.java:890)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.security.AccessController.doPrivileged(AccessController.java:428)
              at java.lang.management.ManagementFactory$PlatformMBeanFinder.<clinit>(ManagementFactory.java:886)
              at java.lang.management.ManagementFactory.getPlatformMXBean(ManagementFactory.java:649)
              at java.lang.management.ManagementFactory.getRuntimeMXBean(ManagementFactory.java:355)
              at Test.main(Test.java:6)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.lang.management.ManagementFactory;

      public final class Test {
       
        public static void main(String... args) throws Throwable {
          ManagementFactory.getRuntimeMXBean();
        }
         
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No workaround available

      Attachments

        Issue Links

          Activity

            People

              fmatte Fairoz Matte
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: