RFR: 8255416: Investigate err_msg to detect unnecessary uses
Thomas Stuefe
stuefe at openjdk.java.net
Wed Oct 28 18:41:44 UTC 2020
On Wed, 28 Oct 2020 16:46:47 GMT, Anton Kozlov <akozlov at openjdk.org> wrote:
> Hi,
>
> When a single string without formatting arguments is provided to `err_msg`, it's redundancy, as the same message could be used without any err_msg. This is a follow-up to the discussion https://github.com/openjdk/jdk/pull/812#discussion_r511784050
>
> Please review a change that makes `err_msg` with a single string to fail compilation.
>
> Detected uses of err_msg with a single string were eliminated as well.
Changes requested by stuefe (Reviewer).
src/hotspot/share/gc/shenandoah/mode/shenandoahMode.hpp line 44:
> 42: if ((name)) { \
> 43: const char* msg = "GC mode needs -XX:-" #name " to work correctly"; \
> 44: vm_exit_during_initialization("Error", msg); \
Same as above, can be inlined into one call. No need for the temporary variable.
src/hotspot/share/utilities/formatBuffer.hpp line 124:
> 122: // If compilation fails because of ambiguity between this and real constructor, you
> 123: // could drop err_msg use at all.
> 124: inline FormatErrBuffer(const char* msg) { ShouldNotReachHere(); }
I do not think this is a good idea (apart from it being too complex for a not that serious issue).
The asserts fire, of course, only at runtime. But this function is used usually in some error context, as part of of error reporting. I do not think our tests cover all those paths.
Either somehow make this a compile time error or just leave it as it is. We also could, since this buffer object is used usually as input for vm_exit_during_initialization(), give that function a var-arg overload.
-------------
PR: https://git.openjdk.java.net/jdk/pull/905
More information about the shenandoah-dev
mailing list