Commit c738041
Make InnerClassInfo thread-safe
This change adjusts fields in InnerClassInfo to be volatile, if those
fields can cause concurrency problems. In particular, the following
methods result in issues when ran with Java 25 in a multi-threade
environment:
* getEnclosingTypeName
* getName
* getSourceName
They follow the pattern of checking whether some value is initialized
with a boolean variable, then setting the value if its not initialized
yet. When those methods are invoked from multiple threads on the same
object, there is no guarantee that the initialized value will be read by
all threads. By making both the flag and the value fields are volatile,
threads will read the correct value; the value could still be
initialized multiple times, but we assume that all threads will be
setting the same value.
This change additionally makes some fields final, to make the code
easier to read and analyze.
Fixes: eclipse-jdt#41991 parent fa6f194 commit c738041
File tree
2 files changed
+11
-11
lines changed- org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt
2 files changed
+11
-11
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
Lines changed: 10 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
0 commit comments