Commit f82dd1e
committed
Apply field predicate before searching type hierarchy
Prior to this commit, findFields() and streamFields() in
ReflectionSupport as well as findAnnotatedFields() and
findAnnotatedFieldValues() in AnnotationSupport first searched for all
fields in the type hierarchy and then applied the user-supplied
predicate (or "is annotated?" predicate) afterwards.
This resulted in fields in subclasses incorrectly "shadowing"
package-private fields in superclasses (in a different package) even if
the predicate would otherwise exclude the field in such a subclass.
For example, given a superclass that declares a package-private static
@TempDir "tempDir" field and a subclass (in a different package) that
declares a @TempDir "tempDir" field, when JUnit Jupiter looked up
@TempDir fields for the subclass, the @TempDir "tempDir" field in the
superclass was not found because the @TempDir "tempDir" field shadowed
it based solely on the field signature, ignoring the type of annotation
sought.
To address that, this commit modifies the internal search algorithms in
ReflectionUtils so that field predicates are applied while searching
the hierarchy for fields.
See #3498
Closes #3532
Closes #3533
(cherry picked from commit f30a8d5)1 parent 1d1eb85 commit f82dd1e
File tree
8 files changed
+184
-19
lines changed- documentation/src/docs/asciidoc/release-notes
- junit-platform-commons/src/main/java/org/junit/platform/commons/util
- platform-tests/src/test/java/org/junit/platform/commons/util
- pkg1
- subpkg
8 files changed
+184
-19
lines changedLines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
32 | 40 | | |
33 | 41 | | |
| 42 | + | |
| 43 | + | |
34 | 44 | | |
35 | 45 | | |
36 | 46 | | |
37 | | - | |
38 | | - | |
39 | 47 | | |
40 | 48 | | |
41 | 49 | | |
| |||
Lines changed: 27 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1238 | 1238 | | |
1239 | 1239 | | |
1240 | 1240 | | |
| 1241 | + | |
1241 | 1242 | | |
1242 | 1243 | | |
1243 | 1244 | | |
| |||
1252 | 1253 | | |
1253 | 1254 | | |
1254 | 1255 | | |
1255 | | - | |
| 1256 | + | |
1256 | 1257 | | |
1257 | 1258 | | |
1258 | | - | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
1259 | 1262 | | |
1260 | 1263 | | |
1261 | 1264 | | |
1262 | 1265 | | |
1263 | | - | |
| 1266 | + | |
1264 | 1267 | | |
1265 | 1268 | | |
1266 | | - | |
| 1269 | + | |
1267 | 1270 | | |
1268 | 1271 | | |
1269 | | - | |
| 1272 | + | |
1270 | 1273 | | |
1271 | 1274 | | |
1272 | 1275 | | |
| |||
1529 | 1532 | | |
1530 | 1533 | | |
1531 | 1534 | | |
1532 | | - | |
| 1535 | + | |
| 1536 | + | |
1533 | 1537 | | |
1534 | | - | |
1535 | | - | |
| 1538 | + | |
| 1539 | + | |
1536 | 1540 | | |
1537 | 1541 | | |
1538 | 1542 | | |
1539 | 1543 | | |
1540 | | - | |
| 1544 | + | |
| 1545 | + | |
1541 | 1546 | | |
1542 | | - | |
1543 | | - | |
| 1547 | + | |
| 1548 | + | |
1544 | 1549 | | |
1545 | 1550 | | |
1546 | 1551 | | |
| |||
1602 | 1607 | | |
1603 | 1608 | | |
1604 | 1609 | | |
1605 | | - | |
| 1610 | + | |
1606 | 1611 | | |
1607 | 1612 | | |
| 1613 | + | |
1608 | 1614 | | |
1609 | 1615 | | |
1610 | 1616 | | |
| |||
1672 | 1678 | | |
1673 | 1679 | | |
1674 | 1680 | | |
1675 | | - | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
1676 | 1684 | | |
1677 | 1685 | | |
1678 | | - | |
| 1686 | + | |
1679 | 1687 | | |
1680 | 1688 | | |
1681 | | - | |
| 1689 | + | |
1682 | 1690 | | |
1683 | 1691 | | |
1684 | 1692 | | |
| |||
1694 | 1702 | | |
1695 | 1703 | | |
1696 | 1704 | | |
1697 | | - | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
1698 | 1708 | | |
1699 | 1709 | | |
1700 | 1710 | | |
1701 | 1711 | | |
1702 | | - | |
| 1712 | + | |
1703 | 1713 | | |
1704 | 1714 | | |
1705 | 1715 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
49 | 51 | | |
| 52 | + | |
50 | 53 | | |
| 54 | + | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
| |||
504 | 508 | | |
505 | 509 | | |
506 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
507 | 533 | | |
508 | 534 | | |
509 | 535 | | |
| |||
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
77 | 78 | | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
1380 | 1382 | | |
1381 | 1383 | | |
1382 | 1384 | | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
1383 | 1407 | | |
1384 | 1408 | | |
1385 | 1409 | | |
| |||
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
0 commit comments