handle version number parsing for JDK 9 (fixes #5275)

This commit is contained in:
Ben Fry
2017-09-29 23:15:17 -04:00
parent bc4471bf38
commit 5d4a48a814
3 changed files with 41 additions and 46 deletions
+6 -34
View File
@@ -111,45 +111,17 @@ public class PApplet implements PConstants {
static public final String javaVersionName =
System.getProperty("java.version");
// /** Short name of Java version, i.e. 1.8. */
// static public final String javaVersionShort =
// //javaVersionName.substring(0, 3);
// javaVersionName.substring(0, javaVersionName.indexOf(".", 2));
// // can't use this one, it's 1.8.0 and breaks things
// //javaVersionName.substring(0, javaVersionName.indexOf("_"));
static public final int javaPlatform =
PApplet.parseInt(PApplet.split(javaVersionName, '.')[1]);
// static {
// try {
// javaPlatform = PApplet.split(javaVersionName, '.')[1];
// } catch (Exception e) {
// javaPlatform = "8"; // set a default in case
// }
// }
parseInt(match(javaVersionName, "[1-9][0-9]*((\\.0)*\\.[1-9][0-9]*)*")[0]);
/**
* Version of Java that's in use, whether 1.1 or 1.3 or whatever,
* stored as a float.
* <p>
* Note that because this is stored as a float, the values may not be
* <EM>exactly</EM> 1.3 or 1.4. The PDE will make 1.8 or whatever into
* a float automatically, so outside the PDE, make sure you're comparing
* against 1.3f or 1.4f, which will have the same amount of error
* (i.e. 1.40000001). This could just be a double, but since Processing
* only uses floats, it's safer as a float because specifying a double
* (with this narrow case especially) with the preprocessor is awkward.
* <p>
* @deprecated Java 10 is around the corner. Use javaPlatform when you need
* a number for comparisons, i.e. "if (javaPlatform >= 7)".
* Do not use; javaPlatform or javaVersionName are better options.
* For instance, javaPlatform is useful when you need a number for
* comparison, i.e. "if (javaPlatform >= 9)".
* @deprecated
*/
@Deprecated
public static final float javaVersion =
new Float(javaVersionName.substring(0, 3));
// public static final float javaVersion =
// new Float(javaVersionName.substring(0, javaVersionName.indexOf(".", 2))).floatValue();
// // Making this a String in 3.0, in anticipation of Java 10
// public static final String javaVersion = "1." + javaPlatform;
public static final float javaVersion = 1 + javaPlatform / 10f;
/**
* Current platform in use, one of the
+10
View File
@@ -1,5 +1,15 @@
0264 (3.3.7 or 3.4)
_ fix exception due to version parsing in Java 9
_ https://github.com/processing/processing/issues/5275
_ make setting the window icon automatic, based on files in local dirs
X https://github.com/processing/processing/issues/5123
X https://github.com/processing/processing/pull/5202
_ need to make this work behind the scenes instead
_ create icon.png or have an 'icons' folder with multiple sizes
_ Hitting ESC in FX2D app on macOS throws IllegalStateException
_ https://github.com/processing/processing/issues/5249
_ when doing createFont, can we add it to the os fonts available?
+25 -12
View File
@@ -1,21 +1,43 @@
0264 (3.3.7 or 3.4)
jakub
X Fix scrub comments for empty block comment /**/
X https://github.com/processing/processing/pull/5265
X https://github.com/processing/processing/issues/5219
contrib
X detect errors from curved quotation marks
X https://github.com/processing/processing/issues/5133
X https://github.com/processing/processing/pull/5152
high
_ menu bars broken in High Sierra
_ https://github.com/processing/processing/issues/5272
_ fix exception due to version parsing in Java 9
_ https://github.com/processing/processing/issues/5275
_ make setting the window icon automatic, based on files in local dirs
X https://github.com/processing/processing/issues/5123
X https://github.com/processing/processing/pull/5202
_ need to make this work behind the scenes instead
_ create icon.png or have an 'icons' folder with multiple sizes
_ add select/copy to the status bar
_ https://github.com/processing/processing/issues/5271
_ untitled folders are stored in temp folder
_ clean up /tmp folders used during build
_ https://github.com/processing/processing/issues/1896
_ don't let people into the /tmp folder for sketches
o don't use tmp folder for sketches?
_ restrict more things like "show sketch folder"
_ don't allow adding files w/o saving
_ others?
contrib
_ console hiding button?
_ https://github.com/processing/processing/pull/5115
_ make "loadXML(String)" handle "file not found"
_ https://github.com/processing/processing/pull/5144
_ detect errors from curved quotation marks
_ https://github.com/processing/processing/issues/5133
_ https://github.com/processing/processing/pull/5152
_ alternate handling of duplicate library conflicts
_ https://github.com/processing/processing/pull/5126
@@ -50,15 +72,6 @@ _ put the reference (and examples?) into .zip files
_ unzipping the app takes forever
_ see the 'examples' section below
_ untitled folders are stored in temp folder
_ clean up /tmp folders used during build
_ https://github.com/processing/processing/issues/1896
_ don't let people into the /tmp folder for sketches
o don't use tmp folder for sketches?
_ restrict more things like "show sketch folder"
_ don't allow adding files w/o saving
_ others?
_ Could not initialize class com.sun.jna.Native on startup (Windows)
_ https://github.com/processing/processing/issues/4929