-
-
Notifications
You must be signed in to change notification settings - Fork 639
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
Make VAVr
Java 8 & 9 compatible
#2105
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ We use these goals frequently to keep the dependencies and plugins up-to-date: | |
<description>Vavr (formerly called Javaslang) is an object-functional language extension to Java 8+.</description> | ||
<modules> | ||
<module>vavr</module> | ||
<module>vavr-benchmark</module> | ||
<module>vavr-match</module> | ||
<module>vavr-test</module> | ||
</modules> | ||
|
@@ -61,28 +62,28 @@ We use these goals frequently to keep the dependencies and plugins up-to-date: | |
<assertj.core.version>3.8.0</assertj.core.version> | ||
<eclipse.lifecycle.mapping.version>1.0.0</eclipse.lifecycle.mapping.version> | ||
<java.version>1.8</java.version> | ||
<jmh.version>1.18</jmh.version> | ||
<jmh.version>1.19</jmh.version> | ||
<junit.version>4.12</junit.version> | ||
<gwt.version>2.8.0</gwt.version> | ||
<maven.enforcer.version>1.4.1</maven.enforcer.version> | ||
<maven.build-helper.version>1.12</maven.build-helper.version> | ||
<maven.bundle.version>3.2.0</maven.bundle.version> | ||
<maven.build-helper.version>3.0.0</maven.build-helper.version> | ||
<maven.bundle.version>3.3.0</maven.bundle.version> | ||
<maven.clean.version>3.0.0</maven.clean.version> | ||
<maven.install.version>2.5.2</maven.install.version> | ||
<maven.compiler.version>3.6.0</maven.compiler.version> | ||
<maven.compiler.version>3.7.0</maven.compiler.version> | ||
<maven.deploy.version>2.8.2</maven.deploy.version> | ||
<maven.gpg.version>1.6</maven.gpg.version> | ||
<maven.jacoco.version>0.7.8</maven.jacoco.version> | ||
<maven.jacoco.version>0.7.9</maven.jacoco.version> | ||
<maven.jar.version>3.0.2</maven.jar.version> | ||
<maven.javadoc.version>2.10.4</maven.javadoc.version> | ||
<maven.release.version>2.5.3</maven.release.version> | ||
<maven.versions.version>2.3</maven.versions.version> | ||
<maven.versions.version>2.4</maven.versions.version> | ||
<maven.surefire.version>2.19.1</maven.surefire.version> | ||
<maven.source.version>3.0.1</maven.source.version> | ||
<maven.exec.version>1.5.0</maven.exec.version> | ||
<maven.gwt.plugin>1.0-rc-6</maven.gwt.plugin> | ||
<scala.maven.version>3.3.1</scala.maven.version> | ||
<scala.version>2.11.7</scala.version> | ||
<scala.version>2.12.2</scala.version> | ||
</properties> | ||
<dependencyManagement> | ||
<dependencies> | ||
|
@@ -253,6 +254,8 @@ We use these goals frequently to keep the dependencies and plugins up-to-date: | |
<arg>-Xlint:all</arg> | ||
<!-- Workaround for JDK bug https://bugs.openjdk.java.net/browse/JDK-6999068 --> | ||
<arg>-Xlint:-processing</arg> | ||
<!-- Enable Java 9 compilation with 1.8 compatibility --> | ||
<arg>-Xlint:-options</arg> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do we use the options? Is it the implicit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is needed because
|
||
</compilerArgs> | ||
</configuration> | ||
</plugin> | ||
|
@@ -456,12 +459,6 @@ We use these goals frequently to keep the dependencies and plugins up-to-date: | |
<!-- A profile for running the benchmarks --> | ||
<profile> | ||
<id>benchmark</id> | ||
<modules> | ||
<module>vavr</module> | ||
<module>vavr-benchmark</module> | ||
<module>vavr-match</module> | ||
<module>vavr-test</module> | ||
</modules> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,9 +112,10 @@ public static <T> Lazy<T> of(Supplier<? extends T> supplier) { | |
* @return A lazy sequence of values. | ||
* @throws NullPointerException if values is null | ||
*/ | ||
@SuppressWarnings("Convert2MethodRef") // TODO should be fixed in JDK 9 and Idea | ||
public static <T> Lazy<Seq<T>> sequence(Iterable<? extends Lazy<? extends T>> values) { | ||
Objects.requireNonNull(values, "values is null"); | ||
return Lazy.of(() -> Vector.ofAll(values).map(Lazy::get)); | ||
return Lazy.of(() -> Vector.ofAll(values).map(lazy -> lazy.get())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does a java 9 build not compile with the method reference? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's weird :/ |
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,10 +40,10 @@ public static class ClassAssert { | |
this.clazz = clazz; | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
public void isNotInstantiable() { | ||
final Constructor<?> cons; | ||
try { | ||
cons = clazz.getDeclaredConstructor(); | ||
final Constructor<?> cons = clazz.getDeclaredConstructor(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏼 |
||
Assertions.assertThat(cons.isAccessible()).isFalse(); | ||
} catch (NoSuchMethodException e) { | ||
throw new AssertionError("no default constructor found"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,21 +19,23 @@ | |
*/ | ||
package io.vavr; | ||
|
||
import io.vavr.control.Either; | ||
import io.vavr.match.annotation.Patterns; | ||
import io.vavr.collection.List; | ||
import io.vavr.control.Either; | ||
import io.vavr.control.Option; | ||
import io.vavr.control.Option.Some; | ||
import io.vavr.match.annotation.Patterns; | ||
import io.vavr.match.annotation.Unapply; | ||
import org.junit.Test; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.Year; | ||
import java.util.function.BiFunction; | ||
import java.util.function.Predicate; | ||
|
||
import static io.vavr.API.$; | ||
import static io.vavr.API.*; | ||
import static io.vavr.Patterns.*; | ||
import static io.vavr.MatchTest_DeveloperPatterns.$Developer; | ||
import static io.vavr.Patterns.*; | ||
import static io.vavr.Predicates.*; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
|
@@ -318,9 +320,9 @@ public void shouldDecomposeListOfTuple3() { | |
@SuppressWarnings("UnnecessaryLocalVariable") | ||
@Test | ||
public void shouldDecomposeListWithNonEmptyTail() { | ||
final List<Option<Number>> intOptionList = List.of(Option.some(1), Option.some(2.0)); | ||
final String actual = Match(intOptionList).of( | ||
Case($Cons($Some($(1)), $Cons($Some($(2.0)), $())), (x, xs) -> { | ||
final List<Option<Number>> numberOptionList = List.of(Option.some(1), Option.some(2.0)); | ||
final String actual = Match(numberOptionList).of( | ||
Case($Cons($Some($(1)), $Cons($Some($(2.0)), $())), (Some<Number> x, List<Option<Number>> xs) -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @danieldietrich, it only compiles on |
||
// types are inferred correctly! | ||
final Some<Number> head = x; | ||
final List<Option<Number>> tail = xs; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does a Java 9 build require now this module? Just asking...
I ask myself if now a jar is released for vavr-benchmark, too (i.e. to maven central).
Is the benchmark profile then still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in a separate commit, because it's obviously not strictly related :)
It should be part of the project so that it is compile-time checked. I will disable the deployment, it's a valid concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked it, since it has tests only, there's nothing to deploy.
The
benchmark
profile has a run config also, so it still has its purpose - though we can remove the duplicatemodules
part, thanks for the note! :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I had to test this module for Java 9 compatibility also, that's why I modified this part also)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The benchmarks should not be part of the main build, even if it is a minimal benchmark.
If there are assertions/checks, they should be moved to the vavr core unit tests.
Benchmarks are about measuring. The only valid case to run them as part of the tests would be that we break the build if the performance decreases. But that is (currently) not possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The benchmarks aren't run during the build. Not even the assertions. just the compilation.
They are just part of the project, to make sure any refactoring is propagated there also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, that's cool.