--- old/jdk/src/share/classes/com/sun/beans/finder/AbstractFinder.java 2013-05-28 20:20:31.426960300 +0400 +++ new/jdk/src/share/classes/com/sun/beans/finder/AbstractFinder.java 2013-05-28 20:20:30.901930200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,9 @@ */ package com.sun.beans.finder; +import java.lang.reflect.Member; +import java.lang.reflect.Modifier; + import java.util.HashMap; import java.util.Map; @@ -37,7 +40,7 @@ * * @author Sergey A. Malenkov */ -abstract class AbstractFinder { +abstract class AbstractFinder { private final Class[] args; /** @@ -81,7 +84,9 @@ * @return {@code true} if the method is valid, * {@code false} otherwise */ - protected abstract boolean isValid(T method); + protected boolean isValid(T method) { + return Modifier.isPublic(method.getModifiers()); + } /** * Performs a search in the {@code methods} array. @@ -120,6 +125,11 @@ boolean useNew = isAssignable(oldParams, newParams); boolean useOld = isAssignable(newParams, oldParams); + if (useOld && useNew) { + // only if parameters are equal + useNew = !newMethod.isSynthetic(); + useOld = !oldMethod.isSynthetic(); + } if (useOld == useNew) { ambiguous = true; } else if (useNew) { @@ -160,6 +170,11 @@ boolean useNew = isAssignable(oldParams, newParams); boolean useOld = isAssignable(newParams, oldParams); + if (useOld && useNew) { + // only if parameters are equal + useNew = !newMethod.isSynthetic(); + useOld = !oldMethod.isSynthetic(); + } if (useOld == useNew) { if (oldParams == map.get(oldMethod)) { ambiguous = true; --- old/jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java 2013-05-28 20:20:35.092169900 +0400 +++ new/jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java 2013-05-28 20:20:34.567139900 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -113,17 +113,4 @@ protected boolean isVarArgs(Constructor constructor) { return constructor.isVarArgs(); } - - /** - * Checks validness of the constructor. - * The valid constructor should be public. - * - * @param constructor the object that represents constructor - * @return {@code true} if the constructor is valid, - * {@code false} otherwise - */ - @Override - protected boolean isValid(Constructor constructor) { - return Modifier.isPublic(constructor.getModifiers()); - } } --- old/jdk/src/share/classes/com/sun/beans/finder/MethodFinder.java 2013-05-28 20:20:38.347356100 +0400 +++ new/jdk/src/share/classes/com/sun/beans/finder/MethodFinder.java 2013-05-28 20:20:37.806325100 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -233,6 +233,6 @@ */ @Override protected boolean isValid(Method method) { - return !method.isBridge() && Modifier.isPublic(method.getModifiers()) && method.getName().equals(this.name); + return super.isValid(method) && method.getName().equals(this.name); } } --- /dev/null 2013-05-28 20:20:42.000000000 +0400 +++ new/jdk/test/java/beans/XMLEncoder/Test8013416.java 2013-05-28 20:20:41.645544700 +0400 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8013416 + * @summary Tests public synthetic methods + * @author Sergey Malenkov + */ + +import java.beans.DefaultPersistenceDelegate; +import java.beans.Encoder; +import java.beans.Expression; +import java.beans.Statement; +import java.beans.XMLEncoder; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Set; + +public class Test8013416 extends AbstractTest { + public static void main(String[] args) { + new Test8013416().test(true); + } + + protected Object getObject() { + Public map = new Public(); + map.put(" pz1 ", " pz2 "); + map.put(" pz3 ", " pz4 "); + return map; + } + + @Override + protected void initialize(XMLEncoder encoder) { + super.initialize(encoder); + encoder.setPersistenceDelegate(Public.class, new PublicPersistenceDelegate()); + } + + private static final class PublicPersistenceDelegate extends DefaultPersistenceDelegate { + @Override + protected Expression instantiate(Object oldInstance, Encoder out) { + return new Expression(oldInstance, oldInstance.getClass(), "new", null); + } + + @Override + protected void initialize(Class type, Object oldInstance, Object newInstance, Encoder out) { + super.initialize(type, oldInstance, newInstance, out); + + Public map = (Public) oldInstance; + for (Entry entry : map.getAll()) { + String[] args = {entry.getKey(), entry.getValue()}; + out.writeStatement(new Statement(oldInstance, "put", args)); + } + } + } + + public static final class Public extends Private { + } + + private static class Private { + private HashMap map = new HashMap(); + + public void put(K key, V value) { + this.map.put(key, value); + } + + public Set> getAll() { + return this.map.entrySet(); + } + } +}