Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Fix mixed compilation to JAR #1376

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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