Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search string in decompiled .class files in Intellij

Tags:

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.

like image 331
LeRiton Avatar asked Jul 19 '17 14:07

LeRiton


People also ask

How do I search .class files in IntelliJ?

Ctrl+N : finds a class by name. Ctrl+Shift+N : finds any file or directory by name (supports CamelCase and snake_case).

How do I search a .class file?

Ctrl + H will bring up a Search/Find dialog. One of the tabs is Java which will let you specify what exactly you are looking for e.g. Class/MNethod etc.

How do I search text in IntelliJ?

From the main menu, select Edit | Find | Find in Files Ctrl+Shift+F . In the search field, type your search string. Alternatively, in the editor, highlight the string you want to find and press Ctrl+Shift+F . IntelliJ IDEA places the highlighted string into the search field.


1 Answers

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.

like image 167
CrazyCoder Avatar answered Oct 06 '22 10:10

CrazyCoder