JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract
jason_mehrens at hotmail.com
Thu Apr 28 19:06:28 UTC 2016
>As mentioned, Class.newInstance() has a special cache for constructor
>and caller that speeds up repeated invocations from the same caller by
>skipping access checks.
I'm sure I'm missing something obvious related to performance or security but, couldn't the exact same 'cachedConstructor' field be used for caching Class.getConstructor(new Class) as long as a constructor copy is returned?
That way the recommended workaround is near the same performance.
More information about the core-libs-dev