RFR: 8311661: Resolve duplicate symbol of StringTable::StringTable with JDK static linking [v2]
Jiangli Zhou
jiangli at openjdk.org
Wed Jul 12 01:29:24 UTC 2023
On Tue, 11 Jul 2023 21:08:01 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> > > Something like this might work. We need to enclose all declarations inside `namespace hotspot {...}`, so all .hpp files need to be touched (which I think is OK).
> >
> >
> > I just looked briefly. For `.hpp` files alone in `hotspot` dir, we have 2276. Although the number of files is large, I think the actual changes are trivial. Still want to make sure everyone is okay with the changes at this scale.
>
> If adding `using hotspot` in precompiled.hpp works, we can roll this out in stages. At the beginning, we can just put the three problematic classes (`Thread`, `StringTable` and `ProfileData`) in the `hotspot` namespace, so only a few files need to be changed.
Moving to the namespace incrementally seems to be reasonable to me. Will let others to chime in on this for their thoughts.
Add `using <namespace>` to precompiled.hpp does help avoid adding `<namespace>::` in many places. We still need to put the implementation code inside `namespace <namespace> { ...}`, or use `<namespace>::`. I experimented with StringTable and only needed to edit stringTable.* and precompiled.hpp. I tested with and without `--disable-precompiled-headers` and both built ok.
C++ references that I read discourages using `using` directive. https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice has some helpful information. For the namespace usages within hotspot, there is probably no concern with pollution. It seems eventually all code would be moved to the namespace then `using` would not be needed.
`Thread` change would be bigger. There are references like `class Thread;`. It seems to be a good idea to be handled with https://bugs.openjdk.org/browse/JDK-8311846 separately.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14808#issuecomment-1631715225
More information about the graal-dev
mailing list