@@ -82,12 +82,13 @@ public void initialize(NativeConfiguration nativeConfiguration, TruffleNFIPlatfo
82
82
}
83
83
84
84
public void addAutoload (RubyConstant autoloadConstant ) {
85
- final String basename = basenameWithoutExtension (StringOperations .getString (autoloadConstant .getAutoloadPath ()));
85
+ final String autoloadPath = StringOperations .getString (autoloadConstant .getAutoloadPath ());
86
+ final String basename = basenameWithoutExtension (autoloadPath );
86
87
87
88
registeredAutoloadsLock .lock ();
88
89
try {
89
90
final Map <String , RubyConstant > constants = ConcurrentOperations .getOrCompute (registeredAutoloads , basename , k -> new HashMap <>());
90
- constants .put (StringOperations . getString ( autoloadConstant . getAutoloadPath ()) , autoloadConstant );
91
+ constants .put (autoloadPath , autoloadConstant );
91
92
} finally {
92
93
registeredAutoloadsLock .unlock ();
93
94
}
@@ -117,6 +118,19 @@ public RubyConstant isAutoloadPath(String expandedPath) {
117
118
return null ;
118
119
}
119
120
121
+ public void removeAutoload (RubyConstant constant ) {
122
+ final String autoloadPath = StringOperations .getString (constant .getAutoloadPath ());
123
+ final String basename = basenameWithoutExtension (autoloadPath );
124
+
125
+ registeredAutoloadsLock .lock ();
126
+ try {
127
+ final Map <String , RubyConstant > constantsMap = registeredAutoloads .get (basename );
128
+ constantsMap .remove (autoloadPath , constant );
129
+ } finally {
130
+ registeredAutoloadsLock .unlock ();
131
+ }
132
+ }
133
+
120
134
private String basenameWithoutExtension (String path ) {
121
135
final String basename = new File (path ).getName ();
122
136
int i = basename .lastIndexOf ('.' );
0 commit comments