use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class VM method createACC.
// region privileged
@JavaType(AccessControlContext.class)
private StaticObject createACC(@JavaType(ProtectionDomain[].class) StaticObject context, boolean isPriviledged, @JavaType(AccessControlContext.class) StaticObject priviledgedContext) {
Klass accKlass = getMeta().java_security_AccessControlContext;
StaticObject acc = accKlass.allocateInstance();
getMeta().java_security_AccessControlContext_context.setObject(acc, context);
getMeta().java_security_AccessControlContext_privilegedContext.setObject(acc, priviledgedContext);
getMeta().java_security_AccessControlContext_isPrivileged.setBoolean(acc, isPriviledged);
if (getMeta().java_security_AccessControlContext_isAuthorized != null) {
getMeta().java_security_AccessControlContext_isAuthorized.setBoolean(acc, true);
}
return acc;
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class VM method JVM_GetClassSigners.
@VmImpl(isJni = true)
@JavaType(Object[].class)
public StaticObject JVM_GetClassSigners(@JavaType(Class.class) StaticObject self) {
Klass klass = self.getMirrorKlass();
if (klass.isPrimitive()) {
return StaticObject.NULL;
}
StaticObject signersArray = (StaticObject) getMeta().HIDDEN_SIGNERS.getHiddenObject(self);
if (signersArray == null || StaticObject.isNull(signersArray)) {
return StaticObject.NULL;
}
return signersArray.copy();
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class VM method JVM_GetPermittedSubclasses.
@VmImpl(isJni = true)
@TruffleBoundary
@JavaType(Class[].class)
public StaticObject JVM_GetPermittedSubclasses(@JavaType(Class.class) StaticObject self) {
Klass k = self.getMirrorKlass();
if (!(k instanceof ObjectKlass)) {
return StaticObject.NULL;
}
ObjectKlass klass = (ObjectKlass) k;
if (!klass.isSealed()) {
return StaticObject.NULL;
}
char[] classes = ((PermittedSubclassesAttribute) klass.getAttribute(PermittedSubclassesAttribute.NAME)).getClasses();
StaticObject[] permittedSubclasses = new StaticObject[classes.length];
RuntimeConstantPool pool = klass.getConstantPool();
int nClasses = 0;
for (int index : classes) {
Klass permitted;
try {
permitted = pool.resolvedKlassAt(klass, index);
} catch (EspressoException e) {
/* Suppress and continue */
continue;
}
if (permitted instanceof ObjectKlass) {
permittedSubclasses[nClasses++] = permitted.mirror();
}
}
if (nClasses == permittedSubclasses.length) {
return StaticObject.createArray(getMeta().java_lang_Class_array, permittedSubclasses);
}
return getMeta().java_lang_Class.allocateReferenceArray(nClasses, (i) -> permittedSubclasses[i]);
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class VM method JVM_GetClassConstantPool.
@VmImpl(isJni = true)
@JavaType(internalName = "Lsun/reflect/ConstantPool;")
public StaticObject JVM_GetClassConstantPool(@JavaType(Class.class) StaticObject self) {
Klass klass = self.getMirrorKlass();
if (klass.isArray() || klass.isPrimitive()) {
// No constant pool for arrays and primitives.
return StaticObject.NULL;
}
StaticObject cp = InterpreterToVM.newObject(getMeta().sun_reflect_ConstantPool, false);
getMeta().sun_reflect_ConstantPool_constantPoolOop.setObject(cp, self);
return cp;
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class VM method JVM_CurrentLoadedClass.
@VmImpl(isJni = true)
@JavaType(Class.class)
public StaticObject JVM_CurrentLoadedClass() {
PrivilegedStack stack = getPrivilegedStack();
StaticObject mirrorKlass = Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<StaticObject>() {
@Override
public StaticObject visitFrame(FrameInstance frameInstance) {
Method m = getMethodFromFrame(frameInstance);
if (m != null) {
if (isTrustedFrame(frameInstance, stack)) {
return StaticObject.NULL;
}
if (!m.isNative()) {
ObjectKlass klass = m.getDeclaringKlass();
StaticObject loader = klass.getDefiningClassLoader();
if (StaticObject.notNull(loader) && !isTrustedLoader(loader)) {
return klass.mirror();
}
}
}
return null;
}
});
return mirrorKlass == null ? StaticObject.NULL : mirrorKlass;
}
Aggregations