-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to Java 17. Some tests have to be manually adopted.
- Loading branch information
Showing
9 changed files
with
181 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java17.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java17Preview.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java17.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java17Preview.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/blacklist.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Java16.java | ||
Java17Preview.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters