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

NPE in Attr.attribIdentAsEnumType

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 8, 9, 10, 11, 12, 13
    • Fix Version/s: None
    • Component/s: tools

      Description

      My colleague Alan Malloy discovered the following crash, which involves a circular enum declaration and annotation processing enabled:

      === EmptyProcessor.java
      import java.util.Set;
      import javax.annotation.processing.AbstractProcessor;
      import javax.annotation.processing.RoundEnvironment;
      import javax.lang.model.element.TypeElement;

      public class EmptyProcessor extends AbstractProcessor {
        @Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
          return false;
        }
      }
      === Mistake.java
      public enum Mistake implements Mistake {
        MISTAKE;
      }
      ===

      $ javac -fullversion
      javac full version "13-ea+22"
      $ javac EmptyProcessor.java
      $ javac -processor EmptyProcessor Mistake.java
      An exception has occurred in the compiler (13-ea). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://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
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribIdentAsEnumType(Attr.java:927)
      at jdk.compiler/com.sun.tools.javac.comp.MemberEnter.visitVarDef(MemberEnter.java:263)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:962)
      at jdk.compiler/com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:163)
      at jdk.compiler/com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:175)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                cushon Liam Miller-Cushon
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: