Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android and bytecode #339

Open
jonahbeckford opened this issue Oct 10, 2023 · 0 comments
Open

Android and bytecode #339

jonahbeckford opened this issue Oct 10, 2023 · 0 comments

Comments

@jonahbeckford
Copy link

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:

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:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant