Skip to content

Commit c25d71e

Browse files
authored
Merge pull request jruby#9298 from headius/ensure_boot_classloader
Ensure we have a classloader to boot from
2 parents ca5b4cb + 45189cb commit c25d71e

5 files changed

Lines changed: 13 additions & 7 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@ public JavaSupport loadJavaSupport() {
15871587
}
15881588

15891589
private void loadBundler() {
1590-
loadService.loadFromClassLoader(getClassLoader(), "jruby/bundler/startup.rb", false);
1590+
loadService.loadFromClassLoader("jruby/bundler/startup.rb", false);
15911591
}
15921592

15931593
@SuppressWarnings("ReturnValueIgnored")
@@ -1781,15 +1781,15 @@ private void initJavaSupport(ThreadContext context) {
17811781

17821782
private void initRubyKernel() {
17831783
// load Ruby parts of core
1784-
loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel.rb", false);
1784+
loadService.loadFromClassLoader("jruby/kernel.rb", false);
17851785
}
17861786

17871787
private void initRubyPreludes() {
17881788
// We cannot load any .rb and debug new parser features
17891789
if (RubyInstanceConfig.DEBUG_PARSER) return;
17901790

17911791
// load Ruby parts of core
1792-
loadService.loadFromClassLoader(getClassLoader(), "jruby/preludes.rb", false);
1792+
loadService.loadFromClassLoader("jruby/preludes.rb", false);
17931793
}
17941794

17951795
public IRManager getIRManager() {
@@ -2630,7 +2630,7 @@ public RubyObjectSpecializer getObjectSpecializer() {
26302630
}
26312631

26322632
public static ClassLoader getClassLoader() {
2633-
// we try to getService the classloader that loaded JRuby, falling back on System
2633+
// we try to get the classloader that loaded JRuby, falling back on System
26342634
ClassLoader loader = Ruby.class.getClassLoader();
26352635
if (loader == null) {
26362636
loader = ClassLoader.getSystemClassLoader();

core/src/main/java/org/jruby/ext/bigdecimal/BigDecimalLibrary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ public void load(Ruby runtime, boolean wrap) throws IOException {
4343
RubyBigDecimal.createBigDecimal(context);
4444

4545
// using load since this file does not exist in MRI
46-
loadService(context).loadFromClassLoader(Ruby.class.getClassLoader(), "jruby/bigdecimal.rb", false);
46+
loadService(context).loadFromClassLoader("jruby/bigdecimal.rb", false);
4747
}
4848
}// BigDecimalLibrary

core/src/main/java/org/jruby/ext/jruby/JRubyLibrary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void load(Ruby runtime, boolean wrap) {
7777
var Object = objectClass(context);
7878

7979
// load Ruby parts of the 'jruby' library
80-
loadService(context).loadFromClassLoader(runtime.getJRubyClassLoader(), "jruby/jruby.rb", false);
80+
loadService(context).loadFromClassLoader("jruby/jruby.rb", false);
8181

8282
var JRuby = defineModule(context, "JRuby").
8383
defineMethods(context, JRubyLibrary.class).defineMethods(context, JRubyUtilLibrary.class);

core/src/main/java/org/jruby/javasupport/Java.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public void load(Ruby runtime, boolean wrap) {
139139
RubyClass objectClass = (RubyClass) getProxyClass(context, java.lang.Object.class);
140140

141141
// load Ruby parts of the 'java' library
142-
loadService(context).loadFromClassLoader(Ruby.class.getClassLoader(), "jruby/java.rb", false);
142+
loadService(context).loadFromClassLoader("jruby/java.rb", false);
143143

144144
// rewire ArrayJavaProxy superclass to point at Object, so it inherits Object behaviors
145145
Access.getClass(context, "ArrayJavaProxy").

core/src/main/java/org/jruby/runtime/load/LoadService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,15 @@ public String[] getSuffixes() {
186186
protected final Map<String, JarFile> jarFiles = new HashMap<>(0);
187187

188188
protected final Ruby runtime;
189+
protected final ClassLoader systemClassLoader;
189190
protected LibrarySearcher librarySearcher;
190191

191192
protected String mainScript;
192193
protected String mainScriptPath;
193194

194195
public LoadService(Ruby runtime) {
195196
this.runtime = runtime;
197+
this.systemClassLoader = Ruby.getClassLoader();
196198
if (RubyInstanceConfig.DEBUG_LOAD_TIMINGS) {
197199
loadTimer = new TracingLoadTimer();
198200
} else {
@@ -383,6 +385,10 @@ public void load(String file, boolean wrap) {
383385
}
384386
}
385387

388+
public void loadFromClassLoader(String file, boolean wrap) {
389+
loadFromClassLoader(systemClassLoader, file, wrap);
390+
}
391+
386392
public void loadFromClassLoader(ClassLoader classLoader, String file, boolean wrap) {
387393
long startTime = loadTimer.startLoad("classloader:" + file);
388394
int currentLine = runtime.getCurrentLine();

0 commit comments

Comments
 (0)