Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JRuby 1.7.0.pre1
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:jruby 1.6.1 (ruby-1.8.7-p330) (2011-05-07 4705f9e) (OpenJDK 64-Bit Server VM 1.6.0_22) [linux-amd64-java]
-
Number of attachments :
Description
When CRuby is loading a feature, $LOADED_FEATURES does not include the feature. JRuby includes it.
% echo 'p $LOADED_FEATURES' > foo.rb % ruby -I. -rfoo -e 'load "foo.rb"' ["enumerator.so", "/usr/local/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so", "/usr/local/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so"] ["enumerator.so", "/usr/local/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so", "/usr/local/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so", "/home/nahi/git/jruby/foo.rb"] % ruby187 -I. -rfoo -e 'load "foo.rb"' ["enumerator.so"] ["enumerator.so", "foo.rb"] % jruby -I. -rfoo -e 'load "foo.rb"' ["enumerator.jar", "foo.rb"] ["enumerator.jar", "foo.rb"]
Following ad-hoc patch breaks LoadService. You can't build jruby because of generate-ri-cache failure.
diff --git a/src/org/jruby/runtime/load/LoadService.java b/src/org/jruby/runtime/load/LoadService.java
index b9eb6b9..a80e809 100644
--- a/src/org/jruby/runtime/load/LoadService.java
+++ b/src/org/jruby/runtime/load/LoadService.java
@@ -746,13 +746,15 @@ public class LoadService {
synchronized (loadedFeaturesInternal) {
if (featureAlreadyLoaded(loadNameRubyString)) {
return false;
- } else {
- addLoadedFeature(loadNameRubyString);
}
}
// otherwise load the library we've found
state.library.load(runtime, false);
+
+ synchronized (loadedFeaturesInternal) {
+ addLoadedFeature(loadNameRubyString);
+ }
return true;
} catch (MainExitException mee) {
// allow MainExitException to propagate out for exec and friends
The patch doesn't preserve the intent of the synchronization on loadedFeaturesInternal (see
JRUBY-3078), but I think that was obsoleted by the fix forJRUBY-3343and can be removed.