harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r727683 [5/11] - in /harmony/enhanced/classlib/branches/java6: ./ doc/ make/ modules/accessibility/src/main/java/javax/accessibility/ modules/archive/src/main/java/java/util/jar/ modules/archive/src/main/java/java/util/zip/ modules/archive/...
Date Thu, 18 Dec 2008 09:46:26 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/exports.txt?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/exports.txt (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/exports.txt Thu Dec 18 01:46:12 2008
@@ -200,55 +200,50 @@
 Java_org_apache_harmony_luni_platform_OSMemory_setFloat
 Java_org_apache_harmony_luni_platform_OSMemory_getDouble
 Java_org_apache_harmony_luni_platform_OSMemory_setDouble
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_createSocketImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_createDatagramSocketImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_readSocketImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_readSocketDirectImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_writeSocketImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_writeSocketDirectImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_setNonBlockingImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_connectSocketImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_connectWithTimeoutSocketImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_connectStreamWithTimeoutSocketImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_socketBindImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_listenStreamSocketImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_availableStreamImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_acceptSocketImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_supportsUrgentDataImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendUrgentDataImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_connectDatagramImpl2
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_disconnectDatagramImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_socketBindImpl2
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_peekDatagramImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_receiveDatagramImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_receiveDatagramDirectImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_recvConnectedDatagramImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_recvConnectedDatagramDirectImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendDatagramImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendDatagramDirectImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendConnectedDatagramImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendConnectedDatagramDirectImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_createServerStreamSocketImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_createMulticastSocketImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_receiveStreamImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendStreamImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_shutdownInputImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_shutdownOutputImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_acceptStreamSocketImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_createStreamSocketImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendDatagramImpl2
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_createDatagramSocket
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_read
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_readDirect
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_write
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_writeDirect
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_setNonBlocking
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_connect
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_connectWithTimeout
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_connectStreamWithTimeoutSocket
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_bind
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_listenStreamSocket
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_availableStream
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_accept
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_supportsUrgentData
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendUrgentData
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_connectDatagram
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_disconnectDatagram
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_peekDatagram
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_receiveDatagram
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_receiveDatagramDirect
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_recvConnectedDatagram
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_recvConnectedDatagramDirect
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendDatagram
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendDatagramDirect
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendConnectedDatagram
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendConnectedDatagramDirect
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_receiveStream
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_shutdownInput
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_shutdownOutput
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_acceptStreamSocket
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_createStreamSocket
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendDatagram2
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_selectImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_getSocketLocalAddressImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_getSocketLocalPortImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_getSocketOptionImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_setSocketOptionImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_getSocketFlagsImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_socketCloseImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_getHostByAddrImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_getHostByNameImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_setInetAddressImpl
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_getSocketLocalAddress
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_getSocketLocalPort
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_getSocketOption
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_setSocketOption
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_getSocketFlags
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_socketClose
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_getHostByAddr
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_getHostByName
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_setInetAddress
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_isReachableByICMPImpl
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_inheritedChannelImpl
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_inheritedChannel
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_oneTimeInitializationImpl
 Java_org_apache_harmony_luni_platform_OSResourcesMonitor_isSystemPhysicalMemoryLow
 Java_org_apache_harmony_luni_platform_Environment_getEnvBytes

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/makefile?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/makefile Thu Dec 18 01:46:12 2008
@@ -35,7 +35,7 @@
 	$(SHAREDSUB)osc.o $(SHAREDSUB)socket.o $(SHAREDSUB)inetadds.o \
 	$(SHAREDSUB)filedesc.o $(SHAREDSUB)timezone.o \
 	$(SHAREDSUB)OSFileSystem.o OSFileSystemLinux32.o \
-	OSMemory.o OSMemoryLinux32.o $(SHAREDSUB)OSNetworkSystem.o \
+	$(SHAREDSUB)OSMemory.o OSMemoryLinux32.o $(SHAREDSUB)OSNetworkSystem.o \
 	OSNetworkSystemLinux.o $(HY_OS)/OSResourcesMonitor.o hyenv.o consoleimpl.o
 
 ifneq ($(HY_ZIP_API),true)

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSMemoryWin32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSMemoryWin32.c?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSMemoryWin32.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSMemoryWin32.c Thu Dec 18 01:46:12 2008
@@ -157,3 +157,21 @@
   
   return (jlong) mapAddress;
 }
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_luni_platform_OSMemory_getCharArray
+  (JNIEnv * env, jobject thiz, jlong address, jcharArray jdest, jint offset, jint length)
+{
+  jboolean isCopy;
+  jchar *dest = (*env)->GetCharArrayElements (env, jdest, &isCopy);
+  memcpy (dest + offset, (const void *) address, (size_t) length);
+  (*env)->ReleaseCharArrayElements (env, jdest, dest, 0);
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_luni_platform_OSMemory_setCharArray
+  (JNIEnv * env, jobject thiz, jlong address, jcharArray jsrc, jint offset, jint length)
+{
+  jboolean isCopy;
+  jchar *src = (*env)->GetCharArrayElements (env, jsrc, &isCopy);
+  memcpy ((void *) address, (const jchar *) src + offset, (size_t) length);
+  (*env)->ReleaseCharArrayElements (env, jsrc, src, JNI_ABORT);
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c Thu Dec 18 01:46:12 2008
@@ -35,9 +35,11 @@
  * Method:    selectImpl
  * Signature: ([Ljava/io/FileDescriptor;[Ljava/io/FileDescriptor;II[IJ)I
  */
-JNIEXPORT jint JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_selectImpl	
-  (JNIEnv * env, jclass	thisClz, jobjectArray readFDArray, jobjectArray	writeFDArray,
-   jint	countReadC, jint countWriteC, jintArray	outFlags, jlong	timeout){
+JNIEXPORT jint JNICALL
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_selectImpl	
+  (JNIEnv * env, jobject thiz, jobjectArray readFDArray, jobjectArray writeFDArray,
+   jint	countReadC, jint countWriteC, jintArray	outFlags, jlong	timeout)
+{
   PORT_ACCESS_FROM_ENV (env);
   hytimeval_struct timeP;	
   I_32 result =	0;		
@@ -158,31 +160,31 @@
   return result;
 }
 
-/*Alternative Select function*/
+/* Alternative Select function */
 int 
-selectRead (JNIEnv * env,hysocket_t hysocketP, I_32 uSecTime, BOOLEAN accept){
+selectRead (JNIEnv * env, hysocket_t hysocketP, I_32 uSecTime, BOOLEAN accept){
   PORT_ACCESS_FROM_ENV (env);
   hytimeval_struct timeP;
   hyfdset_t fdset_read;
   I_32 result = 0;
 
-  if (0 <= uSecTime)
-    hysock_timeval_init (0, uSecTime, &timeP);
-
   fdset_read = hymem_allocate_memory(sizeof (struct hyfdset_struct));
   FD_ZERO (&fdset_read->handle);
-  if (hysocketP->flags & SOCKET_IPV4_OPEN_MASK)
-    {
-      FD_SET (hysocketP->ipv4, &fdset_read->handle);
-    }
-  if (hysocketP->flags & SOCKET_IPV6_OPEN_MASK)
-    {
-      FD_SET (hysocketP->ipv6, &fdset_read->handle);
-    }
-  if (0 <= uSecTime)
-    result = hysock_select (0, fdset_read, NULL, NULL,&timeP);  
-  else
-    result = hysock_select (0, fdset_read, NULL, NULL,NULL);  
+
+  if (hysocketP->flags & SOCKET_IPV4_OPEN_MASK) {
+    FD_SET (hysocketP->ipv4, &fdset_read->handle);
+  }
+  if (hysocketP->flags & SOCKET_IPV6_OPEN_MASK) {
+    FD_SET (hysocketP->ipv6, &fdset_read->handle);
+  }
+
+  if (0 <= uSecTime) {
+    hysock_timeval_init (0, uSecTime, &timeP);
+    result = hysock_select(0, fdset_read, NULL, NULL, &timeP);
+  } else {
+    result = hysock_select(0, fdset_read, NULL, NULL, NULL);
+  }
+
   hymem_free_memory(fdset_read);
   return result;
 }
@@ -192,8 +194,10 @@
  * Method:    isReachableByICMPImpl
  * Signature: ([BII)I
  */
-JNIEXPORT jint JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_isReachableByICMPImpl
-  (JNIEnv * env, jobject clz, jobject address,jobject localaddr, jint ttl, jint timeout){
+JNIEXPORT jint JNICALL
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_isReachableByICMPImpl
+  (JNIEnv * env, jobject clz, jobject address,jobject localaddr, jint ttl, jint timeout)
+{
   PORT_ACCESS_FROM_ENV (env);
   struct sockaddr_in dest,source,local;
   struct ICMPHeader* send_buf = 0;
@@ -328,9 +332,49 @@
     icmp_hdr->checksum = ip_checksum((unsigned short *)icmp_hdr, packet_size);
 }
 
-JNIEXPORT jobject JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_inheritedChannelImpl
-  (JNIEnv * env , jobject clz)
+JNIEXPORT jobject JNICALL
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_inheritedChannel
+  (JNIEnv * env , jobject thiz)
 {
-  //inheritedChannel is not supported on windows platform. 
+  // inheritedChannel is not supported on windows platform. 
   return NULL;
 }
+
+/*
+ * Utilizes the Winsock2 call to get the available bytes pending on a socket
+ * which is similar to, but different to the call on other platforms.
+ *
+ * Class:     org_apache_harmony_luni_platform_OSNetworkSystem
+ * Method:    availableStream
+ * Signature: (Ljava/io/FileDescriptor;)I
+ */
+JNIEXPORT jint JNICALL
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_availableStream
+  (JNIEnv * env, jobject thiz, jobject fileDescriptor)
+{
+  PORT_ACCESS_FROM_ENV(env);
+  hysocket_t hysocketP;
+  OSSOCKET socket;
+  U_32 nbytes = 0;
+  I_32 result;
+
+  hysocketP = getJavaIoFileDescriptorContentsAsAPointer(env, fileDescriptor);
+  if (!hysock_socketIsValid(hysocketP)) {
+    throwJavaNetSocketException(env, HYPORT_ERROR_SOCKET_BADSOCKET);
+    return (jint) 0;
+  }
+
+  if ((hysocketP->flags & SOCKET_USE_IPV4_MASK) == SOCKET_USE_IPV4_MASK) {
+      socket = hysocketP->ipv4;
+  } else {
+      socket = hysocketP->ipv6;
+  }
+
+  result = ioctlsocket(socket, FIONREAD, &nbytes);
+  if (result != 0) {
+    throwJavaNetSocketException(env, result);
+    return (jint) 0;
+  }
+
+  return (jint) nbytes;
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/makefile?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/makefile Thu Dec 18 01:46:12 2008
@@ -35,7 +35,7 @@
   $(SHAREDSUB)socket.obj $(SHAREDSUB)inetadds.obj \
   $(SHAREDSUB)filedesc.obj $(SHAREDSUB)timezone.obj \
   OSFileSystemWin32.obj hyenv.obj\
-  $(SHAREDSUB)OSFileSystem.obj OSMemoryWin32.obj OSMemory.obj \
+  $(SHAREDSUB)OSFileSystem.obj OSMemoryWin32.obj $(SHAREDSUB)OSMemory.obj \
   $(SHAREDSUB)OSNetworkSystem.obj OSNetworkSystemWin32.obj \
   OSResourcesMonitorWin32.obj consoleimpl.obj
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java Thu Dec 18 01:46:12 2008
@@ -19,6 +19,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.Authenticator;
+import java.net.ConnectException;
 import java.net.HttpURLConnection;
 import java.net.InetSocketAddress;
 import java.net.MalformedURLException;
@@ -33,6 +34,8 @@
 import java.net.URL;
 import java.security.Permission;
 import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 import junit.framework.TestCase;
 
@@ -294,6 +297,44 @@
     }
 
     /**
+     * @tests HttpURLConnection.getHeaderFields
+     */
+    public void test_getHeaderFields() throws Exception {
+        URL url = new URL("http://www.apache.org");
+        HttpURLConnection httpURLConnect = (HttpURLConnection) url
+                .openConnection();
+        assertEquals(200, httpURLConnect.getResponseCode());
+        assertEquals("OK", httpURLConnect.getResponseMessage());
+        Map headers = httpURLConnect.getHeaderFields();
+        // there should be at least 2 headers
+        assertTrue(headers.size() > 1);
+        List list = (List) headers.get("Content-Length");
+        if (list == null) {
+            list = (List) headers.get("content-length");
+        }
+        assertNotNull(list);
+        try {
+            headers.put("key", "value");
+            fail("should throw UnsupportedOperationException");
+        } catch (UnsupportedOperationException e) {
+            // Expected
+        }
+        try {
+            list.set(0, "value");
+            fail("should throw UnsupportedOperationException");
+        } catch (UnsupportedOperationException e) {
+            // Expected
+        }
+        
+        try {
+            httpURLConnect.setRequestProperty("key", "value");
+            fail("should throw IlegalStateException");
+        } catch (IllegalStateException e) {
+            // Expected
+        }
+    }
+
+    /**
      * @tests org.apache.harmony.luni.internal.net.www.http.getOutputStream()
      */
     public void testGetOutputStream() throws Exception {
@@ -317,6 +358,23 @@
     }
 
     /**
+     * Test whether getOutputStream can work after connection
+     */
+    public void test_getOutputStream_AfterConnect() throws Exception {
+        URL url = new URL("http://www.apache.org");
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        connection.setDoOutput(true);
+        connection.connect();
+        String str_get = connection.getRequestMethod();
+        assertTrue(str_get.equalsIgnoreCase("GET"));
+
+        // call to getOutputStream should implicitly set req. method to POST
+        connection.getOutputStream();
+        String str_post = connection.getRequestMethod();
+        assertTrue(str_post.equalsIgnoreCase("POST"));
+    }
+
+    /**
      * Test checks if the proxy specified in openConnection method will be used
      * for connection to the server
      */
@@ -359,6 +417,38 @@
     }
 
     /**
+     * @tests HttpURLConnection.usingProxy
+     */
+    public void testUsingProxy2() throws Exception {
+        try {
+            System.setProperty("http.proxyHost", "www.apache.org");
+            URL url = new URL("http://www.apache.org");
+            HttpURLConnection urlConnect = (HttpURLConnection) url
+                    .openConnection();
+            urlConnect.getInputStream();
+            assertTrue(urlConnect.usingProxy());
+            
+            System.setProperty("http.proxyPort", "81");
+            url = new URL("http://www.apache.org");
+            urlConnect = (HttpURLConnection) url.openConnection();
+            urlConnect.getInputStream();
+            assertFalse(urlConnect.usingProxy());
+            
+            url = new URL("http://localhost");
+            urlConnect = (HttpURLConnection) url.openConnection();
+            try {
+                urlConnect.getInputStream();
+                fail("should throw ConnectException");
+            } catch (ConnectException e) {
+                // Expected
+            }
+            assertFalse(urlConnect.usingProxy());
+        } finally {
+            System.setProperties(null);
+        }
+    }
+
+    /**
      * Test checks if the proxy provided by proxy selector will be used for
      * connection to the server
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java Thu Dec 18 01:46:12 2008
@@ -1851,6 +1851,23 @@
     }
 
     /**
+     * @tests java.io.File#mkdir()
+     *
+     * HARMONY-6041
+     */
+    public void test_mkdir_special_unicode() throws IOException {
+        tempDirectory = new File("\u5C73");
+        int i = 0;
+        while (tempDirectory.exists()) {
+            tempDirectory = new File("\u5C73" + i);
+            ++i;
+        }
+        assertFalse(tempDirectory.exists());
+        assertTrue(tempDirectory.mkdir());
+        assertTrue(tempDirectory.exists());
+    }
+
+    /**
      * @tests java.io.File#mkdirs()
      */
     public void test_mkdirs() {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java Thu Dec 18 01:46:12 2008
@@ -57,6 +57,18 @@
         assertEquals("Incorrect int read/written", 20, raf.read());
         raf.close();
         
+        raf = new java.io.RandomAccessFile(f, "rwd");
+        raf.write(20);
+        raf.seek(0);
+        assertEquals("Incorrect int read/written", 20, raf.read());
+        raf.close();
+
+        raf = new java.io.RandomAccessFile(f, "rws");
+        raf.write(20);
+        raf.seek(0);
+        assertEquals("Incorrect int read/written", 20, raf.read());
+        raf.close();
+        
         // Regression for HARMONY-50
         File f = File.createTempFile("xxx", "yyy");
         f.deleteOnExit();
@@ -80,6 +92,14 @@
         RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
         raf.write("Test".getBytes(), 0, 4);
         raf.close();
+        
+        raf = new java.io.RandomAccessFile(fileName, "rwd");
+        raf.write("Test".getBytes(), 0, 4);
+        raf.close();
+
+        raf = new java.io.RandomAccessFile(fileName, "rws");
+        raf.write("Test".getBytes(), 0, 4);
+        raf.close();
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java Thu Dec 18 01:46:12 2008
@@ -485,6 +485,25 @@
         assertEquals(expected[0], bytes[0]);
         assertEquals(expected[1], bytes[1]);
     }
+    
+    /*
+     * @tests java.lang.String#getBytes()
+     */
+    public void test_getBytes_NPE() throws Exception {
+        try {
+            "abc".getBytes((String) null);
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+
+        try {
+            "Hello World".getBytes(1, 2, null, 1);
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
 
     /**
      * @tests java.lang.String#getChars(int, int, char[], int)

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java Thu Dec 18 01:46:12 2008
@@ -619,6 +619,26 @@
 
 	}
 
+    /*
+     * @tests java.lang.ThreadGroupt#setDaemon(boolean)
+     */
+    public void test_setDaemon_Parent_Child() {
+        ThreadGroup ptg = new ThreadGroup("Parent");
+        ThreadGroup ctg = new ThreadGroup(ptg, "Child");
+
+        ctg.setDaemon(true);
+        assertTrue(ctg.isDaemon());
+
+        ctg.setDaemon(false);
+        assertFalse(ctg.isDaemon());
+
+        ptg.setDaemon(true);
+        assertFalse(ctg.isDaemon());
+
+        ptg.setDaemon(false);
+        assertFalse(ctg.isDaemon());
+    }
+
 	/**
 	 * @tests java.lang.ThreadGroup#setMaxPriority(int)
 	 */

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/AuthenticatorTest.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/AuthenticatorTest.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/AuthenticatorTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/AuthenticatorTest.java Thu Dec 18 01:46:12 2008
@@ -16,14 +16,21 @@
 
 package org.apache.harmony.luni.tests.java.net;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.Authenticator;
 import java.net.InetAddress;
 import java.net.MalformedURLException;
+import java.net.PasswordAuthentication;
+import java.net.ServerSocket;
+import java.net.Socket;
 import java.net.URL;
 import java.net.UnknownHostException;
 import java.net.Authenticator.RequestorType;
 
 import junit.framework.TestCase;
+import tests.support.Support_PortManager;
 
 public class AuthenticatorTest extends TestCase {
 
@@ -120,6 +127,69 @@
         assertNull(mock.getRequestorType());
     }
 
+    /**
+     * @tests java.net.Authenticator#setDefault(java.net.Authenticator)
+     */
+    public void test_setDefault() {
+        final int port = Support_PortManager.getNextPort();
+        final Object lock = new Object();
+        final int[] result = new int[1];
+        Thread t = new Thread(new Runnable() {
+            public void run() {
+                try {
+                    ServerSocket ss = null;
+                    synchronized (lock) {
+                        ss = new ServerSocket(port);
+                        lock.notifyAll();
+                    }
+                    Socket s = ss.accept();
+                    InputStream in = s.getInputStream();
+                    in.read(new byte[1024]);
+                    OutputStream out = s.getOutputStream();
+                    out
+                            .write("HTTP/1.1 401 Unauthorized\r\nWWW-Authenticate:Basic realm=\"something\"\r\n\r\n"
+                                    .getBytes("ISO8859_1"));
+                    Thread.sleep(500);
+                    out.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+        synchronized (lock) {
+            t.start();
+            try {
+                lock.wait();
+            } catch (InterruptedException e) {
+                // ignored
+            }
+        }
+        Authenticator.setDefault(new Authenticator() {
+            protected PasswordAuthentication getPasswordAuthentication() {
+                synchronized (lock) {
+                    result[0] = 1;
+                }
+                return null;
+            }
+        });
+        Authenticator.setDefault(new Authenticator() {
+            protected PasswordAuthentication getPasswordAuthentication() {
+                synchronized (lock) {
+                    result[0] = 2;
+                }
+                return null;
+            }
+        });
+        try {
+            new URL("http://localhost:" + port).openStream();
+        } catch (IOException e) {
+            // ignored
+        }
+        synchronized (lock) {
+            assertEquals("wrong authenticator: " + result[0], 2, result[0]);
+        }
+    }
+
     /*
      * Mock Authernticator for test
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.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/DatagramSocketTest.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java Thu Dec 18 01:46:12 2008
@@ -28,7 +28,6 @@
 import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
-import java.net.MulticastSocket;
 import java.net.NetworkInterface;
 import java.net.PortUnreachableException;
 import java.net.SocketAddress;
@@ -36,7 +35,7 @@
 import java.net.UnknownHostException;
 import java.util.Date;
 
-import org.apache.harmony.luni.net.SocketImplProvider;
+import org.apache.harmony.luni.net.PlainDatagramSocketImpl;
 
 import tests.support.Support_Configuration;
 import tests.support.Support_PortManager;
@@ -964,7 +963,7 @@
             DatagramSocketImplFactory {
 
         public DatagramSocketImpl createDatagramSocketImpl() {
-            return SocketImplProvider.getDatagramSocketImpl();
+            return new PlainDatagramSocketImpl();
         }
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.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/InetAddressTest.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java Thu Dec 18 01:46:12 2008
@@ -389,6 +389,35 @@
     }
 
     /**
+     * @tests java.net.InetAddress#getLocalHost()
+     */
+    public void test_getLocalHost_extended() throws Exception {
+        class Inet_SecurityManager extends SecurityManager {
+            @Override
+            public void checkConnect(String host, int port) {
+                super.checkConnect(host, port);
+                throw new SecurityException();
+            }
+        }
+
+        // Bogus, but we don't know the host name or ip of the machine
+        // running the test, so we can't build our own address
+        DatagramSocket dg = new DatagramSocket(0, InetAddress.getLocalHost());
+        assertEquals("Incorrect host returned", InetAddress.getLocalHost(), dg
+                .getLocalAddress());
+        dg.close();
+
+        SecurityManager oldman = System.getSecurityManager();
+        try {
+            System.setSecurityManager(new Inet_SecurityManager());
+            assertTrue("Host address should be a loop back address",
+                    InetAddress.getLocalHost().isLoopbackAddress());
+        } finally {
+            System.setSecurityManager(oldman);
+        }
+    }
+    
+    /**
      * @tests java.net.InetAddress#hashCode()
      */
     public void test_hashCode() {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/ServerSocketTest.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/ServerSocketTest.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/ServerSocketTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/ServerSocketTest.java Thu Dec 18 01:46:12 2008
@@ -35,7 +35,7 @@
 import java.util.Date;
 import java.util.Properties;
 
-import org.apache.harmony.luni.net.SocketImplProvider;
+import org.apache.harmony.luni.net.PlainSocketImpl;
 
 import tests.support.Support_Configuration;
 import tests.support.Support_Exec;
@@ -333,7 +333,7 @@
 
     private static class MockSocketImplFactory implements SocketImplFactory {
         public SocketImpl createSocketImpl() {
-            return SocketImplProvider.getServerSocketImpl();
+            return new PlainSocketImpl();
         }
     }
 

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=727683&r1=727682&r2=727683&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 Dec 18 01:46:12 2008
@@ -36,7 +36,7 @@
 import java.net.UnknownHostException;
 import java.security.Permission;
 
-import org.apache.harmony.luni.net.SocketImplProvider;
+import org.apache.harmony.luni.net.PlainSocketImpl;
 
 import tests.support.Support_Configuration;
 
@@ -2093,7 +2093,7 @@
     private class MockSocketImplFactory implements SocketImplFactory {
 
         public SocketImpl createSocketImpl() {
-            return SocketImplProvider.getServerSocketImpl();
+            return new PlainSocketImpl();
         }
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashtableTest.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/HashtableTest.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashtableTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashtableTest.java Thu Dec 18 01:46:12 2008
@@ -192,6 +192,16 @@
 		}
 
 		assertEquals("All keys not retrieved", 10, ht10.size());
+
+        // cast Enumeration to Iterator
+        Iterator iterator = (Iterator) elms;
+        assertFalse(iterator.hasNext());
+        try {
+            iterator.next();
+            fail("should throw NoSuchElementException");
+        } catch (NoSuchElementException e) {
+            // Expected
+        }
 	}
 
 	/**
@@ -359,8 +369,18 @@
 		}
 
 		assertEquals("All keys not retrieved", 10, ht10.size());
-	}
 
+        // cast Enumeration to Iterator
+        Iterator iterator = (Iterator) keys;
+        assertFalse(iterator.hasNext());
+        try {
+            iterator.next();
+            fail("should throw NoSuchElementException");
+        } catch (NoSuchElementException e) {
+            // Expected
+        }
+	}
+	
 	/**
 	 * @tests java.util.Hashtable#keys()
 	 */
@@ -429,6 +449,10 @@
 		assertEquals("Wrong size 2", 1, map2.size());
 		assertTrue("Wrong contents 2", map2.keySet().iterator().next().equals(
 				next));
+
+        // cast Iterator to Enumeration
+        Enumeration enumeration = (Enumeration) s.iterator();
+        assertTrue(enumeration.hasMoreElements());
 	}
 
 	/**
@@ -654,6 +678,150 @@
         }
         assertFalse(hashtable.containsKey("my.nonexistent.prop"));
     }
+    
+    /**
+     * @tests java.util.Hashtable#elements()
+     * @tests java.util.Hashtable#keys()
+     * @tests java.util.Hashtable#keySet()
+     */
+    public void test_keys_elements_keySet_Exceptions() {
+        Hashtable hashTable = new Hashtable();
+        String key = "key";
+        String value = "value";
+        hashTable.put(key, value);
+
+        Iterator iterator = (Iterator) hashTable.keys();
+        assertTrue(iterator.hasNext());
+        try {
+            iterator.remove();
+            fail("should throw UnsupportedOperationException");
+        } catch (UnsupportedOperationException e) {
+            // Expected
+        }
+        iterator.next();
+        try {
+            iterator.remove();
+            fail("should throw UnsupportedOperationException");
+        } catch (UnsupportedOperationException e) {
+            // Expected
+        }
+        assertFalse(iterator.hasNext());
+
+        iterator = (Iterator) hashTable.elements();
+        assertTrue(iterator.hasNext());
+        try {
+            iterator.remove();
+            fail("should throw UnsupportedOperationException");
+        } catch (UnsupportedOperationException e) {
+            // Expected
+        }
+        iterator.next();
+        try {
+            iterator.remove();
+            fail("should throw UnsupportedOperationException");
+        } catch (UnsupportedOperationException e) {
+            // Expected
+        }
+        assertFalse(iterator.hasNext());
+
+        iterator = hashTable.keySet().iterator();
+        assertTrue(iterator.hasNext());
+        try {
+            iterator.remove();
+            fail("should throw IllegalStateException");
+        } catch (IllegalStateException e) {
+            // Expected
+        }
+        iterator.next();
+        iterator.remove();
+        assertFalse(iterator.hasNext());
+
+        hashTable.clear();
+        for (int i = 0; i < 10; i++) {
+            hashTable.put(key + i, value + i);
+        }
+
+        // cast Enumeration to Iterator
+        Enumeration enumeration = hashTable.keys();
+        iterator = (Iterator) enumeration;
+        assertTrue(enumeration.hasMoreElements());
+        assertTrue(iterator.hasNext());
+        for (int i = 0; i < 10; i++) {
+            if (i % 2 == 0) {
+                enumeration.nextElement();
+            } else {
+                iterator.next();
+            }
+        }
+        assertFalse(enumeration.hasMoreElements());
+        assertFalse(iterator.hasNext());
+        try {
+            enumeration.nextElement();
+            fail("should throw NoSuchElementException");
+        } catch (NoSuchElementException e) {
+            // Expected
+        }
+        try {
+            iterator.next();
+            fail("should throw NoSuchElementException");
+        } catch (NoSuchElementException e) {
+            // Expected
+        }
+
+        // cast Enumeration to Iterator
+        enumeration = hashTable.elements();
+        iterator = (Iterator) enumeration;
+        assertTrue(enumeration.hasMoreElements());
+        assertTrue(iterator.hasNext());
+        for (int i = 0; i < 10; i++) {
+            if (i % 2 == 0) {
+                enumeration.nextElement();
+            } else {
+                iterator.next();
+            }
+        }
+        assertFalse(enumeration.hasMoreElements());
+        assertFalse(iterator.hasNext());
+        try {
+            enumeration.nextElement();
+            fail("should throw NoSuchElementException");
+        } catch (NoSuchElementException e) {
+            // Expected
+        }
+        try {
+            iterator.next();
+            fail("should throw NoSuchElementException");
+        } catch (NoSuchElementException e) {
+            // Expected
+        }
+
+        // cast Iterator to Enumeration
+        enumeration = (Enumeration) hashTable.keySet().iterator();
+        iterator = (Iterator) enumeration;
+        assertTrue(enumeration.hasMoreElements());
+        assertTrue(iterator.hasNext());
+        for (int i = 0; i < 10; i++) {
+            if (i % 2 == 0) {
+                enumeration.nextElement();
+            } else {
+                iterator.next();
+            }
+        }
+        assertFalse(enumeration.hasMoreElements());
+        assertFalse(iterator.hasNext());
+        try {
+            enumeration.nextElement();
+            fail("should throw NoSuchElementException");
+        } catch (NoSuchElementException e) {
+            // Expected
+        }
+        try {
+            iterator.next();
+            fail("should throw NoSuchElementException");
+        } catch (NoSuchElementException e) {
+            // Expected
+        }
+    }
 
 	protected Hashtable hashtableClone(Hashtable s) {
 		return (Hashtable) s.clone();

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.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/PropertiesTest.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java Thu Dec 18 01:46:12 2008
@@ -29,6 +29,8 @@
 import java.io.Writer;
 import java.util.Enumeration;
 import java.util.InvalidPropertiesFormatException;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
 import java.util.Properties;
 import java.util.Scanner;
 import java.util.Set;
@@ -415,6 +417,16 @@
             assertTrue("Incorrect names returned", p.equals("test.prop")
                     || p.equals("bogus.prop"));
         }
+
+        // cast Enumeration to Iterator
+        Iterator iterator = (Iterator) names;
+        assertFalse(iterator.hasNext());
+        try {
+            iterator.next();
+            fail("should throw NoSuchElementException");
+        } catch (NoSuchElementException e) {
+            // Expected
+        }
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.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/ResourceBundleTest.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java Thu Dec 18 01:46:12 2008
@@ -347,11 +347,36 @@
         }
     }
 
+    /*
+     * the class and constructor must be public so ResourceBundle has the
+     * possibility to instantiate
+     */
+    public static class GetBundleTest {
+        public GetBundleTest() {
+            // Try to load a resource with the same name as the class.
+            // getBundle() should not try to instantiate the class since
+            // its not a ResourceBundle. If a .properties file exists it
+            // would be loaded.
+            ResourceBundle
+                    .getBundle("org.apache.harmony.luni.tests.java.util.ResourceBundleTest$GetBundleTest");
+        }
+    };
+
     /**
-     * The control with given formats.
+     * @tests java.util.ResourceBundle#getBundle(java.lang.String)
      */
-    static class GivenFormatsControl extends Control {
-        List<String> formats;
+    public void test_getBundleLjava_lang_String() {
+        /* ResourceBundle.getBundle recursion loading class name */
+        try {
+            new GetBundleTest();
+            fail("Should throw MissingResourceException");
+        } catch (MissingResourceException e) {
+            // expected
+        }
+    }
+
+	protected void setUp() {
+	}
 
         GivenFormatsControl(List<String> theFormats) {
             super();

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java Thu Dec 18 01:46:12 2008
@@ -1,371 +1,411 @@
-package org.apache.harmony.luni.tests.java.io;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import junit.framework.TestCase;
-
-/**
- * Please note that this case can only be passed on Linux due to some file
- * system dependent reason.
- * 
- */
-public class UnixFileTest extends TestCase {
-	private boolean root = false;
-	
-	private File testFile;
-
-	private File testDir;
-	
-	private static final int TOTAL_SPACE_NUM = 0;
-
-	private static final int FREE_SPACE_NUM = 1;
-
-	private static final int USABLE_SPACE_NUM = 2;
-
-	private static class ConsoleResulter extends Thread {
-		Process proc;
-
-		InputStream is;
-
-		String resStr;
-
-		ConsoleResulter(Process p, InputStream in) {
-			proc = p;
-			is = in;
-		}
-
-		@Override
-		public void run() {
-			StringBuffer result = new StringBuffer();
-			synchronized (result) {
-				try {
-					BufferedReader br = new BufferedReader(
-							new InputStreamReader(is));
-					String line;
-					while ((line = br.readLine()) != null) {
-						result.append(line);
-					}
-					if (result.length() != 0) {
-						resStr = result.toString();
-					}
-
-					br.close();
-				} catch (IOException ioe) {
-					result = null;
-				}
-				synchronized (proc) {
-					proc.notifyAll();
-				}
-			}
-		}
-	}
-
-	private static long getLinuxSpace(int index, File file) throws Exception {
-		long[] result = new long[3];
-		String par = file.getAbsolutePath();
-		String osName = System.getProperty("os.name");
-		// in case the test case will run under other OS.
-		if (osName.toLowerCase().indexOf("linux") != -1) {
-			String[] cmd = new String[2];
-			cmd[0] = "df";
-			cmd[1] = par; // get the total space of file
-			Runtime rt = Runtime.getRuntime();
-
-			Process proc = rt.exec(cmd);
-			// get output from the command
-			ConsoleResulter outputResult = new ConsoleResulter(proc, proc
-					.getInputStream());
-
-			synchronized (proc) {
-				outputResult.start();
-				proc.wait();
-			}
-			// If there is no error, obtain the result
-			if (outputResult.resStr != null) {
-				// exit the subprocess safely
-				proc.waitFor();
-
-				// filter unnecessary information
-				String[] txtResult = outputResult.resStr
-						.split("\\D|\\p{javaLowerCase}|\\p{javaUpperCase}");
-				for (int i = 0, j = 0; i < txtResult.length; i++) {
-					if (txtResult[i].length() > 3) {
-						result[j++] = Long.parseLong(txtResult[i]) * 1024L;
-					}
-				}
-			}
-		}
-
-		// calculate free spaces according to df command
-		result[1] = result[0] - result[1];
-		return result[index];
-	}
-	
-	/**
-	 * @tests java.io.File#canExecute()
-	 * 
-	 * @since 1.6
-	 */
-	public void test_canExecute() {		
-		assertFalse(testFile.canExecute());
-		assertTrue(testFile.setExecutable(true, false));
-		assertTrue(testFile.canExecute());
-		assertTrue(testFile.setExecutable(true, true));
-		assertTrue(testFile.canExecute());
-
-		assertTrue(testFile.setExecutable(false, false));
-		assertFalse(testFile.canExecute());
-		assertTrue(testFile.setExecutable(false, true));
-		assertFalse(testFile.canExecute());
-
-		assertTrue(testFile.setExecutable(true, false));
-		assertTrue(testFile.canExecute());
-
-		// tests directory
-		assertTrue(testDir.canExecute());
-		assertTrue(testDir.setExecutable(false, true));
-		if (root) {
-			assertTrue(testDir.canExecute());
-		} else {
-			assertFalse(testDir.canExecute());			
-		}		
-		assertTrue(testDir.setExecutable(true, false));
-		assertTrue(testDir.canExecute());
-	}
-	
-	/**
-	 * @tests java.io.File#getFreeSpace()
-	 * 
-	 * @since 1.6
-	 */
-	public void test_getFreeSpace() throws Exception {
-		long fileSpace = getLinuxSpace(FREE_SPACE_NUM, testFile);
-		long dirSpace = getLinuxSpace(FREE_SPACE_NUM, testDir);
-		// in case we cannot fetch the value from command line
-		if (fileSpace > 0) {
-			assertEquals(fileSpace, testFile.getFreeSpace());			
-		}
-		
-		if (dirSpace > 0) {
-			assertEquals(dirSpace, testDir.getFreeSpace());		
-		}		
-	}
-
-	/**
-	 * @tests java.io.File#getTotalSpace()
-	 * 
-	 * @since 1.6
-	 */
-	public void test_getTotalSpace() throws Exception {
-		long fileSpace = getLinuxSpace(TOTAL_SPACE_NUM, testFile);
-		long dirSpace = getLinuxSpace(TOTAL_SPACE_NUM, testDir);
-		if (fileSpace > 0) {
-			assertEquals(fileSpace, testFile.getTotalSpace());
-		}
-		if (dirSpace > 0) {
-			assertEquals(dirSpace, testDir.getTotalSpace());			
-		}
-	}
-
-	/**
-	 * @tests java.io.File#getUsableSpace()
-	 * 
-	 * @since 1.6
-	 */
-	public void test_getUsableSpace() throws Exception {
-		long fileSpace = getLinuxSpace(USABLE_SPACE_NUM, testFile);
-		long dirSpace = getLinuxSpace(USABLE_SPACE_NUM, testDir);
-		if (fileSpace > 0) {
-			assertEquals(fileSpace, testFile.getUsableSpace());
-		}
-		if (dirSpace > 0) {
-			assertEquals(dirSpace, testDir.getUsableSpace());			
-		}
-	}
-	
-	/**
-	 * @tests java.io.File#setExecutable(boolean, boolean)
-	 * 
-	 * @since 1.6
-	 */
-	public void test_setExecutableZZ() {		
-		// setExecutable(true, true/false)
-		assertFalse(testFile.canExecute());
-		assertTrue(testFile.setExecutable(true, false));
-		assertTrue(testFile.canExecute());
-		assertTrue(testFile.setExecutable(true, true));
-		assertTrue(testFile.canExecute());
-
-		// setExecutable(false, true/false)
-		assertTrue(testFile.setExecutable(false, true));
-		if (root) {
-			assertTrue(testFile.canExecute());			
-		} else {
-			assertFalse(testFile.canExecute());			
-		}		
-		assertTrue(testFile.setExecutable(false, false));
-		assertFalse(testFile.canExecute());
-
-		// tests directory
-		assertTrue(testDir.canExecute());
-		assertTrue(testDir.setExecutable(false, true));
-		if (root) {
-			assertTrue(testDir.canExecute());
-		} else {
-			assertFalse(testDir.canExecute());
-		}
-		assertTrue(testDir.setExecutable(false, false));
-		if (root) {
-			assertTrue(testDir.canExecute());
-		} else {
-			assertFalse(testDir.canExecute());
-		}
-
-		assertTrue(testDir.setExecutable(true, true));
-		assertTrue(testDir.canExecute());
-		assertTrue(testDir.setExecutable(true, false));
-		assertTrue(testDir.canExecute());
-	}
-
-	/**
-	 * @tests java.io.File#setExecutable(boolean)
-	 * 
-	 * @since 1.6
-	 */
-	public void test_setExecutableZ() {
-		// So far this method only deals with the situation that the user is the
-		// owner of the file
-		assertTrue(testFile.setExecutable(true));
-		assertTrue(testFile.canExecute());
-		assertTrue(testFile.setExecutable(false));
-		assertFalse(testFile.canExecute());
-		assertTrue(testFile.setExecutable(true));
-
-		// tests directory
-		assertTrue(testDir.canExecute());
-		assertTrue(testDir.setExecutable(false));
-		if (root) {
-			assertTrue(testDir.canExecute());
-		} else {
-			assertFalse(testDir.canExecute());			
-		}		
-		assertTrue(testDir.setExecutable(true));
-		assertTrue(testDir.canExecute());
-	}
-	
-	/**
-	 * @tests java.io.File#setReadable(boolean, boolean)
-	 * 
-	 * @since 1.6
-	 */
-	public void test_setReadableZZ() throws Exception {
-		// setReadable(false, false/true) succeeds on Linux
-		// However, canRead() always returns true when the user is 'root'.
-		assertTrue(testFile.canRead());
-		assertTrue(testFile.setReadable(false, false));
-		if (root) {
-			assertTrue(testFile.canRead());
-		} else {
-			assertFalse(testFile.canRead());			
-		}
-		assertTrue(testFile.setReadable(false, true));
-		if (root) {
-			assertTrue(testFile.canRead());
-		} else {
-			assertFalse(testFile.canRead());			
-		}
-
-		// tests directory, setReadable(false, true/false)
-		assertTrue(testDir.canRead());
-		assertTrue(testDir.setReadable(false, true));
-		if (root) {
-			assertTrue(testDir.canRead());
-		} else {
-			assertFalse(testDir.canRead());			
-		}
-		assertTrue(testDir.setReadable(false, false));
-		if (root) {
-			assertTrue(testDir.canRead());
-		} else {
-			assertFalse(testDir.canRead());			
-		}
-
-		// setReadable(true, false/true) and set them in turn
-		assertTrue(testFile.setReadable(true, false));
-		assertTrue(testFile.canRead());
-		assertTrue(testFile.setReadable(false, true));
-		if (root) {
-			assertTrue(testFile.canRead());
-		} else {
-			assertFalse(testFile.canRead());			
-		}
-		assertTrue(testFile.setReadable(true, true));
-		assertTrue(testFile.canRead());
-		assertTrue(testFile.setReadable(false, true));
-		if (root) {
-			assertTrue(testFile.canRead());
-		} else {
-			assertFalse(testFile.canRead());			
-		}
-
-		// tests directory, setReadable(true, true/false)
-		assertTrue(testDir.setReadable(true, false));
-		assertTrue(testDir.canRead());
-		assertTrue(testDir.setReadable(true, true));
-		assertTrue(testDir.canRead());		
-	}
-
-	/**
-	 * @tests java.io.File#setReadable(boolean)
-	 * 
-	 * @since 1.6
-	 */
-	public void test_setReadableZ() {
-		// So far this method only deals with the situation that the user is the
-		// owner of the file. setReadable(false) succeeds on Linux
-		// However, canRead() always returns true when the user is 'root'.		
-		assertTrue(testFile.canRead());
-		assertTrue(testFile.setReadable(false));
-		if (root) {
-			assertTrue(testFile.canRead());
-		} else {
-			assertFalse(testFile.canRead());			
-		}		
-		assertTrue(testFile.setReadable(true));
-		assertTrue(testFile.canRead());
-
-		assertTrue(testDir.canRead());	
-		assertTrue(testDir.setReadable(false));
-		if (root) {
-			assertTrue(testDir.canRead());
-		} else {
-			assertFalse(testDir.canRead());			
-		}
-	}
-
-	@Override
-	protected void setUp() throws Exception {
-		super.setUp();
-		testFile = File.createTempFile("testfile", null);
-		testDir = new File(System.getProperty("java.io.tmpdir") + "/temp");
-		if (!testDir.exists()) {
-			testDir.mkdir();
-		}
-		root = System.getProperty("user.name").equals("root");
-	}
-
-	@Override
-	protected void tearDown() throws Exception {
-		testFile.delete();
-		testDir.delete();
-		testFile = null;
-		testDir = null;
-		root = false;
-		super.tearDown();
-	}
-
-}
+package org.apache.harmony.luni.tests.java.io;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import junit.framework.TestCase;
+
+/**
+ * Please note that this case can only be passed on Linux due to some file
+ * system dependent reason.
+ * 
+ */
+public class UnixFileTest extends TestCase {
+	private boolean root = false;
+	
+	private File testFile;
+
+	private File testDir;
+	
+	private static final int TOTAL_SPACE_NUM = 0;
+
+	private static final int FREE_SPACE_NUM = 1;
+
+	private static final int USABLE_SPACE_NUM = 2;
+
+	private static class ConsoleResulter extends Thread {
+		Process proc;
+
+		InputStream is;
+
+		String resStr;
+
+		ConsoleResulter(Process p, InputStream in) {
+			proc = p;
+			is = in;
+		}
+
+		@Override
+		public void run() {
+			StringBuffer result = new StringBuffer();
+			synchronized (result) {
+				try {
+					BufferedReader br = new BufferedReader(
+							new InputStreamReader(is));
+					String line;
+					while ((line = br.readLine()) != null) {
+						result.append(line);
+					}
+					if (result.length() != 0) {
+						resStr = result.toString();
+					}
+
+					br.close();
+				} catch (IOException ioe) {
+					result = null;
+				}
+				synchronized (proc) {
+					proc.notifyAll();
+				}
+			}
+		}
+	}
+
+	private static long getLinuxSpace(int index, File file) throws Exception {
+		long[] result = new long[3];
+		String par = file.getAbsolutePath();
+		String osName = System.getProperty("os.name");
+		// in case the test case will run under other OS.
+		if (osName.toLowerCase().indexOf("linux") != -1) {
+			String[] cmd = new String[2];
+			cmd[0] = "df";
+			cmd[1] = par; // get the total space of file
+			Runtime rt = Runtime.getRuntime();
+
+			Process proc = rt.exec(cmd);
+			// get output from the command
+			ConsoleResulter outputResult = new ConsoleResulter(proc, proc
+					.getInputStream());
+
+			synchronized (proc) {
+				outputResult.start();
+				proc.wait();
+			}
+			// If there is no error, obtain the result
+			if (outputResult.resStr != null) {
+				// exit the subprocess safely
+				proc.waitFor();
+
+				// filter unnecessary information
+				String[] txtResult = outputResult.resStr
+						.split("\\D|\\p{javaLowerCase}|\\p{javaUpperCase}");
+				for (int i = 0, j = 0; i < txtResult.length; i++) {
+					if (txtResult[i].length() > 3) {
+						result[j++] = Long.parseLong(txtResult[i]) * 1024L;
+					}
+				}
+			}
+		}
+
+		// calculate free spaces according to df command
+		result[1] = result[0] - result[1];
+		return result[index];
+	}
+	
+	/**
+	 * @tests java.io.File#canExecute()
+	 * 
+	 * @since 1.6
+	 */
+	public void test_canExecute() {		
+		assertFalse(testFile.canExecute());
+		assertTrue(testFile.setExecutable(true, false));
+		assertTrue(testFile.canExecute());
+		assertTrue(testFile.setExecutable(true, true));
+		assertTrue(testFile.canExecute());
+
+		assertTrue(testFile.setExecutable(false, false));
+		assertFalse(testFile.canExecute());
+		assertTrue(testFile.setExecutable(false, true));
+		assertFalse(testFile.canExecute());
+
+		assertTrue(testFile.setExecutable(true, false));
+		assertTrue(testFile.canExecute());
+
+		// tests directory
+		assertTrue(testDir.canExecute());
+		assertTrue(testDir.setExecutable(false, true));
+		if (root) {
+			assertTrue(testDir.canExecute());
+		} else {
+			assertFalse(testDir.canExecute());			
+		}		
+		assertTrue(testDir.setExecutable(true, false));
+		assertTrue(testDir.canExecute());
+	}
+	
+	/**
+	 * @tests java.io.File#getFreeSpace()
+	 * 
+	 * @since 1.6
+	 */
+	public void test_getFreeSpace() throws Exception {
+		long fileSpace = getLinuxSpace(FREE_SPACE_NUM, testFile);
+		long dirSpace = getLinuxSpace(FREE_SPACE_NUM, testDir);
+		// in case we cannot fetch the value from command line
+		if (fileSpace > 0) {
+			assertEquals(fileSpace, testFile.getFreeSpace());			
+		}
+		
+		if (dirSpace > 0) {
+			assertEquals(dirSpace, testDir.getFreeSpace());		
+		}		
+	}
+
+	/**
+	 * @tests java.io.File#getTotalSpace()
+	 * 
+	 * @since 1.6
+	 */
+	public void test_getTotalSpace() throws Exception {
+		long fileSpace = getLinuxSpace(TOTAL_SPACE_NUM, testFile);
+		long dirSpace = getLinuxSpace(TOTAL_SPACE_NUM, testDir);
+		if (fileSpace > 0) {
+			assertEquals(fileSpace, testFile.getTotalSpace());
+		}
+		if (dirSpace > 0) {
+			assertEquals(dirSpace, testDir.getTotalSpace());			
+		}
+	}
+
+	/**
+	 * @tests java.io.File#getUsableSpace()
+	 * 
+	 * @since 1.6
+	 */
+	public void test_getUsableSpace() throws Exception {
+		long fileSpace = getLinuxSpace(USABLE_SPACE_NUM, testFile);
+		long dirSpace = getLinuxSpace(USABLE_SPACE_NUM, testDir);
+		if (fileSpace > 0) {
+			assertEquals(fileSpace, testFile.getUsableSpace());
+		}
+		if (dirSpace > 0) {
+			assertEquals(dirSpace, testDir.getUsableSpace());			
+		}
+	}
+	
+	/**
+	 * @tests java.io.File#setExecutable(boolean, boolean)
+	 * 
+	 * @since 1.6
+	 */
+	public void test_setExecutableZZ() {		
+		// setExecutable(true, true/false)
+		assertFalse(testFile.canExecute());
+		assertTrue(testFile.setExecutable(true, false));
+		assertTrue(testFile.canExecute());
+		assertTrue(testFile.setExecutable(true, true));
+		assertTrue(testFile.canExecute());
+
+		// setExecutable(false, true/false)
+		assertTrue(testFile.setExecutable(false, true));
+		if (root) {
+			assertTrue(testFile.canExecute());			
+		} else {
+			assertFalse(testFile.canExecute());			
+		}		
+		assertTrue(testFile.setExecutable(false, false));
+		assertFalse(testFile.canExecute());
+
+		// tests directory
+		assertTrue(testDir.canExecute());
+		assertTrue(testDir.setExecutable(false, true));
+		if (root) {
+			assertTrue(testDir.canExecute());
+		} else {
+			assertFalse(testDir.canExecute());
+		}
+		assertTrue(testDir.setExecutable(false, false));
+		if (root) {
+			assertTrue(testDir.canExecute());
+		} else {
+			assertFalse(testDir.canExecute());
+		}
+
+		assertTrue(testDir.setExecutable(true, true));
+		assertTrue(testDir.canExecute());
+		assertTrue(testDir.setExecutable(true, false));
+		assertTrue(testDir.canExecute());
+	}
+
+	/**
+	 * @tests java.io.File#setExecutable(boolean)
+	 * 
+	 * @since 1.6
+	 */
+	public void test_setExecutableZ() {
+		// So far this method only deals with the situation that the user is the
+		// owner of the file
+		assertTrue(testFile.setExecutable(true));
+		assertTrue(testFile.canExecute());
+		assertTrue(testFile.setExecutable(false));
+		assertFalse(testFile.canExecute());
+		assertTrue(testFile.setExecutable(true));
+
+		// tests directory
+		assertTrue(testDir.canExecute());
+		assertTrue(testDir.setExecutable(false));
+		if (root) {
+			assertTrue(testDir.canExecute());
+		} else {
+			assertFalse(testDir.canExecute());			
+		}		
+		assertTrue(testDir.setExecutable(true));
+		assertTrue(testDir.canExecute());
+	}
+	
+	/**
+	 * @tests java.io.File#setReadable(boolean, boolean)
+	 * 
+	 * @since 1.6
+	 */
+	public void test_setReadableZZ() throws Exception {
+		// setReadable(false, false/true) succeeds on Linux
+		// However, canRead() always returns true when the user is 'root'.
+		assertTrue(testFile.canRead());
+		assertTrue(testFile.setReadable(false, false));
+		if (root) {
+			assertTrue(testFile.canRead());
+		} else {
+			assertFalse(testFile.canRead());			
+		}
+		assertTrue(testFile.setReadable(false, true));
+		if (root) {
+			assertTrue(testFile.canRead());
+		} else {
+			assertFalse(testFile.canRead());			
+		}
+
+		// tests directory, setReadable(false, true/false)
+		assertTrue(testDir.canRead());
+		assertTrue(testDir.setReadable(false, true));
+		if (root) {
+			assertTrue(testDir.canRead());
+		} else {
+			assertFalse(testDir.canRead());			
+		}
+		assertTrue(testDir.setReadable(false, false));
+		if (root) {
+			assertTrue(testDir.canRead());
+		} else {
+			assertFalse(testDir.canRead());			
+		}
+
+		// setReadable(true, false/true) and set them in turn
+		assertTrue(testFile.setReadable(true, false));
+		assertTrue(testFile.canRead());
+		assertTrue(testFile.setReadable(false, true));
+		if (root) {
+			assertTrue(testFile.canRead());
+		} else {
+			assertFalse(testFile.canRead());			
+		}
+		assertTrue(testFile.setReadable(true, true));
+		assertTrue(testFile.canRead());
+		assertTrue(testFile.setReadable(false, true));
+		if (root) {
+			assertTrue(testFile.canRead());
+		} else {
+			assertFalse(testFile.canRead());			
+		}
+
+		// tests directory, setReadable(true, true/false)
+		assertTrue(testDir.setReadable(true, false));
+		assertTrue(testDir.canRead());
+		assertTrue(testDir.setReadable(true, true));
+		assertTrue(testDir.canRead());		
+	}
+
+	/**
+	 * @tests java.io.File#setReadable(boolean)
+	 * 
+	 * @since 1.6
+	 */
+	public void test_setReadableZ() {
+		// So far this method only deals with the situation that the user is the
+		// owner of the file. setReadable(false) succeeds on Linux
+		// However, canRead() always returns true when the user is 'root'.		
+		assertTrue(testFile.canRead());
+		assertTrue(testFile.setReadable(false));
+		if (root) {
+			assertTrue(testFile.canRead());
+		} else {
+			assertFalse(testFile.canRead());			
+		}		
+		assertTrue(testFile.setReadable(true));
+		assertTrue(testFile.canRead());
+
+		assertTrue(testDir.canRead());	
+		assertTrue(testDir.setReadable(false));
+		if (root) {
+			assertTrue(testDir.canRead());
+		} else {
+			assertFalse(testDir.canRead());			
+		}
+	}
+
+	@Override
+	protected void setUp() throws Exception {
+		super.setUp();
+		testFile = File.createTempFile("testfile", null);
+		testDir = new File(System.getProperty("java.io.tmpdir") + "/temp");
+		if (!testDir.exists()) {
+			testDir.mkdir();
+		}
+		root = System.getProperty("user.name").equals("root");
+	}
+
+	@Override
+	protected void tearDown() throws Exception {
+		testFile.delete();
+		testDir.delete();
+		testFile = null;
+		testDir = null;
+		root = false;
+		super.tearDown();
+	}
+
+    public void test_getCanonicalPath() throws IOException {
+        File tmpFolder1 = new File("folder1");
+        tmpFolder1.mkdirs();
+        tmpFolder1.deleteOnExit();
+
+        File tmpFolder2 = new File(tmpFolder1.toString() + "/folder2");
+        tmpFolder2.mkdirs();
+        tmpFolder2.deleteOnExit();
+
+        File tmpFolder3 = new File(tmpFolder2.toString() + "/folder3");
+        tmpFolder3.mkdirs();
+        tmpFolder3.deleteOnExit();
+
+        File tmpFolder4 = new File(tmpFolder3.toString() + "/folder4");
+        tmpFolder4.mkdirs();
+        tmpFolder4.deleteOnExit();
+
+        // make a link to folder1/folder2
+        Runtime.getRuntime().exec("ln -s folder1/folder2 folder2");
+        File linkFile = new File("folder2");
+        linkFile.deleteOnExit();
+
+        File file = new File("folder2");
+        assertEquals(tmpFolder2.getCanonicalPath(), file.getCanonicalPath());
+
+        file = new File("folder1/folder2");
+        assertEquals(tmpFolder2.getCanonicalPath(), file.getCanonicalPath());
+
+        file = new File("folder2/folder3");
+        assertEquals(tmpFolder3.getCanonicalPath(), file.getCanonicalPath());
+
+        file = new File("folder2/folder3/folder4");
+        assertEquals(tmpFolder4.getCanonicalPath(), file.getCanonicalPath());
+
+        file = new File("folder1/folder2/folder3");
+        assertEquals(tmpFolder3.getCanonicalPath(), file.getCanonicalPath());
+
+        file = new File("folder1/folder2/folder3/folder4");
+        assertEquals(tmpFolder4.getCanonicalPath(), file.getCanonicalPath());
+    }
+}

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/DatagramChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/DatagramChannelImpl.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/DatagramChannelImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/DatagramChannelImpl.java Thu Dec 18 01:46:12 2008
@@ -37,7 +37,7 @@
 import java.nio.channels.spi.SelectorProvider;
 
 import org.apache.harmony.luni.net.NetUtil;
-import org.apache.harmony.luni.net.SocketImplProvider;
+import org.apache.harmony.luni.net.PlainDatagramSocketImpl;
 import org.apache.harmony.luni.platform.FileDescriptorHandler;
 import org.apache.harmony.luni.platform.INetworkSystem;
 import org.apache.harmony.luni.platform.Platform;
@@ -117,8 +117,8 @@
     @Override
     synchronized public DatagramSocket socket() {
         if (null == socket) {
-            socket = new DatagramSocketAdapter(SocketImplProvider
-                    .getDatagramSocketImpl(fd, localPort), this);
+            socket = new DatagramSocketAdapter(
+                    new PlainDatagramSocketImpl(fd, localPort), this);
         }
         return socket;
     }

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=727683&r1=727682&r2=727683&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 Dec 18 01:46:12 2008
@@ -32,7 +32,7 @@
 import java.nio.channels.spi.SelectorProvider;
 
 import org.apache.harmony.luni.net.NetUtil;
-import org.apache.harmony.luni.net.SocketImplProvider;
+import org.apache.harmony.luni.net.PlainSocketImpl;
 import org.apache.harmony.luni.platform.FileDescriptorHandler;
 import org.apache.harmony.luni.platform.Platform;
 
@@ -42,10 +42,6 @@
 public class ServerSocketChannelImpl extends ServerSocketChannel implements
         FileDescriptorHandler {
 
-    // ----------------------------------------------------
-    // Class variables
-    // ----------------------------------------------------
-
     // status un-init, not initialized.
     private static final int SERVER_STATUS_UNINIT = -1;
 
@@ -55,10 +51,6 @@
     // status closed.
     private static final int SERVER_STATUS_CLOSED = 1;
 
-    // -------------------------------------------------------------------
-    // Instance variables
-    // -------------------------------------------------------------------
-
     // The fd to interact with native code
     private final FileDescriptor fd;
 
@@ -76,10 +68,6 @@
     private static class AcceptLock {}
     private final Object acceptLock = new AcceptLock();
 
-    // ----------------------------------------------------
-    // Constructor
-    // ----------------------------------------------------
-
     /*
      * Constructor
      */
@@ -87,9 +75,9 @@
         super(sp);
         status = SERVER_STATUS_OPEN;
         fd = new FileDescriptor();
-        Platform.getNetworkSystem().createServerStreamSocket(fd,
+        Platform.getNetworkSystem().createStreamSocket(fd,
                 NetUtil.preferIPv4Stack());
-        impl = SocketImplProvider.getServerSocketImpl(fd);
+        impl = new PlainSocketImpl(fd);
         socket = new ServerSocketAdapter(impl, this);
     }
     
@@ -99,15 +87,11 @@
         super(SelectorProvider.provider());
         status = SERVER_STATUS_OPEN;
         fd = new FileDescriptor();
-        impl = SocketImplProvider.getServerSocketImpl(fd);        
+        impl = new PlainSocketImpl(fd);
         socket = new ServerSocketAdapter(impl, this);
         isBound = false;
     }
 
-    // ----------------------------------------------------
-    // Methods
-    // ----------------------------------------------------
-
     /*
      * Getting the internal Socket If we have not the socket, we create a new
      * one.
@@ -168,10 +152,6 @@
         return sockChannel;
     }
 
-    // -------------------------------------------------------------------
-    // Protected inherited methods
-    // -------------------------------------------------------------------
-
     /*
      * @see java.nio.channels.spi.AbstractSelectableChannel#implConfigureBlocking
      * 
@@ -202,10 +182,6 @@
         return fd;
     }
 
-    // ----------------------------------------------------
-    // Adapter classes.
-    // ----------------------------------------------------
-
     /*
      * The adapter class of ServerSocket.
      */

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=727683&r1=727682&r2=727683&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 Dec 18 01:46:12 2008
@@ -42,7 +42,7 @@
 import java.nio.channels.UnsupportedAddressTypeException;
 import java.nio.channels.spi.SelectorProvider;
 
-import org.apache.harmony.luni.net.SocketImplProvider;
+import org.apache.harmony.luni.net.PlainSocketImpl;
 import org.apache.harmony.luni.platform.FileDescriptorHandler;
 import org.apache.harmony.luni.platform.INetworkSystem;
 import org.apache.harmony.luni.platform.Platform;
@@ -147,7 +147,7 @@
         fd = new FileDescriptor();
         status = SOCKET_STATUS_UNCONNECTED;
         if (connect) {
-            networkSystem.createSocket(fd, true);
+            networkSystem.createStreamSocket(fd, true);
         }
     }
 
@@ -196,8 +196,8 @@
                     addr = connectAddress.getAddress();
                     port = connectAddress.getPort();
                 }
-                socket = new SocketAdapter(SocketImplProvider.getSocketImpl(fd,
-                        localPort, addr, port), this);
+                socket = new SocketAdapter(
+                        new PlainSocketImpl(fd, localPort, addr, port), this);
             } catch (SocketException e) {
                 return null;
             }
@@ -242,9 +242,15 @@
 
         // check the address
         InetSocketAddress inetSocketAddress = validateAddress(socketAddress);
+        InetAddress normalAddr = inetSocketAddress.getAddress();
+
+        // When connecting, map ANY address to Localhost
+        if (normalAddr.isAnyLocalAddress()) {
+            normalAddr = InetAddress.getLocalHost();
+        }
 
         int port = inetSocketAddress.getPort();
-        String hostName = inetSocketAddress.getAddress().getHostName();
+        String hostName = normalAddr.getHostName();
         // security check
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
@@ -256,23 +262,12 @@
         boolean finished = false;
 
         try {
-            if (!isBound) {
-                // bind
-                networkSystem.bind2(fd, 0, true, InetAddress
-                        .getByAddress(new byte[] { 0, 0, 0, 0 }));
-                isBound = true;
-            }
-
             if (isBlocking()) {
                 begin();
-                result = networkSystem.connect(fd, trafficClass,
-                        inetSocketAddress.getAddress(), inetSocketAddress
-                                .getPort());
-
+                result = networkSystem.connect(fd, trafficClass, normalAddr, port);
             } else {
                 result = networkSystem.connectWithTimeout(fd, 0, trafficClass,
-                        inetSocketAddress.getAddress(), inetSocketAddress
-                                .getPort(), HY_SOCK_STEP_START, connectContext);
+                        normalAddr, port, HY_SOCK_STEP_START, connectContext);
                 // set back to nonblocking to work around with a bug in portlib
                 if (!this.isBlocking()) {
                     networkSystem.setNonBlocking(fd, true);
@@ -357,6 +352,8 @@
         synchronized (this) {
             status = (finished ? SOCKET_STATUS_CONNECTED : status);
             isBound = finished;
+            // TPE: Workaround for bug that turns socket back to blocking
+            if (!isBlocking()) implConfigureBlocking(false);
         }
         return finished;
     }

Propchange: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/native/niochar/windows/hyniochar.def
            ('svn:mergeinfo' removed)

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java Thu Dec 18 01:46:12 2008
@@ -30,6 +30,11 @@
  */
 public class AttributeDefinitionBands extends BandSet {
 
+    public static final int CONTEXT_CLASS = 0;
+    public static final int CONTEXT_CODE = 3;
+    public static final int CONTEXT_FIELD = 1;
+    public static final int CONTEXT_METHOD = 2;
+
     private final Map layouts = new HashMap();
 
     private final SegmentHeader segmentHeader;
@@ -42,18 +47,22 @@
     private final List attributeDefinitions = new ArrayList();
 
     private final CpBands cpBands;
+    private final Segment segment;
 
-    public AttributeDefinitionBands(SegmentHeader segmentHeader, CpBands cpBands) {
-        this.segmentHeader = segmentHeader;
-        this.cpBands = cpBands;
+    public AttributeDefinitionBands(Segment segment) {
+        this.segmentHeader = segment.getSegmentHeader();
+        this.cpBands = segment.getCpBands();
+        this.segment = segment;
     }
 
     public void finaliseBands() {
+        addSyntheticDefinitions();
         segmentHeader.setAttribute_definition_count(classAttributes.keySet()
                 .size()
                 + methodAttributes.keySet().size()
                 + fieldAttributes.keySet().size()
-                + codeAttributes.keySet().size());
+                + codeAttributes.keySet().size()
+                + attributeDefinitions.size());
         if (classAttributes.keySet().size() > 7) {
             segmentHeader.setHave_class_flags_hi(true);
         }
@@ -73,31 +82,31 @@
         if(classAttributes.size() > 7) {
             availableClassIndices = addHighIndices(availableClassIndices);
         }
-        addAttributeDefinitions(classAttributes, availableClassIndices, 0);
+        addAttributeDefinitions(classAttributes, availableClassIndices, CONTEXT_CLASS);
         int[] availableMethodIndices = new int[] {26, 27, 28, 29, 30, 31};
         if(methodAttributes.size() > 6) {
             availableMethodIndices = addHighIndices(availableMethodIndices);
         }
-        addAttributeDefinitions(methodAttributes, availableMethodIndices, 0);
+        addAttributeDefinitions(methodAttributes, availableMethodIndices, CONTEXT_METHOD);
         int[] availableFieldIndices = new int[] {18, 23, 24, 25, 26, 27, 28, 29, 30, 31};
         if(fieldAttributes.size() > 10) {
             availableFieldIndices = addHighIndices(availableFieldIndices);
         }
-        addAttributeDefinitions(fieldAttributes, availableFieldIndices, 0);
+        addAttributeDefinitions(fieldAttributes, availableFieldIndices, CONTEXT_FIELD);
         int[] availableCodeIndices = new int[] {17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
         if(codeAttributes.size() > 15) {
             availableCodeIndices = addHighIndices(availableCodeIndices);
         }
-        addAttributeDefinitions(codeAttributes, availableCodeIndices, 0);
+        addAttributeDefinitions(codeAttributes, availableCodeIndices, CONTEXT_CODE);
 
         int[] attributeDefinitionHeader = new int[attributeDefinitions.size()];
         int[] attributeDefinitionName = new int[attributeDefinitions.size()];
         int[] attributeDefinitionLayout = new int[attributeDefinitions.size()];
         for (int i = 0; i < attributeDefinitionLayout.length; i++) {
             AttributeDefinition def = (AttributeDefinition) attributeDefinitions.get(i);
-            attributeDefinitionHeader[i] = def.contextType | (def.index << 2);
-            attributeDefinitionName[i] = cpBands.getCPUtf8(def.name).getIndex();
-            attributeDefinitionLayout[i] = cpBands.getCPUtf8(def.layout).getIndex();
+            attributeDefinitionHeader[i] = def.contextType | (def.index + 1 << 2);
+            attributeDefinitionName[i] = def.name.getIndex();
+            attributeDefinitionLayout[i] = def.layout.getIndex();
         }
 
         out.write(encodeBandInt("attributeDefinitionHeader", attributeDefinitionHeader, Codec.BYTE1));
@@ -105,6 +114,25 @@
         out.write(encodeBandInt("attributeDefinitionLayout", attributeDefinitionLayout, Codec.UNSIGNED5));
     }
 
+    private void addSyntheticDefinitions() {
+        boolean anySytheticClasses = segment.getClassBands().isAnySyntheticClasses();
+        boolean anySyntheticMethods = segment.getClassBands().isAnySyntheticMethods();
+        boolean anySyntheticFields = segment.getClassBands().isAnySyntheticFields();
+        if(anySytheticClasses || anySyntheticMethods || anySyntheticFields) {
+            CPUTF8 syntheticUTF = cpBands.getCPUtf8("Synthetic");
+            CPUTF8 emptyUTF = cpBands.getCPUtf8("");
+            if(anySytheticClasses) {
+                attributeDefinitions.add(new AttributeDefinition(12, CONTEXT_CLASS, syntheticUTF, emptyUTF));
+            }
+            if(anySyntheticMethods) {
+                attributeDefinitions.add(new AttributeDefinition(12, CONTEXT_METHOD, syntheticUTF, emptyUTF));
+            }
+            if(anySyntheticFields) {
+                attributeDefinitions.add(new AttributeDefinition(12, CONTEXT_FIELD, syntheticUTF, emptyUTF));
+            }
+        }
+    }
+
     private int[] addHighIndices(int[] availableIndices) {
         int[] temp = new int[availableIndices.length + 32];
         for (int i = 0; i < availableIndices.length; i++) {
@@ -125,7 +153,7 @@
             String name = (String) iterator.next();
             String layout = (String) layouts.get(name);
             int index = availableIndices[i];
-            attributeDefinitions.add(new AttributeDefinition(index, contextType, name, layout));
+            attributeDefinitions.add(new AttributeDefinition(index, contextType, cpBands.getCPUtf8(name), cpBands.getCPUtf8(layout)));
         }
     }
 
@@ -137,11 +165,11 @@
 
         public int index;
         public int contextType;
-        public String name;
-        public String layout;
+        public CPUTF8 name;
+        public CPUTF8 layout;
 
-        public AttributeDefinition(int index, int contextType, String name,
-                String layout) {
+        public AttributeDefinition(int index, int contextType, CPUTF8 name,
+                CPUTF8 layout) {
             this.index = index;
             this.contextType = contextType;
             this.name = name;

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java?rev=727683&r1=727682&r2=727683&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java Thu Dec 18 01:46:12 2008
@@ -283,6 +283,11 @@
 //        }
         long z = value;
         if (isSigned()) {
+            if(z < Integer.MIN_VALUE) {
+                z += 4294967296L;
+            } else if (z > Integer.MAX_VALUE) {
+                z -= 4294967296L;
+            }
             if (z < 0) {
                 z = (-z << s) - 1;
             } else {



Mime
View raw message