Commit 53b604b
authored
Avoid exception when capturing fields in jdk16+ (#7774)
Since jdk16, calling setAccessible(true) on fields that are on another
java module that is not open/exported will result with
InaccessibleObjectException thrown each time. To avoid this exception
we can call `trySetAccessible` that will return true if we can call
setAccessible without exception.
The method `trySetAccessible` is only available since jdk9 so we need
to use MethodHandle on it to be able to call it only when it is
available.
NB: setAccessible for jdk8 will always work anyway.
InaccessibleObjectException provides a useful message for the cause
of this error and we have added back a similar message by getting the
module where resides the field that is not accessible to explain to
the user why the field is not captured what it can do to resolve the
problem.
Fix also the report of evaluation errors for log template for
inaccessible fields inside an object (marked UNDEFINED)1 parent 00856e0 commit 53b604b
File tree
10 files changed
+193
-123
lines changed- dd-java-agent/agent-debugger
- debugger-bootstrap/src
- main/java/datadog/trace/bootstrap/debugger
- el
- test/java/datadog/trace/bootstrap/debugger/el
- src
- main/java/com/datadog/debugger
- agent
- util
- test/java/com/datadog/debugger/agent
10 files changed
+193
-123
lines changedLines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 102 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
| 6 | + | |
| 7 | + | |
4 | 8 | | |
5 | 9 | | |
| 10 | + | |
| 11 | + | |
6 | 12 | | |
7 | 13 | | |
8 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
9 | 60 | | |
10 | 61 | | |
11 | 62 | | |
12 | 63 | | |
13 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
14 | 68 | | |
15 | 69 | | |
16 | 70 | | |
| |||
35 | 89 | | |
36 | 90 | | |
37 | 91 | | |
38 | | - | |
| 92 | + | |
| 93 | + | |
39 | 94 | | |
40 | 95 | | |
41 | | - | |
| 96 | + | |
42 | 97 | | |
43 | 98 | | |
44 | 99 | | |
| |||
153 | 208 | | |
154 | 209 | | |
155 | 210 | | |
156 | | - | |
| 211 | + | |
157 | 212 | | |
158 | 213 | | |
159 | 214 | | |
| |||
163 | 218 | | |
164 | 219 | | |
165 | 220 | | |
166 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
167 | 232 | | |
168 | 233 | | |
169 | 234 | | |
170 | 235 | | |
171 | 236 | | |
172 | | - | |
173 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
174 | 243 | | |
175 | 244 | | |
176 | 245 | | |
177 | 246 | | |
178 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
179 | 274 | | |
180 | 275 | | |
Lines changed: 40 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
| 10 | + | |
| 11 | + | |
6 | 12 | | |
7 | 13 | | |
8 | 14 | | |
9 | 15 | | |
10 | | - | |
11 | | - | |
| 16 | + | |
| 17 | + | |
12 | 18 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
17 | 50 | | |
18 | 51 | | |
19 | 52 | | |
| |||
25 | 58 | | |
26 | 59 | | |
27 | 60 | | |
| 61 | + | |
28 | 62 | | |
29 | 63 | | |
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
449 | 454 | | |
450 | 455 | | |
451 | 456 | | |
452 | 457 | | |
453 | 458 | | |
454 | 459 | | |
455 | 460 | | |
456 | | - | |
| 461 | + | |
457 | 462 | | |
458 | 463 | | |
459 | 464 | | |
| |||
Lines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| 106 | + | |
| 107 | + | |
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
| |||
111 | 114 | | |
112 | 115 | | |
113 | 116 | | |
| 117 | + | |
114 | 118 | | |
115 | 119 | | |
116 | 120 | | |
| |||
298 | 302 | | |
299 | 303 | | |
300 | 304 | | |
301 | | - | |
302 | | - | |
303 | | - | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
304 | 313 | | |
305 | 314 | | |
306 | 315 | | |
| |||
0 commit comments