You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2017/04/26 19:00:11 UTC

svn commit: r1792793 - in /pivot/trunk: core/test/org/apache/pivot/util/test/VersionTest.java wtk/src/org/apache/pivot/wtk/ApplicationContext.java

Author: rwhitcomb
Date: Wed Apr 26 19:00:11 2017
New Revision: 1792793

URL: http://svn.apache.org/viewvc?rev=1792793&view=rev
Log:
PIVOT-996:  Add new code to ApplicationContext to get the Java Runtime version,
which is in addition to the Java JVM version, and to make it available to other
code as a new API call.

Added this new call to VersionTest to make sure the "decode()" and then "toString()"
methods deal nicely with this value.  Just to make sure we can catch the failure
during testing if this ever gets broken again.

I want to consider deprecating the "getJVMVersion()" method as I don't think it
is useful (anymore, if it ever was?); however, I have not done that in this
submission.

Modified:
    pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java

Modified: pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java?rev=1792793&r1=1792792&r2=1792793&view=diff
==============================================================================
--- pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java (original)
+++ pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java Wed Apr 26 19:00:11 2017
@@ -104,5 +104,11 @@ public class VersionTest {
         assertEquals("PIVOT-996 test case", jvmVersionParsed, jvmVersionExplicit);
         System.out.format("PIVOT-996 parsed/toString: %1$s, expected: %2$s%n", parsedToString, PIVOT_996_OUTPUT);
         assertEquals("PIVOT-996 toString", parsedToString, PIVOT_996_OUTPUT);
+
+        String sysJavaVersion = System.getProperty("java.runtime.version");
+        Version javaVersion = Version.decode(sysJavaVersion);
+        String formattedJavaVersion = javaVersion.toString();
+        System.out.format("Java Runtime version (parsed and formatted): %1$s, raw: %2$s%n", formattedJavaVersion, sysJavaVersion);
+        assertEquals("Java Runtime version", sysJavaVersion, formattedJavaVersion);
     }
 }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java?rev=1792793&r1=1792792&r2=1792793&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java Wed Apr 26 19:00:11 2017
@@ -1723,11 +1723,13 @@ public abstract class ApplicationContext
 
     private static final Package CURRENT_PACKAGE = ApplicationContext.class.getPackage();
     private static Version jvmVersion = null;
+    private static Version javaVersion = null;
     private static Version pivotVersion = null;
 
     static {
         // Get the JVM version
         jvmVersion = Version.decode(System.getProperty("java.vm.version"));
+        javaVersion = Version.decode(System.getProperty("java.runtime.version"));
 
         // Get the Pivot version
         String version = CURRENT_PACKAGE.getImplementationVersion();
@@ -1806,7 +1808,8 @@ public abstract class ApplicationContext
     }
 
     /**
-     * Returns the current JVM version.
+     * Returns the current JVM version, parsed from the "java.vm.version" system
+     * property.
      *
      * @return The current JVM version, or <tt>null</tt> if the version can't be
      * determined.
@@ -1816,6 +1819,17 @@ public abstract class ApplicationContext
     }
 
     /**
+     * Returns the current Java Runtime version, parsed from the "java.runtime.version"
+     * system property.
+     *
+     * @return The current Java version, or <tt>null</tt> if the version can't be
+     * determined.
+     */
+    public static Version getJavaVersion() {
+        return javaVersion;
+    }
+
+    /**
      * Returns the current Pivot version.
      *
      * @return The current Pivot version (determined at build time), or