@@ -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
0 commit comments