Skip to content

Commit 8d2d3c7

Browse files
retronymadriaanm
authored andcommitted
Require and target Java 8
- Require Java 8 in ant build - use -source 1.8 and -target 1.8 for javac - Default scalac's -target to `jvm-1.8`, ignore and deprecate attempts to use `jvm-1.{6.7}` - Remove fragile javap-app test. The feature itself is slated for removal. - Remove obsolete Java6 checkfile - Adapt DCE tests - Remove deprecated/redundant -target:jvm-1.6 from flags where the intent was to trigger generation of stack map frames. - Remove tests with -target:jvm-1.5 that tested without stack map frames - Ignore OpenJDK JVM warnings (via test/[files|scaladoc]/filters).
1 parent 7b224c5 commit 8d2d3c7

30 files changed

+43
-205
lines changed

build-ant-macros.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
<then>
106106
<stopwatch name="@{project}.timer"/>
107107
<mkdir dir="${@{project}-classes}"/>
108-
<javac debug="true" srcdir="${src.dir}/@{project}" destdir="${@{project}-classes}" classpath="${@{project}-classes}" includes="**/*.java" target="1.6" source="1.5" compiler="javac1.6">
108+
<javac debug="true" srcdir="${src.dir}/@{project}" destdir="${@{project}-classes}" classpath="${@{project}-classes}" includes="**/*.java" target="1.8" source="1.8" compiler="javac1.8">
109109
<compilerarg line="${javac.args} @{args}"/>
110110
</javac>
111111
<if>
@@ -132,7 +132,7 @@
132132
<attribute name="args" default=""/>
133133
<attribute name="excludes" default=""/>
134134
<sequential>
135-
<javac debug="true" srcdir="${src.dir}/@{project}" destdir="${build-@{stage}.dir}/classes/@{destproject}" includes="**/*.java" excludes="@{excludes}" target="1.6" source="1.5">
135+
<javac debug="true" srcdir="${src.dir}/@{project}" destdir="${build-@{stage}.dir}/classes/@{destproject}" includes="**/*.java" excludes="@{excludes}" target="1.8" source="1.8">
136136
<compilerarg line="${javac.args} @{args}"/>
137137
<classpath refid="@{stage}.@{destproject}.build.path"/>
138138
</javac>

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ Seq[Setting[_]](
8383
// we always assume that Java classes are standalone and do not have any dependency
8484
// on Scala classes
8585
compileOrder := CompileOrder.JavaThenScala,
86-
javacOptions in Compile ++= Seq("-g", "-source", "1.5", "-target", "1.6"),
86+
javacOptions in Compile ++= Seq("-g", "-source", "1.8", "-target", "1.8"),
8787
// we don't want any unmanaged jars; as a reminder: unmanaged jar is a jar stored
8888
// directly on the file system and it's not resolved through Ivy
8989
// Ant's build stored unmanaged jars in `lib/` directory

build.xml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ TODO:
193193

194194
<!-- if ANT_OPTS is already set by the environment, it will be unaltered,
195195
but if it is unset it will take this default value. -->
196-
<property name="env.ANT_OPTS" value="-Xms1536M -Xmx1536M -Xss1M -XX:MaxPermSize=192M -XX:+UseParallelGC" />
196+
<property name="env.ANT_OPTS" value="-Xms1536M -Xmx1536M -Xss1M -XX:+UseParallelGC" />
197197

198198
<property name="scalacfork.jvmargs" value="${env.ANT_OPTS} ${jvm.opts}"/>
199199

@@ -477,20 +477,12 @@ TODO:
477477
<!-- some default in case something went wrong getting the revision -->
478478
<property name="version.number" value="-unknown-"/>
479479

480-
<condition property="has.java6">
481-
<equals arg1="${ant.java.version}" arg2="1.6"/>
482-
</condition>
483-
<condition property="has.java7">
484-
<equals arg1="${ant.java.version}" arg2="1.7"/>
485-
</condition>
486480
<condition property="has.java8">
487481
<equals arg1="${ant.java.version}" arg2="1.8"/>
488482
</condition>
489483
<condition property="has.unsupported.jdk">
490484
<not><or>
491485
<isset property="has.java8" />
492-
<isset property="has.java7" />
493-
<isset property="has.java6" />
494486
</or></not>
495487
</condition>
496488

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,8 +1379,11 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
13791379
settings.userSetSettings filter (_.isDeprecated) foreach { s =>
13801380
currentRun.reporting.deprecationWarning(NoPosition, s.name + " is deprecated: " + s.deprecationMessage.get)
13811381
}
1382-
if (settings.target.value.contains("jvm-1.5"))
1383-
currentRun.reporting.deprecationWarning(NoPosition, settings.target.name + ":" + settings.target.value + " is deprecated: use target for Java 1.6 or above.")
1382+
val supportedTarget = "jvm-1.8"
1383+
if (settings.target.value != supportedTarget) {
1384+
currentRun.reporting.deprecationWarning(NoPosition, settings.target.name + ":" + settings.target.value + " is deprecated and has no effect, setting to " + supportedTarget)
1385+
settings.target.value = supportedTarget
1386+
}
13841387
}
13851388

13861389
/* An iterator returning all the units being compiled in this run */

src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
843843
* loading another throwable first).
844844
*
845845
* New (http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.10.1)
846-
* - Requires consistent stack map frames. GenBCode generates stack frames if -target:jvm-1.6
846+
* - Requires consistent stack map frames. GenBCode always generates stack frames.
847847
* or higher.
848848
* - In practice: the ASM library computes stack map frames for us (ClassWriter). Emitting
849849
* correct frames after an ATHROW is probably complex, so ASM uses the following strategy:

src/compiler/scala/tools/nsc/backend/jvm/BCodeIdiomatic.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ abstract class BCodeIdiomatic extends SubComponent {
2828
import coreBTypes._
2929

3030
val classfileVersion: Int = settings.target.value match {
31-
case "jvm-1.5" => asm.Opcodes.V1_5
32-
case "jvm-1.6" => asm.Opcodes.V1_6
33-
case "jvm-1.7" => asm.Opcodes.V1_7
3431
case "jvm-1.8" => asm.Opcodes.V1_8
3532
}
3633

src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters { self =>
441441
// -----------------------------------------------------------------------------------------
442442

443443
private val classfileVersion: Int = settings.target.value match {
444-
case "jvm-1.5" => asm.Opcodes.V1_5
445-
case "jvm-1.6" => asm.Opcodes.V1_6
446-
case "jvm-1.7" => asm.Opcodes.V1_7
447444
case "jvm-1.8" => asm.Opcodes.V1_8
448445
}
449446

src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ trait AbsScalaSettings {
3131

3232
def BooleanSetting(name: String, descr: String): BooleanSetting
3333
def ChoiceSetting(name: String, helpArg: String, descr: String, choices: List[String], default: String): ChoiceSetting
34+
def ChoiceSettingForcedDefault(name: String, helpArg: String, descr: String, choices: List[String], default: String): ChoiceSetting
3435
def IntSetting(name: String, descr: String, default: Int, range: Option[(Int, Int)], parser: String => Option[Int]): IntSetting
3536
def MultiStringSetting(name: String, helpArg: String, descr: String): MultiStringSetting
3637
def MultiChoiceSetting[E <: MultiChoiceEnumeration](name: String, helpArg: String, descr: String, domain: E, default: Option[List[String]]): MultiChoiceSetting[E]

src/compiler/scala/tools/nsc/settings/MutableSettings.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ class MutableSettings(val errorFn: String => Unit)
221221
def BooleanSetting(name: String, descr: String) = add(new BooleanSetting(name, descr))
222222
def ChoiceSetting(name: String, helpArg: String, descr: String, choices: List[String], default: String) =
223223
add(new ChoiceSetting(name, helpArg, descr, choices, default))
224+
def ChoiceSettingForcedDefault(name: String, helpArg: String, descr: String, choices: List[String], default: String) =
225+
ChoiceSetting(name, helpArg, descr, choices, default).withPostSetHook(sett =>
226+
if (sett.value != default) {
227+
sett.withDeprecationMessage(s"${name}:${sett.value} is deprecated, forcing use of $default")
228+
sett.value = default
229+
}
230+
)
224231
def IntSetting(name: String, descr: String, default: Int, range: Option[(Int, Int)], parser: String => Option[Int]) =
225232
add(new IntSetting(name, descr, default, range, parser))
226233
def MultiStringSetting(name: String, arg: String, descr: String) = add(new MultiStringSetting(name, arg, descr))

src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ trait StandardScalaSettings {
3838
val nowarn = BooleanSetting ("-nowarn", "Generate no warnings.")
3939
val optimise: BooleanSetting // depends on post hook which mutates other settings
4040
val print = BooleanSetting ("-print", "Print program with Scala-specific features removed.")
41-
val target = ChoiceSetting ("-target", "target", "Target platform for object files. All JVM 1.5 targets are deprecated.",
42-
List("jvm-1.5", "jvm-1.6", "jvm-1.7", "jvm-1.8"), "jvm-1.6")
41+
val target = ChoiceSettingForcedDefault ("-target", "target", "Target platform for object files. All JVM 1.5 - 1.7 targets are deprecated.",
42+
List("jvm-1.5", "jvm-1.6", "jvm-1.7", "jvm-1.8"), "jvm-1.8")
4343
val unchecked = BooleanSetting ("-unchecked", "Enable additional warnings where generated code depends on assumptions.")
4444
val uniqid = BooleanSetting ("-uniqid", "Uniquely tag all identifiers in debugging output.")
4545
val usejavacp = BooleanSetting ("-usejavacp", "Utilize the java.class.path in classpath resolution.")

src/compiler/scala/tools/nsc/transform/Delambdafy.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import scala.collection.mutable.LinkedHashMap
1818
*
1919
* From a lambda, Delambdafy will create:
2020
*
21-
* Under -target:jvm-1.7 and below:
21+
* Under GenASM
2222
*
2323
* 1) a new top level class that
2424
a) has fields and a constructor taking the captured environment (including possibly the "this"
@@ -27,7 +27,7 @@ import scala.collection.mutable.LinkedHashMap
2727
* c) if needed a bridge method for the apply method
2828
* 2) an instantiation of the newly created class which replaces the lambda
2929
*
30-
* Under -target:jvm-1.8 with GenBCode:
30+
* Under GenBCode:
3131
*
3232
* 1) An application of the captured arguments to a fictional symbol representing the lambda factory.
3333
* This will be translated by the backed into an invokedynamic using a bootstrap method in JDK8's `LambdaMetaFactory`.
@@ -477,8 +477,7 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
477477
val methodType: Type = target.info
478478
methodType.exists(_.isInstanceOf[ErasedValueType])
479479
}
480-
val isTarget18 = settings.target.value.contains("jvm-1.8")
481-
settings.isBCodeActive && isTarget18 && !hasValueClass
480+
settings.isBCodeActive && !hasValueClass
482481
}
483482

484483
def functionalInterface: Symbol = {

src/compiler/scala/tools/nsc/transform/UnCurry.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ abstract class UnCurry extends InfoTransform
237237

238238
def canUseDelamdafyMethod = (
239239
(inConstructorFlag == 0) // Avoiding synthesizing code prone to SI-6666, SI-8363 by using old-style lambda translation
240-
&& (!isSpecialized || (settings.target.value == "jvm-1.8")) // DelambdafyTransformer currently only emits generic FunctionN-s, use the old style in the meantime
240+
&& (!isSpecialized || settings.isBCodeActive) // DelambdafyTransformer currently only emits generic FunctionN-s, use the old style in the meantime
241241
)
242242
if (inlineFunctionExpansion || !canUseDelamdafyMethod) {
243243
val parents = addSerializable(abstractFunctionForFunctionType(fun.tpe))

src/manual/scala/man1/scalac.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,9 @@ object scalac extends Command {
152152
CmdOption("sourcepath", Argument("path")),
153153
"Specify location(s) of source files."),
154154
Definition(
155-
CmdOptionBound("target:", "{jvm-1.5,jvm-1.6,jvm-1.7}"),
155+
CmdOptionBound("target:", "{jvm-1.8}"),
156156
SeqPara(
157-
Mono("\"jvm-1.5\"") & " target JVM 1.5 (deprecated),",
158-
Mono("\"jvm-1.6\"") & " target JVM 1.6 (default),",
159-
Mono("\"jvm-1.7\"") & " target JVM 1.7,")),
157+
Mono("\"jvm-1.8\"") & " target JVM 1.8 (default)")),
160158
Definition(
161159
CmdOption("toolcp", Argument("path")),
162160
"Add to the runner classpath."),

