File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed
library/src/scala/runtime Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -9,19 +9,15 @@ import scala.annotation.*
99 */
1010object LazyVals {
1111 @ 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+ }
2521
2622 private [this ] val base : Int = {
2723 val processors = java.lang.Runtime .getRuntime.nn.availableProcessors()
You can’t perform that action at this time.
0 commit comments