changeset 22530:cbab86a6c7f6

make processing of <jre>/lib/jvmci/*.properties file like other Java *.properties files in that the last definition of any propery "wins"
author Doug Simon <doug.simon@oracle.com>
date Mon, 07 Sep 2015 22:23:35 +0200
parents 8d95daa4324b
children 99dc98466321
files mx.jvmci/mx_jvmci.py src/share/vm/jvmci/jvmciRuntime.cpp
diffstat 2 files changed, 19 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/mx.jvmci/mx_jvmci.py	Mon Sep 07 18:08:46 2015 +0200
+++ b/mx.jvmci/mx_jvmci.py	Mon Sep 07 22:23:35 2015 +0200
@@ -669,29 +669,27 @@
 
 def _updateJVMCIProperties(jdkDir, compilers):
     jvmciProperties = join(jdkDir, 'jre', 'lib', 'jvmci', 'jvmci.properties')
-    def createFile(compilers):
+    def createFile(lines):
         with open(jvmciProperties, 'w') as fp:
-            print >> fp, "# the first entry wins, reorder entries to change the default compiler"
-            for compiler in compilers:
-                print >> fp, "jvmci.compiler=" + compiler
+            header = "# the last definition of a property wins (i.e., it overwrites any earlier definitions)"
+            if header not in lines:
+                print >> fp, header
+            for line in lines:
+                print >> fp, line
 
-    if not exists(jvmciProperties):
-        createFile(compilers)
-    else:
-        oldCompilers = []
+    lines = []
+    if exists(jvmciProperties):
         with open(jvmciProperties) as fp:
             for line in fp:
                 if line.startswith('jvmci.compiler='):
-                    oldCompilers += [line.strip().split('=')[1]]
-        changed = False
-        newCompilers = []
-        for c in compilers:
-            if not c in oldCompilers:
-                changed = True
-                newCompilers += [c]
-        if changed:
-            # prepend new compilers, since the first property wins
-            createFile(newCompilers + oldCompilers)
+                    compiler = line.strip().split('=')[1]
+                    if compiler not in compilers:
+                        lines.append(line.strip())
+                else:
+                    lines.append(line.strip())
+    for compiler in compilers:
+        lines.append("jvmci.compiler=" + compiler)
+    createFile(lines)
 
 def _installDistInJdks(deployableDist):
     """
--- a/src/share/vm/jvmci/jvmciRuntime.cpp	Mon Sep 07 18:08:46 2015 +0200
+++ b/src/share/vm/jvmci/jvmciRuntime.cpp	Mon Sep 07 22:23:35 2015 +0200
@@ -841,7 +841,8 @@
  * Everything before the '=' is the property name and everything after '=' is the value.
  * Lines that start with '#' are treated as comments and ignored.
  * No special processing of whitespace or any escape characters is performed.
- * Also, no check is made whether an existing property is overridden.
+ * The last definition of a property "wins" (i.e., it overrides all earlier
+ * definitions of the property).
  */
 class JVMCIPropertiesFileClosure : public ParseClosure {
   SystemProperty** _plist;
@@ -865,7 +866,7 @@
     *sep = '\0';
     const char* name = line;
     char* value = sep + 1;
-    Arguments::PropertyList_add(_plist, name, value);
+    Arguments::PropertyList_unique_add(_plist, name, value);
   }
 };