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

the exotic identifiers #"class", #"super", #"this" can not be used in method calls

XMLWordPrintable

    • generic
    • generic

      Please see the following test:
      --------------------------------------------
      public class A {
          public void #"class"() {}
          public void #"super"() {}
          public void #"this"() {}

          public static void main(String argv[]) {
              A testClass = new A();
              testClass.#"class"();
              testClass.#"super"();
              testClass.#"this"();
          }
      }
      -----------------------------------------------

      The attempt to compile it using JDK 7 b76 fails with the output:
      -----------------------------------------------
      A.java:8: cannot find symbol
              testClass.#"class"();
              ^
        symbol: class testClass
        location: class A
      A.java:9: call to super must be first statement in constructor
              testClass.#"super"();
                                ^
      A.java:10: call to this must be first statement in constructor
              testClass.#"this"();
                               ^
      3 errors
      -----------------------------------------------

      If these identifiers have special semantics it should be obviously mentioned in the specification.

            jjg Jonathan Gibbons
            dmiltsov Dmitry Miltsov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: