Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / April 2005

Tip: Looking for answers? Try searching our database.

A Java 5 question

Thread view: 
Aleksandar Pecanov - 05 Apr 2005 16:47 GMT
Hi

( This is the first time to post something to the newsgroup so please
don't be harsh  )
This is not exactly a problem, I'm just trying to figure out some things
in JDK 5. I have the following method:
       
       public boolean addClass( Class c ) {
if( !c.isAnnotationPresent( SomeAnnotation.class ) )
throw new InvalidJdbcObjectException("Missing annotation for type: "+c);
           ...
}

... now, in the second line a warning is indicated: "The method
isAnnotationPresent(Class) belongs to the raw type Class. References to
generic type Class<T> should be parameterized"...
Is there a way of avoiding this warning through a standard procedur
(withoud compiler params, just code workaround or something).

Thank you.
Tor Iver Wilhelmsen - 05 Apr 2005 22:40 GMT
> if( !c.isAnnotationPresent( SomeAnnotation.class ) )

Your use is consistent with Sun's example at

http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html

despite the JLS saying that Foo.class is of the ungeneric type
"Class".
Fred - 06 Apr 2005 14:40 GMT
So why not parameterize the parameter?

public boolean addClass( Class<? extends Object>c ) would be somewhat
flexible.  Or if you know the type of class that will be used as an
argument, that'd be even more appropriate (i.e. Class<this_type> c ).

That's just off the cuff, though, which is to say I've not tried to
compile either.

-Fred


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.