Skip to content

Linkage errors from java_import are lazy #8299

@headius

Description

@headius

As of JRuby 9.3.0.0, linkage errors that would occur during java_import have become lazy, happening only after the import upon the first use of the class.

Using a modified version of the case from #799, the blah.Blah class can be java_imported without error, but eventually fails due to the missing blah.Foo class:

$ (chruby jruby-9.3.14.0 ; jruby -e 'java_import "blah.Blah"')
$ (chruby jruby-9.3.14.0 ; jruby -e 'java_import "blah.Blah"; Blah.new')
Unhandled Java exception: java.lang.NoClassDefFoundError: blah/Foo
java.lang.NoClassDefFoundError: blah/Foo
               <clinit> at blah/Blah.java:5

I think this was probably a simple mistake in the porting of java_import from Ruby to Java in #6661 at the following line, which defers class initialization for this path:

5a8ef9f#diff-cabfd925021b0b615287200ad6cf2469755af74bf4dfd560ea31161b22fda59eR116

We probably should fix this to eagerly initialize java_import classes so that linkage errors show up sooner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions