Access protected static method using reflection?

abheyb

New member
When I tried to invoke a protected static method using reflections, it gave me a "IllegalAccessException".
How can I do the same???




try
{
Class1 cgcache = new Class1();
Class ob = cgcache.getClass();
Class[] args1 = new Class[1];
args1[0] = ClassName1.class;
Method strMethod = ob.getDeclaredMethod("gtDAct", args1);
Object arglist[] = new Object[1];
assertEquals(objName, strMethod.invoke(null,arglist));
}
catch(NoSuchMethodException ne)
{
ne.printStackTrace();
}
 
Back
Top