Bug 49615

Summary: BCELifier produces incorrect code for methods containing loads of class literals from constant pool [PATCH].
Product: BCEL - Now in Jira Reporter: Tassos Bassoukos <abassouK>
Component: MainAssignee: issues <issues>
Status: RESOLVED FIXED    
Severity: normal Keywords: PatchAvailable
Priority: P2    
Version: 5.3   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: Proposed fix, please review.

Description Tassos Bassoukos 2010-07-19 09:22:41 UTC
Created attachment 25784 [details]
Proposed fix, please review.

When a class literal is loaded from the constant pool, the BCELifier produces not compilable code. The attached patch fixes this issue with 3 modifications:
* LDC#getValue(): when a class constant is referenced, return a correct ObjectType instance.
* PUSH: new constructor that takes an ObjectType instance and does the right thing (I hope)
* BCELFactory#createConstant(): if the constant is an ObjectType, produce the correct embedding string.
Comment 1 Dave Brosius 2010-07-19 20:14:13 UTC
Here is a sample input class showing the problem:

public class Foo
{
	public String getFooName()
	{
		return Foo.class.getName();
	}
}
Comment 2 Dave Brosius 2010-07-19 20:29:45 UTC
Patch fixes the issue. Seems good to me.

Applied, thanks alot for your help.