JDT Debug IncompatibleThreadStateException when invoking invokeMethod [message #1314275] |
Fri, 25 April 2014 09:11 |
Tamas Szabo Messages: 12 Registered: June 2013 |
Junior Member |
|
|
Maybe this is not the best place to ask this question, but then you can point me to the appropriate one.
Context: I am implementing my own Variables View in Eclipse, which will be populated with my custom debug variables.
Problem: I am trying to invoke the invokeMethod on an com.sun.jdi.ObjectReference and sometimes this invocation throws an IncompatibleThreadStateException. Actually, I don't even understand why this is thrown here, because I invoke this method when the program execution is suspended. What is even more interesting is the following logic usually works at the second try.
public static Value invokeMethod(ThreadReference threadReference, ObjectReference ref, String methodName) {
Value result = null;
int t = 0;
Method method = null;
List<Method> methods = ref.referenceType().methodsByName(methodName);
for (Method m : methods) {
try {
if (m.arguments().isEmpty()) {
method = m;
break;
}
} catch (AbsentInformationException e) {
// ignore
}
}
if (method != null) {
while (result == null && t < 5) {
try {
result = ref.invokeMethod(threadReference, method, (List<? extends Value>) Collections.emptyList(), 0);
} catch (Exception e) {
result = null;
}
t++;
}
}
return result;
}
I have set this threshold to 5, so that I don't end up in an infinite loop if all goes wrong, but this method returns a non-null value 99.9% of the time.
Question: why is this happening and if once an IncompatibleThreadStateException is thrown, why does a consecutive try solve it?
|
|
|
Powered by
FUDForum. Page generated in 0.03741 seconds