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

U+00B2 should be considered valid when used as part of Java identifier

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      The Unicode superscript 2 character (², U+00B2) is classified as a "Number" from what I can tell. As such should it not be possible to have it be part of a Java identifier? It would make it a bit nicer to write code like:

        double cos²_a = Math.pow(Math.cos(a), 2);

      For long, complex formulas it certainly improves readability. Sadly the latest Java compiler indicates this is an invalid character:

      error: illegal character: '\u00b2'

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile source code with a local identifier including the U+00B2 character.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      As long as it is not the leading character it should be considered part of a Java identifier.
      ACTUAL -
      The compiler errors out.

      CUSTOMER SUBMITTED WORKAROUND :
      Use "2" in identifiers.

            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: