--- a/src/demo/share/jfc/J2Ddemo/java2d/DemoInstVarsAccessor.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/demo/share/jfc/J2Ddemo/java2d/DemoInstVarsAccessor.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,3 +1,34 @@
+/*
+ *
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Oracle nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
package java2d;
import java.awt.Color;
--- a/src/demo/share/jfc/J2Ddemo/java2d/DemoInstVarsAccessorImplBase.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/demo/share/jfc/J2Ddemo/java2d/DemoInstVarsAccessorImplBase.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,3 +1,34 @@
+/*
+ *
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Oracle nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
package java2d;
import java.awt.Color;
--- a/src/java.base/share/classes/module-info.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.base/share/classes/module-info.java Thu Sep 27 10:49:10 2018 -0700
@@ -234,7 +234,6 @@
jdk.jconsole,
java.net.http;
exports sun.net.www to
- java.desktop,
java.net.http,
jdk.jartool;
exports sun.net.www.protocol.http to
--- a/src/java.base/share/lib/security/default.policy Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.base/share/lib/security/default.policy Thu Sep 27 10:49:10 2018 -0700
@@ -140,10 +140,6 @@
permission java.io.FilePermission "<<ALL FILES>>", "read";
};
-grant codeBase "jrt:/jdk.desktop" {
- permission java.lang.RuntimePermission "accessClassInPackage.com.sun.awt";
-};
-
grant codeBase "jrt:/jdk.dynalink" {
permission java.security.AllPermission;
};
--- a/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java Thu Sep 27 10:49:10 2018 -0700
@@ -46,6 +46,7 @@
private static native void nativeSetMenuState(final int menu, final boolean visible, final boolean enabled);
private static native void nativeSetDefaultMenuBar(final long menuBarPeer);
+ private static native void nativeActivateDefaultMenuBar(final long menuBarPeer);
static final _AppMenuBarHandler instance = new _AppMenuBarHandler();
static _AppMenuBarHandler getInstance() {
@@ -78,26 +79,18 @@
void setDefaultMenuBar(final JMenuBar menuBar) {
installDefaultMenuBar(menuBar);
- if (menuBar == null) {
- return;
- }
+ }
+ static boolean isMenuBarActivationNeeded() {
// scan the current frames, and see if any are foreground
final Frame[] frames = Frame.getFrames();
for (final Frame frame : frames) {
if (frame.isVisible() && !isFrameMinimized(frame)) {
- return;
+ return false;
}
}
- // if we have no foreground frames, then we have to "kick" the menubar
- final JFrame pingFrame = new JFrame();
- pingFrame.getRootPane().putClientProperty("Window.alpha", Float.valueOf(0.0f));
- pingFrame.setUndecorated(true);
- pingFrame.setVisible(true);
- pingFrame.toFront();
- pingFrame.setVisible(false);
- pingFrame.dispose();
+ return true;
}
static boolean isFrameMinimized(final Frame frame) {
@@ -150,6 +143,11 @@
// grab the pointer to the CMenuBar, and retain it in native
((CMenuBar) peer).execute(_AppMenuBarHandler::nativeSetDefaultMenuBar);
+
+ // if there is no currently active frame, install the default menu bar in the application main menu
+ if (isMenuBarActivationNeeded()) {
+ ((CMenuBar) peer).execute(_AppMenuBarHandler::nativeActivateDefaultMenuBar);
+ }
}
void setAboutMenuItemVisible(final boolean present) {
--- a/src/java.desktop/macosx/classes/sun/font/CStrike.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/macosx/classes/sun/font/CStrike.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -506,12 +506,6 @@
private SparseBitShiftingTwoLayerArray secondLayerCache;
private HashMap<Integer, Float> generalCache;
- // Empty non private constructor was added because access to this
- // class shouldn't be emulated by a synthetic accessor method.
- GlyphAdvanceCache() {
- super();
- }
-
public synchronized float get(final int index) {
if (index < 0) {
if (-index < SECOND_LAYER_SIZE) {
--- a/src/java.desktop/macosx/classes/sun/lwawt/LWButtonPeer.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/macosx/classes/sun/lwawt/LWButtonPeer.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -81,12 +81,6 @@
@SuppressWarnings("serial")// Safe: outer class is non-serializable.
private final class JButtonDelegate extends JButton {
- // Empty non private constructor was added because access to this
- // class shouldn't be emulated by a synthetic accessor method.
- JButtonDelegate() {
- super();
- }
-
@Override
public boolean hasFocus() {
return getTarget().hasFocus();
--- a/src/java.desktop/macosx/classes/sun/lwawt/LWChoicePeer.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/macosx/classes/sun/lwawt/LWChoicePeer.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -135,12 +135,6 @@
@SuppressWarnings("serial")// Safe: outer class is non-serializable.
private final class JComboBoxDelegate extends JComboBox<String> {
- // Empty non private constructor was added because access to this
- // class shouldn't be emulated by a synthetic accessor method.
- JComboBoxDelegate() {
- super();
- }
-
@Override
public boolean hasFocus() {
return getTarget().hasFocus();
--- a/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -159,12 +159,6 @@
enableEvents(0xFFFFFFFF);
}
- // Empty non private constructor was added because access to this
- // class shouldn't be emulated by a synthetic accessor method.
- DelegateContainer() {
- super();
- }
-
@Override
public boolean isLightweight() {
return false;
--- a/src/java.desktop/macosx/classes/sun/lwawt/LWTextAreaPeer.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/macosx/classes/sun/lwawt/LWTextAreaPeer.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -219,12 +219,6 @@
private final class JTextAreaDelegate extends JTextArea {
- // Empty non private constructor was added because access to this
- // class shouldn't be emulated by a synthetic accessor method.
- JTextAreaDelegate() {
- super();
- }
-
@Override
public void replaceSelection(String content) {
getDocument().removeDocumentListener(LWTextAreaPeer.this);
--- a/src/java.desktop/macosx/classes/sun/lwawt/LWTextFieldPeer.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/macosx/classes/sun/lwawt/LWTextFieldPeer.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -122,12 +122,6 @@
@SuppressWarnings("serial")// Safe: outer class is non-serializable.
private final class JPasswordFieldDelegate extends JPasswordField {
- // Empty non private constructor was added because access to this
- // class shouldn't be emulated by a synthetic accessor method.
- JPasswordFieldDelegate() {
- super();
- }
-
@Override
public void replaceSelection(String content) {
getDocument().removeDocumentListener(LWTextFieldPeer.this);
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Thu Sep 27 10:49:10 2018 -0700
@@ -165,8 +165,6 @@
: this;
}
}
- // ignore focus "lost" native request as it may mistakenly
- // deactivate active window (see 8001161)
if (globalFocusedWindow == this) {
responder.handleWindowFocusEvent(parentWindowActive, null);
}
@@ -181,4 +179,19 @@
// another window.
return globalFocusedWindow != null ? !globalFocusedWindow.isParentWindowActive() : true;
}
+
+ @Override
+ public void synthesizeWindowActivation(boolean doActivate) {
+ if (isParentWindowActive() != doActivate) {
+ handleWindowFocusEvent(doActivate);
+ }
+ }
+
+ public static void updateGlobalFocusedWindow(CEmbeddedFrame newGlobalFocusedWindow) {
+ synchronized (classLock) {
+ if (newGlobalFocusedWindow.isParentWindowActive()) {
+ globalFocusedWindow = newGlobalFocusedWindow;
+ }
+ }
+ }
}
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java Thu Sep 27 10:49:10 2018 -0700
@@ -147,6 +147,8 @@
@Override
public boolean requestWindowFocus() {
+ CEmbeddedFrame.updateGlobalFocusedWindow(target);
+ target.synthesizeWindowActivation(true);
return true;
}
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Sep 27 10:49:10 2018 -0700
@@ -1205,17 +1205,27 @@
}
private void orderAboveSiblings() {
- // Recursively pop up the windows from the very bottom, (i.e. root owner) so that
- // the windows are ordered above their nearest owner; ancestors of the window,
- // which is going to become 'main window', are placed above their siblings.
CPlatformWindow rootOwner = getRootOwner();
- if (rootOwner.isVisible() && !rootOwner.isIconified()) {
- rootOwner.execute(CWrapper.NSWindow::orderFront);
- }
+
// Do not order child windows of iconified owner.
if (!rootOwner.isIconified()) {
final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();
- orderAboveSiblingsImpl(windowAccessor.getOwnedWindows(rootOwner.target));
+ Window[] windows = windowAccessor.getOwnedWindows(rootOwner.target);
+
+ // No need to order windows if it doesn't own other windows and hence return
+ if (windows.length == 0) {
+ return;
+ }
+
+ // Recursively pop up the windows from the very bottom, (i.e. root owner) so that
+ // the windows are ordered above their nearest owner; ancestors of the window,
+ // which is going to become 'main window', are placed above their siblings.
+ if (rootOwner.isVisible()) {
+ rootOwner.execute(CWrapper.NSWindow::orderFront);
+ }
+
+ // Order child windows.
+ orderAboveSiblingsImpl(windows);
}
}
@@ -1276,6 +1286,21 @@
}
}
+ private Window getOwnerFrameOrDialog(Window window) {
+ Window owner = window.getOwner();
+ while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) {
+ owner = owner.getOwner();
+ }
+ return owner;
+ }
+
+ private boolean isSimpleWindowOwnedByEmbeddedFrame() {
+ if (peer != null && peer.isSimpleWindow()) {
+ return (getOwnerFrameOrDialog(target) instanceof CEmbeddedFrame);
+ }
+ return false;
+ }
+
// ----------------------------------------------------------------------
// NATIVE CALLBACKS
// ----------------------------------------------------------------------
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m Thu Sep 27 10:49:10 2018 -0700
@@ -537,10 +537,14 @@
}
-(BOOL) isCodePointInUnicodeBlockNeedingIMEvent: (unichar) codePoint {
- if (((codePoint >= 0x3000) && (codePoint <= 0x303F)) ||
+ if ((codePoint == 0x0024) || (codePoint == 0x00A3) ||
+ (codePoint == 0x00A5) ||
+ ((codePoint >= 0x20A3) && (codePoint <= 0x20BF)) ||
+ ((codePoint >= 0x3000) && (codePoint <= 0x303F)) ||
((codePoint >= 0xFF00) && (codePoint <= 0xFFEF))) {
// Code point is in 'CJK Symbols and Punctuation' or
- // 'Halfwidth and Fullwidth Forms' Unicode block.
+ // 'Halfwidth and Fullwidth Forms' Unicode block or
+ // currency symbols unicode
return YES;
}
return NO;
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m Thu Sep 27 10:49:10 2018 -0700
@@ -477,6 +477,21 @@
return isBlocked;
}
+// Test whether window is simple window and owned by embedded frame
+- (BOOL) isSimpleWindowOwnedByEmbeddedFrame {
+ BOOL isSimpleWindowOwnedByEmbeddedFrame = NO;
+
+ JNIEnv *env = [ThreadUtilities getJNIEnv];
+ jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
+ if (platformWindow != NULL) {
+ static JNF_MEMBER_CACHE(jm_isBlocked, jc_CPlatformWindow, "isSimpleWindowOwnedByEmbeddedFrame", "()Z");
+ isSimpleWindowOwnedByEmbeddedFrame = JNFCallBooleanMethod(env, platformWindow, jm_isBlocked) == JNI_TRUE ? YES : NO;
+ (*env)->DeleteLocalRef(env, platformWindow);
+ }
+
+ return isSimpleWindowOwnedByEmbeddedFrame;
+}
+
// Tests whether the corresponding Java platform window is visible or not
+ (BOOL) isJavaPlatformWindowVisible:(NSWindow *)window {
BOOL isVisible = NO;
@@ -543,7 +558,7 @@
// NSWindow overrides
- (BOOL) canBecomeKeyWindow {
AWT_ASSERT_APPKIT_THREAD;
- return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_KEY);
+ return self.isEnabled && (IS(self.styleBits, SHOULD_BECOME_KEY) || [self isSimpleWindowOwnedByEmbeddedFrame]);
}
- (BOOL) canBecomeMainWindow {
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -35,10 +35,10 @@
#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import "CPopupMenu.h"
+#import "CMenuBar.h"
#import "ThreadUtilities.h"
#import "NSApplicationAWT.h"
-
#pragma mark App Menu helpers
// The following is a AWT convention?
@@ -201,11 +201,11 @@
self.fPreferencesMenu = (NSMenuItem*)[appMenu itemWithTag:PREFERENCES_TAG];
self.fAboutMenu = (NSMenuItem*)[appMenu itemAtIndex:0];
-
+
NSDockTile *dockTile = [NSApp dockTile];
self.fProgressIndicator = [[NSProgressIndicator alloc]
initWithFrame:NSMakeRect(3.f, 0.f, dockTile.size.width - 6.f, 20.f)];
-
+
[fProgressIndicator setStyle:NSProgressIndicatorBarStyle];
[fProgressIndicator setIndeterminate:NO];
[[dockTile contentView] addSubview:fProgressIndicator];
@@ -824,3 +824,23 @@
JNF_COCOA_EXIT(env);
}
+
+/*
+ * Class: com_apple_eawt__AppMenuBarHandler
+ * Method: nativeActivateDefaultMenuBar
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMenuBarHandler_nativeActivateDefaultMenuBar
+(JNIEnv *env, jclass clz, jlong cMenuBarPtr)
+{
+JNF_COCOA_ENTER(env);
+
+ CMenuBar *menu = (CMenuBar *)jlong_to_ptr(cMenuBarPtr);
+ [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
+ if (menu) {
+ [CMenuBar activate:menu modallyDisabled:NO];
+ }
+ }];
+
+JNF_COCOA_EXIT(env);
+}
--- a/src/java.desktop/share/classes/com/sun/awt/SecurityWarning.java Thu Sep 27 08:49:12 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2008, 2018, 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.awt;
-
-import java.awt.*;
-import java.awt.geom.*;
-
-import sun.awt.AWTAccessor;
-
-
-/**
- * Security Warning control interface.
- *
- * This class provides a couple of methods that help a developer relocate
- * the AWT security warning to an appropriate position relative to the current
- * window size. A "top-level window" is an instance of the {@code Window}
- * class (or its descendant, such as {@code JFrame}). The security warning
- * is applied to all windows created by an untrusted code. All such windows
- * have a non-null "warning string" (see {@link Window#getWarningString()}).
- * <p>
- * <b>WARNING</b>: This class is an implementation detail and only meant
- * for limited use outside of the core platform. This API may change
- * drastically between update release, and it may even be
- * removed or be moved to some other packages or classes.
- *
- * @deprecated This class is deprecated, no replacement.
- */
-@Deprecated(since = "11", forRemoval = true)
-public final class SecurityWarning {
-
- /**
- * The SecurityWarning class should not be instantiated
- */
- private SecurityWarning() {
- }
-
- /**
- * Gets the size of the security warning.
- *
- * The returned value is not valid until the peer has been created. Before
- * invoking this method a developer must call the {@link Window#pack()},
- * {@link Window#setVisible}, or some other method that creates the peer.
- *
- * @param window the window to get the security warning size for
- *
- * @throws NullPointerException if the window argument is null
- * @throws IllegalArgumentException if the window is trusted (i.e.
- * the {@code getWarningString()} returns null)
- */
- public static Dimension getSize(Window window) {
- if (window == null) {
- throw new NullPointerException(
- "The window argument should not be null.");
- }
- if (window.getWarningString() == null) {
- throw new IllegalArgumentException(
- "The window must have a non-null warning string.");
- }
- // We don't check for a non-null peer since it may be destroyed
- // after assigning a valid value to the security warning size.
-
- return AWTAccessor.getWindowAccessor().getSecurityWarningSize(window);
- }
-
- /**
- * Sets the position of the security warning.
- * <p>
- * The {@code alignmentX} and {@code alignmentY} arguments specify the
- * origin of the coordinate system used to calculate the position of the
- * security warning. The values must be in the range [0.0f...1.0f]. The
- * {@code 0.0f} value represents the left (top) edge of the rectangular
- * bounds of the window. The {@code 1.0f} value represents the right
- * (bottom) edge of the bounds. Whenever the size of the window changes,
- * the origin of the coordinate system gets relocated accordingly. For
- * convenience a developer may use the {@code Component.*_ALIGNMENT}
- * constants to pass predefined values for these arguments.
- * <p>
- * The {@code point} argument specifies the location of the security
- * warning in the coordinate system described above. If both {@code x} and
- * {@code y} coordinates of the point are equal to zero, the warning will
- * be located right in the origin of the coordinate system. On the other
- * hand, if both {@code alignmentX} and {@code alignmentY} are equal to
- * zero (i.e. the origin of the coordinate system is placed at the top-left
- * corner of the window), then the {@code point} argument represents the
- * absolute location of the security warning relative to the location of
- * the window. The "absolute" in this case means that the position of the
- * security warning is not effected by resizing of the window.
- * <p>
- * Note that the security warning management code guarantees that:
- * <ul>
- * <li>The security warning cannot be located farther than two pixels from
- * the rectangular bounds of the window (see {@link Window#getBounds}), and
- * <li>The security warning is always visible on the screen.
- * </ul>
- * If either of the conditions is violated, the calculated position of the
- * security warning is adjusted by the system to meet both these
- * conditions.
- * <p>
- * The default position of the security warning is in the upper-right
- * corner of the window, two pixels to the right from the right edge. This
- * corresponds to the following arguments passed to this method:
- * <ul>
- * <li>{@code alignmentX = Component.RIGHT_ALIGNMENT}
- * <li>{@code alignmentY = Component.TOP_ALIGNMENT}
- * <li>{@code point = (2, 0)}
- * </ul>
- *
- * @param window the window to set the position of the security warning for
- * @param alignmentX the horizontal origin of the coordinate system
- * @param alignmentY the vertical origin of the coordinate system
- * @param point the position of the security warning in the specified
- * coordinate system
- *
- * @throws NullPointerException if the window argument is null
- * @throws NullPointerException if the point argument is null
- * @throws IllegalArgumentException if the window is trusted (i.e.
- * the {@code getWarningString()} returns null
- * @throws IllegalArgumentException if the alignmentX or alignmentY
- * arguments are not within the range [0.0f ... 1.0f]
- */
- public static void setPosition(Window window, Point2D point,
- float alignmentX, float alignmentY)
- {
- if (window == null) {
- throw new NullPointerException(
- "The window argument should not be null.");
- }
- if (window.getWarningString() == null) {
- throw new IllegalArgumentException(
- "The window must have a non-null warning string.");
- }
- if (point == null) {
- throw new NullPointerException(
- "The point argument must not be null");
- }
- if (alignmentX < 0.0f || alignmentX > 1.0f) {
- throw new IllegalArgumentException(
- "alignmentX must be in the range [0.0f ... 1.0f].");
- }
- if (alignmentY < 0.0f || alignmentY > 1.0f) {
- throw new IllegalArgumentException(
- "alignmentY must be in the range [0.0f ... 1.0f].");
- }
-
- AWTAccessor.getWindowAccessor().setSecurityWarningPosition(window,
- point, alignmentX, alignmentY);
- }
-}
-
--- a/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2018, 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
@@ -547,14 +547,15 @@
getEventDispatcher().addLineMonitor(this);
}
- doIO = true;
-
- // need to set Active and Started
- // note: the current API always requires that
- // Started and Active are set at the same time...
- if (isSource && stoppedWritten) {
- setStarted(true);
- setActive(true);
+ synchronized(lock) {
+ doIO = true;
+ // need to set Active and Started
+ // note: the current API always requires that
+ // Started and Active are set at the same time...
+ if (isSource && stoppedWritten) {
+ setStarted(true);
+ setActive(true);
+ }
}
if (Printer.trace) Printer.trace("<< DirectDL: implStart() succeeded");
@@ -582,10 +583,10 @@
// read/write thread, that's why isStartedRunning()
// cannot be used
doIO = false;
+ setActive(false);
+ setStarted(false);
lock.notifyAll();
}
- setActive(false);
- setStarted(false);
stoppedWritten = false;
if (Printer.trace) Printer.trace(" << DirectDL: implStop() succeeded");
@@ -731,12 +732,14 @@
if ((long)off + (long)len > (long)b.length) {
throw new ArrayIndexOutOfBoundsException(b.length);
}
-
- if (!isActive() && doIO) {
- // this is not exactly correct... would be nicer
- // if the native sub system sent a callback when IO really starts
- setActive(true);
- setStarted(true);
+ synchronized(lock) {
+ if (!isActive() && doIO) {
+ // this is not exactly correct... would be nicer
+ // if the native sub system sent a callback when IO really
+ // starts
+ setActive(true);
+ setStarted(true);
+ }
}
int written = 0;
while (!flushing) {
@@ -957,11 +960,14 @@
if ((long)off + (long)len > (long)b.length) {
throw new ArrayIndexOutOfBoundsException(b.length);
}
- if (!isActive() && doIO) {
- // this is not exactly correct... would be nicer
- // if the native sub system sent a callback when IO really starts
- setActive(true);
- setStarted(true);
+ synchronized(lock) {
+ if (!isActive() && doIO) {
+ // this is not exactly correct... would be nicer
+ // if the native sub system sent a callback when IO really
+ // starts
+ setActive(true);
+ setStarted(true);
+ }
}
int read = 0;
while (doIO && !flushing) {
--- a/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -169,18 +169,9 @@
String nm = System.getProperty("java.awt.headless");
if (nm == null) {
- /* No need to ask for DISPLAY when run in a browser */
- if (System.getProperty("javaplugin.version") != null) {
- headless = defaultHeadless = Boolean.FALSE;
- } else {
- String osName = System.getProperty("os.name");
- if (osName.contains("OS X") && "sun.awt.HToolkit".equals(
- System.getProperty("awt.toolkit")))
- {
- headless = defaultHeadless = Boolean.TRUE;
- } else {
- final String display = System.getenv("DISPLAY");
- headless = defaultHeadless =
+ final String osName = System.getProperty("os.name");
+ final String display = System.getenv("DISPLAY");
+ headless = defaultHeadless =
("Linux".equals(osName) ||
"SunOS".equals(osName) ||
"FreeBSD".equals(osName) ||
@@ -188,8 +179,6 @@
"OpenBSD".equals(osName) ||
"AIX".equals(osName)) &&
(display == null || display.trim().isEmpty());
- }
- }
} else {
headless = Boolean.valueOf(nm);
}
--- a/src/java.desktop/share/classes/java/awt/Window.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/java/awt/Window.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2018, 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
@@ -394,16 +394,6 @@
private transient volatile int securityWarningWidth = 0;
private transient volatile int securityWarningHeight = 0;
- /**
- * These fields represent the desired location for the security
- * warning if this window is untrusted.
- * See com.sun.awt.SecurityWarning for more details.
- */
- private transient double securityWarningPointX = 2.0;
- private transient double securityWarningPointY = 0.0;
- private transient float securityWarningAlignmentX = RIGHT_ALIGNMENT;
- private transient float securityWarningAlignmentY = TOP_ALIGNMENT;
-
static {
/* ensure that the necessary native libraries are loaded */
Toolkit.loadLibraries();
@@ -3127,10 +3117,6 @@
this.securityWarningWidth = 0;
this.securityWarningHeight = 0;
- this.securityWarningPointX = 2.0;
- this.securityWarningPointY = 0.0;
- this.securityWarningAlignmentX = RIGHT_ALIGNMENT;
- this.securityWarningAlignmentY = TOP_ALIGNMENT;
deserializeResources(s);
}
@@ -4031,9 +4017,9 @@
private Point2D calculateSecurityWarningPosition(double x, double y,
double w, double h)
{
- // The position according to the spec of SecurityWarning.setPosition()
- double wx = x + w * securityWarningAlignmentX + securityWarningPointX;
- double wy = y + h * securityWarningAlignmentY + securityWarningPointY;
+ // The desired location for the security warning
+ double wx = x + w * RIGHT_ALIGNMENT + 2.0;
+ double wy = y + h * TOP_ALIGNMENT + 0.0;
// First, make sure the warning is not too far from the window bounds
wx = Window.limit(wx,
@@ -4068,33 +4054,12 @@
window.updateWindow();
}
- public Dimension getSecurityWarningSize(Window window) {
- return new Dimension(window.securityWarningWidth,
- window.securityWarningHeight);
- }
-
public void setSecurityWarningSize(Window window, int width, int height)
{
window.securityWarningWidth = width;
window.securityWarningHeight = height;
}
- public void setSecurityWarningPosition(Window window,
- Point2D point, float alignmentX, float alignmentY)
- {
- window.securityWarningPointX = point.getX();
- window.securityWarningPointY = point.getY();
- window.securityWarningAlignmentX = alignmentX;
- window.securityWarningAlignmentY = alignmentY;
-
- synchronized (window.getTreeLock()) {
- WindowPeer peer = (WindowPeer) window.peer;
- if (peer != null) {
- peer.repositionSecurityWarning();
- }
- }
- }
-
public Point2D calculateSecurityWarningPosition(Window window,
double x, double y, double w, double h)
{
--- a/src/java.desktop/share/classes/javax/swing/RepaintManager.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/javax/swing/RepaintManager.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -1814,12 +1814,6 @@
*/
private static final class DisplayChangedHandler implements
DisplayChangedListener {
- // Empty non private constructor was added because access to this
- // class shouldn't be generated by the compiler using synthetic
- // accessor method
- DisplayChangedHandler() {
- }
-
public void displayChanged() {
scheduleDisplayChanges();
}
--- a/src/java.desktop/share/classes/javax/swing/border/TitledBorder.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/javax/swing/border/TitledBorder.java Thu Sep 27 10:49:10 2018 -0700
@@ -42,6 +42,8 @@
import javax.swing.UIManager;
import javax.swing.plaf.basic.BasicHTML;
+import jdk.internal.ref.CleanerFactory;
+
/**
* A class which implements an arbitrary border
* with the addition of a String title in a
@@ -759,22 +761,19 @@
private void installPropertyChangeListeners() {
final WeakReference<TitledBorder> weakReference = new WeakReference<TitledBorder>(this);
- final PropertyChangeListener listener = new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (weakReference.get() == null) {
- UIManager.removePropertyChangeListener(this);
- UIManager.getDefaults().removePropertyChangeListener(this);
- } else {
- String prop = evt.getPropertyName();
- if ("lookAndFeel".equals(prop) || "LabelUI".equals(prop)) {
- label.updateUI();
- }
- }
+ final PropertyChangeListener listener = evt -> {
+ TitledBorder tb = weakReference.get();
+ String prop = evt.getPropertyName();
+ if (tb != null && ("lookAndFeel".equals(prop) || "LabelUI".equals(prop))) {
+ tb.label.updateUI();
}
};
UIManager.addPropertyChangeListener(listener);
UIManager.getDefaults().addPropertyChangeListener(listener);
+ CleanerFactory.cleaner().register(this, () -> {
+ UIManager.removePropertyChangeListener(listener);
+ UIManager.getDefaults().removePropertyChangeListener(listener);
+ });
}
}
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java Thu Sep 27 10:49:10 2018 -0700
@@ -874,7 +874,7 @@
progressString);
if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
- return new Point(x + Math.round(width/2 - stringWidth/2),
+ return new Point(x + (int)Math.round(width/2.0 - stringWidth/2.0),
y + ((height +
fontSizer.getAscent() -
fontSizer.getLeading() -
@@ -882,7 +882,7 @@
} else { // VERTICAL
return new Point(x + ((width - fontSizer.getAscent() +
fontSizer.getLeading() + fontSizer.getDescent()) / 2),
- y + Math.round(height/2 - stringWidth/2));
+ y + (int)Math.round(height/2.0 - stringWidth/2.0));
}
}
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java Thu Sep 27 10:49:10 2018 -0700
@@ -1872,7 +1872,12 @@
// and if there is any selected rows
if (rMax != (table.getRowCount() - 1) &&
(table.getSelectedRow() == -1)) {
- rMax = rMax - 1;
+ // Do not decrement rMax if rMax becomes
+ // less than or equal to rMin
+ // else cells will not be painted
+ if (rMax - rMin > 1) {
+ rMax = rMax - 1;
+ }
}
}
--- a/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java Thu Sep 27 10:49:10 2018 -0700
@@ -2339,18 +2339,26 @@
*/
void drawShape(Graphics g, CSS.Value type, int ax, int ay, int aw,
int ah, float align) {
- // Align to bottom of shape.
- int gap = isLeftToRight ? - (bulletgap + 8) : (aw + bulletgap);
+ final Object origAA = ((Graphics2D) g).getRenderingHint(
+ RenderingHints.KEY_ANTIALIASING);
+ ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ int size = g.getFont().getSize();
+
+ // Position shape to the middle of the html text.
+ int gap = isLeftToRight ? - (bulletgap + size/3) : (aw + bulletgap);
int x = ax + gap;
- int y = Math.max(ay, ay + (int)(align * ah) - 8);
+ int y = Math.max(ay, ay + (int)Math.ceil(ah/2));
if (type == CSS.Value.SQUARE) {
- g.drawRect(x, y, 8, 8);
+ g.drawRect(x, y, size/3, size/3);
} else if (type == CSS.Value.CIRCLE) {
- g.drawOval(x, y, 8, 8);
+ g.drawOval(x, y, size/3, size/3);
} else {
- g.fillOval(x, y, 8, 8);
+ g.fillOval(x, y, size/3, size/3);
}
+ ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ origAA);
}
/**
--- a/src/java.desktop/share/classes/sun/applet/AppletClassLoader.java Thu Sep 27 08:49:12 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,854 +0,0 @@
-/*
- * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.applet;
-
-import java.io.BufferedInputStream;
-import java.io.EOFException;
-import java.io.File;
-import java.io.FilePermission;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLConnection;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.NoSuchElementException;
-
-import sun.awt.AppContext;
-import sun.awt.SunToolkit;
-import sun.net.www.ParseUtil;
-import sun.security.util.SecurityConstants;
-
-/**
- * This class defines the class loader for loading applet classes and
- * resources. It extends URLClassLoader to search the applet code base
- * for the class or resource after checking any loaded JAR files.
- */
-public class AppletClassLoader extends URLClassLoader {
- private URL base; /* applet code base URL */
- private CodeSource codesource; /* codesource for the base URL */
- private AccessControlContext acc;
- private boolean exceptionStatus = false;
-
- private final Object threadGroupSynchronizer = new Object();
- private final Object grabReleaseSynchronizer = new Object();
-
- private boolean codebaseLookup = true;
- private volatile boolean allowRecursiveDirectoryRead = true;
-
- /*
- * Creates a new AppletClassLoader for the specified base URL.
- */
- protected AppletClassLoader(URL base) {
- super(new URL[0]);
- this.base = base;
- this.codesource =
- new CodeSource(base, (java.security.cert.Certificate[]) null);
- acc = AccessController.getContext();
- }
-
- public void disableRecursiveDirectoryRead() {
- allowRecursiveDirectoryRead = false;
- }
-
-
- /**
- * Set the codebase lookup flag.
- */
- void setCodebaseLookup(boolean codebaseLookup) {
- this.codebaseLookup = codebaseLookup;
- }
-
- /*
- * Returns the applet code base URL.
- */
- URL getBaseURL() {
- return base;
- }
-
- /*
- * Returns the URLs used for loading classes and resources.
- */
- public URL[] getURLs() {
- URL[] jars = super.getURLs();
- URL[] urls = new URL[jars.length + 1];
- System.arraycopy(jars, 0, urls, 0, jars.length);
- urls[urls.length - 1] = base;
- return urls;
- }
-
- /*
- * Adds the specified JAR file to the search path of loaded JAR files.
- * Changed modifier to protected in order to be able to overwrite addJar()
- * in PluginClassLoader.java
- */
- protected void addJar(String name) throws IOException {
- URL url;
- try {
- url = new URL(base, name);
- } catch (MalformedURLException e) {
- throw new IllegalArgumentException("name");
- }
- addURL(url);
- // DEBUG
- //URL[] urls = getURLs();
- //for (int i = 0; i < urls.length; i++) {
- // System.out.println("url[" + i + "] = " + urls[i]);
- //}
- }
-
- /*
- * Override loadClass so that class loading errors can be caught in
- * order to print better error messages.
- */
- public synchronized Class<?> loadClass(String name, boolean resolve)
- throws ClassNotFoundException
- {
- // First check if we have permission to access the package. This
- // should go away once we've added support for exported packages.
- int i = name.lastIndexOf('.');
- if (i != -1) {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPackageAccess(name.substring(0, i));
- }
- try {
- return super.loadClass(name, resolve);
- } catch (ClassNotFoundException e) {
- throw e;
- } catch (RuntimeException e) {
- throw e;
- } catch (Error e) {
- throw e;
- }
- }
-
- /*
- * Finds the applet class with the specified name. First searches
- * loaded JAR files then the applet code base for the class.
- */
- protected Class<?> findClass(String name) throws ClassNotFoundException {
-
- int index = name.indexOf(';');
- String cookie = "";
- if(index != -1) {
- cookie = name.substring(index, name.length());
- name = name.substring(0, index);
- }
-
- // check loaded JAR files
- try {
- return super.findClass(name);
- } catch (ClassNotFoundException e) {
- }
-
- // Otherwise, try loading the class from the code base URL
-
- // 4668479: Option to turn off codebase lookup in AppletClassLoader
- // during resource requests. [stanley.ho]
- if (codebaseLookup == false)
- throw new ClassNotFoundException(name);
-
-// final String path = name.replace('.', '/').concat(".class").concat(cookie);
- String encodedName = ParseUtil.encodePath(name.replace('.', '/'), false);
- final String path = (new StringBuffer(encodedName)).append(".class").append(cookie).toString();
- try {
- byte[] b = AccessController.doPrivileged(
- new PrivilegedExceptionAction<byte[]>() {
- public byte[] run() throws IOException {
- try {
- URL finalURL = new URL(base, path);
-
- // Make sure the codebase won't be modified
- if (base.getProtocol().equals(finalURL.getProtocol()) &&
- base.getHost().equals(finalURL.getHost()) &&
- base.getPort() == finalURL.getPort()) {
- return getBytes(finalURL);
- }
- else {
- return null;
- }
- } catch (Exception e) {
- return null;
- }
- }
- }, acc);
-
- if (b != null) {
- return defineClass(name, b, 0, b.length, codesource);
- } else {
- throw new ClassNotFoundException(name);
- }
- } catch (PrivilegedActionException e) {
- throw new ClassNotFoundException(name, e.getException());
- }
- }
-
- /**
- * Returns the permissions for the given codesource object.
- * The implementation of this method first calls super.getPermissions,
- * to get the permissions
- * granted by the super class, and then adds additional permissions
- * based on the URL of the codesource.
- * <p>
- * If the protocol is "file"
- * and the path specifies a file, permission is granted to read all files
- * and (recursively) all files and subdirectories contained in
- * that directory. This is so applets with a codebase of
- * file:/blah/some.jar can read in file:/blah/, which is needed to
- * be backward compatible. We also add permission to connect back to
- * the "localhost".
- *
- * @param codesource the codesource
- * @throws NullPointerException if {@code codesource} is {@code null}.
- * @return the permissions granted to the codesource
- */
- protected PermissionCollection getPermissions(CodeSource codesource)
- {
- final PermissionCollection perms = super.getPermissions(codesource);
-
- URL url = codesource.getLocation();
-
- String path = null;
- Permission p;
-
- try {
- p = url.openConnection().getPermission();
- } catch (java.io.IOException ioe) {
- p = null;
- }
-
- if (p instanceof FilePermission) {
- path = p.getName();
- } else if ((p == null) && (url.getProtocol().equals("file"))) {
- path = url.getFile().replace('/', File.separatorChar);
- path = ParseUtil.decode(path);
- }
-
- if (path != null) {
- final String rawPath = path;
- if (!path.endsWith(File.separator)) {
- int endIndex = path.lastIndexOf(File.separatorChar);
- if (endIndex != -1) {
- path = path.substring(0, endIndex + 1) + "-";
- perms.add(new FilePermission(path,
- SecurityConstants.FILE_READ_ACTION));
- }
- }
- final File f = new File(rawPath);
- final boolean isDirectory = f.isDirectory();
- // grant codebase recursive read permission
- // this should only be granted to non-UNC file URL codebase and
- // the codesource path must either be a directory, or a file
- // that ends with .jar or .zip
- if (allowRecursiveDirectoryRead && (isDirectory ||
- rawPath.toLowerCase().endsWith(".jar") ||
- rawPath.toLowerCase().endsWith(".zip"))) {
-
- Permission bperm;
- try {
- bperm = base.openConnection().getPermission();
- } catch (java.io.IOException ioe) {
- bperm = null;
- }
- if (bperm instanceof FilePermission) {
- String bpath = bperm.getName();
- if (bpath.endsWith(File.separator)) {
- bpath += "-";
- }
- perms.add(new FilePermission(bpath,
- SecurityConstants.FILE_READ_ACTION));
- } else if ((bperm == null) && (base.getProtocol().equals("file"))) {
- String bpath = base.getFile().replace('/', File.separatorChar);
- bpath = ParseUtil.decode(bpath);
- if (bpath.endsWith(File.separator)) {
- bpath += "-";
- }
- perms.add(new FilePermission(bpath, SecurityConstants.FILE_READ_ACTION));
- }
-
- }
- }
- return perms;
- }
-
- /*
- * Returns the contents of the specified URL as an array of bytes.
- */
- private static byte[] getBytes(URL url) throws IOException {
- URLConnection uc = url.openConnection();
- if (uc instanceof java.net.HttpURLConnection) {
- java.net.HttpURLConnection huc = (java.net.HttpURLConnection) uc;
- int code = huc.getResponseCode();
- if (code >= java.net.HttpURLConnection.HTTP_BAD_REQUEST) {
- throw new IOException("open HTTP connection failed.");
- }
- }
- int len = uc.getContentLength();
-
- // Fixed #4507227: Slow performance to load
- // class and resources. [stanleyh]
- //
- // Use buffered input stream [stanleyh]
- InputStream in = new BufferedInputStream(uc.getInputStream());
-
- byte[] b;
- try {
- b = in.readAllBytes();
- if (len != -1 && b.length != len)
- throw new EOFException("Expected:" + len + ", read:" + b.length);
- } finally {
- in.close();
- }
- return b;
- }
-
- // Object for synchronization around getResourceAsStream()
- private Object syncResourceAsStream = new Object();
- private Object syncResourceAsStreamFromJar = new Object();
-
- // Flag to indicate getResourceAsStream() is in call
- private boolean resourceAsStreamInCall = false;
- private boolean resourceAsStreamFromJarInCall = false;
-
- /**
- * Returns an input stream for reading the specified resource.
- *
- * The search order is described in the documentation for {@link
- * #getResource(String)}.<p>
- *
- * @param name the resource name
- * @return an input stream for reading the resource, or {@code null}
- * if the resource could not be found
- * @since 1.1
- */
- public InputStream getResourceAsStream(String name)
- {
-
- if (name == null) {
- throw new NullPointerException("name");
- }
-
- try
- {
- InputStream is = null;
-
- // Fixed #4507227: Slow performance to load
- // class and resources. [stanleyh]
- //
- // The following is used to avoid calling
- // AppletClassLoader.findResource() in
- // super.getResourceAsStream(). Otherwise,
- // unnecessary connection will be made.
- //
- synchronized(syncResourceAsStream)
- {
- resourceAsStreamInCall = true;
-
- // Call super class
- is = super.getResourceAsStream(name);
-
- resourceAsStreamInCall = false;
- }
-
- // 4668479: Option to turn off codebase lookup in AppletClassLoader
- // during resource requests. [stanley.ho]
- if (codebaseLookup == true && is == null)
- {
- // If resource cannot be obtained,
- // try to download it from codebase
- URL url = new URL(base, ParseUtil.encodePath(name, false));
- is = url.openStream();
- }
-
- return is;
- }
- catch (Exception e)
- {
- return null;
- }
- }
-
-
- /**
- * Returns an input stream for reading the specified resource from the
- * the loaded jar files.
- *
- * The search order is described in the documentation for {@link
- * #getResource(String)}.<p>
- *
- * @param name the resource name
- * @return an input stream for reading the resource, or {@code null}
- * if the resource could not be found
- * @since 1.1
- */
- public InputStream getResourceAsStreamFromJar(String name) {
-
- if (name == null) {
- throw new NullPointerException("name");
- }
-
- try {
- InputStream is = null;
- synchronized(syncResourceAsStreamFromJar) {
- resourceAsStreamFromJarInCall = true;
- // Call super class
- is = super.getResourceAsStream(name);
- resourceAsStreamFromJarInCall = false;
- }
-
- return is;
- } catch (Exception e) {
- return null;
- }
- }
-
-
- /*
- * Finds the applet resource with the specified name. First checks
- * loaded JAR files then the applet code base for the resource.
- */
- public URL findResource(String name) {
- // check loaded JAR files
- URL url = super.findResource(name);
-
- // 6215746: Disable META-INF/* lookup from codebase in
- // applet/plugin classloader. [stanley.ho]
- if (name.startsWith("META-INF/"))
- return url;
-
- // 4668479: Option to turn off codebase lookup in AppletClassLoader
- // during resource requests. [stanley.ho]
- if (codebaseLookup == false)
- return url;
-
- if (url == null)
- {
- //#4805170, if it is a call from Applet.getImage()
- //we should check for the image only in the archives
- boolean insideGetResourceAsStreamFromJar = false;
- synchronized(syncResourceAsStreamFromJar) {
- insideGetResourceAsStreamFromJar = resourceAsStreamFromJarInCall;
- }
-
- if (insideGetResourceAsStreamFromJar) {
- return null;
- }
-
- // Fixed #4507227: Slow performance to load
- // class and resources. [stanleyh]
- //
- // Check if getResourceAsStream is called.
- //
- boolean insideGetResourceAsStream = false;
-
- synchronized(syncResourceAsStream)
- {
- insideGetResourceAsStream = resourceAsStreamInCall;
- }
-
- // If getResourceAsStream is called, don't
- // trigger the following code. Otherwise,
- // unnecessary connection will be made.
- //
- if (insideGetResourceAsStream == false)
- {
- // otherwise, try the code base
- try {
- url = new URL(base, ParseUtil.encodePath(name, false));
- // check if resource exists
- if(!resourceExists(url))
- url = null;
- } catch (Exception e) {
- // all exceptions, including security exceptions, are caught
- url = null;
- }
- }
- }
- return url;
- }
-
-
- private boolean resourceExists(URL url) {
- // Check if the resource exists.
- // It almost works to just try to do an openConnection() but
- // HttpURLConnection will return true on HTTP_BAD_REQUEST
- // when the requested name ends in ".html", ".htm", and ".txt"
- // and we want to be able to handle these
- //
- // Also, cannot just open a connection for things like FileURLConnection,
- // because they succeed when connecting to a nonexistent file.
- // So, in those cases we open and close an input stream.
- boolean ok = true;
- try {
- URLConnection conn = url.openConnection();
- if (conn instanceof java.net.HttpURLConnection) {
- java.net.HttpURLConnection hconn =
- (java.net.HttpURLConnection) conn;
-
- // To reduce overhead, using http HEAD method instead of GET method
- hconn.setRequestMethod("HEAD");
-
- int code = hconn.getResponseCode();
- if (code == java.net.HttpURLConnection.HTTP_OK) {
- return true;
- }
- if (code >= java.net.HttpURLConnection.HTTP_BAD_REQUEST) {
- return false;
- }
- } else {
- /**
- * Fix for #4182052 - stanleyh
- *
- * The same connection should be reused to avoid multiple
- * HTTP connections
- */
-
- // our best guess for the other cases
- InputStream is = conn.getInputStream();
- is.close();
- }
- } catch (Exception ex) {
- ok = false;
- }
- return ok;
- }
-
- /*
- * Returns an enumeration of all the applet resources with the specified
- * name. First checks loaded JAR files then the applet code base for all
- * available resources.
- */
- @Override
- public Enumeration<URL> findResources(String name) throws IOException {
-
- final Enumeration<URL> e = super.findResources(name);
-
- // 6215746: Disable META-INF/* lookup from codebase in
- // applet/plugin classloader. [stanley.ho]
- if (name.startsWith("META-INF/"))
- return e;
-
- // 4668479: Option to turn off codebase lookup in AppletClassLoader
- // during resource requests. [stanley.ho]
- if (codebaseLookup == false)
- return e;
-
- URL u = new URL(base, ParseUtil.encodePath(name, false));
- if (!resourceExists(u)) {
- u = null;
- }
-
- final URL url = u;
- return new Enumeration<URL>() {
- private boolean done;
- public URL nextElement() {
- if (!done) {
- if (e.hasMoreElements()) {
- return e.nextElement();
- }
- done = true;
- if (url != null) {
- return url;
- }
- }
- throw new NoSuchElementException();
- }
- public boolean hasMoreElements() {
- return !done && (e.hasMoreElements() || url != null);
- }
- };
- }
-
- /*
- * Load and resolve the file specified by the applet tag CODE
- * attribute. The argument can either be the relative path
- * of the class file itself or just the name of the class.
- */
- Class<?> loadCode(String name) throws ClassNotFoundException {
- // first convert any '/' or native file separator to .
- name = name.replace('/', '.');
- name = name.replace(File.separatorChar, '.');
-
- // deal with URL rewriting
- String cookie = null;
- int index = name.indexOf(';');
- if(index != -1) {
- cookie = name.substring(index, name.length());
- name = name.substring(0, index);
- }
-
- // save that name for later
- String fullName = name;
- // then strip off any suffixes
- if (name.endsWith(".class") || name.endsWith(".java")) {
- name = name.substring(0, name.lastIndexOf('.'));
- }
- try {
- if(cookie != null)
- name = (new StringBuffer(name)).append(cookie).toString();
- return loadClass(name);
- } catch (ClassNotFoundException e) {
- }
- // then if it didn't end with .java or .class, or in the
- // really pathological case of a class named class or java
- if(cookie != null)
- fullName = (new StringBuffer(fullName)).append(cookie).toString();
-
- return loadClass(fullName);
- }
-
- /*
- * The threadgroup that the applets loaded by this classloader live
- * in. In the sun.* implementation of applets, the security manager's
- * (AppletSecurity) getThreadGroup returns the thread group of the
- * first applet on the stack, which is the applet's thread group.
- */
- private AppletThreadGroup threadGroup;
- private AppContext appContext;
-
- public ThreadGroup getThreadGroup() {
- synchronized (threadGroupSynchronizer) {
- if (threadGroup == null || threadGroup.isDestroyed()) {
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- threadGroup = new AppletThreadGroup(base + "-threadGroup");
- // threadGroup.setDaemon(true);
- // threadGroup is now destroyed by AppContext.dispose()
-
- // Create the new AppContext from within a Thread belonging
- // to the newly created ThreadGroup, and wait for the
- // creation to complete before returning from this method.
- AppContextCreator creatorThread = new AppContextCreator(threadGroup);
-
- // Since this thread will later be used to launch the
- // applet's AWT-event dispatch thread and we want the applet
- // code executing the AWT callbacks to use their own class
- // loader rather than the system class loader, explicitly
- // set the context class loader to the AppletClassLoader.
- creatorThread.setContextClassLoader(AppletClassLoader.this);
-
- creatorThread.start();
- try {
- synchronized(creatorThread.syncObject) {
- while (!creatorThread.created) {
- creatorThread.syncObject.wait();
- }
- }
- } catch (InterruptedException e) { }
- appContext = creatorThread.appContext;
- return null;
- }
- });
- }
- return threadGroup;
- }
- }
-
- /*
- * Get the AppContext, if any, corresponding to this AppletClassLoader.
- */
- public AppContext getAppContext() {
- return appContext;
- }
-
- int usageCount = 0;
-
- /**
- * Grab this AppletClassLoader and its ThreadGroup/AppContext, so they
- * won't be destroyed.
- */
-public void grab() {
- synchronized(grabReleaseSynchronizer) {
- usageCount++;
- }
- getThreadGroup(); // Make sure ThreadGroup/AppContext exist
- }
-
- protected void setExceptionStatus()
- {
- exceptionStatus = true;
- }
-
- public boolean getExceptionStatus()
- {
- return exceptionStatus;
- }
-
- /**
- * Release this AppletClassLoader and its ThreadGroup/AppContext.
- * If nothing else has grabbed this AppletClassLoader, its ThreadGroup
- * and AppContext will be destroyed.
- *
- * Because this method may destroy the AppletClassLoader's ThreadGroup,
- * this method should NOT be called from within the AppletClassLoader's
- * ThreadGroup.
- *
- * Changed modifier to protected in order to be able to overwrite this
- * function in PluginClassLoader.java
- */
- protected void release() {
-
- AppContext tempAppContext = null;
-
- synchronized(grabReleaseSynchronizer) {
- if (usageCount > 1) {
- --usageCount;
- } else {
- synchronized(threadGroupSynchronizer) {
- tempAppContext = resetAppContext();
- }
- }
- }
-
- // Dispose appContext outside any sync block to
- // prevent potential deadlock.
- if (tempAppContext != null) {
- try {
- tempAppContext.dispose(); // nuke the world!
- } catch (IllegalThreadStateException e) { }
- }
- }
-
- /*
- * reset classloader's AppContext and ThreadGroup
- * This method is for subclass PluginClassLoader to
- * reset superclass's AppContext and ThreadGroup but do
- * not dispose the AppContext. PluginClassLoader does not
- * use UsageCount to decide whether to dispose AppContext
- *
- * @return previous AppContext
- */
- protected AppContext resetAppContext() {
- AppContext tempAppContext = null;
-
- synchronized(threadGroupSynchronizer) {
- // Store app context in temp variable
- tempAppContext = appContext;
- usageCount = 0;
- appContext = null;
- threadGroup = null;
- }
- return tempAppContext;
- }
-
-
- // Hash map to store applet compatibility info
- private HashMap<String, Boolean> jdk11AppletInfo = new HashMap<>();
- private HashMap<String, Boolean> jdk12AppletInfo = new HashMap<>();
-
- /**
- * Set applet target level as JDK 1.1.
- *
- * @param clazz Applet class.
- * @param bool true if JDK is targeted for JDK 1.1;
- * false otherwise.
- */
- void setJDK11Target(Class<?> clazz, boolean bool)
- {
- jdk11AppletInfo.put(clazz.toString(), Boolean.valueOf(bool));
- }
-
- /**
- * Set applet target level as JDK 1.2.
- *
- * @param clazz Applet class.
- * @param bool true if JDK is targeted for JDK 1.2;
- * false otherwise.
- */
- void setJDK12Target(Class<?> clazz, boolean bool)
- {
- jdk12AppletInfo.put(clazz.toString(), Boolean.valueOf(bool));
- }
-
- /**
- * Determine if applet is targeted for JDK 1.1.
- *
- * @param clazz Applet class.
- * @return TRUE if applet is targeted for JDK 1.1;
- * FALSE if applet is not;
- * null if applet is unknown.
- */
- Boolean isJDK11Target(Class<?> clazz)
- {
- return jdk11AppletInfo.get(clazz.toString());
- }
-
- /**
- * Determine if applet is targeted for JDK 1.2.
- *
- * @param clazz Applet class.
- * @return TRUE if applet is targeted for JDK 1.2;
- * FALSE if applet is not;
- * null if applet is unknown.
- */
- Boolean isJDK12Target(Class<?> clazz)
- {
- return jdk12AppletInfo.get(clazz.toString());
- }
-}
-
-/*
- * The AppContextCreator class is used to create an AppContext from within
- * a Thread belonging to the new AppContext's ThreadGroup. To wait for
- * this operation to complete before continuing, wait for the notifyAll()
- * operation on the syncObject to occur.
- */
-class AppContextCreator extends Thread {
- Object syncObject = new Object();
- AppContext appContext = null;
- volatile boolean created = false;
-
- /**
- * Must call the 5-args super-class constructor to erase locals.
- */
- private AppContextCreator() {
- throw new UnsupportedOperationException("Must erase locals");
- }
-
- AppContextCreator(ThreadGroup group) {
- super(group, null, "AppContextCreator", 0, false);
- }
-
- public void run() {
- appContext = SunToolkit.createNewAppContext();
- created = true;
- synchronized(syncObject) {
- syncObject.notifyAll();
- }
- } // run()
-
-} // class AppContextCreator
--- a/src/java.desktop/share/classes/sun/applet/AppletSecurity.java Thu Sep 27 08:49:12 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,421 +0,0 @@
-/*
- * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.applet;
-
-import java.io.File;
-import java.io.FilePermission;
-import java.io.IOException;
-import java.io.FileDescriptor;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.net.SocketPermission;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.HashSet;
-import java.util.StringTokenizer;
-import java.security.*;
-import java.lang.reflect.*;
-import jdk.internal.misc.JavaNetURLClassLoaderAccess;
-import jdk.internal.misc.JavaSecurityAccess;
-import jdk.internal.misc.SharedSecrets;
-import sun.awt.AWTSecurityManager;
-import sun.awt.AppContext;
-import sun.awt.AWTPermissions;
-import sun.security.util.SecurityConstants;
-
-import static java.lang.StackWalker.*;
-import static java.lang.StackWalker.Option.*;
-
-
-/**
- * This class defines an applet security policy
- *
- */
-public
-class AppletSecurity extends AWTSecurityManager {
- private static final JavaNetURLClassLoaderAccess JNUCLA
- = SharedSecrets.getJavaNetURLClassLoaderAccess();
- private static final JavaSecurityAccess JSA = SharedSecrets.getJavaSecurityAccess();
-
- /**
- * Construct and initialize.
- */
- public AppletSecurity() {
- reset();
- }
-
- // Cache to store known restricted packages
- private HashSet<String> restrictedPackages = new HashSet<>();
-
- /**
- * Reset from Properties
- */
- public void reset()
- {
- // Clear cache
- restrictedPackages.clear();
-
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run()
- {
- // Enumerate system properties
- Enumeration<?> e = System.getProperties().propertyNames();
-
- while (e.hasMoreElements())
- {
- String name = (String) e.nextElement();
-
- if (name != null && name.startsWith("package.restrict.access."))
- {
- String value = System.getProperty(name);
-
- if (value != null && value.equalsIgnoreCase("true"))
- {
- String pkg = name.substring(24);
-
- // Cache restricted packages
- restrictedPackages.add(pkg);
- }
- }
- }
- return null;
- }
- });
- }
-
- private static final StackWalker walker =
- AccessController.doPrivileged(
- (PrivilegedAction<StackWalker>) () ->
- StackWalker.getInstance(RETAIN_CLASS_REFERENCE));
- /**
- * Returns the class loader of the most recently executing method from
- * a class defined using a non-system class loader. A non-system
- * class loader is defined as being a class loader that is not equal to
- * the system class loader (as returned
- * by {@link ClassLoader#getSystemClassLoader}) or one of its ancestors.
- * <p>
- * This method will return
- * <code>null</code> in the following three cases:
- * <ol>
- * <li>All methods on the execution stack are from classes
- * defined using the system class loader or one of its ancestors.
- *
- * <li>All methods on the execution stack up to the first
- * "privileged" caller
- * (see {@link java.security.AccessController#doPrivileged})
- * are from classes
- * defined using the system class loader or one of its ancestors.
- *
- * <li> A call to <code>checkPermission</code> with
- * <code>java.security.AllPermission</code> does not
- * result in a SecurityException.
- * </ol>
- *
- * NOTE: This is an implementation of the SecurityManager.currentClassLoader
- * method that uses StackWalker. SecurityManager.currentClassLoader
- * has been removed from SE. This is a temporary workaround which is
- * only needed while applets are still supported.
- *
- * @return the class loader of the most recent occurrence on the stack
- * of a method from a class defined using a non-system class
- * loader.
- */
- private static ClassLoader currentClassLoader() {
- StackFrame f =
- walker.walk(s -> s.takeWhile(AppletSecurity::isNonPrivileged)
- .filter(AppletSecurity::isNonSystemFrame)
- .findFirst())
- .orElse(null);
-
- SecurityManager sm = System.getSecurityManager();
- if (f != null && sm != null) {
- try {
- sm.checkPermission(new AllPermission());
- } catch (SecurityException se) {
- return f.getDeclaringClass().getClassLoader();
- }
- }
- return null;
- }
-
- /**
- * Returns true if the StackFrame is not AccessController.doPrivileged.
- */
- private static boolean isNonPrivileged(StackFrame f) {
- // possibly other doPrivileged variants
- Class<?> c = f.getDeclaringClass();
- return c == AccessController.class &&
- f.getMethodName().equals("doPrivileged");
- }
-
- /**
- * Returns true if the StackFrame is not from a class defined by the
- * system class loader or one of its ancestors.
- */
- private static boolean isNonSystemFrame(StackFrame f) {
- ClassLoader loader = ClassLoader.getSystemClassLoader();
- ClassLoader ld = f.getDeclaringClass().getClassLoader();
- if (ld == null || ld == loader) return false;
-
- while ((loader = loader.getParent()) != null) {
- if (ld == loader)
- return false;
- }
- return true;
- }
-
- /**
- * get the current (first) instance of an AppletClassLoader on the stack.
- */
- private AppletClassLoader currentAppletClassLoader()
- {
- // try currentClassLoader first
- ClassLoader loader = currentClassLoader();
-
- if ((loader == null) || (loader instanceof AppletClassLoader))
- return (AppletClassLoader)loader;
-
- // if that fails, get all the classes on the stack and check them.
- Class<?>[] context = getClassContext();
- for (int i = 0; i < context.length; i++) {
- loader = context[i].getClassLoader();
- if (loader instanceof AppletClassLoader)
- return (AppletClassLoader)loader;
- }
-
- /*
- * fix bug # 6433620 the logic here is : try to find URLClassLoader from
- * class context, check its AccessControlContext to see if
- * AppletClassLoader is in stack when it's created. for this kind of
- * URLClassLoader, return the AppContext associated with the
- * AppletClassLoader.
- */
- for (int i = 0; i < context.length; i++) {
- final ClassLoader currentLoader = context[i].getClassLoader();
-
- if (currentLoader instanceof URLClassLoader) {
- URLClassLoader ld = (URLClassLoader)currentLoader;
- loader = AccessController.doPrivileged(
- new PrivilegedAction<ClassLoader>() {
- public ClassLoader run() {
-
- AccessControlContext acc = null;
- ProtectionDomain[] pds = null;
-
- try {
- acc = JNUCLA.getAccessControlContext(ld);
- if (acc == null) {
- return null;
- }
-
- pds = JSA.getProtectDomains(acc);
- if (pds == null) {
- return null;
- }
- } catch (Exception e) {
- throw new UnsupportedOperationException(e);
- }
-
- for (int i=0; i<pds.length; i++) {
- ClassLoader cl = pds[i].getClassLoader();
-
- if (cl instanceof AppletClassLoader) {
- return cl;
- }
- }
-
- return null;
- }
- });
-
- if (loader != null) {
- return (AppletClassLoader) loader;
- }
- }
- }
-
- // if that fails, try the context class loader
- loader = Thread.currentThread().getContextClassLoader();
- if (loader instanceof AppletClassLoader)
- return (AppletClassLoader)loader;
-
- // no AppletClassLoaders on the stack
- return (AppletClassLoader)null;
- }
-
- /**
- * Returns true if this threadgroup is in the applet's own thread
- * group. This will return false if there is no current class
- * loader.
- */
- protected boolean inThreadGroup(ThreadGroup g) {
- if (currentAppletClassLoader() == null)
- return false;
- else
- return getThreadGroup().parentOf(g);
- }
-
- /**
- * Returns true of the threadgroup of thread is in the applet's
- * own threadgroup.
- */
- protected boolean inThreadGroup(Thread thread) {
- return inThreadGroup(thread.getThreadGroup());
- }
-
- /**
- * Applets are not allowed to manipulate threads outside
- * applet thread groups. However a terminated thread no longer belongs
- * to any group.
- */
- public void checkAccess(Thread t) {
- /* When multiple applets is reloaded simultaneously, there will be
- * multiple invocations to this method from plugin's SecurityManager.
- * This method should not be synchronized to avoid deadlock when
- * a page with multiple applets is reloaded
- */
- if ((t.getState() != Thread.State.TERMINATED) && !inThreadGroup(t)) {
- checkPermission(SecurityConstants.MODIFY_THREAD_PERMISSION);
- }
- }
-
- private boolean inThreadGroupCheck = false;
-
- /**
- * Applets are not allowed to manipulate thread groups outside
- * applet thread groups.
- */
- public synchronized void checkAccess(ThreadGroup g) {
- if (inThreadGroupCheck) {
- // if we are in a recursive check, it is because
- // inThreadGroup is calling appletLoader.getThreadGroup
- // in that case, only do the super check, as appletLoader
- // has a begin/endPrivileged
- checkPermission(SecurityConstants.MODIFY_THREADGROUP_PERMISSION);
- } else {
- try {
- inThreadGroupCheck = true;
- if (!inThreadGroup(g)) {
- checkPermission(SecurityConstants.MODIFY_THREADGROUP_PERMISSION);
- }
- } finally {
- inThreadGroupCheck = false;
- }
- }
- }
-
-
- /**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to access the package specified by
- * the argument.
- * <p>
- * This method is used by the {@code loadClass} method of class
- * loaders.
- * <p>
- * The {@code checkPackageAccess} method for class
- * {@code SecurityManager} calls
- * {@code checkPermission} with the
- * {@code RuntimePermission("accessClassInPackage."+ pkgname)}
- * permission.
- *
- * @param pkgname the package name.
- * @exception SecurityException if the caller does not have
- * permission to access the specified package.
- * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean)
- */
- public void checkPackageAccess(final String pkgname) {
-
- // first see if the VM-wide policy allows access to this package
- super.checkPackageAccess(pkgname);
-
- // now check the list of restricted packages
- for (Iterator<String> iter = restrictedPackages.iterator(); iter.hasNext();)
- {
- String pkg = iter.next();
-
- // Prevent matching "sun" and "sunir" even if they
- // starts with similar beginning characters
- //
- if (pkgname.equals(pkg) || pkgname.startsWith(pkg + "."))
- {
- checkPermission(new java.lang.RuntimePermission
- ("accessClassInPackage." + pkgname));
- }
- }
- }
-
- /**
- * Returns the thread group of the applet. We consult the classloader
- * if there is one.
- */
- public ThreadGroup getThreadGroup() {
- /* If any applet code is on the execution stack, we return
- that applet's ThreadGroup. Otherwise, we use the default
- behavior. */
- AppletClassLoader appletLoader = currentAppletClassLoader();
- ThreadGroup loaderGroup = (appletLoader == null) ? null
- : appletLoader.getThreadGroup();
- if (loaderGroup != null) {
- return loaderGroup;
- } else {
- return super.getThreadGroup();
- }
- } // getThreadGroup()
-
- /**
- * Get the AppContext corresponding to the current context.
- * The default implementation returns null, but this method
- * may be overridden by various SecurityManagers
- * (e.g. AppletSecurity) to index AppContext objects by the
- * calling context.
- *
- * @return the AppContext corresponding to the current context.
- * @see sun.awt.AppContext
- * @see java.lang.SecurityManager
- * @since 1.2.1
- */
- public AppContext getAppContext() {
- AppletClassLoader appletLoader = currentAppletClassLoader();
-
- if (appletLoader == null) {
- return null;
- } else {
- AppContext context = appletLoader.getAppContext();
-
- // context == null when some thread in applet thread group
- // has not been destroyed in AppContext.dispose()
- if (context == null) {
- throw new SecurityException("Applet classloader has invalid AppContext");
- }
-
- return context;
- }
- }
-
-} // class AppletSecurity
--- a/src/java.desktop/share/classes/sun/applet/AppletThreadGroup.java Thu Sep 27 08:49:12 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.applet;
-
-/**
- * This class defines an applet thread group.
- *
- * @author Arthur van Hoff
- */
-public class AppletThreadGroup extends ThreadGroup {
-
- /**
- * Constructs a new thread group for an applet.
- * The parent of this new group is the thread
- * group of the currently running thread.
- *
- * @param name the name of the new thread group.
- */
- public AppletThreadGroup(String name) {
- this(Thread.currentThread().getThreadGroup(), name);
- }
-
- /**
- * Creates a new thread group for an applet.
- * The parent of this new group is the specified
- * thread group.
- *
- * @param parent the parent thread group.
- * @param name the name of the new thread group.
- * @exception NullPointerException if the thread group argument is
- * {@code null}.
- * @exception SecurityException if the current thread cannot create a
- * thread in the specified thread group.
- * @see java.lang.SecurityException
- * @since 1.1.1
- */
- public AppletThreadGroup(ThreadGroup parent, String name) {
- super(parent, name);
- setMaxPriority(Thread.NORM_PRIORITY - 1);
- }
-}
--- a/src/java.desktop/share/classes/sun/awt/AWTAccessor.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/awt/AWTAccessor.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, 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
@@ -295,20 +295,11 @@
*/
void updateWindow(Window window);
- /** Get the size of the security warning.
- */
- Dimension getSecurityWarningSize(Window w);
-
/**
* Set the size of the security warning.
*/
void setSecurityWarningSize(Window w, int width, int height);
- /** Set the position of the security warning.
- */
- void setSecurityWarningPosition(Window w, Point2D point,
- float alignmentX, float alignmentY);
-
/** Request to recalculate the new position of the security warning for
* the given window size/location as reported by the native system.
*/
--- a/src/java.desktop/share/classes/sun/awt/HToolkit.java Thu Sep 27 08:49:12 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,317 +0,0 @@
-/*
- * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.awt;
-
-import java.awt.*;
-import java.awt.datatransfer.Clipboard;
-import java.awt.dnd.DragGestureListener;
-import java.awt.dnd.DragGestureRecognizer;
-import java.awt.dnd.DragSource;
-import java.awt.im.InputMethodHighlight;
-import java.awt.im.spi.InputMethodDescriptor;
-import java.awt.image.ColorModel;
-import java.awt.peer.FramePeer;
-import java.awt.peer.KeyboardFocusManagerPeer;
-import java.awt.peer.SystemTrayPeer;
-import java.awt.peer.TrayIconPeer;
-import java.util.Map;
-import java.util.Properties;
-
-/*
- * HToolkit is a platform independent Toolkit used
- * with the HeadlessToolkit. It is primarily used
- * in embedded JRE's that do not have sun/awt/X11 classes.
- */
-public final class HToolkit extends SunToolkit implements ComponentFactory {
-
- private static final KeyboardFocusManagerPeer kfmPeer = new KeyboardFocusManagerPeer() {
- @Override
- public void setCurrentFocusedWindow(Window win) {}
- @Override
- public Window getCurrentFocusedWindow() { return null; }
- @Override
- public void setCurrentFocusOwner(Component comp) {}
- @Override
- public Component getCurrentFocusOwner() { return null; }
- @Override
- public void clearGlobalFocusOwner(Window activeWindow) {}
- };
-
- public HToolkit() {
- }
-
- /*
- * Component peer objects - unsupported.
- */
-
- @Override
- public FramePeer createLightweightFrame(LightweightFrame target)
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
- // See 6833019.
- return kfmPeer;
- }
-
- @Override
- public TrayIconPeer createTrayIcon(TrayIcon target)
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public SystemTrayPeer createSystemTray(SystemTray target)
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public boolean isTraySupported() {
- return false;
- }
-
- public GlobalCursorManager getGlobalCursorManager()
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- /*
- * Headless toolkit - unsupported.
- */
- @Override
- protected void loadSystemColors(int[] systemColors)
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public ColorModel getColorModel()
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public int getScreenResolution()
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public Map<java.awt.font.TextAttribute, ?> mapInputMethodHighlight(
- InputMethodHighlight highlight)
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- @Deprecated(since = "10")
- public int getMenuShortcutKeyMask()
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public int getMenuShortcutKeyMaskEx()
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public boolean getLockingKeyState(int keyCode)
- throws UnsupportedOperationException {
- throw new HeadlessException();
- }
-
- @Override
- public void setLockingKeyState(int keyCode, boolean on)
- throws UnsupportedOperationException {
- throw new HeadlessException();
- }
-
- @Override
- public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
- throws IndexOutOfBoundsException, HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public int getMaximumCursorColors()
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public <T extends DragGestureRecognizer> T
- createDragGestureRecognizer(Class<T> abstractRecognizerClass,
- DragSource ds, Component c,
- int srcActions, DragGestureListener dgl)
- {
- return null;
- }
-
- @Override
- public Dimension getScreenSize()
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public Insets getScreenInsets(GraphicsConfiguration gc)
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public void setDynamicLayout(boolean dynamic)
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- protected boolean isDynamicLayoutSet()
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public boolean isDynamicLayoutActive()
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- @Override
- public Clipboard getSystemClipboard()
- throws HeadlessException {
- throw new HeadlessException();
- }
-
- /*
- * Printing
- */
- @Override
- public PrintJob getPrintJob(Frame frame, String jobtitle,
- JobAttributes jobAttributes,
- PageAttributes pageAttributes) {
- if (frame != null) {
- // Should never happen
- throw new HeadlessException();
- }
- throw new IllegalArgumentException(
- "PrintJob not supported in a headless environment");
- }
-
- @Override
- public PrintJob getPrintJob(Frame frame, String doctitle, Properties props)
- {
- if (frame != null) {
- // Should never happen
- throw new HeadlessException();
- }
- throw new IllegalArgumentException(
- "PrintJob not supported in a headless environment");
- }
-
- /*
- * Headless toolkit - supported.
- */
-
- @Override
- public void sync() {
- // Do nothing
- }
-
- @Override
- protected boolean syncNativeQueue(final long timeout) {
- return false;
- }
-
- @Override
- public void beep() {
- // Send alert character
- System.out.write(0x07);
- }
-
- /*
- * Modality
- */
- @Override
- public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
- return false;
- }
-
- @Override
- public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
- return false;
- }
-
- @Override
- public boolean isDesktopSupported() {
- return false;
- }
-
- @Override
- public boolean isTaskbarSupported() {
- return false;
- }
-
- public boolean isWindowOpacityControlSupported() {
- return false;
- }
-
- @Override
- public boolean isWindowShapingSupported() {
- return false;
- }
-
- @Override
- public boolean isWindowTranslucencySupported() {
- return false;
- }
-
- @Override
- public void grab(Window w) { }
-
- @Override
- public void ungrab(Window w) { }
-
- protected boolean syncNativeQueue() { return false; }
-
- @Override
- public InputMethodDescriptor getInputMethodAdapterDescriptor()
- throws AWTException
- {
- return (InputMethodDescriptor)null;
- }
-}
--- a/src/java.desktop/share/classes/sun/font/CMap.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/font/CMap.java Thu Sep 27 10:49:10 2018 -0700
@@ -566,6 +566,7 @@
char getGlyph(int charCode) {
+ final int origCharCode = charCode;
int index = 0;
char glyphCode = 0;
@@ -637,8 +638,8 @@
}
}
}
- if (glyphCode != 0) {
- //System.err.println("cc="+Integer.toHexString((int)charCode) + " gc="+(int)glyphCode);
+ if (glyphCode == 0) {
+ glyphCode = getFormatCharGlyph(origCharCode);
}
return glyphCode;
}
@@ -804,6 +805,7 @@
}
char getGlyph(int charCode) {
+ final int origCharCode = charCode;
int controlGlyph = getControlCodeGlyph(charCode, true);
if (controlGlyph >= 0) {
return (char)controlGlyph;
@@ -859,7 +861,7 @@
return glyphCode;
}
}
- return 0;
+ return getFormatCharGlyph(origCharCode);
}
}
@@ -883,6 +885,7 @@
}
char getGlyph(int charCode) {
+ final int origCharCode = charCode;
int controlGlyph = getControlCodeGlyph(charCode, true);
if (controlGlyph >= 0) {
return (char)controlGlyph;
@@ -894,7 +897,7 @@
charCode -= firstCode;
if (charCode < 0 || charCode >= entryCount) {
- return 0;
+ return getFormatCharGlyph(origCharCode);
} else {
return glyphIdArray[charCode];
}
@@ -1032,6 +1035,7 @@
}
char getGlyph(int charCode) {
+ final int origCharCode = charCode;
int controlGlyph = getControlCodeGlyph(charCode, false);
if (controlGlyph >= 0) {
return (char)controlGlyph;
@@ -1057,7 +1061,7 @@
(startGlyphID[range] + (charCode - startCharCode[range]));
}
- return 0;
+ return getFormatCharGlyph(origCharCode);
}
}
@@ -1079,16 +1083,21 @@
case 0x000a:
case 0x000d: return CharToGlyphMapper.INVISIBLE_GLYPH_ID;
}
- } else if (charCode >= 0x200c) {
+ } else if (noSurrogates && charCode >= 0xFFFF) {
+ return 0;
+ }
+ return -1;
+ }
+
+ final char getFormatCharGlyph(int charCode) {
+ if (charCode >= 0x200c) {
if ((charCode <= 0x200f) ||
(charCode >= 0x2028 && charCode <= 0x202e) ||
(charCode >= 0x206a && charCode <= 0x206f)) {
- return CharToGlyphMapper.INVISIBLE_GLYPH_ID;
- } else if (noSurrogates && charCode >= 0xFFFF) {
- return 0;
+ return (char)CharToGlyphMapper.INVISIBLE_GLYPH_ID;
}
}
- return -1;
+ return 0;
}
static class UVS {
--- a/src/java.desktop/share/classes/sun/font/SunFontManager.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/font/SunFontManager.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, 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
@@ -2740,7 +2740,7 @@
new java.security.PrivilegedAction<Object>() {
public Object run() {
SecurityManager sm = System.getSecurityManager();
- return sm instanceof sun.applet.AppletSecurity;
+ return sm instanceof sun.awt.AWTSecurityManager;
}
});
return appletSM.booleanValue();
--- a/src/java.desktop/share/classes/sun/font/SunLayoutEngine.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/font/SunLayoutEngine.java Thu Sep 27 10:49:10 2018 -0700
@@ -35,6 +35,7 @@
import java.lang.ref.SoftReference;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Locale;
+import java.util.WeakHashMap;
/*
* different ways to do this
@@ -148,17 +149,30 @@
this.key = key;
}
+ static WeakHashMap<Font2D, Boolean> aatInfo = new WeakHashMap<>();
+
private boolean isAAT(Font2D font) {
+ Boolean aatObj;
+ synchronized (aatInfo) {
+ aatObj = aatInfo.get(font);
+ }
+ if (aatObj != null) {
+ return aatObj.booleanValue();
+ }
+ boolean aat = false;
if (font instanceof TrueTypeFont) {
TrueTypeFont ttf = (TrueTypeFont)font;
- return ttf.getDirectoryEntry(TrueTypeFont.morxTag) != null ||
+ aat = ttf.getDirectoryEntry(TrueTypeFont.morxTag) != null ||
ttf.getDirectoryEntry(TrueTypeFont.mortTag) != null;
} else if (font instanceof PhysicalFont) {
PhysicalFont pf = (PhysicalFont)font;
- return pf.getTableBytes(TrueTypeFont.morxTag) != null ||
+ aat = pf.getTableBytes(TrueTypeFont.morxTag) != null ||
pf.getTableBytes(TrueTypeFont.mortTag) != null;
}
- return false;
+ synchronized (aatInfo) {
+ aatInfo.put(font, Boolean.valueOf(aat));
+ }
+ return aat;
}
public void layout(FontStrikeDesc desc, float[] mat, float ptSize, int gmask,
--- a/src/java.desktop/share/classes/sun/java2d/marlin/DMarlinRenderingEngine.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/java2d/marlin/DMarlinRenderingEngine.java Thu Sep 27 10:49:10 2018 -0700
@@ -31,6 +31,7 @@
import java.awt.geom.Path2D;
import java.awt.geom.PathIterator;
import java.security.AccessController;
+import java.util.Arrays;
import sun.awt.geom.PathConsumer2D;
import static sun.java2d.marlin.MarlinUtils.logInfo;
import sun.java2d.ReentrantContextProvider;
@@ -334,7 +335,6 @@
int dashLen = -1;
boolean recycleDashes = false;
- double scale = 1.0d;
double[] dashesD = null;
// Ensure converting dashes to double precision:
@@ -375,7 +375,7 @@
// a*b == -c*d && a*a+c*c == b*b+d*d. In the actual check below, we
// leave a bit of room for error.
if (nearZero(a*b + c*d) && nearZero(a*a + c*c - (b*b + d*d))) {
- scale = Math.sqrt(a*a + c*c);
+ final double scale = Math.sqrt(a*a + c*c);
if (dashesD != null) {
for (int i = 0; i < dashLen; i++) {
@@ -427,7 +427,7 @@
pc2d = transformerPC2D.deltaTransformConsumer(pc2d, strokerat);
// stroker will adjust the clip rectangle (width / miter limit):
- pc2d = rdrCtx.stroker.init(pc2d, width, caps, join, miterlimit, scale,
+ pc2d = rdrCtx.stroker.init(pc2d, width, caps, join, miterlimit,
(dashesD == null));
// Curve Monotizer:
@@ -834,10 +834,26 @@
// Define the initial clip bounds:
final double[] clipRect = rdrCtx.clipRect;
- clipRect[0] = clip.getLoY();
- clipRect[1] = clip.getLoY() + clip.getHeight();
- clipRect[2] = clip.getLoX();
- clipRect[3] = clip.getLoX() + clip.getWidth();
+ // Adjust the clipping rectangle with the renderer offsets
+ final double rdrOffX = DRenderer.RDR_OFFSET_X;
+ final double rdrOffY = DRenderer.RDR_OFFSET_Y;
+
+ // add a small rounding error:
+ final double margin = 1e-3d;
+
+ clipRect[0] = clip.getLoY()
+ - margin + rdrOffY;
+ clipRect[1] = clip.getLoY() + clip.getHeight()
+ + margin + rdrOffY;
+ clipRect[2] = clip.getLoX()
+ - margin + rdrOffX;
+ clipRect[3] = clip.getLoX() + clip.getWidth()
+ + margin + rdrOffX;
+
+ if (MarlinConst.DO_LOG_CLIP) {
+ MarlinUtils.logInfo("clipRect (clip): "
+ + Arrays.toString(rdrCtx.clipRect));
+ }
// Enable clipping:
rdrCtx.doClip = true;
--- a/src/java.desktop/share/classes/sun/java2d/marlin/DRendererContext.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/java2d/marlin/DRendererContext.java Thu Sep 27 10:49:10 2018 -0700
@@ -85,6 +85,8 @@
boolean closedPath = false;
// clip rectangle (ymin, ymax, xmin, xmax):
final double[] clipRect = new double[4];
+ // clip inverse scale (mean) to adjust length checks
+ double clipInvScale = 0.0d;
// CurveBasicMonotonizer instance
final CurveBasicMonotonizer monotonizer;
// CurveClipSplitter instance
@@ -105,7 +107,6 @@
final PathConsumer2DAdapter p2dAdapter = new PathConsumer2DAdapter();
-
/**
* Constructor
*
@@ -162,6 +163,7 @@
stroking = 0;
doClip = false;
closedPath = false;
+ clipInvScale = 0.0d;
// if context is maked as DIRTY:
if (dirty) {
--- a/src/java.desktop/share/classes/sun/java2d/marlin/DStroker.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/java2d/marlin/DStroker.java Thu Sep 27 10:49:10 2018 -0700
@@ -139,7 +139,6 @@
* <code>JOIN_MITER</code>, <code>JOIN_ROUND</code> or
* <code>JOIN_BEVEL</code>.
* @param miterLimit the desired miter limit
- * @param scale scaling factor applied to clip boundaries
* @param subdivideCurves true to indicate to subdivide curves, false if dasher does
* @return this instance
*/
@@ -148,7 +147,6 @@
final int capStyle,
final int joinStyle,
final double miterLimit,
- final double scale,
final boolean subdivideCurves)
{
this.out = pc2d;
@@ -169,7 +167,6 @@
if (rdrCtx.doClip) {
// Adjust the clipping rectangle with the stroker margin (miter limit, width)
- double rdrOffX = 0.0d, rdrOffY = 0.0d;
double margin = lineWidth2;
if (capStyle == CAP_SQUARE) {
@@ -178,23 +175,21 @@
if ((joinStyle == JOIN_MITER) && (margin < limit)) {
margin = limit;
}
- if (scale != 1.0d) {
- margin *= scale;
- rdrOffX = scale * DRenderer.RDR_OFFSET_X;
- rdrOffY = scale * DRenderer.RDR_OFFSET_Y;
- }
- // add a small rounding error:
- margin += 1e-3d;
// bounds as half-open intervals: minX <= x < maxX and minY <= y < maxY
// adjust clip rectangle (ymin, ymax, xmin, xmax):
final double[] _clipRect = rdrCtx.clipRect;
- _clipRect[0] -= margin - rdrOffY;
- _clipRect[1] += margin + rdrOffY;
- _clipRect[2] -= margin - rdrOffX;
- _clipRect[3] += margin + rdrOffX;
+ _clipRect[0] -= margin;
+ _clipRect[1] += margin;
+ _clipRect[2] -= margin;
+ _clipRect[3] += margin;
this.clipRect = _clipRect;
+ if (MarlinConst.DO_LOG_CLIP) {
+ MarlinUtils.logInfo("clipRect (stroker): "
+ + Arrays.toString(rdrCtx.clipRect));
+ }
+
// initialize curve splitter here for stroker & dasher:
if (DO_CLIP_SUBDIVIDER) {
subdivide = subdivideCurves;
@@ -304,13 +299,9 @@
// If it is >=0, we know that abs(ext) is <= 90 degrees, so we only
// need 1 curve to approximate the circle section that joins omx,omy
// and mx,my.
- final int numCurves = (cosext >= 0.0d) ? 1 : 2;
-
- switch (numCurves) {
- case 1:
+ if (cosext >= 0.0d) {
drawBezApproxForArc(cx, cy, omx, omy, mx, my, rev);
- break;
- case 2:
+ } else {
// we need to split the arc into 2 arcs spanning the same angle.
// The point we want will be one of the 2 intersections of the
// perpendicular bisector of the chord (omx,omy)->(mx,my) and the
@@ -339,8 +330,6 @@
}
drawBezApproxForArc(cx, cy, omx, omy, mmx, mmy, rev);
drawBezApproxForArc(cx, cy, mmx, mmy, mx, my, rev);
- break;
- default:
}
}
--- a/src/java.desktop/share/classes/sun/java2d/marlin/DTransformingPathConsumer2D.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/java2d/marlin/DTransformingPathConsumer2D.java Thu Sep 27 10:49:10 2018 -0700
@@ -119,44 +119,56 @@
// Scale only
if (rdrCtx.doClip) {
// adjust clip rectangle (ymin, ymax, xmin, xmax):
- adjustClipScale(rdrCtx.clipRect, mxx, myy);
+ rdrCtx.clipInvScale = adjustClipScale(rdrCtx.clipRect,
+ mxx, myy);
}
return dt_DeltaScaleFilter.init(out, mxx, myy);
}
} else {
if (rdrCtx.doClip) {
// adjust clip rectangle (ymin, ymax, xmin, xmax):
- adjustClipInverseDelta(rdrCtx.clipRect, mxx, mxy, myx, myy);
+ rdrCtx.clipInvScale = adjustClipInverseDelta(rdrCtx.clipRect,
+ mxx, mxy, myx, myy);
}
return dt_DeltaTransformFilter.init(out, mxx, mxy, myx, myy);
}
}
- private static void adjustClipOffset(final double[] clipRect) {
- clipRect[0] += Renderer.RDR_OFFSET_Y;
- clipRect[1] += Renderer.RDR_OFFSET_Y;
- clipRect[2] += Renderer.RDR_OFFSET_X;
- clipRect[3] += Renderer.RDR_OFFSET_X;
+ private static double adjustClipScale(final double[] clipRect,
+ final double mxx, final double myy)
+ {
+ // Adjust the clipping rectangle (iv_DeltaScaleFilter):
+ final double scaleY = 1.0d / myy;
+ clipRect[0] *= scaleY;
+ clipRect[1] *= scaleY;
+
+ if (clipRect[1] < clipRect[0]) {
+ double tmp = clipRect[0];
+ clipRect[0] = clipRect[1];
+ clipRect[1] = tmp;
+ }
+
+ final double scaleX = 1.0d / mxx;
+ clipRect[2] *= scaleX;
+ clipRect[3] *= scaleX;
+
+ if (clipRect[3] < clipRect[2]) {
+ double tmp = clipRect[2];
+ clipRect[2] = clipRect[3];
+ clipRect[3] = tmp;
+ }
+
+ if (MarlinConst.DO_LOG_CLIP) {
+ MarlinUtils.logInfo("clipRect (ClipScale): "
+ + Arrays.toString(clipRect));
+ }
+ return 0.5d * (Math.abs(scaleX) + Math.abs(scaleY));
}
- private static void adjustClipScale(final double[] clipRect,
- final double mxx, final double myy)
+ private static double adjustClipInverseDelta(final double[] clipRect,
+ final double mxx, final double mxy,
+ final double myx, final double myy)
{
- adjustClipOffset(clipRect);
-
- // Adjust the clipping rectangle (iv_DeltaScaleFilter):
- clipRect[0] /= myy;
- clipRect[1] /= myy;
- clipRect[2] /= mxx;
- clipRect[3] /= mxx;
- }
-
- private static void adjustClipInverseDelta(final double[] clipRect,
- final double mxx, final double mxy,
- final double myx, final double myy)
- {
- adjustClipOffset(clipRect);
-
// Adjust the clipping rectangle (iv_DeltaTransformFilter):
final double det = mxx * myy - mxy * myx;
final double imxx = myy / det;
@@ -198,6 +210,16 @@
clipRect[1] = ymax;
clipRect[2] = xmin;
clipRect[3] = xmax;
+
+ if (MarlinConst.DO_LOG_CLIP) {
+ MarlinUtils.logInfo("clipRect (ClipInverseDelta): "
+ + Arrays.toString(clipRect));
+ }
+
+ final double scaleX = Math.sqrt(imxx * imxx + imxy * imxy);
+ final double scaleY = Math.sqrt(imyx * imyx + imyy * imyy);
+
+ return 0.5d * (scaleX + scaleY);
}
DPathConsumer2D inverseDeltaTransformConsumer(DPathConsumer2D out,
@@ -215,7 +237,7 @@
if (mxx == 1.0d && myy == 1.0d) {
return out;
} else {
- return iv_DeltaScaleFilter.init(out, 1.0d/mxx, 1.0d/myy);
+ return iv_DeltaScaleFilter.init(out, 1.0d / mxx, 1.0d / myy);
}
} else {
final double det = mxx * myy - mxy * myx;
@@ -532,19 +554,6 @@
PathClipFilter init(final DPathConsumer2D out) {
this.out = out;
- // Adjust the clipping rectangle with the renderer offsets
- final double rdrOffX = DRenderer.RDR_OFFSET_X;
- final double rdrOffY = DRenderer.RDR_OFFSET_Y;
-
- // add a small rounding error:
- final double margin = 1e-3d;
-
- final double[] _clipRect = this.clipRect;
- _clipRect[0] -= margin - rdrOffY;
- _clipRect[1] += margin + rdrOffY;
- _clipRect[2] -= margin - rdrOffX;
- _clipRect[3] += margin + rdrOffX;
-
if (MarlinConst.DO_CLIP_SUBDIVIDER) {
// adjust padded clip rectangle:
curveSplitter.init();
@@ -867,6 +876,11 @@
private static final int MAX_N_CURVES = 3 * 4;
+ private final DRendererContext rdrCtx;
+
+ // scaled length threshold:
+ private double minLength;
+
// clip rectangle (ymin, ymax, xmin, xmax):
final double[] clipRect;
@@ -884,12 +898,23 @@
private final DCurve curve;
CurveClipSplitter(final DRendererContext rdrCtx) {
+ this.rdrCtx = rdrCtx;
this.clipRect = rdrCtx.clipRect;
this.curve = rdrCtx.curve;
}
void init() {
this.init_clipRectPad = true;
+
+ if (DO_CHECK_LENGTH) {
+ this.minLength = (this.rdrCtx.clipInvScale == 0.0d) ? LEN_TH
+ : (LEN_TH * this.rdrCtx.clipInvScale);
+
+ if (MarlinConst.DO_LOG_CLIP) {
+ MarlinUtils.logInfo("CurveClipSplitter.minLength = "
+ + minLength);
+ }
+ }
}
private void initPaddedClip() {
@@ -906,7 +931,7 @@
if (TRACE) {
MarlinUtils.logInfo("clip: X [" + _clipRectPad[2] + " .. " + _clipRectPad[3] +"] "
- + "Y ["+ _clipRectPad[0] + " .. " + _clipRectPad[1] +"]");
+ + "Y [" + _clipRectPad[0] + " .. " + _clipRectPad[1] +"]");
}
}
@@ -919,7 +944,7 @@
MarlinUtils.logInfo("divLine P0(" + x0 + ", " + y0 + ") P1(" + x1 + ", " + y1 + ")");
}
- if (DO_CHECK_LENGTH && DHelpers.fastLineLen(x0, y0, x1, y1) <= LEN_TH) {
+ if (DO_CHECK_LENGTH && DHelpers.fastLineLen(x0, y0, x1, y1) <= minLength) {
return false;
}
@@ -940,7 +965,7 @@
MarlinUtils.logInfo("divQuad P0(" + x0 + ", " + y0 + ") P1(" + x1 + ", " + y1 + ") P2(" + x2 + ", " + y2 + ")");
}
- if (DO_CHECK_LENGTH && DHelpers.fastQuadLen(x0, y0, x1, y1, x2, y2) <= LEN_TH) {
+ if (DO_CHECK_LENGTH && DHelpers.fastQuadLen(x0, y0, x1, y1, x2, y2) <= minLength) {
return false;
}
@@ -963,7 +988,7 @@
MarlinUtils.logInfo("divCurve P0(" + x0 + ", " + y0 + ") P1(" + x1 + ", " + y1 + ") P2(" + x2 + ", " + y2 + ") P3(" + x3 + ", " + y3 + ")");
}
- if (DO_CHECK_LENGTH && DHelpers.fastCurvelen(x0, y0, x1, y1, x2, y2, x3, y3) <= LEN_TH) {
+ if (DO_CHECK_LENGTH && DHelpers.fastCurvelen(x0, y0, x1, y1, x2, y2, x3, y3) <= minLength) {
return false;
}
@@ -991,8 +1016,8 @@
outCodeOR, clipRectPad);
if (TRACE) {
- MarlinUtils.logInfo("nSplits: "+ nSplits);
- MarlinUtils.logInfo("subTs: "+Arrays.toString(Arrays.copyOfRange(subTs, 0, nSplits)));
+ MarlinUtils.logInfo("nSplits: " + nSplits);
+ MarlinUtils.logInfo("subTs: " + Arrays.toString(Arrays.copyOfRange(subTs, 0, nSplits)));
}
if (nSplits == 0) {
// only curve support shortcut
@@ -1010,7 +1035,7 @@
for (int i = 0, off = 0; i <= nSplits; i++, off += type) {
if (TRACE) {
- MarlinUtils.logInfo("Part Curve "+Arrays.toString(Arrays.copyOfRange(mid, off, off + type)));
+ MarlinUtils.logInfo("Part Curve " + Arrays.toString(Arrays.copyOfRange(mid, off, off + type)));
}
emitCurrent(type, mid, off, out);
}
--- a/src/java.desktop/share/classes/sun/java2d/marlin/MarlinConst.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/java2d/marlin/MarlinConst.java Thu Sep 27 10:49:10 2018 -0700
@@ -82,11 +82,11 @@
static final boolean DO_CLIP_SUBDIVIDER = MarlinProperties.isDoClipSubdivider();
- // flag to enable logs related bounds checks
+ // flag to enable logs related to bounds checks
static final boolean DO_LOG_BOUNDS = ENABLE_LOGS && false;
- // flag to enable float precision correction
- static final boolean DO_FIX_FLOAT_PREC = true;
+ // flag to enable logs related to clip rect
+ static final boolean DO_LOG_CLIP = ENABLE_LOGS && false;
// Initial Array sizing (initial context capacity) ~ 450K
--- a/src/java.desktop/share/classes/sun/java2d/marlin/MarlinRenderingEngine.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/java2d/marlin/MarlinRenderingEngine.java Thu Sep 27 10:49:10 2018 -0700
@@ -31,6 +31,7 @@
import java.awt.geom.Path2D;
import java.awt.geom.PathIterator;
import java.security.AccessController;
+import java.util.Arrays;
import static sun.java2d.marlin.MarlinUtils.logInfo;
import sun.awt.geom.PathConsumer2D;
import sun.java2d.ReentrantContextProvider;
@@ -333,7 +334,6 @@
int dashLen = -1;
boolean recycleDashes = false;
- float scale = 1.0f;
if (at != null && !at.isIdentity()) {
final double a = at.getScaleX();
@@ -366,7 +366,7 @@
// a*b == -c*d && a*a+c*c == b*b+d*d. In the actual check below, we
// leave a bit of room for error.
if (nearZero(a*b + c*d) && nearZero(a*a + c*c - (b*b + d*d))) {
- scale = (float) Math.sqrt(a*a + c*c);
+ final float scale = (float) Math.sqrt(a*a + c*c);
if (dashes != null) {
recycleDashes = true;
@@ -421,7 +421,7 @@
pc2d = transformerPC2D.deltaTransformConsumer(pc2d, strokerat);
// stroker will adjust the clip rectangle (width / miter limit):
- pc2d = rdrCtx.stroker.init(pc2d, width, caps, join, miterlimit, scale,
+ pc2d = rdrCtx.stroker.init(pc2d, width, caps, join, miterlimit,
(dashes == null));
// Curve Monotizer:
@@ -831,10 +831,26 @@
// Define the initial clip bounds:
final float[] clipRect = rdrCtx.clipRect;
- clipRect[0] = clip.getLoY();
- clipRect[1] = clip.getLoY() + clip.getHeight();
- clipRect[2] = clip.getLoX();
- clipRect[3] = clip.getLoX() + clip.getWidth();
+ // Adjust the clipping rectangle with the renderer offsets
+ final float rdrOffX = Renderer.RDR_OFFSET_X;
+ final float rdrOffY = Renderer.RDR_OFFSET_Y;
+
+ // add a small rounding error:
+ final float margin = 1e-3f;
+
+ clipRect[0] = clip.getLoY()
+ - margin + rdrOffY;
+ clipRect[1] = clip.getLoY() + clip.getHeight()
+ + margin + rdrOffY;
+ clipRect[2] = clip.getLoX()
+ - margin + rdrOffX;
+ clipRect[3] = clip.getLoX() + clip.getWidth()
+ + margin + rdrOffX;
+
+ if (MarlinConst.DO_LOG_CLIP) {
+ MarlinUtils.logInfo("clipRect (clip): "
+ + Arrays.toString(rdrCtx.clipRect));
+ }
// Enable clipping:
rdrCtx.doClip = true;
--- a/src/java.desktop/share/classes/sun/java2d/marlin/RendererContext.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/java2d/marlin/RendererContext.java Thu Sep 27 10:49:10 2018 -0700
@@ -85,6 +85,8 @@
boolean closedPath = false;
// clip rectangle (ymin, ymax, xmin, xmax):
final float[] clipRect = new float[4];
+ // clip inverse scale (mean) to adjust length checks
+ float clipInvScale = 0.0f;
// CurveBasicMonotonizer instance
final CurveBasicMonotonizer monotonizer;
// CurveClipSplitter instance
@@ -159,6 +161,7 @@
stroking = 0;
doClip = false;
closedPath = false;
+ clipInvScale = 0.0f;
// if context is maked as DIRTY:
if (dirty) {
--- a/src/java.desktop/share/classes/sun/java2d/marlin/Stroker.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/java2d/marlin/Stroker.java Thu Sep 27 10:49:10 2018 -0700
@@ -141,7 +141,6 @@
* <code>JOIN_MITER</code>, <code>JOIN_ROUND</code> or
* <code>JOIN_BEVEL</code>.
* @param miterLimit the desired miter limit
- * @param scale scaling factor applied to clip boundaries
* @param subdivideCurves true to indicate to subdivide curves, false if dasher does
* @return this instance
*/
@@ -150,7 +149,6 @@
final int capStyle,
final int joinStyle,
final float miterLimit,
- final float scale,
final boolean subdivideCurves)
{
this.out = pc2d;
@@ -171,7 +169,6 @@
if (rdrCtx.doClip) {
// Adjust the clipping rectangle with the stroker margin (miter limit, width)
- float rdrOffX = 0.0f, rdrOffY = 0.0f;
float margin = lineWidth2;
if (capStyle == CAP_SQUARE) {
@@ -180,23 +177,21 @@
if ((joinStyle == JOIN_MITER) && (margin < limit)) {
margin = limit;
}
- if (scale != 1.0f) {
- margin *= scale;
- rdrOffX = scale * Renderer.RDR_OFFSET_X;
- rdrOffY = scale * Renderer.RDR_OFFSET_Y;
- }
- // add a small rounding error:
- margin += 1e-3f;
// bounds as half-open intervals: minX <= x < maxX and minY <= y < maxY
// adjust clip rectangle (ymin, ymax, xmin, xmax):
final float[] _clipRect = rdrCtx.clipRect;
- _clipRect[0] -= margin - rdrOffY;
- _clipRect[1] += margin + rdrOffY;
- _clipRect[2] -= margin - rdrOffX;
- _clipRect[3] += margin + rdrOffX;
+ _clipRect[0] -= margin;
+ _clipRect[1] += margin;
+ _clipRect[2] -= margin;
+ _clipRect[3] += margin;
this.clipRect = _clipRect;
+ if (MarlinConst.DO_LOG_CLIP) {
+ MarlinUtils.logInfo("clipRect (stroker): "
+ + Arrays.toString(rdrCtx.clipRect));
+ }
+
// initialize curve splitter here for stroker & dasher:
if (DO_CLIP_SUBDIVIDER) {
subdivide = subdivideCurves;
@@ -306,13 +301,9 @@
// If it is >=0, we know that abs(ext) is <= 90 degrees, so we only
// need 1 curve to approximate the circle section that joins omx,omy
// and mx,my.
- final int numCurves = (cosext >= 0.0f) ? 1 : 2;
-
- switch (numCurves) {
- case 1:
+ if (cosext >= 0.0f) {
drawBezApproxForArc(cx, cy, omx, omy, mx, my, rev);
- break;
- case 2:
+ } else {
// we need to split the arc into 2 arcs spanning the same angle.
// The point we want will be one of the 2 intersections of the
// perpendicular bisector of the chord (omx,omy)->(mx,my) and the
@@ -341,8 +332,6 @@
}
drawBezApproxForArc(cx, cy, omx, omy, mmx, mmy, rev);
drawBezApproxForArc(cx, cy, mmx, mmy, mx, my, rev);
- break;
- default:
}
}
--- a/src/java.desktop/share/classes/sun/java2d/marlin/TransformingPathConsumer2D.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/java2d/marlin/TransformingPathConsumer2D.java Thu Sep 27 10:49:10 2018 -0700
@@ -120,44 +120,56 @@
// Scale only
if (rdrCtx.doClip) {
// adjust clip rectangle (ymin, ymax, xmin, xmax):
- adjustClipScale(rdrCtx.clipRect, mxx, myy);
+ rdrCtx.clipInvScale = adjustClipScale(rdrCtx.clipRect,
+ mxx, myy);
}
return dt_DeltaScaleFilter.init(out, mxx, myy);
}
} else {
if (rdrCtx.doClip) {
// adjust clip rectangle (ymin, ymax, xmin, xmax):
- adjustClipInverseDelta(rdrCtx.clipRect, mxx, mxy, myx, myy);
+ rdrCtx.clipInvScale = adjustClipInverseDelta(rdrCtx.clipRect,
+ mxx, mxy, myx, myy);
}
return dt_DeltaTransformFilter.init(out, mxx, mxy, myx, myy);
}
}
- private static void adjustClipOffset(final float[] clipRect) {
- clipRect[0] += Renderer.RDR_OFFSET_Y;
- clipRect[1] += Renderer.RDR_OFFSET_Y;
- clipRect[2] += Renderer.RDR_OFFSET_X;
- clipRect[3] += Renderer.RDR_OFFSET_X;
+ private static float adjustClipScale(final float[] clipRect,
+ final float mxx, final float myy)
+ {
+ // Adjust the clipping rectangle (iv_DeltaScaleFilter):
+ final float scaleY = 1.0f / myy;
+ clipRect[0] *= scaleY;
+ clipRect[1] *= scaleY;
+
+ if (clipRect[1] < clipRect[0]) {
+ float tmp = clipRect[0];
+ clipRect[0] = clipRect[1];
+ clipRect[1] = tmp;
+ }
+
+ final float scaleX = 1.0f / mxx;
+ clipRect[2] *= scaleX;
+ clipRect[3] *= scaleX;
+
+ if (clipRect[3] < clipRect[2]) {
+ float tmp = clipRect[2];
+ clipRect[2] = clipRect[3];
+ clipRect[3] = tmp;
+ }
+
+ if (MarlinConst.DO_LOG_CLIP) {
+ MarlinUtils.logInfo("clipRect (ClipScale): "
+ + Arrays.toString(clipRect));
+ }
+ return 0.5f * (Math.abs(scaleX) + Math.abs(scaleY));
}
- private static void adjustClipScale(final float[] clipRect,
- final float mxx, final float myy)
+ private static float adjustClipInverseDelta(final float[] clipRect,
+ final float mxx, final float mxy,
+ final float myx, final float myy)
{
- adjustClipOffset(clipRect);
-
- // Adjust the clipping rectangle (iv_DeltaScaleFilter):
- clipRect[0] /= myy;
- clipRect[1] /= myy;
- clipRect[2] /= mxx;
- clipRect[3] /= mxx;
- }
-
- private static void adjustClipInverseDelta(final float[] clipRect,
- final float mxx, final float mxy,
- final float myx, final float myy)
- {
- adjustClipOffset(clipRect);
-
// Adjust the clipping rectangle (iv_DeltaTransformFilter):
final float det = mxx * myy - mxy * myx;
final float imxx = myy / det;
@@ -199,6 +211,16 @@
clipRect[1] = ymax;
clipRect[2] = xmin;
clipRect[3] = xmax;
+
+ if (MarlinConst.DO_LOG_CLIP) {
+ MarlinUtils.logInfo("clipRect (ClipInverseDelta): "
+ + Arrays.toString(clipRect));
+ }
+
+ final float scaleX = (float) Math.sqrt(imxx * imxx + imxy * imxy);
+ final float scaleY = (float) Math.sqrt(imyx * imyx + imyy * imyy);
+
+ return 0.5f * (scaleX + scaleY);
}
PathConsumer2D inverseDeltaTransformConsumer(PathConsumer2D out,
@@ -216,7 +238,7 @@
if (mxx == 1.0f && myy == 1.0f) {
return out;
} else {
- return iv_DeltaScaleFilter.init(out, 1.0f/mxx, 1.0f/myy);
+ return iv_DeltaScaleFilter.init(out, 1.0f / mxx, 1.0f / myy);
}
} else {
final float det = mxx * myy - mxy * myx;
@@ -533,19 +555,6 @@
PathClipFilter init(final PathConsumer2D out) {
this.out = out;
- // Adjust the clipping rectangle with the renderer offsets
- final float rdrOffX = Renderer.RDR_OFFSET_X;
- final float rdrOffY = Renderer.RDR_OFFSET_Y;
-
- // add a small rounding error:
- final float margin = 1e-3f;
-
- final float[] _clipRect = this.clipRect;
- _clipRect[0] -= margin - rdrOffY;
- _clipRect[1] += margin + rdrOffY;
- _clipRect[2] -= margin - rdrOffX;
- _clipRect[3] += margin + rdrOffX;
-
if (MarlinConst.DO_CLIP_SUBDIVIDER) {
// adjust padded clip rectangle:
curveSplitter.init();
@@ -868,6 +877,11 @@
private static final int MAX_N_CURVES = 3 * 4;
+ private final RendererContext rdrCtx;
+
+ // scaled length threshold:
+ private float minLength;
+
// clip rectangle (ymin, ymax, xmin, xmax):
final float[] clipRect;
@@ -885,12 +899,23 @@
private final Curve curve;
CurveClipSplitter(final RendererContext rdrCtx) {
+ this.rdrCtx = rdrCtx;
this.clipRect = rdrCtx.clipRect;
this.curve = rdrCtx.curve;
}
void init() {
this.init_clipRectPad = true;
+
+ if (DO_CHECK_LENGTH) {
+ this.minLength = (this.rdrCtx.clipInvScale == 0.0f) ? LEN_TH
+ : (LEN_TH * this.rdrCtx.clipInvScale);
+
+ if (MarlinConst.DO_LOG_CLIP) {
+ MarlinUtils.logInfo("CurveClipSplitter.minLength = "
+ + minLength);
+ }
+ }
}
private void initPaddedClip() {
@@ -907,7 +932,7 @@
if (TRACE) {
MarlinUtils.logInfo("clip: X [" + _clipRectPad[2] + " .. " + _clipRectPad[3] +"] "
- + "Y ["+ _clipRectPad[0] + " .. " + _clipRectPad[1] +"]");
+ + "Y [" + _clipRectPad[0] + " .. " + _clipRectPad[1] +"]");
}
}
@@ -920,7 +945,7 @@
MarlinUtils.logInfo("divLine P0(" + x0 + ", " + y0 + ") P1(" + x1 + ", " + y1 + ")");
}
- if (DO_CHECK_LENGTH && Helpers.fastLineLen(x0, y0, x1, y1) <= LEN_TH) {
+ if (DO_CHECK_LENGTH && Helpers.fastLineLen(x0, y0, x1, y1) <= minLength) {
return false;
}
@@ -941,7 +966,7 @@
MarlinUtils.logInfo("divQuad P0(" + x0 + ", " + y0 + ") P1(" + x1 + ", " + y1 + ") P2(" + x2 + ", " + y2 + ")");
}
- if (DO_CHECK_LENGTH && Helpers.fastQuadLen(x0, y0, x1, y1, x2, y2) <= LEN_TH) {
+ if (DO_CHECK_LENGTH && Helpers.fastQuadLen(x0, y0, x1, y1, x2, y2) <= minLength) {
return false;
}
@@ -964,7 +989,7 @@
MarlinUtils.logInfo("divCurve P0(" + x0 + ", " + y0 + ") P1(" + x1 + ", " + y1 + ") P2(" + x2 + ", " + y2 + ") P3(" + x3 + ", " + y3 + ")");
}
- if (DO_CHECK_LENGTH && Helpers.fastCurvelen(x0, y0, x1, y1, x2, y2, x3, y3) <= LEN_TH) {
+ if (DO_CHECK_LENGTH && Helpers.fastCurvelen(x0, y0, x1, y1, x2, y2, x3, y3) <= minLength) {
return false;
}
@@ -992,8 +1017,8 @@
outCodeOR, clipRectPad);
if (TRACE) {
- MarlinUtils.logInfo("nSplits: "+ nSplits);
- MarlinUtils.logInfo("subTs: "+Arrays.toString(Arrays.copyOfRange(subTs, 0, nSplits)));
+ MarlinUtils.logInfo("nSplits: " + nSplits);
+ MarlinUtils.logInfo("subTs: " + Arrays.toString(Arrays.copyOfRange(subTs, 0, nSplits)));
}
if (nSplits == 0) {
// only curve support shortcut
@@ -1011,7 +1036,7 @@
for (int i = 0, off = 0; i <= nSplits; i++, off += type) {
if (TRACE) {
- MarlinUtils.logInfo("Part Curve "+Arrays.toString(Arrays.copyOfRange(mid, off, off + type)));
+ MarlinUtils.logInfo("Part Curve " + Arrays.toString(Arrays.copyOfRange(mid, off, off + type)));
}
emitCurrent(type, mid, off, out);
}
--- a/src/java.desktop/share/classes/sun/java2d/marlin/Version.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/java2d/marlin/Version.java Thu Sep 27 10:49:10 2018 -0700
@@ -27,7 +27,7 @@
public final class Version {
- private static final String VERSION = "marlin-0.9.1-Unsafe-OpenJDK";
+ private static final String VERSION = "marlin-0.9.1.1-Unsafe-OpenJDK";
public static String getVersion() {
return VERSION;
--- a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java Thu Sep 27 10:49:10 2018 -0700
@@ -895,17 +895,16 @@
}
protected PageFormat getPageFormatFromAttributes() {
- if (attributes == null || attributes.isEmpty()) {
+ Pageable pageable = null;
+ if (attributes == null || attributes.isEmpty() ||
+ !((pageable = getPageable()) instanceof OpenBook)) {
return null;
}
PageFormat newPf = attributeToPageFormat(
getPrintService(), attributes);
PageFormat oldPf = null;
- Pageable pageable = getPageable();
- if ((pageable != null) &&
- (pageable instanceof OpenBook) &&
- ((oldPf = pageable.getPageFormat(0)) != null)) {
+ if ((oldPf = pageable.getPageFormat(0)) != null) {
// If orientation, media, imageable area attributes are not in
// "attributes" set, then use respective values of the existing
// page format "oldPf".
--- a/src/java.desktop/share/native/libfontmanager/freetypeScaler.c Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/share/native/libfontmanager/freetypeScaler.c Thu Sep 27 10:49:10 2018 -0700
@@ -679,7 +679,6 @@
int error, imageSize;
UInt16 width, height;
GlyphInfo *glyphInfo;
- int glyph_index;
int renderFlags = FT_LOAD_RENDER, target;
FT_GlyphSlot ftglyph;
@@ -720,8 +719,6 @@
}
renderFlags |= target;
- glyph_index = FT_Get_Char_Index(scalerInfo->face, glyphCode);
-
error = FT_Load_Glyph(scalerInfo->face, glyphCode, renderFlags);
if (error) {
//do not destroy scaler yet.
@@ -958,7 +955,6 @@
FTScalerContext *context, FTScalerInfo* scalerInfo,
jint glyphCode, jfloat xpos, jfloat ypos) {
int renderFlags;
- int glyph_index;
FT_Error error;
FT_GlyphSlot ftglyph;
@@ -974,8 +970,6 @@
renderFlags = FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP;
- glyph_index = FT_Get_Char_Index(scalerInfo->face, glyphCode);
-
error = FT_Load_Glyph(scalerInfo->face, glyphCode, renderFlags);
if (error) {
return NULL;
--- a/src/java.desktop/unix/classes/sun/awt/X11/XIconWindow.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/unix/classes/sun/awt/X11/XIconWindow.java Thu Sep 27 10:49:10 2018 -0700
@@ -281,8 +281,9 @@
ColorData cdata = adata.get_color_data(0);
int num_colors = cdata.get_awt_numICMcolors();
for (int i = 0; i < buf.length; i++) {
- buf[i] = (buf[i] >= num_colors) ?
- 0 : cdata.get_awt_icmLUT2Colors(buf[i]);
+ int b = Byte.toUnsignedInt(buf[i]);
+ buf[i] = (b >= num_colors) ?
+ 0 : cdata.get_awt_icmLUT2Colors(b);
}
bytes = Native.toData(buf);
} else if (srcBuf instanceof DataBufferInt) {
--- a/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2018, 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
@@ -215,6 +215,12 @@
static long awt_defaultFg; // Pixel
private static XMouseInfoPeer xPeer;
+ /**
+ * Should we check "_NET_WM_STRUT/_NET_WM_STRUT_PARTIAL" during insets
+ * calculation.
+ */
+ private static Boolean checkSTRUT;
+
static {
initSecurityWarning();
if (GraphicsEnvironment.isHeadless()) {
@@ -826,13 +832,26 @@
}
/*
- * If we're running in non-Xinerama environment and the current
- * window manager supports _NET protocol then the screen insets
- * are calculated using _NET_WM_WORKAREA property of the root
- * window.
- * Otherwise, i. e. if Xinerama is on or _NET_WM_WORKAREA is
- * not set, we try to calculate the insets ourselves using
- * getScreenInsetsManually method.
+ * If the current window manager supports _NET protocol then the screen
+ * insets are calculated using _NET_WORKAREA property of the root window.
+ * <p>
+ * Note that _NET_WORKAREA is a rectangular area and it does not work
+ * well in the Xinerama mode.
+ * <p>
+ * We will trust the part of this rectangular area only if it starts at the
+ * requested graphics configuration. Below is an example when the
+ * _NET_WORKAREA intersects with the requested graphics configuration but
+ * produces wrong result.
+ *
+ * //<-x1,y1///////
+ * // // ////////////////
+ * // SCREEN1 // // SCREEN2 //
+ * // ********** // // x2,y2->//
+ * //////////////// // //
+ * ////////////////
+ *
+ * When two screens overlap and the first contains a dock(*****), then
+ * _NET_WORKAREA may start at point x1,y1 and end at point x2,y2.
*/
@Override
public Insets getScreenInsets(GraphicsConfiguration gc)
@@ -846,30 +865,33 @@
XToolkit.awtLock();
try
{
- X11GraphicsConfig x11gc = (X11GraphicsConfig)gc;
- X11GraphicsDevice x11gd = x11gc.getDevice();
- long root = XlibUtil.getRootWindow(x11gd.getScreen());
+ X11GraphicsEnvironment x11ge = (X11GraphicsEnvironment)
+ GraphicsEnvironment.getLocalGraphicsEnvironment();
+ X11GraphicsConfig x11gc = (X11GraphicsConfig) gc;
+ long root = XlibUtil.getRootWindow(x11gc.getDevice().getScreen());
int scale = x11gc.getScale();
- Rectangle rootBounds = XlibUtil.getWindowGeometry(root, scale);
-
- X11GraphicsEnvironment x11ge = (X11GraphicsEnvironment)
- GraphicsEnvironment.getLocalGraphicsEnvironment();
- if (!x11ge.runningXinerama())
- {
- Insets screenInsets = getInsets(root, rootBounds, scale);
- if (screenInsets != null) return screenInsets;
+ if (x11ge.runningXinerama() && checkSTRUT()) {
+ // implementation based on _NET_WM_STRUT/_NET_WM_STRUT_PARTIAL
+ Rectangle rootBounds = XlibUtil.getWindowGeometry(root, scale);
+ Insets insets = getScreenInsetsManually(root, rootBounds,
+ gc.getBounds(), scale);
+ if ((insets.left | insets.top | insets.bottom | insets.right) != 0
+ || rootBounds == null) {
+ return insets;
+ }
}
-
- Insets insets = getScreenInsetsManually(root, rootBounds,
- gc.getBounds(), scale);
- if ((insets.left | insets.top | insets.bottom | insets.right) == 0
- && rootBounds != null ) {
- root = XlibWrapper.RootWindow(XToolkit.getDisplay(),
- x11gd.getScreen());
- Insets screenInsets = getInsets(root, rootBounds, scale);
- if (screenInsets != null) return screenInsets;
+ Rectangle workArea = XToolkit.getWorkArea(root, scale);
+ Rectangle screen = gc.getBounds();
+ if (workArea != null && screen.contains(workArea.getLocation())) {
+ workArea = workArea.intersection(screen);
+ int top = workArea.y - screen.y;
+ int left = workArea.x - screen.x;
+ int bottom = screen.height - workArea.height - top;
+ int right = screen.width - workArea.width - left;
+ return new Insets(top, left, bottom, right);
}
- return insets;
+ // Note that it is better to return zeros than inadequate values
+ return new Insets(0, 0, 0, 0);
}
finally
{
@@ -877,14 +899,16 @@
}
}
- private Insets getInsets(long root, Rectangle rootBounds, int scale) {
- Rectangle workArea = XToolkit.getWorkArea(root, scale);
- if (workArea == null) {
- return null;
+ /**
+ * Returns the value of "sun.awt.X11.checkSTRUT" property. Default value is
+ * {@code false}.
+ */
+ private static boolean checkSTRUT() {
+ if (checkSTRUT == null) {
+ checkSTRUT = AccessController.doPrivileged(
+ new GetBooleanAction("sun.awt.X11.checkSTRUT"));
}
- return new Insets(workArea.y, workArea.x,
- rootBounds.height - workArea.height - workArea.y,
- rootBounds.width - workArea.width - workArea.x);
+ return checkSTRUT;
}
/*
@@ -893,6 +917,14 @@
* hints' values to screen insets.
*
* This method should be called under XToolkit.awtLock()
+ *
+ * This method is unused by default because of two reasons:
+ * - Iteration over windows may be extremely slow, and execution of
+ * getScreenInsets() can be x100 slower than in one monitor config.
+ * - _NET_WM_STRUT/_NET_WM_STRUT_PARTIAL are hints for the applications.
+ * WM should take into account these hints when "_NET_WORKAREA" is
+ * calculated, but the system panels do not necessarily contain these
+ * hints(Gnome 3 for example).
*/
private Insets getScreenInsetsManually(long root, Rectangle rootBounds,
Rectangle screenBounds, int scale)
--- a/src/java.desktop/unix/legal/xwindows.md Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/unix/legal/xwindows.md Thu Sep 27 10:49:10 2018 -0700
@@ -125,61 +125,6 @@
_____________________________
-Copyright notice for HPkeysym.h:
-/*
-
-Copyright 1987, 1998 The Open Group
-
-All Rights Reserved.
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall
-not be used in advertising or otherwise to promote the sale, use or
-other dealings in this Software without prior written authorization
-from The Open Group.
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
-
-All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the names of Hewlett Packard
-or Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD
-TO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. Hewlett-Packard shall not be liable for errors
-contained herein or direct, indirect, special, incidental or
-consequential damages in connection with the furnishing,
-performance, or use of this material.
-
-*/
-_____________________________________
-
Copyright notice in keysym2ucs.h:
Copyright 1987, 1994, 1998 The Open Group
--- a/src/java.desktop/unix/native/libawt_xawt/awt/HPkeysym.h Thu Sep 27 08:49:12 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,165 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/* $Xorg: HPkeysym.h,v 1.4 2000/08/18 04:05:43 coskrey Exp $ */
-/*
-
-Copyright 1987, 1998 The Open Group
-
-All Rights Reserved.
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall
-not be used in advertising or otherwise to promote the sale, use or
-other dealings in this Software without prior written authorization
-from The Open Group.
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the names of Hewlett Packard
-or Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD
-TO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. Hewlett-Packard shall not be liable for errors
-contained herein or direct, indirect, special, incidental or
-consequential damages in connection with the furnishing,
-performance, or use of this material.
-
-*/
-
-#ifndef _HPKEYSYM_H
-
-#define _HPKEYSYM_H
-
-#define hpXK_ClearLine 0x1000FF6F
-#define hpXK_InsertLine 0x1000FF70
-#define hpXK_DeleteLine 0x1000FF71
-#define hpXK_InsertChar 0x1000FF72
-#define hpXK_DeleteChar 0x1000FF73
-#define hpXK_BackTab 0x1000FF74
-#define hpXK_KP_BackTab 0x1000FF75
-#define hpXK_Modelock1 0x1000FF48
-#define hpXK_Modelock2 0x1000FF49
-#define hpXK_Reset 0x1000FF6C
-#define hpXK_System 0x1000FF6D
-#define hpXK_User 0x1000FF6E
-#define hpXK_mute_acute 0x100000A8
-#define hpXK_mute_grave 0x100000A9
-#define hpXK_mute_asciicircum 0x100000AA
-#define hpXK_mute_diaeresis 0x100000AB
-#define hpXK_mute_asciitilde 0x100000AC
-#define hpXK_lira 0x100000AF
-#define hpXK_guilder 0x100000BE
-#define hpXK_Ydiaeresis 0x100000EE
-#define hpXK_IO 0x100000EE
-#define hpXK_longminus 0x100000F6
-#define hpXK_block 0x100000FC
-
-
-#ifndef _OSF_Keysyms
-#define _OSF_Keysyms
-
-#define osfXK_Copy 0x1004FF02
-#define osfXK_Cut 0x1004FF03
-#define osfXK_Paste 0x1004FF04
-#define osfXK_BackTab 0x1004FF07
-#define osfXK_BackSpace 0x1004FF08
-#define osfXK_Clear 0x1004FF0B
-#define osfXK_Escape 0x1004FF1B
-#define osfXK_AddMode 0x1004FF31
-#define osfXK_PrimaryPaste 0x1004FF32
-#define osfXK_QuickPaste 0x1004FF33
-#define osfXK_PageLeft 0x1004FF40
-#define osfXK_PageUp 0x1004FF41
-#define osfXK_PageDown 0x1004FF42
-#define osfXK_PageRight 0x1004FF43
-#define osfXK_Activate 0x1004FF44
-#define osfXK_MenuBar 0x1004FF45
-#define osfXK_Left 0x1004FF51
-#define osfXK_Up 0x1004FF52
-#define osfXK_Right 0x1004FF53
-#define osfXK_Down 0x1004FF54
-#define osfXK_EndLine 0x1004FF57
-#define osfXK_BeginLine 0x1004FF58
-#define osfXK_EndData 0x1004FF59
-#define osfXK_BeginData 0x1004FF5A
-#define osfXK_PrevMenu 0x1004FF5B
-#define osfXK_NextMenu 0x1004FF5C
-#define osfXK_PrevField 0x1004FF5D
-#define osfXK_NextField 0x1004FF5E
-#define osfXK_Select 0x1004FF60
-#define osfXK_Insert 0x1004FF63
-#define osfXK_Undo 0x1004FF65
-#define osfXK_Menu 0x1004FF67
-#define osfXK_Cancel 0x1004FF69
-#define osfXK_Help 0x1004FF6A
-#define osfXK_SelectAll 0x1004FF71
-#define osfXK_DeselectAll 0x1004FF72
-#define osfXK_Reselect 0x1004FF73
-#define osfXK_Extend 0x1004FF74
-#define osfXK_Restore 0x1004FF78
-#define osfXK_Delete 0x1004FFFF
-
-#endif /* _OSF_Keysyms */
-
-
-/**************************************************************
- * The use of the following macros is deprecated.
- * They are listed below only for backwards compatibility.
- */
-#define XK_Reset 0x1000FF6C
-#define XK_System 0x1000FF6D
-#define XK_User 0x1000FF6E
-#define XK_ClearLine 0x1000FF6F
-#define XK_InsertLine 0x1000FF70
-#define XK_DeleteLine 0x1000FF71
-#define XK_InsertChar 0x1000FF72
-#define XK_DeleteChar 0x1000FF73
-#define XK_BackTab 0x1000FF74
-#define XK_KP_BackTab 0x1000FF75
-#define XK_Ext16bit_L 0x1000FF76
-#define XK_Ext16bit_R 0x1000FF77
-#define XK_mute_acute 0x100000a8
-#define XK_mute_grave 0x100000a9
-#define XK_mute_asciicircum 0x100000aa
-#define XK_mute_diaeresis 0x100000ab
-#define XK_mute_asciitilde 0x100000ac
-#define XK_lira 0x100000af
-#define XK_guilder 0x100000be
-#ifndef XK_Ydiaeresis
-#define XK_Ydiaeresis 0x100000ee
-#endif
-#define XK_IO 0x100000ee
-#define XK_longminus 0x100000f6
-#define XK_block 0x100000fc
-
-#endif /* _HPKEYSYM_H */
--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XWindow.c Thu Sep 27 08:49:12 2018 -0700
+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XWindow.c Thu Sep 27 10:49:10 2018 -0700
@@ -54,17 +54,12 @@
#include <X11/Sunkeysym.h> /* Sun vendor-specific */
#include <X11/ap_keysym.h> /* Apollo (HP) vendor-specific */
/*
- * #include <X11/HPkeysym.h> HP vendor-specific
- * I checked HPkeysym.h into the workspace because although
- * I think it will ship with X11R6.4.2 (and later) on Linux,
- * it doesn't seem to be in Solaris 9 Update 2.
- *
- * This is done not only for the hp keysyms, but also to
+ * HPKeysym.h is used not only for the hp keysyms, but also to
* give us the osf keysyms that are also defined in HPkeysym.h.
* However, HPkeysym.h is missing a couple of osf keysyms,
* so I have #defined them below.
*/
-#include "HPkeysym.h" /* HP vendor-specific */
+#include <X11/HPkeysym.h> /* HP vendor-specific */
#include "java_awt_event_KeyEvent.h"
#include "java_awt_event_InputEvent.h"
--- a/test/jdk/ProblemList.txt Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/ProblemList.txt Thu Sep 27 10:49:10 2018 -0700
@@ -128,7 +128,6 @@
java/awt/FileDialog/8003399/bug8003399.java 8198334 windows-all
java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion.java 8060176 windows-all,macosx-all
java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_1.java 8060176 windows-all,macosx-all
-java/awt/dnd/BadSerializaionTest/BadSerializationTest.java 8039082 generic-all
java/awt/dnd/MissingEventsOnModalDialog/MissingEventsOnModalDialogTest.java 8164464 linux-all,macosx-all
java/awt/dnd/URIListBetweenJVMsTest/URIListBetweenJVMsTest.html 8171510 macosx-all
javax/swing/dnd/7171812/bug7171812.java 8041447 macosx-all
@@ -687,7 +686,6 @@
javax/sound/sampled/DirectAudio/bug6372428.java 8055097 generic-all
javax/sound/sampled/Clip/bug5070081.java 8055097 generic-all
javax/sound/sampled/DataLine/LongFramePosition.java 8055097 generic-all
-javax/sound/sampled/Clip/AutoCloseTimeCheck.java 8207150 generic-all
javax/sound/sampled/Clip/Drain/ClipDrain.java 7062792 generic-all
--- a/test/jdk/TEST.ROOT Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/TEST.ROOT Thu Sep 27 10:49:10 2018 -0700
@@ -19,7 +19,7 @@
# Tests that must run in othervm mode
othervm.dirs=java/awt java/beans javax/accessibility javax/imageio javax/sound javax/swing javax/print \
com/apple/laf com/sun/java/accessibility com/sun/java/swing sanity/client demo/jfc \
-javax/management com/sun/awt sun/awt sun/java2d javax/xml/jaxp/testng/validation java/lang/ProcessHandle
+javax/management sun/awt sun/java2d javax/xml/jaxp/testng/validation java/lang/ProcessHandle
# Tests that cannot run concurrently
exclusiveAccess.dirs=java/rmi/Naming java/util/prefs sun/management/jmxremote sun/tools/jstatd sun/security/mscapi java/util/stream java/util/Arrays/largeMemory java/util/BitSet/stream javax/rmi
--- a/test/jdk/TEST.groups Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/TEST.groups Thu Sep 27 10:49:10 2018 -0700
@@ -351,7 +351,6 @@
jdk_awt = \
java/awt \
- com/sun/awt \
com/apple/eawt \
com/apple/laf \
sun/awt
@@ -489,8 +488,7 @@
:jdk_sound \
:jdk_sctp \
javax/accessibility \
- com/sun/java/swing \
- com/sun/awt
+ com/sun/java/swing
needs_g1gc = \
jdk/jfr/event/gc/refstat/TestRefStatEventWithG1ConcurrentMark.java \
--- a/test/jdk/com/sun/awt/SecurityWarning/CustomSecurityManager.java Thu Sep 27 08:49:12 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-
-import sun.awt.AWTPermissions;
-import java.security.Permission;
-
-public class CustomSecurityManager extends SecurityManager {
- @Override
- public void checkPermission(Permission perm) {
- if (perm.implies(AWTPermissions.TOPLEVEL_WINDOW_PERMISSION)) {
- throw new SecurityException();
- }
- }
-}
--- a/test/jdk/com/sun/awt/SecurityWarning/GetSizeShouldNotReturnZero.java Thu Sep 27 08:49:12 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- @test %W% %E%
- @key headful
- @bug 6818312
- @summary The size returned by SecurityWarning.getSize() should not be zero
- @author anthony.petrov@sun.com: area=awt.toplevel
- @library ../../../../java/awt/regtesthelpers
- @modules java.desktop/com.sun.awt
- java.desktop/sun.awt
- @build Util CustomSecurityManager CopyClassFile
- @run main CopyClassFile CustomSecurityManager bootcp/
- @run main/othervm/secure=CustomSecurityManager -Xbootclasspath/a:bootcp GetSizeShouldNotReturnZero
-*/
-
-/**
- * GetSizeShouldNotReturnZero.java
- *
- * summary: The size returned by SecurityWarning.getSize() should not be zero
- */
-
-import com.sun.awt.SecurityWarning;
-import test.java.awt.regtesthelpers.Util;
-
-import java.awt.*;
-
-public class GetSizeShouldNotReturnZero
-{
- private static void init()
- {
- Frame f = new Frame();
- f.setSize(100, 100);
- f.setVisible(true);
-
- Robot robot = Util.createRobot();
- Util.waitForIdle(robot);
-
- Dimension size = SecurityWarning.getSize(f);
- if (size.width == 0 || size.height == 0) {
- fail("Reported security warning size: " + size);
- return;
- }
- pass();
- }//End init()
-
-
- /*****************************************************
- * Standard Test Machinery Section
- * DO NOT modify anything in this section -- it's a
- * standard chunk of code which has all of the
- * synchronisation necessary for the test harness.
- * By keeping it the same in all tests, it is easier
- * to read and understand someone else's test, as
- * well as insuring that all tests behave correctly
- * with the test harness.
- * There is a section following this for test-
- * classes
- ******************************************************/
- private static boolean theTestPassed = false;
- private static boolean testGeneratedInterrupt = false;
- private static String failureMessage = "";
-
- private static Thread mainThread = null;
-
- private static int sleepTime = 300000;
-
- // Not sure about what happens if multiple of this test are
- // instantiated in the same VM. Being static (and using
- // static vars), it aint gonna work. Not worrying about
- // it for now.
- public static void main( String args[] ) throws InterruptedException
- {
- mainThread = Thread.currentThread();
- try
- {
- init();
- }
- catch( TestPassedException e )
- {
- //The test passed, so just return from main and harness will
- // interepret this return as a pass
- return;
- }
- //At this point, neither test pass nor test fail has been
- // called -- either would have thrown an exception and ended the
- // test, so we know we have multiple threads.
-
- //Test involves other threads, so sleep and wait for them to
- // called pass() or fail()
- try
- {
- Thread.sleep( sleepTime );
- //Timed out, so fail the test
- throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
- }
- catch (InterruptedException e)
- {
- //The test harness may have interrupted the test. If so, rethrow the exception
- // so that the harness gets it and deals with it.
- if( ! testGeneratedInterrupt ) throw e;
-
- //reset flag in case hit this code more than once for some reason (just safety)
- testGeneratedInterrupt = false;
-
- if ( theTestPassed == false )
- {
- throw new RuntimeException( failureMessage );
- }
- }
-
- }//main
-
- public static synchronized void setTimeoutTo( int seconds )
- {
- sleepTime = seconds * 1000;
- }
-
- public static synchronized void pass()
- {
- System.out.println( "The test passed." );
- System.out.println( "The test is over, hit Ctl-C to stop Java VM" );
- //first check if this is executing in main thread
- if ( mainThread == Thread.currentThread() )
- {
- //Still in the main thread, so set the flag just for kicks,
- // and throw a test passed exception which will be caught
- // and end the test.
- theTestPassed = true;
- throw new TestPassedException();
- }
- theTestPassed = true;
- testGeneratedInterrupt = true;
- mainThread.interrupt();
- }//pass()
-
- public static synchronized void fail()
- {
- //test writer didn't specify why test failed, so give generic
- fail( "it just plain failed! :-)" );
- }
-
- public static synchronized void fail( String whyFailed )
- {
- System.out.println( "The test failed: " + whyFailed );
- System.out.println( "The test is over, hit Ctl-C to stop Java VM" );
- //check if this called from main thread
- if ( mainThread == Thread.currentThread() )
- {
- //If main thread, fail now 'cause not sleeping
- throw new RuntimeException( whyFailed );
- }
- theTestPassed = false;
- testGeneratedInterrupt = true;
- failureMessage = whyFailed;
- mainThread.interrupt();
- }//fail()
-
-}// class GetSizeShouldNotReturnZero
-
-//This exception is used to exit from any level of call nesting
-// when it's determined that the test has passed, and immediately
-// end the test.
-class TestPassedException extends RuntimeException
-{
-}
--- a/test/jdk/com/sun/awt/TEST.properties Thu Sep 27 08:49:12 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-modules=java.desktop
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/Frame/CycleThroughFrameTest/CycleThroughFrameTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ @test
+ @key headful
+ @bug 8206392
+ @requires (os.family == "mac")
+ @summary Cycle through frames using keyboard shortcut doesn't work on Mac
+ @compile CycleThroughFrameTest.java
+ @run main/manual CycleThroughFrameTest
+*/
+
+import java.awt.Frame;
+import java.awt.Button;
+import java.awt.TextArea;
+import java.awt.FlowLayout;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+public class CycleThroughFrameTest {
+
+ public static final int maxFrames = 5;
+ private static JFrame[] frame;
+ private static Frame instructionFrame;
+ private static volatile boolean testContinueFlag = true;
+
+ private static final String TEST_INSTRUCTIONS =
+ " This is a manual test\n\n" +
+ " 1) Configure Keyboard shortcut if not done in your system:\n" +
+ " 2) Open System Preferences, go to -> Keyboard -> Shortcuts -> Keyboard\n" +
+ " 3) Enable 'Move focus to next window' if disabled\n" +
+ " 4) Enable 'Move focus to next window drawer' if disabled\n" +
+ " 5) Close System Preferences\n" +
+ " 5) Press COMMAND + ` keys to cycle through frames in forward order\n" +
+ " 6) Press FAIL if focus doesn't move to next frame\n" +
+ " 7) Press COMMAND + SHIFT + ` to cycle through frames in reverse order\n" +
+ " 8) Press FAIL if focus doesn't move to next frame in reverse order\n" +
+ " 9) Press PASS otherwise";
+
+ private static final String FAIL_MESSAGE = "Focus doesn't move to next frame";
+
+ public void showJFrame(int frameNumber) {
+
+ String title = "Frame " + frameNumber;
+ frame[frameNumber] = new JFrame(title);
+ frame[frameNumber].setSize(300, 200);
+ frame[frameNumber].setLocation(50+(frameNumber*20), 50+(frameNumber*20));
+ frame[frameNumber].setVisible(true);
+ }
+
+ private void createAndShowFrame() throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame = new JFrame[maxFrames];
+ for (int i = 0; i < maxFrames; i++) {
+ showJFrame(i);
+ }
+ }
+ });
+ }
+
+ public void createAndShowInstructionFrame() {
+ Button passButton = new Button("Pass");
+ passButton.setEnabled(true);
+
+ Button failButton = new Button("Fail");
+ failButton.setEnabled(true);
+
+ TextArea instructions = new TextArea(12, 70);
+ instructions.setText(TEST_INSTRUCTIONS);
+
+ instructionFrame = new Frame("Test Instructions");
+ instructionFrame.add(passButton);
+ instructionFrame.add(failButton);
+ instructionFrame.add(instructions);
+ instructionFrame.setSize(200,200);
+ instructionFrame.setLayout(new FlowLayout());
+ instructionFrame.pack();
+ instructionFrame.setVisible(true);
+
+ passButton.addActionListener(ae -> {
+ dispose();
+ testContinueFlag = false;
+ });
+
+ failButton.addActionListener(ae -> {
+ dispose();
+ testContinueFlag = false;
+ throw new RuntimeException(FAIL_MESSAGE);
+ });
+ }
+
+ private static void dispose() {
+ for (int i = 0; i < maxFrames; i++) {
+ frame[i].dispose();
+ }
+ instructionFrame.dispose();
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ CycleThroughFrameTest testObj = new CycleThroughFrameTest();
+ testObj.createAndShowFrame();
+ testObj.createAndShowInstructionFrame();
+
+ final int sleepTime = 300000;
+ final int sleepLoopTime = 1000;
+ int remainingSleepTime = sleepTime;
+ while(remainingSleepTime > 0 && testContinueFlag) {
+ Thread.sleep(sleepLoopTime);
+ remainingSleepTime -= sleepLoopTime;
+ }
+
+ if (testContinueFlag) {
+ dispose();
+ throw new RuntimeException("Timed out after " +
+ (sleepTime - remainingSleepTime) / 1000 + " seconds");
+ }
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/MenuBar/TestNoScreenMenuBar.java Thu Sep 27 10:49:10 2018 -0700
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+
+/**
+ * @test
+ * @key headful
+ * @bug 8146310
+ * @summary [macosx] setDefaultMenuBar does not initialize screen menu bar
+ * @author Alan Snyder
+ * @run main/othervm TestNoScreenMenuBar
+ * @requires (os.family == "mac")
+ */
+
+import java.awt.AWTException;
+import java.awt.Desktop;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.SwingUtilities;
+
+public class TestNoScreenMenuBar
+{
+ static TestNoScreenMenuBar theTest;
+ private Robot robot;
+ private boolean isApplicationOpened;
+ private boolean isActionPerformed;
+
+ public TestNoScreenMenuBar(String[] args)
+ {
+ try {
+ robot = new Robot();
+ robot.setAutoDelay(50);
+ } catch (AWTException ex) {
+ throw new RuntimeException(ex);
+ }
+
+ if (!(args.length > 0 && args[0].equals("baseline"))) {
+ // activate another application
+ openOtherApplication();
+ robot.delay(500);
+ }
+
+ // The failure mode is installing the default menu bar while the application is inactive
+ Desktop desktop = Desktop.getDesktop();
+ desktop.setDefaultMenuBar(createMenuBar());
+
+ robot.delay(500);
+ desktop.requestForeground(true);
+ robot.delay(500);
+ }
+
+ JMenuBar createMenuBar()
+ {
+ JMenuBar mb = new JMenuBar();
+ // A very long name makes it more likely that the robot will hit the menu
+ JMenu menu = new JMenu("TestTestTestTestTestTestTestTestTestTest");
+ mb.add(menu);
+ JMenuItem item = new JMenuItem("TestTestTestTestTestTestTestTestTestTest");
+ item.addActionListener(ev -> {
+ isActionPerformed = true;
+ });
+ menu.add(item);
+ return mb;
+ }
+
+ void dispose()
+ {
+ closeOtherApplication();
+ Desktop.getDesktop().setDefaultMenuBar(null);
+ }
+
+ private void performMenuItemTest()
+ {
+ // Find the menu on the screen menu bar
+ // The location depends upon the application name which is the name of the first menu.
+ // Unfortunately, the application name can vary based on how the application is run.
+ // The work around is to make the menu and the menu item names very long.
+
+ int menuBarX = 250;
+ int menuBarY = 11;
+ int menuItemX = menuBarX;
+ int menuItemY = 34;
+
+ robot.mouseMove(menuBarX, menuBarY);
+ robot.delay(100);
+ robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ robot.delay(100);
+ robot.mouseMove(menuItemX, menuItemY);
+ robot.delay(100);
+ robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ robot.waitForIdle();
+
+ waitForAction();
+ }
+
+ private synchronized void waitForAction()
+ {
+ try {
+ for (int i = 0; i < 10; i++) {
+ if (isActionPerformed) {
+ return;
+ }
+ wait(100);
+ }
+ } catch (InterruptedException ex) {
+ }
+ throw new RuntimeException("Test failed: menu item action was not performed");
+ }
+
+ private void openOtherApplication() {
+ String[] cmd = { "/usr/bin/open", "/Applications/System Preferences.app" };
+ execute(cmd);
+ isApplicationOpened = true;
+ }
+
+ private void closeOtherApplication() {
+ if (isApplicationOpened) {
+ String[] cmd = { "/usr/bin/osascript", "-e", "tell application \"System Preferences\" to close window 1" };
+ execute(cmd);
+ }
+ }
+
+ private void execute(String[] cmd) {
+ try {
+ Process p = Runtime.getRuntime().exec(cmd);
+ p.waitFor();
+ } catch (IOException | InterruptedException ex) {
+ throw new RuntimeException("Unable to execute command");
+ }
+ }
+
+ private static void runSwing(Runnable r)
+ {
+ try {
+ SwingUtilities.invokeAndWait(r);
+ } catch (InterruptedException e) {
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ if (!System.getProperty("os.name").contains("OS X")) {
+ System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
+ return;
+ }
+
+ System.setProperty("apple.laf.useScreenMenuBar", "true");
+ try {
+ runSwing(() -> theTest = new TestNoScreenMenuBar(args));
+ theTest.performMenuItemTest();
+ } finally {
+ if (theTest != null) {
+ runSwing(() -> theTest.dispose());
+ }
+ }
+ }
+}
--- a/test/jdk/java/awt/Mixing/AWT_Mixing/FrameBorderCounter.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/java/awt/Mixing/AWT_Mixing/FrameBorderCounter.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, 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
@@ -20,15 +20,14 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Frame;
import java.awt.Point;
import java.awt.Robot;
+import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowAdapter;
public class FrameBorderCounter {
@@ -59,6 +58,7 @@
background.setVisible(true);
}
});
+ robot.waitForIdle();
EventQueue.invokeAndWait(new Runnable() {
public void run() {
frame = new Frame("Frame");
--- a/test/jdk/java/awt/Mixing/AWT_Mixing/OpaqueOverlappingChoice.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/java/awt/Mixing/AWT_Mixing/OpaqueOverlappingChoice.java Thu Sep 27 10:49:10 2018 -0700
@@ -33,8 +33,7 @@
* @bug 6994264
* @summary Opaque overlapping test for Choice AWT component
* @library /java/awt/patchlib ../../regtesthelpers
- * @modules java.desktop/com.sun.awt
- * java.desktop/java.awt.peer
+ * @modules java.desktop/java.awt.peer
* java.desktop/sun.awt
* @build java.desktop/java.awt.Helper
* @build Util
--- a/test/jdk/java/awt/Toolkit/ScreenInsetsTest/ScreenInsetsTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/java/awt/Toolkit/ScreenInsetsTest/ScreenInsetsTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,8 +32,13 @@
@run main ScreenInsetsTest
*/
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
import test.java.awt.regtesthelpers.Util;
@@ -41,21 +46,33 @@
{
public static void main(String[] args)
{
- if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH))
- {
- // this state is used in the test - sorry
- return;
- }
-
boolean passed = true;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
- for (GraphicsDevice gd : gds)
- {
+ for (GraphicsDevice gd : gds) {
+
GraphicsConfiguration gc = gd.getDefaultConfiguration();
Rectangle gcBounds = gc.getBounds();
Insets gcInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
+ int left = gcInsets.left;
+ int right = gcInsets.right;
+ int bottom = gcInsets.bottom;
+ int top = gcInsets.top;
+ if (left < 0 || right < 0 || bottom < 0 || top < 0) {
+ throw new RuntimeException("Negative value: " + gcInsets);
+ }
+ int maxW = gcBounds.width / 3;
+ int maxH = gcBounds.height / 3;
+ if (left > maxW || right > maxW || bottom > maxH || top > maxH) {
+ throw new RuntimeException("Big value: " + gcInsets);
+ }
+
+ if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH))
+ {
+ // this state is used in the test - sorry
+ continue;
+ }
Frame f = new Frame("Test", gc);
f.setUndecorated(true);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/Window/WindowOwnedByEmbeddedFrameTest/WindowOwnedByEmbeddedFrameTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @key headful
+ * @bug 8130655
+ * @summary Tests that window owned by EmbeddedFrame can receive keyboard input
+ * @requires (os.family == "mac")
+ * @modules java.desktop/sun.awt
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main WindowOwnedByEmbeddedFrameTest
+ */
+
+import sun.awt.EmbeddedFrame;
+
+import java.awt.Robot;
+import java.awt.TextField;
+import java.awt.Window;
+import java.awt.event.KeyEvent;
+
+import test.java.awt.regtesthelpers.Util;
+
+public class WindowOwnedByEmbeddedFrameTest {
+ private static TextField textField;
+ private static EmbeddedFrame embeddedFrame;
+ private static Window window;
+
+ public static void main(String[] args) {
+ try {
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(50);
+
+ embeddedFrame = createEmbeddedFrame();
+
+ textField = new TextField("");
+
+ window = new Window(embeddedFrame);
+ window.setSize(200, 200);
+ window.setLocationRelativeTo(null);
+ window.add(textField);
+ window.setVisible(true);
+
+ Util.waitForIdle(robot);
+
+ Util.clickOnComp(textField, robot);
+ Util.waitForIdle(robot);
+
+ robot.keyPress(KeyEvent.VK_T);
+ robot.keyRelease(KeyEvent.VK_T);
+ Util.waitForIdle(robot);
+
+ robot.keyPress(KeyEvent.VK_E);
+ robot.keyRelease(KeyEvent.VK_E);
+ Util.waitForIdle(robot);
+
+ robot.keyPress(KeyEvent.VK_S);
+ robot.keyRelease(KeyEvent.VK_S);
+ Util.waitForIdle(robot);
+
+ robot.keyPress(KeyEvent.VK_T);
+ robot.keyRelease(KeyEvent.VK_T);
+ Util.waitForIdle(robot);
+
+ if ("".equals(textField.getText())) {
+ throw new RuntimeException("Keyboard input in text field isn't possible");
+ }
+ } finally {
+ if (embeddedFrame != null) {
+ embeddedFrame.dispose();
+ }
+ if (window != null) {
+ window.dispose();
+ }
+ }
+ }
+
+ private static EmbeddedFrame createEmbeddedFrame() {
+ try {
+ return (EmbeddedFrame) Class.forName("sun.lwawt.macosx.CEmbeddedFrame").newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot create EmbeddedFrame", e);
+ }
+ }
+}
+
--- a/test/jdk/java/awt/dnd/BadSerializaionTest/BadSerializationTest.java Thu Sep 27 08:49:12 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/**
- * @test
- * @key headful
- * @bug 8030050
- * @summary Validate fields on DnD class deserialization
- * @author petr.pchelko@oracle.com
- */
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InvalidObjectException;
-import java.io.ObjectInputStream;
-import java.util.stream.Stream;
-
-public class BadSerializationTest {
-
- private static final String[] badSerialized = new String[] {
- "badAction",
- "noEvents",
- "nullComponent",
- "nullDragSource",
- "nullOrigin"
- };
-
- private static final String goodSerialized = "good";
-
- public static void main(String[] args) throws Exception {
- String testSrc = System.getProperty("test.src") + File.separator;
- testReadObject(testSrc + goodSerialized, false);
- Stream.of(badSerialized).forEach(file -> testReadObject(testSrc + file, true));
- }
-
- private static void testReadObject(String filename, boolean expectException) {
- Exception exceptionCaught = null;
- try (FileInputStream fileInputStream = new FileInputStream(filename);
- ObjectInputStream ois = new ObjectInputStream(fileInputStream)) {
- ois.readObject();
- } catch (InvalidObjectException e) {
- exceptionCaught = e;
- } catch (IOException e) {
- throw new RuntimeException("FAILED: IOException", e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("FAILED: ClassNotFoundException", e);
- }
- if (exceptionCaught != null && !expectException) {
- throw new RuntimeException("FAILED: UnexpectedException", exceptionCaught);
- }
- if (exceptionCaught == null && expectException) {
- throw new RuntimeException("FAILED: Invalid object was created with no exception");
- }
- }
-}
Binary file test/jdk/java/awt/dnd/BadSerializaionTest/badAction has changed
Binary file test/jdk/java/awt/dnd/BadSerializaionTest/good has changed
Binary file test/jdk/java/awt/dnd/BadSerializaionTest/noEvents has changed
Binary file test/jdk/java/awt/dnd/BadSerializaionTest/nullComponent has changed
Binary file test/jdk/java/awt/dnd/BadSerializaionTest/nullDragSource has changed
Binary file test/jdk/java/awt/dnd/BadSerializaionTest/nullOrigin has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/dnd/BadSerializationTest/BadSerializationTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @key headful
+ * @bug 8030050 8039082
+ * @summary Validate fields on DnD class deserialization
+ */
+
+import java.awt.Point;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragSource;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.stream.Stream;
+
+import javax.swing.JPanel;
+
+import static java.awt.dnd.DnDConstants.ACTION_COPY;
+
+public class BadSerializationTest {
+
+ private static final String[] badSerialized = new String[] {
+ "badAction",
+ "noEvents",
+ "nullComponent",
+ "nullDragSource",
+ "nullOrigin"
+ };
+
+ private static final String goodSerialized = "good";
+
+ public static void main(String[] args) throws Exception {
+ if (args.length > 0 && args[0].equals("-write")) {
+ writeObjects(); //Creates the binary files for the test.
+ } else {
+ String testSrc = System.getProperty("test.src") + File.separator;
+ testReadObject(testSrc + goodSerialized, false);
+ Stream.of(badSerialized).forEach(
+ file -> testReadObject(testSrc + file, true));
+ }
+ }
+
+ private static void testReadObject(String filename, boolean expectException) {
+ Exception exceptionCaught = null;
+ try (FileInputStream fileInputStream = new FileInputStream(filename);
+ ObjectInputStream ois = new ObjectInputStream(fileInputStream)) {
+ ois.readObject();
+ } catch (InvalidObjectException e) {
+ exceptionCaught = e;
+ } catch (IOException e) {
+ throw new RuntimeException("FAILED: IOException", e);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("FAILED: ClassNotFoundException", e);
+ }
+ if (exceptionCaught != null && !expectException) {
+ throw new RuntimeException("FAILED: UnexpectedException", exceptionCaught);
+ }
+ if (exceptionCaught == null && expectException) {
+ throw new RuntimeException("FAILED: Invalid object was created with no exception");
+ }
+ }
+
+ /**
+ * Creates the stubs for the test. It is necessary to disable all checks in
+ * the constructors of DragGestureEvent/DragGestureRecognizer before run.
+ */
+ private static void writeObjects() throws Exception {
+ ArrayList<InputEvent> evs = new ArrayList<>();
+ Point ori = new Point();
+
+ write(new DragGestureEvent(new NothingNull(), ACTION_COPY, ori, evs),
+ "noEvents");
+
+ evs.add(new KeyEvent(new JPanel(), 0, 0, 0, 0, 'a', 0));
+
+ write(new DragGestureEvent(new NullComponent(), ACTION_COPY, ori, evs),
+ "nullComponent");
+
+ write(new DragGestureEvent(new NothingNull(), 100, ori, evs),
+ "badAction");
+
+ write(new DragGestureEvent(new NullDragSource(), ACTION_COPY, ori, evs),
+ "nullDragSource");
+
+ write(new DragGestureEvent(new NothingNull(), ACTION_COPY, null, evs),
+ "nullOrigin");
+
+ write(new DragGestureEvent(new NothingNull(), ACTION_COPY, ori, evs),
+ "good");
+ }
+
+ private static void write(Object obj, String file) throws Exception {
+ try (FileOutputStream fis = new FileOutputStream(file);
+ ObjectOutputStream ois = new ObjectOutputStream(fis)) {
+ ois.writeObject(obj);
+ }
+ }
+
+ public static final class NullDragSource extends DragGestureRecognizer {
+
+ public NullDragSource() {
+ super(null, new JPanel());
+ }
+
+ protected void registerListeners() {
+ }
+
+ protected void unregisterListeners() {
+ }
+ }
+
+ public static final class NullComponent extends DragGestureRecognizer {
+
+ public NullComponent() {
+ super(new DragSource(), null);
+ }
+
+ protected void registerListeners() {
+ }
+
+ protected void unregisterListeners() {
+ }
+ }
+
+ public static final class NothingNull extends DragGestureRecognizer {
+
+ public NothingNull() {
+ super(new DragSource(), new JPanel());
+ }
+
+ protected void registerListeners() {
+ }
+
+ protected void unregisterListeners() {
+ }
+ }
+}
Binary file test/jdk/java/awt/dnd/BadSerializationTest/badAction has changed
Binary file test/jdk/java/awt/dnd/BadSerializationTest/good has changed
Binary file test/jdk/java/awt/dnd/BadSerializationTest/noEvents has changed
Binary file test/jdk/java/awt/dnd/BadSerializationTest/nullComponent has changed
Binary file test/jdk/java/awt/dnd/BadSerializationTest/nullDragSource has changed
Binary file test/jdk/java/awt/dnd/BadSerializationTest/nullOrigin has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/font/GlyphVector/ZWJLigatureTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/* @test
+ @bug 7017058 8191130 8195836
+ @summary Test handling of ZWJ by layout.
+ */
+
+/*
+ * A forced mapping of ZWJ (u+200D) to a special invisible glyph ID
+ * was breaking many uses of ZWJ to form ligatures in fonts supporting
+ * Indic scripts (Malayalam, Bengali, Sinhala at least) and also Emoji.
+ * Without knowing the exact properties of a font under test, and also
+ * how a layout engine maps chars to glyphs, it is difficult to write
+ * a complete robust automated test.
+ * So whilst it tries to show rendering for any fonts that claims to
+ * support the target alphabet, it will fail only when specific known
+ * fonts fail.
+ * The test automatically passes or fails only if these fonts do
+ * not ligature away the ZWJ.
+ * Besides this the test renders the specific text from these fonts
+ * and any others that claim to fully support the text, so it can be
+ * manually examined if so desired.
+ */
+
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+import java.util.Locale;
+
+public class ZWJLigatureTest {
+
+ // These are fonts and scripts on Windows that should support
+ // the behaviours enough to make reliable tests";
+
+ static final String malayalamName = "Malayalam";
+ static final String malayalamFont = "Kartika";
+ static final String malayalamText = "\u0D2C\u0D3E\u0D32\u0D28\u0D4D\u200D";
+
+ static final String bengaliName = "Bengali";
+ static final String bengaliFont = "Vrinda";
+ static final String bengaliText =
+ "\u09CE \u09A4\u09CD\u200D " +
+ "\u09A4\u09BE\u09CE \u09A4\u09BE\u09A4\u09CD\u200D";
+
+ static final String sinhalaName = "Sinhala";
+ static final String sinhalaFont = "Iskoola Pota";
+ static final String sinhalaText =
+ "\u0DC1\u0DCA\u200D\u0DBB\u0DD3" +
+ "\u0D9A\u0DCA\u200D\u0DBB\u0DD2" +
+ "\u0D9A\u0DCA\u200D\u0DBB\u0DD3" +
+ "\u0DA7\u0DCA\u200D\u0DBB\u0DDA" +
+ "\u0DB6\u0DCA\u200D\u0DBB\u0DD0" +
+ "\u0D9B\u0DCA\u200D\u0DBA\u0DCF";
+
+
+ static String[] scripts = { malayalamName, bengaliName, sinhalaName };
+ static String[] fontNames = { malayalamFont, bengaliFont, sinhalaFont };
+ static String[] text = { malayalamText, bengaliText, sinhalaText };
+
+
+ static void doTest() {
+ boolean testFailed = false;
+
+ BufferedImage bi = new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
+ Graphics2D g2d = (Graphics2D)bi.getGraphics();
+ FontRenderContext frc = g2d.getFontRenderContext();
+ for (int f=0; f < fontNames.length; f++) {
+ Font font = new Font(fontNames[f], Font.PLAIN, 30);
+ String family = font.getFamily(Locale.ENGLISH).toLowerCase();
+ if (!fontNames[f].toLowerCase().equals(family)) {
+ System.out.println(fontNames[f] + " not found, skipping.");
+ continue;
+ } else {
+ System.out.println("Testing " + fontNames[f] +
+ " for " + scripts[f]);
+ }
+ char[] chs = text[f].toCharArray();
+ GlyphVector gv = font.layoutGlyphVector(frc, chs, 0, chs.length, 0);
+ for (int g=0; g<gv.getNumGlyphs(); g++) {
+ int glyph = gv.getGlyphCode(g);
+ int charIdx = gv.getGlyphCharIndex(g);
+ int codePoint = text[f].codePointAt(charIdx);
+ Point2D pos = gv.getGlyphPosition(g);
+
+ if (codePoint == 0x200D) {
+ testFailed = true;
+ System.out.println("FAIL: GOT ZWJ\n");
+ }
+ System.out.println("["+g+"]: gid="+Integer.toHexString(glyph)
+ +", charIdx="+Integer.toHexString(charIdx)
+ +", codePoint="+Integer.toHexString(codePoint)
+ +", pos=["+pos.getX()+","+pos.getY()+"]");
+ }
+ }
+ if (testFailed) {
+ throw new RuntimeException("TEST FAILED");
+ }
+ }
+
+ public static void main(String[] args) {
+ doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/print/PageFormat/WrongPaperForBookPrintingTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -0,0 +1,244 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ @key headful
+ @bug 8201818
+ @summary Printing attributes break page size set via "java.awt.print.Book"
+ object
+ @run main/manual WrongPaperForBookPrintingTest
+ */
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.FlowLayout;
+import java.awt.Graphics;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.print.Book;
+import java.awt.print.PageFormat;
+import java.awt.print.Paper;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.Size2DSyntax;
+import javax.print.attribute.standard.Chromaticity;
+import javax.print.attribute.standard.MediaSize;
+import javax.print.attribute.standard.MediaSizeName;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+import javax.swing.Timer;
+import javax.swing.WindowConstants;
+
+public class WrongPaperForBookPrintingTest implements Printable {
+ private static final CountDownLatch testEndedSignal = new CountDownLatch(1);
+ private static final int testTimeout = 300000;
+ private static volatile String testFailureMsg;
+ private static volatile boolean testPassed;
+ private static volatile boolean testFinished;
+
+ public static void main(String[] args) {
+ SwingUtilities.invokeLater(() -> createAndShowTestDialog());
+
+ try {
+ if (!testEndedSignal.await(testTimeout, TimeUnit.MILLISECONDS)) {
+ throw new RuntimeException(String.format(
+ "Test timeout '%d ms' elapsed.", testTimeout));
+ }
+ if (!testPassed) {
+ String failureMsg = testFailureMsg;
+ if ((failureMsg != null) && (!failureMsg.trim().isEmpty())) {
+ throw new RuntimeException(failureMsg);
+ } else {
+ throw new RuntimeException("Test failed.");
+ }
+ }
+ } catch (InterruptedException ie) {
+ throw new RuntimeException(ie);
+ } finally {
+ testFinished = true;
+ }
+ }
+
+ private static void doTest() {
+ PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+ aset.add(Chromaticity.MONOCHROME);
+
+ MediaSize isoA5Size = MediaSize.getMediaSizeForName(MediaSizeName.ISO_A5);
+ float[] size = isoA5Size.getSize(Size2DSyntax.INCH);
+ Paper paper = new Paper();
+ paper.setSize(size[0] * 72.0, size[1] * 72.0);
+ paper.setImageableArea(0.0, 0.0, size[0] * 72.0, size[1] * 72.0);
+ PageFormat pf = new PageFormat();
+ pf.setPaper(paper);
+
+ Book pageable = new Book();
+ pageable.append(new WrongPaperForBookPrintingTest(), pf);
+
+ PrinterJob job = PrinterJob.getPrinterJob();
+ job.setPageable(pageable);
+ if (job.printDialog()) {
+ try {
+ job.print(aset);
+ } catch (PrinterException pe) {
+ throw new RuntimeException(pe);
+ }
+ }
+ }
+
+ private static void pass() {
+ testPassed = true;
+ testEndedSignal.countDown();
+ }
+
+ private static void fail(String failureMsg) {
+ testFailureMsg = failureMsg;
+ testPassed = false;
+ testEndedSignal.countDown();
+ }
+
+ private static String convertMillisToTimeStr(int millis) {
+ if (millis < 0) {
+ return "00:00:00";
+ }
+ int hours = millis / 3600000;
+ int minutes = (millis - hours * 3600000) / 60000;
+ int seconds = (millis - hours * 3600000 - minutes * 60000) / 1000;
+ return String.format("%02d:%02d:%02d", hours, minutes, seconds);
+ }
+
+ private static void createAndShowTestDialog() {
+ String description =
+ " To run this test it is required to have a virtual PDF\r\n" +
+ " printer or any other printer supporting A5 paper size.\r\n" +
+ "\r\n" +
+ " 1. Verify that NOT A5 paper size is set as default for the\r\n" +
+ " printer to be used.\r\n" +
+ " 2. Click on \"Start Test\" button.\r\n" +
+ " 3. In the shown print dialog select the printer and click\r\n" +
+ " on \"Print\" button.\r\n" +
+ " 4. Verify that a page with a drawn rectangle is printed on\r\n" +
+ " a paper of A5 size which is (5.8 x 8.3 in) or\r\n" +
+ " (148 x 210 mm).\r\n" +
+ "\r\n" +
+ " If the printed page size is correct, click on \"PASS\"\r\n" +
+ " button, otherwise click on \"FAIL\" button.";
+
+ final JDialog dialog = new JDialog();
+ dialog.setTitle("WrongPaperForBookPrintingTest");
+ dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ dialog.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ dialog.dispose();
+ fail("Main dialog was closed.");
+ }
+ });
+
+ final JLabel testTimeoutLabel = new JLabel(String.format(
+ "Test timeout: %s", convertMillisToTimeStr(testTimeout)));
+ final long startTime = System.currentTimeMillis();
+ final Timer timer = new Timer(0, null);
+ timer.setDelay(1000);
+ timer.addActionListener((e) -> {
+ int leftTime = testTimeout - (int) (System.currentTimeMillis() - startTime);
+ if ((leftTime < 0) || testFinished) {
+ timer.stop();
+ dialog.dispose();
+ }
+ testTimeoutLabel.setText(String.format(
+ "Test timeout: %s", convertMillisToTimeStr(leftTime)));
+ });
+ timer.start();
+
+ JTextArea textArea = new JTextArea(description);
+ textArea.setEditable(false);
+
+ final JButton testButton = new JButton("Start Test");
+ final JButton passButton = new JButton("PASS");
+ final JButton failButton = new JButton("FAIL");
+ testButton.addActionListener((e) -> {
+ testButton.setEnabled(false);
+ new Thread(() -> {
+ try {
+ doTest();
+
+ SwingUtilities.invokeLater(() -> {
+ passButton.setEnabled(true);
+ failButton.setEnabled(true);
+ });
+ } catch (Throwable t) {
+ t.printStackTrace();
+ dialog.dispose();
+ fail("Exception occurred in a thread executing the test.");
+ }
+ }).start();
+ });
+ passButton.setEnabled(false);
+ passButton.addActionListener((e) -> {
+ dialog.dispose();
+ pass();
+ });
+ failButton.setEnabled(false);
+ failButton.addActionListener((e) -> {
+ dialog.dispose();
+ fail("Size of a printed page is wrong.");
+ });
+
+ JPanel mainPanel = new JPanel(new BorderLayout());
+ JPanel labelPanel = new JPanel(new FlowLayout());
+ labelPanel.add(testTimeoutLabel);
+ mainPanel.add(labelPanel, BorderLayout.NORTH);
+ mainPanel.add(textArea, BorderLayout.CENTER);
+ JPanel buttonPanel = new JPanel(new FlowLayout());
+ buttonPanel.add(testButton);
+ buttonPanel.add(passButton);
+ buttonPanel.add(failButton);
+ mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+ dialog.add(mainPanel);
+
+ dialog.pack();
+ dialog.setVisible(true);
+ }
+
+ @Override
+ public int print(Graphics g, PageFormat pf, int pageIndex)
+ throws PrinterException {
+ if (pageIndex == 0) {
+ g.setColor(Color.RED);
+ g.drawRect((int) pf.getImageableX(), (int) pf.getImageableY(),
+ (int) pf.getImageableWidth() - 1, (int) pf.getImageableHeight() - 1);
+ return Printable.PAGE_EXISTS;
+ } else {
+ return Printable.NO_SUCH_PAGE;
+ }
+ }
+}
--- a/test/jdk/java/lang/SecurityManager/CheckPackageAccess.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/java/lang/SecurityManager/CheckPackageAccess.java Thu Sep 27 10:49:10 2018 -0700
@@ -143,7 +143,7 @@
"jdk.internal.loader", null, null),
// java.desktop module loaded by boot loader and has an openQual pkg
// that is exported
- new Test("java.desktop", "java.applet", null, "sun.applet",
+ new Test("java.desktop", "java.applet", null, "sun.font",
"sun.awt", null, "javax.swing.plaf.basic"),
// java.security.jgss module loaded by platform loader
new Test("java.security.jgss", "org.ietf.jgss", null,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/sound/sampled/Clip/ClipIsRunningAfterStop.java Thu Sep 27 10:49:10 2018 -0700
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.concurrent.TimeUnit;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.Clip;
+import javax.sound.sampled.DataLine;
+import javax.sound.sampled.LineUnavailableException;
+
+import static javax.sound.sampled.AudioFormat.Encoding.PCM_SIGNED;
+
+/**
+ * @test
+ * @bug 8207150
+ * @summary Clip.isRunning() may return true after Clip.stop() was called
+ */
+public final class ClipIsRunningAfterStop {
+
+ private static volatile Exception failed;
+
+ public static void main(final String[] args) throws Exception {
+ final Runnable r = () -> {
+ try {
+ test();
+ } catch (LineUnavailableException | IllegalArgumentException ignored) {
+ // the test is not applicable
+ } catch (Exception ex) {
+ failed = ex;
+ }
+ };
+ Thread t1 = new Thread(r);
+ Thread t2 = new Thread(r);
+ Thread t3 = new Thread(r);
+ t1.start();
+ t2.start();
+ t3.start();
+ t1.join();
+ t2.join();
+ t3.join();
+ if (failed != null) {
+ throw new RuntimeException(failed);
+ }
+ }
+
+ private static void test() throws Exception {
+ // Will run the test no more than 15 seconds
+ long endtime = System.nanoTime() + TimeUnit.SECONDS.toNanos(15);
+ while (failed == null && endtime - System.nanoTime() > 0) {
+ Clip clip = createClip();
+ clip.loop(Clip.LOOP_CONTINUOUSLY);
+ clip.stop();
+ if (clip.isRunning()) {
+ if (clip.isRunning()) {
+ throw new RuntimeException("Clip is running");
+ }
+ }
+ if (clip.isActive()) {
+ if (clip.isActive()) {
+ throw new RuntimeException("Clip is active");
+ }
+ }
+ clip.close();
+ }
+ }
+
+ private static Clip createClip() throws LineUnavailableException {
+ AudioFormat format =
+ new AudioFormat(PCM_SIGNED, 44100, 8, 1, 1, 44100, false);
+ DataLine.Info info = new DataLine.Info(Clip.class, format);
+ Clip clip = (Clip) AudioSystem.getLine(info);
+ clip.open(format, new byte[2], 0, 2);
+ return clip;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/swing/JEditorPane/TestHTMLBulletsSizeAndAliasing.java Thu Sep 27 10:49:10 2018 -0700
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 8201925 8202013
+ * @summary Verifies if JEditorPane unordered list bullets look pixelated
+ * and large relative to text font size
+ * @run main/manual TestHTMLBulletsSizeAndAliasing
+ */
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import javax.swing.JSplitPane;
+import javax.swing.SwingUtilities;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JEditorPane;
+
+public class TestHTMLBulletsSizeAndAliasing {
+
+ public static void main(String[] args) throws Exception {
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ AliasingTest test = new AliasingTest(latch);
+ Thread T1 = new Thread(test);
+ T1.start();
+
+ // wait for latch to complete
+ boolean ret = false;
+ try {
+ ret = latch.await(60, TimeUnit.SECONDS);
+ } catch (InterruptedException ie) {
+ throw ie;
+ }
+ if (!ret) {
+ test.dispose();
+ throw new RuntimeException(" User has not executed the test");
+ }
+
+ if (test.testResult == false) {
+ throw new RuntimeException("JEditorPane unordered list bullets look pixelated");
+ }
+ }
+}
+
+class AliasingTest implements Runnable {
+ static JFrame f;
+ static JDialog dialog;
+ public boolean testResult = false;
+ private final CountDownLatch latch;
+
+ public AliasingTest(CountDownLatch latch) throws Exception {
+ this.latch = latch;
+ }
+
+ @Override
+ public void run() {
+ try {
+ SwingUtilities.invokeAndWait(() -> {
+ createUI();
+ aliasingTest();
+ });
+ } catch (Exception ex) {
+ if (f != null) {
+ f.dispose();
+ }
+ latch.countDown();
+ throw new RuntimeException("createUI Failed: " + ex.getMessage());
+ }
+
+ }
+
+ public void dispose() {
+ dialog.dispose();
+ f.dispose();
+ }
+
+
+ private static String getHtml() {
+ return "<html><body>" +
+ "<ul>" +
+ "<li>Text</li>" +
+ "<li>Document</li>" +
+ "</ul>" +
+ "</body></html>";
+ }
+
+ private static Component createSplitPane() {
+ JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+ createHtmlViewer(false), createHtmlViewer(true));
+ splitPane.setOneTouchExpandable(true);
+ splitPane.setResizeWeight(0.5);
+ splitPane.setPreferredSize(new Dimension(150, 150));
+ return splitPane;
+ }
+
+ private static Component createHtmlViewer(boolean antialiasing) {
+ JEditorPane editorPane;
+ if (antialiasing) {
+ editorPane = new JEditorPane() {
+ @Override
+ public void paint(Graphics g) {
+ Graphics2D g2d = (Graphics2D) g.create();
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ super.paint(g2d);
+ g2d.dispose();
+ }
+ };
+ }
+ else {
+ editorPane = new JEditorPane();
+ }
+ editorPane.setEditable(false);
+ editorPane.setContentType("text/html");
+ editorPane.setText(getHtml());
+ return new JScrollPane(editorPane);
+ }
+ private static void aliasingTest() {
+ f = new JFrame("List Bullets");
+ f.add(createSplitPane());
+ f.pack();
+ f.setLocationRelativeTo(null);
+ f.setVisible(true);
+ }
+
+
+ private final void createUI() {
+ String description
+ = " INSTRUCTIONS:\n"
+ + " A JEditorPane divided by SplitPane will be shown.\n"
+ + " The upper html is rendered in a default JEditorPane.\n "
+ + " The lower html is rendered in a JEditorPane using "
+ + " rendering hints to turn on antialiasing.\n"
+ + " If upper html bullets looks pixelated AND"
+ + " larger than needed relative to text font size\n"
+ + " and not as smooth as shown in lower html\n "
+ + " then press fail else press pass";
+
+ dialog = new JDialog();
+ dialog.setTitle("textselectionTest");
+ JTextArea textArea = new JTextArea(description);
+ textArea.setEditable(false);
+ final JButton passButton = new JButton("PASS");
+ passButton.addActionListener((e) -> {
+ testResult = true;
+ dispose();
+ latch.countDown();
+ });
+ final JButton failButton = new JButton("FAIL");
+ failButton.addActionListener((e) -> {
+ testResult = false;
+ dispose();
+ latch.countDown();
+ });
+ JPanel mainPanel = new JPanel(new BorderLayout());
+ mainPanel.add(textArea, BorderLayout.CENTER);
+ JPanel buttonPanel = new JPanel(new FlowLayout());
+ buttonPanel.add(passButton);
+ buttonPanel.add(failButton);
+ mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+ dialog.add(mainPanel);
+ dialog.pack();
+ dialog.setVisible(true);
+ }
+}
--- a/test/jdk/javax/swing/JSplitPane/4816114/bug4816114.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/javax/swing/JSplitPane/4816114/bug4816114.java Thu Sep 27 10:49:10 2018 -0700
@@ -24,20 +24,26 @@
/*
* @test
* @key headful
- * @bug 4816114
+ * @bug 4816114 8203904
* @summary REGRESSION: Regression in divider location behavior when JSplitPane is resized
* @author Andrey Pikalev
* @run main bug4816114
*/
-import javax.swing.*;
-import java.awt.*;
-import java.lang.reflect.*;
-
+import java.awt.Robot;
+import java.awt.Dimension;
+import java.awt.AWTException;
+import java.awt.BorderLayout;
+import javax.swing.JFrame;
+import javax.swing.JButton;
+import javax.swing.SwingUtilities;
+import javax.swing.JSplitPane;
+import javax.swing.BorderFactory;
+import java.lang.reflect.InvocationTargetException;
public class bug4816114 {
- JFrame fr;
+ static JFrame fr;
JSplitPane splitPane;
boolean[] resized = new boolean[] { false, false, false,
@@ -49,43 +55,49 @@
static bug4816114 test = new bug4816114();
public static void main(String[] args) throws InterruptedException, InvocationTargetException, AWTException {
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- test.createAndShowGUI();
- }
- });
- Robot robot = new Robot();
- robot.waitForIdle();
- Thread.sleep(1000);
- Thread.sleep(2000);
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ test.createAndShowGUI();
+ }
+ });
+ Robot robot = new Robot();
+ robot.waitForIdle();
+ Thread.sleep(1000);
+ Thread.sleep(2000);
- step++;
- test.doTest(150, 300);
+ step++;
+ test.doTest(150, 300);
- step++;
- test.doTest(650, 300);
+ step++;
+ test.doTest(650, 300);
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- test.splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
- }
- });
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ test.splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
+ }
+ });
- step++;
- test.doTest(300, 650);
+ step++;
+ test.doTest(300, 650);
- step++;
- test.doTest(300, 150);
+ step++;
+ test.doTest(300, 150);
+
+ step++;
+ test.doTest(300, 650);
- step++;
- test.doTest(300, 650);
-
- if ( !test.isPassed() ) {
- throw new Error("The divider location is wrong.");
+ if ( !test.isPassed() ) {
+ throw new Error("The divider location is wrong.");
+ }
+ } finally {
+ SwingUtilities.invokeAndWait(() -> fr.dispose());
}
}
+
public void createAndShowGUI() {
fr = new JFrame("Test");
+ fr.setUndecorated(true);
splitPane = new TestSplitPane();
splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/swing/JTable/TestClearSel.java Thu Sep 27 10:49:10 2018 -0700
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @key headful
+ * @bug 8202702
+ * @summary Verifies if Jtable clear selction causes disappearance of a row.
+ * @run main/manual TestClearSel
+ */
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.FlowLayout;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTable;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableModel;
+
+public class TestClearSel {
+
+ static DefaultTableModel model;
+
+ public static void main(String[] args) throws Exception {
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ ClearSelTest test = new ClearSelTest(latch);
+ Thread T1 = new Thread(test);
+ T1.start();
+
+ // wait for latch to complete
+ boolean ret = false;
+ try {
+ ret = latch.await(60, TimeUnit.SECONDS);
+ } catch (InterruptedException ie) {
+ throw ie;
+ }
+ if (!ret) {
+ test.dispose();
+ throw new RuntimeException(" User has not executed the test");
+ }
+
+ if (test.testResult == false) {
+ throw new RuntimeException("Some text were not rendered properly"
+ + " during painting of Jtable rows ");
+ }
+ }
+}
+
+class ClearSelTest implements Runnable {
+ static JFrame f;
+ static JDialog dialog;
+ static DefaultTableModel model;
+ public boolean testResult = false;
+ private final CountDownLatch latch;
+ private static String[] rows = new String[]{
+ "Row1", "Row2", "Row3", "Row4", "Row5",
+ "Row6", "Row7", "Row8", "Row9", "Row10"};
+
+ public ClearSelTest(CountDownLatch latch) throws Exception {
+ this.latch = latch;
+ }
+
+ @Override
+ public void run() {
+ try {
+ SwingUtilities.invokeAndWait(() -> {
+ createUI();
+ clearSelTest();
+ });
+ } catch (Exception ex) {
+ if (f != null) {
+ f.dispose();
+ }
+ latch.countDown();
+ throw new RuntimeException("createUI Failed: " + ex.getMessage());
+ }
+
+ }
+
+ public void dispose() {
+ dialog.dispose();
+ f.dispose();
+ }
+
+ private static void clearSelTest() {
+ final DefaultTableModel model = new DefaultTableModel();
+ model.addColumn("Test", rows);
+ final JTable table = new JTable(model);
+ table.setRowHeight(25);
+
+ final MouseAdapter adapt = new MouseAdapter() {
+
+ @Override
+ public void mouseMoved(final MouseEvent pE) {
+ final int row = table.rowAtPoint(pE.getPoint());
+ if (row > -1) {
+ table.setRowSelectionInterval(row, row);
+ } else {
+ table.clearSelection();
+ }
+ }
+
+ @Override
+ public void mouseEntered(final MouseEvent pE) {
+ final int row = table.rowAtPoint(pE.getPoint());
+ if (row > -1) {
+ table.setRowSelectionInterval(row, row);
+ } else {
+ table.clearSelection();
+ }
+ }
+
+ @Override
+ public void mouseExited(final MouseEvent pE) {
+ table.clearSelection();
+ }
+ };
+ table.addMouseListener(adapt);
+ table.addMouseMotionListener(adapt);
+
+ f = new JFrame();
+ f.setSize(300, 300);
+ f.setLocationRelativeTo(null);
+ f.add(table);
+ f.setVisible(true);
+ }
+
+
+ private final void createUI() {
+ String description
+ = " INSTRUCTIONS:\n"
+ + " A JTable will be shown.\n"
+ + " Move mouse over different row to select the row.\n "
+ + " Please verify if row text disappear "
+ + " if mouse is moved out of table.\n"
+ + " If any moment any part of the rows will not be\n "
+ + " painted properly and if some text are missing in JTable,\n "
+ + " then press fail else press pass";
+
+ dialog = new JDialog();
+ dialog.setTitle("textselectionTest");
+ JTextArea textArea = new JTextArea(description);
+ textArea.setEditable(false);
+ final JButton passButton = new JButton("PASS");
+ passButton.addActionListener((e) -> {
+ testResult = true;
+ dispose();
+ latch.countDown();
+ });
+ final JButton failButton = new JButton("FAIL");
+ failButton.addActionListener((e) -> {
+ testResult = false;
+ dispose();
+ latch.countDown();
+ });
+ JPanel mainPanel = new JPanel(new BorderLayout());
+ mainPanel.add(textArea, BorderLayout.CENTER);
+ JPanel buttonPanel = new JPanel(new FlowLayout());
+ buttonPanel.add(passButton);
+ buttonPanel.add(failButton);
+ mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+ dialog.add(mainPanel);
+ dialog.pack();
+ dialog.setVisible(true);
+ }
+}
--- a/test/jdk/javax/swing/UIDefaults/6795356/TableTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/javax/swing/UIDefaults/6795356/TableTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, 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,14 +24,11 @@
/*
* @test
* @bug 6795356
- * @summary Checks that SwingLazyValue class correclty works
+ * @summary Checks that SwingLazyValue class works correctly
* @author Alexander Potochkin
- * @modules java.desktop/sun.applet
* @run main/othervm TableTest
*/
-import sun.applet.AppletSecurity;
-
import javax.swing.*;
import javax.swing.table.TableCellEditor;
import java.awt.*;
@@ -41,7 +38,7 @@
public static void main(String[] args) throws Exception {
KeyboardFocusManager.getCurrentKeyboardFocusManager();
- System.setSecurityManager(new AppletSecurity());
+ System.setSecurityManager(new SecurityManager());
JTable table = new JTable();
TableCellEditor de = table.getDefaultEditor(Double.class);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/swing/border/TestTitledBorderLeak.java Thu Sep 27 10:49:10 2018 -0700
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import javax.swing.border.TitledBorder;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JLabel;
+import javax.swing.SwingUtilities;
+
+/**
+ * @test
+ * @key headful
+ * @bug 8204963
+ * @summary Verifies TitledBorder's memory leak
+ * @run main TestTitledBorderLeak
+ */
+
+public class TestTitledBorderLeak {
+
+ final static int TOTAL_TITLEDBORDER = 10;
+ final static int GC_ATTEMPTS = 10;
+ static ArrayList<WeakReference<TitledBorder>> weakRefArrTB =
+ new ArrayList(TOTAL_TITLEDBORDER);
+
+ public static void main(String[] args) throws Exception {
+
+ JFrame frame[] = new JFrame[TOTAL_TITLEDBORDER];
+
+ SwingUtilities.invokeAndWait(() -> {
+ for (int i = 0; i < TOTAL_TITLEDBORDER; i++) {
+ TitledBorder tb = new TitledBorder("");
+ weakRefArrTB.add(i, new WeakReference<TitledBorder>(tb));
+ JLabel label = new JLabel("TitledBorder");
+ label.setBorder(tb);
+ frame[i] = new JFrame("Borders");
+ JPanel panel = new JPanel();
+ panel.add(label);
+ frame[i].setContentPane(panel);
+ frame[i].setVisible(true);
+
+ }
+ });
+ if (TOTAL_TITLEDBORDER != weakRefArrTB.size()) {
+ System.err.println("TOTAL_TITLEDBORDER != weakRefArrTB.size()");
+ }
+ Thread.sleep(3000);
+ SwingUtilities.invokeAndWait(() -> {
+ for (int i = 0; i < TOTAL_TITLEDBORDER; i++) {
+ frame[i].dispose();
+ frame[i] = null;
+ }
+ });
+ Thread.sleep(3000);
+ attemptGCTitledBorder();
+ if (TOTAL_TITLEDBORDER != getCleanedUpTitledBorderCount()) {
+ throw new RuntimeException("Expected Total TitledBorder to be freed : " + TOTAL_TITLEDBORDER +
+ " Freed " + getCleanedUpTitledBorderCount());
+ }
+ System.out.println("OK");
+ }
+
+ private static void attemptGCTitledBorder() {
+ // Attempt gc GC_ATTEMPTS times
+ for (int i = 0; i < GC_ATTEMPTS; i++) {
+ System.gc();
+ System.runFinalization();
+ if (getCleanedUpTitledBorderCount() == TOTAL_TITLEDBORDER) {
+ break;
+ }
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ System.err.println("InterruptedException occurred during Thread.sleep()");
+ }
+ }
+ }
+
+ private static int getCleanedUpTitledBorderCount() {
+ int count = 0;
+ for (WeakReference<TitledBorder> ref : weakRefArrTB) {
+ if (ref.get() == null) {
+ count++;
+ }
+ }
+ return count;
+ }
+}
--- a/test/jdk/sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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,7 @@
import java.awt.Robot;
import java.awt.image.BufferedImage;
+import javax.swing.UIManager;
import static com.sun.swingset3.demos.button.ButtonDemo.DEMO_TITLE;
import static org.jemmy2ext.JemmyExt.*;
@@ -66,8 +67,9 @@
sComparator = new StrictImageComparator();
}
- @Test
- public void test() throws Exception {
+ @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+ public void test(String lookAndFeel) throws Exception {
+ UIManager.setLookAndFeel(lookAndFeel);
Robot rob = new Robot();
new ClassReference(ButtonDemo.class.getCanonicalName()).startApplication();
@@ -112,19 +114,22 @@
assertNotBlack(pressedImage[0]);
return !sComparator.compare(initialButtonImage, pressedImage[0]);
}
+
public String getDescription() {
return "Button with new image";
}
});
} finally {
- if(pressedImage[0] != null) save(pressedImage[0], "button" + i + "_pressed.png");
+ if (pressedImage[0] != null) {
+ save(pressedImage[0], "button" + i + "_pressed.png");
+ }
button.releaseMouse();
//additional instrumentation for JDK-8198920. To be removed after the bug is fixed
button.getOutput().printTrace("JDK-8198920: Button released at " + System.currentTimeMillis());
try {
button.waitState(comp -> actionListenerCalled.get());
button.getOutput().printTrace("JDK-8198920: Action listener was called by " + System.currentTimeMillis());
- } catch(org.netbeans.jemmy.TimeoutExpiredException e) {
+ } catch (org.netbeans.jemmy.TimeoutExpiredException e) {
button.getOutput().printTrace("JDK-8198920: Action listener was not called by " + System.currentTimeMillis());
}
//end of instrumentation for JDK-8198920
--- a/test/jdk/sanity/client/SwingSet/src/ButtonDemoTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ButtonDemoTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -28,6 +28,7 @@
import java.util.concurrent.BlockingQueue;
import javax.swing.ButtonModel;
import javax.swing.JButton;
+import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
@@ -93,8 +94,9 @@
"isArmed = false, isEnabled = true, isPressed = false, isSelected = false"
};
- @Test
- public void test() throws Exception {
+ @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+ public void test(String lookAndFeel) throws Exception {
+ UIManager.setLookAndFeel(lookAndFeel);
new ClassReference(ButtonDemo.class.getCanonicalName()).startApplication();
--- a/test/jdk/sanity/client/SwingSet/src/ComboBoxDemoTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ComboBoxDemoTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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,6 +24,7 @@
import org.jtregext.GuiTestListener;
import com.sun.swingset3.demos.combobox.ComboBoxDemo;
import static org.testng.AssertJUnit.*;
+import javax.swing.UIManager;
import org.testng.annotations.Test;
import org.netbeans.jemmy.ClassReference;
import org.netbeans.jemmy.operators.JComboBoxOperator;
@@ -50,6 +51,7 @@
public class ComboBoxDemoTest {
private static enum ComboBoxInfo {
+
PRESETS("Presets:"),
HAIR("Hair:"),
EYES_N_NOSE("Eyes & Nose:"),
@@ -63,9 +65,9 @@
}
- @Test
- public void test() throws Exception {
-
+ @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+ public void test(String lookAndFeel) throws Exception {
+ UIManager.setLookAndFeel(lookAndFeel);
new ClassReference(ComboBoxDemo.class.getCanonicalName()).startApplication();
JFrameOperator frame = new JFrameOperator(DEMO_TITLE);
--- a/test/jdk/sanity/client/SwingSet/src/ListDemoTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ListDemoTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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
@@ -26,6 +26,7 @@
import java.awt.Component;
import javax.swing.JList;
+import javax.swing.UIManager;
import org.netbeans.jemmy.ClassReference;
import org.netbeans.jemmy.ComponentChooser;
@@ -67,14 +68,16 @@
public boolean checkComponent(Component comp) {
return getUIValue(listOp, (JList list) -> list.getModel().getSize()) == size;
}
+
public String getDescription() {
return "Model size to be equal to " + size;
}
});
}
- @Test
- public void test() throws Exception {
+ @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+ public void test(String lookAndFeel) throws Exception {
+ UIManager.setLookAndFeel(lookAndFeel);
new ClassReference(ListDemo.class.getCanonicalName()).startApplication();
--- a/test/jdk/sanity/client/SwingSet/src/OptionPaneDemoTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/OptionPaneDemoTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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
@@ -70,8 +70,9 @@
public static final String YES = "Yes";
public static final String SELECT_AN_OPTION = UIManager.getString("OptionPane.titleText");
- @Test
- public void test() throws Exception {
+ @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+ public void test(String lookAndFeel) throws Exception {
+ UIManager.setLookAndFeel(lookAndFeel);
new ClassReference(OptionPaneDemo.class.getCanonicalName()).startApplication();
@@ -94,7 +95,7 @@
private void useInputDialog(JFrameOperator jfo, String textToType, String buttonToPush) {
new JButtonOperator(jfo, INPUT_BUTTON).pushNoBlock();
JDialogOperator jdo = new JDialogOperator(INPUT);
- if(textToType != null) {
+ if (textToType != null) {
JTextFieldOperator jto = new JTextFieldOperator(jdo);
jto.typeText(textToType);
jto.waitText(textToType);
@@ -146,7 +147,7 @@
}
private void callADialogAndClose(JFrameOperator jfo, String buttonToOpenDialog,
- String dialogTitle, String buttonToPush) {
+ String dialogTitle, String buttonToPush) {
new JButtonOperator(jfo, buttonToOpenDialog).pushNoBlock();
JDialogOperator jdo = new JDialogOperator(dialogTitle);
new JButtonOperator(jdo, buttonToPush).push();
--- a/test/jdk/sanity/client/SwingSet/src/ProgressBarDemoTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ProgressBarDemoTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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,6 +25,7 @@
import com.sun.swingset3.demos.progressbar.ProgressBarDemo;
import static com.sun.swingset3.demos.progressbar.ProgressBarDemo.*;
import java.awt.Component;
+import javax.swing.UIManager;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
import org.netbeans.jemmy.ClassReference;
@@ -55,9 +56,9 @@
private final static long PROGRESS_BAR_TIMEOUT = 180000;
- @Test
- public void test() throws Exception {
-
+ @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+ public void test(String lookAndFeel) throws Exception {
+ UIManager.setLookAndFeel(lookAndFeel);
new ClassReference(ProgressBarDemo.class.getCanonicalName()).startApplication();
JFrameOperator frame = new JFrameOperator(DEMO_TITLE);
--- a/test/jdk/sanity/client/SwingSet/src/ScrollPaneDemoTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ScrollPaneDemoTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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,6 +25,7 @@
import com.sun.swingset3.demos.scrollpane.ScrollPaneDemo;
import static com.sun.swingset3.demos.scrollpane.ScrollPaneDemo.DEMO_TITLE;
import static org.testng.AssertJUnit.*;
+import javax.swing.UIManager;
import org.testng.annotations.Test;
import org.netbeans.jemmy.ClassReference;
import org.netbeans.jemmy.operators.JFrameOperator;
@@ -49,8 +50,9 @@
@Listeners(GuiTestListener.class)
public class ScrollPaneDemoTest {
- @Test
- public void test() throws Exception {
+ @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+ public void test(String lookAndFeel) throws Exception {
+ UIManager.setLookAndFeel(lookAndFeel);
new ClassReference(ScrollPaneDemo.class.getName()).startApplication();
--- a/test/jdk/sanity/client/SwingSet/src/SpinnerDemoTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/SpinnerDemoTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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,6 +25,7 @@
import com.sun.swingset3.demos.spinner.SpinnerDemo;
import static com.sun.swingset3.demos.spinner.SpinnerDemo.DEMO_TITLE;
import java.text.DecimalFormat;
+import javax.swing.UIManager;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
import org.netbeans.jemmy.ClassReference;
@@ -54,8 +55,9 @@
private static final int SPINNERS_COUNT = 9;
private static final DecimalFormat decimalFormat = new DecimalFormat();
- @Test
- public void test() throws Exception {
+ @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+ public void test(String lookAndFeel) throws Exception {
+ UIManager.setLookAndFeel(lookAndFeel);
new ClassReference(SpinnerDemo.class.getCanonicalName()).startApplication();
JFrameOperator frame = new JFrameOperator(DEMO_TITLE);
--- a/test/jdk/sanity/client/SwingSet/src/TabbedPaneDemoTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/TabbedPaneDemoTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -26,6 +26,7 @@
import static com.sun.swingset3.demos.tabbedpane.TabbedPaneDemo.*;
import static org.jemmy2ext.JemmyExt.getLabeledContainerOperator;
import static org.testng.AssertJUnit.*;
+import javax.swing.UIManager;
import org.testng.annotations.Test;
import org.netbeans.jemmy.ClassReference;
import org.netbeans.jemmy.operators.ContainerOperator;
@@ -52,8 +53,9 @@
@Listeners(GuiTestListener.class)
public class TabbedPaneDemoTest {
- @Test
- public void test() throws Exception {
+ @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+ public void test(String lookAndFeel) throws Exception {
+ UIManager.setLookAndFeel(lookAndFeel);
new ClassReference(TabbedPaneDemo.class.getCanonicalName()).startApplication();
JFrameOperator mainFrame = new JFrameOperator(DEMO_TITLE);
--- a/test/jdk/sanity/client/SwingSet/src/TableDemoTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/TableDemoTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -33,6 +33,7 @@
import java.util.List;
import javax.swing.JTable;
+import javax.swing.UIManager;
import org.jtregext.GuiTestListener;
import org.netbeans.jemmy.ClassReference;
@@ -104,8 +105,9 @@
*
* @throws Exception
*/
- @Test
- public void test() throws Exception {
+ @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+ public void test(String lookAndFeel) throws Exception {
+ UIManager.setLookAndFeel(lookAndFeel);
new ClassReference(TableDemo.class.getCanonicalName()).startApplication();
--- a/test/jdk/sanity/client/SwingSet/src/ToggleButtonDemoTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ToggleButtonDemoTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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
@@ -28,6 +28,7 @@
import com.sun.swingset3.demos.togglebutton.ToggleButtonDemo;
import static com.sun.swingset3.demos.togglebutton.ToggleButtonDemo.*;
import java.util.function.BiFunction;
+import javax.swing.UIManager;
import org.jemmy2ext.JemmyExt.ByClassChooser;
import static org.jemmy2ext.JemmyExt.EXACT_STRING_COMPARATOR;
import static org.jemmy2ext.JemmyExt.getBorderTitledJPanelOperator;
@@ -65,8 +66,9 @@
@Listeners(GuiTestListener.class)
public class ToggleButtonDemoTest {
- @Test
- public void test() throws Exception {
+ @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+ public void test(String lookAndFeel) throws Exception {
+ UIManager.setLookAndFeel(lookAndFeel);
new ClassReference(ToggleButtonDemo.class.getCanonicalName()).startApplication();
JFrameOperator mainFrame = new JFrameOperator(ToggleButtonDemo.class.getAnnotation(DemoProperties.class).value());
--- a/test/jdk/sanity/client/SwingSet/src/TreeDemoTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/TreeDemoTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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,6 +25,7 @@
import static com.sun.swingset3.demos.tree.TreeDemo.DEMO_TITLE;
import java.awt.Component;
+import javax.swing.UIManager;
import javax.swing.tree.TreePath;
import org.jtregext.GuiTestListener;
@@ -68,14 +69,16 @@
public boolean checkComponent(Component comp) {
return tree.getRowCount() == count;
}
+
public String getDescription() {
return "A tree to have " + count + " rows";
}
});
}
- @Test
- public void test() throws Exception {
+ @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+ public void test(String lookAndFeel) throws Exception {
+ UIManager.setLookAndFeel(lookAndFeel);
new ClassReference(TreeDemo.class.getCanonicalName()).startApplication();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/java2d/marlin/ScaleClipTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Path2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.Raster;
+import java.io.File;
+import java.io.IOException;
+import javax.imageio.ImageIO;
+
+/**
+ * Scaled Line Clipping rendering test
+ *
+ * @test
+ * @summary verify that scaled line is properly rendered
+ * @bug 8210335
+ */
+public class ScaleClipTest {
+
+ static final boolean SAVE_IMAGE = false;
+ static final int SIZE = 50;
+
+ enum SCALE_MODE {
+ ORTHO,
+ NON_ORTHO,
+ COMPLEX
+ };
+
+ public static void main(String[] args) {
+
+ // First display which renderer is tested:
+ // JDK9 only:
+ System.setProperty("sun.java2d.renderer.verbose", "true");
+
+ System.out.println("ScaleClipTest: size = " + SIZE);
+
+ final BufferedImage image = new BufferedImage(SIZE, SIZE, BufferedImage.TYPE_INT_ARGB);
+
+ boolean fail = false;
+
+ // testNegativeScale:
+ for (SCALE_MODE mode : SCALE_MODE.values()) {
+ try {
+ testNegativeScale(image, mode);
+ } catch (IllegalStateException ise) {
+ System.err.println("testNegativeScale[" + mode + "] failed:");
+ ise.printStackTrace();
+ fail = true;
+ }
+ }
+
+ // testMarginScale:
+ for (SCALE_MODE mode : SCALE_MODE.values()) {
+ try {
+ testMarginScale(image, mode);
+ } catch (IllegalStateException ise) {
+ System.err.println("testMarginScale[" + mode + "] failed:");
+ ise.printStackTrace();
+ fail = true;
+ }
+ }
+
+ // Fail at the end:
+ if (fail) {
+ throw new RuntimeException("ScaleClipTest has failures.");
+ }
+ }
+
+ private static void testNegativeScale(final BufferedImage image, final SCALE_MODE mode) {
+
+ final Graphics2D g2d = (Graphics2D) image.getGraphics();
+ try {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
+
+ g2d.setBackground(Color.WHITE);
+ g2d.clearRect(0, 0, SIZE, SIZE);
+
+ g2d.setColor(Color.BLACK);
+
+ // Bug in TransformingPathConsumer2D.adjustClipScale()
+ // non ortho scale only
+ final double scale = -1.0;
+
+ final AffineTransform at;
+ switch (mode) {
+ default:
+ case ORTHO:
+ at = AffineTransform.getScaleInstance(scale, scale);
+ break;
+ case NON_ORTHO:
+ at = AffineTransform.getScaleInstance(scale, scale + 1e-5);
+ break;
+ case COMPLEX:
+ at = AffineTransform.getScaleInstance(scale, scale);
+ at.concatenate(AffineTransform.getShearInstance(1e-4, 1e-4));
+ break;
+ }
+ g2d.setTransform(at);
+
+ // Set cap/join to reduce clip margin:
+ g2d.setStroke(new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+
+ final Path2D p = new Path2D.Double();
+ p.moveTo(scale * 10, scale * 10);
+ p.lineTo(scale * (SIZE - 10), scale * (SIZE - 10));
+
+ g2d.draw(p);
+
+ if (SAVE_IMAGE) {
+ try {
+ final File file = new File("ScaleClipTest-testNegativeScale-" + mode + ".png");
+
+ System.out.println("Writing file: " + file.getAbsolutePath());
+ ImageIO.write(image, "PNG", file);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+
+ // Check image:
+ // 25, 25 = black
+ checkPixel(image.getData(), 25, 25, Color.BLACK.getRGB());
+
+ } finally {
+ g2d.dispose();
+ }
+ }
+
+ private static void testMarginScale(final BufferedImage image, final SCALE_MODE mode) {
+
+ final Graphics2D g2d = (Graphics2D) image.getGraphics();
+ try {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
+
+ g2d.setBackground(Color.WHITE);
+ g2d.clearRect(0, 0, SIZE, SIZE);
+
+ g2d.setColor(Color.BLACK);
+
+ // Bug in Stroker.init()
+ // ortho scale only: scale used twice !
+ final double scale = 1e-2;
+
+ final AffineTransform at;
+ switch (mode) {
+ default:
+ case ORTHO:
+ at = AffineTransform.getScaleInstance(scale, scale);
+ break;
+ case NON_ORTHO:
+ at = AffineTransform.getScaleInstance(scale, scale + 1e-5);
+ break;
+ case COMPLEX:
+ at = AffineTransform.getScaleInstance(scale, scale);
+ at.concatenate(AffineTransform.getShearInstance(1e-4, 1e-4));
+ break;
+ }
+ g2d.setTransform(at);
+
+ final double invScale = 1.0 / scale;
+
+ // Set cap/join to reduce clip margin:
+ final float w = (float) (3.0 * invScale);
+ g2d.setStroke(new BasicStroke(w, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+
+ final Path2D p = new Path2D.Double();
+ p.moveTo(invScale * -0.5, invScale * 10);
+ p.lineTo(invScale * -0.5, invScale * (SIZE - 10));
+
+ g2d.draw(p);
+
+ if (SAVE_IMAGE) {
+ try {
+ final File file = new File("ScaleClipTest-testMarginScale-" + mode + ".png");
+
+ System.out.println("Writing file: " + file.getAbsolutePath());
+ ImageIO.write(image, "PNG", file);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+
+ // Check image:
+ // 0, 25 = black
+ checkPixel(image.getData(), 0, 25, Color.BLACK.getRGB());
+ } finally {
+ g2d.dispose();
+ }
+ }
+
+ private static void checkPixel(final Raster raster,
+ final int x, final int y,
+ final int expected) {
+
+ final int[] rgb = (int[]) raster.getDataElements(x, y, null);
+
+ if (rgb[0] != expected) {
+ throw new IllegalStateException("bad pixel at (" + x + ", " + y
+ + ") = " + rgb[0] + " expected: " + expected);
+ }
+ }
+
+}
--- a/test/jdk/sun/misc/URLClassPath/ClassnameCharTest.java Thu Sep 27 08:49:12 2018 -0700
+++ b/test/jdk/sun/misc/URLClassPath/ClassnameCharTest.java Thu Sep 27 10:49:10 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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,7 +25,7 @@
* @bug 4957669 5017871
* @summary cannot load class names containing some JSR 202 characters;
* plugin does not escape unicode character in http request
- * @modules java.desktop/sun.applet
+ * @modules java.base/sun.net.www
* jdk.httpserver
* @compile -XDignore.symbol.file=true ClassnameCharTest.java
* @run main ClassnameCharTest
@@ -33,9 +33,14 @@
import java.io.*;
import java.net.*;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.CodeSource;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.jar.*;
import com.sun.net.httpserver.*;
-import sun.applet.AppletClassLoader;
+import sun.net.www.ParseUtil;
public class ClassnameCharTest {
static String FNPrefix = System.getProperty("test.src", ".") + File.separator;
@@ -79,7 +84,7 @@
try {
URL base = new URL("http://localhost:" + server.getAddress().getPort());
System.out.println ("Server: listening on " + base);
- MyAppletClassLoader acl = new MyAppletClassLoader(base);
+ MyURLClassLoader acl = new MyURLClassLoader(base);
Class<?> class1 = acl.findClass("fo o");
System.out.println("class1 = " + class1);
pass();
@@ -90,15 +95,95 @@
server.stop(0);
}
}
-
- static class MyAppletClassLoader extends AppletClassLoader {
- MyAppletClassLoader(URL base) {
- super(base);
+ // the class loader code was copied from the now deleted AppletClassLoader
+ static class MyURLClassLoader extends URLClassLoader {
+ private URL base; /* applet code base URL */
+ private CodeSource codesource; /* codesource for the base URL */
+ private AccessControlContext acc;
+ MyURLClassLoader(URL base) {
+ super(new URL[0]);
+ this.base = base;
+ this.codesource =
+ new CodeSource(base, (java.security.cert.Certificate[]) null);
+ acc = AccessController.getContext();
}
@Override
public Class<?> findClass(String name) throws ClassNotFoundException {
- return super.findClass(name);
+ int index = name.indexOf(';');
+ String cookie = "";
+ if(index != -1) {
+ cookie = name.substring(index, name.length());
+ name = name.substring(0, index);
+ }
+
+ // check loaded JAR files
+ try {
+ return super.findClass(name);
+ } catch (ClassNotFoundException e) {
+ }
+
+ // Otherwise, try loading the class from the code base URL
+ // final String path = name.replace('.', '/').concat(".class").concat(cookie);
+ String encodedName = ParseUtil.encodePath(name.replace('.', '/'), false);
+ final String path = (new StringBuffer(encodedName)).append(".class").append(cookie).toString();
+ try {
+ byte[] b = AccessController.doPrivileged(
+ new PrivilegedExceptionAction<byte[]>() {
+ public byte[] run() throws IOException {
+ try {
+ URL finalURL = new URL(base, path);
+
+ // Make sure the codebase won't be modified
+ if (base.getProtocol().equals(finalURL.getProtocol()) &&
+ base.getHost().equals(finalURL.getHost()) &&
+ base.getPort() == finalURL.getPort()) {
+ return getBytes(finalURL);
+ }
+ else {
+ return null;
+ }
+ } catch (Exception e) {
+ return null;
+ }
+ }
+ }, acc);
+
+ if (b != null) {
+ return defineClass(name, b, 0, b.length, codesource);
+ } else {
+ throw new ClassNotFoundException(name);
+ }
+ } catch (PrivilegedActionException e) {
+ throw new ClassNotFoundException(name, e.getException());
+ }
+ }
+
+ /*
+ * Returns the contents of the specified URL as an array of bytes.
+ */
+ private static byte[] getBytes(URL url) throws IOException {
+ URLConnection uc = url.openConnection();
+ if (uc instanceof java.net.HttpURLConnection) {
+ java.net.HttpURLConnection huc = (java.net.HttpURLConnection) uc;
+ int code = huc.getResponseCode();
+ if (code >= java.net.HttpURLConnection.HTTP_BAD_REQUEST) {
+ throw new IOException("open HTTP connection failed.");
+ }
+ }
+ int len = uc.getContentLength();
+
+ InputStream in = new BufferedInputStream(uc.getInputStream());
+
+ byte[] b;
+ try {
+ b = in.readAllBytes();
+ if (len != -1 && b.length != len)
+ throw new EOFException("Expected:" + len + ", read:" + b.length);
+ } finally {
+ in.close();
+ }
+ return b;
}
}