Skip to content

Instantly share code, notes, and snippets.

@retronym
Created March 14, 2017 04:01
Show Gist options
  • Save retronym/5be15bec7832e1aa37e5805ad0ee9596 to your computer and use it in GitHub Desktop.
Save retronym/5be15bec7832e1aa37e5805ad0ee9596 to your computer and use it in GitHub Desktop.
⚡ scala -classpath /Users/jz/.ivy2/cache/com.google.guava/guava/bundles/guava-21.0.jar
Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_112).
Type in expressions for evaluation. Or try :help.
scala> :power
Power mode enabled. :phase is at typer.
import scala.tools.nsc._, intp.global._, definitions._
Try :help or completions for vals._ and power._
scala> val cl = new java.net.URLClassLoader(global.classPath.asURLs.toArray, null)
cl: java.net.URLClassLoader = java.net.URLClassLoader@6c1c7ebc
scala> typeOf[com.google.common.base.Objects]
res1: $r.intp.global.Type = com.google.common.base.Objects
scala> typeOf[com.google.common.base.Objects].getBinaryName
<console>:37: error: value getBinaryName is not a member of $r.intp.global.Type
typeOf[com.google.common.base.Objects].getBinaryName
^
scala> symbolOf[com.google.common.base.Objects].associatedFile
res3: scala.reflect.io.AbstractFile = /Users/jz/.ivy2/cache/com.google.guava/guava/bundles/guava-21.0.jar(com/google/common/base/Objects.class)
scala> symbolOf[com.google.common.base.Objects].associatedFile.underlyingSource
res5: Option[scala.reflect.io.AbstractFile] = Some(/Users/jz/.ivy2/cache/com.google.guava/guava/bundles/guava-21.0.jar)
scala> symbolOf[com.google.common.base.Objects].javaBinaryName
javaBinaryName javaBinaryNameString
scala> symbolOf[com.google.common.base.Objects].javaBinaryNameString
res6: String = com/google/common/base/Objects
scala> cl.loadClass(res6.replace('/', '.'))
res8: Class[_] = class com.google.common.base.Objects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment