RFR: 8271525: ResourceHashtableBase::iterate() should not declared as const

Coleen Phillimore coleenp at openjdk.java.net
Fri Jul 30 21:32:29 UTC 2021


On Fri, 30 Jul 2021 04:16:59 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> `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`.

If you want to enforce not modifying the items in the table, the table can be instantiated with a const type.  I think that's what you want.

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

PR: https://git.openjdk.java.net/jdk/pull/4942


More information about the hotspot-dev mailing list