提交 843bc085 编写于 作者: A aefimov

Merge

......@@ -918,3 +918,10 @@ b01c6e5aa43c784fc66465b56227ddd9aa29eee6 jdk8u191-b01
2db6890a956723ac347b573217d91bbbedbb0528 jdk8u201-b00
2db6890a956723ac347b573217d91bbbedbb0528 jdk8u191-b02
89e2889d02d2f5dabdeda7f60cf80a8df3100eb4 jdk8u191-b03
94e4769c6d69241f9eb7164a85fc91fc83faab5c jdk8u191-b04
51b6cc7fbd98a87c6cdb5c70b7dbe25bb10e0dd7 jdk8u182-b00
bead1ed7344f2911f5bed83639cf5160596561ef jdk8u192-b00
444b4528c8ecdd39b5923820fa2ed6d583808b5e jdk8u192-b01
e56bb18a4dff4c234c5949c750f910a1ed92fafe jdk8u192-b02
cadea780bc765ccca4aa919522e876b368c58145 jdk8u192-b03
b17237c1ab9c4670d939fef09a6bbecdecad824a jdk8u192-b04
......@@ -247,16 +247,28 @@ endif
##########################################################################################
# Copy msvcrXX.dll on windows
# Copy the microsoft runtime libraries on windows
ifeq ($(OPENJDK_TARGET_OS), windows)
MSVCR_TARGET := $(JDK_OUTPUTDIR)/bin/$(notdir $(MSVCR_DLL))
# Chmod to avoid permission issues if bundles are unpacked on unix platforms.
$(MSVCR_TARGET): $(MSVCR_DLL)
$(call install-file)
define copy-and-chmod
$(install-file)
$(CHMOD) a+rx $@
endef
# Use separate macro calls in case the source files are not in the same
# directory.
$(eval $(call SetupCopyFiles,COPY_MSVCR, \
DEST := $(JDK_OUTPUTDIR)/bin, \
FILES := $(MSVCR_DLL), \
MACRO := copy-and-chmod))
$(eval $(call SetupCopyFiles,COPY_MSVCP, \
DEST := $(JDK_OUTPUTDIR)/bin, \
FILES := $(MSVCP_DLL), \
MACRO := copy-and-chmod))
COPY_FILES += $(MSVCR_TARGET)
COPY_FILES += $(COPY_MSVCR) $(COPY_MSVCP)
endif
##########################################################################################
......
#
# 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
......@@ -265,7 +265,10 @@ $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents: $(BUILD_TOOLS) $(IMAGES_OU
$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar.contents: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents
$(MKDIR) -p $(@D)
$(RM) $@ $@.tmp
$(GREP) -e '\.class$$' $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents > $@.tmp
# Cygwin grep does not match $ as end of line if there are windows line
# endings in the input.
$(TR) -d '\r' < $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents \
| $(GREP) -e '\.class$$' > $@.tmp
ifneq ($(PROFILE), )
ifneq ($(strip $(RT_JAR_INCLUDE_TYPES)), )
# Add back classes from excluded packages (fixing the $ substitution in the process)
......@@ -279,9 +282,11 @@ $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar.contents: $(IMAGES_OUTPUTDIR)/lib$
$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.resources.jar.contents: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents
$(MKDIR) -p $(@D)
$(RM) $@ $@.tmp
$(GREP) -v -e '\.class$$' \
-e '/_the\.*' -e '^_the\.*' -e '\\_the\.*' -e 'javac_state' \
$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents > $@.tmp
# Cygwin grep does not match $ as end of line if there are windows line
# endings in the input.
$(TR) -d '\r' < $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents \
| $(GREP) -v -e '\.class$$' \
-e '/_the\.*' -e '^_the\.*' -e '\\_the\.*' -e 'javac_state' > $@.tmp
ifneq ($(PROFILE), )
# Strip out all META-INF/services/ entries
$(GREP) -v -e 'META-INF/services/' $@.tmp > $@.tmp2
......
......@@ -23,9 +23,6 @@
# questions.
#
# Openwin is defined on Solaris.
OPENWIN_LIB := $(OPENWIN_HOME)/lib
WIN_AWT_LIB := $(JDK_OUTPUTDIR)/objs/libawt/awt.lib
##########################################################################################
......@@ -477,7 +474,6 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBAWT, \
ASFLAGS := $(LIBAWT_ASFLAGS), \
MAPFILE := $(LIBAWT_MAPFILE), \
LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_solaris := -R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR), \
LDFLAGS_SUFFIX_linux := -ljvm $(LIBM) $(LIBDL) -ljava, \
LDFLAGS_SUFFIX_solaris := -ljvm $(LIBM) $(LIBDL) -ljava -lc, \
LDFLAGS_SUFFIX_aix :=-ljvm $(LIBM) $(LIBDL) -ljava -lm,\
......@@ -636,14 +632,7 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),)
$(X_CFLAGS), \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt_xawt/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(X_LIBS) $(LIBAWT_XAWT_LDFLAGS), \
LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN) \
$(call SET_SHARED_LIBRARY_ORIGIN,/..), \
LDFLAGS_solaris := -L$(OPENWIN_HOME)/sfw/lib$(OPENJDK_TARGET_CPU_ISADIR) \
-L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) \
-R$(OPENWIN_HOME)/sfw/lib$(OPENJDK_TARGET_CPU_ISADIR) \
-R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) \
-R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) \
$(X_LIBS) $(LIBAWT_XAWT_LDFLAGS) \
$(call SET_SHARED_LIBRARY_ORIGIN) \
$(call SET_SHARED_LIBRARY_ORIGIN,/..), \
LDFLAGS_SUFFIX := $(LIBAWT_XAWT_LDFLAGS_SUFFIX), \
......@@ -839,9 +828,7 @@ ifeq ($(BUILD_HEADLESS), true)
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..) \
-R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) \
-R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR), \
LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN)., \
REORDER := $(LIBAWT_HEADLESS_REORDER), \
LDFLAGS_SUFFIX_linux := -ljvm -lawt -lm $(LIBDL) -ljava, \
......@@ -904,6 +891,10 @@ ifeq ($(OPENJDK_TARGET_OS), linux)
BUILD_LIBFONTMANAGER_ExtensionSubtables.cpp_CXXFLAGS := -fno-strict-aliasing
endif
# LDFLAGS clarification:
# Filter relevant linker flags disallowing unresolved symbols as we cannot
# build-time decide to which library to link against (libawt_headless or
# libawt_xawt). See JDK-8196516 for details.
$(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \
LIBRARY := fontmanager, \
OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
......@@ -918,7 +909,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \
CFLAGS_windows = -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/windows \
-DCC_NOEX, \
MAPFILE := $(BUILD_LIBFONTMANAGER_MAPFILE), \
LDFLAGS := $(subst -Xlinker -z -Xlinker defs,,$(LDFLAGS_JDKLIB)) $(LDFLAGS_CXX_JDK) \
LDFLAGS := $(subst -Xlinker -z -Xlinker defs,, \
$(subst -Wl$(COMMA)-z$(COMMA)defs,,$(LDFLAGS_JDKLIB))) $(LDFLAGS_CXX_JDK) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_SUFFIX := $(BUILD_LIBFONTMANAGER_FONTLIB), \
LDFLAGS_SUFFIX_linux := -lawt $(LIBM) $(LIBCXX) -ljava -ljvm -lc, \
......@@ -1071,7 +1063,7 @@ else # OPENJDK_TARGET_OS not windows
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjawt/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_solaris := -L$(OPENWIN_HOME)/sfw/lib$(OPENJDK_TARGET_CPU_ISADIR) -L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR), \
LDFLAGS_solaris := $(X_LIBS), \
LDFLAGS_SUFFIX_linux := $(JAWT_LIBS) $(LDFLAGS_JDKLIB_SUFFIX), \
LDFLAGS_SUFFIX_aix := $(JAWT_LIBS) $(LDFLAGS_JDKLIB_SUFFIX),\
LDFLAGS_SUFFIX_solaris := $(JAWT_LIBS) $(LDFLAGS_JDKLIB_SUFFIX) -lXrender, \
......@@ -1169,11 +1161,11 @@ ifndef OPENJDK
CFLAGS := $(CFLAGS_JDKLIB) \
-I$(JDK_TOPDIR)/src/share/javavm/export \
-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export \
-I$(OPENWIN_HOME)/include, \
$(X_CFLAGS), \
MAPFILE := $(SUNWJDGA_MAPFILE), \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_SUFFIX := -L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -ldga -lX11 $(LIBDL) -lc, \
LDFLAGS_SUFFIX := $(X_LIBS) -ldga -lX11 $(LIBDL) -lc, \
OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libsunwjdga, \
DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
......@@ -1224,8 +1216,6 @@ ifndef BUILD_HEADLESS_ONLY
else ifeq ($(OPENJDK_TARGET_OS), windows)
LIBSPLASHSCREEN_CFLAGS += -DWITH_WIN32
else ifeq ($(OPENJDK_TARGET_OS), solaris)
LIBSPLASHSCREEN_CFLAGS += -DWITH_X11 -I$(OPENWIN_HOME)/include -I$(OPENWIN_HOME)/include/X11/extensions
else
LIBSPLASHSCREEN_CFLAGS += -DWITH_X11 $(X_CFLAGS)
endif
......@@ -1245,10 +1235,7 @@ ifndef BUILD_HEADLESS_ONLY
-framework JavaNativeFoundation
else ifeq ($(OPENJDK_TARGET_OS), windows)
LIBSPLASHSCREEN_LDFLAGS_SUFFIX += kernel32.lib user32.lib gdi32.lib delayimp.lib -DELAYLOAD:user32.dll
else ifeq ($(OPENJDK_TARGET_OS), solaris)
# Solaris still uses OPENWIN_LIB ..
LIBSPLASHSCREEN_LDFLAGS_SUFFIX += -L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -lX11 -lXext $(LIBM) -lpthread
else # .. all other Unixes can use X_LIBS
else
LIBSPLASHSCREEN_LDFLAGS_SUFFIX += $(X_LIBS) -lX11 -lXext $(LIBM) -lpthread
endif
......
......@@ -383,6 +383,11 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
cmdtoargs.c
# Staticically link with c runtime on windows.
LIBJLI_CFLAGS := $(filter-out -MD, $(LIBJLI_CFLAGS))
# Supply the name of the C runtime lib.
LIBJLI_CFLAGS += -DMSVCR_DLL_NAME='"$(notdir $(MSVCR_DLL))"'
ifneq ($(MSVCP_DLL), )
LIBJLI_CFLAGS += -DMSVCP_DLL_NAME='"$(notdir $(MSVCP_DLL))"'
endif
else ifneq ($(OPENJDK_TARGET_OS), macosx)
BUILD_LIBJLI_FILES += java_md_common.c
......
......@@ -94,7 +94,6 @@ SUNWprivate_1.1 {
Java_java_awt_Rectangle_initIDs;
Java_sun_awt_image_BufImgSurfaceData_initIDs;
Java_sun_awt_image_BufImgSurfaceData_initRaster;
Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData;
Java_sun_awt_image_BytePackedRaster_initIDs;
Java_sun_awt_image_ImagingLib_lookupByteBI;
Java_sun_awt_image_ImagingLib_lookupByteRaster;
......
......@@ -96,7 +96,6 @@ SUNWprivate_1.1 {
Java_sun_awt_image_BufImgSurfaceData_initIDs;
Java_sun_awt_image_BufImgSurfaceData_initRaster;
Java_sun_awt_image_BufImgSurfaceData_setSurfaceData;
Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData;
Java_sun_awt_image_BytePackedRaster_initIDs;
Java_sun_awt_image_ImagingLib_lookupByteBI;
Java_sun_awt_image_ImagingLib_lookupByteRaster;
......
......@@ -158,6 +158,7 @@ SUNWprivate_1.1 {
Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl;
Java_sun_awt_X11_XRobotPeer_mouseWheelImpl;
Java_sun_awt_X11_XRobotPeer_setup;
Java_sun_awt_X11_XRobotPeer_loadNativeLibraries;
Java_sun_awt_X11_XToolkit_getNumberOfButtonsImpl;
Java_java_awt_Component_initIDs;
Java_java_awt_Container_initIDs;
......
/*
* Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -93,7 +93,9 @@ class GTKEngine {
*/
static enum Settings {
GTK_FONT_NAME,
GTK_ICON_SIZES
GTK_ICON_SIZES,
GTK_CURSOR_BLINK,
GTK_CURSOR_BLINK_TIME
}
/* Custom regions are needed for representing regions that don't exist
......
/*
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -371,7 +371,17 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
int vProgWidth = 22 - (progXThickness * 2);
int vProgHeight = 80 - (progYThickness * 2);
Integer caretBlinkRate = Integer.valueOf(500);
Integer caretBlinkRate;
if (Boolean.FALSE.equals(GTKEngine.INSTANCE.getSetting(
GTKEngine.Settings.GTK_CURSOR_BLINK))) {
caretBlinkRate = Integer.valueOf(0);
} else {
caretBlinkRate = (Integer) GTKEngine.INSTANCE.getSetting(
GTKEngine.Settings.GTK_CURSOR_BLINK_TIME);
if (caretBlinkRate == null) {
caretBlinkRate = Integer.valueOf(500);
}
}
Insets zeroInsets = new InsetsUIResource(0, 0, 0, 0);
Double defaultCaretAspectRatio = new Double(0.025);
......
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
......@@ -28,6 +28,8 @@ package com.sun.jndi.ldap;
import java.util.Hashtable;
import java.util.Vector;
import java.util.EventObject;
import java.util.Iterator;
import java.util.Map;
import javax.naming.*;
import javax.naming.event.*;
......@@ -204,31 +206,35 @@ final class EventSupport {
* Removes <tt>l</tt> from all notifiers in this context.
*/
synchronized void removeNamingListener(NamingListener l) {
if (debug) System.err.println("EventSupport removing listener");
if (debug) {
System.err.println("EventSupport removing listener");
}
// Go through list of notifiers, remove 'l' from each.
// If 'l' is notifier's only listener, remove notifier too.
for (NamingEventNotifier notifier : notifiers.values()) {
Iterator<NamingEventNotifier> iterator = notifiers.values().iterator();
while (iterator.hasNext()) {
NamingEventNotifier notifier = iterator.next();
if (notifier != null) {
if (debug)
if (debug) {
System.err.println("EventSupport removing listener from notifier");
}
notifier.removeNamingListener(l);
if (!notifier.hasNamingListeners()) {
if (debug)
if (debug) {
System.err.println("EventSupport stopping notifier");
}
notifier.stop();
notifiers.remove(notifier.info);
iterator.remove();
}
}
}
// Remove from list of unsolicited notifier
if (debug) System.err.println("EventSupport removing unsolicited: " +
unsolicited);
if (debug) {
System.err.println("EventSupport removing unsolicited: " + unsolicited);
}
if (unsolicited != null) {
unsolicited.removeElement(l);
}
}
synchronized boolean hasUnsolicited() {
......
......@@ -39,6 +39,7 @@ import java.security.PrivilegedAction;
import com.sun.jndi.ldap.pool.PoolCleaner;
import com.sun.jndi.ldap.pool.Pool;
import sun.misc.InnocuousThread;
/**
* Contains utilities for managing connection pools of LdapClient.
......@@ -163,7 +164,17 @@ public final class LdapPoolManager {
if (idleTimeout > 0) {
// Create cleaner to expire idle connections
new PoolCleaner(idleTimeout, pools).start();
PrivilegedAction<Void> pa = new PrivilegedAction<Void>() {
public Void run() {
Thread t = InnocuousThread.newSystemThread(
"LDAP PoolCleaner",
new PoolCleaner(idleTimeout, pools));
assert t.getContextClassLoader() == null;
t.setDaemon(true);
t.start();
return null;
}};
AccessController.doPrivileged(pa);
}
if (debug) {
......
......@@ -30,7 +30,7 @@ package com.sun.jndi.ldap.pool;
*
* @author Rosanna Lee
*/
final public class PoolCleaner extends Thread {
final public class PoolCleaner implements Runnable {
final private Pool[] pools;
final private long period;
......@@ -42,9 +42,9 @@ final public class PoolCleaner extends Thread {
super();
this.period = period;
this.pools = pools.clone();
setDaemon(true);
}
@Override
public void run() {
long threshold;
while (true) {
......
/*
* 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.tracing;
......
/*
* Copyright (c) 1995, 2003, 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
......@@ -171,7 +171,7 @@ public class FilteredImageSource implements ImageProducer {
* @param ic the consumer for the filtered image
* @see ImageConsumer
*/
public void startProduction(ImageConsumer ic) {
public synchronized void startProduction(ImageConsumer ic) {
if (proxies == null) {
proxies = new Hashtable();
}
......@@ -198,7 +198,7 @@ public class FilteredImageSource implements ImageProducer {
*
* @see ImageConsumer
*/
public void requestTopDownLeftRightResend(ImageConsumer ic) {
public synchronized void requestTopDownLeftRightResend(ImageConsumer ic) {
if (proxies != null) {
ImageFilter imgf = (ImageFilter) proxies.get(ic);
if (imgf != null) {
......
......@@ -88,8 +88,8 @@ class IdentityScope extends Identity {
try {
Class.forName(classname);
} catch (ClassNotFoundException e) {
//Security.error("unable to establish a system scope from " +
// classname);
System.err.println("unable to establish a system scope from " +
classname);
e.printStackTrace();
}
}
......
......@@ -1051,7 +1051,7 @@ public abstract class Signature extends SignatureSpi {
debug.println("Further warnings of this type will "
+ "be suppressed");
}
new Exception("Call trace").printStackTrace();
new Exception("Debug call trace").printStackTrace();
}
}
Exception lastException = null;
......
/*
* Copyright (c) 2012, 2015, 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
......@@ -692,9 +692,8 @@ public final class IsoFields {
return (R) temporal.with(WEEK_BASED_YEAR,
Math.addExact(temporal.get(WEEK_BASED_YEAR), amount));
case QUARTER_YEARS:
// no overflow (256 is multiple of 4)
return (R) temporal.plus(amount / 256, YEARS)
.plus((amount % 256) * 3, MONTHS);
return (R) temporal.plus(amount / 4, YEARS)
.plus((amount % 4) * 3, MONTHS);
default:
throw new IllegalStateException("Unreachable");
}
......
......@@ -491,7 +491,7 @@ public class HashMap<K,V> extends AbstractMap<K,V>
}
/**
* Implements Map.putAll and Map constructor
* Implements Map.putAll and Map constructor.
*
* @param m the map
* @param evict false when initially constructing this map, else
......@@ -558,7 +558,7 @@ public class HashMap<K,V> extends AbstractMap<K,V>
}
/**
* Implements Map.get and related methods
* Implements Map.get and related methods.
*
* @param hash hash for key
* @param key the key
......@@ -613,7 +613,7 @@ public class HashMap<K,V> extends AbstractMap<K,V>
}
/**
* Implements Map.put and related methods
* Implements Map.put and related methods.
*
* @param hash hash for key
* @param key the key
......@@ -701,7 +701,7 @@ public class HashMap<K,V> extends AbstractMap<K,V>
}
threshold = newThr;
@SuppressWarnings({"rawtypes","unchecked"})
Node<K,V>[] newTab = (Node<K,V>[])new Node[newCap];
Node<K,V>[] newTab = (Node<K,V>[])new Node[newCap];
table = newTab;
if (oldTab != null) {
for (int j = 0; j < oldCap; ++j) {
......@@ -801,7 +801,7 @@ public class HashMap<K,V> extends AbstractMap<K,V>
}
/**
* Implements Map.remove and related methods
* Implements Map.remove and related methods.
*
* @param hash hash for key
* @param key the key
......@@ -1364,8 +1364,11 @@ public class HashMap<K,V> extends AbstractMap<K,V>
}
/**
* Reconstitute the {@code HashMap} instance from a stream (i.e.,
* deserialize it).
* Reconstitutes this map from a stream (that is, deserializes it).
* @param s the stream
* @throws ClassNotFoundException if the class of a serialized object
* could not be found
* @throws IOException if an I/O error occurs
*/
private void readObject(java.io.ObjectInputStream s)
throws IOException, ClassNotFoundException {
......@@ -1905,7 +1908,6 @@ public class HashMap<K,V> extends AbstractMap<K,V>
/**
* Forms tree of the nodes linked from this node.
* @return root of tree
*/
final void treeify(Node<K,V>[] tab) {
TreeNode<K,V> root = null;
......@@ -2043,8 +2045,11 @@ public class HashMap<K,V> extends AbstractMap<K,V>
return;
if (root.parent != null)
root = root.root();
if (root == null || root.right == null ||
(rl = root.left) == null || rl.left == null) {
if (root == null
|| (movable
&& (root.right == null
|| (rl = root.left) == null
|| rl.left == null))) {
tab[index] = first.untreeify(map); // too small
return;
}
......@@ -2273,7 +2278,7 @@ public class HashMap<K,V> extends AbstractMap<K,V>
static <K,V> TreeNode<K,V> balanceDeletion(TreeNode<K,V> root,
TreeNode<K,V> x) {
for (TreeNode<K,V> xp, xpl, xpr;;) {
for (TreeNode<K,V> xp, xpl, xpr;;) {
if (x == null || x == root)
return root;
else if ((xp = x.parent) == null) {
......
......@@ -910,12 +910,12 @@ public class ImageView extends View {
}
synchronized(ImageView.this) {
if ((changed & 1) == 1 && (state & WIDTH_FLAG) == 0) {
width = newWidth;
}
if ((changed & 2) == 2 && (state & HEIGHT_FLAG) == 0) {
if ((changed & 1) == 1 && (state & HEIGHT_FLAG) == 0) {
height = newHeight;
}
if ((changed & 2) == 2 && (state & WIDTH_FLAG) == 0) {
width = newWidth;
}
if ((state & LOADING_FLAG) == LOADING_FLAG) {
// No need to resize or repaint, still in the process of
// loading.
......
/*
* 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. 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.util.Collections;
......
/*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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,6 @@
package sun.awt.image;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.GraphicsConfiguration;
import java.awt.image.ColorModel;
......@@ -38,9 +37,6 @@ import java.awt.image.DataBuffer;
import sun.java2d.SurfaceData;
import sun.java2d.SunGraphics2D;
import sun.java2d.StateTrackable;
import sun.java2d.StateTrackable.*;
import sun.java2d.StateTracker;
import sun.java2d.loops.SurfaceType;
import sun.java2d.loops.CompositeType;
import sun.java2d.loops.RenderLoops;
......@@ -409,8 +405,6 @@ public class BufImgSurfaceData extends SurfaceData {
// their pixels are immediately retrievable anyway.
}
private static native void freeNativeICMData(long pData);
/**
* Returns destination Image associated with this SurfaceData.
*/
......@@ -424,12 +418,5 @@ public class BufImgSurfaceData extends SurfaceData {
private ICMColorData(long pData) {
this.pData = pData;
}
public void finalize() {
if (pData != 0L) {
BufImgSurfaceData.freeNativeICMData(pData);
pData = 0L;
}
}
}
}
......@@ -146,7 +146,7 @@ final class Dasher implements sun.awt.geom.PathConsumer2D {
if (dashOn) {
if (starting) {
firstSegmentsBuffer = Helpers.widenArray(firstSegmentsBuffer,
firstSegidx, type - 2);
firstSegidx, type - 2 + 1);
firstSegmentsBuffer[firstSegidx++] = type;
System.arraycopy(pts, off, firstSegmentsBuffer, firstSegidx, type - 2);
firstSegidx += type - 2;
......
......@@ -26,7 +26,10 @@
package sun.misc;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.ProtectionDomain;
import java.security.PrivilegedAction;
import java.util.concurrent.atomic.AtomicInteger;
/**
* A thread that has no permissions, is not a member of any user-defined
......@@ -36,15 +39,44 @@ import java.security.ProtectionDomain;
*/
public final class InnocuousThread extends Thread {
private static final Unsafe UNSAFE;
private static final ThreadGroup THREADGROUP;
private static final long THREAD_LOCALS;
private static final long INHERITABLE_THREAD_LOCALS;
private static final ThreadGroup INNOCUOUSTHREADGROUP;
private static final AccessControlContext ACC;
private static final long THREADLOCALS;
private static final long INHERITABLETHREADLOCALS;
private static final long INHERITEDACCESSCONTROLCONTEXT;
private static final long CONTEXTCLASSLOADER;
private static final AtomicInteger threadNumber = new AtomicInteger(1);
private static String newName() {
return "InnocuousThread-" + threadNumber.getAndIncrement();
}
/**
* Returns a new InnocuousThread with an auto-generated thread name.
* Its context class loader is set to null.
*/
public static Thread newSystemThread(Runnable target) {
return newSystemThread(newName(), target);
}
/**
* Returns a new InnocuousThread with null context class loader.
*/
public static Thread newSystemThread(String name, Runnable target) {
return new InnocuousThread(INNOCUOUSTHREADGROUP,
target, name, null);
}
public InnocuousThread(Runnable target) {
super(THREADGROUP, target, "anInnocuousThread");
super(INNOCUOUSTHREADGROUP, target, newName());
UNSAFE.putOrderedObject(this, INHERITEDACCESSCONTROLCONTEXT, ACC);
eraseThreadLocals();
}
private InnocuousThread(ThreadGroup group, Runnable target, String name, ClassLoader tccl) {
super(group, target, name, 0L);
UNSAFE.putOrderedObject(this, INHERITEDACCESSCONTROLCONTEXT, ACC);
UNSAFE.putOrderedObject(this, CONTEXTCLASSLOADER, tccl);
eraseThreadLocals();
}
......@@ -79,8 +111,8 @@ public final class InnocuousThread extends Thread {
* Drops all thread locals (and inherited thread locals).
*/
public void eraseThreadLocals() {
UNSAFE.putObject(this, THREADLOCALS, null);
UNSAFE.putObject(this, INHERITABLETHREADLOCALS, null);
UNSAFE.putObject(this, THREAD_LOCALS, null);
UNSAFE.putObject(this, INHERITABLE_THREAD_LOCALS, null);
}
// Use Unsafe to access Thread group and ThreadGroup parent fields
......@@ -95,12 +127,14 @@ public final class InnocuousThread extends Thread {
Class<?> tk = Thread.class;
Class<?> gk = ThreadGroup.class;
THREADLOCALS = UNSAFE.objectFieldOffset
THREAD_LOCALS = UNSAFE.objectFieldOffset
(tk.getDeclaredField("threadLocals"));
INHERITABLETHREADLOCALS = UNSAFE.objectFieldOffset
INHERITABLE_THREAD_LOCALS = UNSAFE.objectFieldOffset
(tk.getDeclaredField("inheritableThreadLocals"));
INHERITEDACCESSCONTROLCONTEXT = UNSAFE.objectFieldOffset
(tk.getDeclaredField("inheritedAccessControlContext"));
CONTEXTCLASSLOADER = UNSAFE.objectFieldOffset
(tk.getDeclaredField("contextClassLoader"));
long tg = UNSAFE.objectFieldOffset(tk.getDeclaredField("group"));
long gp = UNSAFE.objectFieldOffset(gk.getDeclaredField("parent"));
......@@ -113,7 +147,14 @@ public final class InnocuousThread extends Thread {
break;
group = parent;
}
THREADGROUP = new ThreadGroup(group, "InnocuousThreadGroup");
final ThreadGroup root = group;
INNOCUOUSTHREADGROUP = AccessController.doPrivileged(
new PrivilegedAction<ThreadGroup>() {
@Override
public ThreadGroup run() {
return new ThreadGroup(root, "InnocuousThreadGroup");
}
});
} catch (Exception e) {
throw new Error(e);
}
......
......@@ -275,7 +275,7 @@ public final class ProviderList {
}
if (debug != null) {
debug.println("Loading all providers");
new Exception("Call trace").printStackTrace();
new Exception("Debug Info. Call trace:").printStackTrace();
}
int n = 0;
for (int i = 0; i < configs.length; i++) {
......
......@@ -347,7 +347,6 @@ public class PKCS8Key implements PrivateKey {
}
} catch (IOException e) {
// e.printStackTrace ();
throw new InvalidKeyException("IOException : " +
e.getMessage());
}
......
......@@ -257,47 +257,51 @@ final class P11Signature extends SignatureSpi {
session = token.killSession(session);
return;
}
// "cancel" operation by finishing it
// XXX make sure all this always works correctly
if (mode == M_SIGN) {
try {
if (type == T_UPDATE) {
token.p11.C_SignFinal(session.id(), 0);
} else {
byte[] digest;
if (type == T_DIGEST) {
digest = md.digest();
} else { // T_RAW
digest = buffer;
try {
// "cancel" operation by finishing it
// XXX make sure all this always works correctly
if (mode == M_SIGN) {
try {
if (type == T_UPDATE) {
token.p11.C_SignFinal(session.id(), 0);
} else {
byte[] digest;
if (type == T_DIGEST) {
digest = md.digest();
} else { // T_RAW
digest = buffer;
}
token.p11.C_Sign(session.id(), digest);
}
token.p11.C_Sign(session.id(), digest);
}
} catch (PKCS11Exception e) {
throw new ProviderException("cancel failed", e);
}
} else { // M_VERIFY
try {
byte[] signature;
if (keyAlgorithm.equals("DSA")) {
signature = new byte[40];
} else {
signature = new byte[(p11Key.length() + 7) >> 3];
} catch (PKCS11Exception e) {
throw new ProviderException("cancel failed", e);
}
if (type == T_UPDATE) {
token.p11.C_VerifyFinal(session.id(), signature);
} else {
byte[] digest;
if (type == T_DIGEST) {
digest = md.digest();
} else { // T_RAW
digest = buffer;
} else { // M_VERIFY
try {
byte[] signature;
if (keyAlgorithm.equals("DSA")) {
signature = new byte[40];
} else {
signature = new byte[(p11Key.length() + 7) >> 3];
}
token.p11.C_Verify(session.id(), digest, signature);
if (type == T_UPDATE) {
token.p11.C_VerifyFinal(session.id(), signature);
} else {
byte[] digest;
if (type == T_DIGEST) {
digest = md.digest();
} else { // T_RAW
digest = buffer;
}
token.p11.C_Verify(session.id(), digest, signature);
}
} catch (PKCS11Exception e) {
// will fail since the signature is incorrect
// XXX check error code
}
} catch (PKCS11Exception e) {
// will fail since the signature is incorrect
// XXX check error code
}
} finally {
session = token.releaseSession(session);
}
}
......@@ -316,6 +320,8 @@ final class P11Signature extends SignatureSpi {
}
initialized = true;
} catch (PKCS11Exception e) {
// release session when initialization failed
session = token.releaseSession(session);
throw new ProviderException("Initialization failed", e);
}
if (bytesProcessed != 0) {
......@@ -476,6 +482,8 @@ final class P11Signature extends SignatureSpi {
}
bytesProcessed += len;
} catch (PKCS11Exception e) {
initialized = false;
session = token.releaseSession(session);
throw new ProviderException(e);
}
break;
......@@ -523,6 +531,8 @@ final class P11Signature extends SignatureSpi {
bytesProcessed += len;
byteBuffer.position(ofs + len);
} catch (PKCS11Exception e) {
initialized = false;
session = token.releaseSession(session);
throw new ProviderException("Update failed", e);
}
break;
......
......@@ -186,6 +186,7 @@ public class AuthPolicyFile extends javax.security.auth.Policy {
} catch (Exception e) {
// ignore, treat it like we have no keystore
if (debug != null) {
debug.println("Debug info only. No keystore.");
e.printStackTrace();
}
return null;
......@@ -260,7 +261,7 @@ public class AuthPolicyFile extends javax.security.auth.Policy {
loaded_one = true;
} catch (Exception e) {
if (debug != null) {
debug.println("error reading policy " + e);
debug.println("Debug info only. Error reading policy " + e);
e.printStackTrace();
}
// ignore that policy
......
......@@ -434,18 +434,6 @@ abstract class DSA extends SignatureSpi {
return printable;
}
private static void debug(Exception e) {
if (debug) {
e.printStackTrace();
}
}
private static void debug(String s) {
if (debug) {
System.err.println(s);
}
}
/**
* Standard SHA224withDSA implementation as defined in FIPS186-3.
*/
......
......@@ -563,7 +563,8 @@ public class PolicyFile extends java.security.Policy {
loaded_policy = true;
} catch (Exception e) {
if (debug != null) {
debug.println("error reading policy "+e);
debug.println(
"Debug info only. Error reading policy " +e);
e.printStackTrace();
}
// ignore that policy
......@@ -616,6 +617,7 @@ public class PolicyFile extends java.security.Policy {
} catch (Exception e) {
// ignore, treat it like we have no keystore
if (debug != null) {
debug.println("Debug info only. Ignoring exception.");
e.printStackTrace();
}
}
......
......@@ -53,6 +53,11 @@ public abstract class SSLContextImpl extends SSLContextSpi {
private X509TrustManager trustManager;
private SecureRandom secureRandom;
private final static Collection<CipherSuite> clientCustomizedCipherSuites =
getCustomizedCipherSuites("jdk.tls.client.cipherSuites");
private final static Collection<CipherSuite> serverCustomizedCipherSuites =
getCustomizedCipherSuites("jdk.tls.server.cipherSuites");
SSLContextImpl() {
ephemeralKeyManager = new EphemeralKeyManager();
clientCache = new SSLSessionContextImpl();
......@@ -279,19 +284,50 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}
/*
* Return the list of all available CipherSuites with a priority of
* minPriority or above.
* Return the list of all available CipherSuites that are supported
* using currently installed providers.
*/
private static CipherSuiteList getApplicableCipherSuiteList(
ProtocolList protocols, boolean onlyEnabled) {
private static CipherSuiteList getApplicableSupportedCipherSuiteList(
ProtocolList protocols) {
return getApplicableCipherSuiteList(
CipherSuite.allowedCipherSuites(),
protocols, CipherSuite.SUPPORTED_SUITES_PRIORITY);
}
int minPriority = CipherSuite.SUPPORTED_SUITES_PRIORITY;
if (onlyEnabled) {
minPriority = CipherSuite.DEFAULT_SUITES_PRIORITY;
/*
* Return the list of all available CipherSuites that are default enabled
* in client or server side.
*/
private static CipherSuiteList getApplicableEnabledCipherSuiteList(
ProtocolList protocols, boolean isClient) {
if (isClient) {
if (!clientCustomizedCipherSuites.isEmpty()) {
return getApplicableCipherSuiteList(
clientCustomizedCipherSuites,
protocols, CipherSuite.SUPPORTED_SUITES_PRIORITY);
}
} else {
if (!serverCustomizedCipherSuites.isEmpty()) {
return getApplicableCipherSuiteList(
serverCustomizedCipherSuites,
protocols, CipherSuite.SUPPORTED_SUITES_PRIORITY);
}
}
Collection<CipherSuite> allowedCipherSuites =
CipherSuite.allowedCipherSuites();
return getApplicableCipherSuiteList(
CipherSuite.allowedCipherSuites(),
protocols, CipherSuite.DEFAULT_SUITES_PRIORITY);
}
/*
* Return the list of available CipherSuites which are applicable to
* the specified protocols.
*/
private static CipherSuiteList getApplicableCipherSuiteList(
Collection<CipherSuite> allowedCipherSuites,
ProtocolList protocols, int minPriority) {
TreeSet<CipherSuite> suites = new TreeSet<>();
if (!(protocols.collection().isEmpty()) &&
......@@ -335,6 +371,67 @@ public abstract class SSLContextImpl extends SSLContextSpi {
return new CipherSuiteList(suites);
}
/*
* Get the customized cipher suites specified by the given system property.
*/
private static Collection<CipherSuite> getCustomizedCipherSuites(
String propertyName) {
String property = AccessController.doPrivileged(
new GetPropertyAction(propertyName));
if (debug != null && Debug.isOn("sslctx")) {
System.out.println(
"System property " + propertyName + " is set to '" +
property + "'");
}
if (property != null && property.length() != 0) {
// remove double quote marks from beginning/end of the property
if (property.length() > 1 && property.charAt(0) == '"' &&
property.charAt(property.length() - 1) == '"') {
property = property.substring(1, property.length() - 1);
}
}
if (property != null && property.length() != 0) {
String[] cipherSuiteNames = property.split(",");
Collection<CipherSuite> cipherSuites =
new ArrayList<>(cipherSuiteNames.length);
for (int i = 0; i < cipherSuiteNames.length; i++) {
cipherSuiteNames[i] = cipherSuiteNames[i].trim();
if (cipherSuiteNames[i].isEmpty()) {
continue;
}
CipherSuite suite;
try {
suite = CipherSuite.valueOf(cipherSuiteNames[i]);
} catch (IllegalArgumentException iae) {
if (debug != null && Debug.isOn("sslctx")) {
System.out.println(
"Unknown or unsupported cipher suite name: " +
cipherSuiteNames[i]);
}
continue;
}
if (suite.isAvailable()) {
cipherSuites.add(suite);
} else {
if (debug != null && Debug.isOn("sslctx")) {
System.out.println(
"The current installed providers do not " +
"support cipher suite: " + cipherSuiteNames[i]);
}
}
}
return cipherSuites;
}
return Collections.emptyList();
}
private static String[] getAvailableProtocols(
ProtocolVersion[] protocolCandidates) {
......@@ -429,10 +526,10 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}));
}
supportedCipherSuiteList = getApplicableCipherSuiteList(
supportedProtocolList, false); // all supported
serverDefaultCipherSuiteList = getApplicableCipherSuiteList(
serverDefaultProtocolList, true); // enabled only
supportedCipherSuiteList = getApplicableSupportedCipherSuiteList(
supportedProtocolList);
serverDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList(
serverDefaultProtocolList, false);
}
@Override
......@@ -489,8 +586,8 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}));
}
clientDefaultCipherSuiteList = getApplicableCipherSuiteList(
clientDefaultProtocolList, true); // enabled only
clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList(
clientDefaultProtocolList, true);
}
@Override
......@@ -529,8 +626,9 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}));
}
clientDefaultCipherSuiteList = getApplicableCipherSuiteList(
clientDefaultProtocolList, true); // enabled only
clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList(
clientDefaultProtocolList, true);
}
@Override
......@@ -571,8 +669,8 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}));
}
clientDefaultCipherSuiteList = getApplicableCipherSuiteList(
clientDefaultProtocolList, true); // enabled only
clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList(
clientDefaultProtocolList, true);
}
@Override
......@@ -703,8 +801,9 @@ public abstract class SSLContextImpl extends SSLContextSpi {
clientDefaultProtocolList = new ProtocolList(
getAvailableProtocols(candidates));
clientDefaultCipherSuiteList = getApplicableCipherSuiteList(
clientDefaultProtocolList, true); // enabled only
clientDefaultCipherSuiteList =
getApplicableEnabledCipherSuiteList(
clientDefaultProtocolList, true);
} else {
clientDefaultProtocolList = null; // unlikely to be used
clientDefaultCipherSuiteList = null; // unlikely to be used
......
......@@ -1927,13 +1927,21 @@ final public class SSLEngineImpl extends SSLEngine {
case cs_START:
/*
* If we need to change the engine mode and the enabled
* protocols haven't specifically been set by the user,
* change them to the corresponding default ones.
* If we need to change the socket mode and the enabled
* protocols and cipher suites haven't specifically been
* set by the user, change them to the corresponding
* default ones.
*/
if (roleIsServer != (!flag) &&
sslContext.isDefaultProtocolList(enabledProtocols)) {
enabledProtocols = sslContext.getDefaultProtocolList(!flag);
if (roleIsServer != (!flag)) {
if (sslContext.isDefaultProtocolList(enabledProtocols)) {
enabledProtocols =
sslContext.getDefaultProtocolList(!flag);
}
if (sslContext.isDefaultCipherSuiteList(enabledCipherSuites)) {
enabledCipherSuites =
sslContext.getDefaultCipherSuiteList(!flag);
}
}
roleIsServer = !flag;
......
......@@ -2399,13 +2399,22 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
case cs_START:
/*
* If we need to change the socket mode and the enabled
* protocols haven't specifically been set by the user,
* change them to the corresponding default ones.
* protocols and cipher suites haven't specifically been
* set by the user, change them to the corresponding
* default ones.
*/
if (roleIsServer != (!flag) &&
sslContext.isDefaultProtocolList(enabledProtocols)) {
enabledProtocols = sslContext.getDefaultProtocolList(!flag);
if (roleIsServer != (!flag)) {
if (sslContext.isDefaultProtocolList(enabledProtocols)) {
enabledProtocols =
sslContext.getDefaultProtocolList(!flag);
}
if (sslContext.isDefaultCipherSuiteList(enabledCipherSuites)) {
enabledCipherSuites =
sslContext.getDefaultCipherSuiteList(!flag);
}
}
roleIsServer = !flag;
break;
......
......@@ -2209,7 +2209,19 @@ public final class Main {
private void doPrintEntries(PrintStream out)
throws Exception
{
out.println(rb.getString("Keystore.type.") + keyStore.getType());
// Adjust displayed keystore type if needed.
String keystoreTypeToPrint = keyStore.getType();
if ("JKS".equalsIgnoreCase(keystoreTypeToPrint)) {
if (ksfile != null && ksfile.exists()) {
String realType = keyStoreType(ksfile);
// If the magic number does not conform to JKS
// then it must be PKCS12
if (!"JKS".equalsIgnoreCase(realType)) {
keystoreTypeToPrint = P12KEYSTORE;
}
}
}
out.println(rb.getString("Keystore.type.") + keystoreTypeToPrint);
out.println(rb.getString("Keystore.provider.") +
keyStore.getProvider().getName());
out.println();
......
......@@ -75,8 +75,8 @@ public class AnchorCertificates {
} catch (Exception e) {
if (debug != null) {
debug.println("Error parsing cacerts");
e.printStackTrace();
}
e.printStackTrace();
}
return null;
}
......
......@@ -380,8 +380,9 @@ public class SignatureFileVerifier {
if (e.getMessage() != null) {
debug.println(key + ": " + e.getMessage());
} else {
debug.println(key + ": " + algorithm +
" was disabled, no exception msg given.");
debug.println("Debug info only. " + key + ": " +
algorithm +
" was disabled, no exception msg given.");
e.printStackTrace();
}
}
......
......@@ -124,7 +124,8 @@ public class CertificateExtensions implements CertAttrSet<Extension> {
unparseableExtensions.put(ext.getExtensionId().toString(),
new UnparseableExtension(ext, e));
if (debug != null) {
debug.println("Error parsing extension: " + ext);
debug.println("Debug info only." +
" Error parsing extension: " + ext);
e.printStackTrace();
HexDumpEncoder h = new HexDumpEncoder();
System.err.println(h.encodeBuffer(ext.getExtensionValue()));
......
......@@ -393,7 +393,6 @@ public class X509Key implements PublicKey {
throw new InvalidKeyException ("excess key data");
} catch (IOException e) {
// e.printStackTrace ();
throw new InvalidKeyException("IOException: " +
e.getMessage());
}
......
......@@ -4,7 +4,9 @@
*
* 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.
* 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
......
/*
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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,6 +32,7 @@
#include "jni_util.h"
/* Define uintptr_t */
#include "gdefs.h"
#include "Disposer.h"
/**
* This include file contains support code for loops using the
......@@ -79,19 +80,6 @@ Java_sun_awt_image_BufImgSurfaceData_initIDs
"Lsun/awt/image/BufImgSurfaceData$ICMColorData;"));
}
/*
* Class: sun_java2d_SurfaceData
* Method: freeNativeICMData
* Signature: (Ljava/awt/image/IndexColorModel;)V
*/
JNIEXPORT void JNICALL
Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData
(JNIEnv *env, jclass sd, jlong pData)
{
ColorData *cdata = (ColorData*)jlong_to_ptr(pData);
freeICMColorData(cdata);
}
/*
* Class: sun_awt_image_BufImgSurfaceData
* Method: initOps
......@@ -139,6 +127,15 @@ Java_sun_awt_image_BufImgSurfaceData_initRaster(JNIEnv *env, jobject bisd,
bisdo->rasbounds.y2 = height;
}
/*
* Releases native structures associated with BufImgSurfaceData.ICMColorData.
*/
static void BufImg_Dispose_ICMColorData(JNIEnv *env, jlong pData)
{
ColorData *cdata = (ColorData*)jlong_to_ptr(pData);
freeICMColorData(cdata);
}
/*
* Method for disposing native BufImgSD
*/
......@@ -321,6 +318,7 @@ static ColorData *BufImg_SetupICM(JNIEnv *env,
}
(*env)->SetObjectField(env, bisdo->icm, colorDataID, colorData);
Disposer_AddRecord(env, colorData, BufImg_Dispose_ICMColorData, pData);
}
}
......
......@@ -34,6 +34,10 @@ import sun.awt.X11GraphicsConfig;
class XRobotPeer implements RobotPeer {
static {
loadNativeLibraries();
}
private X11GraphicsConfig xgc = null;
/*
* native implementation uses some static shared data (pipes, processes)
......@@ -98,4 +102,5 @@ class XRobotPeer implements RobotPeer {
private static native synchronized void keyReleaseImpl(int keycode);
private static native synchronized void getRGBPixelsImpl(X11GraphicsConfig xgc, int x, int y, int width, int height, int pixelArray[]);
private static native void loadNativeLibraries();
}
/*
* 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
* 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.java2d.x11;
import java.awt.image.*;
......
......@@ -67,38 +67,36 @@ extern jobjectArray lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolea
*/
JNIEXPORT jstring JNICALL
Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
char hostname[NI_MAXHOST+1];
char hostname[NI_MAXHOST + 1];
hostname[0] = '\0';
if (JVM_GetHostName(hostname, NI_MAXHOST)) {
/* Something went wrong, maybe networking is not setup? */
strcpy(hostname, "localhost");
#if defined(__solaris__)
} else {
struct addrinfo hints, *res;
int error;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_UNSPEC;
error = getaddrinfo(hostname, NULL, &hints, &res);
if (error == 0) {
/* host is known to name service */
error = getnameinfo(res->ai_addr,
res->ai_addrlen,
hostname,
NI_MAXHOST,
NULL,
0,
NI_NAMEREQD);
// try to resolve hostname via nameservice
// if it is known but getnameinfo fails, hostname will still be the
// value from gethostname
struct addrinfo hints, *res;
/* if getnameinfo fails hostname is still the value
from gethostname */
// make sure string is null-terminated
hostname[NI_MAXHOST] = '\0';
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_INET;
freeaddrinfo(res);
if (getaddrinfo(hostname, NULL, &hints, &res) == 0) {
getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST,
NULL, 0, NI_NAMEREQD);
freeaddrinfo(res);
}
}
#else
} else {
// make sure string is null-terminated
hostname[NI_MAXHOST] = '\0';
}
#endif
return (*env)->NewStringUTF(env, hostname);
}
......
......@@ -66,49 +66,36 @@
*/
JNIEXPORT jstring JNICALL
Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
char hostname[NI_MAXHOST+1];
char hostname[NI_MAXHOST + 1];
hostname[0] = '\0';
if (JVM_GetHostName(hostname, sizeof(hostname))) {
/* Something went wrong, maybe networking is not setup? */
strcpy(hostname, "localhost");
} else {
// ensure null-terminated
hostname[NI_MAXHOST] = '\0';
/* Solaris doesn't want to give us a fully qualified domain name.
* We do a reverse lookup to try and get one. This works
* if DNS occurs before NIS in /etc/resolv.conf, but fails
* if NIS comes first (it still gets only a partial name).
* We use thread-safe system calls.
*/
#if defined(__solaris__) && defined(AF_INET6)
struct addrinfo hints, *res;
int error;
} else {
// try to resolve hostname via nameservice
// if it is known but getnameinfo fails, hostname will still be the
// value from gethostname
struct addrinfo hints, *res;
// make sure string is null-terminated
hostname[NI_MAXHOST] = '\0';
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_UNSPEC;
error = getaddrinfo(hostname, NULL, &hints, &res);
if (error == 0) {
/* host is known to name service */
error = getnameinfo(res->ai_addr,
res->ai_addrlen,
hostname,
NI_MAXHOST,
NULL,
0,
NI_NAMEREQD);
/* if getnameinfo fails hostname is still the value
from gethostname */
if (getaddrinfo(hostname, NULL, &hints, &res) == 0) {
getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST,
NULL, 0, NI_NAMEREQD);
freeaddrinfo(res);
}
#endif
}
#else
} else {
// make sure string is null-terminated
hostname[NI_MAXHOST] = '\0';
}
#endif
return (*env)->NewStringUTF(env, hostname);
}
......
......@@ -27,6 +27,9 @@
#error This file should not be included in headless library
#endif
#include "jvm_md.h"
#include <dlfcn.h>
#include "awt_p.h"
#include "awt_GraphicsEnv.h"
#define XK_MISCELLANY
......@@ -49,11 +52,46 @@
#include <sys/socket.h>
#endif
static Bool (*compositeQueryExtension) (Display*, int*, int*);
static Status (*compositeQueryVersion) (Display*, int*, int*);
static Window (*compositeGetOverlayWindow) (Display *, Window);
extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
static jint * masks;
static jint num_buttons;
static void *xCompositeHandle;
static const char* XCOMPOSITE = JNI_LIB_NAME("Xcomposite");
static const char* XCOMPOSITE_VERSIONED = VERSIONED_JNI_LIB_NAME("Xcomposite", "1");
static Bool checkXCompositeFunctions(void) {
return (compositeQueryExtension != NULL &&
compositeQueryVersion != NULL &&
compositeGetOverlayWindow != NULL);
}
static void initXCompositeFunctions(void) {
if (xCompositeHandle == NULL) {
xCompositeHandle = dlopen(XCOMPOSITE, RTLD_LAZY | RTLD_GLOBAL);
if (xCompositeHandle == NULL) {
xCompositeHandle = dlopen(XCOMPOSITE_VERSIONED, RTLD_LAZY | RTLD_GLOBAL);
}
}
//*(void **)(&asyncGetCallTraceFunction)
if (xCompositeHandle != NULL) {
*(void **)(&compositeQueryExtension) = dlsym(xCompositeHandle, "XCompositeQueryExtension");
*(void **)(&compositeQueryVersion) = dlsym(xCompositeHandle, "XCompositeQueryVersion");
*(void **)(&compositeGetOverlayWindow) = dlsym(xCompositeHandle, "XCompositeGetOverlayWindow");
}
if (xCompositeHandle && !checkXCompositeFunctions()) {
dlclose(xCompositeHandle);
}
}
static int32_t isXTestAvailable() {
int32_t major_opcode, first_event, first_error;
int32_t event_basep, error_basep, majorp, minorp;
......@@ -88,6 +126,35 @@ static int32_t isXTestAvailable() {
return isXTestAvailable;
}
static Bool hasXCompositeOverlayExtension(Display *display) {
int xoverlay = False;
int eventBase, errorBase;
if (checkXCompositeFunctions() &&
compositeQueryExtension(display, &eventBase, &errorBase))
{
int major = 0;
int minor = 0;
compositeQueryVersion(display, &major, &minor);
if (major > 0 || minor >= 3) {
xoverlay = True;
}
}
return xoverlay;
}
static jboolean isXCompositeDisplay(Display *display, int screenNumber) {
char NET_WM_CM_Sn[25];
snprintf(NET_WM_CM_Sn, sizeof(NET_WM_CM_Sn), "_NET_WM_CM_S%d\0", screenNumber);
Atom managerSelection = XInternAtom(display, NET_WM_CM_Sn, 0);
Window owner = XGetSelectionOwner(display, managerSelection);
return owner != 0;
}
static XImage *getWindowImage(Display * display, Window window,
int32_t x, int32_t y,
......@@ -232,6 +299,12 @@ Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env,
DASSERT(adata != NULL);
rootWindow = XRootWindow(awt_display, adata->awt_visInfo.screen);
if (hasXCompositeOverlayExtension(awt_display) &&
isXCompositeDisplay(awt_display, adata->awt_visInfo.screen))
{
rootWindow = compositeGetOverlayWindow(awt_display, rootWindow);
}
image = getWindowImage(awt_display, rootWindow, x, y, width, height);
/* Array to use to crunch around the pixel values */
......@@ -412,3 +485,8 @@ Java_sun_awt_X11_XRobotPeer_mouseWheelImpl (JNIEnv *env,
AWT_UNLOCK();
}
JNIEXPORT void JNICALL
Java_sun_awt_X11_XRobotPeer_loadNativeLibraries (JNIEnv *env, jclass cls) {
initXCompositeFunctions();
}
......@@ -1051,6 +1051,16 @@ Java_sun_font_FontConfigManager_getFontConfig
CHECK_NULL(fontFileID = (*env)->GetFieldID(env, fcFontClass,
"fontFile", "Ljava/lang/String;"));
jclass fontUtilitiesClass =
(*env)->FindClass(env, "sun/font/FontUtilities");
CHECK_NULL(fontUtilitiesClass);
jfieldID isOpenJDKID =
(*env)->GetStaticFieldID(env, fontUtilitiesClass, "isOpenJDK", "Z");
CHECK_NULL(isOpenJDKID);
jboolean isOpenJDK =
(*env)->GetStaticBooleanField(env, fontUtilitiesClass, isOpenJDKID);
if ((libfontconfig = openFontConfig()) == NULL) {
return;
}
......@@ -1239,6 +1249,7 @@ Java_sun_font_FontConfigManager_getFontConfig
&& (strcmp((char*)fontformat, "TrueType") != 0)
#if defined(__linux__) || defined(_AIX)
&& (strcmp((char*)fontformat, "Type 1") != 0)
&& !(isOpenJDK && (strcmp((char*)fontformat, "CFF") == 0))
#endif
) {
continue;
......
......@@ -1308,9 +1308,6 @@ static GtkWidget *gtk2_get_widget(WidgetType widget_type)
{
result = gtk2_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE] =
(*fp_gtk_entry_new)();
GtkSettings* settings = fp_gtk_widget_get_settings(result);
fp_g_object_set(settings, "gtk-cursor-blink", FALSE, NULL);
}
result = gtk2_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE];
break;
......@@ -1355,10 +1352,6 @@ static GtkWidget *gtk2_get_widget(WidgetType widget_type)
{
gtk2_widgets[_GTK_ENTRY_TYPE] =
(*fp_gtk_entry_new)();
GtkSettings* settings =
fp_gtk_widget_get_settings(gtk2_widgets[_GTK_ENTRY_TYPE]);
fp_g_object_set(settings, "gtk-cursor-blink", FALSE, NULL);
}
result = gtk2_widgets[_GTK_ENTRY_TYPE];
break;
......@@ -1550,9 +1543,6 @@ static GtkWidget *gtk2_get_widget(WidgetType widget_type)
{
result = gtk2_widgets[_GTK_SPIN_BUTTON_TYPE] =
(*fp_gtk_spin_button_new)(NULL, 0, 0);
GtkSettings* settings = fp_gtk_widget_get_settings(result);
fp_g_object_set(settings, "gtk-cursor-blink", FALSE, NULL);
}
result = gtk2_widgets[_GTK_SPIN_BUTTON_TYPE];
break;
......@@ -2502,14 +2492,20 @@ jobject get_string_property(JNIEnv *env, GtkSettings* settings, const gchar* key
return result;
}
/*
jobject get_integer_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
{
gint intval = NULL;
gint intval = NULL;
(*fp_g_object_get)(settings, key, &intval, NULL);
return create_Integer(env, intval);
}*/
}
jobject get_boolean_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
{
gint intval = NULL;
(*fp_g_object_get)(settings, key, &intval, NULL);
return create_Boolean(env, intval);
}
jobject gtk2_get_setting(JNIEnv *env, Setting property)
{
......@@ -2521,6 +2517,10 @@ jobject gtk2_get_setting(JNIEnv *env, Setting property)
return get_string_property(env, settings, "gtk-font-name");
case GTK_ICON_SIZES:
return get_string_property(env, settings, "gtk-icon-sizes");
case GTK_CURSOR_BLINK:
return get_boolean_property(env, settings, "gtk-cursor-blink");
case GTK_CURSOR_BLINK_TIME:
return get_integer_property(env, settings, "gtk-cursor-blink-time");
}
return NULL;
......
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -140,7 +140,9 @@ typedef enum _ColorType
typedef enum _Setting
{
GTK_FONT_NAME,
GTK_ICON_SIZES
GTK_ICON_SIZES,
GTK_CURSOR_BLINK,
GTK_CURSOR_BLINK_TIME
} Setting;
/* GTK types, here to eliminate need for GTK headers at compile time */
......
......@@ -266,26 +266,17 @@ LoadMSVCRT()
* assumed to be present in the "JRE path" directory. If it is not found
* there (or "JRE path" fails to resolve), skip the explicit load and let
* nature take its course, which is likely to be a failure to execute.
* This is clearly completely specific to the exact compiler version
* which isn't very nice, but its hardly the only place.
* No attempt to look for compiler versions in between 2003 and 2010
* as we aren't supporting building with those.
* The makefiles will provide the correct lib contained in quotes in the
* macro MSVCR_DLL_NAME.
*/
#ifdef _MSC_VER
#if _MSC_VER < 1400
#define CRT_DLL "msvcr71.dll"
#endif
#if _MSC_VER >= 1600
#define CRT_DLL "msvcr100.dll"
#endif
#ifdef CRT_DLL
#ifdef MSVCR_DLL_NAME
if (GetJREPath(crtpath, MAXPATHLEN)) {
if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") +
JLI_StrLen(CRT_DLL) >= MAXPATHLEN) {
JLI_StrLen(MSVCR_DLL_NAME) >= MAXPATHLEN) {
JLI_ReportErrorMessage(JRE_ERROR11);
return JNI_FALSE;
}
(void)JLI_StrCat(crtpath, "\\bin\\" CRT_DLL); /* Add crt dll */
(void)JLI_StrCat(crtpath, "\\bin\\" MSVCR_DLL_NAME); /* Add crt dll */
JLI_TraceLauncher("CRT path is %s\n", crtpath);
if (_access(crtpath, 0) == 0) {
if (LoadLibrary(crtpath) == 0) {
......@@ -294,8 +285,24 @@ LoadMSVCRT()
}
}
}
#endif /* CRT_DLL */
#endif /* _MSC_VER */
#endif /* MSVCR_DLL_NAME */
#ifdef MSVCP_DLL_NAME
if (GetJREPath(crtpath, MAXPATHLEN)) {
if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") +
JLI_StrLen(MSVCP_DLL_NAME) >= MAXPATHLEN) {
JLI_ReportErrorMessage(JRE_ERROR11);
return JNI_FALSE;
}
(void)JLI_StrCat(crtpath, "\\bin\\" MSVCP_DLL_NAME); /* Add prt dll */
JLI_TraceLauncher("PRT path is %s\n", crtpath);
if (_access(crtpath, 0) == 0) {
if (LoadLibrary(crtpath) == 0) {
JLI_ReportErrorMessage(DLL_ERROR4, crtpath);
return JNI_FALSE;
}
}
}
#endif /* MSVCP_DLL_NAME */
loaded = 1;
}
return JNI_TRUE;
......
#
#
# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2003, 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
......@@ -243,7 +243,7 @@ sequence.fallback=lucida,symbols,\
# Exclusion Ranges
exclusion.alphabetic=0700-1e9f,1f00-2017,2020-20ab,20ad-f8ff
exclusion.alphabetic=0700-1cff,1d80-1e9f,1f00-2017,2020-20ab,20ad-f8ff
exclusion.chinese-gb18030=0390-03d6,2200-22ef,2701-27be
exclusion.hebrew=0041-005a,0060-007a,007f-00ff,20ac-20ac
......
......@@ -452,7 +452,7 @@ WinAccessBridge::queuePackage(char *buffer, long bufsize) {
*/
BOOL
WinAccessBridge::receiveAQueuedPackage() {
AccessBridgeQueueElement *element;
AccessBridgeQueueElement *element = NULL;
PrintDebugString("in WinAccessBridge::receiveAQueuedPackage()");
......@@ -464,15 +464,6 @@ WinAccessBridge::receiveAQueuedPackage() {
QueueReturns result = messageQueue->remove(&element);
PrintDebugString(" 'element->buffer' contains:");
DEBUG_CODE(PackageType *type = (PackageType *) element->buffer);
DEBUG_CODE(FocusGainedPackageTag *pkg = (FocusGainedPackageTag *) (((char *) element->buffer) + sizeof(PackageType)));
DEBUG_CODE(PrintDebugString(" PackageType = %X", *type));
#ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
DEBUG_CODE(PrintDebugString(" EventPackage: vmID = %X, event = %p, source = %p", pkg->vmID, pkg->Event, pkg->AccessibleContextSource));
#else // JOBJECT64 is jlong (64 bit)
DEBUG_CODE(PrintDebugString(" EventPackage: vmID = %X, event = %016I64X, source = %016I64X", pkg->vmID, pkg->Event, pkg->AccessibleContextSource));
#endif
switch (result) {
case cQueueBroken:
......
......@@ -35,6 +35,7 @@
#include <BaseTsd.h>
#include <wincrypt.h>
#include <stdio.h>
#include <memory>
#define OID_EKU_ANY "2.5.29.37.0"
......@@ -47,14 +48,27 @@
#define KEYSTORE_EXCEPTION "java/security/KeyStoreException"
#define PROVIDER_EXCEPTION "java/security/ProviderException"
#define SIGNATURE_EXCEPTION "java/security/SignatureException"
#define OUT_OF_MEMORY_ERROR "java/lang/OutOfMemoryError"
extern "C" {
/*
* Throws an arbitrary Java exception with the given message.
*/
void ThrowExceptionWithMessage(JNIEnv *env, const char *exceptionName,
const char *szMessage)
{
jclass exceptionClazz = env->FindClass(exceptionName);
if (exceptionClazz != NULL) {
env->ThrowNew(exceptionClazz, szMessage);
}
}
/*
* Throws an arbitrary Java exception.
* The exception message is a Windows system error message.
*/
void ThrowException(JNIEnv *env, char *exceptionName, DWORD dwError)
void ThrowException(JNIEnv *env, const char *exceptionName, DWORD dwError)
{
char szMessage[1024];
szMessage[0] = '\0';
......@@ -65,12 +79,22 @@ void ThrowException(JNIEnv *env, char *exceptionName, DWORD dwError)
strcpy(szMessage, "Unknown error");
}
jclass exceptionClazz = env->FindClass(exceptionName);
if (exceptionClazz != NULL) {
env->ThrowNew(exceptionClazz, szMessage);
}
ThrowExceptionWithMessage(env, exceptionName, szMessage);
}
/*
* Overloaded 'operator new[]' variant, which will raise Java's
* OutOfMemoryError in the case of a failure.
*/
void* operator new[](std::size_t size, JNIEnv *env)
{
void* buf = ::operator new[](size, std::nothrow);
if (buf == NULL) {
ThrowExceptionWithMessage(env, OUT_OF_MEMORY_ERROR,
"Native memory allocation failed");
}
return buf;
}
/*
* Maps the name of a hash algorithm to an algorithm identifier.
......@@ -423,7 +447,11 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh
NULL, 0)) > 1) {
// Found friendly name
pszNameString = new char[cchNameString];
pszNameString = new (env) char[cchNameString];
if (pszNameString == NULL) {
__leave;
}
CertGetNameString(pc,
CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL,
pszNameString, cchNameString);
......@@ -560,7 +588,10 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash
}
// Copy hash from Java to native buffer
pHashBuffer = new jbyte[jHashSize];
pHashBuffer = new (env) jbyte[jHashSize];
if (pHashBuffer == NULL) {
__leave;
}
env->GetByteArrayRegion(jHash, 0, jHashSize, pHashBuffer);
// Set hash value in the hash object
......@@ -598,7 +629,10 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash
__leave;
}
pSignedHashBuffer = new jbyte[dwBufLen];
pSignedHashBuffer = new (env) jbyte[dwBufLen];
if (pSignedHashBuffer == NULL) {
__leave;
}
if (::CryptSignHash(hHash, dwKeySpec, NULL, dwFlags, (BYTE*)pSignedHashBuffer, &dwBufLen) == FALSE)
{
ThrowException(env, SIGNATURE_EXCEPTION, GetLastError());
......@@ -686,9 +720,16 @@ JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_verifySignedHas
}
// Copy hash and signedHash from Java to native buffer
pHashBuffer = new jbyte[jHashSize];
pHashBuffer = new (env) jbyte[jHashSize];
if (pHashBuffer == NULL) {
__leave;
}
env->GetByteArrayRegion(jHash, 0, jHashSize, pHashBuffer);
pSignedHashBuffer = new jbyte[jSignedHashSize];
pSignedHashBuffer = new (env) jbyte[jSignedHashSize];
if (pSignedHashBuffer == NULL) {
__leave;
}
env->GetByteArrayRegion(jSignedHash, 0, jSignedHashSize,
pSignedHashBuffer);
......@@ -901,7 +942,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate
}
// Copy encoding from Java to native buffer
pbCertEncoding = new jbyte[jCertEncodingSize];
pbCertEncoding = new (env) jbyte[jCertEncodingSize];
if (pbCertEncoding == NULL) {
__leave;
}
env->GetByteArrayRegion(jCertEncoding, 0, jCertEncodingSize, pbCertEncoding);
// Create a certificate context from the encoded cert
......@@ -914,7 +958,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate
// Set the certificate's friendly name
int size = env->GetStringLength(jCertAliasName);
pszCertAliasName = new WCHAR[size + 1];
pszCertAliasName = new (env) WCHAR[size + 1];
if (pszCertAliasName == NULL) {
__leave;
}
jCertAliasChars = env->GetStringChars(jCertAliasName, NULL);
memcpy(pszCertAliasName, jCertAliasChars, size * sizeof(WCHAR));
......@@ -952,7 +999,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate
__leave;
}
pszContainerName = new char[dwDataLen];
pszContainerName = new (env) char[dwDataLen];
if (pszContainerName == NULL) {
__leave;
}
if (! ::CryptGetProvParam(
(HCRYPTPROV) hCryptProv,
......@@ -966,7 +1016,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate
}
// Convert to a wide char string
pwszContainerName = new WCHAR[dwDataLen];
pwszContainerName = new (env) WCHAR[dwDataLen];
if (pwszContainerName == NULL) {
__leave;
}
if (mbstowcs(pwszContainerName, pszContainerName, dwDataLen) == 0) {
ThrowException(env, KEYSTORE_EXCEPTION, GetLastError());
......@@ -989,7 +1042,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate
__leave;
}
pszProviderName = new char[dwDataLen];
pszProviderName = new (env) char[dwDataLen];
if (pszProviderName == NULL) {
__leave;
}
if (! ::CryptGetProvParam(
(HCRYPTPROV) hCryptProv,
......@@ -1003,7 +1059,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate
}
// Convert to a wide char string
pwszProviderName = new WCHAR[dwDataLen];
pwszProviderName = new (env) WCHAR[dwDataLen];
if (pwszProviderName == NULL) {
__leave;
}
if (mbstowcs(pwszProviderName, pszProviderName, dwDataLen) == 0) {
ThrowException(env, KEYSTORE_EXCEPTION, GetLastError());
......@@ -1143,7 +1202,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_removeCertificate
}
// Copy encoding from Java to native buffer
pbCertEncoding = new jbyte[jCertEncodingSize];
pbCertEncoding = new (env) jbyte[jCertEncodingSize];
if (pbCertEncoding == NULL) {
__leave;
}
env->GetByteArrayRegion(jCertEncoding, 0, jCertEncodingSize, pbCertEncoding);
// Create a certificate context from the encoded cert
......@@ -1166,7 +1228,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_removeCertificate
if ((cchNameString = ::CertGetNameString(pTBDCertContext,
CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, NULL, 0)) > 1) {
pszNameString = new char[cchNameString];
pszNameString = new (env) char[cchNameString];
if (pszNameString == NULL) {
__leave;
}
::CertGetNameString(pTBDCertContext,
CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, pszNameString,
......@@ -1316,7 +1381,10 @@ JNIEXPORT jlong JNICALL Java_sun_security_mscapi_RSACipher_findCertificateUsingA
continue; // not found
}
pszNameString = new char[cchNameString];
pszNameString = new (env) char[cchNameString];
if (pszNameString == NULL) {
__leave;
}
if (::CertGetNameString(pCertContext,
CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, pszNameString,
......@@ -1492,7 +1560,10 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSACipher_encryptDecrypt
__try
{
// Copy data from Java buffer to native buffer
pData = new jbyte[dwBufLen];
pData = new (env) jbyte[dwBufLen];
if (pData == NULL) {
__leave;
}
env->GetByteArrayRegion(jData, 0, dwBufLen, pData);
if (doEncrypt == JNI_TRUE) {
......@@ -1566,7 +1637,10 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getPublicKeyB
__leave;
}
pbKeyBlob = new BYTE[dwBlobLen];
pbKeyBlob = new (env) BYTE[dwBlobLen];
if (pbKeyBlob == NULL) {
__leave;
}
// Generate key blob
if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0,
......@@ -1620,8 +1694,12 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getExponent
RSAPUBKEY* pRsaPubKey =
(RSAPUBKEY *) (keyBlob + sizeof(PUBLICKEYSTRUC));
int len = sizeof(pRsaPubKey->pubexp);
exponentBytes = new jbyte[len];
exponentBytes = new (env) jbyte[len];
if (exponentBytes == NULL) {
__leave;
}
// convert from little-endian while copying from blob
for (int i = 0, j = len - 1; i < len; i++, j--) {
......@@ -1672,9 +1750,12 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getModulus
RSAPUBKEY* pRsaPubKey =
(RSAPUBKEY *) (keyBlob + sizeof(PUBLICKEYSTRUC));
int len = pRsaPubKey->bitlen / 8;
modulusBytes = new jbyte[len];
int len = pRsaPubKey->bitlen / 8;
modulusBytes = new (env) jbyte[len];
if (modulusBytes == NULL) {
__leave;
}
BYTE * pbModulus =
(BYTE *) (keyBlob + sizeof(PUBLICKEYSTRUC) + sizeof(RSAPUBKEY));
......@@ -1795,12 +1876,16 @@ jbyteArray generateKeyBlob(
(jKeyBitLength / 8);
}
jbyte* jBlobBytes = new jbyte[jBlobLength];
jbyte* jBlobBytes = NULL;
jbyte* jBlobElement;
jbyteArray jBlob = NULL;
jsize jElementLength;
__try {
jBlobBytes = new (env) jbyte[jBlobLength];
if (jBlobBytes == NULL) {
__leave;
}
BLOBHEADER *pBlobHeader = (BLOBHEADER *) jBlobBytes;
if (bGeneratePrivateKeyBlob) {
......
......@@ -3812,6 +3812,8 @@ MsgRouting AwtComponent::WmChar(UINT character, UINT repCnt, UINT flags,
MsgRouting AwtComponent::WmForwardChar(WCHAR character, LPARAM lParam,
BOOL synthetic)
{
deadKeyActive = FALSE;
// just post WM_CHAR with unicode key value
DefWindowProc(WM_CHAR, (WPARAM)character, lParam);
return mrConsume;
......
......@@ -196,15 +196,7 @@ void AwtScrollPane::SetScrollInfo(int orient, int max, int page,
// and the page size changes
posAfter = GetScrollPos(orient);
if (posBefore != posAfter) {
if(max==0 && posAfter==0) {
// Caller used nMin==nMax idiom to hide scrollbar.
// On the new themes (Windows XP, Vista) this would reset
// scroll position to zero ("just inside the range") (6404832).
//
PostScrollEvent(orient, SB_THUMBPOSITION, posBefore);
}else{
PostScrollEvent(orient, SB_THUMBPOSITION, posAfter);
}
PostScrollEvent(orient, SB_THUMBPOSITION, posAfter);
}
}
......@@ -263,8 +255,11 @@ void AwtScrollPane::RecalcSizes(int parentWidth, int parentHeight,
(policy == java_awt_ScrollPane_SCROLLBARS_ALWAYS));
env->DeleteLocalRef(hAdj);
} else {
SetScrollInfo(SB_HORZ, 0, 0,
/* Set scroll info to imitate the behaviour and since we don't
need to display it, explicitly don't show the bar */
SetScrollInfo(SB_HORZ, childWidth - 1, parentWidth,
(policy == java_awt_ScrollPane_SCROLLBARS_ALWAYS));
::ShowScrollBar(GetHWnd(), SB_HORZ, false);
}
if (needsVert) {
......@@ -275,8 +270,11 @@ void AwtScrollPane::RecalcSizes(int parentWidth, int parentHeight,
(policy == java_awt_ScrollPane_SCROLLBARS_ALWAYS));
env->DeleteLocalRef(vAdj);
} else {
SetScrollInfo(SB_VERT, 0, 0,
/* Set scroll info to imitate the behaviour and since we don't
need to display it, explicitly don't show the bar */
SetScrollInfo(SB_VERT, childHeight - 1, parentHeight,
(policy == java_awt_ScrollPane_SCROLLBARS_ALWAYS));
::ShowScrollBar(GetHWnd(), SB_VERT, false);
}
env->DeleteLocalRef(target);
......
......@@ -44,7 +44,7 @@
# generic-all Problems on all platforms
# generic-ARCH Where ARCH is one of: sparc, sparcv9, x64, i586, etc.
# OSNAME-all Where OSNAME is one of: solaris, linux, windows, macosx, aix
# OSNAME-ARCH Specific on to one OSNAME and ARCH, e.g. solaris-amd64
# OSNAME-ARCH Specific on to one OSNAME and ARCH, e.g. solaris-x64
# OSNAME-REV Specific on to one OSNAME and REV, e.g. solaris-5.8
#
# More than one label is allowed but must be on the same line.
......@@ -221,7 +221,7 @@ java/nio/channels/DatagramChannel/BasicMulticastTests.java linux-i586
java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java linux-i586
# 8148996
java/nio/file/WatchService/WithSecurityManager.java linux-i586
java/nio/file/WatchService/WithSecurityManager.java linux-all
# 8173179
java/nio/file/Files/probeContentType/Basic.java solaris-x64
......@@ -258,6 +258,9 @@ javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java linux-all
# 8170248
javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java linux-all
# 8205049
sun/rmi/transport/tcp/DisableRMIOverHttp/DisableRMIOverHTTPTest.java windows-all
############################################################################
# jdk_security
......@@ -283,8 +286,8 @@ sun/security/krb5/auto/tools/KinitConfPlusProps.java windo
# 8151225
sun/security/rsa/SpecTest.java linux-i586
# 8173182
sun/security/pkcs11/MessageDigest/TestCloning.java solaris-x64
# 8043951
sun/security/pkcs11/MessageDigest/TestCloning.java solaris-all
# 8156709
sun/security/provider/SecureRandom/StrongSecureRandom.java macosx-x64
......@@ -292,14 +295,25 @@ sun/security/provider/SecureRandom/StrongSecureRandom.java macosx-x64
# 8163498
sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java linux-i586
# 8203055
# 8129560
sun/security/pkcs11/rsa/TestKeyPairGenerator.java solaris-all
sun/security/pkcs11/rsa/TestKeyPairGenerator.java linux-all,solaris-all
# 8151834
sun/security/mscapi/SmallPrimeExponentP.java windows-i586
#8176354
#8176354
sun/security/ssl/com/sun/net/ssl/internal/ssl/X509KeyManager/PreferredKey.java generic-all
# 8206909
com/sun/crypto/provider/CICO/PBEFunc/CICOPBEFuncTest.java solaris-sparcv9
# 8206911
javax/xml/crypto/dsig/GenerationTests.java solaris-all
# 8206912
sun/security/krb5/auto/ReplayCacheTestProc.java solaris-sparcv9
############################################################################
# jdk_sound
......
......@@ -393,6 +393,7 @@ needs_jre = \
javax/management/mxbean/LeakTest.java \
javax/management/mxbean/MXBeanTest.java \
javax/management/mxbean/PropertyNamesTest.java \
javax/xml/bind/marshal/8036981/Test.java \
javax/xml/bind/marshal/8134111/UnmarshalTest.java \
javax/xml/ws/8043129 \
jdk/lambda/vm/InterfaceAccessFlagsTest.java \
......
/*
* 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.
*
* 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.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.ConcurrentModificationException;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.naming.event.EventContext;
import javax.naming.event.NamingEvent;
import javax.naming.event.NamingExceptionEvent;
import javax.naming.event.NamingListener;
import javax.naming.event.ObjectChangeListener;
/**
* @test
* @bug 8176192
* @summary Incorrect usage of Iterator in Java 8 In com.sun.jndi.ldap.
* EventSupport.removeNamingListener
* @modules java.naming
* @run main RemoveNamingListenerTest
*/
public class RemoveNamingListenerTest {
private static volatile Exception exception;
public static void main(String args[]) throws Exception {
// start the LDAP server
TestLDAPServer server = new TestLDAPServer();
server.start();
// Set up environment for creating initial context
Hashtable<String, Object> env = new Hashtable<>(3);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:" + server.getPort() + "/o=example");
env.put("com.sun.jndi.ldap.connect.timeout", "2000");
EventContext ctx = null;
try {
ctx = (EventContext) (new InitialContext(env).lookup(""));
String target = "cn=Vyom Tewari";
// Create listeners
NamingListener oneListener = new SampleListener();
NamingListener objListener = new SampleListener();
NamingListener subListener = new SampleListener();
// Register listeners using different scopes
ctx.addNamingListener(target, EventContext.ONELEVEL_SCOPE, oneListener);
ctx.addNamingListener(target, EventContext.OBJECT_SCOPE, objListener);
ctx.addNamingListener(target, EventContext.SUBTREE_SCOPE, subListener);
//remove a listener in different thread
Thread t = new Thread(new RemoveNamingListener(ctx, subListener));
t.start();
t.join();
if (exception != null) {
throw exception;
}
System.out.println("Test run OK!!!");
} finally {
if (ctx != null) {
ctx.close();
}
server.stopServer();
}
}
/**
* Helper thread that removes the naming listener.
*/
static class RemoveNamingListener implements Runnable {
final EventContext ctx;
final NamingListener listener;
RemoveNamingListener(EventContext ctx, NamingListener listener) {
this.ctx = ctx;
this.listener = listener;
}
@Override
public void run() {
try {
ctx.removeNamingListener(listener);
} catch (NamingException | ConcurrentModificationException ex) {
exception = ex;
}
}
}
static class SampleListener implements ObjectChangeListener {
@Override
public void objectChanged(NamingEvent ne) {
//do nothing
}
@Override
public void namingExceptionThrown(NamingExceptionEvent nee) {
//do nothing
}
}
}
class TestLDAPServer extends Thread {
private final int LDAP_PORT;
private final ServerSocket serverSocket;
private volatile boolean isRunning;
TestLDAPServer() throws IOException {
serverSocket = new ServerSocket(0);
isRunning = true;
LDAP_PORT = serverSocket.getLocalPort();
setDaemon(true);
}
public int getPort() {
return LDAP_PORT;
}
public void stopServer() {
isRunning = false;
if (serverSocket != null && !serverSocket.isClosed()) {
try {
// this will cause ServerSocket.accept() to throw SocketException.
serverSocket.close();
} catch (IOException ignored) {
}
}
}
@Override
public void run() {
try {
while (isRunning) {
Socket clientSocket = serverSocket.accept();
Thread handler = new Thread(new LDAPServerHandler(clientSocket));
handler.setDaemon(true);
handler.start();
}
} catch (IOException iOException) {
//do not throw exception if server is not running.
if (isRunning) {
throw new RuntimeException(iOException);
}
} finally {
stopServer();
}
}
}
class LDAPServerHandler implements Runnable {
private final Socket clientSocket;
public LDAPServerHandler(final Socket clientSocket) {
this.clientSocket = clientSocket;
}
@Override
public void run() {
BufferedInputStream in = null;
PrintWriter out = null;
byte[] bindResponse = {0x30, 0x0C, 0x02, 0x01, 0x01, 0x61, 0x07, 0x0A, 0x01, 0x00, 0x04, 0x00, 0x04, 0x00};
byte[] searchResponse = {0x30, 0x0C, 0x02, 0x01, 0x02, 0x65, 0x07, 0x0A, 0x01, 0x00, 0x04, 0x00, 0x04, 0x00};
try {
in = new BufferedInputStream(clientSocket.getInputStream());
out = new PrintWriter(new OutputStreamWriter(
clientSocket.getOutputStream(), StandardCharsets.UTF_8), true);
while (true) {
// Read the LDAP BindRequest
while (in.read() != -1) {
in.skip(in.available());
break;
}
// Write an LDAP BindResponse
out.write(new String(bindResponse));
out.flush();
// Read the LDAP SearchRequest
while (in.read() != -1) {
in.skip(in.available());
break;
}
// Write an LDAP SearchResponse
out.write(new String(searchResponse));
out.flush();
}
} catch (IOException iOException) {
throw new RuntimeException(iOException);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException ignored) {
}
}
if (out != null) {
out.close();
}
if (clientSocket != null) {
try {
clientSocket.close();
} catch (IOException ignored) {
}
}
}
}
}
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
* @test
* @bug 8075942
* @summary test there is no exception rendering a dashed stroke
* @run DashStrokeTest
* @run -Dsun.java2d.renderer=sun.java2d.pisces.PiscesRenderingEngine
*/
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Stroke;
import java.awt.geom.GeneralPath;
import java.awt.image.BufferedImage;
public class DashStrokeTest {
public static void main(String[] args) {
GeneralPath shape = new GeneralPath();
int[] pointTypes = {0, 0, 1, 1, 0, 1, 1, 0};
double[] xpoints = {428, 420, 400, 400, 400, 400, 420, 733};
double[] ypoints = {180, 180, 180, 160, 30, 10, 10, 10};
shape.moveTo(xpoints[0], ypoints[0]);
for (int i = 1; i < pointTypes.length; i++) {
if (pointTypes[i] == 1 && i < pointTypes.length - 1) {
shape.quadTo(xpoints[i], ypoints[i],
xpoints[i + 1], ypoints[i + 1]);
} else {
shape.lineTo(xpoints[i], ypoints[i]);
}
}
BufferedImage image = new
BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = image.createGraphics();
Color color = new Color(124, 0, 124, 255);
g2.setColor(color);
Stroke stroke = new BasicStroke(1.0f,
BasicStroke.CAP_BUTT,
BasicStroke.JOIN_BEVEL,
10.0f, new float[] {9, 6}, 0.0f);
g2.setStroke(stroke);
g2.draw(shape);
}
}
/*
* 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 8195738
* @summary scroll position in ScrollPane is reset after calling validate()
* @run main ScrollPaneValidateTest
*/
import java.awt.ScrollPane;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Button;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.Point;
import java.awt.Robot;
import java.awt.AWTException;
public class ScrollPaneValidateTest extends Frame {
ScrollPane pane;
public ScrollPaneValidateTest() {
setBounds(300, 300, 300, 300);
pane = new ScrollPane(ScrollPane.SCROLLBARS_NEVER);
add(pane, BorderLayout.NORTH);
pane.add(new InnerPanel());
}
public static void main(String[] args) throws AWTException {
Robot robot = new Robot();
final ScrollPaneValidateTest obj = new ScrollPaneValidateTest();
obj.setVisible(true);
// set to some scroll position
obj.pane.setScrollPosition(600, 200);
// get the newly set position
Point scrollPosition = obj.pane.getScrollPosition();
// call validate multiple times
obj.pane.validate();
robot.delay(1000);
obj.pane.validate();
robot.delay(1000);
// compare position after calling the validate function
if(!scrollPosition.equals(obj.pane.getScrollPosition())) {
obj.dispose();
throw new RuntimeException("Scrolling position is changed in ScrollPane");
}
obj.dispose();
return;
}
class InnerPanel extends Panel {
public InnerPanel() {
this.setLayout(new GridLayout(2, 4));
for (int i = 1; i <= 8; i++) {
this.add(new Button("Button" + i));
}
}
public Dimension getPreferredSize() {
return new Dimension(980, 200);
}
}
}
/*
* 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 8202696
* @summary Verifies if Phonetic extensions are getting displayed.
*/
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.util.Locale;
public class PhoneticExtensionsGlyphTest {
private static final String[] logicalFonts = {"dialog", "dialoginput", "serif", "sansserif", "monospaced"};
private static final String phoneticExtnChars = "\u1D00 \u1D01 \u1D02 \u1D03 \u1D04 \u1D05 \u1D06 \u1D07 \u1D08 \u1D09\n"
+"\u1D0A \u1D0B \u1D0C \u1D0D \u1D0E \u1D0F \u1D10 \u1D11 \u1D12 \u1D13\n"
+"\u1D14 \u1D15 \u1D16 \u1D17 \u1D18 \u1D19 \u1D1A \u1D1B \u1D1C \u1D1D\n"
+"\u1D1E \u1D1F \u1D20 \u1D21 \u1D22 \u1D23 \u1D24 \u1D25 \u1D26 \u1D27\n"
+"\u1D28 \u1D29 \u1D2A \u1D2B \u1D2C \u1D2D \u1D2E \u1D2F \u1D30 \u1D31\n"
+"\u1D32 \u1D33 \u1D34 \u1D35 \u1D36 \u1D37 \u1D38 \u1D39 \u1D3A \u1D3B\n"
+"\u1D3C \u1D3D \u1D3E \u1D3F \u1D40 \u1D41 \u1D42 \u1D43 \u1D44 \u1D45\n"
+"\u1D46 \u1D47 \u1D48 \u1D49 \u1D4A \u1D4B \u1D4C \u1D4D \u1D4E \u1D4F\n"
+"\u1D50 \u1D51 \u1D52 \u1D53 \u1D54 \u1D55 \u1D56 \u1D57 \u1D58 \u1D59\n"
+"\u1D5A \u1D5B \u1D5C \u1D5D \u1D5E \u1D5F \u1D60 \u1D61 \u1D62 \u1D63\n"
+"\u1D64 \u1D65 \u1D66 \u1D67 \u1D68 \u1D69 \u1D6A \u1D6B \u1D6C \u1D6D\n"
+"\u1D6E \u1D6F \u1D70 \u1D71 \u1D72 \u1D73 \u1D74 \u1D75 \u1D76 \u1D77\n"
+"\u1D78 \u1D79 \u1D7A \u1D7B \u1D7C \u1D7D \u1D7E \u1D7F";
public static void main(String[] args) throws Exception {
if (!System.getProperty("os.name").startsWith("Win")) {
return;
}
if(!canDisplayPhoneticChars()) {
throw new RuntimeException("Phonetic extensions failed to display.");
}
}
private static boolean isLogicalFont(Font f) {
String fontName = f.getFamily().toLowerCase(Locale.ROOT);
for (int i = 0; i < logicalFonts.length; i++) {
if (logicalFonts[i].equals(fontName)) {
return true;
}
}
return false;
}
private static boolean canDisplayPhoneticChars() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Font[] fonts = ge.getAllFonts();
boolean ret = false;
for (Font font : fonts) {
if (isLogicalFont(font) && font.canDisplayUpTo(phoneticExtnChars) == -1) {
ret = true;
break;
}
}
return ret;
}
}
/*
* Copyright (c) 2017, 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 8188083
* @summary The test checks whether applying image filters using
* FilteredImageSource results in a NullPointerException.
* @run main FilteredImageSourceTest
*/
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.ColorModel;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageConsumer;
import java.awt.image.ImageFilter;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.util.Hashtable;
/*
* An empty image consumer that will be added to the list of consumers
* interested in image data for the filtered image.
*/
class EmptyImageConsumer implements ImageConsumer {
@Override
public void setDimensions(int width, int height) {
}
@Override
public void setProperties(Hashtable<?, ?> props) {
}
@Override
public void setColorModel(ColorModel colorModel) {
}
@Override
public void setHints(int hintFlags) {
}
@Override
public void setPixels(int x, int y, int width, int height,
ColorModel colorModel, byte[] pixels,
int offset, int scanSize) {
}
@Override
public void setPixels(int x, int y, int width, int height,
ColorModel colorModel, int[] pixels,
int offset, int scanSize) {
}
@Override
public void imageComplete(int i) {
}
}
/*
* An empty image producer whose sole purpose is to provide stub methods
* that will be invoked while preparing filtered image.
*/
class EmptyImageProducer implements ImageProducer {
@Override
public void addConsumer(ImageConsumer imageConsumer) {
}
@Override
public boolean isConsumer(ImageConsumer imageConsumer) {
return false;
}
@Override
public void removeConsumer(ImageConsumer imageConsumer) {
}
@Override
public void startProduction(ImageConsumer imageConsumer) {
}
@Override
public void requestTopDownLeftRightResend(ImageConsumer imageConsumer) {
}
}
/*
* Typically, an Image object will contain an ImageProducer that prepares
* image data. FilteredImageSource will be set as image producer for images
* that require image filter applied to image data.
*/
class EmptyFilteredImage extends Image {
ImageFilter filter = null;
ImageProducer producer = null;
public EmptyFilteredImage(ImageProducer imgSource) {
filter = new ImageFilter();
producer = new FilteredImageSource(imgSource, filter);
}
@Override
public int getWidth(ImageObserver observer) {
return 100;
}
@Override
public int getHeight(ImageObserver observer) {
return 100;
}
@Override
public ImageProducer getSource() {
return producer;
}
@Override
public Graphics getGraphics() {
throw new UnsupportedOperationException();
}
@Override
public Object getProperty(String name, ImageObserver observer) {
return null;
}
}
public final class FilteredImageSourceTest {
// Minimum test duration in ms
private static final int TEST_MIN_DURATION = 5000;
/*
* A throwable object that will hold any exception generated while
* executing methods on FilteredImageSource. The test passes if the
* methods execute without any exception
*/
private static volatile Throwable fail = null;
public static void main(final String[] args)
throws InterruptedException {
final ImageConsumer ic = new EmptyImageConsumer();
final ImageProducer ip = new EmptyImageProducer();
final Image image = new EmptyFilteredImage(ip);
/*
* Simulate the framework's operations on FilteredImageSource by
* invoking the concerned methods in multiple threads and observe
* whether exceptions are generated.
*/
Thread t1 = new Thread(() -> {
try {
while (true) {
image.getSource().addConsumer(ic);
}
} catch (Throwable t) {
fail = t;
}
});
t1.setDaemon(true);
Thread t2 = new Thread(() -> {
try {
while (true) {
image.getSource().removeConsumer(ic);
}
} catch (Throwable t) {
fail = t;
}
});
t2.setDaemon(true);
Thread t3 = new Thread(() -> {
try {
while (true) {
image.getSource().startProduction(ic);
}
} catch (Throwable t) {
fail = t;
}
});
t3.setDaemon(true);
// Start the threads
t1.start();
t2.start();
t3.start();
// Wait on one of the threads for a specific duration.
t1.join(TEST_MIN_DURATION);
if (fail != null) {
throw new RuntimeException("Test failed with exception: ", fail);
}
}
}
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
......@@ -21,48 +21,82 @@
* questions.
*/
import java.security.*;
/*
* @test
* @bug 8161571
* @bug 8161571 8178370
* @summary Reject signatures presented for verification that contain extra
* bytes.
* @modules jdk.crypto.ec
* @run main SignatureLength
*/
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.security.Security;
import java.security.Signature;
import java.security.SignatureException;
public class SignatureLength {
public static void main(String[] args) throws Exception {
main0("EC", 256, "SHA256withECDSA", "SunEC");
main0("RSA", 2048, "SHA256withRSA", "SunRsaSign");
main0("DSA", 2048, "SHA256withDSA", "SUN");
for (Provider p0 : Security.getProviders()) {
for (Provider p1 : Security.getProviders()) {
for (Provider p2 : Security.getProviders()) {
// SunMSCAPI signer can only be initialized with
// a key generated with SunMSCAPI
if (!p0.getName().equals("SunMSCAPI")
&& p1.getName().equals("SunMSCAPI")) continue;
// SunMSCAPI generated key can only be signed
// with SunMSCAPI signer
if (p0.getName().equals("SunMSCAPI")
&& !p1.getName().equals("SunMSCAPI")) continue;
// SunMSCAPI and SunPKCS11 verifiers may return false
// instead of throwing SignatureException
boolean mayNotThrow = p2.getName().equals("SunMSCAPI")
|| p2.getName().startsWith("SunPKCS11");
if (System.getProperty("os.name").equals("SunOS")) {
main0("EC", 256, "SHA256withECDSA", null);
main0("RSA", 2048, "SHA256withRSA", null);
main0("EC", 256, "SHA256withECDSA", p0, p1, p2, mayNotThrow);
main0("RSA", 2048, "SHA256withRSA", p0, p1, p2, mayNotThrow);
main0("DSA", 2048, "SHA256withDSA", p0, p1, p2, mayNotThrow);
}
}
}
}
private static void main0(String keyAlgorithm, int keysize,
String signatureAlgorithm, String provider) throws Exception {
String signatureAlgorithm, Provider generatorProvider,
Provider signerProvider, Provider verifierProvider,
boolean mayNotThrow) throws Exception {
KeyPairGenerator generator;
Signature signer;
Signature verifier;
try {
generator = KeyPairGenerator.getInstance(keyAlgorithm,
generatorProvider);
signer = Signature.getInstance(signatureAlgorithm,
signerProvider);
verifier = Signature.getInstance(signatureAlgorithm,
verifierProvider);
} catch (NoSuchAlgorithmException nsae) {
// ignore this set of providers
return;
}
byte[] plaintext = "aaa".getBytes("UTF-8");
// Generate
KeyPairGenerator generator =
provider == null ?
(KeyPairGenerator) KeyPairGenerator.getInstance(keyAlgorithm) :
(KeyPairGenerator) KeyPairGenerator.getInstance(
keyAlgorithm, provider);
generator.initialize(keysize);
System.out.println("Generating " + keyAlgorithm + " keypair using " +
generator.getProvider().getName() + " JCE provider");
KeyPair keypair = generator.generateKeyPair();
// Sign
Signature signer =
provider == null ?
Signature.getInstance(signatureAlgorithm) :
Signature.getInstance(signatureAlgorithm, provider);
signer.initSign(keypair.getPrivate());
signer.update(plaintext);
System.out.println("Signing using " + signer.getProvider().getName() +
......@@ -80,19 +114,26 @@ public class SignatureLength {
badSignature[signature.length + 4] = 0x01;
// Verify
Signature verifier =
provider == null ?
Signature.getInstance(signatureAlgorithm) :
Signature.getInstance(signatureAlgorithm, provider);
verifier.initVerify(keypair.getPublic());
verifier.update(plaintext);
System.out.println("Verifying using " +
verifier.getProvider().getName() + " JCE provider");
try {
System.out.println("Valid? " + verifier.verify(badSignature));
throw new Exception(
"ERROR: expected a SignatureException but none was thrown");
boolean valid = verifier.verify(badSignature);
System.out.println("Valid? " + valid);
if (mayNotThrow) {
if (valid) {
throw new Exception(
"ERROR: expected a SignatureException but none was thrown"
+ " and invalid signature was verified");
} else {
System.out.println("OK: verification failed as expected");
}
} else {
throw new Exception(
"ERROR: expected a SignatureException but none was thrown");
}
} catch (SignatureException e) {
System.out.println("OK: caught expected exception: " + e);
}
......
/*
* Copyright (c) 2012, 2013, 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
......@@ -67,6 +67,7 @@ import static org.testng.Assert.assertTrue;
import java.time.LocalDate;
import java.time.Month;
import java.time.temporal.ChronoUnit;
import java.time.temporal.IsoFields;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
......@@ -444,4 +445,40 @@ public class TestLocalDate extends AbstractTest {
}
}
@DataProvider(name="quarterYearsToAdd")
Object[][] provider_quarterYearsToAdd() {
return new Object[][] {
{Long.valueOf(-1000000000)},
{Long.valueOf(-256)},
{Long.valueOf(-255)},
{Long.valueOf(-1)},
{Long.valueOf(0)},
{Long.valueOf(1)},
{Long.valueOf(255)},
{Long.valueOf(256)},
{Long.valueOf(1000000000)},
};
}
@Test(dataProvider="quarterYearsToAdd")
public void test_plus_QuarterYears(long quarterYears) {
LocalDate t0 = TEST_2007_07_15
.plus(quarterYears, IsoFields.QUARTER_YEARS);
LocalDate t1 = TEST_2007_07_15
.plus(quarterYears, ChronoUnit.MONTHS)
.plus(quarterYears, ChronoUnit.MONTHS)
.plus(quarterYears, ChronoUnit.MONTHS);
assertEquals(t0, t1);
}
@Test(dataProvider="quarterYearsToAdd")
public void test_minus_QuarterYears(long quarterYears) {
LocalDate t0 = TEST_2007_07_15
.minus(quarterYears, IsoFields.QUARTER_YEARS);
LocalDate t1 = TEST_2007_07_15
.minus(quarterYears, ChronoUnit.MONTHS)
.minus(quarterYears, ChronoUnit.MONTHS)
.minus(quarterYears, ChronoUnit.MONTHS);
assertEquals(t0, t1);
}
}
/*
* 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.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.concurrent.ThreadLocalRandom;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
/*
* @test
* @bug 8186171
* @run testng Bug8186171Test
* @summary Verify the fix for scenario reported in JDK-8186171
* @author deepak.kejriwal@oracle.com
*/
@Test
public class Bug8186171Test{
/**
* Tests and extends the scenario reported in
* https://bugs.openjdk.java.net/browse/JDK-8186171
* HashMap: Entry.setValue may not work after Iterator.remove() called for previous entries
* Runs 1000 times as it is based on randomization.
*/
@Test(invocationCount = 1000)
static void testBug8186171NonDeterministic()
{
final ThreadLocalRandom rnd = ThreadLocalRandom.current();
final Object v1 = rnd.nextBoolean() ? null : 1;
final Object v2 = (rnd.nextBoolean() && v1 != null) ? null : 2;
/** If true, always lands in first bucket in hash tables. */
final boolean poorHash = rnd.nextBoolean();
class Key implements Comparable<Key> {
final int i;
Key(int i) { this.i = i; }
public int hashCode() { return poorHash ? 0 : super.hashCode(); }
public int compareTo(Key x) {
return Integer.compare(this.i, x.i);
}
}
// HashMap and ConcurrentHashMap have:
// TREEIFY_THRESHOLD = 8; UNTREEIFY_THRESHOLD = 6;
final int size = rnd.nextInt(1, 25);
List<Key> keys = new ArrayList<>();
for (int i = size; i-->0; ) keys.add(new Key(i));
Key keyToFrob = keys.get(rnd.nextInt(keys.size()));
Map<Key, Object> m = new HashMap<Key, Object>();
for (Key key : keys) m.put(key, v1);
for (Iterator<Map.Entry<Key, Object>> it = m.entrySet().iterator();
it.hasNext(); ) {
Map.Entry<Key, Object> entry = it.next();
if (entry.getKey() == keyToFrob)
entry.setValue(v2); // does this have the expected effect?
else
it.remove();
}
assertFalse(m.containsValue(v1));
assertTrue(m.containsValue(v2));
assertTrue(m.containsKey(keyToFrob));
assertEquals(1, m.size());
}
/**
* Tests and extends the scenario reported in
* https://bugs.openjdk.java.net/browse/JDK-8186171
* HashMap: Entry.setValue may not work after Iterator.remove() called for previous entries
* Runs single time by reproducing exact scenario for issue mentioned in 8186171
*/
@Test()
static void testBug8186171Deterministic(){
class Key implements Comparable<Key>
{
final int i;
Key(int i) { this.i = i; }
@Override
public int hashCode() { return 0; } //Returning same hashcode so that all keys landup to same bucket
@Override
public int compareTo(Key x){
if(this.i == x.i){
return 0;
}
else {
return Integer.compare(this.i, x.i);
}
}
@Override
public String toString()
{
return "Key_" + i;
}
}
// HashMap have TREEIFY_THRESHOLD = 8; UNTREEIFY_THRESHOLD = 6;
final int size = 11;
List<Key> keys = new ArrayList<>();
for (int i = 0; i < size; i++){
keys.add(new Key(i));
}
Key keyToFrob = keys.get(9);
Map<Key, Object> m = new HashMap<Key, Object>();
for (Key key : keys) m.put(key, null);
for (Iterator<Map.Entry<Key, Object>> it = m.entrySet().iterator(); it.hasNext(); ){
Map.Entry<Key, Object> entry = it.next();
if (entry.getKey() == keyToFrob){
entry.setValue(2);
}
else{
it.remove();
}
}
assertFalse(m.containsValue(null));
assertTrue(m.containsValue(2));
assertTrue(m.containsKey(keyToFrob));
assertEquals(1, m.size());
}
}
/*
* 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 8195095
* @summary Tests if Images are scaled correctly in JEditorPane.
* @run main ImageViewTest
*/
import java.awt.Robot;
import java.awt.Point;
import java.awt.Color;
import java.awt.Insets;
import javax.swing.JEditorPane;
import javax.swing.SwingUtilities;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
public class ImageViewTest {
private static final int WIDTH = 200;
private static final int HEIGHT = 200;
private static JFrame f;
private static JEditorPane editorPane1;
private static JEditorPane editorPane2;
private static JEditorPane editorPane3;
private static JEditorPane editorPane4;
private static void test(Robot r, JEditorPane editorPane) throws Exception {
SwingUtilities.invokeAndWait(() -> {
f = new JFrame();
editorPane.setEditable(false);
f.add(editorPane);
f.setSize(220,240);
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setVisible(true);
});
r.waitForIdle();
r.delay(500);
SwingUtilities.invokeAndWait(() -> {
Insets insets = editorPane.getInsets();
Point loc = editorPane.getLocationOnScreen();
final Color blue = Color.BLUE;
final int offset = 10;
Color center = r.getPixelColor(loc.x + insets.left + WIDTH / 2,
loc.y + insets.top + HEIGHT / 2);
Color left = r.getPixelColor(loc.x + insets.left + offset,
loc.y + insets.top + HEIGHT / 2);
Color right = r.getPixelColor(loc.x + insets.left + WIDTH - offset,
loc.y + insets.top + HEIGHT / 2);
Color bottom = r.getPixelColor(loc.x + insets.left + WIDTH / 2,
loc.y + insets.top + HEIGHT - offset);
Color top = r.getPixelColor(loc.x + insets.left + WIDTH / 2,
loc.y + insets.top + offset);
f.dispose();
System.out.println("center color: " + center);
System.out.println("left color: " + left);
System.out.println("right color: " + right);
System.out.println("bottom color: " + bottom);
System.out.println("top color: " + top);
System.out.println();
if (!(blue.equals(center) && blue.equals(left) && blue.equals(right) &&
blue.equals(top) && blue.equals(bottom))) {
throw new RuntimeException("Test failed: Image not scaled correctly");
}
});
r.waitForIdle();
}
public static void main(String[] args) throws Exception {
final String ABSOLUTE_FILE_PATH = ImageViewTest.class.getResource("circle.png").getPath();
System.out.println(ABSOLUTE_FILE_PATH);
Robot r = new Robot();
SwingUtilities.invokeAndWait(() -> {
editorPane1 = new JEditorPane("text/html",
"<img height=\"200\" src=\"file:///" + ABSOLUTE_FILE_PATH + "\"");
editorPane2 = new JEditorPane("text/html",
"<img width=\"200\" src=\"file:///" + ABSOLUTE_FILE_PATH + "\"");
editorPane3 = new JEditorPane("text/html",
"<img width=\"200\" height=\"200\" src=\"file:///" + ABSOLUTE_FILE_PATH + "\"");
editorPane4 = new JEditorPane("text/html",
"<img src=\"file:///" + ABSOLUTE_FILE_PATH + "\"");
});
r.waitForIdle();
System.out.println("Test with only height set to 200");
test(r, editorPane1);
System.out.println("Test with only width set to 200");
test(r, editorPane2);
System.out.println("Test with none of them set");
test(r, editorPane3);
System.out.println("Test with both of them set to 200");
test(r, editorPane4);
System.out.println("Test Passed.");
}
}
/*
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -33,8 +33,6 @@ import java.io.*;
import java.net.*;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.Policy;
import java.security.URIParameter;
import java.util.ArrayList;
import java.util.Collections;
import javax.xml.crypto.dsig.*;
......@@ -115,10 +113,8 @@ public class XMLDSigWithSecMgr implements Runnable {
// the policy only grants this test SocketPermission to accept, resolve
// and connect to localhost so that it can dereference 2nd reference
URI policyURI =
new File(System.getProperty("test.src", "."), "policy").toURI();
Policy.setPolicy
(Policy.getInstance("JavaPolicy", new URIParameter(policyURI)));
System.setProperty("java.security.policy",
System.getProperty("test.src", ".") + File.separator + "policy");
System.setSecurityManager(new SecurityManager());
try {
......
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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,8 +36,6 @@ public class JSSEServer {
private SSLServerSocket server = null;
private Exception exception = null;
public JSSEServer(SSLContext context,
boolean needClientAuth) throws Exception {
SSLServerSocketFactory serverFactory = context.getServerSocketFactory();
......@@ -47,35 +45,28 @@ public class JSSEServer {
System.out.println("Server: port=" + getPort());
}
public void start() {
new Thread(new Runnable() {
public Exception start() {
System.out.println("Server: started");
Exception exception = null;
try (SSLSocket socket = (SSLSocket) server.accept()) {
System.out.println("Server: accepted connection");
socket.setSoTimeout(TLSRestrictions.TIMEOUT);
InputStream sslIS = socket.getInputStream();
OutputStream sslOS = socket.getOutputStream();
sslIS.read();
sslOS.write('S');
sslOS.flush();
System.out.println("Server: finished");
} catch (Exception e) {
exception = e;
e.printStackTrace(System.out);
System.out.println("Server: failed");
}
@Override
public void run() {
try {
System.out.println("Server: started");
try (SSLSocket socket = (SSLSocket) server.accept()) {
socket.setSoTimeout(TLSRestrictions.TIMEOUT);
InputStream sslIS = socket.getInputStream();
OutputStream sslOS = socket.getOutputStream();
sslIS.read();
sslOS.write('S');
sslOS.flush();
System.out.println("Server: finished");
}
} catch (Exception e) {
e.printStackTrace(System.out);
exception = e;
}
}
}).start();
return exception;
}
public int getPort() {
return server.getLocalPort();
}
public Exception getException() {
return exception;
}
}
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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,10 @@ import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.net.ssl.KeyManagerFactory;
......@@ -210,58 +214,58 @@ public class TLSRestrictions {
needClientAuth,
pass);
setConstraint("Server", serverConstraint);
JSSEServer server = new JSSEServer(
createSSLContext(trustNames, certNames),
needClientAuth);
int port = server.getPort();
server.start();
// Run client on another JVM so that its properties cannot be in conflict
// with server's.
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
"-Dcert.dir=" + CERT_DIR,
"-Djava.security.debug=certpath",
"-classpath",
TEST_CLASSES,
"JSSEClient",
port + "",
trustNameStr,
certNameStr,
clientConstraint);
int exitValue = outputAnalyzer.getExitValue();
String clientOut = outputAnalyzer.getOutput();
Exception serverException = server.getException();
if (serverException != null) {
System.out.println("Server: failed");
}
System.out.println("---------- Client output start ----------");
System.out.println(clientOut);
System.out.println("---------- Client output end ----------");
if (serverException instanceof SocketTimeoutException
|| clientOut.contains("SocketTimeoutException")) {
System.out.println("The communication gets timeout and skips the test.");
return;
}
if (pass) {
if (serverException != null || exitValue != 0) {
throw new RuntimeException(
"Unexpected failure. Operation was blocked.");
}
} else {
if (serverException == null && exitValue == 0) {
throw new RuntimeException(
"Unexpected pass. Operation was allowed.");
ExecutorService executor = Executors.newFixedThreadPool(1);
try {
JSSEServer server = new JSSEServer(
createSSLContext(trustNames, certNames),
needClientAuth);
int port = server.getPort();
Future<Exception> serverFuture = executor.submit(() -> server.start());
// Run client on another JVM so that its properties cannot be in conflict
// with server's.
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
"-Dcert.dir=" + CERT_DIR,
"-Djava.security.debug=certpath",
"-classpath",
TEST_CLASSES,
"JSSEClient",
port + "",
trustNameStr,
certNameStr,
clientConstraint);
int clientExitValue = outputAnalyzer.getExitValue();
String clientOut = outputAnalyzer.getOutput();
System.out.println("---------- Client output start ----------");
System.out.println(clientOut);
System.out.println("---------- Client output end ----------");
Exception serverException = serverFuture.get(TIMEOUT, TimeUnit.MILLISECONDS);
if (serverException instanceof SocketTimeoutException
|| clientOut.contains("SocketTimeoutException")) {
System.out.println("The communication gets timeout and skips the test.");
return;
}
// The test may encounter non-SSL issues, like network problem.
if (!(serverException instanceof SSLHandshakeException
|| clientOut.contains("SSLHandshakeException"))) {
throw new RuntimeException("Failure with unexpected exception.");
if (pass) {
if (serverException != null || clientExitValue != 0) {
throw new RuntimeException(
"Unexpected failure. Operation was blocked.");
}
} else {
if (serverException == null && clientExitValue == 0) {
throw new RuntimeException(
"Unexpected pass. Operation was allowed.");
}
// The test may encounter non-SSL issues, like network problem.
if (!(serverException instanceof SSLHandshakeException
|| clientOut.contains("SSLHandshakeException"))) {
throw new RuntimeException("Failure with unexpected exception.");
}
}
} finally {
executor.shutdown();
}
}
......@@ -513,7 +517,6 @@ public class TLSRestrictions {
true);
break;
}
System.out.println("Case passed");
System.out.println("========================================");
}
......
/*
* Copyright (c) 2016, 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.
*/
// SunJSSE does not support dynamic system properties, no way to re-use
// system properties in samevm/agentvm mode.
/*
* @test
* @bug 8162362
* @summary Cannot enable previously default enabled cipher suites
* @run main/othervm
* CustomizedCipherSuites Default true
* TLS_RSA_WITH_AES_128_CBC_SHA
* SSL_RSA_WITH_DES_CBC_SHA
* @run main/othervm
* -Djdk.tls.client.cipherSuites="unknown"
* CustomizedCipherSuites Default true
* TLS_RSA_WITH_AES_128_CBC_SHA
* SSL_RSA_WITH_DES_CBC_SHA
* @run main/othervm
* -Djdk.tls.client.cipherSuites=""
* CustomizedCipherSuites Default true
* TLS_RSA_WITH_AES_128_CBC_SHA
* SSL_RSA_WITH_DES_CBC_SHA
* @run main/othervm
* -Djdk.tls.client.cipherSuites="SSL_RSA_WITH_DES_CBC_SHA"
* CustomizedCipherSuites Default true
* SSL_RSA_WITH_DES_CBC_SHA
* TLS_RSA_WITH_AES_128_CBC_SHA
* @run main/othervm
* -Djdk.tls.server.cipherSuites="SSL_RSA_WITH_DES_CBC_SHA"
* CustomizedCipherSuites Default false
* SSL_RSA_WITH_DES_CBC_SHA
* TLS_RSA_WITH_AES_128_CBC_SHA
* @run main/othervm
* -Djdk.tls.client.cipherSuites="TLS_RSA_WITH_AES_128_CBC_SHA,unknown,SSL_RSA_WITH_DES_CBC_SHA"
* CustomizedCipherSuites Default true
* SSL_RSA_WITH_DES_CBC_SHA
* ""
* @run main/othervm
* -Djdk.tls.server.cipherSuites="TLS_RSA_WITH_AES_128_CBC_SHA,unknown,SSL_RSA_WITH_DES_CBC_SHA"
* CustomizedCipherSuites Default false
* TLS_RSA_WITH_AES_128_CBC_SHA
* ""
* @run main/othervm
* -Djdk.tls.server.cipherSuites="SSL_RSA_WITH_DES_CBC_SHA"
* CustomizedCipherSuites Default true
* TLS_RSA_WITH_AES_128_CBC_SHA
* SSL_RSA_WITH_DES_CBC_SHA
* @run main/othervm
* -Djdk.tls.client.cipherSuites="SSL_RSA_WITH_DES_CBC_SHA"
* CustomizedCipherSuites Default false
* TLS_RSA_WITH_AES_128_CBC_SHA
* SSL_RSA_WITH_DES_CBC_SHA
*/
import javax.net.ssl.*;
/**
* Test the customized default cipher suites.
*
* This test is based on the behavior that SSL_RSA_WITH_DES_CBC_SHA is
* disabled by default, and TLS_RSA_WITH_AES_128_CBC_SHA is enabled by
* default in JDK. If the behavior is changed in the future, please
* update the test cases above accordingly.
*/
public class CustomizedCipherSuites {
private static String contextProtocol;
private static boolean isClientMode;
private static String enabledCipherSuite;
private static String disabledCipherSuite;
public static void main(String[] args) throws Exception {
contextProtocol = trimQuotes(args[0]);
isClientMode = Boolean.parseBoolean(args[1]);
enabledCipherSuite = trimQuotes(args[2]);
disabledCipherSuite = trimQuotes(args[3]);
//
// Create instance of SSLContext with the specified protocol.
//
SSLContext context = SSLContext.getInstance(contextProtocol);
// Default SSLContext is initialized automatically.
if (!contextProtocol.equals("Default")) {
// Use default TK, KM and random.
context.init((KeyManager[])null, (TrustManager[])null, null);
}
// SSLContext default parameters is client mode in JDK.
if (isClientMode) {
//
// Check default parameters of the specified SSLContext protocol
//
SSLParameters parameters = context.getDefaultSSLParameters();
System.out.println("Checking SSLContext default parameters ...");
checkEnabledCiphers(parameters.getCipherSuites());
}
//
// Check supported parameters of the specified SSLContext protocol
//
SSLParameters parameters = context.getSupportedSSLParameters();
System.out.println("Checking SSLContext suppport parameters ...");
checkSupportedCiphers(parameters.getCipherSuites());
//
// Check the default cipher suites of SSLEngine.
//
SSLEngine engine = context.createSSLEngine();
engine.setUseClientMode(isClientMode);
System.out.println("Checking SSLEngine default cipher suites ...");
checkEnabledCiphers(engine.getEnabledCipherSuites());
//
// Check the supported cipher suites of SSLEngine.
//
System.out.println("Checking SSLEngine supported cipher suites ...");
checkSupportedCiphers(engine.getSupportedCipherSuites());
if (isClientMode) {
SSLSocketFactory factory = context.getSocketFactory();
// Use an unconnected socket.
try (SSLSocket socket = (SSLSocket)factory.createSocket()) {
//
// Check the default cipher suites of SSLSocket.
//
System.out.println(
"Checking SSLSocket default cipher suites ...");
checkEnabledCiphers(socket.getEnabledCipherSuites());
//
// Check the supported cipher suites of SSLSocket.
//
System.out.println(
"Checking SSLSocket supported cipher suites ...");
checkSupportedCiphers(socket.getSupportedCipherSuites());
}
} else {
SSLServerSocketFactory factory = context.getServerSocketFactory();
// Use an unbound server socket.
try (SSLServerSocket socket =
(SSLServerSocket)factory.createServerSocket()) {
//
// Check the default cipher suites of SSLServerSocket.
//
System.out.println(
"Checking SSLServerSocket default cipher suites ...");
checkEnabledCiphers(socket.getEnabledCipherSuites());
//
// Check the supported cipher suites of SSLServerSocket.
//
System.out.println(
"Checking SSLServerSocket supported cipher suites ...");
checkSupportedCiphers(socket.getSupportedCipherSuites());
}
}
System.out.println("\t... Success");
}
private static void checkEnabledCiphers(
String[] ciphers) throws Exception {
if (ciphers.length == 0) {
throw new Exception("No default cipher suites");
}
boolean isMatch = false;
if (enabledCipherSuite.isEmpty()) {
// Don't check if not specify the expected cipher suite.
isMatch = true;
}
boolean isBroken = false;
for (String cipher : ciphers) {
System.out.println("\tdefault cipher suite " + cipher);
if (!enabledCipherSuite.isEmpty() &&
cipher.equals(enabledCipherSuite)) {
isMatch = true;
}
if (!disabledCipherSuite.isEmpty() &&
cipher.equals(disabledCipherSuite)) {
isBroken = true;
}
}
if (!isMatch) {
throw new Exception(
"Cipher suite " + enabledCipherSuite + " should be enabled");
}
if (isBroken) {
throw new Exception(
"Cipher suite " + disabledCipherSuite + " should be disabled");
}
}
private static void checkSupportedCiphers(
String[] ciphers) throws Exception {
if (ciphers.length == 0) {
throw new Exception("No supported cipher suites");
}
boolean hasEnabledCipherSuite = enabledCipherSuite.isEmpty();
boolean hasDisabledCipherSuite = disabledCipherSuite.isEmpty();
for (String cipher : ciphers) {
System.out.println("\tsupported cipher suite " + cipher);
if (!enabledCipherSuite.isEmpty() &&
cipher.equals(enabledCipherSuite)) {
hasEnabledCipherSuite = true;
}
if (!disabledCipherSuite.isEmpty() &&
cipher.equals(disabledCipherSuite)) {
hasDisabledCipherSuite = true;
}
}
if (!hasEnabledCipherSuite) {
throw new Exception(
"Cipher suite " + enabledCipherSuite + " should be supported");
}
if (!hasDisabledCipherSuite) {
throw new Exception(
"Cipher suite " + disabledCipherSuite + " should be supported");
}
}
private static String trimQuotes(String candidate) {
if (candidate != null && candidate.length() != 0) {
// Remove double quote marks from beginning/end of the string.
if (candidate.length() > 1 && candidate.charAt(0) == '"' &&
candidate.charAt(candidate.length() - 1) == '"') {
return candidate.substring(1, candidate.length() - 1);
}
}
return candidate;
}
}
/*
* 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 8193171
* @summary keytool -list displays "JKS" for a PKCS12 keystore.
* @library /lib/testlibrary
* @run main/othervm ListPKCS12
*/
import jdk.testlibrary.SecurityTools;
import jdk.testlibrary.OutputAnalyzer;
public class ListPKCS12 {
public static void main(String[] args) throws Throwable {
kt("-genkey -alias a -dname CN=A -keystore ks" +
" -storetype pkcs12 -storepass changeit")
.shouldHaveExitValue(0);
kt("-list -keystore ks -storepass changeit")
.shouldNotContain("Keystore type: jks")
.shouldNotContain("Keystore type: JKS")
.shouldContain("Keystore type: PKCS12")
.shouldHaveExitValue(0);
}
static OutputAnalyzer kt(String arg) throws Exception {
return SecurityTools.keytool(arg);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册