以编程方式检查 .class 文件是否扩展特定类

发布于 2024-09-11 05:00:01 字数 193 浏览 2 评论 0原文

我有一个问题,我已经尝试解决好几个小时了。在 Eclipse 插件中,我有一个 ArrayList,其中包含一些 java .class 文件的完整路径(作为字符串)。我想做的是检查列表中包含的类是否扩展了特定的类。我考虑过解析该文件,查找“extends”之后的内容,但是我们谈论的是 .class 文件而不是 .java 文件。还有其他想法吗?

谢谢!

I have a problem I've been trying to solve for quite some hours. In an Eclipse plugin, I have an ArrayList that contains the full paths (as strings) of some java .class files. What I'd like to do is check if the classes that are included in the list extend a particular class. I thought about parsing the file, looking for what is after "extends," however we are talking about a .class file and not of a .java file. Any other ideas?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

耶耶耶 2024-09-18 05:00:02

使用 URLClassLoader 加载文件(问题:您需要知道正确的父文件夹和 Package + ClassName)并使用普通的 java.lang.Class 方法进行检查。

Use an URLClassLoader to load the file (Problem: You would need to know the right parent folder and Package + ClassName) and use the normal java.lang.Class methods to check.

凉风有信 2024-09-18 05:00:02

您正在寻找的工具是 asm。 (或者 bcel,但现在 asm 更流行。)

The tool you're looking for is asm. (Or bcel, but asm is more popular these days.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文