6116N/A/*
6116N/A * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
6116N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6116N/A *
6116N/A * This code is free software; you can redistribute it and/or modify it
6116N/A * under the terms of the GNU General Public License version 2 only, as
6116N/A * published by the Free Software Foundation.
6116N/A *
6116N/A * This code is distributed in the hope that it will be useful, but WITHOUT
6116N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6116N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6116N/A * version 2 for more details (a copy is included in the LICENSE file that
6116N/A * accompanied this code).
6116N/A *
6116N/A * You should have received a copy of the GNU General Public License version
6116N/A * 2 along with this work; if not, write to the Free Software Foundation,
6116N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6116N/A *
6116N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6116N/A * or visit www.oracle.com if you need additional information or have any
6116N/A * questions.
6116N/A */
6116N/A
6116N/A/*
6116N/A * @test
6116N/A * @bug 8013416
6116N/A * @summary Tests public synthetic methods
6116N/A * @author Sergey Malenkov
6116N/A */
6116N/A
6116N/Aimport java.beans.DefaultPersistenceDelegate;
6116N/Aimport java.beans.Encoder;
6116N/Aimport java.beans.Expression;
6116N/Aimport java.beans.Statement;
6116N/Aimport java.beans.XMLEncoder;
6116N/Aimport java.util.HashMap;
6116N/Aimport java.util.Map.Entry;
6116N/Aimport java.util.Set;
6116N/A
6116N/Apublic class Test8013416 extends AbstractTest {
6116N/A public static void main(String[] args) {
6116N/A new Test8013416().test(true);
6116N/A }
6116N/A
6116N/A protected Object getObject() {
6116N/A Public<String, String> map = new Public<String, String>();
6116N/A map.put(" pz1 ", " pz2 ");
6116N/A map.put(" pz3 ", " pz4 ");
6116N/A return map;
6116N/A }
6116N/A
6116N/A @Override
6116N/A protected void initialize(XMLEncoder encoder) {
6116N/A super.initialize(encoder);
6116N/A encoder.setPersistenceDelegate(Public.class, new PublicPersistenceDelegate());
6116N/A }
6116N/A
6116N/A private static final class PublicPersistenceDelegate extends DefaultPersistenceDelegate {
6116N/A @Override
6116N/A protected Expression instantiate(Object oldInstance, Encoder out) {
6116N/A return new Expression(oldInstance, oldInstance.getClass(), "new", null);
6116N/A }
6116N/A
6116N/A @Override
6116N/A protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
6116N/A super.initialize(type, oldInstance, newInstance, out);
6116N/A
6116N/A Public<String, String> map = (Public) oldInstance;
6116N/A for (Entry<String, String> entry : map.getAll()) {
6116N/A String[] args = {entry.getKey(), entry.getValue()};
6116N/A out.writeStatement(new Statement(oldInstance, "put", args));
6116N/A }
6116N/A }
6116N/A }
6116N/A
6116N/A public static final class Public<K, V> extends Private<K, V> {
6116N/A }
6116N/A
6116N/A private static class Private<K, V> {
6116N/A private HashMap<K, V> map = new HashMap<K, V>();
6116N/A
6116N/A public void put(K key, V value) {
6116N/A this.map.put(key, value);
6116N/A }
6116N/A
6116N/A public Set<Entry<K, V>> getAll() {
6116N/A return this.map.entrySet();
6116N/A }
6116N/A }
6116N/A}