Skip to content

Commit 3ebf919

Browse files
committed
Completely remove logic to set Main-Class
It never actually worked (see previous commit), we have no tests for it, and it's only useful for a marginal feature (when the compiler outputs a jar), better to remove dead code and wait for a usecase to appear.
1 parent e89516a commit 3ebf919

8 files changed

+9
-146
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,12 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
7777
/*
7878
* must-single-thread
7979
*/
80-
def initBytecodeWriter(entryPoints: List[Symbol]): BytecodeWriter = {
80+
def initBytecodeWriter(): BytecodeWriter = {
8181
getSingleOutput match {
82-
case Some(f) if f hasExtension "jar" =>
83-
// If no main class was specified, see if there's only one
84-
// entry point among the classes going into the jar.
85-
if (mainClass.isEmpty) {
86-
entryPoints map (_.fullName('.')) match {
87-
case Nil =>
88-
log("No Main-Class designated or discovered.")
89-
case name :: Nil =>
90-
log(s"Unique entry point: setting Main-Class to $name")
91-
setMainClass(name)
92-
case names =>
93-
log(s"No Main-Class due to multiple entry points:\n ${names.mkString("\n ")}")
94-
}
95-
}
96-
else log(s"Main-Class was specified: ${mainClass.get}")
97-
82+
case Some(f) if f.hasExtension("jar") =>
9883
new DirectToJarfileWriter(f.file)
99-
100-
case _ => factoryNonJarBytecodeWriter()
84+
case _ =>
85+
factoryNonJarBytecodeWriter()
10186
}
10287
}
10388

compiler/src/dotty/tools/backend/jvm/BackendInterface.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,11 @@ abstract class BackendInterface extends BackendInterfaceDefinitions {
156156
/* various configuration options used by backend */
157157
def emitAsmp: Option[String]
158158
def dumpClasses: Option[String]
159-
def mainClass: Option[String]
160159
def noForwarders: Boolean
161160
def debuglevel: Int
162161
def settings_debug: Boolean
163162
def targetPlatform: String
164163
def sourceFileFor(cu: CompilationUnit): String
165-
def setMainClass(name: String): Unit
166164
def informProgress(msg: String): Unit
167165
def hasLabelDefs: Boolean // whether this compiler uses LabelDefs (i.e., scalac)
168166

@@ -508,7 +506,6 @@ abstract class BackendInterface extends BackendInterfaceDefinitions {
508506
def isNonBottomSubClass(sym: Symbol): Boolean
509507
def hasAnnotation(sym: Symbol): Boolean
510508
def shouldEmitForwarders: Boolean
511-
def isJavaEntryPoint: Boolean
512509
def isJavaDefaultMethod: Boolean
513510
def isClassConstructor: Boolean
514511
def isSerializable: Boolean

compiler/src/dotty/tools/backend/jvm/BytecodeWriters.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ trait BytecodeWriters {
5050
}
5151

5252
class DirectToJarfileWriter(jfile: JFile) extends BytecodeWriter {
53-
val jarMainAttrs = mainClass.map(nm => List(Name.MAIN_CLASS -> nm)).getOrElse(Nil)
54-
55-
val writer = new Jar(jfile).jarWriter(jarMainAttrs: _*)
53+
val writer = new Jar(jfile).jarWriter()
5654

5755
def writeClass(label: String, jclassName: String, jclassBytes: Array[Byte], outfile: AbstractFile): Unit = {
5856
assert(outfile == null,

compiler/src/dotty/tools/backend/jvm/CollectEntryPoints.scala

Lines changed: 0 additions & 104 deletions
This file was deleted.

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,6 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
400400
if (ctx.settings.Ydumpclasses.isDefault) None
401401
else Some(ctx.settings.Ydumpclasses.value)
402402

403-
def mainClass: Option[String] =
404-
if (ctx.settings.XmainClass.isDefault) None
405-
else Some(ctx.settings.XmainClass.value)
406-
def setMainClass(name: String): Unit = ctx.settings.XmainClass.update(name)
407-
408-
409403
def noForwarders: Boolean = ctx.settings.XnoForwarders.value
410404
def debuglevel: Int = 3 // 0 -> no debug info; 1-> filename; 2-> lines; 3-> varnames
411405
def settings_debug: Boolean = ctx.settings.Ydebug.value
@@ -700,7 +694,6 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
700694
def hasAnnotation(ann: Symbol): Boolean = toDenot(sym).hasAnnotation(ann)
701695
def shouldEmitForwarders: Boolean =
702696
(sym.is(Flags.Module)) && sym.isStatic
703-
def isJavaEntryPoint: Boolean = CollectEntryPoints.isJavaEntryPoint(sym)
704697
def isEnum = sym.is(Flags.Enum)
705698

706699
def isClassConstructor: Boolean = toDenot(sym).isClassConstructor

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import dotty.tools.io._
3232

3333
class GenBCode extends Phase {
3434
def phaseName: String = GenBCode.name
35-
private val entryPoints = new mutable.HashSet[Symbol]()
36-
def registerEntryPoint(sym: Symbol): Unit = entryPoints += sym
3735

3836
private val superCallsMap = newMutableSymbolMap[Set[ClassSymbol]]
3937
def registerSuperCall(sym: Symbol, calls: ClassSymbol): Unit = {
@@ -50,9 +48,8 @@ class GenBCode extends Phase {
5048
}
5149

5250
def run(implicit ctx: Context): Unit = {
53-
new GenBCodePipeline(entryPoints.toList,
54-
new DottyBackendInterface(outputDir, superCallsMap.toMap)(ctx))(ctx).run(ctx.compilationUnit.tpdTree)
55-
entryPoints.clear()
51+
new GenBCodePipeline(new DottyBackendInterface(
52+
outputDir, superCallsMap.toMap)(ctx))(ctx).run(ctx.compilationUnit.tpdTree)
5653
}
5754

5855
override def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] = {
@@ -69,7 +66,7 @@ object GenBCode {
6966
val name: String = "genBCode"
7067
}
7168

72-
class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInterface)(implicit val ctx: Context) extends BCodeSyncAndTry {
69+
class GenBCodePipeline(val int: DottyBackendInterface)(implicit val ctx: Context) extends BCodeSyncAndTry {
7370

7471
private[this] var tree: Tree = _
7572

@@ -474,7 +471,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
474471
// Statistics.stopTimer(BackendStats.bcodeInitTimer, initStart)
475472

476473
// initBytecodeWriter invokes fullName, thus we have to run it before the typer-dependent thread is activated.
477-
bytecodeWriter = initBytecodeWriter(entryPoints)
474+
bytecodeWriter = initBytecodeWriter()
478475
mirrorCodeGen = new JMirrorBuilder
479476

480477
val needsOutfileForSymbol = bytecodeWriter.isInstanceOf[ClassBytecodeWriter]

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ class Compiler {
118118
new RestoreScopes, // Repair scopes rendered invalid by moving definitions in prior phases of the group
119119
new SelectStatic, // get rid of selects that would be compiled into GetStatic
120120
new sjs.JUnitBootstrappers, // Generate JUnit-specific bootstrapper classes for Scala.js (not enabled by default)
121-
// FIXME: See comment in CollectEntryPoints
122-
// new CollectEntryPoints, // Find classes with main methods
123121
new CollectSuperCalls) :: // Find classes that are called with super
124122
Nil
125123

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class ScalaSettings extends Settings.SettingGroup {
7777
val XprintDiffDel: Setting[Boolean] = BooleanSetting("-Xprint-diff-del", "Print changed parts of the tree since last print including deleted parts.")
7878
val XprintInline: Setting[Boolean] = BooleanSetting("-Xprint-inline", "Show where inlined code comes from")
7979
val Xprompt: Setting[Boolean] = BooleanSetting("-Xprompt", "Display a prompt after each error (debugging option).")
80-
val XmainClass: Setting[String] = StringSetting("-Xmain-class", "path", "Class for manifest's Main-Class entry (only useful with -d <jar>)", "")
8180
val XnoValueClasses: Setting[Boolean] = BooleanSetting("-Xno-value-classes", "Do not use value classes. Helps debugging.")
8281
val XreplLineWidth: Setting[Int] = IntSetting("-Xrepl-line-width", "Maximal number of columns per line for REPL output", 390)
8382
val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Xfatal-warnings", "Fail the compilation if there are any warnings.")

0 commit comments

Comments
 (0)