Skip to content

Commit

Permalink
Eager initialize java_import'ed classes
Browse files Browse the repository at this point in the history
This was originally done on purpose while working toward the
possibility of lazy imports, but it's better for now to just let
the class initialize and fail fast if there are linkage errors.

Fixes jruby#8299

Resolves regression discussed in jruby#799 that prevented consistent
error messages for unlinkable classes.
  • Loading branch information
headius committed Jun 26, 2024
1 parent b328a8a commit 6cae00d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/javasupport/ext/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private static IRubyObject javaImport(ThreadContext context, RubyModule target,
if (className.contains("::")) {
throw runtime.newArgumentError("must use Java style name: " + className);
}
javaClass = Java.getJavaClass(runtime, className, false); // raises NameError if not found
javaClass = Java.getJavaClass(runtime, className); // raises NameError if not found
} else if (klass instanceof JavaPackage) {
throw runtime.newArgumentError("java_import does not work for Java packages (try include_package instead)");
} else if (klass instanceof RubyModule) {
Expand Down

0 comments on commit 6cae00d

Please sign in to comment.