Skip to content

Commit

Permalink
[GR-16941] Backport: Fix getCallerClass methods to acquire the correc…
Browse files Browse the repository at this point in the history
…t frame.

PullRequest: graal/4004
  • Loading branch information
ezzarghili committed Jul 11, 2019
2 parents 25509f4 + 387e152 commit 54dbcd8
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,24 @@ class GetCallerClassVisitor extends JavaStackFrameVisitor {

@Override
public boolean visitFrame(FrameInfoQueryResult frameInfo) {
if (!StackTraceUtils.shouldShowFrame(frameInfo, false, false)) {
if (!foundCallee) {
/*
* Always ignore the frame. It is an internal frame of the VM or a frame related to
* reflection.
* Skip the frame that contained the invocation of getCallerFrame() and continue the
* stack walk. Note that this could be a frame related to reflection, but we still must
* not ignore it: For example, Constructor.newInstance calls Reflection.getCallerClass
* and for this check Constructor.newInstance counts as a frame. But if the actual
* invoked constructor calls Reflection.getCallerClass, then Constructor.newInstance
* does not count as as frame (handled by the shouldShowFrame check below because this
* path was already taken for the constructor frame).
*/
foundCallee = true;
return true;

} else if (!foundCallee) {
} else if (!StackTraceUtils.shouldShowFrame(frameInfo, false, false)) {
/*
* Skip the frame that contained the invocation of getCallerFrame() and continue the
* stack walk.
* Always ignore the frame. It is an internal frame of the VM or a frame related to
* reflection.
*/
foundCallee = true;
return true;

} else {
Expand Down

0 comments on commit 54dbcd8

Please sign in to comment.