Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8361494

[IR Framework] Escape too much in replacement of placeholder

XMLWordPrintable

    • b07

        ```
        nodeRegex = nodeRegex.replaceAll(IRNode.IS_REPLACED, userPostfix.value());
        ```
        because in RawIRNode.java, \ and $ in arguments of parametric rules of IR framework are not replaced textually but interpreted as replacement for matched groups.

        This is problematic for nested classes (using $) and for actually writing regexes: for instance, if we want to match any classes of name "MyValue" followed by digits one must write:
        @(failOn = {ALLOC_OF, "MyValue\\\\d+"}
        the 4 \ means only 2 \ in the String value, which is an escaped \ for replaceAll. But in the substitution
        ```
        nodeRegex = nodeRegex.replaceAll(IRNode.IS_REPLACED, userPostfix.value());
        ```
        the replacement feature is useless since IS_REPLACED has no capturing group. We should use java.util.regex.Matcher.quoteReplacement to escape \ and $ not to have to do it manually.

              mchevalier Marc Chevalier
              mchevalier Marc Chevalier
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: