harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r884518 [7/8] - in /harmony/enhanced/classlib/branches/java6: ./ depends/build/ depends/jars/ make/ modules/accessibility/make/ modules/accessibility/src/main/java/javax/accessibility/ modules/applet/src/main/java/org/apache/harmony/applet/...
Date Thu, 26 Nov 2009 11:12:56 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/MulticastSocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/MulticastSocketTest.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/MulticastSocketTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/MulticastSocketTest.java Thu Nov 26 11:12:49 2009
@@ -29,6 +29,7 @@
 import java.net.SocketAddress;
 import java.net.SocketException;
 import java.net.UnknownHostException;
+import java.util.ArrayList;
 import java.util.Enumeration;
 
 import tests.support.Support_NetworkInterface;
@@ -367,7 +368,7 @@
 		int groupPort = ports[0];
 		int serverPort = ports[1];
 
-                Enumeration theInterfaces = NetworkInterface.getNetworkInterfaces();
+        Enumeration<NetworkInterface> theInterfaces = NetworkInterface.getNetworkInterfaces();
 
         // first validate that we handle a null group ok
         mss = new MulticastSocket(groupPort);
@@ -463,38 +464,47 @@
                 NetworkInterface loopbackInterface = NetworkInterface
                         .getByInetAddress(InetAddress.getByName("127.0.0.1"));
 
+                boolean anyLoop = networkInterface1.equals(loopbackInterface) || networkInterface2.equals(loopbackInterface);
+                
+                ArrayList<NetworkInterface> realInterfaces = new ArrayList<NetworkInterface>();
                 theInterfaces = NetworkInterface.getNetworkInterfaces();
                 while (theInterfaces.hasMoreElements()) {
-
-                    NetworkInterface thisInterface = (NetworkInterface) theInterfaces
-                            .nextElement();
+                    NetworkInterface thisInterface = (NetworkInterface) theInterfaces.nextElement();
                     if (thisInterface.getInetAddresses().hasMoreElements()
                             && (Support_NetworkInterface
-                                    .useInterface(thisInterface) == true)) {
+                                    .useInterface(thisInterface) == true)){
+                        realInterfaces.add(thisInterface);
+                    }
+                }
+                
+                for (int i = 0; i < realInterfaces.size(); i++) {
+                    final int SECOND = 1;
+                    NetworkInterface thisInterface = realInterfaces.get(i);
+                   
                         // get the first address on the interface
 
                         // start server which is joined to the group and has
                         // only asked for packets on this interface
-                        Enumeration addresses = thisInterface
-                                .getInetAddresses();
+                        Enumeration<InetAddress> addresses = thisInterface.getInetAddresses();
 
                         NetworkInterface sendingInterface = null;
-                        boolean isLoopback = false;
                         if (addresses.hasMoreElements()) {
-                            InetAddress firstAddress = (InetAddress) addresses
-                                    .nextElement();
-                            if (firstAddress.isLoopbackAddress()) {
-                                isLoopback = true;
-                            }
+                            InetAddress firstAddress = (InetAddress) addresses.nextElement();
                             if (firstAddress instanceof Inet4Address) {
                                 group = InetAddress.getByName("224.0.0.4");
-                                if (networkInterface1.equals(NetworkInterface
-                                        .getByInetAddress(InetAddress
-                                                .getByName("127.0.0.1")))) {
-                                    sendingInterface = networkInterface2;
+                                if (anyLoop) {
+                                    if (networkInterface1.equals(loopbackInterface)) {
+                                        sendingInterface = networkInterface2;
+                                    } else {
+                                        sendingInterface = networkInterface1;
+                                    }
                                 } else {
-                                    sendingInterface = networkInterface1;
+                                    if(i == SECOND){
+                                        sendingInterface = networkInterface2;
+                                    } else {
+                                        sendingInterface = networkInterface1;
                                 }
+                               }
                             } else {
                                 // if this interface only seems to support
                                 // IPV6 addresses
@@ -504,12 +514,6 @@
                             }
                         }
 
-                        InetAddress useAddress = null;
-                        addresses = sendingInterface.getInetAddresses();
-                        if (addresses.hasMoreElements()) {
-                            useAddress = (InetAddress) addresses.nextElement();
-                        }
-
                         ports = Support_PortManager.getNextPortsForUDP(2);
                         serverPort = ports[0];
                         groupPort = ports[1];
@@ -522,8 +526,6 @@
                         // Now send out a package on interface
                         // networkInterface 1. We should
                         // only see the packet if we send it on interface 1
-                        InetSocketAddress theAddress = new InetSocketAddress(
-                                useAddress, groupPort);
                         mss = new MulticastSocket(groupPort);
                         mss.setNetworkInterface(sendingInterface);
                         msg = "Hello World - Again" + thisInterface.getName();
@@ -544,7 +546,7 @@
 
                         server.stopServer();
                     }
-                }
+                
 
                 // validate that we can join the same address on two
                 // different interfaces but not on the same interface

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java Thu Nov 26 11:12:49 2009
@@ -1939,8 +1939,8 @@
     @SuppressWarnings("deprecation")
     public void test_shutdownInput() throws IOException {
         ServerSocket server = new ServerSocket(0);
-        Socket client = new Socket(InetAddress.getLocalHost(), server
-                .getLocalPort());
+        int port = server.getLocalPort();
+        Socket client = new Socket(InetAddress.getLocalHost(), port);
 
         Socket worker = server.accept();
         worker.setTcpNoDelay(true);
@@ -1963,7 +1963,9 @@
         server.close();
 
         // Regression test for HARMONY-2944
-        Socket s = new Socket("0.0.0.0", 0, false);
+        // Port 0 is not allowed to be used in connect() on some platforms, 
+        // Since server has been closed here, so the port is free now
+        Socket s = new Socket("0.0.0.0", port, false);
         s.shutdownInput();
         try {
             s.shutdownInput();
@@ -1980,8 +1982,8 @@
     @SuppressWarnings("deprecation")
     public void test_shutdownOutput() throws IOException {
         ServerSocket server = new ServerSocket(0);
-        Socket client = new Socket(InetAddress.getLocalHost(), server
-                .getLocalPort());
+        int port = server.getLocalPort();
+        Socket client = new Socket(InetAddress.getLocalHost(), port);
 
         Socket worker = server.accept();
         OutputStream theOutput = worker.getOutputStream();
@@ -2003,7 +2005,9 @@
         server.close();
 
         // Regression test for HARMONY-2944
-        Socket s = new Socket("0.0.0.0", 0, false);
+        // Port 0 is not allowed to be used in connect() on some platforms, 
+        // Since server has been closed here, so the port is free now
+        Socket s = new Socket("0.0.0.0", port, false);
         s.shutdownOutput();
         try {
             s.shutdownOutput();

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java Thu Nov 26 11:12:49 2009
@@ -124,28 +124,32 @@
             alist.add(-1, new Object());
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             alist.add(-1, null);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             alist.add(alist.size() + 1, new Object());
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             alist.add(alist.size() + 1, null);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
     }
 
@@ -229,6 +233,8 @@
             obj.addAll((int) -1, (Collection) null);
             fail("IndexOutOfBoundsException expected");
         } catch (IndexOutOfBoundsException e) {
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         // Regression for HARMONY-5705
@@ -296,14 +302,16 @@
             obj.addAll(-1, obj);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             obj.addAll(obj.size() + 1, obj);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
@@ -317,13 +325,16 @@
             obj.addAll(obj.size() + 1, null);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             obj.addAll((int) -1, (Collection) null);
             fail("IndexOutOfBoundsException expected");
         } catch (IndexOutOfBoundsException e) {
+            // Expected
+            assertNotNull(e.getMessage());
         }
     }
 
@@ -547,6 +558,8 @@
             alist.get(8765);
             fail("Failed to throw expected exception for index > size");
         } catch (IndexOutOfBoundsException e) {
+            // Expected
+            assertNotNull(e.getMessage());
         }
     }
 
