1407N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1407N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1407N/A *
1407N/A * This code is free software; you can redistribute it and/or modify it
1407N/A * under the terms of the GNU General Public License version 2 only, as
1407N/A * published by the Free Software Foundation.
1407N/A *
1407N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1407N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1407N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1407N/A * version 2 for more details (a copy is included in the LICENSE file that
1407N/A * accompanied this code).
1407N/A *
1407N/A * You should have received a copy of the GNU General Public License version
1407N/A * 2 along with this work; if not, write to the Free Software Foundation,
1407N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1407N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1407N/A */
1407N/A
1407N/A/*
1407N/A * @test
1407N/A * @bug 6723447
1407N/A * @summary Tests return type for property setters
1407N/A * @author Sergey Malenkov
1407N/A */
1407N/A
1407N/Aimport java.beans.IndexedPropertyDescriptor;
1407N/Aimport java.beans.IntrospectionException;
1407N/Aimport java.beans.Introspector;
1407N/Aimport java.beans.PropertyDescriptor;
1407N/Aimport java.lang.reflect.Method;
1407N/Aimport java.math.BigDecimal;
1407N/A
1407N/Apublic class Test6723447 {
1407N/A
1407N/A public static void main(String[] args) {
1407N/A test(Test6723447.class);
1407N/A test(BigDecimal.class);
1407N/A }
1407N/A
1407N/A private static void test(Class<?> type) {
1407N/A for (PropertyDescriptor pd : getPropertyDescriptors(type)) {
1407N/A test(pd.getWriteMethod());
1407N/A if (pd instanceof IndexedPropertyDescriptor) {
1407N/A IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
1407N/A test(ipd.getIndexedWriteMethod());
1407N/A }
1407N/A }
1407N/A }
1407N/A
1407N/A private static void test(Method method) {
1407N/A if (method != null) {
1407N/A Class<?> type = method.getReturnType();
1407N/A if (!type.equals(void.class)) {
1407N/A throw new Error("unexpected return type: " + type);
1407N/A }
1407N/A }
1407N/A }
1407N/A
1407N/A private static PropertyDescriptor[] getPropertyDescriptors(Class<?> type) {
1407N/A try {
1407N/A return Introspector.getBeanInfo(type).getPropertyDescriptors();
1407N/A }
1407N/A catch (IntrospectionException exception) {
1407N/A throw new Error("unexpected exception", exception);
1407N/A }
1407N/A }
1407N/A
1407N/A public Object getValue() {
1407N/A return null;
1407N/A }
1407N/A
1407N/A public Object setValue(Object value) {
1407N/A return value;
1407N/A }
1407N/A
1407N/A public Object getValues(int index) {
1407N/A return null;
1407N/A }
1407N/A
1407N/A public Object setValues(int index, Object value) {
1407N/A return value;
1407N/A }
1407N/A}