Skip to content

Instantly share code, notes, and snippets.

@kaja47
Created February 6, 2013 12:41
Show Gist options
  • Select an option

  • Save kaja47/4722309 to your computer and use it in GitHub Desktop.

Select an option

Save kaja47/4722309 to your computer and use it in GitHub Desktop.
class A { val l: Long = 47 }
class B { val a: Int = 0; val b: Int = 0; def aa = a; def bb = b }
val a = new A
val b = new B
unsafe.putInt(a, 8, unsafe.getInt(b, 8))
val a_b = a.asInstanceOf[B]
a_b.getClass // B
a_b.aa // 47
a_b.bb // 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment