简体   繁体   English

java Class.getDeclaredMethods似乎显示已删除的方法

[英]java Class.getDeclaredMethods appears to be showing methods that have been deleted

I'm using the following code to print the methods of a class: 我正在使用以下代码来打印类的方法:

for (Method meth : c.getDeclaredMethods())
{
  System.out.println("  " + shorten(meth.toGenericString()));
}

When it runs on the class I choose, it prints the current methods of my class, plus some methods that I once had, but have since deleted. 当它在我选择的类上运行时,它会打印我的类的当前方法,以及我曾经拥有的一些方法,但之后已被删除。 The navigator in my IDE (netbeans 7.2) does not show the old methods. 我的IDE(netbeans 7.2)中的导航器不显示旧方法。 None of the methods are flagged as bridge or synthetic. 没有任何方法被标记为桥或合成。

Does the java compiler somehow keep a history? java编译器是否以某种方式保留历史记录?

The compiler doesn't, and the IDE (netbeans) shouldn't. 编译器没有,IDE(netbeans)不应该。 Most likely you have built .class files from older .java files which still exist. 很可能你从旧的.java文件中构建了.class文件,这些文件仍然存在。 Try doing a clean build (deleting all .class files before building again) and see if the problem persists. 尝试进行干净的构建(在重新构建之前删除所有.class文件)并查看问题是否仍然存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM