What are the main differences between the JDK in terms of handling safe var args?
The above issues a warning in JDK 1.6 -
Type safety: A generic array of List is created for a varargs parameter
Please help me understand.
JDK7 added the @SafeVarargs annotation to note when generic varargs are genuinely safe, and applied that annotation to e.g. Collections.addAll
.
It's a part of Project Coin. You can look at the proposal here http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/000217.html
In short, this warning was moved to method declaration instead of method call. There was a good comment about this: https://stackoverflow.com/a/3819038/891391
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With