Skip to content

Commit

Permalink
Update to Java 17. Some tests have to be manually adopted.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfuchss committed Apr 4, 2022
1 parent a835243 commit 53855e1
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/spotless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Java16.java
Java17Preview.java
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>14</maven.compiler.source>
<maven.compiler.target>14</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<spotless.version>2.21.0</spotless.version>
</properties>
<dependencyManagement>
Expand Down

0 comments on commit 53855e1

Please sign in to comment.