I want to check if a class or method is used in a jar file to delete the ones that are not used. I don't know how to approach it.
3 Answers
You can use an IDE to do what you are looking for (Netbeans IDE or IntelliJ Jetbrains)
The process is simple, import the jar file, and check for the definition/declaration of a particular class.

- 86
- 2
The most used way to identify if a method is used is by building a call graph. If a method is not called, then it can be removed. However, call graphs are not always sound because of the usages of reflection, unsafe, and polymorphism. So if you want to remove a method, you have to be sure that this method is not used by reflection or the other categories of unsoundness.
In order to remove classes, you have not only to ensure that the methods are not used but also the fields of the classes. Therefore, you need to identify all methods that might reference a field.
All the described analyses you can approach using the tools Soot, WALA, Javassist, or OPAL.

- 1,261
- 2
- 16
- 36
On eclipse simply:
- Open the class.
- Highlight the class name.
- Ctrl+Shift+G
You should see under the Search tab the amount of references pointing to that class.
The same procedure can be followed with any property or method.

- 99
- 1
- 10