src/share/classes/java/beans/DefaultPersistenceDelegate.java
Print this page
*** 24,33 ****
--- 24,34 ----
*/
package java.beans;
import java.util.*;
import java.lang.reflect.*;
+ import java.util.Objects;
import sun.reflect.misc.*;
/**
* The <code>DefaultPersistenceDelegate</code> is a concrete implementation of
*** 179,203 ****
throw new IllegalStateException("Could not find getter for the property " + property);
}
return method;
}
- private static boolean equals(Object o1, Object o2) {
- return (o1 == null) ? (o2 == null) : o1.equals(o2);
- }
-
private void doProperty(Class type, PropertyDescriptor pd, Object oldInstance, Object newInstance, Encoder out) throws Exception {
Method getter = pd.getReadMethod();
Method setter = pd.getWriteMethod();
if (getter != null && setter != null) {
Expression oldGetExp = new Expression(oldInstance, getter.getName(), new Object[]{});
Expression newGetExp = new Expression(newInstance, getter.getName(), new Object[]{});
Object oldValue = oldGetExp.getValue();
Object newValue = newGetExp.getValue();
out.writeExpression(oldGetExp);
! if (!equals(newValue, out.get(oldValue))) {
// Search for a static constant with this value;
Object e = (Object[])pd.getValue("enumerationValues");
if (e instanceof Object[] && Array.getLength(e) % 3 == 0) {
Object[] a = (Object[])e;
for(int i = 0; i < a.length; i = i + 3) {
--- 180,200 ----
throw new IllegalStateException("Could not find getter for the property " + property);
}
return method;
}
private void doProperty(Class type, PropertyDescriptor pd, Object oldInstance, Object newInstance, Encoder out) throws Exception {
Method getter = pd.getReadMethod();
Method setter = pd.getWriteMethod();
if (getter != null && setter != null) {
Expression oldGetExp = new Expression(oldInstance, getter.getName(), new Object[]{});
Expression newGetExp = new Expression(newInstance, getter.getName(), new Object[]{});
Object oldValue = oldGetExp.getValue();
Object newValue = newGetExp.getValue();
out.writeExpression(oldGetExp);
! if (!Objects.equals(newValue, out.get(oldValue))) {
// Search for a static constant with this value;
Object e = (Object[])pd.getValue("enumerationValues");
if (e instanceof Object[] && Array.getLength(e) % 3 == 0) {
Object[] a = (Object[])e;
for(int i = 0; i < a.length; i = i + 3) {
*** 231,241 ****
Expression oldGetExp = new Expression(field, "get", new Object[] { oldInstance });
Expression newGetExp = new Expression(field, "get", new Object[] { newInstance });
Object oldValue = oldGetExp.getValue();
Object newValue = newGetExp.getValue();
out.writeExpression(oldGetExp);
! if (!equals(newValue, out.get(oldValue))) {
out.writeStatement(new Statement(field, "set", new Object[] { oldInstance, oldValue }));
}
}
catch (Exception exception) {
out.getExceptionListener().exceptionThrown(exception);
--- 228,238 ----
Expression oldGetExp = new Expression(field, "get", new Object[] { oldInstance });
Expression newGetExp = new Expression(field, "get", new Object[] { newInstance });
Object oldValue = oldGetExp.getValue();
Object newValue = newGetExp.getValue();
out.writeExpression(oldGetExp);
! if (!Objects.equals(newValue, out.get(oldValue))) {
out.writeStatement(new Statement(field, "set", new Object[] { oldInstance, oldValue }));
}
}
catch (Exception exception) {
out.getExceptionListener().exceptionThrown(exception);