Skip to content

Commit 290e3f1

Browse files
committed
Simplify setupLoader and remove temporary field.
1 parent f7b72f0 commit 290e3f1

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

core/src/main/java/org/jruby/RubyInstanceConfig.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,15 @@ public void setProfilingService( String service ) {
14071407
}
14081408

14091409
private static ClassLoader setupLoader() {
1410-
return RubyInstanceConfig.class.getClassLoader();
1410+
ClassLoader loader = RubyInstanceConfig.class.getClassLoader();
1411+
1412+
// loader can be null for example when jruby comes from the boot-classLoader
1413+
1414+
if (loader == null) {
1415+
loader = Thread.currentThread().getContextClassLoader();
1416+
}
1417+
1418+
return loader;
14111419
}
14121420

14131421
////////////////////////////////////////////////////////////////////////////
@@ -1454,9 +1462,11 @@ private static ClassLoader setupLoader() {
14541462
private ProfileOutput profileOutput = new ProfileOutput(System.err);
14551463
private String profilingService;
14561464

1457-
private ClassLoader thisLoader = setupLoader();
1458-
// thisLoader can be null for example when jruby comes from the boot-classLoader
1459-
private ClassLoader loader = thisLoader == null ? Thread.currentThread().getContextClassLoader() : thisLoader;
1465+
private ClassLoader loader = setupLoader();
1466+
1467+
public ClassLoader getCurrentThreadClassLoader() {
1468+
return Thread.currentThread().getContextClassLoader();
1469+
}
14601470

14611471
// from CommandlineParser
14621472
private List<String> loadPaths = new ArrayList<String>();

0 commit comments

Comments
 (0)