Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354052 - [1.7] NPE in org.eclipse.jdt.internal.compiler.ClassFile.traverse(ClassFile.java:4507)
Summary: [1.7] NPE in org.eclipse.jdt.internal.compiler.ClassFile.traverse(ClassFile.j...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 critical (vote)
Target Milestone: 3.7.1   Edit
Assignee: Satyam Kandula CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-05 15:44 EDT by Volker Berlin CLA
Modified: 2011-09-14 11:04 EDT (History)
3 users (show)

See Also:
srikanth_sankaran: review+
Olivier_Thomann: review+


Attachments
Eclipse log file (37.99 KB, application/octet-stream)
2011-08-05 15:45 EDT, Volker Berlin CLA
no flags Details
Proposed patch (2.31 KB, patch)
2011-08-09 00:19 EDT, Satyam Kandula CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Berlin CLA 2011-08-05 15:44:23 EDT
Build Identifier: M20110804-0800

After switching from the BETA_JAVA7 to the release version Java 7 does not compile anymore. In the log there are the follow exceptions. More details are in the log file.

Java Model Exception: java.lang.NullPointerException
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:246)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:268)
	at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:190)
	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.initialReconcile(JavaReconcilingStrategy.java:178)
	at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.initialReconcile(CompositeReconcilingStrategy.java:114)
	at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.initialReconcile(JavaCompositeReconcilingStrategy.java:136)
	at org.eclipse.jface.text.reconciler.MonoReconciler.initialProcess(MonoReconciler.java:105)
	at org.eclipse.jdt.internal.ui.text.JavaReconciler.initialProcess(JavaReconciler.java:406)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:173)
Caused by: java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.ClassFile.traverse(ClassFile.java:4507)
	at org.eclipse.jdt.internal.compiler.ClassFile.generateStackMapTableAttribute(ClassFile.java:3363)
	at org.eclipse.jdt.internal.compiler.ClassFile.completeCodeAttribute(ClassFile.java:1187)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:257)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:182)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:543)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:612)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:360)
	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:919)
	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:958)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:202)
	... 17 more


Reproducible: Always

Steps to Reproduce:
1. Starting Eclipse
2. Trigger compiling
Comment 1 Volker Berlin CLA 2011-08-05 15:45:45 EDT
Created attachment 201019 [details]
Eclipse log file

Log file from the compiler error
Comment 2 Srikanth Sankaran CLA 2011-08-08 01:48:44 EDT
Satyam, please take a look.
Comment 3 Satyam Kandula CLA 2011-08-08 08:50:28 EDT
Smaller testcase to reproduce the problem.
#########
public class X {
	 public static void foo() {
		 X z;
		 while ((z = getObject()) != null) {
			 z.bar();
		 }
	 }
	 public void bar() {}
	 public static X getObject() {
		 return null;
	 }
}
##########
Comment 4 Srikanth Sankaran CLA 2011-08-08 09:10:38 EDT
(In reply to comment #3)
> Smaller testcase to reproduce the problem.

Have you been able to check if this is due to recent regression ? 
How far back does the current behavior date ?
Comment 5 Srikanth Sankaran CLA 2011-08-08 09:16:37 EDT
(In reply to comment #4)
> (In reply to comment #3)
> > Smaller testcase to reproduce the problem.
> 
> Have you been able to check if this is due to recent regression ? 
> How far back does the current behavior date ?

Checked it myself, is fine on 3.7, so this is a regression that has
come in due to the merge from the BETA_JAVA7 branch.
Comment 6 Srikanth Sankaran CLA 2011-08-08 09:19:48 EDT
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > Smaller testcase to reproduce the problem.
> > 
> > Have you been able to check if this is due to recent regression ? 
> > How far back does the current behavior date ?
> 
> Checked it myself, is fine on 3.7, so this is a regression that has
> come in due to the merge from the BETA_JAVA7 branch.

Regression caused by the fix for bug 352145 ?
Comment 7 Satyam Kandula CLA 2011-08-08 09:32:52 EDT
(In reply to comment #6)
> Regression caused by the fix for bug 352145 ?
Yes, that's I right and I should have mentioned :(
Comment 8 Satyam Kandula CLA 2011-08-09 00:19:43 EDT
Created attachment 201116 [details]
Proposed patch

Added the necessary null in the patch.
Comment 9 Satyam Kandula CLA 2011-08-09 00:21:00 EDT
(In reply to comment #8)
> Created attachment 201116 [details]
> Proposed patch
> 
> Added the necessary null in the patch.
This patch is on top of HEAD. Srikanth, Please review.
Comment 10 Srikanth Sankaran CLA 2011-08-09 00:32:22 EDT
Patch looks good. Could you please mention the bug URL in a // comment
and release it. I'll mark Olivier for additional review, but we can
release it already.
Comment 11 Satyam Kandula CLA 2011-08-09 00:41:27 EDT
Released in HEAD and 3.7.1 Maintenance branch
Comment 12 Olivier Thomann CLA 2011-08-15 12:26:49 EDT
The null check is indeed required in case of backwards branching (aload0 is reached before astore0 when iterating over the bytecodes in a linear way).
Comment 13 Jay Arthanareeswaran CLA 2011-08-25 07:46:07 EDT
Verified for 3.7.1 RC2 with build M20110824-0800.
Comment 14 Olivier Thomann CLA 2011-09-14 11:04:51 EDT
Verified for 3.8M2.