Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Revisions: Issue #37943 Back to Issue ]
Summary 0037943: JDK 9: remove [deprecation] newInstance() in Class warnings
Revision 2018-02-26 13:52 by caristu
Description When building Openbravo with JDK 9, several "[deprecation] newInstance() in Class" warnings appears:

warning: [deprecation] newInstance() in Class has been deprecated

Besides, it seems that is not a recommended practice to make use of this method. So, these warnings should be fixed by retrieving the instance from a constructor object. See [1] and [2].

This is a safe change as Class.newInstance() is more limited than Constructor.newInstance(): the first one can only invoke the zero-argument constructor, while the second one may invoke any constructor. So, in order to fix this issue we have just to:

a) Replace calls to Class.newInstance() with Constructor.newInstance() without using any argument.
b) Catch the new exception types that are thrown by Constructor.newInstance(): InvocationTargetException and NoSuchMethodException. Both of these exception types are subclasses of ReflectiveOperationException.

[1] https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html [^]
[2] https://docs.oracle.com/javase/tutorial/reflect/member/ctorInstance.html [^]
Revision 2018-02-26 13:51 by caristu
Description When building Openbravo with JDK 9, several "[deprecation] newInstance() in Class" warnings appears:

warning: [deprecation] newInstance() in Class has been deprecated

Besides, it seems that is not a recommended practice to make use of this method. So, these warnings should be fixed by retrieving the instance from a constructor object. See [1] and [2].

This is a safe change as Class.newInstance() is more limited than Constructor.newInstance(): the first one can only invoke the zero-argument constructor, while the second one may invoke any constructor. So, in order to fix this issue we have just to:

a) Invoke Constructor.newInstance() without any argument
b) Catch the new exception types that are thrown by Constructor.newInstance(): InvocationTargetException and NoSuchMethodException. Both of these exception types are subclasses of ReflectiveOperationException.

[1] https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html [^]
[2] https://docs.oracle.com/javase/tutorial/reflect/member/ctorInstance.html [^]
Revision 2018-02-26 13:51 by caristu
Description When building Openbravo with JDK 9, several "[deprecation] newInstance() in Class" warnings appears:

warning: [deprecation] newInstance() in Class has been deprecated

Besides, it seems that is not a recommended practice to make use of this method. So, these warnings should be fixed by retrieving the instance from a constructor object. See [1] and [2].

This is a safe change as Class.newInstance() is more limited than Constructor.newInstance(): the first one can only invoke the zero-argument constructor, while the second one may invoke any constructor.

So, fix this issue we have just to:

a) Invoke Constructor.newInstance() without any argument
b) Catch the new exception types that are thrown by Constructor.newInstance(): InvocationTargetException and NoSuchMethodException. Both of these exception types are subclasses of ReflectiveOperationException.

[1] https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html [^]
[2] https://docs.oracle.com/javase/tutorial/reflect/member/ctorInstance.html [^]
Revision 2018-02-15 19:04 by caristu
Description When building Openbravo with JDK 9, several "[deprecation] newInstance() in Class" warnings appears:

warning: [deprecation] newInstance() in Class has been deprecated

Besides, it seems that is not a recommended practice to make use of this method. So, these warnings should be fixed by retrieving the instance from a constructor object. See [1] and [2].

[1] https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html [^]
[2] https://docs.oracle.com/javase/tutorial/reflect/member/ctorInstance.html [^]
Revision 2018-02-15 18:55 by caristu
Description When building Openbravo with JDK 9, several "[deprecation] newInstance() in Class" warnings appears:

warning: [deprecation] newInstance() in Class has been deprecated

Besides, it seems that is not a recommended practice to make use of this method. So, these warnings should be fixed by retrieving the instance from a constructor object[1]

[1] https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html [^]


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker