-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8309400: JDI spec needs to clarify when OpaqueFrameException and NativeMethodException are thrown #26335
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
8309400: JDI spec needs to clarify when OpaqueFrameException and NativeMethodException are thrown #26335
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * This code is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -395,29 +395,25 @@ public PacketStream send() { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (JDWPException exc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch (exc.errorCode()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| case JDWP.Error.OPAQUE_FRAME: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (thread.isVirtual()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // We first need to find out if the current frame is native, or if the | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // previous frame is native, in which case we throw NativeMethodException | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (int i = 0; i < 2; i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| StackFrameImpl sf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| sf = (StackFrameImpl)thread.frame(i); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (IndexOutOfBoundsException e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // This should never happen, but we need to check for it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| sf.validateStackFrame(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| MethodImpl meth = (MethodImpl)sf.location().method(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (meth.isNative()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new NativeMethodException(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // We first need to find out if the current frame is native, or if the | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // previous frame is native, in which case we throw NativeMethodException | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (int i = 0; i < 2; i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| StackFrameImpl sf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| sf = (StackFrameImpl)thread.frame(i); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (IndexOutOfBoundsException e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // This should never happen, but we need to check for it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| sf.validateStackFrame(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| MethodImpl meth = (MethodImpl)sf.location().method(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (meth.isNative()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new NativeMethodException(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, I mean
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I see now. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| // No native frames involved. Must have been due to thread | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // not being mounted. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new OpaqueFrameException(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new NativeMethodException(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // No native frames involved. Must have been due to virtual thread | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // not being mounted or some other reason such as failure to deopt. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new OpaqueFrameException(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| case JDWP.Error.THREAD_NOT_SUSPENDED: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new IncompatibleThreadStateException( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Thread not current or suspended"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I'm not sure the comment at line 406 is fully correct. The
IncompatibleThreadStateExceptionwill be thrown if a virtual thread is not suspended. So, theOpaqueFrameExceptionwill be thrown only when a virtual thread is suspended but not at an event. The same concern should apply for the line 488.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are talking about the difference between "not suspended" vs "not suspended at an event". The former results in IncompatibleThreadStateException. For the latter I felt the wording implied it was suspended, but not at an event. Maybe it should just say "suspended, but not at an event"?
The JVMTI spec does not have this issue because it doesn't mention virtual threads as part of the OPAQUE_ERROR description. It instead mentions the method being native as an example of what can cause OPAQUE_ERROR. We can't do that here because a native method results in NativeMethodException, not OpaqueFrameException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this would make it clear.
And yes, the JVMTI vs JDI spec difference is reasonable.