Integrated: 8264565: Templatize num_arguments() functions of DCmd subclasses
Ioi Lam
iklam at openjdk.java.net
Tue Apr 6 03:30:29 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; }
This pull request has now been integrated.
Changeset: ff223530
Author: Ioi Lam <iklam at openjdk.org>
URL: https://git.openjdk.java.net/jdk/commit/ff223530
Stats: 277 lines in 8 files changed: 27 ins; 241 del; 9 mod
8264565: Templatize num_arguments() functions of DCmd subclasses
Reviewed-by: coleenp, dholmes
-------------
PR: https://git.openjdk.java.net/jdk/pull/3312
More information about the hotspot-dev
mailing list