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

Location.isModuleOrientedLocation accepts only limited "MODULE" strings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 25
    • tools
    • None

      There is a little bug in Location.isModuleOrientedLocation:

              default boolean isModuleOrientedLocation() {
                  return getName().matches("\\bMODULE\\b");
              }

      The code around suggests we are supposed to have locations with CAPITALIZED_UNDERSCORE_NAMES. But the regexp: a) does not match anything beyond simple "MODULE" string, because it regexp is un-anchored; b) "\b" does not match "_" to begin with!

      jshell> "MODULE".matches("\\bMODULE\\b")
      $1 ==> true

      jshell> "MODULE_TEST".matches("\\bMODULE\\b")
      $2 ==> false

      jshell> "MODULE TEST".matches("\\bMODULE\\b")
      $3 ==> false

      This is less of the problem for `StandardLocation` that would directly implement `isModuleOrientedLocation`. The fix might have external compatibility impact, so it remains to be seen what should be done here.

      If we are expanding the check, we need JDK-8351556 to land first to avoid regressions.

            Unassigned Unassigned
            shade Aleksey Shipilev
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: