8256755: Update build.tools.depend.Depend to handle record components in API signatures
Reviewed-by: jlahoda
This commit is contained in:
parent
9aeadbb020
commit
b0bd0c24aa
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -59,6 +59,7 @@ import javax.lang.model.element.ModuleElement.RequiresDirective;
|
|||||||
import javax.lang.model.element.ModuleElement.UsesDirective;
|
import javax.lang.model.element.ModuleElement.UsesDirective;
|
||||||
import javax.lang.model.element.PackageElement;
|
import javax.lang.model.element.PackageElement;
|
||||||
import javax.lang.model.element.QualifiedNameable;
|
import javax.lang.model.element.QualifiedNameable;
|
||||||
|
import javax.lang.model.element.RecordComponentElement;
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
import javax.lang.model.element.TypeParameterElement;
|
import javax.lang.model.element.TypeParameterElement;
|
||||||
import javax.lang.model.element.VariableElement;
|
import javax.lang.model.element.VariableElement;
|
||||||
@ -258,6 +259,13 @@ public class Depend implements Plugin {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitRecordComponent(@SuppressWarnings("preview")RecordComponentElement e, Void p) {
|
||||||
|
update(e.getSimpleName());
|
||||||
|
visit(e.asType());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visitVariable(VariableElement e, Void p) {
|
public Void visitVariable(VariableElement e, Void p) {
|
||||||
visit(e.asType());
|
visit(e.asType());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -51,6 +51,7 @@ public class DependTest {
|
|||||||
test.testFields();
|
test.testFields();
|
||||||
test.testModules();
|
test.testModules();
|
||||||
test.testAnnotations();
|
test.testAnnotations();
|
||||||
|
test.testRecords();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMethods() throws Exception {
|
public void testMethods() throws Exception {
|
||||||
@ -191,6 +192,36 @@ public class DependTest {
|
|||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testRecords() throws Exception {
|
||||||
|
doOrdinaryTest("package test; public record Test (int x, int y) { }",
|
||||||
|
"package test; public record Test (int x, int y) { }", // identical
|
||||||
|
false);
|
||||||
|
doOrdinaryTest("package test; public record Test (int x, int y) { }",
|
||||||
|
"package test; public record Test (int x, int y) {" +
|
||||||
|
"public Test { } }", // compact ctr
|
||||||
|
false);
|
||||||
|
doOrdinaryTest("package test; public record Test (int x, int y) { }",
|
||||||
|
"package test; public record Test (int x, int y) {" +
|
||||||
|
"public Test (int x, int y) { this.x=x; this.y=y;} }", // canonical ctr
|
||||||
|
false);
|
||||||
|
doOrdinaryTest("package test; public record Test (int x, int y) { }",
|
||||||
|
"package test; public record Test (int y, int x) { }", // reverse
|
||||||
|
true);
|
||||||
|
doOrdinaryTest("package test; public record Test (int x, int y) { }",
|
||||||
|
"package test; public record Test (int x, int y, int z) { }", // additional
|
||||||
|
true);
|
||||||
|
doOrdinaryTest("package test; public record Test (int x, int y) { }",
|
||||||
|
"package test; public record Test () { }", // empty
|
||||||
|
true);
|
||||||
|
doOrdinaryTest("package test; public record Test (int x, int y) { }",
|
||||||
|
"package test; /*package*/ record Test (int x, int y) { }", // package
|
||||||
|
true);
|
||||||
|
doOrdinaryTest("package test; public record Test (int x, int y) { }",
|
||||||
|
"package test; public record Test (int x, int y) {" +
|
||||||
|
"public Test (int x, int y, int z) { this(x, y); } }", // additional ctr
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
private final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
private final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
private Path depend;
|
private Path depend;
|
||||||
private Path scratchServices;
|
private Path scratchServices;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user