"String index out of range" when inspecting variable
Migrated from http://lampsvn.epfl.ch/trac/scala/ticket/2990
Reporter michal
on Mac 10.6.2 (Java build 1.6.0_17-b04-248-10M3025, Scala code runner version 2.8.0.r20371-b20100106020130) following message appears when trying to inspect variable during debug process:
"String index out of range"
Reporter michal
on Mac 10.6.2 (Java build 1.6.0_17-b04-248-10M3025, Scala code runner version 2.8.0.r20371-b20100106020130) following message appears when trying to inspect variable during debug process:
"String index out of range"
Leave a comment
on 2010-01-29 03:20 *
By tracImporter
Trac author: michal
Attachment: file:index.png
Attachment: file:index.png
on 2010-01-29 03:35 *
By
Are you able to inspect via the Eclipse Variables view?
on 2010-01-29 03:44 *
By tracImporter
Trac author: michal
yes, strange but that works perfectly. also, hint appearing on variable (showing"arr: Array[Int]") is correct. The only thing that doesn't work here is "Inspect..." chosen from menu.
yes, strange but that works perfectly. also, hint appearing on variable (showing"arr: Array[Int]") is correct. The only thing that doesn't work here is "Inspect..." chosen from menu.
on 2010-01-29 04:56 *
By
OK, thanks. I'll get around to this ASAP, but it's lowish priority given that there's a workaround.
Actually, I think this is high priority as:
1) The workaround is hard to figure out (I did not find the workaround myself when I tried)
2) User will get exceptions dialogs at once on the screen if a previous session (f.x. in java) had some watches.
3) Being able to use the debugger is critical.
1) The workaround is hard to figure out (I did not find the workaround myself when I tried)
2) User will get exceptions dialogs at once on the screen if a previous session (f.x. in java) had some watches.
3) Being able to use the debugger is critical.
> The only thing that doesn't work here is "Inspect..." chosen from menu.
watches do not work too - http://comments.gmane.org/gmane.comp.lang.scala.ide.user/280
watches do not work too - http://comments.gmane.org/gmane.comp.lang.scala.ide.user/280
on 2010-11-01 06:56 *
By Matthew Farwell
The problem is org.eclipse.jdt.internal.debug.eval.ast.engine.BinaryBasedSourceGenerator method:
private boolean isAnonymousTypeName(String typeName) {
char char0 = getSimpleName(typeName).charAt(0);
return '0' <= char0 && char0 <= '9';
}
private String getSimpleName(String qualifiedName) {
int pos = qualifiedName.lastIndexOf('$');
if (pos == -1) {
pos = qualifiedName.lastIndexOf('.');
}
return ((pos == -1)? qualifiedName : qualifiedName.substring(pos + 1));
}
The name is uk.co.farwell.HelloTest$ (or similar) and getSimpleName returns an empty String. Hence the IndexOutOfBoundsException.
In fact, if you create a java class with a name uk.co.farwell.HelloJava$, you have the same problem:
package uk.co.farwell;
public class HelloJava$ {
private static int sum(int arr[]) {
return 0;
}
public static void main(String args[]) {
int arr[] = new int[] { 1,2,3,4,5};
System.out.println("Sum: " + sum(arr));
}
}
However, the problem is more visible with Scala.
private boolean isAnonymousTypeName(String typeName) {
char char0 = getSimpleName(typeName).charAt(0);
return '0' <= char0 && char0 <= '9';
}
private String getSimpleName(String qualifiedName) {
int pos = qualifiedName.lastIndexOf('$');
if (pos == -1) {
pos = qualifiedName.lastIndexOf('.');
}
return ((pos == -1)? qualifiedName : qualifiedName.substring(pos + 1));
}
The name is uk.co.farwell.HelloTest$ (or similar) and getSimpleName returns an empty String. Hence the IndexOutOfBoundsException.
In fact, if you create a java class with a name uk.co.farwell.HelloJava$, you have the same problem:
package uk.co.farwell;
public class HelloJava$ {
private static int sum(int arr[]) {
return 0;
}
public static void main(String args[]) {
int arr[] = new int[] { 1,2,3,4,5};
System.out.println("Sum: " + sum(arr));
}
}
However, the problem is more visible with Scala.
on 2010-11-02 11:28 *
By Matthew Farwell
This is possibly a duplicate of #1885.
Updating tickets (#1000069, #1000195, #1000213, #1000223, #1000006, #1000021, #1000038, #1000048, #1000051, #1000052, #1000075, #1000103, #1000109, #1000115, #1000119, #1000156, #1000186, #1000207, #1000238, #1000262, #1000263, #380, #389, #683, #1238, #1331, #1635, #1645, #1715, #1729, #1744, #1783, #1839, #1869, #1885, #1890, #1902, #1918, #1919, #1924, #1925, #1946, #1964, #1991, #2131, #2233, #2342, #2348, #2408, #2459, #2499, #2523, #2572, #2582, #2602, #2614, #2615, #2675, #2710, #2745, #2763, #2816, #2830, #2834, #2878, #2879, #2887, #2888, #2901, #2911, #2912, #2922, #2937, #2938, #2942, #2951, #2955, #2957, #2961, #2964, #2965, #2974, #2975, #2989, #2990, #3002, #3055, #3070, #3087, #3135, #3139, #3173, #3182, #3184, #3200, #3213, #3214, #3221, #3243, #3251)
on 2015-03-13 15:15 *
By Simon Schäfer
Type set to Enhancement
Version changed from 2.0.0-final-29 to 4.0.0
Milestone changed from Enhancements to -none-