--- old/src/share/classes/com/sun/tools/sjavac/server/JavacServiceClient.java 2014-08-09 00:28:50.931764799 +0200 +++ new/src/share/classes/com/sun/tools/sjavac/server/JavacServiceClient.java 2014-08-09 00:28:50.799768627 +0200 @@ -41,6 +41,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -136,6 +137,31 @@ } /** + * Extract the package name and the class from the string. + * Deps will be a map from packag name to class name. + */ + static void addClasspathPackageDependency(Map> deps, String fullname) { + // Modules beware! + String pkg; + int p = fullname.lastIndexOf('.'); + if (p == -1) { + // Arghh, a source file without a package. + pkg = ":"; + } + else { + pkg = ":"+fullname.substring(0, p); + } + synchronized (deps) { + Set set = deps.get(pkg); + if (set == null) { + set = new HashSet(); + deps.put(pkg, set); + } + set.add(fullname); + } + } + + /** * Connect and compile using the javac server settings and the args. When using more advanced features, the sources_to_compile and visible_sources are * supplied to the server and meta data is returned in package_artifacts, package_dependencies and package_pubapis. */ @@ -281,12 +307,17 @@ lastPackageSet = new HashSet<>(); rc.packageDependencies.put(pkg, lastPackageSet); } else if (l.length() > 1 && lastPackageSet != null) { - lastPackageSet.add(l.substring(1)); + if (l.startsWith(" :. ")) { + // This is a classpath dependency. + addClasspathPackageDependency(rc.classpathPackageDependencies, l.substring(4)); + } else { + // Standard package dependency. + lastPackageSet.add(l.substring(1)); + } } } // Load package pubapis - Map tmp = new HashMap<>(); - StringBuffer lastPublicApi = null; + List lastPublicApi = new LinkedList<>(); for (;;) { String l = in.readLine(); if (l == null) { @@ -297,18 +328,12 @@ } if (l.length() > 1 && l.charAt(0) == '+') { String pkg = l.substring(1); - lastPublicApi = new StringBuffer(); - tmp.put(pkg, lastPublicApi); + lastPublicApi = new LinkedList<>(); + rc.packagePublicApis.put(pkg, lastPublicApi); } else if (l.length() > 1 && lastPublicApi != null) { - lastPublicApi.append(l.substring(1)); - lastPublicApi.append("\n"); + lastPublicApi.add(l.substring(1)); } } - for (String p : tmp.keySet()) { - //assert (packagePublicApis.get(p) == null); - String api = tmp.get(p).toString(); - rc.packagePubapis.put(p, api); - } // Now reading the max memory possible. for (;;) { String l = in.readLine(); @@ -334,6 +359,8 @@ rc.setReturnCode(Integer.parseInt(l)); rc.stdout = stdout.toString(); rc.stderr = stderr.toString(); + System.out.print(rc.stdout); + System.err.print(rc.stderr); } catch (Exception e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw));