Bug 177623

Summary: [1.6][compiler] Stackmap frames generation should be protected against invalid code
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: philippe_mulet
Version: 3.3   
Target Milestone: 3.3 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix none

Description Olivier Thomann CLA 2007-03-15 14:58:31 EDT
When invalid code is getting compiled, the stack map frame generation should not fail with NPE.
java.lang.NullPointerException	at org.eclipse.jdt.internal.compiler.codegen.StackMapFrameCodeStream.getfield(StackMapFrameCodeStream.java:799)	at org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference.generateReadSequence(QualifiedNameReference.java:653)	at org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference.generateCode(QualifiedNameReference.java:386)	at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.generateCode(ReturnStatement.java:126)	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:229)	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:176)	

It should protect itself against this and the code should fail at runtime with a VerifyError since the code generation produced invalid bytecodes.
Comment 1 Olivier Thomann CLA 2007-03-15 14:59:17 EDT
Steps to reproduce:
change line 595 in QualifiedNameReference with:
if ((needValue && !lastFieldBinding.isStatic())) {

and execute GenericTypeTest#test1116 in 1.6 mode.
Comment 2 Olivier Thomann CLA 2007-03-16 11:03:05 EDT
Created attachment 61108 [details]
Proposed fix
Comment 3 Olivier Thomann CLA 2007-03-16 11:03:44 EDT
Released for 3.3M6.
Comment 4 Frederic Fusier CLA 2007-03-20 11:40:55 EDT
Verified for 3.3 M6 using I20070319-1800.