-
Notifications
You must be signed in to change notification settings - Fork 324
Forbid methods that mutate final fields #10388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 55 metrics, 10 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.59.0-SNAPSHOT~9d987f7668, baseline=1.59.0-SNAPSHOT~340e03e23d
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.125 s) : 0, 1125017
Total [baseline] (11.137 s) : 0, 11136848
Agent [candidate] (1.116 s) : 0, 1116381
Total [candidate] (11.206 s) : 0, 11205689
section appsec
Agent [baseline] (1.3 s) : 0, 1300328
Total [baseline] (11.389 s) : 0, 11388843
Agent [candidate] (1.305 s) : 0, 1304715
Total [candidate] (11.43 s) : 0, 11430057
section iast
Agent [baseline] (1.273 s) : 0, 1273099
Total [baseline] (11.459 s) : 0, 11459068
Agent [candidate] (1.269 s) : 0, 1269003
Total [candidate] (11.474 s) : 0, 11473682
section profiling
Agent [baseline] (1.235 s) : 0, 1234900
Total [baseline] (11.23 s) : 0, 11229852
Agent [candidate] (1.233 s) : 0, 1233163
Total [candidate] (11.189 s) : 0, 11188565
gantt
title petclinic - break down per module: candidate=1.59.0-SNAPSHOT~9d987f7668, baseline=1.59.0-SNAPSHOT~340e03e23d
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.26 ms) : 0, 1260
crashtracking [candidate] (1.246 ms) : 0, 1246
BytebuddyAgent [baseline] (674.389 ms) : 0, 674389
BytebuddyAgent [candidate] (668.559 ms) : 0, 668559
GlobalTracer [baseline] (293.802 ms) : 0, 293802
GlobalTracer [candidate] (291.904 ms) : 0, 291904
AppSec [baseline] (33.945 ms) : 0, 33945
AppSec [candidate] (33.678 ms) : 0, 33678
Debugger [baseline] (71.069 ms) : 0, 71069
Debugger [candidate] (70.818 ms) : 0, 70818
Remote Config [baseline] (683.824 µs) : 0, 684
Remote Config [candidate] (686.215 µs) : 0, 686
Telemetry [baseline] (9.49 ms) : 0, 9490
Telemetry [candidate] (9.306 ms) : 0, 9306
Flare Poller [baseline] (3.903 ms) : 0, 3903
Flare Poller [candidate] (3.907 ms) : 0, 3907
section appsec
crashtracking [baseline] (1.239 ms) : 0, 1239
crashtracking [candidate] (1.241 ms) : 0, 1241
BytebuddyAgent [baseline] (707.21 ms) : 0, 707210
BytebuddyAgent [candidate] (710.637 ms) : 0, 710637
GlobalTracer [baseline] (267.635 ms) : 0, 267635
GlobalTracer [candidate] (268.16 ms) : 0, 268160
IAST [baseline] (25.767 ms) : 0, 25767
IAST [candidate] (25.936 ms) : 0, 25936
AppSec [baseline] (178.333 ms) : 0, 178333
AppSec [candidate] (175.613 ms) : 0, 175613
Debugger [baseline] (69.459 ms) : 0, 69459
Debugger [candidate] (72.339 ms) : 0, 72339
Remote Config [baseline] (811.297 µs) : 0, 811
Remote Config [candidate] (808.879 µs) : 0, 809
Telemetry [baseline] (9.739 ms) : 0, 9739
Telemetry [candidate] (9.801 ms) : 0, 9801
Flare Poller [baseline] (3.959 ms) : 0, 3959
Flare Poller [candidate] (3.934 ms) : 0, 3934
section iast
crashtracking [baseline] (1.253 ms) : 0, 1253
crashtracking [candidate] (1.247 ms) : 0, 1247
BytebuddyAgent [baseline] (819.893 ms) : 0, 819893
BytebuddyAgent [candidate] (819.232 ms) : 0, 819232
GlobalTracer [baseline] (269.169 ms) : 0, 269169
GlobalTracer [candidate] (266.992 ms) : 0, 266992
IAST [baseline] (28.553 ms) : 0, 28553
IAST [candidate] (28.313 ms) : 0, 28313
AppSec [baseline] (35.519 ms) : 0, 35519
AppSec [candidate] (35.195 ms) : 0, 35195
Debugger [baseline] (69.21 ms) : 0, 69210
Debugger [candidate] (68.554 ms) : 0, 68554
Remote Config [baseline] (636.818 µs) : 0, 637
Remote Config [candidate] (605.615 µs) : 0, 606
Telemetry [baseline] (8.87 ms) : 0, 8870
Telemetry [candidate] (8.81 ms) : 0, 8810
Flare Poller [baseline] (3.683 ms) : 0, 3683
Flare Poller [candidate] (3.762 ms) : 0, 3762
section profiling
crashtracking [baseline] (1.266 ms) : 0, 1266
crashtracking [candidate] (1.265 ms) : 0, 1265
BytebuddyAgent [baseline] (717.938 ms) : 0, 717938
BytebuddyAgent [candidate] (717.575 ms) : 0, 717575
GlobalTracer [baseline] (229.794 ms) : 0, 229794
GlobalTracer [candidate] (229.797 ms) : 0, 229797
AppSec [baseline] (33.272 ms) : 0, 33272
AppSec [candidate] (33.158 ms) : 0, 33158
Debugger [baseline] (70.931 ms) : 0, 70931
Debugger [candidate] (69.43 ms) : 0, 69430
Remote Config [baseline] (673.146 µs) : 0, 673
Remote Config [candidate] (664.771 µs) : 0, 665
Telemetry [baseline] (9.457 ms) : 0, 9457
Telemetry [candidate] (9.266 ms) : 0, 9266
Flare Poller [baseline] (3.891 ms) : 0, 3891
Flare Poller [candidate] (3.887 ms) : 0, 3887
ProfilingAgent [baseline] (96.873 ms) : 0, 96873
ProfilingAgent [candidate] (97.12 ms) : 0, 97120
Profiling [baseline] (97.468 ms) : 0, 97468
Profiling [candidate] (97.717 ms) : 0, 97717
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.59.0-SNAPSHOT~9d987f7668, baseline=1.59.0-SNAPSHOT~340e03e23d
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.113 s) : 0, 1113044
Total [baseline] (9.369 s) : 0, 9368881
Agent [candidate] (1.113 s) : 0, 1113372
Total [candidate] (9.401 s) : 0, 9401282
section iast
Agent [baseline] (1.257 s) : 0, 1256987
Total [baseline] (9.974 s) : 0, 9973821
Agent [candidate] (1.269 s) : 0, 1268707
Total [candidate] (9.939 s) : 0, 9938975
gantt
title insecure-bank - break down per module: candidate=1.59.0-SNAPSHOT~9d987f7668, baseline=1.59.0-SNAPSHOT~340e03e23d
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.247 ms) : 0, 1247
crashtracking [candidate] (1.241 ms) : 0, 1241
BytebuddyAgent [baseline] (667.192 ms) : 0, 667192
BytebuddyAgent [candidate] (666.879 ms) : 0, 666879
GlobalTracer [baseline] (290.924 ms) : 0, 290924
GlobalTracer [candidate] (291.603 ms) : 0, 291603
AppSec [baseline] (33.674 ms) : 0, 33674
AppSec [candidate] (33.545 ms) : 0, 33545
Debugger [baseline] (70.117 ms) : 0, 70117
Debugger [candidate] (70.012 ms) : 0, 70012
Remote Config [baseline] (682.338 µs) : 0, 682
Remote Config [candidate] (703.703 µs) : 0, 704
Telemetry [baseline] (9.254 ms) : 0, 9254
Telemetry [candidate] (9.392 ms) : 0, 9392
Flare Poller [baseline] (3.87 ms) : 0, 3870
Flare Poller [candidate] (3.872 ms) : 0, 3872
section iast
crashtracking [baseline] (1.236 ms) : 0, 1236
crashtracking [candidate] (1.252 ms) : 0, 1252
BytebuddyAgent [baseline] (810.188 ms) : 0, 810188
BytebuddyAgent [candidate] (818.825 ms) : 0, 818825
GlobalTracer [baseline] (266.08 ms) : 0, 266080
GlobalTracer [candidate] (268.068 ms) : 0, 268068
IAST [baseline] (28.1 ms) : 0, 28100
IAST [candidate] (28.408 ms) : 0, 28408
AppSec [baseline] (32.268 ms) : 0, 32268
AppSec [candidate] (36.886 ms) : 0, 36886
Debugger [baseline] (70.148 ms) : 0, 70148
Debugger [candidate] (65.81 ms) : 0, 65810
Remote Config [baseline] (590.41 µs) : 0, 590
Remote Config [candidate] (605.549 µs) : 0, 606
Telemetry [baseline] (8.656 ms) : 0, 8656
Telemetry [candidate] (8.838 ms) : 0, 8838
Flare Poller [baseline] (3.63 ms) : 0, 3630
Flare Poller [candidate] (3.762 ms) : 0, 3762
LoadParameters
See matching parameters
SummaryFound 3 performance improvements and 2 performance regressions! Performance is the same for 14 metrics, 17 unstable metrics.
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.59.0-SNAPSHOT~9d987f7668, baseline=1.59.0-SNAPSHOT~340e03e23d
dateFormat X
axisFormat %s
section baseline
no_agent (17.366 ms) : 17192, 17540
. : milestone, 17366,
appsec (18.703 ms) : 18510, 18897
. : milestone, 18703,
code_origins (17.906 ms) : 17726, 18087
. : milestone, 17906,
iast (18.152 ms) : 17969, 18334
. : milestone, 18152,
profiling (19.693 ms) : 19497, 19889
. : milestone, 19693,
tracing (18.128 ms) : 17943, 18313
. : milestone, 18128,
section candidate
no_agent (19.295 ms) : 19093, 19497
. : milestone, 19295,
appsec (18.826 ms) : 18636, 19017
. : milestone, 18826,
code_origins (17.69 ms) : 17513, 17866
. : milestone, 17690,
iast (17.818 ms) : 17640, 17996
. : milestone, 17818,
profiling (18.729 ms) : 18543, 18914
. : milestone, 18729,
tracing (17.55 ms) : 17376, 17723
. : milestone, 17550,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.59.0-SNAPSHOT~9d987f7668, baseline=1.59.0-SNAPSHOT~340e03e23d
dateFormat X
axisFormat %s
section baseline
no_agent (1.191 ms) : 1179, 1203
. : milestone, 1191,
iast (3.159 ms) : 3116, 3202
. : milestone, 3159,
iast_FULL (5.719 ms) : 5663, 5776
. : milestone, 5719,
iast_GLOBAL (3.3 ms) : 3257, 3344
. : milestone, 3300,
profiling (2.059 ms) : 2039, 2079
. : milestone, 2059,
tracing (1.833 ms) : 1817, 1849
. : milestone, 1833,
section candidate
no_agent (1.206 ms) : 1195, 1218
. : milestone, 1206,
iast (3.023 ms) : 2987, 3059
. : milestone, 3023,
iast_FULL (5.621 ms) : 5566, 5676
. : milestone, 5621,
iast_GLOBAL (3.63 ms) : 3574, 3685
. : milestone, 3630,
profiling (2.06 ms) : 2040, 2081
. : milestone, 2060,
tracing (1.841 ms) : 1825, 1856
. : milestone, 1841,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 1 unstable metrics. Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.59.0-SNAPSHOT~9d987f7668, baseline=1.59.0-SNAPSHOT~340e03e23d
dateFormat X
axisFormat %s
section baseline
no_agent (1.476 ms) : 1464, 1487
. : milestone, 1476,
appsec (3.727 ms) : 3508, 3947
. : milestone, 3727,
iast (2.215 ms) : 2150, 2281
. : milestone, 2215,
iast_GLOBAL (2.267 ms) : 2201, 2333
. : milestone, 2267,
profiling (2.067 ms) : 2014, 2121
. : milestone, 2067,
tracing (2.051 ms) : 1999, 2102
. : milestone, 2051,
section candidate
no_agent (1.475 ms) : 1463, 1486
. : milestone, 1475,
appsec (3.645 ms) : 3430, 3860
. : milestone, 3645,
iast (2.223 ms) : 2158, 2289
. : milestone, 2223,
iast_GLOBAL (2.261 ms) : 2195, 2327
. : milestone, 2261,
profiling (2.1 ms) : 2045, 2155
. : milestone, 2100,
tracing (2.039 ms) : 1987, 2091
. : milestone, 2039,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.59.0-SNAPSHOT~9d987f7668, baseline=1.59.0-SNAPSHOT~340e03e23d
dateFormat X
axisFormat %s
section baseline
no_agent (15.39 s) : 15390000, 15390000
. : milestone, 15390000,
appsec (14.81 s) : 14810000, 14810000
. : milestone, 14810000,
iast (17.993 s) : 17993000, 17993000
. : milestone, 17993000,
iast_GLOBAL (17.789 s) : 17789000, 17789000
. : milestone, 17789000,
profiling (15.245 s) : 15245000, 15245000
. : milestone, 15245000,
tracing (14.827 s) : 14827000, 14827000
. : milestone, 14827000,
section candidate
no_agent (15.077 s) : 15077000, 15077000
. : milestone, 15077000,
appsec (14.695 s) : 14695000, 14695000
. : milestone, 14695000,
iast (17.967 s) : 17967000, 17967000
. : milestone, 17967000,
iast_GLOBAL (18.017 s) : 18017000, 18017000
. : milestone, 18017000,
profiling (14.775 s) : 14775000, 14775000
. : milestone, 14775000,
tracing (14.876 s) : 14876000, 14876000
. : milestone, 14876000,
|
AlexeyKuznetsov-DD
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this PR is useful...
How it will help to stop mutating final fields?
Reflection is not always mutating final fields.
I would better to have CI settings to use something --illegal-final-field-mutation=deny and fix all failed tests.
WDYT?
@AlexeyKuznetsov-DD Right it won't stop our current usage of mutating final fields, which would be a follow-up task. The goal of this PR would be to prevent further use of methods that are mutating final fields. I updated the PR description to be a bit more clear about this! |
PerfectSlayer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @sarahchen6
There is already a PR for this initiative: #9557 Would you like to take it over?
I did a first pass at identifying the (soon to be) illegal mutations and there aren't much to fix. It should be fixed nonetheless. And adding the flag for |
Oh great sure! Totally missed it sorry - I'll close this one then. |
What Does This Do
Add the
Field#setandMethodHandles.Lookup::unreflectSettermethods to the ForbiddenAPIs list in order to discourage further use.Motivation
Java is headed toward integrity by default, which includes disallowing the mutation of final fields by deep reflection. As of Java 26 (ETA Mar 2026), warnings will be emitted, and in future versions, these mutations will be disallowed by default. We should avoid using these methods going forward.
Additional Notes
References:
Contributor Checklist
type:and (comp:orinst:) labels in addition to any useful labelsclose,fixor any linking keywords when referencing an issue.Use
solvesinstead, and assign the PR milestone to the issueJira ticket: https://datadoghq.atlassian.net/browse/APMLP-594