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.lang.reflect.Method; 29 import java.util.AbstractList; 30 import java.util.ArrayList; 31 import java.util.Arrays; 32 import java.util.Comparator; 33 import java.util.Vector; 34 35 /** 36 * @test 37 * @bug 8156043 38 */ 39 public final class TestMethodOrderDependence { 40 41 public static class Base { 42 43 public Object getI() { 44 return null; 45 } 46 } 47 48 public static class Super extends Base { 49 50 public Number getI() { 51 return null; 52 } 53 } 54 55 public static class Sub extends Super { 56 57 public Integer getI() { 58 return null; 59 } 60 61 public void setFoo(Character foo) { 62 } 63 64 public void setFoo(String foo) { 65 } 66 67 public void setFoo(Object[] foo) { 68 } 69 70 public void setFoo(Enum foo) { 71 } 72 73 public void setFoo(Long foo) { 74 } 75 76 public void setFoo(Long[] foo) { 77 } 78 79 public void setFoo(Long foo, int i) { 80 } 81 82 public void setFoo(Object foo) { 83 } 84 85 public void setFoo(AbstractList foo) { 86 } 87 88 public void setFoo(ArrayList foo) { 89 } 90 91 public void setFoo(Integer foo) { 92 } 93 94 public void setFoo(Number foo) { 95 } 96 97 public void setFoo(Comparable<?> foo) { 98 } 99 100 public void setFoo(Serializable foo) { 101 } 102 103 public void setFoo(Vector<?> foo) { 104 } 105 106 public void setFoo(long foo) { 107 } 108 109 public void setFoo(int foo) { 110 } 111 } 112 113 public static void main(final String[] args) throws Exception { 114 final BeanInfo beanInfo = Introspector.getBeanInfo(Sub.class); 115 final PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors(); 116 for (final PropertyDescriptor pd : pds) { 117 final Class<?> type = pd.getPropertyType(); 118 if (type != Class.class && type != Long[].class 119 && type != Integer.class) { 120 throw new RuntimeException(Arrays.toString(pds)); 121 } 122 } 123 } 124 }