Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove guava dependency #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
@@ -1,6 +1,5 @@
package org.mapleir.ir.cfg;

import com.google.common.collect.Streams;
import org.mapleir.dot4j.model.DotGraph;
import org.mapleir.flowgraph.ExceptionRange;
import org.mapleir.flowgraph.FlowGraph;
Expand Down Expand Up @@ -30,6 +29,7 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import static org.mapleir.ir.code.Opcode.PHI_STORE;

Expand Down Expand Up @@ -58,7 +58,8 @@ public int makeBlockId() {
}

public Stream<CodeUnit> allExprStream() {
return vertices().stream().flatMap(Collection::stream).map(Stmt::enumerateWithSelf).flatMap(Streams::stream);
return vertices().stream().flatMap(Collection::stream).map(Stmt::enumerateWithSelf)
.flatMap(codeUnits -> StreamSupport.stream(codeUnits.spliterator(), false));
}

/**
Expand Down
5 changes: 0 additions & 5 deletions org.mapleir.main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
<groupId>org.mapleir</groupId>
<artifactId>main</artifactId>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>22.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
5 changes: 0 additions & 5 deletions org.mapleir.parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>22.0</version>
</dependency>
</dependencies>
<modules>
<module>../org.mapleir.app-services</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import org.mapleir.stdlib.collections.graph.util.OrderedNode.ODirectedGraph;
import org.mapleir.stdlib.collections.graph.util.OrderedNode.OGraph;

import com.google.common.base.Predicates;
import com.google.common.collect.Iterators;

import junit.framework.TestCase;


Expand Down Expand Up @@ -60,8 +57,8 @@ private void assertPreOrdered(List<OrderedNode> nodes) {
OrderedNode node = nodes.get(i);
visited.add(node);
OrderedNode prev = nodes.get(i - 1);
if (!Iterators.all(g.getSuccessors(prev).iterator(), Predicates.in(visited)))
assertTrue("unvisited pred", Iterators.contains(g.getPredecessors(node).iterator(), prev));
if (g.getSuccessors(prev).anyMatch(x -> !visited.contains(x)))
assertTrue("unvisited pred", g.getPredecessors(node).anyMatch(prev::equals));
}
}

Expand All @@ -70,7 +67,7 @@ private void assertTopoOrdered(List<OrderedNode> nodes) {
assertEquals("missing nodes", new HashSet<>(nodes), g.vertices());
for (OrderedNode node : nodes) {
visited.add(node);
assertTrue("unvisited pred", Iterators.all(g.getPredecessors(node).iterator(), Predicates.in(visited)));
assertTrue("unvisited pred", g.getPredecessors(node).allMatch(visited::contains));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.topdank.byteio.in;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.JarURLConnection;
Expand All @@ -16,8 +17,6 @@
import org.topdank.byteengineer.commons.data.JarResource;
import org.topdank.byteengineer.commons.data.LocateableJarContents;

import com.google.common.io.ByteStreams;

public class SingleJarDownloader<C extends ClassNode> extends AbstractJarDownloader<C> {

protected final JarInfo jarInfo;
Expand Down Expand Up @@ -64,6 +63,12 @@ public void download() throws IOException {
}

private byte[] read(InputStream inputStream) throws IOException {
return ByteStreams.toByteArray(inputStream);
byte[] buf = new byte[8192];
ByteArrayOutputStream baos = new ByteArrayOutputStream(Math.max(8192, inputStream.available()));
int r;
while ((r = inputStream.read(buf)) >= 0) {
baos.write(buf, 0, r);
}
return baos.toByteArray();
}
}