-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathJarAnalyzer.java
More file actions
32 lines (25 loc) · 950 Bytes
/
Copy pathJarAnalyzer.java
File metadata and controls
32 lines (25 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package org.example;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import java.io.IOException;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
public class JarAnalyzer {
private final String jarPath;
public JarAnalyzer(String jarPath) {
this.jarPath = jarPath;
}
public void processClasses(ClassVisitor visitor) throws IOException {
try (JarFile jarFile = new JarFile(jarPath)) {
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
if (entry.getName().endsWith(".class")) {
ClassReader classReader = new ClassReader(jarFile.getInputStream(entry));
classReader.accept(visitor, ClassReader.EXPAND_FRAMES);
}
}
}
}
}