Bug 470232 - NPE at org.eclipse.jdt.internal.compiler.ast.WhileStatement.doesNotCompleteNormally
Summary: NPE at org.eclipse.jdt.internal.compiler.ast.WhileStatement.doesNotCompleteNo...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.5.1   Edit
Assignee: Sasikanth Bharadwaj CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 473232 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-06-16 02:58 EDT by Eugene Ryazanov CLA
Modified: 2015-08-20 22:36 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Ryazanov CLA 2015-06-16 02:58:25 EDT
After upgrade from 4.4.2 to 4.5.0RC3 compilation of some sources fails with

Internal compiler error: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.ast.WhileStatement.doesNotCompleteNormally(WhileStatement.java:294)

Reduced test case:

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) {
	}
}

The same code with with for (; ...;) instead of while (...) compiles normally.
Comment 1 Jay Arthanareeswaran CLA 2015-06-16 04:40:55 EDT
Reproduced in master. Looks like we are accessing the constant early during shape analysis? 

Sasi, please take a look.
Comment 2 Sasikanth Bharadwaj CLA 2015-06-16 07:05:24 EDT
The binary expression is not resolved yet and that's why we see a null at this location. Using a for instead of while works because ForStatement.doesNotCompleteNormally handles the case when constant is null while the implementation in WhileStatement doesn't. Should be a straight forward fix
Comment 3 Eclipse Genie CLA 2015-06-30 01:37:57 EDT
New Gerrit change created: https://git.eclipse.org/r/51084
Comment 4 Sasikanth Bharadwaj CLA 2015-06-30 02:52:16 EDT
Jay, please take a look at the (fairly simple) change above. Thanks
Comment 5 Jay Arthanareeswaran CLA 2015-07-01 01:59:24 EDT
Sasi, please go ahead and release this in master if you are happy with test results. We will wait for M1 before putting this in 4.5.1.
Comment 7 Sasikanth Bharadwaj CLA 2015-07-01 02:39:19 EDT
(In reply to comment #5)
> Sasi, please go ahead and release this in master if you are happy with test
> results. We will wait for M1 before putting this in 4.5.1.
done
Comment 8 Stephan Herrmann CLA 2015-07-21 14:26:53 EDT
*** Bug 473232 has been marked as a duplicate of this bug. ***
Comment 10 Jay Arthanareeswaran CLA 2015-08-04 05:01:34 EDT
Verified for 4.6 M1 with build I20150803-2000.
Comment 11 Manoj N Palat CLA 2015-08-20 22:36:16 EDT
Verified for Eclipse Mars 4.5 SR1 (4.5.1) Build id: M20150819-1000