-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Yunsafe opens packages in jrt under --release
If no package names are provided, sun.misc is assumed, for the paradigmatic use case sun.misc.Unsafe.
- Loading branch information
Showing
8 changed files
with
96 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
unsafe.scala:9: error: value threadId is not a member of Thread | ||
def f(t: Thread) = t.threadId | ||
^ | ||
1 error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
// scalac: --release:8 -Yunsafe:java.lang | ||
// javaVersion: 19+ | ||
|
||
// -Yunsafe opens packages but does not override class definitions | ||
// because ct.sym comes first | ||
|
||
class C { | ||
def f(t: Thread) = t.threadId | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
// scalac: --release:8 -Yunsafe | ||
|
||
import sun.misc.Unsafe | ||
|
||
class C { | ||
val f = classOf[Unsafe].getDeclaredField("theUnsafe") | ||
f.setAccessible(true) | ||
val unsafe = f.get(null).asInstanceOf[Unsafe] | ||
|
||
val k = unsafe.allocateInstance(classOf[K]).asInstanceOf[K] | ||
assert(k.value == 0) | ||
} | ||
|
||
class K { | ||
val value = 42 | ||
} | ||
|
||
object Test extends App { | ||
new C | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters