diff --git a/pom.xml b/pom.xml
index 9bb288f..0978225 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,8 @@
UTF-8
- 11
+ 1.8
+ 1.8
@@ -28,10 +29,7 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.8.0
-
- 11
-
+ 3.8.0
org.apache.maven.plugins
diff --git a/src/main/java/de/orb/wiiu/rpxparser/RPXFile.java b/src/main/java/de/orb/wiiu/rpxparser/RPXFile.java
index 94de135..a388891 100644
--- a/src/main/java/de/orb/wiiu/rpxparser/RPXFile.java
+++ b/src/main/java/de/orb/wiiu/rpxparser/RPXFile.java
@@ -7,6 +7,7 @@ import java.nio.file.Files;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -34,16 +35,23 @@ public class RPXFile {
return elf_reader.sections() //
.filter(section -> section instanceof ElfExportsTable) //
.flatMap(m -> ((ElfExportsTable) m).stream()) //
- .collect(Collectors.toUnmodifiableList());
+ .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
}
public Map> getImports() {
return elf_reader.sections() //
.filter(section -> section instanceof ElfRelocationTable) // We want to check ElfRelocationTable sections
.flatMap(section -> ((ElfRelocationTable) section).stream()) // Get all relocations
- .flatMap(r -> r.symbol().stream()) // Get symbols of relocations if existing
+ .flatMap(r -> {
+ ElfSymbol t = r.symbol().get();
+ if (t != null) {
+ return Stream.of(t);
+ }
+ return Stream.empty();
+ }) // Get symbols of relocations if existing
.filter(symbol -> symbol.section().filter(s -> (s instanceof ElfImportsTable)).isPresent()) // Only keep symbols of ElfImportsTable section
- .map(symbol -> new RPLImport(symbol.name().orElseThrow(), ((ElfImportsTable) symbol.section().get()).rplname())) // Map to RPLImport
+ .map(symbol -> new RPLImport(symbol.name().orElseThrow(() -> new NoSuchElementException()),
+ ((ElfImportsTable) symbol.section().get()).rplname())) // Map to RPLImport
.distinct() //
.collect(Collectors.collectingAndThen( //
Collectors.groupingBy(RPLImport::getRplName, Collectors.toList()), // Group by RPLName
@@ -88,12 +96,12 @@ public class RPXFile {
public Stream getFunctionSymbolsTextStream() {
return getSymbols().filter(s -> s.type() == ElfSymbol.STT_FUNC) // We are only interested in functions
- .filter(s -> !s.name().isEmpty()) // Not interested in functions with an empty name
+ .filter(s -> s.name().map(name -> name).filter(name -> !name.isEmpty()).isPresent()) // Not interested in functions with an empty name
.filter(s -> s.section().filter(m -> ".text".equals(m.name())).isPresent()); //
}
public List getFunctionSymbolsText() {
- return getFunctionSymbolsTextStream().collect(Collectors.toUnmodifiableList());
+ return getFunctionSymbolsTextStream().collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
}
}