mirror of
https://github.com/corda/corda.git
synced 2025-06-17 06:38:21 +00:00
only initialize class when necessary to avoid deadlock
Previously, we would attempt to initialize a class (e.g. call its static initializer) whenever a method in that class was called, as well as in any of the cases listed in http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.4. However, the above approach may lead to deadlock in an app which relies on being able to call non-static methods in parallel with a static initializer invocation in the same class. Thus, this commit ensures that we initialize classes only in the cases defined by the standard.
This commit is contained in:
@ -791,8 +791,6 @@ interpret3(Thread* t, const int base)
|
||||
goto throw_;
|
||||
}
|
||||
|
||||
initClass(t, methodClass(t, frameMethod(t, frame)));
|
||||
|
||||
loop:
|
||||
instruction = codeBody(t, code, ip++);
|
||||
|
||||
@ -1907,8 +1905,6 @@ interpret3(Thread* t, const int base)
|
||||
PROTECT(t, method);
|
||||
PROTECT(t, class_);
|
||||
|
||||
initClass(t, class_);
|
||||
|
||||
code = findVirtualMethod(t, method, class_);
|
||||
goto invoke;
|
||||
} else {
|
||||
@ -2909,7 +2905,9 @@ invoke(Thread* t, object method)
|
||||
class_ = methodClass(t, method);
|
||||
}
|
||||
|
||||
initClass(t, class_);
|
||||
if (methodFlags(t, method) & ACC_STATIC) {
|
||||
initClass(t, class_);
|
||||
}
|
||||
|
||||
object result = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user