use of com.oracle.truffle.espresso.meta.Meta in project graal by oracle.
the class JniEnv method GetStringRegion.
/**
* <h3>void GetStringRegion(JNIEnv *env, jstring str, jsize start, jsize len, jchar *buf);</h3>
* <p>
* Copies len number of Unicode characters beginning at offset start to the given buffer buf.
* <p>
* Throws StringIndexOutOfBoundsException on index overflow.
*/
@JniImpl
@TruffleBoundary
public void GetStringRegion(@JavaType(String.class) StaticObject str, int start, int len, @Pointer TruffleObject bufPtr) {
char[] chars;
if (getJavaVersion().compactStringsEnabled()) {
chars = getMeta().toHostString(str).toCharArray();
} else {
chars = getMeta().java_lang_String_value.getObject(str).unwrap();
}
if (start < 0 || start + (long) len > chars.length) {
Meta meta = getMeta();
throw meta.throwException(meta.java_lang_StringIndexOutOfBoundsException);
}
CharBuffer buf = NativeUtils.directByteBuffer(bufPtr, len, JavaKind.Char).asCharBuffer();
buf.put(chars, start, len);
}
use of com.oracle.truffle.espresso.meta.Meta in project graal by oracle.
the class JniEnv method setPendingException.
public void setPendingException(StaticObject ex) {
Meta meta = getMeta();
assert StaticObject.notNull(ex) && meta.java_lang_Throwable.isAssignableFrom(ex.getKlass());
setPendingException(EspressoException.wrap(ex, meta));
}
use of com.oracle.truffle.espresso.meta.Meta 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.meta.Meta 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.meta.Meta 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