In Java, is it possible to access an instance of a static class (nested) using reflection?
Supposing I have the following 2 classes defined in the package Package1.SubPackage.SubSubPackage:
public class MyMainClass {
public static class SalesObjectGrouper1 {
public static final GrouperContext CONTEXT = new GrouperContext("MyDate");
}
private static class SalesObjectGrouper2 {
public static final GrouperContext CONTEXT = new GrouperContext("MyDate");
}
}
If I run the following code:
try {
xyz = Class.forName( "Package1.SubPackage.SubSubPackage.MyMainClass.SalesObjectGrouper1" );
} catch( ClassNotFoundException ex ) {
// always hit the error
}
it will error indicating class cannot be found. Can this be done?
char z;
Andez