Skip to content

Commit

Permalink
Minor PMD fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ledmington committed Jan 3, 2025
1 parent 503c190 commit 7f56e7d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
6 changes: 6 additions & 0 deletions elf/src/main/java/com/ledmington/elf/ELFParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public final class ELFParser {

private ELFParser() {}

/**
* Parses the given file and returns an {@link ELF} file object.
*
* @param filename The name of the file to be parsed.
* @return An ELF file object.
*/
public static ELF parse(final String filename) {
final File file = new File(filename);
if (!file.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,20 @@ public enum GnuPropertyType {
this(code, "UNKNOWN");
}

/**
* Returns the 32-bit code of this GNU property type.
*
* @return The 32-bit code of this GNU property type.
*/
public int getCode() {
return code;
}

/**
* Returns a String with the description of this type as GNU's <code>readelf</code> would print it.
*
* @return The description of this type.
*/
public String getDescription() {
return description;
}
Expand Down
12 changes: 7 additions & 5 deletions emu/src/test/java/com/ledmington/emu/TestEmulation.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package com.ledmington.emu;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand All @@ -25,18 +27,18 @@
import org.junit.jupiter.api.Test;

/** End-to-end testing emulating entire executables. */
public final class TestEmulation {
final class TestEmulation {

@Test
void doNothing() {
final Path p;
try {
p = Paths.get(
Objects.requireNonNull(this.getClass().getClassLoader().getResource("do_nothing.elf"))
.toURI());
p = Paths.get(Objects.requireNonNull(
Thread.currentThread().getContextClassLoader().getResource("do_nothing.elf"))
.toURI());
} catch (final URISyntaxException e) {
throw new RuntimeException(e);
}
Emu.run(p.toString());
assertDoesNotThrow(() -> Emu.run(p.toString()));
}
}

0 comments on commit 7f56e7d

Please sign in to comment.