Example #1
0
 //directly called only by native mathods implementation
 internal void PrepareMethodInvocation(MethodInfo methodToRun, JavaInstance instance, object[] parameters)
 {
     if (methodToRun.IsNative)
     {
         NativeMethodInfo nativeMethod = (NativeMethodInfo)methodToRun;
         object           returnValue  = nativeMethod.Implementation(instance, parameters, this);
         if (returnValue != null)
         {
             stack.Peek().PushToOperandStack(returnValue);
         }
     }
     else
     {
         StackFrame newFrame = new StackFrame(methodToRun, this);
         newFrame.InitLocals(instance, parameters);
         stack.Push(newFrame);
     }
 }
Example #2
0
        public void SignalException(string exceptionClassName, string ctorDescriptor = null, object[] parameters = null)
        {
            var exceptionInstance       = CreateJavaInstance(exceptionClassName);
            NativeMethodInfo nativeCtor = null;

            if (ctorDescriptor == null)
            {
                nativeCtor = exceptionInstance.JavaClass.GetMethodInfo(ClassDefaults.ConstructorMethodName + ClassDefaults.VoidMethodDescriptor) as NativeMethodInfo;
            }
            else
            {
                nativeCtor = exceptionInstance.JavaClass.GetMethodInfo(ClassDefaults.ConstructorMethodName + ctorDescriptor) as NativeMethodInfo;
            }

            if (nativeCtor != null)
            {
                nativeCtor.Implementation(exceptionInstance, parameters ?? ClassDefaults.EmptyParameters, this);
            }

            SignalException(exceptionInstance);
        }