This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Question on resolving generics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question on resolving generics" Watch "Question on resolving generics" New topic

Question on resolving generics

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

I'm getting 2 warnings regarding generics that I cannot resolve. I'm running on Java 6 using Eclipse 3.2.2.

1st warning:

The argument of type String[] should explicitly be cast to Object[] for the invocation of the varargs method format(String, Object...) from type MessageFormat. It could alternatively be cast to Object for a varargs invocation

The warning refers to code in method writeExportLinks() (line 618):

2nd warning:

Type safety: The method put(Object, Object) belongs to the raw type Map. References to generic type Map<K,V> should be parameterized

The warning refers to code in method getOpenTag() (line 632):

ANY help or direction would be greatly appreciated.

Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
I'm guessing

is wanted because of the vararg declaration of the method allows
write(String, Object)
write(String, Object, Object)
ad infinitum

also, the declaration of the Map variable should be generically parameterized:

(on the assumption the map is String->String)
if attributeMap is also correctly declared, the clone method will return the correct type.

Bill Shirley - bshirley -
if (Posts < 30) JavaRanchFAQ);
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387


Thanks for the reply. I'll give it a shot.

I agree. Here's the link:
subject: Question on resolving generics
It's not a secret anymore!