# HG changeset patch # User lana # Date 1415731235 28800 # Node ID 48ff867c7f24c54c155134781e29edd9b34512d9 # Parent ffc348308de2e872f5d510d440604c3726a67a18# Parent f4a778ce0cabbb391f0e8519186453e88a837399 Merge diff -r ffc348308de2 -r 48ff867c7f24 src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Tue Nov 11 10:40:35 2014 -0800 @@ -676,7 +676,7 @@ final long nsWindowPtr = getNSWindowPtr(); LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit(); Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); - if( w != null + if( w != null && w.getPeer() != null && ((LWWindowPeer)w.getPeer()).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME && !lwcToolkit.isApplicationActive()) { lwcToolkit.activateApplicationIgnoringOtherApps(); diff -r ffc348308de2 -r 48ff867c7f24 src/macosx/native/java/util/MacOSXPreferencesFile.m --- a/src/macosx/native/java/util/MacOSXPreferencesFile.m Fri Nov 07 09:22:58 2014 -0800 +++ b/src/macosx/native/java/util/MacOSXPreferencesFile.m Tue Nov 11 10:40:35 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,6 +71,8 @@ static jclass exceptionClass = NULL; jclass c; + (*env)->ExceptionClear(env); // If an exception is pending, clear it before + // calling FindClass() and/or ThrowNew(). if (exceptionClass) { c = exceptionClass; } else { @@ -534,8 +536,13 @@ (JNIEnv *env, jobject klass, jobject jpath, jobject jname, jlong juser, jlong jhost) { - CFStringRef path = toCF(env, jpath); - CFStringRef name = toCF(env, jname); + CFStringRef path = NULL; + CFStringRef name = NULL; + + path = toCF(env, jpath); + if (path != NULL) { + name = toCF(env, jname); + } CFStringRef user = (CFStringRef)jlong_to_ptr(juser); CFStringRef host = (CFStringRef)jlong_to_ptr(jhost); CFDictionaryRef node = NULL; @@ -579,8 +586,13 @@ (JNIEnv *env, jobject klass, jobject jpath, jobject jname, jlong juser, jlong jhost) { - CFStringRef path = toCF(env, jpath); - CFStringRef name = toCF(env, jname); + CFStringRef path = NULL; + CFStringRef name = NULL; + + path = toCF(env, jpath); + if (path != NULL) { + name = toCF(env, jname); + } CFStringRef user = (CFStringRef)jlong_to_ptr(juser); CFStringRef host = (CFStringRef)jlong_to_ptr(jhost); CFStringRef parentName; @@ -647,9 +659,17 @@ jobject jname, jlong juser, jlong jhost) { // like addNode, but can put a three-level-deep dict into the root file - CFStringRef path = toCF(env, jpath); - CFStringRef child = toCF(env, jchild); - CFStringRef name = toCF(env, jname); + CFStringRef path = NULL; + CFStringRef child = NULL; + CFStringRef name = NULL; + + path = toCF(env, jpath); + if (path != NULL) { + child = toCF(env, jchild); + } + if (child != NULL) { + name = toCF(env, jname); + } CFStringRef user = (CFStringRef)jlong_to_ptr(juser); CFStringRef host = (CFStringRef)jlong_to_ptr(jhost); CFMutableDictionaryRef parent; @@ -693,9 +713,17 @@ (JNIEnv *env, jobject klass, jobject jpath, jobject jchild, jobject jname, jlong juser, jlong jhost) { - CFStringRef path = toCF(env, jpath); - CFStringRef child = toCF(env, jchild); - CFStringRef name = toCF(env, jname); + CFStringRef path = NULL; + CFStringRef child = NULL; + CFStringRef name = NULL; + + path = toCF(env, jpath); + if (path != NULL) { + child = toCF(env, jchild); + } + if (child != NULL) { + name = toCF(env, jname); + } CFStringRef user = (CFStringRef)jlong_to_ptr(juser); CFStringRef host = (CFStringRef)jlong_to_ptr(jhost); CFDictionaryRef constParent; @@ -734,10 +762,21 @@ (JNIEnv *env, jobject klass, jobject jpath, jobject jkey, jobject jvalue, jobject jname, jlong juser, jlong jhost) { - CFStringRef path = toCF(env, jpath); - CFStringRef key = toCF(env, jkey); - CFStringRef value = toCF(env, jvalue); - CFStringRef name = toCF(env, jname); + CFStringRef path = NULL; + CFStringRef key = NULL; + CFStringRef value = NULL; + CFStringRef name = NULL; + + path = toCF(env, jpath); + if (path != NULL) { + key = toCF(env, jkey); + } + if (key != NULL) { + value = toCF(env, jvalue); + } + if (value != NULL) { + name = toCF(env, jname); + } CFStringRef user = (CFStringRef)jlong_to_ptr(juser); CFStringRef host = (CFStringRef)jlong_to_ptr(jhost); CFMutableDictionaryRef node = NULL; @@ -771,9 +810,17 @@ (JNIEnv *env, jobject klass, jobject jpath, jobject jkey, jobject jname, jlong juser, jlong jhost) { - CFStringRef path = toCF(env, jpath); - CFStringRef key = toCF(env, jkey); - CFStringRef name = toCF(env, jname); + CFStringRef path = NULL; + CFStringRef key = NULL; + CFStringRef name = NULL; + + path = toCF(env, jpath); + if (path != NULL) { + key = toCF(env, jkey); + } + if (key != NULL) { + name = toCF(env, jname); + } CFStringRef user = (CFStringRef)jlong_to_ptr(juser); CFStringRef host = (CFStringRef)jlong_to_ptr(jhost); CFDictionaryRef constNode; @@ -812,9 +859,17 @@ (JNIEnv *env, jobject klass, jobject jpath, jobject jkey, jobject jname, jlong juser, jlong jhost) { - CFStringRef path = toCF(env, jpath); - CFStringRef key = toCF(env, jkey); - CFStringRef name = toCF(env, jname); + CFStringRef path = NULL; + CFStringRef key = NULL; + CFStringRef name = NULL; + + path = toCF(env, jpath); + if (path != NULL) { + key = toCF(env, jkey); + } + if (key != NULL) { + name = toCF(env, jname); + } CFStringRef user = (CFStringRef)jlong_to_ptr(juser); CFStringRef host = (CFStringRef)jlong_to_ptr(jhost); CFPropertyListRef value; @@ -914,8 +969,13 @@ jobject jname, jlong juser, jlong jhost, Boolean allowSlash) { - CFStringRef path = toCF(env, jpath); - CFStringRef name = toCF(env, jname); + CFStringRef path = NULL; + CFStringRef name = NULL; + + path = toCF(env, jpath); + if (path != NULL) { + name = toCF(env, jname); + } CFStringRef user = (CFStringRef)jlong_to_ptr(juser); CFStringRef host = (CFStringRef)jlong_to_ptr(jhost); CFDictionaryRef node; diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/java/io/SequenceInputStream.java --- a/src/share/classes/java/io/SequenceInputStream.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/java/io/SequenceInputStream.java Tue Nov 11 10:40:35 2014 -0800 @@ -135,7 +135,7 @@ * @since JDK1.1 */ public int available() throws IOException { - if(in == null) { + if (in == null) { return 0; // no way to signal EOF from available() } return in.available(); @@ -160,15 +160,14 @@ * @exception IOException if an I/O error occurs. */ public int read() throws IOException { - if (in == null) { - return -1; + while (in != null) { + int c = in.read(); + if (c != -1) { + return c; + } + nextStream(); } - int c = in.read(); - if (c == -1) { - nextStream(); - return read(); - } - return c; + return -1; } /** @@ -204,13 +203,14 @@ } else if (len == 0) { return 0; } - - int n = in.read(b, off, len); - if (n <= 0) { + do { + int n = in.read(b, off, len); + if (n > 0) { + return n; + } nextStream(); - return read(b, off, len); - } - return n; + } while (in != null); + return -1; } /** diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/java/lang/invoke/MethodType.java --- a/src/share/classes/java/lang/invoke/MethodType.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/java/lang/invoke/MethodType.java Tue Nov 11 10:40:35 2014 -0800 @@ -891,11 +891,6 @@ * with MHs.eCE. * 3a. unboxing conversions can be followed by the full matrix of primitive conversions * 3b. unboxing of null is permitted (creates a zero primitive value) - * Most unboxing conversions, like {@code Object->int}, has potentially - * different behaviors for asType vs. MHs.eCE, because the dynamic value - * might be a wrapper of a type that requires narrowing, like {@code (Object)1L->byte}. - * The equivalence is only certain if the static src type is a wrapper, - * and the conversion will be a widening one. * Other than interfaces, reference-to-reference conversions are the same. * Boxing primitives to references is the same for both operators. */ @@ -906,11 +901,8 @@ // Or a boxing conversion, which is always to an exact wrapper class. return canConvert(src, dst); } else if (dst.isPrimitive()) { - Wrapper dw = Wrapper.forPrimitiveType(dst); - // Watch out: If src is Number or Object, we could get dynamic narrowing conversion. - // The conversion is known to be widening only if the wrapper type is statically visible. - return (Wrapper.isWrapperType(src) && - dw.isConvertibleFrom(Wrapper.forWrapperType(src))); + // Unboxing behavior is different between MHs.eCA & MH.asType (see 3b). + return false; } else { // R->R always works, but we have to avoid a check-cast to an interface. return !dst.isInterface() || dst.isAssignableFrom(src); diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/java/lang/ref/ReferenceQueue.java --- a/src/share/classes/java/lang/ref/ReferenceQueue.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/java/lang/ref/ReferenceQueue.java Tue Nov 11 10:40:35 2014 -0800 @@ -138,11 +138,17 @@ synchronized (lock) { Reference r = reallyPoll(); if (r != null) return r; + long start = (timeout == 0) ? 0 : System.nanoTime(); for (;;) { lock.wait(timeout); r = reallyPoll(); if (r != null) return r; - if (timeout != 0) return null; + if (timeout != 0) { + long end = System.nanoTime(); + timeout -= (end - start) / 1000_000; + if (timeout <= 0) return null; + start = end; + } } } } diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/java/util/BitSet.java --- a/src/share/classes/java/util/BitSet.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/java/util/BitSet.java Tue Nov 11 10:40:35 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -696,6 +696,9 @@ *
 {@code
      * for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1)) {
      *     // operate on index i here
+     *     if (i == Integer.MAX_VALUE) {
+     *         break; // or (i+1) would overflow
+     *     }
      * }}
