use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class ExceptionDispatch method slowPath.
private StaticObject slowPath(ObjectKlass klass, StaticObject message, StaticObject cause) {
assert meta.java_lang_Throwable.isAssignableFrom(klass);
StaticObject ex;
if (CompilerDirectives.isPartialEvaluationConstant(klass)) {
// if klass was a compilation constant, the constantness of the klass field in ex should
// propagate even through the boundary.
ex = klass.allocateInstance();
} else {
ex = allocate(klass);
}
slowInitEx(ex, klass, message, cause);
return ex;
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class ClassRegistries method getAllModuleRefs.
public ModuleRef[] getAllModuleRefs() {
ArrayList<ModuleRef> list = new ArrayList<>();
// add modules from boot registry
list.addAll(bootClassRegistry.modules().values());
// add modules from all other registries
synchronized (weakClassLoaderSet) {
for (StaticObject classLoader : weakClassLoaderSet) {
list.addAll(getClassRegistry(classLoader).modules().values());
}
}
return list.toArray(ModuleRef.EMPTY_ARRAY);
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class Field method getReflectiveFieldRoot.
public static Field getReflectiveFieldRoot(StaticObject seed, Meta meta) {
StaticObject curField = seed;
Field target = null;
while (target == null) {
target = (Field) meta.HIDDEN_FIELD_KEY.getHiddenObject(curField);
if (target == null) {
curField = meta.java_lang_reflect_Field_root.getObject(curField);
}
}
return target;
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class Klass method readMember.
@ExportMessage
Object readMember(String member, @Shared("lookupField") @Cached LookupFieldNode lookupFieldNode, @Shared("error") @Cached BranchProfile error) throws UnknownIdentifierException {
Field field = lookupFieldNode.execute(this, member, true);
if (field != null) {
Object result = field.get(this.tryInitializeAndGetStatics());
if (result instanceof StaticObject && ((StaticObject) result).isForeignObject()) {
return ((StaticObject) result).rawForeignObject();
}
return result;
}
// Klass<T>.class == Class<T>
if (STATIC_TO_CLASS.equals(member)) {
return mirror();
}
// Klass<T>.static == Klass<T>
if (CLASS_TO_STATIC.equals(member)) {
return this;
}
if (getMeta()._void != this && ARRAY.equals(member)) {
return array();
}
if (isArray() && COMPONENT.equals(member)) {
return ((ArrayKlass) this).getComponentType();
}
if (getSuperKlass() != null && SUPER.equals(member)) {
return getSuperKlass();
}
error.enter();
throw UnknownIdentifierException.create(member);
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class MethodTypeConstant method signatureToMethodType.
static StaticObject signatureToMethodType(Symbol<Symbol.Type>[] signature, Klass accessingKlass, boolean failWithBME, Meta meta) {
Symbol<Symbol.Type> rt = Signatures.returnType(signature);
int pcount = Signatures.parameterCount(signature, false);
StaticObject[] ptypes = new StaticObject[pcount];
StaticObject rtype;
try {
for (int i = 0; i < pcount; i++) {
Symbol<Symbol.Type> paramType = Signatures.parameterType(signature, i);
ptypes[i] = meta.resolveSymbolAndAccessCheck(paramType, accessingKlass).mirror();
}
} catch (EspressoException e) {
if (meta.java_lang_ClassNotFoundException.isAssignableFrom(e.getGuestException().getKlass())) {
throw meta.throwExceptionWithMessage(meta.java_lang_NoClassDefFoundError, e.getGuestMessage());
}
throw e;
}
try {
rtype = meta.resolveSymbolAndAccessCheck(rt, accessingKlass).mirror();
} catch (EspressoException e) {
EspressoException rethrow = e;
if (meta.java_lang_ClassNotFoundException.isAssignableFrom(e.getGuestException().getKlass())) {
rethrow = EspressoException.wrap(Meta.initExceptionWithMessage(meta.java_lang_NoClassDefFoundError, e.getGuestMessage()), meta);
}
if (failWithBME) {
rethrow = EspressoException.wrap(Meta.initExceptionWithCause(meta.java_lang_BootstrapMethodError, rethrow.getGuestException()), meta);
}
throw rethrow;
}
return (StaticObject) meta.java_lang_invoke_MethodHandleNatives_findMethodHandleType.invokeDirect(null, rtype, StaticObject.createArray(meta.java_lang_Class_array, ptypes));
}
Aggregations