RFR: 8311500: StackWalker.getCallerClass() can throw if invoked reflectively

Aleksey Shipilev shade at openjdk.org
Wed Jul 5 14:43:56 UTC 2023


On Wed, 5 Jul 2023 11:45:59 GMT, Volker Simonis <simonis at openjdk.org> wrote:

> As the included jtreg test demonstrates, `StackWalker.getCallerClass()` can throw an `UnsupportedOperationException` if called reflectively. Currently this only happens if we invoke `StackWalker.getCallerClass()` recursively reflectively, but this issue will become more prominent once we fix [JDK-8285447](https://bugs.openjdk.org/browse/JDK-8285447).

Neither PR nor the bug describes what the root cause it, so it is very hard to see if patch makes sense. Please describe the problem and solution briefly?

src/hotspot/share/prims/stackwalk.cpp line 168:

> 166:                               int max_nframes, int start_index,
> 167:                               objArrayHandle  frames_array,
> 168:                               int& end_index, bool firstBatch, TRAPS) {

The style is `is_first_batch`.

-------------

PR Review: https://git.openjdk.org/jdk/pull/14773#pullrequestreview-1514691062
PR Review Comment: https://git.openjdk.org/jdk/pull/14773#discussion_r1253212866


More information about the core-libs-dev mailing list