test/files/filters

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#
22
#Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 28).
33
Java HotSpot\(TM\) .* warning:
4+
OpenJDK .* warning:
45
# Hotspot receiving VM options through the $_JAVA_OPTIONS
56
# env variable outputs them on stderr
67
Picked up _JAVA_OPTIONS:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
warning: -target is deprecated: -target:jvm-1.7 is deprecated, forcing use of jvm-1.8
2+
error: No warnings can be incurred under -Xfatal-warnings.
3+
one warning found
4+
one error found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-target:jvm-1.7 -deprecation -Xfatal-warnings
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
class C

test/files/neg/t6289.check

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#partest java6
2-
t6289/J.java:2: method does not override or implement a method from a supertype
3-
@Override public void foo() { }
4-
^
5-
1 error
6-
#partest !java6
71
t6289/J.java:2: error: method does not override or implement a method from a supertype
82
@Override public void foo() { }
93
^

test/files/run/nothingTypeDce.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-target:jvm-1.6 -Ybackend:GenBCode -Yopt:unreachable-code
1+
-Ybackend:GenBCode -Yopt:unreachable-code

test/files/run/nothingTypeDce.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// See comment in BCodeBodyBuilder
22

3-
// -target:jvm-1.6 -Ybackend:GenBCode -Yopt:unreachable-code
4-
// target enables stack map frames generation
3+
// -Ybackend:GenBCode -Yopt:unreachable-code
54

65
class C {
76
// can't just emit a call to ???, that returns value of type Nothing$ (not Int).

test/files/run/nothingTypeNoFramesNoDce.check

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/files/run/nothingTypeNoFramesNoDce.flags

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/files/run/nothingTypeNoFramesNoDce.scala

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

test/files/run/nothingTypeNoOpt.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-target:jvm-1.6 -Ybackend:GenBCode -Yopt:l:none
1+
-Ybackend:GenBCode -Yopt:l:none

test/files/run/repl-javap-app.check

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

test/files/run/repl-javap-app.scala

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

test/junit/scala/tools/nsc/backend/jvm/opt/CompactLocalVariablesTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class CompactLocalVariablesTest {
1717

1818
// recurse-unreachable-jumps is required for eliminating catch blocks, in the first dce round they
1919
// are still live.only after eliminating the empty handler the catch blocks become unreachable.
20-
val methodOptCompiler = newCompiler(extraArgs = "-target:jvm-1.6 -Ybackend:GenBCode -Yopt:unreachable-code,compact-locals")
21-
val noCompactVarsCompiler = newCompiler(extraArgs = "-target:jvm-1.6 -Ybackend:GenBCode -Yopt:unreachable-code")
20+
val methodOptCompiler = newCompiler(extraArgs = "-Ybackend:GenBCode -Yopt:unreachable-code,compact-locals")
21+
val noCompactVarsCompiler = newCompiler(extraArgs = "-Ybackend:GenBCode -Yopt:unreachable-code")
2222

2323
@Test
2424
def compactUnused(): Unit = {

test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOpts.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import ASMConverters._
1616
import scala.tools.testing.ClearAfterClass
1717

1818
object MethodLevelOpts extends ClearAfterClass.Clearable {
19-
var methodOptCompiler = newCompiler(extraArgs = "-target:jvm-1.6 -Ybackend:GenBCode -Yopt:l:method")
19+
var methodOptCompiler = newCompiler(extraArgs = "-Ybackend:GenBCode -Yopt:l:method")
2020
def clear(): Unit = { methodOptCompiler = null }
2121
}
2222

0 commit comments

Comments
 (0)