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

Avoid loading classes not present on Android #2471

Closed
donv opened this issue Jan 16, 2015 · 7 comments
Closed

Avoid loading classes not present on Android #2471

donv opened this issue Jan 16, 2015 · 7 comments

Comments

@donv
Copy link
Member

donv commented Jan 16, 2015

Currently there is a har load path from org.jruby.Ruby to java.lang.invoke.MethodHandles which is not present on Android. We ned to avoid this load path when the compiler is disabled.

W/dalvikvm( 3569): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lorg/jruby/compiler/JITCompiler;
E/RUBOTO  ( 3569): Exception starting JRuby
E/RUBOTO  ( 3569): java.lang.reflect.InvocationTargetException
W/System.err( 3569): java.lang.reflect.InvocationTargetException
W/System.err( 3569):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 3569):    at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err( 3569):    at org.ruboto.JRubyAdapter.setUpJRuby(JRubyAdapter.java:261)
W/System.err( 3569):    at org.ruboto.JRubyAdapter.setUpJRuby(JRubyAdapter.java:123)
W/System.err( 3569):    at org.ruboto.test.InstrumentationTestRunner$1.run(InstrumentationTestRunner.java:49)
W/System.err( 3569):    at java.lang.Thread.run(Thread.java:841)
W/System.err( 3569): Caused by: java.lang.NoClassDefFoundError: java.lang.invoke.MethodHandles
W/System.err( 3569):    at org.jruby.compiler.JITCompiler.<clinit>(JITCompiler.java:177)
W/System.err( 3569):    at org.jruby.Ruby.<init>(Ruby.java:246)
W/System.err( 3569):    at org.jruby.Ruby.newInstance(Ruby.java:327)
W/System.err( 3569):    ... 6 more
@donv donv added this to the JRuby 9.0.0.0-pre1 milestone Jan 16, 2015
@donv
Copy link
Member Author

donv commented Jan 16, 2015

Tried adding jsr292-mock-1.1.jar to satisfy class loading, but it barfs on building the apk:

    [apply] trouble processing "java/lang/ClassValue.class":
    [apply] 
    [apply] Ill-advised or mistaken usage of a core class (java.* or javax.*)
    [apply] when not building a core library.

i will look at using the --core-libray option.

@donv
Copy link
Member Author

donv commented Jan 16, 2015

When running with --core-libray and the jsr292-mock-1.1.jar, the app builds, but fails during runtime:

W/System.err( 4250): Caused by: java.lang.UnsupportedOperationException
W/System.err( 4250):    at java.lang.invoke.MethodHandles.publicLookup(MethodHandles.java)
W/System.err( 4250):    at org.jruby.compiler.JITCompiler.<clinit>(JITCompiler.java:177)
W/System.err( 4250):    ... 8 more

@donv
Copy link
Member Author

donv commented Jan 16, 2015

@enebo We should avoid loading the JITCompiler class and the jsr292 classes when the compiler is disabled. Any idea how best to do that?

@enebo
Copy link
Member

enebo commented Jan 18, 2015

in Ruby.init the instance is created. You can just check RubyInstanceConfig for compiler mode and if it is OFF then don't construct JITCompiler.

@enebo
Copy link
Member

enebo commented Jan 18, 2015

If someone wants to add the code to make JIT conditional they can but we will not hold up pre1 for this since I am guessing there has been no 9k evaluation recently based on the inability to work around the JIT classs. Moving forward and next 9k release (pre2,rc1,...) will hopefully be working well enough.

@donv donv added the Ruboto label May 16, 2015
@donv
Copy link
Member Author

donv commented May 16, 2015

OK, time has passed. @enebo @headius Any tips on how to do this? Add some interface and load implementation by reflection?

@headius
Copy link
Member

headius commented Jul 8, 2020

This is no longer relevant since Android now supports invokedynamic and method handles.

@headius headius closed this as completed Jul 8, 2020
@headius headius added this to the Invalid or Duplicate milestone Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants