@@ -2509,7 +2509,7 @@ public static SixModelObject hlllist(ThreadContext tc) {
2509
2509
public static SixModelObject hllhash (ThreadContext tc ) {
2510
2510
return tc .curFrame .codeRef .staticInfo .compUnit .hllConfig .hashType ;
2511
2511
}
2512
- public static SixModelObject findmethod (ThreadContext tc , SixModelObject invocant , String name ) {
2512
+ public static SixModelObject findmethodInCache (ThreadContext tc , SixModelObject invocant , String name ) {
2513
2513
if (invocant == null )
2514
2514
throw ExceptionHandling .dieInternal (tc , "Cannot call method '" + name + "' on a null object" );
2515
2515
invocant = decont (invocant , tc );
@@ -2521,6 +2521,13 @@ public static SixModelObject findmethod(ThreadContext tc, SixModelObject invocan
2521
2521
return meth ;
2522
2522
}
2523
2523
public static SixModelObject findmethod (SixModelObject invocant , String name , ThreadContext tc ) {
2524
+ SixModelObject method = findmethodNonFatal (invocant , name , tc );
2525
+ if (method == null )
2526
+ throw ExceptionHandling .dieInternal (tc ,
2527
+ "Method '" + name + "' not found for invocant of class '" + typeName (invocant , tc ) + "'" );
2528
+ return method ;
2529
+ }
2530
+ public static SixModelObject findmethodNonFatal (SixModelObject invocant , String name , ThreadContext tc ) {
2524
2531
if (invocant == null )
2525
2532
throw ExceptionHandling .dieInternal (tc , "Cannot call method '" + name + "' on a null object" );
2526
2533
invocant = decont (invocant , tc );
@@ -2546,12 +2553,12 @@ public static SixModelObject findmethod(SixModelObject invocant, String name, Th
2546
2553
public static String typeName (SixModelObject invocant , ThreadContext tc ) {
2547
2554
invocant = decont (invocant , tc );
2548
2555
SixModelObject how = invocant .st .HOW ;
2549
- SixModelObject nameMeth = findmethod (tc , how , "name" );
2556
+ SixModelObject nameMeth = findmethodInCache (tc , how , "name" );
2550
2557
invokeDirect (tc , nameMeth , howObjCallSite , new Object [] { how , invocant });
2551
2558
return result_s (tc .curFrame );
2552
2559
}
2553
2560
public static long can (SixModelObject invocant , String name , ThreadContext tc ) {
2554
- return findmethod (invocant , name , tc ) == null ? 0 : 1 ;
2561
+ return findmethodNonFatal (invocant , name , tc ) == null ? 0 : 1 ;
2555
2562
}
2556
2563
public static long eqaddr (SixModelObject a , SixModelObject b ) {
2557
2564
return a == b ? 1 : 0 ;
@@ -2656,7 +2663,7 @@ public static long istype_nodecont(SixModelObject obj, SixModelObject type, Thre
2656
2663
/* If we get here, need to call .^type_check on the value we're
2657
2664
* checking. */
2658
2665
if (cache == null || (typeCheckMode & STable .TYPE_CHECK_CACHE_THEN_METHOD ) != 0 ) {
2659
- SixModelObject tcMeth = findmethod (obj .st .HOW , "type_check" , tc );
2666
+ SixModelObject tcMeth = findmethodNonFatal (obj .st .HOW , "type_check" , tc );
2660
2667
if (tcMeth == null )
2661
2668
return 0 ;
2662
2669
/* TODO: Review why the following busts stuff. */
@@ -2675,7 +2682,7 @@ public static long istype_nodecont(SixModelObject obj, SixModelObject type, Thre
2675
2682
2676
2683
/* If the flag to call .accepts_type on the target value is set, do so. */
2677
2684
if ((typeCheckMode & STable .TYPE_CHECK_NEEDS_ACCEPTS ) != 0 ) {
2678
- SixModelObject atMeth = findmethod (type .st .HOW , "accepts_type" , tc );
2685
+ SixModelObject atMeth = findmethodNonFatal (type .st .HOW , "accepts_type" , tc );
2679
2686
if (atMeth == null )
2680
2687
throw ExceptionHandling .dieInternal (tc ,
2681
2688
"Expected accepts_type method, but none found in meta-object" );
0 commit comments