有没有办法使用Eclipse列出某个类的equals()的所有调用? [英] Is there a way to list all calls of equals() of a certain class using Eclipse?

查看:114
本文介绍了有没有办法使用Eclipse列出某个类的equals()的所有调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前面临以下问题:

我有一个类,其中equals() - 方法被覆盖。但是我不确定它是否曾被使用过(无论是在我的同事还是在我的同事项目中)。有办法找出来吗?
当我搜索引用时,它只是给了我对Object equals() - Method(很多)的所有引用。肯定有一种比扫描所有这些更简单的方法......

I have a certain class in which the equals() - Method is overridden. However I'm not sure if it is ever being used (either in my or in one of my collegues projects). Is there a way to find out? When I search for references, well, it just gives me ALL references to the Object equals() - Method (which are quite a few). There surely must be an easier way than scan through all of them...

任何人都有了想法?

推荐答案

你要求Eclipse解决一个不可能的任务。

You're asking Eclipse to solve an impossible task.

要弄清楚是否调用了特定的重写方法不是静态可判定的,这就是Eclipse超过响应的原因。

To figure out if a particular overridden method is called or not is not statically decidable, which is why Eclipse over approximates the response.

假设你有一些字段 Object o 并且你在某些时候做 o.equals(...)。要确定 o 是否可以引用 YourClass 对象,需要确定<$ c的运行时类型$ c> o 沿着每个可能的执行路径,这是不能静态完成的。

Assume you have some field Object o and that you at some point do o.equals(...). To determine whether or not o could ever refer to a YourClass object requires that you determine the runtime type of o along every possible execution path, which simply can't be done statically.

之所以不可能与编译器拒绝以下代码的原因完全相同:

The reason why it is impossible is quite similar to why the compiler rejects the following code:

Object o = "hello";
System.out.println(o.length());

您可以做的最好的事情可能是通过设置断点或投掷来调试程序例如,来自equals方法的UnsupportedOperationException。

The best thing you can do is probably debug your program, either by setting a break point or by throwing for instance an UnsupportedOperationException from within the equals method.

这篇关于有没有办法使用Eclipse列出某个类的equals()的所有调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