• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on resolving generics

 
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Regards.
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm guessing



is wanted because of the vararg declaration of the method allows
write(String)
or
write(String, Object)
or
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.
 
Melinda Savoy
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bill,

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

Regards.
 
The human mind is a dangerous plaything. This tiny ad is pretty safe:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic