Bug 394234 - Invalid StackMapTable generated in Java 7
Summary: Invalid StackMapTable generated in Java 7
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.7.1   Edit
Hardware: PC Linux
: P2 critical (vote)
Target Milestone: 1.7.2   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-13 18:48 EST by Neil Gentleman CLA
Modified: 2012-11-15 11:46 EST (History)
1 user (show)

See Also:


Attachments
maven project reproducing the issue (1.56 KB, application/x-gzip)
2012-11-13 18:49 EST, Neil Gentleman CLA
no flags Details
patch to org.aspectj.weaver.bcel.asm.StackMapAdder (948 bytes, patch)
2012-11-13 18:52 EST, Neil Gentleman CLA
aclement: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.