[java] Remove support for Java 15 preview language features
This commit is contained in:
@ -185,7 +185,7 @@ Example:
|
||||
* [apex](pmd_rules_apex.html) (Salesforce Apex)
|
||||
* [java](pmd_rules_java.html)
|
||||
* Supported Versions: 1.3, 1.4, 1.5, 5, 1.6, 6, 1.7, 7, 1.8, 8, 9, 1.9, 10, 1.10, 11, 12,
|
||||
13, 14, 14-preview, 15, 15-preview, 16, 16-preview, 17 (default), 17-preview
|
||||
13, 14, 15, 16, 16-preview, 17 (default), 17-preview
|
||||
* [ecmascript](pmd_rules_ecmascript.html) (JavaScript)
|
||||
* [jsp](pmd_rules_jsp.html)
|
||||
* [modelica](pmd_rules_modelica.html)
|
||||
|
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* Promote "JEP 409: Sealed Classes" as permanent language feature with Java 17.
|
||||
* Support "JEP 406: Pattern Matching for switch (Preview)" for Java 17 Preview.
|
||||
* Remove support for Java 15 preview language features
|
||||
* Andreas Dangel 07/2021
|
||||
*====================================================================
|
||||
* Fix #3117 - infinite loop when parsing invalid code nested in lambdas
|
||||
@ -398,12 +399,6 @@ public class JavaParser {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkforBadInstanceOfPattern() {
|
||||
if (!(jdkVersion == 15 && preview || jdkVersion >= 16)) {
|
||||
throwParseException("Pattern Matching for instanceof is only supported with Java 15 Preview and Java >= 16");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForBadAnonymousDiamondUsage() {
|
||||
if (jdkVersion < 9) {
|
||||
ASTAllocationExpression node = (ASTAllocationExpression)jjtree.peekNode();
|
||||
@ -447,14 +442,14 @@ public class JavaParser {
|
||||
if (jdkVersion >= 14 && "yield".equals(image)) {
|
||||
throwParseException("With JDK 14, 'yield' is a contextual keyword and cannot be used for type declarations!");
|
||||
}
|
||||
if ((jdkVersion == 15 && preview || jdkVersion >= 16) && "record".equals(image)) {
|
||||
throwParseException("With JDK 15 Preview and Java >= 16, 'record' is a contextual keyword and cannot be used for type declarations!");
|
||||
if (jdkVersion >= 16 && "record".equals(image)) {
|
||||
throwParseException("With JDK >= 16, 'record' is a contextual keyword and cannot be used for type declarations!");
|
||||
}
|
||||
if ((jdkVersion == 15 && preview || jdkVersion == 16 && preview || jdkVersion >= 17) && "sealed".equals(image)) {
|
||||
throwParseException("With JDK 15 Preview and JDK 16 Preview and JDK >= 17, 'sealed' is a contextual keyword and cannot be used for type declarations!");
|
||||
if ((jdkVersion == 16 && preview || jdkVersion >= 17) && "sealed".equals(image)) {
|
||||
throwParseException("With JDK 16 Preview and JDK >= 17, 'sealed' is a contextual keyword and cannot be used for type declarations!");
|
||||
}
|
||||
if ((jdkVersion == 15 && preview || jdkVersion == 16 && preview || jdkVersion >= 17) && "permits".equals(image)) {
|
||||
throwParseException("With JDK 15 Preview and JDK 16 Preview and JDK >= 17, 'permits' is a contextual keyword and cannot be used for type declarations!");
|
||||
if ((jdkVersion == 16 && preview || jdkVersion >= 17) && "permits".equals(image)) {
|
||||
throwParseException("With JDK 16 Preview and JDK >= 17, 'permits' is a contextual keyword and cannot be used for type declarations!");
|
||||
}
|
||||
}
|
||||
private void checkForMultipleCaseLabels() {
|
||||
@ -501,29 +496,35 @@ public class JavaParser {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkforBadInstanceOfPattern() {
|
||||
if (jdkVersion < 16) {
|
||||
throwParseException("Pattern Matching for instanceof is only supported with JDK >= 16");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isRecordTypeSupported() {
|
||||
return jdkVersion >= 16;
|
||||
}
|
||||
|
||||
private void checkForRecordType() {
|
||||
if (!isRecordTypeSupported()) {
|
||||
throwParseException("Records are only supported with Java 15 Preview and Java >= 16");
|
||||
throwParseException("Records are only supported with JDK >= 16");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForLocalInterfaceOrEnumType() {
|
||||
if (!isRecordTypeSupported()) {
|
||||
throwParseException("Local interfaces and enums are only supported with Java 15 Preview and Java >= 16");
|
||||
throwParseException("Local interfaces and enums are only supported with JDK >= 16");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isRecordTypeSupported() {
|
||||
return jdkVersion == 15 && preview || jdkVersion >= 16;
|
||||
}
|
||||
|
||||
private boolean isSealedClassSupported() {
|
||||
return jdkVersion == 15 && preview || jdkVersion == 16 && preview || jdkVersion >= 17;
|
||||
return jdkVersion == 16 && preview || jdkVersion >= 17;
|
||||
}
|
||||
|
||||
private void checkForSealedClassUsage() {
|
||||
if (!isSealedClassSupported()) {
|
||||
throwParseException("Sealed Classes are only supported with JDK 15 Preview, JDK 16 Preview and JDK >= 17.");
|
||||
throwParseException("Sealed Classes are only supported with JDK 16 Preview and JDK >= 17.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@ public class JavaLanguageModule extends BaseLanguageModule {
|
||||
addVersion("13", new JavaLanguageHandler(13));
|
||||
addVersion("14", new JavaLanguageHandler(14));
|
||||
addVersion("15", new JavaLanguageHandler(15));
|
||||
addVersion("15-preview", new JavaLanguageHandler(15, true));
|
||||
addVersion("16", new JavaLanguageHandler(16));
|
||||
addVersion("16-preview", new JavaLanguageHandler(16, true));
|
||||
addDefaultVersion("17", new JavaLanguageHandler(17)); // 17 is the default
|
||||
|
@ -42,20 +42,12 @@ public class LanguageVersionTest extends AbstractLanguageVersionTest {
|
||||
LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("11"), },
|
||||
{ JavaLanguageModule.NAME, JavaLanguageModule.TERSE_NAME, "12",
|
||||
LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("12"), },
|
||||
{ JavaLanguageModule.NAME, JavaLanguageModule.TERSE_NAME, "12-preview",
|
||||
LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("12-preview"), },
|
||||
{ JavaLanguageModule.NAME, JavaLanguageModule.TERSE_NAME, "13",
|
||||
LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("13"), },
|
||||
{ JavaLanguageModule.NAME, JavaLanguageModule.TERSE_NAME, "13-preview",
|
||||
LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("13-preview"), },
|
||||
{ JavaLanguageModule.NAME, JavaLanguageModule.TERSE_NAME, "14",
|
||||
LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("14"), },
|
||||
{ JavaLanguageModule.NAME, JavaLanguageModule.TERSE_NAME, "14-preview",
|
||||
LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("14-preview"), },
|
||||
{ JavaLanguageModule.NAME, JavaLanguageModule.TERSE_NAME, "15",
|
||||
LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("15"), },
|
||||
{ JavaLanguageModule.NAME, JavaLanguageModule.TERSE_NAME, "15-preview",
|
||||
LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("15-preview"), },
|
||||
{ JavaLanguageModule.NAME, JavaLanguageModule.TERSE_NAME, "16",
|
||||
LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("16"), },
|
||||
{ JavaLanguageModule.NAME, JavaLanguageModule.TERSE_NAME, "16-preview",
|
||||
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.java.ast;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||
import net.sourceforge.pmd.lang.ast.test.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.ast.test.BaseTreeDumpTest;
|
||||
import net.sourceforge.pmd.lang.ast.test.RelevantAttributePrinter;
|
||||
import net.sourceforge.pmd.lang.java.JavaParsingHelper;
|
||||
|
||||
public class Java15PreviewTreeDumpTest extends BaseTreeDumpTest {
|
||||
private final JavaParsingHelper java15p =
|
||||
JavaParsingHelper.WITH_PROCESSING.withDefaultVersion("15-preview")
|
||||
.withResourceContext(Java15PreviewTreeDumpTest.class, "jdkversiontests/java15p/");
|
||||
private final JavaParsingHelper java15 = java15p.withDefaultVersion("15");
|
||||
|
||||
public Java15PreviewTreeDumpTest() {
|
||||
super(new RelevantAttributePrinter(), ".java");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseParsingHelper<?, ?> getParser() {
|
||||
return java15p;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void patternMatchingInstanceof() {
|
||||
doTest("PatternMatchingInstanceof");
|
||||
|
||||
// extended tests for type resolution etc.
|
||||
ASTCompilationUnit compilationUnit = java15p.parseResource("PatternMatchingInstanceof.java");
|
||||
List<ASTInstanceOfExpression> instanceOfExpressions = compilationUnit.findDescendantsOfType(ASTInstanceOfExpression.class);
|
||||
for (ASTInstanceOfExpression expr : instanceOfExpressions) {
|
||||
ASTVariableDeclaratorId variable = expr.getChild(1).getFirstChildOfType(ASTVariableDeclaratorId.class);
|
||||
Assert.assertEquals(String.class, variable.getType());
|
||||
// Note: these variables are not part of the symbol table
|
||||
// See ScopeAndDeclarationFinder#visit(ASTVariableDeclaratorId, Object)
|
||||
Assert.assertNull(variable.getNameDeclaration());
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = ParseException.class)
|
||||
public void patternMatchingInstanceofBeforeJava15PreviewShouldFail() {
|
||||
java15.parseResource("PatternMatchingInstanceof.java");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void recordPoint() {
|
||||
doTest("Point");
|
||||
|
||||
// extended tests for type resolution etc.
|
||||
ASTCompilationUnit compilationUnit = java15p.parseResource("Point.java");
|
||||
ASTRecordDeclaration recordDecl = compilationUnit.getFirstDescendantOfType(ASTRecordDeclaration.class);
|
||||
List<ASTRecordComponent> components = recordDecl.getFirstChildOfType(ASTRecordComponentList.class)
|
||||
.findChildrenOfType(ASTRecordComponent.class);
|
||||
Assert.assertNull(components.get(0).getVarId().getNameDeclaration().getAccessNodeParent());
|
||||
Assert.assertEquals(Integer.TYPE, components.get(0).getVarId().getNameDeclaration().getType());
|
||||
Assert.assertEquals("int", components.get(0).getVarId().getNameDeclaration().getTypeImage());
|
||||
}
|
||||
|
||||
@Test(expected = ParseException.class)
|
||||
public void recordPointBeforeJava15PreviewShouldFail() {
|
||||
java15.parseResource("Point.java");
|
||||
}
|
||||
|
||||
@Test(expected = ParseException.class)
|
||||
public void recordCtorWithThrowsShouldFail() {
|
||||
java15p.parse(" record R {"
|
||||
+ " R throws IOException {}"
|
||||
+ " }");
|
||||
}
|
||||
|
||||
@Test(expected = ParseException.class)
|
||||
public void recordMustNotExtend() {
|
||||
java15p.parse("record RecordEx(int x) extends Number { }");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void innerRecords() {
|
||||
doTest("Records");
|
||||
}
|
||||
|
||||
@Test(expected = ParseException.class)
|
||||
public void recordIsARestrictedIdentifier() {
|
||||
java15p.parse("public class record {}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void localRecords() {
|
||||
doTest("LocalRecords");
|
||||
}
|
||||
|
||||
@Test(expected = ParseException.class)
|
||||
public void sealedClassBeforeJava15Preview() {
|
||||
java15.parseResource("geometry/Shape.java");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sealedClass() {
|
||||
doTest("geometry/Shape");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonSealedClass() {
|
||||
doTest("geometry/Square");
|
||||
}
|
||||
|
||||
@Test(expected = ParseException.class)
|
||||
public void sealedInterfaceBeforeJava15Preview() {
|
||||
java15.parseResource("expression/Expr.java");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sealedInterface() {
|
||||
doTest("expression/Expr");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void localInterfaceAndEnums() {
|
||||
doTest("LocalInterfacesAndEnums");
|
||||
}
|
||||
|
||||
@Test(expected = ParseException.class)
|
||||
public void localInterfacesAndEnumsBeforeJava15PreviewShouldFail() {
|
||||
java15.parseResource("LocalInterfacesAndEnums.java");
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ public class Java15TreeDumpTest extends BaseTreeDumpTest {
|
||||
private final JavaParsingHelper java15 =
|
||||
JavaParsingHelper.WITH_PROCESSING.withDefaultVersion("15")
|
||||
.withResourceContext(Java15TreeDumpTest.class, "jdkversiontests/java15/");
|
||||
private final JavaParsingHelper java15p = java15.withDefaultVersion("15-preview");
|
||||
private final JavaParsingHelper java14 = java15.withDefaultVersion("14");
|
||||
|
||||
public Java15TreeDumpTest() {
|
||||
@ -31,7 +30,6 @@ public class Java15TreeDumpTest extends BaseTreeDumpTest {
|
||||
@Test
|
||||
public void textBlocks() {
|
||||
doTest("TextBlocks");
|
||||
java15p.parseResource("TextBlocks.java"); // make sure we can parse it with preview as well
|
||||
}
|
||||
|
||||
@Test(expected = net.sourceforge.pmd.lang.ast.ParseException.class)
|
||||
@ -47,6 +45,5 @@ public class Java15TreeDumpTest extends BaseTreeDumpTest {
|
||||
@Test
|
||||
public void sealedAndNonSealedIdentifiers() {
|
||||
doTest("NonSealedIdentifier");
|
||||
java15p.parseResource("NonSealedIdentifier.java"); // make sure we can parse it with preview as well
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ public class ParserCornersTest {
|
||||
public void testGitHubBug2767() {
|
||||
// PMD fails to parse an initializer block.
|
||||
// PMD 6.26.0 parses this code just fine.
|
||||
java.withDefaultVersion("15-preview")
|
||||
java.withDefaultVersion("16")
|
||||
.parse("class Foo {\n"
|
||||
+ " {final int I;}\n"
|
||||
+ "}\n");
|
||||
|
@ -12,16 +12,16 @@ import java.io.IOException
|
||||
|
||||
class ASTPatternTest : ParserTestSpec({
|
||||
|
||||
parserTest("Test patterns only available on JDK 15 (preview) and JDK16 and JDK16 (preview) and JDK17 and JDK 17 (preview)",
|
||||
javaVersions = JavaVersion.values().asList().minus(J15__PREVIEW).minus(J16).minus(J16__PREVIEW).minus(J17).minus(J17__PREVIEW)) {
|
||||
parserTest("Test patterns only available on JDK16 and JDK16 (preview) and JDK17 and JDK 17 (preview)",
|
||||
javaVersions = JavaVersion.values().asList().minus(J16).minus(J16__PREVIEW).minus(J17).minus(J17__PREVIEW)) {
|
||||
|
||||
expectParseException("Pattern Matching for instanceof is only supported with Java 15 Preview and Java >= 16") {
|
||||
expectParseException("Pattern Matching for instanceof is only supported with JDK >= 16") {
|
||||
parseAstExpression("obj instanceof Class c")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
parserTest("Test simple patterns", javaVersions = listOf(J15__PREVIEW, J16, J17)) {
|
||||
parserTest("Test simple patterns", javaVersions = listOf(J16, J17)) {
|
||||
|
||||
importedTypes += IOException::class.java
|
||||
|
||||
|
@ -21,7 +21,7 @@ enum class JavaVersion : Comparable<JavaVersion> {
|
||||
J12,
|
||||
J13,
|
||||
J14,
|
||||
J15, J15__PREVIEW,
|
||||
J15,
|
||||
J16, J16__PREVIEW,
|
||||
J17, J17__PREVIEW;
|
||||
|
||||
|
@ -1,20 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
public class LocalInterfacesAndEnums {
|
||||
|
||||
{
|
||||
class MyLocalClass {}
|
||||
|
||||
// static local classes are not allowed (neither Java15 nor Java15 Preview)
|
||||
//static class MyLocalStaticClass {}
|
||||
|
||||
interface MyLocalInterface {}
|
||||
|
||||
enum MyLocalEnum { A }
|
||||
|
||||
// not supported anymore with Java16
|
||||
//@interface MyLocalAnnotation {}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
+- CompilationUnit[@PackageName = "", @declarationsAreInDefaultPackage = true]
|
||||
+- TypeDeclaration[]
|
||||
+- ClassOrInterfaceDeclaration[@Abstract = false, @BinaryName = "LocalInterfacesAndEnums", @Default = false, @Final = false, @Image = "LocalInterfacesAndEnums", @Interface = false, @Local = false, @Modifiers = 1, @Native = false, @Nested = false, @NonSealed = false, @PackagePrivate = false, @Private = false, @Protected = false, @Public = true, @Sealed = false, @SimpleName = "LocalInterfacesAndEnums", @Static = false, @Strictfp = false, @Synchronized = false, @Transient = false, @TypeKind = TypeKind.CLASS, @Volatile = false]
|
||||
+- ClassOrInterfaceBody[@AnonymousInnerClass = false, @EnumChild = false]
|
||||
+- ClassOrInterfaceBodyDeclaration[@AnonymousInnerClass = false, @EnumChild = false, @Kind = DeclarationKind.INITIALIZER]
|
||||
+- Initializer[@Static = false]
|
||||
+- Block[@containsComment = true]
|
||||
+- BlockStatement[@Allocation = false]
|
||||
| +- ClassOrInterfaceDeclaration[@Abstract = false, @BinaryName = "LocalInterfacesAndEnums$1MyLocalClass", @Default = false, @Final = false, @Image = "MyLocalClass", @Interface = false, @Local = true, @Modifiers = 0, @Native = false, @Nested = false, @NonSealed = false, @PackagePrivate = false, @Private = false, @Protected = false, @Public = false, @Sealed = false, @SimpleName = "MyLocalClass", @Static = false, @Strictfp = false, @Synchronized = false, @Transient = false, @TypeKind = TypeKind.CLASS, @Volatile = false]
|
||||
| +- ClassOrInterfaceBody[@AnonymousInnerClass = false, @EnumChild = false]
|
||||
+- BlockStatement[@Allocation = false]
|
||||
| +- ClassOrInterfaceDeclaration[@Abstract = false, @BinaryName = "LocalInterfacesAndEnums$1MyLocalInterface", @Default = false, @Final = false, @Image = "MyLocalInterface", @Interface = true, @Local = true, @Modifiers = 0, @Native = false, @Nested = false, @NonSealed = false, @PackagePrivate = false, @Private = false, @Protected = false, @Public = false, @Sealed = false, @SimpleName = "MyLocalInterface", @Static = false, @Strictfp = false, @Synchronized = false, @Transient = false, @TypeKind = TypeKind.INTERFACE, @Volatile = false]
|
||||
| +- ClassOrInterfaceBody[@AnonymousInnerClass = false, @EnumChild = false]
|
||||
+- BlockStatement[@Allocation = false]
|
||||
+- EnumDeclaration[@Abstract = false, @BinaryName = "LocalInterfacesAndEnums$MyLocalEnum", @Default = false, @Final = false, @Image = "MyLocalEnum", @Local = true, @Modifiers = 0, @Native = false, @Nested = false, @PackagePrivate = true, @Private = false, @Protected = false, @Public = false, @SimpleName = "MyLocalEnum", @Static = false, @Strictfp = false, @Synchronized = false, @Transient = false, @TypeKind = TypeKind.ENUM, @Volatile = false]
|
||||
+- EnumBody[]
|
||||
+- EnumConstant[@AnonymousClass = false, @Image = "A"]
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.java.net/jeps/384">JEP 384: Records (Second Preview)</a>
|
||||
*/
|
||||
public class LocalRecords {
|
||||
public interface Merchant {}
|
||||
public static double computeSales(Merchant merchant, int month) {
|
||||
return month;
|
||||
}
|
||||
List<Merchant> findTopMerchants(List<Merchant> merchants, int month) {
|
||||
// Local record
|
||||
record MerchantSales(Merchant merchant, double sales) {}
|
||||
|
||||
return merchants.stream()
|
||||
.map(merchant -> new MerchantSales(merchant, computeSales(merchant, month)))
|
||||
.sorted((m1, m2) -> Double.compare(m2.sales(), m1.sales()))
|
||||
.map(MerchantSales::merchant)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
void methodWithLocalRecordAndModifiers() {
|
||||
final record MyRecord1(String a) {}
|
||||
final static record MyRecord2(String a) {}
|
||||
@Deprecated record MyRecord3(String a) {}
|
||||
final @Deprecated static record MyRecord4(String a) {}
|
||||
}
|
||||
|
||||
void statementThatStartsWithRecordAsRegularIdent() {
|
||||
// https://github.com/pmd/pmd/issues/3145
|
||||
final Map<String, String> record = new HashMap<>();
|
||||
record.put("key", "value");
|
||||
}
|
||||
|
||||
void methodWithLocalClass() {
|
||||
class MyLocalClass {}
|
||||
}
|
||||
|
||||
void methodWithLocalVarsNamedSealed() {
|
||||
int result = 0;
|
||||
int non = 1;
|
||||
int sealed = 2;
|
||||
result = non-sealed;
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,34 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* @see <a href="https://openjdk.java.net/jeps/375">JEP 375: Pattern Matching for instanceof (Second Preview)</a>
|
||||
*/
|
||||
public class PatternMatchingInstanceof {
|
||||
private String s = "other string";
|
||||
|
||||
public void test() {
|
||||
Object obj = "abc";
|
||||
//obj = 1;
|
||||
if (obj instanceof String s) {
|
||||
System.out.println("a) obj == s: " + (obj == s)); // true
|
||||
} else {
|
||||
System.out.println("b) obj == s: " + (obj == s)); // false
|
||||
}
|
||||
|
||||
if (!(obj instanceof String s)) {
|
||||
System.out.println("c) obj == s: " + (obj == s)); // false
|
||||
} else {
|
||||
System.out.println("d) obj == s: " + (obj == s)); // true
|
||||
}
|
||||
|
||||
if (obj instanceof String s && s.length() > 2) {
|
||||
System.out.println("e) obj == s: " + (obj == s)); // true
|
||||
}
|
||||
if (obj instanceof String s || s.length() > 5) {
|
||||
System.out.println("f) obj == s: " + (obj == s)); // false
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new PatternMatchingInstanceof().test();
|
||||
}
|
||||
}
|
@ -1,288 +0,0 @@
|
||||
+- CompilationUnit[@PackageName = "", @declarationsAreInDefaultPackage = true]
|
||||
+- TypeDeclaration[]
|
||||
+- ClassOrInterfaceDeclaration[@Abstract = false, @BinaryName = "PatternMatchingInstanceof", @Default = false, @Final = false, @Image = "PatternMatchingInstanceof", @Interface = false, @Local = false, @Modifiers = 1, @Native = false, @Nested = false, @NonSealed = false, @PackagePrivate = false, @Private = false, @Protected = false, @Public = true, @Sealed = false, @SimpleName = "PatternMatchingInstanceof", @Static = false, @Strictfp = false, @Synchronized = false, @Transient = false, @TypeKind = TypeKind.CLASS, @Volatile = false]
|
||||
+- ClassOrInterfaceBody[@AnonymousInnerClass = false, @EnumChild = false]
|
||||
+- ClassOrInterfaceBodyDeclaration[@AnonymousInnerClass = false, @EnumChild = false, @Kind = DeclarationKind.FIELD]
|
||||
| +- FieldDeclaration[@Abstract = false, @AnnotationMember = false, @Array = false, @ArrayDepth = 0, @Default = false, @Final = false, @InterfaceMember = false, @Modifiers = 4, @Native = false, @PackagePrivate = false, @Private = true, @Protected = false, @Public = false, @Static = false, @Strictfp = false, @Synchronized = false, @SyntacticallyFinal = false, @SyntacticallyPublic = false, @SyntacticallyStatic = false, @Transient = false, @VariableName = "s", @Volatile = false]
|
||||
| +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "String"]
|
||||
| | +- ReferenceType[@Array = false, @ArrayDepth = 0]
|
||||
| | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "String", @ReferenceToClassSameCompilationUnit = false]
|
||||
| +- VariableDeclarator[@Initializer = true, @Name = "s"]
|
||||
| +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = true, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "s", @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = false, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "s"]
|
||||
| +- VariableInitializer[]
|
||||
| +- Expression[@StandAlonePrimitive = false]
|
||||
| +- PrimaryExpression[]
|
||||
| +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| +- Literal[@CharLiteral = false, @DoubleLiteral = false, @EscapedStringLiteral = ""other string"", @FloatLiteral = false, @Image = ""other string"", @IntLiteral = false, @LongLiteral = false, @SingleCharacterStringLiteral = false, @StringLiteral = true, @TextBlock = false, @TextBlockContent = ""other string"", @ValueAsDouble = NaN, @ValueAsFloat = NaN, @ValueAsInt = 0, @ValueAsLong = 0]
|
||||
+- ClassOrInterfaceBodyDeclaration[@AnonymousInnerClass = false, @EnumChild = false, @Kind = DeclarationKind.METHOD]
|
||||
| +- MethodDeclaration[@Abstract = false, @Arity = 0, @Default = false, @Final = false, @InterfaceMember = false, @Kind = MethodLikeKind.METHOD, @MethodName = "test", @Modifiers = 1, @Name = "test", @Native = false, @PackagePrivate = false, @Private = false, @Protected = false, @Public = true, @Static = false, @Strictfp = false, @Synchronized = false, @SyntacticallyAbstract = false, @SyntacticallyPublic = true, @Transient = false, @Void = true, @Volatile = false]
|
||||
| +- ResultType[@Void = true, @returnsArray = false]
|
||||
| +- MethodDeclarator[@Image = "test", @ParameterCount = 0]
|
||||
| | +- FormalParameters[@ParameterCount = 0, @Size = 0]
|
||||
| +- Block[@containsComment = false]
|
||||
| +- BlockStatement[@Allocation = false]
|
||||
| | +- LocalVariableDeclaration[@Abstract = false, @Array = false, @ArrayDepth = 0, @Default = false, @Final = false, @Modifiers = 0, @Native = false, @PackagePrivate = true, @Private = false, @Protected = false, @Public = false, @Static = false, @Strictfp = false, @Synchronized = false, @Transient = false, @TypeInferred = false, @VariableName = "obj", @Volatile = false]
|
||||
| | +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "Object"]
|
||||
| | | +- ReferenceType[@Array = false, @ArrayDepth = 0]
|
||||
| | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Object", @ReferenceToClassSameCompilationUnit = false]
|
||||
| | +- VariableDeclarator[@Initializer = true, @Name = "obj"]
|
||||
| | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "obj", @LambdaParameter = false, @LocalVariable = true, @Name = "obj", @PatternBinding = false, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "obj"]
|
||||
| | +- VariableInitializer[]
|
||||
| | +- Expression[@StandAlonePrimitive = false]
|
||||
| | +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | +- Literal[@CharLiteral = false, @DoubleLiteral = false, @EscapedStringLiteral = ""abc"", @FloatLiteral = false, @Image = ""abc"", @IntLiteral = false, @LongLiteral = false, @SingleCharacterStringLiteral = false, @StringLiteral = true, @TextBlock = false, @TextBlockContent = ""abc"", @ValueAsDouble = NaN, @ValueAsFloat = NaN, @ValueAsInt = 0, @ValueAsLong = 0]
|
||||
| +- BlockStatement[@Allocation = false]
|
||||
| | +- Statement[]
|
||||
| | +- IfStatement[@Else = true]
|
||||
| | +- Expression[@StandAlonePrimitive = false]
|
||||
| | | +- InstanceOfExpression[]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | | +- Name[@Image = "obj"]
|
||||
| | | +- TypePattern[]
|
||||
| | | +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "String"]
|
||||
| | | | +- ReferenceType[@Array = false, @ArrayDepth = 0]
|
||||
| | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "String", @ReferenceToClassSameCompilationUnit = false]
|
||||
| | | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "s", @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "s"]
|
||||
| | +- Statement[]
|
||||
| | | +- Block[@containsComment = true]
|
||||
| | | +- BlockStatement[@Allocation = false]
|
||||
| | | +- Statement[]
|
||||
| | | +- StatementExpression[]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | | +- Name[@Image = "System.out.println"]
|
||||
| | | +- PrimarySuffix[@ArgumentCount = 1, @Arguments = true, @ArrayDereference = false]
|
||||
| | | +- Arguments[@ArgumentCount = 1, @Size = 1]
|
||||
| | | +- ArgumentList[@Size = 1]
|
||||
| | | +- Expression[@StandAlonePrimitive = false]
|
||||
| | | +- AdditiveExpression[@Image = "+", @Operator = "+"]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | | +- Literal[@CharLiteral = false, @DoubleLiteral = false, @EscapedStringLiteral = ""a) obj == s: "", @FloatLiteral = false, @Image = ""a) obj == s: "", @IntLiteral = false, @LongLiteral = false, @SingleCharacterStringLiteral = false, @StringLiteral = true, @TextBlock = false, @TextBlockContent = ""a) obj == s: "", @ValueAsDouble = NaN, @ValueAsFloat = NaN, @ValueAsInt = 0, @ValueAsLong = 0]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Expression[@StandAlonePrimitive = false]
|
||||
| | | +- EqualityExpression[@Image = "==", @Operator = "=="]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | | +- Name[@Image = "obj"]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Name[@Image = "s"]
|
||||
| | +- Statement[]
|
||||
| | +- Block[@containsComment = true]
|
||||
| | +- BlockStatement[@Allocation = false]
|
||||
| | +- Statement[]
|
||||
| | +- StatementExpression[]
|
||||
| | +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Name[@Image = "System.out.println"]
|
||||
| | +- PrimarySuffix[@ArgumentCount = 1, @Arguments = true, @ArrayDereference = false]
|
||||
| | +- Arguments[@ArgumentCount = 1, @Size = 1]
|
||||
| | +- ArgumentList[@Size = 1]
|
||||
| | +- Expression[@StandAlonePrimitive = false]
|
||||
| | +- AdditiveExpression[@Image = "+", @Operator = "+"]
|
||||
| | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Literal[@CharLiteral = false, @DoubleLiteral = false, @EscapedStringLiteral = ""b) obj == s: "", @FloatLiteral = false, @Image = ""b) obj == s: "", @IntLiteral = false, @LongLiteral = false, @SingleCharacterStringLiteral = false, @StringLiteral = true, @TextBlock = false, @TextBlockContent = ""b) obj == s: "", @ValueAsDouble = NaN, @ValueAsFloat = NaN, @ValueAsInt = 0, @ValueAsLong = 0]
|
||||
| | +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | +- Expression[@StandAlonePrimitive = false]
|
||||
| | +- EqualityExpression[@Image = "==", @Operator = "=="]
|
||||
| | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Name[@Image = "obj"]
|
||||
| | +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | +- Name[@Image = "s"]
|
||||
| +- BlockStatement[@Allocation = false]
|
||||
| | +- Statement[]
|
||||
| | +- IfStatement[@Else = true]
|
||||
| | +- Expression[@StandAlonePrimitive = false]
|
||||
| | | +- UnaryExpressionNotPlusMinus[@Image = "!", @Operator = "!"]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Expression[@StandAlonePrimitive = false]
|
||||
| | | +- InstanceOfExpression[]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | | +- Name[@Image = "obj"]
|
||||
| | | +- TypePattern[]
|
||||
| | | +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "String"]
|
||||
| | | | +- ReferenceType[@Array = false, @ArrayDepth = 0]
|
||||
| | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "String", @ReferenceToClassSameCompilationUnit = false]
|
||||
| | | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "s", @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "s"]
|
||||
| | +- Statement[]
|
||||
| | | +- Block[@containsComment = true]
|
||||
| | | +- BlockStatement[@Allocation = false]
|
||||
| | | +- Statement[]
|
||||
| | | +- StatementExpression[]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | | +- Name[@Image = "System.out.println"]
|
||||
| | | +- PrimarySuffix[@ArgumentCount = 1, @Arguments = true, @ArrayDereference = false]
|
||||
| | | +- Arguments[@ArgumentCount = 1, @Size = 1]
|
||||
| | | +- ArgumentList[@Size = 1]
|
||||
| | | +- Expression[@StandAlonePrimitive = false]
|
||||
| | | +- AdditiveExpression[@Image = "+", @Operator = "+"]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | | +- Literal[@CharLiteral = false, @DoubleLiteral = false, @EscapedStringLiteral = ""c) obj == s: "", @FloatLiteral = false, @Image = ""c) obj == s: "", @IntLiteral = false, @LongLiteral = false, @SingleCharacterStringLiteral = false, @StringLiteral = true, @TextBlock = false, @TextBlockContent = ""c) obj == s: "", @ValueAsDouble = NaN, @ValueAsFloat = NaN, @ValueAsInt = 0, @ValueAsLong = 0]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Expression[@StandAlonePrimitive = false]
|
||||
| | | +- EqualityExpression[@Image = "==", @Operator = "=="]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | | +- Name[@Image = "obj"]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Name[@Image = "s"]
|
||||
| | +- Statement[]
|
||||
| | +- Block[@containsComment = true]
|
||||
| | +- BlockStatement[@Allocation = false]
|
||||
| | +- Statement[]
|
||||
| | +- StatementExpression[]
|
||||
| | +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Name[@Image = "System.out.println"]
|
||||
| | +- PrimarySuffix[@ArgumentCount = 1, @Arguments = true, @ArrayDereference = false]
|
||||
| | +- Arguments[@ArgumentCount = 1, @Size = 1]
|
||||
| | +- ArgumentList[@Size = 1]
|
||||
| | +- Expression[@StandAlonePrimitive = false]
|
||||
| | +- AdditiveExpression[@Image = "+", @Operator = "+"]
|
||||
| | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Literal[@CharLiteral = false, @DoubleLiteral = false, @EscapedStringLiteral = ""d) obj == s: "", @FloatLiteral = false, @Image = ""d) obj == s: "", @IntLiteral = false, @LongLiteral = false, @SingleCharacterStringLiteral = false, @StringLiteral = true, @TextBlock = false, @TextBlockContent = ""d) obj == s: "", @ValueAsDouble = NaN, @ValueAsFloat = NaN, @ValueAsInt = 0, @ValueAsLong = 0]
|
||||
| | +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | +- Expression[@StandAlonePrimitive = false]
|
||||
| | +- EqualityExpression[@Image = "==", @Operator = "=="]
|
||||
| | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Name[@Image = "obj"]
|
||||
| | +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | +- Name[@Image = "s"]
|
||||
| +- BlockStatement[@Allocation = false]
|
||||
| | +- Statement[]
|
||||
| | +- IfStatement[@Else = false]
|
||||
| | +- Expression[@StandAlonePrimitive = false]
|
||||
| | | +- ConditionalAndExpression[]
|
||||
| | | +- InstanceOfExpression[]
|
||||
| | | | +- PrimaryExpression[]
|
||||
| | | | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | | | +- Name[@Image = "obj"]
|
||||
| | | | +- TypePattern[]
|
||||
| | | | +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "String"]
|
||||
| | | | | +- ReferenceType[@Array = false, @ArrayDepth = 0]
|
||||
| | | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "String", @ReferenceToClassSameCompilationUnit = false]
|
||||
| | | | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "s", @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "s"]
|
||||
| | | +- RelationalExpression[@Image = ">"]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | | | +- Name[@Image = "s.length"]
|
||||
| | | | +- PrimarySuffix[@ArgumentCount = 0, @Arguments = true, @ArrayDereference = false]
|
||||
| | | | +- Arguments[@ArgumentCount = 0, @Size = 0]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Literal[@CharLiteral = false, @DoubleLiteral = false, @EscapedStringLiteral = "2", @FloatLiteral = false, @Image = "2", @IntLiteral = true, @LongLiteral = false, @SingleCharacterStringLiteral = false, @StringLiteral = false, @TextBlock = false, @TextBlockContent = "2", @ValueAsDouble = NaN, @ValueAsFloat = NaN, @ValueAsInt = 2, @ValueAsLong = 2]
|
||||
| | +- Statement[]
|
||||
| | +- Block[@containsComment = true]
|
||||
| | +- BlockStatement[@Allocation = false]
|
||||
| | +- Statement[]
|
||||
| | +- StatementExpression[]
|
||||
| | +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Name[@Image = "System.out.println"]
|
||||
| | +- PrimarySuffix[@ArgumentCount = 1, @Arguments = true, @ArrayDereference = false]
|
||||
| | +- Arguments[@ArgumentCount = 1, @Size = 1]
|
||||
| | +- ArgumentList[@Size = 1]
|
||||
| | +- Expression[@StandAlonePrimitive = false]
|
||||
| | +- AdditiveExpression[@Image = "+", @Operator = "+"]
|
||||
| | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Literal[@CharLiteral = false, @DoubleLiteral = false, @EscapedStringLiteral = ""e) obj == s: "", @FloatLiteral = false, @Image = ""e) obj == s: "", @IntLiteral = false, @LongLiteral = false, @SingleCharacterStringLiteral = false, @StringLiteral = true, @TextBlock = false, @TextBlockContent = ""e) obj == s: "", @ValueAsDouble = NaN, @ValueAsFloat = NaN, @ValueAsInt = 0, @ValueAsLong = 0]
|
||||
| | +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | +- Expression[@StandAlonePrimitive = false]
|
||||
| | +- EqualityExpression[@Image = "==", @Operator = "=="]
|
||||
| | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | +- Name[@Image = "obj"]
|
||||
| | +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | +- Name[@Image = "s"]
|
||||
| +- BlockStatement[@Allocation = false]
|
||||
| +- Statement[]
|
||||
| +- IfStatement[@Else = false]
|
||||
| +- Expression[@StandAlonePrimitive = false]
|
||||
| | +- ConditionalOrExpression[]
|
||||
| | +- InstanceOfExpression[]
|
||||
| | | +- PrimaryExpression[]
|
||||
| | | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | | +- Name[@Image = "obj"]
|
||||
| | | +- TypePattern[]
|
||||
| | | +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "String"]
|
||||
| | | | +- ReferenceType[@Array = false, @ArrayDepth = 0]
|
||||
| | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "String", @ReferenceToClassSameCompilationUnit = false]
|
||||
| | | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "s", @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "s"]
|
||||
| | +- RelationalExpression[@Image = ">"]
|
||||
| | +- PrimaryExpression[]
|
||||
| | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | | | +- Name[@Image = "s.length"]
|
||||
| | | +- PrimarySuffix[@ArgumentCount = 0, @Arguments = true, @ArrayDereference = false]
|
||||
| | | +- Arguments[@ArgumentCount = 0, @Size = 0]
|
||||
| | +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | +- Literal[@CharLiteral = false, @DoubleLiteral = false, @EscapedStringLiteral = "5", @FloatLiteral = false, @Image = "5", @IntLiteral = true, @LongLiteral = false, @SingleCharacterStringLiteral = false, @StringLiteral = false, @TextBlock = false, @TextBlockContent = "5", @ValueAsDouble = NaN, @ValueAsFloat = NaN, @ValueAsInt = 5, @ValueAsLong = 5]
|
||||
| +- Statement[]
|
||||
| +- Block[@containsComment = true]
|
||||
| +- BlockStatement[@Allocation = false]
|
||||
| +- Statement[]
|
||||
| +- StatementExpression[]
|
||||
| +- PrimaryExpression[]
|
||||
| +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | +- Name[@Image = "System.out.println"]
|
||||
| +- PrimarySuffix[@ArgumentCount = 1, @Arguments = true, @ArrayDereference = false]
|
||||
| +- Arguments[@ArgumentCount = 1, @Size = 1]
|
||||
| +- ArgumentList[@Size = 1]
|
||||
| +- Expression[@StandAlonePrimitive = false]
|
||||
| +- AdditiveExpression[@Image = "+", @Operator = "+"]
|
||||
| +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | +- Literal[@CharLiteral = false, @DoubleLiteral = false, @EscapedStringLiteral = ""f) obj == s: "", @FloatLiteral = false, @Image = ""f) obj == s: "", @IntLiteral = false, @LongLiteral = false, @SingleCharacterStringLiteral = false, @StringLiteral = true, @TextBlock = false, @TextBlockContent = ""f) obj == s: "", @ValueAsDouble = NaN, @ValueAsFloat = NaN, @ValueAsInt = 0, @ValueAsLong = 0]
|
||||
| +- PrimaryExpression[]
|
||||
| +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| +- Expression[@StandAlonePrimitive = false]
|
||||
| +- EqualityExpression[@Image = "==", @Operator = "=="]
|
||||
| +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | +- Name[@Image = "obj"]
|
||||
| +- PrimaryExpression[]
|
||||
| +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| +- Name[@Image = "s"]
|
||||
+- ClassOrInterfaceBodyDeclaration[@AnonymousInnerClass = false, @EnumChild = false, @Kind = DeclarationKind.METHOD]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @Default = false, @Final = false, @InterfaceMember = false, @Kind = MethodLikeKind.METHOD, @MethodName = "main", @Modifiers = 17, @Name = "main", @Native = false, @PackagePrivate = false, @Private = false, @Protected = false, @Public = true, @Static = true, @Strictfp = false, @Synchronized = false, @SyntacticallyAbstract = false, @SyntacticallyPublic = true, @Transient = false, @Void = true, @Volatile = false]
|
||||
+- ResultType[@Void = true, @returnsArray = false]
|
||||
+- MethodDeclarator[@Image = "main", @ParameterCount = 1]
|
||||
| +- FormalParameters[@ParameterCount = 1, @Size = 1]
|
||||
| +- FormalParameter[@Abstract = false, @Array = true, @ArrayDepth = 1, @Default = false, @ExplicitReceiverParameter = false, @Final = false, @Modifiers = 0, @Native = false, @PackagePrivate = true, @Private = false, @Protected = false, @Public = false, @Static = false, @Strictfp = false, @Synchronized = false, @Transient = false, @TypeInferred = false, @Varargs = false, @Volatile = false]
|
||||
| +- Type[@Array = true, @ArrayDepth = 1, @ArrayType = true, @TypeImage = "String"]
|
||||
| | +- ReferenceType[@Array = true, @ArrayDepth = 1]
|
||||
| | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = true, @ArrayDepth = 1, @Image = "String", @ReferenceToClassSameCompilationUnit = false]
|
||||
| +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = true, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = true, @Image = "args", @LambdaParameter = false, @LocalVariable = false, @Name = "args", @PatternBinding = false, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "args"]
|
||||
+- Block[@containsComment = false]
|
||||
+- BlockStatement[@Allocation = true]
|
||||
+- Statement[]
|
||||
+- StatementExpression[]
|
||||
+- PrimaryExpression[]
|
||||
+- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| +- AllocationExpression[@AnonymousClass = false]
|
||||
| +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "PatternMatchingInstanceof", @ReferenceToClassSameCompilationUnit = true]
|
||||
| +- Arguments[@ArgumentCount = 0, @Size = 0]
|
||||
+- PrimarySuffix[@ArgumentCount = -1, @Arguments = false, @ArrayDereference = false, @Image = "test"]
|
||||
+- PrimarySuffix[@ArgumentCount = 0, @Arguments = true, @ArrayDereference = false]
|
||||
+- Arguments[@ArgumentCount = 0, @Size = 0]
|
@ -1,14 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.java.net/jeps/384">JEP 384: Records (Second Preview)</a>
|
||||
*/
|
||||
public record Point(int x, int y) {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Point p = new Point(1, 2);
|
||||
System.out.println("p = " + p);
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
+- CompilationUnit[@PackageName = "", @declarationsAreInDefaultPackage = true]
|
||||
+- TypeDeclaration[]
|
||||
+- RecordDeclaration[@Abstract = false, @BinaryName = "Point", @Default = false, @Final = true, @Image = "Point", @Local = false, @Modifiers = 1, @Native = false, @Nested = false, @PackagePrivate = false, @Private = false, @Protected = false, @Public = true, @SimpleName = "Point", @Static = false, @Strictfp = false, @Synchronized = false, @Transient = false, @TypeKind = TypeKind.RECORD, @Volatile = false]
|
||||
+- RecordComponentList[@Size = 2]
|
||||
| +- RecordComponent[@Varargs = false]
|
||||
| | +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "int"]
|
||||
| | | +- PrimitiveType[@Array = false, @ArrayDepth = 0, @Boolean = false, @Image = "int"]
|
||||
| | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = true, @ForeachVariable = false, @FormalParameter = false, @Image = "x", @LambdaParameter = false, @LocalVariable = false, @Name = "x", @PatternBinding = false, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "x"]
|
||||
| +- RecordComponent[@Varargs = false]
|
||||
| +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "int"]
|
||||
| | +- PrimitiveType[@Array = false, @ArrayDepth = 0, @Boolean = false, @Image = "int"]
|
||||
| +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = true, @ForeachVariable = false, @FormalParameter = false, @Image = "y", @LambdaParameter = false, @LocalVariable = false, @Name = "y", @PatternBinding = false, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "y"]
|
||||
+- RecordBody[]
|
||||
+- ClassOrInterfaceBodyDeclaration[@AnonymousInnerClass = false, @EnumChild = false, @Kind = DeclarationKind.METHOD]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @Default = false, @Final = false, @InterfaceMember = false, @Kind = MethodLikeKind.METHOD, @MethodName = "main", @Modifiers = 17, @Name = "main", @Native = false, @PackagePrivate = false, @Private = false, @Protected = false, @Public = true, @Static = true, @Strictfp = false, @Synchronized = false, @SyntacticallyAbstract = false, @SyntacticallyPublic = true, @Transient = false, @Void = true, @Volatile = false]
|
||||
+- ResultType[@Void = true, @returnsArray = false]
|
||||
+- MethodDeclarator[@Image = "main", @ParameterCount = 1]
|
||||
| +- FormalParameters[@ParameterCount = 1, @Size = 1]
|
||||
| +- FormalParameter[@Abstract = false, @Array = true, @ArrayDepth = 1, @Default = false, @ExplicitReceiverParameter = false, @Final = false, @Modifiers = 0, @Native = false, @PackagePrivate = true, @Private = false, @Protected = false, @Public = false, @Static = false, @Strictfp = false, @Synchronized = false, @Transient = false, @TypeInferred = false, @Varargs = false, @Volatile = false]
|
||||
| +- Type[@Array = true, @ArrayDepth = 1, @ArrayType = true, @TypeImage = "String"]
|
||||
| | +- ReferenceType[@Array = true, @ArrayDepth = 1]
|
||||
| | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = true, @ArrayDepth = 1, @Image = "String", @ReferenceToClassSameCompilationUnit = false]
|
||||
| +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = true, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = true, @Image = "args", @LambdaParameter = false, @LocalVariable = false, @Name = "args", @PatternBinding = false, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "args"]
|
||||
+- Block[@containsComment = false]
|
||||
+- BlockStatement[@Allocation = true]
|
||||
| +- LocalVariableDeclaration[@Abstract = false, @Array = false, @ArrayDepth = 0, @Default = false, @Final = false, @Modifiers = 0, @Native = false, @PackagePrivate = true, @Private = false, @Protected = false, @Public = false, @Static = false, @Strictfp = false, @Synchronized = false, @Transient = false, @TypeInferred = false, @VariableName = "p", @Volatile = false]
|
||||
| +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "Point"]
|
||||
| | +- ReferenceType[@Array = false, @ArrayDepth = 0]
|
||||
| | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Point", @ReferenceToClassSameCompilationUnit = false]
|
||||
| +- VariableDeclarator[@Initializer = true, @Name = "p"]
|
||||
| +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "p", @LambdaParameter = false, @LocalVariable = true, @Name = "p", @PatternBinding = false, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "p"]
|
||||
| +- VariableInitializer[]
|
||||
| +- Expression[@StandAlonePrimitive = false]
|
||||
| +- PrimaryExpression[]
|
||||
| +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| +- AllocationExpression[@AnonymousClass = false]
|
||||
| +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Point", @ReferenceToClassSameCompilationUnit = false]
|
||||
| +- Arguments[@ArgumentCount = 2, @Size = 2]
|
||||
| +- ArgumentList[@Size = 2]
|
||||
| +- Expression[@StandAlonePrimitive = true]
|
||||
| | +- PrimaryExpression[]
|
||||
| | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| | +- Literal[@CharLiteral = false, @DoubleLiteral = false, @EscapedStringLiteral = "1", @FloatLiteral = false, @Image = "1", @IntLiteral = true, @LongLiteral = false, @SingleCharacterStringLiteral = false, @StringLiteral = false, @TextBlock = false, @TextBlockContent = "1", @ValueAsDouble = NaN, @ValueAsFloat = NaN, @ValueAsInt = 1, @ValueAsLong = 1]
|
||||
| +- Expression[@StandAlonePrimitive = true]
|
||||
| +- PrimaryExpression[]
|
||||
| +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| +- Literal[@CharLiteral = false, @DoubleLiteral = false, @EscapedStringLiteral = "2", @FloatLiteral = false, @Image = "2", @IntLiteral = true, @LongLiteral = false, @SingleCharacterStringLiteral = false, @StringLiteral = false, @TextBlock = false, @TextBlockContent = "2", @ValueAsDouble = NaN, @ValueAsFloat = NaN, @ValueAsInt = 2, @ValueAsLong = 2]
|
||||
+- BlockStatement[@Allocation = false]
|
||||
+- Statement[]
|
||||
+- StatementExpression[]
|
||||
+- PrimaryExpression[]
|
||||
+- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| +- Name[@Image = "System.out.println"]
|
||||
+- PrimarySuffix[@ArgumentCount = 1, @Arguments = true, @ArrayDereference = false]
|
||||
+- Arguments[@ArgumentCount = 1, @Size = 1]
|
||||
+- ArgumentList[@Size = 1]
|
||||
+- Expression[@StandAlonePrimitive = false]
|
||||
+- AdditiveExpression[@Image = "+", @Operator = "+"]
|
||||
+- PrimaryExpression[]
|
||||
| +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
| +- Literal[@CharLiteral = false, @DoubleLiteral = false, @EscapedStringLiteral = ""p = "", @FloatLiteral = false, @Image = ""p = "", @IntLiteral = false, @LongLiteral = false, @SingleCharacterStringLiteral = false, @StringLiteral = true, @TextBlock = false, @TextBlockContent = ""p = "", @ValueAsDouble = NaN, @ValueAsFloat = NaN, @ValueAsInt = 0, @ValueAsLong = 0]
|
||||
+- PrimaryExpression[]
|
||||
+- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
|
||||
+- Name[@Image = "p"]
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.java.net/jeps/384">JEP 384: Records (Second Preview)</a>
|
||||
*/
|
||||
public class Records {
|
||||
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@interface Nullable { }
|
||||
|
||||
@Target({ElementType.CONSTRUCTOR, ElementType.PARAMETER})
|
||||
@interface MyAnnotation { }
|
||||
|
||||
public record MyComplex(int real, @Deprecated int imaginary) {
|
||||
// explicit declaration of a canonical constructor
|
||||
@MyAnnotation
|
||||
public MyComplex(@MyAnnotation int real, int imaginary) {
|
||||
if (real > 100) throw new IllegalArgumentException("too big");
|
||||
this.real = real;
|
||||
this.imaginary = imaginary;
|
||||
}
|
||||
|
||||
public record Nested(int a) {}
|
||||
|
||||
public static class NestedClass { }
|
||||
}
|
||||
|
||||
|
||||
public record Range(int lo, int hi) {
|
||||
// compact record constructor
|
||||
@MyAnnotation
|
||||
public Range {
|
||||
if (lo > hi) /* referring here to the implicit constructor parameters */
|
||||
throw new IllegalArgumentException(String.format("(%d,%d)", lo, hi));
|
||||
}
|
||||
|
||||
public void foo() { }
|
||||
}
|
||||
|
||||
public record VarRec(@Nullable @Deprecated String @Nullable ... x) {}
|
||||
|
||||
public record ArrayRec(int x[]) {}
|
||||
|
||||
public record EmptyRec<Type>() {
|
||||
public void foo() { }
|
||||
public Type bar() { return null; }
|
||||
public static void baz() {
|
||||
EmptyRec<String> r = new EmptyRec<>();
|
||||
System.out.println(r);
|
||||
}
|
||||
}
|
||||
|
||||
// see https://www.javaspecialists.eu/archive/Issue276.html
|
||||
public interface Person {
|
||||
String firstName();
|
||||
String lastName();
|
||||
}
|
||||
public record PersonRecord(String firstName, String lastName)
|
||||
implements Person, java.io.Serializable {
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,9 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package com.example.expression;
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.java.net/jeps/360">JEP 360: Sealed Classes (Preview)</a>
|
||||
*/
|
||||
public final class ConstantExpr implements Expr { }
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package com.example.expression;
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.java.net/jeps/360">JEP 360: Sealed Classes (Preview)</a>
|
||||
*/
|
||||
public sealed interface Expr
|
||||
permits ConstantExpr, PlusExpr, TimesExpr, NegExpr { }
|
@ -1,11 +0,0 @@
|
||||
+- CompilationUnit[@PackageName = "com.example.expression", @declarationsAreInDefaultPackage = false]
|
||||
+- PackageDeclaration[@Name = "com.example.expression", @PackageNameImage = "com.example.expression"]
|
||||
| +- Name[@Image = "com.example.expression"]
|
||||
+- TypeDeclaration[]
|
||||
+- ClassOrInterfaceDeclaration[@Abstract = false, @BinaryName = "com.example.expression.Expr", @Default = false, @Final = false, @Image = "Expr", @Interface = true, @Local = false, @Modifiers = 16385, @Native = false, @Nested = false, @NonSealed = false, @PackagePrivate = false, @Private = false, @Protected = false, @Public = true, @Sealed = true, @SimpleName = "Expr", @Static = false, @Strictfp = false, @Synchronized = false, @Transient = false, @TypeKind = TypeKind.INTERFACE, @Volatile = false]
|
||||
+- PermitsList[]
|
||||
| +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "ConstantExpr", @ReferenceToClassSameCompilationUnit = false]
|
||||
| +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "PlusExpr", @ReferenceToClassSameCompilationUnit = false]
|
||||
| +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "TimesExpr", @ReferenceToClassSameCompilationUnit = false]
|
||||
| +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "NegExpr", @ReferenceToClassSameCompilationUnit = false]
|
||||
+- ClassOrInterfaceBody[@AnonymousInnerClass = false, @EnumChild = false]
|
@ -1,9 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package com.example.expression;
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.java.net/jeps/360">JEP 360: Sealed Classes (Preview)</a>
|
||||
*/
|
||||
public final class NegExpr implements Expr { }
|
@ -1,9 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package com.example.expression;
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.java.net/jeps/360">JEP 360: Sealed Classes (Preview)</a>
|
||||
*/
|
||||
public final class PlusExpr implements Expr { }
|
@ -1,9 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package com.example.expression;
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.java.net/jeps/360">JEP 360: Sealed Classes (Preview)</a>
|
||||
*/
|
||||
public final class TimesExpr implements Expr { }
|
@ -1,9 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package com.example.geometry;
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.java.net/jeps/360">JEP 360: Sealed Classes (Preview)</a>
|
||||
*/
|
||||
public final class Circle extends Shape { }
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package com.example.geometry;
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.java.net/jeps/360">JEP 360: Sealed Classes (Preview)</a>
|
||||
*/
|
||||
public final class FilledRectangle extends Rectangle { }
|
||||
|
@ -1,11 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package com.example.geometry;
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.java.net/jeps/360">JEP 360: Sealed Classes (Preview)</a>
|
||||
*/
|
||||
public sealed class Rectangle extends Shape
|
||||
permits TransparentRectangle, FilledRectangle { }
|
||||
|
@ -1,11 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package com.example.geometry;
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.java.net/jeps/360">JEP 360: Sealed Classes (Preview)</a>
|
||||
*/
|
||||
public sealed class Shape
|
||||
permits Circle, Rectangle, Square { }
|
||||
|
@ -1,10 +0,0 @@
|
||||
+- CompilationUnit[@PackageName = "com.example.geometry", @declarationsAreInDefaultPackage = false]
|
||||
+- PackageDeclaration[@Name = "com.example.geometry", @PackageNameImage = "com.example.geometry"]
|
||||
| +- Name[@Image = "com.example.geometry"]
|
||||
+- TypeDeclaration[]
|
||||
+- ClassOrInterfaceDeclaration[@Abstract = false, @BinaryName = "com.example.geometry.Shape", @Default = false, @Final = false, @Image = "Shape", @Interface = false, @Local = false, @Modifiers = 16385, @Native = false, @Nested = false, @NonSealed = false, @PackagePrivate = false, @Private = false, @Protected = false, @Public = true, @Sealed = true, @SimpleName = "Shape", @Static = false, @Strictfp = false, @Synchronized = false, @Transient = false, @TypeKind = TypeKind.CLASS, @Volatile = false]
|
||||
+- PermitsList[]
|
||||
| +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Circle", @ReferenceToClassSameCompilationUnit = false]
|
||||
| +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Rectangle", @ReferenceToClassSameCompilationUnit = false]
|
||||
| +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Square", @ReferenceToClassSameCompilationUnit = false]
|
||||
+- ClassOrInterfaceBody[@AnonymousInnerClass = false, @EnumChild = false]
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user