8051626: Rework security restrictions of Java Access Bridge and related Utilities

Move non-public code to internal directories; restrict those directories

Reviewed-by: mchung, prr, mullan, serb
This commit is contained in:
Peter Brunet 2015-08-14 13:59:40 -05:00 committed by Pete Brunet
parent 0e680c10d5
commit 9de97cfe33
14 changed files with 141 additions and 56 deletions

View File

@ -246,6 +246,10 @@ package.access=sun.,\
jdk.nashorn.tools.,\
jdk.tools.jimage.,\
com.sun.activation.registries.,\
com.sun.java.accessibility.util.internal.,\
#ifdef windows
com.sun.java.accessibility.internal.,\
#endif
#ifdef macosx
apple.,\
#endif
@ -297,6 +301,10 @@ package.definition=sun.,\
jdk.nashorn.tools.,\
jdk.tools.jimage.,\
com.sun.activation.registries.,\
com.sun.java.accessibility.util.internal.,\
#ifdef windows
com.sun.java.accessibility.internal.,\
#endif
#ifdef macosx
apple.,\
#endif

View File

@ -78,8 +78,8 @@ public class Translator extends AccessibleContext
return null;
}
try {
t = Class.forName("com.sun.java.accessibility.util."
+ c.getName()
t = Class.forName("com.sun.java.accessibility.util.internal"
+ c.getSimpleName()
+ "Translator");
return t;
} catch (Exception e) {

View File

@ -23,7 +23,7 @@
* questions.
*/
package com.sun.java.accessibility.util.java.awt;
package com.sun.java.accessibility.util.internal;
import java.lang.*;
import java.util.*;

View File

@ -23,7 +23,7 @@
* questions.
*/
package com.sun.java.accessibility.util.java.awt;
package com.sun.java.accessibility.util.internal;
import java.lang.*;
import java.util.*;

View File

@ -23,7 +23,7 @@
* questions.
*/
package com.sun.java.accessibility.util.java.awt;
package com.sun.java.accessibility.util.internal;
import java.lang.*;
import java.util.*;

View File

@ -23,7 +23,7 @@
* questions.
*/
package com.sun.java.accessibility.util.java.awt;
package com.sun.java.accessibility.util.internal;
import java.lang.*;
import java.util.*;

View File

@ -23,7 +23,7 @@
* questions.
*/
package com.sun.java.accessibility.util.java.awt;
package com.sun.java.accessibility.util.internal;
import java.lang.*;
import java.util.*;

View File

@ -22,5 +22,5 @@
# questions.
com.sun.java.accessibility.ProviderImpl
com.sun.java.accessibility.internal.ProviderImpl

View File

@ -23,7 +23,7 @@
* questions.
*/
package com.sun.java.accessibility;
package com.sun.java.accessibility.internal;
import java.awt.*;
import java.awt.event.*;

View File

@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.java.accessibility;
package com.sun.java.accessibility.internal;
import javax.accessibility.AccessibilityProvider;

View File

@ -37,7 +37,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) {
// Determine bitness of Win OS
JNIEXPORT jboolean JNICALL
Java_com_sun_java_accessibility_AccessBridge_isSysWow(JNIEnv *env, jobject callingObj) {
Java_com_sun_java_accessibility_internal_AccessBridge_isSysWow(JNIEnv *env, jobject callingObj) {
BOOL bIsWow64 = FALSE;
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);

View File

@ -103,7 +103,7 @@ AccessBridgeJavaEntryPoints::BuildJavaEntryPoints() {
PrintDebugString("Calling BuildJavaEntryPoints():");
FIND_CLASS(bridgeClass, "com/sun/java/accessibility/AccessBridge");
FIND_CLASS(bridgeClass, "com/sun/java/accessibility/internal/AccessBridge");
// ------- general methods

View File

@ -30,7 +30,7 @@
#include "AccessBridgeDebug.h"
#include "JavaAccessBridge.h"
#include "com_sun_java_accessibility_AccessBridge.h" // programatically generated by JNI
#include "com_sun_java_accessibility_internal_AccessBridge.h" // programatically generated by JNI
#include "accessBridgeResource.h"
#include "accessBridgeCallbacks.h"
#include "AccessBridgeMessages.h"
@ -84,7 +84,7 @@ extern "C" {
*
*/
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_runDLL(JNIEnv *env, jobject obj) {
Java_com_sun_java_accessibility_internal_AccessBridge_runDLL(JNIEnv *env, jobject obj) {
PrintDebugString("\r\nJavaAccessBridge.DLL runDLL() called");
theJavaAccessBridge->javaRun(env, obj);
}
@ -1711,7 +1711,7 @@ JavaAccessBridge::firePropertyCaretChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jint oldValue, jint newValue) {
PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyCaretChanged(%p, %p, %p, %p, %d, %d)",
PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyCaretChanged(%p, %p, %p, %p, %d, %d)",
env, callingObj, event,
source, oldValue, newValue);
@ -1765,7 +1765,7 @@ JavaAccessBridge::firePropertyDescriptionChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jstring oldValue, jstring newValue){
PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyDescriptionChanged(%p, %p, %p, %p, %p, %p)",
PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyDescriptionChanged(%p, %p, %p, %p, %p, %p)",
env, callingObj, event,
source, oldValue, newValue);
@ -1851,7 +1851,7 @@ JavaAccessBridge::firePropertyNameChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jstring oldValue, jstring newValue){
PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyNameChanged(%p, %p, %p, %p, %p, %p)",
PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyNameChanged(%p, %p, %p, %p, %p, %p)",
env, callingObj, event,
source, oldValue, newValue);
@ -1937,7 +1937,7 @@ void
JavaAccessBridge::firePropertySelectionChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source) {
PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertySelectionChanged(%p, %p, %p, %p)",
PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertySelectionChanged(%p, %p, %p, %p)",
env, callingObj, event, source);
// sanity check
@ -1988,7 +1988,7 @@ JavaAccessBridge::firePropertyStateChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jstring oldValue, jstring newValue){
PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyStateChanged(%p, %p, %p, %p, %p, %p)",
PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyStateChanged(%p, %p, %p, %p, %p, %p)",
env, callingObj, event,
source, oldValue, newValue);
@ -2074,7 +2074,7 @@ void
JavaAccessBridge::firePropertyTextChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source) {
PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyTextChanged(%p, %p, %p, %p)",
PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyTextChanged(%p, %p, %p, %p)",
env, callingObj, event, source);
// sanity check
@ -2125,7 +2125,7 @@ JavaAccessBridge::firePropertyValueChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jstring oldValue, jstring newValue){
PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyValueChanged(%p, %p, %p, %p, %p, %p)",
PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyValueChanged(%p, %p, %p, %p, %p, %p)",
env, callingObj, event,
source, oldValue, newValue);
@ -2210,7 +2210,7 @@ void
JavaAccessBridge::firePropertyVisibleDataChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source) {
PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyVisibleDataChanged(%p, %p, %p, %p)",
PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyVisibleDataChanged(%p, %p, %p, %p)",
env, callingObj, event, source);
// sanity check
@ -2261,7 +2261,7 @@ JavaAccessBridge::firePropertyChildChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jobject oldValue, jobject newValue){
PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyChildPropertyChanged(%p, %p, %p, %p, %p, %p)",
PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyChildPropertyChanged(%p, %p, %p, %p, %p, %p)",
env, callingObj, event,
source, oldValue, newValue);
@ -2319,7 +2319,7 @@ JavaAccessBridge::firePropertyActiveDescendentChange(JNIEnv *env, jobject callin
jobject event, jobject source,
jobject oldValue, jobject newValue){
PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyActiveDescendentPropertyChanged(%p, %p, %p, %p, %p, %p)",
PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyActiveDescendentPropertyChanged(%p, %p, %p, %p, %p, %p)",
env, callingObj, event,
source, oldValue, newValue);
@ -2376,7 +2376,7 @@ JavaAccessBridge::firePropertyTableModelChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jstring oldValue, jstring newValue){
PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyTableModelChange(%p, %p, %p, %p, %p, %p)",
PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyTableModelChange(%p, %p, %p, %p, %p, %p)",
env, callingObj, event,
source, oldValue, newValue);
@ -2557,7 +2557,7 @@ JavaAccessBridge::firePropertyTableModelChange(JNIEnv *env, jobject callingObj,
extern "C" { // event stuff from AccessBridge.h, generated by JNI
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_sendDebugString(JNIEnv *env, jobject callingObj, jstring debugStr) {
Java_com_sun_java_accessibility_internal_AccessBridge_sendDebugString(JNIEnv *env, jobject callingObj, jstring debugStr) {
const wchar_t *stringBytes;
stringBytes = (const wchar_t *) env->GetStringChars(debugStr, 0);
@ -2575,7 +2575,7 @@ extern "C" { // event stuff from AccessBridge.h, generated by JNI
}
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_propertyCaretChange(JNIEnv *env, jobject callingObj,
Java_com_sun_java_accessibility_internal_AccessBridge_propertyCaretChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jint oldValue, jint newValue) {
theJavaAccessBridge->firePropertyCaretChange(env, callingObj,
@ -2584,7 +2584,7 @@ extern "C" { // event stuff from AccessBridge.h, generated by JNI
}
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_propertyDescriptionChange(JNIEnv *env, jobject callingObj,
Java_com_sun_java_accessibility_internal_AccessBridge_propertyDescriptionChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jstring oldValue, jstring newValue) {
theJavaAccessBridge->firePropertyDescriptionChange(env, callingObj,
@ -2593,7 +2593,7 @@ extern "C" { // event stuff from AccessBridge.h, generated by JNI
}
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_propertyNameChange(JNIEnv *env, jobject callingObj,
Java_com_sun_java_accessibility_internal_AccessBridge_propertyNameChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jstring oldValue, jstring newValue) {
theJavaAccessBridge->firePropertyNameChange(env, callingObj,
@ -2602,14 +2602,14 @@ extern "C" { // event stuff from AccessBridge.h, generated by JNI
}
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_propertySelectionChange(JNIEnv *env, jobject callingObj,
Java_com_sun_java_accessibility_internal_AccessBridge_propertySelectionChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source) {
theJavaAccessBridge->firePropertySelectionChange(env, callingObj,
event, source);
}
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_propertyStateChange(JNIEnv *env, jobject callingObj,
Java_com_sun_java_accessibility_internal_AccessBridge_propertyStateChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jstring oldValue, jstring newValue) {
theJavaAccessBridge->firePropertyStateChange(env, callingObj,
@ -2618,14 +2618,14 @@ extern "C" { // event stuff from AccessBridge.h, generated by JNI
}
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_propertyTextChange(JNIEnv *env, jobject callingObj,
Java_com_sun_java_accessibility_internal_AccessBridge_propertyTextChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source) {
theJavaAccessBridge->firePropertyTextChange(env, callingObj,
event, source);
}
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_propertyValueChange(JNIEnv *env, jobject callingObj,
Java_com_sun_java_accessibility_internal_AccessBridge_propertyValueChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jstring oldValue, jstring newValue) {
theJavaAccessBridge->firePropertyValueChange(env, callingObj,
@ -2634,14 +2634,14 @@ extern "C" { // event stuff from AccessBridge.h, generated by JNI
}
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_propertyVisibleDataChange(JNIEnv *env, jobject callingObj,
Java_com_sun_java_accessibility_internal_AccessBridge_propertyVisibleDataChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source) {
theJavaAccessBridge->firePropertyVisibleDataChange(env, callingObj,
event, source);
}
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_propertyChildChange(JNIEnv *env, jobject callingObj,
Java_com_sun_java_accessibility_internal_AccessBridge_propertyChildChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jobject oldValue, jobject newValue) {
theJavaAccessBridge->firePropertyChildChange(env, callingObj,
@ -2650,7 +2650,7 @@ extern "C" { // event stuff from AccessBridge.h, generated by JNI
}
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_propertyActiveDescendentChange(JNIEnv *env, jobject callingObj,
Java_com_sun_java_accessibility_internal_AccessBridge_propertyActiveDescendentChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jobject oldValue,
jobject newValue) {
@ -2660,7 +2660,7 @@ extern "C" { // event stuff from AccessBridge.h, generated by JNI
}
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_propertyTableModelChange(JNIEnv *env, jobject callingObj,
Java_com_sun_java_accessibility_internal_AccessBridge_propertyTableModelChange(JNIEnv *env, jobject callingObj,
jobject event, jobject source,
jstring oldValue, jstring newValue) {
@ -2677,34 +2677,34 @@ extern "C" { // event stuff from AccessBridge.h, generated by JNI
JNIEXPORT void JNICALL
Java_com_sun_java_accessibility_AccessBridge_javaShutdown(JNIEnv *env, jobject callingObj) {
Java_com_sun_java_accessibility_internal_AccessBridge_javaShutdown(JNIEnv *env, jobject callingObj) {
theJavaAccessBridge->javaShutdown(env, callingObj);
}
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_focusGained, fireFocusGained)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_focusLost, fireFocusLost)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_caretUpdate, fireCaretUpdate)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_mouseClicked, fireMouseClicked)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_mouseEntered, fireMouseEntered)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_mouseExited, fireMouseExited)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_mousePressed, fireMousePressed)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_mouseReleased, fireMouseReleased)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_menuCanceled, fireMenuCanceled)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_menuDeselected, fireMenuDeselected)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_menuSelected, fireMenuSelected)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_popupMenuCanceled, firePopupMenuCanceled)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_popupMenuWillBecomeInvisible, firePopupMenuWillBecomeInvisible)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_popupMenuWillBecomeVisible, firePopupMenuWillBecomeVisible)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_focusGained, fireFocusGained)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_focusLost, fireFocusLost)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_caretUpdate, fireCaretUpdate)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_mouseClicked, fireMouseClicked)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_mouseEntered, fireMouseEntered)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_mouseExited, fireMouseExited)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_mousePressed, fireMousePressed)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_mouseReleased, fireMouseReleased)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_menuCanceled, fireMenuCanceled)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_menuDeselected, fireMenuDeselected)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_menuSelected, fireMenuSelected)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_popupMenuCanceled, firePopupMenuCanceled)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_popupMenuWillBecomeInvisible, firePopupMenuWillBecomeInvisible)
HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_popupMenuWillBecomeVisible, firePopupMenuWillBecomeVisible)
/*
* Map a HWND to a Java component
*
* Class: com_sun_java_accessibility_AccessBridge
* Class: com_sun_java_accessibility_internal_AccessBridge
* Method: jawtGetComponentFromNativeWindowHandle
* Signature: (I)Ljava/awt/Component;
*/
JNIEXPORT jobject JNICALL
Java_com_sun_java_accessibility_AccessBridge_jawtGetComponentFromNativeWindowHandle
Java_com_sun_java_accessibility_internal_AccessBridge_jawtGetComponentFromNativeWindowHandle
(JNIEnv *env, jobject callingObj, jint windowHandle) {
JAWT awt;
@ -2726,12 +2726,12 @@ extern "C" { // event stuff from AccessBridge.h, generated by JNI
/*
* Map a Java component to a HWND
*
* Class: com_sun_java_accessibility_AccessBridge
* Class: com_sun_java_accessibility_internal_AccessBridge
* Method: jawtGetNativeWindowHandleFromComponent
* Signature: (Ljava/awt/Component;)I
*/
JNIEXPORT jint JNICALL
Java_com_sun_java_accessibility_AccessBridge_jawtGetNativeWindowHandleFromComponent
Java_com_sun_java_accessibility_internal_AccessBridge_jawtGetNativeWindowHandleFromComponent
(JNIEnv *env, jobject callingObj, jobject component) {
JAWT awt;

View File

@ -0,0 +1,77 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8051626
* @summary Ensure no failure when using Java Accessibility Utility with security manager
* @modules java.desktop jdk.accessibility
*
* @run main/othervm Bug8051626
*/
import com.sun.java.accessibility.util.AWTEventMonitor;
import java.awt.Dimension;
import java.lang.reflect.InvocationTargetException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class Bug8051626 {
public static void main(final String[] args) throws InterruptedException,
InvocationTargetException {
final Bug8051626 app = new Bug8051626();
app.test();
}
private void test() throws InterruptedException, InvocationTargetException {
System.setSecurityManager(new SecurityManager());
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
final JFrame frame = new JFrame("Bug 8051626");
try {
final JPanel panel = new JPanel();
final JButton okButton = new JButton("OK");
panel.add(okButton);
frame.getContentPane().add(panel);
frame.setMinimumSize(new Dimension(300, 180));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocation(400, 300);
frame.setVisible(true);
// If the security manager is on this should not cause an exception.
// Prior to the 8051626 fix it would as follows:
// java.security.AccessControlException:
// access denied ("java.lang.RuntimePermission" "accessClassInPackage.com.sun.java.accessibility.util")
AWTEventMonitor.getComponentWithFocus();
} finally {
frame.dispose();
}
}
});
}
}