File tree 1 file changed +13
-7
lines changed
library/src/scala/runtime
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -10,13 +10,19 @@ import scala.annotation.*
10
10
object LazyVals {
11
11
@ nowarn
12
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 ]
13
+ def throwInitializationException () =
14
+ throw new ExceptionInInitializerError (
15
+ new IllegalStateException (" Can't find instance of sun.misc.Unsafe" )
16
+ )
17
+ try
18
+ val unsafeField = classOf [sun.misc.Unsafe ].getDeclaredField(" theUnsafe" ).nn
19
+ if unsafeField.getType == classOf [sun.misc.Unsafe ] then
20
+ unsafeField.setAccessible(true )
21
+ unsafeField.get(null ).asInstanceOf [sun.misc.Unsafe ]
22
+ else
23
+ throwInitializationException()
24
+ catch case _ : NoSuchFieldException =>
25
+ throwInitializationException()
20
26
}
21
27
22
28
private [this ] val base : Int = {
You can’t perform that action at this time.
0 commit comments