Skip to content

Instantly share code, notes, and snippets.

@retronym
Last active June 4, 2017 03:44
Show Gist options
  • Save retronym/5eba5edabca36fc0b917b5f0095ce990 to your computer and use it in GitHub Desktop.
Save retronym/5eba5edabca36fc0b917b5f0095ce990 to your computer and use it in GitHub Desktop.
SBT launcher notes

SBT Launcher

Status Quo

sbt/launcher is a small Scala application that bootstraps an arbitrary Scala program (typically, SBT) described a config file and sourced via Ivy dependency resolution.

This creates a child classloader containing Scala 2.10.6. A child of this contains SBT itself and xsbti/interface-0.13.11.jar.

SBT needs to use non-standard classloader delegation to selectively hide classes when creating child classloaders for plugin code, for the Scala compiler, or for user code.

Inspecting the classloader family tree

  def showClassLoader(cl: ClassLoader, level: Int = 0): Unit = {
    def p(s: Any) = println(("  " * level) + s)
    p(cl.getClass)
    cl match {
      case u: java.net.URLClassLoader => u.getURLs.foreach(u => p(u.toString))
      case _ =>
        if (cl.getClass.getName == "sbt.classpath.DualLoader") {
          def get(name: String): ClassLoader = {
            val fld = cl.getClass.getDeclaredField(name)
            fld.setAccessible(true)
            fld.get(cl).asInstanceOf[ClassLoader]
          }
          showClassLoader(get("parentA"), level + 1)
          showClassLoader(get("parentB"), level + 1)
        }
    };
    Option(cl.getParent).filter(_ != cl).foreach(p => showClassLoader(p, level + 1))
  }

run

class sbt.classpath.ClasspathUtilities$$anon$1
file:/Users/jz/code/scratch2/target/scala-2.11/classes/
file:/Users/jz/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.7.jar
file:/Users/jz/.ivy2/cache/com.lihaoyi/fastparse_2.11/jars/fastparse_2.11-0.2.1.jar
file:/Users/jz/.ivy2/cache/com.lihaoyi/fastparse-utils_2.11/jars/fastparse-utils_2.11-0.2.1.jar
file:/Users/jz/.ivy2/cache/com.lihaoyi/pprint_2.11/jars/pprint_2.11-0.3.6.jar
file:/Users/jz/.ivy2/cache/com.lihaoyi/derive_2.11/jars/derive_2.11-0.3.6.jar
  class java.net.URLClassLoader
  file:/Users/jz/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.7.jar
  file:/Users/jz/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar
  file:/Users/jz/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.11.7.jar
  file:/Users/jz/.ivy2/cache/org.scala-lang.modules/scala-xml_2.11/bundles/scala-xml_2.11-1.0.4.jar
  file:/Users/jz/.ivy2/cache/org.scala-lang.modules/scala-parser-combinators_2.11/bundles/scala-parser-combinators_2.11-1.0.4.jar
  file:/Users/jz/.ivy2/cache/jline/jline/jars/jline-2.12.1.jar
    class xsbt.boot.BootFilteredLoader
      class sun.misc.Launcher$AppClassLoader
      file:/usr/local/Cellar/sbt/0.13.13/libexec/sbt-launch.jar
        class sun.misc.Launcher$ExtClassLoader
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/cldrdata.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/dnsns.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/jaccess.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/jfxrt.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/localedata.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/nashorn.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunec.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/zipfs.jar
        file:/System/Library/Java/Extensions/AppleScriptEngine.jar
        file:/System/Library/Java/Extensions/dns_sd.jar
        file:/System/Library/Java/Extensions/j3daudio.jar
        file:/System/Library/Java/Extensions/j3dcore.jar
        file:/System/Library/Java/Extensions/j3dutils.jar
        file:/System/Library/Java/Extensions/jai_codec.jar
        file:/System/Library/Java/Extensions/jai_core.jar
        file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib
        file:/System/Library/Java/Extensions/libJ3D.jnilib
        file:/System/Library/Java/Extensions/libJ3DAudio.jnilib
        file:/System/Library/Java/Extensions/libJ3DUtils.jnilib
        file:/System/Library/Java/Extensions/libmlib_jai.jnilib
        file:/System/Library/Java/Extensions/mlibwrapper_jai.jar
        file:/System/Library/Java/Extensions/MRJToolkit.jar
        file:/System/Library/Java/Extensions/vecmath.jar
        file:/usr/lib/java/libjdns_sd.jnilib

