--- old/src/share/classes/com/sun/tools/sjavac/Util.java 2014-08-09 00:28:47.143874713 +0200 +++ new/src/share/classes/com/sun/tools/sjavac/Util.java 2014-08-09 00:28:47.039877730 +0200 @@ -30,8 +30,11 @@ import java.io.IOException; import java.nio.file.Path; import java.util.Arrays; +import java.util.ArrayList; import java.util.HashSet; import java.util.Set; +import java.util.List; +import java.util.Map; import java.util.StringTokenizer; /** @@ -73,6 +76,7 @@ } public static String extractStringOption(String opName, String s, String deflt) { + if (s == null) return deflt; int p = s.indexOf(opName+"="); if (p == -1) return deflt; p+=opName.length()+1; @@ -93,6 +97,7 @@ } public static int extractIntOption(String opName, String s, int deflt) { + if (s == null) return deflt; int p = s.indexOf(opName+"="); if (p == -1) return deflt; p+=opName.length()+1; @@ -178,4 +183,46 @@ public static File pathToFile(Path path) { return path == null ? null : path.toFile(); } + + /** + * Extract the jar/zip/cym archive file name from a classfile tosttring. + */ + public static String extractArchive(String c) { + // Example: + // ZipFileIndexFileObject[/home/fredrik/bin/jdk1.8.0/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Runnable.class)] + if (c.startsWith("ZipFileIndexFileObject[")) { + int p = c.indexOf('(', 23); + if (p == -1) { + return null; + } + return c.substring(23, p); + } + return null; + } + + /** + * Utility to add to a Map> + */ + public static void addToMapSet(String k, String v, Map> m) { + Set set = m.get(k); + if (set == null) { + set = new HashSet(); + m.put(k, set); + } + set.add(v); + } + + /** + * Utility to add to a Map> + */ + public static void addToMapList(String k, String v, Map> m) { + List list = m.get(k); + if (list == null) { + list = new ArrayList(); + m.put(k, list); + } + list.add(v); + } + + }