Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Don't assume every class has a ClassLoader [JRUBY-5965] #55

Merged
merged 1 commit into from

2 participants

@tobias

This also replaces the blanket catch with the proper exception classes.

This fixes http://jira.codehaus.org/browse/JRUBY-5965

@tobias tobias Don't assume every class has a ClassLoader [JRUBY-5965]
This also replaces the blanket catch with the proper exception classes.
3524733
@headius headius merged commit 19f613b into from
@headius
Owner

Also merged into jruby-1_6 in 3c6a6a2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 6, 2011
  1. @tobias

    Don't assume every class has a ClassLoader [JRUBY-5965]

    tobias authored
    This also replaces the blanket catch with the proper exception classes.
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/org/jruby/javasupport/JavaClass.java
View
15 src/org/jruby/javasupport/JavaClass.java
@@ -131,7 +131,13 @@
private void handleScalaSingletons(Class<?> javaClass, InitializerState state) {
// check for Scala companion object
try {
- Class<?> companionClass = javaClass.getClassLoader().loadClass(javaClass.getName() + "$");
+ ClassLoader cl = javaClass.getClassLoader();
+ if (cl == null) {
+ //this is a core class, bail
+ return;
+ }
+
+ Class<?> companionClass = cl.loadClass(javaClass.getName() + "$");
Field field = companionClass.getField("MODULE$");
Object singleton = field.get(null);
if (singleton != null) {
@@ -184,8 +190,11 @@ private void handleScalaSingletons(Class<?> javaClass, InitializerState state) {
}
}
}
- } catch (Exception e) {
- // ignore... there's no companion object
+
+ // ignore... there's no companion object
+ } catch (ClassNotFoundException e) {
+ } catch (NoSuchFieldException e) {
+ } catch (IllegalAccessException e) {
}
}
Something went wrong with that request. Please try again.