@CEntryPoint @CEntryPointOptions(prologue = EnterNativeTruffleContextPrologue.class, epilogue = LeaveDetachThreadEpilogue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static void detachCurrentThread(@SuppressWarnings("unused") NativeTruffleContext context) { }
@SuppressWarnings("deprecation") private static CEntryPointData create(CEntryPoint annotation, CEntryPointOptions options, Supplier<String> alternativeNameSupplier) { String annotatedName = annotation.name(); Class<? extends Function<String, String>> nameTransformation = DEFAULT_NAME_TRANSFORMATION; String documentation = String.join(System.lineSeparator(), annotation.documentation()); CEntryPoint.Builtin builtin = annotation.builtin(); Class<?> prologue = DEFAULT_PROLOGUE; Class<?> epilogue = DEFAULT_EPILOGUE; Class<?> exceptionHandler = annotation.exceptionHandler(); Publish publishAs = Publish.SymbolAndHeader; if (options != null) { nameTransformation = options.nameTransformation(); prologue = options.prologue(); epilogue = options.epilogue(); publishAs = options.publishAs(); } return create(annotatedName, alternativeNameSupplier, nameTransformation, documentation, builtin, prologue, epilogue, exceptionHandler, publishAs); }
private void registerEntryPoints(Map<Method, CEntryPointData> entryPoints) { for (Method m : loader.findAnnotatedMethods(CEntryPoint.class)) { if (!Modifier.isStatic(m.getModifiers())) { throw UserError.abort("entry point method " + m.getDeclaringClass().getName() + "." + m.getName() + " is not static. Add a static modifier to the method."); } boolean include = true; CEntryPointOptions options = m.getAnnotation(CEntryPointOptions.class); if (options != null) { BooleanSupplier instance; try { Constructor<? extends BooleanSupplier> constructor = options.include().getDeclaredConstructor(); constructor.setAccessible(true); instance = constructor.newInstance(); } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw VMError.shouldNotReachHere(ex); } include = instance.getAsBoolean(); } if (include) { entryPoints.put(m, CEntryPointData.create(m)); } } }
@CEntryPoint(exceptionHandler = JNIExceptionHandlerReturnMinusOne.class) @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static int GetStringLength(JNIEnvironment env, JNIObjectHandle hstr) { String str = JNIObjectHandles.getObject(hstr); return (str != null) ? str.length() : 0; }
@CEntryPoint @CEntryPointOptions(prologue = EnterNativeTruffleEnvPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static NativeTruffleContext getTruffleContext(NativeTruffleEnv env) { return env.context(); }
@CEntryPoint(exceptionHandler = JNIExceptionHandlerReturnNullWord.class) @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static CShortPointer GetStringChars(JNIEnvironment env, JNIObjectHandle hstr, CCharPointer isCopy) { return Support.pinStringAndGetChars(hstr, isCopy); }
@CEntryPoint @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static int GetVersion(JNIEnvironment env) { return JNIVersion.JNI_VERSION_1_8(); }
@CEntryPoint @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static JNIObjectRefType GetObjectRefType(JNIEnvironment env, JNIObjectHandle handle) { try { return JNIObjectHandles.getHandleType(handle); } catch (Throwable t) { return JNIObjectRefType.Invalid; } }
@CEntryPoint(exceptionHandler = JNIExceptionHandlerReturnNullWord.class) @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static JNIFieldId GetStaticFieldID(JNIEnvironment env, JNIObjectHandle hclazz, CCharPointer cname, CCharPointer csig) { return Support.getFieldID(hclazz, cname, csig, true); }
@CEntryPoint(exceptionHandler = JNIExceptionHandlerVoid.class) @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static void ReleaseStringUTFChars(JNIEnvironment env, JNIObjectHandle hstr, CCharPointer chars) { JNIThreadLocalPinnedObjects.unpinArrayByAddress(chars); }
@CEntryPoint @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static boolean ExceptionCheck(JNIEnvironment env) { return JNIThreadLocalPendingException.get() != null; }
@CEntryPoint(exceptionHandler = JNIExceptionHandlerVoid.class) @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static void ExceptionClear(JNIEnvironment env) { JNIThreadLocalPendingException.clear(); }
@CEntryPoint(exceptionHandler = JNIExceptionHandlerVoid.class) @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static void Throw(JNIEnvironment env, JNIObjectHandle handle) throws Throwable { throw (Throwable) JNIObjectHandles.getObject(handle); }
@CEntryPoint(exceptionHandler = JNIExceptionHandlerReturnNullWord.class) @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static JNIFieldId GetFieldID(JNIEnvironment env, JNIObjectHandle hclazz, CCharPointer cname, CCharPointer csig) { return Support.getFieldID(hclazz, cname, csig, false); }
@CEntryPoint(exceptionHandler = JNIExceptionHandlerReturnNullWord.class) @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static CShortPointer GetStringCritical(JNIEnvironment env, JNIObjectHandle hstr, CCharPointer isCopy) { return Support.pinStringAndGetChars(hstr, isCopy); }
/** * Stub for unimplemented JNI functionality with a JavaVM argument. */ @CEntryPoint @CEntryPointOptions(prologue = JNIJavaVMEnterAttachThreadPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static void unimplemented(JNIJavaVM vm) { VMError.shouldNotReachHere("An unimplemented JNI function was called. Please refer to the stack trace."); } }
@CEntryPoint @CEntryPointOptions(prologue = JNIJavaVMEnterAttachThreadPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static int AttachCurrentThreadAsDaemon(JNIJavaVM vm, JNIEnvironmentPointer penv, JNIJavaVMAttachArgs args) { return Support.attachCurrentThread(vm, penv, args, true); }
@CEntryPoint(exceptionHandler = JNIExceptionHandlerReturnNullWord.class) @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static JNIMethodId GetMethodID(JNIEnvironment env, JNIObjectHandle hclazz, CCharPointer cname, CCharPointer csig) { return Support.getMethodID(hclazz, cname, csig, false); }
@CEntryPoint(exceptionHandler = JNIExceptionHandlerVoid.class) @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static void ReleaseStringChars(JNIEnvironment env, JNIObjectHandle hstr, CShortPointer chars) { Support.unpinString(chars); }
@CEntryPoint(exceptionHandler = JNIExceptionHandlerVoid.class) @CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static void ReleaseStringCritical(JNIEnvironment env, JNIObjectHandle hstr, CShortPointer carray) { Support.unpinString(carray); }