Skip to content

Commit 855c2b6

Browse files
authored
Merge pull request scala#8686 from retronym/topic/jdknext-2.12
Make junit/test pass on JDK 14
2 parents b8c33ad + 661d922 commit 855c2b6

File tree

6 files changed

+37
-22
lines changed

6 files changed

+37
-22
lines changed

test/junit/scala/lang/annotations/RunTest.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ class RunTest extends RunTesting {
1414
@Test
1515
def annotationInfoNotErased(): Unit = {
1616
val code =
17-
"""import javax.annotation.Resource
17+
"""import scala.reflect.ClassBearingAnnotation
1818
|import scala.annotation.meta.getter
1919
|class C {
20-
| type Rg = Resource @getter
21-
| @(Resource @getter)(`type` = classOf[Int]) def a = 0
20+
| type Rg = ClassBearingAnnotation @getter
21+
| @(ClassBearingAnnotation @getter)(`type` = classOf[Int]) def a = 0
2222
| @Rg(`type` = classOf[Int]) def b = 0
2323
|}
2424
|val c = classOf[C]
25-
|def typeArg(meth: String) = c.getDeclaredMethod(meth).getDeclaredAnnotation(classOf[Resource]).`type`
25+
|def typeArg(meth: String) = c.getDeclaredMethod(meth).getDeclaredAnnotation(classOf[ClassBearingAnnotation]).`type`
2626
|List("a", "b") map typeArg
2727
|""".stripMargin
2828

test/junit/scala/lang/primitives/BoxUnboxTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class BoxUnboxTest extends RunTesting {
2121

2222
def genericNull[T] = null.asInstanceOf[T] // allowed, see scala/bug#4437, point 2
2323

24-
val b = new Integer(1)
24+
val b = Integer.valueOf(1)
2525
val u = 1
2626

2727
assertEquals(1.toInt, u)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package scala.reflect;
2+
3+
import java.lang.annotation.Retention;
4+
import java.lang.annotation.Target;
5+
6+
import static java.lang.annotation.ElementType.*;
7+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
8+
9+
@Target({TYPE, FIELD, METHOD})
10+
@Retention(RUNTIME)
11+
public @interface ClassBearingAnnotation {
12+
Class<?> type() default java.lang.Object.class;
13+
}

test/junit/scala/reflect/ClassOfTest.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,27 @@ class ClassOfTest extends RunTesting {
7171
@Test
7272
def t9702(): Unit = {
7373
val code =
74-
"""import javax.annotation.Resource
74+
"""import scala.reflect.ClassBearingAnnotation
7575
|import scala.reflect.ClassOfTest.VC
7676
|class C {
7777
| type aList[K] = List[K]
7878
| type aVC = VC
7979
| type aInt = Int
8080
| type aInteger = Integer
81-
| @Resource(`type` = classOf[List[Int]]) def a = 0
82-
| @Resource(`type` = classOf[List[_]]) def b = 0
83-
| @Resource(`type` = classOf[aList[_]]) def c = 0
84-
| @Resource(`type` = classOf[Int]) def d = 0
85-
| @Resource(`type` = classOf[aInt]) def e = 0
86-
| @Resource(`type` = classOf[Integer]) def f = 0
87-
| @Resource(`type` = classOf[aInteger]) def g = 0
88-
| @Resource(`type` = classOf[VC]) def h = 0
89-
| @Resource(`type` = classOf[aVC]) def i = 0
90-
| @Resource(`type` = classOf[Array[Int]]) def j = 0
91-
| @Resource(`type` = classOf[Array[List[_]]]) def k = 0
81+
| @ClassBearingAnnotation(`type` = classOf[List[Int]]) def a = 0
82+
| @ClassBearingAnnotation(`type` = classOf[List[_]]) def b = 0
83+
| @ClassBearingAnnotation(`type` = classOf[aList[_]]) def c = 0
84+
| @ClassBearingAnnotation(`type` = classOf[Int]) def d = 0
85+
| @ClassBearingAnnotation(`type` = classOf[aInt]) def e = 0
86+
| @ClassBearingAnnotation(`type` = classOf[Integer]) def f = 0
87+
| @ClassBearingAnnotation(`type` = classOf[aInteger]) def g = 0
88+
| @ClassBearingAnnotation(`type` = classOf[VC]) def h = 0
89+
| @ClassBearingAnnotation(`type` = classOf[aVC]) def i = 0
90+
| @ClassBearingAnnotation(`type` = classOf[Array[Int]]) def j = 0
91+
| @ClassBearingAnnotation(`type` = classOf[Array[List[_]]]) def k = 0
9292
|}
9393
|val c = classOf[C]
94-
|def typeArg(meth: String) = c.getDeclaredMethod(meth).getDeclaredAnnotation(classOf[Resource]).`type`
94+
|def typeArg(meth: String) = c.getDeclaredMethod(meth).getDeclaredAnnotation(classOf[ClassBearingAnnotation]).`type`
9595
|('a' to 'k').toList.map(_.toString).map(typeArg)
9696
""".stripMargin
9797

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.junit.runner.RunWith
88
import org.junit.runners.JUnit4
99

1010
import scala.tools.asm.Opcodes._
11+
import scala.tools.nsc.reporters.StoreReporter
1112
import scala.tools.partest.ASMConverters._
1213
import scala.tools.testing.BytecodeTesting
1314
import scala.tools.testing.BytecodeTesting._
@@ -148,7 +149,7 @@ class BoxUnboxTest extends BytecodeTesting {
148149
|}
149150
""".stripMargin
150151

151-
val c = compileClass(code)
152+
val c = compileClass(code, allowMessage = (info: StoreReporter#Info) => info.msg.contains("there were two deprecation warnings"))
152153

153154
assertNoInvoke(getMethod(c, "t1"))
154155
assertNoInvoke(getMethod(c, "t2"))
@@ -310,7 +311,7 @@ class BoxUnboxTest extends BytecodeTesting {
310311
| }
311312
|}
312313
""".stripMargin
313-
val c = compileClass(code)
314+
val c = compileClass(code, allowMessage = (info: StoreReporter#Info) => info.msg.contains("there was one deprecation warning"))
314315
assertNoInvoke(getMethod(c, "t1"))
315316
assertSameSummary(getMethod(c, "t2"), List(ICONST_1, ICONST_3, IADD, IRETURN))
316317
assertSameSummary(getMethod(c, "t3"), List(ICONST_3, ICONST_4, IADD, IRETURN))

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import scala.collection.JavaConverters._
1111
import scala.tools.asm.Opcodes._
1212
import scala.tools.asm.tree.ClassNode
1313
import scala.tools.nsc.backend.jvm.AsmUtils._
14+
import scala.tools.nsc.reporters.StoreReporter
1415
import scala.tools.partest.ASMConverters._
1516
import scala.tools.testing.BytecodeTesting
1617
import scala.tools.testing.BytecodeTesting._
@@ -158,7 +159,7 @@ class MethodLevelOptsTest extends BytecodeTesting {
158159
| }
159160
|}
160161
""".stripMargin
161-
val c = compileClass(code)
162+
val c = compileClass(code, allowMessage = (info: StoreReporter#Info) => info.msg.contains("there was one deprecation warning"))
162163
assertSameCode(getMethod(c, "t"), List(
163164
IntOp(BIPUSH, 23), IntOp(NEWARRAY, 5), Op(POP), VarOp(ILOAD, 1), VarOp(ILOAD, 2), Op(IADD), Op(IRETURN)))
164165
}
@@ -173,7 +174,7 @@ class MethodLevelOptsTest extends BytecodeTesting {
173174
| }
174175
|}
175176
""".stripMargin
176-
val c = compileClass(code)
177+
val c = compileClass(code, allowMessage = (info: StoreReporter#Info) => info.msg.contains("there was one deprecation warning"))
177178
assertSameCode(getMethod(c, "t"), List(
178179
TypeOp(NEW, "java/lang/Integer"), Ldc(LDC, "nono"), Invoke(INVOKESPECIAL, "java/lang/Integer", "<init>", "(Ljava/lang/String;)V", false),
179180
VarOp(ILOAD, 1), VarOp(ILOAD, 2), Op(IADD), Op(IRETURN)))

0 commit comments

Comments
 (0)