Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid deprecated Class.newInstance in favor of constructor-based instantiation [SPR-14486] #19055

Closed
spring-projects-issues opened this issue Jul 19, 2016 · 0 comments

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Jul 19, 2016

Juergen Hoeller opened SPR-14486 and commented

As of JDK 9, Class.newInstance() is deprecated in favor of Constructor.newInstance(), with the latter throwing InvocationTargetException instead of simply propagating user exceptions to the caller. Let's use this as an opportunity to revise our remaining use of Class.newInstance(), in particular our remaining use of BeanUtils.instantiate(Class) which is based on it (in contrast to BeanUtils.instantiateClass(Class which explicitly uses the default constructor).

Along the same line, Proxy.getProxyClass and XMLReaderFactory.createXMLReader are in JDK 9 now as well. While we have no immediate replacement for those yet, we seem to be able to keep using them under our conditions (within the same ClassLoader). Those spots need to be marked as @SuppressWarnings("deprecated") though in order for our build to work on JDK 9 (with -Werror).


Issue Links:

  • #17928 Compatibility with merged JDK 9 mainline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants