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

JDK 9 Class.newInstance performance degradation

    XMLWordPrintable

Details

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Issue is there for Oracle as well as OpenJDK java11

      A DESCRIPTION OF THE PROBLEM :
      We are seeing a performance degradation on JDK11 with Class.newInstance() as compared to JDK8.
      For quick check I executed below class on both JDK11 and JDK8. Execution time is ~25ms vs ~14ms in JDK11 and JDK8 respectively.
      Is this a known issue or any workaround?

      public class PerformanceTest {
          public PerformanceTest() {
          }
          public static void main(String[] args) {
              long l = System.currentTimeMillis();
              for (int i = 0; i < 100000; i++) {
                  try {
                      PerformanceTest.class.newInstance();
                  } catch (InstantiationException e) {
                      e.printStackTrace();
                  } catch (IllegalAccessException e) {
                      e.printStackTrace();
                  }
              }
              System.out.println("time taken = " + (System.currentTimeMillis() - l) + "ms");
          }
      }


      REGRESSION : Last worked in version 8

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute following class on JDK8 and JDK11 which indicates performance degradation with 11

      public class PerformanceTest {
          public PerformanceTest() {
          }
          public static void main(String[] args) {
              long l = System.currentTimeMillis();
              for (int i = 0; i < 100000; i++) {
                  try {
                      PerformanceTest.class.newInstance();
                  } catch (InstantiationException e) {
                      e.printStackTrace();
                  } catch (IllegalAccessException e) {
                      e.printStackTrace();
                  }
              }
              System.out.println("time taken = " + (System.currentTimeMillis() - l) + "ms");
          }
      }



      FREQUENCY : always


      Attachments

        Activity

          People

            bchristi Brent Christian
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated: