RFR: 8264565: Templatize num_arguments() functions of DCmd subclasses
Coleen Phillimore
coleenp at openjdk.java.net
Fri Apr 2 16:50:24 UTC 2021
On Thu, 1 Apr 2021 17:46:22 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> We have many version of `num_arguments()` for the `DCmd` subclasses. They all have identical structure. We should templatize them to reduce duplicated code and avoid cut-and-paste errors.
>
> It's still possible to write a customized `num_arguments()` function (although none of the existing cases needs to do that). The rules are described here:
>
> class DCmd : public ResourceObj {
> ...
> // num_arguments() is used by the DCmdFactoryImpl::get_num_arguments() template functions.
> // - For subclasses of DCmdWithParser, it's calculated by DCmdParser::num_arguments().
> // - Other subclasses of DCmd have zero arguments by default. You can change this
> // by defining your own version of MyDCmd::num_arguments().
> static int num_arguments() { return 0; }
Wow cool and nice.
-------------
Marked as reviewed by coleenp (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/3312
More information about the hotspot-dev
mailing list