Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 455557

Summary: [jdt] NPE LoopingFlowContext.recordNullReference
Product: [Eclipse Project] JDT Reporter: EPP Error Reports <error-reports-inbox>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED FIXED QA Contact:
Severity: blocker    
Priority: P3 CC: ed, jarthana
Version: 4.5   
Target Milestone: 4.5 M5   
Hardware: All   
OS: All   
Whiteboard:

Description EPP Error Reports CLA 2014-12-18 02:28:35 EST
The following error was reported via the automated error reporting:

The user provided the following details for this error report:



    code:                   2
    plugin:                 org.eclipse.core.resources_3.9.100.v20141128-1217
    message:                Problems occurred when invoking code from plug-in: "org.eclipse.core.resources".
    fingerprint:            5b9eb6b7
    exception class:        java.lang.NullPointerException
    exception message:      -
    number of children:     0
    
    java.lang.NullPointerException: null
    at org.eclipse.jdt.internal.compiler.flow.LoopingFlowContext.recordNullReference(LoopingFlowContext.java:565)
    at org.eclipse.jdt.internal.compiler.flow.LoopingFlowContext.internalRecordNullityMismatch(LoopingFlowContext.java:759)
    at org.eclipse.jdt.internal.compiler.flow.FlowContext.recordNullityMismatch(FlowContext.java:1007)
    at org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching.checkAssignment(NullAnnotationMatching.java:112)
    at org.eclipse.jdt.internal.compiler.ast.ForeachStatement.analyseCode(ForeachStatement.java:115)
    at org.eclipse.jdt.internal.compiler.ast.Block.analyseCode(Block.java:43)
    at org.eclipse.jdt.internal.compiler.ast.ForeachStatement.analyseCode(ForeachStatement.java:126)
    at org.eclipse.jdt.internal.compiler.ast.Block.analyseCode(Block.java:43)
    at org.eclipse.jdt.internal.compiler.ast.IfStatement.analyseCode(IfStatement.java:105)
    at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.analyseCode(MethodDeclaration.java:126)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.internalAnalyseCode(TypeDeclaration.java:737)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.analyseCode(TypeDeclaration.java:261)
    at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.analyseCode(CompilationUnitDeclaration.java:118)
    at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:776)
    at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:137)
    at java.lang.Thread.run(Thread.java:745)
   


General Information:

    reported-by:       OCLstdlibTables.Types._Ed Willink
    anonymous-id:     4480ddfc-64ed-45bb-a550-d1669a82122a
    eclipse-build-id: 4.5.0.I20141210-2000
    eclipse-product:  org.eclipse.sdk.ide
    operating system: Windows8 6.3.0 (x86_64) - win32
    jre-version:      1.7.0_72-b14

The following plug-ins were present on the execution stack (*):
    1. org.eclipse.jdt_3.11.0.v20141210-2000

Please note that:
* Messages, stacktraces, and nested status objects may be shortened.
* Bug fields like status, resolution, and whiteboard are sent
  back to reporters.
* The list of present bundles and their respective versions was
  calculated by package naming heuristics. This may or may not reflect reality.
  
Please visit http://goo.gl/MWFSff for further details. 


Thank you for your assistance.
Your friendly error-reports-inbox.
Comment 1 EPP Error Reports CLA 2014-12-18 02:28:37 EST
I've looked up the (to date) top-3 most similar bug groups and listed the 
closest bug of each group below. This report may or may not be duplicate of
those (low or similar scores for all entries may indicate that this hasn't
been reported yet):

>     1. Bug 451237: [egit] UI freeze of 3.0s at 22:31:47.800 – 1    


If this report actually is a duplicate of those, please mark it as such. This
information helps me to improve the recommendations further for the next issue.

Thank you for your assistance.
Your friendly error-reports-inbox.
Comment 2 Ed Willink CLA 2014-12-18 06:56:34 EST
M4 Regression.

This is a blocker for me. My code just does not compile. Reverting to M3 and problems go away.
Comment 3 Jay Arthanareeswaran CLA 2014-12-18 07:01:05 EST
Ed, can you share the code that is causing this problem? Thanks!

