AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

@SuppressWarnings("unchecked")

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Steven Buroff
Guest





PostPosted: Tue Feb 22, 2005 5:45 pm    Post subject: @SuppressWarnings("unchecked") Reply with quote



I can't seem to get the @SuppressWarnings("unchecked") to work.
Here is my test program.

public class Tryit {
@SuppressWarnings({"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.String
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



Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.