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

Reply via email to