Skip to content
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: 0 additions & 2 deletions compiler/src/dotty/tools/MainGenericCompiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import java.io.File
import java.lang.Thread
import scala.annotation.internal.sharable
import dotty.tools.dotc.util.ClasspathFromClassloader
import dotty.tools.runner.ObjectRunner
import dotty.tools.dotc.config.Properties.envOrNone
import dotty.tools.io.Jar
import dotty.tools.runner.ScalaClassLoader
import java.nio.file.Paths
import dotty.tools.dotc.config.CommandLineParser
import dotty.tools.scripting.StringDriver
Expand Down
57 changes: 0 additions & 57 deletions compiler/src/dotty/tools/backend/WorklistAlgorithm.scala

This file was deleted.

51 changes: 18 additions & 33 deletions compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.net.{URI, URL}
import java.nio.file.{FileSystems, Files}

import dotty.tools.dotc.classpath.PackageNameUtils.{packageContains, separatePkgAndClassNames}
import dotty.tools.io.{AbstractFile, PlainFile, ClassPath, ClassRepresentation, EfficientClassPath, JDK9Reflectors}
import dotty.tools.io.{AbstractFile, PlainFile, ClassPath, ClassRepresentation, EfficientClassPath}
import FileUtils.*
import PlainFile.toPlainFile

Expand Down Expand Up @@ -124,34 +124,21 @@ trait JFileDirectoryLookup[FileEntryType <: ClassRepresentation] extends Directo
}

object JrtClassPath {
import java.nio.file.*, java.net.URI
def apply(release: Option[String]): Option[ClassPath] = {
import scala.util.Properties.*
if (!isJavaAtLeast("9")) None
else {
// Longer term we'd like an official API for this in the JDK
// Discussion: http://mail.openjdk.java.net/pipermail/compiler-dev/2018-March/thread.html#11738

val currentMajorVersion: Int = JDK9Reflectors.runtimeVersionMajor(JDK9Reflectors.runtimeVersion()).intValue()
release match {
case Some(v) if v.toInt < currentMajorVersion =>
try {
val ctSym = Paths.get(javaHome).resolve("lib").resolve("ct.sym")
if (Files.notExists(ctSym)) None
else Some(new CtSymClassPath(ctSym, v.toInt))
} catch {
case NonFatal(_) => None
}
case _ =>
try {
val fs = FileSystems.getFileSystem(URI.create("jrt:/"))
Some(new JrtClassPath(fs))
} catch {
case _: ProviderNotFoundException | _: FileSystemNotFoundException => None
}
}
}
}
import java.nio.file.*, java.net.URI, scala.util.Properties
def apply(release: Option[String]): Option[ClassPath] =
// Longer term we'd like an official API for this in the JDK
// Discussion: http://mail.openjdk.java.net/pipermail/compiler-dev/2018-March/thread.html#11738
release match
case Some(v) if v.toInt < Runtime.version().feature() =>
try
val ctSym = Paths.get(Properties.javaHome).resolve("lib").resolve("ct.sym")
if (Files.notExists(ctSym)) None
else Some(new CtSymClassPath(ctSym, v.toInt))
catch case NonFatal(_) => None
case _ =>
try Some(new JrtClassPath(FileSystems.getFileSystem(URI.create("jrt:/"))))
catch case _: ProviderNotFoundException | _: FileSystemNotFoundException => None
end apply
}

/**
Expand Down Expand Up @@ -228,11 +215,9 @@ final class CtSymClassPath(ctSym: java.nio.file.Path, release: Int) extends Clas
// e.g. "java.lang" -> Seq(/876/java/lang, /87/java/lang, /8/java/lang))
private val packageIndex: scala.collection.Map[String, scala.collection.Seq[Path]] = {
val index = collection.mutable.HashMap[String, collection.mutable.ListBuffer[Path]]()
val isJava12OrHigher = scala.util.Properties.isJavaAtLeast("12")
rootsForRelease.foreach(root => Files.walk(root).iterator().asScala.filter(Files.isDirectory(_)).foreach { p =>
val moduleNamePathElementCount = if (isJava12OrHigher) 1 else 0
if (p.getNameCount > root.getNameCount + moduleNamePathElementCount) {
val packageDotted = p.subpath(moduleNamePathElementCount + root.getNameCount, p.getNameCount).toString.replace('/', '.')
if (p.getNameCount > root.getNameCount + 1) {
val packageDotted = p.subpath(1 + root.getNameCount, p.getNameCount).toString.replace('/', '.')
index.getOrElseUpdate(packageDotted, new collection.mutable.ListBuffer) += p
}
})
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dotty.tools.dotc.config.Settings.{Setting, SettingAlias, SettingGroup, Se
import dotty.tools.dotc.config.SourceVersion
import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.rewrites.Rewrites
import dotty.tools.io.{AbstractFile, Directory, JDK9Reflectors, PlainDirectory, NoAbstractFile}
import dotty.tools.io.{AbstractFile, Directory, PlainDirectory, NoAbstractFile}
import Setting.ChoiceWithHelp
import ScalaSettingCategories.*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package config

import Settings.Setting.ChoiceWithHelp
import dotty.tools.backend.jvm.BackendUtils.classfileVersionMap
import dotty.tools.io.{AbstractFile, Directory, JDK9Reflectors, PlainDirectory, NoAbstractFile}
import dotty.tools.io.{AbstractFile, Directory, PlainDirectory, NoAbstractFile}

object ScalaSettingsProperties:

Expand All @@ -16,7 +16,7 @@ object ScalaSettingsProperties:
(minTargetVersion to maxTargetVersion).toList.map(_.toString)

def supportedReleaseVersions: List[String] =
val jdkVersion = JDK9Reflectors.runtimeVersionMajor(JDK9Reflectors.runtimeVersion()).intValue()
val jdkVersion = Runtime.version().feature()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Runtime.Version::major was deprecated in JDK 10 in favor of Runtime.Version::feature.
See https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Runtime.Version.html#major()

val maxVersion = Math.min(jdkVersion, maxTargetVersion)
(minReleaseVersion to maxVersion).toList.map(_.toString)

Expand Down
106 changes: 0 additions & 106 deletions compiler/src/dotty/tools/io/JDK9Reflectors.java

This file was deleted.

5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/io/ZipArchive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.net.URL
import java.io.{ IOException, InputStream, OutputStream, FilterInputStream }
import java.nio.file.Files
import java.util.zip.{ ZipEntry, ZipFile }
import java.util.jar.Manifest
import java.util.jar.{ Manifest, JarFile }
import scala.collection.mutable
import scala.jdk.CollectionConverters.*

Expand Down Expand Up @@ -117,8 +117,7 @@ final class FileZipArchive(jpath: JPath, release: Option[String]) extends ZipArc
private def openZipFile(): ZipFile = try {
release match {
case Some(r) if file.getName.endsWith(".jar") =>
val releaseVersion = JDK9Reflectors.runtimeVersionParse(r)
JDK9Reflectors.newJarFile(file, true, ZipFile.OPEN_READ, releaseVersion)
new JarFile(file, true, ZipFile.OPEN_READ, Runtime.Version.parse(r))
case _ =>
new ZipFile(file)
}
Expand Down
48 changes: 0 additions & 48 deletions compiler/src/dotty/tools/runner/ObjectRunner.scala

This file was deleted.

Loading
Loading