From 2c1a7f026e6ba4d06d73118b44599b617445fccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Mon, 7 Oct 2024 16:40:37 +0200 Subject: [PATCH 1/5] Fix NPE with empty pattern list --- pmd-java/etc/grammar/Java.jjt | 4 +- .../java21/RecordPatterns.java | 9 ++ .../jdkversiontests/java21/RecordPatterns.txt | 104 ++++++++++++------ 3 files changed, 79 insertions(+), 38 deletions(-) diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index ef9406b9c3..630520f4e7 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1889,13 +1889,13 @@ void RecordPattern(): (Annotation())* ReferenceType() RecordStructurePattern() } -void RecordStructurePattern() #void: +void RecordStructurePattern() #PatternList: {} { "(" [ ComponentPatternList() ] ")" } -void ComponentPatternList() #PatternList : +void ComponentPatternList() #void : {} { ComponentPattern() ( "," ComponentPattern() )* diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.java index bf944eace8..318c0e0134 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.java +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.java @@ -97,4 +97,13 @@ public class RecordPatterns { System.out.println("String " + s); } } + + + record Empty(){} + void foo(Object o) { + boolean x = o instanceof Empty; + x = o instanceof Empty(); + } + + ; } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.txt index 04bed57df7..7c71e3a2b4 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.txt @@ -1,7 +1,7 @@ +- CompilationUnit[@PackageName = ""] +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatterns", @CanonicalName = "RecordPatterns", @EffectiveVisibility = Visibility.V_PUBLIC, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "RecordPatterns", @Static = false, @TopLevel = true, @UnnamedToplevelClass = false, @Visibility = Visibility.V_PUBLIC] +- ModifierList[@EffectiveModifiers = (JModifier.PUBLIC), @ExplicitModifiers = (JModifier.PUBLIC)] - +- ClassBody[@Empty = false, @Size = 18] + +- ClassBody[@Empty = false, @Size = 21] +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatterns$Point", @CanonicalName = "RecordPatterns.Point", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Point", @Static = true, @TopLevel = false, @UnnamedToplevelClass = false, @Visibility = Visibility.V_PACKAGE] | +- ModifierList[@EffectiveModifiers = (JModifier.STATIC, JModifier.FINAL), @ExplicitModifiers = ()] | +- RecordComponentList[@Empty = false, @Size = 2, @Varargs = false] @@ -512,38 +512,70 @@ | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String ", @Empty = false, @Image = "\"String \"", @Length = 7, @LiteralText = "\"String \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "test4", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] - +- VoidType[] - +- FormalParameters[@Empty = false, @Size = 1] - | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL] - | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] - | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] - | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] - | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] - | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "bo", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL] - +- Block[@Empty = false, @Size = 1, @containsComment = false] - +- IfStatement[@Else = false] - +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false] - | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | +- RecordPattern[] - | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] - | +- PatternList[@Empty = false, @Size = 1] - | +- RecordPattern[] - | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] - | +- PatternList[@Empty = false, @Size = 1] - | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] - | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] - | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = true, @Unnamed = false, @Visibility = Visibility.V_LOCAL] - +- Block[@Empty = false, @Size = 1, @containsComment = false] - +- ExpressionStatement[] - +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] - +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] - | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "System"] - +- ArgumentList[@Empty = false, @Size = 1] - +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] - +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String ", @Empty = false, @Image = "\"String \"", @Length = 7, @LiteralText = "\"String \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] + | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] + | +- VoidType[] + | +- FormalParameters[@Empty = false, @Size = 1] + | | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] + | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] + | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] + | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] + | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] + | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] + | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "bo", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL] + | +- Block[@Empty = false, @Size = 1, @containsComment = false] + | +- IfStatement[@Else = false] + | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- RecordPattern[] + | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] + | | +- PatternList[@Empty = false, @Size = 1] + | | +- RecordPattern[] + | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] + | | +- PatternList[@Empty = false, @Size = 1] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] + | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] + | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = true, @Unnamed = false, @Visibility = Visibility.V_LOCAL] + | +- Block[@Empty = false, @Size = 1, @containsComment = false] + | +- ExpressionStatement[] + | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "System"] + | +- ArgumentList[@Empty = false, @Size = 1] + | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] + | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String ", @Empty = false, @Image = "\"String \"", @Length = 7, @LiteralText = "\"String \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] + +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatterns$Empty", @CanonicalName = "RecordPatterns.Empty", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Empty", @Static = true, @TopLevel = false, @UnnamedToplevelClass = false, @Visibility = Visibility.V_PACKAGE] + | +- ModifierList[@EffectiveModifiers = (JModifier.STATIC, JModifier.FINAL), @ExplicitModifiers = ()] + | +- RecordComponentList[@Empty = true, @Size = 0, @Varargs = false] + | +- RecordBody[@Empty = true, @Size = 0] + +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "foo", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] + | +- VoidType[] + | +- FormalParameters[@Empty = false, @Size = 1] + | | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] + | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Object"] + | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "o", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL] + | +- Block[@Empty = false, @Size = 2, @containsComment = false] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] + | | +- PrimitiveType[@Kind = PrimitiveTypeKind.BOOLEAN] + | | +- VariableDeclarator[@Initializer = true, @Name = "x"] + | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "x", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Empty"] + | +- ExpressionStatement[] + | +- AssignmentExpression[@CompileTimeConstant = false, @Compound = false, @Operator = AssignmentOp.ASSIGN, @ParenthesisDepth = 0, @Parenthesized = false] + | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] + | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] + | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | +- RecordPattern[] + | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Empty"] + | +- PatternList[@Empty = true, @Size = 0] + +- EmptyDeclaration[] From b724b4dd33971ea0bdf45660c9107bd2e2ff95b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Mon, 7 Oct 2024 18:18:32 +0200 Subject: [PATCH 2/5] Fix DataflowPassTest --- .../java21/RecordPatterns.java | 5 ++- .../jdkversiontests/java21/RecordPatterns.txt | 41 ++++++++++--------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.java index 318c0e0134..36b02e94d8 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.java +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.java @@ -101,8 +101,9 @@ public class RecordPatterns { record Empty(){} void foo(Object o) { - boolean x = o instanceof Empty; - x = o instanceof Empty(); + if (o instanceof Empty + || o instanceof Empty()) + System.out.println("Empty " + o); } ; diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.txt index 7c71e3a2b4..44dc24bba6 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.txt @@ -559,23 +559,26 @@ | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Object"] | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "o", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL] - | +- Block[@Empty = false, @Size = 2, @containsComment = false] - | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] - | | +- PrimitiveType[@Kind = PrimitiveTypeKind.BOOLEAN] - | | +- VariableDeclarator[@Initializer = true, @Name = "x"] - | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "x", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL] - | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Empty"] - | +- ExpressionStatement[] - | +- AssignmentExpression[@CompileTimeConstant = false, @Compound = false, @Operator = AssignmentOp.ASSIGN, @ParenthesisDepth = 0, @Parenthesized = false] - | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] - | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | +- RecordPattern[] - | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Empty"] - | +- PatternList[@Empty = true, @Size = 0] + | +- Block[@Empty = false, @Size = 1, @containsComment = false] + | +- IfStatement[@Else = false] + | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.CONDITIONAL_OR, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Empty"] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- RecordPattern[] + | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Empty"] + | | +- PatternList[@Empty = true, @Size = 0] + | +- ExpressionStatement[] + | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "System"] + | +- ArgumentList[@Empty = false, @Size = 1] + | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] + | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Empty ", @Empty = false, @Image = "\"Empty \"", @Length = 6, @LiteralText = "\"Empty \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] +- EmptyDeclaration[] From fbde9b967f2194975546141a78ffa9df726ea5d3 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 11 Oct 2024 12:35:19 +0200 Subject: [PATCH 3/5] [doc] Update release notes (#5261, #5264) --- docs/pages/release_notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 197b7a4aec..4b87f9bfae 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -32,6 +32,7 @@ The old rule names still work but are deprecated. ### πŸ› Fixed Issues * java * [#4532](https://github.com/pmd/pmd/issues/4532): \[java] Rule misnomer for JUnit* rules + * [#5261](https://github.com/pmd/pmd/issues/5261): \[java] Record patterns with empty deconstructor lists lead to NPE * java-errorprone * [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault() @@ -49,6 +50,7 @@ The old rule names still work but are deprecated. * [#4965](https://github.com/pmd/pmd/pull/4965): \[java] Rename JUnit rules with overly restrictive names - [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5225](https://github.com/pmd/pmd/pull/5225): \[java] Fix #5067: CloseResource: False positive for FileSystems.getDefault() - [Lukas GrΓ€f](https://github.com/lukasgraef) (@lukasgraef) * [#5241](https://github.com/pmd/pmd/pull/5241): Ignore javacc code in coverage report - [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) +* [#5264](https://github.com/pmd/pmd/pull/5264): \[java] Fix NPE with empty pattern list - [ClΓ©ment Fournier](https://github.com/oowekyala) (@oowekyala) {% endtocmaker %} From 7655cfc63bb1b7dfdea2298beec0ae30215bb5e5 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 11 Oct 2024 12:35:45 +0200 Subject: [PATCH 4/5] Add @gudzpoz as a contributor --- .all-contributorsrc | 9 ++++++ docs/pages/pmd/projectdocs/credits.md | 41 ++++++++++++++------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 28d946f30a..e04c9b717b 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -7819,6 +7819,15 @@ "contributions": [ "bug" ] + }, + { + "login": "gudzpoz", + "name": "gudzpoz", + "avatar_url": "https://avatars.githubusercontent.com/u/14026120?v=4", + "profile": "https://kyo.iroiro.party/", + "contributions": [ + "bug" + ] } ], "contributorsPerLine": 7, diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index 4795947746..04fbc8f37a 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -930,180 +930,181 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d fsapatin
fsapatin

πŸ› gearsethenry
gearsethenry

πŸ› gracia19
gracia19

πŸ› - guo fei
guo fei

πŸ› + gudzpoz
gudzpoz

πŸ› + guo fei
guo fei

πŸ› gurmsc5
gurmsc5

πŸ› gwilymatgearset
gwilymatgearset

πŸ’» πŸ› haigsn
haigsn

πŸ› hemanshu070
hemanshu070

πŸ› henrik242
henrik242

πŸ› hongpuwu
hongpuwu

πŸ› - hvbtup
hvbtup

πŸ’» πŸ› + hvbtup
hvbtup

πŸ’» πŸ› igniti GmbH
igniti GmbH

πŸ› ilovezfs
ilovezfs

πŸ› imax-erik
imax-erik

πŸ› itaigilo
itaigilo

πŸ› jakivey32
jakivey32

πŸ› jbennett2091
jbennett2091

πŸ› - jcamerin
jcamerin

πŸ› + jcamerin
jcamerin

πŸ› jkeener1
jkeener1

πŸ› jmetertea
jmetertea

πŸ› johnra2
johnra2

πŸ’» johnzhao9
johnzhao9

πŸ› josemanuelrolon
josemanuelrolon

πŸ’» πŸ› kabroxiko
kabroxiko

