# HG changeset patch # User lana # Date 1344396221 25200 # Node ID b0d6552ba3011f32446e048ee335d50c24ddfef0 # Parent e0ef14d8974162c155765f8171d4baa23331c934# Parent e865efbc71059a414b3b2dd2e0adfcb3d2ab6ff9 Merge diff -r e0ef14d89741 -r b0d6552ba301 .hgtags --- a/.hgtags Tue Aug 07 12:47:45 2012 +0100 +++ b/.hgtags Tue Aug 07 20:23:41 2012 -0700 @@ -171,3 +171,4 @@ 00b22b23269a57d0bb46c57753be2fe9a9d2c1a3 jdk8-b47 3e4ab821f46166fcf63e8fe5c8046216003c941f jdk8-b48 51707c3b75c0f521794d9ab425f4e5b2351c70c1 jdk8-b49 +e4bae5c53fca8fcb9393d47fd36a34b9e2e8d4ec jdk8-b50 diff -r e0ef14d89741 -r b0d6552ba301 make/Makefile --- a/make/Makefile Tue Aug 07 12:47:45 2012 +0100 +++ b/make/Makefile Tue Aug 07 20:23:41 2012 -0700 @@ -237,7 +237,7 @@ SUBDIRS += apple endif SUBDIRS_tools = launchers -SUBDIRS_misc = org sunw jpda +SUBDIRS_misc = org jpda # demos ifndef NO_DEMOS diff -r e0ef14d89741 -r b0d6552ba301 make/common/Release.gmk --- a/make/common/Release.gmk Tue Aug 07 12:47:45 2012 +0100 +++ b/make/common/Release.gmk Tue Aug 07 20:23:41 2012 -0700 @@ -305,8 +305,7 @@ org/ietf \ org/omg \ org/w3c/dom \ - org/xml/sax \ - sunw + org/xml/sax # # Directories where sources may be found. If a file with the same path # name exists in more than one of these places, the one found last on this diff -r e0ef14d89741 -r b0d6552ba301 make/docs/CORE_PKGS.gmk --- a/make/docs/CORE_PKGS.gmk Tue Aug 07 12:47:45 2012 +0100 +++ b/make/docs/CORE_PKGS.gmk Tue Aug 07 20:23:41 2012 -0700 @@ -33,7 +33,6 @@ java.awt.peer \ java.awt.dnd.peer \ sun.* \ - sunw.* \ com.sun.* \ org.apache.* \ org.jcp.* \ diff -r e0ef14d89741 -r b0d6552ba301 make/sunw/Makefile --- a/make/sunw/Makefile Tue Aug 07 12:47:45 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -# -# Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -BUILDDIR = .. -PACKAGE = sunw -PRODUCT = sun -include $(BUILDDIR)/common/Defs.gmk - -# -# Files -# -FILES_java = \ - sunw/util/EventObject.java \ - sunw/util/EventListener.java \ - sunw/io/Serializable.java - -# -# include rules -# -include $(BUILDDIR)/common/Rules.gmk - -# -# Rules -# -clean clobber:: .delete.classlist - $(RM) -r $(CLASSBINDIR)/sunw - diff -r e0ef14d89741 -r b0d6552ba301 makefiles/CreateJars.gmk --- a/makefiles/CreateJars.gmk Tue Aug 07 12:47:45 2012 +0100 +++ b/makefiles/CreateJars.gmk Tue Aug 07 20:23:41 2012 -0700 @@ -807,8 +807,7 @@ org/ietf \ org/omg \ org/w3c/dom \ - org/xml/sax \ - sunw + org/xml/sax SRC_ZIP_SRCS = $(JDK_TOPDIR)/src/share/classes $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes SRC_ZIP_SRCS += $(JDK_OUTPUTDIR)/gensrc diff -r e0ef14d89741 -r b0d6552ba301 makefiles/docs/CORE_PKGS.gmk --- a/makefiles/docs/CORE_PKGS.gmk Tue Aug 07 12:47:45 2012 +0100 +++ b/makefiles/docs/CORE_PKGS.gmk Tue Aug 07 20:23:41 2012 -0700 @@ -33,7 +33,6 @@ java.awt.peer \ java.awt.dnd.peer \ sun.* \ - sunw.* \ com.sun.* \ org.apache.* \ org.jcp.* \ diff -r e0ef14d89741 -r b0d6552ba301 src/macosx/classes/com/apple/laf/AquaComboBoxUI.java --- a/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java Tue Aug 07 12:47:45 2012 +0100 +++ b/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java Tue Aug 07 20:23:41 2012 -0700 @@ -259,7 +259,8 @@ protected void installKeyboardActions() { super.installKeyboardActions(); - final ActionMap actionMap = comboBox.getActionMap(); + ActionMap actionMap = new ActionMapUIResource(); + actionMap.put("aquaSelectNext", highlightNextAction); actionMap.put("aquaSelectPrevious", highlightPreviousAction); actionMap.put("aquaEnterPressed", triggerSelectionAction); @@ -269,6 +270,8 @@ actionMap.put("aquaSelectEnd", highlightLastAction); actionMap.put("aquaSelectPageUp", highlightPageUpAction); actionMap.put("aquaSelectPageDown", highlightPageDownAction); + + SwingUtilities.replaceUIActionMap(comboBox, actionMap); } abstract class ComboBoxAction extends AbstractAction { diff -r e0ef14d89741 -r b0d6552ba301 src/macosx/classes/sun/lwawt/LWTextAreaPeer.java --- a/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java Tue Aug 07 12:47:45 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java Tue Aug 07 20:23:41 2012 -0700 @@ -129,16 +129,6 @@ } @Override - public void setText(final String l) { - // Please note that we do not want to post an event - // if TextArea.setText() replaces an empty text by an empty text, - // that is, if component's text remains unchanged. - if (!l.isEmpty() || getTextComponent().getDocument().getLength() != 0) { - super.setText(l); - } - } - - @Override public void replaceRange(final String text, final int start, final int end) { synchronized (getDelegateLock()) { diff -r e0ef14d89741 -r b0d6552ba301 src/macosx/classes/sun/lwawt/LWTextComponentPeer.java --- a/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java Tue Aug 07 12:47:45 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java Tue Aug 07 20:23:41 2012 -0700 @@ -124,7 +124,7 @@ } @Override - public void setText(final String l) { + public final void setText(final String l) { synchronized (getDelegateLock()) { // JTextArea.setText() posts two different events (remove & insert). // Since we make no differences between text events, diff -r e0ef14d89741 -r b0d6552ba301 src/share/classes/com/sun/beans/TypeResolver.java --- a/src/share/classes/com/sun/beans/TypeResolver.java Tue Aug 07 12:47:45 2012 +0100 +++ b/src/share/classes/com/sun/beans/TypeResolver.java Tue Aug 07 20:23:41 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -45,6 +45,9 @@ * @author Sergey Malenkov */ public final class TypeResolver { + + private static final WeakCache> CACHE = new WeakCache<>(); + /** * Replaces the given {@code type} in an inherited method * with the actual type it has in the given {@code inClass}. @@ -149,12 +152,55 @@ * @param formal the type where occurrences of the variables * in {@code actual} will be replaced by the corresponding bound values * @return a resolved type - * - * @see #TypeResolver(Type) - * @see #resolve(Type) */ public static Type resolve(Type actual, Type formal) { - return getTypeResolver(actual).resolve(formal); + if (formal instanceof Class) { + return formal; + } + if (formal instanceof GenericArrayType) { + Type comp = ((GenericArrayType) formal).getGenericComponentType(); + comp = resolve(actual, comp); + return (comp instanceof Class) + ? Array.newInstance((Class) comp, 0).getClass() + : GenericArrayTypeImpl.make(comp); + } + if (formal instanceof ParameterizedType) { + ParameterizedType fpt = (ParameterizedType) formal; + Type[] actuals = resolve(actual, fpt.getActualTypeArguments()); + return ParameterizedTypeImpl.make( + (Class) fpt.getRawType(), actuals, fpt.getOwnerType()); + } + if (formal instanceof WildcardType) { + WildcardType fwt = (WildcardType) formal; + Type[] upper = resolve(actual, fwt.getUpperBounds()); + Type[] lower = resolve(actual, fwt.getLowerBounds()); + return new WildcardTypeImpl(upper, lower); + } + if (formal instanceof TypeVariable) { + Map map; + synchronized (CACHE) { + map = CACHE.get(actual); + if (map == null) { + map = new HashMap<>(); + prepare(map, actual); + CACHE.put(actual, map); + } + } + Type result = map.get(formal); + if (result == null || result.equals(formal)) { + return formal; + } + result = fixGenericArray(result); + // A variable can be bound to another variable that is itself bound + // to something. For example, given: + // class Super {...} + // class Mid extends Super {...} + // class Sub extends Mid + // the variable T is bound to X, which is in turn bound to String. + // So if we have to resolve T, we need the tail recursion here. + return resolve(actual, result); + } + throw new IllegalArgumentException("Bad Type kind: " + formal.getClass()); } /** @@ -164,12 +210,14 @@ * @param actual the type that supplies bindings for type variables * @param formals the array of types to resolve * @return an array of resolved types - * - * @see #TypeResolver(Type) - * @see #resolve(Type[]) */ public static Type[] resolve(Type actual, Type[] formals) { - return getTypeResolver(actual).resolve(formals); + int length = formals.length; + Type[] actuals = new Type[length]; + for (int i = 0; i < length; i++) { + actuals[i] = resolve(actual, formals[i]); + } + return actuals; } /** @@ -228,32 +276,6 @@ return classes; } - public static TypeResolver getTypeResolver(Type type) { - synchronized (CACHE) { - TypeResolver resolver = CACHE.get(type); - if (resolver == null) { - resolver = new TypeResolver(type); - CACHE.put(type, resolver); - } - return resolver; - } - } - - private static final WeakCache CACHE = new WeakCache<>(); - - private final Map, Type> map = new HashMap<>(); - - /** - * Constructs the type resolver for the given actual type. - * - * @param actual the type that supplies bindings for type variables - * - * @see #prepare(Type) - */ - private TypeResolver(Type actual) { - prepare(actual); - } - /** * Fills the map from type parameters * to types as seen by the given {@code type}. @@ -265,9 +287,10 @@ * to a {@link ParameterizedType ParameterizedType} with no parameters, * or it represents the erasure of a {@link ParameterizedType ParameterizedType}. * + * @param map the mappings of all type variables * @param type the next type in the hierarchy */ - private void prepare(Type type) { + private static void prepare(Map map, Type type) { Class raw = (Class)((type instanceof Class) ? type : ((ParameterizedType)type).getRawType()); @@ -280,91 +303,25 @@ assert formals.length == actuals.length; for (int i = 0; i < formals.length; i++) { - this.map.put(formals[i], actuals[i]); + map.put(formals[i], actuals[i]); } Type gSuperclass = raw.getGenericSuperclass(); if (gSuperclass != null) { - prepare(gSuperclass); + prepare(map, gSuperclass); } for (Type gInterface : raw.getGenericInterfaces()) { - prepare(gInterface); + prepare(map, gInterface); } // If type is the raw version of a parameterized class, we type-erase // all of its type variables, including inherited ones. if (type instanceof Class && formals.length > 0) { - for (Map.Entry, Type> entry : this.map.entrySet()) { + for (Map.Entry entry : map.entrySet()) { entry.setValue(erase(entry.getValue())); } } } /** - * Replaces the given {@code formal} type - * with the type it stand for in this type resolver. - * - * @param formal the array of types to resolve - * @return a resolved type - */ - private Type resolve(Type formal) { - if (formal instanceof Class) { - return formal; - } - if (formal instanceof GenericArrayType) { - Type comp = ((GenericArrayType)formal).getGenericComponentType(); - comp = resolve(comp); - return (comp instanceof Class) - ? Array.newInstance((Class)comp, 0).getClass() - : GenericArrayTypeImpl.make(comp); - } - if (formal instanceof ParameterizedType) { - ParameterizedType fpt = (ParameterizedType)formal; - Type[] actuals = resolve(fpt.getActualTypeArguments()); - return ParameterizedTypeImpl.make( - (Class)fpt.getRawType(), actuals, fpt.getOwnerType()); - } - if (formal instanceof WildcardType) { - WildcardType fwt = (WildcardType)formal; - Type[] upper = resolve(fwt.getUpperBounds()); - Type[] lower = resolve(fwt.getLowerBounds()); - return new WildcardTypeImpl(upper, lower); - } - if (!(formal instanceof TypeVariable)) { - throw new IllegalArgumentException("Bad Type kind: " + formal.getClass()); - } - Type actual = this.map.get((TypeVariable) formal); - if (actual == null || actual.equals(formal)) { - return formal; - } - actual = fixGenericArray(actual); - return resolve(actual); - // A variable can be bound to another variable that is itself bound - // to something. For example, given: - // class Super {...} - // class Mid extends Super {...} - // class Sub extends Mid - // the variable T is bound to X, which is in turn bound to String. - // So if we have to resolve T, we need the tail recursion here. - } - - /** - * Replaces all formal types in the given array - * with the types they stand for in this type resolver. - * - * @param formals the array of types to resolve - * @return an array of resolved types - * - * @see #resolve(Type) - */ - private Type[] resolve(Type[] formals) { - int length = formals.length; - Type[] actuals = new Type[length]; - for (int i = 0; i < length; i++) { - actuals[i] = resolve(formals[i]); - } - return actuals; - } - - /** * Replaces a {@link GenericArrayType GenericArrayType} * with plain array class where it is possible. * Bug 5041784 diff -r e0ef14d89741 -r b0d6552ba301 src/share/classes/com/sun/beans/finder/MethodFinder.java --- a/src/share/classes/com/sun/beans/finder/MethodFinder.java Tue Aug 07 12:47:45 2012 +0100 +++ b/src/share/classes/com/sun/beans/finder/MethodFinder.java Tue Aug 07 20:23:41 2012 -0700 @@ -164,8 +164,10 @@ return findAccessibleMethod(m); } Type[] gpts = m.getGenericParameterTypes(); - if (Arrays.equals(params, TypeResolver.erase(TypeResolver.resolve(pt, gpts)))) { - return findAccessibleMethod(m); + if (params.length == gpts.length) { + if (Arrays.equals(params, TypeResolver.erase(TypeResolver.resolve(pt, gpts)))) { + return findAccessibleMethod(m); + } } } } diff -r e0ef14d89741 -r b0d6552ba301 src/share/classes/java/awt/GraphicsEnvironment.java --- a/src/share/classes/java/awt/GraphicsEnvironment.java Tue Aug 07 12:47:45 2012 +0100 +++ b/src/share/classes/java/awt/GraphicsEnvironment.java Tue Aug 07 20:23:41 2012 -0700 @@ -170,12 +170,12 @@ if (System.getProperty("javaplugin.version") != null) { headless = defaultHeadless = Boolean.FALSE; } else { - if ("sun.awt.HeadlessGraphicsEnvironment".equals( - System.getProperty("java.awt.graphicsenv"))) + String osName = System.getProperty("os.name"); + if (osName.contains("OS X") && "sun.awt.HToolkit".equals( + System.getProperty("awt.toolkit"))) { headless = defaultHeadless = Boolean.TRUE; } else { - String osName = System.getProperty("os.name"); headless = defaultHeadless = Boolean.valueOf(("Linux".equals(osName) || "SunOS".equals(osName) || diff -r e0ef14d89741 -r b0d6552ba301 src/share/classes/java/awt/TextComponent.java --- a/src/share/classes/java/awt/TextComponent.java Tue Aug 07 12:47:45 2012 +0100 +++ b/src/share/classes/java/awt/TextComponent.java Tue Aug 07 20:23:41 2012 -0700 @@ -235,9 +235,14 @@ * @see java.awt.TextComponent#getText */ public synchronized void setText(String t) { + boolean skipTextEvent = (text == null || text.isEmpty()) + && (t == null || t.isEmpty()); text = (t != null) ? t : ""; TextComponentPeer peer = (TextComponentPeer)this.peer; - if (peer != null) { + // Please note that we do not want to post an event + // if TextArea.setText() or TextField.setText() replaces an empty text + // by an empty text, that is, if component's text remains unchanged. + if (peer != null && !skipTextEvent) { peer.setText(text); } } diff -r e0ef14d89741 -r b0d6552ba301 src/share/classes/java/beans/IndexedPropertyDescriptor.java --- a/src/share/classes/java/beans/IndexedPropertyDescriptor.java Tue Aug 07 12:47:45 2012 +0100 +++ b/src/share/classes/java/beans/IndexedPropertyDescriptor.java Tue Aug 07 20:23:41 2012 -0700 @@ -181,20 +181,21 @@ // the Indexed readMethod was explicitly set to null. return null; } + String nextMethodName = Introspector.GET_PREFIX + getBaseName(); if (indexedReadMethodName == null) { Class type = getIndexedPropertyType0(); if (type == boolean.class || type == null) { indexedReadMethodName = Introspector.IS_PREFIX + getBaseName(); } else { - indexedReadMethodName = Introspector.GET_PREFIX + getBaseName(); + indexedReadMethodName = nextMethodName; } } Class[] args = { int.class }; indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, 1, args); - if (indexedReadMethod == null) { + if ((indexedReadMethod == null) && !indexedReadMethodName.equals(nextMethodName)) { // no "is" method, so look for a "get" method. - indexedReadMethodName = Introspector.GET_PREFIX + getBaseName(); + indexedReadMethodName = nextMethodName; indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, 1, args); } setIndexedReadMethod0(indexedReadMethod); diff -r e0ef14d89741 -r b0d6552ba301 src/share/classes/java/beans/Introspector.java --- a/src/share/classes/java/beans/Introspector.java Tue Aug 07 12:47:45 2012 +0100 +++ b/src/share/classes/java/beans/Introspector.java Tue Aug 07 20:23:41 2012 -0700 @@ -25,6 +25,7 @@ package java.beans; +import com.sun.beans.TypeResolver; import com.sun.beans.WeakCache; import com.sun.beans.finder.ClassFinder; @@ -34,6 +35,7 @@ import java.lang.ref.SoftReference; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.lang.reflect.Type; import java.util.Map; import java.util.ArrayList; @@ -951,44 +953,61 @@ continue; } - Class[] argTypes = FeatureDescriptor.getParameterTypes(beanClass, method); - Class resultType = FeatureDescriptor.getReturnType(beanClass, method); - - if (name.startsWith(ADD_PREFIX) && argTypes.length == 1 && - resultType == Void.TYPE && - Introspector.isSubclass(argTypes[0], eventListenerType)) { - String listenerName = name.substring(3); - if (listenerName.length() > 0 && - argTypes[0].getName().endsWith(listenerName)) { - if (adds == null) { - adds = new HashMap<>(); + if (name.startsWith(ADD_PREFIX)) { + Class returnType = method.getReturnType(); + if (returnType == void.class) { + Type[] parameterTypes = method.getGenericParameterTypes(); + if (parameterTypes.length == 1) { + Class type = TypeResolver.erase(TypeResolver.resolveInClass(beanClass, parameterTypes[0])); + if (Introspector.isSubclass(type, eventListenerType)) { + String listenerName = name.substring(3); + if (listenerName.length() > 0 && + type.getName().endsWith(listenerName)) { + if (adds == null) { + adds = new HashMap<>(); + } + adds.put(listenerName, method); + } + } } - adds.put(listenerName, method); } } - else if (name.startsWith(REMOVE_PREFIX) && argTypes.length == 1 && - resultType == Void.TYPE && - Introspector.isSubclass(argTypes[0], eventListenerType)) { - String listenerName = name.substring(6); - if (listenerName.length() > 0 && - argTypes[0].getName().endsWith(listenerName)) { - if (removes == null) { - removes = new HashMap<>(); + else if (name.startsWith(REMOVE_PREFIX)) { + Class returnType = method.getReturnType(); + if (returnType == void.class) { + Type[] parameterTypes = method.getGenericParameterTypes(); + if (parameterTypes.length == 1) { + Class type = TypeResolver.erase(TypeResolver.resolveInClass(beanClass, parameterTypes[0])); + if (Introspector.isSubclass(type, eventListenerType)) { + String listenerName = name.substring(6); + if (listenerName.length() > 0 && + type.getName().endsWith(listenerName)) { + if (removes == null) { + removes = new HashMap<>(); + } + removes.put(listenerName, method); + } + } } - removes.put(listenerName, method); } } - else if (name.startsWith(GET_PREFIX) && argTypes.length == 0 && - resultType.isArray() && - Introspector.isSubclass(resultType.getComponentType(), - eventListenerType)) { - String listenerName = name.substring(3, name.length() - 1); - if (listenerName.length() > 0 && - resultType.getComponentType().getName().endsWith(listenerName)) { - if (gets == null) { - gets = new HashMap<>(); + else if (name.startsWith(GET_PREFIX)) { + Class[] parameterTypes = method.getParameterTypes(); + if (parameterTypes.length == 0) { + Class returnType = FeatureDescriptor.getReturnType(beanClass, method); + if (returnType.isArray()) { + Class type = returnType.getComponentType(); + if (Introspector.isSubclass(type, eventListenerType)) { + String listenerName = name.substring(3, name.length() - 1); + if (listenerName.length() > 0 && + type.getName().endsWith(listenerName)) { + if (gets == null) { + gets = new HashMap<>(); + } + gets.put(listenerName, method); + } + } } - gets.put(listenerName, method); } } } @@ -1240,11 +1259,11 @@ private boolean isEventHandler(Method m) { // We assume that a method is an event handler if it has a single // argument, whose type inherit from java.util.Event. - Class argTypes[] = FeatureDescriptor.getParameterTypes(beanClass, m); + Type argTypes[] = m.getGenericParameterTypes(); if (argTypes.length != 1) { return false; } - return isSubclass(argTypes[0], EventObject.class); + return isSubclass(TypeResolver.erase(TypeResolver.resolveInClass(beanClass, argTypes[0])), EventObject.class); } /* @@ -1296,24 +1315,25 @@ } // make sure method signature matches. - Class params[] = FeatureDescriptor.getParameterTypes(start, method); - if (method.getName().equals(methodName) && - params.length == argCount) { - if (args != null) { - boolean different = false; - if (argCount > 0) { - for (int j = 0; j < argCount; j++) { - if (params[j] != args[j]) { - different = true; + if (method.getName().equals(methodName)) { + Type[] params = method.getGenericParameterTypes(); + if (params.length == argCount) { + if (args != null) { + boolean different = false; + if (argCount > 0) { + for (int j = 0; j < argCount; j++) { + if (TypeResolver.erase(TypeResolver.resolveInClass(start, params[j])) != args[j]) { + different = true; + continue; + } + } + if (different) { continue; } } - if (different) { - continue; - } } + return method; } - return method; } } } diff -r e0ef14d89741 -r b0d6552ba301 src/share/classes/java/beans/PropertyDescriptor.java --- a/src/share/classes/java/beans/PropertyDescriptor.java Tue Aug 07 12:47:45 2012 +0100 +++ b/src/share/classes/java/beans/PropertyDescriptor.java Tue Aug 07 20:23:41 2012 -0700 @@ -210,12 +210,13 @@ // The read method was explicitly set to null. return null; } + String nextMethodName = Introspector.GET_PREFIX + getBaseName(); if (readMethodName == null) { Class type = getPropertyType0(); if (type == boolean.class || type == null) { readMethodName = Introspector.IS_PREFIX + getBaseName(); } else { - readMethodName = Introspector.GET_PREFIX + getBaseName(); + readMethodName = nextMethodName; } } @@ -225,8 +226,8 @@ // methods. If an "is" method exists, this is the official // reader method so look for this one first. readMethod = Introspector.findMethod(cls, readMethodName, 0); - if (readMethod == null) { - readMethodName = Introspector.GET_PREFIX + getBaseName(); + if ((readMethod == null) && !readMethodName.equals(nextMethodName)) { + readMethodName = nextMethodName; readMethod = Introspector.findMethod(cls, readMethodName, 0); } try { diff -r e0ef14d89741 -r b0d6552ba301 src/share/classes/javax/swing/TimerQueue.java --- a/src/share/classes/javax/swing/TimerQueue.java Tue Aug 07 12:47:45 2012 +0100 +++ b/src/share/classes/javax/swing/TimerQueue.java Tue Aug 07 20:23:41 2012 -0700 @@ -187,6 +187,9 @@ addTimer(delayedTimer); } } + + // Allow run other threads on systems without kernel threads + timer.getLock().newCondition().awaitNanos(1); } catch (SecurityException ignore) { } finally { timer.getLock().unlock(); diff -r e0ef14d89741 -r b0d6552ba301 src/share/classes/sun/misc/MetaIndex.java --- a/src/share/classes/sun/misc/MetaIndex.java Tue Aug 07 12:47:45 2012 +0100 +++ b/src/share/classes/sun/misc/MetaIndex.java Tue Aug 07 20:23:41 2012 -0700 @@ -71,7 +71,6 @@ org/w3c/ com/sun/imageio/ javax/ -sunw/util/ java/ sun/ ... diff -r e0ef14d89741 -r b0d6552ba301 src/share/classes/sunw/io/Serializable.java --- a/src/share/classes/sunw/io/Serializable.java Tue Aug 07 12:47:45 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1996, 1997, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sunw.io; - -/** - * FOR BACKWARD COMPATIBILITY ONLY - DO NOT USE. - *

