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

Show classpath/modulepath in error message #990

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- The line in the error message that shows the version of EqualsVerifier and the JDK, now also indicates whether EqualsVerifier runs on the classpath or the modulepath.

## [3.16.1] - 2024-04-03

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Here's a description of the modules:
| ----------------------------- | --------------------------------------------------------------------- |
| docs | project's Jekyll website |
| equalsverifier-core | the actual EqualsVerifier code |
| equalsverifier-11 | tests for Java 11 and up |
| equalsverifier-11 | logic for modules, tests for Java 11 and up |
| equalsverifier-16 | logic for records, and corresponding tests |
| equalsverifier-17 | logic for sealed classes, and corresponding tests |
| equalsverifier-21 | tests for record pattern matching |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package nl.jqno.equalsverifier.internal.reflection;

public final class ModuleHelper {

private ModuleHelper() {}

public static boolean runsOnModulePath() {
return ModuleLayer.boot().findModule("nl.jqno.equalsverifier").isPresent();

Check warning on line 8 in equalsverifier-11/src/main/java/nl/jqno/equalsverifier/internal/reflection/ModuleHelper.java

View workflow job for this annotation

GitHub Actions / pitest

2 different changes can be made to line 8 without causing a test to fail

replaced boolean return with false for runsOnModulePath (0 tests run BooleanFalseReturnValsMutator) replaced boolean return with true for runsOnModulePath (0 tests run BooleanTrueReturnValsMutator)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@
</unpackOptions>
</binaries>
</moduleSet>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>nl.jqno.equalsverifier:equalsverifier-11</include>
</includes>
<binaries>
<outputDirectory>META-INF/versions/11</outputDirectory>
<unpack>true</unpack>
<includeDependencies>false</includeDependencies>
<unpackOptions>
<excludes>
<exclude>/META-INF/**</exclude>
</excludes>
</unpackOptions>
</binaries>
</moduleSet>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package nl.jqno.equalsverifier.internal.reflection;

/**
* Note: this is a generic implementation for a multi-release jar class.
* See equalsverifier-11 submodule.
*/
public final class ModuleHelper {

private ModuleHelper() {}

public static boolean runsOnModulePath() {
return false;

Check warning on line 12 in equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/ModuleHelper.java

View workflow job for this annotation

GitHub Actions / pitest

A change can be made to line 12 without causing a test to fail

replaced boolean return with true for runsOnModulePath (275 tests run BooleanTrueReturnValsMutator)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package nl.jqno.equalsverifier.internal.util;

import nl.jqno.equalsverifier.internal.reflection.ModuleHelper;

public final class ErrorMessage {

private ErrorMessage() {}
Expand All @@ -10,10 +12,11 @@
public static String suffix() {
return Formatter
.of(
"%%\n(EqualsVerifier %%, JDK %% on %%)",
"%%\n(EqualsVerifier %%, JDK %% running on %%, on %%)",
WEBSITE_URL,
ErrorMessage.class.getPackage().getImplementationVersion(),
System.getProperty("java.version"),
ModuleHelper.runsOnModulePath() ? "modulepath" : "classpath",

Check warning on line 19 in equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/util/ErrorMessage.java

View workflow job for this annotation

GitHub Actions / pitest

A change can be made to line 19 without causing a test to fail

negated conditional (275 tests run NegateConditionalsMutator)
System.getProperty("os.name")
)
.format();
Expand Down
7 changes: 7 additions & 0 deletions equalsverifier-release-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier-11</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier-16</artifactId>
Expand Down
6 changes: 6 additions & 0 deletions equalsverifier-release-nodep/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier-11</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier-16</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void assertPresenceOfCoreClasses() {

public void assertPresenceOfMultiReleaseClasses() {
assertPresenceOf(
"/META-INF/versions/11" + EV + "/internal/reflection/ModuleHelper.class",
"/META-INF/versions/16" + EV + "/internal/reflection/RecordsHelper.class",
"/META-INF/versions/17" + EV + "/internal/reflection/SealedTypesHelper.class"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ public void artifactId() {
@Test
public void dependencies() {
assertAll(
() -> pom.assertNumberOfDependencies(5),
() -> pom.assertNumberOfDependencies(6),
() -> pom.assertDependencyIsOptional(1),
() -> pom.assertDependencyIsOptional(2),
() -> pom.assertDependencyIsOptional(3),
() -> pom.assertDependency(4, "org.objenesis", "objenesis"),
() -> pom.assertDependency(5, "net.bytebuddy", "byte-buddy")
() -> pom.assertDependencyIsOptional(4),
() -> pom.assertDependency(5, "org.objenesis", "objenesis"),
() -> pom.assertDependency(6, "net.bytebuddy", "byte-buddy")
);
}
}
Loading