Summary: | Anonymous inner classes generated by Eclipse 3.0M8+ cannot be decompiled by BCEL library | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Jody McDonnell <jody.mcdonnell> |
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> |
Status: | RESOLVED WORKSFORME | QA Contact: | |
Severity: | minor | ||
Priority: | P3 | ||
Version: | 3.0 | ||
Target Milestone: | 3.1 M1 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Jody McDonnell
2004-07-19 17:29:08 EDT
I will investigate. I cannot reproduce it if cheetah is not installed. If I compile with cheetah, using the -1.5 compliance, it fails with the stack trace you have. I will investigate changes between 1.5 compliance mode and 1.4 compliance mode. I think that the difference is that using 1.5 compliance mode the synthetic is now part of the field modifiers and not an attribute anymore. So this could explain why BCEL cannot disassemble it anymore. So if you stay with compliance 1.4 or 1.3, it should work. If I patch BCEL code to add synthetic as part of the field flag, then I get this: import org.apache.bcel.generic.*; import org.apache.bcel.classfile.*; import org.apache.bcel.*; import java.io.*; public class DialogOkayCancel$1Creator implements Constants { private InstructionFactory _factory; private ConstantPoolGen _cp; private ClassGen _cg; public DialogOkayCancel$1Creator() { _cg = new ClassGen("DialogOkayCancel$1", "java.awt.event.WindowAdapter", "DialogOkayCancel.java", ACC_FINAL | ACC_SUPER, new String[] { }); _cp = _cg.getConstantPool(); _factory = new InstructionFactory(_cg, _cp); } public void create(OutputStream out) throws IOException { createFields(); createMethod_0(); createMethod_1(); _cg.getJavaClass().dump(out); } private void createFields() { FieldGen field; field = new FieldGen(ACC_FINAL | ACC_SYNTHETIC, new ObjectType("DialogOkayCancel"), "this$0", _cp); _cg.addField(field.getField()); } private void createMethod_0() { InstructionList il = new InstructionList(); MethodGen method = new MethodGen(0, Type.VOID, new Type[] { new ObjectType("DialogOkayCancel") }, new String[] { "arg0" }, "<init>", "DialogOkayCancel$1", il, _cp); InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); il.append(_factory.createLoad(Type.OBJECT, 1)); il.append(_factory.createFieldAccess("DialogOkayCancel$1", "this$0", new ObjectType("DialogOkayCancel"), Constants.PUTFIELD)); InstructionHandle ih_5 = il.append(_factory.createLoad(Type.OBJECT, 0)); il.append(_factory.createInvoke("java.awt.event.WindowAdapter", "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); InstructionHandle ih_9 = il.append(_factory.createReturn(Type.VOID)); method.setMaxStack(); method.setMaxLocals(); _cg.addMethod(method.getMethod()); il.dispose(); } private void createMethod_1() { InstructionList il = new InstructionList(); MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, new Type[] { new ObjectType("java.awt.event.WindowEvent") }, new String[] { "arg0" }, "windowClosing", "DialogOkayCancel$1", il, _cp); InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); il.append(_factory.createFieldAccess("DialogOkayCancel$1", "this$0", new ObjectType("DialogOkayCancel"), Constants.GETFIELD)); il.append(_factory.createInvoke("DialogOkayCancel", "cancelClicked", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); InstructionHandle ih_7 = il.append(_factory.createReturn(Type.VOID)); method.setMaxStack(); method.setMaxLocals(); _cg.addMethod(method.getMethod()); il.dispose(); } public static void main(String[] args) throws Exception { DialogOkayCancel$1Creator creator = new DialogOkayCancel$1Creator(); creator.create(new FileOutputStream("DialogOkayCancel$1.class")); } } So this was the issue you got. Closing as WORKSFORME. |