mbien commented on code in PR #5271:
URL: https://github.com/apache/netbeans/pull/5271#discussion_r1066650447
##########
extide/gradle/src/org/netbeans/modules/gradle/GradleJavaCompatProblemsProvider.java:
##########
@@ -143,8 +143,12 @@ private static int getJavaMajorVersion(File javaHome) {
}
String javaVersion = releasePros.getProperty("JAVA_VERSION");
//NOI18N
+ // This should look like "17" or "17.0.9"
if ((javaVersion != null) && javaVersion.startsWith("\"") &&
javaVersion.endsWith("\"")) {
- javaVersion = javaVersion.substring(1,
javaVersion.indexOf('.'));
+ int dot = javaVersion.indexOf('.');
+ javaVersion = dot > 0
+ ? javaVersion.substring(1, javaVersion.indexOf('.'))
+ : javaVersion.substring(1, javaVersion.length() - 1);
Review Comment:
this could be using:
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Runtime.Version.html#parse(java.lang.String)
once the module moved to 11 so that we don't have to come up with so many
ways how to parse java versions.
Maybe mark the spot with a TODO?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists