jdk/test/java/beans/Introspector/Test6660539.java
author malenkov
Fri, 31 Aug 2012 14:49:23 +0400
changeset 13651 cf84d3383a29
parent 11086 09b1d6383d0b
child 23010 6dadb192ad81
permissions -rw-r--r--
7186794: Setter not found. PropertyDescriptor(PropertyDescriptor,PropertyDescriptor) Reviewed-by: rupashka
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
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3438
diff changeset
     2
 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
3438
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3438
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3438
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3438
diff changeset
    21
 * questions.
3438
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 java.beans.BeanInfo;
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    32
import java.beans.IntrospectionException;
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    33
import java.beans.Introspector;
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    34
import java.beans.PropertyDescriptor;
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    35
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    36
public class Test6660539 implements Runnable {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    37
    private static final String NAME = "$$$";
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    38
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    39
    public static void main(String[] args) throws Exception {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    40
        for (PropertyDescriptor pd : getPropertyDescriptors()) {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    41
            pd.setDisplayName(NAME);
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    42
        }
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    43
        ThreadGroup group = new ThreadGroup(NAME);
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    44
        Thread thread = new Thread(group, new Test6660539());
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    45
        thread.start();
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    46
        thread.join();
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    47
    }
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    48
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    49
    public void run() {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    50
        for (PropertyDescriptor pd : getPropertyDescriptors()) {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    51
            if (pd.getDisplayName().equals(NAME))
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    52
                throw new Error("shared BeanInfo cache");
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    53
        }
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    54
    }
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    55
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    56
    private static PropertyDescriptor[] getPropertyDescriptors() {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    57
        try {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    58
            BeanInfo info = Introspector.getBeanInfo(Test6660539.class);
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    59
            return info.getPropertyDescriptors();
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    60
        }
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    61
        catch (IntrospectionException exception) {
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    62
            throw new Error("unexpected", exception);
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
    }
8bd2d2eeac83 6660539: Introspector shares cache of mutable BeanInfo between AppContexts.
malenkov
parents:
diff changeset
    65
}