JDK 8 code review request for 7140820 Add covariant overrides to Collections clone methods (original) (raw)
Ulf Zibis Ulf.Zibis at gmx.de
Mon Jan 30 13:16:40 UTC 2012
- Previous message: JDK 8 code review request for 7140820 Add covariant overrides to Collections clone methods
- Next message: JDK 8 code review request for 7140820 Add covariant overrides to Collections clone methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Am 30.01.2012 13:19, schrieb Tom Hawtin:
A better solution to the unchecked casts from clone, is not to clone. Using a constructor gets rid of the problem, and ensures you aren't using some funky (potentially malicious) subclass.
- return (Hashtable<String, java.lang.Object>)env.clone(); + return new Hashtable<>(env);
Isn't cloning faster than normal instantiation? I can imagine, that behind the scenes cloning mainly only needs to duplicate the binary footprint of an object.
-Ulf
- Previous message: JDK 8 code review request for 7140820 Add covariant overrides to Collections clone methods
- Next message: JDK 8 code review request for 7140820 Add covariant overrides to Collections clone methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]