use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class VM method getGuestReflectiveConstructorRoot.
@JavaType(java.lang.reflect.Constructor.class)
private static StaticObject getGuestReflectiveConstructorRoot(@JavaType(java.lang.reflect.Constructor.class) StaticObject seed, Meta meta) {
assert InterpreterToVM.instanceOf(seed, meta.java_lang_reflect_Constructor);
StaticObject curConstructor = seed;
Method target = null;
while (target == null) {
target = (Method) meta.HIDDEN_CONSTRUCTOR_KEY.getHiddenObject(curConstructor);
if (target == null) {
curConstructor = meta.java_lang_reflect_Constructor_root.getObject(curConstructor);
}
}
return curConstructor;
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class VM method JVM_FindPrimitiveClass.
@VmImpl(isJni = true)
@JavaType(Class.class)
public StaticObject JVM_FindPrimitiveClass(@Pointer TruffleObject namePtr) {
Meta meta = getMeta();
String hostName = NativeUtils.interopPointerToString(namePtr);
return findPrimitiveClass(meta, hostName);
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class VM method JVM_GetClassSignature.
@VmImpl(isJni = true)
@JavaType(String.class)
public StaticObject JVM_GetClassSignature(@JavaType(Class.class) StaticObject self) {
if (self.getMirrorKlass() instanceof ObjectKlass) {
ObjectKlass klass = (ObjectKlass) self.getMirrorKlass();
SignatureAttribute signature = (SignatureAttribute) klass.getAttribute(Name.Signature);
if (signature != null) {
String sig = klass.getConstantPool().symbolAt(signature.getSignatureIndex(), "signature").toString();
return getMeta().toGuestString(sig);
}
}
return StaticObject.NULL;
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class VM method JVM_GetClassDeclaredMethods.
// TODO(tg): inject constructor calltarget.
@VmImpl(isJni = true)
@JavaType(java.lang.reflect.Method[].class)
public StaticObject JVM_GetClassDeclaredMethods(@JavaType(Class.class) StaticObject self, boolean publicOnly) {
Meta meta = getMeta();
ArrayList<Method> collectedMethods = new ArrayList<>();
Klass klass = self.getMirrorKlass();
klass.ensureLinked();
for (Method m : klass.getDeclaredMethods()) {
if ((!publicOnly || m.isPublic()) && // Filter out <init> and <clinit> from reflection.
!Name._init_.equals(m.getName()) && !Name._clinit_.equals(m.getName())) {
collectedMethods.add(m);
}
}
final Method[] methods = collectedMethods.toArray(Method.EMPTY_ARRAY);
return meta.java_lang_reflect_Method.allocateReferenceArray(methods.length, new IntFunction<StaticObject>() {
@Override
public StaticObject apply(int i) {
return methods[i].makeMirror();
}
});
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class Management method DumpThreads.
@ManagementImpl
@SuppressWarnings("unused")
@JavaType(internalName = "[Ljava/lang/management/ThreadInfo;")
public StaticObject DumpThreads(@JavaType(long[].class) StaticObject ids, boolean lockedMonitors, boolean lockedSynchronizers, @Inject SubstitutionProfiler profiler) {
StaticObject threadIds = ids;
if (StaticObject.isNull(threadIds)) {
StaticObject[] activeThreads = getContext().getActiveThreads();
threadIds = InterpreterToVM.allocatePrimitiveArray((byte) JavaKind.Long.getBasicType(), activeThreads.length, getMeta());
for (int j = 0; j < activeThreads.length; ++j) {
long tid = getThreadAccess().getThreadId(activeThreads[j]);
getInterpreterToVM().setArrayLong(tid, j, threadIds);
}
}
StaticObject result = getMeta().java_lang_management_ThreadInfo.allocateReferenceArray(threadIds.length());
if (GetThreadInfo(threadIds, 0, result, profiler) != JNI_OK) {
return StaticObject.NULL;
}
return result;
}
Aggregations