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

[575] junit-native does not support org.junit.rules.ExpectedException. #576

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tzezula
Copy link

@tzezula tzezula commented Feb 19, 2024

Fixies issue #575 by registering all used subclasses of TypeSafeMatcher and TypeSafeDiagnosingMatcher for reflective access to all declared methods.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Feb 19, 2024
@fniephaus
Copy link
Member

@tzezula I added more reviewers. Could you please add a test or test project for this? Not sure whether this will do the trick. Instead of adding it as a new sample, maybe you could extend an existing one?

}
};
if (typeSafeMatcher != null) {
access.registerSubtypeReachabilityHandler(registerMatcherForReflection, typeSafeMatcher);
Copy link
Member

Choose a reason for hiding this comment

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

How do we guarantee this does not affect user code by registering their classes?

Copy link
Author

Choose a reason for hiding this comment

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

@vjovanov: Good question. I believe it's acceptable to register even the user classes. This is because subclasses of org.hamcrest.TypeSafeMatcher and org.hamcrest.TypeSafeDiagnosingMatcher that utilize the default constructor rely on Class.getDeclaredMethods() to function properly. You can refer to TypeSafeMatcher#TypeSafeMatcher(), which indirectly invokes ReflectiveTypeFinder#findExpectedType(). Ideally, we would only mark the matchesSafely method for getDeclaredMethods, but unfortunately, this is not possible.

@tzezula tzezula force-pushed the issue-575 branch 2 times, most recently from f5f1c11 to 01c5970 Compare February 20, 2024 14:55
@tzezula
Copy link
Author

tzezula commented Feb 21, 2024

@fniephaus I've added the test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants