Skip to content

Commit

Permalink
Merge pull request scala#8686 from retronym/topic/jdknext-2.12
Browse files Browse the repository at this point in the history
Make junit/test pass on JDK 14
  • Loading branch information
retronym authored Feb 3, 2020
2 parents b8c33ad + 661d922 commit 855c2b6
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 22 deletions.
8 changes: 4 additions & 4 deletions test/junit/scala/lang/annotations/RunTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class RunTest extends RunTesting {
@Test
def annotationInfoNotErased(): Unit = {
val code =
"""import javax.annotation.Resource
"""import scala.reflect.ClassBearingAnnotation
|import scala.annotation.meta.getter
|class C {
| type Rg = Resource @getter
| @(Resource @getter)(`type` = classOf[Int]) def a = 0
| type Rg = ClassBearingAnnotation @getter
| @(ClassBearingAnnotation @getter)(`type` = classOf[Int]) def a = 0
| @Rg(`type` = classOf[Int]) def b = 0
|}
|val c = classOf[C]
|def typeArg(meth: String) = c.getDeclaredMethod(meth).getDeclaredAnnotation(classOf[Resource]).`type`
|def typeArg(meth: String) = c.getDeclaredMethod(meth).getDeclaredAnnotation(classOf[ClassBearingAnnotation]).`type`
|List("a", "b") map typeArg
|""".stripMargin

Expand Down
2 changes: 1 addition & 1 deletion test/junit/scala/lang/primitives/BoxUnboxTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BoxUnboxTest extends RunTesting {

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

val b = new Integer(1)
val b = Integer.valueOf(1)
val u = 1

assertEquals(1.toInt, u)
Expand Down
13 changes: 13 additions & 0 deletions test/junit/scala/reflect/ClassBearingAnnotation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package scala.reflect;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target({TYPE, FIELD, METHOD})
@Retention(RUNTIME)
public @interface ClassBearingAnnotation {
Class<?> type() default java.lang.Object.class;
}
26 changes: 13 additions & 13 deletions test/junit/scala/reflect/ClassOfTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,27 @@ class ClassOfTest extends RunTesting {
@Test
def t9702(): Unit = {
val code =
"""import javax.annotation.Resource
"""import scala.reflect.ClassBearingAnnotation
|import scala.reflect.ClassOfTest.VC
|class C {
| type aList[K] = List[K]
| type aVC = VC
| type aInt = Int
| type aInteger = Integer
| @Resource(`type` = classOf[List[Int]]) def a = 0
| @Resource(`type` = classOf[List[_]]) def b = 0
| @Resource(`type` = classOf[aList[_]]) def c = 0
| @Resource(`type` = classOf[Int]) def d = 0
| @Resource(`type` = classOf[aInt]) def e = 0
| @Resource(`type` = classOf[Integer]) def f = 0
| @Resource(`type` = classOf[aInteger]) def g = 0
| @Resource(`type` = classOf[VC]) def h = 0
| @Resource(`type` = classOf[aVC]) def i = 0
| @Resource(`type` = classOf[Array[Int]]) def j = 0
| @Resource(`type` = classOf[Array[List[_]]]) def k = 0
| @ClassBearingAnnotation(`type` = classOf[List[Int]]) def a = 0
| @ClassBearingAnnotation(`type` = classOf[List[_]]) def b = 0
| @ClassBearingAnnotation(`type` = classOf[aList[_]]) def c = 0
| @ClassBearingAnnotation(`type` = classOf[Int]) def d = 0
| @ClassBearingAnnotation(`type` = classOf[aInt]) def e = 0
| @ClassBearingAnnotation(`type` = classOf[Integer]) def f = 0
| @ClassBearingAnnotation(`type` = classOf[aInteger]) def g = 0
| @ClassBearingAnnotation(`type` = classOf[VC]) def h = 0
| @ClassBearingAnnotation(`type` = classOf[aVC]) def i = 0
| @ClassBearingAnnotation(`type` = classOf[Array[Int]]) def j = 0
| @ClassBearingAnnotation(`type` = classOf[Array[List[_]]]) def k = 0
|}
|val c = classOf[C]
|def typeArg(meth: String) = c.getDeclaredMethod(meth).getDeclaredAnnotation(classOf[Resource]).`type`
|def typeArg(meth: String) = c.getDeclaredMethod(meth).getDeclaredAnnotation(classOf[ClassBearingAnnotation]).`type`
|('a' to 'k').toList.map(_.toString).map(typeArg)
""".stripMargin

Expand Down
5 changes: 3 additions & 2 deletions test/junit/scala/tools/nsc/backend/jvm/opt/BoxUnboxTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.junit.runner.RunWith
import org.junit.runners.JUnit4

import scala.tools.asm.Opcodes._
import scala.tools.nsc.reporters.StoreReporter
import scala.tools.partest.ASMConverters._
import scala.tools.testing.BytecodeTesting
import scala.tools.testing.BytecodeTesting._
Expand Down Expand Up @@ -148,7 +149,7 @@ class BoxUnboxTest extends BytecodeTesting {
|}
""".stripMargin

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

assertNoInvoke(getMethod(c, "t1"))
assertNoInvoke(getMethod(c, "t2"))
Expand Down Expand Up @@ -310,7 +311,7 @@ class BoxUnboxTest extends BytecodeTesting {
| }
|}
""".stripMargin
val c = compileClass(code)
val c = compileClass(code, allowMessage = (info: StoreReporter#Info) => info.msg.contains("there was one deprecation warning"))
assertNoInvoke(getMethod(c, "t1"))
assertSameSummary(getMethod(c, "t2"), List(ICONST_1, ICONST_3, IADD, IRETURN))
assertSameSummary(getMethod(c, "t3"), List(ICONST_3, ICONST_4, IADD, IRETURN))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import scala.collection.JavaConverters._
import scala.tools.asm.Opcodes._
import scala.tools.asm.tree.ClassNode
import scala.tools.nsc.backend.jvm.AsmUtils._
import scala.tools.nsc.reporters.StoreReporter
import scala.tools.partest.ASMConverters._
import scala.tools.testing.BytecodeTesting
import scala.tools.testing.BytecodeTesting._
Expand Down Expand Up @@ -158,7 +159,7 @@ class MethodLevelOptsTest extends BytecodeTesting {
| }
|}
""".stripMargin
val c = compileClass(code)
val c = compileClass(code, allowMessage = (info: StoreReporter#Info) => info.msg.contains("there was one deprecation warning"))
assertSameCode(getMethod(c, "t"), List(
IntOp(BIPUSH, 23), IntOp(NEWARRAY, 5), Op(POP), VarOp(ILOAD, 1), VarOp(ILOAD, 2), Op(IADD), Op(IRETURN)))
}
Expand All @@ -173,7 +174,7 @@ class MethodLevelOptsTest extends BytecodeTesting {
| }
|}
""".stripMargin
val c = compileClass(code)
val c = compileClass(code, allowMessage = (info: StoreReporter#Info) => info.msg.contains("there was one deprecation warning"))
assertSameCode(getMethod(c, "t"), List(
TypeOp(NEW, "java/lang/Integer"), Ldc(LDC, "nono"), Invoke(INVOKESPECIAL, "java/lang/Integer", "<init>", "(Ljava/lang/String;)V", false),
VarOp(ILOAD, 1), VarOp(ILOAD, 2), Op(IADD), Op(IRETURN)))
Expand Down

0 comments on commit 855c2b6

Please sign in to comment.