I have a jar file with 30 classes. I want at the beginning of the main method I call a class from this jar, which, using the Java reflection capabilities, gets Classlinks to each class in the bank. My ultimate goal is to perform some kind of operation, requesting a variable that is defined for each class. Basically I am looking for something like. Is there an easy way to do this using the standard reflection APIs, or will it be too much hassle to create a working solution?
List l = Reflection.getAllClasses();
String var;
foreach(Class c : l) {
var = c.getField("fieldname");
doSomething(var);
}
Edit:
Just to make it clear: the code will be executed using a proven can.
source
share