Commit f43221d
fix(extension): serialize ClassDataLoader.findClass per class name
Two threads racing findClass for the same name could both reach
defineClass, which the JVM rejects with LinkageError. Guard the
cache-check + defineClass block with synchronized(getClassLoadingLock(name))
so only one thread per name defines, while a lock-free fast path still
handles the warm-cache case for already-loaded classes.
The synchronized block is chosen over registerAsParallelCapable because
it protects direct findClass callers in addition to the standard
loadClass delegation path, and keeps the invariant locally visible in
findClass itself.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 9d9b6f2 commit f43221d
1 file changed
Lines changed: 26 additions & 13 deletions
Lines changed: 26 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
87 | 93 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
92 | 99 | | |
93 | | - | |
94 | | - | |
95 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
96 | 109 | | |
97 | 110 | | |
98 | 111 | | |
| |||
0 commit comments