-
Bug
-
Resolution: Won't Fix
-
P2
-
7
-
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
----------------------------------
------------------------------------------
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
----------------------------------