Merge
This commit is contained in:
commit
ae0dd64548
@ -32,6 +32,7 @@ import java.util.List;
|
||||
import javax.swing.RootPaneContainer;
|
||||
|
||||
import com.apple.eawt.AppEvent.FullScreenEvent;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.lang.annotation.Native;
|
||||
|
||||
@ -75,7 +76,7 @@ final class FullScreenHandler {
|
||||
static void handleFullScreenEventFromNative(final Window window, final int type) {
|
||||
if (!(window instanceof RootPaneContainer)) return; // handles null
|
||||
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
SunToolkit.executeOnEventHandlerThread(window, new Runnable() {
|
||||
public void run() {
|
||||
final FullScreenHandler handler = getHandlerFor((RootPaneContainer)window);
|
||||
if (handler != null) handler.notifyListener(new FullScreenEvent(window), type);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2013, 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
|
||||
@ -31,6 +31,8 @@ import java.io.File;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import com.apple.eawt.AppEvent.*;
|
||||
|
||||
@ -269,11 +271,9 @@ class _AppEventHandler {
|
||||
}
|
||||
|
||||
class _AppReOpenedDispatcher extends _AppEventMultiplexor<AppReOpenedListener> {
|
||||
void performOnListeners(final List<AppReOpenedListener> listeners, final _NativeEvent event) {
|
||||
void performOnListener(AppReOpenedListener listener, final _NativeEvent event) {
|
||||
final AppReOpenedEvent e = new AppReOpenedEvent();
|
||||
for (final AppReOpenedListener listener : listeners) {
|
||||
listener.appReOpened(e);
|
||||
}
|
||||
listener.appReOpened(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,50 +415,67 @@ class _AppEventHandler {
|
||||
}
|
||||
|
||||
abstract class _AppEventMultiplexor<L> {
|
||||
final List<L> _listeners = new ArrayList<L>(0);
|
||||
private final Map<L, AppContext> listenerToAppContext =
|
||||
new IdentityHashMap<L, AppContext>();
|
||||
boolean nativeListenerRegistered;
|
||||
|
||||
// called from AppKit Thread-0
|
||||
void dispatch(final _NativeEvent event, final Object... args) {
|
||||
// grab a local ref to the listeners
|
||||
final List<L> localListeners;
|
||||
// grab a local ref to the listeners and its contexts as an array of the map's entries
|
||||
final ArrayList<Map.Entry<L, AppContext>> localEntries;
|
||||
synchronized (this) {
|
||||
if (_listeners.size() == 0) return;
|
||||
localListeners = new ArrayList<L>(_listeners);
|
||||
if (listenerToAppContext.size() == 0) {
|
||||
return;
|
||||
}
|
||||
localEntries = new ArrayList<Map.Entry<L, AppContext>>(listenerToAppContext.size());
|
||||
localEntries.addAll(listenerToAppContext.entrySet());
|
||||
}
|
||||
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
performOnListeners(localListeners, event);
|
||||
}
|
||||
});
|
||||
for (final Map.Entry<L, AppContext> e : localEntries) {
|
||||
final L listener = e.getKey();
|
||||
final AppContext listenerContext = e.getValue();
|
||||
SunToolkit.invokeLaterOnAppContext(listenerContext, new Runnable() {
|
||||
public void run() {
|
||||
performOnListener(listener, event);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
synchronized void addListener(final L listener) {
|
||||
setListenerContext(listener, AppContext.getAppContext());
|
||||
|
||||
if (!nativeListenerRegistered) {
|
||||
registerNativeListener();
|
||||
nativeListenerRegistered = true;
|
||||
}
|
||||
_listeners.add(listener);
|
||||
}
|
||||
|
||||
synchronized void removeListener(final L listener) {
|
||||
_listeners.remove(listener);
|
||||
listenerToAppContext.remove(listener);
|
||||
}
|
||||
|
||||
abstract void performOnListeners(final List<L> listeners, final _NativeEvent event);
|
||||
abstract void performOnListener(L listener, final _NativeEvent event);
|
||||
void registerNativeListener() { }
|
||||
|
||||
private void setListenerContext(L listener, AppContext listenerContext) {
|
||||
if (listenerContext == null) {
|
||||
throw new RuntimeException(
|
||||
"Attempting to add a listener from a thread group without AppContext");
|
||||
}
|
||||
listenerToAppContext.put(listener, AppContext.getAppContext());
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _BooleanAppEventMultiplexor<L, E> extends _AppEventMultiplexor<L> {
|
||||
@Override
|
||||
void performOnListeners(final List<L> listeners, final _NativeEvent event) {
|
||||
void performOnListener(L listener, final _NativeEvent event) {
|
||||
final boolean isTrue = Boolean.TRUE.equals(event.get(0));
|
||||
final E e = createEvent(isTrue);
|
||||
if (isTrue) {
|
||||
for (final L listener : listeners) performTrueEventOn(listener, e);
|
||||
performTrueEventOn(listener, e);
|
||||
} else {
|
||||
for (final L listener : listeners) performFalseEventOn(listener, e);
|
||||
performFalseEventOn(listener, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -479,30 +496,34 @@ class _AppEventHandler {
|
||||
*/
|
||||
abstract class _AppEventDispatcher<H> {
|
||||
H _handler;
|
||||
AppContext handlerContext;
|
||||
|
||||
// called from AppKit Thread-0
|
||||
void dispatch(final _NativeEvent event) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
// grab a local ref to the handler
|
||||
final H localHandler;
|
||||
synchronized (_AppEventDispatcher.this) {
|
||||
localHandler = _handler;
|
||||
}
|
||||
// grab a local ref to the handler
|
||||
final H localHandler;
|
||||
final AppContext localHandlerContext;
|
||||
synchronized (_AppEventDispatcher.this) {
|
||||
localHandler = _handler;
|
||||
localHandlerContext = handlerContext;
|
||||
}
|
||||
|
||||
// invoke the handler outside of the synchronized block
|
||||
if (localHandler == null) {
|
||||
performDefaultAction(event);
|
||||
} else {
|
||||
if (localHandler == null) {
|
||||
performDefaultAction(event);
|
||||
} else {
|
||||
SunToolkit.invokeLaterOnAppContext(localHandlerContext, new Runnable() {
|
||||
public void run() {
|
||||
performUsing(localHandler, event);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
synchronized void setHandler(final H handler) {
|
||||
this._handler = handler;
|
||||
|
||||
setHandlerContext(AppContext.getAppContext());
|
||||
|
||||
// if a new handler is installed, block addition of legacy ApplicationListeners
|
||||
if (handler == legacyHandler) return;
|
||||
legacyHandler.blockLegacyAPI();
|
||||
@ -510,6 +531,15 @@ class _AppEventHandler {
|
||||
|
||||
void performDefaultAction(final _NativeEvent event) { } // by default, do nothing
|
||||
abstract void performUsing(final H handler, final _NativeEvent event);
|
||||
|
||||
protected void setHandlerContext(AppContext ctx) {
|
||||
if (ctx == null) {
|
||||
throw new RuntimeException(
|
||||
"Attempting to set a handler from a thread group without AppContext");
|
||||
}
|
||||
|
||||
handlerContext = ctx;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _QueuingAppEventDispatcher<H> extends _AppEventDispatcher<H> {
|
||||
@ -531,6 +561,8 @@ class _AppEventHandler {
|
||||
synchronized void setHandler(final H handler) {
|
||||
this._handler = handler;
|
||||
|
||||
setHandlerContext(AppContext.getAppContext());
|
||||
|
||||
// dispatch any events in the queue
|
||||
if (queuedEvents != null) {
|
||||
// grab a local ref to the queue, so the real one can be nulled out
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
package com.apple.eawt.event;
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
@ -70,7 +72,7 @@ final class GestureHandler {
|
||||
static void handleGestureFromNative(final Window window, final int type, final double x, final double y, final double a, final double b) {
|
||||
if (window == null) return; // should never happen...
|
||||
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
SunToolkit.executeOnEventHandlerThread(window, new Runnable() {
|
||||
public void run() {
|
||||
final Component component = SwingUtilities.getDeepestComponentAt(window, (int)x, (int)y);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2013, 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
|
||||
@ -32,6 +32,7 @@ import java.util.Hashtable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.lwawt.LWToolkit;
|
||||
import sun.lwawt.macosx.*;
|
||||
|
||||
@ -144,7 +145,7 @@ class ScreenMenu extends Menu implements ContainerListener, ComponentListener, S
|
||||
updateItems();
|
||||
fItemBounds = new Rectangle[invoker.getMenuComponentCount()];
|
||||
}
|
||||
}, null);
|
||||
}, invoker);
|
||||
} catch (final Exception e) {
|
||||
System.err.println(e);
|
||||
e.printStackTrace();
|
||||
@ -172,7 +173,7 @@ class ScreenMenu extends Menu implements ContainerListener, ComponentListener, S
|
||||
|
||||
fItemBounds = null;
|
||||
}
|
||||
}, null);
|
||||
}, invoker);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -200,7 +201,7 @@ class ScreenMenu extends Menu implements ContainerListener, ComponentListener, S
|
||||
if (kind == 0) return;
|
||||
if (fItemBounds == null) return;
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Component target = null;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2013, 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
|
||||
@ -53,7 +53,7 @@ public class CCheckboxMenuItem extends CMenuItem implements CheckboxMenuItemPeer
|
||||
|
||||
public void handleAction(final boolean state) {
|
||||
final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
|
||||
public void run() {
|
||||
target.setState(state);
|
||||
}
|
||||
|
@ -107,10 +107,6 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
|
||||
loc = rootComponent.getLocation();
|
||||
}
|
||||
|
||||
//It sure will be LWComponentPeer instance as rootComponent is a Window
|
||||
PlatformWindow platformWindow = ((LWComponentPeer)rootComponent.getPeer()).getPlatformWindow();
|
||||
long nativeViewPtr = CPlatformWindow.getNativeViewPtr(platformWindow);
|
||||
|
||||
// If there isn't any drag image make one of default appearance:
|
||||
if (fDragImage == null)
|
||||
this.setDefaultDragImage(component);
|
||||
@ -137,6 +133,11 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
|
||||
}
|
||||
|
||||
try {
|
||||
//It sure will be LWComponentPeer instance as rootComponent is a Window
|
||||
PlatformWindow platformWindow = ((LWComponentPeer)rootComponent.getPeer()).getPlatformWindow();
|
||||
long nativeViewPtr = CPlatformWindow.getNativeViewPtr(platformWindow);
|
||||
if (nativeViewPtr == 0L) throw new InvalidDnDOperationException("Unsupported platform window implementation");
|
||||
|
||||
// Create native dragging source:
|
||||
final long nativeDragSource = createNativeDragSource(component, nativeViewPtr, transferable, triggerEvent,
|
||||
(int) (dragOrigin.getX()), (int) (dragOrigin.getY()), extModifiers,
|
||||
|
@ -52,6 +52,8 @@ public final class CDropTarget {
|
||||
fPeer = peer;
|
||||
|
||||
long nativePeer = CPlatformWindow.getNativeViewPtr(((LWComponentPeer) peer).getPlatformWindow());
|
||||
if (nativePeer == 0L) return; // Unsupported for a window without a native view (plugin)
|
||||
|
||||
// Create native dragging destination:
|
||||
fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer);
|
||||
if (fNativeDropTarget == 0) {
|
||||
|
@ -479,12 +479,14 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
deliverZoom(true);
|
||||
|
||||
this.normalBounds = peer.getBounds();
|
||||
long screen = CWrapper.NSWindow.screen(getNSWindowPtr());
|
||||
Rectangle toBounds = CWrapper.NSScreen.visibleFrame(screen).getBounds();
|
||||
// Flip the y coordinate
|
||||
Rectangle frame = CWrapper.NSScreen.frame(screen).getBounds();
|
||||
toBounds.y = frame.height - toBounds.y - toBounds.height;
|
||||
setBounds(toBounds.x, toBounds.y, toBounds.width, toBounds.height);
|
||||
|
||||
GraphicsConfiguration config = getPeer().getGraphicsConfiguration();
|
||||
Insets i = ((CGraphicsDevice)config.getDevice()).getScreenInsets();
|
||||
Rectangle toBounds = config.getBounds();
|
||||
setBounds(toBounds.x + i.left,
|
||||
toBounds.y + i.top,
|
||||
toBounds.width - i.left - i.right,
|
||||
toBounds.height - i.top - i.bottom);
|
||||
}
|
||||
}
|
||||
|
||||
@ -751,13 +753,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
// the move/size notification from the underlying system comes
|
||||
// but it contains a bounds smaller than the whole screen
|
||||
// and therefore we need to create the synthetic notifications
|
||||
Rectangle screenBounds;
|
||||
final long screenPtr = CWrapper.NSWindow.screen(getNSWindowPtr());
|
||||
try {
|
||||
screenBounds = CWrapper.NSScreen.frame(screenPtr).getBounds();
|
||||
} finally {
|
||||
CWrapper.NSObject.release(screenPtr);
|
||||
}
|
||||
Rectangle screenBounds = getPeer().getGraphicsConfiguration().getBounds();
|
||||
peer.notifyReshape(screenBounds.x, screenBounds.y, screenBounds.width,
|
||||
screenBounds.height);
|
||||
}
|
||||
@ -900,8 +896,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
nativePeer = ((CPlatformWindow) platformWindow).getContentView().getAWTView();
|
||||
} else if (platformWindow instanceof CViewPlatformEmbeddedFrame){
|
||||
nativePeer = ((CViewPlatformEmbeddedFrame) platformWindow).getNSViewPtr();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported platformWindow implementation");
|
||||
}
|
||||
return nativePeer;
|
||||
}
|
||||
@ -932,25 +926,19 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
|
||||
final Rectangle oldB = nativeBounds;
|
||||
nativeBounds = new Rectangle(x, y, width, height);
|
||||
final GraphicsConfiguration oldGC = peer.getGraphicsConfiguration();
|
||||
|
||||
final GraphicsConfiguration newGC = peer.getGraphicsConfiguration();
|
||||
// System-dependent appearance optimization.
|
||||
if (peer != null) {
|
||||
peer.notifyReshape(x, y, width, height);
|
||||
}
|
||||
|
||||
if ((byUser && !oldB.getSize().equals(nativeBounds.getSize()))
|
||||
|| isFullScreenAnimationOn || !Objects.equals(newGC, oldGC)) {
|
||||
flushBuffers();
|
||||
// System-dependent appearance optimization.
|
||||
if ((byUser && !oldB.getSize().equals(nativeBounds.getSize()))
|
||||
|| isFullScreenAnimationOn) {
|
||||
flushBuffers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deliverWindowClosingEvent() {
|
||||
if (peer != null) {
|
||||
if (peer.getBlocker() == null) {
|
||||
peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING));
|
||||
}
|
||||
if (peer != null && peer.getBlocker() == null) {
|
||||
peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2013, 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
|
||||
@ -96,7 +96,7 @@ public class CViewEmbeddedFrame extends EmbeddedFrame {
|
||||
validate();
|
||||
setVisible(true);
|
||||
}
|
||||
}, null);
|
||||
}, this);
|
||||
} catch (InterruptedException | InvocationTargetException ex) {}
|
||||
}
|
||||
}
|
||||
|
@ -71,8 +71,6 @@ public final class CWrapper {
|
||||
public static native void zoom(long window);
|
||||
|
||||
public static native void makeFirstResponder(long window, long responder);
|
||||
|
||||
public static native long screen(long window);
|
||||
}
|
||||
|
||||
public static final class NSView {
|
||||
@ -95,12 +93,6 @@ public final class CWrapper {
|
||||
public static native void release(long object);
|
||||
}
|
||||
|
||||
public static final class NSScreen {
|
||||
public static native Rectangle2D frame(long screen);
|
||||
public static native Rectangle2D visibleFrame(long screen);
|
||||
public static native long screenByDisplayId(int displayID);
|
||||
}
|
||||
|
||||
public static final class NSColor {
|
||||
public static native long clearColor();
|
||||
}
|
||||
|
@ -82,8 +82,13 @@ JNF_COCOA_ENTER(env);
|
||||
// keys, so we need to do the same translation here that we do
|
||||
// for the regular key down events
|
||||
if ([eventKey length] == 1) {
|
||||
unichar ch = NsCharToJavaChar([eventKey characterAtIndex:0], 0);
|
||||
eventKey = [NSString stringWithCharacters: &ch length: 1];
|
||||
unichar origChar = [eventKey characterAtIndex:0];
|
||||
unichar newChar = NsCharToJavaChar(origChar, 0);
|
||||
if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
|
||||
newChar = origChar;
|
||||
}
|
||||
|
||||
eventKey = [NSString stringWithCharacters: &newChar length: 1];
|
||||
}
|
||||
|
||||
if ([menuKey isEqualToString:eventKey]) {
|
||||
|
@ -396,31 +396,6 @@ JNF_COCOA_ENTER(env);
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CWrapper$NSWindow
|
||||
* Method: screen
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_screen
|
||||
(JNIEnv *env, jclass cls, jlong windowPtr)
|
||||
{
|
||||
__block jlong screenPtr = 0L;
|
||||
|
||||
JNF_COCOA_ENTER(env);
|
||||
|
||||
AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
|
||||
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
||||
const NSScreen *screen = [window screen];
|
||||
CFRetain(screen); // GC
|
||||
screenPtr = ptr_to_jlong(screen);
|
||||
}];
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
|
||||
return screenPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Method: miniaturize
|
||||
* Signature: (J)V
|
||||
@ -690,92 +665,6 @@ JNF_COCOA_ENTER(env);
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CWrapper$NSScreen
|
||||
* Method: frame
|
||||
* Signature: (J)Ljava/awt/Rectangle;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_sun_lwawt_macosx_CWrapper_00024NSScreen_frame
|
||||
(JNIEnv *env, jclass cls, jlong screenPtr)
|
||||
{
|
||||
jobject jRect = NULL;
|
||||
|
||||
JNF_COCOA_ENTER(env);
|
||||
|
||||
__block NSRect rect = NSZeroRect;
|
||||
|
||||
NSScreen *screen = (NSScreen *)jlong_to_ptr(screenPtr);
|
||||
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
||||
rect = [screen frame];
|
||||
}];
|
||||
|
||||
jRect = NSToJavaRect(env, rect);
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
|
||||
return jRect;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CWrapper_NSScreen
|
||||
* Method: visibleFrame
|
||||
* Signature: (J)Ljava/awt/geom/Rectangle2D;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_sun_lwawt_macosx_CWrapper_00024NSScreen_visibleFrame
|
||||
(JNIEnv *env, jclass cls, jlong screenPtr)
|
||||
{
|
||||
jobject jRect = NULL;
|
||||
|
||||
JNF_COCOA_ENTER(env);
|
||||
|
||||
__block NSRect rect = NSZeroRect;
|
||||
|
||||
NSScreen *screen = (NSScreen *)jlong_to_ptr(screenPtr);
|
||||
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
||||
rect = [screen visibleFrame];
|
||||
}];
|
||||
|
||||
jRect = NSToJavaRect(env, rect);
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
|
||||
return jRect;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CWrapper_NSScreen
|
||||
* Method: screenByDisplayId
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_sun_lwawt_macosx_CWrapper_00024NSScreen_screenByDisplayId
|
||||
(JNIEnv *env, jclass cls, jint displayID)
|
||||
{
|
||||
__block jlong screenPtr = 0L;
|
||||
|
||||
JNF_COCOA_ENTER(env);
|
||||
|
||||
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
||||
NSArray *screens = [NSScreen screens];
|
||||
for (NSScreen *screen in screens) {
|
||||
NSDictionary *screenInfo = [screen deviceDescription];
|
||||
NSNumber *screenID = [screenInfo objectForKey:@"NSScreenNumber"];
|
||||
if ([screenID intValue] == displayID){
|
||||
CFRetain(screen); // GC
|
||||
screenPtr = ptr_to_jlong(screen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
|
||||
return screenPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CWrapper$NSColor
|
||||
* Method: clearColor
|
||||
|
@ -102,7 +102,7 @@ horizontal=horizontal
|
||||
#
|
||||
# accessible actions
|
||||
#
|
||||
toggle expand=toggle expand
|
||||
toggleexpand=toggle expand
|
||||
|
||||
# new relations, roles and states for J2SE 1.5.0
|
||||
|
||||
|
@ -102,7 +102,7 @@ horizontal=horizontal
|
||||
#
|
||||
# accessible actions
|
||||
#
|
||||
toggle expand=ein-/ausblenden
|
||||
toggleexpand=ein-/ausblenden
|
||||
|
||||
# new relations, roles and states for J2SE 1.5.0
|
||||
|
||||
|
@ -102,7 +102,7 @@ horizontal=horizontal
|
||||
#
|
||||
# accessible actions
|
||||
#
|
||||
toggle expand=activar/desactivar ampliaci\u00F3n
|
||||
toggleexpand=activar/desactivar ampliaci\u00F3n
|
||||
|
||||
# new relations, roles and states for J2SE 1.5.0
|
||||
|
||||
|
@ -102,7 +102,7 @@ horizontal=horizontal
|
||||
#
|
||||
# accessible actions
|
||||
#
|
||||
toggle expand=basculer le d\u00E9veloppement
|
||||
toggleexpand=basculer le d\u00E9veloppement
|
||||
|
||||
# new relations, roles and states for J2SE 1.5.0
|
||||
|
||||
|
@ -102,7 +102,7 @@ horizontal=orizzontale
|
||||
#
|
||||
# accessible actions
|
||||
#
|
||||
toggle expand=abilita/disabilita espansione
|
||||
toggleexpand=abilita/disabilita espansione
|
||||
|
||||
# new relations, roles and states for J2SE 1.5.0
|
||||
|
||||
|
@ -102,7 +102,7 @@ horizontal=\u6C34\u5E73
|
||||
#
|
||||
# accessible actions
|
||||
#
|
||||
toggle expand=\u5C55\u958B\u306E\u30C8\u30B0\u30EB
|
||||
toggleexpand=\u5C55\u958B\u306E\u30C8\u30B0\u30EB
|
||||
|
||||
# new relations, roles and states for J2SE 1.5.0
|
||||
|
||||
|
@ -102,7 +102,7 @@ horizontal=\uAC00\uB85C
|
||||
#
|
||||
# accessible actions
|
||||
#
|
||||
toggle expand=\uD1A0\uAE00 \uD655\uC7A5
|
||||
toggleexpand=\uD1A0\uAE00 \uD655\uC7A5
|
||||
|
||||
# new relations, roles and states for J2SE 1.5.0
|
||||
|
||||
|
@ -102,7 +102,7 @@ horizontal=horizontal
|
||||
#
|
||||
# accessible actions
|
||||
#
|
||||
toggle expand=alternar expans\u00E3o
|
||||
toggleexpand=alternar expans\u00E3o
|
||||
|
||||
# new relations, roles and states for J2SE 1.5.0
|
||||
|
||||
|
@ -102,7 +102,7 @@ horizontal=horisontell
|
||||
#
|
||||
# accessible actions
|
||||
#
|
||||
toggle expand=v\u00E4xla ut\u00F6ka
|
||||
toggleexpand=v\u00E4xla ut\u00F6ka
|
||||
|
||||
# new relations, roles and states for J2SE 1.5.0
|
||||
|
||||
|
@ -102,7 +102,7 @@ horizontal=\u6C34\u5E73
|
||||
#
|
||||
# accessible actions
|
||||
#
|
||||
toggle expand=\u5207\u6362\u5C55\u5F00
|
||||
toggleexpand=\u5207\u6362\u5C55\u5F00
|
||||
|
||||
# new relations, roles and states for J2SE 1.5.0
|
||||
|
||||
|
@ -102,7 +102,7 @@ horizontal=\u6C34\u5E73
|
||||
#
|
||||
# accessible actions
|
||||
#
|
||||
toggle expand=\u5207\u63DB\u64F4\u5C55
|
||||
toggleexpand=\u5207\u63DB\u64F4\u5C55
|
||||
|
||||
# new relations, roles and states for J2SE 1.5.0
|
||||
|
||||
|
@ -296,6 +296,12 @@ public abstract class GraphicsDevice {
|
||||
bgColor.getBlue(), 255);
|
||||
w.setBackground(bgColor);
|
||||
}
|
||||
// Check if this window is in fullscreen mode on another device.
|
||||
final GraphicsConfiguration gc = w.getGraphicsConfiguration();
|
||||
if (gc != null && gc.getDevice() != this
|
||||
&& gc.getDevice().getFullScreenWindow() == w) {
|
||||
gc.getDevice().setFullScreenWindow(null);
|
||||
}
|
||||
}
|
||||
if (fullScreenWindow != null && windowedModeBounds != null) {
|
||||
// if the window went into fs mode before it was realized it may
|
||||
|
@ -652,11 +652,12 @@ public class Introspector {
|
||||
}
|
||||
} else {
|
||||
if (pd.getReadMethod() != null) {
|
||||
String pdName = pd.getReadMethod().getName();
|
||||
if (gpd != null) {
|
||||
// Don't replace the existing read
|
||||
// method if it starts with "is"
|
||||
Method method = gpd.getReadMethod();
|
||||
if (!method.getName().startsWith(IS_PREFIX)) {
|
||||
String gpdName = gpd.getReadMethod().getName();
|
||||
if (gpdName.equals(pdName) || !gpdName.startsWith(IS_PREFIX)) {
|
||||
gpd = new PropertyDescriptor(gpd, pd);
|
||||
}
|
||||
} else {
|
||||
|
@ -54,7 +54,7 @@ public interface AccessibleAction {
|
||||
* @since 1.5
|
||||
*/
|
||||
public static final String TOGGLE_EXPAND =
|
||||
new String ("toggle expand");
|
||||
new String ("toggleexpand");
|
||||
|
||||
/**
|
||||
* An action which increments a value.
|
||||
|
@ -170,8 +170,8 @@ public final class ContentModel implements Serializable {
|
||||
case '&': {
|
||||
Element e = (Element) token;
|
||||
if (valSet == null) {
|
||||
valSet = new boolean[Element.maxIndex + 1];
|
||||
val = new boolean[Element.maxIndex + 1];
|
||||
valSet = new boolean[Element.getMaxIndex() + 1];
|
||||
val = new boolean[valSet.length];
|
||||
// All Element instances are created before this ever executes
|
||||
}
|
||||
if (valSet[e.index]) {
|
||||
|
@ -28,6 +28,7 @@ package javax.swing.text.html.parser;
|
||||
import java.util.Hashtable;
|
||||
import java.util.BitSet;
|
||||
import java.io.*;
|
||||
import sun.awt.AppContext;
|
||||
|
||||
/**
|
||||
* An element as described in a DTD using the ELEMENT construct.
|
||||
@ -51,8 +52,6 @@ class Element implements DTDConstants, Serializable {
|
||||
public ContentModel content;
|
||||
public AttributeList atts;
|
||||
|
||||
static int maxIndex = 0;
|
||||
|
||||
/**
|
||||
* A field to store user data. Mostly used to store
|
||||
* style sheets.
|
||||
@ -68,7 +67,18 @@ class Element implements DTDConstants, Serializable {
|
||||
Element(String name, int index) {
|
||||
this.name = name;
|
||||
this.index = index;
|
||||
maxIndex = Math.max(maxIndex, index);
|
||||
if (index > getMaxIndex()) {
|
||||
AppContext.getAppContext().put(MAX_INDEX_KEY, index);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Object MAX_INDEX_KEY = new Object();
|
||||
|
||||
static int getMaxIndex() {
|
||||
Integer value = (Integer) AppContext.getAppContext().get(MAX_INDEX_KEY);
|
||||
return (value != null)
|
||||
? value.intValue()
|
||||
: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,9 +105,15 @@ public final class XErrorHandlerUtil {
|
||||
* Unsets a current synthetic error handler. Must be called with the acquired AWT lock.
|
||||
*/
|
||||
public static void RESTORE_XERROR_HANDLER() {
|
||||
RESTORE_XERROR_HANDLER(true);
|
||||
}
|
||||
|
||||
private static void RESTORE_XERROR_HANDLER(boolean doXSync) {
|
||||
// Wait until all requests are processed by the X server
|
||||
// and only then uninstall the error handler.
|
||||
XSync();
|
||||
if (doXSync) {
|
||||
XSync();
|
||||
}
|
||||
current_error_handler = null;
|
||||
}
|
||||
|
||||
|
@ -46,11 +46,11 @@
|
||||
|
||||
/*
|
||||
* Expected types of arguments of the macro.
|
||||
* (JNIEnv*)
|
||||
* (JNIEnv*, jboolean)
|
||||
*/
|
||||
#define RESTORE_XERROR_HANDLER(env) do { \
|
||||
#define RESTORE_XERROR_HANDLER(env, doXSync) do { \
|
||||
JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", \
|
||||
"RESTORE_XERROR_HANDLER", "()V"); \
|
||||
"RESTORE_XERROR_HANDLER", "(Z)V", doXSync); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
@ -64,8 +64,18 @@
|
||||
do { \
|
||||
code; \
|
||||
} while (0); \
|
||||
RESTORE_XERROR_HANDLER(env); \
|
||||
RESTORE_XERROR_HANDLER(env, JNI_TRUE); \
|
||||
if (handlerHasFlag == JNI_TRUE) { \
|
||||
GET_HANDLER_ERROR_OCCURRED_FLAG(env, handlerRef, errorOccurredFlag); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Expected types of arguments of the macro.
|
||||
* (JNIEnv*, jobject, jboolean)
|
||||
*/
|
||||
#define GET_HANDLER_ERROR_OCCURRED_FLAG(env, handlerRef, errorOccurredFlag) do { \
|
||||
if (handlerRef != NULL) { \
|
||||
errorOccurredFlag = JNU_CallMethodByName(env, NULL, handlerRef, "getErrorOccurredFlag", \
|
||||
"()Z").z; \
|
||||
} \
|
||||
|
@ -392,10 +392,12 @@ Java_sun_java2d_opengl_GLXSurfaceData_initPbuffer
|
||||
attrlist[3] = height;
|
||||
|
||||
errorOccurredFlag = JNI_FALSE;
|
||||
EXEC_WITH_XERROR_HANDLER(env, "sun/awt/X11/XErrorHandler$GLXBadAllocHandler",
|
||||
"()Lsun/awt/X11/XErrorHandler$GLXBadAllocHandler;", JNI_TRUE,
|
||||
errorHandlerRef, errorOccurredFlag,
|
||||
pbuffer = j2d_glXCreatePbuffer(awt_display, glxinfo->fbconfig, attrlist));
|
||||
WITH_XERROR_HANDLER(env, "sun/awt/X11/XErrorHandler$GLXBadAllocHandler",
|
||||
"()Lsun/awt/X11/XErrorHandler$GLXBadAllocHandler;", JNI_TRUE, errorHandlerRef);
|
||||
pbuffer = j2d_glXCreatePbuffer(awt_display, glxinfo->fbconfig, attrlist);
|
||||
XSync(awt_display, False);
|
||||
RESTORE_XERROR_HANDLER(env, JNI_FALSE);
|
||||
GET_HANDLER_ERROR_OCCURRED_FLAG(env, errorHandlerRef, errorOccurredFlag);
|
||||
|
||||
if ((pbuffer == 0) || errorOccurredFlag) {
|
||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
||||
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.DisplayMode;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Toolkit;
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8019587
|
||||
* @author Sergey Bylokhov
|
||||
*/
|
||||
public class IncorrectDisplayModeExitFullscreen {
|
||||
|
||||
public static void main(final String[] args) {
|
||||
|
||||
final GraphicsDevice[] devices =
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||
.getScreenDevices();
|
||||
if (devices.length < 2 || devices[0].getDisplayModes().length < 2
|
||||
|| !devices[0].isFullScreenSupported()
|
||||
|| !devices[1].isFullScreenSupported()) {
|
||||
System.err.println("Testcase is not applicable");
|
||||
return;
|
||||
}
|
||||
final DisplayMode defaultDM = devices[0].getDisplayMode();
|
||||
final DisplayMode[] dms = devices[0].getDisplayModes();
|
||||
DisplayMode nonDefaultDM = null;
|
||||
|
||||
for (final DisplayMode dm : dms) {
|
||||
if (!dm.equals(defaultDM)) {
|
||||
nonDefaultDM = dm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nonDefaultDM == null) {
|
||||
System.err.println("Testcase is not applicable");
|
||||
return;
|
||||
}
|
||||
|
||||
final Frame frame = new Frame();
|
||||
frame.setBackground(Color.GREEN);
|
||||
frame.setUndecorated(true);
|
||||
try {
|
||||
devices[0].setFullScreenWindow(frame);
|
||||
sleep();
|
||||
devices[0].setDisplayMode(nonDefaultDM);
|
||||
sleep();
|
||||
devices[1].setFullScreenWindow(frame);
|
||||
sleep();
|
||||
if (!defaultDM.equals(devices[0].getDisplayMode())) {
|
||||
throw new RuntimeException("DisplayMode is not restored");
|
||||
}
|
||||
} finally {
|
||||
// cleaning up
|
||||
devices[0].setFullScreenWindow(null);
|
||||
devices[1].setFullScreenWindow(null);
|
||||
frame.dispose();
|
||||
}
|
||||
}
|
||||
private static void sleep() {
|
||||
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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 @summary JVM crash if the frame maximized from offscreen
|
||||
* @author Petr Pchelko
|
||||
* @library ../../regtesthelpers
|
||||
* @build Util
|
||||
* @compile MaximizeOffscreenTest.java
|
||||
* @run main/othervm MaximizeOffscreenTest
|
||||
*/
|
||||
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class MaximizeOffscreenTest {
|
||||
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
constructTestUI();
|
||||
}
|
||||
});
|
||||
|
||||
Util.waitForIdle(null);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
}
|
||||
});
|
||||
Util.waitForIdle(null);
|
||||
}
|
||||
|
||||
private static void constructTestUI() {
|
||||
frame = new JFrame("Test frame");
|
||||
frame.setUndecorated(true);
|
||||
frame.setBounds(-1000, -1000, 100, 100);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
80
jdk/test/java/beans/Introspector/Test6707231.java
Normal file
80
jdk/test/java/beans/Introspector/Test6707231.java
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.
|
||||
*/
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6707231
|
||||
* @summary Tests the boolean getter
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public class Test6707231 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
test(Bean.class, Bean.class);
|
||||
test(Public.class, Public.class);
|
||||
test(Private.class, Bean.class);
|
||||
}
|
||||
|
||||
public static class Bean {
|
||||
private boolean value;
|
||||
|
||||
public boolean isValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(boolean value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Public extends Bean {
|
||||
public boolean isValue() {
|
||||
return super.isValue();
|
||||
}
|
||||
|
||||
public void setValue(boolean value) {
|
||||
super.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Private extends Bean {
|
||||
public boolean isValue() {
|
||||
return super.isValue();
|
||||
}
|
||||
|
||||
public void setValue(boolean value) {
|
||||
super.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test(Class<?> actual, Class<?> expected) {
|
||||
PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(actual, "value");
|
||||
Class<?> getter = pd.getReadMethod().getDeclaringClass();
|
||||
Class<?> setter = pd.getWriteMethod().getDeclaringClass();
|
||||
if ((getter != expected) || (setter != expected)) {
|
||||
throw new Error(actual.getName());
|
||||
}
|
||||
}
|
||||
}
|
@ -35,10 +35,11 @@ import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class ActionListenerCalledTwiceTest {
|
||||
static String menuItems[] = { "Item1", "Item2" };
|
||||
static String menuItems[] = { "Item1", "Item2", "Item3" };
|
||||
static KeyStroke keyStrokes[] = {
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK),
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_MASK),
|
||||
};
|
||||
|
||||
static volatile int listenerCallCounter = 0;
|
||||
|
92
jdk/test/javax/swing/text/html/parser/Test8017492.java
Normal file
92
jdk/test/javax/swing/text/html/parser/Test8017492.java
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.
|
||||
*/
|
||||
|
||||
import java.util.Vector;
|
||||
import javax.swing.text.html.HTML;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
import javax.swing.text.html.parser.DTD;
|
||||
import javax.swing.text.html.parser.Element;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8017492
|
||||
* @run main/othervm Test8017492
|
||||
* @summary Tests for OutOfMemoryError/NegativeArraySizeException
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public class Test8017492 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Runnable task = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
SunToolkit.createNewAppContext();
|
||||
DTD dtd = DTD.getDTD("dtd");
|
||||
dtd.elements = new Vector<Element>() {
|
||||
@Override
|
||||
public synchronized int size() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
};
|
||||
dtd.getElement("element");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new Error("unexpected", exception);
|
||||
}
|
||||
}
|
||||
};
|
||||
// run task with different AppContext
|
||||
Thread thread = new Thread(new ThreadGroup("$$$"), task);
|
||||
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
thread.join();
|
||||
// add error handling
|
||||
HTMLDocument document = new HTMLDocument() {
|
||||
@Override
|
||||
public HTMLEditorKit.ParserCallback getReader(int pos) {
|
||||
return getReader(pos, 0, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HTMLEditorKit.ParserCallback getReader(int pos, int popDepth, int pushDepth, HTML.Tag insertTag) {
|
||||
return new HTMLDocument.HTMLReader(pos, popDepth, pushDepth, insertTag) {
|
||||
@Override
|
||||
public void handleError(String error, int pos) {
|
||||
throw new Error(error);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
// run parser
|
||||
new HTMLEditorKit().insertHTML(document, 0, "<html><body>text", 0, 0, null);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user