use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class JniEnv method CallNonvirtualObjectMethodVarargs.
// endregion Call*Method
// region CallNonvirtual*Method
@JniImpl
@JavaType(Object.class)
public StaticObject CallNonvirtualObjectMethodVarargs(@JavaType(Object.class) StaticObject receiver, @JavaType(Class.class) StaticObject clazz, @Handle(Method.class) long methodId, @Pointer TruffleObject varargsPtr) {
Method method = methodIds.getObject(methodId);
assert !method.isStatic();
assert (clazz.getMirrorKlass()) == method.getDeclaringKlass();
Object result = method.invokeDirect(receiver, popVarArgs(varargsPtr, method.getParsedSignature()));
return getMeta().asObject(result);
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class JniEnv method NewString.
@JniImpl
@TruffleBoundary
@JavaType(String.class)
public StaticObject NewString(@Pointer TruffleObject unicodePtr, int len) {
// TODO(garcia) : works only for UTF16 encoded strings.
final char[] array = new char[len];
StaticObject value = StaticObject.wrap(array, getMeta());
SetCharArrayRegion(value, 0, len, unicodePtr);
return getMeta().toGuestString(new String(array));
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class JniEnv method GetFieldID.
// Checkstyle: stop method name check
// region Get*ID
/**
* <h3>jfieldID GetFieldID(JNIEnv *env, jclass clazz, const char *name, const char *sig);</h3>
* <p>
* Returns the field ID for an instance (nonstatic) field of a class. The field is specified by
* its name and signature. The Get<type>Field and Set<type>Field families of accessor functions
* use field IDs to retrieve object fields. GetFieldID() causes an uninitialized class to be
* initialized. GetFieldID() cannot be used to obtain the length field of an array. Use
* GetArrayLength() instead.
*
* @param clazz a Java class object.
* @param namePtr the field name in a 0-terminated modified UTF-8 string.
* @param typePtr the field signature in a 0-terminated modified UTF-8 string.
* @return a field ID, or NULL if the operation fails.
* @throws NoSuchFieldError: if the specified field cannot be found.
* @throws ExceptionInInitializerError: if the class initializer fails due to an exception.
* @throws OutOfMemoryError: if the system runs out of memory.
*/
@JniImpl
@Handle(Field.class)
public long GetFieldID(@JavaType(Class.class) StaticObject clazz, @Pointer TruffleObject namePtr, @Pointer TruffleObject typePtr) {
String name = NativeUtils.interopPointerToString(namePtr);
String type = NativeUtils.interopPointerToString(typePtr);
assert name != null && type != null;
Klass klass = clazz.getMirrorKlass();
Field field = null;
Symbol<Name> fieldName = getNames().lookup(name);
if (fieldName != null) {
Symbol<Type> fieldType = getTypes().lookup(type);
if (fieldType != null) {
// Lookup only if name and type are known symbols.
klass.safeInitialize();
field = klass.lookupField(fieldName, fieldType);
assert field == null || field.getType().equals(fieldType);
}
}
if (field == null || field.isStatic()) {
Meta meta = getMeta();
throw meta.throwExceptionWithMessage(meta.java_lang_NoSuchFieldError, name);
}
assert !field.isStatic();
return fieldIds.handlify(field);
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class ConstantPool method classFormatError.
@JavaType(ClassFormatError.class)
public static EspressoException classFormatError(String message) {
CompilerDirectives.transferToInterpreter();
Meta meta = EspressoContext.get(null).getMeta();
throw meta.throwExceptionWithMessage(meta.java_lang_ClassFormatError, message);
}
use of com.oracle.truffle.espresso.substitutions.JavaType in project graal by oracle.
the class ConstantPool method noClassDefFoundError.
@JavaType(NoClassDefFoundError.class)
static EspressoException noClassDefFoundError(String message) {
CompilerDirectives.transferToInterpreter();
Meta meta = EspressoContext.get(null).getMeta();
throw meta.throwExceptionWithMessage(meta.java_lang_NoClassDefFoundError, message);
}
Aggregations