JDK-8335478 : Add notes for Error handling in Method.invoke and Constructor.newInstance
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 24
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2024-07-01
  • Updated: 2024-11-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
CSR :  
Duplicate :  
Duplicate :  
Description
Method.invoke and Constructor.newInstance wrap Error instances from the calls into InvocationTargetException instances. If the Error is OutOfMemoryError or StackOverflowError, attempts to wrap the ITE into other exceptions may fail with secondary Error, which will hide the original Error.

Changing the API to propagate any Error is out-of-spec, and is not considered.

We should add notes in these 2 methods about the potential risks of swallowing errors.
Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/19980 Date: 2024-07-01 21:48:44 +0000
09-07-2024