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
Surefire test exclusion can cause NoClassDefFoundError
on case-insensitive file system
#3536
Comments
Here's what roughly happens:
I've tried setting the
The root cause is the same. This is bound to happen at some point when these classes are used. If it doesn't happen during test discovery it would happen at runtime when these classes are loaded. Therefore, I think this needs to be changed in Checkstyle, if they decide to support development on macOS (and potentially other case-insensitive file systems). I know too little about the project to suggest a fix but I wonder why these resources are even compiled (maybe to check that they actually do compile?) since IIRC Checkstyle operates on source code, not byte code. If the |
Running the Checkstyle Maven build using
-Dtest='!someTest'
on a case-insensitive filesystem, Surefire reportsTestEngine with ID 'junit-jupiter' failed to discover tests
. If a user hits this issue, then the root cause will not be easy to debug, as it requires (very) careful inspection of the*.dump
file insidetarget/surefire-reports
.Steps to reproduce
The following commands demonstrate the issue, if executed in the context of a case-insensitive filesystem:
This will produce:
Context
The above reproduction steps were executed with Java 17.0.8.1 and Maven 3.9.5; the selected Checkstyle tag uses Surefire 3.2.1 and Junit 5.9.2. Macos-using colleagues of mine hit this issue due to this code. On Linux I did not hit the issue, though I could reproduce it by creating an in-memory FAT filesystem.
The issue is triggered by these two nested classes, named
p
andP
, which on a case-insensitive filesystem cause bytecode to be written to the same.class
file. Defining such "colliding" classes is an anti-pattern, but presumably Checkstyle did this for testing purposes, and ideally JUnit handles this case more robustly.Of note: the issue does not manifest if Surefire is instructed to perform a "positive" rather than a "negative" filter, using e.g.
-Dtest='foo'
.(I filed this issue against JUnit rather than Surefire, as the stack trace indicates the error happens quite "deep" inside JUnit code. Did not yet investigate whether an easy fix exists.)
Deliverables
CC @romani and @rnveach as Checkstyle maintainers (just as an FYI). CC @rickie and @mohamedsamehsalah as the colleagues who helped debug this.
The text was updated successfully, but these errors were encountered: