From 7892bbf38fb77e7d2f1361515f14280b3a513c96 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 20 May 2014 12:31:00 +0200 Subject: SI-8601 Test that static LOAD_FIELD is not eliminated This test fails under 2.11.0, and works now that DCE treats static loads as useful instructions. --- test/files/run/t8601e.flags | 1 + test/files/run/t8601e/StaticInit.class | Bin 0 -> 417 bytes test/files/run/t8601e/StaticInit.java | 8 ++++++++ test/files/run/t8601e/Test.scala | 12 ++++++++++++ 4 files changed, 21 insertions(+) create mode 100644 test/files/run/t8601e.flags create mode 100644 test/files/run/t8601e/StaticInit.class create mode 100644 test/files/run/t8601e/StaticInit.java create mode 100644 test/files/run/t8601e/Test.scala (limited to 'test/files/run') 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 Binary files /dev/null and b/test/files/run/t8601e/StaticInit.class 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. was not run!") + } catch { + case t: ExceptionInInitializerError => + } +} -- cgit v1.2.3