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

javac has a inconsistency issue between JDK 8 and JDK 11

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      java version "1.8.0_441"
      Java(TM) SE Runtime Environment (build 1.8.0_441-b07)
      Java HotSpot(TM) 64-Bit Server VM (build 25.441-b07, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      When we call an internal library (for example: com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl), JDK 8 compiles with warnings and is possible to execute the program. In JDK 11 and above, it shows compilation errors.

      To keep JDK consistency between versions, JDK 8 should throw the errors during compilation.

      STEPS TO REPRODUCE THE PROBLEM
      Compile test.java file

      javac test.java

      with JDK 11 and above, it will fail. With JDK 8 is possible to successfully run the code

      java test

      ACTUAL VS EXPECTED BEHAVIOR
      EXPECTED -
      (as in JDK 11)

      test.java:1: error: package com.sun.org.apache.xerces.internal.dom is not visible
      import com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl;
                                               ^
        (package com.sun.org.apache.xerces.internal.dom is declared in module java.xml, which does not export it)
      1 error

      ACTUAL -
      (as in JDK 8)

      test.java:1: warning: DeferredDocumentImpl is internal proprietary API and may be removed in a future release
      import com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl;
                                                   ^
      test.java:5: warning: DeferredDocumentImpl is internal proprietary API and may be removed in a future release
          DeferredDocumentImpl d = new DeferredDocumentImpl();
          ^
      test.java:5: warning: DeferredDocumentImpl is internal proprietary API and may be removed in a future release
          DeferredDocumentImpl d = new DeferredDocumentImpl();
                                       ^
      3 warnings

      ---------- BEGIN SOURCE ----------
      import com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl;

      public class test {
         public static void main(String[] args) {
              DeferredDocumentImpl d = new DeferredDocumentImpl();
         }
      }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: