# HG changeset patch # User Doug Simon # Date 1433332067 -7200 # Node ID dd987b035a0b7d46d8fc6f0cf65fa14488a3d924 # Parent c8418635b575bfa46117f2299ebaacec9c90c92a fix bug where computed graal.version value is longer than the placeholder value diff -r c8418635b575 -r dd987b035a0b graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java --- 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(); diff -r c8418635b575 -r dd987b035a0b mx/mx_graal.py --- 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)