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

[TIMOB-23933] Only exclude internally used classpaths #268

Merged
merged 3 commits into from
Jan 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions android/hooks/metabase/src/JavaMetabaseGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
*/
import java.io.File;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import java.util.jar.JarFile;
import java.util.List;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
Expand Down Expand Up @@ -36,7 +38,7 @@ public class JavaMetabaseGenerator
* This probably isn't even needed anymore after out whitelist, but could be used to further narrow down specific classes out of the whitelisted packages we allowed.
*/
private static final Pattern blacklist = Pattern
.compile("^(com\\/sun|com\\/oracle|jdk\\/internal|org\\/apache\\/bcel|org\\/jcp|org\\/json|org\\/ietf|sun\\/|com\\/apple|quicktime\\/|apple\\/|com\\/oracle\\/jrockit|oracle\\/jrockit|sunw\\/|org\\/omg|java\\/awt|java\\/applet|junit\\/|edu\\/umd\\/cs\\/findbugs|orgpath\\/icedtea)");
.compile("^(com\\/sun|com\\/oracle|jdk\\/internal|org\\/apache\\/bcel|org\\/jcp|org\\/ietf|sun\\/|com\\/apple|quicktime\\/|apple\\/|com\\/oracle\\/jrockit|oracle\\/jrockit|sunw\\/|org\\/omg|java\\/awt|java\\/applet|junit\\/|edu\\/umd\\/cs\\/findbugs|orgpath\\/icedtea)");

/**
* Basically we just want:
Expand Down Expand Up @@ -135,19 +137,17 @@ public static void main(String[] args) throws Exception
ClassPath cp = new ClassPath();
String classpath = cp.getClassPath();
String[] tokens = classpath.split(File.pathSeparator);
// Remove the first two tokens as these are our internal BCEL and json dependencies
List<String> tokenList = Arrays.asList(tokens).subList(2, tokens.length);

OutputStreamWriter pw = new OutputStreamWriter(System.out, "UTF-8");
JSONWriter writer = new JSONWriter(pw);
writer.object();
writer.key("classes");
writer.object();
Set<String> uniques = new HashSet<String>();
for (String token : tokens)
for (String token : tokenList)
{
// Skip the libraries we use to generate the metabase
if (token.endsWith("bcel-5.2.jar") || token.endsWith("json.jar")) {
continue;
}
if (token.endsWith(".jar"))
{
JarFile jarFile = new JarFile(token);
Expand Down