Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Last active June 26, 2019 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xuwei-k/0755ff03cb8f4b363918bd1d428de439 to your computer and use it in GitHub Desktop.
Save xuwei-k/0755ff03cb8f4b363918bd1d428de439 to your computer and use it in GitHub Desktop.
sbt.version=0.13.18
scalaVersion := "2.12.8"
addSbtPlugin("pl.project13.sbt" % "sbt-jol" % "0.1.3")
> ;jol:internals foo.B2 ; jol:internals foo.B1
[info] Resolving net.sf.jopt-simple#jopt-simple;4.6 ...
[info] # WARNING: Unable to attach Serviceability Agent. You can try again with escalated privileges. Two options: a) use -Djol.tryWithSudo=true to try with sudo; b) echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
[info] # Running 64-bit HotSpot VM.
[info] # Using compressed oop with 3-bit shift.
[info] # Using compressed klass with 3-bit shift.
[info] # WARNING | Compressed references base/shifts are guessed by the experiment!
[info] # WARNING | Therefore, computed addresses are just guesses, and ARE NOT RELIABLE.
[info] # WARNING | Make sure to attach Serviceability Agent to get the reliable addresses.
[info] # Objects are 8 bytes aligned.
[info] # Field sizes by type: 4, 1, 1, 2, 2, 4, 4, 8, 8 [bytes]
[info] # Array element sizes: 4, 1, 1, 2, 2, 4, 4, 8, 8 [bytes]
[info]
[info] VM fails to invoke the default constructor, falling back to class-only introspection.
[info]
[info] foo.B2 object internals:
[info] OFFSET SIZE TYPE DESCRIPTION VALUE
[info] 0 12 (object header) N/A
[info] 12 4 String A2.x N/A
[info] Instance size: 16 bytes
[info] Space losses: 0 bytes internal + 0 bytes external = 0 bytes total
[success] Total time: 1 s, completed 2019/06/26 16:23:42
[info] Resolving net.sf.jopt-simple#jopt-simple;4.6 ...
[info] # WARNING: Unable to attach Serviceability Agent. You can try again with escalated privileges. Two options: a) use -Djol.tryWithSudo=true to try with sudo; b) echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
[info] # Running 64-bit HotSpot VM.
[info] # Using compressed oop with 3-bit shift.
[info] # Using compressed klass with 3-bit shift.
[info] # WARNING | Compressed references base/shifts are guessed by the experiment!
[info] # WARNING | Therefore, computed addresses are just guesses, and ARE NOT RELIABLE.
[info] # WARNING | Make sure to attach Serviceability Agent to get the reliable addresses.
[info] # Objects are 8 bytes aligned.
[info] # Field sizes by type: 4, 1, 1, 2, 2, 4, 4, 8, 8 [bytes]
[info] # Array element sizes: 4, 1, 1, 2, 2, 4, 4, 8, 8 [bytes]
[info]
[info] VM fails to invoke the default constructor, falling back to class-only introspection.
[info]
[info] foo.B1 object internals:
[info] OFFSET SIZE TYPE DESCRIPTION VALUE
[info] 0 12 (object header) N/A
[info] 12 4 String A1.x N/A
[info] 16 4 String B1.x N/A
[info] 20 4 (loss due to the next object alignment)
[info] Instance size: 24 bytes
[info] Space losses: 0 bytes internal + 4 bytes external = 4 bytes total
[success] Total time: 1 s, completed 2019/06/26 16:23:42
package foo
abstract class A1(x: String) {
def y = x
}
final class B1(x: String) extends A1(x) {
def z = x
}
abstract class A2(protected val x: String) {
def y = x
}
final class B2(x: String) extends A2(x) {
def z = x
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment