use of com.oracle.truffle.espresso.ref.EspressoReference in project graal by oracle.
the class Target_java_lang_ref_Reference method get.
@SuppressWarnings("rawtypes")
@Substitution(hasReceiver = true)
@JavaType(Object.class)
public static StaticObject get(@JavaType(java.lang.ref.Reference.class) StaticObject self, @Inject Meta meta) {
assert !InterpreterToVM.instanceOf(self, meta.java_lang_ref_PhantomReference) : "Cannot call Reference.get on PhantomReference";
if (//
InterpreterToVM.instanceOf(self, meta.java_lang_ref_WeakReference) || //
InterpreterToVM.instanceOf(self, meta.java_lang_ref_SoftReference) || InterpreterToVM.instanceOf(self, meta.java_lang_ref_FinalReference)) {
// Ignore guest referent field.
EspressoReference ref = (EspressoReference) meta.HIDDEN_HOST_REFERENCE.getHiddenObject(self);
if (ref == null) {
return StaticObject.NULL;
}
assert ref instanceof Reference;
StaticObject obj = ref.get();
return obj == null ? StaticObject.NULL : obj;
} else {
return meta.java_lang_ref_Reference_referent.getObject(self);
}
}
Aggregations