From 7fa8edea749aa72f063b7581e57f6f083bb705ec Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Tue, 1 Oct 2024 08:28:06 +0900 Subject: [PATCH] use CollectionConverters instead of deprecated JavaConverters --- .../src/test/scala/sbt/internal/inc/ActionTest.scala | 2 +- .../inc/ExtractUsedNamesPerformanceSpecification.scala | 2 +- .../src/main/scala/sbt/internal/inc/IndexBasedZipFsOps.scala | 2 +- .../sbt/internal/inc/classfile/IndexBasedZipFsOpsSpec.scala | 2 +- .../internal/inc/classfile/JavaCompilerForUnitTesting.scala | 2 +- .../main/scala/sbt/internal/inc/classpath/ClassLoaders.scala | 2 +- .../src/main/scala/sbt/internal/inc/AnalyzingCompiler.scala | 2 +- .../src/main/scala/sbt/internal/inc/CompilerArguments.scala | 2 +- .../src/main/scala/sbt/internal/inc/javac/LocalJava.scala | 4 ++-- .../src/main/scala-2.12/sbt/internal/inc/WrappedSet.scala | 2 +- .../zinc-core/src/main/scala/sbt/internal/inc/Changes.scala | 4 ++-- .../src/main/scala/sbt/internal/inc/Incremental.scala | 4 ++-- .../src/main/scala/sbt/internal/inc/IncrementalCommon.scala | 2 +- .../main/scala/sbt/internal/inc/InvalidationProfiler.scala | 2 +- .../zinc-core/src/main/scala/sbt/internal/inc/Lookup.scala | 4 ++-- .../main/scala/sbt/internal/inc/cached/CompilationCache.scala | 2 +- .../main/scala/sbt/internal/inc/text/AnalysisMappers.scala | 2 +- .../src/test/scala/sbt/internal/inc/IncHandler.scala | 2 +- zinc/src/test/scala/sbt/inc/cached/CachedHashingSpec.scala | 2 +- 19 files changed, 23 insertions(+), 23 deletions(-) diff --git a/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/ActionTest.scala b/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/ActionTest.scala index f873220166..e8b40c07a6 100644 --- a/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/ActionTest.scala +++ b/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/ActionTest.scala @@ -4,7 +4,7 @@ package inc import verify._ import sbt.io.IO.withTemporaryDirectory -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ /** This is a basic test for compiler bridge, mostly wrapped as * AnalyzingCompiler. diff --git a/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/ExtractUsedNamesPerformanceSpecification.scala b/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/ExtractUsedNamesPerformanceSpecification.scala index f10cc4a0f6..d649c5216f 100644 --- a/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/ExtractUsedNamesPerformanceSpecification.scala +++ b/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/ExtractUsedNamesPerformanceSpecification.scala @@ -22,7 +22,7 @@ class ExtractUsedNamesPerformanceSpecification catch { case _: FileSystemNotFoundException => val env = Map("create" -> "true") - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ Option(FileSystems.newFileSystem(uri, env.asJava)) case _: IllegalArgumentException => Option(FileSystems.getDefault) diff --git a/internal/zinc-classfile/src/main/scala/sbt/internal/inc/IndexBasedZipFsOps.scala b/internal/zinc-classfile/src/main/scala/sbt/internal/inc/IndexBasedZipFsOps.scala index 7759af62c8..5706a55f10 100644 --- a/internal/zinc-classfile/src/main/scala/sbt/internal/inc/IndexBasedZipFsOps.scala +++ b/internal/zinc-classfile/src/main/scala/sbt/internal/inc/IndexBasedZipFsOps.scala @@ -16,7 +16,7 @@ import java.nio.file.Path import sbt.internal.inc.zip.ZipCentralDir -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.collection.immutable.Seq /** diff --git a/internal/zinc-classfile/src/test/scala/sbt/internal/inc/classfile/IndexBasedZipFsOpsSpec.scala b/internal/zinc-classfile/src/test/scala/sbt/internal/inc/classfile/IndexBasedZipFsOpsSpec.scala index 3402d18715..bdce9975d0 100644 --- a/internal/zinc-classfile/src/test/scala/sbt/internal/inc/classfile/IndexBasedZipFsOpsSpec.scala +++ b/internal/zinc-classfile/src/test/scala/sbt/internal/inc/classfile/IndexBasedZipFsOpsSpec.scala @@ -3,7 +3,7 @@ package classfile import java.nio.file._ import java.nio.file.spi.FileSystemProvider -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ class IndexBasedZipFsOpsSpec extends UnitSpec { private val XL = 0xffff // minimum size to be zip64, which I'm calling "XL" diff --git a/internal/zinc-classfile/src/test/scala/sbt/internal/inc/classfile/JavaCompilerForUnitTesting.scala b/internal/zinc-classfile/src/test/scala/sbt/internal/inc/classfile/JavaCompilerForUnitTesting.scala index 6096946640..1f61717d1d 100644 --- a/internal/zinc-classfile/src/test/scala/sbt/internal/inc/classfile/JavaCompilerForUnitTesting.scala +++ b/internal/zinc-classfile/src/test/scala/sbt/internal/inc/classfile/JavaCompilerForUnitTesting.scala @@ -26,7 +26,7 @@ import xsbti.{ AnalysisCallback, BasicVirtualFileRef, TestCallback, VirtualFile, import xsbti.TestCallback.ExtractedClassDependencies import xsbti.compile.SingleOutput -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ object JavaCompilerForUnitTesting { private class TestVirtualFile(p: Path) extends BasicVirtualFileRef(p.toString) with VirtualFile { diff --git a/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClassLoaders.scala b/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClassLoaders.scala index 3074c2d236..ab85b0d2a1 100644 --- a/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClassLoaders.scala +++ b/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClassLoaders.scala @@ -108,7 +108,7 @@ final class ClasspathFilter(parent: ClassLoader, root: ClassLoader, classpath: S } override def getResources(name: String): java.util.Enumeration[URL] = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ val us = super.getResources(name) if (us ne null) us.asScala.filter(onClasspath).asJavaEnumeration else null } diff --git a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/AnalyzingCompiler.scala b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/AnalyzingCompiler.scala index 1f2d57fd6a..735bc65ab2 100644 --- a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/AnalyzingCompiler.scala +++ b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/AnalyzingCompiler.scala @@ -311,7 +311,7 @@ final class AnalyzingCompiler( // see https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html private def loadService[A](cls: Class[A], loader: ClassLoader): Option[A] = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ val sl = ServiceLoader.load(cls, loader) val list = sl.iterator.asScala.toList list.lastOption diff --git a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/CompilerArguments.scala b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/CompilerArguments.scala index f490e91508..bfdc68c21b 100644 --- a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/CompilerArguments.scala +++ b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/CompilerArguments.scala @@ -103,7 +103,7 @@ final class CompilerArguments( */ def createBootClasspath(addLibrary: Boolean): String = { def findBoot: String = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ System.getProperties.asScala.iterator .collectFirst { case (k, v) if k.endsWith(".boot.class.path") => v diff --git a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/LocalJava.scala b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/LocalJava.scala index a4fee662a2..ff3f9f6594 100644 --- a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/LocalJava.scala +++ b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/LocalJava.scala @@ -38,7 +38,7 @@ import javax.tools.{ import sbt.internal.util.LoggerWriter import sbt.util.{ Level, Logger } -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.util.control.NonFatal import xsbti.{ Reporter, Logger => XLogger, PathBasedFile, VirtualFile, VirtualFileRef } import xsbti.compile.{ @@ -104,7 +104,7 @@ object LocalJava { ): Int = { (javadocTool, standardDocletClass) match { case (Some(m), Some(clz)) => - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ val task = m.getTask( out, null, diff --git a/internal/zinc-core/src/main/scala-2.12/sbt/internal/inc/WrappedSet.scala b/internal/zinc-core/src/main/scala-2.12/sbt/internal/inc/WrappedSet.scala index 75177061dc..7f0d83bba5 100644 --- a/internal/zinc-core/src/main/scala-2.12/sbt/internal/inc/WrappedSet.scala +++ b/internal/zinc-core/src/main/scala-2.12/sbt/internal/inc/WrappedSet.scala @@ -15,7 +15,7 @@ import xsbti.VirtualFileRef import scala.collection.immutable.Set private[inc] class WrappedSet(s: java.util.Set[VirtualFileRef]) extends Set[VirtualFileRef] { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ def iterator: Iterator[xsbti.VirtualFileRef] = s.asScala.iterator def contains(elem: xsbti.VirtualFileRef): Boolean = s.contains(elem) diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/Changes.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/Changes.scala index db1c4b7b35..bc40d58f84 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/Changes.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/Changes.scala @@ -13,7 +13,7 @@ package sbt package internal package inc -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import xsbti.{ UseScope, VirtualFileRef } import xsbti.api.NameHash @@ -127,7 +127,7 @@ abstract class UnderlyingChanges[A] extends Changes[A] { def changed: Set[A] def unmodified: Set[A] - import scala.collection.JavaConverters.setAsJavaSetConverter + import scala.jdk.CollectionConverters._ override def getAdded: java.util.Set[A] = added.asJava override def getChanged: java.util.Set[A] = changed.asJava override def getRemoved: java.util.Set[A] = removed.asJava diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/Incremental.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/Incremental.scala index 37e93decba..018ffa3b95 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/Incremental.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/Incremental.scala @@ -23,7 +23,7 @@ import sbt.internal.inc.JavaInterfaceUtil.EnrichOption import sbt.util.{ InterfaceUtil, Level, Logger } import sbt.util.InterfaceUtil.{ jl2l, jo2o, l2jl, t2 } -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.collection.mutable import scala.util.control.NonFatal import xsbti.{ FileConverter, Position, Problem, Severity, UseScope, VirtualFile, VirtualFileRef } @@ -1010,7 +1010,7 @@ private final class AnalysisCallback( } def addProductsAndDeps(base: Analysis): Analysis = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ srcs.asScala.foldLeft(base) { case (a, src) => val stamp = stampReader.source(src) diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalCommon.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalCommon.scala index 3a94b4bc0c..f736de7f36 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalCommon.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalCommon.scala @@ -528,7 +528,7 @@ private[inc] abstract class IncrementalCommon( ): (Set[String], Set[VirtualFileRef]) = { def classNames(srcs: Set[VirtualFileRef]): Set[String] = srcs.flatMap(previous.classNames) def toImmutableSet(srcs: java.util.Set[VirtualFileRef]): Set[VirtualFileRef] = { - import scala.collection.JavaConverters.asScalaIteratorConverter + import scala.jdk.CollectionConverters._ srcs.iterator().asScala.toSet } diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/InvalidationProfiler.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/InvalidationProfiler.scala index 210fb13d1d..ca9d9caa3f 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/InvalidationProfiler.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/InvalidationProfiler.scala @@ -19,7 +19,7 @@ import xsbti.compile.{ InitialChanges => XInitialChanges } import xsbti.compile.{ InvalidationProfiler => XInvalidationProfiler } import xsbti.compile.{ RunProfiler => XRunProfiler } -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.collection.mutable import scala.collection.mutable.ArrayBuffer diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/Lookup.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/Lookup.scala index 284aff3abd..0f7097fee3 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/Lookup.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/Lookup.scala @@ -66,7 +66,7 @@ trait Lookup extends ExternalLookup { */ trait ExternalLookup extends ExternalHooks.Lookup { import sbt.internal.inc.JavaInterfaceUtil.EnrichOption - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ /** * Find the external `AnalyzedClass` (from another analysis) given a class name and, if available, @@ -130,7 +130,7 @@ trait ExternalLookup extends ExternalHooks.Lookup { changedClasses: util.Set[String], previousAnalysis: CompileAnalysis ): Boolean = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ shouldDoIncrementalCompilation(changedClasses.iterator().asScala.toSet, previousAnalysis) } diff --git a/internal/zinc-persist/src/main/scala/sbt/internal/inc/cached/CompilationCache.scala b/internal/zinc-persist/src/main/scala/sbt/internal/inc/cached/CompilationCache.scala index 029eeb784b..a37a2fb28e 100644 --- a/internal/zinc-persist/src/main/scala/sbt/internal/inc/cached/CompilationCache.scala +++ b/internal/zinc-persist/src/main/scala/sbt/internal/inc/cached/CompilationCache.scala @@ -28,7 +28,7 @@ trait CompilationCache { case class ProjectRebasedCache(remoteRoot: Path, cacheLocation: Path) extends CompilationCache { override def loadCache(projectLocation: File): Option[(CompileAnalysis, MiniSetup)] = { import JavaInterfaceUtil.EnrichOptional - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ val projectLocationPath = projectLocation.toPath val readMapper = new RebaseReadWriteMapper(remoteRoot, projectLocationPath) val writeMapper = new RebaseReadWriteMapper(projectLocationPath, remoteRoot) diff --git a/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/AnalysisMappers.scala b/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/AnalysisMappers.scala index cab6562a91..cb3069a01f 100644 --- a/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/AnalysisMappers.scala +++ b/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/AnalysisMappers.scala @@ -17,7 +17,7 @@ import java.nio.file.{ Path, Paths } import sbt.internal.inc.UsedName import xsbti.{ UseScope, VirtualFileRef } import xsbti.compile.analysis.Stamp -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ case class Mapper[V](read: String => V, write: V => String) case class ContextAwareMapper[C, V](read: (C, String) => V, write: (C, V) => String) diff --git a/internal/zinc-scripted/src/test/scala/sbt/internal/inc/IncHandler.scala b/internal/zinc-scripted/src/test/scala/sbt/internal/inc/IncHandler.scala index 7a76d0cf8c..72ccda8709 100644 --- a/internal/zinc-scripted/src/test/scala/sbt/internal/inc/IncHandler.scala +++ b/internal/zinc-scripted/src/test/scala/sbt/internal/inc/IncHandler.scala @@ -780,7 +780,7 @@ case class ProjectStructure( } def loadIncOptions(properties: Properties): (IncOptions, Array[String]) = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ val map = new java.util.HashMap[String, String] properties.asScala foreach { case (k: String, v: String) => map.put(k, v) } val base = IncOptions diff --git a/zinc/src/test/scala/sbt/inc/cached/CachedHashingSpec.scala b/zinc/src/test/scala/sbt/inc/cached/CachedHashingSpec.scala index d6704c547c..444383c9ad 100644 --- a/zinc/src/test/scala/sbt/inc/cached/CachedHashingSpec.scala +++ b/zinc/src/test/scala/sbt/inc/cached/CachedHashingSpec.scala @@ -22,7 +22,7 @@ import sbt.internal.inc.{ } import sbt.io.IO -import scala.collection.JavaConverters.asScalaIteratorConverter +import scala.jdk.CollectionConverters._ class CachedHashingSpec extends BaseCompilerSpec { lazy val isWindows: Boolean =