From 86bdae8ce26d291c0096ed500581239dd2a87125 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Sun, 16 Feb 2014 06:32:39 +0100
Subject: Bug 958 - Add support for OpenJDK version notation

Manu <puybaret@eteks.com>:

In OpenJDK, Java version notation is a little different from Oracle JDK one:
OpenJDK uses "-u" instead of "_" to separate the version number from the update number, i.e. "1.7.0-u60-b04" vs "1.7.0_60-ea".
That would be nice to take this into account in the static initializer of jogamp.common.os.PlatformPropsImpl class. You could simply replace the line:
  final int usIdx = JAVA_VERSION.lastIndexOf("_");
by:
  final int usIdx = JAVA_VERSION.replace("-u", "_").lastIndexOf("_");
If you want to program it better, you can also test the "java.runtime.name" property that returns "OpenJDK Runtime Environment" for OpenJDK.

See also bug #944 https://jogamp.org/bugzilla/show_bug.cgi?id=944

+++

Done .. avoding the replace op.
---
 src/java/jogamp/common/os/PlatformPropsImpl.java | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

(limited to 'src/java')

diff --git a/src/java/jogamp/common/os/PlatformPropsImpl.java b/src/java/jogamp/common/os/PlatformPropsImpl.java
index f3b7ace..0965185 100644
--- a/src/java/jogamp/common/os/PlatformPropsImpl.java
+++ b/src/java/jogamp/common/os/PlatformPropsImpl.java
@@ -97,9 +97,16 @@ public abstract class PlatformPropsImpl {
         JAVA_VERSION = System.getProperty("java.version");
         JAVA_VERSION_NUMBER = new VersionNumber(JAVA_VERSION);
         {
-           final int usIdx = JAVA_VERSION.lastIndexOf("_");
-           if( usIdx > 0 ) {
-               final String buildS = Platform.JAVA_VERSION.substring(usIdx+1);
+           int usIdx = JAVA_VERSION.lastIndexOf("-u"); // OpenJDK update notation
+           int usOff;
+           if( 0 < usIdx ) {
+               usOff = 2;
+           } else {
+               usIdx = JAVA_VERSION.lastIndexOf("_"); // Oracle update notation
+               usOff = 1;
+           }
+           if( 0 < usIdx ) {
+               final String buildS = Platform.JAVA_VERSION.substring(usIdx+usOff);
                final VersionNumber update = new VersionNumber(buildS);
                JAVA_VERSION_UPDATE = update.getMajor();
            } else {
-- 
cgit v1.2.3