Skip to content

Instantly share code, notes, and snippets.

@animeshtrivedi
Forked from ramn/GetUnsafeClass.scala
Created May 9, 2017 16:33
Show Gist options
  • Save animeshtrivedi/f97d9f5c696f102b7fe83b20a3b5644b to your computer and use it in GitHub Desktop.
Save animeshtrivedi/f97d9f5c696f102b7fe83b20a3b5644b to your computer and use it in GitHub Desktop.
sun.misc.Unsafe use in Scala
def getUnsafeInstance: sun.misc.Unsafe = {
val f = classOf[sun.misc.Unsafe].getDeclaredField("theUnsafe")
f.setAccessible(true)
val unsafe = f.get(null).asInstanceOf[sun.misc.Unsafe]
unsafe
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment