Some classes fail to compile when @ExtensionMethod annotation is used (Steps included) #496

Closed
lombokissues opened this Issue Jul 14, 2015 · 5 comments

Projects

None yet

2 participants

@lombokissues
Collaborator

Migrated from Google Code (issue 423)

@lombokissues
Collaborator

๐Ÿ‘ค cord.bartlett ย  ๐Ÿ•— Oct 26, 2012 at 01:24 UTC

After debugging several random compilation errors in a project of mine, I have been able to reproduce an example class that fails to compile when @ ExtensionMethod is included.

It does not matter if extension methods are even called, it will still fails to compile no matter what. The example class has been simplified as much as possible, and reproduces the error every time.

Tested with javac 1.7.0_05 / lombok 0.11.4 / maven 3.0.4
The project has no errors in eclipse / ECJ from what I can tell.

package example;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;

import lombok.Getter;
import lombok.experimental.ExtensionMethod;

@ ExtensionMethod(Empty.class) // does not matter whether or not we use extensions, so we'll just provide an empty class
public class LombokExample {

@ Getter
private String family = "xyz";

public List<Object> getMatches(Set<String> exclusions) {

    if (exclusions.contains(getFamily())) {
        return Collections.emptyList();
    }

    List<Object> matches = new ArrayList<Object>();

    Collections.sort(matches, new Comparator<Object>() {
        public int compare(Object o1, Object o2) {
            return o1.hashCode() - o2.hashCode();
        }
    });

    return matches;
}

}

package example;

public class Empty {}

What is the expected output? What do you see instead?

A stacktrace is emitted by the @ ExtensionMethod annotation processor during compilation

java.lang.NullPointerException: node
at lombok.javac.handlers.JavacHandlerUtil.upToTypeNode(JavacHandlerUtil.java:978)
at lombok.javac.handlers.HandleExtensionMethod$ExtensionMethodReplaceVisitor.handleMethodCall(HandleExtensionMethod.java:154)
at lombok.javac.handlers.HandleExtensionMethod$ExtensionMethodReplaceVisitor.visitMethodInvocation(HandleExtensionMethod.java:147)
at lombok.javac.handlers.HandleExtensionMethod$ExtensionMethodReplaceVisitor.visitMethodInvocation(HandleExtensionMethod.java:130)
at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1333)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.visitExpressionStatement(TreeScanner.java:240)
at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1173)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90)
at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:159)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:790)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:142)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:690)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:98)
at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:132)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:618)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.visitNewClass(TreeScanner.java:277)
at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1388)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:98)
at com.sun.source.util.TreeScanner.visitMethodInvocation(TreeScanner.java:268)
at lombok.javac.handlers.HandleExtensionMethod$ExtensionMethodReplaceVisitor.visitMethodInvocation(HandleExtensionMethod.java:148)
at lombok.javac.handlers.HandleExtensionMethod$ExtensionMethodReplaceVisitor.visitMethodInvocation(HandleExtensionMethod.java:130)
at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1333)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.visitExpressionStatement(TreeScanner.java:240)
at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1173)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90)
at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:159)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:790)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:142)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:690)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:98)
at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:132)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:618)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.visitNewClass(TreeScanner.java:277)
at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1388)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:98)
at com.sun.source.util.TreeScanner.visitMethodInvocation(TreeScanner.java:268)
at lombok.javac.handlers.HandleExtensionMethod$ExtensionMethodReplaceVisitor.visitMethodInvocation(HandleExtensionMethod.java:148)
at lombok.javac.handlers.HandleExtensionMethod$ExtensionMethodReplaceVisitor.visitMethodInvocation(HandleExtensionMethod.java:130)
at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1333)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.visitReturn(TreeScanner.java:252)
at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1246)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90)
at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:159)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:790)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:142)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:690)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:76)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:98)
at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:132)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:618)
at lombok.javac.handlers.HandleExtensionMethod$ExtensionMethodReplaceVisitor.replace(HandleExtensionMethod.java:142)
at lombok.javac.handlers.HandleExtensionMethod.handle(HandleExtensionMethod.java:86)
at lombok.javac.HandlerLibrary$AnnotationHandlerContainer.handle(HandlerLibrary.java:105)
at lombok.javac.HandlerLibrary.handleAnnotation(HandlerLibrary.java:243)
at lombok.javac.JavacTransformer$AnnotationVisitor.visitAnnotationOnType(JavacTransformer.java:86)
at lombok.javac.JavacNode.traverse(JavacNode.java:104)
at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
at lombok.javac.JavacNode.traverse(JavacNode.java:67)
at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
at lombok.javac.JavacNode.traverse(JavacNode.java:62)
at lombok.javac.JavacAST.traverse(JavacAST.java:117)
at lombok.javac.JavacTransformer.transform(JavacTransformer.java:70)
at lombok.javac.apt.Processor.process(Processor.java:249)
at lombok.core.AnnotationProcessor$JavacDescriptor.process(AnnotationProcessor.java:117)
at lombok.core.AnnotationProcessor.process(AnnotationProcessor.java:169)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
at com.sun.tools.javac.main.Main.compile(Main.java:439)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:342)
at com.sun.tools.javac.main.Main.compile(Main.java:333)
at com.sun.tools.javac.Main.compile(Main.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:554)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:161)
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:605)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

What version of the product are you using? On what operating system?
javac 1.7.0_05 (Windows 64 bit)
lombok 0.11.4
maven 3.0.4

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Oct 29, 2012 at 21:01 UTC

Reproducible with oracle java javac 1.7.0_09 on mac using the supplied example. (package is not relevant).

No maven is needed, just the above example and javac -cp lombok.jar LombokExample.java

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Oct 29, 2012 at 21:23 UTC

Fixed. Will be in the next release.

@lombokissues lombokissues removed the accepted label Jul 14, 2015
@lombokissues lombokissues added this to the 0.11.5 milestone Jul 14, 2015
@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Oct 30, 2012 at 00:09 UTC

Now officially released in lombok v0.11.6.

@lombokissues lombokissues modified the milestone: 0.11.5, 0.11.6 Jul 14, 2015
@lombokissues
Collaborator

End of migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment