diff --git a/core/src/main/java/com/threerings/getdown/data/Application.java b/core/src/main/java/com/threerings/getdown/data/Application.java index db0098d..a5a5f9f 100644 --- a/core/src/main/java/com/threerings/getdown/data/Application.java +++ b/core/src/main/java/com/threerings/getdown/data/Application.java @@ -244,7 +244,7 @@ public class Application */ public Application (EnvConfig envc) { _envc = envc; - _config = getLocalPath(envc.appDir, CONFIG_FILE); + _config = new File(envc.appDir, CONFIG_FILE); } /** @@ -435,7 +435,15 @@ public class Application } /** - * Returns a resource for a zip file containing a Java VM that can be downloaded to use in + * @return directory into which a local VM installation should be unpacked. + */ + public File getJavaLocalDir () + { + return _javaLocalDir; + } + + /** + * @return a resource for a zip file containing a Java VM that can be downloaded to use in * place of the installed VM (in the case where the VM that launched Getdown does not meet the * application's version requirements) or null if no VM is available for this platform. */ @@ -445,7 +453,9 @@ public class Application return null; } - String vmfile = LaunchUtil.LOCAL_JAVA_DIR + ".jar"; + // take extension from java location + String vmfileExt = _javaLocation.substring(_javaLocation.lastIndexOf('.')); + String vmfile = _javaLocalDir.getName() + vmfileExt; try { URL remote = new URL(createVAppBase(_targetVersion), encodePath(_javaLocation)); return new Resource(vmfile, remote, getLocalPath(vmfile), @@ -645,6 +655,9 @@ public class Application _javaLocation = (String)javaloc; } + // used only in conjunction with java_location + _javaLocalDir = getLocalPath(config.getString("java_local_dir", LaunchUtil.LOCAL_JAVA_DIR)); + // determine whether we have any tracking configuration _trackingURL = config.getString("tracking_url"); @@ -788,7 +801,7 @@ public class Application */ public File getLocalPath (String path) { - return getLocalPath(getAppDir(), path); + return new File(getAppDir(), path); } /** @@ -811,8 +824,7 @@ public class Application // if we have an unpacked VM, check the 'release' file for its version Resource vmjar = getJavaVMResource(); if (vmjar != null && vmjar.isMarkedValid()) { - File vmdir = new File(getAppDir(), LaunchUtil.LOCAL_JAVA_DIR); - File relfile = new File(vmdir, "release"); + File relfile = new File(_javaLocalDir, "release"); if (!relfile.exists()) { log.warning("Unpacked JVM missing 'release' file. Assuming valid version."); return true; @@ -930,7 +942,7 @@ public class Application ArrayList args = new ArrayList<>(); // reconstruct the path to the JVM - args.add(LaunchUtil.getJVMPath(getAppDir(), _windebug || optimum)); + args.add(LaunchUtil.getJVMBinaryPath(_javaLocalDir, _windebug || optimum)); // check whether we're using -jar mode or -classpath mode boolean dashJarMode = MANIFEST_CLASS.equals(_class); @@ -1717,11 +1729,6 @@ public class Application } } - protected File getLocalPath (File appdir, String path) - { - return new File(appdir, path); - } - protected final EnvConfig _envc; protected File _config; protected Digest _digest; @@ -1753,6 +1760,7 @@ public class Application protected long _javaMinVersion, _javaMaxVersion; protected boolean _javaExactVersionRequired; protected String _javaLocation; + protected File _javaLocalDir; protected List _codes = new ArrayList<>(); protected List _resources = new ArrayList<>(); @@ -1772,9 +1780,6 @@ public class Application protected List _txtJvmArgs = new ArrayList<>(); - /** If a warning has been issued about not being able to set modtimes. */ - protected boolean _warnedAboutSetLastModified; - /** Locks gettingdown.lock in the app dir. Held the entire time updating is going on.*/ protected FileLock _lock; diff --git a/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java b/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java index 4a9998e..0c33c29 100644 --- a/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java +++ b/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java @@ -19,7 +19,7 @@ import static com.threerings.getdown.Log.log; */ public class LaunchUtil { - /** The directory into which a local VM installation should be unpacked. */ + /** The default directory into which a local VM installation should be unpacked. */ public static final String LOCAL_JAVA_DIR = "java_vm"; /** @@ -32,6 +32,7 @@ public class LaunchUtil * probably getdown-pro.jar or getdown-retro-pro.jar if you are using * the results of the standard build. * @param newVersion the new version to which Getdown will update when it is executed. + * @param javaLocalDir JRE location within appdir, falls back to {@link #LOCAL_JAVA_DIR} in case if null is passed * * @return true if the relaunch succeeded, false if we were unable to relaunch due to being on * Windows 9x where we cannot launch subprocesses without waiting around for them to exit, @@ -45,7 +46,7 @@ public class LaunchUtil * resort to telling the user that it is in a bad way. */ public static boolean updateVersionAndRelaunch ( - File appdir, String getdownJarName, String newVersion) + File appdir, String getdownJarName, String newVersion, String javaLocalDir) throws IOException { // create the file that instructs Getdown to upgrade @@ -61,8 +62,9 @@ public class LaunchUtil } // do the deed - String[] args = new String[] { - getJVMPath(appdir), "-jar", pro.toString(), appdir.getPath() + String[] args = { + getJVMBinaryPath(new File(appdir, StringUtil.isBlank(javaLocalDir) ? LOCAL_JAVA_DIR : javaLocalDir), false), + "-jar", pro.toString(), appdir.getPath() }; log.info("Running " + StringUtil.join(args, "\n ")); try { @@ -75,22 +77,14 @@ public class LaunchUtil } /** - * Reconstructs the path to the JVM used to launch this process. - */ - public static String getJVMPath (File appdir) - { - return getJVMPath(appdir, false); - } - - /** - * Reconstructs the path to the JVM used to launch this process. - * + * @param javaLocalDir JRE location within appdir * @param windebug if true we will use java.exe instead of javaw.exe on Windows. + * @return the path to the JVM binary used to launch this process. */ - public static String getJVMPath (File appdir, boolean windebug) + public static String getJVMBinaryPath(File javaLocalDir, boolean windebug) { // first look in our application directory for an installed VM - String vmpath = checkJVMPath(new File(appdir, LOCAL_JAVA_DIR).getAbsolutePath(), windebug); + String vmpath = checkJVMPath(javaLocalDir.getAbsolutePath(), windebug); // then fall back to the VM in which we're already running if (vmpath == null) { @@ -99,7 +93,7 @@ public class LaunchUtil // then throw up our hands and hope for the best if (vmpath == null) { - log.warning("Unable to find java [appdir=" + appdir + + log.warning("Unable to find java [javaLocalDir=" + javaLocalDir + ", java.home=" + System.getProperty("java.home") + "]!"); vmpath = "java"; } @@ -150,7 +144,7 @@ public class LaunchUtil if (newgd.renameTo(curgd)) { FileUtil.deleteHarder(oldgd); // yay! try { - // copy the moved file back to getdown-dop-new.jar so that we don't end up + // copy the moved file back to newgd so that we don't end up // downloading another copy next time FileUtil.copy(curgd, newgd); } catch (IOException e) { diff --git a/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java b/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java index 99def4f..5ff873c 100644 --- a/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java +++ b/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java @@ -507,13 +507,13 @@ public abstract class Getdown extends Thread vmjar.install(true); // these only run on non-Windows platforms, so we use Unix file separators - String localJavaDir = LaunchUtil.LOCAL_JAVA_DIR + "/"; - FileUtil.makeExecutable(_app.getLocalPath(localJavaDir + "bin/java")); - FileUtil.makeExecutable(_app.getLocalPath(localJavaDir + "lib/jspawnhelper")); - FileUtil.makeExecutable(_app.getLocalPath(localJavaDir + "lib/amd64/jspawnhelper")); + File javaLocalDir = _app.getJavaLocalDir(); + FileUtil.makeExecutable(new File(javaLocalDir, "bin/java")); + FileUtil.makeExecutable(new File(javaLocalDir, "lib/jspawnhelper")); + FileUtil.makeExecutable(new File(javaLocalDir, "lib/amd64/jspawnhelper")); // lastly regenerate the .jsa dump file that helps Java to start up faster - String vmpath = LaunchUtil.getJVMPath(_app.getLocalPath("")); + String vmpath = LaunchUtil.getJVMBinaryPath(javaLocalDir, false); try { log.info("Regenerating classes.jsa for " + vmpath + "..."); Runtime.getRuntime().exec(vmpath + " -Xshare:dump");