eclipse关于反射的代码都运行异常,同样的代码复制到记事本或myeclipse就可以正常运行,这是怎么回事
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class Demo1 {
public static void main(String[] args) throws Exception {
Class cs = Class.forName("Test");
Field[] ff = cs.getDeclaredFields();
for (Field f : ff) {
System.out.println(f);
}
Method[] mm = cs.getDeclaredMethods();
for (Method m : mm) {
System.out.println(m);
}
Constructor[] cc = cs.getConstructors();
for (Constructor c : cc) {
System.out.println(c);
}
}
}
class Test {
private int id;
private int age;
private Double double1 = 123.4;
public Test() {
};
private void method1() {
};
private void method2() {
};
private void method3() {
};
}