πŸ’» πŸ› - karthikaiyasamy
karthikaiyasamy

πŸ“– + karthikaiyasamy
karthikaiyasamy

πŸ“– karwer
karwer

πŸ› kaulonline
kaulonline

πŸ› kdaemonv
kdaemonv

πŸ› kdebski85
kdebski85

πŸ› πŸ’» kenji21
kenji21

πŸ’» πŸ› kfranic
kfranic

πŸ› - khalidkh
khalidkh

πŸ› + khalidkh
khalidkh

πŸ› koalalam
koalalam

πŸ› krzyk
krzyk

πŸ› lasselindqvist
lasselindqvist

πŸ› lgemeinhardt
lgemeinhardt

πŸ› lihuaib
lihuaib

πŸ› liqingjun123
liqingjun123

πŸ› - lonelyma1021
lonelyma1021

πŸ› + lonelyma1021
lonelyma1021

πŸ› lpeddy
lpeddy

πŸ› lujiefsi
lujiefsi

πŸ’» lukelukes
lukelukes

πŸ’» lyriccoder
lyriccoder

πŸ› marcelmore
marcelmore

πŸ› matchbox
matchbox

πŸ› - matthiaskraaz
matthiaskraaz

πŸ› + matthiaskraaz
matthiaskraaz

πŸ› meandonlyme
meandonlyme

πŸ› mikesive
mikesive

πŸ› milossesic
milossesic

πŸ› mluckam
mluckam

πŸ’» πŸ› mohan-chinnappan-n
mohan-chinnappan-n

πŸ’» mriddell95
mriddell95

πŸ› - mrlzh
mrlzh

πŸ› + mrlzh
mrlzh

πŸ› msloan
msloan

πŸ› mucharlaravalika
mucharlaravalika

πŸ› mvenneman
mvenneman

πŸ› nareshl119
nareshl119

πŸ› nicolas-harraudeau-sonarsource
nicolas-harraudeau-sonarsource

πŸ› noerremark
noerremark

πŸ› - novsirion
novsirion

πŸ› + novsirion
novsirion

πŸ› nwcm
nwcm

πŸ“– πŸ› πŸ’» oggboy
oggboy

πŸ› oinume
oinume

πŸ› orimarko
orimarko

πŸ’» πŸ› pablogomez2197
pablogomez2197

πŸ› pacvz
pacvz

πŸ’» - pallavi agarwal
pallavi agarwal

πŸ› + pallavi agarwal
pallavi agarwal

πŸ› parksungrin
parksungrin

πŸ› patpatpat123
patpatpat123

πŸ› patriksevallius
patriksevallius

πŸ› pbrajesh1
pbrajesh1

