@@ -308,19 +308,21 @@ protected RubyInstanceConfig initRuntimeConfig(final RubyInstanceConfig config)
308
308
309
309
try { // try to set jruby home to jar file path
310
310
final URL resource = Ruby .class .getResource ("/META-INF/jruby.home" );
311
- if ( resource != null && "jar" .equals (resource .getProtocol ()) ) {
312
- String home ;
313
- try { // http://weblogs.java.net/blog/2007/04/25/how-convert-javaneturl-javaiofile
314
- home = resource .toURI ().getSchemeSpecificPart ();
315
- }
316
- catch (URISyntaxException e ) {
317
- home = resource .getPath ();
318
- }
319
- // Trim trailing slash. It confuses OSGi containers...
320
- final int last = home .length () - 1 ;
321
- if ( home .charAt (last ) == '/' ) home = home .substring (0 , last );
311
+ if ( resource != null && "jar" .equals ( resource .getProtocol () ) ) {
312
+ String home = config .getJRubyHome (); // uri: protocol only since 9k :
313
+ if ( home == null || ! home .startsWith ("uri:classloader:" ) ) {
314
+ try {
315
+ home = resource .toURI ().getSchemeSpecificPart ();
316
+ }
317
+ catch (URISyntaxException e ) {
318
+ home = resource .getPath ();
319
+ }
320
+
321
+ final int last = home .length () - 1 ; // trailing '/' confuses OSGi containers...
322
+ if ( home .charAt (last ) == '/' ) home = home .substring (0 , last );
322
323
323
- config .setJRubyHome (home );
324
+ config .setJRubyHome (home );
325
+ }
324
326
}
325
327
}
326
328
catch (Exception e ) {
@@ -564,4 +566,4 @@ private static void setupJRubyManagement() {
564
566
}
565
567
}
566
568
567
- }
569
+ }
0 commit comments