mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8227046: compiler implementation for sealed classes
8225056: VM support for sealed classes 8227044: javax.lang.model for sealed classes 8227045: Preview APIs support for sealed classes 8227047: Javadoc for sealed types 8245854: JVM TI Specification for sealed classes Co-authored-by: Harold Seigel <harold.seigel@oracle.com> Co-authored-by: Jan Lahoda <jan.lahoda@oracle.com> Reviewed-by: mcimadamore, forax, darcy, dholmes, jlahoda, lfoltan, mchung, sspitsyn, vromero
This commit is contained in:
parent
567692e4ae
commit
d42bfef8a4
139 changed files with 6877 additions and 192 deletions
|
@ -1492,6 +1492,26 @@ public class JavacParserTest extends TestCase {
|
|||
expectedAST);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStartAndEndPositionForClassesInPermitsClause() throws IOException {
|
||||
String code = "package t; sealed class Test permits Sub1, Sub2 {} final class Sub1 extends Test {} final class Sub2 extends Test {}";
|
||||
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, fm, null,
|
||||
List.of("--enable-preview", "-source", Integer.toString(Runtime.version().feature())),
|
||||
null, Arrays.asList(new MyFileObject(code)));
|
||||
CompilationUnitTree cut = ct.parse().iterator().next();
|
||||
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
|
||||
List<? extends Tree> permitsList = clazz.getPermitsClause();
|
||||
assertEquals("testStartAndEndPositionForClassesInPermitsClause", 2, permitsList.size());
|
||||
Trees t = Trees.instance(ct);
|
||||
List<String> expected = List.of("Sub1", "Sub2");
|
||||
int i = 0;
|
||||
for (Tree permitted: permitsList) {
|
||||
int start = (int) t.getSourcePositions().getStartPosition(cut, permitted);
|
||||
int end = (int) t.getSourcePositions().getEndPosition(cut, permitted);
|
||||
assertEquals("testStartAndEndPositionForClassesInPermitsClause", expected.get(i++), code.substring(start, end));
|
||||
}
|
||||
}
|
||||
|
||||
void run(String[] args) throws Exception {
|
||||
int passed = 0, failed = 0;
|
||||
final Pattern p = (args != null && args.length > 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue