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: | Main | Assignee: | 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. |
Here is a sample input class showing the problem: public class Foo { public String getFooName() { return Foo.class.getName(); } } Patch fixes the issue. Seems good to me. Applied, thanks alot for your help. |
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.