changeset 21693:dd987b035a0b

fix bug where computed graal.version value is longer than the placeholder value
author Doug Simon <doug.simon@oracle.com>
date Wed, 03 Jun 2015 13:47:47 +0200
parents c8418635b575
children 696baf53a985
files graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java mx/mx_graal.py
diffstat 2 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java	Wed Jun 03 10:56:15 2015 +0200
+++ b/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java	Wed Jun 03 13:47:47 2015 +0200
@@ -40,8 +40,8 @@
         if (access != null) {
             GraalRuntime rt = access.getRuntime();
             // The constant is patched in-situ by the build system
-            System.setProperty("graal.version", "@@graal.version@@".trim());
-            assert !System.getProperty("graal.version").startsWith("@@") && !System.getProperty("graal.version").endsWith("@@") : "Graal version string constant was not patched by build system";
+            System.setProperty("graal.version", "@@@@@@@@@@@@@@@@graal.version@@@@@@@@@@@@@@@@".trim());
+            assert !System.getProperty("graal.version").startsWith("@@@@@@@@@@@@@@@@") && !System.getProperty("graal.version").endsWith("@@@@@@@@@@@@@@@@") : "Graal version string constant was not patched by build system";
             return rt;
         }
         return new InvalidGraalRuntime();
--- a/mx/mx_graal.py	Wed Jun 03 10:56:15 2015 +0200
+++ b/mx/mx_graal.py	Wed Jun 03 13:47:47 2015 +0200
@@ -620,16 +620,23 @@
 
 def _patchGraalVersionConstant(dist):
     """
-    Patches the constant "@@graal.version@@" in the constant pool of Graal.class
+    Patches the constant "@@@@@@@@@@@@@@@@graal.version@@@@@@@@@@@@@@@@" in the constant pool of Graal.class
     with the computed Graal version string.
     """
     zf = zipfile.ZipFile(dist.path, 'r')
     graalClassfilePath = 'com/oracle/graal/api/runtime/Graal.class'
     graalClassfile = zf.read(graalClassfilePath)
-    versionSpec = '{:' + str(len('@@graal.version@@')) + '}'
+    placeholder = '@@@@@@@@@@@@@@@@graal.version@@@@@@@@@@@@@@@@'
+    placeholderLen = len(placeholder)
+    versionSpec = '{:' + str(placeholderLen) + '}'
     versionStr = versionSpec.format(graal_version())
-    if '@@graal.version@@' not in graalClassfile:
-        assert versionStr in graalClassfile, 'could not find "@@graal.version@@" or "' + versionStr + '" constant in ' + dist.path + '!' + graalClassfilePath
+
+    if len(versionStr) > placeholderLen:
+        # Truncate the version string if necessary
+        assert versionStr.startswith('unknown'), versionStr
+        versionStr = versionStr[:placeholderLen]
+    if placeholder not in graalClassfile:
+        assert versionStr in graalClassfile, 'could not find "' + placeholder + '" or "' + versionStr + '" constant in ' + dist.path + '!' + graalClassfilePath
         zf.close()
         return False
 
@@ -637,7 +644,7 @@
     zfOut = zipfile.ZipFile(zfOutPath, 'w')
     for zi in zf.infolist():
         if zi.filename == graalClassfilePath:
-            data = graalClassfile.replace('@@graal.version@@', versionStr)
+            data = graalClassfile.replace(placeholder, versionStr)
         else:
             data = zf.read(zi)
         zfOut.writestr(zi, data)