* * @param fromIndex the index to start checking from (inclusive) @@ -1186,10 +1189,12 @@ int i = nextSetBit(0); if (i != -1) { b.append(i); - for (i = nextSetBit(i+1); i >= 0; i = nextSetBit(i+1)) { + while (true) { + if (++i < 0) break; + if ((i = nextSetBit(i)) < 0) break; int endOfRun = nextClearBit(i); do { b.append(", ").append(i); } - while (++i < endOfRun); + while (++i != endOfRun); } } diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/java/util/IdentityHashMap.java --- a/src/share/classes/java/util/IdentityHashMap.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/java/util/IdentityHashMap.java Tue Nov 11 10:40:35 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ package java.util; -import java.io.*; import java.lang.reflect.Array; import java.util.function.BiConsumer; import java.util.function.BiFunction; @@ -74,7 +73,7 @@ * maximum size and the number of buckets is unspecified. * *

If the size of the map (the number of key-value mappings) sufficiently - * exceeds the expected maximum size, the number of buckets is increased + * exceeds the expected maximum size, the number of buckets is increased. * Increasing the number of buckets ("rehashing") may be fairly expensive, so * it pays to create identity hash maps with a sufficiently large expected * maximum size. On the other hand, iteration over collection views requires @@ -160,6 +159,10 @@ * The maximum capacity, used if a higher value is implicitly specified * by either of the constructors with arguments. * MUST be a power of two <= 1<<29. + * + * In fact, the map can hold no more than MAXIMUM_CAPACITY-1 items + * because it has to have at least one slot with the key == null + * in order to avoid infinite loops in get(), put(), remove() */ private static final int MAXIMUM_CAPACITY = 1 << 29; @@ -181,11 +184,6 @@ transient int modCount; /** - * The next size value at which to resize (capacity * load factor). - */ - private transient int threshold; - - /** * Value representing null keys inside tables. */ static final Object NULL_KEY = new Object(); @@ -229,27 +227,18 @@ } /** - * Returns the appropriate capacity for the specified expected maximum - * size. Returns the smallest power of two between MINIMUM_CAPACITY - * and MAXIMUM_CAPACITY, inclusive, that is greater than - * (3 * expectedMaxSize)/2, if such a number exists. Otherwise - * returns MAXIMUM_CAPACITY. If (3 * expectedMaxSize)/2 is negative, it - * is assumed that overflow has occurred, and MAXIMUM_CAPACITY is returned. + * Returns the appropriate capacity for the given expected maximum size. + * Returns the smallest power of two between MINIMUM_CAPACITY and + * MAXIMUM_CAPACITY, inclusive, that is greater than (3 * + * expectedMaxSize)/2, if such a number exists. Otherwise returns + * MAXIMUM_CAPACITY. */ - private int capacity(int expectedMaxSize) { - // Compute min capacity for expectedMaxSize given a load factor of 2/3 - int minCapacity = (3 * expectedMaxSize)/2; - - // Compute the appropriate capacity - int result; - if (minCapacity > MAXIMUM_CAPACITY || minCapacity < 0) { - result = MAXIMUM_CAPACITY; - } else { - result = MINIMUM_CAPACITY; - while (result < minCapacity) - result <<= 1; - } - return result; + private static int capacity(int expectedMaxSize) { + // assert expectedMaxSize >= 0; + return + (expectedMaxSize > MAXIMUM_CAPACITY / 3) ? MAXIMUM_CAPACITY : + (expectedMaxSize <= 2 * MINIMUM_CAPACITY / 3) ? MINIMUM_CAPACITY : + Integer.highestOneBit(expectedMaxSize + (expectedMaxSize << 1)); } /** @@ -262,7 +251,6 @@ // assert initCapacity >= MINIMUM_CAPACITY; // assert initCapacity <= MAXIMUM_CAPACITY; - threshold = (initCapacity * 2)/3; table = new Object[2 * initCapacity]; } @@ -429,52 +417,58 @@ * @see #containsKey(Object) */ public V put(K key, V value) { - Object k = maskNull(key); - Object[] tab = table; - int len = tab.length; - int i = hash(k, len); + final Object k = maskNull(key); + + retryAfterResize: for (;;) { + final Object[] tab = table; + final int len = tab.length; + int i = hash(k, len); - Object item; - while ( (item = tab[i]) != null) { - if (item == k) { - @SuppressWarnings("unchecked") - V oldValue = (V) tab[i + 1]; - tab[i + 1] = value; - return oldValue; + for (Object item; (item = tab[i]) != null; + i = nextKeyIndex(i, len)) { + if (item == k) { + @SuppressWarnings("unchecked") + V oldValue = (V) tab[i + 1]; + tab[i + 1] = value; + return oldValue; + } } - i = nextKeyIndex(i, len); - } + + final int s = size + 1; + // Use optimized form of 3 * s. + // Next capacity is len, 2 * current capacity. + if (s + (s << 1) > len && resize(len)) + continue retryAfterResize; - modCount++; - tab[i] = k; - tab[i + 1] = value; - if (++size >= threshold) - resize(len); // len == 2 * current capacity. - return null; + modCount++; + tab[i] = k; + tab[i + 1] = value; + size = s; + return null; + } } /** - * Resize the table to hold given capacity. + * Resizes the table if necessary to hold given capacity. * * @param newCapacity the new capacity, must be a power of two. + * @return whether a resize did in fact take place */ - private void resize(int newCapacity) { + private boolean resize(int newCapacity) { // assert (newCapacity & -newCapacity) == newCapacity; // power of 2 int newLength = newCapacity * 2; Object[] oldTable = table; int oldLength = oldTable.length; - if (oldLength == 2*MAXIMUM_CAPACITY) { // can't expand any further - if (threshold == MAXIMUM_CAPACITY-1) + if (oldLength == 2 * MAXIMUM_CAPACITY) { // can't expand any further + if (size == MAXIMUM_CAPACITY - 1) throw new IllegalStateException("Capacity exhausted."); - threshold = MAXIMUM_CAPACITY-1; // Gigantic map! - return; + return false; } if (oldLength >= newLength) - return; + return false; Object[] newTable = new Object[newLength]; - threshold = newLength / 3; for (int j = 0; j < oldLength; j += 2) { Object key = oldTable[j]; @@ -490,6 +484,7 @@ } } table = newTable; + return true; } /** @@ -504,8 +499,8 @@ int n = m.size(); if (n == 0) return; - if (n > threshold) // conservatively pre-expand - resize(capacity(n)); + if (n > size) + resize(capacity(n)); // conservatively pre-expand for (Entry e : m.entrySet()) put(e.getKey(), e.getValue()); @@ -542,7 +537,6 @@ return null; i = nextKeyIndex(i, len); } - } /** @@ -1266,8 +1260,8 @@ private static final long serialVersionUID = 8188218128353913216L; /** - * Save the state of the IdentityHashMap instance to a stream - * (i.e., serialize it). + * Saves the state of the IdentityHashMap instance to a stream + * (i.e., serializes it). * * @serialData The size of the HashMap (the number of key-value * mappings) (int), followed by the key (Object) and @@ -1295,8 +1289,8 @@ } /** - * Reconstitute the IdentityHashMap instance from a stream (i.e., - * deserialize it). + * Reconstitutes the IdentityHashMap instance from a stream (i.e., + * deserializes it). */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { @@ -1305,9 +1299,10 @@ // Read in size (number of Mappings) int size = s.readInt(); - - // Allow for 33% growth (i.e., capacity is >= 2* size()). - init(capacity((size*4)/3)); + if (size < 0) + throw new java.io.StreamCorruptedException + ("Illegal mappings count: " + size); + init(capacity(size)); // Read the keys and values, and put the mappings in the table for (int i=0; i= Short.MIN_VALUE && value <= Short.MAX_VALUE) { mv.visitIntInsn(Opcodes.SIPUSH, value); } else { - mv.visitLdcInsn(new Integer(value)); + mv.visitLdcInsn(value); } } @@ -422,7 +422,7 @@ if (value == 0L || value == 1L) { mv.visitInsn(Opcodes.LCONST_0 + (int) value); } else { - mv.visitLdcInsn(new Long(value)); + mv.visitLdcInsn(value); } } @@ -437,7 +437,7 @@ if (bits == 0L || bits == 0x3f800000 || bits == 0x40000000) { // 0..2 mv.visitInsn(Opcodes.FCONST_0 + (int) value); } else { - mv.visitLdcInsn(new Float(value)); + mv.visitLdcInsn(value); } } @@ -452,7 +452,7 @@ if (bits == 0L || bits == 0x3ff0000000000000L) { // +0.0d and 1.0d mv.visitInsn(Opcodes.DCONST_0 + (int) value); } else { - mv.visitLdcInsn(new Double(value)); + mv.visitLdcInsn(value); } } @@ -1647,11 +1647,13 @@ */ public void catchException(final Label start, final Label end, final Type exception) { + Label doCatch = new Label(); if (exception == null) { - mv.visitTryCatchBlock(start, end, mark(), null); + mv.visitTryCatchBlock(start, end, doCatch, null); } else { - mv.visitTryCatchBlock(start, end, mark(), + mv.visitTryCatchBlock(start, end, doCatch, exception.getInternalName()); } + mark(doCatch); } } diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java --- a/src/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java Tue Nov 11 10:40:35 2014 -0800 @@ -737,7 +737,7 @@ } else if (cst >= Short.MIN_VALUE && cst <= Short.MAX_VALUE) { mv.visitIntInsn(Opcodes.SIPUSH, cst); } else { - mv.visitLdcInsn(new Integer(cst)); + mv.visitLdcInsn(cst); } } @@ -745,7 +745,7 @@ if (cst == 0L || cst == 1L) { mv.visitInsn(Opcodes.LCONST_0 + (int) cst); } else { - mv.visitLdcInsn(new Long(cst)); + mv.visitLdcInsn(cst); } } @@ -754,7 +754,7 @@ if (bits == 0L || bits == 0x3f800000 || bits == 0x40000000) { // 0..2 mv.visitInsn(Opcodes.FCONST_0 + (int) cst); } else { - mv.visitLdcInsn(new Float(cst)); + mv.visitLdcInsn(cst); } } @@ -763,7 +763,7 @@ if (bits == 0L || bits == 0x3ff0000000000000L) { // +0.0d and 1.0d mv.visitInsn(Opcodes.DCONST_0 + (int) cst); } else { - mv.visitLdcInsn(new Double(cst)); + mv.visitLdcInsn(cst); } } diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java --- a/src/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java Tue Nov 11 10:40:35 2014 -0800 @@ -366,8 +366,7 @@ protected void addSVUID(long svuid) { FieldVisitor fv = super.visitField(Opcodes.ACC_FINAL - + Opcodes.ACC_STATIC, "serialVersionUID", "J", null, new Long( - svuid)); + + Opcodes.ACC_STATIC, "serialVersionUID", "J", null, svuid); if (fv != null) { fv.visitEnd(); } diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/jdk/internal/org/objectweb/asm/tree/AnnotationNode.java --- a/src/share/classes/jdk/internal/org/objectweb/asm/tree/AnnotationNode.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/jdk/internal/org/objectweb/asm/tree/AnnotationNode.java Tue Nov 11 10:40:35 2014 -0800 @@ -247,11 +247,13 @@ an.accept(av.visitAnnotation(name, an.desc)); } else if (value instanceof List) { AnnotationVisitor v = av.visitArray(name); - List array = (List) value; - for (int j = 0; j < array.size(); ++j) { - accept(v, null, array.get(j)); + if (v != null) { + List array = (List) value; + for (int j = 0; j < array.size(); ++j) { + accept(v, null, array.get(j)); + } + v.visitEnd(); } - v.visitEnd(); } else { av.visit(name, value); } diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/jdk/internal/org/objectweb/asm/tree/LookupSwitchInsnNode.java --- a/src/share/classes/jdk/internal/org/objectweb/asm/tree/LookupSwitchInsnNode.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/jdk/internal/org/objectweb/asm/tree/LookupSwitchInsnNode.java Tue Nov 11 10:40:35 2014 -0800 @@ -110,7 +110,7 @@ : labels.length); if (keys != null) { for (int i = 0; i < keys.length; ++i) { - this.keys.add(new Integer(keys[i])); + this.keys.add(keys[i]); } } if (labels != null) { diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodInsnNode.java --- a/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodInsnNode.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodInsnNode.java Tue Nov 11 10:40:35 2014 -0800 @@ -160,6 +160,7 @@ @Override public void accept(final MethodVisitor mv) { mv.visitMethodInsn(opcode, owner, name, desc, itf); + acceptAnnotations(mv); } @Override diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java --- a/src/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java Tue Nov 11 10:40:35 2014 -0800 @@ -802,7 +802,7 @@ if (labels.get(label) != null) { throw new IllegalArgumentException("Already visited label"); } - labels.put(label, new Integer(insnCount)); + labels.put(label, insnCount); super.visitLabel(label); } diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java --- a/src/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java Tue Nov 11 10:40:35 2014 -0800 @@ -732,7 +732,7 @@ Textifier t = createTextifier(); text.add(t.getText()); text.add(visible ? ") // parameter " : ") // invisible, parameter "); - text.add(new Integer(parameter)); + text.add(parameter); text.add("\n"); return t; } diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/jdk/internal/org/objectweb/asm/version.txt --- a/src/share/classes/jdk/internal/org/objectweb/asm/version.txt Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/jdk/internal/org/objectweb/asm/version.txt Tue Nov 11 10:40:35 2014 -0800 @@ -1,12 +1,12 @@ Path: . -Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/asm-svn-2014-06-19 +Working Copy Root Path: /hudson/jobs/objectweb-init/workspace/asm-svn-2014-10-15 URL: file:///svnroot/asm/trunk/asm Repository Root: file:///svnroot/asm Repository UUID: 271bd773-ee82-43a6-9b2b-1890ed8ce7f9 -Revision: 1750 +Revision: 1772 Node Kind: directory Schedule: normal -Last Changed Author: forax -Last Changed Rev: 1750 -Last Changed Date: 2014-06-06 00:31:02 +0200 (Fri, 06 Jun 2014) +Last Changed Author: ebruneton +Last Changed Rev: 1772 +Last Changed Date: 2014-09-06 09:13:07 +0200 (Sat, 06 Sep 2014) diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/jdk/net/Sockets.java --- a/src/share/classes/jdk/net/Sockets.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/jdk/net/Sockets.java Tue Nov 11 10:40:35 2014 -0800 @@ -371,6 +371,7 @@ set = new HashSet<>(); set.add(StandardSocketOptions.SO_RCVBUF); set.add(StandardSocketOptions.SO_REUSEADDR); + set.add(StandardSocketOptions.IP_TOS); set = Collections.unmodifiableSet(set); options.put(ServerSocket.class, set); diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/sun/invoke/util/Wrapper.java --- a/src/share/classes/sun/invoke/util/Wrapper.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/sun/invoke/util/Wrapper.java Tue Nov 11 10:40:35 2014 -0800 @@ -26,19 +26,19 @@ package sun.invoke.util; public enum Wrapper { - BOOLEAN(Boolean.class, boolean.class, 'Z', (Boolean)false, new boolean[0], Format.unsigned(1)), + // wrapperType primitiveType char zero emptyArray format + BOOLEAN( Boolean.class, boolean.class, 'Z', (Boolean)false, new boolean[0], Format.unsigned( 1)), // These must be in the order defined for widening primitive conversions in JLS 5.1.2 - BYTE(Byte.class, byte.class, 'B', (Byte)(byte)0, new byte[0], Format.signed(8)), - SHORT(Short.class, short.class, 'S', (Short)(short)0, new short[0], Format.signed(16)), - CHAR(Character.class, char.class, 'C', (Character)(char)0, new char[0], Format.unsigned(16)), - INT(Integer.class, int.class, 'I', (Integer)/*(int)*/0, new int[0], Format.signed(32)), - LONG(Long.class, long.class, 'J', (Long)(long)0, new long[0], Format.signed(64)), - FLOAT(Float.class, float.class, 'F', (Float)(float)0, new float[0], Format.floating(32)), - DOUBLE(Double.class, double.class, 'D', (Double)(double)0, new double[0], Format.floating(64)), - //NULL(Null.class, null.class, 'N', null, null, Format.other(1)), - OBJECT(Object.class, Object.class, 'L', null, new Object[0], Format.other(1)), + BYTE ( Byte.class, byte.class, 'B', (Byte)(byte)0, new byte[0], Format.signed( 8)), + SHORT ( Short.class, short.class, 'S', (Short)(short)0, new short[0], Format.signed( 16)), + CHAR (Character.class, char.class, 'C', (Character)(char)0, new char[0], Format.unsigned(16)), + INT ( Integer.class, int.class, 'I', (Integer)/*(int)*/0, new int[0], Format.signed( 32)), + LONG ( Long.class, long.class, 'J', (Long)(long)0, new long[0], Format.signed( 64)), + FLOAT ( Float.class, float.class, 'F', (Float)(float)0, new float[0], Format.floating(32)), + DOUBLE ( Double.class, double.class, 'D', (Double)(double)0, new double[0], Format.floating(64)), + OBJECT ( Object.class, Object.class, 'L', null, new Object[0], Format.other( 1)), // VOID must be the last type, since it is "assignable" from any other type: - VOID(Void.class, void.class, 'V', null, null, Format.other(0)), + VOID ( Void.class, void.class, 'V', null, null, Format.other( 0)), ; private final Class wrapperType; diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/sun/nio/fs/AbstractPoller.java --- a/src/share/classes/sun/nio/fs/AbstractPoller.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/sun/nio/fs/AbstractPoller.java Tue Nov 11 10:40:35 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -100,8 +100,6 @@ // validate arguments before request to poller if (dir == null) throw new NullPointerException(); - if (events.length == 0) - throw new IllegalArgumentException("No events to register"); Set> eventSet = new HashSet<>(events.length); for (WatchEvent.Kind event: events) { // standard events @@ -114,17 +112,16 @@ } // OVERFLOW is ignored - if (event == StandardWatchEventKinds.OVERFLOW) { - if (events.length == 1) - throw new IllegalArgumentException("No events to register"); + if (event == StandardWatchEventKinds.OVERFLOW) continue; - } // null/unsupported if (event == null) throw new NullPointerException("An element in event set is 'null'"); throw new UnsupportedOperationException(event.name()); } + if (eventSet.isEmpty()) + throw new IllegalArgumentException("No events to register"); return (WatchKey)invoke(RequestType.REGISTER, dir, eventSet, modifiers); } @@ -192,14 +189,17 @@ * the request. */ Object awaitResult() { + boolean interrupted = false; synchronized (this) { while (!completed) { try { wait(); } catch (InterruptedException x) { - // ignore + interrupted = true; } } + if (interrupted) + Thread.currentThread().interrupt(); return result; } } diff -r ffc348308de2 -r 48ff867c7f24 src/share/classes/sun/nio/fs/PollingWatchService.java --- a/src/share/classes/sun/nio/fs/PollingWatchService.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/classes/sun/nio/fs/PollingWatchService.java Tue Nov 11 10:40:35 2014 -0800 @@ -74,8 +74,6 @@ throws IOException { // check events - CCE will be thrown if there are invalid elements - if (events.length == 0) - throw new IllegalArgumentException("No events to register"); final Set> eventSet = new HashSet>(events.length); for (WatchEvent.Kind event: events) { @@ -90,8 +88,6 @@ // OVERFLOW is ignored if (event == StandardWatchEventKinds.OVERFLOW) { - if (events.length == 1) - throw new IllegalArgumentException("No events to register"); continue; } @@ -100,6 +96,8 @@ throw new NullPointerException("An element in event set is 'null'"); throw new UnsupportedOperationException(event.name()); } + if (eventSet.isEmpty()) + throw new IllegalArgumentException("No events to register"); // A modifier may be used to specify the sensitivity level SensitivityWatchEventModifier sensivity = SensitivityWatchEventModifier.MEDIUM; diff -r ffc348308de2 -r 48ff867c7f24 src/share/native/sun/security/pkcs11/wrapper/p11_crypt.c --- a/src/share/native/sun/security/pkcs11/wrapper/p11_crypt.c Fri Nov 07 09:22:58 2014 -0800 +++ b/src/share/native/sun/security/pkcs11/wrapper/p11_crypt.c Tue Nov 11 10:40:35 2014 -0800 @@ -141,8 +141,8 @@ (CK_BYTE_PTR)(outBufP + jOutOfs), &ckEncryptedPartLen); - (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT); (*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT); + (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT); ckAssertReturnValueOK(env, rv); return ckEncryptedPartLen; @@ -214,7 +214,7 @@ } if (directOut == 0) { - (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT); + (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT); } ckAssertReturnValueOK(env, rv); @@ -266,7 +266,7 @@ //printf("EF: ckLastEncryptedPartLen=%i", ckLastEncryptedPartLen); if (directOut == 0) { - (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT); + (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT); } ckAssertReturnValueOK(env, rv); @@ -361,8 +361,8 @@ (CK_BYTE_PTR)(outBufP + jOutOfs), &ckPartLen); - (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT); (*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT); + (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT); ckAssertReturnValueOK(env, rv); @@ -429,7 +429,7 @@ } if (directOut == 0) { - (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT); + (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT); } ckAssertReturnValueOK(env, rv); @@ -478,7 +478,7 @@ &ckLastPartLen); if (directOut == 0) { - (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT); + (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT); } diff -r ffc348308de2 -r 48ff867c7f24 src/solaris/native/sun/nio/ch/FileDispatcherImpl.c --- a/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c Fri Nov 07 09:22:58 2014 -0800 +++ b/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c Tue Nov 11 10:40:35 2014 -0800 @@ -34,6 +34,10 @@ #include #include #include +#if defined(__linux__) +#include +#include +#endif #include "nio.h" #include "nio_util.h" @@ -177,10 +181,21 @@ JNIEXPORT jlong JNICALL Java_sun_nio_ch_FileDispatcherImpl_size0(JNIEnv *env, jobject this, jobject fdo) { + jint fd = fdval(env, fdo); struct stat64 fbuf; - if (fstat64(fdval(env, fdo), &fbuf) < 0) + if (fstat64(fd, &fbuf) < 0) return handle(env, -1, "Size failed"); + +#ifdef BLKGETSIZE64 + if (S_ISBLK(fbuf.st_mode)) { + uint64_t size; + if (ioctl(fd, BLKGETSIZE64, &size) < 0) + return handle(env, -1, "Size failed"); + return (jlong)size; + } +#endif + return fbuf.st_size; } diff -r ffc348308de2 -r 48ff867c7f24 src/windows/classes/sun/awt/windows/WPathGraphics.java --- a/src/windows/classes/sun/awt/windows/WPathGraphics.java Fri Nov 07 09:22:58 2014 -0800 +++ b/src/windows/classes/sun/awt/windows/WPathGraphics.java Tue Nov 11 10:40:35 2014 -0800 @@ -1400,7 +1400,9 @@ * The saved device transform is needed as the current transform * is not likely to be the same. */ - deviceClip(savedClip.getPathIterator(savedTransform)); + if (savedClip != null) { + deviceClip(savedClip.getPathIterator(savedTransform)); + } /* Scale the bounding rectangle by the scale transform. * Because the scaling transform has only x and y diff -r ffc348308de2 -r 48ff867c7f24 test/com/sun/jndi/ldap/LdapTimeoutTest.java --- a/test/com/sun/jndi/ldap/LdapTimeoutTest.java Fri Nov 07 09:22:58 2014 -0800 +++ b/test/com/sun/jndi/ldap/LdapTimeoutTest.java Tue Nov 11 10:40:35 2014 -0800 @@ -46,8 +46,7 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS; public class LdapTimeoutTest { - private static final ScheduledExecutorService pool = - Executors.newScheduledThreadPool(1); + static volatile int passed = 0, failed = 0; static void pass() {passed++;} static void fail() {failed++; Thread.dumpStack();} @@ -80,7 +79,6 @@ new LdapTimeoutTest().simpleAuthConnectTest(env); } finally { s.interrupt(); - LdapTimeoutTest.pool.shutdown(); } System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); @@ -90,7 +88,6 @@ void ldapReadTimeoutTest(Hashtable env, boolean ssl) { InitialContext ctx = null; if (ssl) env.put(Context.SECURITY_PROTOCOL, "ssl"); - ScheduledFuture killer = killSwitch(5_000); long start = System.nanoTime(); try { ctx = new InitialDirContext(env); @@ -112,13 +109,12 @@ pass(); } } finally { - if (!shutItDown(killer, ctx)) fail(); + if (!shutItDown(ctx)) fail(); } } void simpleAuthConnectTest(Hashtable env) { InitialContext ctx = null; - ScheduledFuture killer = killSwitch(5_000); long start = System.nanoTime(); try { ctx = new InitialDirContext(env); @@ -141,13 +137,12 @@ fail(); } } finally { - if (!shutItDown(killer, ctx)) fail(); + if (!shutItDown(ctx)) fail(); } } void deadServerNoTimeout(Hashtable env) { InitialContext ctx = null; - ScheduledFuture killer = killSwitch(30_000); long start = System.currentTimeMillis(); try { ctx = new InitialDirContext(env); @@ -169,12 +164,11 @@ pass(); } } finally { - if (!shutItDown(killer, ctx)) fail(); + if (!shutItDown(ctx)) fail(); } } - boolean shutItDown(ScheduledFuture killer, InitialContext ctx) { - killer.cancel(true); + boolean shutItDown(InitialContext ctx) { try { if (ctx != null) ctx.close(); return true; @@ -183,17 +177,6 @@ } } - ScheduledFuture killSwitch(int ms) { - final Thread current = Thread.currentThread(); - return LdapTimeoutTest.pool.schedule(new Callable() { - public Void call() throws Exception { - System.err.println("Fail: killSwitch()"); - System.exit(0); - return null; - } - }, ms, MILLISECONDS); - } - static class Server extends Thread { final ServerSocket serverSock; diff -r ffc348308de2 -r 48ff867c7f24 test/java/awt/Frame/DisposeStressTest/DisposeStressTest.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Frame/DisposeStressTest/DisposeStressTest.html Tue Nov 11 10:40:35 2014 -0800 @@ -0,0 +1,21 @@ + + + +DisposeStressTest + + + +

DisposeStressTest
Bug ID: 4051487, 4145670

+ +

This is an AUTOMATIC test, simply wait for completion

+ + + + diff -r ffc348308de2 -r 48ff867c7f24 test/java/awt/Frame/DisposeStressTest/DisposeStressTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Frame/DisposeStressTest/DisposeStressTest.java Tue Nov 11 10:40:35 2014 -0800 @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +/* + test + @bug 4051487 4145670 8062021 + @summary Tests that disposing of an empty Frame or a Frame with a MenuBar + while it is being created does not crash the VM. + @author dpm area=Threads + @run applet/timeout=7200 DisposeStressTest.html +*/ + +// Note there is no @ in front of test above. This is so that the +// harness will not mistake this file as a test file. It should +// only see the html file as a test file. (the harness runs all +// valid test files, so it would run this test twice if this file +// were valid as well as the html file.) +// Also, note the area= after Your Name in the author tag. Here, you +// should put which functional area the test falls in. See the +// AWT-core home page -> test areas and/or -> AWT team for a list of +// areas. +// Note also the 'DisposeStressTest.html' in the run tag. This should +// be changed to the name of the test. + + +/** + * DisposeStressTest.java + * + * summary: + */ + +import java.applet.Applet; +import java.awt.*; + + +//Automated tests should run as applet tests if possible because they +// get their environments cleaned up, including AWT threads, any +// test created threads, and any system resources used by the test +// such as file descriptors. (This is normally not a problem as +// main tests usually run in a separate VM, however on some platforms +// such as the Mac, separate VMs are not possible and non-applet +// tests will cause problems). Also, you don't have to worry about +// synchronisation stuff in Applet tests they way you do in main +// tests... + + +public class DisposeStressTest extends Applet + { + //Declare things used in the test, like buttons and labels here + + public void init() + { + //Create instructions for the user here, as well as set up + // the environment -- set the layout manager, add buttons, + // etc. + + this.setLayout (new BorderLayout ()); + + String[] instructions = + { + "This is an AUTOMATIC test", + "simply wait until it is done" + }; + Sysout.createDialog( ); + Sysout.printInstructions( instructions ); + + }//End init() + + public void start () + { + for (int i = 0; i < 1000; i++) { + Frame f = new Frame(); + f.setBounds(10, 10, 10, 10); + f.show(); + f.dispose(); + + Frame f2 = new Frame(); + f2.setBounds(10, 10, 100, 100); + MenuBar bar = new MenuBar(); + Menu menu = new Menu(); + menu.add(new MenuItem("foo")); + bar.add(menu); + f2.setMenuBar(bar); + f2.show(); + f2.dispose(); + } + }// start() + + }// class DisposeStressTest + + +/**************************************************** + Standard Test Machinery + DO NOT modify anything below -- it's a standard + chunk of code whose purpose is to make user + interaction uniform, and thereby make it simpler + to read and understand someone else's test. + ****************************************************/ + +/** + This is part of the standard test machinery. + It creates a dialog (with the instructions), and is the interface + for sending text messages to the user. + To print the instructions, send an array of strings to Sysout.createDialog + WithInstructions method. Put one line of instructions per array entry. + To display a message for the tester to see, simply call Sysout.println + with the string to be displayed. + This mimics System.out.println but works within the test harness as well + as standalone. + */ + +class Sysout + { + private static TestDialog dialog; + + public static void createDialogWithInstructions( String[] instructions ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + dialog.printInstructions( instructions ); + dialog.show(); + println( "Any messages for the tester will display here." ); + } + + public static void createDialog( ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + String[] defInstr = { "Instructions will appear here. ", "" } ; + dialog.printInstructions( defInstr ); + dialog.show(); + println( "Any messages for the tester will display here." ); + } + + + public static void printInstructions( String[] instructions ) + { + dialog.printInstructions( instructions ); + } + + + public static void println( String messageIn ) + { + dialog.displayMessage( messageIn ); + } + + }// Sysout class + +/** + This is part of the standard test machinery. It provides a place for the + test instructions to be displayed, and a place for interactive messages + to the user to be displayed. + To have the test instructions displayed, see Sysout. + To have a message to the user be displayed, see Sysout. + Do not call anything in this dialog directly. + */ +class TestDialog extends Dialog + { + + TextArea instructionsText; + TextArea messageText; + int maxStringLength = 80; + + //DO NOT call this directly, go through Sysout + public TestDialog( Frame frame, String name ) + { + super( frame, name ); + int scrollBoth = TextArea.SCROLLBARS_BOTH; + instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); + add( "North", instructionsText ); + + messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); + add("South", messageText); + + pack(); + + show(); + }// TestDialog() + + //DO NOT call this directly, go through Sysout + public void printInstructions( String[] instructions ) + { + //Clear out any current instructions + instructionsText.setText( "" ); + + //Go down array of instruction strings + + String printStr, remainingStr; + for( int i=0; i < instructions.length; i++ ) + { + //chop up each into pieces maxSringLength long + remainingStr = instructions[ i ]; + while( remainingStr.length() > 0 ) + { + //if longer than max then chop off first max chars to print + if( remainingStr.length() >= maxStringLength ) + { + //Try to chop on a word boundary + int posOfSpace = remainingStr. + lastIndexOf( ' ', maxStringLength - 1 ); + + if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; + + printStr = remainingStr.substring( 0, posOfSpace + 1 ); + remainingStr = remainingStr.substring( posOfSpace + 1 ); + } + //else just print + else + { + printStr = remainingStr; + remainingStr = ""; + } + + instructionsText.append( printStr + "\n" ); + + }// while + + }// for + + }//printInstructions() + + //DO NOT call this directly, go through Sysout + public void displayMessage( String messageIn ) + { + messageText.append( messageIn + "\n" ); + } + + }// TestDialog class diff -r ffc348308de2 -r 48ff867c7f24 test/java/awt/print/PrinterJob/ImagePrinting/NullClipARGB.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/print/PrinterJob/ImagePrinting/NullClipARGB.java Tue Nov 11 10:40:35 2014 -0800 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8061392 + * @summary Test no NPE when printing transparency with null clip. + */ + +import java.awt.*; +import java.awt.image.*; +import java.awt.print.*; + +public class NullClipARGB implements Printable { + + public static void main( String[] args ) { + + try { + PrinterJob pj = PrinterJob.getPrinterJob(); + pj.setPrintable(new NullClipARGB()); + pj.print(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + public int print(Graphics g, PageFormat pf, int pageIndex) + throws PrinterException{ + + if (pageIndex != 0) { + return NO_SUCH_PAGE; + } + Graphics2D g2 = (Graphics2D)g; + System.out.println("original clip="+g2.getClip()); + g2.translate(pf.getImageableX(), pf.getImageableY()); + g2.rotate(0.2); + g2.setClip(null); + g2.setColor( Color.BLACK ); + g2.drawString("This text should be visible through the image", 0, 20); + BufferedImage bi = new BufferedImage(100, 100, + BufferedImage.TYPE_INT_ARGB ); + Graphics ig = bi.createGraphics(); + ig.setColor( new Color( 192, 192, 192, 80 ) ); + ig.fillRect( 0, 0, 100, 100 ); + ig.setColor( Color.BLACK ); + ig.drawRect( 0, 0, 99, 99 ); + ig.dispose(); + g2.drawImage(bi, 10, 0, 90, 90, null ); + g2.translate(100, 100); + g2.drawString("This text should also be visible through the image", 0, 20); + g2.drawImage(bi, 10, 0, 90, 90, null ); + return PAGE_EXISTS; + } +} diff -r ffc348308de2 -r 48ff867c7f24 test/java/io/SequenceInputStream/LotsOfStreams.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/io/SequenceInputStream/LotsOfStreams.java Tue Nov 11 10:40:35 2014 -0800 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 7011804 + * @summary SequenceInputStream#read() was implemented recursivly, + * which may cause stack overflow + */ + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.SequenceInputStream; +import java.util.Enumeration; + +public class LotsOfStreams { + + static final int MAX_SUBSTREAMS = 32000; + + public static void main(String[] argv) throws Exception { + try (InputStream stream = + new SequenceInputStream(new LOSEnumeration())) { + stream.read(); + } + try (InputStream stream = + new SequenceInputStream(new LOSEnumeration())) { + byte[] b = new byte[1]; + stream.read(b, 0, 1); + } + } + + static class LOSEnumeration + implements Enumeration { + + private static InputStream inputStream = + new ByteArrayInputStream(new byte[0]); + private int left = MAX_SUBSTREAMS; + + public boolean hasMoreElements() { + return (left > 0); + } + public InputStream nextElement() { + left--; + return inputStream; + } + } +} diff -r ffc348308de2 -r 48ff867c7f24 test/java/lang/invoke/ExplicitCastArgumentsTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/invoke/ExplicitCastArgumentsTest.java Tue Nov 11 10:40:35 2014 -0800 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.invoke; + +import sun.invoke.util.Wrapper; + +/* @test + * @summary unit tests for MethodHandles.explicitCastArguments() + * + * @run main/bootclasspath java.lang.invoke.ExplicitCastArgumentsTest + */ +public class ExplicitCastArgumentsTest { + private static final boolean VERBOSE = Boolean.getBoolean("verbose"); + + public static void main(String[] args) throws Throwable { + for (Wrapper from : Wrapper.values()) { + for (Wrapper to : Wrapper.values()) { + if (from == Wrapper.VOID || to == Wrapper.VOID) continue; + testRef2Prim (from, to); + } + } + System.out.println("TEST PASSED"); + } + + public static void testRef2Prim(Wrapper from, Wrapper to) throws Throwable { + // MHs.eCA javadoc: + // If T0 is a reference and T1 a primitive, and if the reference is null at runtime, a zero value is introduced. + test(from.wrapperType(), to.primitiveType(), null, false); + } + + public static void test(Class from, Class to, Object param, boolean failureExpected) throws Throwable { + if (VERBOSE) System.out.printf("%-10s => %-10s: %5s: ", from.getSimpleName(), to.getSimpleName(), param); + + MethodHandle original = MethodHandles.identity(from); + MethodType newType = original.type().changeReturnType(to); + + try { + MethodHandle target = MethodHandles.explicitCastArguments(original, newType); + Object result = target.invokeWithArguments(param); + + if (VERBOSE) { + String resultStr; + if (result != null) { + resultStr = String.format("%10s (%10s)", "'"+result+"'", result.getClass().getSimpleName()); + } else { + resultStr = String.format("%10s", result); + } + System.out.println(resultStr); + } + + if (failureExpected) { + String msg = String.format("No exception thrown: %s => %s; parameter: %s", from, to, param); + throw new AssertionError(msg); + } + } catch (AssertionError e) { + throw e; // report test failure + } catch (Throwable e) { + if (VERBOSE) System.out.printf("%s: %s\n", e.getClass(), e.getMessage()); + if (!failureExpected) { + String msg = String.format("Unexpected exception was thrown: %s => %s; parameter: %s", from, to, param); + throw new AssertionError(msg, e); + } + } + } +} diff -r ffc348308de2 -r 48ff867c7f24 test/java/lang/ref/EarlyTimeout.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/ref/EarlyTimeout.java Tue Nov 11 10:40:35 2014 -0800 @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 6853696 + * @summary ReferenceQueue#remove(timeout) should not return null before + * timeout is elapsed + */ + +import java.lang.InterruptedException; +import java.lang.System; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.util.concurrent.CountDownLatch; +import static java.util.concurrent.TimeUnit.NANOSECONDS; + +/** + * In order to demonstrate the issue we make several threads (two appears to be sufficient) + * to block in ReferenceQueue#remove(timeout) at the same time. + * Then, we force a reference to be enqueued by setting its referent to null and calling System.gc(). + * One of the threads gets the reference returned from the remove(). + * The other threads get null: + * 1) with bug: this may happen before the specified timeout is elapsed, + * 2) without bug: this can only happen after the timeout is fully elapsed. + */ + +public class EarlyTimeout extends Thread { + + static final int THREADS_COUNT = 2; + static final int TIMEOUT = 1000; + + static Object referent = new Object(); + static final ReferenceQueue queue = new ReferenceQueue(); + static final WeakReference weakReference = new WeakReference(referent, queue); + static final CountDownLatch startedSignal = new CountDownLatch(THREADS_COUNT); + + long actual; + Reference reference; + + public static void main(String[] args) throws Exception { + EarlyTimeout[] threads = new EarlyTimeout[THREADS_COUNT]; + for (int i = 0; i < THREADS_COUNT; ++i) { + threads[i] = new EarlyTimeout(); + threads[i].start(); + } + // The main thread waits until the threads has started and give it a chance + // for the threads to block on the queue.remove(TIMEOUT) call + startedSignal.await(); + Thread.sleep(TIMEOUT / 2); + referent = null; + System.gc(); + for (EarlyTimeout thread : threads) { + thread.join(); + } + if (weakReference.get() != null) { + throw new RuntimeException("weakReference was not cleared"); + } + int nonNullRefCount = 0; + for (EarlyTimeout thread : threads) { + if (thread.reference == null && thread.actual < TIMEOUT) { + throw new RuntimeException("elapsed time " + thread.actual + + " is less than timeout " + TIMEOUT); + } + if (thread.reference != null && thread.reference == weakReference) { + nonNullRefCount++; + } + } + if (nonNullRefCount > 1) { + throw new RuntimeException("more than one references were removed from queue"); + } + } + + public void run() { + try { + startedSignal.countDown(); + long start = System.nanoTime(); + reference = queue.remove(TIMEOUT); + actual = NANOSECONDS.toMillis(System.nanoTime() - start); + } catch (InterruptedException ex) { + throw new RuntimeException(ex); + } + } +} diff -r ffc348308de2 -r 48ff867c7f24 test/java/nio/channels/FileChannel/BlockDeviceSize.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/nio/channels/FileChannel/BlockDeviceSize.java Tue Nov 11 10:40:35 2014 -0800 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 8054029 + * @summary Block devices should not report size=0 on Linux + */ + +import java.io.RandomAccessFile; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.channels.FileChannel; +import java.nio.file.AccessDeniedException; +import java.nio.file.NoSuchFileException; +import static java.nio.file.StandardOpenOption.*; + + +public class BlockDeviceSize { + private static final String BLK_FNAME = "/dev/sda1"; + private static final Path BLK_PATH = Paths.get(BLK_FNAME); + + public static void main(String[] args) throws Throwable { + try (FileChannel ch = FileChannel.open(BLK_PATH, READ); + RandomAccessFile file = new RandomAccessFile(BLK_FNAME, "r")) { + + long size1 = ch.size(); + long size2 = file.length(); + if (size1 != size2) { + throw new RuntimeException("size differs when retrieved" + + " in different ways: " + size1 + " != " + size2); + } + System.out.println("OK"); + + } catch (NoSuchFileException nsfe) { + System.err.println("File " + BLK_FNAME + " not found." + + " Skipping test"); + } catch (AccessDeniedException ade) { + System.err.println("Access to " + BLK_FNAME + " is denied." + + " Run test as root."); + } + } +} diff -r ffc348308de2 -r 48ff867c7f24 test/java/nio/file/WatchService/Basic.java --- a/test/java/nio/file/WatchService/Basic.java Fri Nov 07 09:22:58 2014 -0800 +++ b/test/java/nio/file/WatchService/Basic.java Tue Nov 11 10:40:35 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - * @bug 4313887 6838333 7017446 + * @bug 4313887 6838333 7017446 8011537 8042470 * @summary Unit test for java.nio.file.WatchService * @library .. * @run main Basic @@ -295,24 +295,31 @@ // IllegalArgumentException System.out.println("IllegalArgumentException tests..."); try { - dir.register(watcher, new WatchEvent.Kind[]{ } ); + dir.register(watcher /*empty event list*/); throw new RuntimeException("IllegalArgumentException not thrown"); } catch (IllegalArgumentException x) { } try { // OVERFLOW is ignored so this is equivalent to the empty set - dir.register(watcher, new WatchEvent.Kind[]{ OVERFLOW }); + dir.register(watcher, OVERFLOW); + throw new RuntimeException("IllegalArgumentException not thrown"); + } catch (IllegalArgumentException x) { + } + try { + // OVERFLOW is ignored even if specified multiple times + dir.register(watcher, OVERFLOW, OVERFLOW); throw new RuntimeException("IllegalArgumentException not thrown"); } catch (IllegalArgumentException x) { } // UnsupportedOperationException try { - dir.register(watcher, new WatchEvent.Kind[]{ + dir.register(watcher, new WatchEvent.Kind() { @Override public String name() { return "custom"; } @Override public Class type() { return Object.class; } - }}); + }); + throw new RuntimeException("UnsupportedOperationException not thrown"); } catch (UnsupportedOperationException x) { } try { @@ -328,7 +335,7 @@ // NullPointerException System.out.println("NullPointerException tests..."); try { - dir.register(null, new WatchEvent.Kind[]{ ENTRY_CREATE }); + dir.register(null, ENTRY_CREATE); throw new RuntimeException("NullPointerException not thrown"); } catch (NullPointerException x) { } @@ -380,7 +387,7 @@ try { dir.register(watcher, new WatchEvent.Kind[]{ ENTRY_CREATE }); - throw new RuntimeException("ClosedWatchServiceException not thrown"); + throw new RuntimeException("ClosedWatchServiceException not thrown"); } catch (ClosedWatchServiceException x) { } @@ -468,6 +475,28 @@ } } + /** + * Test that thread interruped status is preserved upon a call + * to register() + */ + static void testThreadInterrupt(Path dir) throws IOException { + System.out.println("-- Thread interrupted status test --"); + + FileSystem fs = FileSystems.getDefault(); + Thread curr = Thread.currentThread(); + try (WatchService watcher = fs.newWatchService()) { + System.out.println("interrupting current thread"); + curr.interrupt(); + dir.register(watcher, ENTRY_CREATE); + if (!curr.isInterrupted()) + throw new RuntimeException("thread should remain interrupted"); + System.out.println("current thread is still interrupted"); + System.out.println("OKAY"); + } finally { + curr.interrupted(); + } + } + public static void main(String[] args) throws IOException { Path dir = TestUtil.createTemporaryDirectory(); try { @@ -478,6 +507,7 @@ testWakeup(dir); testExceptions(dir); testTwoWatchers(dir); + testThreadInterrupt(dir); } finally { TestUtil.removeAll(dir); diff -r ffc348308de2 -r 48ff867c7f24 test/java/util/BitSet/BSMethods.java --- a/test/java/util/BitSet/BSMethods.java Fri Nov 07 09:22:58 2014 -0800 +++ b/test/java/util/BitSet/BSMethods.java Tue Nov 11 10:40:35 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +23,10 @@ /* @test * @bug 4098239 4107540 4080736 4261102 4274710 4305272 - * 4979017 4979028 4979031 5030267 6222207 + * 4979017 4979028 4979031 5030267 6222207 8040806 * @summary Test the operation of the methods of BitSet class * @author Mike McCloskey, Martin Buchholz + * @run main/othervm BSMethods */ import java.util.*; @@ -897,6 +898,21 @@ private static void testToString() { check(new BitSet().toString().equals("{}")); check(makeSet(2,3,42,43,234).toString().equals("{2, 3, 42, 43, 234}")); + + final long MB = 1024*1024; + if (Runtime.getRuntime().maxMemory() >= 512*MB) { + // only run it if we have enough memory + try { + check(makeSet(Integer.MAX_VALUE-1).toString().equals( + "{" + (Integer.MAX_VALUE-1) + "}")); + check(makeSet(Integer.MAX_VALUE).toString().equals( + "{" + Integer.MAX_VALUE + "}")); + check(makeSet(0, 1, Integer.MAX_VALUE-1, Integer.MAX_VALUE).toString().equals( + "{0, 1, " + (Integer.MAX_VALUE-1) + ", " + Integer.MAX_VALUE + "}")); + } catch (IndexOutOfBoundsException exc) { + fail("toString() with indices near MAX_VALUE"); + } + } } private static void testLogicalIdentities() { diff -r ffc348308de2 -r 48ff867c7f24 test/java/util/IdentityHashMap/Capacity.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/util/IdentityHashMap/Capacity.java Tue Nov 11 10:40:35 2014 -0800 @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Random; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import static org.testng.Assert.*; + +/* + * @test + * @bug 6904367 + * @summary IdentityHashMap reallocates storage when inserting expected + * number of elements + * @run testng Capacity + */ + +@Test +public class Capacity { + static final Field tableField; + static final Random random = new Random(); + static final Object[][] sizesData; + + @DataProvider(name="sizes", parallel = true) + public Object[][] sizesToTest() { return sizesData; } + + static { + try { + tableField = IdentityHashMap.class.getDeclaredField("table"); + tableField.setAccessible(true); + } catch (NoSuchFieldException e) { + throw new LinkageError("table", e); + } + + ArrayList sizes = new ArrayList<>(); + for (int size = 0; size < 200; size++) + sizes.add(new Object[] { size }); + + // some numbers known to demonstrate bug 6904367 + for (int size : new int[] {682, 683, 1365, 2730, 2731, 5461}) + sizes.add(new Object[] { size }); + + // a few more random sizes to try + for (int i = 0; i != 128; i++) + sizes.add(new Object[] { random.nextInt(5000) }); + + sizesData = sizes.toArray(new Object[0][]); + } + + static int capacity(IdentityHashMap map) { + try { + return ((Object[]) tableField.get(map)).length / 2; + } catch (Throwable t) { + throw new LinkageError("table", t); + } + } + + static void assertCapacity(IdentityHashMap map, + int expectedCapacity) { + assertEquals(capacity(map), expectedCapacity); + } + + static void growUsingPut(IdentityHashMap map, + int elementsToAdd) { + for (int i = 0; i < elementsToAdd; i++) + map.put(new Object(), new Object()); + } + + static void growUsingPutAll(IdentityHashMap map, + int elementsToAdd) { + IdentityHashMap other = new IdentityHashMap<>(); + growUsingPut(other, elementsToAdd); + map.putAll(other); + } + + static void growUsingRepeatedPutAll(IdentityHashMap map, + int elementsToAdd) { + for (int i = 0; i < elementsToAdd; i++) + map.putAll(Collections.singletonMap(new Object(), + new Object())); + } + + /** + * Checks that expected number of items can be inserted into + * the map without resizing of the internal storage + */ + @Test(dataProvider = "sizes") + public void canInsertExpectedItemsWithoutResizing(int size) + throws Throwable { + // First try growing using put() + IdentityHashMap m = new IdentityHashMap<>(size); + int initialCapacity = capacity(m); + growUsingPut(m, size); + assertCapacity(m, initialCapacity); + + // Doubling from the expected size will cause exactly one + // resize, except near minimum capacity. + if (size > 1) { + growUsingPut(m, size); + assertCapacity(m, 2 * initialCapacity); + } + + // Try again, growing with putAll() + m = new IdentityHashMap<>(size); + initialCapacity = capacity(m); + growUsingPutAll(m, size); + assertCapacity(m, initialCapacity); + + // Doubling from the expected size will cause exactly one + // resize, except near minimum capacity. + if (size > 1) { + growUsingPutAll(m, size); + assertCapacity(m, 2 * initialCapacity); + } + } + + /** + * Given the expected size, computes such a number N of items that + * inserting (N+1) items will trigger resizing of the internal storage + */ + static int threshold(int size) throws Throwable { + IdentityHashMap m = new IdentityHashMap<>(size); + int initialCapacity = capacity(m); + while (capacity(m) == initialCapacity) + growUsingPut(m, 1); + return m.size() - 1; + } + + /** + * Checks that inserting (threshold+1) item causes resizing + * of the internal storage + */ + @Test(dataProvider = "sizes") + public void passingThresholdCausesResize(int size) throws Throwable { + final int threshold = threshold(size); + IdentityHashMap m = new IdentityHashMap<>(threshold); + int initialCapacity = capacity(m); + + growUsingPut(m, threshold); + assertCapacity(m, initialCapacity); + + growUsingPut(m, 1); + assertCapacity(m, 2 * initialCapacity); + } + + /** + * Checks that 4 methods of requiring capacity lead to the same + * internal capacity, unless sized below default capacity. + */ + @Test(dataProvider = "sizes") + public void differentGrowthPatternsResultInSameCapacity(int size) + throws Throwable { + if (size < 21) // 21 is default maxExpectedSize + return; + + IdentityHashMap m; + m = new IdentityHashMap(size); + int capacity1 = capacity(m); + + m = new IdentityHashMap<>(); + growUsingPut(m, size); + int capacity2 = capacity(m); + + m = new IdentityHashMap<>(); + growUsingPutAll(m, size); + int capacity3 = capacity(m); + + m = new IdentityHashMap<>(); + growUsingRepeatedPutAll(m, size); + int capacity4 = capacity(m); + + if (capacity1 != capacity2 || + capacity2 != capacity3 || + capacity3 != capacity4) + throw new AssertionError("Capacities not equal: " + + capacity1 + " " + + capacity2 + " " + + capacity3 + " " + + capacity4); + } + + public void defaultExpectedMaxSizeIs21() { + assertCapacity(new IdentityHashMap(), 32); + assertCapacity(new IdentityHashMap(21), 32); + } + + public void minimumCapacityIs4() { + assertCapacity(new IdentityHashMap(0), 4); + assertCapacity(new IdentityHashMap(1), 4); + assertCapacity(new IdentityHashMap(2), 4); + assertCapacity(new IdentityHashMap(3), 8); + } + + @Test(enabled = false) + /** needs too much memory to run normally */ + public void maximumCapacityIs2ToThe29() { + assertCapacity(new IdentityHashMap(Integer.MAX_VALUE), + 1 << 29); + } +} diff -r ffc348308de2 -r 48ff867c7f24 test/java/util/logging/LoggingDeadlock2.java --- a/test/java/util/logging/LoggingDeadlock2.java Fri Nov 07 09:22:58 2014 -0800 +++ b/test/java/util/logging/LoggingDeadlock2.java Tue Nov 11 10:40:35 2014 -0800 @@ -28,7 +28,7 @@ * @author Serguei Spitsyn / Hitachi / Martin Buchholz * * @build LoggingDeadlock2 - * @run main/timeout=15 LoggingDeadlock2 + * @run main LoggingDeadlock2 * * There is a clear deadlock between LogManager. and * Cleaner.run() methods. diff -r ffc348308de2 -r 48ff867c7f24 test/javax/swing/JComboBox/8057893/bug8057893.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JComboBox/8057893/bug8057893.java Tue Nov 11 10:40:35 2014 -0800 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.EventQueue; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.WindowConstants; +import sun.awt.SunToolkit; + +/** + * @test + * @bug 8057893 + * @author Alexander Scherbatiy + * @summary JComboBox actionListener never receives "comboBoxEdited" + * from getActionCommand + * @run main bug8057893 + */ +public class bug8057893 { + + private static volatile boolean isComboBoxEdited = false; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(50); + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + EventQueue.invokeAndWait(() -> { + JFrame frame = new JFrame(); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + JComboBox comboBox = new JComboBox<>(new String[]{"one", "two"}); + comboBox.setEditable(true); + comboBox.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + if ("comboBoxEdited".equals(e.getActionCommand())) { + isComboBoxEdited = true; + } + } + }); + frame.add(comboBox); + frame.pack(); + frame.setVisible(true); + comboBox.requestFocusInWindow(); + }); + + toolkit.realSync(); + + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + toolkit.realSync(); + + if(!isComboBoxEdited){ + throw new RuntimeException("ComboBoxEdited event is not fired!"); + } + } +} diff -r ffc348308de2 -r 48ff867c7f24 test/jdk/net/Sockets/SupportedOptions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/net/Sockets/SupportedOptions.java Tue Nov 11 10:40:35 2014 -0800 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8062744 + * @run main SupportedOptions + */ + +import java.net.*; +import java.io.IOException; +import jdk.net.*; + +public class SupportedOptions { + + public static void main(String[] args) throws Exception { + if (!Sockets.supportedOptions(ServerSocket.class) + .contains(StandardSocketOptions.IP_TOS)) { + throw new RuntimeException("Test failed"); + } + // Now set the option + ServerSocket ss = new ServerSocket(); + Sockets.setOption(ss, java.net.StandardSocketOptions.IP_TOS, 128); + } +} diff -r ffc348308de2 -r 48ff867c7f24 test/sun/jvmstat/monitor/MonitoredVm/CR6672135.java --- a/test/sun/jvmstat/monitor/MonitoredVm/CR6672135.java Fri Nov 07 09:22:58 2014 -0800 +++ b/test/sun/jvmstat/monitor/MonitoredVm/CR6672135.java Tue Nov 11 10:40:35 2014 -0800 @@ -34,6 +34,7 @@ * @bug 6672135 * @summary setInterval() for local MonitoredHost and local MonitoredVm * @author Tomas Hurka + * @run main/othervm -XX:+UsePerfData CR6672135 */ public class CR6672135 { diff -r ffc348308de2 -r 48ff867c7f24 test/sun/security/pkcs11/Cipher/JNICheck.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/pkcs11/Cipher/JNICheck.java Tue Nov 11 10:40:35 2014 -0800 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8063700 + * @run main/othervm -Xcheck:jni JNICheck + */ + +import javax.crypto.Cipher; +import javax.crypto.SealedObject; +import javax.crypto.SecretKey; +import javax.crypto.KeyGenerator; +import java.security.NoSuchProviderException; + +public class JNICheck { + + /* This test is similar to the JCK test that found 8063700. */ + static class SealedObjectTest { + Cipher c; + + SealedObjectTest() throws Exception { + try { + c = Cipher.getInstance("AES", "SunPKCS11-Solaris"); + } catch (NoSuchProviderException nspe) { + System.out.println("No SunPKCS11-Solaris provider. Test skipped"); + return; + } + + String s = "Test string"; + SealedObject so; + SecretKey key = KeyGenerator.getInstance("AES").generateKey(); + + c.init(Cipher.ENCRYPT_MODE, key); + so = new SealedObject(s, c); + + so.getObject(key, "SunPKCS11-Solaris"); + } + } + + public static void main(String args[]) throws Exception { + new SealedObjectTest(); + } +}