Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit JUnit support and reduce/avoid use of build-time initialization #613

Open
fniephaus opened this issue Aug 5, 2024 · 0 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@fniephaus
Copy link
Member

We currently build-time initialize NativeImageJUnitLauncher, which references TestPlan and transitively many other JUnit classes. As a result, we also have to mark lots of other classes for build-time initialization (here's an example).

--strict-image-heap requires all classes to be marked for build-time init that become part of the image heap. However, JUnit provides various mechanisms that allow users to pull in their own classes. One such mechanism is @ParameterizedTest with its @ValueSource and @EnumSource. The moment an object becomes part of the heap of a user-defined type, native testing fails because those types also need to be explicitly marked for build-time init.

Generally, we are aiming at keeping the use of build-time init at a minimum (e.g., oracle/graal#7488), so it makes sense to revisit our JUnit support and reduce or even avoid the use of build-time initialization.

This probably means that test discovery also needs to run at run time, unless it can somehow be pre-computed at build-time and stored in such a way that user-defined types cannot end up in the heap. However, it also probably means that we need to register all methods for reflection that JUnit can potentially access reflectively (e.g., to instantiate and run a test case).

@fniephaus fniephaus added the enhancement New feature or request label Aug 5, 2024
@vjovanov vjovanov assigned vjovanov and dnestoro and unassigned vjovanov Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants