Skip to content

chore(Core): Avoid injection errors for Java 26#2244

Open
l-1squared wants to merge 9 commits into
masterfrom
fix/no-injection-errors
Open

chore(Core): Avoid injection errors for Java 26#2244
l-1squared wants to merge 9 commits into
masterfrom
fix/no-injection-errors

Conversation

@l-1squared

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent ByteBuddy class injection failures on newer JVMs (Java 26) by conditionally falling back to a wrapper class loading strategy when reflective injection is not available, and it extends ScenarioExecutorTest to validate lifecycle behavior under different class loading strategies.

Changes:

  • Update ByteBuddyStageClassCreator to select INJECTION only when ClassInjector.UsingReflection is available; otherwise use WRAPPER.
  • Add/extend tests in ScenarioExecutorTest to validate wrapper/injection behavior for lifecycle methods, visibility edge-cases (package-private/protected), and class identity differences across class loaders.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
jgiven-core/src/main/java/com/tngtech/jgiven/impl/ByteBuddyStageClassCreator.java Adjusts ByteBuddy class loading strategy selection to avoid injection-related failures.
jgiven-core/src/test/java/com/tngtech/jgiven/impl/ScenarioExecutorTest.java Adds tests covering wrapper vs injection lifecycle execution and classloader identity edge-cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread jgiven-core/src/main/java/com/tngtech/jgiven/impl/ByteBuddyStageClassCreator.java Outdated
Comment thread jgiven-core/src/test/java/com/tngtech/jgiven/impl/ScenarioExecutorTest.java Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

Comment thread jgiven-core/src/test/java/com/tngtech/jgiven/impl/ScenarioExecutorTest.java Outdated
Comment thread jgiven-core/src/test/java/com/tngtech/jgiven/impl/ScenarioExecutorTest.java Outdated
Comment thread jgiven-core/src/main/java/com/tngtech/jgiven/impl/ByteBuddyStageClassCreator.java Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

General comment on this class: it would probably be better to repeat the test cases for the different strategies in more general terms: First, I noticed that the tests are essentially the same -- as are the stage classes (it does not seem to me that this is really necessary given that the executor retrieves the actual instances from the creator anyway). At that point, I would have suggested using nested test classes to group the test cases. But then realizing that they are essentially (did not compare each, tbh.) the same, it seems to me like it should be possible to have one generalized test base and just inherit that in each of those nested classes with some specialized setup for each strategy, no?

@l-1squared
l-1squared force-pushed the fix/no-injection-errors branch from 9dd3526 to 1d7a449 Compare July 24, 2026 06:36
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
@l-1squared
l-1squared force-pushed the fix/no-injection-errors branch 6 times, most recently from 71385e5 to 00987ed Compare July 26, 2026 08:23
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
@l-1squared
l-1squared force-pushed the fix/no-injection-errors branch from 00987ed to 1fa606a Compare July 26, 2026 11:29
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.

JGiven breaks on Java 26+ with the newest (1.18.10) byte-buddy

3 participants