@@ -603,7 +616,8 @@
             mylist.removeRange(0, 1);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         int[] data = { 1, 2, 3 };
@@ -619,28 +633,32 @@
             mylist.removeRange(-1, 1);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             mylist.removeRange(0, -1);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             mylist.removeRange(1, 0);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             mylist.removeRange(2, 1);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
     }
     
@@ -656,6 +674,8 @@
             alist.remove(999);
             fail("Failed to throw exception when index out of range");
         } catch (IndexOutOfBoundsException e) {
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         ArrayList myList = (ArrayList) (((ArrayList) (alist)).clone());
@@ -683,11 +703,15 @@
             l.remove(-1);
             fail("-1 should cause exception");
         } catch (IndexOutOfBoundsException e) {
+            // Expected
+            assertNotNull(e.getMessage());
         }
         try {
             l.remove(0);
             fail("0 should case exception");
         } catch (IndexOutOfBoundsException e) {
+            // Expected
+            assertNotNull(e.getMessage());
         }
     }
 
@@ -713,28 +737,32 @@
             alist.set(-1, obj);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             alist.set(alist.size(), obj);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             alist.set(-1, null);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             alist.set(alist.size(), null);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimerTest.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimerTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimerTest.java Thu Nov 26 11:12:49 2009
@@ -20,6 +20,7 @@
 import java.util.Date;
 import java.util.Timer;
 import java.util.TimerTask;
+import java.util.concurrent.atomic.AtomicReference;
 
 public class TimerTest extends junit.framework.TestCase {
 
@@ -1181,6 +1182,25 @@
 		}
 	}
 
