Add java8 debug tests Adds tests for debugging lambda and default methods. The test should be written to support desugaring. Bug: 37731140 Bug: 38218137 Change-Id: I2e79346c722262331e560786a8999733f7b596b6
diff --git a/src/test/debugTestResourcesJava8/DebugDefaultMethod.java b/src/test/debugTestResourcesJava8/DebugDefaultMethod.java new file mode 100644 index 0000000..db216b3 --- /dev/null +++ b/src/test/debugTestResourcesJava8/DebugDefaultMethod.java
@@ -0,0 +1,35 @@ +// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +public class DebugDefaultMethod { + + interface I { + default void doSomething(String msg) { + String name = getClass().getName(); + System.out.println(name + ": " + msg); + } + } + + static class DefaultImpl implements I { + } + + static class OverrideImpl implements I { + + @Override + public void doSomething(String msg) { + String newMsg = "OVERRIDE" + msg; + System.out.println(newMsg); + } + } + + private static void testDefaultMethod(I i) { + i.doSomething("Test"); + } + + public static void main(String[] args) { + testDefaultMethod(new DefaultImpl()); + testDefaultMethod(new OverrideImpl()); + } + +}
diff --git a/src/test/debugTestResourcesJava8/DebugLambda.java b/src/test/debugTestResourcesJava8/DebugLambda.java new file mode 100644 index 0000000..c3b8695 --- /dev/null +++ b/src/test/debugTestResourcesJava8/DebugLambda.java
@@ -0,0 +1,23 @@ +// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +public class DebugLambda { + + interface I { + int getInt(); + } + + private static void printInt(I i) { + System.out.println(i.getInt()); + } + + public static void testLambda(int i, int j) { + printInt(() -> i + j); + } + + public static void main(String[] args) { + DebugLambda.testLambda(5, 10); + } + +}