473,651 Members | 2,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

@SuppressWarnin gs("unchecked" )

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
Jul 17 '05 #1
0 13660

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.