Skip to content

Commit d881891

Browse files
committed
Make -usejavacp a private setting as -Yusejavacp (preserving old API as an alias)
1 parent 714f3b6 commit d881891

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

compiler/src/dotty/tools/dotc/config/PathResolver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class PathResolver(using c: Context) {
194194
*/
195195
object Calculated {
196196
def scalaHome: String = Defaults.scalaHome
197-
def useJavaClassPath: Boolean = settings.usejavacp.value || Defaults.useJavaClassPath
197+
def useJavaClassPath: Boolean = settings.Yusejavacp.value || Defaults.useJavaClassPath
198198
def javaBootClassPath: String = cmdLineOrElse("javabootclasspath", Defaults.javaBootClassPath)
199199
def javaExtDirs: String = cmdLineOrElse("javaextdirs", Defaults.javaExtDirs)
200200
def javaUserClassPath: String = if (useJavaClassPath) Defaults.javaUserClassPath else ""

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ trait CommonScalaSettings:
124124

125125
/* Other settings */
126126
val encoding: Setting[String] = StringSetting(RootSetting, "encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding, aliases = List("--encoding"))
127-
val usejavacp: Setting[Boolean] = BooleanSetting(RootSetting, "usejavacp", "Utilize the java.class.path in classpath resolution.", aliases = List("--use-java-class-path"))
128127
val scalajs: Setting[Boolean] = BooleanSetting(RootSetting, "scalajs", "Compile in Scala.js mode (requires scalajs-library.jar on the classpath).", aliases = List("--scalajs"))
129128
val replInitScript: Setting[String] = StringSetting(RootSetting, "repl-init-script", "code", "The code will be run on REPL startup.", "", aliases = List("--repl-init-script"))
130129
val replQuitAfterInit: Setting[Boolean] = BooleanSetting(RootSetting, "repl-quit-after-init", "Quit REPL after evaluating the init script.", aliases = List("--repl-quit-after-init"))
@@ -405,12 +404,12 @@ private sealed trait YSettings:
405404
val YlogClasspath: Setting[Boolean] = BooleanSetting(ForkSetting, "Ylog-classpath", "Output information about what classpath is being applied.")
406405
val YdisableFlatCpCaching: Setting[Boolean] = BooleanSetting(ForkSetting, "YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")
407406
val YnoStdlibPatches: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-stdlib-patches", "Do not patch stdlib files (temporary and only to be used for the stdlib migration)", false)
408-
409407
val Yreporter: Setting[String] = StringSetting(ForkSetting, name = "Yreporter", helpArg = "<class>", descr = "Specify a dotty.tools.dotc.reporting.Reporter", default = "dotty.tools.dotc.reporting.ConsoleReporter")
410408

411409
val Yscala2Unpickler: Setting[String] = StringSetting(ForkSetting, "Yscala2-unpickler", "", "Control where we may get Scala 2 symbols from. This is either \"always\", \"never\", or a classpath.", "always")
412410

413411
val YnoImports: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-imports", "Compile without importing scala.*, java.lang.*, or Predef.")
412+
414413
val Yimports: Setting[List[String]] = MultiStringSetting(ForkSetting, "Yimports", helpArg="", "Custom root imports. If set, none of scala.*, java.lang.*, or Predef.* will be imported unless explicitly included.")
415414
val YnoPredef: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-predef", "Compile without importing Predef.")
416415
val Yskip: Setting[List[String]] = PhasesSetting(ForkSetting, "Yskip", "Skip")
@@ -449,8 +448,8 @@ private sealed trait YSettings:
449448
val YprofileExternalTool: Setting[List[String]] = PhasesSetting(ForkSetting, "Yprofile-external-tool", "Enable profiling for a phase using an external tool hook. Generally only useful for a single phase.", "typer", depends = List(YprofileEnabled -> true))
450449
val YprofileRunGcBetweenPhases: Setting[List[String]] = PhasesSetting(ForkSetting, "Yprofile-run-gc", "Run a GC between phases - this allows heap size to be accurate at the expense of more time. Specify a list of phases, or *", "_", depends = List(YprofileEnabled -> true))
451450
val YprofileTrace: Setting[String] = StringSetting(ForkSetting, "Yprofile-trace", "file", s"Capture trace of compilation in JSON Chrome Trace format to the specified file. This option requires ${YprofileEnabled.name}. The output file can be visualized using https://ui.perfetto.dev/.", "", depends = List(YprofileEnabled -> true))
452-
453451
val YbestEffort: Setting[Boolean] = BooleanSetting(ForkSetting, "Ybest-effort", "Enable best-effort compilation attempting to produce betasty to the META-INF/best-effort directory, regardless of errors, as part of the pickler phase.")
452+
val Yusejavacp: Setting[Boolean] = BooleanSetting(ForkSetting, "Yusejavacp", "Utilize the java.class.path in classpath resolution.", aliases = List("--use-java-class-path", "-usejavacp", "--usejavacp"))
454453
val YwithBestEffortTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Ywith-best-effort-tasty", "Allow to compile using best-effort tasty files. If such file is used, the compiler will stop after the pickler phase.")
455454

456455
val YmagicOffsetHeader: Setting[String] = StringSetting(ForkSetting, "Ymagic-offset-header", "header", "Specify the magic header comment that marks the start of the actual code in generated wrapper scripts. Example: -Ymagic-offset-header:SOURCE_CODE_START. Then, in the source, the magic comment `///SOURCE_CODE_START:<ORIGINAL_FILE_PATH>` marks the start of user code. The comment should be suffixed by `:<ORIGINAL_FILE_PATH>` to indicate the original file.", "")

compiler/test/dotty/tools/dotc/classpath/MultiReleaseJarTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
3838

3939
def apiMethods(jarPath: Path, release: String): Set[String] = {
4040
given ctx: Context = initCtx.fresh
41-
ctx.settings.usejavacp.update(true)
41+
ctx.settings.Yusejavacp.update(true)
4242
ctx.settings.classpath.update(jarPath.toAbsolutePath.toString)
4343
ctx.settings.javaOutputVersion.update(release)
4444
ctx.initialize()
@@ -76,7 +76,7 @@ class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
7676

7777
def classExists(className: String, release: String): Boolean = {
7878
given ctx: Context = initCtx.fresh
79-
ctx.settings.usejavacp.update(true)
79+
ctx.settings.Yusejavacp.update(true)
8080
ctx.settings.javaOutputVersion.update(release)
8181
ctx.initialize()
8282
val classFile = ctx.platform.classPath.findClassFile(className)

scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import java.nio.file.Paths
77
import collection.immutable.ArraySeq
88

99
import dotty.tools.dotc.config.Settings._
10-
import dotty.tools.dotc.config.{ CommonScalaSettings, AllScalaSettings }
10+
import dotty.tools.dotc.config.{ CommonScalaSettings, AllScalaSettings, YSettings }
1111
import dotty.tools.dotc.reporting.Reporter
1212
import dotty.tools.dotc.core.Contexts._
1313
import dotty.tools.scaladoc.Inkuire._
@@ -116,7 +116,8 @@ object Scaladoc:
116116
)(s => newContext.setSetting(s.asInstanceOf[Setting[T]], newValue))
117117
}
118118

119-
val commonScalaSettings = (new SettingGroup with CommonScalaSettings).allSettings
119+
val scaladocYSettings = Seq((new SettingGroup with YSettings).Yusejavacp)
120+
val commonScalaSettings = (new SettingGroup with CommonScalaSettings).allSettings ++ scaladocYSettings
120121
val allScalaSettings = (new SettingGroup with AllScalaSettings).allSettings
121122

122123
val (shared, other) = allSettings

scaladoc/test/dotty/tools/scaladoc/snippets/SnippetCompilerTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import dotty.tools.io.{AbstractFile, VirtualDirectory}
77

88
class SnippetCompilerTest {
99
val compiler = SnippetCompiler(
10-
Seq(SnippetCompilerSetting(testContext.settings.usejavacp, true))
10+
Seq(SnippetCompilerSetting(testContext.settings.Yusejavacp, true))
1111
)
1212
def wrapFn: String => WrappedSnippet = (str: String) => WrappedSnippet(
1313
str,

scaladoc/test/dotty/tools/scaladoc/testUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def testArgs(files: Seq[File] = Nil, dest: File = new File("notUsed")) = Scalado
6060

6161
def testContext =
6262
val ctx = (new ContextBase).initialCtx.fresh.setReporter(new TestReporter)
63-
ctx.setSetting(ctx.settings.usejavacp, true)
63+
ctx.setSetting(ctx.settings.Yusejavacp, true)
6464
ctx
6565

6666
def testDocContext(files: Seq[File] = Nil) = DocContext(testArgs(files), testContext)

0 commit comments

Comments
 (0)