RFR: 8255561: add tests to check binary compatibility rules for records
Jonathan Gibbons
jjg at openjdk.java.net
Thu Nov 5 22:14:02 UTC 2020
On Thu, 5 Nov 2020 18:55:12 GMT, Vicente Romero <vromero at openjdk.org> wrote:
> Hi all,
>
> Please review this change. It is providing compatibility tests for records. The tests are covering the assertions at section: [13.4.27 Evolution of Record Classes](http://cr.openjdk.java.net/~gbierman/8246771/8246771-20200928/specs/records-jls.html#jls-13.4.27).
>
> Thanks,
> Vicente
A coupe of suggestions, one more significant that the other
test/langtools/tools/javac/records/RecordsBinaryCompatibilityTests.java line 277:
> 275:
> 276: // let's first check that it runs wo issues
> 277: if (!output.contains("0")) {
This is a very weak test that may easily fail for the wrong reasons. Can you make the reference value more distinctive, like 12345, or "Hello World" that could never appear accidentally
test/langtools/tools/javac/records/RecordsBinaryCompatibilityTests.java line 251:
> 249: String clientCode,
> 250: boolean shouldFail,
> 251: String expectedError) throws Exception {
Since the expected error always seems to be the name of a class, you could make the type of the parameter be `Class<?>` and then pass class literals as arguments. Inside the method, you get use `getName()` to get the name you expect to see.
-------------
PR: https://git.openjdk.java.net/jdk/pull/1082
More information about the compiler-dev
mailing list