提交 f0559fb6 编写于 作者: L lana

Merge

...@@ -171,3 +171,4 @@ b92353a01aa049bc508fc56f0347d5934b7c4390 jdk8-b45 ...@@ -171,3 +171,4 @@ b92353a01aa049bc508fc56f0347d5934b7c4390 jdk8-b45
00b22b23269a57d0bb46c57753be2fe9a9d2c1a3 jdk8-b47 00b22b23269a57d0bb46c57753be2fe9a9d2c1a3 jdk8-b47
3e4ab821f46166fcf63e8fe5c8046216003c941f jdk8-b48 3e4ab821f46166fcf63e8fe5c8046216003c941f jdk8-b48
51707c3b75c0f521794d9ab425f4e5b2351c70c1 jdk8-b49 51707c3b75c0f521794d9ab425f4e5b2351c70c1 jdk8-b49
e4bae5c53fca8fcb9393d47fd36a34b9e2e8d4ec jdk8-b50
...@@ -237,7 +237,7 @@ ifeq ($(PLATFORM), macosx) ...@@ -237,7 +237,7 @@ ifeq ($(PLATFORM), macosx)
SUBDIRS += apple SUBDIRS += apple
endif endif
SUBDIRS_tools = launchers SUBDIRS_tools = launchers
SUBDIRS_misc = org sunw jpda SUBDIRS_misc = org jpda
# demos # demos
ifndef NO_DEMOS ifndef NO_DEMOS
......
...@@ -305,8 +305,7 @@ SOURCES = \ ...@@ -305,8 +305,7 @@ SOURCES = \
org/ietf \ org/ietf \
org/omg \ org/omg \
org/w3c/dom \ org/w3c/dom \
org/xml/sax \ org/xml/sax
sunw
# #
# Directories where sources may be found. If a file with the same path # 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 # name exists in more than one of these places, the one found last on this
......
...@@ -33,7 +33,6 @@ EXCLUDE_PKGS = \ ...@@ -33,7 +33,6 @@ EXCLUDE_PKGS = \
java.awt.peer \ java.awt.peer \
java.awt.dnd.peer \ java.awt.dnd.peer \
sun.* \ sun.* \
sunw.* \
com.sun.* \ com.sun.* \
org.apache.* \ org.apache.* \
org.jcp.* \ org.jcp.* \
......
#
# 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
...@@ -807,8 +807,7 @@ SRC_ZIP_INCLUDES = \ ...@@ -807,8 +807,7 @@ SRC_ZIP_INCLUDES = \
org/ietf \ org/ietf \
org/omg \ org/omg \
org/w3c/dom \ org/w3c/dom \
org/xml/sax \ org/xml/sax
sunw
SRC_ZIP_SRCS = $(JDK_TOPDIR)/src/share/classes $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes SRC_ZIP_SRCS = $(JDK_TOPDIR)/src/share/classes $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes
SRC_ZIP_SRCS += $(JDK_OUTPUTDIR)/gensrc SRC_ZIP_SRCS += $(JDK_OUTPUTDIR)/gensrc
......
...@@ -33,7 +33,6 @@ EXCLUDE_PKGS = \ ...@@ -33,7 +33,6 @@ EXCLUDE_PKGS = \
java.awt.peer \ java.awt.peer \
java.awt.dnd.peer \ java.awt.dnd.peer \
sun.* \ sun.* \
sunw.* \
com.sun.* \ com.sun.* \
org.apache.* \ org.apache.* \
org.jcp.* \ org.jcp.* \
......
...@@ -259,7 +259,8 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { ...@@ -259,7 +259,8 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
protected void installKeyboardActions() { protected void installKeyboardActions() {
super.installKeyboardActions(); super.installKeyboardActions();
final ActionMap actionMap = comboBox.getActionMap(); ActionMap actionMap = new ActionMapUIResource();
actionMap.put("aquaSelectNext", highlightNextAction); actionMap.put("aquaSelectNext", highlightNextAction);
actionMap.put("aquaSelectPrevious", highlightPreviousAction); actionMap.put("aquaSelectPrevious", highlightPreviousAction);
actionMap.put("aquaEnterPressed", triggerSelectionAction); actionMap.put("aquaEnterPressed", triggerSelectionAction);
...@@ -269,6 +270,8 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { ...@@ -269,6 +270,8 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
actionMap.put("aquaSelectEnd", highlightLastAction); actionMap.put("aquaSelectEnd", highlightLastAction);
actionMap.put("aquaSelectPageUp", highlightPageUpAction); actionMap.put("aquaSelectPageUp", highlightPageUpAction);
actionMap.put("aquaSelectPageDown", highlightPageDownAction); actionMap.put("aquaSelectPageDown", highlightPageDownAction);
SwingUtilities.replaceUIActionMap(comboBox, actionMap);
} }
abstract class ComboBoxAction extends AbstractAction { abstract class ComboBoxAction extends AbstractAction {
......
...@@ -128,16 +128,6 @@ final class LWTextAreaPeer ...@@ -128,16 +128,6 @@ final class LWTextAreaPeer
repaintPeer(); repaintPeer();
} }
@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 @Override
public void replaceRange(final String text, final int start, public void replaceRange(final String text, final int start,
final int end) { final int end) {
......
...@@ -124,7 +124,7 @@ abstract class LWTextComponentPeer<T extends TextComponent, D extends JComponent ...@@ -124,7 +124,7 @@ abstract class LWTextComponentPeer<T extends TextComponent, D extends JComponent
} }
@Override @Override
public void setText(final String l) { public final void setText(final String l) {
synchronized (getDelegateLock()) { synchronized (getDelegateLock()) {
// JTextArea.setText() posts two different events (remove & insert). // JTextArea.setText() posts two different events (remove & insert).
// Since we make no differences between text events, // Since we make no differences between text events,
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -45,6 +45,9 @@ import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl; ...@@ -45,6 +45,9 @@ import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
* @author Sergey Malenkov * @author Sergey Malenkov
*/ */
public final class TypeResolver { public final class TypeResolver {
private static final WeakCache<Type, Map<Type, Type>> CACHE = new WeakCache<>();
/** /**
* Replaces the given {@code type} in an inherited method * Replaces the given {@code type} in an inherited method
* with the actual type it has in the given {@code inClass}. * with the actual type it has in the given {@code inClass}.
...@@ -149,12 +152,55 @@ public final class TypeResolver { ...@@ -149,12 +152,55 @@ public final class TypeResolver {
* @param formal the type where occurrences of the variables * @param formal the type where occurrences of the variables
* in {@code actual} will be replaced by the corresponding bound values * in {@code actual} will be replaced by the corresponding bound values
* @return a resolved type * @return a resolved type
*
* @see #TypeResolver(Type)
* @see #resolve(Type)
*/ */
public static Type resolve(Type actual, Type formal) { 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<Type, Type> 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<T> {...}
// class Mid<X> extends Super<T> {...}
// class Sub extends Mid<String>
// 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 @@ public final class TypeResolver { ...@@ -164,12 +210,14 @@ public final class TypeResolver {
* @param actual the type that supplies bindings for type variables * @param actual the type that supplies bindings for type variables
* @param formals the array of types to resolve * @param formals the array of types to resolve
* @return an array of resolved types * @return an array of resolved types
*
* @see #TypeResolver(Type)
* @see #resolve(Type[])
*/ */
public static Type[] resolve(Type actual, Type[] formals) { 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 @@ public final class TypeResolver { ...@@ -228,32 +276,6 @@ public final class TypeResolver {
return classes; 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<Type, TypeResolver> CACHE = new WeakCache<>();
private final Map<TypeVariable<?>, 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 * Fills the map from type parameters
* to types as seen by the given {@code type}. * to types as seen by the given {@code type}.
...@@ -265,9 +287,10 @@ public final class TypeResolver { ...@@ -265,9 +287,10 @@ public final class TypeResolver {
* to a {@link ParameterizedType ParameterizedType} with no parameters, * to a {@link ParameterizedType ParameterizedType} with no parameters,
* or it represents the erasure of a {@link ParameterizedType ParameterizedType}. * 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 * @param type the next type in the hierarchy
*/ */
private void prepare(Type type) { private static void prepare(Map<Type, Type> map, Type type) {
Class<?> raw = (Class<?>)((type instanceof Class<?>) Class<?> raw = (Class<?>)((type instanceof Class<?>)
? type ? type
: ((ParameterizedType)type).getRawType()); : ((ParameterizedType)type).getRawType());
...@@ -280,90 +303,24 @@ public final class TypeResolver { ...@@ -280,90 +303,24 @@ public final class TypeResolver {
assert formals.length == actuals.length; assert formals.length == actuals.length;
for (int i = 0; i < formals.length; i++) { 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(); Type gSuperclass = raw.getGenericSuperclass();
if (gSuperclass != null) { if (gSuperclass != null) {
prepare(gSuperclass); prepare(map, gSuperclass);
} }
for (Type gInterface : raw.getGenericInterfaces()) { for (Type gInterface : raw.getGenericInterfaces()) {
prepare(gInterface); prepare(map, gInterface);
} }
// If type is the raw version of a parameterized class, we type-erase // If type is the raw version of a parameterized class, we type-erase
// all of its type variables, including inherited ones. // all of its type variables, including inherited ones.
if (type instanceof Class<?> && formals.length > 0) { if (type instanceof Class<?> && formals.length > 0) {
for (Map.Entry<TypeVariable<?>, Type> entry : this.map.entrySet()) { for (Map.Entry<Type, Type> entry : map.entrySet()) {
entry.setValue(erase(entry.getValue())); 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<T> {...}
// class Mid<X> extends Super<T> {...}
// class Sub extends Mid<String>
// 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} * Replaces a {@link GenericArrayType GenericArrayType}
* with plain array class where it is possible. * with plain array class where it is possible.
......
...@@ -164,8 +164,10 @@ public final class MethodFinder extends AbstractFinder<Method> { ...@@ -164,8 +164,10 @@ public final class MethodFinder extends AbstractFinder<Method> {
return findAccessibleMethod(m); return findAccessibleMethod(m);
} }
Type[] gpts = m.getGenericParameterTypes(); Type[] gpts = m.getGenericParameterTypes();
if (Arrays.equals(params, TypeResolver.erase(TypeResolver.resolve(pt, gpts)))) { if (params.length == gpts.length) {
return findAccessibleMethod(m); if (Arrays.equals(params, TypeResolver.erase(TypeResolver.resolve(pt, gpts)))) {
return findAccessibleMethod(m);
}
} }
} }
} }
......
...@@ -170,12 +170,12 @@ public abstract class GraphicsEnvironment { ...@@ -170,12 +170,12 @@ public abstract class GraphicsEnvironment {
if (System.getProperty("javaplugin.version") != null) { if (System.getProperty("javaplugin.version") != null) {
headless = defaultHeadless = Boolean.FALSE; headless = defaultHeadless = Boolean.FALSE;
} else { } else {
if ("sun.awt.HeadlessGraphicsEnvironment".equals( String osName = System.getProperty("os.name");
System.getProperty("java.awt.graphicsenv"))) if (osName.contains("OS X") && "sun.awt.HToolkit".equals(
System.getProperty("awt.toolkit")))
{ {
headless = defaultHeadless = Boolean.TRUE; headless = defaultHeadless = Boolean.TRUE;
} else { } else {
String osName = System.getProperty("os.name");
headless = defaultHeadless = headless = defaultHeadless =
Boolean.valueOf(("Linux".equals(osName) || Boolean.valueOf(("Linux".equals(osName) ||
"SunOS".equals(osName) || "SunOS".equals(osName) ||
......
...@@ -235,9 +235,14 @@ public class TextComponent extends Component implements Accessible { ...@@ -235,9 +235,14 @@ public class TextComponent extends Component implements Accessible {
* @see java.awt.TextComponent#getText * @see java.awt.TextComponent#getText
*/ */
public synchronized void setText(String t) { public synchronized void setText(String t) {
boolean skipTextEvent = (text == null || text.isEmpty())
&& (t == null || t.isEmpty());
text = (t != null) ? t : ""; text = (t != null) ? t : "";
TextComponentPeer peer = (TextComponentPeer)this.peer; 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); peer.setText(text);
} }
} }
......
...@@ -181,20 +181,21 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor { ...@@ -181,20 +181,21 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
// the Indexed readMethod was explicitly set to null. // the Indexed readMethod was explicitly set to null.
return null; return null;
} }
String nextMethodName = Introspector.GET_PREFIX + getBaseName();
if (indexedReadMethodName == null) { if (indexedReadMethodName == null) {
Class<?> type = getIndexedPropertyType0(); Class<?> type = getIndexedPropertyType0();
if (type == boolean.class || type == null) { if (type == boolean.class || type == null) {
indexedReadMethodName = Introspector.IS_PREFIX + getBaseName(); indexedReadMethodName = Introspector.IS_PREFIX + getBaseName();
} else { } else {
indexedReadMethodName = Introspector.GET_PREFIX + getBaseName(); indexedReadMethodName = nextMethodName;
} }
} }
Class<?>[] args = { int.class }; Class<?>[] args = { int.class };
indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, 1, args); 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. // no "is" method, so look for a "get" method.
indexedReadMethodName = Introspector.GET_PREFIX + getBaseName(); indexedReadMethodName = nextMethodName;
indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, 1, args); indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, 1, args);
} }
setIndexedReadMethod0(indexedReadMethod); setIndexedReadMethod0(indexedReadMethod);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
package java.beans; package java.beans;
import com.sun.beans.TypeResolver;
import com.sun.beans.WeakCache; import com.sun.beans.WeakCache;
import com.sun.beans.finder.ClassFinder; import com.sun.beans.finder.ClassFinder;
...@@ -34,6 +35,7 @@ import java.lang.ref.Reference; ...@@ -34,6 +35,7 @@ import java.lang.ref.Reference;
import java.lang.ref.SoftReference; import java.lang.ref.SoftReference;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.Map; import java.util.Map;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -951,44 +953,61 @@ public class Introspector { ...@@ -951,44 +953,61 @@ public class Introspector {
continue; continue;
} }
Class<?>[] argTypes = FeatureDescriptor.getParameterTypes(beanClass, method); if (name.startsWith(ADD_PREFIX)) {
Class<?> resultType = FeatureDescriptor.getReturnType(beanClass, method); Class<?> returnType = method.getReturnType();
if (returnType == void.class) {
if (name.startsWith(ADD_PREFIX) && argTypes.length == 1 && Type[] parameterTypes = method.getGenericParameterTypes();
resultType == Void.TYPE && if (parameterTypes.length == 1) {
Introspector.isSubclass(argTypes[0], eventListenerType)) { Class<?> type = TypeResolver.erase(TypeResolver.resolveInClass(beanClass, parameterTypes[0]));
String listenerName = name.substring(3); if (Introspector.isSubclass(type, eventListenerType)) {
if (listenerName.length() > 0 && String listenerName = name.substring(3);
argTypes[0].getName().endsWith(listenerName)) { if (listenerName.length() > 0 &&
if (adds == null) { type.getName().endsWith(listenerName)) {
adds = new HashMap<>(); if (adds == null) {
adds = new HashMap<>();
}
adds.put(listenerName, method);
}
}
} }
adds.put(listenerName, method);
} }
} }
else if (name.startsWith(REMOVE_PREFIX) && argTypes.length == 1 && else if (name.startsWith(REMOVE_PREFIX)) {
resultType == Void.TYPE && Class<?> returnType = method.getReturnType();
Introspector.isSubclass(argTypes[0], eventListenerType)) { if (returnType == void.class) {
String listenerName = name.substring(6); Type[] parameterTypes = method.getGenericParameterTypes();
if (listenerName.length() > 0 && if (parameterTypes.length == 1) {
argTypes[0].getName().endsWith(listenerName)) { Class<?> type = TypeResolver.erase(TypeResolver.resolveInClass(beanClass, parameterTypes[0]));
if (removes == null) { if (Introspector.isSubclass(type, eventListenerType)) {
removes = new HashMap<>(); 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 && else if (name.startsWith(GET_PREFIX)) {
resultType.isArray() && Class<?>[] parameterTypes = method.getParameterTypes();
Introspector.isSubclass(resultType.getComponentType(), if (parameterTypes.length == 0) {
eventListenerType)) { Class<?> returnType = FeatureDescriptor.getReturnType(beanClass, method);
String listenerName = name.substring(3, name.length() - 1); if (returnType.isArray()) {
if (listenerName.length() > 0 && Class<?> type = returnType.getComponentType();
resultType.getComponentType().getName().endsWith(listenerName)) { if (Introspector.isSubclass(type, eventListenerType)) {
if (gets == null) { String listenerName = name.substring(3, name.length() - 1);
gets = new HashMap<>(); 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 @@ public class Introspector { ...@@ -1240,11 +1259,11 @@ public class Introspector {
private boolean isEventHandler(Method m) { private boolean isEventHandler(Method m) {
// We assume that a method is an event handler if it has a single // We assume that a method is an event handler if it has a single
// argument, whose type inherit from java.util.Event. // argument, whose type inherit from java.util.Event.
Class argTypes[] = FeatureDescriptor.getParameterTypes(beanClass, m); Type argTypes[] = m.getGenericParameterTypes();
if (argTypes.length != 1) { if (argTypes.length != 1) {
return false; return false;
} }
return isSubclass(argTypes[0], EventObject.class); return isSubclass(TypeResolver.erase(TypeResolver.resolveInClass(beanClass, argTypes[0])), EventObject.class);
} }
/* /*
...@@ -1296,24 +1315,25 @@ public class Introspector { ...@@ -1296,24 +1315,25 @@ public class Introspector {
} }
// make sure method signature matches. // make sure method signature matches.
Class params[] = FeatureDescriptor.getParameterTypes(start, method); if (method.getName().equals(methodName)) {
if (method.getName().equals(methodName) && Type[] params = method.getGenericParameterTypes();
params.length == argCount) { if (params.length == argCount) {
if (args != null) { if (args != null) {
boolean different = false; boolean different = false;
if (argCount > 0) { if (argCount > 0) {
for (int j = 0; j < argCount; j++) { for (int j = 0; j < argCount; j++) {
if (params[j] != args[j]) { if (TypeResolver.erase(TypeResolver.resolveInClass(start, params[j])) != args[j]) {
different = true; different = true;
continue;
}
}
if (different) {
continue; continue;
} }
} }
if (different) {
continue;
}
} }
return method;
} }
return method;
} }
} }
} }
......
...@@ -210,12 +210,13 @@ public class PropertyDescriptor extends FeatureDescriptor { ...@@ -210,12 +210,13 @@ public class PropertyDescriptor extends FeatureDescriptor {
// The read method was explicitly set to null. // The read method was explicitly set to null.
return null; return null;
} }
String nextMethodName = Introspector.GET_PREFIX + getBaseName();
if (readMethodName == null) { if (readMethodName == null) {
Class<?> type = getPropertyType0(); Class<?> type = getPropertyType0();
if (type == boolean.class || type == null) { if (type == boolean.class || type == null) {
readMethodName = Introspector.IS_PREFIX + getBaseName(); readMethodName = Introspector.IS_PREFIX + getBaseName();
} else { } else {
readMethodName = Introspector.GET_PREFIX + getBaseName(); readMethodName = nextMethodName;
} }
} }
...@@ -225,8 +226,8 @@ public class PropertyDescriptor extends FeatureDescriptor { ...@@ -225,8 +226,8 @@ public class PropertyDescriptor extends FeatureDescriptor {
// methods. If an "is" method exists, this is the official // methods. If an "is" method exists, this is the official
// reader method so look for this one first. // reader method so look for this one first.
readMethod = Introspector.findMethod(cls, readMethodName, 0); readMethod = Introspector.findMethod(cls, readMethodName, 0);
if (readMethod == null) { if ((readMethod == null) && !readMethodName.equals(nextMethodName)) {
readMethodName = Introspector.GET_PREFIX + getBaseName(); readMethodName = nextMethodName;
readMethod = Introspector.findMethod(cls, readMethodName, 0); readMethod = Introspector.findMethod(cls, readMethodName, 0);
} }
try { try {
......
...@@ -187,6 +187,9 @@ class TimerQueue implements Runnable ...@@ -187,6 +187,9 @@ class TimerQueue implements Runnable
addTimer(delayedTimer); addTimer(delayedTimer);
} }
} }
// Allow run other threads on systems without kernel threads
timer.getLock().newCondition().awaitNanos(1);
} catch (SecurityException ignore) { } catch (SecurityException ignore) {
} finally { } finally {
timer.getLock().unlock(); timer.getLock().unlock();
......
...@@ -71,7 +71,6 @@ com/sun/jndi/ ...@@ -71,7 +71,6 @@ com/sun/jndi/
org/w3c/ org/w3c/
com/sun/imageio/ com/sun/imageio/
javax/ javax/
sunw/util/
java/ java/
sun/ sun/
... ...
......
/*
* 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.
* <p>
* 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
* <p>
* 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.
* <p>
* 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);
}
}
...@@ -463,13 +463,6 @@ class XTextAreaPeer extends XComponentPeer implements TextAreaPeer { ...@@ -463,13 +463,6 @@ class XTextAreaPeer extends XComponentPeer implements TextAreaPeer {
protected boolean setTextImpl(String txt) { protected boolean setTextImpl(String txt) {
if (jtext != null) { 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). // JTextArea.setText() posts two different events (remove & insert).
// Since we make no differences between text events, // Since we make no differences between text events,
// the document listener has to be disabled while // the document listener has to be disabled while
......
...@@ -431,6 +431,7 @@ GetJavaProperties(JNIEnv *env) ...@@ -431,6 +431,7 @@ GetJavaProperties(JNIEnv *env)
PreferredToolkit prefToolkit = getPreferredToolkit(); PreferredToolkit prefToolkit = getPreferredToolkit();
switch (prefToolkit) { switch (prefToolkit) {
case CToolkit: case CToolkit:
case HToolkit:
sprops.graphics_env = "sun.awt.CGraphicsEnvironment"; sprops.graphics_env = "sun.awt.CGraphicsEnvironment";
break; break;
case XToolkit: case XToolkit:
...@@ -438,9 +439,6 @@ GetJavaProperties(JNIEnv *env) ...@@ -438,9 +439,6 @@ GetJavaProperties(JNIEnv *env)
sprops.graphics_env = "sun.awt.X11GraphicsEnvironment"; sprops.graphics_env = "sun.awt.X11GraphicsEnvironment";
#ifdef MACOSX #ifdef MACOSX
break; break;
default:
sprops.graphics_env = "sun.java2d.HeadlessGraphicsEnvironment";
break;
} }
#endif #endif
/* AWT properties */ /* AWT properties */
......
...@@ -131,48 +131,13 @@ AwtTextArea::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { ...@@ -131,48 +131,13 @@ AwtTextArea::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
MsgRouting mr = mrDoDefault; MsgRouting mr = mrDoDefault;
switch (message) { 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<LONG>(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 EM_SETCHARFORMAT:
case WM_SETFONT: case WM_SETFONT:
SetIgnoreEnChange(TRUE); SetIgnoreEnChange(TRUE);
break; break;
} }
retValue = AwtComponent::WindowProc(message, wParam, lParam); retValue = AwtTextComponent::WindowProc(message, wParam, lParam);
switch (message) { switch (message) {
case EM_SETCHARFORMAT: case EM_SETCHARFORMAT:
......
...@@ -215,6 +215,50 @@ done: ...@@ -215,6 +215,50 @@ done:
return c; 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<LONG>(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) { LONG AwtTextComponent::EditGetCharFromPos(POINT& pt) {
return static_cast<LONG>(SendMessage(EM_CHARFROMPOS, 0, return static_cast<LONG>(SendMessage(EM_CHARFROMPOS, 0,
reinterpret_cast<LPARAM>(&pt))); reinterpret_cast<LPARAM>(&pt)));
......
...@@ -50,6 +50,7 @@ public: ...@@ -50,6 +50,7 @@ public:
static AwtTextComponent* Create(jobject self, jobject parent, BOOL isMultiline); static AwtTextComponent* Create(jobject self, jobject parent, BOOL isMultiline);
virtual LPCTSTR GetClassName(); virtual LPCTSTR GetClassName();
LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
int RemoveCR(WCHAR *pStr); int RemoveCR(WCHAR *pStr);
......
/*
* 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));
}
}
/*
* 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);
}
}
}
/*
* 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));
}
}
}
/* /*
* Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this * published by the Free Software Foundation.
* 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 * This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...@@ -23,32 +21,37 @@ ...@@ -23,32 +21,37 @@
* questions. * questions.
*/ */
package sunw.util; /*
* @test
/** * @bug 7122740
* FOR BACKWARD COMPATIBILITY ONLY - DO NOT USE. * @summary Tests just a benchmark of PropertyDescriptor(String, Class) performance
* <p> * @author Sergey Malenkov
* This is a backwards compatibility class to allow Java Beans that * @run main/manual Test7122740
* were developed under JDK 1.0.2 to run correctly under JDK 1.1
* <p>
* 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.
* <p>
* 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 { 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<T> {
private T value;
public T getValue() {
return this.value;
}
public void setValue(T value) {
this.value = value;
}
}
private static class Concrete extends Abstract<String> {
}
} }
/* /*
* Copyright (c) 1996, 1997, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this * published by the Free Software Foundation.
* 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 * This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...@@ -23,32 +21,51 @@ ...@@ -23,32 +21,51 @@
* questions. * questions.
*/ */
package sunw.io; /*
* @test
/** * @bug 7184799
* FOR BACKWARD COMPATIBILITY ONLY - DO NOT USE. * @summary Tests just a benchmark of Introspector.getBeanInfo(Class) performance
* <p> * @author Sergey Malenkov
* This is a backwards compatibility class to allow Java Beans that * @run main/manual Test7184799
* were developed under JDK 1.0.2 to run correctly under JDK 1.1
* <p>
* 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.
* <p>
* 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 { 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));
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册