File tree 1 file changed +9
-13
lines changed
library/src/scala/runtime
1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -9,19 +9,15 @@ import scala.annotation.*
9
9
*/
10
10
object LazyVals {
11
11
@ nowarn
12
- private [this ] val unsafe : sun.misc.Unsafe =
13
- classOf [sun.misc.Unsafe ].getDeclaredFields.nn.find { field =>
14
- field.nn.getType == classOf [sun.misc.Unsafe ] && {
15
- field.nn.setAccessible(true )
16
- true
17
- }
18
- }
19
- .map(_.nn.get(null ).asInstanceOf [sun.misc.Unsafe ])
20
- .getOrElse {
21
- throw new ExceptionInInitializerError {
22
- new IllegalStateException (" Can't find instance of sun.misc.Unsafe" )
23
- }
24
- }
12
+ private [this ] val unsafe : sun.misc.Unsafe = {
13
+ val unsafeField = classOf [sun.misc.Unsafe ].getDeclaredField(" theUnsafe" ).nn
14
+ if unsafeField.getType == classOf [sun.misc.Unsafe ] then
15
+ unsafeField.setAccessible(true )
16
+ else throw new ExceptionInInitializerError {
17
+ new IllegalStateException (" Can't find instance of sun.misc.Unsafe" )
18
+ }
19
+ unsafeField.get(null ).asInstanceOf [sun.misc.Unsafe ]
20
+ }
25
21
26
22
private [this ] val base : Int = {
27
23
val processors = java.lang.Runtime .getRuntime.nn.availableProcessors()
You can’t perform that action at this time.
0 commit comments