Bug 51801 - Eclipse debugger fails on BCEL-instrumented methods having generic local variables.
Summary: Eclipse debugger fails on BCEL-instrumented methods having generic local vari...
Status: NEW
Alias: None
Product: BCEL - Now in Jira
Classification: Unclassified
Component: Main (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: issues@commons.apache.org
Depends on:
Reported: 2011-09-12 04:17 UTC by Byron Hawkins
Modified: 2011-09-12 06:12 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Byron Hawkins 2011-09-12 04:17:32 UTC
When any method is instrumented with BCEL to include additional constants, and the method was originally compiled with local variables that have generic arguments, the method is no longer viewable in the Eclipse debugger. For these methods, it complains "com.sun.jdi.InternalException: Got error code in reply:35 occurred retrieving 'this' from stack frame." It sounds like the local variable table is somehow not compatible with the debugger, even if the instrumentation activity did not touch the generic local variables. 

I'm currently using the 6.0-20110805.040858-2 snapshot. Please let me know if there is any workaround. Thanks!
Comment 1 Byron Hawkins 2011-09-12 06:12:00 UTC
Here is an icky workaround:

        Method method = <initialize>;
        MethodGen methodGenerator = new MethodGen(method, ...);
    	InstructionList instructions = methodGenerator.getInstructionList();

		Map<Integer, InstructionHandle> handlesByPosition = new HashMap<Integer, InstructionHandle>();
		for (InstructionHandle handle : instructions.getInstructionHandles())
			handlesByPosition.put(handle.getPosition(), handle);

		if (method.getLocalVariableTable() != null)
			for (LocalVariable local : method.getLocalVariableTable().getLocalVariableTable())
				methodGenerator.addLocalVariable(local.getName(), Type.getType(local.getSignature()), local.getIndex(),
						handlesByPosition.get(local.getStartPC()), handlesByPosition.get(local.getStartPC() + local.getLength()));