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

Can't get tree from a top level class

XMLWordPrintable

    • b59
    • 6
    • b59
    • generic
    • generic
    • Verified

      The annotation processor below throws a null pointer exception.

      import java.util.Set;
      import javax.annotation.processing.*;
      import javax.lang.model.element.*;
      import javax.lang.model.util.*;

      import com.sun.source.tree.*;
      import com.sun.tools.javac.api.Trees;

      @SupportedAnnotationTypes("*")
      public class MyAnnotationProcessor extends AbstractProcessor {
          public boolean process(Set<? extends TypeElement> annotations,
                                 RoundEnvironment roundEnvironment)
          {
              final Trees trees = Trees.instance(processingEnv);
              for (TypeElement e : roundEnvironment.getSpecifiedTypeElements()) {
                  ClassTree node = trees.getTree(e);
                  node.getClass();
              }
              return true;
          }
      }

            ahe Peter Ahe
            ahe Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: