use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class ConstantPool method verifyError.
@JavaType(VerifyError.class)
static EspressoException verifyError(String message) {
CompilerDirectives.transferToInterpreter();
Meta meta = EspressoContext.get(null).getMeta();
throw meta.throwExceptionWithMessage(meta.java_lang_VerifyError, message);
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class VM method JVM_LookupDefineClass.
@VmImpl(isJni = true)
@TruffleBoundary
@JavaType(Class.class)
public StaticObject JVM_LookupDefineClass(@JavaType(Class.class) StaticObject lookup, @Pointer TruffleObject namePtr, @Pointer TruffleObject bufPtr, int len, @JavaType(ProtectionDomain.class) StaticObject pd, boolean initialize, int flags, @JavaType(Object.class) StaticObject classData) {
if (StaticObject.isNull(lookup)) {
throw getMeta().throwExceptionWithMessage(getMeta().java_lang_InternalError, "Lookup class is null");
}
assert !getUncached().isNull(bufPtr);
assert lookup.getMirrorKlass() instanceof ObjectKlass;
boolean isNestMate = (flags & NESTMATE_CLASS) == NESTMATE_CLASS;
boolean isHidden = (flags & HIDDEN_CLASS) == HIDDEN_CLASS;
boolean isStrong = (flags & STRONG_LOADER_LINK) == STRONG_LOADER_LINK;
boolean vmAnnotations = (flags & ACCESS_VM_ANNOTATIONS) == ACCESS_VM_ANNOTATIONS;
ObjectKlass nest = null;
if (isNestMate) {
nest = (ObjectKlass) lookup.getMirrorKlass().nest();
}
if (!isHidden) {
if (!StaticObject.isNull(classData)) {
throw getMeta().throwExceptionWithMessage(getMeta().java_lang_IllegalArgumentException, "classData is only applicable for hidden classes");
}
if (isNestMate) {
throw getMeta().throwExceptionWithMessage(getMeta().java_lang_IllegalArgumentException, "dynamic nestmate is only applicable for hidden classes");
}
if (!isStrong) {
throw getMeta().throwExceptionWithMessage(getMeta().java_lang_IllegalArgumentException, "an ordinary class must be strongly referenced by its defining loader");
}
if (vmAnnotations) {
throw getMeta().throwExceptionWithMessage(getMeta().java_lang_IllegalArgumentException, "vm annotations only allowed for hidden classes");
}
if (flags != STRONG_LOADER_LINK) {
throw getMeta().throwExceptionWithMessage(getMeta().java_lang_IllegalArgumentException, String.format("invalid flag 0x%x", flags));
}
}
ByteBuffer buf = NativeUtils.directByteBuffer(bufPtr, len, JavaKind.Byte);
final byte[] bytes = new byte[len];
buf.get(bytes);
// can be null
Symbol<Type> type = namePtrToInternal(namePtr);
StaticObject loader = lookup.getMirrorKlass().getDefiningClassLoader();
ObjectKlass k;
if (isHidden) {
// Special handling
k = getRegistries().defineKlass(type, bytes, loader, new ClassRegistry.ClassDefinitionInfo(pd, nest, classData, isStrong));
} else {
k = getRegistries().defineKlass(type, bytes, loader, new ClassRegistry.ClassDefinitionInfo(pd));
}
if (initialize) {
k.safeInitialize();
} else {
k.ensureLinked();
}
return k.mirror();
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class VM method createDummyACC.
@JavaType(AccessControlContext.class)
private StaticObject createDummyACC() {
Klass pdKlass = getMeta().java_security_ProtectionDomain;
StaticObject pd = pdKlass.allocateInstance();
getMeta().java_security_ProtectionDomain_init_CodeSource_PermissionCollection.invokeDirect(pd, StaticObject.NULL, StaticObject.NULL);
StaticObject context = StaticObject.wrap(new StaticObject[] { pd }, getMeta());
return createACC(context, false, StaticObject.NULL);
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class VM method JVM_GetClassName.
@VmImpl(isJni = true)
@JavaType(String.class)
public StaticObject JVM_GetClassName(@JavaType(Class.class) StaticObject self) {
Klass klass = self.getMirrorKlass();
// Conversion from internal form.
String externalName = klass.getExternalName();
// Class names must be interned.
StaticObject guestString = getMeta().toGuestString(externalName);
return getStrings().intern(guestString);
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class VM method getGuestReflectiveFieldRoot.
@JavaType(java.lang.reflect.Field.class)
private static StaticObject getGuestReflectiveFieldRoot(@JavaType(java.lang.reflect.Field.class) StaticObject seed, Meta meta) {
assert InterpreterToVM.instanceOf(seed, meta.java_lang_reflect_Field);
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 curField;
}
Aggregations