# HG changeset patch
# User lana
# Date 1398979289 25200
# Node ID 5cbca4ed35a31860b6ecbb216c97adb3cdca22e3
# Parent 15ce1fa297a52532a8489c395e135de9598d73c2# Parent 6c6e4f22e8b5e0d3092514e0b9cdb874c5694ec5
Merge
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/make/data/jdwp/jdwp.spec
--- a/jdk/make/data/jdwp/jdwp.spec Thu May 01 12:51:13 2014 -0700
+++ b/jdk/make/data/jdwp/jdwp.spec Thu May 01 14:21:29 2014 -0700
@@ -1147,7 +1147,8 @@
(ErrorSet
(Error INVALID_CLASS "clazz is not the ID of a class.")
(Error INVALID_OBJECT "clazz is not a known ID.")
- (Error INVALID_METHODID "methodID is not the ID of a method.")
+ (Error INVALID_METHODID "methodID is not the ID of a static method in "
+ "this class type or one of its superclasses.")
(Error INVALID_THREAD)
(Error THREAD_NOT_SUSPENDED)
(Error VM_DEAD)
@@ -1250,6 +1251,83 @@
)
)
(CommandSet InterfaceType=5
+ (Command InvokeMethod=1
+ "Invokes a static method. "
+ "The method must not be a static initializer. "
+ "The method must be a member of the interface type. "
+ "
Since JDWP version 1.8 "
+ "
"
+ "The method invocation will occur in the specified thread. "
+ "Method invocation can occur only if the specified thread "
+ "has been suspended by an event. "
+ "Method invocation is not supported "
+ "when the target VM has been suspended by the front-end. "
+ "
"
+ "The specified method is invoked with the arguments in the specified "
+ "argument list. "
+ "The method invocation is synchronous; the reply packet is not "
+ "sent until the invoked method returns in the target VM. "
+ "The return value (possibly the void value) is "
+ "included in the reply packet. "
+ "If the invoked method throws an exception, the "
+ "exception object ID is set in the reply packet; otherwise, the "
+ "exception object ID is null. "
+ "
"
+ "For primitive arguments, the argument value's type must match the "
+ "argument's type exactly. For object arguments, there must exist a "
+ "widening reference conversion from the argument value's type to the "
+ "argument's type and the argument's type must be loaded. "
+ "
"
+ "By default, all threads in the target VM are resumed while "
+ "the method is being invoked if they were previously "
+ "suspended by an event or by a command. "
+ "This is done to prevent the deadlocks "
+ "that will occur if any of the threads own monitors "
+ "that will be needed by the invoked method. It is possible that "
+ "breakpoints or other events might occur during the invocation. "
+ "Note, however, that this implicit resume acts exactly like "
+ "the ThreadReference resume command, so if the thread's suspend "
+ "count is greater than 1, it will remain in a suspended state "
+ "during the invocation. By default, when the invocation completes, "
+ "all threads in the target VM are suspended, regardless their state "
+ "before the invocation. "
+ "
"
+ "The resumption of other threads during the invoke can be prevented "
+ "by specifying the INVOKE_SINGLE_THREADED "
+ "bit flag in the options
field; however, "
+ "there is no protection against or recovery from the deadlocks "
+ "described above, so this option should be used with great caution. "
+ "Only the specified thread will be resumed (as described for all "
+ "threads above). Upon completion of a single threaded invoke, the invoking thread "
+ "will be suspended once again. Note that any threads started during "
+ "the single threaded invocation will not be suspended when the "
+ "invocation completes. "
+ "
"
+ "If the target VM is disconnected during the invoke (for example, through "
+ "the VirtualMachine dispose command) the method invocation continues. "
+ (Out
+ (interfaceType clazz "The interface type ID.")
+ (threadObject thread "The thread in which to invoke.")
+ (method methodID "The method to invoke.")
+ (Repeat arguments
+ (value arg "The argument value.")
+ )
+ (int options "Invocation options")
+ )
+ (Reply
+ (value returnValue "The returned value.")
+ (tagged-object exception "The thrown exception.")
+ )
+ (ErrorSet
+ (Error INVALID_CLASS "clazz is not the ID of an interface.")
+ (Error INVALID_OBJECT "clazz is not a known ID.")
+ (Error INVALID_METHODID "methodID is not the ID of a static method in this "
+ "interface type or is the ID of a static initializer.")
+ (Error INVALID_THREAD)
+ (Error THREAD_NOT_SUSPENDED)
+ (Error VM_DEAD)
+ )
+ )
)
(CommandSet Method=6
(Command LineTable=1
@@ -1543,7 +1621,7 @@
"
"
"By default, all threads in the target VM are resumed while "
"the method is being invoked if they were previously "
- "suspended by an event or by command. "
+ "suspended by an event or by a command. "
"This is done to prevent the deadlocks "
"that will occur if any of the threads own monitors "
"that will be needed by the invoked method. It is possible that "
@@ -1586,7 +1664,9 @@
(Error INVALID_OBJECT)
(Error INVALID_CLASS "clazz is not the ID of a reference "
"type.")
- (Error INVALID_METHODID "methodID is not the ID of a method.")
+ (Error INVALID_METHODID "methodID is not the ID of an instance method "
+ "in this object's type or one of its superclasses, "
+ "superinterfaces, or implemented interfaces.")
(Error INVALID_THREAD)
(Error THREAD_NOT_SUSPENDED)
(Error VM_DEAD)
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/make/lib/Awt2dLibraries.gmk
--- a/jdk/make/lib/Awt2dLibraries.gmk Thu May 01 12:51:13 2014 -0700
+++ b/jdk/make/lib/Awt2dLibraries.gmk Thu May 01 14:21:29 2014 -0700
@@ -798,6 +798,10 @@
BUILD_LIBFONTMANAGER_ExtensionSubtables.cpp_CXXFLAGS := -fno-strict-aliasing
endif
+# Libfontmanager doesn't actually need X_LIBS to link, but if building
+# on a Solaris machine without X installed, using a devkit, linking
+# to libawt_xawt will fail without the -L parameters from X_LIBS. Filter
+# out the -R parameters since they aren't needed.
$(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \
LIBRARY := fontmanager, \
OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
@@ -816,7 +820,8 @@
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_SUFFIX := $(BUILD_LIBFONTMANAGER_FONTLIB), \
LDFLAGS_SUFFIX_linux := -lawt $(LIBM) $(LIBCXX) -ljava -ljvm -lc, \
- LDFLAGS_SUFFIX_solaris := -lawt -lawt_xawt -lc $(LIBM) $(LIBCXX) -ljava -ljvm, \
+ LDFLAGS_SUFFIX_solaris := $(filter-out -R%, $(X_LIBS)) \
+ -lawt -lawt_xawt -lc $(LIBM) $(LIBCXX) -ljava -ljvm, \
LDFLAGS_SUFFIX_aix := -lawt -lawt_xawt $(LIBM) $(LIBCXX) -ljava -ljvm,\
LDFLAGS_SUFFIX_macosx := -lawt $(LIBM) $(LIBCXX) -undefined dynamic_lookup \
-ljava -ljvm, \
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/make/mapfiles/libjava/mapfile-vers
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/classes/apple/laf/JRSUIConstants.java
--- a/jdk/src/macosx/classes/apple/laf/JRSUIConstants.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/classes/apple/laf/JRSUIConstants.java Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,13 @@
import java.lang.annotation.Native;
public final class JRSUIConstants {
+
+ /**
+ * There is no way to get width of focus border, so it is hardcoded here.
+ * All components, which can be focused should take care about it.
+ */
+ public static final int FOCUS_SIZE = 4;
+
private static native long getPtrForConstant(final int constant);
static class Key {
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java
--- a/jdk/src/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -36,6 +36,8 @@
import com.apple.laf.AquaUtilControlSize.*;
import com.apple.laf.AquaUtils.RecyclableSingleton;
+import static apple.laf.JRSUIConstants.FOCUS_SIZE;
+
/**
* All the "magic numbers" in this class should go away once
* "default font" and sizes for controls in Java Aqua Look and Feel
@@ -145,7 +147,8 @@
protected static Map getAllTypes() {
final Map specifiersByName = new HashMap();
- final Insets focusInsets = new Insets(4, 4, 4, 4);
+ final Insets focusInsets = new Insets(FOCUS_SIZE, FOCUS_SIZE,
+ FOCUS_SIZE, FOCUS_SIZE);
final TypeSpecifier[] specifiers = {
new TypeSpecifier("toolbar", true) {
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/classes/com/apple/laf/AquaIcon.java
--- a/jdk/src/macosx/classes/com/apple/laf/AquaIcon.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/classes/com/apple/laf/AquaIcon.java Thu May 01 14:21:29 2014 -0700
@@ -44,7 +44,8 @@
}
static UIResource getIconFor(final JRSUIControlSpec spec, final int width, final int height) {
- return new CachableJRSUIIcon(width, height) {
+ return new ScalingJRSUIIcon(width, height) {
+ @Override
public void initIconPainter(final AquaPainter painter) {
spec.initIconPainter(painter);
}
@@ -128,35 +129,12 @@
if (image != null) return image;
if (!GraphicsEnvironment.isHeadless()) {
- image = getOptimizedImage();
+ image = createImage();
}
return image;
}
- private Image getOptimizedImage() {
- final Image img = createImage();
- // TODO: no RuntimeOptions for now
- //if (RuntimeOptions.getRenderer(null) != RuntimeOptions.Sun) return img;
- return getProgressiveOptimizedImage(img, getIconWidth(), getIconHeight());
- }
-
- static Image getProgressiveOptimizedImage(final Image img, final int w, final int h) {
- if (img == null) return null;
-
- final int halfImgW = img.getWidth(null) / 2;
- final int halfImgH = img.getHeight(null) / 2;
- if (w * 2 > halfImgW && h * 2 > halfImgH) return img;
-
- final BufferedImage halfImage = new BufferedImage(halfImgW, halfImgH, BufferedImage.TYPE_INT_ARGB);
- final Graphics g = halfImage.getGraphics();
- ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
- g.drawImage(img, 0, 0, halfImgW, halfImgH, null);
- g.dispose();
-
- return getProgressiveOptimizedImage(halfImage, w, h);
- }
-
abstract Image createImage();
public boolean hasIconRef() {
@@ -189,24 +167,50 @@
}
- static abstract class CachableJRSUIIcon extends CachingScalingIcon implements UIResource {
- public CachableJRSUIIcon(final int width, final int height) {
- super(width, height);
+ static abstract class ScalingJRSUIIcon implements Icon, UIResource {
+ final int width;
+ final int height;
+
+ public ScalingJRSUIIcon(final int width, final int height) {
+ this.width = width;
+ this.height = height;
}
- Image createImage() {
- final AquaPainter painter = AquaPainter.create(JRSUIState.getInstance());
+ @Override
+ public void paintIcon(final Component c, Graphics g,
+ final int x, final int y) {
+ if (GraphicsEnvironment.isHeadless()) {
+ return;
+ }
+
+ g = g.create();
+
+ if (g instanceof Graphics2D) {
+ // improves icon rendering quality in Quartz
+ ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_RENDERING,
+ RenderingHints.VALUE_RENDER_QUALITY);
+ }
+
+ final AquaPainter painter =
+ AquaPainter.create(JRSUIState.getInstance());
initIconPainter(painter);
- final BufferedImage img = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
- final Graphics g = img.getGraphics();
- g.setClip(new Rectangle(0, 0, getIconWidth(), getIconHeight()));
- painter.paint(g, null, 0, 0, getIconWidth(), getIconHeight());
+ g.setClip(new Rectangle(x, y, width, height));
+ painter.paint(g, c, x, y, width, height);
g.dispose();
- return img;
}
public abstract void initIconPainter(final AquaPainter painter);
+
+ @Override
+ public int getIconWidth() {
+ return width;
+ }
+
+ @Override
+ public int getIconHeight() {
+ return height;
+ }
}
static class FileIcon extends CachingScalingIcon {
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/classes/com/apple/laf/AquaInternalFrameUI.java
--- a/jdk/src/macosx/classes/com/apple/laf/AquaInternalFrameUI.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/classes/com/apple/laf/AquaInternalFrameUI.java Thu May 01 14:21:29 2014 -0700
@@ -787,8 +787,9 @@
}
static final RecyclableSingleton RESIZE_ICON = new RecyclableSingleton() {
+ @Override
protected Icon getInstance() {
- return new AquaIcon.CachableJRSUIIcon(11, 11) {
+ return new AquaIcon.ScalingJRSUIIcon(11, 11) {
public void initIconPainter(final AquaPainter iconState) {
iconState.state.set(Widget.GROW_BOX_TEXTURED);
iconState.state.set(WindowType.UTILITY);
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/classes/com/apple/laf/AquaPainter.java
--- a/jdk/src/macosx/classes/com/apple/laf/AquaPainter.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/classes/com/apple/laf/AquaPainter.java Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -141,40 +141,71 @@
paintFromSingleCachedImage(g, control, stateToPaint, boundsRect);
}
+ /**
+ * Paints a native control, which identified by its size and a set of
+ * additional arguments using a cached image.
+ *
+ * @param g Graphics to draw the control
+ * @param control the reference to the native control
+ * @param controlState the state of the native control
+ * @param bounds the rectangle where the native part should be drawn.
+ * Note: the focus can/will be drawn outside of this bounds.
+ */
static void paintFromSingleCachedImage(final Graphics2D g,
- final JRSUIControl control, final JRSUIState controlState,
- final Rectangle bounds) {
+ final JRSUIControl control,
+ final JRSUIState controlState,
+ final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
- int scale = 1;
- if (g instanceof SunGraphics2D) {
- scale = ((SunGraphics2D) g).surfaceData.getDefaultScale();
+ int focus = 0;
+ if (controlState.is(JRSUIConstants.Focused.YES)) {
+ focus = JRSUIConstants.FOCUS_SIZE;
}
+
+ final int imgX = bounds.x - focus;
+ final int imgY = bounds.y - focus;
+ final int imgW = bounds.width + (focus << 1);
+ final int imgH = bounds.height + (focus << 1);
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
- final int imgW = bounds.width * scale;
- final int imgH = bounds.height * scale;
- AquaPixelsKey key = new AquaPixelsKey(config,
- imgW, imgH, scale, controlState);
- BufferedImage img = (BufferedImage) cache.getImage(key);
+ final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
+ bounds, controlState);
+ Image img = cache.getImage(key);
if (img == null) {
- img = new BufferedImage(imgW, imgH, BufferedImage.TYPE_INT_ARGB_PRE);
+
+ Image baseImage = createImage(imgX, imgY, imgW, imgH, bounds,
+ control, controlState);
+
+ img = new MultiResolutionBufferedImage(baseImage,
+ (rvWidth, rvHeight) -> createImage(imgX, imgY,
+ rvWidth, rvHeight, bounds, control, controlState));
+
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
-
- final WritableRaster raster = img.getRaster();
- final DataBufferInt buffer = (DataBufferInt) raster.getDataBuffer();
-
- control.set(controlState);
- control.paint(SunWritableRaster.stealData(buffer, 0),
- imgW, imgH, 0, 0, bounds.width, bounds.height);
- SunWritableRaster.markDirty(buffer);
}
- g.drawImage(img, bounds.x, bounds.y, bounds.width, bounds.height, null);
+ g.drawImage(img, imgX, imgY, imgW, imgH, null);
+ }
+
+ private static Image createImage(int imgX, int imgY, int imgW, int imgH,
+ final Rectangle bounds,
+ final JRSUIControl control,
+ JRSUIState controlState) {
+ BufferedImage img = new BufferedImage(imgW, imgH,
+ BufferedImage.TYPE_INT_ARGB_PRE);
+
+ final WritableRaster raster = img.getRaster();
+ final DataBufferInt buffer = (DataBufferInt) raster.getDataBuffer();
+
+ control.set(controlState);
+ control.paint(SunWritableRaster.stealData(buffer, 0), imgW, imgH,
+ bounds.x - imgX, bounds.y - imgY, bounds.width,
+ bounds.height);
+ SunWritableRaster.markDirty(buffer);
+ return img;
}
}
@@ -187,21 +218,22 @@
private final GraphicsConfiguration config;
private final int w;
private final int h;
- private final int scale;
+ private final Rectangle bounds;
private final JRSUIState state;
AquaPixelsKey(final GraphicsConfiguration config,
- final int w, final int h, final int scale,
+ final int w, final int h, final Rectangle bounds,
final JRSUIState state) {
this.pixelCount = w * h;
this.config = config;
this.w = w;
this.h = h;
- this.scale = scale;
+ this.bounds = bounds;
this.state = state;
this.hash = hash();
}
+ @Override
public int getPixelCount() {
return pixelCount;
}
@@ -210,7 +242,7 @@
int hash = config != null ? config.hashCode() : 0;
hash = 31 * hash + w;
hash = 31 * hash + h;
- hash = 31 * hash + scale;
+ hash = 31 * hash + bounds.hashCode();
hash = 31 * hash + state.hashCode();
return hash;
}
@@ -225,7 +257,7 @@
if (obj instanceof AquaPixelsKey) {
AquaPixelsKey key = (AquaPixelsKey) obj;
return config == key.config && w == key.w && h == key.h
- && scale == key.scale && state.equals(key.state);
+ && bounds.equals(key.bounds) && state.equals(key.state);
}
return false;
}
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Thu May 01 14:21:29 2014 -0700
@@ -44,6 +44,7 @@
import sun.awt.*;
import sun.awt.datatransfer.DataTransferer;
+import sun.java2d.opengl.OGLRenderQueue;
import sun.lwawt.*;
import sun.lwawt.LWWindowPeer.PeerType;
import sun.security.action.GetBooleanAction;
@@ -410,7 +411,11 @@
@Override
public void sync() {
- // TODO Auto-generated method stub
+ // flush the OGL pipeline (this is a no-op if OGL is not enabled)
+ OGLRenderQueue.sync();
+ // setNeedsDisplay() selector was sent to the appropriate CALayer so now
+ // we have to flush the native selectors queue.
+ flushNativeSelectors();
}
@Override
@@ -813,6 +818,11 @@
private native boolean nativeSyncQueue(long timeout);
+ /**
+ * Just spin a single empty block synchronously.
+ */
+ private static native void flushNativeSelectors();
+
@Override
public Clipboard createPlatformClipboard() {
return new CClipboard("System");
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/native/com/apple/laf/JRSUIController.m
--- a/jdk/src/macosx/native/com/apple/laf/JRSUIController.m Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/native/com/apple/laf/JRSUIController.m Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -199,7 +199,7 @@
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
CGContextRef cgRef = CGBitmapContextCreate(rawPixelData, imgW, imgH, 8, imgW * 4, colorspace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
CGColorSpaceRelease(colorspace);
- CGContextScaleCTM(cgRef, imgW/w , imgH/h);
+ CGContextScaleCTM(cgRef, imgW/(w + x + x) , imgH/(h + y + y));
jint status = doPaintCGContext(cgRef, controlPtr, oldProperties, newProperties, x, y, w, h);
CGContextRelease(cgRef);
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/native/sun/awt/AWTWindow.m
--- a/jdk/src/macosx/native/sun/awt/AWTWindow.m Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m Thu May 01 14:21:29 2014 -0700
@@ -762,6 +762,10 @@
return lastKeyWindow;
}
+- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame {
+ return !NSEqualSizes(self.nsWindow.frame.size, newFrame.size);
+}
+
@end // AWTWindow
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/native/sun/awt/CClipboard.h
--- a/jdk/src/macosx/native/sun/awt/CClipboard.h Thu May 01 12:51:13 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * 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
- * 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.
- */
-
-#import
-#import "jni.h"
-
-@interface CClipboard : NSObject {
- jobject fClipboardOwner;
-
- // Track pasteboard changes. Initialized once at the start, and then updated
- // on an application resume event. If it's different than the last time we claimed
- // the clipboard that means we lost the clipboard to someone else.
- NSInteger fChangeCount;
-}
-
-+ (CClipboard *) sharedClipboard;
-
-- (void) javaDeclareTypes:(NSArray *)inTypes withOwner:(jobject)inClipboard jniEnv:(JNIEnv *)inEnv;
-- (void) javaSetData:(NSData *)inData forType:(NSString *) inFormat;
-
-- (NSArray *) javaGetTypes;
-- (NSData *) javaGetDataForType:(NSString *)inFormat;
-
-@end
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/native/sun/awt/CClipboard.m
--- a/jdk/src/macosx/native/sun/awt/CClipboard.m Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/native/sun/awt/CClipboard.m Thu May 01 14:21:29 2014 -0700
@@ -23,70 +23,28 @@
* questions.
*/
-#import "CClipboard.h"
#import "CDataTransferer.h"
#import "ThreadUtilities.h"
#import "jni_util.h"
#import
#import
-static CClipboard *sClipboard = nil;
-
-//
-// CClipboardUpdate is used for mulitple calls to setData that happen before
-// the model and AppKit can get back in sync.
-//
-
-@interface CClipboardUpdate : NSObject {
- NSData *fData;
- NSString *fFormat;
-}
-
-- (id)initWithData:(NSData *)inData withFormat:(NSString *)inFormat;
-- (NSData *)data;
-- (NSString *)format;
-
-@end
-
-@implementation CClipboardUpdate
-
-- (id)initWithData:(NSData *)inData withFormat:(NSString *)inFormat
-{
- self = [super init];
+@interface CClipboard : NSObject { }
+@property NSInteger changeCount;
+@property jobject clipboardOwner;
- if (self != nil) {
- fData = [inData retain];
- fFormat = [inFormat retain];
- }
-
- return self;
-}
-
-- (void)dealloc
-{
- [fData release];
- fData = nil;
-
- [fFormat release];
- fFormat = nil;
-
- [super dealloc];
-}
-
-- (NSData *)data {
- return fData;
-}
-
-- (NSString *)format {
- return fFormat;
-}
++ (CClipboard*)sharedClipboard;
+- (void)declareTypes:(NSArray *)types withOwner:(jobject)owner jniEnv:(JNIEnv*)env;
+- (void)checkPasteboard:(id)sender;
@end
@implementation CClipboard
+@synthesize changeCount = _changeCount;
+@synthesize clipboardOwner = _clipboardOwner;
-// Clipboard creation is synchronized at the Java level.
-+ (CClipboard *) sharedClipboard
-{
+// Clipboard creation is synchronized at the Java level
++ (CClipboard*)sharedClipboard {
+ static CClipboard* sClipboard = nil;
if (sClipboard == nil) {
sClipboard = [[CClipboard alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:sClipboard selector: @selector(checkPasteboard:)
@@ -97,90 +55,38 @@
return sClipboard;
}
-- (id) init
-{
- self = [super init];
-
- if (self != nil) {
- fChangeCount = [[NSPasteboard generalPasteboard] changeCount];
+- (id)init {
+ if (self = [super init]) {
+ self.changeCount = [[NSPasteboard generalPasteboard] changeCount];
}
-
return self;
}
-- (void) javaDeclareTypes:(NSArray *)inTypes withOwner:(jobject)inClipboard jniEnv:(JNIEnv *)inEnv {
-
+- (void)declareTypes:(NSArray*)types withOwner:(jobject)owner jniEnv:(JNIEnv*)env {
@synchronized(self) {
- if (inClipboard != NULL) {
- if (fClipboardOwner != NULL) {
- JNFDeleteGlobalRef(inEnv, fClipboardOwner);
+ if (owner != NULL) {
+ if (self.clipboardOwner != NULL) {
+ JNFDeleteGlobalRef(env, self.clipboardOwner);
}
- fClipboardOwner = JNFNewGlobalRef(inEnv, inClipboard);
+ self.clipboardOwner = JNFNewGlobalRef(env, owner);
}
}
- [ThreadUtilities performOnMainThread:@selector(_nativeDeclareTypes:) on:self withObject:inTypes waitUntilDone:YES];
-}
-
-- (void) _nativeDeclareTypes:(NSArray *)inTypes {
- AWT_ASSERT_APPKIT_THREAD;
-
- fChangeCount = [[NSPasteboard generalPasteboard] declareTypes:inTypes owner:self];
-}
-
-
-- (NSArray *) javaGetTypes {
-
- NSMutableArray *args = [NSMutableArray arrayWithCapacity:1];
- [ThreadUtilities performOnMainThread:@selector(_nativeGetTypes:) on:self withObject:args waitUntilDone:YES];
- return [args lastObject];
-}
-
-- (void) _nativeGetTypes:(NSMutableArray *)args {
- AWT_ASSERT_APPKIT_THREAD;
-
- [args addObject:[[NSPasteboard generalPasteboard] types]];
+ [ThreadUtilities performOnMainThreadWaiting:YES block:^() {
+ self.changeCount = [[NSPasteboard generalPasteboard] declareTypes:types owner:self];
+ }];
}
-- (void) javaSetData:(NSData *)inData forType:(NSString *) inFormat {
-
- CClipboardUpdate *newUpdate = [[CClipboardUpdate alloc] initWithData:inData withFormat:inFormat];
- [ThreadUtilities performOnMainThread:@selector(_nativeSetData:) on:self withObject:newUpdate waitUntilDone:YES];
- [newUpdate release];
-}
-
-- (void) _nativeSetData:(CClipboardUpdate *)newUpdate {
- AWT_ASSERT_APPKIT_THREAD;
-
- [[NSPasteboard generalPasteboard] setData:[newUpdate data] forType:[newUpdate format]];
-}
-
-- (NSData *) javaGetDataForType:(NSString *) inFormat {
+- (void)checkPasteboard:(id)sender {
- NSMutableArray *args = [NSMutableArray arrayWithObject:inFormat];
- [ThreadUtilities performOnMainThread:@selector(_nativeGetDataForType:) on:self withObject:args waitUntilDone:YES];
- return [args lastObject];
-}
-
-- (void) _nativeGetDataForType:(NSMutableArray *) args {
- AWT_ASSERT_APPKIT_THREAD;
-
- NSData *returnValue = [[NSPasteboard generalPasteboard] dataForType:[args objectAtIndex:0]];
-
- if (returnValue) [args replaceObjectAtIndex:0 withObject:returnValue];
- else [args removeLastObject];
-}
-
-- (void) checkPasteboard:(id)application {
- AWT_ASSERT_APPKIT_THREAD;
-
// This is called via NSApplicationDidBecomeActiveNotification.
// If the change count on the general pasteboard is different than when we set it
// someone else put data on the clipboard. That means the current owner lost ownership.
+
NSInteger newChangeCount = [[NSPasteboard generalPasteboard] changeCount];
-
- if (fChangeCount != newChangeCount) {
- fChangeCount = newChangeCount;
+
+ if (self.changeCount != newChangeCount) {
+ self.changeCount = newChangeCount;
// Notify that the content might be changed
static JNF_CLASS_CACHE(jc_CClipboard, "sun/lwawt/macosx/CClipboard");
@@ -191,11 +97,11 @@
// If we have a Java pasteboard owner, tell it that it doesn't own the pasteboard anymore.
static JNF_MEMBER_CACHE(jm_lostOwnership, jc_CClipboard, "notifyLostOwnership", "()V");
@synchronized(self) {
- if (fClipboardOwner) {
+ if (self.clipboardOwner) {
JNIEnv *env = [ThreadUtilities getJNIEnv];
- JNFCallVoidMethod(env, fClipboardOwner, jm_lostOwnership); // AWT_THREADING Safe (event)
- JNFDeleteGlobalRef(env, fClipboardOwner);
- fClipboardOwner = NULL;
+ JNFCallVoidMethod(env, self.clipboardOwner, jm_lostOwnership); // AWT_THREADING Safe (event)
+ JNFDeleteGlobalRef(env, self.clipboardOwner);
+ self.clipboardOwner = NULL;
}
}
}
@@ -225,7 +131,7 @@
}
(*env)->ReleasePrimitiveArrayCritical(env, inTypes, elements, JNI_ABORT);
- [[CClipboard sharedClipboard] javaDeclareTypes:formatArray withOwner:inJavaClip jniEnv:env];
+ [[CClipboard sharedClipboard] declareTypes:formatArray withOwner:inJavaClip jniEnv:env];
JNF_COCOA_EXIT(env);
}
@@ -248,7 +154,9 @@
NSData *bytesAsData = [NSData dataWithBytes:rawBytes length:nBytes];
(*env)->ReleasePrimitiveArrayCritical(env, inBytes, rawBytes, JNI_ABORT);
NSString *format = formatForIndex(inFormat);
- [[CClipboard sharedClipboard] javaSetData:bytesAsData forType:format];
+ [ThreadUtilities performOnMainThreadWaiting:YES block:^() {
+ [[NSPasteboard generalPasteboard] setData:bytesAsData forType:format];
+ }];
JNF_COCOA_EXIT(env);
}
@@ -263,7 +171,12 @@
jlongArray returnValue = NULL;
JNF_COCOA_ENTER(env);
- NSArray *dataTypes = [[CClipboard sharedClipboard] javaGetTypes];
+ __block NSArray* dataTypes;
+ [ThreadUtilities performOnMainThreadWaiting:YES block:^() {
+ dataTypes = [[[NSPasteboard generalPasteboard] types] retain];
+ }];
+ [dataTypes autorelease];
+
NSUInteger nFormats = [dataTypes count];
NSUInteger knownFormats = 0;
NSUInteger i;
@@ -320,11 +233,16 @@
JNF_COCOA_ENTER(env);
NSString *formatAsString = formatForIndex(format);
- NSData *clipData = [[CClipboard sharedClipboard] javaGetDataForType:formatAsString];
-
+ __block NSData* clipData;
+ [ThreadUtilities performOnMainThreadWaiting:YES block:^() {
+ clipData = [[[NSPasteboard generalPasteboard] dataForType:formatAsString] retain];
+ }];
+
if (clipData == NULL) {
[JNFException raise:env as:"java/io/IOException" reason:"Font transform has NaN position"];
return NULL;
+ } else {
+ [clipData autorelease];
}
NSUInteger dataSize = [clipData length];
@@ -350,13 +268,13 @@
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CClipboard_checkPasteboard
(JNIEnv *env, jobject inObject )
{
- JNF_COCOA_ENTER(env);
+JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
[[CClipboard sharedClipboard] checkPasteboard:nil];
}];
- JNF_COCOA_EXIT(env);
+JNF_COCOA_EXIT(env);
}
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/native/sun/awt/CImage.m
--- a/jdk/src/macosx/native/sun/awt/CImage.m Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/native/sun/awt/CImage.m Thu May 01 14:21:29 2014 -0700
@@ -379,7 +379,7 @@
return getOrder(size1.width <= size2.width && size1.height <= size2.height);
}];
- NSMutableArray *sortedPixelSizes = [[NSMutableArray alloc] init];
+ NSMutableArray *sortedPixelSizes = [[[NSMutableArray alloc] init] autorelease];
NSSize lastSize = [[sortedImageRepresentations lastObject] size];
NSUInteger i = [sortedImageRepresentations indexOfObjectPassingTest:
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/native/sun/awt/CTextPipe.m
--- a/jdk/src/macosx/native/sun/awt/CTextPipe.m Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/native/sun/awt/CTextPipe.m Thu May 01 14:21:29 2014 -0700
@@ -147,7 +147,7 @@
CGAffineTransform invTx = CGAffineTransformInvert(strike->fTx);
- NSUInteger i;
+ NSInteger i;
for (i = 0; i < length; i++)
{
CGGlyph glyph = glyphs[i];
@@ -355,19 +355,31 @@
static JNF_CLASS_CACHE(jc_StandardGlyphVector_GlyphTransformInfo, "sun/font/StandardGlyphVector$GlyphTransformInfo");
static JNF_MEMBER_CACHE(jm_StandardGlyphVector_GlyphTransformInfo_transforms, jc_StandardGlyphVector_GlyphTransformInfo, "transforms", "[D");
jdoubleArray g_gtiTransformsArray = JNFGetObjectField(env, gti, jm_StandardGlyphVector_GlyphTransformInfo_transforms); //(*env)->GetObjectField(env, gti, g_gtiTransforms);
+ if (g_gtiTransformsArray == NULL) {
+ return;
+ }
jdouble *g_gvTransformsAsDoubles = (*env)->GetPrimitiveArrayCritical(env, g_gtiTransformsArray, NULL);
+ if (g_gvTransformsAsDoubles == NULL) {
+ (*env)->DeleteLocalRef(env, g_gtiTransformsArray);
+ return;
+ }
static JNF_MEMBER_CACHE(jm_StandardGlyphVector_GlyphTransformInfo_indices, jc_StandardGlyphVector_GlyphTransformInfo, "indices", "[I");
jintArray g_gtiTXIndicesArray = JNFGetObjectField(env, gti, jm_StandardGlyphVector_GlyphTransformInfo_indices);
jint *g_gvTXIndicesAsInts = (*env)->GetPrimitiveArrayCritical(env, g_gtiTXIndicesArray, NULL);
-
+ if (g_gvTXIndicesAsInts == NULL) {
+ (*env)->ReleasePrimitiveArrayCritical(env, g_gtiTransformsArray, g_gvTransformsAsDoubles, JNI_ABORT);
+ (*env)->DeleteLocalRef(env, g_gtiTransformsArray);
+ (*env)->DeleteLocalRef(env, g_gtiTXIndicesArray);
+ return;
+ }
// slowest case, we have per-glyph transforms, and possibly glyph substitution as well
JavaCT_DrawGlyphVector(qsdo, strike, useSubstituion, uniChars, glyphs, advances, g_gvTXIndicesAsInts, g_gvTransformsAsDoubles, length);
(*env)->ReleasePrimitiveArrayCritical(env, g_gtiTransformsArray, g_gvTransformsAsDoubles, JNI_ABORT);
- (*env)->DeleteLocalRef(env, g_gtiTransformsArray);
+ (*env)->ReleasePrimitiveArrayCritical(env, g_gtiTXIndicesArray, g_gvTXIndicesAsInts, JNI_ABORT);
- (*env)->ReleasePrimitiveArrayCritical(env, g_gtiTXIndicesArray, g_gvTXIndicesAsInts, JNI_ABORT);
+ (*env)->DeleteLocalRef(env, g_gtiTransformsArray);
(*env)->DeleteLocalRef(env, g_gtiTXIndicesArray);
}
@@ -403,6 +415,9 @@
{
// fill the glyph buffer
jint *glyphsAsInts = (*env)->GetPrimitiveArrayCritical(env, glyphsArray, NULL);
+ if (glyphsAsInts == NULL) {
+ return;
+ }
// if a glyph code from Java is negative, that means it is really a unicode value
// which we can use in CoreText to strike the character in another font
@@ -429,11 +444,15 @@
// fill the advance buffer
static JNF_MEMBER_CACHE(jm_StandardGlyphVector_positions, jc_StandardGlyphVector, "positions", "[F");
jfloatArray posArray = JNFGetObjectField(env, gVector, jm_StandardGlyphVector_positions);
- if (posArray != NULL)
- {
+ jfloat *positions = NULL;
+ if (posArray != NULL) {
// in this case, the positions have already been pre-calculated for us on the Java side
-
- jfloat *positions = (*env)->GetPrimitiveArrayCritical(env, posArray, NULL);
+ positions = (*env)->GetPrimitiveArrayCritical(env, posArray, NULL);
+ if (positions == NULL) {
+ (*env)->DeleteLocalRef(env, posArray);
+ }
+ }
+ if (positions != NULL) {
CGPoint prev;
prev.x = positions[0];
prev.y = positions[1];
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/native/sun/awt/JavaComponentAccessibility.m
--- a/jdk/src/macosx/native/sun/awt/JavaComponentAccessibility.m Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/native/sun/awt/JavaComponentAccessibility.m Thu May 01 14:21:29 2014 -0700
@@ -242,11 +242,15 @@
jsize count = [ignoredKeys count];
JNIEnv *env = [ThreadUtilities getJNIEnv];
- jclass clazz = (*env)->FindClass(env, "java/lang/String");
- result = (*env)->NewObjectArray(env, count, clazz, NULL); // AWT_THREADING Safe (known object)
- (*env)->DeleteLocalRef(env, clazz);
- NSUInteger i;
+ static JNF_CLASS_CACHE(jc_String, "java/lang/String");
+ result = JNFNewObjectArray(env, &jc_String, count);
+ if (!result) {
+ NSLog(@"In %s, can't create Java array of String objects", __FUNCTION__);
+ return;
+ }
+
+ NSInteger i;
for (i = 0; i < count; i++) {
jstring jString = JNFNSToJavaString(env, [ignoredKeys objectAtIndex:i]);
(*env)->SetObjectArrayElement(env, result, i, jString);
@@ -281,7 +285,7 @@
jsize arrayLen = (*env)->GetArrayLength(env, jchildrenAndRoles);
NSMutableArray *children = [NSMutableArray arrayWithCapacity:arrayLen/2]; //childrenAndRoles array contains two elements (child, role) for each child
- NSUInteger i;
+ NSInteger i;
NSUInteger childIndex = (whichChildren >= 0) ? whichChildren : 0; // if we're getting one particular child, make sure to set its index correctly
for(i = 0; i < arrayLen; i+=2)
{
@@ -377,8 +381,13 @@
// Get all the other accessibility attributes states we need in one swell foop.
// javaRole isn't pulled in because we need protected access to AccessibleRole.key
jbooleanArray attributeStates = JNFCallStaticObjectMethod(env, jm_getInitialAttributeStates, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
- if (attributeStates == NULL) return NULL;
+ if (attributeStates == NULL) return nil;
jboolean *attributeStatesArray = (*env)->GetBooleanArrayElements(env, attributeStates, 0);
+ if (attributeStatesArray == NULL) {
+ // Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
+ NSLog(@"%s failed calling GetBooleanArrayElements", __FUNCTION__);
+ return nil;
+ }
// if there's a component, it can be enabled and it has a size/position
if (attributeStatesArray[0]) {
@@ -1206,7 +1215,7 @@
// Go through the tabs and find selAccessible
_numTabs = [tabs count];
JavaComponentAccessibility *aTab;
- NSUInteger i;
+ NSInteger i;
for (i = 0; i < _numTabs; i++) {
aTab = (JavaComponentAccessibility *)[tabs objectAtIndex:i];
if ([aTab isAccessibleWithEnv:env forAccessible:selAccessible]) {
@@ -1233,7 +1242,7 @@
NSString *tabJavaRole = JNFJavaToNSString(env, JNFGetObjectField(env, jtabJavaRole, sjf_key));
- NSUInteger i;
+ NSInteger i;
NSUInteger tabIndex = (whichTabs >= 0) ? whichTabs : 0; // if we're getting one particular child, make sure to set its index correctly
for(i = 0; i < arrayLen; i+=2) {
jobject jtab = (*env)->GetObjectArrayElement(env, jtabsAndRoles, i);
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/native/sun/awt/JavaTextAccessibility.m
--- a/jdk/src/macosx/native/sun/awt/JavaTextAccessibility.m Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/native/sun/awt/JavaTextAccessibility.m Thu May 01 14:21:29 2014 -0700
@@ -40,6 +40,11 @@
*/
NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
jint *values = (*env)->GetIntArrayElements(env, array, 0);
+ if (values == NULL) {
+ // Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
+ NSLog(@"%s failed calling GetIntArrayElements", __FUNCTION__);
+ return nil;
+ };
NSValue *value = [NSValue valueWithRange:NSMakeRange(values[0], values[1] - values[0])];
(*env)->ReleaseIntArrayElements(env, array, values, 0);
return value;
@@ -285,6 +290,11 @@
// We cheat because we know that the array is 4 elements long (x, y, width, height)
jdouble *values = (*env)->GetDoubleArrayElements(env, axBounds, 0);
+ if (values == NULL) {
+ // Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
+ NSLog(@"%s failed calling GetDoubleArrayElements", __FUNCTION__);
+ return nil;
+ };
NSRect bounds;
bounds.origin.x = values[0];
bounds.origin.y = [[[[self view] window] screen] frame].size.height - values[1] - values[3]; //values[1] is y-coord from top-left of screen. Flip. Account for the height (values[3]) when flipping
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/native/sun/awt/LWCToolkit.m
--- a/jdk/src/macosx/native/sun/awt/LWCToolkit.m Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/native/sun/awt/LWCToolkit.m Thu May 01 14:21:29 2014 -0700
@@ -144,6 +144,18 @@
return JNI_FALSE;
}
+/*
+ * Class: sun_lwawt_macosx_LWCToolkit
+ * Method: flushNativeSelectors
+ * Signature: ()J
+ */
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_flushNativeSelectors
+(JNIEnv *env, jclass clz)
+{
+JNF_COCOA_ENTER(env);
+ [ThreadUtilities performOnMainThreadWaiting:YES block:^(){}];
+JNF_COCOA_EXIT(env);
+}
static JNF_CLASS_CACHE(jc_Component, "java/awt/Component");
static JNF_MEMBER_CACHE(jf_Component_appContext, jc_Component, "appContext", "Lsun/awt/AppContext;");
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m
--- a/jdk/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m Thu May 01 14:21:29 2014 -0700
@@ -142,9 +142,16 @@
splash->screenFormat.byteOrder = 1 ? BYTE_ORDER_LSBFIRST : BYTE_ORDER_MSBFIRST;
splash->screenFormat.depthBytes = 4;
- [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
- [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]];
- }];
+ // If this property is present we are running SWT and should not start a runLoop
+ // Can't check if running SWT in webstart, so splash screen in webstart SWT
+ // applications is not supported
+ char envVar[80];
+ snprintf(envVar, sizeof(envVar), "JAVA_STARTED_ON_FIRST_THREAD_%d", getpid());
+ if (getenv(envVar) == NULL) {
+ [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
+ [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]];
+ }];
+ }
}
void
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
--- a/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c Thu May 01 14:21:29 2014 -0700
@@ -154,7 +154,10 @@
if (pmStr != NULL) {
CFStringGetCString(pmStr, buf, BUFLEN, kCFStringEncodingUTF8);
CFRelease(pmStr);
- (*env)->SetObjectArrayElement(env, ampms, 1, (*env)->NewStringUTF(env, buf));
+ tmp_string = (*env)->NewStringUTF(env, buf);
+ if (tmp_string != NULL) {
+ (*env)->SetObjectArrayElement(env, ampms, 1, tmp_string);
+ }
}
}
CFRelease(df);
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/back/InterfaceTypeImpl.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/back/InterfaceTypeImpl.c Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 1998, 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.
+ */
+
+#include "util.h"
+#include "InterfaceTypeImpl.h"
+#include "inStream.h"
+#include "outStream.h"
+
+static jboolean
+invokeStatic(PacketInputStream *in, PacketOutputStream *out)
+{
+ return sharedInvoke(in, out);
+}
+
+void *InterfaceType_Cmds[] = { (void *)0x1
+ , (void *)invokeStatic
+};
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/back/InterfaceTypeImpl.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/back/InterfaceTypeImpl.h Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 1998, 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.
+ */
+extern void *InterfaceType_Cmds[];
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/back/VirtualMachineImpl.c
--- a/jdk/src/share/back/VirtualMachineImpl.c Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/back/VirtualMachineImpl.c Thu May 01 14:21:29 2014 -0700
@@ -36,7 +36,7 @@
static char *versionName = "Java Debug Wire Protocol (Reference Implementation)";
static int majorVersion = 1; /* JDWP major version */
-static int minorVersion = 6; /* JDWP minor version */
+static int minorVersion = 8; /* JDWP minor version */
static jboolean
version(PacketInputStream *in, PacketOutputStream *out)
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/back/debugDispatch.c
--- a/jdk/src/share/back/debugDispatch.c Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/back/debugDispatch.c Thu May 01 14:21:29 2014 -0700
@@ -29,6 +29,7 @@
#include "VirtualMachineImpl.h"
#include "ReferenceTypeImpl.h"
#include "ClassTypeImpl.h"
+#include "InterfaceTypeImpl.h"
#include "ArrayTypeImpl.h"
#include "FieldImpl.h"
#include "MethodImpl.h"
@@ -67,6 +68,7 @@
l1Array[JDWP_COMMAND_SET(VirtualMachine)] = (void *)VirtualMachine_Cmds;
l1Array[JDWP_COMMAND_SET(ReferenceType)] = (void *)ReferenceType_Cmds;
l1Array[JDWP_COMMAND_SET(ClassType)] = (void *)ClassType_Cmds;
+ l1Array[JDWP_COMMAND_SET(InterfaceType)] = (void *)InterfaceType_Cmds;
l1Array[JDWP_COMMAND_SET(ArrayType)] = (void *)ArrayType_Cmds;
l1Array[JDWP_COMMAND_SET(Field)] = (void *)Field_Cmds;
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/back/util.c
--- a/jdk/src/share/back/util.c Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/back/util.c Thu May 01 14:21:29 2014 -0700
@@ -591,6 +591,8 @@
invokeType = INVOKE_CONSTRUCTOR;
} else if (inStream_command(in) == JDWP_COMMAND(ClassType, InvokeMethod)) {
invokeType = INVOKE_STATIC;
+ } else if (inStream_command(in) == JDWP_COMMAND(InterfaceType, InvokeMethod)) {
+ invokeType = INVOKE_STATIC;
} else if (inStream_command(in) == JDWP_COMMAND(ObjectReference, InvokeMethod)) {
invokeType = INVOKE_INSTANCE;
} else {
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/beans/util/Cache.java
--- a/jdk/src/share/classes/com/sun/beans/util/Cache.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/beans/util/Cache.java Thu May 01 14:21:29 2014 -0700
@@ -119,13 +119,13 @@
synchronized (this.queue) {
// synchronized search improves stability
// we must create and add new value if there are no needed entry
- int index = index(hash, this.table);
- current = getEntryValue(key, hash, this.table[index]);
+ current = getEntryValue(key, hash, this.table[index(hash, this.table)]);
if (current != null) {
return current;
}
V value = create(key);
Objects.requireNonNull(value, "value");
+ int index = index(hash, this.table);
this.table[index] = new CacheEntry<>(hash, key, value, this.table[index]);
if (++this.size >= this.threshold) {
if (this.table.length == MAXIMUM_CAPACITY) {
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifScrollBarUI.java
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifScrollBarUI.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifScrollBarUI.java Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -24,17 +24,19 @@
*/
package com.sun.java.swing.plaf.motif;
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.plaf.*;
-import javax.swing.border.*;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Rectangle;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JScrollBar;
+import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicScrollBarUI;
-import java.awt.Dimension;
-import java.awt.Insets;
-import java.awt.Rectangle;
-import java.awt.Graphics;
-import java.awt.Color;
+import static sun.swing.SwingUtilities2.drawHLine;
+import static sun.swing.SwingUtilities2.drawVLine;
/**
@@ -74,17 +76,13 @@
return new MotifScrollBarButton(orientation);
}
-
public void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
g.setColor(trackColor);
g.fillRect(trackBounds.x, trackBounds.y, trackBounds.width, trackBounds.height);
}
-
- public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
- {
-
- if(thumbBounds.isEmpty() || !scrollbar.isEnabled()) {
+ public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
+ if (thumbBounds.isEmpty() || !scrollbar.isEnabled()) {
return;
}
@@ -93,15 +91,15 @@
g.translate(thumbBounds.x, thumbBounds.y);
g.setColor(thumbColor);
- g.fillRect(0, 0, w-1, h-1);
+ g.fillRect(0, 0, w - 1, h - 1);
g.setColor(thumbHighlightColor);
- g.drawLine(0, 0, 0, h-1);
- g.drawLine(1, 0, w-1, 0);
+ drawVLine(g, 0, 0, h - 1);
+ drawHLine(g, 1, w - 1, 0);
g.setColor(thumbLightShadowColor);
- g.drawLine(1, h-1, w-1, h-1);
- g.drawLine(w-1, 1, w-1, h-2);
+ drawHLine(g, 1, w - 1, h - 1);
+ drawVLine(g, w - 1, 1, h - 2);
g.translate(-thumbBounds.x, -thumbBounds.y);
}
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifSliderUI.java
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifSliderUI.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifSliderUI.java Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -25,14 +25,17 @@
package com.sun.java.swing.plaf.motif;
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.plaf.*;
+import javax.swing.JComponent;
+import javax.swing.JSlider;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicSliderUI;
-import javax.swing.plaf.basic.BasicSliderUI;
+import static sun.swing.SwingUtilities2.drawHLine;
+import static sun.swing.SwingUtilities2.drawVLine;
/**
* Motif Slider
@@ -123,15 +126,15 @@
// highlight
g.setColor(getHighlightColor());
- g.drawLine(0, 1, w - 1, 1); // top
- g.drawLine(0, 1, 0, h); // left
- g.drawLine(w/2, 2, w/2, h-1); // center
+ drawHLine(g, 0, w - 1, 1); // top
+ drawVLine(g, 0, 1, h); // left
+ drawVLine(g, w / 2, 2, h - 1); // center
// shadow
g.setColor(getShadowColor());
- g.drawLine(0, h, w - 1, h); // bottom
- g.drawLine(w - 1, 1, w - 1, h); // right
- g.drawLine(w/2 - 1, 2, w/2 - 1, h); // center
+ drawHLine(g, 0, w - 1, h); // bottom
+ drawVLine(g, w - 1, 1, h); // right
+ drawVLine(g, w / 2 - 1, 2, h); // center
g.translate(-x, -(knobBounds.y-1));
}
@@ -143,15 +146,15 @@
// highlight
g.setColor(getHighlightColor());
- g.drawLine(1, y, w, y); // top
- g.drawLine(1, y+1, 1, y+h-1); // left
- g.drawLine(2, y+h/2, w-1, y+h/2); // center
+ drawHLine(g, 1, w, y); // top
+ drawVLine(g, 1, y + 1, y + h - 1); // left
+ drawHLine(g, 2, w - 1, y + h / 2); // center
// shadow
g.setColor(getShadowColor());
- g.drawLine(2, y+h-1, w, y+h-1); // bottom
- g.drawLine(w, y+h-1, w, y); // right
- g.drawLine(2, y+h/2-1, w-1, y+h/2-1); // center
+ drawHLine(g, 2, w, y + h - 1); // bottom
+ drawVLine(g, w, y + h - 1, y); // right
+ drawHLine(g, 2, w - 1, y + h / 2 - 1);// center
g.translate(-(knobBounds.x-1), 0);
}
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/jdi/ClassType.java
--- a/jdk/src/share/classes/com/sun/jdi/ClassType.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/jdi/ClassType.java Thu May 01 14:21:29 2014 -0700
@@ -103,7 +103,7 @@
*
* Object values must be assignment compatible with the field type
* (This implies that the field type must be loaded through the
- * enclosing class's class loader). Primitive values must be
+ * enclosing class' class loader). Primitive values must be
* either assignment compatible with the field type or must be
* convertible to the field type without loss of information.
* See JLS section 5.2 for more information on assignment
@@ -153,7 +153,7 @@
*
* Object arguments must be assignment compatible with the argument type
* (This implies that the argument type must be loaded through the
- * enclosing class's class loader). Primitive arguments must be
+ * enclosing class' class loader). Primitive arguments must be
* either assignment compatible with the argument type or must be
* convertible to the argument type without loss of information.
* If the method being called accepts a variable number of arguments,
@@ -216,7 +216,7 @@
* @return a {@link Value} mirror of the invoked method's return value.
* @throws java.lang.IllegalArgumentException if the method is not
* a member of this class or a superclass, if the size of the argument list
- * does not match the number of declared arguemnts for the method, or
+ * does not match the number of declared arguments for the method, or
* if the method is an initializer, constructor or static intializer.
* @throws {@link InvalidTypeException} if any argument in the
* argument list is not assignable to the corresponding method argument
@@ -230,7 +230,7 @@
* @throws InvalidTypeException If the arguments do not meet this requirement --
* Object arguments must be assignment compatible with the argument
* type. This implies that the argument type must be
- * loaded through the enclosing class's class loader.
+ * loaded through the enclosing class' class loader.
* Primitive arguments must be either assignment compatible with the
* argument type or must be convertible to the argument type without loss
* of information. See JLS section 5.2 for more information on assignment
@@ -267,7 +267,7 @@
*
* Object arguments must be assignment compatible with the argument type
* (This implies that the argument type must be loaded through the
- * enclosing class's class loader). Primitive arguments must be
+ * enclosing class' class loader). Primitive arguments must be
* either assignment compatible with the argument type or must be
* convertible to the argument type without loss of information.
* If the method being called accepts a variable number of arguments,
@@ -335,7 +335,7 @@
* @throws InvalidTypeException If the arguments do not meet this requirement --
* Object arguments must be assignment compatible with the argument
* type. This implies that the argument type must be
- * loaded through the enclosing class's class loader.
+ * loaded through the enclosing class' class loader.
* Primitive arguments must be either assignment compatible with the
* argument type or must be convertible to the argument type without loss
* of information. See JLS section 5.2 for more information on assignment
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/jdi/InterfaceType.java
--- a/jdk/src/share/classes/com/sun/jdi/InterfaceType.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/jdi/InterfaceType.java Thu May 01 14:21:29 2014 -0700
@@ -79,4 +79,123 @@
* If none exist, returns a zero length List.
*/
List implementors();
+
+ /**
+ * Invokes the specified static {@link Method} in the
+ * target VM. The
+ * specified method must be defined in this interface.
+ * The method must be a static method
+ * but not a static initializer.
+ *
+ * The method invocation will occur in the specified thread.
+ * Method invocation can occur only if the specified thread
+ * has been suspended by an event which occurred in that thread.
+ * Method invocation is not supported
+ * when the target VM has been suspended through
+ * {@link VirtualMachine#suspend} or when the specified thread
+ * is suspended through {@link ThreadReference#suspend}.
+ *
+ * The specified method is invoked with the arguments in the specified
+ * argument list. The method invocation is synchronous; this method
+ * does not return until the invoked method returns in the target VM.
+ * If the invoked method throws an exception, this method will throw
+ * an {@link InvocationException} which contains a mirror to the exception
+ * object thrown.
+ *
+ * Object arguments must be assignment compatible with the argument type
+ * (This implies that the argument type must be loaded through the
+ * enclosing class' class loader). Primitive arguments must be
+ * either assignment compatible with the argument type or must be
+ * convertible to the argument type without loss of information.
+ * If the method being called accepts a variable number of arguments,
+ * then the last argument type is an array of some component type.
+ * The argument in the matching position can be omitted, or can be null,
+ * an array of the same component type, or an argument of the
+ * component type followed by any number of other arguments of the same
+ * type. If the argument is omitted, then a 0 length array of the
+ * component type is passed. The component type can be a primitive type.
+ * Autoboxing is not supported.
+ *
+ * See Section 5.2 of
+ * The Java™ Language Specification
+ * for more information on assignment compatibility.
+ *
+ * By default, all threads in the target VM are resumed while
+ * the method is being invoked if they were previously
+ * suspended by an event or by {@link VirtualMachine#suspend} or
+ * {@link ThreadReference#suspend}. This is done to prevent the deadlocks
+ * that will occur if any of the threads own monitors
+ * that will be needed by the invoked method.
+ * Note, however, that this implicit resume acts exactly like
+ * {@link ThreadReference#resume}, so if the thread's suspend
+ * count is greater than 1, it will remain in a suspended state
+ * during the invocation and thus a deadlock could still occur.
+ * By default, when the invocation completes,
+ * all threads in the target VM are suspended, regardless their state
+ * before the invocation.
+ * It is possible that
+ * breakpoints or other events might occur during the invocation.
+ * This can cause deadlocks as described above. It can also cause a deadlock
+ * if invokeMethod is called from the client's event handler thread. In this
+ * case, this thread will be waiting for the invokeMethod to complete and
+ * won't read the EventSet that comes in for the new event. If this
+ * new EventSet is SUSPEND_ALL, then a deadlock will occur because no
+ * one will resume the EventSet. To avoid this, all EventRequests should
+ * be disabled before doing the invokeMethod, or the invokeMethod should
+ * not be done from the client's event handler thread.
+ *
+ * The resumption of other threads during the invocation can be prevented
+ * by specifying the {@link #INVOKE_SINGLE_THREADED}
+ * bit flag in the options
argument; however,
+ * there is no protection against or recovery from the deadlocks
+ * described above, so this option should be used with great caution.
+ * Only the specified thread will be resumed (as described for all
+ * threads above). Upon completion of a single threaded invoke, the invoking thread
+ * will be suspended once again. Note that any threads started during
+ * the single threaded invocation will not be suspended when the
+ * invocation completes.
+ *
+ * If the target VM is disconnected during the invoke (for example, through
+ * {@link VirtualMachine#dispose}) the method invocation continues.
+ *
+ * @param thread the thread in which to invoke.
+ * @param method the {@link Method} to invoke.
+ * @param arguments the list of {@link Value} arguments bound to the
+ * invoked method. Values from the list are assigned to arguments
+ * in the order they appear in the method signature.
+ * @param options the integer bit flag options.
+ * @return a {@link Value} mirror of the invoked method's return value.
+ * @throws java.lang.IllegalArgumentException if the method is not
+ * a member of this interface, if the size of the argument list
+ * does not match the number of declared arguments for the method, or
+ * if the method is not static or is a static initializer.
+ * @throws {@link InvalidTypeException} if any argument in the
+ * argument list is not assignable to the corresponding method argument
+ * type.
+ * @throws ClassNotLoadedException if any argument type has not yet been loaded
+ * through the appropriate class loader.
+ * @throws IncompatibleThreadStateException if the specified thread has not
+ * been suspended by an event.
+ * @throws InvocationException if the method invocation resulted in
+ * an exception in the target VM.
+ * @throws InvalidTypeException If the arguments do not meet this requirement --
+ * Object arguments must be assignment compatible with the argument
+ * type. This implies that the argument type must be
+ * loaded through the enclosing class' class loader.
+ * Primitive arguments must be either assignment compatible with the
+ * argument type or must be convertible to the argument type without loss
+ * of information. See JLS section 5.2 for more information on assignment
+ * compatibility.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ *
+ * @since 1.8
+ */
+ default Value invokeMethod(ThreadReference thread, Method method,
+ List extends Value> arguments, int options)
+ throws InvalidTypeException,
+ ClassNotLoadedException,
+ IncompatibleThreadStateException,
+ InvocationException {
+ throw new UnsupportedOperationException();
+ }
}
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/jdi/Method.java
--- a/jdk/src/share/classes/com/sun/jdi/Method.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/jdi/Method.java Thu May 01 14:21:29 2014 -0700
@@ -138,6 +138,18 @@
boolean isAbstract();
/**
+ * Determine if this method is a default method
+ *
+ * @return true
if the method is declared default;
+ * false otherwise
+ *
+ * @since 1.8
+ */
+ default boolean isDefault() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
* Determine if this method is synchronized.
*
* @return true
if the method is declared synchronized;
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/jdi/ObjectReference.java
--- a/jdk/src/share/classes/com/sun/jdi/ObjectReference.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/jdi/ObjectReference.java Thu May 01 14:21:29 2014 -0700
@@ -194,10 +194,10 @@
* {@link #INVOKE_NONVIRTUAL} bit flag in the options
* argument. If this flag is set, the specified method is invoked
* whether or not it is overridden for this object's runtime type.
- * The method, in this case, must not belong to an interface and
- * must not be abstract. This option is useful for performing method
- * invocations like those done with the super
keyword in
- * the Java programming language.
+ * The method, in this case, must have an implementation, either in a class
+ * or an interface. This option is useful for performing method invocations
+ * like those done with the super
keyword in the Java programming
+ * language.
*
* By default, all threads in the target VM are resumed while
* the method is being invoked if they were previously
@@ -246,10 +246,10 @@
* @return a {@link Value} mirror of the invoked method's return value.
* @throws java.lang.IllegalArgumentException if the method is not
* a member of this object's class, if the size of the argument list
- * does not match the number of declared arguemnts for the method,
+ * does not match the number of declared arguments for the method,
* if the method is a constructor or static intializer, or
* if {@link #INVOKE_NONVIRTUAL} is specified and the method is
- * either abstract or an interface member.
+ * either abstract or a non-default interface member.
* @throws {@link InvalidTypeException} if any argument in the
* argument list is not assignable to the corresponding method argument
* type.
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, 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
@@ -118,6 +118,7 @@
return null;
}
+ @SuppressWarnings("fallthrough")
public void processControlLogic() {
for (int i = 0; i < used_count; i++) {
@@ -170,6 +171,7 @@
this.delay[i][0] / 1200.0) / control_time);
if (stage_ix[i] < 0)
stage_ix[i] = 0;
+ // Fallthrough
case EG_DELAY:
if (stage_ix[i] == 0) {
double attack = this.attack[i][0];
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/tools/example/debug/expr/LValue.java
--- a/jdk/src/share/classes/com/sun/tools/example/debug/expr/LValue.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/expr/LValue.java Thu May 01 14:21:29 2014 -0700
@@ -559,6 +559,9 @@
} else if (refType instanceof ClassType) {
ClassType clazz = (ClassType)refType;
return jdiValue = clazz.invokeMethod(thread, matchingMethod, methodArguments, 0);
+ } else if (refType instanceof InterfaceType) {
+ InterfaceType iface = (InterfaceType)refType;
+ return jdiValue = iface.invokeMethod(thread, matchingMethod, methodArguments, 0);
} else {
throw new InvalidTypeException("Cannot invoke static method on " +
refType.name());
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java
--- a/jdk/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java Thu May 01 14:21:29 2014 -0700
@@ -29,9 +29,27 @@
import java.util.*;
-public class ClassTypeImpl extends ReferenceTypeImpl
+final public class ClassTypeImpl extends InvokableTypeImpl
implements ClassType
{
+ private static class IResult implements InvocationResult {
+ final private JDWP.ClassType.InvokeMethod rslt;
+
+ public IResult(JDWP.ClassType.InvokeMethod rslt) {
+ this.rslt = rslt;
+ }
+
+ @Override
+ public ObjectReferenceImpl getException() {
+ return rslt.exception;
+ }
+
+ @Override
+ public ValueImpl getResult() {
+ return rslt.returnValue;
+ }
+ }
+
private boolean cachedSuperclass = false;
private ClassType superclass = null;
private int lastLine = -1;
@@ -65,6 +83,7 @@
return superclass;
}
+ @Override
public List interfaces() {
if (interfaces == null) {
interfaces = getInterfaces();
@@ -72,26 +91,9 @@
return interfaces;
}
- void addInterfaces(List list) {
- List immediate = interfaces();
- list.addAll(interfaces());
-
- Iterator iter = immediate.iterator();
- while (iter.hasNext()) {
- InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
- interfaze.addSuperinterfaces(list);
- }
-
- ClassTypeImpl superclass = (ClassTypeImpl)superclass();
- if (superclass != null) {
- superclass.addInterfaces(list);
- }
- }
-
- public List allInterfaces() {
- List all = new ArrayList();
- addInterfaces(all);
- return all;
+ @Override
+ public List allInterfaces() {
+ return getAllInterfaces();
}
public List subclasses() {
@@ -159,28 +161,6 @@
}
}
- PacketStream sendInvokeCommand(final ThreadReferenceImpl thread,
- final MethodImpl method,
- final ValueImpl[] args,
- final int options) {
- CommandSender sender =
- new CommandSender() {
- public PacketStream send() {
- return JDWP.ClassType.InvokeMethod.enqueueCommand(
- vm, ClassTypeImpl.this, thread,
- method.ref(), args, options);
- }
- };
-
- PacketStream stream;
- if ((options & INVOKE_SINGLE_THREADED) != 0) {
- stream = thread.sendResumingCommand(sender);
- } else {
- stream = vm.sendResumingCommand(sender);
- }
- return stream;
- }
-
PacketStream sendNewInstanceCommand(final ThreadReferenceImpl thread,
final MethodImpl method,
final ValueImpl[] args,
@@ -203,52 +183,6 @@
return stream;
}
- public Value invokeMethod(ThreadReference threadIntf, Method methodIntf,
- List extends Value> origArguments, int options)
- throws InvalidTypeException,
- ClassNotLoadedException,
- IncompatibleThreadStateException,
- InvocationException {
- validateMirror(threadIntf);
- validateMirror(methodIntf);
- validateMirrorsOrNulls(origArguments);
-
- MethodImpl method = (MethodImpl)methodIntf;
- ThreadReferenceImpl thread = (ThreadReferenceImpl)threadIntf;
-
- validateMethodInvocation(method);
-
- List extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments);
-
- ValueImpl[] args = arguments.toArray(new ValueImpl[0]);
- JDWP.ClassType.InvokeMethod ret;
- try {
- PacketStream stream =
- sendInvokeCommand(thread, method, args, options);
- ret = JDWP.ClassType.InvokeMethod.waitForReply(vm, stream);
- } catch (JDWPException exc) {
- if (exc.errorCode() == JDWP.Error.INVALID_THREAD) {
- throw new IncompatibleThreadStateException();
- } else {
- throw exc.toJDIException();
- }
- }
-
- /*
- * There is an implict VM-wide suspend at the conclusion
- * of a normal (non-single-threaded) method invoke
- */
- if ((options & INVOKE_SINGLE_THREADED) == 0) {
- vm.notifySuspend();
- }
-
- if (ret.exception != null) {
- throw new InvocationException(ret.exception);
- } else {
- return ret.returnValue;
- }
- }
-
public ObjectReference newInstance(ThreadReference threadIntf,
Method methodIntf,
List extends Value> origArguments,
@@ -311,58 +245,6 @@
return method;
}
- public List allMethods() {
- ArrayList list = new ArrayList(methods());
-
- ClassType clazz = superclass();
- while (clazz != null) {
- list.addAll(clazz.methods());
- clazz = clazz.superclass();
- }
-
- /*
- * Avoid duplicate checking on each method by iterating through
- * duplicate-free allInterfaces() rather than recursing
- */
- for (InterfaceType interfaze : allInterfaces()) {
- list.addAll(interfaze.methods());
- }
-
- return list;
- }
-
- List inheritedTypes() {
- List inherited = new ArrayList();
- if (superclass() != null) {
- inherited.add(0, (ReferenceType)superclass()); /* insert at front */
- }
- for (ReferenceType rt : interfaces()) {
- inherited.add(rt);
- }
- return inherited;
- }
-
- void validateMethodInvocation(Method method)
- throws InvalidTypeException,
- InvocationException {
- /*
- * Method must be in this class or a superclass.
- */
- ReferenceTypeImpl declType = (ReferenceTypeImpl)method.declaringType();
- if (!declType.isAssignableFrom(this)) {
- throw new IllegalArgumentException("Invalid method");
- }
-
- /*
- * Method must be a static and not a static initializer
- */
- if (!method.isStatic()) {
- throw new IllegalArgumentException("Cannot invoke instance method on a class type");
- } else if (method.isStaticInitializer()) {
- throw new IllegalArgumentException("Cannot invoke static initializer");
- }
- }
-
void validateConstructorInvocation(Method method)
throws InvalidTypeException,
InvocationException {
@@ -382,51 +264,33 @@
}
}
- @Override
- void addVisibleMethods(Map methodMap, Set seenInterfaces) {
- /*
- * Add methods from
- * parent types first, so that the methods in this class will
- * overwrite them in the hash table
- */
-
- Iterator iter = interfaces().iterator();
- while (iter.hasNext()) {
- InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
- if (!seenInterfaces.contains(interfaze)) {
- interfaze.addVisibleMethods(methodMap, seenInterfaces);
- seenInterfaces.add(interfaze);
- }
- }
-
- ClassTypeImpl clazz = (ClassTypeImpl)superclass();
- if (clazz != null) {
- clazz.addVisibleMethods(methodMap, seenInterfaces);
- }
-
- addToMethodMap(methodMap, methods());
- }
-
- boolean isAssignableTo(ReferenceType type) {
- ClassTypeImpl superclazz = (ClassTypeImpl)superclass();
- if (this.equals(type)) {
- return true;
- } else if ((superclazz != null) && superclazz.isAssignableTo(type)) {
- return true;
- } else {
- List interfaces = interfaces();
- Iterator iter = interfaces.iterator();
- while (iter.hasNext()) {
- InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
- if (interfaze.isAssignableTo(type)) {
- return true;
- }
- }
- return false;
- }
- }
public String toString() {
return "class " + name() + " (" + loaderString() + ")";
}
+
+ @Override
+ CommandSender getInvokeMethodSender(ThreadReferenceImpl thread,
+ MethodImpl method,
+ ValueImpl[] args,
+ int options) {
+ return () ->
+ JDWP.ClassType.InvokeMethod.enqueueCommand(vm,
+ ClassTypeImpl.this,
+ thread,
+ method.ref(),
+ args,
+ options);
+ }
+
+ @Override
+ InvocationResult waitForReply(PacketStream stream) throws JDWPException {
+ return new IResult(JDWP.ClassType.InvokeMethod.waitForReply(vm, stream));
+ }
+
+ @Override
+ boolean canInvoke(Method method) {
+ // Method must be in this class or a superclass.
+ return ((ReferenceTypeImpl)method.declaringType()).isAssignableFrom(this);
+ }
}
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/tools/jdi/InterfaceTypeImpl.java
--- a/jdk/src/share/classes/com/sun/tools/jdi/InterfaceTypeImpl.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/InterfaceTypeImpl.java Thu May 01 14:21:29 2014 -0700
@@ -29,14 +29,31 @@
import java.util.List;
import java.util.ArrayList;
-import java.util.Map;
-import java.util.Iterator;
import java.util.Collections;
import java.util.Set;
import java.lang.ref.SoftReference;
-public class InterfaceTypeImpl extends ReferenceTypeImpl
- implements InterfaceType {
+final public class InterfaceTypeImpl extends InvokableTypeImpl
+ implements InterfaceType {
+
+ private static class IResult implements InvocationResult {
+ final private JDWP.InterfaceType.InvokeMethod rslt;
+
+ public IResult(JDWP.InterfaceType.InvokeMethod rslt) {
+ this.rslt = rslt;
+ }
+
+ @Override
+ public ObjectReferenceImpl getException() {
+ return rslt.exception;
+ }
+
+ @Override
+ public ValueImpl getResult() {
+ return rslt.returnValue;
+ }
+
+ }
private SoftReference> superinterfacesRef = null;
@@ -81,102 +98,6 @@
return implementors;
}
- @Override
- void addVisibleMethods(Map methodMap, Set seenInterfaces) {
- /*
- * Add methods from
- * parent types first, so that the methods in this class will
- * overwrite them in the hash table
- */
-
- for (InterfaceType interfaze : superinterfaces()) {
- if (!seenInterfaces.contains(interfaze)) {
- ((InterfaceTypeImpl)interfaze).addVisibleMethods(methodMap, seenInterfaces);
- seenInterfaces.add(interfaze);
- }
- }
-
- addToMethodMap(methodMap, methods());
- }
-
- public List allMethods() {
- ArrayList list = new ArrayList(methods());
-
- /*
- * It's more efficient if don't do this
- * recursively.
- */
- for (InterfaceType interfaze : allSuperinterfaces()) {
- list.addAll(interfaze.methods());
- }
-
- return list;
- }
-
- List allSuperinterfaces() {
- ArrayList list = new ArrayList();
- addSuperinterfaces(list);
- return list;
- }
-
- void addSuperinterfaces(List list) {
- /*
- * This code is a little strange because it
- * builds the list with a more suitable order than the
- * depth-first approach a normal recursive solution would
- * take. Instead, all direct superinterfaces precede all
- * indirect ones.
- */
-
- /*
- * Get a list of direct superinterfaces that's not already in the
- * list being built.
- */
- List immediate = new ArrayList(superinterfaces());
- Iterator iter = immediate.iterator();
- while (iter.hasNext()) {
- InterfaceType interfaze = iter.next();
- if (list.contains(interfaze)) {
- iter.remove();
- }
- }
-
- /*
- * Add all new direct superinterfaces
- */
- list.addAll(immediate);
-
- /*
- * Recurse for all new direct superinterfaces.
- */
- iter = immediate.iterator();
- while (iter.hasNext()) {
- InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
- interfaze.addSuperinterfaces(list);
- }
- }
-
- boolean isAssignableTo(ReferenceType type) {
-
- // Exact match?
- if (this.equals(type)) {
- return true;
- } else {
- // Try superinterfaces.
- for (InterfaceType interfaze : superinterfaces()) {
- if (((InterfaceTypeImpl)interfaze).isAssignableTo(type)) {
- return true;
- }
- }
-
- return false;
- }
- }
-
- List inheritedTypes() {
- return superinterfaces();
- }
-
public boolean isInitialized() {
return isPrepared();
}
@@ -184,4 +105,39 @@
public String toString() {
return "interface " + name() + " (" + loaderString() + ")";
}
-}
+
+ @Override
+ InvocationResult waitForReply(PacketStream stream) throws JDWPException {
+ return new IResult(JDWP.InterfaceType.InvokeMethod.waitForReply(vm, stream));
+ }
+
+ @Override
+ CommandSender getInvokeMethodSender(final ThreadReferenceImpl thread,
+ final MethodImpl method,
+ final ValueImpl[] args,
+ final int options) {
+ return () ->
+ JDWP.InterfaceType.InvokeMethod.enqueueCommand(vm,
+ InterfaceTypeImpl.this,
+ thread,
+ method.ref(),
+ args,
+ options);
+ }
+
+ @Override
+ ClassType superclass() {
+ return null;
+ }
+
+ @Override
+ List interfaces() {
+ return superinterfaces();
+ }
+
+ @Override
+ boolean canInvoke(Method method) {
+ // method must be directly in this interface
+ return this.equals(method.declaringType());
+ }
+}
\ No newline at end of file
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/tools/jdi/InvokableTypeImpl.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/com/sun/tools/jdi/InvokableTypeImpl.java Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,305 @@
+/*
+ * Copyright (c) 2014, 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 com.sun.tools.jdi;
+
+import com.sun.jdi.ClassNotLoadedException;
+import com.sun.jdi.ClassType;
+import com.sun.jdi.IncompatibleThreadStateException;
+import com.sun.jdi.InterfaceType;
+import com.sun.jdi.InvalidTypeException;
+import com.sun.jdi.InvocationException;
+import com.sun.jdi.Method;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.ThreadReference;
+import com.sun.jdi.Value;
+import com.sun.jdi.VirtualMachine;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A supertype for ReferenceTypes allowing method invocations
+ */
+abstract class InvokableTypeImpl extends ReferenceTypeImpl {
+ /**
+ * The invocation result wrapper
+ * It is necessary because both ClassType and InterfaceType
+ * use their own type to represent the invocation result
+ */
+ static interface InvocationResult {
+ ObjectReferenceImpl getException();
+ ValueImpl getResult();
+ }
+
+ InvokableTypeImpl(VirtualMachine aVm, long aRef) {
+ super(aVm, aRef);
+ }
+
+ /**
+ * Method invocation support.
+ * Shared by ClassType and InterfaceType
+ * @param threadIntf the thread in which to invoke.
+ * @param methodIntf method the {@link Method} to invoke.
+ * @param origArguments the list of {@link Value} arguments bound to the
+ * invoked method. Values from the list are assigned to arguments
+ * in the order they appear in the method signature.
+ * @param options the integer bit flag options.
+ * @return a {@link Value} mirror of the invoked method's return value.
+ * @throws java.lang.IllegalArgumentException if the method is not
+ * a member of this type, if the size of the argument list
+ * does not match the number of declared arguments for the method, or
+ * if the method is not static or is a static initializer.
+ * @throws {@link InvalidTypeException} if any argument in the
+ * argument list is not assignable to the corresponding method argument
+ * type.
+ * @throws ClassNotLoadedException if any argument type has not yet been loaded
+ * through the appropriate class loader.
+ * @throws IncompatibleThreadStateException if the specified thread has not
+ * been suspended by an event.
+ * @throws InvocationException if the method invocation resulted in
+ * an exception in the target VM.
+ * @throws InvalidTypeException If the arguments do not meet this requirement --
+ * Object arguments must be assignment compatible with the argument
+ * type. This implies that the argument type must be
+ * loaded through the enclosing class's class loader.
+ * Primitive arguments must be either assignment compatible with the
+ * argument type or must be convertible to the argument type without loss
+ * of information. See JLS section 5.2 for more information on assignment
+ * compatibility.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ final public Value invokeMethod(ThreadReference threadIntf, Method methodIntf,
+ List extends Value> origArguments, int options)
+ throws InvalidTypeException,
+ ClassNotLoadedException,
+ IncompatibleThreadStateException,
+ InvocationException {
+ validateMirror(threadIntf);
+ validateMirror(methodIntf);
+ validateMirrorsOrNulls(origArguments);
+ MethodImpl method = (MethodImpl) methodIntf;
+ ThreadReferenceImpl thread = (ThreadReferenceImpl) threadIntf;
+ validateMethodInvocation(method);
+ List extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments);
+ ValueImpl[] args = arguments.toArray(new ValueImpl[0]);
+ InvocationResult ret;
+ try {
+ PacketStream stream = sendInvokeCommand(thread, method, args, options);
+ ret = waitForReply(stream);
+ } catch (JDWPException exc) {
+ if (exc.errorCode() == JDWP.Error.INVALID_THREAD) {
+ throw new IncompatibleThreadStateException();
+ } else {
+ throw exc.toJDIException();
+ }
+ }
+ /*
+ * There is an implict VM-wide suspend at the conclusion
+ * of a normal (non-single-threaded) method invoke
+ */
+ if ((options & ClassType.INVOKE_SINGLE_THREADED) == 0) {
+ vm.notifySuspend();
+ }
+ if (ret.getException() != null) {
+ throw new InvocationException(ret.getException());
+ } else {
+ return ret.getResult();
+ }
+ }
+
+ @Override
+ boolean isAssignableTo(ReferenceType type) {
+ ClassTypeImpl superclazz = (ClassTypeImpl) superclass();
+ if (this.equals(type)) {
+ return true;
+ } else if ((superclazz != null) && superclazz.isAssignableTo(type)) {
+ return true;
+ } else {
+ List interfaces = interfaces();
+ Iterator iter = interfaces.iterator();
+ while (iter.hasNext()) {
+ InterfaceTypeImpl interfaze = (InterfaceTypeImpl) iter.next();
+ if (interfaze.isAssignableTo(type)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ @Override
+ final void addVisibleMethods(Map methodMap, Set seenInterfaces) {
+ /*
+ * Add methods from
+ * parent types first, so that the methods in this class will
+ * overwrite them in the hash table
+ */
+ Iterator iter = interfaces().iterator();
+ while (iter.hasNext()) {
+ InterfaceTypeImpl interfaze = (InterfaceTypeImpl) iter.next();
+ if (!seenInterfaces.contains(interfaze)) {
+ interfaze.addVisibleMethods(methodMap, seenInterfaces);
+ seenInterfaces.add(interfaze);
+ }
+ }
+ ClassTypeImpl clazz = (ClassTypeImpl) superclass();
+ if (clazz != null) {
+ clazz.addVisibleMethods(methodMap, seenInterfaces);
+ }
+ addToMethodMap(methodMap, methods());
+ }
+
+ final void addInterfaces(List list) {
+ List immediate = interfaces();
+ list.addAll(interfaces());
+ Iterator iter = immediate.iterator();
+ while (iter.hasNext()) {
+ InterfaceTypeImpl interfaze = (InterfaceTypeImpl) iter.next();
+ interfaze.addInterfaces(list);
+ }
+ ClassTypeImpl superclass = (ClassTypeImpl) superclass();
+ if (superclass != null) {
+ superclass.addInterfaces(list);
+ }
+ }
+
+ /**
+ * Returns all the implemented interfaces recursively
+ * @return A list of all the implemented interfaces (recursively)
+ */
+ final List getAllInterfaces() {
+ List all = new ArrayList<>();
+ addInterfaces(all);
+ return all;
+ }
+
+ /**
+ * Shared implementation of {@linkplain ClassType#allMethods()} and
+ * {@linkplain InterfaceType#allMethods()}
+ * @return A list of all methods (recursively)
+ */
+ public final List allMethods() {
+ ArrayList list = new ArrayList<>(methods());
+ ClassType clazz = superclass();
+ while (clazz != null) {
+ list.addAll(clazz.methods());
+ clazz = clazz.superclass();
+ }
+ /*
+ * Avoid duplicate checking on each method by iterating through
+ * duplicate-free allInterfaces() rather than recursing
+ */
+ for (InterfaceType interfaze : getAllInterfaces()) {
+ list.addAll(interfaze.methods());
+ }
+ return list;
+ }
+
+ @Override
+ final List inheritedTypes() {
+ List inherited = new ArrayList<>();
+ if (superclass() != null) {
+ inherited.add(0, superclass()); /* insert at front */
+ }
+ for (ReferenceType rt : interfaces()) {
+ inherited.add(rt);
+ }
+ return inherited;
+ }
+
+ private PacketStream sendInvokeCommand(final ThreadReferenceImpl thread,
+ final MethodImpl method,
+ final ValueImpl[] args,
+ final int options) {
+ CommandSender sender = getInvokeMethodSender(thread, method, args, options);
+ PacketStream stream;
+ if ((options & ClassType.INVOKE_SINGLE_THREADED) != 0) {
+ stream = thread.sendResumingCommand(sender);
+ } else {
+ stream = vm.sendResumingCommand(sender);
+ }
+ return stream;
+ }
+
+ private void validateMethodInvocation(Method method)
+ throws InvalidTypeException,
+ InvocationException {
+ if (!canInvoke(method)) {
+ throw new IllegalArgumentException("Invalid method");
+ }
+ /*
+ * Method must be a static and not a static initializer
+ */
+ if (!method.isStatic()) {
+ throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type");
+ } else if (method.isStaticInitializer()) {
+ throw new IllegalArgumentException("Cannot invoke static initializer");
+ }
+ }
+
+ /**
+ * A subclass will provide specific {@linkplain CommandSender}
+ * @param thread the current invocation thread
+ * @param method the method to invoke
+ * @param args the arguments to pass to the method
+ * @param options the integer bit flag options
+ * @return the specific {@literal CommandSender} instance
+ */
+ abstract CommandSender getInvokeMethodSender(ThreadReferenceImpl thread,
+ MethodImpl method,
+ ValueImpl[] args,
+ int options);
+
+ /**
+ * Waits for the reply to the last sent command
+ * @param stream the stream to listen for the reply on
+ * @return the {@linkplain InvocationResult} instance
+ * @throws JDWPException when something goes wrong in JDWP
+ */
+ abstract InvocationResult waitForReply(PacketStream stream) throws JDWPException;
+
+ /**
+ * Get the {@linkplain ReferenceType} superclass
+ * @return the superclass or null
+ */
+ abstract ClassType superclass();
+
+ /**
+ * Get the implemented/extended interfaces
+ * @return the list of implemented/extended interfaces
+ */
+ abstract List interfaces();
+
+ /**
+ * Checks the provided method whether it can be invoked
+ * @param method the method to check
+ * @return {@code TRUE} if the implementation knows how to invoke the method,
+ * {@code FALSE} otherwise
+ */
+ abstract boolean canInvoke(Method method);
+}
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/tools/jdi/MethodImpl.java
--- a/jdk/src/share/classes/com/sun/tools/jdi/MethodImpl.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/MethodImpl.java Thu May 01 14:21:29 2014 -0700
@@ -187,6 +187,13 @@
return isModifierSet(VMModifiers.ABSTRACT);
}
+ public boolean isDefault() {
+ return !isModifierSet(VMModifiers.ABSTRACT) &&
+ !isModifierSet(VMModifiers.STATIC) &&
+ !isModifierSet(VMModifiers.PRIVATE) &&
+ declaringType() instanceof InterfaceType;
+ }
+
public boolean isSynchronized() {
return isModifierSet(VMModifiers.SYNCHRONIZED);
}
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java
--- a/jdk/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java Thu May 01 14:21:29 2014 -0700
@@ -277,7 +277,6 @@
void validateMethodInvocation(Method method, int options)
throws InvalidTypeException,
InvocationException {
-
/*
* Method must be in this object's class, a superclass, or
* implemented interface
@@ -287,6 +286,19 @@
throw new IllegalArgumentException("Invalid method");
}
+ if (declType instanceof ClassTypeImpl) {
+ validateClassMethodInvocation(method, options);
+ } else if (declType instanceof InterfaceTypeImpl) {
+ validateIfaceMethodInvocation(method, options);
+ } else {
+ throw new InvalidTypeException();
+ }
+ }
+
+ void validateClassMethodInvocation(Method method, int options)
+ throws InvalidTypeException,
+ InvocationException {
+
ClassTypeImpl clazz = invokableReferenceType(method);
/*
@@ -300,9 +312,7 @@
* For nonvirtual invokes, method must have a body
*/
if ((options & INVOKE_NONVIRTUAL) != 0) {
- if (method.declaringType() instanceof InterfaceType) {
- throw new IllegalArgumentException("Interface method");
- } else if (method.isAbstract()) {
+ if (method.isAbstract()) {
throw new IllegalArgumentException("Abstract method");
}
}
@@ -324,7 +334,7 @@
*/
Method invoker = clazz.concreteMethodByName(method.name(),
method.signature());
- // isAssignableFrom check above guarantees non-null
+ // invoker is supposed to be non-null under normal circumstances
invokedClass = (ClassTypeImpl)invoker.declaringType();
}
/* The above code is left over from previous versions.
@@ -332,6 +342,17 @@
*/
}
+ void validateIfaceMethodInvocation(Method method, int options)
+ throws InvalidTypeException,
+ InvocationException {
+ /*
+ * Only default methods allowed for nonvirtual invokes
+ */
+ if (!method.isDefault()) {
+ throw new IllegalArgumentException("Not a default method");
+ }
+ }
+
PacketStream sendInvokeCommand(final ThreadReferenceImpl thread,
final ClassTypeImpl refType,
final MethodImpl method,
@@ -370,7 +391,10 @@
ThreadReferenceImpl thread = (ThreadReferenceImpl)threadIntf;
if (method.isStatic()) {
- if (referenceType() instanceof ClassType) {
+ if (referenceType() instanceof InterfaceType) {
+ InterfaceType type = (InterfaceType)referenceType();
+ return type.invokeMethod(thread, method, origArguments, options);
+ } else if (referenceType() instanceof ClassType) {
ClassType type = (ClassType)referenceType();
return type.invokeMethod(thread, method, origArguments, options);
} else {
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java
--- a/jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java Thu May 01 14:21:29 2014 -0700
@@ -48,7 +48,7 @@
private ResourceBundle messages = null;
private int vmSequenceNumber = 0;
private static final int majorVersion = 1;
- private static final int minorVersion = 6;
+ private static final int minorVersion = 8;
private static final Object lock = new Object();
private static VirtualMachineManagerImpl vmm;
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/java/awt/Container.java
--- a/jdk/src/share/classes/java/awt/Container.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Container.java Thu May 01 14:21:29 2014 -0700
@@ -263,6 +263,16 @@
boolean ignoreEnabled) {
return cont.findComponentAt(x, y, ignoreEnabled);
}
+
+ @Override
+ public void startLWModal(Container cont) {
+ cont.startLWModal();
+ }
+
+ @Override
+ public void stopLWModal(Container cont) {
+ cont.stopLWModal();
+ }
});
}
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/java/awt/datatransfer/Clipboard.java
--- a/jdk/src/share/classes/java/awt/datatransfer/Clipboard.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/java/awt/datatransfer/Clipboard.java Thu May 01 14:21:29 2014 -0700
@@ -27,14 +27,13 @@
import java.awt.EventQueue;
+import java.util.Objects;
import java.util.Set;
import java.util.HashSet;
import java.util.Arrays;
import java.io.IOException;
-import sun.awt.EventListenerAggregate;
-
/**
* A class that implements a mechanism to transfer data using
* cut/copy/paste operations.
@@ -68,7 +67,7 @@
*
* @since 1.5
*/
- private EventListenerAggregate flavorListeners;
+ private Set flavorListeners;
/**
* A set of DataFlavor
s that is available on
@@ -131,11 +130,7 @@
this.contents = contents;
if (oldOwner != null && oldOwner != owner) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- oldOwner.lostOwnership(Clipboard.this, oldContents);
- }
- });
+ EventQueue.invokeLater(() -> oldOwner.lostOwnership(Clipboard.this, oldContents));
}
fireFlavorsChanged();
}
@@ -261,10 +256,12 @@
if (listener == null) {
return;
}
+
if (flavorListeners == null) {
+ flavorListeners = new HashSet<>();
currentDataFlavors = getAvailableDataFlavorSet();
- flavorListeners = new EventListenerAggregate(FlavorListener.class);
}
+
flavorListeners.add(listener);
}
@@ -306,7 +303,7 @@
*/
public synchronized FlavorListener[] getFlavorListeners() {
return flavorListeners == null ? new FlavorListener[0] :
- (FlavorListener[])flavorListeners.getListenersCopy();
+ flavorListeners.toArray(new FlavorListener[flavorListeners.size()]);
}
/**
@@ -320,21 +317,15 @@
if (flavorListeners == null) {
return;
}
+
Set prevDataFlavors = currentDataFlavors;
currentDataFlavors = getAvailableDataFlavorSet();
- if (prevDataFlavors.equals(currentDataFlavors)) {
+ if (Objects.equals(prevDataFlavors, currentDataFlavors)) {
return;
}
- FlavorListener[] flavorListenerArray =
- (FlavorListener[])flavorListeners.getListenersInternal();
- for (int i = 0; i < flavorListenerArray.length; i++) {
- final FlavorListener listener = flavorListenerArray[i];
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- listener.flavorsChanged(new FlavorEvent(Clipboard.this));
- }
- });
- }
+ flavorListeners.forEach(listener ->
+ EventQueue.invokeLater(() ->
+ listener.flavorsChanged(new FlavorEvent(Clipboard.this))));
}
/**
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java
--- a/jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Thu May 01 14:21:29 2014 -0700
@@ -25,13 +25,28 @@
package java.awt.datatransfer;
-import java.io.*;
-import java.nio.*;
-import java.util.*;
-
import sun.awt.datatransfer.DataTransferer;
import sun.reflect.misc.ReflectUtil;
+import java.io.ByteArrayInputStream;
+import java.io.CharArrayReader;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.OptionalDataException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Objects;
+
import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
/**
@@ -92,7 +107,7 @@
* As such, asking a {@code Transferable} for either {@code DataFlavor} returns
* the same results.
*
- * For more information on the using data transfer with Swing see
+ * For more information on using data transfer with Swing see
* the
* How to Use Drag and Drop and Data Transfer,
* section in Java Tutorial.
@@ -390,7 +405,7 @@
* If the mimeType
is
* "application/x-java-serialized-object; class=<representation class>",
* the result is the same as calling
- * new DataFlavor(Class:forName(<representation class>)
.
+ * new DataFlavor(Class.forName(<representation class>)
.
*
* Otherwise:
*
@@ -398,7 +413,7 @@
* mimeType = mimeType
*
* @param mimeType the string used to identify the MIME type for this flavor;
- * if the the mimeType
does not specify a
+ * if the mimeType
does not specify a
* "class=" parameter, or if the class is not successfully
* loaded, then an IllegalArgumentException
* is thrown
@@ -433,7 +448,7 @@
* If the mimeType is
* "application/x-java-serialized-object; class=<representation class>",
* the result is the same as calling
- * new DataFlavor(Class:forName(<representation class>)
.
+ * new DataFlavor(Class.forName(<representation class>)
.
*
* Otherwise:
*
@@ -501,7 +516,7 @@
* @throws ClassNotFoundException
* @throws NullPointerException if mimeType
is null
*
- * @see tryToLoadClass
+ * @see #tryToLoadClass
*/
private void initialize(String mimeType, String humanPresentableName, ClassLoader classLoader) throws MimeTypeParseException, ClassNotFoundException {
if (mimeType == null) {
@@ -986,14 +1001,8 @@
return true;
}
- if (representationClass == null) {
- if (that.getRepresentationClass() != null) {
- return false;
- }
- } else {
- if (!representationClass.equals(that.getRepresentationClass())) {
- return false;
- }
+ if (!Objects.equals(this.getRepresentationClass(), that.getRepresentationClass())) {
+ return false;
}
if (mimeType == null) {
@@ -1006,34 +1015,22 @@
}
if ("text".equals(getPrimaryType())) {
- if (DataTransferer.doesSubtypeSupportCharset(this) &&
- representationClass != null &&
- !(isRepresentationClassReader() ||
- String.class.equals(representationClass) ||
- isRepresentationClassCharBuffer() ||
- char[].class.equals(representationClass)))
- {
+ if (DataTransferer.doesSubtypeSupportCharset(this)
+ && representationClass != null
+ && !isStandardTextRepresentationClass()) {
String thisCharset =
- DataTransferer.canonicalName(getParameter("charset"));
+ DataTransferer.canonicalName(this.getParameter("charset"));
String thatCharset =
- DataTransferer.canonicalName(that.getParameter("charset"));
- if (thisCharset == null) {
- if (thatCharset != null) {
- return false;
- }
- } else {
- if (!thisCharset.equals(thatCharset)) {
- return false;
- }
+ DataTransferer.canonicalName(that.getParameter("charset"));
+ if (!Objects.equals(thisCharset, thatCharset)) {
+ return false;
}
}
- if ("html".equals(getSubType()) &&
- this.getParameter("document") != null )
- {
- if (!this.getParameter("document").
- equals(that.getParameter("document")))
- {
+ if ("html".equals(getSubType())) {
+ String thisDocument = this.getParameter("document");
+ String thatDocument = that.getParameter("document");
+ if (!Objects.equals(thisDocument, thatDocument)) {
return false;
}
}
@@ -1090,18 +1087,21 @@
// MimeType.match which reports a match if one or both of the
// subTypes is '*', regardless of the other subType.
- if ("text".equals(primaryType) &&
- DataTransferer.doesSubtypeSupportCharset(this) &&
- representationClass != null &&
- !(isRepresentationClassReader() ||
- String.class.equals(representationClass) ||
- isRepresentationClassCharBuffer() ||
- char[].class.equals(representationClass)))
- {
- String charset =
- DataTransferer.canonicalName(getParameter("charset"));
- if (charset != null) {
- total += charset.hashCode();
+ if ("text".equals(primaryType)) {
+ if (DataTransferer.doesSubtypeSupportCharset(this)
+ && representationClass != null
+ && !isStandardTextRepresentationClass()) {
+ String charset = DataTransferer.canonicalName(getParameter("charset"));
+ if (charset != null) {
+ total += charset.hashCode();
+ }
+ }
+
+ if ("html".equals(getSubType())) {
+ String document = this.getParameter("document");
+ if (document != null) {
+ total += document.hashCode();
+ }
}
}
}
@@ -1177,6 +1177,20 @@
return mimeType.match(mtype);
}
+ /**
+ * Checks if the representation class is one of the standard text
+ * representation classes.
+ *
+ * @return true if the representation class is one of the standard text
+ * representation classes, otherwise false
+ */
+ private boolean isStandardTextRepresentationClass() {
+ return isRepresentationClassReader()
+ || String.class.equals(representationClass)
+ || isRepresentationClassCharBuffer()
+ || char[].class.equals(representationClass);
+ }
+
/**
* Does the DataFlavor
represent a serialized object?
* @return whether or not a serialized object is represented
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/java/awt/dnd/DragSourceContext.java
--- a/jdk/src/share/classes/java/awt/dnd/DragSourceContext.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/java/awt/dnd/DragSourceContext.java Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -472,7 +472,7 @@
* ENTER
, OVER
,
* CHANGED
*/
-
+ @SuppressWarnings("fallthrough")
protected synchronized void updateCurrentCursor(int sourceAct, int targetAct, int status) {
// if the cursor has been previously set then don't do any defaults
@@ -576,9 +576,9 @@
throw new InvalidObjectException("Null trigger component");
}
- int DGRActions = newTrigger.getSourceAsDragGestureRecognizer().getSourceActions()
+ int newSourceActions = f.get("sourceActions", 0)
& (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
- if (DGRActions == DnDConstants.ACTION_NONE) {
+ if (newSourceActions == DnDConstants.ACTION_NONE) {
throw new InvalidObjectException("Invalid source actions");
}
int triggerActions = newTrigger.getDragAction();
@@ -591,8 +591,7 @@
cursor = (Cursor)f.get("cursor", null);
useCustomCursor = f.get("useCustomCursor", false);
- sourceActions = f.get("sourceActions", 0)
- & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
+ sourceActions = newSourceActions;
transferable = (Transferable)s.readObject();
listener = (DragSourceListener)s.readObject();
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/java/awt/geom/Line2D.java
--- a/jdk/src/share/classes/java/awt/geom/Line2D.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/java/awt/geom/Line2D.java Thu May 01 14:21:29 2014 -0700
@@ -35,7 +35,7 @@
* default coordinate system called user space in which the y-axis
* values increase downward and x-axis values increase to the right. For
* more information on the user space coordinate system, see the
- *
+ *
* Coordinate Systems section of the Java 2D Programmer's Guide.
*
* This class is only the abstract superclass for all objects that
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/java/beans/Introspector.java
--- a/jdk/src/share/classes/java/beans/Introspector.java Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/java/beans/Introspector.java Thu May 01 14:21:29 2014 -0700
@@ -848,7 +848,7 @@
}
private static boolean isAssignable(Class> current, Class> candidate) {
- return current == null ? candidate == null : current.isAssignableFrom(candidate);
+ return ((current == null) || (candidate == null)) ? current == candidate : current.isAssignableFrom(candidate);
}
private PropertyDescriptor mergePropertyWithIndexedProperty(PropertyDescriptor pd, IndexedPropertyDescriptor ipd) {
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/java/nio/package.html
--- a/jdk/src/share/classes/java/nio/package.html Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/java/nio/package.html Thu May 01 14:21:29 2014 -0700
@@ -121,7 +121,7 @@
available.
A byte buffer provides access to its content as either a heterogeneous
- or homogeneous sequence of binary data
+ or homogeneous sequence of binary data
of any non-boolean primitive type, in either big-endian or little-endian byte order.
diff -r 15ce1fa297a5 -r 5cbca4ed35a3 jdk/src/share/classes/java/sql/package.html
--- a/jdk/src/share/classes/java/sql/package.html Thu May 01 12:51:13 2014 -0700
+++ b/jdk/src/share/classes/java/sql/package.html Thu May 01 14:21:29 2014 -0700
@@ -323,10 +323,10 @@