compile

class java.net.URLClassLoader
file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/org.scala-sbt-compiler-interface-0.13.13-bin_2.12.2-20170309-225501-c90d728__52.0/org.scala-sbt-compiler-interface-0.13.13-bin_2.12.2-20170309-225501-c90d728__52.0.jar
  class sbt.classpath.DualLoader
    class java.net.URLClassLoader
    file:/Users/jz/.ivy2/local/org.scala-lang/scala-library/2.12.2-c90d728-SNAPSHOT/jars/scala-library.jar
    file:/Users/jz/.ivy2/local/org.scala-lang/scala-compiler/2.12.2-c90d728-SNAPSHOT/jars/scala-compiler.jar
    file:/Users/jz/.ivy2/local/org.scala-lang/scala-reflect/2.12.2-c90d728-SNAPSHOT/jars/scala-reflect.jar
    file:/Users/jz/.ivy2/cache/org.scala-lang.modules/scala-xml_2.12/bundles/scala-xml_2.12-1.0.6.jar
    file:/Users/jz/.ivy2/cache/jline/jline/jars/jline-2.14.3.jar
      class xsbt.boot.BootFilteredLoader
        class sun.misc.Launcher$AppClassLoader
        file:/usr/local/Cellar/sbt/0.13.13/libexec/sbt-launch.jar
          class sun.misc.Launcher$ExtClassLoader
          file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/cldrdata.jar
          file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/dnsns.jar
          file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/jaccess.jar
          file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/jfxrt.jar
          file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/localedata.jar
          file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/nashorn.jar
          file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunec.jar
          file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar
          file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar
          file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/zipfs.jar
          file:/System/Library/Java/Extensions/AppleScriptEngine.jar
          file:/System/Library/Java/Extensions/dns_sd.jar
          file:/System/Library/Java/Extensions/j3daudio.jar
          file:/System/Library/Java/Extensions/j3dcore.jar
          file:/System/Library/Java/Extensions/j3dutils.jar
          file:/System/Library/Java/Extensions/jai_codec.jar
          file:/System/Library/Java/Extensions/jai_core.jar
          file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib
          file:/System/Library/Java/Extensions/libJ3D.jnilib
          file:/System/Library/Java/Extensions/libJ3DAudio.jnilib
          file:/System/Library/Java/Extensions/libJ3DUtils.jnilib
          file:/System/Library/Java/Extensions/libmlib_jai.jnilib
          file:/System/Library/Java/Extensions/mlibwrapper_jai.jar
          file:/System/Library/Java/Extensions/MRJToolkit.jar
          file:/System/Library/Java/Extensions/vecmath.jar
          file:/usr/lib/java/libjdns_sd.jnilib
    class java.net.URLClassLoader
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/actions-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/api-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/apply-macro-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/cache-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/classfile-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/classpath-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/collections-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/command-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/compile-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/compiler-integration-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/compiler-interface-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/compiler-ivy-integration-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/completion-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/control-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/cross-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/incremental-compiler-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/io-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/ivy-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/ivy-2.3.0-sbt-2cf13e211b2cb31f0d3b317289dca70eca3362f6.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/jansi-1.11.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/jawn-parser_2.10-0.6.0.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/jline-2.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/jsch-0.1.50.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/json4s-ast_2.10-3.2.10.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/json4s-core_2.10-3.2.10.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/json4s-support_2.10-0.6.0.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/launcher-interface-1.0.0-M1.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/logging-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/logic-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/main-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/main-settings-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/paranamer-2.6.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/persist-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/process-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/quasiquotes_2.10-2.0.1.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/relation-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/run-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/sbinary_2.10-0.4.2.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/sbt-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/scala-pickling_2.10-0.10.1.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/scala-reflect-2.10.6.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/serialization_2.10-0.1.2.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/task-system-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/tasks-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/template-resolver-0.1.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/test-agent-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/test-interface-1.0.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/testing-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/tracking-0.13.13.jar
    file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/xsbti/interface-0.13.13.jar
      class java.net.URLClassLoader
      file:/Users/jz/.sbt/boot/scala-2.10.6/lib/guava-21.0.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/lib/jansi.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/lib/jline.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/lib/scala-compiler.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/lib/scala-library.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/lib/scala-reflect.jar
        class xsbt.boot.BootFilteredLoader
          class sun.misc.Launcher$AppClassLoader
          file:/usr/local/Cellar/sbt/0.13.13/libexec/sbt-launch.jar
            class sun.misc.Launcher$ExtClassLoader
            file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/cldrdata.jar
            file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/dnsns.jar
            file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/jaccess.jar
            file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/jfxrt.jar
            file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/localedata.jar
            file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/nashorn.jar
            file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunec.jar
            file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar
            file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar
            file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/zipfs.jar
            file:/System/Library/Java/Extensions/AppleScriptEngine.jar
            file:/System/Library/Java/Extensions/dns_sd.jar
            file:/System/Library/Java/Extensions/j3daudio.jar
            file:/System/Library/Java/Extensions/j3dcore.jar
            file:/System/Library/Java/Extensions/j3dutils.jar
            file:/System/Library/Java/Extensions/jai_codec.jar
            file:/System/Library/Java/Extensions/jai_core.jar
            file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib
            file:/System/Library/Java/Extensions/libJ3D.jnilib
            file:/System/Library/Java/Extensions/libJ3DAudio.jnilib
            file:/System/Library/Java/Extensions/libJ3DUtils.jnilib
            file:/System/Library/Java/Extensions/libmlib_jai.jnilib
            file:/System/Library/Java/Extensions/mlibwrapper_jai.jar
            file:/System/Library/Java/Extensions/MRJToolkit.jar
            file:/System/Library/Java/Extensions/vecmath.jar
            file:/usr/lib/java/libjdns_sd.jnilib
    class sbt.classpath.NullLoader
      class sun.misc.Launcher$AppClassLoader
      file:/usr/local/Cellar/sbt/0.13.13/libexec/sbt-launch.jar
        class sun.misc.Launcher$ExtClassLoader
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/cldrdata.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/dnsns.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/jaccess.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/jfxrt.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/localedata.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/nashorn.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunec.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar
        file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/zipfs.jar
        file:/System/Library/Java/Extensions/AppleScriptEngine.jar
        file:/System/Library/Java/Extensions/dns_sd.jar
        file:/System/Library/Java/Extensions/j3daudio.jar
        file:/System/Library/Java/Extensions/j3dcore.jar
        file:/System/Library/Java/Extensions/j3dutils.jar
        file:/System/Library/Java/Extensions/jai_codec.jar
        file:/System/Library/Java/Extensions/jai_core.jar
        file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib
        file:/System/Library/Java/Extensions/libJ3D.jnilib
        file:/System/Library/Java/Extensions/libJ3DAudio.jnilib
        file:/System/Library/Java/Extensions/libJ3DUtils.jnilib
        file:/System/Library/Java/Extensions/libmlib_jai.jnilib
        file:/System/Library/Java/Extensions/mlibwrapper_jai.jar
        file:/System/Library/Java/Extensions/MRJToolkit.jar
        file:/System/Library/Java/Extensions/vecmath.jar
        file:/usr/lib/java/libjdns_sd.jnilib

