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

Use ByteBuddy in unit tests to avoid having to add add-opens to unit tests #171

Merged
merged 3 commits into from
Jun 24, 2024

Conversation

shartte
Copy link
Contributor

@shartte shartte commented Jun 24, 2024

What it says on the tin :-)

We use the ByteBuddy agent implicitly already through Mockito.

@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented Jun 24, 2024

  • Publish PR to GitHub Packages

Last commit published: a84c04e67e087497239e6c93e4848384b20bbc34.

PR Publishing

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven {
        name 'Maven for PR #171' // https://github.com/neoforged/FancyModLoader/pull/171
        url 'https://prmaven.neoforged.net/FancyModLoader/pr171'
        content {
            includeModule('net.neoforged.fancymodloader', 'junit-fml')
            includeModule('net.neoforged.fancymodloader', 'earlydisplay')
            includeModule('net.neoforged.fancymodloader', 'loader')
        }
    }
}

@shartte shartte requested a review from Matyrobbrt June 24, 2024 16:56
@shartte shartte merged commit f32a089 into neoforged:main Jun 24, 2024
3 checks passed
@shartte shartte deleted the bytebuddy-add-opens branch June 24, 2024 18:33
@SquidDev
Copy link

SquidDev commented Jul 1, 2024

Apologies if you're already aware, but there's plans to disable dynamic loading of agents (and so ByteBuddyAgent.install) in the future — see JEP 451. This definitely doesn't matter right now, as NeoForged is pinned to Java 21, but worth bearing in mind for the future!

@shartte
Copy link
Contributor Author

shartte commented Jul 1, 2024

Apologies if you're already aware, but there's plans to disable dynamic loading of agents (and so ByteBuddyAgent.install) in the future — see JEP 451. This definitely doesn't matter right now, as NeoForged is pinned to Java 21, but worth bearing in mind for the future!

I am aware, yes. I do however think that the ecosystem will not stand this if it breaks use of Mocking frameworks in Gradle/IntelliJ (Mockito is a prominent example), so I am confident that either:

  • They'll keep the XX flag to allow it
  • They'll remove it only once Gradle/IJ actually improved their support to set the javaagent on the CLI for tests

In general the only thing really missing to drop the dynamic attach is IJ and Eclipse reading agent settings from Gradle.

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.

3 participants