Java 11 is not worth it, going back to Java 8

This commit is contained in:
orboditilt 2019-02-28 16:41:31 +01:00
parent 7fc35a82e1
commit 02ed1841f0
2 changed files with 16 additions and 10 deletions

View File

@ -12,7 +12,8 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties> </properties>
<dependencies> <dependencies>
@ -28,10 +29,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version> <version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>

View File

@ -7,6 +7,7 @@ import java.nio.file.Files;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -34,16 +35,23 @@ public class RPXFile {
return elf_reader.sections() // return elf_reader.sections() //
.filter(section -> section instanceof ElfExportsTable) // .filter(section -> section instanceof ElfExportsTable) //
.flatMap(m -> ((ElfExportsTable) m).stream()) // .flatMap(m -> ((ElfExportsTable) m).stream()) //
.collect(Collectors.toUnmodifiableList()); .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
} }
public Map<String, List<RPLImport>> getImports() { public Map<String, List<RPLImport>> getImports() {
return elf_reader.sections() // return elf_reader.sections() //
.filter(section -> section instanceof ElfRelocationTable) // We want to check ElfRelocationTable sections .filter(section -> section instanceof ElfRelocationTable) // We want to check ElfRelocationTable sections
.flatMap(section -> ((ElfRelocationTable) section).stream()) // Get all relocations .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 .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() // .distinct() //
.collect(Collectors.collectingAndThen( // .collect(Collectors.collectingAndThen( //
Collectors.groupingBy(RPLImport::getRplName, Collectors.toList()), // Group by RPLName Collectors.groupingBy(RPLImport::getRplName, Collectors.toList()), // Group by RPLName
@ -88,12 +96,12 @@ public class RPXFile {
public Stream<ElfSymbol> getFunctionSymbolsTextStream() { public Stream<ElfSymbol> getFunctionSymbolsTextStream() {
return getSymbols().filter(s -> s.type() == ElfSymbol.STT_FUNC) // We are only interested in functions 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()); // .filter(s -> s.section().filter(m -> ".text".equals(m.name())).isPresent()); //
} }
public List<ElfSymbol> getFunctionSymbolsText() { public List<ElfSymbol> getFunctionSymbolsText() {
return getFunctionSymbolsTextStream().collect(Collectors.toUnmodifiableList()); return getFunctionSymbolsTextStream().collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
} }
} }