-
-
Notifications
You must be signed in to change notification settings - Fork 939
Closed
Milestone
Description
When there's a linkage error loading a Java class, Java reports an exception that indicates the class it could not find (usually because a required jar file was not in classpath). For java_import, we scrape this class name out of the message for our error.
Example:
ext-jruby-local ~/projects/jruby $ jar tf blah.jar
META-INF/
META-INF/MANIFEST.MF
Blah.class
ext-jruby-local ~/projects/jruby $ jar tf foo.jar
META-INF/
META-INF/MANIFEST.MF
Foo.class
ext-jruby-local ~/projects/jruby $ cat Blah.java
public class Blah {
static {
Foo.foo();
}
}
ext-jruby-local ~/projects/jruby $ cat Foo.java
public class Foo {
public static void foo() {
System.out.println("foo");
}
}
If we java_import the class by name, the error reports that it's probably the Foo class missing:
ext-jruby-local ~/projects/jruby $ jruby -e "require 'blah.jar'; java_import 'Blah'"
NameError: cannot link Java class Blah, probable missing dependency: Foo
for_name at org/jruby/javasupport/JavaClass.java:1242
get_proxy_class at org/jruby/javasupport/JavaUtilities.java:34
java_import at file:/Users/headius/projects/jruby/lib/jruby.jar!/jruby/java/core_ext/object.rb:26
map at org/jruby/RubyArray.java:2412
java_import at file:/Users/headius/projects/jruby/lib/jruby.jar!/jruby/java/core_ext/object.rb:22
(root) at -e:1
However, if we access it using the Java namespace (as a lazy constant), we do not include this information:
ext-jruby-local ~/projects/jruby $ jruby -e "require 'blah.jar'; java_import Java::Blah"
NameError: cannot link Java class Blah
get_top_level_proxy_or_package at org/jruby/javasupport/JavaUtilities.java:49
const_missing at file:/Users/headius/projects/jruby/lib/jruby.jar!/jruby/java/java_module.rb:4
(root) at -e:1
The error logic for both paths should be unified so we have consistent errors.
Reactions are currently unavailable