@@ -2862,7 +2862,7 @@ public RubyModule getClassFromPath(final String path, RubyClass undefinedExcepti
28622862 var context = getCurrentContext ();
28632863
28642864 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 )));
28662866 }
28672867
28682868 RubyModule clazz = getObject ();
@@ -2874,17 +2874,19 @@ public RubyModule getClassFromPath(final String path, RubyClass undefinedExcepti
28742874
28752875 if ( p < length && path .charAt (p ) == ':' ) {
28762876 if ( ++p < length && path .charAt (p ) != ':' ) {
2877- throw newRaiseException ( undefinedExceptionClass , str ( this , "undefined class/module " , ids ( this , path )) );
2877+ throw classPathUndefinedException ( path , undefinedExceptionClass , p );
28782878 }
28792879 pbeg = ++p ;
28802880 }
28812881
28822882 // 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.
28832883 IRubyObject cc = flexibleSearch || isJavaPackageOrJavaClassProxyType (clazz ) ?
2884- clazz .getConstant ( context , str ) : clazz .getConstantAt (context , str );
2884+ clazz .constantTableFetch ( str ) : clazz .getConstantAt (context , str );
28852885
28862886 if (!flexibleSearch && cc == null ) return null ;
28872887
2888+ if (cc == null ) throw classPathUndefinedException (path , undefinedExceptionClass , p );
2889+
28882890 if (!(cc instanceof RubyModule mod )) {
28892891 throw typeError (context , str (this , ids (this , path ), " does not refer to class/module" ));
28902892 }
@@ -2894,6 +2896,10 @@ public RubyModule getClassFromPath(final String path, RubyClass undefinedExcepti
28942896 return clazz ;
28952897 }
28962898
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+
28972903 private static boolean isJavaPackageOrJavaClassProxyType (final RubyModule type ) {
28982904 return type instanceof JavaPackage || ClassUtils .isJavaClassProxyType (type );
28992905 }
0 commit comments