- * This is a backwards compatibility class to allow Java Beans that - * were developed under JDK 1.0.2 to run correctly under JDK 1.1 - *

- * To allow beans development under JDK 1.0.2, JavaSoft delivered three - * no-op interfaces/classes (sunw.io.Serializable, sunw.util.EventObject - * and sunw.util.EventListener) that could be downloaded into JDK 1.0.2 - * systems and which would act as placeholders for the real JDK 1.1 - * classes. - *

- * Now under JDK 1.1 we provide versions of these classes and interfaces - * that inherit from the real version in java.util and java.io. These - * mean that beans developed under JDK 1.0.2 against the sunw.* classes - * will now continue to work on JDK 1.1 and will (indirectly) inherit - * from the appropriate java.* interfaces/classes. - * - * @deprecated This is a compatibility type to allow Java Beans that - * were developed under JDK 1.0.2 to run correctly under JDK 1.1. The - * corresponding JDK1.1 type is java.io.Serializable - * - * @see java.io.Serializable - */ - -public interface Serializable extends java.io.Serializable { -} diff -r e0ef14d89741 -r b0d6552ba301 src/share/classes/sunw/util/EventListener.java --- a/src/share/classes/sunw/util/EventListener.java Tue Aug 07 12:47:45 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1996, 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 sunw.util; - -/** - * FOR BACKWARD COMPATIBILITY ONLY - DO NOT USE. - *

- * This is a backwards compatibility class to allow Java Beans that - * were developed under JDK 1.0.2 to run correctly under JDK 1.1 - *

- * To allow beans development under JDK 1.0.2, JavaSoft delivered three - * no-op interfaces/classes (sunw.io.Serializable, sunw.util.EventObject - * and sunw.util.EventListener) that could be downloaded into JDK 1.0.2 - * systems and which would act as placeholders for the real JDK 1.1 - * classes. - *

- * Now under JDK 1.1 we provide versions of these classes and interfaces - * that inherit from the real version in java.util and java.io. These - * mean that beans developed under JDK 1.0.2 against the sunw.* classes - * will now continue to work on JDK 1.1 and will (indirectly) inherit - * from the approrpiate java.* interfaces/classes. - * - * @deprecated This is a compatibility type to allow Java Beans that - * were developed under JDK 1.0.2 to run correctly under JDK 1.1. The - * corresponding JDK1.1 type is java.util.EventListener - * - * @see java.util.EventListener - */ - -public interface EventListener extends java.util.EventListener { -} diff -r e0ef14d89741 -r b0d6552ba301 src/share/classes/sunw/util/EventObject.java --- a/src/share/classes/sunw/util/EventObject.java Tue Aug 07 12:47:45 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 1996, 2003, 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 sunw.util; - -/** - * FOR BACKWARD COMPATIBILITY ONLY - DO NOT USE. - *

- * This is a backwards compatibility class to allow Java Beans that - * were developed under JDK 1.0.2 to run correctly under JDK 1.1 - *

- * To allow beans development under JDK 1.0.2, JavaSoft delivered three - * no-op interfaces/classes (sunw.io.Serializable, sunw.util.EventObject - * and sunw.util.EventListener) that could be downloaded into JDK 1.0.2 - * systems and which would act as placeholders for the real JDK 1.1 - * classes. - *

- * Now under JDK 1.1 we provide versions of these classes and interfaces - * that inherit from the real version in java.util and java.io. These - * mean that beans developed under JDK 1.0.2 against the sunw.* classes - * will now continue to work on JDK 1.1 and will (indirectly) inherit - * from the approrpiate java.* interfaces/classes. - * - * @deprecated This is a compatibility type to allow Java Beans that - * were developed under JDK 1.0.2 to run correctly under JDK 1.1. The - * corresponding JDK1.1 type is java.util.EventObject - * - * @see java.util.EventObject - */ - -public class EventObject extends java.util.EventObject { - - private static final long serialVersionUID = 6723767567830330255L; - - public EventObject(Object source) { - super(source); - } - -} diff -r e0ef14d89741 -r b0d6552ba301 src/solaris/classes/sun/awt/X11/XTextAreaPeer.java --- a/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java Tue Aug 07 12:47:45 2012 +0100 +++ b/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java Tue Aug 07 20:23:41 2012 -0700 @@ -463,13 +463,6 @@ protected boolean setTextImpl(String txt) { if (jtext != null) { - // Please note that we do not want to post an event - // if setText() replaces an empty text by an empty text, - // that is, if component's text remains unchanged. - if (jtext.getDocument().getLength() == 0 && txt.length() == 0) { - return true; - } - // JTextArea.setText() posts two different events (remove & insert). // Since we make no differences between text events, // the document listener has to be disabled while diff -r e0ef14d89741 -r b0d6552ba301 src/solaris/native/java/lang/java_props_md.c --- a/src/solaris/native/java/lang/java_props_md.c Tue Aug 07 12:47:45 2012 +0100 +++ b/src/solaris/native/java/lang/java_props_md.c Tue Aug 07 20:23:41 2012 -0700 @@ -431,6 +431,7 @@ PreferredToolkit prefToolkit = getPreferredToolkit(); switch (prefToolkit) { case CToolkit: + case HToolkit: sprops.graphics_env = "sun.awt.CGraphicsEnvironment"; break; case XToolkit: @@ -438,9 +439,6 @@ sprops.graphics_env = "sun.awt.X11GraphicsEnvironment"; #ifdef MACOSX break; - default: - sprops.graphics_env = "sun.java2d.HeadlessGraphicsEnvironment"; - break; } #endif /* AWT properties */ diff -r e0ef14d89741 -r b0d6552ba301 src/windows/native/sun/windows/awt_TextArea.cpp --- a/src/windows/native/sun/windows/awt_TextArea.cpp Tue Aug 07 12:47:45 2012 +0100 +++ b/src/windows/native/sun/windows/awt_TextArea.cpp Tue Aug 07 20:23:41 2012 -0700 @@ -131,48 +131,13 @@ MsgRouting mr = mrDoDefault; switch (message) { - case WM_PRINTCLIENT: - { - FORMATRANGE fr; - HDC hPrinterDC = (HDC)wParam; - int nHorizRes = ::GetDeviceCaps(hPrinterDC, HORZRES); - int nVertRes = ::GetDeviceCaps(hPrinterDC, VERTRES); - int nLogPixelsX = ::GetDeviceCaps(hPrinterDC, LOGPIXELSX); - int nLogPixelsY = ::GetDeviceCaps(hPrinterDC, LOGPIXELSY); - - // Ensure the printer DC is in MM_TEXT mode. - ::SetMapMode ( hPrinterDC, MM_TEXT ); - - // Rendering to the same DC we are measuring. - ::ZeroMemory(&fr, sizeof(fr)); - fr.hdc = fr.hdcTarget = hPrinterDC; - // Set up the page. - fr.rcPage.left = fr.rcPage.top = 0; - fr.rcPage.right = (nHorizRes/nLogPixelsX) * 1440; // in twips - fr.rcPage.bottom = (nVertRes/nLogPixelsY) * 1440; - fr.rc.left = fr.rcPage.left; - fr.rc.top = fr.rcPage.top; - fr.rc.right = fr.rcPage.right; - fr.rc.bottom = fr.rcPage.bottom; - - // start printing from the first visible line - LRESULT nLine = SendMessage(EM_GETFIRSTVISIBLELINE, 0, 0); - LONG startCh = static_cast(SendMessage(EM_LINEINDEX, - (WPARAM)nLine, 0)); - fr.chrg.cpMin = startCh; - fr.chrg.cpMax = -1; - - SendMessage(EM_FORMATRANGE, TRUE, (LPARAM)&fr); - } - - break; case EM_SETCHARFORMAT: case WM_SETFONT: SetIgnoreEnChange(TRUE); break; } - retValue = AwtComponent::WindowProc(message, wParam, lParam); + retValue = AwtTextComponent::WindowProc(message, wParam, lParam); switch (message) { case EM_SETCHARFORMAT: diff -r e0ef14d89741 -r b0d6552ba301 src/windows/native/sun/windows/awt_TextComponent.cpp --- a/src/windows/native/sun/windows/awt_TextComponent.cpp Tue Aug 07 12:47:45 2012 +0100 +++ b/src/windows/native/sun/windows/awt_TextComponent.cpp Tue Aug 07 20:23:41 2012 -0700 @@ -215,6 +215,50 @@ return c; } +LRESULT +AwtTextComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { + + switch (message) { + case WM_PRINTCLIENT: + { + FORMATRANGE fr; + HDC hPrinterDC = (HDC)wParam; + int nHorizRes = ::GetDeviceCaps(hPrinterDC, HORZRES); + int nVertRes = ::GetDeviceCaps(hPrinterDC, VERTRES); + int nLogPixelsX = ::GetDeviceCaps(hPrinterDC, LOGPIXELSX); + int nLogPixelsY = ::GetDeviceCaps(hPrinterDC, LOGPIXELSY); + + // Ensure the printer DC is in MM_TEXT mode. + ::SetMapMode ( hPrinterDC, MM_TEXT ); + + // Rendering to the same DC we are measuring. + ::ZeroMemory(&fr, sizeof(fr)); + fr.hdc = fr.hdcTarget = hPrinterDC; + // Set up the page. + fr.rcPage.left = fr.rcPage.top = 0; + fr.rcPage.right = (nHorizRes/nLogPixelsX) * 1440; // in twips + fr.rcPage.bottom = (nVertRes/nLogPixelsY) * 1440; + fr.rc.left = fr.rcPage.left; + fr.rc.top = fr.rcPage.top; + fr.rc.right = fr.rcPage.right; + fr.rc.bottom = fr.rcPage.bottom; + + // start printing from the first visible line + LRESULT nLine = SendMessage(EM_GETFIRSTVISIBLELINE, 0, 0); + LONG startCh = static_cast(SendMessage(EM_LINEINDEX, + (WPARAM)nLine, 0)); + fr.chrg.cpMin = startCh; + fr.chrg.cpMax = -1; + + SendMessage(EM_FORMATRANGE, TRUE, (LPARAM)&fr); + } + + break; + } + + return AwtComponent::WindowProc(message, wParam, lParam); +} + LONG AwtTextComponent::EditGetCharFromPos(POINT& pt) { return static_cast(SendMessage(EM_CHARFROMPOS, 0, reinterpret_cast(&pt))); diff -r e0ef14d89741 -r b0d6552ba301 src/windows/native/sun/windows/awt_TextComponent.h --- a/src/windows/native/sun/windows/awt_TextComponent.h Tue Aug 07 12:47:45 2012 +0100 +++ b/src/windows/native/sun/windows/awt_TextComponent.h Tue Aug 07 20:23:41 2012 -0700 @@ -50,6 +50,7 @@ static AwtTextComponent* Create(jobject self, jobject parent, BOOL isMultiline); virtual LPCTSTR GetClassName(); + LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); int RemoveCR(WCHAR *pStr); diff -r e0ef14d89741 -r b0d6552ba301 test/java/awt/Focus/OverrideRedirectWindowActivationTest/OverrideRedirectWindowActivationTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Focus/OverrideRedirectWindowActivationTest/OverrideRedirectWindowActivationTest.java Tue Aug 07 20:23:41 2012 -0700 @@ -0,0 +1,157 @@ +/* + * 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 6385277 + * @summary Tests that override redirect window gets activated on click. + * @author anton.tarasov@sun.com: area=awt.focus + * @library ../../regtesthelpers + * @build Util + * @run main OverrideRedirectWindowActivationTest + */ +import java.awt.*; +import java.awt.event.*; +import java.util.concurrent.Callable; +import javax.swing.SwingUtilities; +import sun.awt.SunToolkit; +import test.java.awt.regtesthelpers.Util; + +public class OverrideRedirectWindowActivationTest { + + private static Frame frame; + private static Window window; + private static Button fbutton; + private static Button wbutton; + private static Label label; + private static Robot robot; + private static SunToolkit toolkit; + + public static void main(String[] args) throws Exception { + + if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) { + System.out.println("No testing on Motif. Test passed."); + return; + } + + toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + robot = new Robot(); + robot.setAutoDelay(50); + + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + + public void eventDispatched(AWTEvent e) { + System.out.println(e); + } + }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK); + + createAndShowWindow(); + toolkit.realSync(); + + createAndShowFrame(); + toolkit.realSync(); + + // click on Frame + clickOn(getClickPoint(frame)); + + if (!frame.isFocused()) { + throw new RuntimeException("Error: a frame couldn't be focused by click."); + } + + //click on Label in Window + clickOn(getClickPoint(label)); + + if (!window.isFocused()) { + throw new RuntimeException("Test failed: the window couldn't be activated by click!"); + } + + // bring focus back to the frame + clickOn(getClickPoint(fbutton)); + + if (!frame.isFocused()) { + throw new RuntimeException("Error: a frame couldn't be focused by click."); + } + + // Test 2. Verifies that clicking on a component of unfocusable Window + // won't activate it. + + window.setFocusableWindowState(false); + toolkit.realSync(); + + + clickOn(getClickPoint(label)); + + if (window.isFocused()) { + throw new RuntimeException("Test failed: unfocusable window got activated by click!"); + } + System.out.println("Test passed."); + + } + + private static void createAndShowWindow() { + + frame = new Frame("Test Frame"); + window = new Window(frame); + wbutton = new Button("wbutton"); + label = new Label("label"); + + window.setBounds(800, 200, 200, 100); + window.setLayout(new FlowLayout()); + window.add(wbutton); + window.add(label); + window.setVisible(true); + + } + + private static void createAndShowFrame() { + fbutton = new Button("fbutton"); + + frame.setBounds(800, 0, 200, 100); + frame.setLayout(new FlowLayout()); + frame.add(fbutton); + frame.setVisible(true); + + } + + static void clickOn(Point point) { + + robot.mouseMove(point.x, point.y); + + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + toolkit.realSync(); + } + + static Point getClickPoint(Component c) { + Point p = c.getLocationOnScreen(); + Dimension d = c.getSize(); + return new Point(p.x + (int) (d.getWidth() / 2), p.y + (int) (d.getHeight() / 2)); + } + + static Point getClickPoint(Frame frame) { + Point p = frame.getLocationOnScreen(); + Dimension d = frame.getSize(); + return new Point(p.x + (int) (d.getWidth() / 2), p.y + (frame.getInsets().top / 2)); + } +} diff -r e0ef14d89741 -r b0d6552ba301 test/java/awt/Window/Grab/GrabTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Window/Grab/GrabTest.java Tue Aug 07 20:23:41 2012 -0700 @@ -0,0 +1,212 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + @test + @bug 7124430 + @summary Tests that SunToolkit.grab API works + @author anton.tarasov@oracle.com: area=awt.toolkit + @library ../../regtesthelpers + @build Util + @run main GrabTest +*/ + +import java.awt.*; +import java.awt.event.*; +import test.java.awt.regtesthelpers.Util; + +public class GrabTest { + private static Frame f; + private static Frame f1; + private static Window w; + private static Button b; + + private static Robot robot; + private static sun.awt.SunToolkit tk; + + static volatile boolean ungrabbed; + static volatile boolean buttonPressed; + static volatile boolean windowPressed; + static volatile boolean framePressed; + + static volatile boolean passed = true; + + public static void main(String[] args) { + + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + public void eventDispatched(AWTEvent e) { + System.out.println(e); + if (e instanceof sun.awt.UngrabEvent) { + ungrabbed = true; + } + } + }, sun.awt.SunToolkit.GRAB_EVENT_MASK); + + f = new Frame("Frame"); + f.setBounds(0, 0, 300, 300); + f.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + System.out.println(e); + framePressed = true; + } + }); + + f1 = new Frame("OtherFrame"); + f1.setBounds(700, 100, 200, 200); + + w = new Window(f); + w.setLayout(new FlowLayout()); + b = new Button("Press"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.out.println(e); + buttonPressed = true; + } + }); + w.add(b); + w.setBounds(400, 100, 200, 200); + w.setBackground(Color.blue); + w.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + System.out.println(e); + windowPressed = true; + } + }); + + f.setVisible(true); + w.setVisible(true); + + tk = (sun.awt.SunToolkit)Toolkit.getDefaultToolkit(); + + try { + robot = new Robot(); + } catch (AWTException ex) { + throw new RuntimeException(ex); + } + + Util.waitForIdle(robot); + + test(); + } + + public static void test() { + tk.grab(w); + + // 1. Check that button press doesn't cause ungrab + Util.clickOnComp(b, robot); + Util.waitForIdle(robot); + checkAndThrow(buttonPressed, "Error: Button can not be pressed"); + if (ungrabbed) { + passed = false; + tk.grab(w); + System.err.println("Failure: [1] Press inside of Window (on Button) caused ungrab"); + } + + // 2. Check that press on the window itself doesn't cause ungrab + Util.clickOnComp(w, robot); + Util.waitForIdle(robot); + checkAndThrow(windowPressed, "Error: Window can't be pressed"); + if (ungrabbed) { + passed = false; + tk.grab(w); + System.err.println("Failure: [2] Press inside of Window caused ungrab"); + } + + // 3. Check that press on the frame causes ungrab, event must be dispatched + Util.clickOnComp(f, robot); + Util.waitForIdle(robot); + checkAndThrow(framePressed, "Error: Frame can't be pressed"); + if (!ungrabbed) { + passed = false; + System.err.println("Failure: [3] Press inside of Frame didn't cause ungrab"); + } + ungrabbed = false; + tk.grab(w); + + // 4. Check that press on the frame's title causes ungrab + Util.clickOnTitle(f, robot); + Util.waitForIdle(robot); + if (!ungrabbed) { + passed = false; + System.err.println("Failure: [4] Press inside of Frame's title didn't cause ungrab"); + } + ungrabbed = false; + tk.grab(w); + + + // 5. Check that press on the other frame's title causes ungrab + f1.setVisible(true); + Util.waitForIdle(robot); + Util.clickOnTitle(f1, robot); + if (!ungrabbed) { + passed = false; + System.err.println("Failure: [5] Press inside of other Frame's title didn't cause ungrab"); + } + f.requestFocus(); // restore focus + Util.waitForIdle(robot); + if (!f.hasFocus()) { + System.err.println("Error: Frame can't be focused"); + } + ungrabbed = false; + tk.grab(w); + + + // 6. Check that press on the outside area causes ungrab + Point loc = f.getLocationOnScreen(); + robot.mouseMove(loc.x + 100, loc.y + f.getSize().height + 1); + Util.waitForIdle(robot); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.delay(50); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + Util.waitForIdle(robot); + if (!ungrabbed) { + passed = false; + System.err.println("Failure: [6] Press on the outside area didn't cause ungrab"); + } + ungrabbed = false; + tk.grab(w); + + + // 7. Check that disposing the window causes ungrab + w.dispose(); + Util.waitForIdle(robot); + if (!ungrabbed) { + passed = false; + System.err.println("Failure: [7] Window disposal didn't cause ungrab"); + } + + if (passed) { + System.out.println("Test passed."); + } else { + throw new RuntimeException("Test failed."); + } + } + + public static void checkAndThrow(boolean condition, String msg) { + if (!condition) { + throw new RuntimeException(msg); + } + } +} diff -r e0ef14d89741 -r b0d6552ba301 test/java/awt/event/TextEvent/TextEventSequenceTest/TextEventSequenceTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/event/TextEvent/TextEventSequenceTest/TextEventSequenceTest.java Tue Aug 07 20:23:41 2012 -0700 @@ -0,0 +1,138 @@ +/* + * 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 4028580 + * @summary TextArea does not send TextEvent when setText. Does for insert + * @author kdm@sparc.spb.su: area= awt.TextAvent + * @run main TextEventSequenceTest + */ +import java.awt.*; +import java.awt.event.*; +import sun.awt.SunToolkit; + +public class TextEventSequenceTest { + + private static Frame f; + private static TextField tf; + private static TextArea t; + private static int cntEmptyStrings = 0; + private static int cntNonEmptyStrings = 0; + + public static void main(String[] args) { + + test("non-empty text string"); + test(""); + test(null); + } + + private static void test(String test) { + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + createAndShowGUI(test); + toolkit.realSync(); + + initCounts(); + t.setText("Hello "); + toolkit.realSync(); + t.append("World! !"); + toolkit.realSync(); + t.insert("from Roger Pham", 13); + toolkit.realSync(); + t.replaceRange("Java Duke", 18, 28); + toolkit.realSync(); + checkCounts(0, 4); + + initCounts(); + t.setText(""); + toolkit.realSync(); + t.setText(""); + toolkit.realSync(); + t.setText(""); + toolkit.realSync(); + checkCounts(1, 0); + + initCounts(); + tf.setText("Hello There!"); + toolkit.realSync(); + checkCounts(0, 1); + + initCounts(); + tf.setText(""); + toolkit.realSync(); + tf.setText(""); + toolkit.realSync(); + tf.setText(""); + toolkit.realSync(); + checkCounts(1, 0); + + f.dispose(); + } + + private static void createAndShowGUI(String text) { + f = new Frame("TextEventSequenceTest"); + f.setLayout(new FlowLayout()); + + TextListener listener = new MyTextListener(); + + tf = new TextField(text); + tf.addTextListener(listener); + f.add(tf); + + t = new TextArea(text, 10, 30); + t.addTextListener(listener); + f.add(t); + + f.pack(); + f.setVisible(true); + } + + static class MyTextListener implements TextListener { + + public synchronized void textValueChanged(TextEvent e) { + TextComponent tc = (TextComponent) e.getSource(); + String text = tc.getText(); + if (text.length() == 0) { + cntEmptyStrings++; + } else { + cntNonEmptyStrings++; + } + } + } + + synchronized static void initCounts() { + cntEmptyStrings = 0; + cntNonEmptyStrings = 0; + } + + synchronized static void checkCounts(int empty, int nonempty) { + if (empty != cntEmptyStrings || nonempty != cntNonEmptyStrings) { + throw new RuntimeException( + String.format("Expected events: empty = %d, nonempty = %d, " + + "actual events: empty = %d, nonempty = %d", + empty, nonempty, cntEmptyStrings, cntNonEmptyStrings)); + } + } +} + diff -r e0ef14d89741 -r b0d6552ba301 test/java/beans/Performance/Test7122740.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/beans/Performance/Test7122740.java Tue Aug 07 20:23:41 2012 -0700 @@ -0,0 +1,57 @@ +/* + * 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 7122740 + * @summary Tests just a benchmark of PropertyDescriptor(String, Class) performance + * @author Sergey Malenkov + * @run main/manual Test7122740 + */ + +import java.beans.PropertyDescriptor; + +public class Test7122740 { + public static void main(String[] args) throws Exception { + long time = System.nanoTime(); + for (int i = 0; i < 1000; i++) { + new PropertyDescriptor("name", PropertyDescriptor.class); + new PropertyDescriptor("value", Concrete.class); + } + time -= System.nanoTime(); + System.out.println("Time (ms): " + (-time / 1000000)); + } + + public static class Abstract { + private T value; + public T getValue() { + return this.value; + } + public void setValue(T value) { + this.value = value; + } + } + + private static class Concrete extends Abstract { + } +} diff -r e0ef14d89741 -r b0d6552ba301 test/java/beans/Performance/Test7184799.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/beans/Performance/Test7184799.java Tue Aug 07 20:23:41 2012 -0700 @@ -0,0 +1,71 @@ +/* + * 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 7184799 + * @summary Tests just a benchmark of Introspector.getBeanInfo(Class) performance + * @author Sergey Malenkov + * @run main/manual Test7184799 + */ + +import java.beans.Introspector; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +public class Test7184799 { + private static final Class[] TYPES = { + Class.class, + String.class, + Character.class, + Boolean.class, + Byte.class, + Short.class, + Integer.class, + Long.class, + Float.class, + Double.class, + Collection.class, + Set.class, + HashSet.class, + TreeSet.class, + LinkedHashSet.class, + Map.class, + HashMap.class, + TreeMap.class, + LinkedHashMap.class, + WeakHashMap.class, + ConcurrentHashMap.class, + Dictionary.class, + Exception.class, + }; + + public static void main(String[] args) throws Exception { + long time = System.nanoTime(); + for (Class type : TYPES) { + Introspector.getBeanInfo(type); + } + time -= System.nanoTime(); + System.out.println("Time (ms): " + (-time / 1000000)); + } +}