diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 79c9cd7ab..fc1bf3cd3 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -18,8 +18,8 @@ jobs: - name: Set up JDK uses: actions/setup-java@v2 with: - java-version: 14 - distribution: 'zulu' + java-version: 17 + distribution: 'temurin' - name: Run Tests run: mvn test -B diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b17b71689..4b44456b2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,8 +11,8 @@ jobs: - name: Set up Maven Central Repository uses: actions/setup-java@v2 with: - java-version: '14' - distribution: 'zulu' + java-version: '17' + distribution: 'temurin' - name: Set maven settings.xml uses: whelk-io/maven-settings-xml-action@v20 with: diff --git a/.github/workflows/spotless.yml b/.github/workflows/spotless.yml index fbb86aaa3..968b4ad8c 100644 --- a/.github/workflows/spotless.yml +++ b/.github/workflows/spotless.yml @@ -18,8 +18,8 @@ jobs: - name: Set up JDK uses: actions/setup-java@v2 with: - java-version: 14 - distribution: 'zulu' + java-version: 17 + distribution: 'temurin' - name: Check with Spotless run: mvn clean spotless:check diff --git a/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java17.java b/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java17.java new file mode 100644 index 000000000..2a7edf8fa --- /dev/null +++ b/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java17.java @@ -0,0 +1,42 @@ +public class Java17 { + + public Java17() { + Shape s = Math.random() > 0.5 ? new Circle(42) : new Rect(1, 4); + Shape c = new Circle(432); + Shape r = new Rect(1, 2); + double area = s.area() + c.area() + r.area(); + System.out.println(area); + } + + private abstract static sealed class Shape permits Circle, Rect { + public abstract double area(); + } + + private static final class Circle extends Shape { + private double r; + + private Circle(double r) { + this.r = r; + } + + @Override + public double area() { + return 2 * Math.PI * r * r; + } + } + + private static final class Rect extends Shape { + private final int a; + private final int b; + + private Rect(int a, int b) { + this.a = a; + this.b = b; + } + + @Override + public double area() { + return a * b; + } + } +} diff --git a/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java17Preview.java b/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java17Preview.java new file mode 100644 index 000000000..00cc243ca --- /dev/null +++ b/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java17Preview.java @@ -0,0 +1,44 @@ +public class Java17Preview { + + public Java17Preview() { + Shape s = Math.random() > 0.5 ? new Circle(42) : new Rect(1, 4); + double area = switch (s) { + case Circle c -> c.area() + 0.123; + case Rect r -> r.area() + r.area(); + }; + + System.out.println(area); + } + + private abstract static sealed class Shape permits Circle, Rect { + public abstract double area(); + } + + private static final class Circle extends Shape { + private double r; + + private Circle(double r) { + this.r = r; + } + + @Override + public double area() { + return 2 * Math.PI * r * r; + } + } + + private static final class Rect extends Shape { + private final int a; + private final int b; + + private Rect(int a, int b) { + this.a = a; + this.b = b; + } + + @Override + public double area() { + return a * b; + } + } +} diff --git a/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java17.java b/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java17.java new file mode 100644 index 000000000..f09bde3be --- /dev/null +++ b/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java17.java @@ -0,0 +1,42 @@ +public class Java17 { + + public Java17() { + Shape s = Math.random() > 0.6 ? new Circle(5435) : new Rect(54, 4); + Shape c = new Circle(43425); + Shape r = new Rect(14, 21); + double area = s.area() + c.area() + r.area(); + System.out.println(area); + } + + private abstract static sealed class Shape permits Circle, Rect { + public abstract double area(); + } + + private static final class Circle extends Shape { + private double r; + + private Circle(double r) { + this.r = r; + } + + @Override + public double area() { + return 2 * Math.PI * r * r; + } + } + + private static final class Rect extends Shape { + private final int a; + private final int b; + + private Rect(int a, int b) { + this.a = a; + this.b = b; + } + + @Override + public double area() { + return a * b; + } + } +} diff --git a/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java17Preview.java b/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java17Preview.java new file mode 100644 index 000000000..76be4842c --- /dev/null +++ b/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java17Preview.java @@ -0,0 +1,44 @@ +public class Java17Preview { + + public Java17Preview() { + Shape s = Math.random() > 0.5 ? new Circle(24) : new Rect(5, 1); + double area = switch (s) { + case Circle c -> c.area() + 2.345; + case Rect r -> r.area() + r.area(); + }; + + System.out.println(area); + } + + private abstract static sealed class Shape permits Circle, Rect { + public abstract double area(); + } + + private static final class Circle extends Shape { + private double r; + + private Circle(double r) { + this.r = r; + } + + @Override + public double area() { + return 2 * Math.PI * r * r; + } + } + + private static final class Rect extends Shape { + private final int a; + private final int b; + + private Rect(int a, int b) { + this.a = a; + this.b = b; + } + + @Override + public double area() { + return a * b; + } + } +} diff --git a/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/blacklist.txt b/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/blacklist.txt index e3701b145..163769f63 100644 --- a/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/blacklist.txt +++ b/jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/blacklist.txt @@ -1 +1 @@ -Java16.java \ No newline at end of file +Java17Preview.java \ No newline at end of file diff --git a/pom.xml b/pom.xml index b17856672..ec0a4f401 100644 --- a/pom.xml +++ b/pom.xml @@ -79,8 +79,8 @@ UTF-8 - 14 - 14 + 17 + 17 2.21.0