Skip to content

Commit

Permalink
Conditionally instantiates java.sql.Date
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Sep 30, 2024
1 parent 0aa0648 commit dfb7165
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
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]

### Fixed

- Instantiates `java.sql.Date` only when available, so EqualsVerifier no longer throws `NoClassDefFoundError` when it's not available. ([Issue 746](https://github.com/jqno/equalsverifier/issues/746))

## [3.17] - 2024-09-24

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,23 +327,28 @@ private void addDateTimeClasses() {
private void addUncommonClasses() {
addFactory(ThreadLocal.class, simple(a -> ThreadLocal.withInitial(() -> a), null));

// Constructing java.sql.* classes reflectively, because they reside in a different module
// which causes trouble when running EqualsVerifier on the modulepath.
ConditionalInstantiator sqlDate = new ConditionalInstantiator("java.sql.Date");
ConditionalInstantiator sqlTime = new ConditionalInstantiator("java.sql.Time");
ConditionalInstantiator sqlTimestamp = new ConditionalInstantiator("java.sql.Timestamp");
addValues(
java.sql.Date.class,
new java.sql.Date(1337),
new java.sql.Date(42),
new java.sql.Date(1337)
sqlDate.resolve(),
sqlDate.instantiate(classes(long.class), objects(1337)),
sqlDate.instantiate(classes(long.class), objects(42)),
sqlDate.instantiate(classes(long.class), objects(1337))
);
addValues(
java.sql.Time.class,
new java.sql.Time(1337),
new java.sql.Time(42),
new java.sql.Time(1337)
sqlTime.resolve(),
sqlTime.instantiate(classes(long.class), objects(1337)),
sqlTime.instantiate(classes(long.class), objects(42)),
sqlTime.instantiate(classes(long.class), objects(1337))
);
addValues(
java.sql.Timestamp.class,
new java.sql.Timestamp(1337),
new java.sql.Timestamp(42),
new java.sql.Timestamp(1337)
sqlTimestamp.resolve(),
sqlTimestamp.instantiate(classes(long.class), objects(1337)),
sqlTimestamp.instantiate(classes(long.class), objects(42)),
sqlTimestamp.instantiate(classes(long.class), objects(1337))
);

addValues(EventObject.class, new EventObject(1), new EventObject(2), new EventObject(1));
Expand Down

0 comments on commit dfb7165

Please sign in to comment.