@@ -2862,7 +2862,7 @@ public RubyModule getClassFromPath(final String path, RubyClass undefinedExcepti
2862
2862
var context = getCurrentContext ();
2863
2863
2864
2864
if (path .length () == 0 || path .charAt (0 ) == '#' ) {
2865
- throw typeError (context , str (this , "can't retrieve anonymous class " , ids (this , path )));
2865
+ throw argumentError (context , str (this , "can't retrieve anonymous class " , ids (this , path )));
2866
2866
}
2867
2867
2868
2868
RubyModule clazz = getObject ();
@@ -2874,17 +2874,19 @@ public RubyModule getClassFromPath(final String path, RubyClass undefinedExcepti
2874
2874
2875
2875
if ( p < length && path .charAt (p ) == ':' ) {
2876
2876
if ( ++p < length && path .charAt (p ) != ':' ) {
2877
- throw newRaiseException ( undefinedExceptionClass , str ( this , "undefined class/module " , ids ( this , path )) );
2877
+ throw classPathUndefinedException ( path , undefinedExceptionClass , p );
2878
2878
}
2879
2879
pbeg = ++p ;
2880
2880
}
2881
2881
2882
2882
// FIXME: JI depends on const_missing getting called from Marshal.load (ruby objests do not). We should marshal JI objects differently so we do not differentiate here.
2883
2883
IRubyObject cc = flexibleSearch || isJavaPackageOrJavaClassProxyType (clazz ) ?
2884
- clazz .getConstant ( context , str ) : clazz .getConstantAt (context , str );
2884
+ clazz .constantTableFetch ( str ) : clazz .getConstantAt (context , str );
2885
2885
2886
2886
if (!flexibleSearch && cc == null ) return null ;
2887
2887
2888
+ if (cc == null ) throw classPathUndefinedException (path , undefinedExceptionClass , p );
2889
+
2888
2890
if (!(cc instanceof RubyModule mod )) {
2889
2891
throw typeError (context , str (this , ids (this , path ), " does not refer to class/module" ));
2890
2892
}
@@ -2894,6 +2896,10 @@ public RubyModule getClassFromPath(final String path, RubyClass undefinedExcepti
2894
2896
return clazz ;
2895
2897
}
2896
2898
2899
+ private RaiseException classPathUndefinedException (String path , RubyClass undefinedExceptionClass , int p ) {
2900
+ return newRaiseException (undefinedExceptionClass , str (this , "undefined class/module " , ids (this , path .substring (0 , p ))));
2901
+ }
2902
+
2897
2903
private static boolean isJavaPackageOrJavaClassProxyType (final RubyModule type ) {
2898
2904
return type instanceof JavaPackage || ClassUtils .isJavaClassProxyType (type );
2899
2905
}
0 commit comments