diff --git a/nusadua/src/main/java/io/github/leibnizhu/nusadua/MethodOverloadProcessor.java b/nusadua/src/main/java/io/github/leibnizhu/nusadua/MethodOverloadProcessor.java index 8914c9a..437fc45 100644 --- a/nusadua/src/main/java/io/github/leibnizhu/nusadua/MethodOverloadProcessor.java +++ b/nusadua/src/main/java/io/github/leibnizhu/nusadua/MethodOverloadProcessor.java @@ -3,6 +3,7 @@ import com.google.auto.service.AutoService; import com.sun.tools.javac.api.JavacTrees; import com.sun.tools.javac.processing.JavacProcessingEnvironment; +import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.TreeMaker; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Names; @@ -38,7 +39,12 @@ public synchronized void init(ProcessingEnvironment processingEnv) { @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { MethodOverloadTranslator visitor = new MethodOverloadTranslator(treeMaker, messager, names); - roundEnv.getRootElements().forEach(element -> trees.getTree(element).accept(visitor)); + roundEnv.getRootElements().forEach(element -> { + JCTree tree = trees.getTree(element); + if (tree != null) { + tree.accept(visitor); + } + }); return true; } } \ No newline at end of file diff --git a/nusadua/src/main/java/io/github/leibnizhu/nusadua/MethodOverloadTranslator.java b/nusadua/src/main/java/io/github/leibnizhu/nusadua/MethodOverloadTranslator.java index 76bb198..4f2f3c0 100644 --- a/nusadua/src/main/java/io/github/leibnizhu/nusadua/MethodOverloadTranslator.java +++ b/nusadua/src/main/java/io/github/leibnizhu/nusadua/MethodOverloadTranslator.java @@ -43,7 +43,7 @@ public MethodOverloadTranslator(TreeMaker treeMaker, Messager messager, Names na */ @Override public void visitClassDef(JCTree.JCClassDecl jcClass) { - String classFullName = jcClass.sym.fullname.toString(); + String classFullName = Optional.ofNullable(jcClass.sym).map(s -> s.fullname).map(Object::toString).orElse(""); Queue newMethods = new LinkedList<>(); Map> methodSignMap = new HashMap<>(); //Map> jcClass.defs.stream()