Skip to content

Whitespace check inconsistency #9973

Closed

Description

@zbynek

GWT version: 2.11
Browser (with version): Chrome
Operating System: N/A


Description

GWT emulation of isWhitespace is listing characters explicitly to avoid discrepancies between Java and JS notion of "whitespace", but there is one inconsistency with Java 8 and one inconsistency with Java 11.
For comparison the table below also shows which characters are recognized as whitespace using chr.match(/\s/) in JS (Chrome).

range java 8 java 11 GWT JS
\u0009-\u000D, \u0020, \u1680, \u2000-\u2006, \u2008-\u200A, \u2028, \u2029, \u205F, \u3000 yes yes yes yes
\u001C-\u001F yes yes yes no
\u00A0,\u2007,\u202F no no no yes
\u180E yes no yes no
\uFEFF no no yes yes
Steps to reproduce
  • Call Character.isWhitespace('\uFEFF') in GWT and JVM (version 8 or 11), observe different results.
  • Call Character.isWhitespace('\u180E') in GWT and JVM (version 11, Temurin), observe different results.
Known workarounds

Implement own utility method for whitespace detection.

Links

Activity

  1. niloc132 commented on Jul 8, 2024

    @niloc132
    Member

    With regards to \u180E, do we consider Java 8 to be broken here? Or do we think that GWT should be aware if it is running "as Java8" or "as Java 11"?

  2. tbroyer commented on Jul 8, 2024

    @tbroyer
    Member

    AFAICT, U+180E was a space (Unicode Zs category) priori to Unicode 6.3.0, and Java 8 was based on Unicode 6.2.0 (Java 9 used Unicode 8)

    I'd go with the more recent Unicode stance and not consider U+180E a space, even if it means GWT with -sourceLevel 8 behaves differently from a JDK 8 (but that would likely be the same as running Java 8 bytecode on a JDK 8 vs a more recent JDK)

  3. added a commit that references this issue on Jul 30, 2024
    e9fecc5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions