diff --git a/.all-contributorsrc b/.all-contributorsrc
index 0666f3e975..ce485028d8 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -7135,6 +7135,16 @@
"contributions": [
"code"
]
+ },
+ {
+ "login": "mohui1999",
+ "name": "Seren",
+ "avatar_url": "https://avatars.githubusercontent.com/u/46819179?v=4",
+ "profile": "https://github.com/mohui1999",
+ "contributions": [
+ "bug",
+ "code"
+ ]
}
],
"contributorsPerLine": 7,
diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md
index 32b6eacc60..7c364b7d02 100644
--- a/docs/pages/pmd/projectdocs/credits.md
+++ b/docs/pages/pmd/projectdocs/credits.md
@@ -656,363 +656,364 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Sebastian Bรถgl ๐ |
Sebastian Schuberth ๐ |
Sebastian Schwarz ๐ |
+ Seren ๐ ๐ป |
Sergey Gorbaty ๐ |
Sergey Kozlov ๐ |
Sergey Yanzin ๐ป ๐ |
- Seth Wilcox ๐ป |
+ Seth Wilcox ๐ป |
Shubham ๐ป ๐ |
Simon Abykov ๐ป ๐ |
Simon Xiao ๐ |
Srinivasan Venkatachalam ๐ |
Stanislav Gromov ๐ |
Stanislav Myachenkov ๐ป |
- Stefan Birkner ๐ |
+ Stefan Birkner ๐ |
Stefan Bohn ๐ |
Stefan Endrullis ๐ |
Stefan Klรถss-Schuster ๐ |
Stefan Wolf ๐ |
Stephan H. Wissel ๐ |
Stephen ๐ |
- Stephen Friedrich ๐ |
+ Stephen Friedrich ๐ |
Steve Babula ๐ป |
Steven Stearns ๐ ๐ป |
Stexxe ๐ |
Stian Lรฅgstad ๐ |
StuartClayton5 ๐ |
Supun Arunoda ๐ |
- Suren Abrahamyan ๐ |
+ Suren Abrahamyan ๐ |
Suvashri ๐ |
SwatiBGupta1110 ๐ |
SyedThoufich ๐ |
Szymon Sasin ๐ |
T-chuangxin ๐ |
TERAI Atsuhiro ๐ |
- TIOBE Software ๐ป ๐ |
+ TIOBE Software ๐ป ๐ |
Tarush Singh ๐ป |
Taylor Smock ๐ |
Techeira Damiรกn ๐ป ๐ |
Ted Husted ๐ |
TehBakker ๐ |
The Gitter Badger ๐ |
- Theodoor ๐ |
+ Theodoor ๐ |
Thiago Henrique Hรผpner ๐ |
Thibault Meyer ๐ |
Thomas Gรผttler ๐ |
Thomas Jones-Low ๐ |
Thomas Smith ๐ป ๐ |
ThrawnCA ๐ |
- Thunderforge ๐ป ๐ |
+ Thunderforge ๐ป ๐ |
Tim van der Lippe ๐ |
Tobias Weimer ๐ป ๐ |
Tom Copeland ๐ ๐ป ๐ |
Tom Daly ๐ |
Tomer Figenblat ๐ |
Tomi De Lucca ๐ป ๐ |
- Torsten Kleiber ๐ |
+ Torsten Kleiber ๐ |
TrackerSB ๐ |
Tyson Stewart ๐ |
Ullrich Hafner ๐ |
Utku Cuhadaroglu ๐ป ๐ |
Valentin Brandl ๐ |
Valeria ๐ |
- Valery Yatsynovich ๐ |
+ Valery Yatsynovich ๐ |
Vasily Anisimov ๐ |
Vibhor Goyal ๐ |
Vickenty Fesunov ๐ |
Victor Noรซl ๐ |
Vincent Galloy ๐ป |
Vincent HUYNH ๐ |
- Vincent Maurin ๐ |
+ Vincent Maurin ๐ |
Vincent Privat ๐ |
Vishhwas ๐ |
Vitaly ๐ |
Vitaly Polonetsky ๐ |
Vojtech Polivka ๐ |
Vsevolod Zholobov ๐ |
- Vyom Yadav ๐ป |
+ Vyom Yadav ๐ป |
Wang Shidong ๐ |
Waqas Ahmed ๐ |
Wayne J. Earl ๐ |
Wchenghui ๐ |
Will Winder ๐ |
William Brockhus ๐ป ๐ |
- Wilson Kurniawan ๐ |
+ Wilson Kurniawan ๐ |
Wim Deblauwe ๐ |
Woongsik Choi ๐ |
XenoAmess ๐ป ๐ |
Yang ๐ป |
YaroslavTER ๐ |
Yasar Shaikh ๐ป |
- Young Chan ๐ป ๐ |
+ Young Chan ๐ป ๐ |
YuJin Kim ๐ |
Yuri Dolzhenko ๐ |
Yurii Dubinka ๐ |
Zoltan Farkas ๐ |
Zustin ๐ |
aaronhurst-google ๐ ๐ป |
- alexmodis ๐ |
+ alexmodis ๐ |
andreoss ๐ |
andrey81inmd ๐ป ๐ |
anicoara ๐ |
arunprasathav ๐ |
asiercamara ๐ |
astillich-igniti ๐ป |
- avesolovksyy ๐ |
+ avesolovksyy ๐ |
avishvat ๐ |
avivmu ๐ |
axelbarfod1 ๐ |
b-3-n ๐ |
balbhadra9 ๐ |
base23de ๐ |
- bergander ๐ |
+ bergander ๐ |
berkam ๐ป ๐ |
breizh31 ๐ |
caesarkim ๐ |
carolyujing ๐ |
cbfiddle ๐ |
cesares-basilico ๐ |
- chrite ๐ |
+ chrite ๐ |
cobratbq ๐ |
coladict ๐ |
cosmoJFH ๐ |
cristalp ๐ |
crunsk ๐ |
cwholmes ๐ |
- cyberjj999 ๐ |
+ cyberjj999 ๐ |
cyw3 ๐ |
d1ss0nanz ๐ |
dague1 ๐ |
dalizi007 ๐ป |
danbrycefairsailcom ๐ |
dariansanity ๐ |
- darrenmiliband ๐ |
+ darrenmiliband ๐ |
davidburstrom ๐ |
dbirkman-paloalto ๐ |
deepak-patra ๐ |
dependabot[bot] ๐ป ๐ |
dinesh150 ๐ |
diziaq ๐ |
- dreaminpast123 ๐ |
+ dreaminpast123 ๐ |
duanyanan ๐ |
dutt-sanjay ๐ |
dylanleung ๐ |
dzeigler ๐ |
ekkirala ๐ |
emersonmoura ๐ |
- fairy ๐ |
+ fairy ๐ |
filiprafalowicz ๐ป |
foxmason ๐ |
frankegabor ๐ |
frankl ๐ |
freafrea ๐ |
fsapatin ๐ |
- gracia19 ๐ |
+ gracia19 ๐ |
guo fei ๐ |
gurmsc5 ๐ |
gwilymatgearset ๐ป ๐ |
haigsn ๐ |
hemanshu070 ๐ |
henrik242 ๐ |
- hongpuwu ๐ |
+ hongpuwu ๐ |
hvbtup ๐ป ๐ |
igniti GmbH ๐ |
ilovezfs ๐ |
itaigilo ๐ |
jakivey32 ๐ |
jbennett2091 ๐ |
- jcamerin ๐ |
+ jcamerin ๐ |
jkeener1 ๐ |
jmetertea ๐ |
johnra2 ๐ป |
josemanuelrolon ๐ป ๐ |
kabroxiko ๐ป ๐ |
karwer ๐ |
- kaulonline ๐ |
+ kaulonline ๐ |
kdaemonv ๐ |
kdebski85 ๐ ๐ป |
kenji21 ๐ป ๐ |
kfranic ๐ |
khalidkh ๐ |
koalalam ๐ |
- krzyk ๐ |
+ krzyk ๐ |
lasselindqvist ๐ |
lgemeinhardt ๐ |
lihuaib ๐ |
lonelyma1021 ๐ |
lpeddy ๐ |
lujiefsi ๐ป |
- lukelukes ๐ป |
+ lukelukes ๐ป |
lyriccoder ๐ |
marcelmore ๐ |
matchbox ๐ |
matthiaskraaz ๐ |
meandonlyme ๐ |
mikesive ๐ |
- milossesic ๐ |
+ milossesic ๐ |
mluckam ๐ป |
mohan-chinnappan-n ๐ป |
mriddell95 ๐ |
mrlzh ๐ |
msloan ๐ |
mucharlaravalika ๐ |
- mvenneman ๐ |
+ mvenneman ๐ |
nareshl119 ๐ |
nicolas-harraudeau-sonarsource ๐ |
noerremark ๐ |
novsirion ๐ |
oggboy ๐ |
oinume ๐ |
- orimarko ๐ป ๐ |
+ orimarko ๐ป ๐ |
pacvz ๐ป |
pallavi agarwal ๐ |
parksungrin ๐ |
patpatpat123 ๐ |
patriksevallius ๐ |
pbrajesh1 ๐ |
- phoenix384 ๐ |
+ phoenix384 ๐ |
piotrszymanski-sc ๐ป |
plan3d ๐ |
poojasix ๐ |
prabhushrikant ๐ |
pujitha8783 ๐ |
r-r-a-j ๐ |
- raghujayjunk ๐ |
+ raghujayjunk ๐ |
rajeshveera ๐ |
rajeswarreddy88 ๐ |
recdevs ๐ |
reudismam ๐ป ๐ |
rijkt ๐ |
rillig-tk ๐ |
- rmohan20 ๐ป ๐ |
+ rmohan20 ๐ป ๐ |
rnveach ๐ |
rxmicro ๐ |
ryan-gustafson ๐ป ๐ |
sabi0 ๐ |
scais ๐ |
sebbASF ๐ |
- sergeygorbaty ๐ป |
+ sergeygorbaty ๐ป |
shilko2013 ๐ |
shiomiyan ๐ |
simeonKondr ๐ |
snajberk ๐ |
sniperrifle2004 ๐ |
snuyanzin ๐ ๐ป |
- sratz ๐ |
+ sratz ๐ |
stonio ๐ |
sturton ๐ป ๐ |
sudharmohan ๐ |
suruchidawar ๐ |
svenfinitiv ๐ |
tashiscool ๐ |
- test-git-hook ๐ |
+ test-git-hook ๐ |
testation21 ๐ป ๐ |
thanosa ๐ |
tiandiyixian ๐ |
tobwoerk ๐ |
tprouvot ๐ ๐ป |
trentchilders ๐ |
- triandicAnt ๐ |
+ triandicAnt ๐ |
trishul14 ๐ |
tsui ๐ |
winhkey ๐ |
witherspore ๐ |
wjljack ๐ |
wuchiuwong ๐ |
- xingsong ๐ |
+ xingsong ๐ |
xioayuge ๐ |
xnYi9wRezm ๐ป ๐ |
xuanuy ๐ |
xyf0921 ๐ |
yalechen-cyw3 ๐ |
yasuharu-sato ๐ |
- zenglian ๐ |
+ zenglian ๐ |
zgrzyt93 ๐ป ๐ |
zh3ng ๐ |
zt_soft ๐ |
ztt79 ๐ |
zzzzfeng ๐ |
รrpรกd Magosรกnyi ๐ |
- ไปป่ดตๆฐ ๐ |
+ ไปป่ดตๆฐ ๐ |
่
ๅปถๅฎ ๐ป |
diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md
index 65ee53748d..b875222f4d 100644
--- a/docs/pages/release_notes.md
+++ b/docs/pages/release_notes.md
@@ -42,6 +42,8 @@ The remaining section describe the complete release notes for 7.0.0.
Fixed Issues:
* java-codestyle
* [#4273](https://github.com/pmd/pmd/issues/4273): \[java] CommentDefaultAccessModifier ignoredAnnotations should include "org.junit.jupiter.api.extension.RegisterExtension" by default
+* java-errorprone
+ * [#4449](https://github.com/pmd/pmd/issues/4449): \[java] AvoidAccessibilityAlteration: Possible false positive in AvoidAccessibilityAlteration rule when using Lambda expression
### ๐ Major Features and Enhancements
@@ -364,6 +366,7 @@ Language specific fixes:
* [#3351](https://github.com/pmd/pmd/issues/3351): \[java] ConstructorCallsOverridableMethod ignores abstract methods
* [#3400](https://github.com/pmd/pmd/issues/3400): \[java] AvoidUsingOctalValues FN with underscores
* [#4356](https://github.com/pmd/pmd/pull/4356): \[java] Fix NPE in CloseResourceRule
+ * [#4449](https://github.com/pmd/pmd/issues/4449): \[java] AvoidAccessibilityAlteration: Possible false positive in AvoidAccessibilityAlteration rule when using Lambda expression
* java-multithreading
* [#2537](https://github.com/pmd/pmd/issues/2537): \[java] DontCallThreadRun can't detect the case that call run() in `this.run()`
* [#2538](https://github.com/pmd/pmd/issues/2538): \[java] DontCallThreadRun can't detect the case that call run() in `foo.bar.run()`
@@ -395,6 +398,7 @@ Language specific fixes:
* [#4412](https://github.com/pmd/pmd/pull/4412): \[doc] Added new error msg to ConstantsInInterface - [David Ljunggren](https://github.com/dague1) (@dague1)
* [#4428](https://github.com/pmd/pmd/pull/4428): \[apex] ApexBadCrypto bug fix for #4427 - inline detection of hard coded values - [Steven Stearns](https://github.com/sfdcsteve) (@sfdcsteve)
* [#4444](https://github.com/pmd/pmd/pull/4444): \[java] CommentDefaultAccessModifier - ignore org.junit.jupiter.api.extension.RegisterExtension by default - [Nirvik Patel](https://github.com/nirvikpatel) (@nirvikpatel)
+* [#4450](https://github.com/pmd/pmd/pull/4450): \[java] Fix #4449 AvoidAccessibilityAlteration: Correctly handle Lambda expressions in PrivilegedAction scenarios - [Seren](https://github.com/mohui1999) (@mohui1999)
### ๐ Stats
* 4416 commits
diff --git a/pmd-java/src/main/resources/category/java/errorprone.xml b/pmd-java/src/main/resources/category/java/errorprone.xml
index c141a2eb81..c888a021ff 100644
--- a/pmd-java/src/main/resources/category/java/errorprone.xml
+++ b/pmd-java/src/main/resources/category/java/errorprone.xml
@@ -87,6 +87,8 @@ suppression methods (e.g. by using `@SuppressWarnings` annotation).
[not(ancestor::ConstructorCall[1][pmd-java:typeIs('java.security.PrivilegedAction')]/AnonymousClassDeclaration)]
(: exclude inner privileged action classes :)
[not(ancestor::ClassOrInterfaceDeclaration[1][pmd-java:typeIs('java.security.PrivilegedAction')])]
+ (: exclude privileged action lambdas :)
+ [not(ancestor::LambdaExpression[pmd-java:typeIs('java.security.PrivilegedAction')])]
]]>
diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/AvoidAccessibilityAlteration.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/AvoidAccessibilityAlteration.xml
index b20329d34b..3e650c070c 100644
--- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/AvoidAccessibilityAlteration.xml
+++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/AvoidAccessibilityAlteration.xml
@@ -184,4 +184,39 @@ public class Violation {
}
]]>
-
\ No newline at end of file
+
+
+ #4449 setAccessible is ok in LambdaExpression
+ 0
+ constructor = this.getClass().getDeclaredConstructor(String.class);
+
+ // deliberate accessibility alteration
+ String privateField = AccessController.doPrivileged((PrivilegedAction)() -> {
+ try {
+ Field field = Violation.class.getDeclaredField("aPrivateField");
+ field.setAccessible(true); //no violation
+ return (String) field.get(null);
+ } catch (ReflectiveOperationException | SecurityException e) {
+ throw new RuntimeException(e);
+ }
+ });
+ }
+ }
+
+ ]]>
+
+
+
+
+