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

Drop Java 7 support #833

Merged
merged 22 commits into from
May 5, 2022
Merged

Drop Java 7 support #833

merged 22 commits into from
May 5, 2022

Conversation

marknp
Copy link
Contributor

@marknp marknp commented Mar 12, 2022

This will make Java 8 the minimum required Java version to run ArchUnit tests. We also refactored many internals to use Java 8 streams and lambdas instead of anonymous classes and replaced ArchUnit's own Function, Predicate, Optional and Supplier by the standard JDK ones. Furthermore, we upgraded most dependencies that were only hold back to be Java 7 compatible (like Guava and AssertJ).

Note that this is obviously a breaking change which will make ArchUnit unusable in Java 7 projects and will break all user code that depend on the mentioned ArchUnit types that were replaced by standard types. Thus, this change will only be released with version 1.0.0.

@marknp marknp force-pushed the drop-java7-support branch 6 times, most recently from 8f9d2eb to a90f39f Compare March 18, 2022 16:39
@codecholeric codecholeric force-pushed the drop-java7-support branch 2 times, most recently from ff1d701 to 98f6286 Compare April 9, 2022 10:48
@codecholeric codecholeric changed the title Drop java7 support Drop Java 7 support Apr 10, 2022
@codecholeric codecholeric force-pushed the drop-java7-support branch 2 times, most recently from 6e74bd5 to 5283d33 Compare April 10, 2022 15:51
marknp added 2 commits April 22, 2022 22:48
Signed-off-by: Marion Knopp <marion.knopp@gmail.com>
Signed-off-by: Marion Knopp <marion.knopp@gmail.com>
@codecholeric codecholeric force-pushed the drop-java7-support branch 3 times, most recently from 60e293f to fb1d8d1 Compare April 23, 2022 16:04
@marknp
Copy link
Contributor Author

marknp commented May 2, 2022

there are two commits to update mockito - should we not join this to one?

@codecholeric
Copy link
Collaborator

Oh, those two Mockito-commits are some artifact from rebasing 🙈 The former one should be squashed into the Guava-upgrade, because it has nothing to do with Mockito 😬 Good catch! 👍

codecholeric and others added 10 commits May 3, 2022 14:02
We needed the Android version to be Java 7 compatible. Using a Java 8 compatible version now gives us some benefits (like a `Collector` for `Immutable{List/Set}`).
Note that some `@Nullable` annotation in Guava made it necessary to refactor some code a little, where Spotbugs now complained about possible nullability.

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
We could not use a newer major version because of being Java 7 compatible. Now we can upgrade to the latest version.

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
These dependencies were hold back by the necessity to be Java 7 compatible. Now that we do not need this anymore we can finally upgrade to the latest version.
Note that some `@Nullable` annotation in Guava made it necessary to refactor some code a little, where Spotbugs now complained about possible nullability.

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
By replacing the getters by an API that takes a `Consumer` to iterate over the internal collections we can avoid copying the internal sets to `ImmutableSet` and still keep an immutable API of `ClassFileImportRecord`.

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Signed-off-by: Marion Knopp <marion.knopp@gmail.com>
The main usage was ArchUnit's own `Optional` type, so now almost all usages are already gone.

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Signed-off-by: Marion Knopp <marion.knopp@gmail.com>
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
The only reason where we specifically use a Guava supplier is to leverage the Guava utility class `Suppliers`. From this in turn we only use `memoize` and `ofInstance`. The former one we can simply wrap into an ArchUnit utility class and the latter one does not really provide much value, since `() -> value` is way shorter to read than `Suppliers.ofInstance(value)` anyway.

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Since the API to create a `Stream` from an `Iterable` is so much less user-friendly we should try to offer `Collection` in the API where reasonable. APIs that consume from the user should take `Iterable` if there is no reason for a more narrow type. But APIs that offer to the user should offer `Collection` instead of `Iterable` to make the `Stream` processing simpler.

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
@perlun
Copy link
Contributor

perlun commented Feb 8, 2023

@hankem @codecholeric - I stumbled into this because of the 122c0aa commit. Since ArchCondition#init(Iterable<T>) was previously a part of the public API and is now replaced by ArchCondition#init(Collection<T>), this is actually a breaking change even for projects which are already on Java 8+. 🤔 (that's what got me looking into this in the first place; we have a subclass of ArchCondition which tried to override the old init() signature => compilation error)

Perhaps we could make this more discoverable by adding it to https://github.com/TNG/ArchUnit/releases/tag/v1.0.0-rc1? 🤔 Just a list below the ArchUnit now needs at least Java 8 to run (see https://github.com/TNG/ArchUnit/pull/833) line with something like this could do:

  • Iterable in user APIs like ArchCondition has now been replaced by Collection

There might be other things worth mentioning there as well, I'll leave it up to your good judgment to decide on that. 👍 The ArchUnit Optional to java.util.Optional is clearly one such case, but #634 is helpful in this (= as I mentioned elsewhere, if people have upgraded to 0.23.1 before they attempt to upgrade to 1.0.0, they are typically much better off, seeing the deprecations before it's "too late")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants