Skip to content

Commit

Permalink
Also return null for NoClassDefFoundError. Fixes #4861.
Browse files Browse the repository at this point in the history
NCDFE can be triggered when trying to load an actual class with
the lower-cased version of its name, as we do when looking for
lower-cased class names that aren't obvious constant names.
headius committed Nov 21, 2017
1 parent fe83edd commit 8d5b2ca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/src/main/java/org/jruby/javasupport/Java.java
Original file line number Diff line number Diff line change
@@ -961,13 +961,16 @@ private static RubyModule getProxyClassOrNull(final Ruby runtime, final String c
// cannot link Java class com.sample.FooBar needs Java 8 (java.lang.UnsupportedClassVersionError: com/sample/FooBar : Unsupported major.minor version 52.0)
throw runtime.newNameError("cannot link Java class " + className + ' ' + msg, className, ex, false);
}
catch (NoClassDefFoundError | ClassNotFoundException ncdfe) {
// let caller try other names
return null;
}
catch (LinkageError ex) {
throw runtime.newNameError("cannot link Java class " + className + ' ' + '(' + ex + ')', className, ex, false);
}
catch (SecurityException ex) {
throw runtime.newSecurityError(ex.getLocalizedMessage());
}
catch (ClassNotFoundException ex) { return null; }

if ( initJavaClass ) {
return getProxyClass(runtime, JavaClass.get(runtime, clazz));

0 comments on commit 8d5b2ca

Please sign in to comment.