Skip to content

Commit

Permalink
Fixed class files support
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteZ1337 committed Aug 25, 2022
1 parent 70f0920 commit 39ac277
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.xenondevs.luyten</groupId>
<artifactId>luytenx</artifactId>
<version>0.8.0</version>
<version>0.8.1</version>

<properties>
<darklaf.version>2.7.3</darklaf.version>
Expand Down
10 changes: 5 additions & 5 deletions src/us/deathmarine/luyten/Luyten.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static File getFileFromCommandLine(String... args) {
}

public static String getVersion() {
return "0.8";
return "0.8.1";
}

/**
Expand Down Expand Up @@ -175,8 +175,8 @@ public void mouseClicked(MouseEvent e) {
scroll.setBorder(new CompoundBorder(BorderFactory.createTitledBorder("Stacktrace"),
new BevelBorder(BevelBorder.LOWERED)));
pane.add(scroll);
final String issue = "https://github.com/deathmarine/Luyten/issues";
final JLabel link = new JLabel("<HTML>Submit to <FONT color=\"#000099\"><U>" + issue + "</U></FONT></HTML>");
final String issue = "https://github.com/ByteZ1337/LuytenX/issues";
final JLabel link = new JLabel("<HTML>Submit to <FONT color=\"#3498db\"><U>" + issue + "</U></FONT></HTML>");
link.setCursor(new Cursor(Cursor.HAND_CURSOR));
link.addMouseListener(new MouseAdapter() {
@Override
Expand All @@ -190,12 +190,12 @@ public void mouseClicked(MouseEvent e) {

@Override
public void mouseEntered(MouseEvent e) {
link.setText("<HTML>Submit to <FONT color=\"#00aa99\"><U>" + issue + "</U></FONT></HTML>");
link.setText("<HTML>Submit to <FONT color=\"#3498db\"><U>" + issue + "</U></FONT></HTML>");
}

@Override
public void mouseExited(MouseEvent e) {
link.setText("<HTML>Submit to <FONT color=\"#000099\"><U>" + issue + "</U></FONT></HTML>");
link.setText("<HTML>Submit to <FONT color=\"#3498db\"><U>" + issue + "</U></FONT></HTML>");
}
});
pane.add(link);
Expand Down
36 changes: 23 additions & 13 deletions src/us/deathmarine/luyten/util/ProcyonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,37 @@
import com.strobel.assembler.metadata.TypeDefinition;
import us.deathmarine.luyten.Model;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

public class ProcyonUtils {

public static byte[] getContent(TypeDefinition type, Model model) {
try (JarFile jarFile = new JarFile(model.getOpenedFile())) {
JarEntry entry = jarFile.getJarEntry(type.getInternalName() + ".class");
if (entry != null) {
try (InputStream inputStream = jarFile.getInputStream(entry)) {
byte[] content = new byte[(int) entry.getSize()];
inputStream.read(content);
return content;
var file = model.getOpenedFile();
if (file.getName().endsWith(".class")) {
try (var inputStream = new FileInputStream(file)) {
var content = new byte[(int) file.length()];
inputStream.read(content);
return content;
} catch (IOException e) {
throw new RuntimeException(e);
}
} else {
try (var jarFile = new JarFile(file)) {
var entry = jarFile.getJarEntry(type.getInternalName() + ".class");
if (entry != null) {
try (var inputStream = jarFile.getInputStream(entry)) {
var content = new byte[(int) entry.getSize()];
inputStream.read(content);
return content;
}
} else {
return null;
}
} else {
return null;
} catch (IOException e) {
throw new RuntimeException(e);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}

Expand Down

0 comments on commit 39ac277

Please sign in to comment.