File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Java 7 feature confusion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java 7 feature confusion" Watch "Java 7 feature confusion" New topic

Java 7 feature confusion

saloni jhanwar
Ranch Hand

Joined: Feb 09, 2012
Posts: 583

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.

Tell the difficulties that i am difficult.
Jelle Klap

Joined: Mar 10, 2008
Posts: 1951

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 ...

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
saloni jhanwar
Ranch Hand

Joined: Feb 09, 2012
Posts: 583

Thanks.So do you meant it comes under Generic topic ?
Don't get me started about those stupid light bulbs.
subject: Java 7 feature confusion
jQuery in Action, 3rd edition