mbien commented on code in PR #6544:
URL: https://github.com/apache/netbeans/pull/6544#discussion_r1349612782


##########
platform/netbinox/src/org/netbeans/modules/netbinox/NetbinoxFactory.java:
##########
@@ -74,6 +77,45 @@ public Framework newFramework(Map map) {
             configMap.put("osgi.locking", "none"); // NOI18N
         }
 
+        // Ensure that the org.osgi.framework.executionenvironment holds all
+        // JavaSE entries that match till the current JDK. The dynamic approach
+        // will work also for newly released JDKs.
+        String[] javaSpecificationVersion = 
System.getProperty("java.specification.version").split("\\.");
+        Integer javaSpecificationMajorVersion = null;
+        try {
+            javaSpecificationMajorVersion = 
Integer.valueOf(javaSpecificationVersion[0]);
+        } catch (NumberFormatException ex) {
+            LOG.log(
+                    Level.WARNING,
+                    "Failed to parse java.specification.version: {0}",
+                    System.getProperty("java.specification.version")
+            );
+        }

Review Comment:
   since this needs to work on 9 and later (the other versions are hardcoded), 
we could use the API here to be future proof:
   
   ```java
          try {
               // java >=9
               Object runtimeVersion = 
Runtime.class.getMethod("version").invoke(null);
               javaSpecificationMajorVersion = (int) 
runtimeVersion.getClass().getMethod("major").invoke(runtimeVersion);
          } catch (ReflectiveOperationException ignore) {
               // java <9
          }
   ```
   using `major` instead of `feature` is deprecated but not for removal and it 
is returning the same value.
   https://docs.oracle.com/javase/9/docs/api/java/lang/Runtime.Version.html
   
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Runtime.Version.html#major()



-- 
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

Reply via email to