blob: 12f0112be0dea5961a2cfb77ceb7dc8ef1bc2d4d [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24/*
25 * @test
26 * @bug 6277266
27 * @summary Tests access control issue in EventHandler
28 * @author Jeff Nisewanger
29 */
30
31import java.beans.EventHandler;
32import java.lang.reflect.InvocationTargetException;
33import java.lang.reflect.Proxy;
34import javax.swing.SwingUtilities;
35
36public class Test6277266 {
37 public static void main(String[] args) {
38 System.setSecurityManager(new SecurityManager());
39 try {
40 SwingUtilities.invokeAndWait(
41 (Runnable) Proxy.newProxyInstance(
42 null,
43 new Class[] {Runnable.class},
44 new EventHandler(
45 Test6277266.class,
46 "getProtectionDomain",
47 null,
48 null
49 )
50 )
51 );
52 throw new Error("SecurityException expected");
53 } catch (InvocationTargetException exception) {
54 if (exception.getCause().getCause() instanceof SecurityException){
55 return; // expected security exception
56 }
57 throw new Error("unexpected exception", exception);
58 } catch (InterruptedException exception) {
59 throw new Error("unexpected exception", exception);
60 }
61 }
62}