Bug 486023 - NPE in IntelliJ since 1.8.7
Summary: NPE in IntelliJ since 1.8.7
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.8.7   Edit
Hardware: PC Windows 8
: P3 critical (vote)
Target Milestone: 1.8.9   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-18 04:52 EST by Mattias Jiderhamn CLA
Modified: 2016-01-18 19:10 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mattias Jiderhamn CLA 2016-01-18 04:52:09 EST
Seems the 1.8.7 release broke the integration with IntelliJ IDEA. During compilation, I'm getting this exception.

Using the Ant compiler works fine for the same project, but we're forced to go back to 1.8.6 in order to be using the IDE.

Caused by: java.lang.NullPointerException
	at org.aspectj.org.eclipse.jdt.internal.compiler.ast.WhileStatement.doesNotCompleteNormally(WhileStatement.java:294)
	at org.aspectj.org.eclipse.jdt.internal.compiler.ast.Block.doesNotCompleteNormally(Block.java:158)
	at org.aspectj.org.eclipse.jdt.internal.compiler.ast.LambdaExpression.analyzeShape(LambdaExpression.java:742)
	at org.aspectj.org.eclipse.jdt.internal.compiler.ast.LambdaExpression.isPotentiallyCompatibleWith(LambdaExpression.java:765)
	at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ConstraintExpressionFormula.reduce(ConstraintExpressionFormula.java:61)
	at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet.reduceOneConstraint(BoundSet.java:844)
	at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.reduce(InferenceContext18.java:857)
	at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.solve(InferenceContext18.java:808)
	at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding.computeCompatibleMethod18(ParameterizedGenericMethodBinding.java:234)
	at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding.computeCompatibleMethod(ParameterizedGenericMethodBinding.java:82)
	at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:742)
	at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:699)
	at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod0(Scope.java:1692)
	at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:1593)
	at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope.getImplicitMethod(Scope.java:2592)
	at org.aspectj.org.eclipse.jdt.internal.compiler.ast.MessageSend.findMethodBinding(MessageSend.java:947)
	at org.aspectj.org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:762)
	at org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1020)
	at org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:645)
	at org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:309)
	at org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:555)
	at org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1217)
	at org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1330)
	at org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:590)
	at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:876)
	at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.processCompiledUnits(Compiler.java:545)
	at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:458)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1036)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185)
	at com.intellij.lang.aspectj.build.AjJpsCompiler.doBuild(AjJpsCompiler.java:227)
...
Comment 1 Andrew Clement CLA 2016-01-18 19:10:13 EST
From the stack trace I can see IntelliJ seems to run things as I expected, it just delegates to one of the compiler entry points.

Bit of digging.... I found JDT bug 470232. From there I get this testcode:

import java.util.function.Consumer;

class While {
	void m() {
		t(Long.class, value -> {
			int x = 1;
			while (--x >= 0)
				;
		});
	}

	<T> void t(Class<T> clazz, Consumer<T> object) {
	}
}

which fails with the indicated NPE on 1.8.8 and 1.8.7 but not 1.8.6. So I imagine we need to pick up the JDT fix for it.

I've folded in that test case from above and confirmed the same fix from that bug addresses it, and pushed it all in for 1.8.9.  Perhaps when compiled outside of the IDE we end up exercising a slightly different code path that ensures the field that is null has been resolved in that case - e.g. we might be compiling files in a different order on the command line vs in the IDE.  Anyway, all fixed.