|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
25 | 25 | * SealedCompilationTests
|
26 | 26 | *
|
27 | 27 | * @test
|
28 |
| - * @bug 8246353 8273257 8294550 |
| 28 | + * @bug 8246353 8273257 8294550 8347562 |
29 | 29 | * @summary Negative compilation tests, and positive compilation (smoke) tests for sealed classes
|
30 | 30 | * @library /lib/combo /tools/lib
|
31 | 31 | * @modules
|
|
41 | 41 | import java.nio.file.Files;
|
42 | 42 | import java.nio.file.Path;
|
43 | 43 | import java.nio.file.Paths;
|
| 44 | +import java.util.Collections; |
44 | 45 | import java.util.List;
|
45 | 46 | import java.util.Set;
|
46 | 47 | import java.util.stream.Collectors;
|
|
61 | 62 | import toolbox.Task;
|
62 | 63 | import toolbox.Task.OutputKind;
|
63 | 64 |
|
| 65 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
64 | 66 | import static org.junit.jupiter.api.Assertions.fail;
|
65 | 67 |
|
66 | 68 | class SealedCompilationTests extends CompilationTestCase {
|
@@ -560,6 +562,13 @@ sealed class C permits T {}
|
560 | 562 | """)) {
|
561 | 563 | assertFail("compiler.err.invalid.permits.clause", s);
|
562 | 564 | }
|
| 565 | + assertFail("compiler.err.illegal.forward.ref", _ -> { |
| 566 | + assertEquals(Collections.nCopies(2, "compiler.err.illegal.forward.ref"), diags.keys()); |
| 567 | + }, |
| 568 | + """ |
| 569 | + sealed class Permits<X, Y> permits X, Y {} |
| 570 | + """ |
| 571 | + ); |
563 | 572 | }
|
564 | 573 |
|
565 | 574 | @Test
|
|
0 commit comments