Mercurial > hg > openjdk > bsd-port > jdk
changeset 7258:ff67c8965852 jdk7u60-b02
Merge
author | lana |
---|---|
date | Wed, 11 Dec 2013 11:19:00 -0800 |
parents | d00ac65fc4c5 (current diff) 91d49c0f1573 (diff) |
children | fbe6fa9fb6c6 |
files | |
diffstat | 27 files changed, 1608 insertions(+), 97 deletions(-) [+] |
line wrap: on
line diff
--- a/make/com/oracle/Makefile Wed Nov 27 14:58:24 2013 -0800 +++ b/make/com/oracle/Makefile Wed Dec 11 11:19:00 2013 -0800 @@ -30,22 +30,8 @@ #SUBDIRS_MAKEFLAGS += JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation,-path include $(BUILDDIR)/common/Defs.gmk -JFR_SRCDIRS_EXIST := $(shell \ - if [ -d $(CLOSED_SHARE_SRC)/native/oracle/jfr ] ; then \ - echo true; \ - else \ - echo false; \ - fi) - -JFR = -ifndef OPENJDK - ifndef JAVASE_EMBEDDED - ifeq ($(JFR_SRCDIRS_EXIST), true) - ifneq (${ARCH},arm) - JFR = jfr - endif - endif - endif +ifeq ($(BUILD_JFR), true) + JFR = jfr endif # build com/oracle/security/ucrypto on Solaris platform for non-OpenJDK builds
--- a/make/common/Release.gmk Wed Nov 27 14:58:24 2013 -0800 +++ b/make/common/Release.gmk Wed Dec 11 11:19:00 2013 -0800 @@ -402,25 +402,9 @@ sun/tools/jinfo \ sun/tools/jmap -JFR_SRCDIRS_EXIST := $(shell \ - if [ -d $(CLOSED_SHARE_SRC)/classes/com/oracle/jrockit/jfr ] ; then \ - echo true; \ - else \ - echo false; \ - fi) - -BUILD_JFR= -ifndef OPENJDK -ifndef JAVASE_EMBEDDED -ifeq ($(JFR_SRCDIRS_EXIST), true) -BUILD_JFR=true -endif -endif -endif - # classes that go into jfr.jar JFR_CLASSES_DIRS= -ifdef BUILD_JFR +ifeq ($(BUILD_JFR), true) JFR_CLASSES_DIRS= \ com/oracle/jrockit/jfr \ oracle/jrockit/jfr \ @@ -629,7 +613,7 @@ $(ECHO) "sun/tools/jstack/" >> $@ $(ECHO) "sun/tools/jinfo/" >> $@ $(ECHO) "sun/tools/jmap/" >> $@ -ifdef BUILD_JFR +ifeq ($(BUILD_JFR), true) $(ECHO) "com/oracle/jrockit/jfr/" >> $@ $(ECHO) "com/oracle/jrockit/jfr/client/" >> $@ $(ECHO) "com/oracle/jrockit/jfr/management/" >> $@ @@ -668,7 +652,7 @@ # Create jfr.jar JFR_JAR= -ifdef BUILD_JFR +ifeq ($(BUILD_JFR), true) JFR_JAR=$(ABS_TEMPDIR)/jfr-orig.jar $(JFR_JAR): $(OTHER_JAR_MANIFEST_FILE) $(prep-target)
--- a/src/macosx/classes/sun/lwawt/macosx/CDropTargetContextPeer.java Wed Nov 27 14:58:24 2013 -0800 +++ b/src/macosx/classes/sun/lwawt/macosx/CDropTargetContextPeer.java Wed Dec 11 11:19:00 2013 -0800 @@ -26,6 +26,7 @@ package sun.lwawt.macosx; import java.awt.*; +import java.awt.dnd.DropTarget; import sun.awt.dnd.SunDropTargetContextPeer; import sun.awt.dnd.SunDropTargetEvent; @@ -38,7 +39,7 @@ private long fNativeDropTransfer = 0; private long fNativeDataAvailable = 0; private Object fNativeData = null; - private boolean insideTarget = true; + private DropTarget insideTarget = null; Object awtLockAccess = new Object(); @@ -88,26 +89,19 @@ return fNativeData; } - // We need to take care of dragExit message because for some reason it is not being - // generated for lightweight components + // We need to take care of dragEnter and dragExit messages because + // native system generates them only for heavyweights @Override protected void processMotionMessage(SunDropTargetEvent event, boolean operationChanged) { - Component eventSource = (Component)event.getComponent(); - Point screenPoint = event.getPoint(); - SwingUtilities.convertPointToScreen(screenPoint, eventSource); - Rectangle screenBounds = new Rectangle(eventSource.getLocationOnScreen().x, - eventSource.getLocationOnScreen().y, - eventSource.getWidth(), eventSource.getHeight()); - if(insideTarget) { - if(!screenBounds.contains(screenPoint)) { + boolean eventInsideTarget = isEventInsideTarget(event); + if (event.getComponent().getDropTarget() == insideTarget) { + if (!eventInsideTarget) { processExitMessage(event); - insideTarget = false; return; } } else { - if(screenBounds.contains(screenPoint)) { + if (eventInsideTarget) { processEnterMessage(event); - insideTarget = true; } else { return; } @@ -115,17 +109,52 @@ super.processMotionMessage(event, operationChanged); } + /** + * Could be called when DnD enters a heavyweight or synthesized in processMotionMessage + */ + @Override + protected void processEnterMessage(SunDropTargetEvent event) { + Component c = event.getComponent(); + DropTarget dt = event.getComponent().getDropTarget(); + if (isEventInsideTarget(event) + && dt != insideTarget + && c.isShowing() + && dt != null + && dt.isActive()) { + insideTarget = dt; + super.processEnterMessage(event); + } + } + + /** + * Could be called when DnD exits a heavyweight or synthesized in processMotionMessage + */ + @Override + protected void processExitMessage(SunDropTargetEvent event) { + if (event.getComponent().getDropTarget() == insideTarget) { + insideTarget = null; + super.processExitMessage(event); + } + } + @Override protected void processDropMessage(SunDropTargetEvent event) { - Component eventSource = (Component)event.getComponent(); + if (isEventInsideTarget(event)) { + super.processDropMessage(event); + insideTarget = null; + } + } + + private boolean isEventInsideTarget(SunDropTargetEvent event) { + Component eventSource = event.getComponent(); Point screenPoint = event.getPoint(); SwingUtilities.convertPointToScreen(screenPoint, eventSource); - Rectangle screenBounds = new Rectangle(eventSource.getLocationOnScreen().x, - eventSource.getLocationOnScreen().y, - eventSource.getWidth(), eventSource.getHeight()); - if(screenBounds.contains(screenPoint)) { - super.processDropMessage(event); - } + Point locationOnScreen = eventSource.getLocationOnScreen(); + Rectangle screenBounds = new Rectangle(locationOnScreen.x, + locationOnScreen.y, + eventSource.getWidth(), + eventSource.getHeight()); + return screenBounds.contains(screenPoint); } @Override
--- a/src/macosx/native/sun/awt/AWTEvent.m Wed Nov 27 14:58:24 2013 -0800 +++ b/src/macosx/native/sun/awt/AWTEvent.m Wed Dec 11 11:19:00 2013 -0800 @@ -382,7 +382,7 @@ { TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); CFDataRef uchr = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); - if (uchr == nil) { return; } + if (uchr == nil) { return 0; } const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout*)CFDataGetBytePtr(uchr); // Carbon modifiers should be used instead of NSEvent modifiers UInt32 modifierKeyState = (GetCurrentEventKeyModifiers() >> 8) & 0xFF;
--- a/src/macosx/native/sun/awt/CDropTarget.m Wed Nov 27 14:58:24 2013 -0800 +++ b/src/macosx/native/sun/awt/CDropTarget.m Wed Dec 11 11:19:00 2013 -0800 @@ -477,6 +477,8 @@ sDraggingExited = FALSE; sDraggingLocation = [sender draggingLocation]; NSPoint javaLocation = [fView convertPoint:sDraggingLocation fromView:nil]; + javaLocation.y = fView.window.frame.size.height - javaLocation.y; + DLog5(@"+ dragEnter: loc native %f, %f, java %f, %f\n", sDraggingLocation.x, sDraggingLocation.y, javaLocation.x, javaLocation.y); ////////// BEGIN Calculate the current drag actions ////////// @@ -570,8 +572,7 @@ // Should we notify Java things have changed? if (sDraggingError == FALSE && notifyJava) { NSPoint javaLocation = [fView convertPoint:sDraggingLocation fromView:nil]; - // For some reason even after the convertPoint drag events come with the y coordinate reverted - javaLocation.y = fView.window.frame.size.height - javaLocation.y; + javaLocation.y = fView.window.frame.size.height - javaLocation.y; //DLog5(@" : dragMoved: loc native %f, %f, java %f, %f\n", sDraggingLocation.x, sDraggingLocation.y, javaLocation.x, javaLocation.y); jlongArray formats = sDraggingFormats;
--- a/src/share/classes/com/sun/beans/finder/ConstructorFinder.java Wed Nov 27 14:58:24 2013 -0800 +++ b/src/share/classes/com/sun/beans/finder/ConstructorFinder.java Wed Dec 11 11:19:00 2013 -0800 @@ -24,11 +24,12 @@ */ package com.sun.beans.finder; -import com.sun.beans.WeakCache; +import com.sun.beans.util.Cache; import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; +import static com.sun.beans.util.Cache.Kind.SOFT; import static sun.reflect.misc.ReflectUtil.isPackageAccessible; /** @@ -41,7 +42,18 @@ * @author Sergey A. Malenkov */ public final class ConstructorFinder extends AbstractFinder<Constructor<?>> { - private static final WeakCache<Signature, Constructor<?>> CACHE = new WeakCache<Signature, Constructor<?>>(); + private static final Cache<Signature, Constructor<?>> CACHE = new Cache<Signature, Constructor<?>>(SOFT, SOFT) { + @Override + public Constructor create(Signature signature) { + try { + ConstructorFinder finder = new ConstructorFinder(signature.getArgs()); + return finder.find(signature.getType().getConstructors()); + } + catch (Exception exception) { + throw new SignatureException(exception); + } + } + }; /** * Finds public constructor @@ -69,13 +81,12 @@ PrimitiveWrapperMap.replacePrimitivesWithWrappers(args); Signature signature = new Signature(type, args); - Constructor<?> constructor = CACHE.get(signature); - if (constructor != null) { - return constructor; + try { + return CACHE.get(signature); } - constructor = new ConstructorFinder(args).find(type.getConstructors()); - CACHE.put(signature, constructor); - return constructor; + catch (SignatureException exception) { + throw exception.toNoSuchMethodException("Constructor is not found"); + } } /**
--- a/src/share/classes/com/sun/beans/finder/MethodFinder.java Wed Nov 27 14:58:24 2013 -0800 +++ b/src/share/classes/com/sun/beans/finder/MethodFinder.java Wed Dec 11 11:19:00 2013 -0800 @@ -25,7 +25,7 @@ package com.sun.beans.finder; import com.sun.beans.TypeResolver; -import com.sun.beans.WeakCache; +import com.sun.beans.util.Cache; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -33,6 +33,7 @@ import java.lang.reflect.Type; import java.util.Arrays; +import static com.sun.beans.util.Cache.Kind.SOFT; import static sun.reflect.misc.ReflectUtil.isPackageAccessible; /** @@ -45,7 +46,18 @@ * @author Sergey A. Malenkov */ public final class MethodFinder extends AbstractFinder<Method> { - private static final WeakCache<Signature, Method> CACHE = new WeakCache<Signature, Method>(); + private static final Cache<Signature, Method> CACHE = new Cache<Signature, Method>(SOFT, SOFT) { + @Override + public Method create(Signature signature) { + try { + MethodFinder finder = new MethodFinder(signature.getName(), signature.getArgs()); + return findAccessibleMethod(finder.find(signature.getType().getMethods())); + } + catch (Exception exception) { + throw new SignatureException(exception); + } + } + }; /** * Finds public method (static or non-static) @@ -65,16 +77,13 @@ PrimitiveWrapperMap.replacePrimitivesWithWrappers(args); Signature signature = new Signature(type, name, args); - Method method = CACHE.get(signature); - boolean cached = method != null; - if (cached && isPackageAccessible(method.getDeclaringClass())) { - return method; + try { + Method method = CACHE.get(signature); + return (method == null) || isPackageAccessible(method.getDeclaringClass()) ? method : CACHE.create(signature); } - method = findAccessibleMethod(new MethodFinder(name, args).find(type.getMethods())); - if (!cached) { - CACHE.put(signature, method); + catch (SignatureException exception) { + throw exception.toNoSuchMethodException("Method '" + name + "' is not found"); } - return method; } /**
--- a/src/share/classes/com/sun/beans/finder/Signature.java Wed Nov 27 14:58:24 2013 -0800 +++ b/src/share/classes/com/sun/beans/finder/Signature.java Wed Dec 11 11:19:00 2013 -0800 @@ -62,6 +62,18 @@ this.args = args; } + Class<?> getType() { + return this.type; + } + + String getName() { + return this.name; + } + + Class<?>[] getArgs() { + return this.args; + } + /** * Indicates whether some other object is "equal to" this one. *
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/beans/finder/SignatureException.java Wed Dec 11 11:19:00 2013 -0800 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. 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.beans.finder; + +final class SignatureException extends RuntimeException { + SignatureException(Throwable cause) { + super(cause); + } + + NoSuchMethodException toNoSuchMethodException(String message) { + Throwable throwable = getCause(); + if (throwable instanceof NoSuchMethodException) { + return (NoSuchMethodException) throwable; + } + NoSuchMethodException exception = new NoSuchMethodException(message); + exception.initCause(throwable); + return exception; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/beans/util/Cache.java Wed Dec 11 11:19:00 2013 -0800 @@ -0,0 +1,613 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. 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.beans.util; + +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.Objects; + +/** + * Hash table based implementation of the cache, + * which allows to use weak or soft references for keys and values. + * An entry in a {@code Cache} will automatically be removed + * when its key or value is no longer in ordinary use. + * + * @author Sergey Malenkov + * @since 1.8 + */ +public abstract class Cache<K,V> { + private static final int MAXIMUM_CAPACITY = 1 << 30; // maximum capacity MUST be a power of two <= 1<<30 + + private final boolean identity; // defines whether the identity comparison is used + private final Kind keyKind; // a reference kind for the cache keys + private final Kind valueKind; // a reference kind for the cache values + + private final ReferenceQueue<Object> queue = new ReferenceQueue<>(); // queue for references to remove + + private volatile CacheEntry<K,V>[] table = newTable(1 << 3); // table's length MUST be a power of two + private int threshold = 6; // the next size value at which to resize + private int size; // the number of key-value mappings contained in this map + + /** + * Creates a corresponding value for the specified key. + * + * @param key a key that can be used to create a value + * @return a corresponding value for the specified key + */ + public abstract V create(K key); + + /** + * Constructs an empty {@code Cache}. + * The default initial capacity is 8. + * The default load factor is 0.75. + * + * @param keyKind a reference kind for keys + * @param valueKind a reference kind for values + * + * @throws NullPointerException if {@code keyKind} or {@code valueKind} are {@code null} + */ + public Cache(Kind keyKind, Kind valueKind) { + this(keyKind, valueKind, false); + } + + /** + * Constructs an empty {@code Cache} + * with the specified comparison method. + * The default initial capacity is 8. + * The default load factor is 0.75. + * + * @param keyKind a reference kind for keys + * @param valueKind a reference kind for values + * @param identity defines whether reference-equality + * is used in place of object-equality + * + * @throws NullPointerException if {@code keyKind} or {@code valueKind} are {@code null} + */ + public Cache(Kind keyKind, Kind valueKind, boolean identity) { + Objects.requireNonNull(keyKind, "keyKind"); + Objects.requireNonNull(valueKind, "valueKind"); + this.keyKind = keyKind; + this.valueKind = valueKind; + this.identity = identity; + } + + /** + * Returns the value to which the specified key is mapped, + * or {@code null} if there is no mapping for the key. + * + * @param key the key whose cached value is to be returned + * @return a value to which the specified key is mapped, + * or {@code null} if there is no mapping for {@code key} + * + * @throws NullPointerException if {@code key} is {@code null} + * or corresponding value is {@code null} + */ + public final V get(K key) { + Objects.requireNonNull(key, "key"); + removeStaleEntries(); + int hash = hash(key); + // unsynchronized search improves performance + // the null value does not mean that there are no needed entry + CacheEntry<K,V>[] table = this.table; // unsynchronized access + V current = getEntryValue(key, hash, table[index(hash, table)]); + if (current != null) { + return current; + } + synchronized (this.queue) { + // synchronized search improves stability + // we must create and add new value if there are no needed entry + int index = index(hash, this.table); + current = getEntryValue(key, hash, this.table[index]); + if (current != null) { + return current; + } + V value = create(key); + Objects.requireNonNull(value, "value"); + this.table[index] = new CacheEntry<>(hash, key, value, this.table[index]); + if (++this.size >= this.threshold) { + if (this.table.length == MAXIMUM_CAPACITY) { + this.threshold = Integer.MAX_VALUE; + } else { + removeStaleEntries(); + table = newTable(this.table.length << 1); + transfer(this.table, table); + // If ignoring null elements and processing ref queue caused massive + // shrinkage, then restore old table. This should be rare, but avoids + // unbounded expansion of garbage-filled tables. + if (this.size >= this.threshold / 2) { + this.table = table; + this.threshold <<= 1; + } else { + transfer(table, this.table); + } + removeStaleEntries(); + } + } + return value; + } + } + + /** + * Removes the cached value that corresponds to the specified key. + * + * @param key the key whose mapping is to be removed from this cache + */ + public final void remove(K key) { + if (key != null) { + synchronized (this.queue) { + removeStaleEntries(); + int hash = hash(key); + int index = index(hash, this.table); + CacheEntry<K,V> prev = this.table[index]; + CacheEntry<K,V> entry = prev; + while (entry != null) { + CacheEntry<K,V> next = entry.next; + if (entry.matches(hash, key)) { + if (entry == prev) { + this.table[index] = next; + } else { + prev.next = next; + } + entry.unlink(); + break; + } + prev = entry; + entry = next; + } + } + } + } + + /** + * Removes all of the mappings from this cache. + * It will be empty after this call returns. + */ + public final void clear() { + synchronized (this.queue) { + int index = this.table.length; + while (0 < index--) { + CacheEntry<K,V> entry = this.table[index]; + while (entry != null) { + CacheEntry<K,V> next = entry.next; + entry.unlink(); + entry = next; + } + this.table[index] = null; + } + while (null != this.queue.poll()) { + // Clear out the reference queue. + } + } + } + + /** + * Retrieves object hash code and applies a supplemental hash function + * to the result hash, which defends against poor quality hash functions. + * This is critical because {@code Cache} uses power-of-two length hash tables, + * that otherwise encounter collisions for hashCodes that do not differ + * in lower bits. + * + * @param key the object which hash code is to be calculated + * @return a hash code value for the specified object + */ + private int hash(Object key) { + if (this.identity) { + int hash = System.identityHashCode(key); + return (hash << 1) - (hash << 8); + } + int hash = key.hashCode(); + // This function ensures that hashCodes that differ only by + // constant multiples at each bit position have a bounded + // number of collisions (approximately 8 at default load factor). + hash ^= (hash >>> 20) ^ (hash >>> 12); + return hash ^ (hash >>> 7) ^ (hash >>> 4); + } + + /** + * Returns index of the specified hash code in the given table. + * Note that the table size must be a power of two. + * + * @param hash the hash code + * @param table the table + * @return an index of the specified hash code in the given table + */ + private static int index(int hash, Object[] table) { + return hash & (table.length - 1); + } + + /** + * Creates a new array for the cache entries. + * + * @param size requested capacity MUST be a power of two + * @return a new array for the cache entries + */ + @SuppressWarnings("unchecked") + private CacheEntry<K,V>[] newTable(int size) { + return (CacheEntry<K,V>[]) new CacheEntry[size]; + } + + private V getEntryValue(K key, int hash, CacheEntry<K,V> entry) { + while (entry != null) { + if (entry.matches(hash, key)) { + return entry.value.getReferent(); + } + entry = entry.next; + } + return null; + } + + private void removeStaleEntries() { + Object reference = this.queue.poll(); + if (reference != null) { + synchronized (this.queue) { + do { + if (reference instanceof Ref) { + Ref ref = (Ref) reference; + @SuppressWarnings("unchecked") + CacheEntry<K,V> owner = (CacheEntry<K,V>) ref.getOwner(); + if (owner != null) { + int index = index(owner.hash, this.table); + CacheEntry<K,V> prev = this.table[index]; + CacheEntry<K,V> entry = prev; + while (entry != null) { + CacheEntry<K,V> next = entry.next; + if (entry == owner) { + if (entry == prev) { + this.table[index] = next; + } else { + prev.next = next; + } + entry.unlink(); + break; + } + prev = entry; + entry = next; + } + } + } + reference = this.queue.poll(); + } + while (reference != null); + } + } + } + + private void transfer(CacheEntry<K,V>[] oldTable, CacheEntry<K,V>[] newTable) { + int oldIndex = oldTable.length; + while (0 < oldIndex--) { + CacheEntry<K,V> entry = oldTable[oldIndex]; + oldTable[oldIndex] = null; + while (entry != null) { + CacheEntry<K,V> next = entry.next; + if (entry.key.isStale() || entry.value.isStale()) { + entry.unlink(); + } else { + int newIndex = index(entry.hash, newTable); + entry.next = newTable[newIndex]; + newTable[newIndex] = entry; + } + entry = next; + } + } + } + + /** + * Represents a cache entry (key-value pair). + */ + private final class CacheEntry<K,V> { + private final int hash; + private final Ref<K> key; + private final Ref<V> value; + private volatile CacheEntry<K,V> next; + + /** + * Constructs an entry for the cache. + * + * @param hash the hash code calculated for the entry key + * @param key the entry key + * @param value the initial value of the entry + * @param next the next entry in a chain + */ + private CacheEntry(int hash, K key, V value, CacheEntry<K,V> next) { + this.hash = hash; + this.key = Cache.this.keyKind.create(this, key, Cache.this.queue); + this.value = Cache.this.valueKind.create(this, value, Cache.this.queue); + this.next = next; + } + + /** + * Determines whether the entry has the given key with the given hash code. + * + * @param hash an expected hash code + * @param object an object to be compared with the entry key + * @return {@code true} if the entry has the given key with the given hash code; + * {@code false} otherwise + */ + private boolean matches(int hash, Object object) { + if (this.hash != hash) { + return false; + } + Object key = this.key.getReferent(); + return (key == object) || !Cache.this.identity && (key != null) && key.equals(object); + } + + /** + * Marks the entry as actually removed from the cache. + */ + private void unlink() { + this.next = null; + this.key.removeOwner(); + this.value.removeOwner(); + Cache.this.size--; + } + } + + /** + * Basic interface for references. + * It defines the operations common for the all kind of references. + * + * @param <T> the type of object to refer + */ + private static interface Ref<T> { + /** + * Returns the object that possesses information about the reference. + * + * @return the owner of the reference or {@code null} if the owner is unknown + */ + Object getOwner(); + + /** + * Returns the object to refer. + * + * @return the referred object or {@code null} if it was collected + */ + T getReferent(); + + /** + * Determines whether the referred object was taken by the garbage collector or not. + * + * @return {@code true} if the referred object was collected + */ + boolean isStale(); + + /** + * Marks this reference as removed from the cache. + */ + void removeOwner(); + } + + /** + * Represents a reference kind. + */ + public static enum Kind { + STRONG { + <T> Ref<T> create(Object owner, T value, ReferenceQueue<? super T> queue) { + return new Strong<>(owner, value); + } + }, + SOFT { + <T> Ref<T> create(Object owner, T referent, ReferenceQueue<? super T> queue) { + return (referent == null) + ? new Strong<>(owner, referent) + : new Soft<>(owner, referent, queue); + } + }, + WEAK { + <T> Ref<T> create(Object owner, T referent, ReferenceQueue<? super T> queue) { + return (referent == null) + ? new Strong<>(owner, referent) + : new Weak<>(owner, referent, queue); + } + }; + + /** + * Creates a reference to the specified object. + * + * @param <T> the type of object to refer + * @param owner the owner of the reference, if needed + * @param referent the object to refer + * @param queue the queue to register the reference with, + * or {@code null} if registration is not required + * @return the reference to the specified object + */ + abstract <T> Ref<T> create(Object owner, T referent, ReferenceQueue<? super T> queue); + + /** + * This is an implementation of the {@link Cache.Ref} interface + * that uses the strong references that prevent their referents + * from being made finalizable, finalized, and then reclaimed. + * + * @param <T> the type of object to refer + */ + private static final class Strong<T> implements Ref<T> { + private Object owner; + private final T referent; + + /** + * Creates a strong reference to the specified object. + * + * @param owner the owner of the reference, if needed + * @param referent the non-null object to refer + */ + private Strong(Object owner, T referent) { + this.owner = owner; + this.referent = referent; + } + + /** + * Returns the object that possesses information about the reference. + * + * @return the owner of the reference or {@code null} if the owner is unknown + */ + public Object getOwner() { + return this.owner; + } + + /** + * Returns the object to refer. + * + * @return the referred object + */ + public T getReferent() { + return this.referent; + } + + /** + * Determines whether the referred object was taken by the garbage collector or not. + * + * @return {@code true} if the referred object was collected + */ + public boolean isStale() { + return false; + } + + /** + * Marks this reference as removed from the cache. + */ + public void removeOwner() { + this.owner = null; + } + } + + /** + * This is an implementation of the {@link Cache.Ref} interface + * that uses the soft references that are cleared at the discretion + * of the garbage collector in response to a memory request. + * + * @param <T> the type of object to refer + * @see java.lang.ref.SoftReference + */ + private static final class Soft<T> extends SoftReference<T> implements Ref<T> { + private Object owner; + + /** + * Creates a soft reference to the specified object. + * + * @param owner the owner of the reference, if needed + * @param referent the non-null object to refer + * @param queue the queue to register the reference with, + * or {@code null} if registration is not required + */ + private Soft(Object owner, T referent, ReferenceQueue<? super T> queue) { + super(referent, queue); + this.owner = owner; + } + + /** + * Returns the object that possesses information about the reference. + * + * @return the owner of the reference or {@code null} if the owner is unknown + */ + public Object getOwner() { + return this.owner; + } + + /** + * Returns the object to refer. + * + * @return the referred object or {@code null} if it was collected + */ + public T getReferent() { + return get(); + } + + /** + * Determines whether the referred object was taken by the garbage collector or not. + * + * @return {@code true} if the referred object was collected + */ + public boolean isStale() { + return null == get(); + } + + /** + * Marks this reference as removed from the cache. + */ + public void removeOwner() { + this.owner = null; + } + } + + /** + * This is an implementation of the {@link Cache.Ref} interface + * that uses the weak references that do not prevent their referents + * from being made finalizable, finalized, and then reclaimed. + * + * @param <T> the type of object to refer + * @see java.lang.ref.WeakReference + */ + private static final class Weak<T> extends WeakReference<T> implements Ref<T> { + private Object owner; + + /** + * Creates a weak reference to the specified object. + * + * @param owner the owner of the reference, if needed + * @param referent the non-null object to refer + * @param queue the queue to register the reference with, + * or {@code null} if registration is not required + */ + private Weak(Object owner, T referent, ReferenceQueue<? super T> queue) { + super(referent, queue); + this.owner = owner; + } + + /** + * Returns the object that possesses information about the reference. + * + * @return the owner of the reference or {@code null} if the owner is unknown + */ + public Object getOwner() { + return this.owner; + } + + /** + * Returns the object to refer. + * + * @return the referred object or {@code null} if it was collected + */ + public T getReferent() { + return get(); + } + + /** + * Determines whether the referred object was taken by the garbage collector or not. + * + * @return {@code true} if the referred object was collected + */ + public boolean isStale() { + return null == get(); + } + + /** + * Marks this reference as removed from the cache. + */ + public void removeOwner() { + this.owner = null; + } + } + } +}
--- a/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java Wed Nov 27 14:58:24 2013 -0800 +++ b/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java Wed Dec 11 11:19:00 2013 -0800 @@ -875,8 +875,7 @@ char[] tmpPassword = ((PasswordCallback) callbacks[0]).getPassword(); if (tmpPassword == null) { - // treat a NULL password as an empty password - tmpPassword = new char[0]; + throw new LoginException("No password provided"); } password = new char[tmpPassword.length]; System.arraycopy(tmpPassword, 0,
--- a/src/share/classes/java/util/logging/Logger.java Wed Nov 27 14:58:24 2013 -0800 +++ b/src/share/classes/java/util/logging/Logger.java Wed Dec 11 11:19:00 2013 -0800 @@ -1557,6 +1557,9 @@ if (parent == null) { throw new NullPointerException(); } + if (manager == null) { + manager = LogManager.getLogManager(); + } manager.checkPermission(); doSetParent(parent); }
--- a/src/solaris/native/java/net/linux_close.c Wed Nov 27 14:58:24 2013 -0800 +++ b/src/solaris/native/java/net/linux_close.c Wed Dec 11 11:19:00 2013 -0800 @@ -192,17 +192,6 @@ { /* - * Send a wakeup signal to all threads blocked on this - * file descriptor. - */ - threadEntry_t *curr = fdEntry->threads; - while (curr != NULL) { - curr->intr = 1; - pthread_kill( curr->thr, sigWakeup ); - curr = curr->next; - } - - /* * And close/dup the file descriptor * (restart if interrupted by signal) */ @@ -214,6 +203,16 @@ } } while (rv == -1 && errno == EINTR); + /* + * Send a wakeup signal to all threads blocked on this + * file descriptor. + */ + threadEntry_t *curr = fdEntry->threads; + while (curr != NULL) { + curr->intr = 1; + pthread_kill( curr->thr, sigWakeup ); + curr = curr->next; + } } /*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/sun/corba/se/impl/orb/SetDefaultORBTest.java Wed Dec 11 11:19:00 2013 -0800 @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8028215 + * @summary SetDefaultORBTest setting ORB impl via properties test + * @run main/othervm SetDefaultORBTest + * + */ + +import java.util.Properties; + +import org.omg.CORBA.ORB; + + +public class SetDefaultORBTest { + + public static void main(String[] args) { + Properties systemProperties = System.getProperties(); + systemProperties.setProperty("org.omg.CORBA.ORBSingletonClass", + "com.sun.corba.se.impl.orb.ORBSingleton"); + System.setSecurityManager(new SecurityManager()); + Properties props = new Properties(); + props.put("org.omg.CORBA.ORBClass", "com.sun.corba.se.impl.orb.ORBImpl"); + ORB orb = ORB.init(args, props); + Class<?> orbClass = orb.getClass(); + if (orbClass.getName().equals("com.sun.corba.se.impl.orb.ORBImpl")) { + System.out.println("orbClass is com.sun.corba.se.impl.orb.ORBimpl as expected"); + } else { + throw new RuntimeException("com.sun.corba.se.impl.orb.ORBimpl class expected for ORBImpl"); + } + ORB singletonORB = ORB.init(); + Class<?> singletoneOrbClass = singletonORB.getClass(); + if (singletoneOrbClass.getName().equals("com.sun.corba.se.impl.orb.ORBSingleton")) { + System.out.println("singeletonOrbClass is com.sun.corba.se.impl.orb.ORBSingleton as expected"); + } else { + throw new RuntimeException("com.sun.corba.se.impl.orb.ORBSingleton class expected for ORBSingleton"); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/dnd/DropTargetEnterExitTest/ExtraDragEnterTest.java Wed Dec 11 11:19:00 2013 -0800 @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8024163 + * @summary Checks the dragEnter event is correctly generated + * @library ../../regtesthelpers + * @build Util + * @compile ExtraDragEnterTest.java + * @run main/othervm ExtraDragEnterTest + * @author Petr Pchelko + */ + +import test.java.awt.regtesthelpers.Util; + +import javax.swing.*; +import java.awt.*; +import java.awt.datatransfer.StringSelection; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.event.InputEvent; +import java.util.concurrent.atomic.AtomicInteger; + +public class ExtraDragEnterTest { + + private static final int FRAME_SIZE = 100; + private static final int FRAME_LOCATION = 100; + + private static AtomicInteger dragEnterCalled = new AtomicInteger(0); + + private static volatile Panel mainPanel; + private static volatile Frame f; + + private static void initAndShowUI() { + f = new Frame("Test frame"); + f.setBounds(FRAME_LOCATION,FRAME_LOCATION,FRAME_SIZE,FRAME_SIZE); + mainPanel = new Panel(); + mainPanel.setBounds(0, 0, FRAME_SIZE, FRAME_SIZE); + mainPanel.setBackground(Color.black); + mainPanel.setLayout(new GridLayout(2, 1)); + + final DraggablePanel dragSource = new DraggablePanel(); + dragSource.setBackground(Color.yellow); + dragSource.setDropTarget(null); + mainPanel.add(dragSource); + + Panel dropTarget = new Panel(); + dropTarget.setBackground(Color.red); + DropTarget dt = new DropTarget(dropTarget, new DropTargetAdapter() { + @Override public void drop(DropTargetDropEvent dtde) { } + + @Override + public void dragEnter(DropTargetDragEvent dtde) { + dragEnterCalled.incrementAndGet(); + } + }); + dropTarget.setDropTarget(dt); + mainPanel.add(dropTarget); + + f.add(mainPanel); + f.setVisible(true); + } + + public static void main(String[] args) throws Throwable { + try { + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + initAndShowUI(); + } + }); + + Robot r = new Robot(); + Util.waitForIdle(r); + Point leftCorner = new Point(mainPanel.getLocationOnScreen()); + leftCorner.translate(5, 5); + Point rightCorner = new Point(mainPanel.getLocationOnScreen()); + rightCorner.translate(mainPanel.getWidth(), mainPanel.getHeight()); + rightCorner.translate(-5, -5); + Util.drag(r, leftCorner, rightCorner, InputEvent.BUTTON1_MASK); + Util.waitForIdle(r); + + int called = dragEnterCalled.get(); + if (called != 1) { + throw new RuntimeException("Failed. Drag enter called " + called + " times. Expected 1" ); + } + } finally { + if (f != null) { + f.dispose(); + } + } + } + + private static class DraggablePanel extends Panel implements DragGestureListener { + + public DraggablePanel() { + (new DragSource()).createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, this); + } + + @Override + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(Cursor.getDefaultCursor(), new StringSelection("test")); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/dnd/DropTargetEnterExitTest/MissedDragExitTest.java Wed Dec 11 11:19:00 2013 -0800 @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8024163 + * @summary Checks that dragExit is generated when the new DropTarget is created under the drag + * @library ../../regtesthelpers + * @build Util + * @compile MissedDragExitTest.java + * @run main/othervm MissedDragExitTest + * @author Petr Pchelko + */ + +import test.java.awt.regtesthelpers.Util; + +import javax.swing.*; +import java.awt.*; +import java.awt.datatransfer.StringSelection; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.event.InputEvent; + +public class MissedDragExitTest { + + private static final int FRAME_SIZE = 100; + private static final int FRAME_LOCATION = 100; + + private static volatile boolean dragExitCalled = false; + + private static volatile Frame f; + + private static void initAndShowUI() { + f = new Frame("Test frame"); + f.setBounds(FRAME_LOCATION,FRAME_LOCATION,FRAME_SIZE,FRAME_SIZE); + + final DraggablePanel dragSource = new DraggablePanel(); + dragSource.setBackground(Color.yellow); + DropTarget dt = new DropTarget(dragSource, new DropTargetAdapter() { + @Override public void drop(DropTargetDropEvent dtde) { } + + @Override + public void dragExit(DropTargetEvent dte) { + dragExitCalled = true; + } + + @Override + public void dragOver(DropTargetDragEvent dtde) { + Panel newDropTarget = new Panel(); + newDropTarget.setDropTarget(new DropTarget()); + newDropTarget.setBackground(Color.red); + newDropTarget.setBounds(0, 0, FRAME_SIZE, FRAME_SIZE); + dragSource.add(newDropTarget); + } + }); + dragSource.setDropTarget(dt); + f.add(dragSource); + + f.setVisible(true); + } + + public static void main(String[] args) throws Throwable { + try { + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + initAndShowUI(); + } + }); + + Robot r = new Robot(); + Util.waitForIdle(r); + Util.drag(r, + new Point(FRAME_LOCATION + FRAME_SIZE / 3, FRAME_LOCATION + FRAME_SIZE / 3), + new Point(FRAME_LOCATION + FRAME_SIZE / 3 * 2, FRAME_LOCATION + FRAME_SIZE / 3 * 2), + InputEvent.BUTTON1_MASK); + Util.waitForIdle(r); + + if (!dragExitCalled) { + throw new RuntimeException("Failed. Drag exit was not called" ); + } + } finally { + if (f != null) { + f.dispose(); + } + } + } + + private static class DraggablePanel extends Panel implements DragGestureListener { + + public DraggablePanel() { + (new DragSource()).createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, this); + } + + @Override + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(Cursor.getDefaultCursor(), new StringSelection("test")); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/beans/XMLDecoder/8028054/Task.java Wed Dec 11 11:19:00 2013 -0800 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +abstract class Task<T> implements Runnable { + private transient boolean working = true; + private final List<T> methods; + private final Thread thread; + + Task(List<T> methods) { + this.methods = methods; + this.thread = new Thread(this); + this.thread.start(); + } + + boolean isAlive() { + return this.thread.isAlive(); + } + + boolean isWorking() { + boolean working = this.working && this.thread.isAlive(); + this.working = false; + return working; + } + + @Override + public void run() { + long time = -System.currentTimeMillis(); + for (T method : this.methods) { + this.working = true; + try { + for (int i = 0; i < 100; i++) { + process(method); + } + } catch (NoSuchMethodException ignore) { + } + } + time += System.currentTimeMillis(); + print("thread done in " + time / 1000 + " seconds"); + } + + protected abstract void process(T method) throws NoSuchMethodException; + + static synchronized void print(Object message) { + System.out.println(message); + System.out.flush(); + } + + static List<Class<?>> getClasses(int count) throws Exception { + String resource = ClassLoader.getSystemClassLoader().getResource("java/lang/Object.class").toString(); + + Pattern pattern = Pattern.compile("jar:file:(.*)!.*"); + Matcher matcher = pattern.matcher(resource); + matcher.matches(); + resource = matcher.group(1); + + List<Class<?>> classes = new ArrayList<>(); + try (JarFile jarFile = new JarFile(resource)) { + Enumeration<JarEntry> entries = jarFile.entries(); + while (entries.hasMoreElements()) { + String name = entries.nextElement().getName(); + if (name.startsWith("java") && name.endsWith(".class")) { + classes.add(Class.forName(name.substring(0, name.indexOf(".")).replace('/', '.'))); + if (count == classes.size()) { + break; + } + } + } + } + return classes; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/beans/XMLDecoder/8028054/TestConstructorFinder.java Wed Dec 11 11:19:00 2013 -0800 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.sun.beans.finder.ConstructorFinder; + +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/* + * @test + * @bug 8028054 + * @summary Tests that cached constructors have synchronized access + * @author Sergey Malenkov + * @compile -XDignore.symbol.file TestConstructorFinder.java + * @run main TestConstructorFinder + */ + +public class TestConstructorFinder { + public static void main(String[] args) throws Exception { + List<Class<?>> classes = Task.getClasses(Integer.MAX_VALUE); + List<Constructor> constructors = new ArrayList<>(); + for (Class<?> type : classes) { + Collections.addAll(constructors, type.getConstructors()); + } + Task.print("found " + constructors.size() + " constructors in " + classes.size() + " classes"); + + List<Task> tasks = new ArrayList<>(); + for (int i = 0; i < 50; i++) { + tasks.add(new Task<Constructor>(constructors) { + @Override + protected void process(Constructor constructor) throws NoSuchMethodException { + ConstructorFinder.findConstructor(constructor.getDeclaringClass(), constructor.getParameterTypes()); + } + }); + } + int alarm = 0; + while (true) { + int alive = 0; + int working = 0; + for (Task task : tasks) { + if (task.isWorking()) { + working++; + alive++; + } else if (task.isAlive()) { + alive++; + } + } + if (alive == 0) { + break; + } + Task.print(working + " out of " + alive + " threads are working"); + if ((working == 0) && (++alarm == 10)) { + Task.print("DEADLOCK DETECTED"); + System.exit(100); + } + Thread.sleep(1000); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/beans/XMLDecoder/8028054/TestMethodFinder.java Wed Dec 11 11:19:00 2013 -0800 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.sun.beans.finder.MethodFinder; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/* + * @test + * @bug 8028054 + * @summary Tests that cached methods have synchronized access + * @author Sergey Malenkov + * @compile -XDignore.symbol.file TestMethodFinder.java + * @run main TestMethodFinder + */ + +public class TestMethodFinder { + public static void main(String[] args) throws Exception { + List<Class<?>> classes = Task.getClasses(4000); + List<Method> methods = new ArrayList<>(); + for (Class<?> type : classes) { + Collections.addAll(methods, type.getMethods()); + } + Task.print("found " + methods.size() + " methods in " + classes.size() + " classes"); + + List<Task> tasks = new ArrayList<>(); + for (int i = 0; i < 50; i++) { + tasks.add(new Task<Method>(methods) { + @Override + protected void process(Method method) throws NoSuchMethodException { + MethodFinder.findMethod(method.getDeclaringClass(), method.getName(), method.getParameterTypes()); + } + }); + } + int alarm = 0; + while (true) { + int alive = 0; + int working = 0; + for (Task task : tasks) { + if (task.isWorking()) { + working++; + alive++; + } else if (task.isAlive()) { + alive++; + } + } + if (alive == 0) { + break; + } + Task.print(working + " out of " + alive + " threads are working"); + if ((working == 0) && (++alarm == 10)) { + Task.print("DEADLOCK DETECTED"); + System.exit(100); + } + Thread.sleep(1000); + } + } +}
--- a/test/java/lang/invoke/BigArityTest.java Wed Nov 27 14:58:24 2013 -0800 +++ b/test/java/lang/invoke/BigArityTest.java Wed Dec 11 11:19:00 2013 -0800 @@ -26,7 +26,7 @@ /* @test * @summary High arity invocations, up to the maximum of 255 arguments * @compile BigArityTest.java - * @run junit/othervm -DBigArityTest.ITERATION_COUNT=1 test.java.lang.invoke.BigArityTest + * @run junit/othervm/timeout=2500 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -esa -DBigArityTest.ITERATION_COUNT=1 test.java.lang.invoke.BigArityTest */ package test.java.lang.invoke;
--- a/test/java/lang/invoke/CallSiteTest.java Wed Nov 27 14:58:24 2013 -0800 +++ b/test/java/lang/invoke/CallSiteTest.java Wed Dec 11 11:19:00 2013 -0800 @@ -28,7 +28,7 @@ * * @build indify.Indify * @compile CallSiteTest.java - * @run main/othervm + * @run main/othervm/timeout=3600 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies * indify.Indify * --expand-properties --classpath ${test.classes} * --java test.java.lang.invoke.CallSiteTest
--- a/test/java/lang/invoke/MethodHandlesTest.java Wed Nov 27 14:58:24 2013 -0800 +++ b/test/java/lang/invoke/MethodHandlesTest.java Wed Dec 11 11:19:00 2013 -0800 @@ -26,7 +26,7 @@ /* @test * @summary unit tests for java.lang.invoke.MethodHandles * @compile MethodHandlesTest.java remote/RemoteExample.java - * @run junit/othervm test.java.lang.invoke.MethodHandlesTest + * @run junit/othervm/timeout=2500 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -esa test.java.lang.invoke.MethodHandlesTest */ package test.java.lang.invoke;
--- a/test/java/lang/invoke/RicochetTest.java Wed Nov 27 14:58:24 2013 -0800 +++ b/test/java/lang/invoke/RicochetTest.java Wed Dec 11 11:19:00 2013 -0800 @@ -25,7 +25,7 @@ /* @test * @summary unit tests for recursive method handles - * @run junit/othervm -DRicochetTest.MAX_ARITY=50 test.java.lang.invoke.RicochetTest + * @run junit/othervm/timeout=3600 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -DRicochetTest.MAX_ARITY=10 test.java.lang.invoke.RicochetTest */ /* * @ignore The following test creates an unreasonable number of adapters in -Xcomp mode (7049122)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/net/Socket/asyncClose/Race.java Wed Dec 11 11:19:00 2013 -0800 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8006395 + * @summary Race in async socket close on Linux + */ + +import java.io.InputStream; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketException; +import java.util.concurrent.Phaser; + +// Racey test, will not always fail, but if it does then we have a problem. + +public class Race { + final static int THREADS = 100; + + public static void main(String[] args) throws Exception { + try (ServerSocket ss = new ServerSocket(0)) { + final int port = ss.getLocalPort(); + final Phaser phaser = new Phaser(THREADS + 1); + for (int i=0; i<100; i++) { + final Socket s = new Socket("localhost", port); + s.setSoLinger(false, 0); + try (Socket sa = ss.accept()) { + sa.setSoLinger(false, 0); + final InputStream is = s.getInputStream(); + Thread[] threads = new Thread[THREADS]; + for (int j=0; j<THREADS; j++) { + threads[j] = new Thread() { + public void run() { + try { + phaser.arriveAndAwaitAdvance(); + while (is.read() != -1) + Thread.sleep(50); + } catch (Exception x) { + if (!(x instanceof SocketException + && x.getMessage().equals("Socket closed"))) + x.printStackTrace(); + // ok, expect Socket closed + } + }}; + } + for (int j=0; j<100; j++) + threads[j].start(); + phaser.arriveAndAwaitAdvance(); + s.close(); + for (int j=0; j<100; j++) + threads[j].join(); + } + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/util/logging/TestGetLoggerNPE.java Wed Dec 11 11:19:00 2013 -0800 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.io.PrintStream; +import java.security.Permission; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.util.logging.LogManager; +import java.util.logging.Logger; +import sun.awt.SunToolkit; + +/* + * @test + * @bug 8025512 + * + * @summary NPE with logging while launching webstart + * + * @build TestGetLoggerNPE + * @run main/othervm TestGetLoggerNPE getLogger + * @run main/othervm TestGetLoggerNPE getLogManager + */ +public class TestGetLoggerNPE { + static volatile Throwable thrown = null; + static volatile sun.awt.AppContext context = null; + public static void main(String[] args) throws Exception { + final String testCase = args.length == 0 ? "getLogger" : args[0]; + final ThreadGroup tg = new ThreadGroup("TestGroup"); + Thread t = new Thread(tg, "test") { + public void run() { + try { + context = SunToolkit.createNewAppContext(); + final PrintStream out = System.out; + System.setOut(null); + try { + if ("getLogger".equals(testCase)) { + Logger.getLogger("sun.plugin"); + } else { + LogManager.getLogManager(); + } + } finally { + System.setOut(out); + } + + System.out.println(Logger.global); + } catch (Throwable x) { + x.printStackTrace(); + thrown = x; + } + } + }; + Policy.setPolicy(new Policy() { + public boolean implies(ProtectionDomain domain, + Permission permission) { + return true; // all permissions + } + }); + System.setSecurityManager(new SecurityManager()); + t.start(); + t.join(); + if (context != null && !context.isDisposed()) { + context.dispose(); + } + if (thrown == null) { + System.out.println("PASSED: " + testCase); + } else { + System.err.println("FAILED: " + testCase); + throw new Error("Test failed: " + testCase + " - " + thrown, thrown); + } + + } + +}
--- a/test/sun/security/krb5/auto/KDC.java Wed Nov 27 14:58:24 2013 -0800 +++ b/test/sun/security/krb5/auto/KDC.java Wed Dec 11 11:19:00 2013 -0800 @@ -630,7 +630,7 @@ * @return the response * @throws java.lang.Exception for various errors */ - private byte[] processMessage(byte[] in) throws Exception { + protected byte[] processMessage(byte[] in) throws Exception { if ((in[0] & 0x1f) == Krb5.KRB_AS_REQ) return processAsReq(in); else @@ -643,7 +643,7 @@ * @return the response * @throws java.lang.Exception for various errors */ - private byte[] processTgsReq(byte[] in) throws Exception { + protected byte[] processTgsReq(byte[] in) throws Exception { TGSReq tgsReq = new TGSReq(in); PrincipalName service = tgsReq.reqBody.sname; if (options.containsKey(KDC.Option.RESP_NT)) { @@ -809,7 +809,7 @@ * @return the response * @throws java.lang.Exception for various errors */ - private byte[] processAsReq(byte[] in) throws Exception { + protected byte[] processAsReq(byte[] in) throws Exception { ASReq asReq = new ASReq(in); int[] eTypes = null; List<PAData> outPAs = new ArrayList<>();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/krb5/auto/LoginNoPass.java Wed Dec 11 11:19:00 2013 -0800 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8028351 + * @summary JWS doesn't get authenticated when using kerberos auth proxy + * @compile -XDignore.symbol.file LoginNoPass.java + * @run main/othervm LoginNoPass + */ + +import sun.security.jgss.GSSUtil; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import java.security.Security; + +public class LoginNoPass { + + static boolean kdcTouched = false; + public static void main(String[] args) throws Exception { + + new OneKDC(null) { + protected byte[] processAsReq(byte[] in) throws Exception { + kdcTouched = true; + return super.processAsReq(in); + } + }.writeJAASConf(); + Security.setProperty("auth.login.defaultCallbackHandler", + "LoginNoPass$CallbackForClient"); + System.setProperty("javax.security.auth.useSubjectCredsOnly", "false"); + + try { + Context c; + c = Context.fromJAAS("client"); + c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); + c.take(new byte[0]); + } catch (Exception e) { + e.printStackTrace(System.out); + // OK + } + if (kdcTouched) { + throw new Exception("Failed"); + } + } + public static class CallbackForClient implements CallbackHandler { + public void handle(Callback[] callbacks) { + // Do nothing + } + } +}