[all packages]
[package BR.unicamp.Guarana]
[class hierarchy]
[index]
java.lang.Object | +----BR.unicamp.Guarana.Guarana
public final class Guarana
This protection could have been implemented by associating suitable MetaObjects to those classes, so that no such security holes can be opened. However, this would have serious performance impact. Since we couldn't find any good reason to make any of these classes or objects reflexive, we decided not to pay that additional cost. If we ever find a good reason to make any of these classes reflexive, we may change this constraint.
public static Result perform(Operation operation) throws MetaException;
Just before delivering the Operation to the target Object, we check whether the primary MetaObject is no longer the one that was originally asked to handle it. If there was any change, Result.throwObject(null) is presented to the MetaObject that was originally asked to handle the Operation, and the handling is restarted with the new MetaObject.
If the MetaObject is unchanged, the operation will be validated and delivered. If the validate method throws, the thrown Object will be considered the Result of the Operation.
This Result will be presented to the Object's MetaObject, if it asked so.
public static void broadcast(Message message, Object object);
public static void reconfigure(Object object, MetaObject oldMetaObject, MetaObject newMetaObject);
This Operation is a do-nothing if the given Object is either the class Guarana, the class Operation, the class Result, or any instace thereof, since these are non-reflexive classes.
This method ensures that any top-level reconfiguration is atomic, by synchronizing either on the current primary MetaObject associated with the Object or on the object's class, and checking whether the MetaObject associated with the Object hasn't changed. If it has, the operation is restarted.
As soon as it makes sure there's no other thread reconfiguring the given Object, it sends the reconfigure request to the current MetaObject. If the current MetaObject was null, but the oldMetaObject was not, the request is ignored, but if the oldMetaObject was null too, an InstanceReconfigure Message is created and broadcasted to the meta-configuration of the Object's class, then to its superclass, and so on. After the InstanceReconfigure Message is broadcasted to the meta-configuration of class java.lang.Object, the MetaObject stored in the InstanceReconfigure Message is used as the new primary MetaObject.
Finally, if the returned MetaObject is different from the current MetaObject, and the current MetaObject is still the primary MetaObject, the returned MetaObject is initialized and associated with the Object, and then the previous primary MetaObject is told to release the Object.
If, at any point after the execution of method reconfigure and before the execution of method release, the primary MetaObject is found to have changed (which means that the execution of either reconfigure or initialize caused the MetaObject to change), the reconfiguration is considered terminated.
There's no standard way to check whether the reconfiguration succeeded, since the new MetaObject may have been accepted but guarded under a Composer controlled by the existing MetaObject, or it may have been rejected at all, or it may have been reconfigured before being accepted, so that the previous meta-configuration remains. The only way to check whether the MetaObject was actually accepted is to Broadcast a Message after the Reconfiguration finishes.
public static native Object makeProxy(Class cls, MetaObject metaObject) throws MetaException;
A MetaObject associated with a proxy Object should not allow messages to be delivered to an uninitialized proxy Object. In fact, this applied to any Object before it is constructed, but proxy Object are seldom constructed at all. If they are, or if their fields are all properly initialized, they may be considered actual Objects.
The following pseudo-code depicts the behavior of this method. The static pseudo-method <alloc> is assumed to allocate an uninitialized Object, or an array of length 0, if the given Class is an array type. For arrays of non-zero lengths, method newInstance of class java.lang.reflect.Array must be used.
if (cls.isPrimitive() || cls == Guarana.class || cls == Operation.class || cls == Result.class) throw new IllegalArgumentException ("cannot create proxy of non-reflexive class"); Object object = <alloc>(cls); broadcast(new NewProxy(object), cls); if (metaObject != null) reconfigure(object, null, metaObject); return object;
public static native int hashCode(Object object);
public static native Class getClass(Object object);
public static native String getClassName(Class clazz);
public static String toString(Object object);
[all packages]
[package BR.unicamp.Guarana]
[class hierarchy]
[index]