提交 c92978fe 编写于 作者: M mullan

Merge

...@@ -366,6 +366,7 @@ TOOLS = \ ...@@ -366,6 +366,7 @@ TOOLS = \
com/sun/source \ com/sun/source \
com/sun/tools/classfile \ com/sun/tools/classfile \
com/sun/tools/doclets \ com/sun/tools/doclets \
com/sun/tools/doclint \
com/sun/tools/example/debug/expr \ com/sun/tools/example/debug/expr \
com/sun/tools/example/debug/tty \ com/sun/tools/example/debug/tty \
com/sun/tools/extcheck \ com/sun/tools/extcheck \
......
...@@ -35,6 +35,7 @@ IMPORT_TOOLS_PACKAGES += \ ...@@ -35,6 +35,7 @@ IMPORT_TOOLS_PACKAGES += \
com/sun/source \ com/sun/source \
com/sun/tools/classfile \ com/sun/tools/classfile \
com/sun/tools/doclets \ com/sun/tools/doclets \
com/sun/tools/doclint \
com/sun/tools/javac \ com/sun/tools/javac \
com/sun/tools/javadoc \ com/sun/tools/javadoc \
com/sun/tools/javah \ com/sun/tools/javah \
......
...@@ -76,7 +76,8 @@ ATTACH_PKGS = com.sun.tools.attach \ ...@@ -76,7 +76,8 @@ ATTACH_PKGS = com.sun.tools.attach \
JCONSOLE_PKGS = com.sun.tools.jconsole JCONSOLE_PKGS = com.sun.tools.jconsole
TREEAPI_PKGS = com.sun.source.tree \ TREEAPI_PKGS = com.sunsource.doctree \
com.sun.source.tree \
com.sun.source.util com.sun.source.util
SMARTCARDIO_PKGS = javax.smartcardio SMARTCARDIO_PKGS = javax.smartcardio
......
...@@ -322,6 +322,7 @@ JAVA_JAVA_java = \ ...@@ -322,6 +322,7 @@ JAVA_JAVA_java = \
java/util/concurrent/CopyOnWriteArrayList.java \ java/util/concurrent/CopyOnWriteArrayList.java \
java/util/concurrent/CopyOnWriteArraySet.java \ java/util/concurrent/CopyOnWriteArraySet.java \
java/util/concurrent/CountDownLatch.java \ java/util/concurrent/CountDownLatch.java \
java/util/concurrent/CountedCompleter.java \
java/util/concurrent/CyclicBarrier.java \ java/util/concurrent/CyclicBarrier.java \
java/util/concurrent/DelayQueue.java \ java/util/concurrent/DelayQueue.java \
java/util/concurrent/Delayed.java \ java/util/concurrent/Delayed.java \
......
# #
# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -23,16 +23,18 @@ ...@@ -23,16 +23,18 @@
# questions. # questions.
# #
#
# Makefile for building all of java
#
BUILDDIR = .. BUILDDIR = ..
PACKAGE = jdk
PRODUCT = jdk PRODUCT = jdk
JAVAC_LINT_OPTIONS=-Xlint:all
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = asm #
include $(BUILDDIR)/common/Subdirs.gmk # Files to compile
#
AUTO_FILES_JAVA_DIRS = jdk
all build clean clobber:: #
$(SUBDIRS-loop) # Rules
#
include $(BUILDDIR)/common/Classes.gmk
...@@ -38,6 +38,7 @@ excludes=\ ...@@ -38,6 +38,7 @@ excludes=\
com/sun/jmx/snmp/ com/sun/jmx/snmp/
jtreg.tests=\ jtreg.tests=\
com/sun/jmx/ \
com/sun/management/ \ com/sun/management/ \
java/lang/management/ \ java/lang/management/ \
javax/management/ javax/management/
......
...@@ -729,6 +729,7 @@ TOOLS_JAR_INCLUDES := \ ...@@ -729,6 +729,7 @@ TOOLS_JAR_INCLUDES := \
com/sun/source \ com/sun/source \
com/sun/tools/classfile \ com/sun/tools/classfile \
com/sun/tools/doclets \ com/sun/tools/doclets \
com/sun/tools/doclint \
com/sun/tools/example/debug/expr \ com/sun/tools/example/debug/expr \
com/sun/tools/example/debug/tty \ com/sun/tools/example/debug/tty \
com/sun/tools/extcheck \ com/sun/tools/extcheck \
......
...@@ -210,9 +210,9 @@ public abstract class LWToolkit extends SunToolkit implements Runnable { ...@@ -210,9 +210,9 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
* and DialogPeer interfaces. * and DialogPeer interfaces.
*/ */
private LWWindowPeer createDelegatedPeer(Window target, PlatformComponent platformComponent, private LWWindowPeer createDelegatedPeer(Window target, PlatformComponent platformComponent,
PlatformWindow platformWindow) PlatformWindow platformWindow, LWWindowPeer.PeerType peerType)
{ {
LWWindowPeer peer = new LWWindowPeer(target, platformComponent, platformWindow); LWWindowPeer peer = new LWWindowPeer(target, platformComponent, platformWindow, peerType);
targetCreatedPeer(target, peer); targetCreatedPeer(target, peer);
peer.initialize(); peer.initialize();
return peer; return peer;
...@@ -222,22 +222,29 @@ public abstract class LWToolkit extends SunToolkit implements Runnable { ...@@ -222,22 +222,29 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
public WindowPeer createWindow(Window target) { public WindowPeer createWindow(Window target) {
PlatformComponent platformComponent = createPlatformComponent(); PlatformComponent platformComponent = createPlatformComponent();
PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.SIMPLEWINDOW); PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.SIMPLEWINDOW);
return createDelegatedPeer(target, platformComponent, platformWindow); return createDelegatedPeer(target, platformComponent, platformWindow, LWWindowPeer.PeerType.SIMPLEWINDOW);
} }
@Override @Override
public FramePeer createFrame(Frame target) { public FramePeer createFrame(Frame target) {
PlatformComponent platformComponent = createPlatformComponent(); PlatformComponent platformComponent = createPlatformComponent();
PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.FRAME); PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.FRAME);
return createDelegatedPeer(target, platformComponent, platformWindow); return createDelegatedPeer(target, platformComponent, platformWindow, LWWindowPeer.PeerType.FRAME);
} }
public LWWindowPeer createEmbeddedFrame(CEmbeddedFrame target) { public LWWindowPeer createEmbeddedFrame(CEmbeddedFrame target) {
PlatformComponent platformComponent = createPlatformComponent(); PlatformComponent platformComponent = createPlatformComponent();
PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.EMBEDDEDFRAME); PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.EMBEDDED_FRAME);
return createDelegatedPeer(target, platformComponent, platformWindow); return createDelegatedPeer(target, platformComponent, platformWindow, LWWindowPeer.PeerType.EMBEDDED_FRAME);
} }
public LWWindowPeer createEmbeddedFrame(CViewEmbeddedFrame target) {
PlatformComponent platformComponent = createPlatformComponent();
PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.VIEW_EMBEDDED_FRAME);
return createDelegatedPeer(target, platformComponent, platformWindow, LWWindowPeer.PeerType.VIEW_EMBEDDED_FRAME);
}
CPrinterDialogPeer createCPrinterDialog(CPrinterDialog target) { CPrinterDialogPeer createCPrinterDialog(CPrinterDialog target) {
PlatformComponent platformComponent = createPlatformComponent(); PlatformComponent platformComponent = createPlatformComponent();
PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.DIALOG); PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.DIALOG);
...@@ -254,7 +261,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable { ...@@ -254,7 +261,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
PlatformComponent platformComponent = createPlatformComponent(); PlatformComponent platformComponent = createPlatformComponent();
PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.DIALOG); PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.DIALOG);
return createDelegatedPeer(target, platformComponent, platformWindow); return createDelegatedPeer(target, platformComponent, platformWindow, LWWindowPeer.PeerType.DIALOG);
} }
@Override @Override
......
...@@ -47,7 +47,8 @@ public class LWWindowPeer ...@@ -47,7 +47,8 @@ public class LWWindowPeer
SIMPLEWINDOW, SIMPLEWINDOW,
FRAME, FRAME,
DIALOG, DIALOG,
EMBEDDEDFRAME EMBEDDED_FRAME,
VIEW_EMBEDDED_FRAME
} }
private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.lwawt.focus.LWWindowPeer"); private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.lwawt.focus.LWWindowPeer");
...@@ -108,6 +109,8 @@ public class LWWindowPeer ...@@ -108,6 +109,8 @@ public class LWWindowPeer
private volatile boolean textured; private volatile boolean textured;
private final PeerType peerType;
/** /**
* Current modal blocker or null. * Current modal blocker or null.
* *
...@@ -116,10 +119,11 @@ public class LWWindowPeer ...@@ -116,10 +119,11 @@ public class LWWindowPeer
private LWWindowPeer blocker; private LWWindowPeer blocker;
public LWWindowPeer(Window target, PlatformComponent platformComponent, public LWWindowPeer(Window target, PlatformComponent platformComponent,
PlatformWindow platformWindow) PlatformWindow platformWindow, PeerType peerType)
{ {
super(target, platformComponent); super(target, platformComponent);
this.platformWindow = platformWindow; this.platformWindow = platformWindow;
this.peerType = peerType;
Window owner = target.getOwner(); Window owner = target.getOwner();
LWWindowPeer ownerPeer = (owner != null) ? (LWWindowPeer)owner.getPeer() : null; LWWindowPeer ownerPeer = (owner != null) ? (LWWindowPeer)owner.getPeer() : null;
...@@ -275,6 +279,11 @@ public class LWWindowPeer ...@@ -275,6 +279,11 @@ public class LWWindowPeer
@Override @Override
public void setBounds(int x, int y, int w, int h, int op) { public void setBounds(int x, int y, int w, int h, int op) {
if((op & NO_EMBEDDED_CHECK) == 0 && getPeerType() == PeerType.VIEW_EMBEDDED_FRAME) {
return;
}
if ((op & SET_CLIENT_SIZE) != 0) { if ((op & SET_CLIENT_SIZE) != 0) {
// SET_CLIENT_SIZE is only applicable to window peers, so handle it here // SET_CLIENT_SIZE is only applicable to window peers, so handle it here
// instead of pulling 'insets' field up to LWComponentPeer // instead of pulling 'insets' field up to LWComponentPeer
...@@ -1210,6 +1219,10 @@ public class LWWindowPeer ...@@ -1210,6 +1219,10 @@ public class LWWindowPeer
return this == grabbingWindow; return this == grabbingWindow;
} }
public PeerType getPeerType() {
return peerType;
}
@Override @Override
public String toString() { public String toString() {
return super.toString() + " [target is " + getTarget() + "]"; return super.toString() + " [target is " + getTarget() + "]";
......
...@@ -151,4 +151,6 @@ public interface PlatformWindow { ...@@ -151,4 +151,6 @@ public interface PlatformWindow {
public long getLayerPtr(); public long getLayerPtr();
public LWWindowPeer getPeer(); public LWWindowPeer getPeer();
public boolean isUnderMouse();
} }
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
package sun.lwawt.macosx; package sun.lwawt.macosx;
import java.awt.Window; import java.awt.Window;
import sun.lwawt.LWMouseInfoPeer; import sun.lwawt.LWMouseInfoPeer;
import sun.lwawt.LWWindowPeer; import sun.lwawt.LWWindowPeer;
...@@ -41,10 +40,6 @@ public class CMouseInfoPeer extends LWMouseInfoPeer ...@@ -41,10 +40,6 @@ public class CMouseInfoPeer extends LWMouseInfoPeer
return false; return false;
} }
LWWindowPeer peer = (LWWindowPeer)w.getPeer(); return ((LWWindowPeer)w.getPeer()).getPlatformWindow().isUnderMouse();
CPlatformWindow platformWindow = (CPlatformWindow)peer.getPlatformWindow();
return nativeIsWindowUnderMouse(platformWindow.getNSWindowPtr());
} }
private static native boolean nativeIsWindowUnderMouse(long ptr);
} }
...@@ -25,16 +25,13 @@ ...@@ -25,16 +25,13 @@
package sun.lwawt.macosx; package sun.lwawt.macosx;
import sun.lwawt.PlatformWindow;
import sun.lwawt.LWWindowPeer;
import sun.java2d.opengl.CGLLayer;
import sun.java2d.SurfaceData;
import sun.awt.CausedFocusEvent;
import java.awt.*; import java.awt.*;
import sun.awt.CausedFocusEvent;
import sun.java2d.SurfaceData;
import sun.java2d.opengl.CGLLayer;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.LWWindowPeer.PeerType;
import sun.lwawt.PlatformWindow;
import sun.util.logging.PlatformLogger; import sun.util.logging.PlatformLogger;
/* /*
...@@ -134,6 +131,7 @@ public class CPlatformEmbeddedFrame implements PlatformWindow { ...@@ -134,6 +131,7 @@ public class CPlatformEmbeddedFrame implements PlatformWindow {
// This method should be properly implemented for applets. // This method should be properly implemented for applets.
// It returns null just as a stub. // It returns null just as a stub.
@Override
public PlatformWindow getTopmostPlatformWindowUnderMouse() { return null; } public PlatformWindow getTopmostPlatformWindowUnderMouse() { return null; }
@Override @Override
...@@ -192,4 +190,13 @@ public class CPlatformEmbeddedFrame implements PlatformWindow { ...@@ -192,4 +190,13 @@ public class CPlatformEmbeddedFrame implements PlatformWindow {
@Override @Override
public void setModalBlocked(boolean blocked) {} public void setModalBlocked(boolean blocked) {}
/*
* The method could not be implemented due to CALayer restrictions.
* The exeption enforce clients not to use it.
*/
@Override
public boolean isUnderMouse() {
throw new RuntimeException("Not implemented");
}
} }
...@@ -26,8 +26,11 @@ ...@@ -26,8 +26,11 @@
package sun.lwawt.macosx; package sun.lwawt.macosx;
import java.awt.*; import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.VolatileImage;
import sun.awt.CGraphicsConfig; import sun.awt.CGraphicsConfig;
import sun.awt.CGraphicsEnvironment;
import sun.lwawt.LWWindowPeer; import sun.lwawt.LWWindowPeer;
import sun.lwawt.macosx.event.NSEvent; import sun.lwawt.macosx.event.NSEvent;
...@@ -37,6 +40,10 @@ import sun.java2d.opengl.CGLSurfaceData; ...@@ -37,6 +40,10 @@ import sun.java2d.opengl.CGLSurfaceData;
public class CPlatformView extends CFRetainedResource { public class CPlatformView extends CFRetainedResource {
private native long nativeCreateView(int x, int y, int width, int height, long windowLayerPtr); private native long nativeCreateView(int x, int y, int width, int height, long windowLayerPtr);
private static native void nativeSetAutoResizable(long awtView, boolean toResize);
private static native int nativeGetNSViewDisplayID(long awtView);
private static native Rectangle2D nativeGetLocationOnScreen(long awtView);
private static native boolean nativeIsViewUnderMouse(long ptr);
private LWWindowPeer peer; private LWWindowPeer peer;
private SurfaceData surfaceData; private SurfaceData surfaceData;
...@@ -59,7 +66,7 @@ public class CPlatformView extends CFRetainedResource { ...@@ -59,7 +66,7 @@ public class CPlatformView extends CFRetainedResource {
public long getAWTView() { public long getAWTView() {
return ptr; return ptr;
} }
public boolean isOpaque() { public boolean isOpaque() {
return !peer.isTranslucent(); return !peer.isTranslucent();
...@@ -158,10 +165,46 @@ public class CPlatformView extends CFRetainedResource { ...@@ -158,10 +165,46 @@ public class CPlatformView extends CFRetainedResource {
} }
} }
public void setAutoResizable(boolean toResize) {
nativeSetAutoResizable(this.getAWTView(), toResize);
}
public boolean isUnderMouse() {
return nativeIsViewUnderMouse(getAWTView());
}
public GraphicsDevice getGraphicsDevice() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
CGraphicsEnvironment cge = (CGraphicsEnvironment)ge;
int displayID = nativeGetNSViewDisplayID(getAWTView());
GraphicsDevice gd = cge.getScreenDevice(displayID);
if (gd == null) {
// this could possibly happen during device removal
// use the default screen device in this case
gd = ge.getDefaultScreenDevice();
}
return gd;
}
public Point getLocationOnScreen() {
Rectangle r = nativeGetLocationOnScreen(this.getAWTView()).getBounds();
return new Point(r.x, r.y);
}
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// NATIVE CALLBACKS // NATIVE CALLBACKS
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
/*
* The callback is called only in the embedded case when the view is
* automatically resized by the superview.
* In normal mode this method is never called.
*/
private void deliverResize(int x, int y, int w, int h) {
peer.notifyReshape(x, y, w, h);
}
private void deliverMouseEvent(NSEvent event) { private void deliverMouseEvent(NSEvent event) {
int x = event.getX(); int x = event.getX();
int y = getBounds().height - event.getY(); int y = getBounds().height - event.getY();
......
...@@ -64,8 +64,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor ...@@ -64,8 +64,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
private static native void nativeDispose(long nsWindowPtr); private static native void nativeDispose(long nsWindowPtr);
private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse(); private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
private static native int nativeGetNSWindowDisplayID(long nsWindowPtr);
// Loger to report issues happened during execution but that do not affect functionality // Loger to report issues happened during execution but that do not affect functionality
private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow"); private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformWindow"); private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformWindow");
...@@ -211,9 +209,8 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor ...@@ -211,9 +209,8 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
private CPlatformResponder responder; private CPlatformResponder responder;
private volatile boolean zoomed = false; // from native perspective private volatile boolean zoomed = false; // from native perspective
public CPlatformWindow(final PeerType peerType) { public CPlatformWindow() {
super(0, true); super(0, true);
assert (peerType == PeerType.SIMPLEWINDOW || peerType == PeerType.DIALOG || peerType == PeerType.FRAME);
} }
/* /*
...@@ -429,16 +426,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor ...@@ -429,16 +426,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
@Override @Override
public GraphicsDevice getGraphicsDevice() { public GraphicsDevice getGraphicsDevice() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); return contentView.getGraphicsDevice();
CGraphicsEnvironment cge = (CGraphicsEnvironment)ge;
int displayID = nativeGetNSWindowDisplayID(getNSWindowPtr());
GraphicsDevice gd = cge.getScreenDevice(displayID);
if (gd == null) {
// this could possibly happen during device removal
// use the default screen device in this case
gd = ge.getDefaultScreenDevice();
}
return gd;
} }
@Override // PlatformWindow @Override // PlatformWindow
...@@ -833,6 +821,11 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor ...@@ -833,6 +821,11 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
return peer; return peer;
} }
@Override
public boolean isUnderMouse() {
return contentView.isUnderMouse();
}
public CPlatformView getContentView() { public CPlatformView getContentView() {
return contentView; return contentView;
} }
......
...@@ -41,7 +41,7 @@ public class CPrinterDialogPeer extends LWWindowPeer { ...@@ -41,7 +41,7 @@ public class CPrinterDialogPeer extends LWWindowPeer {
public CPrinterDialogPeer(CPrinterDialog target, PlatformComponent platformComponent, public CPrinterDialogPeer(CPrinterDialog target, PlatformComponent platformComponent,
PlatformWindow platformWindow) PlatformWindow platformWindow)
{ {
super(target, platformComponent, platformWindow); super(target, platformComponent, platformWindow, LWWindowPeer.PeerType.DIALOG);
//super(target); //super(target);
fTarget = target; fTarget = target;
super.initialize(); super.initialize();
......
/*
* Copyright (c) 2012, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package sun.lwawt.macosx;
import java.awt.AWTKeyStroke;
import java.awt.Toolkit;
import java.lang.reflect.InvocationTargetException;
import sun.awt.EmbeddedFrame;
import sun.lwawt.LWToolkit;
import sun.lwawt.LWWindowPeer;
/*
* The CViewEmbeddedFrame class is used in the SWT_AWT bridge.
* This is a part of public API and should not be renamed or moved
*/
public class CViewEmbeddedFrame extends EmbeddedFrame {
private final long nsViewPtr;
private boolean isActive = false;
public CViewEmbeddedFrame(long nsViewPtr) {
this.nsViewPtr = nsViewPtr;
}
@SuppressWarnings("deprecation")
@Override
public void addNotify() {
if (getPeer() == null) {
LWToolkit toolkit = (LWToolkit) Toolkit.getDefaultToolkit();
setPeer(toolkit.createEmbeddedFrame(this));
}
super.addNotify();
}
public long getEmbedderHandle() {
return nsViewPtr;
}
@Override
public void registerAccelerator(AWTKeyStroke awtks) {
}
@Override
public void unregisterAccelerator(AWTKeyStroke awtks) {
}
public boolean isParentWindowActive() {
return isActive;
}
/*
* Synthetic event delivery for focus management
*/
@Override
public void synthesizeWindowActivation(boolean activated) {
if (isActive != activated) {
isActive = activated;
((LWWindowPeer)getPeer()).notifyActivation(activated, null);
}
}
/*
* Initializes the embedded frame bounds and validates a component.
* Designed to be called from the main thread
* This method should be called once from the initialization of the SWT_AWT Bridge
*/
@SuppressWarnings("deprecation")
public void validateWithBounds(final int x, final int y, final int width, final int height) {
try {
LWCToolkit.invokeAndWait(new Runnable() {
@Override
public void run() {
((LWWindowPeer) getPeer()).setBoundsPrivate(0, 0, width, height);
validate();
setVisible(true);
}
}, null);
} catch (InterruptedException | InvocationTargetException ex) {}
}
}
/*
* Copyright (c) 2012, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package sun.lwawt.macosx;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.Insets;
import java.awt.MenuBar;
import java.awt.Point;
import java.awt.Window;
import sun.awt.CausedFocusEvent.Cause;
import sun.java2d.SurfaceData;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.PlatformWindow;
public class CViewPlatformEmbeddedFrame implements PlatformWindow {
private CPlatformView view;
private LWWindowPeer peer;
private CViewEmbeddedFrame target;
private CPlatformResponder responder;
@Override // PlatformWindow
public void initialize(Window target, final LWWindowPeer peer, PlatformWindow owner) {
this.peer = peer;
this.target = (CViewEmbeddedFrame) target;
responder = new CPlatformResponder(peer, false);
view = new CPlatformView();
view.initialize(peer, responder);
CWrapper.NSView.addSubview(this.target.getEmbedderHandle(), view.getAWTView());
view.setAutoResizable(true);
}
public long getNSViewPtr() {
return view.getAWTView();
}
@Override
public long getLayerPtr() {
return view.getWindowLayerPtr();
}
@Override
public LWWindowPeer getPeer() {
return peer;
}
@Override
public void dispose() {
CWrapper.NSView.removeFromSuperview(view.getAWTView());
view.dispose();
}
@Override
public void setVisible(boolean visible) {
CWrapper.NSView.setHidden(view.getAWTView(), !visible);
}
@Override
public void setTitle(String title) {
}
@Override
public void setBounds(int x, int y, int w, int h) {
view.setBounds(x, y, w, h);
peer.notifyReshape(x, y, w, h);
}
@Override
public GraphicsDevice getGraphicsDevice() {
return view.getGraphicsDevice();
}
@Override
public Point getLocationOnScreen() {
return view.getLocationOnScreen();
}
@Override
public Insets getInsets() {
return new Insets(0, 0, 0, 0);
}
@Override
public FontMetrics getFontMetrics(Font f) {
throw new RuntimeException("Not implemented");
}
@Override
public SurfaceData getScreenSurface() {
return view.getSurfaceData();
}
@Override
public SurfaceData replaceSurfaceData() {
return view.replaceSurfaceData();
}
@Override
public void setModalBlocked(boolean blocked) {
}
@Override
public void toFront() {
}
@Override
public void toBack() {
}
@Override
public void setMenuBar(MenuBar mb) {
}
@Override
public void setAlwaysOnTop(boolean value) {
}
@Override
public PlatformWindow getTopmostPlatformWindowUnderMouse() {
return null;
}
@Override
public void updateFocusableWindowState() {
}
@Override
public boolean rejectFocusRequest(Cause cause) {
return false;
}
@Override
public boolean requestWindowFocus() {
return true;
}
@Override
public boolean isActive() {
return target.isParentWindowActive();
}
@Override
public void setResizable(boolean resizable) {
}
@Override
public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
}
@Override
public Graphics transformGraphics(Graphics g) {
return g;
}
@Override
public void updateIconImages() {
}
@Override
public void setOpacity(float opacity) {
}
@Override
public void setOpaque(boolean isOpaque) {
}
@Override
public void enterFullScreenMode() {
}
@Override
public void exitFullScreenMode() {
}
@Override
public void setWindowState(int windowState) {
}
@Override
public boolean isUnderMouse() {
return view.isUnderMouse();
}
}
...@@ -85,6 +85,8 @@ public final class CWrapper { ...@@ -85,6 +85,8 @@ public final class CWrapper {
public static native void enterFullScreenMode(long view); public static native void enterFullScreenMode(long view);
public static native void exitFullScreenMode(long view); public static native void exitFullScreenMode(long view);
public static native void setHidden(long view, boolean hidden);
} }
public static final class NSObject { public static final class NSObject {
......
...@@ -156,10 +156,13 @@ public final class LWCToolkit extends LWToolkit { ...@@ -156,10 +156,13 @@ public final class LWCToolkit extends LWToolkit {
@Override @Override
protected PlatformWindow createPlatformWindow(PeerType peerType) { protected PlatformWindow createPlatformWindow(PeerType peerType) {
if (peerType == PeerType.EMBEDDEDFRAME) { if (peerType == PeerType.EMBEDDED_FRAME) {
return new CPlatformEmbeddedFrame(); return new CPlatformEmbeddedFrame();
} else if (peerType == PeerType.VIEW_EMBEDDED_FRAME) {
return new CViewPlatformEmbeddedFrame();
} else { } else {
return new CPlatformWindow(peerType); assert (peerType == PeerType.SIMPLEWINDOW || peerType == PeerType.DIALOG || peerType == PeerType.FRAME);
return new CPlatformWindow();
} }
} }
......
...@@ -99,17 +99,16 @@ Java_sun_lwawt_macosx_CPlatformComponent_nativeCreateComponent ...@@ -99,17 +99,16 @@ Java_sun_lwawt_macosx_CPlatformComponent_nativeCreateComponent
__block AWTSurfaceLayers *surfaceLayers = nil; __block AWTSurfaceLayers *surfaceLayers = nil;
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
AWT_ASSERT_NOT_APPKIT_THREAD;
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
AWT_ASSERT_APPKIT_THREAD; AWT_ASSERT_APPKIT_THREAD;
CALayer *windowLayer = jlong_to_ptr(windowLayerPtr); CALayer *windowLayer = jlong_to_ptr(windowLayerPtr);
surfaceLayers = [[AWTSurfaceLayers alloc] initWithWindowLayer: windowLayer]; surfaceLayers = [[AWTSurfaceLayers alloc] initWithWindowLayer: windowLayer];
CFRetain(surfaceLayers); CFRetain(surfaceLayers);
[surfaceLayers release]; [surfaceLayers release];
}]; }];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
return ptr_to_jlong(surfaceLayers); return ptr_to_jlong(surfaceLayers);
...@@ -126,12 +125,13 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformComponent_nativeSetBounds ...@@ -126,12 +125,13 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformComponent_nativeSetBounds
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
AWTSurfaceLayers *surfaceLayers = OBJC(surfaceLayersPtr); AWTSurfaceLayers *surfaceLayers = OBJC(surfaceLayersPtr);
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
AWT_ASSERT_APPKIT_THREAD; AWT_ASSERT_APPKIT_THREAD;
CGRect rect = CGRectMake(x, y, width, height); CGRect rect = CGRectMake(x, y, width, height);
[surfaceLayers setBounds: rect]; [surfaceLayers setBounds: rect];
}]; }];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
} }
...@@ -83,6 +83,7 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -83,6 +83,7 @@ AWT_ASSERT_APPKIT_THREAD;
mouseIsOver = NO; mouseIsOver = NO;
[self resetTrackingArea]; [self resetTrackingArea];
[self setAutoresizesSubviews:NO];
if (windowLayer != nil) { if (windowLayer != nil) {
self.cglLayer = windowLayer; self.cglLayer = windowLayer;
...@@ -174,6 +175,11 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -174,6 +175,11 @@ AWT_ASSERT_APPKIT_THREAD;
* Automatically triggered functions. * Automatically triggered functions.
*/ */
- (void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize {
[super resizeWithOldSuperviewSize: oldBoundsSize];
[self deliverResize: [self frame]];
}
/* /*
* MouseEvents support * MouseEvents support
*/ */
...@@ -437,6 +443,18 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -437,6 +443,18 @@ AWT_ASSERT_APPKIT_THREAD;
} }
} }
-(void) deliverResize: (NSRect) rect {
jint x = (jint) rect.origin.x;
jint y = (jint) rect.origin.y;
jint w = (jint) rect.size.width;
jint h = (jint) rect.size.height;
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
static JNF_MEMBER_CACHE(jm_deliverResize, jc_PlatformView, "deliverResize", "(IIII)V");
JNFCallVoidMethod(env, m_cPlatformView, jm_deliverResize, x,y,w,h);
}
- (void) drawRect:(NSRect)dirtyRect { - (void) drawRect:(NSRect)dirtyRect {
AWT_ASSERT_APPKIT_THREAD; AWT_ASSERT_APPKIT_THREAD;
...@@ -1220,21 +1238,19 @@ Java_sun_lwawt_macosx_CPlatformView_nativeCreateView ...@@ -1220,21 +1238,19 @@ Java_sun_lwawt_macosx_CPlatformView_nativeCreateView
__block AWTView *newView = nil; __block AWTView *newView = nil;
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
AWT_ASSERT_NOT_APPKIT_THREAD;
NSRect rect = NSMakeRect(originX, originY, width, height); NSRect rect = NSMakeRect(originX, originY, width, height);
jobject cPlatformView = (*env)->NewGlobalRef(env, obj); jobject cPlatformView = (*env)->NewGlobalRef(env, obj);
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
AWT_ASSERT_APPKIT_THREAD; AWT_ASSERT_APPKIT_THREAD;
CALayer *windowLayer = jlong_to_ptr(windowLayerPtr); CALayer *windowLayer = jlong_to_ptr(windowLayerPtr);
AWTView *view = [[AWTView alloc] initWithRect:rect AWTView *view = [[AWTView alloc] initWithRect:rect
platformView:cPlatformView platformView:cPlatformView
windowLayer:windowLayer]; windowLayer:windowLayer];
CFRetain(view); CFRetain(view);
[view release]; // GC [view release]; // GC
newView = view; newView = view;
}]; }];
...@@ -1242,3 +1258,125 @@ JNF_COCOA_EXIT(env); ...@@ -1242,3 +1258,125 @@ JNF_COCOA_EXIT(env);
return ptr_to_jlong(newView); return ptr_to_jlong(newView);
} }
/*
* Class: sun_lwawt_macosx_CPlatformView
* Method: nativeSetAutoResizable
* Signature: (JZ)V;
*/
JNIEXPORT void JNICALL
Java_sun_lwawt_macosx_CPlatformView_nativeSetAutoResizable
(JNIEnv *env, jclass cls, jlong viewPtr, jboolean toResize)
{
JNF_COCOA_ENTER(env);
NSView *view = (NSView *)jlong_to_ptr(viewPtr);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
AWT_ASSERT_APPKIT_THREAD;
if (toResize) {
[view setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
} else {
[view setAutoresizingMask: NSViewMinYMargin | NSViewMaxXMargin];
}
if ([view superview] != nil) {
[[view superview] setAutoresizesSubviews:(BOOL)toResize];
}
}];
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CPlatformView
* Method: nativeGetNSViewDisplayID
* Signature: (J)I;
*/
JNIEXPORT jint JNICALL
Java_sun_lwawt_macosx_CPlatformView_nativeGetNSViewDisplayID
(JNIEnv *env, jclass cls, jlong viewPtr)
{
__block jint ret; //CGDirectDisplayID
JNF_COCOA_ENTER(env);
NSView *view = (NSView *)jlong_to_ptr(viewPtr);
NSWindow *window = [view window];
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
AWT_ASSERT_APPKIT_THREAD;
ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue];
}];
JNF_COCOA_EXIT(env);
return ret;
}
/*
* Class: sun_lwawt_macosx_CPlatformView
* Method: nativeGetLocationOnScreen
* Signature: (J)Ljava/awt/Rectangle;
*/
JNIEXPORT jobject JNICALL
Java_sun_lwawt_macosx_CPlatformView_nativeGetLocationOnScreen
(JNIEnv *env, jclass cls, jlong viewPtr)
{
jobject jRect = NULL;
JNF_COCOA_ENTER(env);
__block NSRect rect = NSZeroRect;
NSView *view = (NSView *)jlong_to_ptr(viewPtr);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
AWT_ASSERT_APPKIT_THREAD;
NSRect viewBounds = [view bounds];
NSRect frameInWindow = [view convertRect:viewBounds toView:nil];
rect = [[view window] convertRectToScreen:frameInWindow];
NSRect screenRect = [[NSScreen mainScreen] frame];
//Convert coordinates to top-left corner origin
rect.origin.y = screenRect.size.height - rect.origin.y - viewBounds.size.height;
}];
jRect = NSToJavaRect(env, rect);
JNF_COCOA_EXIT(env);
return jRect;
}
/*
* Class: sun_lwawt_macosx_CPlatformView
* Method: nativeIsViewUnderMouse
* Signature: (J)Z;
*/
JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_CPlatformView_nativeIsViewUnderMouse
(JNIEnv *env, jclass clazz, jlong viewPtr)
{
__block jboolean underMouse = JNI_FALSE;
JNF_COCOA_ENTER(env);
NSView *nsView = OBJC(viewPtr);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
AWT_ASSERT_APPKIT_THREAD;
NSPoint ptWindowCoords = [[nsView window] mouseLocationOutsideOfEventStream];
NSPoint ptViewCoords = [nsView convertPoint:ptWindowCoords fromView:nil];
underMouse = [nsView hitTest:ptViewCoords] != nil;
}];
JNF_COCOA_EXIT(env);
return underMouse;
}
...@@ -1154,34 +1154,6 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMou ...@@ -1154,34 +1154,6 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMou
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
} }
/*
* Class: sun_lwawt_macosx_CPlatformWindow
* Method: nativeGetDisplayID_AppKitThread
* Signature: (J)I
*/
JNIEXPORT jint JNICALL
Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID
(JNIEnv *env, jclass clazz, jlong windowPtr)
{
__block jint ret; // CGDirectDisplayID
JNF_COCOA_ENTER(env);
NSWindow *window = OBJC(windowPtr);
if ([NSThread isMainThread]) {
ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue];
} else {
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue];
}];
}
JNF_COCOA_EXIT(env);
return ret;
}
/* /*
* Class: sun_lwawt_macosx_CPlatformWindow * Class: sun_lwawt_macosx_CPlatformWindow
* Method: _toggleFullScreenMode * Method: _toggleFullScreenMode
...@@ -1203,27 +1175,6 @@ JNF_COCOA_ENTER(env); ...@@ -1203,27 +1175,6 @@ JNF_COCOA_ENTER(env);
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
} }
JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_CMouseInfoPeer_nativeIsWindowUnderMouse
(JNIEnv *env, jclass clazz, jlong windowPtr)
{
__block jboolean underMouse = JNI_FALSE;
JNF_COCOA_ENTER(env);
AWT_ASSERT_NOT_APPKIT_THREAD;
NSWindow *nsWindow = OBJC(windowPtr);
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^() {
AWT_ASSERT_APPKIT_THREAD;
NSPoint pt = [nsWindow mouseLocationOutsideOfEventStream];
underMouse = [[nsWindow contentView] hitTest:pt] != nil;
}];
JNF_COCOA_EXIT(env);
return underMouse;
}
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetEnabled JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetEnabled
(JNIEnv *env, jclass clazz, jlong windowPtr, jboolean isEnabled) (JNIEnv *env, jclass clazz, jlong windowPtr, jboolean isEnabled)
{ {
......
...@@ -123,14 +123,15 @@ Java_sun_lwawt_macosx_CCursorManager_nativeGetCursorPosition ...@@ -123,14 +123,15 @@ Java_sun_lwawt_macosx_CCursorManager_nativeGetCursorPosition
jobject jpt = NULL; jobject jpt = NULL;
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
AWT_ASSERT_NOT_APPKIT_THREAD;
__block NSPoint pt = NSZeroPoint; __block NSPoint pt = NSZeroPoint;
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
AWT_ASSERT_APPKIT_THREAD; [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
AWT_ASSERT_APPKIT_THREAD;
pt = ConvertNSScreenPoint(env, [NSEvent mouseLocation]);
pt = ConvertNSScreenPoint(env, [NSEvent mouseLocation]);
}]; }];
jpt = NSToJavaPoint(env, pt); jpt = NSToJavaPoint(env, pt);
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
......
...@@ -650,6 +650,26 @@ JNF_COCOA_EXIT(env); ...@@ -650,6 +650,26 @@ JNF_COCOA_EXIT(env);
return windowPtr; return windowPtr;
} }
/*
* Class: sun_lwawt_macosx_CWrapper$NSView
* Method: setHidden
* Signature: (JZ)V
*/
JNIEXPORT jlong JNICALL
Java_sun_lwawt_macosx_CWrapper_00024NSView_setHidden
(JNIEnv *env, jclass cls, jlong viewPtr, jboolean toHide)
{
JNF_COCOA_ENTER(env);
NSView *view = (NSView *)jlong_to_ptr(viewPtr);
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
[view setHidden:(BOOL)toHide];
}];
JNF_COCOA_EXIT(env);
}
/* /*
* Class: sun_lwawt_macosx_CWrapper$NSScreen * Class: sun_lwawt_macosx_CWrapper$NSScreen
* Method: frame * Method: frame
......
...@@ -95,7 +95,7 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -95,7 +95,7 @@ AWT_ASSERT_APPKIT_THREAD;
CFRelease(busyObserver); CFRelease(busyObserver);
CFRelease(notBusyObserver); CFRelease(notBusyObserver);
if (!headless) setBusy(YES); if (!headless) setBusy(YES);
// Set the java name of the AppKit main thread appropriately. // Set the java name of the AppKit main thread appropriately.
...@@ -367,7 +367,8 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -367,7 +367,8 @@ AWT_ASSERT_APPKIT_THREAD;
CFRunLoopRef runLoop = [[NSRunLoop currentRunLoop] getCFRunLoop]; CFRunLoopRef runLoop = [[NSRunLoop currentRunLoop] getCFRunLoop];
CFRunLoopRemoveObserver(runLoop, busyObserver, kCFRunLoopDefaultMode); CFRunLoopRemoveObserver(runLoop, busyObserver, kCFRunLoopDefaultMode);
CFRunLoopRemoveObserver(runLoop, notBusyObserver, kCFRunLoopDefaultMode); CFRunLoopRemoveObserver(runLoop, notBusyObserver, kCFRunLoopDefaultMode);
// We don't track if the runloop is busy, so set it free to let AWT finish when it needs
setBusy(NO);
busyObserver = NULL; busyObserver = NULL;
notBusyObserver = NULL; notBusyObserver = NULL;
} else { } else {
......
...@@ -151,16 +151,15 @@ Java_sun_java2d_opengl_CGLLayer_nativeCreateLayer ...@@ -151,16 +151,15 @@ Java_sun_java2d_opengl_CGLLayer_nativeCreateLayer
__block CGLLayer *layer = nil; __block CGLLayer *layer = nil;
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
AWT_ASSERT_NOT_APPKIT_THREAD;
JNFJObjectWrapper *javaLayer = [JNFJObjectWrapper wrapperWithJObject:obj withEnv:env]; JNFJObjectWrapper *javaLayer = [JNFJObjectWrapper wrapperWithJObject:obj withEnv:env];
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
AWT_ASSERT_APPKIT_THREAD; AWT_ASSERT_APPKIT_THREAD;
layer = [[CGLLayer alloc] initWithJavaLayer: javaLayer]; layer = [[CGLLayer alloc] initWithJavaLayer: javaLayer];
}]; }];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
return ptr_to_jlong(layer); return ptr_to_jlong(layer);
......
...@@ -139,7 +139,7 @@ __attribute__((visibility("default"))) ...@@ -139,7 +139,7 @@ __attribute__((visibility("default")))
+ (JNIEnv*)getJNIEnvUncached; + (JNIEnv*)getJNIEnvUncached;
+ (void)performOnMainThread:(SEL)aSelector onObject:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait awtMode:(BOOL)inAWT; + (void)performOnMainThread:(SEL)aSelector onObject:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait awtMode:(BOOL)inAWT;
+ (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block;
@end @end
void OSXAPP_SetJavaVM(JavaVM *vm); void OSXAPP_SetJavaVM(JavaVM *vm);
......
...@@ -245,6 +245,14 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -245,6 +245,14 @@ AWT_ASSERT_APPKIT_THREAD;
} }
} }
+ (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block {
if ([NSThread isMainThread] && wait == YES) {
block();
} else {
[JNFRunLoop performOnMainThreadWaiting:wait withBlock:block];
}
}
@end @end
......
...@@ -115,6 +115,7 @@ public abstract class ClientCommunicatorAdmin { ...@@ -115,6 +115,7 @@ public abstract class ClientCommunicatorAdmin {
// restarted is failed by another thread // restarted is failed by another thread
throw ioe; throw ioe;
} }
return;
} else { } else {
state = RE_CONNECTING; state = RE_CONNECTING;
lock.notifyAll(); lock.notifyAll();
...@@ -195,7 +196,7 @@ public abstract class ClientCommunicatorAdmin { ...@@ -195,7 +196,7 @@ public abstract class ClientCommunicatorAdmin {
if (e instanceof IOException && if (e instanceof IOException &&
!(e instanceof InterruptedIOException)) { !(e instanceof InterruptedIOException)) {
try { try {
restart((IOException)e); gotIOException((IOException)e);
} catch (Exception ee) { } catch (Exception ee) {
logger.warning("Checker-run", logger.warning("Checker-run",
"Failed to check connection: "+ e); "Failed to check connection: "+ e);
......
...@@ -51,6 +51,7 @@ import javax.management.remote.TargetedNotification; ...@@ -51,6 +51,7 @@ import javax.management.remote.TargetedNotification;
import com.sun.jmx.remote.util.ClassLogger; import com.sun.jmx.remote.util.ClassLogger;
import com.sun.jmx.remote.util.EnvHelp; import com.sun.jmx.remote.util.EnvHelp;
import java.rmi.UnmarshalException;
public abstract class ClientNotifForwarder { public abstract class ClientNotifForwarder {
...@@ -594,10 +595,7 @@ public abstract class ClientNotifForwarder { ...@@ -594,10 +595,7 @@ public abstract class ClientNotifForwarder {
} }
return nr; return nr;
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException | NotSerializableException | UnmarshalException e) {
logger.trace("NotifFetcher.fetchNotifs", e);
return fetchOneNotif();
} catch (NotSerializableException e) {
logger.trace("NotifFetcher.fetchNotifs", e); logger.trace("NotifFetcher.fetchNotifs", e);
return fetchOneNotif(); return fetchOneNotif();
} catch (IOException ioe) { } catch (IOException ioe) {
...@@ -619,17 +617,18 @@ public abstract class ClientNotifForwarder { ...@@ -619,17 +617,18 @@ public abstract class ClientNotifForwarder {
timeout. This allows us to skip sequence numbers for timeout. This allows us to skip sequence numbers for
notifications that don't match our filters. Then we ask notifications that don't match our filters. Then we ask
for one notification. If that produces a for one notification. If that produces a
ClassNotFoundException or a NotSerializableException, we ClassNotFoundException, NotSerializableException or
increase our sequence number and ask again. Eventually we UnmarshalException, we increase our sequence number and ask again.
will either get a successful notification, or a return with Eventually we will either get a successful notification, or a
0 notifications. In either case we can return a return with 0 notifications. In either case we can return a
NotificationResult. This algorithm works (albeit less NotificationResult. This algorithm works (albeit less
well) even if the server implementation doesn't optimize a well) even if the server implementation doesn't optimize a
request for 0 notifications to skip sequence numbers for request for 0 notifications to skip sequence numbers for
notifications that don't match our filters. notifications that don't match our filters.
If we had at least one ClassNotFoundException, then we If we had at least one
must emit a JMXConnectionNotification.LOST_NOTIFS. ClassNotFoundException/NotSerializableException/UnmarshalException,
then we must emit a JMXConnectionNotification.LOST_NOTIFS.
*/ */
private NotificationResult fetchOneNotif() { private NotificationResult fetchOneNotif() {
ClientNotifForwarder cnf = ClientNotifForwarder.this; ClientNotifForwarder cnf = ClientNotifForwarder.this;
...@@ -668,23 +667,20 @@ public abstract class ClientNotifForwarder { ...@@ -668,23 +667,20 @@ public abstract class ClientNotifForwarder {
try { try {
// 1 notif to skip possible missing class // 1 notif to skip possible missing class
result = cnf.fetchNotifs(startSequenceNumber, 1, 0L); result = cnf.fetchNotifs(startSequenceNumber, 1, 0L);
} catch (Exception e) { } catch (ClassNotFoundException | NotSerializableException | UnmarshalException e) {
if (e instanceof ClassNotFoundException logger.warning("NotifFetcher.fetchOneNotif",
|| e instanceof NotSerializableException) { "Failed to deserialize a notification: "+e.toString());
logger.warning("NotifFetcher.fetchOneNotif", if (logger.traceOn()) {
"Failed to deserialize a notification: "+e.toString()); logger.trace("NotifFetcher.fetchOneNotif",
if (logger.traceOn()) { "Failed to deserialize a notification.", e);
logger.trace("NotifFetcher.fetchOneNotif",
"Failed to deserialize a notification.", e);
}
notFoundCount++;
startSequenceNumber++;
} else {
if (!shouldStop())
logger.trace("NotifFetcher.fetchOneNotif", e);
return null;
} }
notFoundCount++;
startSequenceNumber++;
} catch (Exception e) {
if (!shouldStop())
logger.trace("NotifFetcher.fetchOneNotif", e);
return null;
} }
} }
...@@ -692,7 +688,7 @@ public abstract class ClientNotifForwarder { ...@@ -692,7 +688,7 @@ public abstract class ClientNotifForwarder {
final String msg = final String msg =
"Dropped " + notFoundCount + " notification" + "Dropped " + notFoundCount + " notification" +
(notFoundCount == 1 ? "" : "s") + (notFoundCount == 1 ? "" : "s") +
" because classes were missing locally"; " because classes were missing locally or incompatible";
lostNotifs(msg, notFoundCount); lostNotifs(msg, notFoundCount);
// Even if result.getEarliestSequenceNumber() is now greater than // Even if result.getEarliestSequenceNumber() is now greater than
// it was initially, meaning some notifs have been dropped // it was initially, meaning some notifs have been dropped
......
...@@ -26,13 +26,8 @@ ...@@ -26,13 +26,8 @@
package com.sun.jmx.remote.internal; package com.sun.jmx.remote.internal;
import java.util.Properties; import java.util.Properties;
import java.io.IOException;
import java.rmi.Remote; import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.NoSuchObjectException;
import java.util.Properties;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.NoSuchObjectException; import java.rmi.NoSuchObjectException;
import java.security.AccessController; import java.security.AccessController;
...@@ -115,9 +110,10 @@ public final class IIOPHelper { ...@@ -115,9 +110,10 @@ public final class IIOPHelper {
* Connects the Stub to the given ORB. * Connects the Stub to the given ORB.
*/ */
public static void connect(Object stub, Object orb) public static void connect(Object stub, Object orb)
throws RemoteException throws IOException
{ {
ensureAvailable(); if (proxy == null)
throw new IOException("Connection to ORB failed, RMI/IIOP not available");
proxy.connect(stub, orb); proxy.connect(stub, orb);
} }
...@@ -125,15 +121,17 @@ public final class IIOPHelper { ...@@ -125,15 +121,17 @@ public final class IIOPHelper {
* Returns true if the given object is an ORB. * Returns true if the given object is an ORB.
*/ */
public static boolean isOrb(Object obj) { public static boolean isOrb(Object obj) {
ensureAvailable(); return (proxy == null) ? false : proxy.isOrb(obj);
return proxy.isOrb(obj);
} }
/** /**
* Creates, and returns, a new ORB instance. * Creates, and returns, a new ORB instance.
*/ */
public static Object createOrb(String[] args, Properties props) { public static Object createOrb(String[] args, Properties props)
ensureAvailable(); throws IOException
{
if (proxy == null)
throw new IOException("ORB initialization failed, RMI/IIOP not available");
return proxy.createOrb(args, props); return proxy.createOrb(args, props);
} }
...@@ -166,24 +164,27 @@ public final class IIOPHelper { ...@@ -166,24 +164,27 @@ public final class IIOPHelper {
/** /**
* Makes a server object ready to receive remote calls * Makes a server object ready to receive remote calls
*/ */
public static void exportObject(Remote obj) throws RemoteException { public static void exportObject(Remote obj) throws IOException {
ensureAvailable(); if (proxy == null)
throw new IOException("RMI object cannot be exported, RMI/IIOP not available");
proxy.exportObject(obj); proxy.exportObject(obj);
} }
/** /**
* Deregisters a server object from the runtime. * Deregisters a server object from the runtime.
*/ */
public static void unexportObject(Remote obj) throws NoSuchObjectException { public static void unexportObject(Remote obj) throws IOException {
ensureAvailable(); if (proxy == null)
throw new NoSuchObjectException("Object not exported");
proxy.unexportObject(obj); proxy.unexportObject(obj);
} }
/** /**
* Returns a stub for the given server object. * Returns a stub for the given server object.
*/ */
public static Remote toStub(Remote obj) throws NoSuchObjectException { public static Remote toStub(Remote obj) throws IOException {
ensureAvailable(); if (proxy == null)
throw new NoSuchObjectException("Object not exported");
return proxy.toStub(obj); return proxy.toStub(obj);
} }
} }
...@@ -506,6 +506,7 @@ public final ...@@ -506,6 +506,7 @@ public final
* returns {@code false} otherwise. * returns {@code false} otherwise.
* @return {@code true} if and only if this class is a synthetic class as * @return {@code true} if and only if this class is a synthetic class as
* defined by the Java Language Specification. * defined by the Java Language Specification.
* @jls 13.1 The Form of a Binary
* @since 1.5 * @since 1.5
*/ */
public boolean isSynthetic() { public boolean isSynthetic() {
......
...@@ -66,6 +66,8 @@ public final class Constructor<T> extends Executable { ...@@ -66,6 +66,8 @@ public final class Constructor<T> extends Executable {
private transient ConstructorRepository genericInfo; private transient ConstructorRepository genericInfo;
private byte[] annotations; private byte[] annotations;
private byte[] parameterAnnotations; private byte[] parameterAnnotations;
// This is set by the vm at Constructor creation
private byte[] typeAnnotations;
// Generics infrastructure // Generics infrastructure
// Accessor for factory // Accessor for factory
...@@ -138,6 +140,8 @@ public final class Constructor<T> extends Executable { ...@@ -138,6 +140,8 @@ public final class Constructor<T> extends Executable {
res.root = this; res.root = this;
// Might as well eagerly propagate this if already present // Might as well eagerly propagate this if already present
res.constructorAccessor = constructorAccessor; res.constructorAccessor = constructorAccessor;
res.typeAnnotations = typeAnnotations;
return res; return res;
} }
...@@ -407,6 +411,7 @@ public final class Constructor<T> extends Executable { ...@@ -407,6 +411,7 @@ public final class Constructor<T> extends Executable {
/** /**
* {@inheritDoc} * {@inheritDoc}
* @jls 13.1 The Form of a Binary
* @since 1.5 * @since 1.5
*/ */
@Override @Override
......
...@@ -324,6 +324,7 @@ public abstract class Executable extends AccessibleObject ...@@ -324,6 +324,7 @@ public abstract class Executable extends AccessibleObject
* @return true if and only if this executable is a synthetic * @return true if and only if this executable is a synthetic
* construct as defined by * construct as defined by
* <cite>The Java&trade; Language Specification</cite>. * <cite>The Java&trade; Language Specification</cite>.
* @jls 13.1 The Form of a Binary
*/ */
public boolean isSynthetic() { public boolean isSynthetic() {
return Modifier.isSynthetic(getModifiers()); return Modifier.isSynthetic(getModifiers());
......
...@@ -80,6 +80,8 @@ class Field extends AccessibleObject implements Member { ...@@ -80,6 +80,8 @@ class Field extends AccessibleObject implements Member {
// currently only two levels deep (i.e., one root Field and // currently only two levels deep (i.e., one root Field and
// potentially many Field objects pointing to it.) // potentially many Field objects pointing to it.)
private Field root; private Field root;
// This is set by the vm at Field creation
private byte[] typeAnnotations;
// Generics infrastructure // Generics infrastructure
...@@ -144,6 +146,8 @@ class Field extends AccessibleObject implements Member { ...@@ -144,6 +146,8 @@ class Field extends AccessibleObject implements Member {
// Might as well eagerly propagate this if already present // Might as well eagerly propagate this if already present
res.fieldAccessor = fieldAccessor; res.fieldAccessor = fieldAccessor;
res.overrideFieldAccessor = overrideFieldAccessor; res.overrideFieldAccessor = overrideFieldAccessor;
res.typeAnnotations = typeAnnotations;
return res; return res;
} }
......
/* /*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -87,6 +87,7 @@ interface Member { ...@@ -87,6 +87,7 @@ interface Member {
* *
* @return true if and only if this member was introduced by * @return true if and only if this member was introduced by
* the compiler. * the compiler.
* @jls 13.1 The Form of a Binary
* @since 1.5 * @since 1.5
*/ */
public boolean isSynthetic(); public boolean isSynthetic();
......
...@@ -79,7 +79,8 @@ public final class Method extends Executable { ...@@ -79,7 +79,8 @@ public final class Method extends Executable {
// currently only two levels deep (i.e., one root Method and // currently only two levels deep (i.e., one root Method and
// potentially many Method objects pointing to it.) // potentially many Method objects pointing to it.)
private Method root; private Method root;
// This is set by the vm at Method creation
private byte[] typeAnnotations;
// Generics infrastructure // Generics infrastructure
private String getGenericSignature() {return signature;} private String getGenericSignature() {return signature;}
...@@ -150,6 +151,8 @@ public final class Method extends Executable { ...@@ -150,6 +151,8 @@ public final class Method extends Executable {
res.root = this; res.root = this;
// Might as well eagerly propagate this if already present // Might as well eagerly propagate this if already present
res.methodAccessor = methodAccessor; res.methodAccessor = methodAccessor;
res.typeAnnotations = typeAnnotations;
return res; return res;
} }
...@@ -497,6 +500,7 @@ public final class Method extends Executable { ...@@ -497,6 +500,7 @@ public final class Method extends Executable {
/** /**
* {@inheritDoc} * {@inheritDoc}
* @jls 13.1 The Form of a Binary
* @since 1.5 * @since 1.5
*/ */
@Override @Override
...@@ -504,6 +508,22 @@ public final class Method extends Executable { ...@@ -504,6 +508,22 @@ public final class Method extends Executable {
return super.isSynthetic(); return super.isSynthetic();
} }
/**
* Returns {@code true} if this method is a default
* method; returns {@code false} otherwise.
*
* A default method is a non-abstract method, that is, a method
* with a body, declared in an interface type.
*
* @return true if and only if this method is a default
* method as defined by the Java Language Specification.
* @since 1.8
*/
public boolean isDefault() {
return (getModifiers() & Modifier.ABSTRACT) == 0 &&
getDeclaringClass().isInterface();
}
// NOTE that there is no synchronization used here. It is correct // NOTE that there is no synchronization used here. It is correct
// (though not efficient) to generate more than one MethodAccessor // (though not efficient) to generate more than one MethodAccessor
// for a given Method. However, avoiding synchronization will // for a given Method. However, avoiding synchronization will
......
...@@ -1188,7 +1188,7 @@ class Properties extends Hashtable<Object,Object> { ...@@ -1188,7 +1188,7 @@ class Properties extends Hashtable<Object,Object> {
provider = loadProviderAsService(cl); provider = loadProviderAsService(cl);
if (provider != null) if (provider != null)
return provider; return provider;
throw new InternalError("No fallback"); return new jdk.internal.util.xml.BasicXmlPropertiesProvider();
}}); }});
} }
......
...@@ -239,12 +239,10 @@ public class MBeanFeatureInfo implements Serializable, DescriptorRead { ...@@ -239,12 +239,10 @@ public class MBeanFeatureInfo implements Serializable, DescriptorRead {
case 1: case 1:
final String[] names = (String[])in.readObject(); final String[] names = (String[])in.readObject();
if (names.length == 0) { final Object[] values = (Object[]) in.readObject();
descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR; descriptor = (names.length == 0) ?
} else { ImmutableDescriptor.EMPTY_DESCRIPTOR :
final Object[] values = (Object[])in.readObject(); new ImmutableDescriptor(names, values);
descriptor = new ImmutableDescriptor(names, values);
}
break; break;
case 0: case 0:
......
...@@ -704,12 +704,10 @@ public class MBeanInfo implements Cloneable, Serializable, DescriptorRead { ...@@ -704,12 +704,10 @@ public class MBeanInfo implements Cloneable, Serializable, DescriptorRead {
case 1: case 1:
final String[] names = (String[])in.readObject(); final String[] names = (String[])in.readObject();
if (names.length == 0) { final Object[] values = (Object[]) in.readObject();
descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR; descriptor = (names.length == 0) ?
} else { ImmutableDescriptor.EMPTY_DESCRIPTOR :
final Object[] values = (Object[])in.readObject(); new ImmutableDescriptor(names, values);
descriptor = new ImmutableDescriptor(names, values);
}
break; break;
case 0: case 0:
......
...@@ -137,8 +137,10 @@ import com.sun.jmx.remote.util.EnvHelp; ...@@ -137,8 +137,10 @@ import com.sun.jmx.remote.util.EnvHelp;
* JAR conventions for service providers</a>, where the service * JAR conventions for service providers</a>, where the service
* interface is <code>JMXConnectorProvider</code>.</p> * interface is <code>JMXConnectorProvider</code>.</p>
* *
* <p>Every implementation must support the RMI connector protocols, * <p>Every implementation must support the RMI connector protocol with
* specified with the string <code>rmi</code> or * the default RMI transport, specified with string <code>rmi</code>.
* An implementation may optionally support the RMI connector protocol
* with the RMI/IIOP transport, specified with the string
* <code>iiop</code>.</p> * <code>iiop</code>.</p>
* *
* <p>Once a provider is found, the result of the * <p>Once a provider is found, the result of the
......
...@@ -129,8 +129,10 @@ import javax.management.MBeanServer; ...@@ -129,8 +129,10 @@ import javax.management.MBeanServer;
* JAR conventions for service providers</a>, where the service * JAR conventions for service providers</a>, where the service
* interface is <code>JMXConnectorServerProvider</code>.</p> * interface is <code>JMXConnectorServerProvider</code>.</p>
* *
* <p>Every implementation must support the RMI connector protocols, * <p>Every implementation must support the RMI connector protocol with
* specified with the string <code>rmi</code> or * the default RMI transport, specified with string <code>rmi</code>.
* An implementation may optionally support the RMI connector protocol
* with the RMI/IIOP transport, specified with the string
* <code>iiop</code>.</p> * <code>iiop</code>.</p>
* *
* <p>Once a provider is found, the result of the * <p>Once a provider is found, the result of the
......
...@@ -238,10 +238,21 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable ...@@ -238,10 +238,21 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// implements JMXConnector interface // implements JMXConnector interface
//-------------------------------------------------------------------- //--------------------------------------------------------------------
/**
* @throws IOException if the connection could not be made because of a
* communication problem, or in the case of the {@code iiop} protocol,
* that RMI/IIOP is not supported
*/
public void connect() throws IOException { public void connect() throws IOException {
connect(null); connect(null);
} }
/**
* @throws IOException if the connection could not be made because of a
* communication problem, or in the case of the {@code iiop} protocol,
* that RMI/IIOP is not supported
*/
public synchronized void connect(Map<String,?> environment) public synchronized void connect(Map<String,?> environment)
throws IOException { throws IOException {
final boolean tracing = logger.traceOn(); final boolean tracing = logger.traceOn();
......
...@@ -337,7 +337,8 @@ public class RMIConnectorServer extends JMXConnectorServer { ...@@ -337,7 +337,8 @@ public class RMIConnectorServer extends JMXConnectorServer {
* @exception IllegalStateException if the connector server has * @exception IllegalStateException if the connector server has
* not been attached to an MBean server. * not been attached to an MBean server.
* @exception IOException if the connector server cannot be * @exception IOException if the connector server cannot be
* started. * started, or in the case of the {@code iiop} protocol, that
* RMI/IIOP is not supported.
*/ */
public synchronized void start() throws IOException { public synchronized void start() throws IOException {
final boolean tracing = logger.traceOn(); final boolean tracing = logger.traceOn();
......
...@@ -36,8 +36,8 @@ questions. ...@@ -36,8 +36,8 @@ questions.
that different implementations of the RMI connector can that different implementations of the RMI connector can
interoperate.</p> interoperate.</p>
<p>The RMI connector supports both the JRMP and the IIOP transports <p>The RMI connector supports the JRMP transport for RMI, and
for RMI.</p> optionally the IIOP transport.</p>
<p>Like most connectors in the JMX Remote API, an RMI connector <p>Like most connectors in the JMX Remote API, an RMI connector
usually has an address, which usually has an address, which
......
/*
* Copyright (c) 2000, 2005, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
// Attributes.java - attribute list with Namespace support
// http://www.saxproject.org
// Written by David Megginson
// NO WARRANTY! This class is in the public domain.
// $Id: Attributes.java,v 1.2 2004/11/03 22:44:51 jsuttor Exp $
package jdk.internal.org.xml.sax;
/**
* Interface for a list of XML attributes.
*
* <blockquote>
* <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote>
*
* <p>This interface allows access to a list of attributes in
* three different ways:</p>
*
* <ol>
* <li>by attribute index;</li>
* <li>by Namespace-qualified name; or</li>
* <li>by qualified (prefixed) name.</li>
* </ol>
*
* <p>The list will not contain attributes that were declared
* #IMPLIED but not specified in the start tag. It will also not
* contain attributes used as Namespace declarations (xmlns*) unless
* the <code>http://xml.org/sax/features/namespace-prefixes</code>
* feature is set to <var>true</var> (it is <var>false</var> by
* default).
* Because SAX2 conforms to the original "Namespaces in XML"
* recommendation, it normally does not
* give namespace declaration attributes a namespace URI.
* </p>
*
* <p>Some SAX2 parsers may support using an optional feature flag
* (<code>http://xml.org/sax/features/xmlns-uris</code>) to request
* that those attributes be given URIs, conforming to a later
* backwards-incompatible revision of that recommendation. (The
* attribute's "local name" will be the prefix, or "xmlns" when
* defining a default element namespace.) For portability, handler
* code should always resolve that conflict, rather than requiring
* parsers that can change the setting of that feature flag. </p>
*
* <p>If the namespace-prefixes feature (see above) is
* <var>false</var>, access by qualified name may not be available; if
* the <code>http://xml.org/sax/features/namespaces</code> feature is
* <var>false</var>, access by Namespace-qualified names may not be
* available.</p>
*
* <p>This interface replaces the now-deprecated SAX1 {@link
* org.xml.sax.AttributeList AttributeList} interface, which does not
* contain Namespace support. In addition to Namespace support, it
* adds the <var>getIndex</var> methods (below).</p>
*
* <p>The order of attributes in the list is unspecified, and will
* vary from implementation to implementation.</p>
*
* @since SAX 2.0
* @author David Megginson
* @see org.xml.sax.helpers.AttributesImpl
* @see org.xml.sax.ext.DeclHandler#attributeDecl
*/
public interface Attributes
{
////////////////////////////////////////////////////////////////////
// Indexed access.
////////////////////////////////////////////////////////////////////
/**
* Return the number of attributes in the list.
*
* <p>Once you know the number of attributes, you can iterate
* through the list.</p>
*
* @return The number of attributes in the list.
* @see #getURI(int)
* @see #getLocalName(int)
* @see #getQName(int)
* @see #getType(int)
* @see #getValue(int)
*/
public abstract int getLength ();
/**
* Look up an attribute's Namespace URI by index.
*
* @param index The attribute index (zero-based).
* @return The Namespace URI, or the empty string if none
* is available, or null if the index is out of
* range.
* @see #getLength
*/
public abstract String getURI (int index);
/**
* Look up an attribute's local name by index.
*
* @param index The attribute index (zero-based).
* @return The local name, or the empty string if Namespace
* processing is not being performed, or null
* if the index is out of range.
* @see #getLength
*/
public abstract String getLocalName (int index);
/**
* Look up an attribute's XML qualified (prefixed) name by index.
*
* @param index The attribute index (zero-based).
* @return The XML qualified name, or the empty string
* if none is available, or null if the index
* is out of range.
* @see #getLength
*/
public abstract String getQName (int index);
/**
* Look up an attribute's type by index.
*
* <p>The attribute type is one of the strings "CDATA", "ID",
* "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
* or "NOTATION" (always in upper case).</p>
*
* <p>If the parser has not read a declaration for the attribute,
* or if the parser does not report attribute types, then it must
* return the value "CDATA" as stated in the XML 1.0 Recommendation
* (clause 3.3.3, "Attribute-Value Normalization").</p>
*
* <p>For an enumerated attribute that is not a notation, the
* parser will report the type as "NMTOKEN".</p>
*
* @param index The attribute index (zero-based).
* @return The attribute's type as a string, or null if the
* index is out of range.
* @see #getLength
*/
public abstract String getType (int index);
/**
* Look up an attribute's value by index.
*
* <p>If the attribute value is a list of tokens (IDREFS,
* ENTITIES, or NMTOKENS), the tokens will be concatenated
* into a single string with each token separated by a
* single space.</p>
*
* @param index The attribute index (zero-based).
* @return The attribute's value as a string, or null if the
* index is out of range.
* @see #getLength
*/
public abstract String getValue (int index);
////////////////////////////////////////////////////////////////////
// Name-based query.
////////////////////////////////////////////////////////////////////
/**
* Look up the index of an attribute by Namespace name.
*
* @param uri The Namespace URI, or the empty string if
* the name has no Namespace URI.
* @param localName The attribute's local name.
* @return The index of the attribute, or -1 if it does not
* appear in the list.
*/
public int getIndex (String uri, String localName);
/**
* Look up the index of an attribute by XML qualified (prefixed) name.
*
* @param qName The qualified (prefixed) name.
* @return The index of the attribute, or -1 if it does not
* appear in the list.
*/
public int getIndex (String qName);
/**
* Look up an attribute's type by Namespace name.
*
* <p>See {@link #getType(int) getType(int)} for a description
* of the possible types.</p>
*
* @param uri The Namespace URI, or the empty String if the
* name has no Namespace URI.
* @param localName The local name of the attribute.
* @return The attribute type as a string, or null if the
* attribute is not in the list or if Namespace
* processing is not being performed.
*/
public abstract String getType (String uri, String localName);
/**
* Look up an attribute's type by XML qualified (prefixed) name.
*
* <p>See {@link #getType(int) getType(int)} for a description
* of the possible types.</p>
*
* @param qName The XML qualified name.
* @return The attribute type as a string, or null if the
* attribute is not in the list or if qualified names
* are not available.
*/
public abstract String getType (String qName);
/**
* Look up an attribute's value by Namespace name.
*
* <p>See {@link #getValue(int) getValue(int)} for a description
* of the possible values.</p>
*
* @param uri The Namespace URI, or the empty String if the
* name has no Namespace URI.
* @param localName The local name of the attribute.
* @return The attribute value as a string, or null if the
* attribute is not in the list.
*/
public abstract String getValue (String uri, String localName);
/**
* Look up an attribute's value by XML qualified (prefixed) name.
*
* <p>See {@link #getValue(int) getValue(int)} for a description
* of the possible values.</p>
*
* @param qName The XML qualified name.
* @return The attribute value as a string, or null if the
* attribute is not in the list or if qualified names
* are not available.
*/
public abstract String getValue (String qName);
}
// end of Attributes.java
/*
* Copyright (c) 2000, 2005, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
// SAX DTD handler.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will.
// $Id: DTDHandler.java,v 1.2 2004/11/03 22:44:51 jsuttor Exp $
package jdk.internal.org.xml.sax;
/**
* Receive notification of basic DTD-related events.
*
* <blockquote>
* <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote>
*
* <p>If a SAX application needs information about notations and
* unparsed entities, then the application implements this
* interface and registers an instance with the SAX parser using
* the parser's setDTDHandler method. The parser uses the
* instance to report notation and unparsed entity declarations to
* the application.</p>
*
* <p>Note that this interface includes only those DTD events that
* the XML recommendation <em>requires</em> processors to report:
* notation and unparsed entity declarations.</p>
*
* <p>The SAX parser may report these events in any order, regardless
* of the order in which the notations and unparsed entities were
* declared; however, all DTD events must be reported after the
* document handler's startDocument event, and before the first
* startElement event.
* (If the {@link org.xml.sax.ext.LexicalHandler LexicalHandler} is
* used, these events must also be reported before the endDTD event.)
* </p>
*
* <p>It is up to the application to store the information for
* future use (perhaps in a hash table or object tree).
* If the application encounters attributes of type "NOTATION",
* "ENTITY", or "ENTITIES", it can use the information that it
* obtained through this interface to find the entity and/or
* notation corresponding with the attribute value.</p>
*
* @since SAX 1.0
* @author David Megginson
* @see org.xml.sax.XMLReader#setDTDHandler
*/
public interface DTDHandler {
/**
* Receive notification of a notation declaration event.
*
* <p>It is up to the application to record the notation for later
* reference, if necessary;
* notations may appear as attribute values and in unparsed entity
* declarations, and are sometime used with processing instruction
* target names.</p>
*
* <p>At least one of publicId and systemId must be non-null.
* If a system identifier is present, and it is a URL, the SAX
* parser must resolve it fully before passing it to the
* application through this event.</p>
*
* <p>There is no guarantee that the notation declaration will be
* reported before any unparsed entities that use it.</p>
*
* @param name The notation name.
* @param publicId The notation's public identifier, or null if
* none was given.
* @param systemId The notation's system identifier, or null if
* none was given.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #unparsedEntityDecl
* @see org.xml.sax.Attributes
*/
public abstract void notationDecl (String name,
String publicId,
String systemId)
throws SAXException;
/**
* Receive notification of an unparsed entity declaration event.
*
* <p>Note that the notation name corresponds to a notation
* reported by the {@link #notationDecl notationDecl} event.
* It is up to the application to record the entity for later
* reference, if necessary;
* unparsed entities may appear as attribute values.
* </p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before passing it to the application.</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @param name The unparsed entity's name.
* @param publicId The entity's public identifier, or null if none
* was given.
* @param systemId The entity's system identifier.
* @param notationName The name of the associated notation.
* @see #notationDecl
* @see org.xml.sax.Attributes
*/
public abstract void unparsedEntityDecl (String name,
String publicId,
String systemId,
String notationName)
throws SAXException;
}
// end of DTDHandler.java
此差异已折叠。
/*
* Copyright (c) 2000, 2005, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
// SAXNotRecognizedException.java - unrecognized feature or value.
// http://www.saxproject.org
// Written by David Megginson
// NO WARRANTY! This class is in the Public Domain.
// $Id: SAXNotRecognizedException.java,v 1.3 2004/11/03 22:55:32 jsuttor Exp $
package jdk.internal.org.xml.sax;
/**
* Exception class for an unrecognized identifier.
*
* <blockquote>
* <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote>
*
* <p>An XMLReader will throw this exception when it finds an
* unrecognized feature or property identifier; SAX applications and
* extensions may use this class for other, similar purposes.</p>
*
* @since SAX 2.0
* @author David Megginson
* @see org.xml.sax.SAXNotSupportedException
*/
public class SAXNotRecognizedException extends SAXException
{
/**
* Default constructor.
*/
public SAXNotRecognizedException ()
{
super();
}
/**
* Construct a new exception with the given message.
*
* @param message The text message of the exception.
*/
public SAXNotRecognizedException (String message)
{
super(message);
}
// Added serialVersionUID to preserve binary compatibility
static final long serialVersionUID = 5440506620509557213L;
}
// end of SAXNotRecognizedException.java
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -83,11 +83,8 @@ class KeepAliveStream extends MeteredStream implements Hurryable { ...@@ -83,11 +83,8 @@ class KeepAliveStream extends MeteredStream implements Hurryable {
if (expected > count) { if (expected > count) {
long nskip = expected - count; long nskip = expected - count;
if (nskip <= available()) { if (nskip <= available()) {
long n = 0; do {} while ((nskip = (expected - count)) > 0L
while (n < nskip) { && skip(Math.min(nskip, available())) > 0L);
nskip = nskip - n;
n = skip(nskip);
}
} else if (expected <= KeepAliveStreamCleaner.MAX_DATA_REMAINING && !hurried) { } else if (expected <= KeepAliveStreamCleaner.MAX_DATA_REMAINING && !hurried) {
//put this KeepAliveStream on the queue so that the data remaining //put this KeepAliveStream on the queue so that the data remaining
//on the socket can be cleanup asyncronously. //on the socket can be cleanup asyncronously.
......
此差异已折叠。
此差异已折叠。
public enum ConfigKey {
CONSTANT3, CONSTANT2;
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册