我的反思有问题。
本质:课堂上有很多方法。我发现这有必要(这里一切都很好):
invokingMethod = InstanceClass.getMethod(AMethodName, AArgumentTypes);
然后我想打电话给他:
result = invokingMethod.invoke(AInstance, AArgumentObjects);
参数的数量可以不同。在这里,只需调用授权方法,因此只需要两个参数
方法签名:
public abstract long userLogin(java.lang.String,java.lang.String)
内容AArgumentsTypes:
内容AArgumentObjects:
因此,我对传递的错误类型的参数有错误。
仅当您将所有参数显式传递给函数时才有效。或者我在调试菜单变量中使用AArgumentObjects [1](如果我在代码中更改它,则错误仍然存在):
使用AArgumentObjects [1]从代码调用后:
Discharges:" java.lang.IllegalArgumentException"
24-Jul-2017 14:21:08.444 SEVERE [http-nio-8081-exec-3] ru.nahodka.general.Reflection.TReflexiveClassUtils.invokeMethod java.lang.IllegalArgumentException: wrong number of arguments
24-Jul-2017 14:21:08.444 INFO [http-nio-8081-exec-3] org.directwebremoting.log.accessLog.writeExceptionToAccessLog Method execution failed:
ru.nahodka.Applications.WebApplication.TCustomizableWebApplicationAbstractBothPart$WebServiceMethodInvokedException: Не удалось произвести вызов функции UserLogin в интерфейсе ru.nahodka.Family.Constants.FamilyClientMainInterfaceConstants.FamilyIntf. Код ошибки rwsrProcedureSuccess.
at ru.nahodka.ISUpravlenie.Implementation.ClientPart.MainInterfaceServiceInvoker.ControlLowLevelMainFunctionalClass.UserLogin(ControlLowLevelMainFunctionalClass.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at ru.nahodka.general.Reflection.TReflexiveUtils.InvokeMethodWithParameters(TReflexiveUtils.java:729)
at ru.nahodka.ISUpravlenie.Implementation.ClientPart.AbstractFunctional.ControlHighLevelAbstractFunctionalClientClass.getLowLevelMethodInvokeResult(ControlHighLevelAbstractFunctionalClientClass.java:170)
at ru.nahodka.ISUpravlenie.Implementation.ClientPart.MainInterfaceServiceInvoker.ControlHighLevelMainFunctionalClass.UserLogin(ControlHighLevelMainFunctionalClass.java:208)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.directwebremoting.impl.CreatorModule$1.doFilter(CreatorModule.java:178)
at org.directwebremoting.impl.CreatorModule.executeMethod(CreatorModule.java:184)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:353)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:306)
at org.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:110)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:211)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:185)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:144)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1533)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1489)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
答案 0 :(得分:0)
我用这种方式解决了问题,谢谢大家:
result = invokingMethod.invoke(AInstance, ((Object[])AArgumentObjects[1]));