Skip to content

Commit

Permalink
8309134: Augment test/langtools/tools/javac/versions/Versions.java fo…
Browse files Browse the repository at this point in the history
…r JDK 21 language changes

Reviewed-by: jjg
  • Loading branch information
jddarcy committed May 30, 2023
1 parent de7fd1c commit cb40db0
Showing 1 changed file with 44 additions and 15 deletions.
59 changes: 44 additions & 15 deletions test/langtools/tools/javac/versions/Versions.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -89,7 +89,7 @@ static enum SourceTarget {
EIGHTEEN(false, "62.0", "18", Versions::checksrc18),
NINETEEN(false, "63.0", "19", Versions::checksrc19),
TWENTY(false, "64.0", "20", Versions::checksrc20),
TWENTY_ONE(false,"65.0", "21", Versions::checksrc20);
TWENTY_ONE(false,"65.0", "21", Versions::checksrc21);

private final boolean dotOne;
private final String classFileVer;
Expand Down Expand Up @@ -248,85 +248,97 @@ protected void check(String major, List<String> args) {
protected void checksrc8(List<String> args) {
printargs("checksrc8", args);
expectedPass(args, List.of("New7.java", "New8.java"));
expectedFail(args, List.of("New10.java"));
expectedFail(args, List.of("New10.java", "New11.java", "New14.java", "New15.java",
"New16.java", "New17.java", "New21.java"));

}

protected void checksrc9(List<String> args) {
printargs("checksrc9", args);
expectedPass(args, List.of("New7.java", "New8.java"));
expectedFail(args, List.of("New10.java"));
expectedFail(args, List.of("New10.java", "New11.java", "New14.java", "New15.java",
"New16.java", "New17.java", "New21.java"));
}

protected void checksrc10(List<String> args) {
printargs("checksrc10", args);
expectedPass(args, List.of("New7.java", "New8.java", "New10.java"));
expectedFail(args, List.of("New11.java"));
expectedFail(args, List.of("New11.java", "New14.java", "New15.java",
"New16.java", "New17.java", "New21.java"));
}

protected void checksrc11(List<String> args) {
printargs("checksrc11", args);
expectedPass(args, List.of("New7.java", "New8.java", "New10.java", "New11.java"));
expectedFail(args, List.of("New14.java"));
expectedFail(args, List.of("New14.java", "New15.java", "New16.java", "New17.java", "New21.java"));
}

protected void checksrc12(List<String> args) {
printargs("checksrc12", args);
expectedPass(args, List.of("New7.java", "New8.java", "New10.java", "New11.java"));
expectedFail(args, List.of("New14.java"));
expectedFail(args, List.of("New14.java", "New15.java", "New16.java", "New17.java", "New21.java"));
}

protected void checksrc13(List<String> args) {
printargs("checksrc13", args);
expectedPass(args, List.of("New7.java", "New8.java", "New10.java", "New11.java"));
expectedFail(args, List.of("New14.java"));
expectedFail(args, List.of("New14.java", "New15.java", "New16.java", "New17.java", "New21.java"));
}

protected void checksrc14(List<String> args) {
printargs("checksrc14", args);
expectedPass(args, List.of("New7.java", "New8.java", "New10.java", "New11.java",
"New14.java"));
expectedFail(args, List.of("New15.java"));
expectedFail(args, List.of("New15.java", "New16.java", "New17.java", "New21.java"));
}

protected void checksrc15(List<String> args) {
printargs("checksrc15", args);
expectedPass(args, List.of("New7.java", "New8.java", "New10.java", "New11.java",
"New14.java", "New15.java"));
expectedFail(args, List.of("New16.java"));
expectedFail(args, List.of("New16.java", "New17.java", "New21.java"));
}

protected void checksrc16(List<String> args) {
printargs("checksrc16", args);
expectedPass(args, List.of("New7.java", "New8.java", "New10.java", "New11.java",
"New14.java", "New15.java", "New16.java"));
expectedFail(args, List.of("New17.java"));
expectedFail(args, List.of("New17.java", "New21.java"));
}

protected void checksrc17(List<String> args) {
printargs("checksrc17", args);
expectedPass(args, List.of("New7.java", "New8.java", "New10.java", "New11.java",
"New14.java", "New15.java", "New16.java", "New17.java"));
// Add expectedFail after new language features added in a later release.
expectedFail(args, List.of("New21.java"));
}

protected void checksrc18(List<String> args) {
printargs("checksrc18", args);
expectedPass(args, List.of("New7.java", "New8.java", "New10.java", "New11.java",
"New14.java", "New15.java", "New16.java", "New17.java"));
// Add expectedFail after new language features added in a later release.
expectedFail(args, List.of("New21.java"));
}

protected void checksrc19(List<String> args) {
printargs("checksrc19", args);
expectedPass(args, List.of("New7.java", "New8.java", "New10.java", "New11.java",
"New14.java", "New15.java", "New16.java", "New17.java"));
// Add expectedFail after new language features added in a later release.
expectedFail(args, List.of("New21.java"));
}

protected void checksrc20(List<String> args) {
printargs("checksrc20", args);
expectedPass(args, List.of("New7.java", "New8.java", "New10.java", "New11.java",
"New14.java", "New15.java", "New16.java", "New17.java"));
expectedFail(args, List.of("New21.java"));
}

protected void checksrc21(List<String> args) {
printargs("checksrc21", args);
expectedPass(args, List.of("New7.java", "New8.java", "New10.java", "New11.java",
"New14.java", "New15.java", "New16.java", "New17.java",
"New21.java"));
// Add expectedFail after new language features added in a later release.
}

Expand Down Expand Up @@ -384,7 +396,6 @@ protected void pass(List<String> args) {
failedCases++;

}

}

protected void fail(List<String> args) {
Expand Down Expand Up @@ -569,6 +580,24 @@ public static final class Wax extends Seal {}
}
"""
);

/*
* Create a file with a new feature in 21, not in 20 : pattern matching for switch
*/
writeSourceFile("New21.java",
"""
public class New21 {
public static void main(String... args) {
Object o = new Object(){};
System.out.println(switch (o) {
case Integer i -> String.format("%d", i);
default -> o.toString();
});
}
}
"""
);
}

protected boolean checkClassFileVersion
Expand Down

1 comment on commit cb40db0

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.