我正在尝试调用Class中声明的私有静态方法。
Class bridgeClass = Class.forName("MyClassName");
Method method = bridgeClass .getDeclaredMethod("isResourcePotentiallyOnPath" , new Class[]{String.class, List.class});
method.setAccessible(true);
然后,
Object [] args = new Object[2];
args[0] = "SomeResource"
args[1] = null; //by default i want to pass in null here
boolean returnValue = (Boolean)method.invoke(null, args);
我看到该方法不是null,而是method.invoke在堆栈的某处导致空指针
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
我做错了什么?
由于
编辑:
以下是我尝试调用的方法
private static boolean isResourcePotentiallyOnPath(String aFullyQualifiedName, List aClassPath){
System.out.println("yahoo.. reached here finally");
Jsr199FileManager fileManager = Jsr199FileManager.getInstance(jvmHomeForJars, aClassPath);
return fileManager.isResourcePotentiallyOnPath(aFullyQualifiedName);
}