harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r554840 - in /harmony/enhanced/classlib/branches/java6/modules: beans/make/ beans/src/main/java/java/beans/ beans/src/main/java/java/beans/beancontext/ beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ beans/src/test/java/org/a...
Date Tue, 10 Jul 2007 06:03:52 GMT
Author: pyang
Date: Mon Jul  9 23:03:50 2007
New Revision: 554840

URL: http://svn.apache.org/viewvc?view=rev&rev=554840
Log:
Merge updates from classlib trunk@554615 since r553714

Modified:
    harmony/enhanced/classlib/branches/java6/modules/beans/make/exclude.common
    harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventHandler.java
    harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java
    harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/VetoableChangeListenerProxy.java
    harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java
    harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/beancontext/BeanContextServiceRevokedEvent.java
    harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java
    harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java
    harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java
    harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/CharArrayReader.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/ProxySelectorImpl.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractSequentialList.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/GregorianCalendar.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/CharArrayReaderTest.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/MulticastSocketTest.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/ProxySelectorTest.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/AbstractSequentialListTest.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/GregorianCalendarTest.java
    harmony/enhanced/classlib/branches/java6/modules/portlib/src/test/native/hytime/shared/hytime.c

Modified: harmony/enhanced/classlib/branches/java6/modules/beans/make/exclude.common
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/make/exclude.common?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/make/exclude.common (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/make/exclude.common Mon Jul  9 23:03:50 2007
@@ -1,5 +1,4 @@
 org/apache/harmony/beans/tests/java/beans/EncoderTest.java
-org/apache/harmony/beans/tests/java/beans/VetoableChangeListenerProxyTest.java
 org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java
 org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
 org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java

Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventHandler.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventHandler.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventHandler.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventHandler.java Mon Jul  9 23:03:50 2007
@@ -37,6 +37,9 @@
 
     public EventHandler(Object target, String action, String eventPropertyName,
             String listenerMethodName) {
+        if(target == null || action  == null){
+            throw new NullPointerException();
+        }
         this.target = target;
         this.action = action;
         this.eventPropertyName = eventPropertyName;
@@ -128,6 +131,9 @@
     @SuppressWarnings("unchecked")
     public static <T> T create(Class<T> listenerInterface, Object target,
             String action, String eventPropertyName, String listenerMethodName) {
+        if(action == null || target == null || listenerInterface == null){
+            throw new NullPointerException();
+        }
         return (T) Proxy.newProxyInstance(target.getClass().getClassLoader(),
                 new Class[] { listenerInterface }, new EventHandler(target,
                         action, eventPropertyName, listenerMethodName));
@@ -136,17 +142,13 @@
     @SuppressWarnings("unchecked")
     public static <T> T create(Class<T> listenerInterface, Object target,
             String action, String eventPropertyName) {
-        return (T) Proxy.newProxyInstance(target.getClass().getClassLoader(),
-                new Class[] { listenerInterface }, new EventHandler(target,
-                        action, eventPropertyName, null));
+        return create(listenerInterface, target, action, eventPropertyName, null);
     }
 
     @SuppressWarnings("unchecked")
     public static <T> T create(Class<T> listenerInterface, Object target,
             String action) {
-        return (T) Proxy.newProxyInstance(target.getClass().getClassLoader(),
-                new Class[] { listenerInterface }, new EventHandler(target,
-                        action, null, null));
+        return create(listenerInterface, target, action, null, null);
     }
 
     private boolean isValidInvocation(Method method, Object[] arguments) {

Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java Mon Jul  9 23:03:50 2007
@@ -26,6 +26,10 @@
     public SimpleBeanInfo() {}
 
     public Image loadImage(String resourceName) {
+        if (null == resourceName) {
+            return null;
+        }
+        
         URL file = getClass().getResource(resourceName);
         
         if (file != null) {

Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/VetoableChangeListenerProxy.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/VetoableChangeListenerProxy.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/VetoableChangeListenerProxy.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/VetoableChangeListenerProxy.java Mon Jul  9 23:03:50 2007
@@ -37,8 +37,6 @@
     public void vetoableChange(PropertyChangeEvent evt)
             throws PropertyVetoException {
         VetoableChangeListener listener = (VetoableChangeListener) getListener();
-        if (listener != null) {
             listener.vetoableChange(evt);
-        }
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java Mon Jul  9 23:03:50 2007
@@ -22,50 +22,39 @@
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Hashtable;
-import java.util.Map.Entry;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
+
+//FIXME: obviously need synchronization, when access listeners
 
 public class VetoableChangeSupport implements Serializable {
 
     private static final long serialVersionUID = -5090210921595982017l;
 
-    private transient List<VetoableChangeListener> allVetoableChangeListeners = new ArrayList<VetoableChangeListener>();
-
-    private transient Map<String, List<VetoableChangeListener>> selectedVetoableChangeListeners = new HashMap<String, List<VetoableChangeListener>>();
-
-    // fields for serialization compatibility
-    private Hashtable<String, VetoableChangeSupport> children;
+    private Hashtable<String, VetoableChangeSupport> children = new Hashtable<String, VetoableChangeSupport>();
     
-    private transient Object sourceBean;
+    private transient ArrayList<VetoableChangeListener> globalListeners = new ArrayList<VetoableChangeListener>();
+    
+    private Object source;
 
-    private int vetoableChangeSupportSerializedDataVersion = 1;
+    private int vetoableChangeSupportSerializedDataVersion = 2;
 
     public VetoableChangeSupport(Object sourceBean) {
         if (sourceBean == null) {
             throw new NullPointerException();
         }
-        this.sourceBean = sourceBean;
-    }
-
-    public void fireVetoableChange(String propertyName, Object oldValue,
-            Object newValue) throws PropertyVetoException {
-        PropertyChangeEvent event = createPropertyChangeEvent(propertyName,
-                oldValue, newValue);
-        doFirePropertyChange(event);
+        this.source = sourceBean;
     }
 
     public synchronized void removeVetoableChangeListener(String propertyName,
             VetoableChangeListener listener) {
         if ((propertyName != null) && (listener != null)) {
-            List<VetoableChangeListener> listeners = selectedVetoableChangeListeners
+            VetoableChangeSupport listeners = children
                     .get(propertyName);
 
             if (listeners != null) {
-                listeners.remove(listener);
+                listeners.removeVetoableChangeListener(listener);
             }
         }
     }
@@ -73,49 +62,35 @@
     public synchronized void addVetoableChangeListener(String propertyName,
             VetoableChangeListener listener) {
         if (propertyName != null && listener != null) {
-            List<VetoableChangeListener> listeners = selectedVetoableChangeListeners
+            VetoableChangeSupport listeners = children
                     .get(propertyName);
 
             if (listeners == null) {
-                listeners = new ArrayList<VetoableChangeListener>();
-                selectedVetoableChangeListeners.put(propertyName, listeners);
+                listeners = new VetoableChangeSupport(source);
+                children.put(propertyName, listeners);
             }
-            listeners.add(listener);
+            listeners.addVetoableChangeListener(listener);
         }
     }
 
     public synchronized VetoableChangeListener[] getVetoableChangeListeners(
             String propertyName) {
-        List<VetoableChangeListener> listeners = null;
+        VetoableChangeSupport listeners = null;
 
         if (propertyName != null) {
-            listeners = selectedVetoableChangeListeners.get(propertyName);
+            listeners = children.get(propertyName);
         }
         return (listeners == null) ? new VetoableChangeListener[] {}
                 : getAsVetoableChangeListenerArray(listeners);
     }
 
-    public void fireVetoableChange(String propertyName, boolean oldValue,
-            boolean newValue) throws PropertyVetoException {
-        PropertyChangeEvent event = createPropertyChangeEvent(propertyName,
-                oldValue, newValue);
-        doFirePropertyChange(event);
-    }
-
-    public void fireVetoableChange(String propertyName, int oldValue,
-            int newValue) throws PropertyVetoException {
-        PropertyChangeEvent event = createPropertyChangeEvent(propertyName,
-                oldValue, newValue);
-        doFirePropertyChange(event);
-    }
-
     public synchronized boolean hasListeners(String propertyName) {
-        boolean result = allVetoableChangeListeners.size() > 0;
+        boolean result = globalListeners.size() > 0;
         if (!result && propertyName != null) {
-            List<VetoableChangeListener> listeners = selectedVetoableChangeListeners
+            VetoableChangeSupport listeners = children
                     .get(propertyName);
             if (listeners != null) {
-                result = listeners.size() > 0;
+                result = listeners.globalListeners.size() > 0;
             }
         }
         return result;
@@ -124,97 +99,96 @@
     public synchronized void removeVetoableChangeListener(
             VetoableChangeListener listener) {
         if (listener != null) {
-            Iterator<VetoableChangeListener> iterator = allVetoableChangeListeners
-                    .iterator();
-            while (iterator.hasNext()) {
-                VetoableChangeListener pcl = iterator.next();
-                if (pcl == listener) {
-                    iterator.remove();
-                    break;
-                }
-            }
+            globalListeners.remove(listener);
         }
     }
 
     public synchronized void addVetoableChangeListener(
             VetoableChangeListener listener) {
-        if (listener != null) {
-            allVetoableChangeListeners.add(listener);
+        if(listener != null){
+            if (listener instanceof VetoableChangeListenerProxy) {
+                VetoableChangeListenerProxy proxy = (VetoableChangeListenerProxy) listener;
+                addVetoableChangeListener(proxy.getPropertyName(),
+                        (VetoableChangeListener) proxy.getListener());
+            } else {
+                globalListeners.add(listener);
+            }
         }
     }
 
     public synchronized VetoableChangeListener[] getVetoableChangeListeners() {
-        List<VetoableChangeListener> result = new ArrayList<VetoableChangeListener>(
-                allVetoableChangeListeners);
-
-        Iterator<String> keysIterator = selectedVetoableChangeListeners
-                .keySet().iterator();
-        while (keysIterator.hasNext()) {
-            String propertyName = keysIterator.next();
+        List<VetoableChangeListener> result = new ArrayList<VetoableChangeListener>();
+        if (globalListeners != null) {
+            result.addAll(globalListeners);
+        }
 
-            List<VetoableChangeListener> selectedListeners = selectedVetoableChangeListeners
+        for (Iterator iterator = children.keySet().iterator(); iterator
+                .hasNext();) {
+            String propertyName = (String) iterator.next();
+            VetoableChangeSupport namedListener = (VetoableChangeSupport) children
                     .get(propertyName);
-            if (selectedListeners != null) {
-                for (VetoableChangeListener listener : selectedListeners) {
-                    result.add(new VetoableChangeListenerProxy(propertyName,
-                            listener));
-                }
+            VetoableChangeListener[] childListeners = namedListener
+                    .getVetoableChangeListeners();
+            for (int i = 0; i < childListeners.length; i++) {
+                result.add(new VetoableChangeListenerProxy(propertyName,
+                        childListeners[i]));
             }
         }
-        return getAsVetoableChangeListenerArray(result);
+        return (VetoableChangeListener[]) (result
+                .toArray(new VetoableChangeListener[result.size()]));
     }
 
     private void writeObject(ObjectOutputStream oos) throws IOException {
-        children = new Hashtable<String, VetoableChangeSupport>();
-        for (Entry<String, List<VetoableChangeListener>> entry : selectedVetoableChangeListeners
-                .entrySet()) {
-            List<VetoableChangeListener> list = entry.getValue();
-            VetoableChangeSupport vetoableChangeSupport = new VetoableChangeSupport(
-                    sourceBean);
-            for (VetoableChangeListener vetoableChangeListener : list) {
-                if (vetoableChangeListener instanceof Serializable) {
-                    vetoableChangeSupport
-                            .addVetoableChangeListener(vetoableChangeListener);
-                }
-            }
-            children.put(entry.getKey(), vetoableChangeSupport);
-        }
         oos.defaultWriteObject();
-
-        for (VetoableChangeListener vetoableChangeListener : allVetoableChangeListeners) {
-            if (vetoableChangeListener instanceof Serializable) {
-                oos.writeObject(vetoableChangeListener);
+        VetoableChangeListener[] copy = new VetoableChangeListener[globalListeners.size()];
+        globalListeners.toArray(copy);
+        for (VetoableChangeListener listener : copy) {
+            if (listener instanceof Serializable) {
+                oos.writeObject(listener);
             }
         }
+        // Denotes end of list
         oos.writeObject(null);
+
     }
 
     
     private void readObject(ObjectInputStream ois) throws IOException,
             ClassNotFoundException {
         ois.defaultReadObject();
-        selectedVetoableChangeListeners = new HashMap<String, List<VetoableChangeListener>>();
-        if (children != null) {
-            for (Entry<String, VetoableChangeSupport> entry : children
-                    .entrySet()) {
-                List<VetoableChangeListener> list = new ArrayList<VetoableChangeListener>();
-                for (VetoableChangeListener vetoableChangeListener : entry
-                        .getValue().allVetoableChangeListeners) {
-                    list.add(vetoableChangeListener);
-                }
-                selectedVetoableChangeListeners.put(entry.getKey(), list);
-            }
-
-        }
-        allVetoableChangeListeners = new ArrayList<VetoableChangeListener>();
-
-        VetoableChangeListener vetoableChangeListener;
-        while (null != (vetoableChangeListener = (VetoableChangeListener) ois
-                .readObject())) {
-            allVetoableChangeListeners.add(vetoableChangeListener);
-        }
+        this.globalListeners = new ArrayList<VetoableChangeListener>();
+        if (null == this.children) {
+            this.children = new Hashtable<String, VetoableChangeSupport>();
+        }
+        Object listener;
+        do {
+            // Reads a listener _or_ proxy
+            listener = ois.readObject();
+            addVetoableChangeListener((VetoableChangeListener) listener);
+        } while (listener != null);
+    }
+    
+    public void fireVetoableChange(String propertyName, boolean oldValue,
+            boolean newValue) throws PropertyVetoException {
+        PropertyChangeEvent event = createPropertyChangeEvent(propertyName,
+                oldValue, newValue);
+        doFirePropertyChange(event);
     }
 
+    public void fireVetoableChange(String propertyName, int oldValue,
+            int newValue) throws PropertyVetoException {
+        PropertyChangeEvent event = createPropertyChangeEvent(propertyName,
+                oldValue, newValue);
+        doFirePropertyChange(event);
+    }
+    
+    public void fireVetoableChange(String propertyName, Object oldValue,
+            Object newValue) throws PropertyVetoException {
+        PropertyChangeEvent event = createPropertyChangeEvent(propertyName,
+                oldValue, newValue);
+        doFirePropertyChange(event);
+    }
+    
     public void fireVetoableChange(PropertyChangeEvent event)
             throws PropertyVetoException {
         doFirePropertyChange(event);
@@ -222,22 +196,10 @@
 
     private PropertyChangeEvent createPropertyChangeEvent(String propertyName,
             Object oldValue, Object newValue) {
-        return new PropertyChangeEvent(sourceBean, propertyName, oldValue,
+        return new PropertyChangeEvent(source, propertyName, oldValue,
                 newValue);
     }
 
-    private PropertyChangeEvent createPropertyChangeEvent(String propertyName,
-            boolean oldValue, boolean newValue) {
-        return new PropertyChangeEvent(sourceBean, propertyName, new Boolean(
-                oldValue), new Boolean(newValue));
-    }
-
-    private PropertyChangeEvent createPropertyChangeEvent(String propertyName,
-            int oldValue, int newValue) {
-        return new PropertyChangeEvent(sourceBean, propertyName, new Integer(
-                oldValue), new Integer(newValue));
-    }
-
     private void doFirePropertyChange(PropertyChangeEvent event)
             throws PropertyVetoException {
         String propName = event.getPropertyName();
@@ -250,20 +212,15 @@
 
         /* Take note of who we are going to notify (and potentially un-notify) */
 
-        VetoableChangeListener[] listensToAll; // Listeners to all property
-        // change events
-        VetoableChangeListener[] listensToOne = null; // Listens to a given
+        VetoableChangeListener[] listensToAll;
+        VetoableChangeSupport listeners = null;
         // property change
         synchronized (this) {
-            listensToAll = allVetoableChangeListeners
-                    .toArray(new VetoableChangeListener[allVetoableChangeListeners
-                            .size()]);
-
-            List<VetoableChangeListener> listeners = selectedVetoableChangeListeners
-                    .get(event.getPropertyName());
-            if (listeners != null) {
-                listensToOne = listeners
-                        .toArray(new VetoableChangeListener[listeners.size()]);
+            listensToAll = globalListeners
+                    .toArray(new VetoableChangeListener[0]);
+            String propertyName = event.getPropertyName();
+            if(propertyName != null){
+                listeners = children.get(propertyName);
             }
         }
 
@@ -271,11 +228,6 @@
             for (VetoableChangeListener listener : listensToAll) {
                 listener.vetoableChange(event);
             }
-            if (listensToOne != null) {
-                for (VetoableChangeListener listener : listensToOne) {
-                    listener.vetoableChange(event);
-                }
-            }
         } catch (PropertyVetoException pve) {
             // Tell them we have changed it back
             PropertyChangeEvent revertEvent = createPropertyChangeEvent(
@@ -286,27 +238,15 @@
                 } catch (PropertyVetoException ignored) {
                 }
             }
-            if (listensToOne != null) {
-                for (VetoableChangeListener listener : listensToOne) {
-                    try {
-                        listener.vetoableChange(revertEvent);
-                    } catch (PropertyVetoException ignored) {
-                    }
-                }
-            }
             throw pve;
         }
+        if(listeners != null){
+            listeners.fireVetoableChange(event);
+        }
     }
 
     private static VetoableChangeListener[] getAsVetoableChangeListenerArray(
-            List<VetoableChangeListener> listeners) {
-        Object[] objects = listeners.toArray();
-        VetoableChangeListener[] arrayResult = new VetoableChangeListener[objects.length];
-
-        for (int i = 0; i < objects.length; ++i) {
-            arrayResult[i] = (VetoableChangeListener) objects[i];
-        }
-
-        return arrayResult;
+            VetoableChangeSupport listeners) {
+        return listeners.globalListeners.toArray(new VetoableChangeListener[0]);
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/beancontext/BeanContextServiceRevokedEvent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/beancontext/BeanContextServiceRevokedEvent.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/beancontext/BeanContextServiceRevokedEvent.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/beancontext/BeanContextServiceRevokedEvent.java Mon Jul  9 23:03:50 2007
@@ -36,8 +36,7 @@
 
         super(bcs);
         this.serviceClass = sc;
-        this.invalidateRefs = invalidate;
-        setPropagatedFrom(bcs);
+        this.invalidateRefs = invalidate;        
     }
 
     public Class getServiceClass() {
@@ -45,7 +44,7 @@
     }
 
     public BeanContextServices getSourceAsBeanContextServices() {
-        return (BeanContextServices) super.propagatedFrom;
+        return (BeanContextServices) super.getBeanContext();
     }
 
     public boolean isCurrentServiceInvalidNow() {

Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java Mon Jul  9 23:03:50 2007
@@ -122,7 +122,7 @@
 
         Method m = SampleListener.class.getMethod("fireSampleEvent",
                 new Class[] { SampleEvent.class });
-        handler.invoke(proxy, m, new Object[] {new SampleEvent("")});
+        handler.invoke(proxy, m, new Object[] { new SampleEvent("") });
 
         assertEquals(invocationObject, handler.getTarget());
         assertEquals("doSomething", getMethodName());
@@ -225,10 +225,11 @@
      * 
      */
     public static Test suite() {
-//        TestSuite suite = new TestSuite();
-//
-//        suite.addTest(new EventHandlerTest("testCreateClassObjectStringStringString_PropertyNull"));
-//        return suite;
+        // TestSuite suite = new TestSuite();
+        //
+        // suite.addTest(new
+        // EventHandlerTest("testCreateClassObjectStringStringString_PropertyNull"));
+        // return suite;
         return new TestSuite(EventHandlerTest.class);
     }
 
@@ -317,13 +318,19 @@
     public void testCreateClassObjectString_MethodNull() {
         MockTarget target = new MockTarget();
         MockButton button = new MockButton();
+        try {
+            PropertyChangeListener proxy = EventHandler.create(
+                    PropertyChangeListener.class, target, null);
+            fail("Should throw NullPointerException.");
+        } catch (NullPointerException e) {
+        }
         PropertyChangeListener proxy = EventHandler.create(
-                PropertyChangeListener.class, target, null);
+                PropertyChangeListener.class, target, "");
         button.addPropertyChangeListener(proxy);
         try {
             button.setLabel("new label value");
-            fail("Should throw NullPointerException.");
-        } catch (NullPointerException e) {
+            fail("Should throw RuntimeException.");
+        } catch (RuntimeException e) {
         }
         assertTrue(Proxy.isProxyClass(proxy.getClass()));
     }
@@ -339,8 +346,8 @@
         button.addPropertyChangeListener(proxy);
         try {
             button.setLabel("new label value");
-            fail("Should throw IndexOutOfBoundsException.");
-        } catch (IndexOutOfBoundsException e) {
+            fail("Should throw RuntimeException.");
+        } catch (RuntimeException e) {
         }
         assertTrue(Proxy.isProxyClass(proxy.getClass()));
     }
@@ -393,17 +400,13 @@
     public void testCreateClassObjectStringString_ActionNull() {
         MockTarget target = new MockTarget();
         MockButton button = new MockButton();
-        PropertyChangeListener proxy = EventHandler.create(
-                PropertyChangeListener.class, target, null, "source.label");
-        assertTrue(Proxy.isProxyClass(proxy.getClass()));
-
-        button.addPropertyChangeListener(proxy);
-        String newLabel = "New Value: set text.";
         try {
-            button.setLabel(newLabel);
-            fail("Should throw NullPointerException.");
+            PropertyChangeListener proxy = EventHandler.create(
+                    PropertyChangeListener.class, target, null, "source.label");
+            fail("should throw NPE");
         } catch (NullPointerException e) {
-        }
+
+        }    
     }
 
     /*
@@ -506,8 +509,8 @@
     public void testCreateClassObjectStringStringString_ClassInvalid() {
         MockTarget target = new MockTarget();
         try {
-            EventHandler.create(String.class, target, "text",
-                    "source.label", "propertyChange");
+            EventHandler.create(String.class, target, "text", "source.label",
+                    "propertyChange");
             fail("Should throw IllegalArgumentException.");
         } catch (IllegalArgumentException e) {
         }
@@ -531,18 +534,14 @@
     public void testCreateClassObjectStringStringString_ActionNull() {
         MockTarget target = new MockTarget();
         MockButton button = new MockButton();
-        PropertyChangeListener proxy = EventHandler.create(
-                PropertyChangeListener.class, target, null, "source.label",
-                "propertyChange");
-        assertTrue(Proxy.isProxyClass(proxy.getClass()));
-
-        button.addPropertyChangeListener(proxy);
-        String newLabel = "New Value: set text.";
         try {
-            button.setLabel(newLabel);
-            fail("Should throw NullPointerException.");
+            PropertyChangeListener proxy = EventHandler.create(
+                    PropertyChangeListener.class, target, null, "source.label",
+                    "propertyChange");
+            fail("should throw NPE");
         } catch (NullPointerException e) {
-        }
+
+        }        
     }
 
     /*
@@ -666,12 +665,13 @@
         String action = "text";
         String eventPropertyName = "source.label";
         String listenerMethodName = "propertyChange";
-        EventHandler handler = new EventHandler(null, action,
-                eventPropertyName, listenerMethodName);
-        assertNull(handler.getTarget());
-        assertSame(action, handler.getAction());
-        assertSame(eventPropertyName, handler.getEventPropertyName());
-        assertSame(listenerMethodName, handler.getListenerMethodName());
+        try {
+            EventHandler handler = new EventHandler(null, action,
+                    eventPropertyName, listenerMethodName);
+            fail("should throw NPE");
+        } catch (NullPointerException e) {
+
+        }
     }
 
     /*
@@ -681,10 +681,17 @@
         MockTarget target = new MockTarget();
         String eventPropertyName = "source.label";
         String listenerMethodName = "propertyChange";
-        EventHandler handler = new EventHandler(target, null,
+        try {
+            EventHandler handler = new EventHandler(target, null,
+                    eventPropertyName, listenerMethodName);
+            fail("should throw NPE");
+        } catch (NullPointerException e) {
+
+        }
+        EventHandler handler = new EventHandler(target, "action",
                 eventPropertyName, listenerMethodName);
         assertSame(target, handler.getTarget());
-        assertNull(handler.getAction());
+        assertEquals("action", handler.getAction());
         assertSame(eventPropertyName, handler.getEventPropertyName());
         assertSame(listenerMethodName, handler.getListenerMethodName());
     }
@@ -863,7 +870,7 @@
         PropertyChangeSupport support = new PropertyChangeSupport(fish);
         Object proxy = EventHandler.create(PropertyChangeListener.class,
                 target, "a", "source.booleanObject");
-        
+
         support.addPropertyChangeListener((PropertyChangeListener) proxy);
         PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
                 "5");
@@ -972,54 +979,58 @@
                 .fireFredEvent(new FredEvent("bean2"));
     }
 
-    
     /**
-     * Checks some invalid property cases
-     * Regression for HARMONY-1884 
+     * Checks some invalid property cases Regression for HARMONY-1884
+     * 
+     * Note: this test fails on RI and it is considered as Non-Bug Difference, 
+     * please refer HARMONY-1884 for details
      */
     public void testInvalidProperties_HY1884() {
-        BeanWithInvalidProps bean = new BeanWithInvalidProps(); 
-        Object proxy;  
+        BeanWithInvalidProps bean = new BeanWithInvalidProps();
+        Object proxy;
+
+        // "prop1" and "prop2" is neither the name of valid property nor the
+        // name of any public method
 
-        // "prop1" and "prop2" is neither the name of valid property nor the 
-        // name of any public method 
-        
         // setter without parameter
-        proxy = EventHandler.create( 
-                PropertyChangeListener.class, bean, "prop1");
-        try { 
-            ((PropertyChangeListener) proxy).propertyChange( 
-                    new PropertyChangeEvent(bean, "prop1", "1", "2")); 
-            //fail(); 
-        } catch (Exception e) { 
-            // expected 
-        } 
+        proxy = EventHandler
+                .create(PropertyChangeListener.class, bean, "prop1");
+        try {
+            ((PropertyChangeListener) proxy)
+                    .propertyChange(new PropertyChangeEvent(bean, "prop1", "1",
+                            "2"));
+             fail();
+        } catch (Exception e) {
+            // expected
+        }
 
         // "is" prefix for big Boolean
-        proxy = EventHandler.create( 
-                PropertyChangeListener.class, bean, "goodProp3", "source.prop2");
-        try { 
-            ((PropertyChangeListener) proxy).propertyChange( 
-                    new PropertyChangeEvent(bean, "goodProp3", Boolean.TRUE, Boolean.FALSE)); 
-            fail(); 
-        } catch (Exception e) { 
-            // expected 
-        } 
+        proxy = EventHandler.create(PropertyChangeListener.class, bean,
+                "goodProp3", "source.prop2");
+        try{
+            ((PropertyChangeListener) proxy)
+                    .propertyChange(new PropertyChangeEvent(bean, "goodProp3",
+                            Boolean.TRUE, Boolean.FALSE));
+            fail("Should throw NPE");
+        }catch(NullPointerException e){
+        }
     }
-    
+
     public static class BeanWithInvalidProps {
         // setter should have a parameter
-        public void setProp1() {}
-        
-        // Introspector doesn't support "is" prefix for big Boolean 
+        public void setProp1() {
+        }
+
+        // Introspector doesn't support "is" prefix for big Boolean
         public Boolean isProp2() {
             return new Boolean(true);
         }
 
         // needed to test prop2
-        public void setGoodProp3(boolean value) {}
+        public void setGoodProp3(boolean value) {
+        }
     }
-    
+
     public interface FredListener extends EventListener {
 
         public void fireFredEvent(FredEvent event);

Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java Mon Jul  9 23:03:50 2007
@@ -91,6 +91,10 @@
         info = new SimpleBeanInfo() {};
         image = info.loadImage("testB.jpg");
         assertNotNull(image);
+        
+        info = new SimpleBeanInfo();
+        image = info.loadImage(null);
+        assertNull(image);
     }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java Mon Jul  9 23:03:50 2007
@@ -29,6 +29,7 @@
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
 import java.io.Serializable;
 import java.util.ArrayList;
 
@@ -105,15 +106,11 @@
         VetoableChangeListener[] listeners2 = support
                 .getVetoableChangeListeners(propertyName);
 
-        assertTrue(support.hasListeners(propertyName));
+        assertFalse(support.hasListeners(propertyName));
         assertFalse(support.hasListeners("text"));
 
-        assertEquals(1, listeners1.length);
-        assertEquals(propertyName,
-                ((VetoableChangeListenerProxy) listeners1[0]).getPropertyName());
-        assertNull(((VetoableChangeListenerProxy) listeners1[0]).getListener());
-        assertEquals(1, listeners2.length);
-        assertNull(listeners2[0]);
+        assertEquals(0, listeners1.length);
+        assertEquals(0, listeners2.length);
     }
 
     /*
@@ -182,11 +179,7 @@
         VetoableChangeListener proxy = EventHandler.create(
                 VetoableChangeListener.class, source, "setText");
         String propertyName = null;
-        try {
             support.addVetoableChangeListener(propertyName, proxy);
-            fail("Should throw NullPointerException.");
-        } catch (NullPointerException e) {
-        }
     }
 
     /*
@@ -288,8 +281,8 @@
         VetoableChangeSupport support = new VetoableChangeSupport(source);
         support.addVetoableChangeListener(null);
 
-        assertTrue(support.hasListeners("label"));
-        assertTrue(support.hasListeners("text"));
+        assertFalse(support.hasListeners("label"));
+        assertFalse(support.hasListeners("text"));
 
         VetoableChangeListener[] listeners1 = support
                 .getVetoableChangeListeners();
@@ -298,11 +291,9 @@
         VetoableChangeListener[] listeners3 = support
                 .getVetoableChangeListeners("text");
 
-        assertEquals(1, listeners1.length);
+        assertEquals(0, listeners1.length);
         assertEquals(0, listeners2.length);
         assertEquals(0, listeners3.length);
-
-        assertNull(listeners1[0]);
     }
 
     /*
@@ -382,11 +373,18 @@
 
         VetoableChangeListenerProxy listenerProxy = new VetoableChangeListenerProxy(
                 propertyName, proxy);
-
-        support.addVetoableChangeListener(listenerProxy);
-
+        assertFalse(support.hasListeners("label"));
+        try{
+            support.addVetoableChangeListener(listenerProxy);
+            fail("should throw NPE");
+        }catch(NullPointerException e){
+            //expected
+            e.printStackTrace();
+        }
+        assertTrue(support.hasListeners("label"));
         assertTrue(support.hasListeners(propertyName));
         assertFalse(support.hasListeners("text"));
+        
         {
             VetoableChangeListener[] listeners1 = support
                     .getVetoableChangeListeners();
@@ -602,12 +600,7 @@
         support.addVetoableChangeListener(null);
         PropertyChangeEvent event = new PropertyChangeEvent(source, "label",
                 "Label: old", "Label: new");
-        try {
             support.fireVetoableChange(event);
-            fail("Should throw NullPointerException.");
-        } catch (NullPointerException e) {
-            // expected
-        }
     }
 
     /*
@@ -635,12 +628,7 @@
         VetoableChangeSupport support = new VetoableChangeSupport(source);
 
         support.addVetoableChangeListener(null);
-        try {
             support.fireVetoableChange("label", true, false);
-            fail("Should throw NullPointerException.");
-        } catch (NullPointerException e) {
-            // expected
-        }
     }
 
     /*
@@ -669,12 +657,7 @@
 
         EventHandler.create(VetoableChangeListener.class, source, "setText");
         support.addVetoableChangeListener("label", null);
-        try {
             support.fireVetoableChange("label", true, false);
-            fail("Should throw NullPointerException.");
-        } catch (NullPointerException e) {
-            // expected
-        }
     }
 
     /*
@@ -1282,14 +1265,13 @@
         String propertyName = "label";
         support.addVetoableChangeListener(propertyName, null);
 
-        assertTrue(support.hasListeners(propertyName));
-        assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
+        assertFalse(support.hasListeners(propertyName));
+        assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
 
         support.removeVetoableChangeListener(propertyName, proxy);
-        assertTrue(support.hasListeners(propertyName));
-        assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
-        assertEquals(1, support.getVetoableChangeListeners().length);
-        assertNull(support.getVetoableChangeListeners(propertyName)[0]);
+        assertFalse(support.hasListeners(propertyName));
+        assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
+        assertEquals(0, support.getVetoableChangeListeners().length);
     }
 
     /*
@@ -1325,12 +1307,7 @@
         String propertyName = "label";
         support.addVetoableChangeListener(propertyName, proxy);
         assertTrue(support.hasListeners(propertyName));
-        try {
             support.removeVetoableChangeListener(null, proxy);
-            fail("Should throw NullPointerException.");
-        } catch (NullPointerException e) {
-            // expected
-        }
     }
 
     /*
@@ -1381,7 +1358,7 @@
 
         String propertyName = "label";
         support.addVetoableChangeListener(propertyName, null);
-        assertTrue(support.hasListeners(propertyName));
+        assertFalse(support.hasListeners(propertyName));
 
         support.removeVetoableChangeListener(propertyName, null);
         assertFalse(support.hasListeners(propertyName));
@@ -1476,14 +1453,14 @@
         String propertyName = "label";
         support.addVetoableChangeListener(null);
 
-        assertTrue(support.hasListeners(propertyName));
-        assertEquals(1, support.getVetoableChangeListeners().length);
+        assertFalse(support.hasListeners(propertyName));
+        assertEquals(0, support.getVetoableChangeListeners().length);
 
         support.removeVetoableChangeListener(proxy);
 
-        assertTrue(support.hasListeners(propertyName));
+        assertFalse(support.hasListeners(propertyName));
         assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
-        assertEquals(1, support.getVetoableChangeListeners().length);
+        assertEquals(0, support.getVetoableChangeListeners().length);
     }
 
     /*
@@ -1544,8 +1521,8 @@
         String propertyName = "label";
         support.addVetoableChangeListener(null);
 
-        assertTrue(support.hasListeners(propertyName));
-        assertEquals(1, support.getVetoableChangeListeners().length);
+        assertFalse(support.hasListeners(propertyName));
+        assertEquals(0, support.getVetoableChangeListeners().length);
 
         support.removeVetoableChangeListener(null);
 
@@ -1632,7 +1609,6 @@
 
     }
 
-
      public void testSerialization_Compatibility() throws Exception {
          MockSource source = new MockSource();
          VetoableChangeSupport support = new VetoableChangeSupport(source);
@@ -1936,5 +1912,11 @@
         assertEquals(vcl, ((VetoableChangeListenerProxy) vcls[0]).getListener());
         assertEquals("property1", ((VetoableChangeListenerProxy) vcls[0])
                 .getPropertyName());
+    }
+    
+    
+    public void testSerializationForm(){
+        ObjectStreamClass objectStreamClass = ObjectStreamClass.lookup(VetoableChangeSupport.class);
+        assertNotNull(objectStreamClass.getField("source"));
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java Mon Jul  9 23:03:50 2007
@@ -161,6 +161,7 @@
         assertEqualsSerially(event,
                 (BeanContextServiceRevokedEvent) SerializationTester
                         .getDeserilizedObject(event));
+
     }
 
      public void testSerialization_Compatibility() throws Exception {
@@ -174,6 +175,19 @@
              }
          });
      }
+     
+     public void testConstructor() throws Exception {
+        BeanContextServices bcs = new MockBeanContextServices();
+        BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent(
+                bcs, ArrayList.class, true);
+        assertEquals(null, event.getPropagatedFrom());
+        assertEquals(ArrayList.class, event.getServiceClass());
+        assertSame(bcs, event.getSource());
+        assertSame(bcs, event.getBeanContext());
+        assertSame(bcs, event.getSourceAsBeanContextServices());
+        assertFalse(event.isPropagated());
+    }
+     
     private void assertEqualsSerially(BeanContextServiceRevokedEvent orig,
             BeanContextServiceRevokedEvent ser) {
         assertNull(ser.getSource());

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/CharArrayReader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/CharArrayReader.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/CharArrayReader.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/CharArrayReader.java Mon Jul  9 23:03:50 2007
@@ -79,6 +79,7 @@
         }
         this.buf = buf;
         this.pos = offset;
+        this.markedPos = offset;
 
         /* This is according to spec */
         this.count = this.pos + length < buf.length ? length : buf.length;

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/ProxySelectorImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/ProxySelectorImpl.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/ProxySelectorImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/ProxySelectorImpl.java Mon Jul  9 23:03:50 2007
@@ -236,7 +236,7 @@
      */
     private boolean isNonProxyHost(String host, String nonProxyHosts) {
         // nonProxyHosts is not set
-        if (null == nonProxyHosts) {
+        if (null == host || null == nonProxyHosts) {
             return false;
         }
         // Construct regex expression of nonProxyHosts

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractSequentialList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractSequentialList.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractSequentialList.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractSequentialList.java Mon Jul  9 23:03:50 2007
@@ -188,6 +188,9 @@
 	@Override
     public E set(int location, E object) {
 		ListIterator<E> it = listIterator(location);
+		if (!it.hasNext()){
+			throw new IndexOutOfBoundsException();
+		}
 		E result = it.next();
 		it.set(object);
 		return result;

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/GregorianCalendar.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/GregorianCalendar.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/GregorianCalendar.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/GregorianCalendar.java Mon Jul  9 23:03:50 2007
@@ -1152,7 +1152,7 @@
                 int newWeek = mod(fields[field] - 1 + value, maxWeeks) + 1;
                 if (newWeek == maxWeeks) {
                     if (fields[day] + (newWeek - fields[field]) * 7 > days) {
-                        set(day, days);
+                        set(field, 1);
                     } else {
                         set(field, newWeek);
                     }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java Mon Jul  9 23:03:50 2007
@@ -21,7 +21,6 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
-import java.math.BigInteger;
 
 /**
  * HashMap is an implementation of Map. All optional operations are supported,
@@ -192,7 +191,7 @@
                     entry = associatedMap.findNullKeyEntry();
                 } else {
                     int hash = key.hashCode();
-                    int index = (hash & 0x7FFFFFFF) % associatedMap.elementData.length;
+                    int index = hash & (associatedMap.elementData.length - 1);
                     entry = associatedMap.findNonNullKeyEntry(key, index, hash);
                 }
                 return object.equals(entry);
@@ -241,14 +240,31 @@
      */
     public HashMap(int capacity) {
         if (capacity >= 0) {
+            capacity = caculateCapacity(capacity);
             elementCount = 0;
-            elementData = newElementArray(capacity == 0 ? 1 : capacity);
+            elementData = newElementArray(capacity);
             loadFactor = 0.75f; // Default load factor of 0.75
             computeMaxSize();
         } else {
             throw new IllegalArgumentException();
         }
     }
+    
+    private static final int caculateCapacity(int x) {
+        if(x >= 1 << 30){
+            return 1 << 30;
+        }
+        if(x == 0){
+            return 16;
+        }
+        x = x -1;
+        x |= x >> 1;
+        x |= x >> 2;
+        x |= x >> 4;
+        x |= x >> 8;
+        x |= x >> 16;
+        return x + 1;
+    }
 
     /**
      * Constructs a new instance of HashMap with the specified capacity and load
@@ -346,7 +362,7 @@
             m = findNullKeyEntry();
         } else {
             int hash = key.hashCode();
-            int index = (hash & 0x7FFFFFFF) % elementData.length;
+            int index = hash & (elementData.length - 1);
             m = findNonNullKeyEntry(key, index, hash);
         }
         return m != null;
@@ -412,7 +428,7 @@
             m = findNullKeyEntry();
         } else {
             int hash = key.hashCode();
-            int index = (hash & 0x7FFFFFFF) % elementData.length;
+            int index = hash & (elementData.length - 1);
             m = findNonNullKeyEntry(key, index, hash);
         }
         if (m != null) {
@@ -522,13 +538,13 @@
             }
         } else {
             int hash = key.hashCode();
-            int index = (hash & 0x7FFFFFFF) % elementData.length;
+            int index = hash & (elementData.length - 1);
             entry = findNonNullKeyEntry(key, index, hash);
             if (entry == null) {
                 modCount++;
                 if (++elementCount > threshold) {
                     rehash();
-                    index = (hash & 0x7FFFFFFF) % elementData.length;
+                    index = hash & (elementData.length - 1);
                 }
                 entry = createHashedEntry(key, index, hash);
             }
@@ -580,27 +596,14 @@
         }
     }
 
-    private static final int PRIMES[] = { 7, 37, 79, 163, 331, 673, 1361, 2729,
-            5471, 10949, 21911, 43853, 87719, 175447, 350899, 701819 };
-
-    private int nextLength(int capacity) {
-        int nextNumber = capacity << 1;
-        for (int i = 0; i < PRIMES.length; i++) {
-            if (nextNumber < PRIMES[i]) {
-                return PRIMES[i];
-            }
-        }
-        // This could overflow an int, but in practice never will.
-        return BigInteger.valueOf(nextNumber).nextProbablePrime().intValue();
-    }
-
     void rehash(int capacity) {
-        int length = nextLength(capacity);
+        int length = caculateCapacity((capacity == 0 ? 1 : capacity << 1));
+
         Entry<K, V>[] newData = newElementArray(length);
         for (int i = 0; i < elementData.length; i++) {
             Entry<K, V> entry = elementData[i];
             while (entry != null) {
-                int index = (entry.origKeyHash & 0x7FFFFFFF) % length;
+                int index = entry.origKeyHash & (length - 1);
                 Entry<K, V> next = entry.next;
                 entry.next = newData[index];
                 newData[index] = entry;
@@ -638,7 +641,7 @@
         Entry<K, V> last = null;
         if (key != null) {
             int hash = key.hashCode();
-            index = (hash & 0x7FFFFFFF) % elementData.length;
+            index = hash & (elementData.length - 1);
             entry = elementData[index];
             while (entry != null && !(entry.origKeyHash == hash && key.equals(entry.key))) {
                 last = entry;
@@ -736,8 +739,7 @@
         elementCount = stream.readInt();
         for (int i = elementCount; --i >= 0;) {
             K key = (K) stream.readObject();
-            int index = (null == key) ? 0 : (key.hashCode() & 0x7FFFFFFF)
-                    % length;
+            int index = (null == key) ? 0 : (key.hashCode() & (length - 1));
             createEntry(key, index, (V) stream.readObject());
         }
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/CharArrayReaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/CharArrayReaderTest.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/CharArrayReaderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/CharArrayReaderTest.java Mon Jul  9 23:03:50 2007
@@ -162,9 +162,10 @@
 	}
 
 	/**
+	 * @throws IOException 
 	 * @tests java.io.CharArrayReader#reset()
 	 */
-	public void test_reset() {
+	public void test_reset() throws IOException {
 		// Test for method void java.io.CharArrayReader.reset()
 		try {
 			cr = new CharArrayReader(hw);
@@ -177,7 +178,20 @@
 		} catch (IOException e) {
 			fail("Exception during reset test : " + e.getMessage());
 		}
-	}
+        
+        // Regression for HARMONY-4357
+        String str = "offsetHello world!";
+        char[] data = new char[str.length()];
+        str.getChars(0, str.length(), data, 0);
+        int offsetLength = 6;
+        int length = data.length - offsetLength;
+
+        CharArrayReader reader = new CharArrayReader(data, offsetLength, length);
+        reader.reset();
+        System.out.print("\nAfter reset(): ");
+        for (int i = 0; i < length; i++)
+            assertEquals(data[offsetLength + i], (char) reader.read());
+    }
 
 	/**
 	 * @tests java.io.CharArrayReader#skip(long)

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/MulticastSocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/MulticastSocketTest.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/MulticastSocketTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/MulticastSocketTest.java Mon Jul  9 23:03:50 2007
@@ -878,17 +878,6 @@
                         assertTrue(
                                 "Group member did not recv data when send on a specific interface: ",
                                 receivedMessage.equals(msg));
-                        assertTrue(
-                                "Datagram was not received from expected interface expected["
-                                        + thisInterface
-                                        + "] got ["
-                                        + NetworkInterface
-                                                .getByInetAddress(server.rdp
-                                                        .getAddress()) + "]",
-                                NetworkInterface.getByInetAddress(
-                                        server.rdp.getAddress()).equals(
-                                        thisInterface));
-
                         // stop the server
                         server.stopServer();
                     }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/ProxySelectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/ProxySelectorTest.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/ProxySelectorTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/ProxySelectorTest.java Mon Jul  9 23:03:50 2007
@@ -200,7 +200,7 @@
         // no proxy, return a proxyList only contains NO_PROXY
         proxyList = selector.select(httpUri);
         assertProxyEquals(proxyList, Proxy.NO_PROXY);
-
+        
         // set http proxy
         System.setProperty("http.proxyHost", HTTP_PROXY_HOST);
         System.setProperty("http.proxyPort", String.valueOf(HTTP_PROXY_PORT));
@@ -230,6 +230,26 @@
         assertProxyEquals(proxyList, Proxy.Type.SOCKS, SOCKS_PROXY_HOST,
                 SOCKS_PROXY_PORT);
 
+    }
+    
+    //Regression for HARMONY-4281
+    public void test_selectLjava_net_URI_SelectExact_NullHost_withNoProxyHostsProperty(){
+        System.setProperty("http.nonProxyHosts", "localhost|127.0.0.1");
+        System.setProperty("http.proxyHost", HTTP_PROXY_HOST);
+        System.setProperty("http.proxyPort", String.valueOf(HTTP_PROXY_PORT));
+        // set https proxy
+        System.setProperty("https.proxyHost", HTTPS_PROXY_HOST);
+        System.setProperty("https.proxyPort", String.valueOf(HTTPS_PROXY_PORT));
+        // set ftp proxy
+        System.setProperty("ftp.proxyHost", FTP_PROXY_HOST);
+        System.setProperty("ftp.proxyPort", String.valueOf(FTP_PROXY_PORT));
+        // set socks proxy
+        System.setProperty("socksProxyHost", SOCKS_PROXY_HOST);
+        System.setProperty("socksProxyPort", String.valueOf(SOCKS_PROXY_PORT));
+
+        proxyList = selector.select(httpUri);
+        assertProxyEquals(proxyList, Proxy.Type.HTTP, HTTP_PROXY_HOST,
+                HTTP_PROXY_PORT);
     }
 
 	/**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/AbstractSequentialListTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/AbstractSequentialListTest.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/AbstractSequentialListTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/AbstractSequentialListTest.java Mon Jul  9 23:03:50 2007
@@ -1,68 +1,95 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package tests.api.java.util;
-
-import java.util.AbstractSequentialList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import junit.framework.TestCase;
-
-public class AbstractSequentialListTest extends TestCase {
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-    
-    class ASLT<E> extends AbstractSequentialList<E> {
-
-        LinkedList<E> l = new LinkedList<E>();
-
-        @Override
-        public ListIterator<E> listIterator(int index) {
-            return l.listIterator(index);
-        }
-
-        @Override
-        public int size() {
-            return l.size();
-        }
-    }
-    
-    /**
-     * @tests {@link java.util.AbstractSequentialList#addAll(int, java.util.Collection)}
-     */
-    public void test_addAll_ILCollection() {
-        AbstractSequentialList<String> al = new ASLT<String>();
-        String[] someList = { "Aardvark",  //$NON-NLS-1$
-                "Bear",  //$NON-NLS-1$
-                "Chimpanzee",  //$NON-NLS-1$
-                "Duck" }; //$NON-NLS-1$
-        Collection<String> c = Arrays.asList(someList);
-        al.addAll(c);
-        assertTrue("Should return true", al.addAll(2, c)); //$NON-NLS-1$
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package tests.api.java.util;
+
+import java.util.AbstractSequentialList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import junit.framework.TestCase;
+
+public class AbstractSequentialListTest extends TestCase {
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+    
+    class ASLT<E> extends AbstractSequentialList<E> {
+
+        LinkedList<E> l = new LinkedList<E>();
+
+        @Override
+        public ListIterator<E> listIterator(int index) {
+            return l.listIterator(index);
+        }
+
+        @Override
+        public int size() {
+            return l.size();
+        }
+    }
+    
+    /**
+     * @tests {@link java.util.AbstractSequentialList#addAll(int, java.util.Collection)}
+     */
+    public void test_addAll_ILCollection() {
+        AbstractSequentialList<String> al = new ASLT<String>();
+        String[] someList = { "Aardvark",  //$NON-NLS-1$
+                "Bear",  //$NON-NLS-1$
+                "Chimpanzee",  //$NON-NLS-1$
+                "Duck" }; //$NON-NLS-1$
+        Collection<String> c = Arrays.asList(someList);
+        al.addAll(c);
+        assertTrue("Should return true", al.addAll(2, c)); //$NON-NLS-1$
+    }
+    
+    public void test_set() throws Exception {
+		MyAbstractSequentialList list = new MyAbstractSequentialList();
+		try {
+			list.set(0, new Object());
+			fail("should throw IndexOutOfBoundsException");
+		} catch (IndexOutOfBoundsException e) {
+			// expected
+		}
+	}
+
+	public static class MyAbstractSequentialList extends AbstractSequentialList {
+
+		private LinkedList list = new LinkedList();
+
+		public ListIterator listIterator(int index) {
+			ListIterator iter = list.listIterator();
+			for (int i = 0; i < index; i++) {
+				iter.next();
+			}
+			return iter;
+		}
+
+		@Override
+		public int size() {
+			return list.size();
+		}
+	}
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/GregorianCalendarTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/GregorianCalendarTest.java?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/GregorianCalendarTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/util/GregorianCalendarTest.java Mon Jul  9 23:03:50 2007
@@ -561,11 +561,21 @@
 
 		cal.set(2004, Calendar.DECEMBER, 31, 5, 0, 0);
 		cal.roll(Calendar.WEEK_OF_YEAR, true);
-		assertTrue("Wrong year: " + cal.getTime(),
-				cal.get(Calendar.YEAR) == 2004);
-		assertTrue("Wrong month: " + cal.getTime(),
-				cal.get(Calendar.MONTH) == Calendar.JANUARY);
-		assertTrue("Wrong date: " + cal.getTime(), cal.get(Calendar.DATE) == 9);
+        assertEquals("Wrong year: " + cal.getTime(), 2004, cal
+                .get(Calendar.YEAR));
+        assertEquals("Wrong month: " + cal.getTime(), Calendar.JANUARY, cal
+                .get(Calendar.MONTH));
+        assertEquals("Wrong date: " + cal.getTime(), 9, cal.get(Calendar.DATE));
+
+        // Regression for HARMONY-4372
+        cal.set(1994, 11, 30, 5, 0, 0);
+        cal.setMinimalDaysInFirstWeek(4);
+        cal.roll(Calendar.WEEK_OF_YEAR, true);
+        assertEquals("Wrong year: " + cal.getTime(), 1994, cal
+                .get(Calendar.YEAR));
+        assertEquals("Wrong month: " + cal.getTime(), Calendar.JANUARY, cal
+                .get(Calendar.MONTH));
+        assertEquals("Wrong date: " + cal.getTime(), 7, cal.get(Calendar.DATE));
 	}
 
 	/**

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/test/native/hytime/shared/hytime.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/test/native/hytime/shared/hytime.c?view=diff&rev=554840&r1=554839&r2=554840
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/test/native/hytime/shared/hytime.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/test/native/hytime/shared/hytime.c Mon Jul  9 23:03:50 2007
@@ -31,15 +31,15 @@
 int test_hytime_shutdown(struct HyPortLibrary *hyportLibrary);
 int test_hytime_startup(struct HyPortLibrary *hyportLibrary);
 
+#ifdef HY_NO_THR
+HyThreadLibrary *privateThreadLibrary;
+#endif
+
 int main (int argc, char **argv, char **envp)
 {
   HyPortLibrary hyportLibrary;
   HyPortLibraryVersion portLibraryVersion;
   int ret;
-
-#ifdef HY_NO_THR
-  HyThreadLibrary *privateThreadLibrary;
-#endif
 
   printf("hytime:\n");
 



Mime
View raw message