system/src/sc/lang/java/ModelUtil.java
public static Object callMethod(Object thisObj, Object method, Object...argValues) {
      if (method instanceof Method) {
         Method jMethod = (Method) method;
         return PTypeUtil.invokeMethod(thisObj, jMethod, argValues);
      }
      else if (method instanceof AbstractMethodDefinition) {
         AbstractMethodDefinition methDef = (AbstractMethodDefinition) method;
         argValues = convertVarargValues(method, argValues);
         if (methDef.isDynMethod())
            return ((AbstractMethodDefinition) method).callVirtual(thisObj, argValues);
         Object invMeth = methDef.getRuntimeMethod();
         return ModelUtil.invokeMethod(thisObj, invMeth, argValues, new ExecutionContext(methDef.getLayeredSystem()));
      }
      else if (method instanceof CFMethod) {
         Method rtMeth = ((CFMethod) method).getRuntimeMethod();

         if (rtMeth == null)
            throw new IllegalArgumentException("Can't invoke method: " + method + " No runtime class found");

         return ModelUtil.callMethod(thisObj, rtMeth, argValues);
      }
      else if (method instanceof ParamTypedMethod) {
         return callMethod(thisObj, ((ParamTypedMethod) method).method, argValues);
      }
      else if (method instanceof String) {
         Object methodObj = ModelUtil.getMethod(thisObj, (String) method);
         if (methodObj == null) {
            throw new IllegalArgumentException("No method: " + method + " on: " + thisObj);
         }
         return callMethod(thisObj, methodObj, argValues);
      }
      else
         throw new UnsupportedOperationException();
   }
// Warning: this version will not check for a dynamic method - use invokeMethod below instead unless you know the MethodDefinition is dynamic
this version will not check for a dynamic method - use invokeMethod below instead unless you know the MethodDefinition is dynamic
this version will not check for a dynamic method - use invokeMethod below instead unless you know the MethodDefinition is dynamic
public static Object callMethod(Object thisObj, Object method, Object...argValues) {
      if (method instanceof Method) {
         Method jMethod = (Method) method;
         return PTypeUtil.invokeMethod(thisObj, jMethod, argValues);
      }
      else if (method instanceof AbstractMethodDefinition) {
         AbstractMethodDefinition methDef = (AbstractMethodDefinition) method;
         argValues = convertVarargValues(method, argValues);
         if (methDef.isDynMethod())
            return ((AbstractMethodDefinition) method).callVirtual(thisObj, argValues);
         Object invMeth = methDef.getRuntimeMethod();
         return ModelUtil.invokeMethod(thisObj, invMeth, argValues, new ExecutionContext(methDef.getLayeredSystem()));
      }
      else if (method instanceof CFMethod) {
         Method rtMeth = ((CFMethod) method).getRuntimeMethod();
         if (rtMeth == null)
            throw new IllegalArgumentException("Can't invoke method: " + method + " No runtime class found");
         return ModelUtil.callMethod(thisObj, rtMeth, argValues);
      }
      else if (method instanceof ParamTypedMethod) {
         return callMethod(thisObj, ((ParamTypedMethod) method).method, argValues);
      }
      else if (method instanceof String) {
         Object methodObj = ModelUtil.getMethod(thisObj, (String) method);
         if (methodObj == null) {
            throw new IllegalArgumentException("No method: " + method + " on: " + thisObj);
         }
         return callMethod(thisObj, methodObj, argValues);
      }
      else
         throw new UnsupportedOperationException();
   }
public static Object callMethod ( Object thisObj , Object method , Object ... argValues ) { if ( method instanceof Method ) { Method jMethod = ( Method ) method ; return PTypeUtil . invokeMethod ( thisObj , jMethod , argValues ) ; } else if ( method instanceof AbstractMethodDefinition ) { AbstractMethodDefinition methDef = ( AbstractMethodDefinition ) method ; argValues = convertVarargValues ( method , argValues ) ; if ( methDef . isDynMethod ( ) ) return ( ( AbstractMethodDefinition ) method ) . callVirtual ( thisObj , argValues ) ; Object invMeth = methDef . getRuntimeMethod ( ) ; return ModelUtil . invokeMethod ( thisObj , invMeth , argValues , new ExecutionContext ( methDef . getLayeredSystem ( ) ) ) ; } else if ( method instanceof CFMethod ) { Method rtMeth = ( ( CFMethod ) method ) . getRuntimeMethod ( ) ; if ( rtMeth == null ) throw new IllegalArgumentException ( "Can't invoke method: " + method + " No runtime class found" ) ; return ModelUtil . callMethod ( thisObj , rtMeth , argValues ) ; } else if ( method instanceof ParamTypedMethod ) { return callMethod ( thisObj , ( ( ParamTypedMethod ) method ) . method , argValues ) ; } else if ( method instanceof String ) { Object methodObj = ModelUtil . getMethod ( thisObj , ( String ) method ) ; if ( methodObj == null ) { throw new IllegalArgumentException ( "No method: " + method + " on: " + thisObj ) ; } return callMethod ( thisObj , methodObj , argValues ) ; } else throw new UnsupportedOperationException ( ) ; }
Warning: this version will not check for a dynamic method - use invokeMethod below instead unless you know the MethodDefinition is dynamic
Warning : this version will not check for a dynamic method - use invokeMethod below instead unless you know the MethodDefinition is dynamic