-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8021 from dotty-staging/fix-#8020
Fix #8020: Create dotty-tasty-inspector library
- Loading branch information
Showing
38 changed files
with
250 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 0 additions & 55 deletions
55
compiler/src/dotty/tools/dotc/consumetasty/ConsumeTasty.scala
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
compiler/src/dotty/tools/dotc/consumetasty/TastyConsumerPhase.scala
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
compiler/src/dotty/tools/dotc/consumetasty/TastyFromClass.scala
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
compiler/src/dotty/tools/dotc/util/ClasspathFromClassloader.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package dotty.tools.dotc.util | ||
|
||
import java.net.URLClassLoader | ||
import java.nio.file.Paths | ||
|
||
import dotty.tools.repl.AbstractFileClassLoader | ||
|
||
object ClasspathFromClassloader { | ||
|
||
/** Attempt to recreate a classpath from a classloader. | ||
* | ||
* BEWARE: with exotic enough classloaders, this may not work at all or do | ||
* the wrong thing. | ||
*/ | ||
def apply(cl: ClassLoader): String = { | ||
val classpathBuff = List.newBuilder[String] | ||
def collectClassLoaderPaths(cl: ClassLoader): Unit = { | ||
if (cl != null) { | ||
cl match { | ||
case cl: URLClassLoader => | ||
// This is wrong if we're in a subclass of URLClassLoader | ||
// that filters loading classes from its parent ¯\_(ツ)_/¯ | ||
collectClassLoaderPaths(cl.getParent) | ||
// Parent classloaders are searched before their child, so the part of | ||
// the classpath coming from the child is added at the _end_ of the | ||
// classpath. | ||
classpathBuff ++= | ||
cl.getURLs.iterator.map(url => Paths.get(url.toURI).toAbsolutePath.toString) | ||
case _ => | ||
// HACK: We can't just collect the classpath from arbitrary parent | ||
// classloaders since the current classloader might intentionally | ||
// filter loading classes from its parent (for example | ||
// BootFilteredLoader in the sbt launcher does this and we really | ||
// don't want to include the scala-library that sbt depends on | ||
// here), but we do need to look at the parent of the REPL | ||
// classloader, so we special case it. We can't do this using a type | ||
// test since the REPL classloader class itself is normally loaded | ||
// with a different classloader. | ||
if (cl.getClass.getName == classOf[AbstractFileClassLoader].getName) | ||
collectClassLoaderPaths(cl.getParent) | ||
} | ||
} | ||
} | ||
collectClassLoaderPaths(cl) | ||
classpathBuff.result().mkString(java.io.File.pathSeparator) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.