Invokes the given method, by ID, on the given object handle. Accepts a pointer to a JValue array of arguments.
653 {
654
655 var env = pEnv->GetContext();
656 var obj = UnwrapRef(env, objHandle);
657
658
659 var mw = RuntimeJavaMethod.FromCookie(methodID);
660 mw.Link();
661 mw.ResolveMethod();
662
663
664 var argTypes = mw.GetParameters();
665 var args = new object[argTypes.Length + (mw.HasCallerID ? 1 : 0)];
666 for (int i = 0; i < argTypes.Length; i++)
667 {
668 var type = argTypes[i];
669 if (type == env.context.PrimitiveJavaTypeFactory.BOOLEAN)
670 args[i] = pArgs[i].z != JNI_FALSE;
671 else if (type == env.context.PrimitiveJavaTypeFactory.BYTE)
672 args[i] = (byte)pArgs[i].b;
673 else if (type == env.context.PrimitiveJavaTypeFactory.CHAR)
674 args[i] = (char)pArgs[i].c;
675 else if (type == env.context.PrimitiveJavaTypeFactory.SHORT)
676 args[i] = pArgs[i].s;
677 else if (type == env.context.PrimitiveJavaTypeFactory.INT)
678 args[i] = pArgs[i].i;
679 else if (type == env.context.PrimitiveJavaTypeFactory.LONG)
680 args[i] = pArgs[i].j;
681 else if (type == env.context.PrimitiveJavaTypeFactory.FLOAT)
682 args[i] = pArgs[i].f;
683 else if (type == env.context.PrimitiveJavaTypeFactory.DOUBLE)
684 args[i] = pArgs[i].d;
685 else
686 args[i] = argTypes[i].GhostWrap(UnwrapRef(env, pArgs[i].l));
687 }
688
689
690 if (mw.HasCallerID)
691 args[args.Length - 1] = env.callerID;
692
693 if (nonVirtual && mw.RequiresNonVirtualDispatcher)
695
696 if (mw.IsConstructor)
697 {
698 if (obj == null)
699 {
700 return mw.CreateInstance(args);
701 }
702 else
703 {
704 var mb = mw.GetMethod();
705 if (mb.IsStatic)
706 {
707
708
709
710 throw new NotSupportedException($"Remapped type {mw.DeclaringType.Name} doesn't support constructor invocation on an existing instance");
711 }
712 else if (!mb.DeclaringType.IsInstanceOfType(obj))
713 {
714
715 throw new NotSupportedException($"Unable to partially construct object of type {obj.GetType().FullName} to type {mb.DeclaringType.FullName}");
716 }
717 }
718 }
719
720 return mw.Invoke(obj, args);
721 }
static object InvokeNonVirtual(JNIEnvContext env, RuntimeJavaMethod mw, object obj, object[] argarray)
Invokes the given non-virtual method, by ID, on the given object handle. Accepts a pointer to a JValu...