Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » JDT Debug IncompatibleThreadStateException when invoking invokeMethod
JDT Debug IncompatibleThreadStateException when invoking invokeMethod [message #1314275] Fri, 25 April 2014 05:11
Eclipse UserFriend
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?
Previous Topic:debug java search (call hierarchy) bug
Next Topic:How to run eclipse Code CleanUp from commandline
Goto Forum:
  


Current Time: Fri Jul 04 14:33:02 EDT 2025

Powered by FUDForum. Page generated in 0.25932 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top