From 83d56dab2844cdac1ca8680ad6ef00b0cc0cf703 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 3 Sep 2021 09:31:03 +0200 Subject: [PATCH] [java] AvoidAccessibilityAlteration: allow setAccessible(false) This restores the cheks for the Java language access control. --- .../main/resources/category/java/errorprone.xml | 1 + .../xml/AvoidAccessibilityAlteration.xml | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/pmd-java/src/main/resources/category/java/errorprone.xml b/pmd-java/src/main/resources/category/java/errorprone.xml index 0bfa9e4138..475e47af45 100644 --- a/pmd-java/src/main/resources/category/java/errorprone.xml +++ b/pmd-java/src/main/resources/category/java/errorprone.xml @@ -76,6 +76,7 @@ is assumed to be deliberate and is not reported. + + + setAccessible(false) is ok + 0 + constructor = this.getClass().getDeclaredConstructor(String.class); + // call to setAccessible with false - that's ok + constructor.setAccessible(false); + } +} + ]]> + \ No newline at end of file