我正在尝试使用 invoke() 方法从 gosu 暂存器调用私有方法。但我无法访问该私有方法。谁能告诉我在 GOSU 语言中调用私有方法的最佳方法。这是代码
try{
var clazz = java.lang.Class.forName(ClaimSearchCriteriaImpl)
var method = clazz.getDeclaredMethod("generateSimpleActiveClaimViewQuery", null)
method.setAccessible(true)
var ss = method.invoke(clazz, null)as ClaimSearchCriteriaImpl
print("Result.."+ss)
} catch(exception){
print("***********"+exception)
}
当我尝试执行此代码时,出现以下异常
java.lang.IllegalAccessException: Class program_.__Program__505 can not access a member of class com.guidewire.cc.domain.claim.impl.ClaimSearchCriteriaImpl with modifiers "private"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:105)
at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:261)
at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:253)
at java.lang.reflect.Method.invoke(Method.java:599)
at program_.__Program__505.evaluate(Unknown Source)
at gw.internal.gosu.parser.GosuProgram.runProgram(GosuProgram.java:421)
at gw.internal.gosu.parser.GosuProgram.evaluate(GosuProgram.java:253)
at gw.internal.gosu.parser.GosuProgram_Proxy.evaluate(gw.internal.gosu.parser.GosuProgram_Proxy:2)
at gw.internal.gosu.parser.ExecutionEnvironment$1.evaluate(ExecutionEnvironment.java:543)
at gw.internal.gosu.parser.ExecutionEnvironment$1.runScript(ExecutionEnvironment.java:523)
at gw.internal.gosu.parser.ExecutionEnvironment$1.run(ExecutionEnvironment.java:489)
at java.lang.Thread.run(Thread.java:724)