AssertionError: isSubtype PACKAGE in Check.checkAccessFromSerializableElementInner

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P2
    • 27
    • Affects Version/s: None
    • Component/s: tools

      Recent JDK 27 EA builds of javac are crashing on the following program.

      The following program has an error (the symbol NoSuch isn't defined), which should be reported as a diagnostic instead of causing a crash.

      ```
      import static java.util.stream.Collectors.toSet;

      import java.io.Serializable;
      import java.util.Set;
      import java.util.stream.Stream;

      abstract class Z {
        Supplier<Set<String>> f() {
          return g(
              s -> Stream.of(NoSuch.NAMES.stream(), Stream.of("hello")).flatMap(i -> i).collect(toSet()));
        }

        abstract <T> Supplier<T> g(Supplier<T> f);
      }

      interface Supplier<T> extends Serializable {
        T get(VisitorState state);
      }

      class VisitorState {
        String getName(String s);
      }
      ```

      $ javac -fullversion Z.java
      ...
      java.lang.AssertionError: isSubtype PACKAGE
              at jdk.compiler/com.sun.tools.javac.code.Types$4.visitType(Types.java:1129)
              at jdk.compiler/com.sun.tools.javac.code.Types$4.visitType(Types.java:1106)
              at jdk.compiler/com.sun.tools.javac.code.Types$DefaultTypeVisitor.visitPackageType(Types.java:4981)
              at jdk.compiler/com.sun.tools.javac.code.Type$PackageType.accept(Type.java:1592)
              at jdk.compiler/com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:4976)
              at jdk.compiler/com.sun.tools.javac.code.Types.isSubtype(Types.java:1102)
              at jdk.compiler/com.sun.tools.javac.code.Types.isSubtype(Types.java:1073)
              at jdk.compiler/com.sun.tools.javac.comp.Check.checkAccessFromSerializableElementInner(Check.java:2900)
              at jdk.compiler/com.sun.tools.javac.comp.Check.checkAccessFromSerializableElement(Check.java:2882)

      This appears to be a regression since JDK 25, the JDK 25 javac reports the following diagnostics:

      javac full version "25.0.2+10-69"
      T.java:10: error: package NoSuch does not exist
              s -> Stream.of(NoSuch.NAMES.stream(), Stream.of("hello")).flatMap(i -> i).collect(toSet()));
                                   ^
      T.java:21: error: missing method body, or declare abstract
        String getName(String s);
               ^
      2 errors

            Assignee:
            Liam Miller-Cushon
            Reporter:
            Liam Miller-Cushon
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: