Skip to content

Commit

Permalink
Simplify setupLoader and remove temporary field.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Feb 8, 2015
1 parent f7b72f0 commit 290e3f1
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions core/src/main/java/org/jruby/RubyInstanceConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,15 @@ public void setProfilingService( String service ) {
}

private static ClassLoader setupLoader() {
return RubyInstanceConfig.class.getClassLoader();
ClassLoader loader = RubyInstanceConfig.class.getClassLoader();

// loader can be null for example when jruby comes from the boot-classLoader

if (loader == null) {
loader = Thread.currentThread().getContextClassLoader();
}

return loader;
}

////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1454,9 +1462,11 @@ private static ClassLoader setupLoader() {
private ProfileOutput profileOutput = new ProfileOutput(System.err);
private String profilingService;

private ClassLoader thisLoader = setupLoader();
// thisLoader can be null for example when jruby comes from the boot-classLoader
private ClassLoader loader = thisLoader == null ? Thread.currentThread().getContextClassLoader() : thisLoader;
private ClassLoader loader = setupLoader();

public ClassLoader getCurrentThreadClassLoader() {
return Thread.currentThread().getContextClassLoader();
}

// from CommandlineParser
private List<String> loadPaths = new ArrayList<String>();
Expand Down

0 comments on commit 290e3f1

Please sign in to comment.