-
Notifications
You must be signed in to change notification settings - Fork 159
Description
I spent a couple days getting an Android build working: https://gitlab.com/dkml/ext/dkml-jnr#dkml-jnr.
But I ran into a major showstopper ... JNR uses dynamic bytecode classloading:
jnr-ffi/src/main/java/jnr/ffi/provider/jffi/AsmClassLoader.java
Lines 24 to 40 in 0deaac0
| final class AsmClassLoader extends ClassLoader { | |
| private final ConcurrentMap<String, Class> definedClasses = new ConcurrentHashMap<String, Class>(); | |
| public AsmClassLoader() { | |
| } | |
| public AsmClassLoader(ClassLoader parent) { | |
| super(parent); | |
| } | |
| public Class defineClass(String name, byte[] b) { | |
| Class klass = defineClass(name, b, 0, b.length); | |
| definedClasses.putIfAbsent(name, klass); | |
| resolveClass(klass); | |
| return klass; | |
| } |
Android does not allow bytecode classloading: https://developer.android.com/training/articles/perf-jni.html#unsupported-featuresbackwards-compatibility
Even when I use System.setProperty("jnr.ffi.asm.enabled", "false"); the AsmClassLoader is still used in:
jnr-ffi/src/main/java/jnr/ffi/provider/jffi/ReflectionLibraryLoader.java
Lines 105 to 108 in 0deaac0
| private static final class LazyLoader<T> extends AbstractMap<Method, Invoker> { | |
| private final DefaultInvokerFactory invokerFactory; | |
| private final jnr.ffi.Runtime runtime = NativeRuntime.getInstance(); | |
| private final AsmClassLoader classLoader = new AsmClassLoader(); |
Anyway, I'm going to switch to JNI. If someone wants to continue the ball rolling, they can.