Looks like this is happening after bug 453483 got fixed.
Comment 4 Ed Willink CLA 2014-12-18 07:19:20 EST
(In reply to Jayaprakash Arthanareeswaran from comment #3)
> Ed, can you share the code that is causing this problem? Thanks!
> 
> Looks like this is happening after bug 453483 got fixed.

I suspect you just need to do some testing for Java 7 users.

The problem code is all in the ewillink/ocl25 branch of https://git.eclipse.org/r/ocl/org.eclipse.ocl.

Probably the quickest bootstrap is:

Install http://www.eclipse.org/modeling/download.php?file=/modeling/mdt/ocl/downloads/drops/5.1.0/S201412151441/mdt-ocl-Update-5.1.0M4.zip with dependencies from staging.

Checkout the org.eclipse.ocl.jdt.annotation7, org.eclipse.ocl.library, org.eclipse.ocl.pivot, org.eclipse.ocl.pivot.internal plugins from GIT.

Only the org.eclipse.ocl.pivot successfully compiles for me.
Comment 5 Stephan Herrmann CLA 2014-12-18 08:42:21 EST
(In reply to Ed Willink from comment #4)
> (In reply to Jayaprakash Arthanareeswaran from comment #3)
> > Ed, can you share the code that is causing this problem? Thanks!
> > 
> > Looks like this is happening after bug 453483 got fixed.

correct, sorry my bad.

 
> I suspect you just need to do some testing for Java 7 users.

Your suspicion doesn't help. All our compiler tests are always run at all relevant compliance levels including 1.7.
 
> Probably the quickest bootstrap is:

I'm downloading this as we speak, and from the stack trace I already learned where the null is leaking from.
Comment 6 Stephan Herrmann CLA 2014-12-18 09:09:52 EST
(In reply to Ed Willink from comment #4)
> Probably the quickest bootstrap is:
> 
> Install
> http://www.eclipse.org/modeling/download.php?file=/modeling/mdt/ocl/
> downloads/drops/5.1.0/S201412151441/mdt-ocl-Update-5.1.0M4.zip with
> dependencies from staging.
> 
> Checkout the org.eclipse.ocl.jdt.annotation7, org.eclipse.ocl.library,
> org.eclipse.ocl.pivot, org.eclipse.ocl.pivot.internal plugins from GIT.
> 
> Only the org.eclipse.ocl.pivot successfully compiles for me.

Sorry, that doesn't look like a quick repro. After downloading 40 MB zip plus 400 MB git I just get a workspace with tens of thousands of unresolved type errors. I guess by saying "with dependencies from staging" you implied the solution to this, but I don't know what "staging" you mean and how I would locate the parts that I need (no, I'm not going to download all of simrel just to create a repro of 10 lines of code).
Perhaps ocl needs some Oomph :)
Comment 7 Ed Willink CLA 2014-12-18 09:35:22 EST
staging is the standard location for SimRel contributions http://download.eclipse.org/releases/staging.

You will indeedd have thousands of errors since nothing compoiles.

I said to check out (only) the org.eclipse.ocl.jdt.annotation7, org.eclipse.ocl.library, org.eclipse.ocl.pivot, org.eclipse.ocl.pivot.internal plugins from GIT.
Comment 8 Ed Willink CLA 2014-12-18 09:46:54 EST
(In reply to Stephan Herrmann from comment #6)
> but I don't know what "staging" you mean

Perhaps you are not aware of how good P2 is these days.

If you want to install project X, you install the download/repo for project X, then let P2 find the rest from either http://download.eclipse.org/releases/staging or http://download.eclipse.org/releases/mars. So installing the OCL downloadable is a quick way of getting EMF/MWE/Xtext/UML2 etc installed without thinking. Then you only need the GIT for the active projects.
Comment 9 Stephan Herrmann CLA 2014-12-18 10:01:21 EST
Literally "installing" all that stuff doesn't get me ahead of where you already are. You are in a far better situation to isolate the original problem into a small repro than me.

So, instead of "installing" I tried to setup for debugging by populating the workspace of a runtime workbench with all I need. A PDE target platform helps here, but that doesn't magically fetch things from a p2 repo.

Nevermind. Since your steps didn't help I created a substitute:

//---
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;

public class X {
	void test(List<String> list, boolean b) {
		if (b)
			while (true)
				for (@NonNull Object y : list) {
				}
	 
}
//---

Stacktrace is close enough to the one in comment 0:

java.lang.NullPointerException
    at org.eclipse.jdt.internal.compiler.flow.LoopingFlowContext.recordNullReference(LoopingFlowContext.java:565)
    at org.eclipse.jdt.internal.compiler.flow.LoopingFlowContext.internalRecordNullityMismatch(LoopingFlowContext.java:759)
    at org.eclipse.jdt.internal.compiler.flow.FlowContext.recordNullityMismatch(FlowContext.java:1007)
    at org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching.checkAssignment(NullAnnotationMatching.java:112)
    at org.eclipse.jdt.internal.compiler.ast.ForeachStatement.analyseCode(ForeachStatement.java:115)
    at org.eclipse.jdt.internal.compiler.ast.Block.analyseCode(Block.java:43)
    at org.eclipse.jdt.internal.compiler.ast.WhileStatement.analyseCode(WhileStatement.java:120)
    at org.eclipse.jdt.internal.compiler.ast.Block.analyseCode(Block.java:43)
    at org.eclipse.jdt.internal.compiler.ast.IfStatement.analyseCode(IfStatement.java:105)
    at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.analyseCode(MethodDeclaration.java:126)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.internalAnalyseCode(TypeDeclaration.java:737)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.analyseCode(TypeDeclaration.java:261)
    at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.analyseCode(CompilationUnitDeclaration.java:118)
    at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:776)
Comment 10 Stephan Herrmann CLA 2014-12-18 10:08:28 EST
https://git.eclipse.org/r/#/c/38492/
Comment 11 Ed Willink CLA 2014-12-18 10:16:18 EST
Thanks.

I often have to do

for (@SuppressWarnings("null")@NonNull Object y : list)

in case that is more stressful.
Comment 12 Stephan Herrmann CLA 2014-12-18 15:51:20 EST
Released for 4.5 M5 via commit 7730019127bc3900db63640d79d3086b55d5a420
Comment 13 Ed Willink CLA 2014-12-21 14:08:30 EST
Thanks. Seems to be fixed in eclipse-SDK-N20141220-150 ok.
Comment 14 Jay Arthanareeswaran CLA 2014-12-22 00:33:52 EST
As per comment #13.