πŸ› phoenix384
phoenix384

πŸ› piotrszymanski-sc
piotrszymanski-sc

πŸ’» - plan3d
plan3d

πŸ› + plan3d
plan3d

πŸ› poojasix
poojasix

πŸ› prabhushrikant
prabhushrikant

πŸ› pujitha8783
pujitha8783

πŸ› r-r-a-j
r-r-a-j

πŸ› raghujayjunk
raghujayjunk

πŸ› rajeshveera
rajeshveera

πŸ› - rajeswarreddy88
rajeswarreddy88

πŸ› + rajeswarreddy88
rajeswarreddy88

πŸ› recdevs
recdevs

πŸ› reudismam
reudismam

πŸ’» πŸ› rijkt
rijkt

πŸ› rillig-tk
rillig-tk

πŸ› rmohan20
rmohan20

πŸ’» πŸ› rnveach
rnveach

πŸ› - rxmicro
rxmicro

πŸ› + rxmicro
rxmicro

πŸ› ryan-gustafson
ryan-gustafson

πŸ’» πŸ› sabi0
sabi0

πŸ› scais
scais

πŸ› schosin
schosin

πŸ› screamingfrog
screamingfrog

πŸ’΅ sebbASF
sebbASF

πŸ› - sergeygorbaty
sergeygorbaty

πŸ’» + sergeygorbaty
sergeygorbaty

πŸ’» shilko2013
shilko2013

πŸ› shiomiyan
shiomiyan

πŸ“– simeonKondr
simeonKondr

πŸ› snajberk
snajberk

πŸ› sniperrifle2004
sniperrifle2004

πŸ› snuyanzin
snuyanzin

πŸ› πŸ’» - soloturn
soloturn

πŸ› + soloturn
soloturn

πŸ› soyodream
soyodream

πŸ› sratz
sratz

πŸ› stonio
stonio

πŸ› sturton
sturton

πŸ’» πŸ› sudharmohan
sudharmohan

πŸ› suruchidawar
suruchidawar

πŸ› - svenfinitiv
svenfinitiv

πŸ› + svenfinitiv
svenfinitiv

πŸ› szymanp23
szymanp23

πŸ› πŸ’» tashiscool
tashiscool

πŸ› test-git-hook
test-git-hook

πŸ› testation21
testation21

πŸ’» πŸ› thanosa
thanosa

πŸ› tiandiyixian
tiandiyixian

πŸ› - tobwoerk
tobwoerk

πŸ› + tobwoerk
tobwoerk

πŸ› tprouvot
tprouvot

πŸ› πŸ’» trentchilders
trentchilders

πŸ› triandicAnt
triandicAnt

πŸ› trishul14
trishul14

πŸ› tsui
tsui

πŸ› wangzitom12306
wangzitom12306

πŸ› - winhkey
winhkey

πŸ› + winhkey
winhkey

πŸ› witherspore
witherspore

πŸ› wjljack
wjljack

πŸ› wuchiuwong
wuchiuwong

πŸ› xingsong
xingsong

πŸ› xioayuge
xioayuge

πŸ› xnYi9wRezm
xnYi9wRezm

πŸ’» πŸ› - xuanuy
xuanuy

πŸ› + xuanuy
xuanuy

πŸ› xyf0921
xyf0921

πŸ› yalechen-cyw3
yalechen-cyw3

πŸ› yasuharu-sato
yasuharu-sato

πŸ› zenglian
zenglian

πŸ› zgrzyt93
zgrzyt93

πŸ’» πŸ› zh3ng
zh3ng

πŸ› - zt_soft
zt_soft

πŸ› + zt_soft
zt_soft

πŸ› ztt79
ztt79

πŸ› zzzzfeng
zzzzfeng

πŸ› ÁrpΓ‘d MagosΓ‘nyi
ÁrpÑd MagosÑnyi

πŸ› From 8ac55e7ad706d6095653e5a0e168e5eb4a822411 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 11 Oct 2024 16:42:42 +0200 Subject: [PATCH 5/5] Bump org.junit from 5.8.2 to 5.11.2 (#5274) Also update junit-platform from 1.10.2 to 1.11.2 - Supersedes and closes #5260 - Supersedes and closes #5259 --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 8f0474ab59..9d4e2061ab 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ ${maven.compiler.test.target} 1.9.24 5.9.1 - 5.8.2 + 5.11.2 1.9.20 5.0 @@ -963,7 +963,7 @@ org.junit.platform junit-platform-suite - 1.10.2 + 1.11.2 test @@ -1092,13 +1092,13 @@ 3.25.5 - org.junit.platform junit-platform-commons - 1.8.2 + 1.11.2 test