Throw exception instead of returning

This commit is contained in:
JeremyStar™ 2024-07-11 05:28:59 +02:00
parent e376e36eb3
commit ae04896e76
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -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;
}
}