As the default behavior of OpenJava compiler, there is no assurance of
callee-side translation ordering. In the case that we make it sure to
translate a class SubMyObject after a class MyObject, we
can use the method waitTranslation()
in
java.lang.OJClass.
At the invocation of this method, the translation on the current class declaration stops and it return to continue after the translation on the class given as the argument finished.public void waitTranslation(OJClass) throws MOPException
Furthermore, the part where that class is used comes. There are several part related to the use of class. i.e. object allocations, method calls, field accesses, .. We call this kind of translation caller-side translation.
For the convenience of explanation, suppose a base class
MyObject extended by a metaclass MyClass, like
following:
public class SubMyObject instantiates SyncClass extends MyObject {} class MyObject instantiates AnotherClass {} class SubSubMyObject instantiates SyncClass extends SubMyObject {}
We can see the following messages in running OpenJava compiler.public class SyncClass instantiates Metaclass extends OJClass { void translateDefinition() throws MOPException { OJClass baseclazz = getSuperclass(); System.out.println( getName() + " is waiting for " + base.getName() ); waitTranslation( baseclazz ); System.out.println( getName() + " finished" ); } }
MyObject is waiting for java.lang.Object MyObject finished SubSubMyObject is waiting for SubMyObject SubMyObject is waiting for MyObject SubMyObject finished SubSubMyObject finished
In the case of the system detects some deadlocks,
waitTranslation()
throws an exception
MOPException
. If already the translation of
a class A were waiting for the translation of a class B,
the invocation of waitTranslation()
on the translation
of the class B would not block but throw an exception.