Do not include Prolog Cafe compiler in daemon classpath

Now that Prolog Cafe is broken up into a runtime and compiler, omit
the compiler from the daemon's classpath.  This saves on startup time
as nearly 3 MiB of JARs no longer need to be unpacked.

Change-Id: Icc4c98264f638dd795887cd607bcc83da6d3ce47
This commit is contained in:
Shawn Pearce
2015-03-13 22:34:14 -07:00
parent 36f51e613d
commit 245e87af04

View File

@@ -88,11 +88,15 @@ public final class GerritLauncher {
// Run the application class // Run the application class
// //
final ClassLoader cl = libClassLoader(); final ClassLoader cl = libClassLoader(isProlog(programClassName(argv[0])));
Thread.currentThread().setContextClassLoader(cl); Thread.currentThread().setContextClassLoader(cl);
return invokeProgram(cl, argv); return invokeProgram(cl, argv);
} }
private static boolean isProlog(String cn) {
return "PrologShell".equals(cn) || "Rulec".equals(cn);
}
private static String getVersion(final File me) { private static String getVersion(final File me) {
if (me == null) { if (me == null) {
return ""; return "";
@@ -122,20 +126,7 @@ public final class GerritLauncher {
Class<?> clazz; Class<?> clazz;
try { try {
try { try {
String cn = name; String cn = programClassName(name);
if (cn.equals(cn.toLowerCase())) {
StringBuilder buf = new StringBuilder();
buf.append(Character.toUpperCase(cn.charAt(0)));
for (int i = 1; i < cn.length(); i++) {
if (cn.charAt(i) == '-' && i + 1 < cn.length()) {
i++;
buf.append(Character.toUpperCase(cn.charAt(i)));
} else {
buf.append(cn.charAt(i));
}
}
cn = buf.toString();
}
clazz = Class.forName(pkg + "." + cn, true, loader); clazz = Class.forName(pkg + "." + cn, true, loader);
} catch (ClassNotFoundException cnfe) { } catch (ClassNotFoundException cnfe) {
if (name.equals(name.toLowerCase())) { if (name.equals(name.toLowerCase())) {
@@ -181,7 +172,25 @@ public final class GerritLauncher {
} }
} }
private static ClassLoader libClassLoader() throws IOException { private static String programClassName(String cn) {
if (cn.equals(cn.toLowerCase())) {
StringBuilder buf = new StringBuilder();
buf.append(Character.toUpperCase(cn.charAt(0)));
for (int i = 1; i < cn.length(); i++) {
if (cn.charAt(i) == '-' && i + 1 < cn.length()) {
i++;
buf.append(Character.toUpperCase(cn.charAt(i)));
} else {
buf.append(cn.charAt(i));
}
}
return buf.toString();
}
return cn;
}
private static ClassLoader libClassLoader(boolean prologCompiler)
throws IOException {
final File path; final File path;
try { try {
path = getDistributionArchive(); path = getDistributionArchive();
@@ -201,12 +210,18 @@ public final class GerritLauncher {
final ZipEntry ze = e.nextElement(); final ZipEntry ze = e.nextElement();
if (ze.isDirectory()) { if (ze.isDirectory()) {
continue; continue;
} else if (ze.getName().startsWith("WEB-INF/lib/")) { }
String name = ze.getName();
if (name.startsWith("WEB-INF/lib/")) {
extractJar(zf, ze, jars); extractJar(zf, ze, jars);
} else if (ze.getName().startsWith("WEB-INF/pgm-lib/")) { } else if (name.startsWith("WEB-INF/pgm-lib/")) {
// Some Prolog tools are restricted.
if (prologCompiler || !name.startsWith("WEB-INF/pgm-lib/prolog-")) {
extractJar(zf, ze, jars); extractJar(zf, ze, jars);
} }
} }
}
} finally { } finally {
zf.close(); zf.close();
} }