Search in sources :

Example 46 with Klass

use of com.oracle.truffle.espresso.impl.Klass in project graal by oracle.

the class VM method JVM_GetNestMembers.

@VmImpl(isJni = true)
@JavaType(Class[].class)
public StaticObject JVM_GetNestMembers(@JavaType(Class.class) StaticObject current) {
    Klass k = current.getMirrorKlass();
    Klass[] nestMembers = k.getNestMembers();
    StaticObject[] array = new StaticObject[nestMembers.length];
    for (int i = 0; i < nestMembers.length; i++) {
        array[i] = nestMembers[i].mirror();
    }
    return StaticObject.createArray(getMeta().java_lang_Class_array, array);
}
Also used : Klass(com.oracle.truffle.espresso.impl.Klass) ObjectKlass(com.oracle.truffle.espresso.impl.ObjectKlass) ArrayKlass(com.oracle.truffle.espresso.impl.ArrayKlass) StaticObject(com.oracle.truffle.espresso.runtime.StaticObject) NoSafepoint(com.oracle.truffle.espresso.jni.NoSafepoint) JavaType(com.oracle.truffle.espresso.substitutions.JavaType)

Example 47 with Klass

use of com.oracle.truffle.espresso.impl.Klass 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;
}
Also used : Klass(com.oracle.truffle.espresso.impl.Klass) ObjectKlass(com.oracle.truffle.espresso.impl.ObjectKlass) ArrayKlass(com.oracle.truffle.espresso.impl.ArrayKlass) StaticObject(com.oracle.truffle.espresso.runtime.StaticObject) JavaType(com.oracle.truffle.espresso.substitutions.JavaType)

Example 48 with Klass

use of com.oracle.truffle.espresso.impl.Klass 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();
}
Also used : Klass(com.oracle.truffle.espresso.impl.Klass) ObjectKlass(com.oracle.truffle.espresso.impl.ObjectKlass) ArrayKlass(com.oracle.truffle.espresso.impl.ArrayKlass) StaticObject(com.oracle.truffle.espresso.runtime.StaticObject) JavaType(com.oracle.truffle.espresso.substitutions.JavaType)

Example 49 with Klass

use of com.oracle.truffle.espresso.impl.Klass 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]);
}
Also used : Klass(com.oracle.truffle.espresso.impl.Klass) ObjectKlass(com.oracle.truffle.espresso.impl.ObjectKlass) ArrayKlass(com.oracle.truffle.espresso.impl.ArrayKlass) RuntimeConstantPool(com.oracle.truffle.espresso.classfile.RuntimeConstantPool) EspressoException(com.oracle.truffle.espresso.runtime.EspressoException) StaticObject(com.oracle.truffle.espresso.runtime.StaticObject) PermittedSubclassesAttribute(com.oracle.truffle.espresso.classfile.attributes.PermittedSubclassesAttribute) ObjectKlass(com.oracle.truffle.espresso.impl.ObjectKlass) NoSafepoint(com.oracle.truffle.espresso.jni.NoSafepoint) JavaType(com.oracle.truffle.espresso.substitutions.JavaType) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 50 with Klass

use of com.oracle.truffle.espresso.impl.Klass 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;
}
Also used : Klass(com.oracle.truffle.espresso.impl.Klass) ObjectKlass(com.oracle.truffle.espresso.impl.ObjectKlass) ArrayKlass(com.oracle.truffle.espresso.impl.ArrayKlass) StaticObject(com.oracle.truffle.espresso.runtime.StaticObject) JavaType(com.oracle.truffle.espresso.substitutions.JavaType)

Aggregations

Klass (com.oracle.truffle.espresso.impl.Klass)71 ObjectKlass (com.oracle.truffle.espresso.impl.ObjectKlass)54 ArrayKlass (com.oracle.truffle.espresso.impl.ArrayKlass)49 StaticObject (com.oracle.truffle.espresso.runtime.StaticObject)33 JavaType (com.oracle.truffle.espresso.substitutions.JavaType)24 Meta (com.oracle.truffle.espresso.meta.Meta)21 Method (com.oracle.truffle.espresso.impl.Method)19 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)10 Name (com.oracle.truffle.espresso.descriptors.Symbol.Name)10 NoSafepoint (com.oracle.truffle.espresso.jni.NoSafepoint)10 ExportMessage (com.oracle.truffle.api.library.ExportMessage)8 Field (com.oracle.truffle.espresso.impl.Field)7 ArrayList (java.util.ArrayList)7 RuntimeConstantPool (com.oracle.truffle.espresso.classfile.RuntimeConstantPool)6 EspressoException (com.oracle.truffle.espresso.runtime.EspressoException)6 InnerClassesAttribute (com.oracle.truffle.espresso.classfile.attributes.InnerClassesAttribute)5 Type (com.oracle.truffle.espresso.descriptors.Symbol.Type)5 NativeType (com.oracle.truffle.espresso.ffi.NativeType)5 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)3 EnclosingMethodAttribute (com.oracle.truffle.espresso.classfile.attributes.EnclosingMethodAttribute)3