8204565: (spec) Document java.{vm.}?specification.version system properties' relation to $FEATURE
authorbchristi
Tue, 12 Jun 2018 14:08:24 -0700
changeset 50531 aeb7fb702890
parent 50530 7e3aa681a484
child 50532 a18c60527166
child 50653 4f11cac95184
8204565: (spec) Document java.{vm.}?specification.version system properties' relation to $FEATURE Reviewed-by: mchung
src/java.base/share/classes/java/lang/System.java
test/hotspot/jtreg/runtime/6981737/Test6981737.java
test/jdk/java/lang/System/Versions.java
--- a/src/java.base/share/classes/java/lang/System.java	Tue Jun 12 13:24:37 2018 -0700
+++ b/src/java.base/share/classes/java/lang/System.java	Tue Jun 12 14:08:24 2018 -0700
@@ -607,8 +607,9 @@
      * <tr><th scope="row">{@code java.home}</th>
      *     <td>Java installation directory</td></tr>
      * <tr><th scope="row">{@code java.vm.specification.version}</th>
-     *     <td>Java Virtual Machine specification version which may be
-     *     interpreted as a {@link Runtime.Version}</td></tr>
+     *     <td>Java Virtual Machine specification version, whose value is the
+     *     {@linkplain Runtime.Version#feature feature} element of the
+     *     {@linkplain Runtime#version() runtime version}</td></tr>
      * <tr><th scope="row">{@code java.vm.specification.vendor}</th>
      *     <td>Java Virtual Machine specification vendor</td></tr>
      * <tr><th scope="row">{@code java.vm.specification.name}</th>
@@ -621,8 +622,9 @@
      * <tr><th scope="row">{@code java.vm.name}</th>
      *     <td>Java Virtual Machine implementation name</td></tr>
      * <tr><th scope="row">{@code java.specification.version}</th>
-     *     <td>Java Runtime Environment specification version which may be
-     *     interpreted as a {@link Runtime.Version}</td></tr>
+     *     <td>Java Runtime Environment specification version, whose value is
+     *     the {@linkplain Runtime.Version#feature feature} element of the
+     *     {@linkplain Runtime#version() runtime version}</td></tr>
      * <tr><th scope="row">{@code java.specification.vendor}</th>
      *     <td>Java Runtime Environment specification  vendor</td></tr>
      * <tr><th scope="row">{@code java.specification.name}</th>
--- a/test/hotspot/jtreg/runtime/6981737/Test6981737.java	Tue Jun 12 13:24:37 2018 -0700
+++ b/test/hotspot/jtreg/runtime/6981737/Test6981737.java	Tue Jun 12 14:08:24 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test Test6981737.java
- * @bug 6981737
+ * @bug 6981737 8204565
  * @summary check for correct vm properties
  * @run main Test6981737
  * @author kamg
@@ -33,13 +33,12 @@
 
     /**
      * Check the 'vendor' properties and java.vm.specification.version property.
-     * In jdk9 onwards they should be "Oracle..." and "<major_version>"
      */
     public static void main(String[] args) throws Exception {
 
         String vendor_re = "Oracle Corporation";
-        int major_version = Runtime.version().major();
-        String vm_spec_version_re = Integer.toString(major_version);
+        int feature_version = Runtime.version().feature();
+        String vm_spec_version_re = Integer.toString(feature_version);
 
         verifyProperty("java.vm.specification.vendor", vendor_re);
         verifyProperty("java.specification.vendor", vendor_re);
--- a/test/jdk/java/lang/System/Versions.java	Tue Jun 12 13:24:37 2018 -0700
+++ b/test/jdk/java/lang/System/Versions.java	Tue Jun 12 14:08:24 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 4989690 6259855 6706299
+ * @bug 4989690 6259855 6706299 8204565
  * @summary Check that version-related system property invariants hold.
  * @author Martin Buchholz
  */
@@ -72,13 +72,17 @@
     public static void main(String [] args) throws Exception {
         String classVersion   = getProperty("java.class.version");
         String javaVersion    = getProperty("java.version");
-        String VMVersion      = getProperty("java.vm.version");
         String runtimeVersion = getProperty("java.runtime.version");
         String specVersion    = getProperty("java.specification.version");
+        String vmSpecVersion  = getProperty("java.vm.specification.version");
+        String featureVersion = Integer.toString(Runtime.version().feature());
 
         if (! (javaVersion.startsWith(specVersion) &&
-               runtimeVersion.startsWith(specVersion)))
+               runtimeVersion.startsWith(specVersion) &&
+               specVersion.equals(featureVersion) &&
+               vmSpecVersion.equals(featureVersion))) {
             throw new Exception("Invalid version-related system properties");
+        }
 
         //----------------------------------------------------------------
         // Check that java.class.version is correct.