diff options
Diffstat (limited to 'test')
31 files changed, 388 insertions, 853 deletions
diff --git a/test/048-reflect-v8/expected.txt b/test/048-reflect-v8/expected.txt index 3109eccda6..2d0b4ccb6b 100644 --- a/test/048-reflect-v8/expected.txt +++ b/test/048-reflect-v8/expected.txt @@ -1,95 +1,4 @@ -============================== -Are These Methods Default: -============================== -IsDefaultTest$DefaultInterface is default = yes -IsDefaultTest$RegularInterface is default = no -IsDefaultTest$ImplementsWithDefault is default = yes -IsDefaultTest$ImplementsWithRegular is default = no -============================== -Class annotations by type: -============================== -Annotations by type, defined by class SingleUser with annotation Calendar: @Calendar(dayOfMonth=unspecified_month, dayOfWeek=single, hour=23) -Annotations by type, defined by class SingleUser with annotation Calendars: <empty> -Annotations by type, defined by class User with annotation Calendar: @Calendar(dayOfMonth=last, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=unspecified_month, dayOfWeek=Fri, hour=23) -Annotations by type, defined by class User with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=last, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=unspecified_month, dayOfWeek=Fri, hour=23)]) -Annotations by type, defined by class User2 with annotation Calendar: @Calendar(dayOfMonth=z, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=x, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=y, dayOfWeek=unspecified_week, hour=6) -Annotations by type, defined by class User2 with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=z, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=x, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=y, dayOfWeek=unspecified_week, hour=6)]) -Annotations by type, defined by class UserComplex with annotation Calendar: @Calendar(dayOfMonth=afirst, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=zsecond, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=athird, dayOfWeek=unspecified_week, hour=23) -Annotations by type, defined by class UserComplex with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=zsecond, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=athird, dayOfWeek=unspecified_week, hour=23)]) -Annotations by type, defined by class UserSub with annotation Calendar: @Calendar(dayOfMonth=last, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=unspecified_month, dayOfWeek=Fri, hour=23) -Annotations by type, defined by class UserSub with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=last, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=unspecified_month, dayOfWeek=Fri, hour=23)]) -Annotations by type, defined by class UserSub2 with annotation Calendar: @Calendar(dayOfMonth=sub2, dayOfWeek=unspecified_week, hour=6) -Annotations by type, defined by class UserSub2 with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=last, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=unspecified_month, dayOfWeek=Fri, hour=23)]) ------------------------------ ------------------------------ -============================== -Class declared annotation: -============================== -Declared annotations by class class SingleUser, annotation interface Calendar: @Calendar(dayOfMonth=unspecified_month, dayOfWeek=single, hour=23) -Declared annotations by class class SingleUser, annotation interface Calendars: <null> -Declared annotations by class class User, annotation interface Calendar: <null> -Declared annotations by class class User, annotation interface Calendars: @Calendars(value=[@Calendar(dayOfMonth=last, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=unspecified_month, dayOfWeek=Fri, hour=23)]) -Declared annotations by class class UserComplex, annotation interface Calendar: @Calendar(dayOfMonth=afirst, dayOfWeek=unspecified_week, hour=6) -Declared annotations by class class UserComplex, annotation interface Calendars: @Calendars(value=[@Calendar(dayOfMonth=zsecond, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=athird, dayOfWeek=unspecified_week, hour=23)]) -Declared annotations by class class UserSub, annotation interface Calendar: <null> -Declared annotations by class class UserSub, annotation interface Calendars: <null> -Declared annotations by class class UserSub2, annotation interface Calendar: @Calendar(dayOfMonth=sub2, dayOfWeek=unspecified_week, hour=6) -Declared annotations by class class UserSub2, annotation interface Calendars: <null> ------------------------------ ------------------------------ -============================== -Declared class annotations by type: -============================== -Declared annnotations by type, defined by class SingleUser with annotation Calendar: @Calendar(dayOfMonth=unspecified_month, dayOfWeek=single, hour=23) -Declared annnotations by type, defined by class SingleUser with annotation Calendars: <empty> -Declared annnotations by type, defined by class User with annotation Calendar: @Calendar(dayOfMonth=last, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=unspecified_month, dayOfWeek=Fri, hour=23) -Declared annnotations by type, defined by class User with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=last, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=unspecified_month, dayOfWeek=Fri, hour=23)]) -Declared annnotations by type, defined by class User2 with annotation Calendar: @Calendar(dayOfMonth=z, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=x, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=y, dayOfWeek=unspecified_week, hour=6) -Declared annnotations by type, defined by class User2 with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=z, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=x, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=y, dayOfWeek=unspecified_week, hour=6)]) -Declared annnotations by type, defined by class UserComplex with annotation Calendar: @Calendar(dayOfMonth=afirst, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=zsecond, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=athird, dayOfWeek=unspecified_week, hour=23) -Declared annnotations by type, defined by class UserComplex with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=zsecond, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=athird, dayOfWeek=unspecified_week, hour=23)]) -Declared annnotations by type, defined by class UserSub with annotation Calendar: <empty> -Declared annnotations by type, defined by class UserSub with annotation Calendars: <empty> -Declared annnotations by type, defined by class UserSub2 with annotation Calendar: @Calendar(dayOfMonth=sub2, dayOfWeek=unspecified_week, hour=6) -Declared annnotations by type, defined by class UserSub2 with annotation Calendars: <empty> ------------------------------ ------------------------------ -============================== -Method annotations by type: -============================== -Annotations by type, defined by method singleUser with annotation Calendar: @Calendar(dayOfMonth=unspecified_month, dayOfWeek=single, hour=23) -Annotations by type, defined by method singleUser with annotation Calendars: <empty> -Annotations by type, defined by method user with annotation Calendar: @Calendar(dayOfMonth=last, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=unspecified_month, dayOfWeek=Fri, hour=23) -Annotations by type, defined by method user with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=last, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=unspecified_month, dayOfWeek=Fri, hour=23)]) -Annotations by type, defined by method user2 with annotation Calendar: @Calendar(dayOfMonth=z, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=x, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=y, dayOfWeek=unspecified_week, hour=6) -Annotations by type, defined by method user2 with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=z, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=x, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=y, dayOfWeek=unspecified_week, hour=6)]) -Annotations by type, defined by method userComplex with annotation Calendar: @Calendar(dayOfMonth=afirst, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=zsecond, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=athird, dayOfWeek=unspecified_week, hour=23) -Annotations by type, defined by method userComplex with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=zsecond, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=athird, dayOfWeek=unspecified_week, hour=23)]) ------------------------------ ------------------------------ -============================== -Declared method annotations: -============================== -Annotations declared by method singleUser with annotation Calendar: @Calendar(dayOfMonth=unspecified_month, dayOfWeek=single, hour=23) -Annotations declared by method singleUser with annotation Calendars: <null> -Annotations declared by method user with annotation Calendar: <null> -Annotations declared by method user with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=last, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=unspecified_month, dayOfWeek=Fri, hour=23)]) -Annotations declared by method user2 with annotation Calendar: <null> -Annotations declared by method user2 with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=z, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=x, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=y, dayOfWeek=unspecified_week, hour=6)]) -Annotations declared by method userComplex with annotation Calendar: @Calendar(dayOfMonth=afirst, dayOfWeek=unspecified_week, hour=6) -Annotations declared by method userComplex with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=zsecond, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=athird, dayOfWeek=unspecified_week, hour=23)]) ------------------------------ ------------------------------ -============================== -Declared method annotations by type: -============================== -Annotations by type, defined by method singleUser with annotation Calendar: @Calendar(dayOfMonth=unspecified_month, dayOfWeek=single, hour=23) -Annotations by type, defined by method singleUser with annotation Calendars: <empty> -Annotations by type, defined by method user with annotation Calendar: @Calendar(dayOfMonth=last, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=unspecified_month, dayOfWeek=Fri, hour=23) -Annotations by type, defined by method user with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=last, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=unspecified_month, dayOfWeek=Fri, hour=23)]) -Annotations by type, defined by method user2 with annotation Calendar: @Calendar(dayOfMonth=z, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=x, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=y, dayOfWeek=unspecified_week, hour=6) -Annotations by type, defined by method user2 with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=z, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=x, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=y, dayOfWeek=unspecified_week, hour=6)]) -Annotations by type, defined by method userComplex with annotation Calendar: @Calendar(dayOfMonth=afirst, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=zsecond, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=athird, dayOfWeek=unspecified_week, hour=23) -Annotations by type, defined by method userComplex with annotation Calendars: @Calendars(value=[@Calendar(dayOfMonth=zsecond, dayOfWeek=unspecified_week, hour=6), @Calendar(dayOfMonth=athird, dayOfWeek=unspecified_week, hour=23)]) ------------------------------ ------------------------------ +Main$DefaultInterface is default = yes +Main$RegularInterface is default = no +Main$ImplementsWithDefault is default = yes +Main$ImplementsWithRegular is default = no diff --git a/test/048-reflect-v8/src/AnnotationTest.java b/test/048-reflect-v8/src/AnnotationTest.java deleted file mode 100644 index 75e684557c..0000000000 --- a/test/048-reflect-v8/src/AnnotationTest.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -public class AnnotationTest extends AnnotationTestHelpers { - public static void testAnnotationsByType() { - System.out.println("=============================="); - System.out.println("Class annotations by type:"); - System.out.println("=============================="); - - // Print associated annotations: - // * A is directly present or repeatably present on an element E; - // * No annotation of A is directly/repeatably present on an element - // AND E is a class AND A's type is inheritable, AND A is associated with its superclass. - // (Looks through subtypes recursively only if there's 0 result at each level, - // and the annotation is @Inheritable). - printAnnotationsByType(Calendar.class, SingleUser.class); - printAnnotationsByType(Calendars.class, SingleUser.class); - - printAnnotationsByType(Calendar.class, User.class); - printAnnotationsByType(Calendars.class, User.class); - - printAnnotationsByType(Calendar.class, User2.class); // Enforce ordering 'z,x,y' - printAnnotationsByType(Calendars.class, User2.class); - - // NOTE: - // Order of outer-most annotations Calendars[C,C],S vs C,Calendars[C,C] is unspecified. - // In particular it's the order of #getDeclaredAnnotations which is completely unmentioned. - // The only requirement for #getAnnotationsByType is to have same ordering as - // #getDeclaredAnnotations. - // (Calendars[] itself has to maintain value() order). - printAnnotationsByType(Calendar.class, UserComplex.class); // Cs(C,C),C collapses into C,C,C. - printAnnotationsByType(Calendars.class, UserComplex.class); - - printAnnotationsByType(Calendar.class, UserSub.class); - printAnnotationsByType(Calendars.class, UserSub.class); - - printAnnotationsByType(Calendar.class, UserSub2.class); - // The directly present "Calendar" annotation masks all the repeatably present - // "Calendar" annotations coming from User. - printAnnotationsByType(Calendars.class, UserSub2.class); - // Edge case: UserSub2 doesn't directly have a Calendars annotation, - // so it doesn't mask the "User" Calendars annotation. - - System.out.println("-----------------------------"); - System.out.println("-----------------------------"); - - } - - public static void testDeclaredAnnotation() { - System.out.println("=============================="); - System.out.println("Class declared annotation:"); - System.out.println("=============================="); - - // Print directly present annotations: - // - // The element E has an annotation_item for it (accessible through an - // annotations_directory_item) corresponding to an annotation A, - // and A's type_idx must match that on the encoded_annotation (from the annotation_item). - // (Does not look through the subtypes recursively) - printDeclaredAnnotation(SingleUser.class, Calendar.class); - printDeclaredAnnotation(SingleUser.class, Calendars.class); - - printDeclaredAnnotation(User.class, Calendar.class); - printDeclaredAnnotation(User.class, Calendars.class); - - printDeclaredAnnotation(UserComplex.class, Calendar.class); - printDeclaredAnnotation(UserComplex.class, Calendars.class); - - printDeclaredAnnotation(UserSub.class, Calendar.class); - printDeclaredAnnotation(UserSub.class, Calendars.class); - - printDeclaredAnnotation(UserSub2.class, Calendar.class); - printDeclaredAnnotation(UserSub2.class, Calendars.class); - - System.out.println("-----------------------------"); - System.out.println("-----------------------------"); - } - - public static void testDeclaredAnnotationsByType() { - System.out.println("=============================="); - System.out.println("Declared class annotations by type:"); - System.out.println("=============================="); - - // A is directly present or repeatably present on an element E; - // -- (does not do any recursion for classes regardless of @Inherited) - printDeclaredAnnotationsByType(Calendar.class, SingleUser.class); - printDeclaredAnnotationsByType(Calendars.class, SingleUser.class); - - printDeclaredAnnotationsByType(Calendar.class, User.class); - printDeclaredAnnotationsByType(Calendars.class, User.class); - - printDeclaredAnnotationsByType(Calendar.class, User2.class); // Enforce ordering 'z,x,y' - printDeclaredAnnotationsByType(Calendars.class, User2.class); - - printDeclaredAnnotationsByType(Calendar.class, UserComplex.class); - printDeclaredAnnotationsByType(Calendars.class, UserComplex.class); - - printDeclaredAnnotationsByType(Calendar.class, UserSub.class); - printDeclaredAnnotationsByType(Calendars.class, UserSub.class); - - printDeclaredAnnotationsByType(Calendar.class, UserSub2.class); - // The directly present "Calendar" annotation masks all the repeatably present "Calendar" - // annotations coming from User. - printDeclaredAnnotationsByType(Calendars.class, UserSub2.class); - // Edge case: UserSub2 doesn't directly have a Calendars annotation, - // so it doesn't mask the "User" Calendars annotation. - - System.out.println("-----------------------------"); - System.out.println("-----------------------------"); - } - - // Print the annotation "annotationClass" that is associated with an element denoted by - // "annotationUseClass." - private static <A extends Annotation> void printAnnotationsByType(Class<A> annotationClass, - Class<?> annotationUseClass) { - A[] annotationsByType = annotationUseClass.getAnnotationsByType(annotationClass); - - String msg = "Annotations by type, defined by class " - + annotationUseClass.getName() + " with annotation " + annotationClass.getName() + ": " - + asString(annotationsByType); - - - System.out.println(msg); - } - - private static <A extends Annotation> void printDeclaredAnnotation(Class<?> annotationUseClass, - Class<A> annotationDefClass) { - A anno = annotationUseClass.getDeclaredAnnotation(annotationDefClass); - - String msg = asString(anno); - - System.out.println("Declared annotations by class " + annotationUseClass - + ", annotation " + annotationDefClass + ": " + msg); - } - - // Print the annotation "annotationClass" that is directly/indirectly present with an element - // denoted by "annotationUseClass." - private static <A extends Annotation> void printDeclaredAnnotationsByType( - Class<A> annotationClass, Class<?> annotationUseClass) { - A[] annotationsByType = annotationUseClass.getDeclaredAnnotationsByType(annotationClass); - - String msg = "Declared annnotations by type, defined by class " + annotationUseClass.getName() - + " with annotation " + annotationClass.getName() + ": " - + asString(annotationsByType); - - System.out.println(msg); - } - - public static void testMethodAnnotationsByType() { - System.out.println("=============================="); - System.out.println("Method annotations by type:"); - System.out.println("=============================="); - - // Print associated annotations: - // * A is directly present or repeatably present on an element E; - // * No annotation of A is directly/repeatably present on an element AND E is a class - // AND A's type is inheritable, AND A is associated with its superclass. - // (Looks through subtypes recursively only if there's 0 result at each level, - // and the annotation is @Inheritable). - printMethodAnnotationsByType(Calendar.class, "singleUser", AnnotationTestFixture.class); - printMethodAnnotationsByType(Calendars.class, "singleUser", AnnotationTestFixture.class); - - printMethodAnnotationsByType(Calendar.class, "user", AnnotationTestFixture.class); - printMethodAnnotationsByType(Calendars.class, "user", AnnotationTestFixture.class); - - printMethodAnnotationsByType(Calendar.class, "user2", AnnotationTestFixture.class); - printMethodAnnotationsByType(Calendars.class, "user2", AnnotationTestFixture.class); - - printMethodAnnotationsByType(Calendar.class, "userComplex", AnnotationTestFixture.class); - printMethodAnnotationsByType(Calendars.class, "userComplex", AnnotationTestFixture.class); - - System.out.println("-----------------------------"); - System.out.println("-----------------------------"); - } - - // Print the annotation "annotationClass" that is associated with an element denoted by - // "annotationUseClass" method methodName. - private static <A extends Annotation> void printMethodAnnotationsByType(Class<A> annotationClass, - String methodName, Class<?> annotationUseClass) { - Method m = null; - try { - m = annotationUseClass.getDeclaredMethod(methodName); - } catch (Throwable t) { - throw new AssertionError(t); - } - A[] annotationsByType = m.getAnnotationsByType(annotationClass); - - String msg = "Annotations by type, defined by method " + m.getName() + " with annotation " + - annotationClass.getName() + ": " + - asString(annotationsByType); - - System.out.println(msg); - } - - public static void testMethodDeclaredAnnotations() { - System.out.println("=============================="); - System.out.println("Declared method annotations:"); - System.out.println("=============================="); - - printMethodDeclaredAnnotation(Calendar.class, "singleUser", AnnotationTestFixture.class); - printMethodDeclaredAnnotation(Calendars.class, "singleUser", AnnotationTestFixture.class); - - printMethodDeclaredAnnotation(Calendar.class, "user", AnnotationTestFixture.class); - printMethodDeclaredAnnotation(Calendars.class, "user", AnnotationTestFixture.class); - - printMethodDeclaredAnnotation(Calendar.class, "user2", AnnotationTestFixture.class); - printMethodDeclaredAnnotation(Calendars.class, "user2", AnnotationTestFixture.class); - - printMethodDeclaredAnnotation(Calendar.class, "userComplex", AnnotationTestFixture.class); - printMethodDeclaredAnnotation(Calendars.class, "userComplex", AnnotationTestFixture.class); - - System.out.println("-----------------------------"); - System.out.println("-----------------------------"); - } - - // Print the annotation "annotationClass" that is associated with an element denoted by - // methodName in annotationUseClass. - private static <A extends Annotation> void printMethodDeclaredAnnotation(Class<A> annotationClass, - String methodName, Class<?> annotationUseClass) { - Method m = null; - try { - m = annotationUseClass.getDeclaredMethod(methodName); - } catch (Throwable t) { - throw new AssertionError(t); - } - Annotation annotationsByType = m.getDeclaredAnnotation(annotationClass); - - String msg = "Annotations declared by method " + m.getName() + " with annotation " - + annotationClass.getName() + ": " - + asString(annotationsByType); - - System.out.println(msg); - } - - public static void testMethodDeclaredAnnotationsByType() { - System.out.println("=============================="); - System.out.println("Declared method annotations by type:"); - System.out.println("=============================="); - - printMethodDeclaredAnnotationByType(Calendar.class, "singleUser", AnnotationTestFixture.class); - printMethodDeclaredAnnotationByType(Calendars.class, "singleUser", AnnotationTestFixture.class); - - printMethodDeclaredAnnotationByType(Calendar.class, "user", AnnotationTestFixture.class); - printMethodDeclaredAnnotationByType(Calendars.class, "user", AnnotationTestFixture.class); - - printMethodDeclaredAnnotationByType(Calendar.class, "user2", AnnotationTestFixture.class); - printMethodDeclaredAnnotationByType(Calendars.class, "user2", AnnotationTestFixture.class); - - printMethodDeclaredAnnotationByType(Calendar.class, "userComplex", AnnotationTestFixture.class); - printMethodDeclaredAnnotationByType(Calendars.class, "userComplex", - AnnotationTestFixture.class); - - System.out.println("-----------------------------"); - System.out.println("-----------------------------"); - } - - // Print the annotation "annotationClass" that is associated with an element denoted by - // methodName in annotationUseClass. - private static <A extends Annotation> void printMethodDeclaredAnnotationByType( - Class<A> annotationClass, String methodName, Class<?> annotationUseClass) { - Method m = null; - try { - m = annotationUseClass.getDeclaredMethod(methodName); - } catch (Throwable t) { - throw new AssertionError(t); - } - A[] annotationsByType = m.getDeclaredAnnotationsByType(annotationClass); - - String msg = "Annotations by type, defined by method " + m.getName() + " with annotation " - + annotationClass.getName() + ": " - + asString(annotationsByType); - - System.out.println(msg); - } -} diff --git a/test/048-reflect-v8/src/AnnotationTestFixture.java b/test/048-reflect-v8/src/AnnotationTestFixture.java deleted file mode 100644 index 248dfacf3b..0000000000 --- a/test/048-reflect-v8/src/AnnotationTestFixture.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -public class AnnotationTestFixture { - - @Calendar(dayOfWeek="single", hour=23) - public static void singleUser() { - - } - @Calendars ({ - @Calendar(dayOfMonth="last"), - @Calendar(dayOfWeek="Fri", hour=23) - }) - public static void user() { - - } - - @Calendars ({ - @Calendar(dayOfMonth="z"), - @Calendar(dayOfMonth="x"), - @Calendar(dayOfMonth="y") - }) - public static void user2() { - - } - - @Calendar(dayOfMonth="afirst") - @Calendars ({ - @Calendar(dayOfMonth="zsecond"), - @Calendar(dayOfMonth="athird", hour=23) - }) - public static void userComplex() { - - } -} diff --git a/test/048-reflect-v8/src/AnnotationTestHelpers.java b/test/048-reflect-v8/src/AnnotationTestHelpers.java deleted file mode 100644 index 6b5bea266e..0000000000 --- a/test/048-reflect-v8/src/AnnotationTestHelpers.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.lang.annotation.Annotation; - -public class AnnotationTestHelpers { - // Provide custom print function that print a deterministic output. - // Note that Annotation#toString has unspecified order: it prints out the - // fields, which is why we can't rely on it. - - public static String asString(Annotation anno) { - if (anno instanceof Calendar) { - return asString((Calendar)anno); - } else if (anno instanceof Calendars) { - return asString((Calendars)anno); - } else { - if (anno == null) { - return "<null>"; - } - // Fall-back, usually would only go here in a test failure. - return anno.toString(); - } - } - - public static String asString(Annotation[] annos) { - String msg = ""; - - if (annos == null) { - msg += "<null>"; - } else if (annos.length == 0) { - msg += "<empty>"; - } else { - for (int i = 0; i < annos.length; ++i) { - msg += asString(annos[i]); - - if (i != annos.length - 1) { - msg += ", "; - } - } - } - - return msg; - } - - public static String asString(Calendar calendar) { - if (calendar == null) { - return "<null>"; - } - - return "@Calendar(dayOfMonth=" + calendar.dayOfMonth() + ", dayOfWeek=" + - calendar.dayOfWeek() + ", hour=" + calendar.hour() + ")"; - } - - public static String asString(Calendars calendars) { - if (calendars == null) { - return "<null>"; - } - - String s = "@Calendars(value=["; - - Calendar[] allValues = calendars.value(); - for (int i = 0; i < allValues.length; ++i) { - s += asString(allValues[i]); - if (i != allValues.length - 1) { - s += ", "; - } - } - - s += "])"; - - return s; - } -} diff --git a/test/048-reflect-v8/src/Calendar.java b/test/048-reflect-v8/src/Calendar.java deleted file mode 100644 index 4a16573bca..0000000000 --- a/test/048-reflect-v8/src/Calendar.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.lang.annotation.Inherited; -import java.lang.annotation.Repeatable; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -// This is a plain old non-1.8 annotation. At runtime we can see that it has a -// "Repeatable" annotation if we query with getDeclaredAnnotation(Repeatable.class) -@Retention(RetentionPolicy.RUNTIME) -@Repeatable(Calendars.class) -@Inherited // note: container must also be @Inherited by JLS. -public @interface Calendar { - String dayOfMonth() default "unspecified_month"; - String dayOfWeek() default "unspecified_week"; - int hour() default 6; -} - diff --git a/test/048-reflect-v8/src/Calendars.java b/test/048-reflect-v8/src/Calendars.java deleted file mode 100644 index caeda52ea6..0000000000 --- a/test/048-reflect-v8/src/Calendars.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -// Plain old annotation, there's nothing 1.8 specific about it. -@Retention(RetentionPolicy.RUNTIME) -@Inherited // note: elements must also be @Inherited by JLS. -public @interface Calendars { - Calendar[] value(); -} diff --git a/test/048-reflect-v8/src/IFaceA.java b/test/048-reflect-v8/src/IFaceA.java deleted file mode 100644 index 9b1f610f84..0000000000 --- a/test/048-reflect-v8/src/IFaceA.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Stored as a complex annotation Calendars(Calendar,Calendar) -// in the binary. -@Calendars ({ - @Calendar(dayOfMonth="if_a_first"), - @Calendar(dayOfMonth="if_b_last") -}) -public interface IFaceA { -} diff --git a/test/048-reflect-v8/src/IFaceSimple.java b/test/048-reflect-v8/src/IFaceSimple.java deleted file mode 100644 index 93cf61057e..0000000000 --- a/test/048-reflect-v8/src/IFaceSimple.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Simple annotation, no container. -@Calendar(dayOfMonth="if_simple_first") -public interface IFaceSimple { - -} diff --git a/test/048-reflect-v8/src/IsDefaultTest.java b/test/048-reflect-v8/src/IsDefaultTest.java deleted file mode 100644 index 177dcf1ab9..0000000000 --- a/test/048-reflect-v8/src/IsDefaultTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.lang.reflect.Method; - -public class IsDefaultTest { - interface DefaultInterface { - default void sayHi() { - System.out.println("hi default"); - } - } - - interface RegularInterface { - void sayHi(); - } - - class ImplementsWithDefault implements DefaultInterface {} - class ImplementsWithRegular implements RegularInterface { - public void sayHi() { - System.out.println("hello specific"); - } - } - - private static void printIsDefault(Class<?> klass) { - Method m; - try { - m = klass.getMethod("sayHi"); - } catch (Throwable t) { - System.out.println(t); - return; - } - - boolean isDefault = m.isDefault(); - System.out.println(klass.getName() + " is default = " + (isDefault ? "yes" : "no")); - } - - public static void test() { - System.out.println("=============================="); - System.out.println("Are These Methods Default:"); - System.out.println("=============================="); - - printIsDefault(DefaultInterface.class); - printIsDefault(RegularInterface.class); - printIsDefault(ImplementsWithDefault.class); - printIsDefault(ImplementsWithRegular.class); - } -} diff --git a/test/048-reflect-v8/src/Main.java b/test/048-reflect-v8/src/Main.java index f2b8287d18..7fa2a923d7 100644 --- a/test/048-reflect-v8/src/Main.java +++ b/test/048-reflect-v8/src/Main.java @@ -14,14 +14,43 @@ * limitations under the License. */ +import java.lang.reflect.Method; + public class Main { + interface DefaultInterface { + default void sayHi() { + System.out.println("hi default"); + } + } + + interface RegularInterface { + void sayHi(); + } + + class ImplementsWithDefault implements DefaultInterface {} + class ImplementsWithRegular implements RegularInterface { + public void sayHi() { + System.out.println("hello specific"); + } + } + + private static void printIsDefault(Class<?> klass) { + Method m; + try { + m = klass.getMethod("sayHi"); + } catch (Throwable t) { + System.out.println(t); + return; + } + + boolean isDefault = m.isDefault(); + System.out.println(klass.getName() + " is default = " + (isDefault ? "yes" : "no")); + } + public static void main(String[] args) { - IsDefaultTest.test(); - AnnotationTest.testAnnotationsByType(); - AnnotationTest.testDeclaredAnnotation(); - AnnotationTest.testDeclaredAnnotationsByType(); - AnnotationTest.testMethodAnnotationsByType(); - AnnotationTest.testMethodDeclaredAnnotations(); - AnnotationTest.testMethodDeclaredAnnotationsByType(); + printIsDefault(DefaultInterface.class); + printIsDefault(RegularInterface.class); + printIsDefault(ImplementsWithDefault.class); + printIsDefault(ImplementsWithRegular.class); } } diff --git a/test/048-reflect-v8/src/SingleUser.java b/test/048-reflect-v8/src/SingleUser.java deleted file mode 100644 index 0f9c430109..0000000000 --- a/test/048-reflect-v8/src/SingleUser.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Stored as a single "Calendar" annotation in the binary. -@Calendar(dayOfWeek="single", hour=23) -public class SingleUser { - -} diff --git a/test/048-reflect-v8/src/User.java b/test/048-reflect-v8/src/User.java deleted file mode 100644 index 003ceeb093..0000000000 --- a/test/048-reflect-v8/src/User.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Stored as a complex annotation Calendars(Calendar,Calendar) -// in the binary. -// -/* FIXME: Use this code instead, when Jack supports repeatable annotations properly. - * - * @Calendar(dayOfMonth="last") - * @Calendar(dayOfWeek="Fri", hour=23) - */ -@Calendars ({ - @Calendar(dayOfMonth="last"), - @Calendar(dayOfWeek="Fri", hour=23) -}) -public class User { - -} diff --git a/test/048-reflect-v8/src/User2.java b/test/048-reflect-v8/src/User2.java deleted file mode 100644 index 1a6049f508..0000000000 --- a/test/048-reflect-v8/src/User2.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Stored as a complex annotation Calendars(Calendar,Calendar,Calendar) -// in the binary. -// (Check for order, should be z,x,y) -@Calendars ({ - @Calendar(dayOfMonth="z"), - @Calendar(dayOfMonth="x"), - @Calendar(dayOfMonth="y") -}) -public class User2 { - -} diff --git a/test/048-reflect-v8/src/UserComplex.java b/test/048-reflect-v8/src/UserComplex.java deleted file mode 100644 index e26234960b..0000000000 --- a/test/048-reflect-v8/src/UserComplex.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Stored as a complex annotation Calendars(Calendar,Calendar) -// followed by a Calendar in the binary. -// In other words { Calendars([C,C]), C } -// -// Note that trying to do {C,Calendars,C} or similar -// is illegal by the JLS. -@Calendar(dayOfMonth="afirst") -@Calendars ({ - @Calendar(dayOfMonth="zsecond"), - @Calendar(dayOfMonth="athird", hour=23) -}) -// @Calendar(dayOfMonth="zlast") // Leave for future ordering test -public class UserComplex { - -} diff --git a/test/048-reflect-v8/src/UserSub.java b/test/048-reflect-v8/src/UserSub.java deleted file mode 100644 index d60aa6a3f1..0000000000 --- a/test/048-reflect-v8/src/UserSub.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -public class UserSub - extends User - implements IFaceA, IFaceSimple { - -} diff --git a/test/048-reflect-v8/src/UserSub2.java b/test/048-reflect-v8/src/UserSub2.java deleted file mode 100644 index 13e2eb07c8..0000000000 --- a/test/048-reflect-v8/src/UserSub2.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This calendar subsumes anything else we would've normally gotten from the subclass. -@Calendar(dayOfMonth="sub2") -public class UserSub2 - extends User - implements IFaceA, IFaceSimple { - -} diff --git a/test/563-checker-invoke-super/build b/test/563-checker-invoke-super/build new file mode 100755 index 0000000000..e06193ba78 --- /dev/null +++ b/test/563-checker-invoke-super/build @@ -0,0 +1,28 @@ +#!/bin/bash +# +# Copyright 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Make us exit on a failure. +# +set -e + +# Hard-wired use of experimental jack. +# TODO: fix this temporary work-around for lambdas, see b/19467889 +export USE_JACK=true +export JACK_SERVER=false +export JACK_REPOSITORY="${ANDROID_BUILD_TOP}/prebuilts/sdk/tools/jacks" + +# e.g. /foo/bar/jack-3.10.ALPHA.jar -> 3.10.ALPHA +export JACK_VERSION="$(find "$JACK_REPOSITORY" -name '*ALPHA*' | sed 's/.*jack-//g' | sed 's/[.]jar//g')" +./default-build "$@" --experimental default-methods diff --git a/test/563-checker-invoke-super/expected.txt b/test/563-checker-invoke-super/expected.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/563-checker-invoke-super/expected.txt diff --git a/test/563-checker-invoke-super/info.txt b/test/563-checker-invoke-super/info.txt new file mode 100644 index 0000000000..23c0d2fa49 --- /dev/null +++ b/test/563-checker-invoke-super/info.txt @@ -0,0 +1,2 @@ +Tests that invoke-super's to interface methods are optimized to direct method +calls when in the same dex file. diff --git a/test/563-checker-invoke-super/src/Main.java b/test/563-checker-invoke-super/src/Main.java new file mode 100644 index 0000000000..8554dbd0ec --- /dev/null +++ b/test/563-checker-invoke-super/src/Main.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface IFace { + public default void $noinline$aMethod() { throw new RuntimeException("Should not be called"); } +} + +class ClassImplA implements IFace { + /// CHECK-START: void ClassImplA.testSuperInvoke() builder (after) + /// CHECK: InvokeStaticOrDirect + public void testSuperInvoke() { + IFace.super.$noinline$aMethod(); + } +} + +class ClassImplB extends ClassImplA { + /// CHECK-START: void ClassImplB.testSuperInvoke2() builder (after) + /// CHECK: InvokeStaticOrDirect + public void testSuperInvoke2() { + super.$noinline$aMethod(); + } +} + +public class Main { + public static void main(String[] args) { } +} diff --git a/test/566-polymorphic-inlining/polymorphic_inline.cc b/test/566-polymorphic-inlining/polymorphic_inline.cc index 55eac5c30a..b2934ed163 100644 --- a/test/566-polymorphic-inlining/polymorphic_inline.cc +++ b/test/566-polymorphic-inlining/polymorphic_inline.cc @@ -29,11 +29,18 @@ static void do_checks(jclass cls, const char* method_name) { jit::Jit* jit = Runtime::Current()->GetJit(); jit::JitCodeCache* code_cache = jit->GetCodeCache(); ArtMethod* method = klass->FindDeclaredDirectMethodByName(method_name, sizeof(void*)); - jit->CompileMethod(method, soa.Self()); - OatQuickMethodHeader* header = OatQuickMethodHeader::FromEntryPoint( - method->GetEntryPointFromQuickCompiledCode()); - CHECK(code_cache->ContainsPc(header->GetCode())); + OatQuickMethodHeader* header = nullptr; + // Infinite loop... Test harness will have its own timeout. + while (true) { + header = OatQuickMethodHeader::FromEntryPoint(method->GetEntryPointFromQuickCompiledCode()); + if (code_cache->ContainsPc(header->GetCode())) { + break; + } else { + // sleep one second to give time to the JIT compiler. + sleep(1); + } + } CodeInfo info = header->GetOptimizedCodeInfo(); CHECK(info.HasInlineInfo()); @@ -45,6 +52,11 @@ extern "C" JNIEXPORT void JNICALL Java_Main_ensureJittedAndPolymorphicInline(JNI return; } + if (kIsDebugBuild) { + // A debug build might often compile the methods without profiling informations filled. + return; + } + do_checks(cls, "testInvokeVirtual"); do_checks(cls, "testInvokeInterface"); } diff --git a/test/972-iface-super-multidex/expected.txt b/test/972-iface-super-multidex/expected.txt new file mode 100644 index 0000000000..a9d31a5320 --- /dev/null +++ b/test/972-iface-super-multidex/expected.txt @@ -0,0 +1,2 @@ +SuperInterface default method called +Expected ICCE caught diff --git a/test/972-iface-super-multidex/info.txt b/test/972-iface-super-multidex/info.txt new file mode 100644 index 0000000000..f7948ad2a5 --- /dev/null +++ b/test/972-iface-super-multidex/info.txt @@ -0,0 +1,3 @@ +Smali-based tests for experimental interface default methods. + +Obviously needs to run under ART or a Java 8 Language runtime and compiler. diff --git a/test/972-iface-super-multidex/smali-multidex/conflictinterface.smali b/test/972-iface-super-multidex/smali-multidex/conflictinterface.smali new file mode 100644 index 0000000000..2c76213015 --- /dev/null +++ b/test/972-iface-super-multidex/smali-multidex/conflictinterface.smali @@ -0,0 +1,23 @@ +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +.class public abstract interface LConflictInterface; +.super Ljava/lang/Object; +.implements LOneConflict; +.implements LTwoConflict; + +# public interface ConflictInterface extends OneConflict, TwoConflict { +# } diff --git a/test/972-iface-super-multidex/smali-multidex/oneconflict.smali b/test/972-iface-super-multidex/smali-multidex/oneconflict.smali new file mode 100644 index 0000000000..7001f02c0f --- /dev/null +++ b/test/972-iface-super-multidex/smali-multidex/oneconflict.smali @@ -0,0 +1,31 @@ +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +.class public abstract interface LOneConflict; +.super Ljava/lang/Object; + +# public interface OneConflict { +# public String runDefault() { +# return "OneConflict default method called"; +# } +# } + +.method public runDefault()Ljava/lang/String; +.registers 2 + # Do an invoke super on this class, to confuse runtime/compiler. + const-string v0, "OneConflict default method called" + return-object v0 +.end method diff --git a/test/972-iface-super-multidex/smali-multidex/superinterface.smali b/test/972-iface-super-multidex/smali-multidex/superinterface.smali new file mode 100644 index 0000000000..d45ecea045 --- /dev/null +++ b/test/972-iface-super-multidex/smali-multidex/superinterface.smali @@ -0,0 +1,31 @@ +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +.class public abstract interface LSuperInterface; +.super Ljava/lang/Object; + +# public interface SuperInterface { +# public String runDefault() { +# return "SuperInterface default method called"; +# } +# } + +.method public runDefault()Ljava/lang/String; +.registers 2 + # Do an invoke super on this class, to confuse runtime/compiler. + const-string v0, "SuperInterface default method called" + return-object v0 +.end method diff --git a/test/972-iface-super-multidex/smali-multidex/twoconflict.smali b/test/972-iface-super-multidex/smali-multidex/twoconflict.smali new file mode 100644 index 0000000000..b971b74649 --- /dev/null +++ b/test/972-iface-super-multidex/smali-multidex/twoconflict.smali @@ -0,0 +1,31 @@ +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +.class public abstract interface LTwoConflict; +.super Ljava/lang/Object; + +# public interface TwoConflict { +# public String runDefault() { +# return "TwoConflict default method called"; +# } +# } + +.method public runDefault()Ljava/lang/String; +.registers 2 + # Do an invoke super on this class, to confuse runtime/compiler. + const-string v0, "TwoConflict default method called" + return-object v0 +.end method diff --git a/test/972-iface-super-multidex/smali/concreteclass.smali b/test/972-iface-super-multidex/smali/concreteclass.smali new file mode 100644 index 0000000000..703da945cc --- /dev/null +++ b/test/972-iface-super-multidex/smali/concreteclass.smali @@ -0,0 +1,62 @@ +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +.class public LConcreteClass; +.super Ljava/lang/Object; +.implements LSuperInterface; +.implements LConflictInterface; + +# public class ConcreteClass implements SuperInterface, ConflictInterface { +# public String runReal() { +# return SuperInterface.super.runDefault(); +# } +# public String runConflict() { +# return ConflictInterface.super.runDefault(); +# } +# public String runDefault() { +# return "This is the wrong class to invoke"; +# } +# } + +.method public constructor <init>()V + .registers 1 + invoke-direct {p0}, Ljava/lang/Object;-><init>()V + return-void +.end method + +.method public runConflict()Ljava/lang/String; +.registers 2 + # Do an invoke super on this class, to confuse runtime/compiler. + invoke-super {p0}, LConflictInterface;->runDefault()Ljava/lang/String; + move-result-object v0 + return-object v0 +.end method + + + +.method public runReal()Ljava/lang/String; +.registers 2 + # Do an invoke super on this class, to confuse runtime/compiler. + invoke-super {p0}, LSuperInterface;->runDefault()Ljava/lang/String; + move-result-object v0 + return-object v0 +.end method + +.method public runDefault()Ljava/lang/String; +.registers 2 + const-string v0, "This is the wrong class to invoke!" + return-object v0 +.end method diff --git a/test/972-iface-super-multidex/src/Main.java b/test/972-iface-super-multidex/src/Main.java new file mode 100644 index 0000000000..3fb3f45428 --- /dev/null +++ b/test/972-iface-super-multidex/src/Main.java @@ -0,0 +1,55 @@ +/* + * Copyright 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.lang.reflect.*; +public class Main { + public static void main(String[] args) { + Class<?> c = null; + try { + c = Class.forName("ConcreteClass"); + } catch (Exception e) { + System.out.println("Could not load class"); + e.printStackTrace(); + return; + } + try { + Method m = c.getMethod("runReal"); + System.out.println((String)m.invoke(c.newInstance(), new Object[0])); + } catch (Exception e) { + System.out.println("Unknown exception occurred"); + e.printStackTrace(); + } + try { + Method m = c.getMethod("runConflict"); + try { + System.out.println((String)m.invoke(c.newInstance(), new Object[0])); + } catch (InvocationTargetException e) { + throw e.getCause(); + } + } catch (AbstractMethodError e) { + System.out.println("Unexpected AME caught"); + e.printStackTrace(); + } catch (NoSuchMethodError e) { + System.out.println("Unexpected NSME caught"); + e.printStackTrace(); + } catch (IncompatibleClassChangeError e) { + System.out.println("Expected ICCE caught"); + } catch (Throwable e) { + System.out.println("Unknown exception caught!"); + e.printStackTrace(); + } + } +} diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk index d6c29837b7..7400248952 100644 --- a/test/Android.run-test.mk +++ b/test/Android.run-test.mk @@ -547,10 +547,8 @@ TEST_ART_BROKEN_OPTIMIZING_READ_BARRIER_RUN_TESTS := \ 527-checker-array-access-split \ 537-checker-arraycopy -# Tests that should fail in the read barrier configuration with JIT. -# 496: Occasional timeout: "Fault message: timeout: the monitored command dumped core" (b/26786304). -TEST_ART_BROKEN_JIT_READ_BARRIER_RUN_TESTS := \ - 496-checker-inlining-and-class-loader +# Tests that should fail in the read barrier configuration with JIT (Optimizing compiler). +TEST_ART_BROKEN_JIT_READ_BARRIER_RUN_TESTS := ifeq ($(ART_USE_READ_BARRIER),true) ifneq (,$(filter interpreter,$(COMPILER_TYPES))) diff --git a/test/etc/default-build b/test/etc/default-build index 7242428f1e..6e855ec30a 100755 --- a/test/etc/default-build +++ b/test/etc/default-build @@ -42,6 +42,12 @@ else HAS_SRC_MULTIDEX=false fi +if [ -d smali-multidex ]; then + HAS_SMALI_MULTIDEX=true +else + HAS_SMALI_MULTIDEX=false +fi + if [ -d src-ex ]; then HAS_SRC_EX=true else @@ -74,6 +80,9 @@ while true; do elif [ "x$1" = "x--no-src-multidex" ]; then HAS_SRC_MULTIDEX=false shift + elif [ "x$1" = "x--no-smali-multidex" ]; then + HAS_SMALI_MULTIDEX=false + shift elif [ "x$1" = "x--no-src-ex" ]; then HAS_SRC_EX=false shift @@ -171,6 +180,19 @@ if [ "${HAS_SMALI}" = "true" ]; then fi fi +if [ "${HAS_SMALI_MULTIDEX}" = "true" ]; then + # Compile Smali classes + ${SMALI} -JXmx512m ${SMALI_ARGS} --output smali_classes2.dex `find smali-multidex -name '*.smali'` + + # Don't bother with dexmerger if we provide our own main function in a smali file. + if [ ${HAS_SRC_MULTIDEX} = "true" ]; then + ${DXMERGER} classes2.dex classes2.dex smali_classes2.dex + else + mv smali_classes2.dex classes2.dex + fi +fi + + if [ ${HAS_SRC_EX} = "true" ]; then if [ ${USE_JACK} = "true" ]; then # Rename previous "classes.dex" so it is not overwritten. @@ -198,7 +220,7 @@ if [ ${HAS_SRC_EX} = "true" ]; then fi # Create a single jar with two dex files for multidex. -if [ ${HAS_SRC_MULTIDEX} = "true" ]; then +if [ ${HAS_SRC_MULTIDEX} = "true" ] || [ ${HAS_SMALI_MULTIDEX} = "true" ]; then zip $TEST_NAME.jar classes.dex classes2.dex elif [ ${NEED_DEX} = "true" ]; then zip $TEST_NAME.jar classes.dex |