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

JShell circularly-required classes cannot be defined

    XMLWordPrintable

Details

    • b23
    • generic
    • generic

    Description

      ADDITIONAL SYSTEM INFORMATION :
      ```
      $ java --version
      openjdk 17.0.1 2021-10-19
      OpenJDK Runtime Environment (build 17.0.1+12)
      OpenJDK 64-Bit Server VM (build 17.0.1+12, mixed mode)
      $ jshell --version
      jshell 17.0.1
      ```

      A DESCRIPTION OF THE PROBLEM :
      If there are some circularly-required classes in some specific way, they cannot be defined in jshell.

      Related bug: https://bugs.openjdk.java.net/browse/JDK-8137064 but that one is fixed. This one still persist in Java 17.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Type into jshell:

      ```
      class Y{ X x; }

      class X extends Y{
        @Override
        public String toString() {
          return "";
        }
      }
      ```

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Two classes `X` and `Y` are created.
      ACTUAL -
      Error messages:

      ```
      | Error:
      | cannot find symbol
      | symbol: class Y
      | class X extends Y{
      | ^
      | Error:
      | method does not override or implement a method from a supertype
      | @Override
      | ^-------^
      ```

      ---------- BEGIN SOURCE ----------
      See "steps to reproduce" above.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      It's possible to workaround by defining an empty class `X`, then define the class `X` as the actual one.

      Attachments

        Issue Links

          Activity

            People

              jlahoda Jan Lahoda
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: