jdk/test/java/beans/Introspector/Test6660539.java
author malenkov
Wed, 29 Apr 2009 20:03:09 +0400
changeset 3438 8bd2d2eeac83
child 5506 202f599c92aa
permissions -rw-r--r--
6660539: Introspector shares cache of mutable BeanInfo between AppContexts. Reviewed-by: peterz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3438
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
     1
/*
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
     2
 * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
     4
 *
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
     8
 *
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    13
 * accompanied this code).
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    14
 *
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    18
 *
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    21
 * have any questions.
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    22
 */
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    23
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    24
/*
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    25
 * @test
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    26
 * @bug 6660539
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    27
 * @summary Tests changeable BeanInfo cache in different application contexts
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    28
 * @author Sergey Malenkov
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    29
 */
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    30
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    31
import sun.awt.SunToolkit;
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    32
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    33
import java.beans.BeanInfo;
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    34
import java.beans.IntrospectionException;
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    35
import java.beans.Introspector;
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    36
import java.beans.PropertyDescriptor;
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    37
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    38
public class Test6660539 implements Runnable {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    39
    private static final String NAME = "$$$";
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    40
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    41
    public static void main(String[] args) throws Exception {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    42
        for (PropertyDescriptor pd : getPropertyDescriptors()) {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    43
            pd.setDisplayName(NAME);
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    44
        }
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    45
        ThreadGroup group = new ThreadGroup(NAME);
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    46
        Thread thread = new Thread(group, new Test6660539());
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    47
        thread.start();
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    48
        thread.join();
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    49
    }
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    50
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    51
    public void run() {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    52
        SunToolkit.createNewAppContext();
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    53
        for (PropertyDescriptor pd : getPropertyDescriptors()) {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    54
            if (pd.getDisplayName().equals(NAME))
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    55
                throw new Error("shared BeanInfo cache");
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    56
        }
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    57
    }
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    58
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    59
    private static PropertyDescriptor[] getPropertyDescriptors() {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    60
        try {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    61
            BeanInfo info = Introspector.getBeanInfo(Test6660539.class);
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    62
            return info.getPropertyDescriptors();
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    63
        }
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    64
        catch (IntrospectionException exception) {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    65
            throw new Error("unexpected", exception);
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    66
        }
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    67
    }
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    68
}