console

        class sbt.PluginManagement$PluginClassLoader
        file:/Users/jz/.sbt/0.13/plugins/target/scala-2.10/sbt-0.13/classes/
        file:/Users/jz/.ivy2/cache/scala_2.10/sbt_0.13/pl.project13.scala/sbt-jmh/jars/sbt-jmh-0.2.16.jar
        file:/Users/jz/.ivy2/cache/pl.project13.scala/sbt-jmh-extras/jars/sbt-jmh-extras-0.2.16.jar
        file:/Users/jz/.ivy2/cache/org.openjdk.jmh/jmh-core/jars/jmh-core-1.14.1.jar
        file:/Users/jz/.ivy2/cache/net.sf.jopt-simple/jopt-simple/jars/jopt-simple-4.6.jar
        file:/Users/jz/.ivy2/cache/org.apache.commons/commons-math3/jars/commons-math3-3.2.jar
        file:/Users/jz/.ivy2/cache/org.openjdk.jmh/jmh-generator-bytecode/jars/jmh-generator-bytecode-1.14.1.jar
        file:/Users/jz/.ivy2/cache/org.openjdk.jmh/jmh-generator-reflection/jars/jmh-generator-reflection-1.14.1.jar
        file:/Users/jz/.ivy2/cache/org.openjdk.jmh/jmh-generator-asm/jars/jmh-generator-asm-1.14.1.jar
        file:/Users/jz/.ivy2/cache/org.ow2.asm/asm/jars/asm-5.0.3.jar
          class java.net.URLClassLoader
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/actions-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/api-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/apply-macro-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/cache-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/classfile-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/classpath-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/collections-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/command-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/compile-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/compiler-integration-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/compiler-interface-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/compiler-ivy-integration-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/completion-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/control-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/cross-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/incremental-compiler-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/io-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/ivy-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/ivy-2.3.0-sbt-2cc8d2761242b072cedb0a04cb39435c4fa24f9a.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/jansi-1.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/jawn-parser_2.10-0.6.0.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/jline-2.13.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/jsch-0.1.46.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/json4s-ast_2.10-3.2.10.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/json4s-core_2.10-3.2.10.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/json4s-support_2.10-0.6.0.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/launcher-interface-1.0.0-M1.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/logging-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/logic-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/main-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/main-settings-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/paranamer-2.6.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/persist-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/process-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/quasiquotes_2.10-2.0.1.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/relation-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/run-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/sbinary_2.10-0.4.2.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/sbt-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/scala-pickling_2.10-0.10.1.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/scala-reflect-2.10.6.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/serialization_2.10-0.1.2.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/task-system-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/tasks-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/test-agent-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/test-interface-1.0.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/testing-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/tracking-0.13.11.jar
          file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/xsbti/interface-0.13.11.jar
            class java.net.URLClassLoader
            file:/Users/jz/.sbt/boot/scala-2.10.6/lib/guava-21.0.jar
            file:/Users/jz/.sbt/boot/scala-2.10.6/lib/jansi.jar
            file:/Users/jz/.sbt/boot/scala-2.10.6/lib/jline.jar
            file:/Users/jz/.sbt/boot/scala-2.10.6/lib/scala-compiler.jar
            file:/Users/jz/.sbt/boot/scala-2.10.6/lib/scala-library.jar
            file:/Users/jz/.sbt/boot/scala-2.10.6/lib/scala-reflect.jar
              class xsbt.boot.BootFilteredLoader
                class sun.misc.Launcher$AppClassLoader
                file:/usr/local/Cellar/sbt/0.13.13/libexec/sbt-launch.jar
                  class sun.misc.Launcher$ExtClassLoader
                  file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/cldrdata.jar
                  file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/dnsns.jar
                  file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/jaccess.jar
                  file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/jfxrt.jar
                  file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/localedata.jar
                  file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/nashorn.jar
                  file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunec.jar
                  file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar
                  file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar
                  file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/zipfs.jar
                  file:/System/Library/Java/Extensions/AppleScriptEngine.jar
                  file:/System/Library/Java/Extensions/dns_sd.jar
                  file:/System/Library/Java/Extensions/j3daudio.jar
                  file:/System/Library/Java/Extensions/j3dcore.jar
                  file:/System/Library/Java/Extensions/j3dutils.jar
                  file:/System/Library/Java/Extensions/jai_codec.jar
                  file:/System/Library/Java/Extensions/jai_core.jar
                  file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib
                  file:/System/Library/Java/Extensions/libJ3D.jnilib
                  file:/System/Library/Java/Extensions/libJ3DAudio.jnilib
                  file:/System/Library/Java/Extensions/libJ3DUtils.jnilib
                  file:/System/Library/Java/Extensions/libmlib_jai.jnilib
                  file:/System/Library/Java/Extensions/mlibwrapper_jai.jar
                  file:/System/Library/Java/Extensions/MRJToolkit.jar
                  file:/System/Library/Java/Extensions/vecmath.jar
                  file:/usr/lib/java/libjdns_sd.jnilib

