1 /* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import java.beans.BeanInfo; 25 import java.beans.Introspector; 26 import java.beans.PropertyDescriptor; 27 import java.io.Serializable; 28 import java.util.AbstractList; 29 import java.util.ArrayList; 30 import java.util.Arrays; 31 import java.util.Vector; 32 33 /** 34 * @test 35 * @bug 8156043 36 */ 37 public final class TestMethodOrderDependence { 38 39 public static class Base { 40 getI()41 public Object getI() { 42 return null; 43 } 44 getE()45 public Object getE() { 46 return null; 47 } 48 } 49 50 public static class Super extends Base { 51 getI()52 public Number getI() { 53 return null; 54 } getE()55 public Comparable<?> getE() { 56 return null; 57 } 58 } 59 60 public static class Sub extends Super { 61 getI()62 public Integer getI() { 63 return null; 64 } 65 setFoo(Character foo)66 public void setFoo(Character foo) { 67 } 68 setFoo(String foo)69 public void setFoo(String foo) { 70 } 71 setFoo(Object[] foo)72 public void setFoo(Object[] foo) { 73 } 74 setFoo(Enum foo)75 public void setFoo(Enum foo) { 76 } 77 setFoo(Long foo)78 public void setFoo(Long foo) { 79 } 80 setFoo(Long[] foo)81 public void setFoo(Long[] foo) { 82 } 83 setFoo(Long foo, int i)84 public void setFoo(Long foo, int i) { 85 } 86 setFoo(Object foo)87 public void setFoo(Object foo) { 88 } 89 setFoo(AbstractList foo)90 public void setFoo(AbstractList foo) { 91 } 92 setFoo(ArrayList foo)93 public void setFoo(ArrayList foo) { 94 } 95 setFoo(Integer foo)96 public void setFoo(Integer foo) { 97 } 98 setFoo(Number foo)99 public void setFoo(Number foo) { 100 } 101 setFoo(Comparable<?> foo)102 public void setFoo(Comparable<?> foo) { 103 } 104 setFoo(Serializable foo)105 public void setFoo(Serializable foo) { 106 } 107 setFoo(Vector<?> foo)108 public void setFoo(Vector<?> foo) { 109 } 110 setFoo(long foo)111 public void setFoo(long foo) { 112 } 113 setFoo(int foo)114 public void setFoo(int foo) { 115 } 116 getE()117 public Enum getE() { 118 return null; 119 } 120 setE(Enum e)121 public void setE(Enum e) { 122 } 123 setE(Float e)124 public void setE(Float e) { 125 } 126 setE(Long e)127 public void setE(Long e) { 128 } 129 } 130 main(final String[] args)131 public static void main(final String[] args) throws Exception { 132 final BeanInfo beanInfo = Introspector.getBeanInfo(Sub.class); 133 final PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors(); 134 for (final PropertyDescriptor pd : pds) { 135 System.err.println("pd = " + pd); 136 final Class<?> type = pd.getPropertyType(); 137 if (type != Class.class && type != Long[].class 138 && type != Integer.class && type != Enum.class) { 139 throw new RuntimeException(Arrays.toString(pds)); 140 } 141 } 142 } 143 } 144