A new helper method Arrays.asArray

timo.kinnunen at gmail.com timo.kinnunen at gmail.com
Tue Jun 14 21:39:19 UTC 2016


I think @SafeVarargs should be OK here since the array containing the varargs already exists before the method starts executing and so the annotation amounts to asserting that the passed-in vararg-array is just as safe during the execution of the method as it is after the method execution completes. 

In any case, I’m only adding it to my versions to silence a compiler warning. In a JDK version the API doc should nail down that the method executes indistinguishable from a method which simply returns the passed-in array and the JDK version can freely choose which annotations to have. I would actually prefer the JDK implementation to use @ForceInline or something like that instead which my versions can’t use. This would guarantee that there is no overhead in calling the method and that type-safety issues present, if any, will occur within the calling context. Which is where they would have been introduced.






-- 
Have a nice day, 
Timo

Sent from Mail for Windows 10

From: Remi Forax


More information about the core-libs-dev mailing list