Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/lang/reflect/DefaultStaticTest/DefaultStaticTestData.java
38828 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* Test Data used for testing default/static method25*26* @author Yong Lu27*/2829import java.util.Arrays;30import java.util.List;3132import org.testng.annotations.DataProvider;33import org.testng.collections.Lists;3435import static helper.Mod.*;36import static helper.Declared.*;37import helper.Mod;38import helper.Declared;39import java.lang.annotation.Repeatable;40import java.lang.annotation.Retention;41import java.lang.annotation.RetentionPolicy;4243@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = YES)44interface TestIF1 {4546default String defaultMethod() {47return "TestIF1.defaultMethod";48}49}5051@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO)52class TestClass1 implements TestIF1 {53}5455@MethodDesc(name = "staticMethod", retval = "TestIF2.staticMethod", mod = STATIC, declared = YES)56interface TestIF2 {5758static String staticMethod() {59return "TestIF2.staticMethod";60}61}6263@MethodDesc(name = "method", retval = "TestIF2.staticMethod", mod = REGULAR, declared = YES)64class TestClass2 implements TestIF2 {6566public String method() {67return TestIF2.staticMethod();68}69}7071@MethodDesc(name = "defaultMethod", retval = "TestIF3.defaultMethod", mod = DEFAULT, declared = YES)72@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = YES)73interface TestIF3 {7475String method();7677default String defaultMethod() {78return "TestIF3.defaultMethod";79}80}8182@MethodDesc(name = "defaultMethod", retval = "TestIF3.defaultMethod", mod = DEFAULT, declared = NO)83@MethodDesc(name = "method", retval = "TestClass3.method", mod = REGULAR, declared = YES)84class TestClass3 implements TestIF3 {8586public String method() {87return "TestClass3.method";88}89}9091@MethodDesc(name = "staticMethod", retval = "TestIF4.staticMethod", mod = STATIC, declared = YES)92@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = YES)93interface TestIF4 {9495String method();9697static String staticMethod() {98return "TestIF4.staticMethod";99}100}101102@MethodDesc(name = "method", retval = "TestClass4.method", mod = REGULAR, declared = YES)103class TestClass4 implements TestIF4 {104105public String method() {106return "TestClass4.method";107}108}109110@MethodDesc(name = "defaultMethod", retval = "TestIF5.defaultMethod", mod = DEFAULT, declared = YES)111@MethodDesc(name = "staticMethod", retval = "TestIF5.staticMethod", mod = STATIC, declared = YES)112interface TestIF5 {113114default String defaultMethod() {115return "TestIF5.defaultMethod";116}117118static String staticMethod() {119return "TestIF5.staticMethod";120}121}122123@MethodDesc(name = "defaultMethod", retval = "TestIF5.defaultMethod", mod = DEFAULT, declared = NO)124class TestClass5 implements TestIF5 {125}126127@MethodDesc(name = "defaultMethod", retval = "TestIF6.defaultMethod", mod = DEFAULT, declared = YES)128@MethodDesc(name = "staticMethod", retval = "TestIF6.staticMethod", mod = STATIC, declared = YES)129@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = YES)130interface TestIF6 {131132String method();133134default String defaultMethod() {135return "TestIF6.defaultMethod";136}137138static String staticMethod() {139return "TestIF6.staticMethod";140}141}142143@MethodDesc(name = "defaultMethod", retval = "TestIF6.defaultMethod", mod = DEFAULT, declared = NO)144@MethodDesc(name = "method", retval = "TestClass6.method", mod = REGULAR, declared = YES)145class TestClass6 implements TestIF6 {146147public String method() {148return "TestClass6.method";149}150}151152@MethodDesc(name = "defaultMethod", retval = "TestIF7.TestClass7", mod = DEFAULT, declared = YES)153interface TestIF7<T> {154155default T defaultMethod(T t) {156return t;157}158}159160@MethodDesc(name = "defaultMethod", retval = "TestIF7.TestClass7", mod = DEFAULT, declared = NO)161class TestClass7<T> implements TestIF7<T> {162}163164@MethodDesc(name = "defaultMethod", retval = "TestIF8.TestClass8", mod = DEFAULT, declared = YES)165interface TestIF8<E> {166167default <E> E defaultMethod(E e) {168return e;169}170}171172@MethodDesc(name = "defaultMethod", retval = "TestIF8.TestClass8", mod = DEFAULT, declared = NO)173class TestClass8<T> implements TestIF8<T> {174}175176@MethodDesc(name = "defaultMethod", retval = "TestIF9.defaultMethod", mod = DEFAULT, declared = YES)177interface TestIF9 extends TestIF1 {178179default String defaultMethod() {180return "TestIF9.defaultMethod";181}182}183184@MethodDesc(name = "defaultMethod", retval = "TestIF9.defaultMethod", mod = DEFAULT, declared = NO)185class TestClass9 implements TestIF9 {186}187188@MethodDesc(name = "defaultMethod", retval = "TestIF9.defaultMethod", mod = DEFAULT, declared = NO)189@MethodDesc(name = "method", retval = "TestIF9.defaultMethod", mod = REGULAR, declared = YES)190class TestClass91 implements TestIF9, TestIF1 {191192public String method() {193return defaultMethod();194}195}196197@MethodDesc(name = "staticMethod", retval = "TestIF10.staticMethod", mod = STATIC, declared = YES)198interface TestIF10 extends TestIF2 {199200static String staticMethod() {201202return "TestIF10.staticMethod";203}204}205206@MethodDesc(name = "staticMethod", retval = "TestIF11.staticMethod", mod = STATIC, declared = YES)207@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO)208interface TestIF11 extends TestIF1 {209210static String staticMethod() {211return "TestIF11.staticMethod";212}213}214215@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO)216class TestClass11 implements TestIF11 {217}218219@MethodDesc(name = "defaultMethod", retval = "TestIF12.defaultMethod", mod = DEFAULT, declared = YES)220interface TestIF12 extends TestIF2 {221222default String defaultMethod() {223return "TestIF12.defaultMethod";224}225}226227@MethodDesc(name = "defaultMethod", retval = "TestIF12.defaultMethod", mod = DEFAULT, declared = NO)228class TestClass12 implements TestIF12 {229}230231//Diamond Case232@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO)233interface TestIF1A extends TestIF1 {234}235236@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO)237interface TestIF1B extends TestIF1 {238}239240@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO)241class TestClass13 implements TestIF1A, TestIF1B {242}243244//Diamond Override Case245@MethodDesc(name = "defaultMethod", retval = "TestIF1C.defaultMethod", mod = DEFAULT, declared = YES)246interface TestIF1C extends TestIF1 {247248default String defaultMethod() {249return "TestIF1C.defaultMethod";250}251}252253@MethodDesc(name = "defaultMethod", retval = "TestIF1D.defaultMethod", mod = DEFAULT, declared = YES)254interface TestIF1D extends TestIF1 {255256default String defaultMethod() {257return "TestIF1D.defaultMethod";258}259}260261@MethodDesc(name = "defaultMethod", retval = "TestClass14.defaultMethod", mod = REGULAR, declared = YES)262class TestClass14 implements TestIF1C, TestIF1D {263264public String defaultMethod() {265return "TestClass14.defaultMethod";266}267}268269@MethodDesc(name = "defaultMethod", retval = "", mod = ABSTRACT, declared = YES)270interface TestIF15 extends TestIF1 {271272String defaultMethod();273}274275@MethodDesc(name = "defaultMethod", retval = "TestClass15.defaultMethod", mod = REGULAR, declared = YES)276class TestClass15 implements TestIF15 {277278public String defaultMethod() {279return "TestClass15.defaultMethod";280}281}282283interface FuncInterface<T> {284285String test(T t);286}287288@MethodDesc(name = "defaultMethod", retval = "TestIF16.defaultMethod", mod = DEFAULT, declared = YES)289interface TestIF16 {290291default String defaultMethod() {292FuncInterface<Object> fi = o -> o.toString();293Object o = "TestIF16.defaultMethod";294return fi.test(o);295}296}297298@MethodDesc(name = "defaultMethod", retval = "TestIF16.defaultMethod", mod = DEFAULT, declared = NO)299class TestClass16 implements TestIF16 {300}301302@MethodDesc(name = "defaultMethod", retval = "TestIF17.defaultMethod", mod = DEFAULT, declared = YES)303@MethodDesc(name = "staticMethod", retval = "TestIF17.staticMethod", mod = STATIC, declared = YES)304interface TestIF17 {305306default String defaultMethod() {307return staticMethod().replace("staticMethod", "defaultMethod");308}309310public static String staticMethod() {311return "TestIF17.staticMethod";312}313}314315@MethodDesc(name = "defaultMethod", retval = "TestIF17.defaultMethod", mod = DEFAULT, declared = NO)316class TestClass17 implements TestIF17 {317}318319320@MethodDesc(name = "defaultMethod", retval = "TestIF17.defaultMethod", mod = DEFAULT, declared = NO)321class TestClass18 extends TestClass17 {322}323324325@Retention(RetentionPolicy.RUNTIME)326@Repeatable(MethodDescs.class)327@interface MethodDesc {328String name();329String retval();330Mod mod();331Declared declared();332}333334@Retention(RetentionPolicy.RUNTIME)335@interface MethodDescs {336MethodDesc[] value();337}338339//Diamond Case for static method340@MethodDesc(name = "staticMethod", retval = "TestIF2A.staticMethod", mod = STATIC, declared = YES)341interface TestIF2A extends TestIF2 {342static String staticMethod() {343return "TestIF2A.staticMethod";344}345}346347@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = YES)348interface TestIF2B extends TestIF2 {349String method();350}351352@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = YES)353interface TestIF18 extends TestIF10, TestIF2A {354String method();355}356357@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = NO)358@MethodDesc(name = "defaultMethod", retval = "TestIF12.defaultMethod", mod = DEFAULT, declared = NO)359interface TestIF19 extends TestIF12, TestIF2B {360}361362@MethodDesc(name = "staticMethod", retval = "TestIF20.staticMethod", mod = STATIC, declared = YES)363@MethodDesc(name = "defaultMethod", retval = "TestIF12.defaultMethod", mod = DEFAULT, declared = NO)364interface TestIF20 extends TestIF12, TestIF2A {365static String staticMethod() {366return "TestIF20.staticMethod";367}368}369370@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = NO)371interface TestIF21 extends TestIF2A, TestIF2B {372}373374public class DefaultStaticTestData {375376/**377* Test data for DefaultStaticInvokeTest The format of inner array is: First378* data is the name of the class under test Second data used in test as the379* arguments used for the method call.380*/381@DataProvider382static Object[][] testClasses() {383return new Object[][]{384{"TestClass1", null},385{"TestClass2", null},386{"TestClass3", null},387{"TestClass4", null},388{"TestClass5", null},389{"TestClass6", null},390{"TestClass7", "TestIF7.TestClass7"},391{"TestClass8", "TestIF8.TestClass8"},392{"TestClass9", null},393{"TestClass91", null},394{"TestClass11", null},395{"TestClass12", null},396{"TestClass13", null},397{"TestClass14", null},398{"TestClass15", null},399{"TestClass16", null},400{"TestClass17", null},401{"TestClass18", null},402};403}404405/**406* Test data for DefaultStaticInvokeTest The format of inner array is: First407* data is the name of the interface under test Second data used in test as408* the arguments used for the method call.409*/410@DataProvider411static Object[][] testInterfaces() {412return new Object[][]{413{"TestIF1", null},414{"TestIF2", null},415{"TestIF2A", null},416{"TestIF2B", null},417{"TestIF3", null},418{"TestIF4", null},419{"TestIF5", null},420{"TestIF6", null},421{"TestIF7", "TestIF7.TestClass7"},422{"TestIF8", "TestIF8.TestClass8"},423{"TestIF9", null},424{"TestIF10", null},425{"TestIF11", null},426{"TestIF12", null},427{"TestIF1A", null},428{"TestIF1B", null},429{"TestIF1C", null},430{"TestIF1D", null},431{"TestIF15", null},432{"TestIF16", null},433{"TestIF17", null},434{"TestIF18", null},435{"TestIF19", null},436{"TestIF20", null},437{"TestIF21", null},438};439}440441@DataProvider442static Object[][] testCasesAll() {443List<Object[]> result = Lists.newArrayList();444result.addAll(Arrays.asList(testClasses()));445result.addAll(Arrays.asList(testInterfaces()));446return result.toArray(new Object[result.size()][]);447}448}449450451