summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2014-05-22 08:38:03 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2014-05-22 09:37:22 +0200
commite4785929497c25db2416e599878d654f00dfc46f (patch)
tree1868a4446e6e33bd9325c4ee0532a624bf694297 /test/files/run
parentbdca8cf69fe9b8153bf4e25d55dc786ba6550a1e (diff)
parent6c99037952766c7075b48171fe65a6077cf6b9f5 (diff)
downloadscala-e4785929497c25db2416e599878d654f00dfc46f.tar.gz
scala-e4785929497c25db2416e599878d654f00dfc46f.tar.bz2
scala-e4785929497c25db2416e599878d654f00dfc46f.zip
Merge branch '2.11.x' into 2.12.x
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/classfile-format-51.scala14
-rw-r--r--test/files/run/large_class.check3
-rw-r--r--test/files/run/large_class.scala27
-rw-r--r--test/files/run/t8574.scala27
-rw-r--r--test/files/run/t8601-closure-elim.flags1
-rw-r--r--test/files/run/t8601-closure-elim.scala26
-rw-r--r--test/files/run/t8601.flags1
-rw-r--r--test/files/run/t8601.scala15
-rw-r--r--test/files/run/t8601b.flags1
-rw-r--r--test/files/run/t8601b.scala14
-rw-r--r--test/files/run/t8601c.flags1
-rw-r--r--test/files/run/t8601c.scala12
-rw-r--r--test/files/run/t8601d.flags1
-rw-r--r--test/files/run/t8601d.scala8
-rw-r--r--test/files/run/t8601e.flags1
-rw-r--r--test/files/run/t8601e/StaticInit.classbin0 -> 417 bytes
-rw-r--r--test/files/run/t8601e/StaticInit.java8
-rw-r--r--test/files/run/t8601e/Test.scala12
18 files changed, 165 insertions, 7 deletions
diff --git a/test/files/run/classfile-format-51.scala b/test/files/run/classfile-format-51.scala
index f92382d89b..24b1ee8397 100644
--- a/test/files/run/classfile-format-51.scala
+++ b/test/files/run/classfile-format-51.scala
@@ -32,7 +32,7 @@ object Test extends DirectTest {
val constructor = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null)
constructor.visitCode()
constructor.visitVarInsn(ALOAD, 0)
- constructor.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V")
+ constructor.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false)
constructor.visitInsn(RETURN)
constructor.visitMaxs(1, 1)
constructor.visitEnd()
@@ -47,19 +47,19 @@ object Test extends DirectTest {
val bootstrap = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, bootstrapMethodName, bootStrapMethodType, null, null)
bootstrap.visitCode()
// val lookup = MethodHandles.lookup();
- bootstrap.visitMethodInsn(INVOKESTATIC, "java/lang/invoke/MethodHandles", "lookup", "()Ljava/lang/invoke/MethodHandles$Lookup;")
+ bootstrap.visitMethodInsn(INVOKESTATIC, "java/lang/invoke/MethodHandles", "lookup", "()Ljava/lang/invoke/MethodHandles$Lookup;", false)
bootstrap.visitVarInsn(ASTORE, 3) // lookup
// val clazz = lookup.lookupClass();
bootstrap.visitVarInsn(ALOAD, 3) // lookup
- bootstrap.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandles$Lookup", "lookupClass", "()Ljava/lang/Class;")
+ bootstrap.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandles$Lookup", "lookupClass", "()Ljava/lang/Class;", false)
bootstrap.visitVarInsn(ASTORE, 4) // clazz
// val methodType = MethodType.fromMethodDescriptorString("()Ljava/lang/String, clazz.getClassLoader()")
bootstrap.visitLdcInsn("()Ljava/lang/String;")
bootstrap.visitVarInsn(ALOAD, 4) // CLAZZ
- bootstrap.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Class", "getClassLoader", "()Ljava/lang/ClassLoader;")
- bootstrap.visitMethodInsn(INVOKESTATIC, "java/lang/invoke/MethodType", "fromMethodDescriptorString", "(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/invoke/MethodType;")
+ bootstrap.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Class", "getClassLoader", "()Ljava/lang/ClassLoader;", false)
+ bootstrap.visitMethodInsn(INVOKESTATIC, "java/lang/invoke/MethodType", "fromMethodDescriptorString", "(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/invoke/MethodType;", false)
bootstrap.visitVarInsn(ASTORE, 5) // methodType
// val methodHandle = lookup.findStatic(thisClass, "target", methodType)
@@ -67,14 +67,14 @@ object Test extends DirectTest {
bootstrap.visitVarInsn(ALOAD, 4) // clazz
bootstrap.visitLdcInsn("target")
bootstrap.visitVarInsn(ALOAD, 5) // methodType
- bootstrap.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandles$Lookup", "findStatic", "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/MethodHandle;")
+ bootstrap.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandles$Lookup", "findStatic", "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/MethodHandle;", false)
bootstrap.visitVarInsn(ASTORE, 6) // methodHandle
// new ConstantCallSite(methodHandle)
bootstrap.visitTypeInsn(NEW, "java/lang/invoke/ConstantCallSite")
bootstrap.visitInsn(DUP)
bootstrap.visitVarInsn(ALOAD, 6) // methodHandle
- bootstrap.visitMethodInsn(INVOKESPECIAL, "java/lang/invoke/ConstantCallSite", "<init>", "(Ljava/lang/invoke/MethodHandle;)V")
+ bootstrap.visitMethodInsn(INVOKESPECIAL, "java/lang/invoke/ConstantCallSite", "<init>", "(Ljava/lang/invoke/MethodHandle;)V", false)
bootstrap.visitInsn(ARETURN)
bootstrap.visitMaxs(4,7)
bootstrap.visitEnd()
diff --git a/test/files/run/large_class.check b/test/files/run/large_class.check
new file mode 100644
index 0000000000..0585c267ac
--- /dev/null
+++ b/test/files/run/large_class.check
@@ -0,0 +1,3 @@
+newSource1.scala:1: error: Could not write class BigEnoughToFail because it exceeds JVM code size limits. Class file too large!
+class BigEnoughToFail {
+ ^
diff --git a/test/files/run/large_class.scala b/test/files/run/large_class.scala
new file mode 100644
index 0000000000..aa486ef8f7
--- /dev/null
+++ b/test/files/run/large_class.scala
@@ -0,0 +1,27 @@
+import scala.tools.partest._
+import java.io.{Console => _, _}
+
+// a cold run of partest takes about 15s for this test on my laptop
+object Test extends DirectTest {
+ override def extraSettings: String = "-usejavacp -d " + testOutput.path
+
+ def s(n: Int) = "\""+n+"\""
+
+ override def code
+ = s"""
+ |class BigEnoughToFail {
+ | def m(a: String, b: String, c: String, d: String, e: String, f: String) = null
+ | ${(1 to 5500) map (n => "def f"+n+" = m("+ s(n+10000)+","+
+ s(n+20000)+","+
+ s(n+30000)+","+
+ s(n+40000)+","+
+ s(n+50000)+","+
+ s(n+60000)+")") mkString ";"}
+ |}""".stripMargin.trim
+
+ override def show(): Unit = {
+ Console.withErr(System.out) {
+ compile()
+ }
+ }
+}
diff --git a/test/files/run/t8574.scala b/test/files/run/t8574.scala
new file mode 100644
index 0000000000..8c23ada482
--- /dev/null
+++ b/test/files/run/t8574.scala
@@ -0,0 +1,27 @@
+import annotation._
+
+@SerialVersionUID(42) @strictfp class Foo[@specialized(Int) T] extends Serializable {
+ def foo(t: T) = t
+}
+
+object Test extends App {
+ def checkUID(cls: Class[_], expected: Long) = {
+ val actual = java.io.ObjectStreamClass.lookup(cls).getSerialVersionUID
+ assert(actual == expected, s"$actual != expected for ${cls}")
+ }
+ def checkStrictFp(cls: Class[_]) = {
+ import java.lang.reflect._
+ for (m <- cls.getDeclaredMethods) {
+ val isStrict = Modifier.isStrict(m.getModifiers)
+ assert(isStrict, cls)
+ }
+ }
+ def check(x: AnyRef) {
+ checkUID(x.getClass, 42)
+ checkStrictFp(x.getClass)
+ }
+
+ check(new Foo[String])
+ check(new Foo[Int])
+}
+
diff --git a/test/files/run/t8601-closure-elim.flags b/test/files/run/t8601-closure-elim.flags
new file mode 100644
index 0000000000..49d036a887
--- /dev/null
+++ b/test/files/run/t8601-closure-elim.flags
@@ -0,0 +1 @@
+-optimize
diff --git a/test/files/run/t8601-closure-elim.scala b/test/files/run/t8601-closure-elim.scala
new file mode 100644
index 0000000000..2c5b03af77
--- /dev/null
+++ b/test/files/run/t8601-closure-elim.scala
@@ -0,0 +1,26 @@
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm
+import scala.tools.asm.util._
+import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ val nullChecks = Set(asm.Opcodes.NEW)
+
+ def show: Unit = {
+ def test(methodName: String) {
+ val classNode = loadClassNode("Foo")
+ val methodNode = getMethod(classNode, "b")
+ val ops = methodNode.instructions.iterator.asScala.map(_.getOpcode).toList
+ assert(!ops.contains(asm.Opcodes.NEW), ops)// should be allocation free if the closure is eliminiated
+ }
+ test("b")
+ }
+}
+
+class Foo {
+ @inline final def a(x: Int => Int) = x(1)
+ final def b {
+ val delta = 0
+ a(x => delta + 1)
+ }
+}
diff --git a/test/files/run/t8601.flags b/test/files/run/t8601.flags
new file mode 100644
index 0000000000..1182725e86
--- /dev/null
+++ b/test/files/run/t8601.flags
@@ -0,0 +1 @@
+-optimize \ No newline at end of file
diff --git a/test/files/run/t8601.scala b/test/files/run/t8601.scala
new file mode 100644
index 0000000000..e1afc23cc4
--- /dev/null
+++ b/test/files/run/t8601.scala
@@ -0,0 +1,15 @@
+object Test {
+ def idiv(x: Int): Unit = x / 0
+ def ldiv(x: Long): Unit = x / 0
+ def irem(x: Int): Unit = x % 0
+ def lrem(x: Long): Unit = x % 0
+
+ def check(x: => Any) = try { x; sys.error("failed to throw divide by zero!") } catch { case _: ArithmeticException => }
+
+ def main(args: Array[String]) {
+ check(idiv(1))
+ check(ldiv(1L))
+ check(irem(1))
+ check(lrem(1L))
+ }
+}
diff --git a/test/files/run/t8601b.flags b/test/files/run/t8601b.flags
new file mode 100644
index 0000000000..1182725e86
--- /dev/null
+++ b/test/files/run/t8601b.flags
@@ -0,0 +1 @@
+-optimize \ No newline at end of file
diff --git a/test/files/run/t8601b.scala b/test/files/run/t8601b.scala
new file mode 100644
index 0000000000..9c37ce33d6
--- /dev/null
+++ b/test/files/run/t8601b.scala
@@ -0,0 +1,14 @@
+object Test {
+ def len(x: Array[String]): Unit = x.length
+ def load(x: Array[String]): Unit = x(0)
+ def newarray(i: Int): Unit = new Array[Int](i)
+
+ def check(x: => Any) = try { x; sys.error("failed to throw NPE!") } catch { case _: NullPointerException => }
+ def checkNegSize(x: => Any) = try { x; sys.error("failed to throw NegativeArraySizeException!") } catch { case _: NegativeArraySizeException => }
+
+ def main(args: Array[String]) {
+ check(len(null)) // bug: did not NPE
+ check(load(null))
+ checkNegSize(newarray(-1))
+ }
+}
diff --git a/test/files/run/t8601c.flags b/test/files/run/t8601c.flags
new file mode 100644
index 0000000000..1182725e86
--- /dev/null
+++ b/test/files/run/t8601c.flags
@@ -0,0 +1 @@
+-optimize \ No newline at end of file
diff --git a/test/files/run/t8601c.scala b/test/files/run/t8601c.scala
new file mode 100644
index 0000000000..c487d6825e
--- /dev/null
+++ b/test/files/run/t8601c.scala
@@ -0,0 +1,12 @@
+object Test {
+ def loadField(x: scala.runtime.IntRef): Unit = x.elem
+ def storeField(x: scala.runtime.IntRef): Unit = x.elem = 42
+
+ def check(x: => Any) = try { x; sys.error("failed to throw NPE!") } catch { case _: NullPointerException => }
+
+ def main(args: Array[String]) {
+ check(loadField(null)) // bug: did not NPE under -Ydead-code
+ check(storeField(null))
+
+ }
+}
diff --git a/test/files/run/t8601d.flags b/test/files/run/t8601d.flags
new file mode 100644
index 0000000000..1182725e86
--- /dev/null
+++ b/test/files/run/t8601d.flags
@@ -0,0 +1 @@
+-optimize \ No newline at end of file
diff --git a/test/files/run/t8601d.scala b/test/files/run/t8601d.scala
new file mode 100644
index 0000000000..ac89963d67
--- /dev/null
+++ b/test/files/run/t8601d.scala
@@ -0,0 +1,8 @@
+object Test {
+ def monitor(x: AnyRef): Unit = {x.synchronized(()); ()}
+ def check(x: => Any) = try { x; sys.error("failed to throw NPE") } catch { case _: NullPointerException => }
+
+ def main(args: Array[String]) {
+ check(monitor(null))
+ }
+}
diff --git a/test/files/run/t8601e.flags b/test/files/run/t8601e.flags
new file mode 100644
index 0000000000..49d036a887
--- /dev/null
+++ b/test/files/run/t8601e.flags
@@ -0,0 +1 @@
+-optimize
diff --git a/test/files/run/t8601e/StaticInit.class b/test/files/run/t8601e/StaticInit.class
new file mode 100644
index 0000000000..99a0e2a643
--- /dev/null
+++ b/test/files/run/t8601e/StaticInit.class
Binary files differ
diff --git a/test/files/run/t8601e/StaticInit.java b/test/files/run/t8601e/StaticInit.java
new file mode 100644
index 0000000000..7543ed98b8
--- /dev/null
+++ b/test/files/run/t8601e/StaticInit.java
@@ -0,0 +1,8 @@
+public class StaticInit {
+ static {
+ if ("".isEmpty()) {
+ throw new RuntimeException();
+ }
+ }
+ public static int fld = 42;
+}
diff --git a/test/files/run/t8601e/Test.scala b/test/files/run/t8601e/Test.scala
new file mode 100644
index 0000000000..838114f6a7
--- /dev/null
+++ b/test/files/run/t8601e/Test.scala
@@ -0,0 +1,12 @@
+class C {
+ def foo: Unit = {StaticInit.fld}
+}
+
+object Test extends App {
+ try {
+ new C().foo
+ sys.error("StaticInit.<clinit> was not run!")
+ } catch {
+ case t: ExceptionInInitializerError =>
+ }
+}