Execution of code in build.sbt

class scala.tools.nsc.interpreter.AbstractFileClassLoader
  class java.net.URLClassLoader
  file:/Users/jz/code/scratch2/project/target/scala-2.10/sbt-0.13/classes/
    class sbt.PluginManagement$PluginClassLoader
    file:/Users/jz/.sbt/0.13/plugins/target/scala-2.10/sbt-0.13/classes/
      class java.net.URLClassLoader
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/actions-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/api-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/apply-macro-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/cache-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/classfile-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/classpath-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/collections-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/command-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/compile-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/compiler-integration-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/compiler-interface-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/compiler-ivy-integration-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/completion-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/control-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/cross-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/incremental-compiler-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/io-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/ivy-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/ivy-2.3.0-sbt-2cf13e211b2cb31f0d3b317289dca70eca3362f6.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/jansi-1.11.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/jawn-parser_2.10-0.6.0.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/jline-2.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/jsch-0.1.50.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/json4s-ast_2.10-3.2.10.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/json4s-core_2.10-3.2.10.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/json4s-support_2.10-0.6.0.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/launcher-interface-1.0.0-M1.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/logging-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/logic-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/main-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/main-settings-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/paranamer-2.6.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/persist-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/process-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/quasiquotes_2.10-2.0.1.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/relation-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/run-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/sbinary_2.10-0.4.2.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/sbt-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/scala-pickling_2.10-0.10.1.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/scala-reflect-2.10.6.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/serialization_2.10-0.1.2.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/task-system-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/tasks-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/template-resolver-0.1.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/test-agent-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/test-interface-1.0.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/testing-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/tracking-0.13.13.jar
      file:/Users/jz/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.13/xsbti/interface-0.13.13.jar
        class java.net.URLClassLoader
        file:/Users/jz/.sbt/boot/scala-2.10.6/lib/guava-21.0.jar
        file:/Users/jz/.sbt/boot/scala-2.10.6/lib/jansi.jar
        file:/Users/jz/.sbt/boot/scala-2.10.6/lib/jline.jar
        file:/Users/jz/.sbt/boot/scala-2.10.6/lib/scala-compiler.jar
        file:/Users/jz/.sbt/boot/scala-2.10.6/lib/scala-library.jar
        file:/Users/jz/.sbt/boot/scala-2.10.6/lib/scala-reflect.jar
          class xsbt.boot.BootFilteredLoader
            class sun.misc.Launcher$AppClassLoader
            file:/usr/local/Cellar/sbt/0.13.13/libexec/sbt-launch.jar
              class sun.misc.Launcher$ExtClassLoader
              file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/cldrdata.jar
              file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/dnsns.jar
              file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/jaccess.jar
              file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/jfxrt.jar
              file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/localedata.jar
              file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/nashorn.jar
              file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunec.jar
              file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar
              file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar
              file:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext/zipfs.jar
              file:/System/Library/Java/Extensions/AppleScriptEngine.jar
              file:/System/Library/Java/Extensions/dns_sd.jar
              file:/System/Library/Java/Extensions/j3daudio.jar
              file:/System/Library/Java/Extensions/j3dcore.jar
              file:/System/Library/Java/Extensions/j3dutils.jar
              file:/System/Library/Java/Extensions/jai_codec.jar
              file:/System/Library/Java/Extensions/jai_core.jar
              file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib
              file:/System/Library/Java/Extensions/libJ3D.jnilib
              file:/System/Library/Java/Extensions/libJ3DAudio.jnilib
              file:/System/Library/Java/Extensions/libJ3DUtils.jnilib
              file:/System/Library/Java/Extensions/libmlib_jai.jnilib
              file:/System/Library/Java/Extensions/mlibwrapper_jai.jar
              file:/System/Library/Java/Extensions/MRJToolkit.jar
              file:/System/Library/Java/Extensions/vecmath.jar
              file:/usr/lib/java/libjdns_sd.jnilib

