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

exotic identifiers with primitive Jata types(#"byte",#"int",...) can't be used in 'extends'

XMLWordPrintable

    • generic
    • generic

      The following code is rejected by the Java compiler(JDK 7 b76) if it deals with a class which name is an exotic identifier with a Java primitive type name inside:
      ------------------------------------------
      class #"int "{};
      class A extends #"int"{};
      ------------------------------------------
      The output is:
      ------------------------------------------
      A.java:2: unexpected type
      class A extends #"int"{};
                      ^
        required: class
        found: int
      1 error
      ------------------------------------------

      The compiler also fails if such names are used as type parameter bound:
      class A<T extends #"int">{};
      The exotic identifiers #"byte",#"int",... are also rejected if used in annotation names.

      The code example and the ouput message:
      ----------------------------------
      @interface #"int" {
          String s() default "default";
          int i() default 123;
      }

      @#"int"
      class A {}
      ----------------------------------
      A.java:6: incompatible types
      @#"int"
       ^
        required: Annotation
        found: int
      1 error
      ----------------------------------

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: