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

package sun.awt does not exist when compiling with "--release 8" flag

XMLWordPrintable

    • x86_64
    • windows_10

      ADDITIONAL SYSTEM INFORMATION :
      Oracle Build of Java 17

      java 17.0.7 2023-04-18 LTS
      Java(TM) SE Runtime Environment (build 17.0.7+8-LTS-224)
      Java HotSpot(TM) 64-Bit Server VM (build 17.0.7+8-LTS-224, mixed mode, sharing)

      Same issue with OpenJDK 20.

      A DESCRIPTION OF THE PROBLEM :
      When compiling with the "--release" flag set to version 8, JDK 17 cannot find sun.awt.* packages.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the source code with "javac --release 8 AwtTest.java"

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Since a JDK 8 rt.jar contains sun.awt.*, I would expect the code to compile without errors.

      From JEP 247: "For N < 9, the documented APIs consist of the public APIs that were on javac's default bootclasspath for JDK N."
      ACTUAL -
      .\AwtTest.java:1: error: package sun.awt does not exist
      import sun.awt.CausedFocusEvent;

      ---------- BEGIN SOURCE ----------
      import sun.awt.CausedFocusEvent;

      public class AwtTest {

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use a separate Java 8 JDK to compile this code

            pnarayanaswa Praveen Narayanaswamy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: