RFR: 8271525: ResourceHashtableBase::iterate() should not declared as const
Ioi Lam
iklam at openjdk.java.net
Fri Jul 30 14:36:42 UTC 2021
`ResourceHashtableBase::iterate()` is declared `const`, but it can actually change the contents of the table. The same is true for `ResourceHashtableBase::get()`, which returns a non-`const` pointer to the value, allowing the caller to modify it.
We should declare these two functions as non-`const`. This will also remove a lot of ugly `const_cast<>` code.
The `iterate()` API is tightened such that the `do_entry()` function can modify the `value` but not the `key`.
-------------
Commit messages:
- added const_iterate()
- added const version of get()
- fixed spacing
- fixed typos
- also make the get() function non-const, since it returns a pointer to the value, which the caller can modify
- step2 -- make iterate() a non-const function
- step1 -- keep iterate() as a const function, but clean up the rest of the code
Changes: https://git.openjdk.java.net/jdk/pull/4942/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4942&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8271525
Stats: 60 lines in 6 files changed: 29 ins; 4 del; 27 mod
Patch: https://git.openjdk.java.net/jdk/pull/4942.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/4942/head:pull/4942
PR: https://git.openjdk.java.net/jdk/pull/4942
More information about the hotspot-dev
mailing list