我正在调试一个包含许多类和表单的项目,这对我查找项目中使用的所有公共变量非常有用。有没有办法在 Netbeans 中做到这一点?我也无法找到 Netbeans 的插件来实现这一点。
非常感谢。
我正在调试一个包含许多类和表单的项目,这对我查找项目中使用的所有公共变量非常有用。有没有办法在 Netbeans 中做到这一点?我也无法找到 Netbeans 的插件来实现这一点。
非常感谢。
http://code.google.com/p/reflections/应该可以
import static org.reflections.ReflectionUtils.getAllFields;
import static org.reflections.ReflectionUtils.withModifier;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.LinkedHashSet;
import java.util.Set;
import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.util.ClasspathHelper;
public class PublicFieldsReflectionsTest
{
public static void main(String[] args)
{
Reflections reflections = new Reflections(
"de.your.project.prefix",
ClasspathHelper.forClass(Object.class),
new SubTypesScanner(false));
Set<Class<?>> allClasses = reflections.getSubTypesOf(Object.class);
Set<Field> allPublicFields = new LinkedHashSet<Field>();
for (Class<?> c : allClasses)
{
//System.out.println("Class "+c);
allPublicFields.addAll(getAllFields(c, withModifier(Modifier.PUBLIC)));
}
for (Field field : allPublicFields)
{
System.out.println(field);
}
}
}