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

[lworld] Separate compilation failure of generic inline class

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: repo-valhalla
    • Fix Version/s: repo-valhalla
    • Component/s: tools
    • Labels:

      Description

      If I have this inline class and a test class

      public inline class Range<T> {
          private final T lower;
          private final T upper;

          private Range(T lower, T upper) {
              this.lower = lower;
              this.upper = upper;
          }

          public static <T> Range<T> of(T lower, T upper) {
              return new Range<>(lower, upper);
          }
      }

      public class Test {
          public static void main(String[] args) {
              Range<Integer> r = Range.of(1, 2);
          }
      }

      Compiling Range first and then, separately, Test fails:


      $ javac Range.java
      $ javac Test.java
      Test.java:3: error: cannot access Range
              Range<Integer> r = Range.of(1, 2);
              ^
        bad class file: ./Range.class
          method descriptor invalid for <init>
          Please remove or make sure it appears in the correct subdirectory of the classpath.
      1 error

      This came about as I was writing some inline classes and corresponding tests.

      For more details and possible fix see email:

      https://mail.openjdk.java.net/pipermail/valhalla-dev/2020-December/008434.html

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sadayapalam Srikanth Adayapalam
              Reporter:
              psandoz Paul Sandoz
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: