-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8273684: Replace usages of java.util.Stack with ArrayDeque #5294
Conversation
👋 Welcome back turbanoff! A progress list of the required criteria for merging this PR into |
@turbanoff The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java
Outdated
Show resolved
Hide resolved
one redundant import
Looks fine |
Or maybe not, did you check that the order of pushing and the order of iteration for the stack and ArrayDeque are the same? I am not sure about it. |
Replace one usage of ArrayList instead of ArrayDeque to preserve order of array elements as it was in original code
Yeah. You are right! TIL that order of iteration is different in ArrayDequeu vs Stack: Stack.push() adds to the "end of stack" (it just calls Vector.add()), while ArrayDeque.push adds "first element" |
Mailing list message from Bernd Eckenfels on serviceability-dev: Maybe better use addFirst(), for example in CommandProcessor there is a comment that order matters (did not check it more closely), so it?s probably best to not reverse orders in any place? The Dequeue Javadoc lists addFirst as the aproperiate stack#push replacement. Gruss On Sun, 29 Aug 2021 21:14:19 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:
Yeah. You are right! TIL that order of iteration is different in ArrayDequeu vs Stack: Stack.push() adds to the "end of stack" (it just calls Vector.add()), while ArrayDeque.push adds "first element" ------------- PR: https://git.openjdk.java.net/jdk/pull/5294 |
In all other places (except HTMLReader), iteration order don't matter. Stack only accessed via classic well known stack operations: push, pop, peek. This methods work in the same way in ArrayDeque. So I think replacing with |
@@ -985,7 +985,7 @@ public void doit(Tokens t) { | |||
Iterator i = agent.getTypeDataBase().getTypes(); | |||
// Make sure the types are emitted in an order than can be read back in | |||
HashSet<String> emitted = new HashSet<>(); | |||
Stack<Type> pending = new Stack<>(); | |||
ArrayDeque<Type> pending = new ArrayDeque<>(); |
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.
Have you run the clhsdb vmstructsdump command to make sure the ordering hasn't changed?
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.
Checked.
Ordering is the same.
with_fixes_java_vmstructsdump.txt
without_fixes_java_vmstructsdump.txt
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.
There is something wrong with the version of jhsdb you are running. It appears to be an old version, not the latest. You should not be seeing the following warning. The code that produces it is not even present in the latest jdk.
Warning: Nashorn engine is planned to be removed from a future JDK release
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.
I wondered about this too. Perhaps this messages coming from the target JDK which I'm attached too?
I attached to my IntelliJ IDEA process. It uses JDK 11.
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.
SA doesn't doesn't run any code on the target.
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.
I wonder if you are exporting CLASSPATH and that is causing jhsdb
to pick up the wrong SA implementation.
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.
Rechecked again.
Now without involving IDEA. Just started small java program and then attached.
Then checkouted revision before my commits (a9188f2) and rebuild and repeated.
with_fixes_java_vmstructsdump.txt
without_fixes_java_vmstructsdump.txt
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.
Ok, looks good. You can consider the SA changes reviewed.
@turbanoff This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 235 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@plummercj, @mrserb) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@turbanoff |
/sponsor |
Going to push as commit cbe57e8.
Your commit was automatically rebased without conflicts. |
@mrserb @turbanoff Pushed as commit cbe57e8. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Usage of thread-safe collection Stack is unnecessary. It's recommended to use ArrayDequeue if a thread-safe implementation is not needed.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5294/head:pull/5294
$ git checkout pull/5294
Update a local copy of the PR:
$ git checkout pull/5294
$ git pull https://git.openjdk.java.net/jdk pull/5294/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5294
View PR using the GUI difftool:
$ git pr show -t 5294
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5294.diff