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

NPE in Types.containsType for type variable used as a qualifier

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2 P2
    • None
    • None
    • tools

      The following example uses a type variable as a qualifier, which is unusual but I think it's legal and should be equivalent to `A.B` here. Even if this isn't legal it shouldn't cause a crash.

      class A<T> {
        protected class B<V> {}

        public static <T, M extends A<T>> void f(Object g) {
          @SuppressWarnings("unchecked")
          M.B<?> mapping = (M.B<?>) g;
        }
      }

      $ /google/data/ro/projects/java-platform/linux-amd64/jdk-25-latest/bin/javac -fullversion A.java
      javac full version "25-ea+23-2842"
      An exception has occurred in the compiler (25-ea). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
      java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Type.accept(com.sun.tools.javac.code.Type$Visitor, Object)" because "t" is null
              at jdk.compiler/com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:4936)
              at jdk.compiler/com.sun.tools.javac.code.Types.containsType(Types.java:1553)
              at jdk.compiler/com.sun.tools.javac.code.Types$1.visitClassType(Types.java:519)
              at jdk.compiler/com.sun.tools.javac.code.Types$1.visitClassType(Types.java:504)
              at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:1052)
              at jdk.compiler/com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:5016)
              at jdk.compiler/com.sun.tools.javac.code.Types.isUnbounded(Types.java:501)
              at jdk.compiler/com.sun.tools.javac.code.Types.giveWarning(Types.java:4566)
              at jdk.compiler/com.sun.tools.javac.code.Types$7.visitClassType(Types.java:1813)
              at jdk.compiler/com.sun.tools.javac.code.Types$7.visitClassType(Types.java:1722)
              at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:1052)
              at jdk.compiler/com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:4936)
              at jdk.compiler/com.sun.tools.javac.code.Types.isCastable(Types.java:1656)
              at jdk.compiler/com.sun.tools.javac.comp.Check.checkCastable(Check.java:630)
              at jdk.compiler/com.sun.tools.javac.comp.Check.checkCastable(Check.java:627)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitTypeCast(Attr.java:4120)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCTypeCast.accept(JCTree.java:2249)

            Unassigned Unassigned
            cushon Liam Miller-Cushon
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: