Throw exception instead of returning
This commit is contained in:
parent
e376e36eb3
commit
ae04896e76
1 changed files with 4 additions and 3 deletions
|
@ -43,9 +43,10 @@ public final class JvmInformation {
|
|||
* Returns the Java version this JVM implements.
|
||||
*
|
||||
* @return the Java version
|
||||
* @throws NumberFormatException if the version could not be converted into an int
|
||||
* @since 1-alpha0
|
||||
*/
|
||||
public static int getJavaVersion() {
|
||||
public static int getJavaVersion() throws NumberFormatException {
|
||||
String version = System.getProperty("java.version");
|
||||
|
||||
if (version.startsWith("1.")) // Omit "1." (if present)
|
||||
|
@ -58,8 +59,8 @@ public final class JvmInformation {
|
|||
try {
|
||||
return Integer.parseInt(version);
|
||||
} catch (NumberFormatException exception) {
|
||||
Logger.crash(new LogIssuer(JvmInformation.class, CodePart.ENGINE), "Could not parse Java version: Integer conversion failed for string \"" + version + "\"");
|
||||
return Integer.MAX_VALUE;
|
||||
Logger.crash(new LogIssuer(JvmInformation.class, CodePart.ENGINE), "Could not parse Java version: Integer conversion failed for string \"" + version + "\"", exception);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue