# HG changeset patch
# User lana
# Date 1265702716 28800
# Node ID 0d8932a7627efcbcbbf561cff119b50b9ebd4f10
# Parent d15d1cfb440bc8dcc938d061589faf6f02d18990# Parent 4f7de5eeeac72fce41f3c74bc9a6dd21beb34756
Merge
diff -r d15d1cfb440b -r 0d8932a7627e jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java
--- a/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc. 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
@@ -146,6 +146,8 @@
* @param out The code output stream.
* @return An expression whose value is oldInstance.
*
+ * @throws NullPointerException if {@code out} is {@code null}
+ *
* @see #DefaultPersistenceDelegate(String[])
*/
protected Expression instantiate(Object oldInstance, Encoder out) {
@@ -367,6 +369,8 @@
* @param newInstance The instance that is to be modified.
* @param out The stream to which any initialization statements should be written.
*
+ * @throws NullPointerException if {@code out} is {@code null}
+ *
* @see java.beans.Introspector#getBeanInfo
* @see java.beans.PropertyDescriptor
*/
diff -r d15d1cfb440b -r 0d8932a7627e jdk/src/share/classes/java/beans/Encoder.java
--- a/jdk/src/share/classes/java/beans/Encoder.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/beans/Encoder.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc. 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
@@ -112,54 +112,82 @@
/**
* Returns the persistence delegate for the given type.
- * The persistence delegate is calculated
- * by applying the following of rules in order:
- *
+ * The persistence delegate is calculated by applying
+ * the following rules in order:
+ *
+ *
+ * If a persistence delegate is associated with the given type
+ * by using the {@link #setPersistenceDelegate} method
+ * it is returned.
*
- * If the type is an array, an internal persistence
- * delegate is returned which will instantiate an
- * array of the appropriate type and length, initializing
- * each of its elements as if they are properties.
+ * A persistence delegate is then looked up by the name
+ * composed of the the fully qualified name of the given type
+ * and the "PersistenceDelegate" postfix.
+ * For example, a persistence delegate for the {@code Bean} class
+ * should be named {@code BeanPersistenceDelegate}
+ * and located in the same package.
+ *
+ * public class Bean { ... }
+ * public class BeanPersistenceDelegate { ... }
+ * The instance of the {@code BeanPersistenceDelegate} class
+ * is returned for the {@code Bean} class.
+ *
+ * If the type is {@code null},
+ * a shared internal persistence delegate is returned
+ * that encodes {@code null} value.
*
- * If the type is a proxy, an internal persistence
- * delegate is returned which will instantiate a
- * new proxy instance using the static
- * "newProxyInstance" method defined in the
- * Proxy class.
+ * If the type is a {@code enum} declaration,
+ * a shared internal persistence delegate is returned
+ * that encodes constants of this enumeration
+ * by their names.
+ *
+ * If the type is a primitive type or the corresponding wrapper,
+ * a shared internal persistence delegate is returned
+ * that encodes values of the given type.
+ *
+ * If the type is an array,
+ * a shared internal persistence delegate is returned
+ * that encodes an array of the appropriate type and length,
+ * and each of its elements as if they are properties.
*
- * If the BeanInfo for this type has a BeanDescriptor
- * which defined a "persistenceDelegate" property, this
- * value is returned.
+ * If the type is a proxy,
+ * a shared internal persistence delegate is returned
+ * that encodes a proxy instance by using
+ * the {@link java.lang.reflect.Proxy#newProxyInstance} method.
*
- * In all other cases the default persistence delegate
- * is returned. The default persistence delegate assumes
- * the type is a JavaBean, implying that it has a default constructor
- * and that its state may be characterized by the matching pairs
- * of "setter" and "getter" methods returned by the Introspector.
+ * If the {@link BeanInfo} for this type has a {@link BeanDescriptor}
+ * which defined a "persistenceDelegate" attribute,
+ * the value of this named attribute is returned.
+ *
+ * In all other cases the default persistence delegate is returned.
+ * The default persistence delegate assumes the type is a JavaBean,
+ * implying that it has a default constructor and that its state
+ * may be characterized by the matching pairs of "setter" and "getter"
+ * methods returned by the {@link Introspector} class.
* The default constructor is the constructor with the greatest number
* of parameters that has the {@link ConstructorProperties} annotation.
- * If none of the constructors have the {@code ConstructorProperties} annotation,
+ * If none of the constructors has the {@code ConstructorProperties} annotation,
* then the nullary constructor (constructor with no parameters) will be used.
- * For example, in the following the nullary constructor
- * for {@code Foo} will be used, while the two parameter constructor
- * for {@code Bar} will be used.
- *
- * public class Foo {
+ * For example, in the following code fragment, the nullary constructor
+ * for the {@code Foo} class will be used,
+ * while the two-parameter constructor
+ * for the {@code Bar} class will be used.
+ *
+ * public class Foo {
* public Foo() { ... }
* public Foo(int x) { ... }
- * }
- * public class Bar {
+ * }
+ * public class Bar {
* public Bar() { ... }
* @ConstructorProperties({"x"})
* public Bar(int x) { ... }
* @ConstructorProperties({"x", "y"})
* public Bar(int x, int y) { ... }
- * }
- *
- *
+ * }
+ *
*
- * @param type The type of the object.
- * @return The persistence delegate for this type of object.
+ * @param type the class of the objects
+ * @return the persistence delegate for the given type
*
* @see #setPersistenceDelegate
* @see java.beans.Introspector#getBeanInfo
@@ -176,21 +204,18 @@
}
/**
- * Sets the persistence delegate associated with this type to
- * persistenceDelegate.
+ * Associates the specified persistence delegate with the given type.
*
- * @param type The class of objects that persistenceDelegate applies to.
- * @param persistenceDelegate The persistence delegate for instances of type.
+ * @param type the class of objects that the specified persistence delegate applies to
+ * @param delegate the persistence delegate for instances of the given type
*
* @see #getPersistenceDelegate
* @see java.beans.Introspector#getBeanInfo
* @see java.beans.BeanInfo#getBeanDescriptor
*/
- public void setPersistenceDelegate(Class> type,
- PersistenceDelegate persistenceDelegate)
- {
+ public void setPersistenceDelegate(Class> type, PersistenceDelegate delegate) {
synchronized (this.finder) {
- this.finder.register(type, persistenceDelegate);
+ this.finder.register(type, delegate);
}
}
diff -r d15d1cfb440b -r 0d8932a7627e jdk/src/share/classes/java/beans/Expression.java
--- a/jdk/src/share/classes/java/beans/Expression.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/beans/Expression.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc. 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
@@ -51,12 +51,19 @@
private Object value = unbound;
/**
- * Creates a new Statement object with a target,
- * methodName and arguments as per the parameters.
+ * Creates a new {@link Expression} object
+ * for the specified target object to invoke the method
+ * specified by the name and by the array of arguments.
+ *
+ * The {@code target} and the {@code methodName} values should not be {@code null}.
+ * Otherwise an attempt to execute this {@code Expression}
+ * will result in a {@code NullPointerException}.
+ * If the {@code arguments} value is {@code null},
+ * an empty array is used as the value of the {@code arguments} property.
*
- * @param target The target of this expression.
- * @param methodName The methodName of this expression.
- * @param arguments The arguments of this expression. If null then an empty array will be used.
+ * @param target the target object of this expression
+ * @param methodName the name of the method to invoke on the specified target
+ * @param arguments the array of arguments to invoke the specified method
*
* @see #getValue
*/
@@ -66,16 +73,23 @@
}
/**
- * Creates a new Expression object for a method
- * that returns a result. The result will never be calculated
- * however, since this constructor uses the value
- * parameter to set the value property by calling the
- * setValue method.
+ * Creates a new {@link Expression} object with the specified value
+ * for the specified target object to invoke the method
+ * specified by the name and by the array of arguments.
+ * The {@code value} value is used as the value of the {@code value} property,
+ * so the {@link #getValue} method will return it
+ * without executing this {@code Expression}.
+ *
+ * The {@code target} and the {@code methodName} values should not be {@code null}.
+ * Otherwise an attempt to execute this {@code Expression}
+ * will result in a {@code NullPointerException}.
+ * If the {@code arguments} value is {@code null},
+ * an empty array is used as the value of the {@code arguments} property.
*
- * @param value The value of this expression.
- * @param target The target of this expression.
- * @param methodName The methodName of this expression.
- * @param arguments The arguments of this expression. If null then an empty array will be used.
+ * @param value the value of this expression
+ * @param target the target object of this expression
+ * @param methodName the name of the method to invoke on the specified target
+ * @param arguments the array of arguments to invoke the specified method
*
* @see #setValue
*/
diff -r d15d1cfb440b -r 0d8932a7627e jdk/src/share/classes/java/beans/Introspector.java
--- a/jdk/src/share/classes/java/beans/Introspector.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/beans/Introspector.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2010 Sun Microsystems, Inc. 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
@@ -29,6 +29,8 @@
import com.sun.beans.finder.BeanInfoFinder;
import com.sun.beans.finder.ClassFinder;
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -39,6 +41,7 @@
import java.util.EventListener;
import java.util.List;
import java.util.TreeMap;
+import java.util.WeakHashMap;
import sun.awt.AppContext;
import sun.reflect.misc.ReflectUtil;
@@ -155,11 +158,11 @@
return (new Introspector(beanClass, null, USE_ALL_BEANINFO)).getBeanInfo();
}
synchronized (BEANINFO_CACHE) {
- WeakCache, BeanInfo> beanInfoCache =
- (WeakCache, BeanInfo>) AppContext.getAppContext().get(BEANINFO_CACHE);
+ Map, BeanInfo> beanInfoCache =
+ (Map, BeanInfo>) AppContext.getAppContext().get(BEANINFO_CACHE);
if (beanInfoCache == null) {
- beanInfoCache = new WeakCache, BeanInfo>();
+ beanInfoCache = new WeakHashMap, BeanInfo>();
AppContext.getAppContext().put(BEANINFO_CACHE, beanInfoCache);
}
BeanInfo beanInfo = beanInfoCache.get(beanClass);
@@ -341,7 +344,7 @@
public static void flushCaches() {
synchronized (BEANINFO_CACHE) {
- WeakCache beanInfoCache = (WeakCache) AppContext.getAppContext().get(BEANINFO_CACHE);
+ Map beanInfoCache = (Map) AppContext.getAppContext().get(BEANINFO_CACHE);
if (beanInfoCache != null) {
beanInfoCache.clear();
}
@@ -369,7 +372,7 @@
throw new NullPointerException();
}
synchronized (BEANINFO_CACHE) {
- WeakCache beanInfoCache = (WeakCache) AppContext.getAppContext().get(BEANINFO_CACHE);
+ Map beanInfoCache = (Map) AppContext.getAppContext().get(BEANINFO_CACHE);
if (beanInfoCache != null) {
beanInfoCache.put(clz, null);
}
@@ -1458,7 +1461,7 @@
private PropertyDescriptor[] properties;
private int defaultProperty;
private MethodDescriptor[] methods;
- private BeanInfo targetBeanInfo;
+ private final Reference targetBeanInfoRef;
public GenericBeanInfo(BeanDescriptor beanDescriptor,
EventSetDescriptor[] events, int defaultEvent,
@@ -1470,7 +1473,7 @@
this.properties = properties;
this.defaultProperty = defaultProperty;
this.methods = methods;
- this.targetBeanInfo = targetBeanInfo;
+ this.targetBeanInfoRef = new SoftReference(targetBeanInfo);
}
/**
@@ -1509,7 +1512,7 @@
methods[i] = new MethodDescriptor(old.methods[i]);
}
}
- targetBeanInfo = old.targetBeanInfo;
+ this.targetBeanInfoRef = old.targetBeanInfoRef;
}
public PropertyDescriptor[] getPropertyDescriptors() {
@@ -1537,6 +1540,7 @@
}
public java.awt.Image getIcon(int iconKind) {
+ BeanInfo targetBeanInfo = this.targetBeanInfoRef.get();
if (targetBeanInfo != null) {
return targetBeanInfo.getIcon(iconKind);
}
diff -r d15d1cfb440b -r 0d8932a7627e jdk/src/share/classes/java/beans/PersistenceDelegate.java
--- a/jdk/src/share/classes/java/beans/PersistenceDelegate.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/beans/PersistenceDelegate.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc. 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
@@ -105,6 +105,8 @@
*
* @param oldInstance The instance that will be created by this expression.
* @param out The stream to which this expression will be written.
+ *
+ * @throws NullPointerException if {@code out} is {@code null}
*/
public void writeObject(Object oldInstance, Encoder out) {
Object newInstance = out.get(oldInstance);
@@ -158,6 +160,8 @@
* @param oldInstance The instance that will be created by this expression.
* @param out The stream to which this expression will be written.
* @return An expression whose value is oldInstance.
+ *
+ * @throws NullPointerException if {@code out} is {@code null}
*/
protected abstract Expression instantiate(Object oldInstance, Encoder out);
@@ -196,6 +200,8 @@
* @param oldInstance The instance to be copied.
* @param newInstance The instance that is to be modified.
* @param out The stream to which any initialization statements should be written.
+ *
+ * @throws NullPointerException if {@code out} is {@code null}
*/
protected void initialize(Class> type,
Object oldInstance, Object newInstance,
diff -r d15d1cfb440b -r 0d8932a7627e jdk/src/share/classes/java/beans/Statement.java
--- a/jdk/src/share/classes/java/beans/Statement.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/beans/Statement.java Tue Feb 09 00:05:16 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc. 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
@@ -69,13 +69,19 @@
ClassLoader loader;
/**
- * Creates a new Statement object with a target,
- * methodName and arguments as per the parameters.
+ * Creates a new {@link Statement} object
+ * for the specified target object to invoke the method
+ * specified by the name and by the array of arguments.
+ *
+ * The {@code target} and the {@code methodName} values should not be {@code null}.
+ * Otherwise an attempt to execute this {@code Expression}
+ * will result in a {@code NullPointerException}.
+ * If the {@code arguments} value is {@code null},
+ * an empty array is used as the value of the {@code arguments} property.
*
- * @param target The target of this statement.
- * @param methodName The methodName of this statement.
- * @param arguments The arguments of this statement. If null then an empty array will be used.
- *
+ * @param target the target object of this statement
+ * @param methodName the name of the method to invoke on the specified target
+ * @param arguments the array of arguments to invoke the specified method
*/
@ConstructorProperties({"target", "methodName", "arguments"})
public Statement(Object target, String methodName, Object[] arguments) {
@@ -85,27 +91,36 @@
}
/**
- * Returns the target of this statement.
+ * Returns the target object of this statement.
+ * If this method returns {@code null},
+ * the {@link #execute} method
+ * throws a {@code NullPointerException}.
*
- * @return The target of this statement.
+ * @return the target object of this statement
*/
public Object getTarget() {
return target;
}
/**
- * Returns the name of the method.
+ * Returns the name of the method to invoke.
+ * If this method returns {@code null},
+ * the {@link #execute} method
+ * throws a {@code NullPointerException}.
*
- * @return The name of the method.
+ * @return the name of the method
*/
public String getMethodName() {
return methodName;
}
/**
- * Returns the arguments of this statement.
+ * Returns the arguments for the method to invoke.
+ * The number of arguments and their types
+ * must match the method being called.
+ * {@code null} can be used as a synonym of an empty array.
*
- * @return the arguments of this statement.
+ * @return the array of arguments
*/
public Object[] getArguments() {
return arguments;
@@ -154,6 +169,9 @@
}
Object[] arguments = getArguments();
+ if (arguments == null) {
+ arguments = emptyArray;
+ }
// Class.forName() won't load classes outside
// of core from a class inside core. Special
// case this method.
@@ -285,7 +303,9 @@
Object target = getTarget();
String methodName = getMethodName();
Object[] arguments = getArguments();
-
+ if (arguments == null) {
+ arguments = emptyArray;
+ }
StringBuffer result = new StringBuffer(instanceName(target) + "." + methodName + "(");
int n = arguments.length;
for(int i = 0; i < n; i++) {
diff -r d15d1cfb440b -r 0d8932a7627e jdk/src/share/classes/java/text/CollationElementIterator.java
--- a/jdk/src/share/classes/java/text/CollationElementIterator.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/text/CollationElementIterator.java Tue Feb 09 00:05:16 2010 -0800
@@ -232,7 +232,7 @@
buffer = makeReorderedBuffer(consonant, value, buffer, true);
value = buffer[0];
expIndex = 1;
- } else {
+ } else if (consonant != NormalizerBase.DONE) {
text.previous();
}
}
@@ -242,7 +242,7 @@
buffer = makeReorderedBuffer(consonant, value, buffer, true);
value = buffer[0];
expIndex = 1;
- } else {
+ } else if (consonant != NormalizerBase.DONE) {
text.previous();
}
}
diff -r d15d1cfb440b -r 0d8932a7627e jdk/src/share/classes/java/text/RuleBasedBreakIterator.java
--- a/jdk/src/share/classes/java/text/RuleBasedBreakIterator.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/text/RuleBasedBreakIterator.java Tue Feb 09 00:05:16 2010 -0800
@@ -621,6 +621,8 @@
return handleNext();
}
+ private int cachedLastKnownBreak = BreakIterator.DONE;
+
/**
* Advances the iterator backwards, to the last boundary preceding this one.
* @return The position of the last boundary position preceding this one.
@@ -638,8 +640,16 @@
// the current position), but not necessarily the last one before
// where we started
int start = current();
- getPrevious();
- int lastResult = handlePrevious();
+ int lastResult = cachedLastKnownBreak;
+ if (lastResult >= start || lastResult <= BreakIterator.DONE) {
+ getPrevious();
+ lastResult = handlePrevious();
+ } else {
+ //it might be better to check if handlePrevious() give us closer
+ //safe value but handlePrevious() is slow too
+ //So, this has to be done carefully
+ text.setIndex(lastResult);
+ }
int result = lastResult;
// iterate forward from the known break position until we pass our
@@ -653,6 +663,7 @@
// set the current iteration position to be the last break position
// before where we started, and then return that value
text.setIndex(lastResult);
+ cachedLastKnownBreak = lastResult;
return lastResult;
}
@@ -757,7 +768,8 @@
// then we can just use next() to get our return value
text.setIndex(offset);
if (offset == text.getBeginIndex()) {
- return handleNext();
+ cachedLastKnownBreak = handleNext();
+ return cachedLastKnownBreak;
}
// otherwise, we have to sync up first. Use handlePrevious() to back
@@ -767,10 +779,19 @@
// position at or before our starting position. Advance forward
// from here until we've passed the starting position. The position
// we stop on will be the first break position after the specified one.
- int result = handlePrevious();
+ int result = cachedLastKnownBreak;
+ if (result >= offset || result <= BreakIterator.DONE) {
+ result = handlePrevious();
+ } else {
+ //it might be better to check if handlePrevious() give us closer
+ //safe value but handlePrevious() is slow too
+ //So, this has to be done carefully
+ text.setIndex(result);
+ }
while (result != BreakIterator.DONE && result <= offset) {
result = handleNext();
}
+ cachedLastKnownBreak = result;
return result;
}
@@ -865,6 +886,8 @@
text = new SafeCharIterator(newText);
}
text.first();
+
+ cachedLastKnownBreak = BreakIterator.DONE;
}
diff -r d15d1cfb440b -r 0d8932a7627e jdk/src/share/classes/java/util/Date.java
--- a/jdk/src/share/classes/java/util/Date.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/java/util/Date.java Tue Feb 09 00:05:16 2010 -0800
@@ -953,7 +953,7 @@
* without affecting its internal state.
*/
static final long getMillisOf(Date date) {
- if (date.cdate == null) {
+ if (date.cdate == null || date.cdate.isNormalized()) {
return date.fastTime;
}
BaseCalendar.Date d = (BaseCalendar.Date) date.cdate.clone();
diff -r d15d1cfb440b -r 0d8932a7627e jdk/src/share/classes/javax/swing/MultiUIDefaults.java
--- a/jdk/src/share/classes/javax/swing/MultiUIDefaults.java Tue Feb 09 00:02:38 2010 -0800
+++ b/jdk/src/share/classes/javax/swing/MultiUIDefaults.java Tue Feb 09 00:05:16 2010 -0800
@@ -27,6 +27,7 @@
import java.util.Enumeration;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.Set;
@@ -89,11 +90,7 @@
@Override
public int size() {
- int n = super.size();
- for (UIDefaults table : tables) {
- n += (table != null) ? table.size() : 0;
- }
- return n;
+ return entrySet().size();
}
@Override
@@ -104,40 +101,26 @@
@Override
public Enumeration