|
From: <ka...@us...> - 2011-06-12 21:22:57
|
Revision: 3545
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3545&view=rev
Author: kappa1
Date: 2011-06-12 21:22:50 +0000 (Sun, 12 Jun 2011)
Log Message:
-----------
AppletLoader: fix some comments, code clean up and refactoring
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-06-09 22:27:53 UTC (rev 3544)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-06-12 21:22:50 UTC (rev 3545)
@@ -766,13 +766,15 @@
}
/**
- * 4 steps
+ * 7 steps
*
- * 1) check version of applet and decide whether to download jars
+ * 1) check applet cache and decide whether to download jars
* 2) download the jars
- * 3) extract natives
- * 4) add to jars to class path
- * 5) switch applets
+ * 3) extract native files
+ * 4) validate jars for any corruption
+ * 5) save applet cache information
+ * 6) add jars to class path
+ * 7) switch to loaded applet
*/
public void run() {
setState(STATE_CHECKING_CACHE);
@@ -785,23 +787,9 @@
// parse the urls for the jars into the url list
loadJarURLs();
- // get path where applet will be stored
- String path = AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
- public String run() throws Exception {
+ // get path where applet files will be stored
+ String path = getCacheDirectory();
- // we append the code base to avoid naming collisions with al_title
- String codebase = "";
- if(prependHost) {
- codebase = getCodeBase().getHost();
- if(codebase == null || codebase.length() == 0) {
- codebase = "localhost";
- }
- codebase += File.separator;
- }
- return getCacheDir() + File.separator + codebase + getParameter("al_title") + File.separator;
- }
- });
-
File dir = new File(path);
// create directory
@@ -818,24 +806,10 @@
String version = getParameter("al_version");
float latestVersion = 0;
- // if applet version specifed, check if you have latest version of applet
+ // if applet version specifed, compare with version in the cache
if (version != null) {
-
latestVersion = Float.parseFloat(version);
-
- // if version file exists
- if (versionFile.exists()) {
- // compare to new version
- if (latestVersion == readFloatFile(versionFile)) {
- versionAvailable = true;
- percentage = 90;
-
- if(debugMode) {
- System.out.println("Loading Cached Applet Version " + latestVersion);
- }
- debug_sleep(2000);
- }
- }
+ versionAvailable = compareVersion(versionFile, latestVersion);
}
// if jars not available or need updating download them
@@ -902,6 +876,33 @@
}
/**
+ * This method will return true if the version stored in the file
+ * matches the supplied float version.
+ *
+ * @param versionFile - location to file containing version information
+ * @param version - float version that needs to be compared
+ * @return returns true if the version in file matches specified version
+ */
+ protected boolean compareVersion(File versionFile, float version) {
+ // if version file exists
+ if (versionFile.exists()) {
+ // compare to version with file
+ if (version == readFloatFile(versionFile)) {
+ percentage = 90; // not need to download cache files again
+
+ if(debugMode) {
+ System.out.println("Loading Cached Applet Version " + version);
+ }
+ debug_sleep(2000);
+
+ return true; // version matches file
+ }
+ }
+
+ return false;
+ }
+
+ /**
* Parses the java_arguments list and sets lwjgl specific
* properties accordingly, before the launch.
*/
@@ -926,11 +927,43 @@
}
/**
- * get path to the lwjgl cache directory
+ * This method will return the location of the cache directory. All the
+ * applet files will be downloaded and stored here. A folder will be
+ * created inside the LWJGL cache directory from the al_title parameter.
+ * This folder will also be prepended by the host name of the codebase
+ * to avoid conflict with same named applets on other hosts.
*
+ * @return path to applets cache directory
+ * @throws Exception if access is denied
+ */
+ protected String getCacheDirectory() throws Exception {
+
+ String path = AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
+ public String run() throws Exception {
+
+ // we append the code base to avoid naming collisions with al_title
+ String codebase = "";
+ if(prependHost) {
+ codebase = getCodeBase().getHost();
+ if(codebase == null || codebase.length() == 0) {
+ codebase = "localhost";
+ }
+ codebase += File.separator;
+ }
+ return getLWJGLCacheDir() + File.separator + codebase + getParameter("al_title") + File.separator;
+ }
+ });
+
+ return path;
+ }
+
+ /**
+ * Get path to the lwjgl cache directory. This location will be where
+ * the OS keeps temporary files.
+ *
* @return path to the lwjgl cache directory
*/
- protected String getCacheDir() {
+ protected String getLWJGLCacheDir() {
String cacheDir = System.getProperty("deployment.user.cachedir");
if (cacheDir == null || System.getProperty("os.name").startsWith("Win")) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-06-12 23:51:50
|
Revision: 3546
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3546&view=rev
Author: kappa1
Date: 2011-06-12 23:51:44 +0000 (Sun, 12 Jun 2011)
Log Message:
-----------
AppletLoader: fix problem with file extension trimming code, added warning when lzma support is missing 'lzma.jar' and lzma files are being loaded.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-06-12 21:22:50 UTC (rev 3545)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-06-12 23:51:44 UTC (rev 3546)
@@ -664,11 +664,13 @@
*/
protected String trimExtensionByCapabilities(String file) {
if (!pack200Supported) {
- file = replaceLast(file, ".pack", "");
+ file = file.replace(".pack", "");
}
if (!lzmaSupported) {
- file = replaceLast(file, ".lzma", "");
+ System.out.println("'lzma.jar' required for LZMA support!");
+ System.out.println("trying files without the lzma extension...");
+ file = file.replace(".lzma", "");
}
return file;
}
@@ -766,7 +768,7 @@
}
/**
- * 7 steps
+ * 8 steps
*
* 1) check applet cache and decide whether to download jars
* 2) download the jars
@@ -774,7 +776,8 @@
* 4) validate jars for any corruption
* 5) save applet cache information
* 6) add jars to class path
- * 7) switch to loaded applet
+ * 7) set any lwjgl properties
+ * 8) switch to loaded applet
*/
public void run() {
setState(STATE_CHECKING_CACHE);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-06-15 21:16:05
|
Revision: 3547
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3547&view=rev
Author: kappa1
Date: 2011-06-15 21:15:58 +0000 (Wed, 15 Jun 2011)
Log Message:
-----------
AppletLoader: validate certificate for native files before attempting to extract them.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-06-12 23:51:44 UTC (rev 3546)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-06-15 21:15:58 UTC (rev 3547)
@@ -1662,6 +1662,9 @@
InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName()));
OutputStream out = new FileOutputStream(path + "natives" + File.separator + entry.getName());
+ // validate if the certificate for native file is correct before extracting
+ validateCertificateChain(certificate, entry.getCertificates());
+
int bufferSize;
byte buffer[] = new byte[65536];
@@ -1675,9 +1678,6 @@
subtaskMessage = "Extracting: " + entry.getName() + " " + ((currentSizeExtract * 100) / totalSizeExtract) + "%";
}
- // validate if the certificate for native file is correct
- validateCertificateChain(certificate, entry.getCertificates());
-
in.close();
out.close();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-06-26 02:19:00
|
Revision: 3553
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3553&view=rev
Author: kappa1
Date: 2011-06-26 02:18:53 +0000 (Sun, 26 Jun 2011)
Log Message:
-----------
AppletLoader: revert native file certificate validation to after extraction as it was failing if done before.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-06-26 01:42:34 UTC (rev 3552)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-06-26 02:18:53 UTC (rev 3553)
@@ -1662,9 +1662,6 @@
InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName()));
OutputStream out = new FileOutputStream(path + "natives" + File.separator + entry.getName());
- // validate if the certificate for native file is correct before extracting
- validateCertificateChain(certificate, entry.getCertificates());
-
int bufferSize;
byte buffer[] = new byte[65536];
@@ -1680,6 +1677,9 @@
in.close();
out.close();
+
+ // validate if the certificate for native file
+ validateCertificateChain(certificate, entry.getCertificates());
}
subtaskMessage = "";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-08-29 00:40:37
|
Revision: 3623
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3623&view=rev
Author: kappa1
Date: 2011-08-29 00:40:28 +0000 (Mon, 29 Aug 2011)
Log Message:
-----------
AppletLoader: implement al_min_jre parameter, various small refactoring, update comments and javadoc.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-08-27 22:21:13 UTC (rev 3622)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-08-29 00:40:28 UTC (rev 3623)
@@ -98,7 +98,7 @@
* The following applet parameters are required:
* <ul>
* <li>al_main - [String] Full package and class the applet to instantiate and display when loaded.</li>
- * <li>al_jars - [String] Comma seperated list of jars to download.</li>
+ * <li>al_jars - [String] Comma separated list of jars to download.</li>
* <p>
* <li>al_windows - [String] Jar containing native files for windows.</li>
* <li>al_linux - [String] Jar containing native files for linux.</li>
@@ -110,19 +110,21 @@
* <p>
* Additionally the following parameters can be supplied to tweak the behaviour of the AppletLoader.
* <ul>
+ * <li>al_cache - [boolean] Whether to use cache system. <i>Default: true</i>.</li>
* <li>al_version - [int or float] Version of deployment. If this is specified, the jars will be cached and
* reused if the version matches. If version doesn't match all of the files are reloaded.</li>
- * <li>al_cache - [boolean] Whether to use cache system. <i>Default: true</i>.</li>
+ *
* <li>al_debug - [boolean] Whether to enable debug mode. <i>Default: false</i>.</li>
- * <li>al_prepend_host - [boolean] Whether to limit caching to this domain, disable if your applet is hosted on multple domains and needs to share the cache. <i>Default: true</i>.</li>
+ * <li>al_min_jre - [String] Specify the minimum jre version that the applet requires, should be in format like 1.6.0_24 or a subset like 1.6 <i>Default: 1.5</i>.</li>
+ * <li>al_prepend_host - [boolean] Whether to limit caching to this domain, disable if your applet is hosted on multiple domains and needs to share the cache. <i>Default: true</i>.</li>
* <p>
* <li>al_windows64 - [String] If specified it will be used instead of al_windows on 64bit windows systems.</li>
- * <li>al_windows32 - [String] If specifed it will be used instead of al_windows on 32bit windows systems.</li>
- * <li>al_linux64 - [String] If specifed it will be used instead of al_linux on 64bit linux systems.</li>
- * <li>al_linux32 - [String] If specifed it will be used instead of al_linux on 32bit linux systems.</li>
- * <li>al_mac32 - [String] If specifed it will be used instead of al_mac on 64bit mac systems.</li>
- * <li>al_mac64 - [String] If specifed it will be used instead of al_mac on 32bit mac systems.</li>
- * <li>al_macppc - [String] If specifed it will be used instead of al_mac on PPC mac systems.</li>
+ * <li>al_windows32 - [String] If specified it will be used instead of al_windows on 32bit windows systems.</li>
+ * <li>al_linux64 - [String] If specified it will be used instead of al_linux on 64bit linux systems.</li>
+ * <li>al_linux32 - [String] If specified it will be used instead of al_linux on 32bit linux systems.</li>
+ * <li>al_mac32 - [String] If specified it will be used instead of al_mac on 64bit mac systems.</li>
+ * <li>al_mac64 - [String] If specified it will be used instead of al_mac on 32bit mac systems.</li>
+ * <li>al_macppc - [String] If specified it will be used instead of al_mac on PPC mac systems.</li>
* <p>
* <li>boxbgcolor - [String] any String AWT color ("red", "blue", etc), RGB (0-255) or hex formated color (#RRGGBB) to use as background. <i>Default: #ffffff</i>.</li>
* <li>boxfgcolor - [String] any String AWT color ("red", "blue", etc), RGB (0-255) or hex formated color (#RRGGBB) to use as foreground. <i>Default: #000000</i>.</li>
@@ -144,7 +146,6 @@
* <li>Bobjob</li>
* <li>Dashiva</li>
* <li>Dr_evil</li>
- * <li>Elias Naur</li>
* <li>Kevin Glass</li>
* <li>Matthias Mann</li>
* <li>Mickelukas</li>
@@ -160,36 +161,39 @@
/** initializing */
public static final int STATE_INIT = 1;
+
+ /** checking version of jre */
+ public static final int STATE_CHECK_JRE_VERSION = 2;
/** determining which packages that are required */
- public static final int STATE_DETERMINING_PACKAGES = 2;
+ public static final int STATE_DETERMINING_PACKAGES = 3;
/** checking for already downloaded files */
- public static final int STATE_CHECKING_CACHE = 3;
+ public static final int STATE_CHECKING_CACHE = 4;
/** downloading packages */
- public static final int STATE_DOWNLOADING = 4;
+ public static final int STATE_DOWNLOADING = 5;
/** extracting packages */
- public static final int STATE_EXTRACTING_PACKAGES = 5;
+ public static final int STATE_EXTRACTING_PACKAGES = 6;
/** validating packages */
- public static final int STATE_VALIDATING_PACKAGES = 6;
+ public static final int STATE_VALIDATING_PACKAGES = 7;
/** updating the classpath */
- public static final int STATE_UPDATING_CLASSPATH = 7;
+ public static final int STATE_UPDATING_CLASSPATH = 8;
/** switching to real applet */
- public static final int STATE_SWITCHING_APPLET = 8;
+ public static final int STATE_SWITCHING_APPLET = 9;
/** initializing real applet */
- public static final int STATE_INITIALIZE_REAL_APPLET = 9;
+ public static final int STATE_INITIALIZE_REAL_APPLET = 10;
/** stating real applet */
- public static final int STATE_START_REAL_APPLET = 10;
+ public static final int STATE_START_REAL_APPLET = 11;
/** done */
- public static final int STATE_DONE = 11;
+ public static final int STATE_DONE = 12;
/** used to calculate length of progress bar */
protected int percentage;
@@ -239,9 +243,6 @@
/** applet to load after all downloads are complete */
protected Applet lwjglApplet;
- /** whether a fatal error occured */
- protected boolean fatalError;
-
/** whether we're running in debug mode */
protected boolean debugMode;
@@ -280,19 +281,33 @@
/** messages to be passed via liveconnect in headless mode */
protected String[] headlessMessage;
+
+ /** whether a fatal error occurred */
+ protected boolean fatalError;
+
+ /** whether a certificate refused error occurred */
+ protected boolean certificateRefused;
+
+ /** whether the minimum required JRE version is not found */
+ protected boolean minimumJreNotFound;
/** generic error message to display on error */
protected String[] genericErrorMessage = { "An error occured while loading the applet.",
"Please contact support to resolve this issue.",
"<placeholder for error message>"};
- /** whether a certificate refused error occured */
- protected boolean certificateRefused;
-
- /** error message to display if user refuses to accept certicate*/
+ /** error message to display if user refuses to accept certificate*/
protected String[] certificateRefusedMessage = { "Permissions for Applet Refused.",
"Please accept the permissions dialog to allow",
"the applet to continue the loading process."};
+
+ /** error message to display if minimum JRE version is not met */
+ protected String[] minimumJREMessage = { "Your version of Java is out of date.",
+ "Visit java.com to get the latest version.",
+ "Java <al_min_jre> or greater is required."};
+
+ /** fatal error message to display */
+ protected String[] errorMessage;
/** have natives been loaded by another instance of this applet */
protected static boolean natives_loaded;
@@ -439,6 +454,7 @@
* This method will return the current progress of the AppletLoader
* as a value from 0-100. In the case of a fatal error it will
* return -1. If the certificate is refused it will return -2.
+ * If the minimum jre requirement is not met will return -3.
*
* When method returns 100 the AppletLoader will sleep until the
* method is called again. When called again it will switch to the
@@ -447,8 +463,10 @@
*/
public int getStatus() {
if (fatalError) {
+ headlessMessage = errorMessage;
+
if (certificateRefused) return -2;
- headlessMessage = (certificateRefused) ? certificateRefusedMessage : genericErrorMessage;
+ if (minimumJreNotFound) return -3;
return -1;
}
@@ -497,6 +515,9 @@
cleanUp(); // clean up resources
return;
}
+
+ // no drawing in headless mode
+ if (headless) return;
// create offscreen if missing
if (offscreen == null) {
@@ -529,12 +550,9 @@
og.fillRect(0, 0, offscreen.getWidth(null), offscreen.getHeight(null));
og.setColor(fgColor);
- String message = getDescriptionForState();
-
+
// if we had a failure of some sort, notify the user
if (fatalError) {
- String[] errorMessage = (certificateRefused) ? certificateRefusedMessage : genericErrorMessage;
-
for(int i=0; i<errorMessage.length; i++) {
if(errorMessage[i] != null) {
int messageX = (offscreen.getWidth(null) - fm.stringWidth(errorMessage[i])) / 2;
@@ -543,7 +561,7 @@
og.drawString(errorMessage[i], messageX, messageY + i*fm.getHeight());
}
}
- } else if (!headless) {
+ } else {
og.setColor(fgColor);
painting = true;
@@ -558,6 +576,8 @@
}
// draw message
+ String message = getDescriptionForState();
+
int messageX = (offscreen.getWidth(null) - fm.stringWidth(message)) / 2;
int messageY = y + 20;
@@ -572,7 +592,7 @@
og.drawString(subtaskMessage, messageX, messageY+20);
}
- // draw loading bar, clipping it depending on percentage done
+ // draw loading progress bar, clipping it depending on percentage done
if (progressbar != null) {
int barSize = (progressbar.getWidth(null) * percentage) / 100;
og.clipRect(x-progressbar.getWidth(null)/2, 0, barSize, offscreen.getHeight(null));
@@ -636,6 +656,8 @@
switch (state) {
case STATE_INIT:
return "Initializing loader";
+ case STATE_CHECK_JRE_VERSION:
+ return "Checking version";
case STATE_DETERMINING_PACKAGES:
return "Determining packages to load";
case STATE_CHECKING_CACHE:
@@ -772,24 +794,30 @@
}
/**
- * 8 steps
+ * 9 steps
*
- * 1) check applet cache and decide whether to download jars
- * 2) download the jars
- * 3) extract native files
- * 4) validate jars for any corruption
- * 5) save applet cache information
- * 6) add jars to class path
- * 7) set any lwjgl properties
- * 8) switch to loaded applet
+ * 1) check jre version meets minimum requirements
+ * 2) check applet cache and decide which jars to download
+ * 3) download the jars
+ * 4) extract native files
+ * 5) validate jars for any corruption
+ * 6) save applet cache information
+ * 7) add jars to class path
+ * 8) set any lwjgl properties
+ * 9) switch to loaded applet
*/
public void run() {
- setState(STATE_CHECKING_CACHE);
+ percentage = 5;
- percentage = 5;
-
try {
debug_sleep(2000);
+
+ // check JRE version meets minimum requirements
+ if (!isMinJREVersionAvailable()) {
+ minimumJreNotFound = true;
+ fatalErrorOccured("Java " + getStringParameter("al_min_jre", "1.5") + " or greater is required.", null);
+ return;
+ }
// parse the urls for the jars into the url list
loadJarURLs();
@@ -809,12 +837,14 @@
// if specified applet version already available don't download anything
boolean versionAvailable = false;
- // version string of applet
+ // version of applet
String version = getParameter("al_version");
-
+ float latestVersion = 0;
+
// if applet version specifed, compare with version in the cache
if (version != null) {
- versionAvailable = compareVersion(versionFile, version.toLowerCase());
+ latestVersion = Float.parseFloat(version);
+ versionAvailable = compareVersion(versionFile, latestVersion);
}
// if jars not available or need updating download them
@@ -837,7 +867,7 @@
// save version information once jars downloaded successfully
if (version != null) {
percentage = 90;
- writeObjectFile(versionFile, version.toLowerCase());
+ writeObjectFile(versionFile, latestVersion);
}
// save file names with last modified info once downloaded successfully
@@ -871,8 +901,8 @@
});
} catch (AccessControlException ace) {
+ certificateRefused = true;
fatalErrorOccured(ace.getMessage(), ace);
- certificateRefused = true;
} catch (Exception e) {
fatalErrorOccured("This occurred while '" + getDescriptionForState() + "'", e);
} finally {
@@ -881,24 +911,69 @@
}
/**
+ * When this method is supplied with a JRE version it will compare it to the
+ * current JRE version.
+ *
+ * minimum requried JRE version is set using al_min_jre parameter, if not
+ * this is not set then the value will default to version 1.5
+ *
+ * The minimumVersion should follow a structure such as x.x.x_x
+ * Example values would include 1.6.0_10 or a subset like 1.6.0 or 1.6
+ *
+ * @return returns true if the available version is greater or equal to the
+ * minimum version required
+ *
+ * @throws Exception a NumberFormatException is thrown if the string is not valid
+ */
+ public boolean isMinJREVersionAvailable() throws Exception {
+ setState(STATE_CHECK_JRE_VERSION);
+
+ String minimumVersion = getStringParameter("al_min_jre", "1.5");
+ String javaVersion = System.getProperty("java.version");
+
+ // split version string into a string arrays
+ String[] jvmVersionData = javaVersion.split("[_\\.]");
+ String[] minVersionData = minimumVersion.split("[_\\.]");
+
+ int maxLength = Math.max(jvmVersionData.length, minVersionData.length);
+
+ // convert string arrays into int arrays
+ int[] jvmVersion = new int[maxLength];
+ int[] minVersion = new int[maxLength];
+
+ for (int i = 0; i < jvmVersionData.length; i++) {
+ jvmVersion[i] = Integer.parseInt(jvmVersionData[i]);
+ }
+
+ for (int i = 0; i < minVersionData.length; i++) {
+ minVersion[i] = Integer.parseInt(minVersionData[i]);
+ }
+
+ // compare versions
+ for (int i = 0; i < maxLength; i++) {
+ if (jvmVersion[i] < minVersion[i]) return false; // minVersion is greater then jvmVersion
+ }
+
+ return true;
+ }
+
+ /**
* This method will return true if the version stored in the file
- * matches the supplied String version.
+ * matches the supplied float version.
*
* @param versionFile - location to file containing version information
- * @param version - String version that needs to be compared
+ * @param version - float version that needs to be compared
* @return returns true if the version in file matches specified version
*/
- protected boolean compareVersion(File versionFile, String version) {
+ protected boolean compareVersion(File versionFile, float version) {
// if version file exists
if (versionFile.exists()) {
- String s = readStringFile(versionFile);
-
// compare to version with file
- if (s != null && s.equals(version)) {
+ if (version == readFloatFile(versionFile)) {
percentage = 90; // not need to download cache files again
if(debugMode) {
- System.out.println("Loading Cached Applet Version: " + version);
+ System.out.println("Loading Cached Applet Version " + version);
}
debug_sleep(2000);
@@ -981,21 +1056,22 @@
}
/**
- * read String object from File
+ * read float from File
*
* @param file to be read
- * @return the String stored in the file or null if it fails
+ * @return the float stored in the file or 0 if it fails
*/
- protected String readStringFile(File file) {
+ protected float readFloatFile(File file) {
try {
- return (String)readObjectFile(file);
+ Float version = (Float)readObjectFile(file);
+ return version.floatValue();
} catch (Exception e) {
// failed to read version file
e.printStackTrace();
}
- // return null if failed to read file
- return null;
+ // return 0 if failed to read file
+ return 0;
}
/**
@@ -1226,7 +1302,8 @@
* @throws Exception - if fails to get infomation
*/
protected void getJarInfo(File dir) throws Exception {
-
+ setState(STATE_CHECKING_CACHE);
+
filesLastModified = new HashMap<String, Long>();
// store file sizes and mark which files not to download
@@ -1285,7 +1362,6 @@
* @throws Exception if download fails
*/
protected void downloadJars(String path) throws Exception {
-
setState(STATE_DOWNLOADING);
URLConnection urlconnection;
@@ -1980,13 +2056,25 @@
}
/**
- * Sets the state of the loaded and prints some debug information
+ * Sets the error message and print debug information
*
* @param error Error message to print
*/
protected void fatalErrorOccured(String error, Exception e) {
fatalError = true;
- genericErrorMessage[genericErrorMessage.length-1] = error;
+
+ if (minimumJreNotFound) {
+ errorMessage = minimumJREMessage;
+ errorMessage[errorMessage.length-1] = error;
+ }
+ else if (certificateRefused) {
+ errorMessage = certificateRefusedMessage;
+ }
+ else {
+ errorMessage = genericErrorMessage;
+ errorMessage[errorMessage.length-1] = error;
+ }
+
System.out.println(error);
if(e != null) {
System.out.println(e.getMessage());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-08-29 00:55:01
|
Revision: 3624
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3624&view=rev
Author: kappa1
Date: 2011-08-29 00:54:54 +0000 (Mon, 29 Aug 2011)
Log Message:
-----------
AppletLoader: somehow removed patch 3559 with last appletloader patch, readded removed code.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-08-29 00:40:28 UTC (rev 3623)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-08-29 00:54:54 UTC (rev 3624)
@@ -146,6 +146,7 @@
* <li>Bobjob</li>
* <li>Dashiva</li>
* <li>Dr_evil</li>
+ * <li>Elias Naur</li>
* <li>Kevin Glass</li>
* <li>Matthias Mann</li>
* <li>Mickelukas</li>
@@ -837,14 +838,12 @@
// if specified applet version already available don't download anything
boolean versionAvailable = false;
- // version of applet
+ // version string of applet
String version = getParameter("al_version");
- float latestVersion = 0;
// if applet version specifed, compare with version in the cache
if (version != null) {
- latestVersion = Float.parseFloat(version);
- versionAvailable = compareVersion(versionFile, latestVersion);
+ versionAvailable = compareVersion(versionFile, version.toLowerCase());
}
// if jars not available or need updating download them
@@ -867,7 +866,7 @@
// save version information once jars downloaded successfully
if (version != null) {
percentage = 90;
- writeObjectFile(versionFile, latestVersion);
+ writeObjectFile(versionFile, version.toLowerCase());
}
// save file names with last modified info once downloaded successfully
@@ -959,21 +958,23 @@
/**
* This method will return true if the version stored in the file
- * matches the supplied float version.
+ * matches the supplied String version.
*
* @param versionFile - location to file containing version information
- * @param version - float version that needs to be compared
+ * @param version - String version that needs to be compared
* @return returns true if the version in file matches specified version
*/
- protected boolean compareVersion(File versionFile, float version) {
+ protected boolean compareVersion(File versionFile, String version) {
// if version file exists
if (versionFile.exists()) {
+ String s = readStringFile(versionFile);
+
// compare to version with file
- if (version == readFloatFile(versionFile)) {
+ if (s != null && s.equals(version)) {
percentage = 90; // not need to download cache files again
if(debugMode) {
- System.out.println("Loading Cached Applet Version " + version);
+ System.out.println("Loading Cached Applet Version: " + version);
}
debug_sleep(2000);
@@ -1056,22 +1057,21 @@
}
/**
- * read float from File
+ * read String object from File
*
* @param file to be read
- * @return the float stored in the file or 0 if it fails
+ * @return the String stored in the file or null if it fails
*/
- protected float readFloatFile(File file) {
+ protected String readStringFile(File file) {
try {
- Float version = (Float)readObjectFile(file);
- return version.floatValue();
+ return (String)readObjectFile(file);
} catch (Exception e) {
// failed to read version file
e.printStackTrace();
}
- // return 0 if failed to read file
- return 0;
+ // return null if failed to read file
+ return null;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-09-07 18:28:25
|
Revision: 3635
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3635&view=rev
Author: kappa1
Date: 2011-09-07 18:28:19 +0000 (Wed, 07 Sep 2011)
Log Message:
-----------
Minor tweak to appletloader as an attempt to get nightly build server to build natives again.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-09-05 08:44:48 UTC (rev 3634)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-09-07 18:28:19 UTC (rev 3635)
@@ -899,10 +899,8 @@
}
});
- } catch (AccessControlException ace) {
- certificateRefused = true;
- fatalErrorOccured(ace.getMessage(), ace);
} catch (Exception e) {
+ certificateRefused = e instanceof AccessControlException;
fatalErrorOccured("This occurred while '" + getDescriptionForState() + "'", e);
} finally {
loaderThread = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-10-06 23:05:12
|
Revision: 3652
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3652&view=rev
Author: kappa1
Date: 2011-10-06 23:05:06 +0000 (Thu, 06 Oct 2011)
Log Message:
-----------
AppletLoader: apply fix/workaround for the double security dialogs issue on OS X
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-06 21:11:46 UTC (rev 3651)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-06 23:05:06 UTC (rev 3652)
@@ -65,8 +65,10 @@
import java.net.URLConnection;
import java.security.AccessControlException;
import java.security.AccessController;
+import java.security.AllPermission;
import java.security.CodeSource;
import java.security.PermissionCollection;
+import java.security.Permissions;
import java.security.PrivilegedExceptionAction;
import java.security.SecureClassLoader;
import java.security.cert.Certificate;
@@ -1155,13 +1157,31 @@
file = file.replace("!", "%21");
urls[i] = new URL(file);
}
-
+
+ // get AppletLoader certificates
+ final Certificate[] certs = getCurrentCertificates();
+
+ // detect if we are running on a mac and save result as boolean
+ String osName = System.getProperty("os.name");
+ final boolean isMacOS = (osName.startsWith("Mac") || osName.startsWith("Darwin"));
+
// add downloaded jars to the classpath with required permissions
classLoader = new URLClassLoader(urls) {
protected PermissionCollection getPermissions (CodeSource codesource) {
PermissionCollection perms = null;
try {
+
+ // if mac, apply workaround for the multiple security dialog issue
+ if (isMacOS) {
+ // if certificates match the AppletLoader certificates then don't use SecureClassLoader to get further permissions
+ if (certificatesMatch(certs, codesource.getCertificates())) {
+ perms = new Permissions();
+ perms.add(new AllPermission());
+ return perms;
+ }
+ }
+
// getPermissions from original classloader is important as it checks for signed jars and shows any security dialogs needed
Method method = SecureClassLoader.class.getDeclaredMethod("getPermissions", new Class[] { CodeSource.class });
method.setAccessible(true);
@@ -1666,18 +1686,8 @@
nativeFolder.mkdir();
}
- // get the current certificate to compare against native files
- Certificate[] certificate = AppletLoader.class.getProtectionDomain().getCodeSource().getCertificates();
-
- // workaround for bug where cached applet loader does not have certificates!?
- if (certificate == null) {
- URL location = AppletLoader.class.getProtectionDomain().getCodeSource().getLocation();
-
- // manually load the certificate
- JarURLConnection jurl = (JarURLConnection) (new URL("jar:" + location.toString() + "!/org/lwjgl/util/applet/AppletLoader.class").openConnection());
- jurl.setDefaultUseCaches(true);
- certificate = jurl.getCertificates();
- }
+ // get the current AppletLoader certificates to compare against certificates of the native files
+ Certificate[] certificate = getCurrentCertificates();
for (int i = urlList.length - nativeJarCount; i < urlList.length; i++) {
@@ -1755,8 +1765,10 @@
in.close();
out.close();
- // validate if the certificate for native file
- validateCertificateChain(certificate, entry.getCertificates());
+ // validate the certificate for the native file being extracted
+ if (!certificatesMatch(certificate, entry.getCertificates())) {
+ throw new Exception("The certificate(s) in " + nativeJar + " do not match the AppletLoader!");
+ }
}
subtaskMessage = "";
@@ -1770,26 +1782,54 @@
}
/**
- * Validates the certificate chain for a single file
+ * Compare two certificate chains to see if they match
*
- * @param ownCerts Chain of certificates to check against
- * @param native_certs Chain of certificates to check
+ * @param cert1 first chain of certificates
+ * @param cert2 second chain of certificates
+ *
+ * @return true if the certificate chains are the same
*/
- protected static void validateCertificateChain(Certificate[] ownCerts, Certificate[] native_certs) throws Exception {
- if (native_certs == null)
- throw new Exception("Unable to validate certificate chain. Native entry did not have a certificate chain at all");
-
- if (ownCerts.length != native_certs.length)
- throw new Exception("Unable to validate certificate chain. Chain differs in length [" + ownCerts.length + " vs " + native_certs.length + "]");
-
- for (int i = 0; i < ownCerts.length; i++) {
- if (!ownCerts[i].equals(native_certs[i])) {
- throw new Exception("Certificate mismatch: " + ownCerts[i] + " != " + native_certs[i]);
+ protected static boolean certificatesMatch(Certificate[] certs1, Certificate[] certs2) throws Exception {
+ if (certs1 == null || certs2 == null) {
+ return false;
+ }
+
+ if (certs1.length != certs2.length) {
+ return false;
+ }
+
+ for (int i = 0; i < certs1.length; i++) {
+ if (!certs1[i].equals(certs2[i])) {
+ return false;
}
}
+
+ return true;
}
/**
+ * Returns the current certificate chain of the AppletLoader
+ *
+ * @return - certificate chain of AppletLoader
+ */
+ protected static Certificate[] getCurrentCertificates() throws Exception {
+ // get the current certificate to compare against native files
+ Certificate[] certificate = AppletLoader.class.getProtectionDomain().getCodeSource().getCertificates();
+
+ // workaround for bug where cached applet loader does not have certificates!?
+ if (certificate == null) {
+ URL location = AppletLoader.class.getProtectionDomain().getCodeSource().getLocation();
+
+ // manually load the certificate
+ JarURLConnection jurl = (JarURLConnection) (new URL("jar:" + location.toString() + "!/org/lwjgl/util/applet/AppletLoader.class").openConnection());
+ jurl.setDefaultUseCaches(true);
+ certificate = jurl.getCertificates();
+ }
+
+ return certificate;
+ }
+
+ /**
* Check and validate jars which will be loaded into the classloader to make
* sure that they are not corrupt. This ensures corrupt files are never marked
* as successful downloadeds by the cache system.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-10-08 18:33:51
|
Revision: 3653
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3653&view=rev
Author: kappa1
Date: 2011-10-08 18:33:44 +0000 (Sat, 08 Oct 2011)
Log Message:
-----------
AppletLoader: apply arielsan's concurrent HTTP requests patch
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-06 23:05:06 UTC (rev 3652)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-08 18:33:44 UTC (rev 3653)
@@ -74,8 +74,14 @@
import java.security.cert.Certificate;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Queue;
import java.util.StringTokenizer;
import java.util.Vector;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
@@ -199,7 +205,7 @@
public static final int STATE_DONE = 12;
/** used to calculate length of progress bar */
- protected int percentage;
+ protected volatile int percentage;
/** current size of download in bytes */
protected int currentSizeDownload;
@@ -285,6 +291,9 @@
/** messages to be passed via liveconnect in headless mode */
protected String[] headlessMessage;
+ /** threads to use when fetching information of files to be downloaded */
+ protected int concurrentLookupThreads;
+
/** whether a fatal error occurred */
protected boolean fatalError;
@@ -311,7 +320,7 @@
/** fatal error message to display */
protected String[] errorMessage;
-
+
/** have natives been loaded by another instance of this applet */
protected static boolean natives_loaded;
@@ -329,7 +338,7 @@
return;
}
}
-
+
// whether to use cache system
cacheEnabled = getBooleanParameter("al_cache", true);
@@ -342,6 +351,9 @@
// whether to run in headless mode
headless = getBooleanParameter("al_headless", false);
+ // obtain the number of concurrent lookup threads to use
+ concurrentLookupThreads = getIntParameter("al_lookup_threads", 1); // defaults to 1
+
// get colors of applet
bgColor = getColor("boxbgcolor", Color.white);
setBackground(bgColor);
@@ -1327,8 +1339,6 @@
// store file sizes and mark which files not to download
fileSizes = new int[urlList.length];
- URLConnection urlconnection;
-
File timestampsFile = new File(dir, "timestamps");
// if timestamps file exists, load it
@@ -1337,39 +1347,76 @@
}
// calculate total size of jars to download
- for (int i = 0; i < urlList.length; i++) {
- urlconnection = urlList[i].openConnection();
- urlconnection.setDefaultUseCaches(false);
- if (urlconnection instanceof HttpURLConnection) {
- ((HttpURLConnection) urlconnection).setRequestMethod("HEAD");
- }
+
+ ExecutorService executorService = Executors.newFixedThreadPool(concurrentLookupThreads);
+ Queue<Future> requests = new LinkedList<Future>();
+
+ // create unique object to sync code in requests
+ final Object sync = new Integer(1);
+
+ for (int j = 0; j < urlList.length; j++) {
+ final int i = j;
+
+ Future request = executorService.submit(new Runnable() {
+
+ public void run() {
+
+ try {
+
+ URLConnection urlconnection = urlList[i].openConnection();
+ urlconnection.setDefaultUseCaches(false);
+ if (urlconnection instanceof HttpURLConnection) {
+ ((HttpURLConnection) urlconnection).setRequestMethod("HEAD");
+ }
+
+ fileSizes[i] = urlconnection.getContentLength();
- fileSizes[i] = urlconnection.getContentLength();
+ long lastModified = urlconnection.getLastModified();
+ String fileName = getFileName(urlList[i]);
- long lastModified = urlconnection.getLastModified();
- String fileName = getFileName(urlList[i]);
+ if (cacheEnabled && lastModified != 0 && filesLastModified.containsKey(fileName)) {
+ long savedLastModified = filesLastModified.get(fileName);
+ // if lastModifed time is the same, don't redownload
+ if (savedLastModified == lastModified) {
+ fileSizes[i] = -2; // mark it to not redownload
+ }
+ }
+
+ if (fileSizes[i] >= 0) {
+ synchronized (sync) {
+ totalSizeDownload += fileSizes[i];
+ }
+ }
- if (cacheEnabled && lastModified != 0 &&
- filesLastModified.containsKey(fileName)) {
- long savedLastModified = filesLastModified.get(fileName);
-
- // if lastModifed time is the same, don't redownload
- if (savedLastModified == lastModified) {
- fileSizes[i] = -2; // mark it to not redownload
- }
+ // put key and value in the hashmap
+ filesLastModified.put(fileName, lastModified);
+
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to fetch information for " + urlList[i], e);
+ }
+ }});
+
+ requests.add(request);
+ }
+
+ while (!requests.isEmpty()) {
+ Iterator<Future> iterator = requests.iterator();
+ while (iterator.hasNext()) {
+ Future request = iterator.next();
+ if (request.isDone()) {
+ request.get(); // will throw an exception if request thrown an exception.
+ iterator.remove();
+
+ // update progress bar
+ percentage = 5 + (int) (10 * (urlList.length - requests.size()) / (float) urlList.length);
+ }
}
-
- if (fileSizes[i] >= 0) {
- totalSizeDownload += fileSizes[i];
- }
-
- // put key and value in the hashmap
- filesLastModified.put(fileName, lastModified);
-
- // update progress bar
- percentage = 5 + (int)(10 * i/(float)urlList.length);
+
+ Thread.sleep(10);
}
+
+ executorService.shutdown();
}
/**
@@ -2087,11 +2134,25 @@
*/
protected boolean getBooleanParameter(String name, boolean defaultValue) {
String parameter = getParameter(name);
- if(parameter != null) {
+ if (parameter != null) {
return Boolean.parseBoolean(parameter);
}
return defaultValue;
}
+
+ /**
+ * Retrieves the int value for the applet
+ * @param name Name of parameter
+ * @param defaultValue default value to return if no such parameter
+ * @return value of parameter or defaultValue
+ */
+ protected int getIntParameter(String name, int defaultValue) {
+ String parameter = getParameter(name);
+ if (parameter != null) {
+ return Integer.parseInt(parameter);
+ }
+ return defaultValue;
+ }
/**
* Sets the error message and print debug information
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-10-08 20:33:49
|
Revision: 3654
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3654&view=rev
Author: kappa1
Date: 2011-10-08 20:33:43 +0000 (Sat, 08 Oct 2011)
Log Message:
-----------
AppletLoader: add missing JavaDoc for al_lookup_threads, clean up natives if validation on them fails.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-08 18:33:44 UTC (rev 3653)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-08 20:33:43 UTC (rev 3654)
@@ -125,6 +125,7 @@
* <li>al_debug - [boolean] Whether to enable debug mode. <i>Default: false</i>.</li>
* <li>al_min_jre - [String] Specify the minimum jre version that the applet requires, should be in format like 1.6.0_24 or a subset like 1.6 <i>Default: 1.5</i>.</li>
* <li>al_prepend_host - [boolean] Whether to limit caching to this domain, disable if your applet is hosted on multiple domains and needs to share the cache. <i>Default: true</i>.</li>
+ * <li>al_lookup_threads - [int] Specify the number of concurrent threads to use to get file information before downloading. <i>Default: 1</i>.</li>
* <p>
* <li>al_windows64 - [String] If specified it will be used instead of al_windows on 64bit windows systems.</li>
* <li>al_windows32 - [String] If specified it will be used instead of al_windows on 32bit windows systems.</li>
@@ -1814,6 +1815,7 @@
// validate the certificate for the native file being extracted
if (!certificatesMatch(certificate, entry.getCertificates())) {
+ f.delete(); // delete extracted native as its certificates doesn't match
throw new Exception("The certificate(s) in " + nativeJar + " do not match the AppletLoader!");
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-10-12 22:07:42
|
Revision: 3667
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3667&view=rev
Author: kappa1
Date: 2011-10-12 22:07:36 +0000 (Wed, 12 Oct 2011)
Log Message:
-----------
AppletLoader: don't output needless lzma.jar is missing message on console unless a lzma file actually being loaded.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-12 20:17:56 UTC (rev 3666)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-12 22:07:36 UTC (rev 3667)
@@ -709,10 +709,9 @@
file = file.replace(".pack", "");
}
- if (!lzmaSupported) {
- System.out.println("'lzma.jar' required for LZMA support!");
- System.out.println("trying files without the lzma extension...");
+ if (!lzmaSupported && file.endsWith(".lzma")) {
file = file.replace(".lzma", "");
+ System.out.println("LZMA decoder (lzma.jar) not found, trying " + file + " without lzma extension.");
}
return file;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-10-12 22:15:38
|
Revision: 3668
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3668&view=rev
Author: kappa1
Date: 2011-10-12 22:15:32 +0000 (Wed, 12 Oct 2011)
Log Message:
-----------
AppletLoader: provide a more meaningful error message when certificates do not match.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-12 22:07:36 UTC (rev 3667)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-12 22:15:32 UTC (rev 3668)
@@ -1843,11 +1843,13 @@
}
if (certs1.length != certs2.length) {
+ System.out.println("Certificate chain differs in length!");
return false;
}
for (int i = 0; i < certs1.length; i++) {
if (!certs1[i].equals(certs2[i])) {
+ System.out.println("Certificate mismatch found!");
return false;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-10-12 22:31:18
|
Revision: 3669
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3669&view=rev
Author: kappa1
Date: 2011-10-12 22:31:12 +0000 (Wed, 12 Oct 2011)
Log Message:
-----------
AppletLoader: create MediaTracker before requesting image in an attempt to fix a logo loading issue.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-12 22:15:32 UTC (rev 3668)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-12 22:31:12 UTC (rev 3669)
@@ -2001,11 +2001,12 @@
*/
public Image getImage(URL url) {
try {
+ MediaTracker tracker = new MediaTracker(this);
+
Image image = super.getImage(url);
// wait for image to load
- MediaTracker tracker = new MediaTracker(this);
- tracker.addImage(image, 0);
+ tracker.addImage(image, 0);
tracker.waitForAll();
// if no errors return image
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-10-20 10:36:53
|
Revision: 3683
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3683&view=rev
Author: kappa1
Date: 2011-10-20 10:36:42 +0000 (Thu, 20 Oct 2011)
Log Message:
-----------
AppletLoader: minor change to provided more information for some error messages.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-20 07:57:54 UTC (rev 3682)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-10-20 10:36:42 UTC (rev 3683)
@@ -1843,7 +1843,7 @@
}
if (certs1.length != certs2.length) {
- System.out.println("Certificate chain differs in length!");
+ System.out.println("Certificate chain differs in length [" + certs1.length + " vs " + certs2.length + "]!");
return false;
}
@@ -1989,7 +1989,7 @@
}
// show error as image could not be loaded
- fatalErrorOccured("Unable to load logo and progressbar images", null);
+ fatalErrorOccured("Unable to load the logo/progressbar image: " + s, null);
return null;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-11-12 21:31:09
|
Revision: 3694
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3694&view=rev
Author: kappa1
Date: 2011-11-12 21:31:00 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
AppletLoader: minor tweak to show better update message when checking cache files for changes
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-11-12 21:03:48 UTC (rev 3693)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-11-12 21:31:00 UTC (rev 3694)
@@ -180,30 +180,33 @@
/** checking for already downloaded files */
public static final int STATE_CHECKING_CACHE = 4;
+
+ /** checking if any updates are available for cache files */
+ public static final int STATE_CHECKING_FOR_UPDATES = 5;
/** downloading packages */
- public static final int STATE_DOWNLOADING = 5;
+ public static final int STATE_DOWNLOADING = 6;
/** extracting packages */
- public static final int STATE_EXTRACTING_PACKAGES = 6;
+ public static final int STATE_EXTRACTING_PACKAGES = 7;
/** validating packages */
- public static final int STATE_VALIDATING_PACKAGES = 7;
+ public static final int STATE_VALIDATING_PACKAGES = 8;
/** updating the classpath */
- public static final int STATE_UPDATING_CLASSPATH = 8;
+ public static final int STATE_UPDATING_CLASSPATH = 9;
/** switching to real applet */
- public static final int STATE_SWITCHING_APPLET = 9;
+ public static final int STATE_SWITCHING_APPLET = 10;
/** initializing real applet */
- public static final int STATE_INITIALIZE_REAL_APPLET = 10;
+ public static final int STATE_INITIALIZE_REAL_APPLET = 11;
/** stating real applet */
- public static final int STATE_START_REAL_APPLET = 11;
+ public static final int STATE_START_REAL_APPLET = 12;
/** done */
- public static final int STATE_DONE = 12;
+ public static final int STATE_DONE = 13;
/** used to calculate length of progress bar */
protected volatile int percentage;
@@ -678,6 +681,8 @@
return "Determining packages to load";
case STATE_CHECKING_CACHE:
return "Calculating download size";
+ case STATE_CHECKING_FOR_UPDATES:
+ return "Checking for updates";
case STATE_DOWNLOADING:
return "Downloading packages";
case STATE_EXTRACTING_PACKAGES:
@@ -1343,6 +1348,7 @@
// if timestamps file exists, load it
if (timestampsFile.exists()) {
+ setState(STATE_CHECKING_FOR_UPDATES);
filesLastModified = readHashMapFile(timestampsFile);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-11-17 21:41:31
|
Revision: 3702
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3702&view=rev
Author: kappa1
Date: 2011-11-17 21:41:24 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
AppletLoader: fix uncaught null pointer exception
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-11-16 14:36:28 UTC (rev 3701)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-11-17 21:41:24 UTC (rev 3702)
@@ -1128,13 +1128,10 @@
return object;
} catch (Exception e) {
// failed to read file
- e.printStackTrace();
+ throw e;
} finally {
fis.close();
}
-
- // return null if failed to read file
- return null;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-01-17 21:05:23
|
Revision: 3726
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3726&view=rev
Author: kappa1
Date: 2012-01-17 21:05:13 +0000 (Tue, 17 Jan 2012)
Log Message:
-----------
prod nightly server to rebuild LWJGL.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-01-16 22:18:31 UTC (rev 3725)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-01-17 21:05:13 UTC (rev 3726)
@@ -141,7 +141,7 @@
* <li>al_logo - [String Path of of the logo resource to paint while loading.<i>Default: "appletlogo.gif"</i>.</li>
* <li>al_progressbar - [String] Path of the progressbar resource to paint on top of the logo, width clipped by percentage.<i>Default: "appletprogress.gif"</i>.</li>
* <p>
- * <li>lwjgl_arguments - </li> [String] used to pass the hidden LWJGL parameters to LWJGL e.g. ("-Dorg.lwjgl.input.Mouse.allowNegativeMouseCoords=true -Dorg.lwjgl.util.Debug=true").</li>
+ * <li>lwjgl_arguments - </li> [String] used to pass LWJGL parameters to LWJGL e.g. ("-Dorg.lwjgl.input.Mouse.allowNegativeMouseCoords=true -Dorg.lwjgl.util.Debug=true").</li>
* </ul>
* </p>
* @author kappaOne <one...@gm...>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-04-22 22:21:47
|
Revision: 3763
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3763&view=rev
Author: kappa1
Date: 2012-04-22 22:21:41 +0000 (Sun, 22 Apr 2012)
Log Message:
-----------
AppletLoader: add extra urlconnections.setUseCaches(false) as an extra precaution to make sure caching is disabled.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-04-18 16:50:40 UTC (rev 3762)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-04-22 22:21:41 UTC (rev 3763)
@@ -1454,6 +1454,7 @@
debug_sleep(2000);
urlconnection = urlList[i].openConnection();
+ urlconnection.setUseCaches(false);
if (urlconnection instanceof HttpURLConnection) {
urlconnection.setRequestProperty("Cache-Control", "no-cache");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-04-22 22:51:54
|
Revision: 3764
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3764&view=rev
Author: kappa1
Date: 2012-04-22 22:51:47 +0000 (Sun, 22 Apr 2012)
Log Message:
-----------
AppletLoader: add try/finally block to ensure file is closed on exception in the downloadJars(), thx to MatthiasM for pointing it out.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-04-22 22:21:41 UTC (rev 3763)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-04-22 22:51:47 UTC (rev 3764)
@@ -1464,44 +1464,47 @@
String currentFile = getFileName(urlList[i]);
InputStream inputstream = getJarInputStream(currentFile, urlconnection);
FileOutputStream fos = new FileOutputStream(path + currentFile);
-
-
+
+
int bufferSize;
long downloadStartTime = System.currentTimeMillis();
int downloadedAmount = 0;
int fileSize = 0;
String downloadSpeedMessage = "";
-
- while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1) {
- debug_sleep(10);
- fos.write(buffer, 0, bufferSize);
- currentSizeDownload += bufferSize;
- fileSize += bufferSize;
- percentage = initialPercentage + ((currentSizeDownload * 45) / totalSizeDownload);
- subtaskMessage = "Retrieving: " + currentFile + " " + ((currentSizeDownload * 100) / totalSizeDownload) + "%";
-
- downloadedAmount += bufferSize;
- long timeLapse = System.currentTimeMillis() - downloadStartTime;
- // update only if a second or more has passed
- if (timeLapse >= 1000) {
- // get kb/s, nice that bytes/millis is same as kilobytes/seconds
- float downloadSpeed = (float) downloadedAmount / timeLapse;
- // round to two decimal places
- downloadSpeed = ((int)(downloadSpeed*100))/100f;
- // set current speed message
- downloadSpeedMessage = " - " + downloadSpeed + " KB/sec";
- // reset downloaded amount
- downloadedAmount = 0;
- // reset start time
- downloadStartTime = System.currentTimeMillis();
+
+ try {
+ while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1) {
+ debug_sleep(10);
+ fos.write(buffer, 0, bufferSize);
+ currentSizeDownload += bufferSize;
+ fileSize += bufferSize;
+ percentage = initialPercentage + ((currentSizeDownload * 45) / totalSizeDownload);
+ subtaskMessage = "Retrieving: " + currentFile + " " + ((currentSizeDownload * 100) / totalSizeDownload) + "%";
+
+ downloadedAmount += bufferSize;
+ long timeLapse = System.currentTimeMillis() - downloadStartTime;
+ // update only if a second or more has passed
+ if (timeLapse >= 1000) {
+ // get kb/s, nice that bytes/millis is same as kilobytes/seconds
+ float downloadSpeed = (float) downloadedAmount / timeLapse;
+ // round to two decimal places
+ downloadSpeed = ((int)(downloadSpeed*100))/100f;
+ // set current speed message
+ downloadSpeedMessage = " - " + downloadSpeed + " KB/sec";
+ // reset downloaded amount
+ downloadedAmount = 0;
+ // reset start time
+ downloadStartTime = System.currentTimeMillis();
+ }
+
+ subtaskMessage += downloadSpeedMessage;
}
-
- subtaskMessage += downloadSpeedMessage;
+
+ } finally {
+ inputstream.close();
+ fos.close();
}
-
- inputstream.close();
- fos.close();
-
+
// download complete, verify if it was successful
if (urlconnection instanceof HttpURLConnection) {
if (fileSize == fileSizes[i]) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-04-22 23:05:16
|
Revision: 3765
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3765&view=rev
Author: kappa1
Date: 2012-04-22 23:05:10 +0000 (Sun, 22 Apr 2012)
Log Message:
-----------
AppletLoader: set all streams that are open to use try/finally blocks to close the streams
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-04-22 22:51:47 UTC (rev 3764)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-04-22 23:05:10 UTC (rev 3765)
@@ -1143,10 +1143,13 @@
*/
protected void writeObjectFile(File file, Object object) throws Exception {
FileOutputStream fos = new FileOutputStream(file);
- ObjectOutputStream dos = new ObjectOutputStream(fos);
- dos.writeObject(object);
- dos.close();
- fos.close();
+ try {
+ ObjectOutputStream dos = new ObjectOutputStream(fos);
+ dos.writeObject(object);
+ dos.close();
+ } finally {
+ fos.close();
+ }
}
/**
@@ -1602,15 +1605,17 @@
byte [] buffer = new byte [1<<14];
- int ret = inputHandle.read(buffer);
- while (ret >= 1) {
- outputHandle.write(buffer,0,ret);
- ret = inputHandle.read(buffer);
+ try {
+ int ret = inputHandle.read(buffer);
+ while (ret >= 1) {
+ outputHandle.write(buffer,0,ret);
+ ret = inputHandle.read(buffer);
+ }
+ } finally {
+ inputHandle.close();
+ outputHandle.close();
}
- inputHandle.close();
- outputHandle.close();
-
// delete LZMA file, as it is no longer needed
f.delete();
}
@@ -1630,17 +1635,19 @@
OutputStream outputHandle = new FileOutputStream(out);
- byte [] buffer = new byte [1<<14];
-
- int ret = inputHandle.read(buffer);
- while (ret >= 1) {
- outputHandle.write(buffer,0,ret);
- ret = inputHandle.read(buffer);
+ try {
+ byte [] buffer = new byte [1<<14];
+
+ int ret = inputHandle.read(buffer);
+ while (ret >= 1) {
+ outputHandle.write(buffer,0,ret);
+ ret = inputHandle.read(buffer);
+ }
+ } finally {
+ inputHandle.close();
+ outputHandle.close();
}
- inputHandle.close();
- outputHandle.close();
-
// delete GZip file, as it is no longer needed
f.delete();
}
@@ -1655,12 +1662,15 @@
File f = new File(in);
FileOutputStream fostream = new FileOutputStream(out);
JarOutputStream jostream = new JarOutputStream(fostream);
+
+ try {
+ Pack200.Unpacker unpacker = Pack200.newUnpacker();
+ unpacker.unpack(f, jostream);
+ } finally {
+ jostream.close();
+ fostream.close();
+ }
- Pack200.Unpacker unpacker = Pack200.newUnpacker();
- unpacker.unpack(f, jostream);
- jostream.close();
- fostream.close();
-
// delete pack file as its no longer needed
f.delete();
}
@@ -1803,21 +1813,23 @@
InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName()));
OutputStream out = new FileOutputStream(path + "natives" + File.separator + entry.getName());
- int bufferSize;
- byte buffer[] = new byte[65536];
-
- while ((bufferSize = in.read(buffer, 0, buffer.length)) != -1) {
- debug_sleep(10);
- out.write(buffer, 0, bufferSize);
- currentSizeExtract += bufferSize;
-
- // update progress bar
- percentage = 65 + (int)(percentageParts * (jarNum + currentSizeExtract/(float)totalSizeExtract));
- subtaskMessage = "Extracting: " + entry.getName() + " " + ((currentSizeExtract * 100) / totalSizeExtract) + "%";
+ try {
+ int bufferSize;
+ byte buffer[] = new byte[65536];
+
+ while ((bufferSize = in.read(buffer, 0, buffer.length)) != -1) {
+ debug_sleep(10);
+ out.write(buffer, 0, bufferSize);
+ currentSizeExtract += bufferSize;
+
+ // update progress bar
+ percentage = 65 + (int)(percentageParts * (jarNum + currentSizeExtract/(float)totalSizeExtract));
+ subtaskMessage = "Extracting: " + entry.getName() + " " + ((currentSizeExtract * 100) / totalSizeExtract) + "%";
+ }
+ } finally {
+ in.close();
+ out.close();
}
-
- in.close();
- out.close();
// validate the certificate for the native file being extracted
if (!certificatesMatch(certificate, entry.getCertificates())) {
@@ -1881,6 +1893,7 @@
JarURLConnection jurl = (JarURLConnection) (new URL("jar:" + location.toString() + "!/org/lwjgl/util/applet/AppletLoader.class").openConnection());
jurl.setDefaultUseCaches(true);
certificate = jurl.getCertificates();
+ jurl.setDefaultUseCaches(false);
}
return certificate;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-04-26 13:19:29
|
Revision: 3766
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3766&view=rev
Author: kappa1
Date: 2012-04-26 13:19:18 +0000 (Thu, 26 Apr 2012)
Log Message:
-----------
AppletLoader: add further checks to prevent Java default caching
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-04-22 23:05:10 UTC (rev 3765)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-04-26 13:19:18 UTC (rev 3766)
@@ -1460,7 +1460,7 @@
urlconnection.setUseCaches(false);
if (urlconnection instanceof HttpURLConnection) {
- urlconnection.setRequestProperty("Cache-Control", "no-cache");
+ urlconnection.setRequestProperty("Cache-Control", "no-store,max-age=0,no-cache");
urlconnection.connect();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-05-08 19:38:24
|
Revision: 3769
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3769&view=rev
Author: kappa1
Date: 2012-05-08 19:38:17 +0000 (Tue, 08 May 2012)
Log Message:
-----------
AppletLoader: fix to ensure a jar file download is attempted 3 times even if it throws some download exception.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-05-04 17:23:36 UTC (rev 3768)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-05-08 19:38:17 UTC (rev 3769)
@@ -211,11 +211,8 @@
/** used to calculate length of progress bar */
protected volatile int percentage;
- /** current size of download in bytes */
- protected int currentSizeDownload;
-
/** total size of download in bytes */
- protected int totalSizeDownload;
+ protected int totalDownloadSize;
/** current size of extracted in bytes */
protected int currentSizeExtract;
@@ -1391,7 +1388,7 @@
if (fileSizes[i] >= 0) {
synchronized (sync) {
- totalSizeDownload += fileSizes[i];
+ totalDownloadSize += fileSizes[i];
}
}
@@ -1438,6 +1435,7 @@
URLConnection urlconnection;
int initialPercentage = percentage = 15;
+ int amountDownloaded = 0;
// download each jar
byte buffer[] = new byte[65536];
@@ -1449,87 +1447,105 @@
int unsuccessfulAttempts = 0;
int maxUnsuccessfulAttempts = 3;
boolean downloadFile = true;
+
+ String currentFile = getFileName(urlList[i]);
// download the jar a max of 3 times
while(downloadFile) {
downloadFile = false;
debug_sleep(2000);
-
- urlconnection = urlList[i].openConnection();
- urlconnection.setUseCaches(false);
-
- if (urlconnection instanceof HttpURLConnection) {
- urlconnection.setRequestProperty("Cache-Control", "no-store,max-age=0,no-cache");
- urlconnection.connect();
- }
-
- String currentFile = getFileName(urlList[i]);
- InputStream inputstream = getJarInputStream(currentFile, urlconnection);
- FileOutputStream fos = new FileOutputStream(path + currentFile);
-
- int bufferSize;
- long downloadStartTime = System.currentTimeMillis();
- int downloadedAmount = 0;
- int fileSize = 0;
- String downloadSpeedMessage = "";
-
- try {
- while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1) {
- debug_sleep(10);
- fos.write(buffer, 0, bufferSize);
- currentSizeDownload += bufferSize;
- fileSize += bufferSize;
- percentage = initialPercentage + ((currentSizeDownload * 45) / totalSizeDownload);
- subtaskMessage = "Retrieving: " + currentFile + " " + ((currentSizeDownload * 100) / totalSizeDownload) + "%";
+ try {
+ urlconnection = urlList[i].openConnection();
+ urlconnection.setUseCaches(false);
- downloadedAmount += bufferSize;
- long timeLapse = System.currentTimeMillis() - downloadStartTime;
- // update only if a second or more has passed
- if (timeLapse >= 1000) {
- // get kb/s, nice that bytes/millis is same as kilobytes/seconds
- float downloadSpeed = (float) downloadedAmount / timeLapse;
- // round to two decimal places
- downloadSpeed = ((int)(downloadSpeed*100))/100f;
- // set current speed message
- downloadSpeedMessage = " - " + downloadSpeed + " KB/sec";
- // reset downloaded amount
- downloadedAmount = 0;
- // reset start time
- downloadStartTime = System.currentTimeMillis();
+ if (urlconnection instanceof HttpURLConnection) {
+ urlconnection.setRequestProperty("Cache-Control", "no-store,max-age=0,no-cache");
+ urlconnection.connect();
+ }
+
+
+ InputStream inputstream = getJarInputStream(currentFile, urlconnection);
+ FileOutputStream fos = new FileOutputStream(path + currentFile);
+
+
+ int bufferSize;
+ int currentDownload = 0;
+
+ long downloadStartTime = System.currentTimeMillis();
+ int downloadedAmount = 0;
+ String downloadSpeedMessage = "";
+
+ try {
+ while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1) {
+ debug_sleep(10);
+ fos.write(buffer, 0, bufferSize);
+ currentDownload += bufferSize;
+
+ int totalDownloaded = amountDownloaded + currentDownload;
+ percentage = initialPercentage + ((totalDownloaded * 45) / totalDownloadSize);
+ subtaskMessage = "Retrieving: " + currentFile + " " + ((totalDownloaded * 100) / totalDownloadSize) + "%";
+
+ downloadedAmount += bufferSize;
+ long timeLapse = System.currentTimeMillis() - downloadStartTime;
+ // update only if a second or more has passed
+ if (timeLapse >= 1000) {
+ // get kb/s, nice that bytes/millis is same as kilobytes/seconds
+ float downloadSpeed = (float) downloadedAmount / timeLapse;
+ // round to two decimal places
+ downloadSpeed = ((int)(downloadSpeed*100))/100f;
+ // set current speed message
+ downloadSpeedMessage = " - " + downloadSpeed + " KB/sec";
+ // reset downloaded amount
+ downloadedAmount = 0;
+ // reset start time
+ downloadStartTime = System.currentTimeMillis();
+ }
+
+ subtaskMessage += downloadSpeedMessage;
}
-
- subtaskMessage += downloadSpeedMessage;
+
+ } finally {
+ inputstream.close();
+ fos.close();
}
- } finally {
- inputstream.close();
- fos.close();
+ // download complete, verify if it was successful
+ if (urlconnection instanceof HttpURLConnection) {
+ if (currentDownload == fileSizes[i]) {
+ // successful download
+ }
+ else if (fileSizes[i] <= 0 && currentDownload != 0) {
+ // If contentLength for fileSizes[i] <= 0, we don't know if the download
+ // is complete. We're going to guess the download is complete.
+ }
+ else {
+ throw new Exception("size mismatch on download of " + currentFile +
+ " expected " + fileSizes[i] + " got " + currentDownload);
+ }
+ }
+
+ // successful file download, update total amount downloaded
+ amountDownloaded += fileSizes[i];
+
+ } catch (Exception e) {
+ e.printStackTrace(); // output exception to console
+
+ // Failed to download the file
+ unsuccessfulAttempts++;
+
+ // download failed try again
+ if (unsuccessfulAttempts < maxUnsuccessfulAttempts) {
+ downloadFile = true;
+ Thread.sleep(100); // wait a bit before retrying
+ }
+ else {
+ // retry attempts exhasted, download failed
+ throw new Exception("failed to download " + currentFile +
+ " after " + maxUnsuccessfulAttempts + " attempts");
+ }
}
-
- // download complete, verify if it was successful
- if (urlconnection instanceof HttpURLConnection) {
- if (fileSize == fileSizes[i]) {
- // successful download
- }
- else if (fileSizes[i] <= 0) {
- // If contentLength for fileSizes[i] <= 0, we don't know if the download
- // is complete. We're going to guess the download is complete.
- }
- else {
- unsuccessfulAttempts++;
- // download failed try again
- if (unsuccessfulAttempts < maxUnsuccessfulAttempts) {
- downloadFile = true;
- currentSizeDownload -= fileSize; // reset progress bar
- }
- else {
- // retry attempts exhasted, download failed
- throw new Exception("failed to download " + currentFile);
- }
- }
- }
}
}
subtaskMessage = "";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-05-13 13:50:59
|
Revision: 3772
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3772&view=rev
Author: kappa1
Date: 2012-05-13 13:50:52 +0000 (Sun, 13 May 2012)
Log Message:
-----------
AppletLoader: fixed issue with applets on linux with Java 7 where the natives where LWJGL natives were failing to load.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-05-13 12:11:12 UTC (rev 3771)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-05-13 13:50:52 UTC (rev 3772)
@@ -1222,7 +1222,13 @@
// allow non lwjgl native to be found from cache directory
protected String findLibrary (String libname) {
- return path + "natives" + File.separator + System.mapLibraryName(libname);
+ String libPath = path + "natives" + File.separator + System.mapLibraryName(libname);
+
+ if (new File(libPath).exists()) {
+ return libPath;
+ }
+
+ return super.findLibrary(libname);
}
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-09-05 22:37:18
|
Revision: 3796
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3796&view=rev
Author: kappa1
Date: 2012-09-05 22:37:11 +0000 (Wed, 05 Sep 2012)
Log Message:
-----------
AppletLoader: Fix NumberFormatException when parsing version string on an EA or beta JVM, thx to UltraMoogleMan for spotting and reporting
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-09-03 20:44:11 UTC (rev 3795)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2012-09-05 22:37:11 UTC (rev 3796)
@@ -944,6 +944,10 @@
String minimumVersion = getStringParameter("al_min_jre", "1.5");
String javaVersion = System.getProperty("java.version");
+ // remove dash and anything after it (letters) from version string e.g. 1.5.0_01-ea
+ minimumVersion = javaVersion.split("-")[0];
+ javaVersion = minimumVersion.split("-")[0];
+
// split version string into a string arrays
String[] jvmVersionData = javaVersion.split("[_\\.]");
String[] minVersionData = minimumVersion.split("[_\\.]");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|