JDK-8270073 : Simplify the Arguments annotation when all arguments have the same Argument value
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,18
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2021-07-08
  • Updated: 2021-08-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Description
Sometimes a method has multiple parameters for which the user wants to specify the same argument value. At the moment, one need to specify an Argument value for each parameter:

@Test
@Arguments({Argument.DEFAULT, Argument.DEFAULT})
public void twoArgsRandomOnce(char x, byte y) {
    // do something
}

This could be simplified such that the user only need to specify one argument which is applied to each parameter:

@Test
@Arguments(Argument.DEFAULT)
public void twoArgsRandomOnce(char x, byte y) {
    // do something
}

A common use-case would be for methods that need to have random values (Argument.RANDOM_ONCE, Argument.RANDOM_EACH).

There are multiple ways to do that:
- @Arguments could either be processed differently to automatically apply a single Argument value to all remaining parameters. However, if the user specified only one Argument value by mistake, he will not be warned by the silent application.
- Adding a new annotation to achieve this, for example, @ArgumentsAll (I would refrain from adding an additional attribute to @Arguments as we are then no longer able to feed it a list without specifying the single default attribute).