Bug 394234

Summary: Invalid StackMapTable generated in Java 7
Product: [Tools] AspectJ Reporter: Neil Gentleman <ngentleman>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P2 CC: aclement
Version: 1.7.1   
Target Milestone: 1.7.2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
maven project reproducing the issue
none
patch to org.aspectj.weaver.bcel.asm.StackMapAdder aclement: iplog+

Description Neil Gentleman CLA 2012-11-13 18:48:24 EST
When compiling for Java 7, AspectJ can compute an invalid StackMapTable. The verifier will throw a ClassNotFoundException when the generated class is loaded.

Example:
class Parent<T> {}
class ChildA<T> extends Parent<T> {}
class ChildB<T> extends Parent<T> {}

public Object methodWithBadStackMapTable(boolean value) {
	return value ? new ChildA<String>() : new ChildB<String>();
}

javap shows the computed StackMapTable to be:
StackMapTable: number_of_entries = 2
   frame_type = 15 /* same */
   frame_type = 71 /* same_locals_1_stack_item */
  stack = [ class "Parent<T>" ]

when it should be:
StackMapTable: number_of_entries = 2
   frame_type = 15 /* same */
   frame_type = 71 /* same_locals_1_stack_item */
  stack = [ class Parent ]
Comment 1 Neil Gentleman CLA 2012-11-13 18:49:41 EST
Created attachment 223544 [details]
maven project reproducing the issue
Comment 2 Neil Gentleman CLA 2012-11-13 18:52:51 EST
Created attachment 223545 [details]
patch to org.aspectj.weaver.bcel.asm.StackMapAdder
Comment 3 Andrew Clement CLA 2012-11-14 18:48:22 EST
thanks for the testcase and nice little fix!  Committed locally, it'll be on the public repo when I can finally get a decent connection to git.eclipse.org.
Comment 4 Andrew Clement CLA 2012-11-15 11:46:35 EST
all pushed to the public repo.