Skip to content

Commit

Permalink
Fix mixed incremental compilation to JAR
Browse files Browse the repository at this point in the history
  • Loading branch information
adpi2 committed Jul 8, 2024
1 parent 54e9fba commit 1ed6a46
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ object JarUtils {
*/
def fromURL(url: URL, jar: Path): ClassInJar = {
val path = url.getPath
if (!path.contains("!")) sys.error(s"unexpected URL $url that does not include '!'")
if (!path.contains("!/")) sys.error(s"unexpected URL $url that does not include '!/'")
else {
val Array(_, cls) = url.getPath.split("!")
val Array(_, cls) = url.getPath.split("!/")
apply(jar, cls)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,8 @@ private final class AnalysisCallback(
private[this] val localClasses = new TrieMap[VirtualFileRef, ConcurrentSet[VirtualFileRef]]
// mapping between src class name and binary (flat) class name for classes generated from src file
private[this] val classNames = new TrieMap[VirtualFileRef, ConcurrentSet[(String, String)]]
// generated class file to its source class name
private[this] val classToSource = new TrieMap[VirtualFileRef, String]
// generated class name to its source class name
private[this] val binaryNameToSourceName = new TrieMap[String, String]
// internal source dependencies
private[this] val intSrcDeps = new TrieMap[String, ConcurrentSet[InternalDependency]]
// external source dependencies
Expand Down Expand Up @@ -779,8 +779,7 @@ private final class AnalysisCallback(
// dependency is a product of a source not included in this compilation
classDependency(dependsOn, fromClassName, context)
case None =>
val vf = converter.toVirtualFile(classFile)
classToSource.get(vf) match {
binaryNameToSourceName.get(onBinaryClassName) match {
case Some(dependsOn) =>
// dependency is a product of a source in this compilation step,
// but not in the same compiler run (as in javac v. scalac)
Expand Down Expand Up @@ -842,7 +841,7 @@ private final class AnalysisCallback(
val vf = converter.toVirtualFile(classFile)
add(nonLocalClasses, source, (vf, binaryClassName))
add(classNames, source, (srcClassName, binaryClassName))
classToSource.put(vf, srcClassName)
binaryNameToSourceName.put(binaryClassName, srcClassName)
()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ final class MixedAnalyzingCompiler(

def toVirtualFile(p: Path) = config.converter.toVirtualFile(p.toAbsolutePath)

JarUtils.getOutputJar(output) match {
val outputJarOpt = JarUtils.getOutputJar(output)
outputJarOpt match {
case Some(outputJar) if !javac.supportsDirectToJar =>
val outputDir = JarUtils.javacTempOutput(outputJar)
Files.createDirectories(outputDir)
Expand All @@ -80,7 +81,7 @@ final class MixedAnalyzingCompiler(
config.converter,
joptions,
CompileOutput(outputDir),
Some(outputJar),
outputJarOpt,
callback,
incToolOptions,
config.reporter,
Expand All @@ -96,7 +97,7 @@ final class MixedAnalyzingCompiler(
config.converter,
joptions,
output,
None,
outputJarOpt,
callback,
incToolOptions,
config.reporter,
Expand Down

0 comments on commit 1ed6a46

Please # to comment.