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

Allow ModuleClassLoader to optionally delegate class-loading to parent #60

Merged
merged 3 commits into from
Jan 13, 2024

Conversation

shartte
Copy link
Contributor

@shartte shartte commented Dec 23, 2023

The goal is to add a new entrypoint to https://github.com/McModLauncher/bootstraplauncher for JUnit runners, which disables classloader isolation. This change adds the needed constructor to ModuleClassLoader to enable that.

This is used to allow test-classes to live in the GAME layer, while still loading JUnit and other testing library classes found on the normal classpath. When being run by a unit testing framework, we do not control the JVM entrypoint like we normally do, and Gradle for example will class-load JUnit before calling any other hook. Our test classes need to refer to those same loaded classes, making it easier if isolation is disabled in such scenarios.

@marchermans
Copy link
Member

So, principally, I understand this idea.
However, given that we usually do this with a filter instead of a blanket allow-all, I was wondering if you had any way of figuring out if such a filter was even possible in this case?

@shartte
Copy link
Contributor Author

shartte commented Dec 26, 2023

So, principally, I understand this idea. However, given that we usually do this with a filter instead of a blanket allow-all, I was wondering if you had any way of figuring out if such a filter was even possible in this case?

No since this should also apply to testing libraries added by users in userdev, and we cannot know those packages/libraries apriori.
In addition, this does not change anything about any environment other than the new JUnit environment. Only there will this take effect.

Copy link
Member

@marchermans marchermans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have thought about this for a while.

Allthough I am convinced that the JUnit API provides other, more standardized, ways of doing testing in a modularly isolated environment, right now we do not have the time.

As such this is at least a bridge and a gap to allow for this to work.

However, since I want to be clear that this should not be used in production, what so ever, I want a very load warning in the source code, in the form of previously mentioned annotations and documentation. As well as, a very loud warning in a log file!

Please add those and then this is good.

@marchermans marchermans merged commit bbf1ff4 into McModLauncher:main Jan 13, 2024
1 check passed
@shartte shartte deleted the junit branch January 13, 2024 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants