简体   繁体   English

如何在Intellij中的反编译.class文件中搜索字符串

[英]How to search string in decompiled .class files in Intellij

Is it possible to search for a specific string in decompiled .class files using Find in Path ( Ctrl + Shift + F ) in Intellij? 是否可以使用Intellij Find in PathCtrl + Shift + F )在反编译的.class文件中搜索特定字符串?

I want to search in a library code for which I have no source code. 我想在库代码中搜索我没有源代码。

Find doesn't pop any result despite the string being present (and visible) in editor. 尽管字符串在编辑器中存在(并且可见),但查找不会弹出任何结果。

It's not possible without manually decompiling all the classes beforehand and attaching the decompiled sources to the library you want to search in. 如果不预先手动反编译所有类并将反编译的源附加到要搜索的库,则无法实现。

IntelliJ IDEA Find in Path works with source and resource files only. IntelliJ IDEA在路径中查找仅适用于源文件和资源文件。 It doesn't search in the binary .class files. 它不会搜索二进制.class文件。 What you see when you navigate to a .class file is the decompiled version of the class. 导航到.class文件时看到的是该类的反编译版本。 Decompilation is performed on the fly, IDE doesn't decompile and index all the .class files automatically, therefore there is no index available and no way to perform fast search. 反编译是动态执行的,IDE不会自动反编译和索引所有.class文件,因此没有可用的索引,也无法执行快速搜索。 Such feature, while technically possible, would require decompiling and indexing all the dependencies which could take a lot of time and system resources, especially in the projects with a lot of dependencies. 这种功能虽然在技术上可行,但需要对所有依赖项进行反编译和索引,这可能会占用大量时间和系统资源,尤其是在具有大量依赖项的项目中。

Usually there are sources available for the libraries you depend on. 通常,您可以使用所依赖的库。 For Gradle/Maven projects IntelliJ IDEA can download and configure such sources automatically, so find in path will work inside the libraries with the attached sources for the majority of the users/projects. 对于Gradle / Maven项目,IntelliJ IDEA可以自动下载和配置这些源,因此在路径中查找将在库内部使用大多数用户/项目的附加源。

In case the library has no sources, you can perform offline decompilation of the entire library using the command line batch decompiler and attach the directory with the decompiled sources to the library. 如果库没有源,您可以使用命令行批量反编译器对整个库执行脱机反编译,并将包含反编译源的目录附加到库中。

Quoted from this answer in the IntelliJ IDEA forum. 引自IntelliJ IDEA论坛中的这个答案

Find in Path (Ctrl + Shift + F) in Intellij and Scope > All Places should search for usage in all places (even in your libraries) (Ctrl + Shift + F) in Intellij查找路径(Ctrl + Shift + F) in IntellijScope > All Places应搜索所有位置的使用情况(即使在您的库中)

Note: Although this will not search for within decompiled classes. 注意:虽然这不会在反编译类中搜索。 This would help you search across for all files. 这有助于您搜索所有文件。

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

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