RFR: JDK-8334217 : [AIX] Misleading error messages after JDK-8320005 [v2]
Thomas Stuefe
stuefe at openjdk.org
Sat Jun 29 05:51:18 UTC 2024
On Fri, 28 Jun 2024 14:47:47 GMT, Suchismith Roy <sroy at openjdk.org> wrote:
> > > > Are these strings not locale dependent? How would this work with a different locale?
> > >
> > >
> > > In principle this might be the case, but our special code does the existence check beforehand (you know the 'loading a dll twice without getting a new handle') and this check returns the string as is. See `Aix_dlopen()` in porting_aix.cpp.
> >
> >
> > Okay. But grepping for an english error string verbatim seems really iffy. @suchismith1993 Please factor out the string at least, e.g. as a common define.
>
> You mean using a #define ? or declaring a string --> const error_report[] = "No Such File or Directory";
What I meant is to define the string somewhere - be it a constexpr or a define - and pull that definition into *both places* where its used.
Tying important implementation decisions to scanning error message literals is super breaky and violates the principle of least surprise. Someone may change the error message in the future, maybe to enrich it. And nobody would expect someone to scan that message literally and base decisions on that.
Better would be introducing clear error numbers. But by using a central common definition for the string you at least minimize the chance of this breaking if someone changes the error messages, and signal too the code reader that the message may be used somewhere else.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19887#issuecomment-2197994707
More information about the hotspot-runtime-dev
mailing list