+    /**
+     * We used to swallow RuntimeExceptions thrown by tasks. Instead, we need to
+     * let those exceptions bubble up, where they will both notify the thread's
+     * uncaught exception handler and terminate the timer's thread.
+     */
+    public void testThrowingTaskKillsTimerThread() throws InterruptedException {
+        final AtomicReference<Thread> threadRef = new AtomicReference<Thread>();
+        new Timer().schedule(new TimerTask() {
+            @Override public void run() {
+                threadRef.set(Thread.currentThread());
+                throw new RuntimeException("task failure!");
+            }
+        }, 1);
+
+        Thread.sleep(400);
+        Thread timerThread = threadRef.get();
+        assertFalse(timerThread.isAlive());
+    }
+
 	protected void setUp() {
 		timerCounter = 0;
 	}

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/net/UnixSocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/net/UnixSocketTest.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/net/UnixSocketTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/net/UnixSocketTest.java Thu Nov 26 11:12:49 2009
@@ -37,69 +37,51 @@
     public void test_getInputStream() throws IOException {
         // Simple read/write test over the IO streams
         final ServerSocket pingServer = new ServerSocket(0);
-        Runnable runnable = new Runnable() {
-            public void run() {
-                try {
-                    Socket worker = pingServer.accept();
-                    pingServer.close();
-                    InputStream in = worker.getInputStream();
-                    in.read();
-                    OutputStream out = worker.getOutputStream();
-                    out.write(new byte[42]);
-                    worker.close();
-                } catch (IOException e) {
-                    fail(e.getMessage());
-                }
-            }
-        };
-        Thread thread = new Thread(runnable, "UnixSocket.getInputStream");
-        thread.start();
-
-        Socket pingClient = new Socket(InetAddress.getLocalHost(), pingServer
-                .getLocalPort());
-
-        // Busy wait until the client is connected.
-        int c = 0;
-        while (!pingClient.isConnected()) {
-            try {
-                Thread.sleep(200);
-            } catch (InterruptedException e) {
-                // ignore
-            }
-            if (++c > 4) {
-                fail("thread is not alive");
-            }
-        }
-
-        // Write some data to the server to provoke it
-        OutputStream out = pingClient.getOutputStream();
-        out.write(new byte[256]);
+        Socket pingClient = new Socket();
 
-        InputStream in = pingClient.getInputStream();
-        in.read(new byte[42]);
         try {
-            in.read();
-            fail("Should throw SocketException");
-        } catch (SocketException e) {
-            // expected
-        }
-        in.close();
+            pingClient.connect(new InetSocketAddress(
+                    InetAddress.getLocalHost(), pingServer.getLocalPort()));
 
-        try {
+            Socket worker = pingServer.accept();
+            pingServer.close();
+
+            // Write some data to the server to provoke it
+            OutputStream clientOut = pingClient.getOutputStream();
+            clientOut.write(new byte[256]);
+            InputStream in = worker.getInputStream();
             in.read();
-            fail("Should throw SocketException");
-        } catch (SocketException e) {
-            // expected
-        }
-        try {
-            in.read(new byte[5]);
-            fail("Should throw SocketException");
-        } catch (SocketException e) {
-            // expected
-        }
 
-        pingClient.close();
-        pingServer.close();
+            OutputStream out = worker.getOutputStream();
+            out.write(new byte[42]);
+            worker.close();
+            InputStream clientIn = pingClient.getInputStream();
+            clientIn.read(new byte[42]);
+
+            try {
+                clientIn.read();
+                fail("Should throw SocketException");
+            } catch (SocketException e) {
+                // expected
+            }
+            clientIn.close();
+
+            try {
+                clientIn.read();
+                fail("Should throw SocketException");
+            } catch (SocketException e) {
+                // expected
+            }
+            try {
+                clientIn.read(new byte[5]);
+                fail("Should throw SocketException");
+            } catch (SocketException e) {
+                // expected
+            }
+        } finally {
+            pingClient.close();
+            pingServer.close();
+        }
     }
 
     public void test_connectLjava_net_SocketAddressI() throws Exception {
@@ -119,7 +101,13 @@
 
     public void test_getOutputStream() throws Exception {
         // Regression test for HARMONY-2934
-        Socket socket = new Socket("127.0.0.1", 0, false);
+        // Port 0 is not allowed to be used in connect() on some platforms, 
+        // get a free port here
+        ServerSocket ss = new ServerSocket(0);
+        int port = ss.getLocalPort();
+        ss.close();
+        
+        Socket socket = new Socket("127.0.0.1", port, false);
         OutputStream o = socket.getOutputStream();
         try {
             o.write(1);

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/resources/net.resources/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/net.resources:790472-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/net.resources:790472-884286

Modified: harmony/enhanced/classlib/branches/java6/modules/misc/src/main/native/accessors/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/misc/src/main/native/accessors/windows/makefile?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/misc/src/main/native/accessors/windows/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/misc/src/main/native/accessors/windows/makefile Thu Nov 26 11:12:49 2009
@@ -33,6 +33,5 @@
   $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
 
 DLLBASE=0x13300000
-COMMENT=/comment:"Accessors native code. (c) Copyright 2006, 2008 The Apache Software Foundation or its licensors, as applicable."
 
 !include <$(HY_HDK)\build\make\rules.mak>

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.drl?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.drl (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.drl Thu Nov 26 11:12:49 2009
@@ -1,4 +1,2 @@
-org/apache/harmony/nio/tests/java/nio/channels/FileChannelWin32OnlyTest.java
 
-#HARMONY-4116
-org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
+

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.ibm?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.ibm (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.ibm Thu Nov 26 11:12:49 2009
@@ -1,3 +1,2 @@
-org/apache/harmony/nio/tests/java/nio/channels/FileChannelWin32OnlyTest.java
-#HARMONY-4116
-org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
+
+

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86_64.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86_64.drl?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86_64.drl (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86_64.drl Thu Nov 26 11:12:49 2009
@@ -1,3 +1,2 @@
-org/apache/harmony/nio/tests/java/nio/channels/FileChannelWin32OnlyTest.java
-#HARMONY-4116
-org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
+
+

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86_64.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86_64.ibm?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86_64.ibm (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86_64.ibm Thu Nov 26 11:12:49 2009
@@ -1,3 +1,2 @@
-org/apache/harmony/nio/tests/java/nio/channels/FileChannelWin32OnlyTest.java
-#HARMONY-4116
-org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
+
+

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.zos.s390.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.zos.s390.ibm?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.zos.s390.ibm (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.zos.s390.ibm Thu Nov 26 11:12:49 2009
@@ -1,3 +1,2 @@
-org/apache/harmony/nio/tests/java/nio/channels/FileChannelWin32OnlyTest.java
-#HARMONY-4116
-org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
+
+

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.zos.s390x.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.zos.s390x.ibm?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.zos.s390x.ibm (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.zos.s390x.ibm Thu Nov 26 11:12:49 2009
@@ -1,3 +1,2 @@
-org/apache/harmony/nio/tests/java/nio/channels/FileChannelWin32OnlyTest.java
-#HARMONY-4116
-org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
+
+

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/make/findbugs-exclude-filter.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/make/findbugs-exclude-filter.xml?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/make/findbugs-exclude-filter.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/make/findbugs-exclude-filter.xml Thu Nov 26 11:12:49 2009
@@ -31,4 +31,16 @@
 		<Bug code="IS" />
 	</Match>
 
+	<!--
+		We realize that the invocation always invokes unsupported operation.
+	-->
+	<Match>
+		<Class name="java.nio.MappedByteBufferAdapter" />
+		<Or>
+			<Method name="protectedArray" />
+			<Method name="protectedArrayOffset" />
+		</Or>
+		<Bug pattern="DMI_UNSUPPORTED_METHOD" />
+	</Match>
+
 </FindBugsFilter>

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/DoubleBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/DoubleBuffer.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/DoubleBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/DoubleBuffer.java Thu Nov 26 11:12:49 2009
@@ -212,11 +212,16 @@
     public abstract DoubleBuffer duplicate();
 
     /**
-     * Checks whether this double buffer is equal to another object.
-     * <p>
-     * If {@code other} is not a double buffer then {@code false} is returned.
-     * Two double buffers are equal if and only if their remaining doubles are
-     * exactly the same. Position, limit, capacity and mark are not considered.
+     * Checks whether this double buffer is equal to another object. If {@code
+     * other} is not a {@code DoubleBuffer} then {@code false} is returned.
+     *
+     * <p>Two double buffers are equal if their remaining doubles are equal.
+     * Position, limit, capacity and mark are not considered.
+     *
+     * <p>This method considers two doubles {@code a} and {@code b} to be equal
+     * if {@code a == b} or if {@code a} and {@code b} are both {@code NaN}.
+     * Unlike {@link Double#equals}, this method considers {@code -0.0} and
+     * {@code +0.0} to be equal.
      *
      * @param other
      *            the object to compare with this double buffer.
@@ -238,7 +243,9 @@
         int otherPosition = otherBuffer.position;
         boolean equalSoFar = true;
         while (equalSoFar && (myPosition < limit)) {
-            equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++);
+            double a = get(myPosition++);
+            double b = otherBuffer.get(otherPosition++);
+            equalSoFar = a == b || (a != a && b != b);
         }
 
         return equalSoFar;

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/FloatBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/FloatBuffer.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/FloatBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/FloatBuffer.java Thu Nov 26 11:12:49 2009
@@ -214,11 +214,16 @@
     public abstract FloatBuffer duplicate();
 
     /**
-     * Checks whether this float buffer is equal to another object.
-     * <p>
-     * If {@code other} is not a float buffer then {@code false} is returned.
-     * Two float buffers are equal if and only if their remaining floats are
-     * exactly the same. Position, limit, capacity and mark are not considered.
+     * Checks whether this float buffer is equal to another object. If {@code
+     * other} is not a {@code FloatBuffer} then {@code false} is returned.
+     *
+     * <p>Two float buffers are equal if their remaining floats are equal.
+     * Position, limit, capacity and mark are not considered.
+     *
+     * <p>This method considers two floats {@code a} and {@code b} to be equal
+     * if {@code a == b} or if {@code a} and {@code b} are both {@code NaN}.
+     * Unlike {@link Float#equals}, this method considers {@code -0.0} and
+     * {@code +0.0} to be equal.
      *
      * @param other
      *            the object to compare with this float buffer.
@@ -240,7 +245,9 @@
         int otherPosition = otherBuffer.position;
         boolean equalSoFar = true;
         while (equalSoFar && (myPosition < limit)) {
-            equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++);
+            float a = get(myPosition++);
+            float b = otherBuffer.get(otherPosition++);
+            equalSoFar = a == b || (a != a && b != b);
         }
 
         return equalSoFar;

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java Thu Nov 26 11:12:49 2009
@@ -20,16 +20,15 @@
 import java.nio.channels.SelectableChannel;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
+import java.nio.channels.SocketChannel;
 import java.nio.channels.spi.AbstractSelectableChannel;
 import java.nio.channels.spi.AbstractSelectionKey;
 
-/*
+/**
  * Default implementation of SelectionKey
  */
 final class SelectionKeyImpl extends AbstractSelectionKey {
 
-    static int stHash;
-
     private AbstractSelectableChannel channel;
 
     private int interestOps;
@@ -42,7 +41,6 @@
 
     public SelectionKeyImpl(AbstractSelectableChannel channel, int operations,
             Object attachment, SelectorImpl selector) {
-        super();
         this.channel = channel;
         interestOps = operations;
         this.selector = selector;
@@ -62,6 +60,12 @@
         }
     }
 
+    int interestOpsNoCheck() {
+        synchronized (selector.keysLock) {
+            return interestOps;
+        }
+    }
+
     @Override
     public SelectionKey interestOps(int operations) {
         checkValid();
@@ -106,4 +110,13 @@
             throw new CancelledKeyException();
         }
     }
+
+    /**
+     * Returns true if the channel for this key is connected. If the channel
+     * does not need connecting, this always return true.
+     */
+    boolean isConnected() {
+        return !(channel instanceof SocketChannel) 
+                || ((SocketChannel) channel).isConnected();
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java Thu Nov 26 11:12:49 2009
@@ -23,6 +23,10 @@
 import java.nio.channels.Pipe;
 import java.nio.channels.SelectableChannel;
 import java.nio.channels.SelectionKey;
+import static java.nio.channels.SelectionKey.OP_ACCEPT;
+import static java.nio.channels.SelectionKey.OP_CONNECT;
+import static java.nio.channels.SelectionKey.OP_READ;
+import static java.nio.channels.SelectionKey.OP_WRITE;
 import java.nio.channels.Selector;
 import java.nio.channels.SocketChannel;
 import java.nio.channels.spi.AbstractSelectableChannel;
@@ -44,6 +48,10 @@
  */
 final class SelectorImpl extends AbstractSelector {
 
+    private static final int[] EMPTY_INT_ARRAY = new int[0];
+
+    private static final int ACCEPT_OR_READ = OP_ACCEPT | OP_READ;
+
     private static final int MOCK_WRITEBUF_SIZE = 1;
 
     private static final int MOCK_READBUF_SIZE = 8;
@@ -58,31 +66,31 @@
 
     private static final int SELECT_NOW = 0;
 
-    /*
-     * keysLock is used to brief synchronization when get selectionKeys snapshot
-     * before selection.
+    /**
+     * Used to synchronize when a key's interest ops change.
      */
     private static class KeysLock {}
     final Object keysLock = new KeysLock();
 
-    private SelectionKey[] keys = new SelectionKey[1];
+    private SelectionKeyImpl[] keys = new SelectionKeyImpl[1];
 
-    private final Set<SelectionKey> keysSet = new HashSet<SelectionKey>();
+    private final Set<SelectionKey> mutableKeys = new HashSet<SelectionKey>();
 
+    /**
+     * The unmodifiable set of keys as exposed to the user. This object is used
+     * for synchronization.
+     */
     private Set<SelectionKey> unmodifiableKeys = Collections
-            .unmodifiableSet(keysSet);
-
-    private final Set<SelectionKey> selectedKeys = new HashSet<SelectionKey>();
-
-    private Set<SelectionKey> unaddableSelectedKeys = new UnaddableSet<SelectionKey>(
-            selectedKeys);
+            .<SelectionKey>unmodifiableSet(mutableKeys);
 
-    // sink and source are used by wakeup()
-    private Pipe.SinkChannel sink;
-
-    private Pipe.SourceChannel source;
+    private final Set<SelectionKey> mutableSelectedKeys = new HashSet<SelectionKey>();
 
-    private FileDescriptor sourcefd;
+    /**
+     * The unmodifiable set of selectable keys as seen by the user. This object
+     * is used for synchronization.
+     */
+    private final Set<SelectionKey> selectedKeys
+            = new UnaddableSet<SelectionKey>(mutableSelectedKeys);
 
     private FileDescriptor[] readableFDs;
 
@@ -102,6 +110,22 @@
 
     private int[] writableFDsToKeys;
 
+    /**
+     * Selection flags that define the ready ops on the ready keys. When not
+     * actively selecting, all elements are 0. Corresponds to the ready keys
+     * set.
+     */
+    private int[] flags = EMPTY_INT_ARRAY;
+
+    /**
+     * A mock channel is used to signal wakeups. Whenever the selector should
+     * stop blocking on a select(), a byte is written to the sink and will be
+     * picked up in source by the selecting thread.
+     */
+    private Pipe.SinkChannel sink;
+    private Pipe.SourceChannel source;
+    private FileDescriptor sourcefd;
+
     public SelectorImpl(SelectorProvider selectorProvider) {
         super(selectorProvider);
         try {
@@ -120,7 +144,7 @@
 
             // register sink channel
             readableFDs[0] = sourcefd;
-            keys[0] = source.keyFor(this);
+            keys[0] = (SelectionKeyImpl) source.keyFor(this);
 
             // index it
             keysToReadableFDs[0] = 0;
@@ -142,11 +166,11 @@
         synchronized (this) {
             synchronized (unmodifiableKeys) {
                 synchronized (selectedKeys) {
+                    sink.close();
+                    source.close();
                     doCancel();
-                    for (SelectionKey sk : keys) {
-                        if (sk != null) {
-                            deregister((AbstractSelectionKey) sk);
-                        }
+                    for (SelectionKey sk : mutableKeys) {
+                        deregister((AbstractSelectionKey) sk);
                     }
                 }
             }
@@ -156,7 +180,7 @@
     private void ensureCommonCapacity(int c) {
         // TODO: rewrite array handling as some internal class
         if (c >= keys.length) {
-            SelectionKey[] newKeys = new SelectionKey[(keys.length + 1) << 1];
+            SelectionKeyImpl[] newKeys = new SelectionKeyImpl[(keys.length + 1) << 1];
             System.arraycopy(keys, 0, newKeys, 0, keys.length);
             keys = newKeys;
         }
@@ -222,7 +246,7 @@
      *            key to add
      * @return index in the storage
      */
-    private int addKey(SelectionKey sk) {
+    private void addKey(SelectionKeyImpl sk) {
 
         lastKeyIndex++;
         int c = lastKeyIndex;
@@ -266,8 +290,7 @@
 
             writableKeysCount++;
         }
-
-        return c;
+        sk.setIndex(c);
     }
 
     /**
@@ -277,8 +300,8 @@
      * @param sk
      *            key to delete
      */
-    private void delKey(SelectionKey sk) {
-        int index = ((SelectionKeyImpl) sk).getIndex();
+    private void delKey(SelectionKeyImpl sk) {
+        int index = sk.getIndex();
 
         // === deleting the key and FDs
 
@@ -309,7 +332,7 @@
             keys[lastKeyIndex] = null;
 
             // update key index
-            ((SelectionKeyImpl) keys[index]).setIndex(index);
+            keys[index].setIndex(index);
 
             // the key in the new position references the same FDs
             keysToReadableFDs[index] = keysToReadableFDs[lastKeyIndex];
@@ -371,9 +394,9 @@
         synchronized (this) {
             synchronized (unmodifiableKeys) {
                 synchronized (selectedKeys) {
-                    delKey(sk);
-                    int newIndex = addKey(sk);
-                    ((SelectionKeyImpl)sk).setIndex(newIndex);
+                    SelectionKeyImpl ski = (SelectionKeyImpl) sk;
+                    delKey(ski);
+                    addKey(ski);
                 }
             }
         }
@@ -391,15 +414,12 @@
         }
         synchronized (this) {
             synchronized (unmodifiableKeys) {
-
                 // create the key
-                SelectionKey sk = new SelectionKeyImpl(channel, operations,
-                        attachment, this);
-
-                int index = addKey(sk);
-                ((SelectionKeyImpl) sk).setIndex(index);
-
-                return sk;
+                SelectionKeyImpl selectionKey = new SelectionKeyImpl(
+                        channel, operations, attachment, this);
+                addKey(selectionKey);
+                mutableKeys.add(selectionKey);
+                return selectionKey;
             }
         }
     }
@@ -410,18 +430,6 @@
     @Override
     public synchronized Set<SelectionKey> keys() {
         closeCheck();
-
-        keysSet.clear();
-
-        if (keys.length != lastKeyIndex + 1) {
-            SelectionKey[] chompedKeys = new SelectionKey[lastKeyIndex + 1];
-            System.arraycopy(keys, 0, chompedKeys, 0, lastKeyIndex + 1);
-            keysSet.addAll(Arrays.asList(chompedKeys));
-        } else {
-            keysSet.addAll(Arrays.asList(keys));
-        }
-
-        keysSet.remove(source.keyFor(this));
         return unmodifiableKeys;
     }
 
@@ -467,70 +475,64 @@
             synchronized (unmodifiableKeys) {
                 synchronized (selectedKeys) {
                     doCancel();
-                    int[] readyChannels = null;
                     boolean isBlock = (SELECT_NOW != timeout);
                     prepareChannels();
+                    boolean success;
                     try {
                         if (isBlock) {
                             begin();
                         }
-                        readyChannels = Platform.getNetworkSystem().select(
-                                readableFDs, writableFDs, timeout);
+                        success = Platform.getNetworkSystem().select(
+                                readableFDs, writableFDs, readableKeysCount, writableKeysCount, timeout, flags);
                     } finally {
                         if (isBlock) {
                             end();
                         }
                     }
-                    return processSelectResult(readyChannels);
+
+                    int selected = success ? processSelectResult() : 0;
+
+                    Arrays.fill(flags, 0);
+
+                    Set<SelectionKey> cancelledKeys = cancelledKeys();
+                    synchronized (cancelledKeys) {
+                        if (cancelledKeys.size() > 0) {
+                            for (SelectionKey currentkey : cancelledKeys) {
+                                delKey((SelectionKeyImpl)currentkey);
+                                mutableKeys.remove(currentkey);
+                                deregister((AbstractSelectionKey) currentkey);
+                                if (mutableSelectedKeys.remove(currentkey)) {
+                                    selected--;
+                                }
+                            }
+                            cancelledKeys.clear();
+                        }
+                        limitCapacity();
+                    }
+
+                    return selected;
                 }
             }
         }
     }
 
-    private boolean isConnected(SelectionKeyImpl key) {
-        SelectableChannel channel = key.channel();
-        if (channel instanceof SocketChannel) {
-            return ((SocketChannel) channel).isConnected();
-        }
-        return true;
-    }
-
     /*
      * Prepares and adds channels to list for selection
      */
     private void prepareChannels() {
-
-        // chomp the arrays if needed
-
-        if (readableFDs.length != readableKeysCount) {
-            FileDescriptor[] chompedReadableFDs = new FileDescriptor[readableKeysCount];
-            System.arraycopy(readableFDs, 0, chompedReadableFDs, 0,
-                    readableKeysCount);
-            readableFDs = chompedReadableFDs;
-        }
-
-        if (writableFDs.length != writableKeysCount) {
-            FileDescriptor[] chompedWriteableFDs = new FileDescriptor[writableKeysCount];
-            System.arraycopy(writableFDs, 0, chompedWriteableFDs, 0,
-                    writableKeysCount);
-            writableFDs = chompedWriteableFDs;
+        if (flags.length < readableKeysCount + writableKeysCount) {
+            flags = new int[readableKeysCount + writableKeysCount];
         }
 
     }
 
-    /*
-     * Analyses selected channels and adds keys of ready channels to
-     * selectedKeys list.
-     * 
-     * readyChannels are encoded as concatenated array of flags for readable
-     * channels followed by writable channels.
+    /**
+     * Updates the key ready ops and selected key set with data from the flags
+     * array.
      */
-    private int processSelectResult(int[] readyChannels) throws IOException {
-        if (0 == readyChannels.length) {
-            return 0;
-        }
+    private int processSelectResult() throws IOException {
         // if the mock channel is selected, read the content.
-        if (READABLE == readyChannels[0]) {
+        if (READABLE == flags[0]) {
             ByteBuffer readbuf = ByteBuffer.allocate(MOCK_READBUF_SIZE);
             while (source.read(readbuf) > 0) {
                 readbuf.flip();
@@ -538,47 +540,44 @@
         }
         int selected = 0;
 
-        for (int i = 1; i < readyChannels.length; i++) {
-
-            if (readyChannels[i] != NA) {
-                SelectionKeyImpl key = (SelectionKeyImpl) (i >= readableKeysCount ? keys[writableFDsToKeys[i
-                        - readableKeysCount]]
-                        : keys[readableFDsToKeys[i]]);
-
-                if (null == key) {
-                    continue;
-                }
-
-                int ops = key.interestOps();
-                int selectedOp = 0;
-
-                switch (readyChannels[i]) {
-
-                    case READABLE:
-                        selectedOp = (SelectionKey.OP_READ | SelectionKey.OP_ACCEPT)
-                                & ops;
-                        break;
-                    case WRITEABLE:
-                        if (isConnected(key)) {
-                            selectedOp = SelectionKey.OP_WRITE & ops;
-                        } else {
-                            selectedOp = SelectionKey.OP_CONNECT & ops;
-                        }
-                        break;
-                }
-
-                if (0 != selectedOp) {
-                    boolean isOldSelectedKey = selectedKeys.contains(key);
-                    if (isOldSelectedKey && key.readyOps() != selectedOp) {
-                        key.setReadyOps(key.readyOps() | selectedOp);
-                        selected++;
-                    } else if (!isOldSelectedKey) {
-                        key.setReadyOps(selectedOp);
-                        selectedKeys.add(key);
-                        selected++;
+        for (int i = 1; i < flags.length; i++) {
+            if (flags[i] == NA) {
+                continue;
+            }
+            SelectionKeyImpl key = i >= readableKeysCount ? keys[writableFDsToKeys[i
+                    - readableKeysCount]]
+                    : keys[readableFDsToKeys[i]];
+
+            if (null == key) {
+                continue;
+            }
+
+            int ops = key.interestOpsNoCheck();
+            int selectedOp = 0;
+
+            switch (flags[i]) {
+                case READABLE:
+                    selectedOp = ACCEPT_OR_READ & ops;
+                    break;
+                case WRITEABLE:
+                    if (key.isConnected()) {
+                        selectedOp = OP_WRITE & ops;
+                    } else {
+                        selectedOp = OP_CONNECT & ops;
                     }
-                }
+                    break;
+            }
 
+            if (0 != selectedOp) {
+                boolean wasSelected = mutableSelectedKeys.contains(key);
+                if (wasSelected && key.readyOps() != selectedOp) {
+                    key.setReadyOps(key.readyOps() | selectedOp);
+                    selected++;
+                } else if (!wasSelected) {
+                    key.setReadyOps(selectedOp);
+                    mutableSelectedKeys.add(key);
+                    selected++;
+                }
             }
         }
 
@@ -591,23 +590,24 @@
     @Override
     public synchronized Set<SelectionKey> selectedKeys() {
         closeCheck();
-        return unaddableSelectedKeys;
+        return selectedKeys;
     }
 
     /*
-     * Assumes calling thread holds locks on 'this', 'keysSet', and 'selectedKeys'. 
+     * Assumes calling thread holds locks on 'this', 'unmodifiableKeys', and 'selectedKeys'.
      */
     private void doCancel() {
         Set<SelectionKey> cancelledKeys = cancelledKeys();
         synchronized (cancelledKeys) {
             if (cancelledKeys.size() > 0) {
                 for (SelectionKey currentkey : cancelledKeys) {
-                    delKey(currentkey);
+                    delKey((SelectionKeyImpl)currentkey);
+                    mutableKeys.remove(currentkey);
                     deregister((AbstractSelectionKey) currentkey);
-                    selectedKeys.remove(currentkey);
+                    mutableSelectedKeys.remove(currentkey);
                 }
+                cancelledKeys.clear();
             }
-            cancelledKeys.clear();
             limitCapacity();
         }
     }
@@ -627,7 +627,7 @@
 
     private static class UnaddableSet<E> implements Set<E> {
 
-        private Set<E> set;
+        private final Set<E> set;
 
         UnaddableSet(Set<E> set) {
             this.set = set;

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java Thu Nov 26 11:12:49 2009
@@ -124,10 +124,11 @@
                     if (!isBlocking) {
                         // for non blocking mode, use select to see whether
                         // there are any pending connections.
-                        int[] tryResult = Platform.getNetworkSystem().select(
+                        int[] tryResult = new int[1];
+                        boolean success = Platform.getNetworkSystem().select(
                                 new FileDescriptor[] { this.fd },
-                                new FileDescriptor[0], 0);
-                        if (0 == tryResult.length || 0 == tryResult[0]) {
+                                new FileDescriptor[0], 1, 0, 0, tryResult);
+                        if (!success || 0 == tryResult[0]) {
                             // no pending connections, returns immediately.
                             return null;
                         }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java Thu Nov 26 11:12:49 2009
@@ -277,15 +277,11 @@
             finished = (CONNECT_SUCCESS == result);
             isBound = finished;
         } catch (IOException e) {
-            if (e instanceof ConnectException && !isBlocking()) {
-                status = SOCKET_STATUS_PENDING;
-            } else {
-                if (isOpen()) {
-                    close();
-                    finished = true;
-                }
-                throw e;
+            if (isOpen()) {
+                close();
+                finished = true;
             }
+            throw e;
         } finally {
             if (isBlocking()) {
                 end(finished);

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/native/nio/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/native/nio/unix/makefile?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/native/nio/unix/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/native/nio/unix/makefile Thu Nov 26 11:12:49 2009
@@ -22,7 +22,7 @@
 BUILDFILES = \
 	../shared/DirectBufferUtil.o ../shared/AddressUtil.o
 ifeq ($(HY_OS),linux)
-BUILDFILES += ../unix/EpollSelectorImpl.o
+BUILDFILES += EpollSelectorImpl.o
 endif
 
 ifneq ($(HY_ZIP_API),true)

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/native/nio/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/native/nio/windows/makefile?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/native/nio/windows/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/native/nio/windows/makefile Thu Nov 26 11:12:49 2009
@@ -41,6 +41,5 @@
   $(LIBPATH)hythr$(HY_LINKLIB_SUFFIX) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
 
 DLLBASE=0x13200000
-COMMENT=/comment:"nio component native code. (c) Copyright 1991, 2007 The Apache Software Foundation or its licensors, as applicable."
 
 !include <$(HY_HDK)\build\make\rules.mak>

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java Thu Nov 26 11:12:49 2009
@@ -19,6 +19,8 @@
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.ClosedSelectorException;
@@ -26,8 +28,12 @@
 import java.nio.channels.Selector;
 import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SocketChannel;
+import java.nio.channels.Pipe;
 import java.nio.channels.spi.SelectorProvider;
 import java.util.Set;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import junit.framework.TestCase;
 import tests.support.Support_PortManager;
@@ -337,6 +343,69 @@
         selectOnce(SelectType.TIMEOUT, 0);
     }
 
+    public void test_keySetViewsModifications() throws IOException {
+        Set<SelectionKey> keys = selector.keys();
+
+        SelectionKey key1 = ssc.register(selector, SelectionKey.OP_ACCEPT);
+
+        assertTrue(keys.contains(key1));
+
+        SocketChannel sc = SocketChannel.open();
+        sc.configureBlocking(false);
+        SelectionKey key2 = sc.register(selector, SelectionKey.OP_READ);
+
+        assertTrue(keys.contains(key1));
+        assertTrue(keys.contains(key2));
+
+        key1.cancel();
+        assertTrue(keys.contains(key1));
+
+        selector.selectNow();
+        assertFalse(keys.contains(key1));
+        assertTrue(keys.contains(key2));
+     }
+
+    /**
+     * This test cancels a key while selecting to verify that the cancelled
+     * key set is processed both before and after the call to the underlying
+     * operating system.
+     */
+    public void test_cancelledKeys() throws Exception {
+        final AtomicReference<Throwable> failure = new AtomicReference<Throwable>();
+        final AtomicBoolean complete = new AtomicBoolean();
+
+        final Pipe pipe = Pipe.open();
+        pipe.source().configureBlocking(false);
+        final SelectionKey key = pipe.source().register(selector, SelectionKey.OP_READ);
+
+        Thread thread = new Thread() {
+            public void run() {
+                try {
+                    // make sure to call key.cancel() while the main thread is selecting
+                    Thread.sleep(500);
+                    key.cancel();
+                    assertFalse(key.isValid());
+                    pipe.sink().write(ByteBuffer.allocate(4)); // unblock select()
+                } catch (Throwable e) {
+                    failure.set(e);
+                } finally {
+                    complete.set(true);
+                }
+            }
+        };
+        assertTrue(key.isValid());
+
+        thread.start();
+        do {
+            assertEquals(0, selector.select(5000)); // blocks
+            assertEquals(0, selector.selectedKeys().size());
+        } while (!complete.get()); // avoid spurious interrupts
+        assertFalse(key.isValid());
+
+        thread.join();
+        assertNull(failure.get());
+    }
+
     private void assert_select_SelectorClosed(SelectType type, int timeout)
             throws IOException {
         // selector is closed

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/native/niochar/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/native/niochar/windows/makefile?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/native/niochar/windows/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/native/niochar/windows/makefile Thu Nov 26 11:12:49 2009
@@ -122,6 +122,5 @@
 MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
   
 DLLBASE=0x13200000
-COMMENT=/comment:"nio_char component native code. (c) Copyright 1991, 2008 The Apache Software Foundation or its licensors, as applicable."
 
 !include <$(HY_HDK)\build\make\rules.mak>

Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/depends/manifests/asm-3.1/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/pack200/depends/manifests/asm-3.1:785554-824035
+/harmony/enhanced/classlib/trunk/modules/pack200/depends/manifests/asm-3.1:785554-884286

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java Thu Nov 26 11:12:49 2009
@@ -226,10 +226,11 @@
     public static int[] getSpecifier(Codec codec, Codec defaultForBand) {
         // lazy initialization
         if(canonicalCodecsToSpecifiers == null) {
-            canonicalCodecsToSpecifiers = new HashMap();
+            HashMap reverseMap = new HashMap(canonicalCodec.length);
             for (int i = 0; i < canonicalCodec.length; i++) {
-                canonicalCodecsToSpecifiers.put(canonicalCodec[i], new Integer(i));
+                reverseMap.put(canonicalCodec[i], new Integer(i));
             }
+            canonicalCodecsToSpecifiers = reverseMap;
         }
 
         if(canonicalCodecsToSpecifiers.containsKey(codec)) {

Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java:782694-824035
+/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java:782694-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java:782694-824035
+/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java:782694-884286

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/common/shared/iohelp.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/common/shared/iohelp.c?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/common/shared/iohelp.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/common/shared/iohelp.c Thu Nov 26 11:12:49 2009
@@ -34,18 +34,16 @@
   while (*pathIndex != '\0')
     {
       if ((*pathIndex == '\\' || *pathIndex == '/')
-          && (*pathIndex != jclSeparator))
-        *pathIndex = jclSeparator;
+          && (*pathIndex != DIR_SEPARATOR))
+        *pathIndex = DIR_SEPARATOR;
       pathIndex++;
     }
 
-  /* Remove duplicate separators */
-  if (jclSeparator == '/')
-    return;                     /* Do not do POSIX platforms */
+#if !(DIR_SEPARATOR == '/')
 
   /* Remove duplicate initial separators */
   pathIndex = path;
-  while ((*pathIndex != '\0') && (*pathIndex == jclSeparator))
+  while ((*pathIndex != '\0') && (*pathIndex == DIR_SEPARATOR))
     {
       pathIndex++;
     }
@@ -68,5 +66,6 @@
         }
     }
   /* This will have to handle extra \'s but currently doesn't */
+#endif
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/include/shared/iohelp.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/include/shared/iohelp.h?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/include/shared/iohelp.h (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/include/shared/iohelp.h Thu Nov 26 11:12:49 2009
@@ -21,8 +21,6 @@
 #include "vmi.h"
 #include "exceptions.h"
 
-/* DIR_SEPARATOR is defined in hycomp.h */
-#define jclSeparator DIR_SEPARATOR
 void ioh_convertToPlatform (char *path);
 
 #endif /* iohelp_h */

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/windows/makefile?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/windows/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/windows/makefile Thu Nov 26 11:12:49 2009
@@ -44,6 +44,5 @@
 	ws2_32.lib Iphlpapi.lib shell32.lib
 
 DLLBASE=0x11100000
-COMMENT=/comment:"Platform port library. (c) Copyright 1993, 2009 The Apache Software Foundation or its licensors, as applicable."
 
 !include <$(HY_HDK)\build\make\rules.mak>

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thread/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thread/windows/makefile?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thread/windows/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thread/windows/makefile Thu Nov 26 11:12:49 2009
@@ -36,6 +36,5 @@
 MDLLIBFILES = $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) $(LIBPATH)hycommon$(HY_LINKLIB_SUFFIX)
 
 DLLBASE=0x11500000
-COMMENT=/comment:"Thread support library. (c) Copyright 1993, 2006 The Apache Software Foundation or its licensors, as applicable."
 
 !include <$(HY_HDK)\build\make\rules.mak>

Propchange: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thrstub/shared/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov 26 11:12:49 2009
@@ -0,0 +1 @@
+*.obj

Propchange: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thrstub/windows/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov 26 11:12:49 2009
@@ -0,0 +1,2 @@
+*.RES
+*.pdb

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thrstub/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thrstub/windows/makefile?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thrstub/windows/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/thrstub/windows/makefile Thu Nov 26 11:12:49 2009
@@ -32,6 +32,5 @@
 HYLDFLAGS = $(HYLDFLAGS) -def:$(LIBBASE).def 
 
 DLLBASE=0x11500000
-COMMENT=/comment:"Thread support library. (c) Copyright 1993, 2007 The Apache Software Foundation or its licensors, as applicable."
 
 !include <$(HY_HDK)\build\make\rules.mak>

Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/make/run-test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/make/run-test.xml?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/make/run-test.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/make/run-test.xml Thu Nov 26 11:12:49 2009
@@ -36,6 +36,7 @@
         <run-selected-hdk-tests module="prefs" jar="prefs_tests.jar">
             <excludeorinclude>
                 <exclude name="org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.class" unless="test.case" />
+                <exclude name="org/apache/harmony/prefs/tests/java/util/prefs/PreferencesProviderTest.class" unless="test.case" />
                 <include name="**/*Test.class" unless="test.case"/>
             </excludeorinclude>
         </run-selected-hdk-tests>
@@ -44,6 +45,14 @@
                 <include name="org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.class" unless="test.case" />
             </excludeorinclude>
         </run-selected-hdk-tests>
+        <run-selected-hdk-tests module="prefs" jar="prefs_tests.jar">
+            <excludeorinclude>
+                <include name="org/apache/harmony/prefs/tests/java/util/prefs/PreferencesProviderTest.class" unless="test.case" />
+            </excludeorinclude>
+            <junit-elements>
+                <classpath location="resources/config" />
+            </junit-elements>
+        </run-selected-hdk-tests>
     </target>
     
 </project>

Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/Preferences.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/Preferences.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/Preferences.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/Preferences.java Thu Nov 26 11:12:49 2009
@@ -16,8 +16,11 @@
 
 package java.util.prefs;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.net.MalformedURLException;
 import java.security.AccessController;
@@ -124,6 +127,10 @@
             }
         });
 
+        if (factoryClassName == null) {
+            factoryClassName = readProviderFromFile();
+        }
+
         // set default provider
         if (factoryClassName == null) {
             String osName = AccessController.doPrivileged(new PrivilegedAction<String>() {
@@ -154,6 +161,45 @@
         }
     }
 
+    private static String readProviderFromFile() throws InternalError {
+        ClassLoader systemLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+            public ClassLoader run() {
+                return ClassLoader.getSystemClassLoader();
+            }
+        });
+
+        if (systemLoader != null) {
+            InputStream in = systemLoader.getResourceAsStream("META-INF/services/java.util.prefs.PreferencesFactory"); //$NON-NLS-1$
+            if (in != null) {
+                BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+                String line = null;
+                try {
+                    while ((line = reader.readLine()) != null) {
+                        int index = line.indexOf("#"); //$NON-NLS-1$
+                        // Trim comments
+                        if (index != -1) {
+                            line = line.substring(0, index);
+                        }
+                        String trimedName = line.trim();
+                        if (!"".equals(trimedName)) { //$NON-NLS-1$
+                            return trimedName;
+                        }
+                    }
+                } catch (IOException e) {
+                    // prefs.11=Load provider configuration file faild: {0}
+                    throw new InternalError(Messages.getString("prefs.11", e));   //$NON-NLS-1$
+                } finally {
+                    try {
+                        reader.close();
+                    } catch (IOException e) {
+                        // ignore
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
     /**
      * Default constructor, for use by subclasses only.
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties Thu Nov 26 11:12:49 2009
@@ -31,3 +31,4 @@
 prefs.D=Enumerate keys error
 prefs.E=Access denied
 prefs.F=Remove node error\!
+prefs.11=Load provider configuration file faild: {0}
\ No newline at end of file

Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/native/prefs/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/native/prefs/windows/makefile?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/native/prefs/windows/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/native/prefs/windows/makefile Thu Nov 26 11:12:49 2009
@@ -39,6 +39,5 @@
 MDLLIBFILES = $(MDLLIBFILES) \
   $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
 DLLBASE=0x13300000
-COMMENT=/comment:"Preferences component native code. (c) Copyright 1993, 2007 The Apache Software Foundation or its licensors, as applicable."
 
 !include <$(HY_HDK)\build\make\rules.mak>

Modified: harmony/enhanced/classlib/branches/java6/modules/print/src/main/java/common/org/apache/harmony/x/print/ServiceUIDialog.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/print/src/main/java/common/org/apache/harmony/x/print/ServiceUIDialog.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/print/src/main/java/common/org/apache/harmony/x/print/ServiceUIDialog.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/print/src/main/java/common/org/apache/harmony/x/print/ServiceUIDialog.java Thu Nov 26 11:12:49 2009
@@ -165,19 +165,19 @@
 public class ServiceUIDialog extends ServiceUIDialogTemplate {
 
     // State of dialog:
-    public static int APPROVE_PRINT = 1;    // OK button was pressed
-    public static int CANSEL_PRINT = -1;    // Cancel button was pressed
-    public static int SETUP_ERROR = 2;      // Dialog Setup was finished with 
-                                            // error, dialog can not be shown
-    public static int SETUP_OK = 3;         // Dialog setup was OK, 
-                                            // you can show the dialog
-    int dialogResult = 0;                   // Current dialog status
+    public static final int APPROVE_PRINT = 1;    // OK button was pressed
+    public static final int CANCEL_PRINT = -1;    // Cancel button was pressed
+    public static final int SETUP_ERROR = 2;      // Dialog Setup was finished with 
+                                                  // error, dialog can not be shown
+    public static final int SETUP_OK = 3;         // Dialog setup was OK, 
+                                                  // you can show the dialog
+    int dialogResult = 0;                         // Current dialog status
     
     // Dialog type:
-    public static int PRINT_DIALOG = 1;     // Dialog for PrintService selecting,
-                                            // all dialog tabs are visible 
-    public static int PAGE_DIALOG = 2;      // Page setup dialog:
-                                            // only PageSetup dialog tab is visible
+    public static final int PRINT_DIALOG = 1;     // Dialog for PrintService selecting,
+                                                  // all dialog tabs are visible 
+    public static final int PAGE_DIALOG = 2;      // Page setup dialog:
+                                                  // only PageSetup dialog tab is visible
     private int dialogType = PRINT_DIALOG;  // dialog type
     
     PrintService [] services = null;        // Print services array for the choice
@@ -463,7 +463,7 @@
         
         printDialog.addWindowListener(new WindowAdapter() {
             public void windowClosing(WindowEvent event) {
-                dialogResult = CANSEL_PRINT;
+                dialogResult = CANCEL_PRINT;
             }
         });
     }
@@ -631,7 +631,7 @@
                  * case. If default Copies value is null - I suppose that default 
                  * and supported value is 1 Copy only. 
                 */
-                supported = new CopiesSupported( (defaul == null)
+                supported = new CopiesSupported( (defaul != null)
                         ? defaul.getValue()
                         : 1);
             }
@@ -1617,7 +1617,7 @@
      */
     class cancelButtonListener implements ActionListener {
         public void actionPerformed(ActionEvent e) {
-            dialogResult = CANSEL_PRINT;
+            dialogResult = CANCEL_PRINT;
             printDialog.hide();
         }
     } /* End of cancelButtonListener */

Modified: harmony/enhanced/classlib/branches/java6/modules/print/src/main/native/print/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/print/src/main/native/print/windows/makefile?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/print/src/main/native/print/windows/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/print/src/main/native/print/windows/makefile Thu Nov 26 11:12:49 2009
@@ -40,7 +40,6 @@
 MDLLIBFILES =
 
 DLLBASE=0x13300000
-COMMENT=/comment:"Print native code. (c) Copyright 2005, 2007 The Apache Software Foundation or its licensors, as applicable."
 
 !include <$(HY_HDK)\build\make\rules.mak>
 

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/MessageDigest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/MessageDigest.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/MessageDigest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/MessageDigest.java Thu Nov 26 11:12:49 2009
@@ -296,12 +296,16 @@
         if (digesta.length != digestb.length) {
             return false;
         }
+        // No early return is allowed to avoid timing attack.
+        // We must not return false until all elements are compared 
+        // to keep the computing time constant
+        boolean result = true;
         for (int i = 0; i < digesta.length; i++) {
             if (digesta[i] != digestb[i]) {
-                return false;
+                result = false;
             }
         }
-        return true;
+        return result;
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Policy.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Policy.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Policy.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Policy.java Thu Nov 26 11:12:49 2009
@@ -46,7 +46,7 @@
             "setPolicy"); //$NON-NLS-1$
 
     // The SecurityPermission required to get current Policy.
-    private static final SecurityPermission GET_POLICY = new SecurityPermission(
+    static final SecurityPermission GET_POLICY = new SecurityPermission(
             "getPolicy"); //$NON-NLS-1$
 
     // The policy currently in effect. 

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/ProtectionDomain.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/ProtectionDomain.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/ProtectionDomain.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/ProtectionDomain.java Thu Nov 26 11:12:49 2009
@@ -244,13 +244,17 @@
 
         if (dynamicPerms) {
             if (Policy.isSet()) {
-                PermissionCollection perms;
-                perms = Policy.getAccessiblePolicy().getPermissions(this);
-                if (perms == null) {
-                    buf.append("\t\t<no dynamic permissions>\n"); //$NON-NLS-1$
+                if (canGetPolicy()) {
+                    PermissionCollection perms;
+                    perms = Policy.getAccessiblePolicy().getPermissions(this);
+                    if (perms == null) {
+                        buf.append("\t\t<no dynamic permissions>\n"); //$NON-NLS-1$
+                    } else {
+                        buf.append("\t\tdynamic: ").append(perms.toString()) //$NON-NLS-1$
+                                .append("\n"); //$NON-NLS-1$
+                    }
                 } else {
-                    buf.append("\t\tdynamic: ").append(perms.toString()) //$NON-NLS-1$
-                            .append("\n"); //$NON-NLS-1$
+                    buf.append("\t\t<no rights to retrieve dynamic permissions>\n"); //$NON-NLS-1$
                 }
             } else {
                 buf.append("\t\t<no dynamic permissions>\n"); //$NON-NLS-1$
@@ -258,4 +262,20 @@
         }
         return buf.toString();
     }
+    
+    /*
+     * Returns true if the caller has permission to retrieve the current
+     * security policy settings, or false if not.
+     */
+    private boolean canGetPolicy() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            try {
+                sm.checkPermission(Policy.GET_POLICY);
+            } catch (SecurityException e) {
+                return false;
+            }
+        }
+        return true;
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Provider.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Provider.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Provider.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Provider.java Thu Nov 26 11:12:49 2009
@@ -192,6 +192,10 @@
 
     @Override
     public synchronized void load(InputStream inStream) throws IOException {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkSecurityAccess("putProviderProperty." + name); //$NON-NLS-1$
+        }
         Properties tmp = new Properties();
         tmp.load(inStream);
         myPutAll(tmp);

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/native/security/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/native/security/windows/makefile?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/native/security/windows/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/native/security/windows/makefile Thu Nov 26 11:12:49 2009
@@ -30,6 +30,5 @@
 
 MDLLIBFILES = $(LIBPATH)hycommon$(HY_LINKLIB_SUFFIX) $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX)
 DLLBASE=0x1300000
-COMMENT=/comment:"Security component native code. (c) Copyright 2006 The Apache Software Foundation or its licensors, as applicable."
 
 !include <$(HY_HDK)\build\make\rules.mak>



Mime
View raw message