• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java 7 feature confusion

 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found two documents on oracle site.I was thinking that one of new feature of java7 non-reifiable-varargs should be mentioned in varargs document but there is nothing like that.Please can you explain that this feature is enhancement of varargs or it comes under an other topic ?.

Thank you.





 
Jelle Klap
Bartender
Posts: 1951
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first link doesn't describe an enhancement to the vararg mechanism itself. I it merely describes a situation where type-erasure for a method using varargs and generics could lead to a ClassCastException at runtime.
In fact, the compiler has always been able to detect this and report it as a warning, it's just that as of Java 7 the way this warning is reported has changed:

Note: The Java SE 5 and 6 compilers generate this warning when the ArrayBuilder.addToList is called; in this example, the warning is generated for the class HeapPollutionExample. These compilers do not generate the warning at the declaration site. However, the Java SE 7 generates the warning at both the declaration site and the call site ...

 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.So do you meant it comes under Generic topic ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic