Allow clinits that create a singleton instance to be postponed
Bug: 142762129
Change-Id: Iaa472dcf1b52dad304488ed3855fbceb16f20f9d
diff --git a/src/test/examples/classmerging/SuperCallRewritingTest.java b/src/test/examples/classmerging/SuperCallRewritingTest.java
index 7a3d45c..6f59419 100644
--- a/src/test/examples/classmerging/SuperCallRewritingTest.java
+++ b/src/test/examples/classmerging/SuperCallRewritingTest.java
@@ -7,6 +7,17 @@
public class SuperCallRewritingTest {
public static void main(String[] args) {
System.out.println("Calling referencedMethod on SubClassThatReferencesSuperMethod");
- System.out.println(new SubClassThatReferencesSuperMethod().referencedMethod());
+ SubClassThatReferencesSuperMethod obj = new SubClassThatReferencesSuperMethod();
+ System.out.println(obj.referencedMethod());
+
+ // Ensure that the instantiations are not dead code eliminated.
+ escape(obj);
+ }
+
+ @NeverInline
+ static void escape(Object o) {
+ if (System.currentTimeMillis() < 0) {
+ System.out.println(o);
+ }
}
}