Skip to content

Commit a803231

Browse files
committed
Fix private func
1 parent eafddd0 commit a803231

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/com/wsdjeg/util/TestMethod.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.wsdjeg.util;
22

3+
import java.lang.reflect.Constructor;
34
import java.lang.reflect.Method;
45

56
public class TestMethod{
@@ -37,7 +38,9 @@ public static void testSpecifiedMethod(String className,String methodName){
3738
System.out.println("startting : className:" + className + " methodName :"+ methodName + "()" );
3839
System.out.println("result:");
3940
Class<?> clazz = Class.forName(className);
40-
clazz.getMethod(methodName).invoke(clazz.newInstance());
41+
Constructor<?> c = clazz.getDeclaredConstructor();
42+
c.setAccessible(true);
43+
clazz.getMethod(methodName).invoke(c.newInstance());
4144
System.out.println("success!");
4245
}catch(Exception e){
4346
System.out.println("fail!");

0 commit comments

Comments
 (0)