简体   繁体   中英

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?

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. It doesn't search in the binary .class files. What you see when you navigate to a .class file is the decompiled version of the 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. 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.

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.

Find in Path (Ctrl + Shift + F) in Intellij and Scope > All Places should search for usage in all places (even in your libraries)

Note: Although this will not search for within decompiled classes. This would help you search across for all files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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