Discussion

Can we rethink the setup to allow simpler classloader structures?

e.g.

  • Rather than the launcher spawning SBT in a child process, could it spawn a new JVM and exit the current one? This might make the "reboot" use case hard or impossible to support, but is this actually needed?
  • Could the launcher itself could be rewritten as a pure Java application?
  • ... or, could it run its Scala and Ivy parts in a child classloader, to avoid having needing to hide them from view of the application is spawns (see BootFilteredLoader)
  • Can we structure the classloaders hierarchy to avoid the need for BootFilteredClassloader / DualClassloader?

Strawman Classloader Proposal

I believe this structure would avoid most (or all) need for non-standard parent delegation.


= JVM App classloader
sbt-launch.jar
  = LAUNCHER_IMPL
  ivy.jar
  launcher-impl.jar
  scala-lib-proguarded.jar
  = LAUNCHED
  sbt-kernel.jar
  jline.jar
    = XSBTI
    xsbti/interface-0.13.13.jar
      = SBT
      scala-*-2.10.6.jar
      sbt-*.jar
        = PLUGINS
        shared-plugin-dep.jar.jar
          = PLUGIN_<N>
          isolated-plugin-dep.jar
          plugin-1.jar
        = BUILD
        project/target/classes
        ...
      = SCALAC-<project-version>
      compiler-interface.jar
      scala-*-project-version.jar
  = USER_<N>
    guava.jar
    subproject<N>/target/classes


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment