Local variables introduced in 1.0.46 broke debugger at least on Sun/Windows JVMs. JVM fails only when we're retrieving localVariables JVM responds with following error message:
"com.sun.jdi.InternalException: Got error code in reply: 35 occurred retrieving this from stack frame."
Where 35 is: Invalid_slot error.
Everything else works fine...
We have inspected byte-code generated by Fan and found out that Local variable table has no entry for this. However Java Compiler adds this entry in local variable table on the similar code.
Here is the patch which adds this entry to the Local variable table which fixes a problem:
diff -r 276896f3d6d7 src/sys/java/fanx/emit/FCodeEmit.java
--- a/src/sys/java/fanx/emit/FCodeEmit.java Thu Sep 24 08:46:10 2009 -0400
+++ b/src/sys/java/fanx/emit/FCodeEmit.java Fri Sep 25 19:22:30 2009 +0700
@@ -262,7 +262,15 @@
AttrEmit attr = code.emitAttr("LocalVariableTable");
Box info = attr.info;
FMethodVar[] vars = fmethod.vars;
- int offset = fmethod.isStatic() ? 0 : 1;
+
+ if(!fmethod.isStatic()){
+ FMethodVar thisVar = new FMethodVar();
+ thisVar.name = "this";
+ thisVar.type = parent.type.self;
+ vars = new FMethodVar[fmethod.vars.length + 1];
+ System.arraycopy(fmethod.vars, 0, vars, 1, fmethod.vars.length);
+ vars[0] = thisVar;
+ }
// Fan variables never reuse stack registers, so
// we can declare their scope across entire method
@@ -275,7 +283,7 @@
info.u2(code.info.len-2-2-4); // max stack, max locals, code len
info.u2(code.emit.utf(var.name));
info.u2(code.emit.utf(pod.typeRef(var.type).jsig()));
- info.u2(i+offset);
+ info.u2(i);
}
}
-- Best regards, Ivan Lobachev
andyFri 25 Sep 2009
Thanks Ivan - I'll let Brian take a look when he gets back from CA Sun.
lobachev Fri 25 Sep 2009
Hello,
Local variables introduced in 1.0.46 broke debugger at least on Sun/Windows JVMs. JVM fails only when we're retrieving localVariables JVM responds with following error message:
"com.sun.jdi.InternalException: Got error code in reply: 35 occurred retrieving
this
from stack frame."Where 35 is: Invalid_slot error.
Everything else works fine...
We have inspected byte-code generated by Fan and found out that Local variable table has no entry for
this
. However Java Compiler addsthis
entry in local variable table on the similar code.Here is the patch which adds
this
entry to the Local variable table which fixes a problem:-- Best regards, Ivan Lobachev
andy Fri 25 Sep 2009
Thanks Ivan - I'll let Brian take a look when he gets back from CA Sun.
brian Tue 29 Sep 2009
I pushed a fix to hg: changeset
I reworked your suggested patch to avoid copying the whole array. Thanks much for submitting a fix!
Let me know how that works for you.
lobachev Thu 1 Oct 2009
Thanks a lot Brian! It works fine now.