• 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

Sun Generics tutorial bug?

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. As per Generics tutorial at http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf , Page # 15, Section 7.3 - Arrays, the folowing code is legal but would generate unchecked warning.



But I get incompatibles types error when I try it! I wonder what the deal is?!

2. The following code is not using any generic stuff, but the warning I get while compiling the same is Generic related.



Does this mean sun has Generified/changed impl of even the raw(legacy?!) Collection classes as well?
 
Bartender
Posts: 3908
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Manoj,

1. yes, seems like an error in tutorial. let's wait for comments from experts

2. there are no separate implementations for legacy and generics collections. all collections are now generic.

regards,
MZ
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How come no information on generic restrictions for array declaration in JLS3.0?
 
manoj pillai
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
2. Thanks for clearing that up Mikalai, you are right - there is no separate impl for generic and raw type. But if you notice the error message, compiler has correctly identified the "raw type" java.util.List but then it makes up the mind and decides to throw a generic related error message. So you cant use non generic collection objects anymore without getting these nasty warning messages I suppose. Price for the "guaranteed" type safety I presume
 
Mikalai Zaikin
Bartender
Posts: 3908
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy !

Originally posted by manoj p:
2. ... So you cant use non generic collection objects anymore without getting these nasty warning messages I suppose. Price for the "guaranteed" type safety I presume



Well, if you do not use any 5.0 features, then you can get rid of warnings using



or, even



regards,
MZ
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic