Skip to content

Commit b0b2d89

Browse files
committed
handle version number parsing for JDK 9 (fixes #5275)
1 parent ebd5557 commit b0b2d89

3 files changed

Lines changed: 41 additions & 46 deletions

File tree

core/src/processing/core/PApplet.java

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -111,45 +111,17 @@ public class PApplet implements PConstants {
111111
static public final String javaVersionName =
112112
System.getProperty("java.version");
113113

114-
// /** Short name of Java version, i.e. 1.8. */
115-
// static public final String javaVersionShort =
116-
// //javaVersionName.substring(0, 3);
117-
// javaVersionName.substring(0, javaVersionName.indexOf(".", 2));
118-
// // can't use this one, it's 1.8.0 and breaks things
119-
// //javaVersionName.substring(0, javaVersionName.indexOf("_"));
120-
121114
static public final int javaPlatform =
122-
PApplet.parseInt(PApplet.split(javaVersionName, '.')[1]);
123-
// static {
124-
// try {
125-
// javaPlatform = PApplet.split(javaVersionName, '.')[1];
126-
// } catch (Exception e) {
127-
// javaPlatform = "8"; // set a default in case
128-
// }
129-
// }
115+
parseInt(match(javaVersionName, "[1-9][0-9]*((\\.0)*\\.[1-9][0-9]*)*")[0]);
130116

131117
/**
132-
* Version of Java that's in use, whether 1.1 or 1.3 or whatever,
133-
* stored as a float.
134-
* <p>
135-
* Note that because this is stored as a float, the values may not be
136-
* <EM>exactly</EM> 1.3 or 1.4. The PDE will make 1.8 or whatever into
137-
* a float automatically, so outside the PDE, make sure you're comparing
138-
* against 1.3f or 1.4f, which will have the same amount of error
139-
* (i.e. 1.40000001). This could just be a double, but since Processing
140-
* only uses floats, it's safer as a float because specifying a double
141-
* (with this narrow case especially) with the preprocessor is awkward.
142-
* <p>
143-
* @deprecated Java 10 is around the corner. Use javaPlatform when you need
144-
* a number for comparisons, i.e. "if (javaPlatform >= 7)".
118+
* Do not use; javaPlatform or javaVersionName are better options.
119+
* For instance, javaPlatform is useful when you need a number for
120+
* comparison, i.e. "if (javaPlatform >= 9)".
121+
* @deprecated
145122
*/
146123
@Deprecated
147-
public static final float javaVersion =
148-
new Float(javaVersionName.substring(0, 3));
149-
// public static final float javaVersion =
150-
// new Float(javaVersionName.substring(0, javaVersionName.indexOf(".", 2))).floatValue();
151-
// // Making this a String in 3.0, in anticipation of Java 10
152-
// public static final String javaVersion = "1." + javaPlatform;
124+
public static final float javaVersion = 1 + javaPlatform / 10f;
153125

154126
/**
155127
* Current platform in use, one of the

core/todo.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
0264 (3.3.7 or 3.4)
2+
_ fix exception due to version parsing in Java 9
3+
_ https://github.com/processing/processing/issues/5275
24

5+
_ make setting the window icon automatic, based on files in local dirs
6+
X https://github.com/processing/processing/issues/5123
7+
X https://github.com/processing/processing/pull/5202
8+
_ need to make this work behind the scenes instead
9+
_ create icon.png or have an 'icons' folder with multiple sizes
10+
11+
_ Hitting ESC in FX2D app on macOS throws IllegalStateException
12+
_ https://github.com/processing/processing/issues/5249
313

414
_ when doing createFont, can we add it to the os fonts available?
515

todo.txt

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
11
0264 (3.3.7 or 3.4)
22

3+
jakub
4+
X Fix scrub comments for empty block comment /**/
5+
X https://github.com/processing/processing/pull/5265
6+
X https://github.com/processing/processing/issues/5219
7+
8+
contrib
9+
X detect errors from curved quotation marks
10+
X https://github.com/processing/processing/issues/5133
11+
X https://github.com/processing/processing/pull/5152
312

413
high
14+
_ menu bars broken in High Sierra
15+
_ https://github.com/processing/processing/issues/5272
16+
_ fix exception due to version parsing in Java 9
17+
_ https://github.com/processing/processing/issues/5275
518
_ make setting the window icon automatic, based on files in local dirs
619
X https://github.com/processing/processing/issues/5123
720
X https://github.com/processing/processing/pull/5202
821
_ need to make this work behind the scenes instead
922
_ create icon.png or have an 'icons' folder with multiple sizes
1023

24+
_ add select/copy to the status bar
25+
_ https://github.com/processing/processing/issues/5271
26+
27+
_ untitled folders are stored in temp folder
28+
_ clean up /tmp folders used during build
29+
_ https://github.com/processing/processing/issues/1896
30+
_ don't let people into the /tmp folder for sketches
31+
o don't use tmp folder for sketches?
32+
_ restrict more things like "show sketch folder"
33+
_ don't allow adding files w/o saving
34+
_ others?
35+
1136
contrib
1237
_ console hiding button?
1338
_ https://github.com/processing/processing/pull/5115
1439
_ make "loadXML(String)" handle "file not found"
1540
_ https://github.com/processing/processing/pull/5144
16-
_ detect errors from curved quotation marks
17-
_ https://github.com/processing/processing/issues/5133
18-
_ https://github.com/processing/processing/pull/5152
1941
_ alternate handling of duplicate library conflicts
2042
_ https://github.com/processing/processing/pull/5126
2143

@@ -50,15 +72,6 @@ _ put the reference (and examples?) into .zip files
5072
_ unzipping the app takes forever
5173
_ see the 'examples' section below
5274

53-
_ untitled folders are stored in temp folder
54-
_ clean up /tmp folders used during build
55-
_ https://github.com/processing/processing/issues/1896
56-
_ don't let people into the /tmp folder for sketches
57-
o don't use tmp folder for sketches?
58-
_ restrict more things like "show sketch folder"
59-
_ don't allow adding files w/o saving
60-
_ others?
61-
6275
_ Could not initialize class com.sun.jna.Native on startup (Windows)
6376
_ https://github.com/processing/processing/issues/4929
6477

0 commit comments

Comments
 (0)