Skip to content

Instantly share code, notes, and snippets.

@UnconventionalMindset
Created February 2, 2022 02:05
Show Gist options
  • Save UnconventionalMindset/da249f200ddb5d38c13a63ed3d3acb1b to your computer and use it in GitHub Desktop.
Save UnconventionalMindset/da249f200ddb5d38c13a63ed3d3acb1b to your computer and use it in GitHub Desktop.
Get Private field in Scala for debugging purposes
def privateField[A](obj: AnyRef, fieldName: String): A = {
val f = obj.getClass.getDeclaredField(fieldName)
f.setAccessible(true)
f.get(obj).asInstanceOf[A]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment