I can't seem to get the @SuppressWarnin gs("unchecked" ) to work.
Here is my test program.
public class Tryit {
@SuppressWarnin gs({"unchecked" })
public <T> T doit(Class<T> clazz){
T val = (T)"xxx";
return val;
}
}
Here is the compiler output:
C:\tmp>javac Tryit.java
Note: Tryit.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
or, with -Xlint:unchecked , I get:
C:\tmp>javac -Xlint:unchecked Tryit.java
Tryit.java:4: warning: [unchecked] unchecked cast
found : java.lang.Strin g
required: T
T val = (T)"xxx";
^
1 warning
Here is the compiler version:
C:\tmp>java -version
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
Other annotations like @override work correctly.
Any idea what I'm doing wrong? Thanks.
Steve Buroff