Uploaded image for project: 'Jalview'
  1. Jalview
  2. JAL-4700

SwingJS 5.x won't compile jalview.util.StringUtils.DELIMITERS_PATTERN

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Blocker
    • Resolution: Unresolved
    • Affects Version/s: 2.12.0, 2.12.0.0
    • Fix Version/s: 2.12.0.0
    • Component/s: jalview-j2s
    • Labels:
      None

      Description

      JalviewJS 12.x can't be run because a previously working in SwingJS regex:
      DELIMITERS_PATTERN = Pattern
                .compile(".*='[^']*(?!')");

      Now throws a JS error:
      FileLoader.js:315 Uncaught SyntaxError: Invalid regular expression: /(?<秘1>.*='[^']*)(?(?<秘2>!'))/g: Invalid group (at Pattern.js:183:8)
          at new RegExp (<anonymous>)
          at clazz.eval [as newRegExp$S$S] (Pattern.js:183:8)
          at clazz.eval (Pattern.js:147:16)
      ..

      The problem looks to be due to a patch for https://github.com/BobHanson/java2script/issues/253 which inserts zero length markers at capture groups, which for our case results in an invalid regex:
      ".*='[^']*(?!')"

      becomes
      "(?<秘1>.*='[^']*)(?(?<秘2>!'))"

      The problem is most likely that the groups patch doesn't allow for zero width negative lookahead - JS didn't support this widely until ~2022, so understandable that this syntax wasn't tested.

        Attachments

          Activity

            People

            Assignee:
            jprocter James Procter
            Reporter:
            jprocter James Procter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: