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