Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public void openPath(TreePath path)
}

//display via name
BytecodeViewer.viewer.workPane.addClassResource(container, name);
BytecodeViewer.viewer.workPane.addClassResource(container, name.substring(0, name.length() - ".class".length()));
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,18 @@ public void processDisplay()
else
{
final Decompiler decompiler = bytecodeViewPanel.decompiler;
final String workingDecompilerName = viewer.resource.workingName + "-" + decompiler.getDecompilerName();
String decompilerName = decompiler.getDecompilerName();
final String workingDecompilerName = viewer.resource.workingName + "-" + decompilerName;

//perform decompiling inside of this thread
final String decompiledSource = decompiler.getDecompiler().decompileClassNode(viewer.resource.getResourceClassNode(), classBytes);

ClassFileContainer container = new ClassFileContainer(workingDecompilerName, decompiledSource, viewer.resource.container);
ClassFileContainer container = new ClassFileContainer(
viewer.resource.workingName,
decompilerName,
decompiledSource,
viewer.resource.container
);

if (!BytecodeViewer.viewer.workPane.classFiles.containsKey(workingDecompilerName))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package the.bytecode.club.bytecodeviewer.resources.classcontainer;

import com.github.javaparser.*;
import com.github.javaparser.JavaParser;
import com.github.javaparser.ParseResult;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.resolution.TypeSolver;
import com.github.javaparser.symbolsolver.JavaSymbolSolver;
Expand All @@ -12,7 +13,6 @@
import the.bytecode.club.bytecodeviewer.resources.classcontainer.locations.*;
import the.bytecode.club.bytecodeviewer.resources.classcontainer.parser.visitors.MyVoidVisitor;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.NavigableMap;
Expand All @@ -27,6 +27,7 @@
*/
public class ClassFileContainer
{

public transient NavigableMap<String, ArrayList<ClassFieldLocation>> fieldMembers = new TreeMap<>();
public transient NavigableMap<String, ArrayList<ClassParameterLocation>> methodParameterMembers = new TreeMap<>();
public transient NavigableMap<String, ArrayList<ClassLocalVariableLocation>> methodLocalMembers = new TreeMap<>();
Expand All @@ -35,13 +36,15 @@ public class ClassFileContainer

public boolean hasBeenParsed = false;
public final String className;
public final String decompiler;
private final String content;
private final String parentContainer;
private final String path;

public ClassFileContainer(String className, String content, ResourceContainer resourceContainer)
public ClassFileContainer(String className, String decompiler, String content, ResourceContainer resourceContainer)
{
this.className = className;
this.decompiler = decompiler;
this.content = content;
this.parentContainer = resourceContainer.name;
this.path = resourceContainer.file.getAbsolutePath();
Expand Down Expand Up @@ -95,15 +98,19 @@ public boolean shouldParse()

public String getName()
{
if (this.className.contains("/"))
return this.className.substring(this.className.lastIndexOf('/') + 1, this.className.lastIndexOf('.'));
else
return this.className.substring(0, this.className.lastIndexOf('.'));
int from = className.lastIndexOf('/') + 1;

int until = className.lastIndexOf('.');
if (until == -1 || until < from) {
until = className.length();
}

return className.substring(from, until);
}

public String getDecompiler()
{
return this.className.substring(this.className.lastIndexOf('-') + 1);
return decompiler;
}

public String getParentContainer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ public JPanel getPanel()
@Override
public void search(ResourceContainer container, String resourceWorkingName, ClassNode node, boolean exact)
{
final Iterator<MethodNode> methods = node.methods.iterator();

String searchOwner = mOwner.getText();
if (searchOwner.isEmpty())
searchOwner = null;
Expand All @@ -105,6 +103,11 @@ public void search(ResourceContainer container, String resourceWorkingName, Clas
if (searchDesc.isEmpty())
searchDesc = null;

if (searchName == null && searchOwner == null && searchDesc == null)
return;

final Iterator<MethodNode> methods = node.methods.iterator();

while (methods.hasNext())
{
final MethodNode method = methods.next();
Expand All @@ -116,9 +119,6 @@ public void search(ResourceContainer container, String resourceWorkingName, Clas
{
final MethodInsnNode min = (MethodInsnNode) insnNode;

if (searchName == null && searchOwner == null && searchDesc == null)
continue;

if (exact)
{
if (searchName != null && !searchName.equals(min.name))
Expand Down