Skip to content

Commit

Permalink
Merge pull request #1376 from adpi2/2.x-fix-mixed-compilation-to-jar
Browse files Browse the repository at this point in the history
[2.x] Fix mixed compilation to JAR
  • Loading branch information
adpi2 authored Jul 10, 2024
2 parents 405967a + 71e9cf3 commit 5fd2231
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ThisBuild / version := {
nightlyVersion match {
case Some(v) => v
case _ =>
if ((ThisBuild / isSnapshot).value) "2.0.0-alpha12-SNAPSHOT"
if ((ThisBuild / isSnapshot).value) "2.0.0-alpha15-SNAPSHOT"
else old
}
}
Expand Down
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 5fd2231

Please sign in to comment.