lishunli / projectlombok

Automatically exported from code.google.com/p/projectlombok
0 stars 0 forks source link

@ExtensionMethod causes NullPointerException thrown by Eclipse during compilation #541

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I haven't been able to reproduce this yet. The problem popped up when I was 
editing a class with @ExtensionMethod(Iterables.class) (from Guava) on it. Some 
compile errors popped up while editing (as expected), but then Eclipse started 
throwing NullPointerExceptions while compiling. Fixing the compile errors made 
it all work again, including the calls to extension methods, removing 
@ExtensionMethod fixed the exception, and allowed me to continue working as 
normal.
I hope you can get enough info from the stack trace. If not, I'll try to reduce 
the source file to manageable size so we can find a reproduction recipe.

What version of the product are you using? On what operating system?
Eclipse 3.7.1
Java version 1.7.0_07
Lombok version 0.11.8
OS Windows 7

Please provide any additional information below.
Stack trace from Eclipse error log:
Java Model Exception: java.lang.NullPointerException
    at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:246)
    at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:195)
    at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:258)
    at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:518)
    at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent(CompilationUnit.java:1079)
    at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:170)
    at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89)
    at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
    at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788)
    at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1244)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:126)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:87)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:151)
    at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86)
    at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:104)
    at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
    at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
Caused by: java.lang.NullPointerException
Caused by: java.lang.NullPointerException

Original issue reported on code.google.com by jorn86 on 5 Jul 2013 at 11:26

GoogleCodeExporter commented 9 years ago
Okay, I have found the cause. This happens when the argument passed to the 
extension method does not exist.
For example:
@ExtensionMethod(Iterables.class)
public class Test {
    public static void main(String[] args) {
        Collection<Object> iterable = new ArrayList<>();
        iterable.addAll(nonExisting);
    }
}

Original comment by jorn86 on 5 Jul 2013 at 11:35