You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by qi...@apache.org on 2008/11/27 06:10:42 UTC

svn commit: r721077 [5/12] - in /harmony/enhanced/classlib/branches/java6: ./ depends/files/ depends/jars/ depends/manifests/asm-3.1/ depends/manifests/asm-3.1/META-INF/ depends/manifests/bcel-5.2/ make/ modules/accessibility/ modules/accessibility/src...

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CollectionsTest.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/CollectionsTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CollectionsTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CollectionsTest.java Wed Nov 26 21:10:32 2008
@@ -292,11 +292,12 @@
 			Collections.binarySearch(null, new Object());
 			fail("Expected NullPointerException for null list parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 		for (int counter = 0; counter < llSize; counter++) {
-			assertTrue("Returned incorrect binary search item position", ll
-					.get(Collections.binarySearch(ll, ll.get(counter))) == ll
-					.get(counter));
+			assertEquals("Returned incorrect binary search item position", ll
+                    .get(counter), ll.get(Collections.binarySearch(ll, ll
+                    .get(counter))));
 		}
 	}
 
@@ -317,14 +318,14 @@
 			Collections.binarySearch(null, new Object(), comp);
 			fail("Expected NullPointerException for null list parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 		for (int counter = 0; counter < rSize; counter++) {
-			assertTrue(
-					"Returned incorrect binary search item position using custom comparator",
-					myReversedLinkedList.get(Collections.binarySearch(
-							myReversedLinkedList, myReversedLinkedList
-									.get(counter), comp)) == myReversedLinkedList
-							.get(counter));
+			assertEquals(
+                    "Returned incorrect binary search item position using custom comparator",
+                    myReversedLinkedList.get(counter), myReversedLinkedList
+                            .get(Collections.binarySearch(myReversedLinkedList,
+                                    myReversedLinkedList.get(counter), comp)));
 		}
 	}
 
@@ -339,11 +340,13 @@
 			Collections.copy(null, ll);
 			fail("Expected NullPointerException for null list first parameter");
 		} catch (NullPointerException e) {
+		    //Expected
 		}
 		try {
 			Collections.copy(ll, null);
 			fail("Expected NullPointerException for null list second parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 		final int llSize = ll.size();
 		ll.set(25, null);
@@ -355,8 +358,8 @@
 		al.add(extraElement2);
 		Collections.copy(al, ll);
 		for (int counter = 0; counter < llSize; counter++) {
-			assertTrue("Elements do not match after copying collection", al
-					.get(counter) == ll.get(counter));
+			assertEquals("Elements do not match after copying collection", ll
+                    .get(counter), al.get(counter));
 		}
 		assertTrue("Elements after copied elements affected by copy",
 				extraElement == al.get(llSize)
@@ -378,6 +381,7 @@
 			Collections.copy(a2, a1);
 			fail("Expected IndexOutOfBoundsException");
 		} catch (IndexOutOfBoundsException e) {
+            //Expected
 		}
 
 		assertEquals("aa", a2.get(0));
@@ -393,11 +397,12 @@
 		ts.addAll(s);
 		Enumeration e = Collections.enumeration(ts);
 		int count = 0;
-		while (e.hasMoreElements())
-			assertTrue("Returned incorrect enumeration",
-					e.nextElement() == objArray[count++]);
-		assertTrue("Enumeration missing elements: " + count,
-				count == objArray.length);
+		while (e.hasMoreElements()) {
+			assertEquals("Returned incorrect enumeration", e.nextElement(),
+                    objArray[count++]);
+        }
+		assertEquals("Enumeration missing elements: " + count, objArray.length,
+                count);
 	}
 
 	/**
@@ -410,16 +415,17 @@
 			Collections.fill(null, new Object());
 			fail("Expected NullPointerException for null list parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 		final int size = ll.size();
 		Collections.fill(ll, "k");
-		assertTrue("Fill modified list size", size == ll.size());
+		assertEquals("Fill modified list size", size, ll.size());
 		Iterator i = ll.iterator();
 		while (i.hasNext())
 			assertEquals("Failed to fill elements", "k", i.next());
 
 		Collections.fill(ll, null);
-		assertTrue("Fill with nulls modified list size", size == ll.size());
+		assertEquals("Fill with nulls modified list size", size, ll.size());
 		i = ll.iterator();
 		while (i.hasNext())
 			assertNull("Failed to fill with nulls", i.next());
@@ -432,8 +438,8 @@
 		// Test for method java.lang.Object
 		// java.util.Collections.max(java.util.Collection)
 		// assumes s, objArray are sorted
-		assertTrue("Returned incorrect max element",
-				Collections.max(s) == objArray[objArray.length - 1]);
+		assertEquals("Returned incorrect max element", Collections.max(s),
+                objArray[objArray.length - 1]);
 	}
 
 	/**
@@ -447,10 +453,10 @@
 
 		// With this custom (backwards) comparator the 'max' element should be
 		// the smallest in the list
-		assertTrue(
-				"Returned incorrect max element using custom comparator",
-				Collections.max(mys, new ReversedMyIntComparator()) == myobjArray[0]);
-	}
+		assertEquals("Returned incorrect max element using custom comparator",
+                Collections.max(mys, new ReversedMyIntComparator()),
+                myobjArray[0]);
+    }
 
 	/**
 	 * @tests java.util.Collections#min(java.util.Collection)
@@ -459,8 +465,8 @@
 		// Test for method java.lang.Object
 		// java.util.Collections.min(java.util.Collection)
 		// assumes s, objArray are sorted
-		assertTrue("Returned incorrect min element",
-				Collections.min(s) == objArray[0]);
+		assertEquals("Returned incorrect min element", Collections.min(s),
+                objArray[0]);
 	}
 
 	/**
@@ -474,10 +480,10 @@
 
 		// With this custom (backwards) comparator the 'min' element should be
 		// the largest in the list
-		assertTrue(
-				"Returned incorrect min element using custom comparator",
-				Collections.min(mys, new ReversedMyIntComparator()) == myobjArray[objArray.length - 1]);
-	}
+		assertEquals("Returned incorrect min element using custom comparator",
+                Collections.min(mys, new ReversedMyIntComparator()),
+                myobjArray[objArray.length - 1]);
+    }
 
 	/**
 	 * @tests java.util.Collections#nCopies(int, java.lang.Object)
@@ -489,11 +495,11 @@
 		List l = Collections.nCopies(100, o);
 		Iterator i = l.iterator();
 		Object first = i.next();
-		assertTrue("Returned list consists of copies not refs", first == o);
+		assertEquals("Returned list consists of copies not refs", first, o);
 		assertEquals("Returned list of incorrect size", 100, l.size());
 		assertTrue("Contains", l.contains(o));
-		assertTrue("Contains null", !l.contains(null));
-		assertTrue("null nCopies contains", !Collections.nCopies(2, null)
+		assertFalse("Contains null", l.contains(null));
+		assertFalse("null nCopies contains", Collections.nCopies(2, null)
 				.contains(o));
 		assertTrue("null nCopies contains null", Collections.nCopies(2, null)
 				.contains(null));
@@ -507,8 +513,7 @@
 			l.add(o);
 			fail("Returned list is not immutable");
 		} catch (UnsupportedOperationException e) {
-			// Correct
-			return;
+			// Expected
 		}
 		try {
 			Collections.nCopies(-2, new HashSet());
@@ -527,21 +532,22 @@
 			Collections.reverse(null);
 			fail("Expected NullPointerException for null list parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 		Collections.reverse(ll);
 		Iterator i = ll.iterator();
 		int count = objArray.length - 1;
 		while (i.hasNext()) {
-			assertTrue("Failed to reverse collection",
-					i.next() == objArray[count]);
-			--count;
+			assertEquals("Failed to reverse collection", objArray[count], i
+                    .next());
+            --count;
 		}
 		ArrayList myList = new ArrayList();
 		myList.add(null);
 		myList.add(new Integer(20));
 		Collections.reverse(myList);
-		assertTrue("Did not reverse correctly--first element is: "
-				+ myList.get(0), myList.get(0).equals(new Integer(20)));
+		assertEquals("Did not reverse correctly--first element is: "
+                + myList.get(0), new Integer(20), myList.get(0));
 		assertNull("Did not reverse correctly--second element is: "
 				+ myList.get(1), myList.get(1));
 	}
@@ -558,8 +564,8 @@
 		Collections.sort(list2, comp);
 		final int llSize = ll.size();
 		for (int counter = 0; counter < llSize; counter++)
-			assertTrue("New comparator does not reverse sorting order", ll
-					.get(counter) == list2.get(llSize - counter - 1));
+			assertEquals("New comparator does not reverse sorting order", list2
+                    .get(llSize - counter - 1), ll.get(counter));
 	}
 
 	/**
@@ -575,6 +581,7 @@
 			Collections.shuffle(null);
 			fail("Expected NullPointerException for null list parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 		ArrayList al = new ArrayList();
 		al.addAll(ll);
@@ -602,15 +609,15 @@
 				sorted = false;
 			}
 		}
-		assertTrue("Shuffling sorted " + type
-				+ " list resulted in sorted list (should be unlikely)", !sorted);
+		assertFalse("Shuffling sorted " + type
+				+ " list resulted in sorted list (should be unlikely)", sorted);
 		for (int counter = 0; counter < 20; counter++) {
 			index = 30031 * counter % (size + 1); // 30031 is a large prime
 			if (list.get(index) != ll.get(index))
 				allMatch = false;
 		}
-		assertTrue("Too many element positions match in shuffled " + type
-				+ " list", !allMatch);
+		assertFalse("Too many element positions match in shuffled " + type
+				+ " list", allMatch);
 	}
 
 	/**
@@ -627,6 +634,7 @@
 			Collections.shuffle(null, new Random(200));
 			fail("Expected NullPointerException for null list parameter");
 		} catch (NullPointerException e) {
+            //Excepted
 		}
 		ArrayList al = new ArrayList();
 		al.addAll(ll);
@@ -655,18 +663,17 @@
 		Set single = Collections.singleton(o);
 		assertEquals("Wrong size", 1, single.size());
 		assertTrue("Contains", single.contains(o));
-		assertTrue("Contains null", !single.contains(null));
-		assertTrue("null nCopies contains", !Collections.singleton(null)
+		assertFalse("Contains null", single.contains(null));
+		assertFalse("null nCopies contains", Collections.singleton(null)
 				.contains(o));
 		assertTrue("null nCopies contains null", Collections.singleton(null)
 				.contains(null));
 		try {
 			single.add("l");
+            fail("Allowed modification of singleton");
 		} catch (UnsupportedOperationException e) {
-			// Correct
-			return;
+			// Excepted
 		}
-		fail("Allowed modification of singleton");
 	}
 
 	/**
@@ -681,6 +688,7 @@
                         Collections.sort((List)null);
 			fail("Expected NullPointerException for null list parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 		Collections.shuffle(ll);
 		Collections.sort(ll);
@@ -709,6 +717,7 @@
 			Collections.sort(null, comp);
 			fail("Expected NullPointerException for null list parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 		Collections.shuffle(myll);
 		Collections.sort(myll, comp);
@@ -738,24 +747,28 @@
 			Collections.swap(smallList, -1, 6);
 			fail("Expected IndexOutOfBoundsException for -1");
 		} catch (IndexOutOfBoundsException e) {
+            //Expected
 		}
 
 		try {
 			Collections.swap(smallList, 6, -1);
 			fail("Expected IndexOutOfBoundsException for -1");
 		} catch (IndexOutOfBoundsException e) {
+            //Expected
 		}
 
 		try {
 			Collections.swap(smallList, 6, 11);
 			fail("Expected IndexOutOfBoundsException for 11");
 		} catch (IndexOutOfBoundsException e) {
+            //Expected
 		}
 
 		try {
 			Collections.swap(smallList, 11, 6);
 			fail("Expected IndexOutOfBoundsException for 11");
 		} catch (IndexOutOfBoundsException e) {
+            //Expected
 		}
 
 		// Ensure a NPE is thrown if the list is NULL
@@ -763,6 +776,7 @@
 			Collections.swap(null, 1, 1);
 			fail("Expected NullPointerException for null list parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 
 		// test with valid parameters
@@ -799,6 +813,7 @@
 			Collections.replaceAll(null, new Object(), new Object());
 			fail("Expected NullPointerException for null list parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 
 		// test replace for an element that is not in the list
@@ -878,6 +893,7 @@
 			Collections.rotate(null, 0);
 			fail("Expected NullPointerException for null list parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 
 		// Test rotating a Sequential Access List
@@ -992,11 +1008,13 @@
 			Collections.indexOfSubList(null, list);
 			fail("Expected NullPointerException for null list first parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 		try {
 			Collections.indexOfSubList(list, null);
 			fail("Expected NullPointerException for null list second parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 
 		String string1 = "A-B-C-D-E-S-JF-SUB-G-H-I-J-SUBL-K-L-LIST-M-N--S-S-O-SUBLIS-P-Q-R-SUBLIST-S-T-U-V-W-X-Y-Z";
@@ -1114,11 +1132,13 @@
 			Collections.lastIndexOfSubList(null, list);
 			fail("Expected NullPointerException for null list first parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 		try {
 			Collections.lastIndexOfSubList(list, null);
 			fail("Expected NullPointerException for null list second parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 
 		testwithCharList(1, string1, "B", false);
@@ -1225,9 +1245,10 @@
 	}
 
 	/**
+	 * @throws InterruptedException
 	 * @tests java.util.Collections#synchronizedCollection(java.util.Collection)
 	 */
-	public void test_synchronizedCollectionLjava_util_Collection() {
+	public void test_synchronizedCollectionLjava_util_Collection() throws InterruptedException {
 		// Test for method java.util.Collection
 		// java.util.Collections.synchronizedCollection(java.util.Collection)
 
@@ -1252,10 +1273,12 @@
 		offsetThread.start();
 		while ((normalSynchChecker.getNumberOfChecks() < numberOfLoops)
 				|| (offsetSynchChecker.getNumberOfChecks() < numberOfLoops)) {
-			try {
-				Thread.sleep(10);
-			} catch (InterruptedException e) {
-			}
+	    
+                       try {
+                               Thread.sleep(10);
+                       } catch (InterruptedException e) {
+                       }
+
 		}
 		assertTrue("Returned collection corrupted by multiple thread access",
 				normalSynchChecker.getResult()
@@ -1277,6 +1300,11 @@
 		}
 		new Support_CollectionTest("", Collections
 				.synchronizedCollection(smallList)).runTest();
+
+        //Test self reference
+        synchCol = Collections.synchronizedCollection(smallList);
+        synchCol.add(smallList);
+        assertTrue("should contain self ref", synchCol.toString().indexOf("(this") > -1);
 	}
 
 	/**
@@ -1287,6 +1315,7 @@
 			Collections.synchronizedList(null);
 			fail("Expected NullPointerException for null list parameter");
 		} catch (NullPointerException e) {
+            //Expected
 		}
 
 		// test with a Sequential Access List
@@ -1299,8 +1328,9 @@
 			smallList.add(objArray[i]);
 		}
 		myList = Collections.synchronizedList(smallList);
-		new Support_ListTest("", myList).runTest();
 
+		new Support_ListTest("", myList).runTest();
+        
 		// test with a Random Access List
 		smallList = new ArrayList();
 		testSynchronizedList(smallList, "Random Access");
@@ -1311,6 +1341,11 @@
 		}
 		myList = Collections.synchronizedList(smallList);
 		new Support_ListTest("", myList).runTest();
+        
+		//Test self reference
+        myList = Collections.synchronizedList(smallList);
+        myList.add(smallList);
+        assertTrue("should contain self ref", myList.toString().indexOf("(this") > -1);
 	}
 
 	private void testSynchronizedList(List smallList, String type) {
@@ -1344,13 +1379,14 @@
 			try {
 				Thread.sleep(10);
 			} catch (InterruptedException e) {
+                //Expected
 			}
 		}
 		assertTrue(
-				type
-						+ " list tests: Returned list corrupted by multiple thread access",
-				normalSynchChecker.getResult()
-						&& offsetSynchChecker.getResult());
+                type
+                        + " list tests: Returned list corrupted by multiple thread access",
+                normalSynchChecker.getResult()
+                        && offsetSynchChecker.getResult());
 		try {
 			normalThread.join(5000);
 			offsetThread.join(5000);
@@ -1392,6 +1428,7 @@
 			try {
 				Thread.sleep(10);
 			} catch (InterruptedException e) {
+                //Expected
 			}
 		}
 		assertTrue("Returned map corrupted by multiple thread access",
@@ -1457,6 +1494,7 @@
 			try {
 				Thread.sleep(10);
 			} catch (InterruptedException e) {
+                //Expected
 			}
 		}
 		assertTrue("Returned set corrupted by multiple thread access",
@@ -1479,6 +1517,11 @@
 		}
 		new Support_SetTest("", Collections.synchronizedSet(smallSet))
 				.runTest();
+        
+		//Test self reference
+        mySet = Collections.synchronizedSet(smallSet);
+        mySet.add(smallSet);
+        assertTrue("should contain self ref", mySet.toString().indexOf("(this") > -1);
 	}
 
 	/**
@@ -1511,6 +1554,7 @@
 			try {
 				Thread.sleep(10);
 			} catch (InterruptedException e) {
+                //Expected
 			}
 		}
 		assertTrue("Returned map corrupted by multiple thread access",
@@ -1568,6 +1612,7 @@
 			try {
 				Thread.sleep(10);
 			} catch (InterruptedException e) {
+                //Expected
 			}
 		}
 		assertTrue("Returned set corrupted by multiple thread access",

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashMapTest.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/HashMapTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashMapTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashMapTest.java Wed Nov 26 21:10:32 2008
@@ -544,7 +544,18 @@
 				!myHashMap.containsValue(new Integer(0)));
 
 	}
+    
+    /**
+     * @tests java.util.AbstractMap#toString()
+     */
+    public void test_toString() {
 
+        HashMap m = new HashMap();
+        m.put(m, m);
+        String result = m.toString();
+        assertTrue("should contain self ref", result.indexOf("(this") > -1);
+    }
+    
 	static class ReusableKey {
 		private int key = 0;
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashSetTest.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/HashSetTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashSetTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashSetTest.java Wed Nov 26 21:10:32 2008
@@ -199,6 +199,16 @@
 		assertEquals("Cleared set returned non-zero size", 0, hs.size());
 	}
 	
+    /**
+     * @tests java.util.AbstractCollection#toString()
+     */
+    public void test_toString() {
+        HashSet s = new HashSet();
+        s.add(s);
+        String result = s.toString();
+        assertTrue("should contain self ref", result.indexOf("(this") > -1);
+    }
+   
 	/**
 	 * @tests java.util.HashSet#SerializationTest
 	 */

Modified: harmony/enhanced/classlib/branches/java6/modules/math/.classpath
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/math/.classpath?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/math/.classpath (original)
+++ harmony/enhanced/classlib/branches/java6/modules/math/.classpath Wed Nov 26 21:10:32 2008
@@ -4,6 +4,6 @@
 	<classpathentry output="bin/test" kind="src" path="src/test/java"/>
 	<classpathentry output="bin/test" kind="src" path="src/test/resources"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry sourcepath="JUNIT_SRC_HOME/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
 	<classpathentry kind="output" path="bin/main"/>
 </classpath>

Modified: harmony/enhanced/classlib/branches/java6/modules/misc/.classpath
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/misc/.classpath?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/misc/.classpath (original)
+++ harmony/enhanced/classlib/branches/java6/modules/misc/.classpath Wed Nov 26 21:10:32 2008
@@ -3,6 +3,6 @@
 	<classpathentry output="bin/main" kind="src" path="src/main/java"/>
 	<classpathentry output="bin/test/common" kind="src" path="src/test/java/common"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry sourcepath="JUNIT_SRC_HOME/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/.classpath
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/.classpath?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/.classpath (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/.classpath Wed Nov 26 21:10:32 2008
@@ -8,6 +8,6 @@
 	<classpathentry kind="src" output="bin/test" path="src/test/java/unix"/>
 	<classpathentry kind="src" output="bin/test" path="src/test/resources"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry kind="var" path="JUNIT_HOME/junit.jar" sourcepath="JUNIT_SRC_HOME/junitsrc.zip"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
 	<classpathentry kind="output" path="bin/main"/>
 </classpath>

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelectableChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelectableChannel.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelectableChannel.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelectableChannel.java Wed Nov 26 21:10:32 2008
@@ -132,10 +132,6 @@
                 // throw NPE exactly to keep consistency
                 throw new NullPointerException();
             }
-            if (0 == interestSet) {
-                // throw ISE exactly to keep consistency
-                throw new IllegalSelectorException();
-            }
             SelectionKey key = keyFor(selector);
             if (null == key) {
                 key = ((AbstractSelector) selector).register(this, interestSet,

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.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/MappedByteBufferTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.java Wed Nov 26 21:10:32 2008
@@ -59,6 +59,7 @@
             int val = ibuffer.get();
             assertEquals("Got wrong int value", i + 1, val); //$NON-NLS-1$
         }
+        fc.close();
     }
     
     /**
@@ -99,6 +100,11 @@
 
         // Invoking force() will change the buffer
         assertFalse(mmbReadWrite.equals(resultReadWrite));
+        
+        fileChannelRead.close();
+        fileChannelR.close();
+        fileChannelReadWrite.close();
+        fileChannelRW.close();
     }
 
     /**
@@ -118,6 +124,9 @@
                 FileChannel.MapMode.READ_WRITE, 0, fileChannelReadWrite.size());
 
         assertEquals(mmbReadWrite, mmbReadWrite.load());
+        
+        fileChannelRead.close();
+        fileChannelReadWrite.close();
     }
 
     protected void setUp() throws IOException {

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileChannelLockingTest.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/FileChannelLockingTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileChannelLockingTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileChannelLockingTest.java Wed Nov 26 21:10:32 2008
@@ -71,6 +71,18 @@
         readWriteChannel = randomAccessFile.getChannel();
     }
 
+    protected void tearDown() throws IOException {
+        if (readOnlyChannel != null) {
+            readOnlyChannel.close();
+        }
+        if (writeOnlyChannel != null) {
+            writeOnlyChannel.close();
+        }
+        if (readWriteChannel != null) {
+            readWriteChannel.close();
+        }
+    }
+
     public void test_illegalLocks() throws IOException {
         // Cannot acquire an exclusive lock on a read-only file channel
         try {

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.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/FileLockTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java Wed Nov 26 21:10:32 2008
@@ -62,6 +62,12 @@
 		mockLock = new MockFileLock(readWriteChannel, 10, 100, false);
 	}
 
+	protected void tearDown() throws IOException {
+	    if (readWriteChannel != null) {
+	        readWriteChannel.close();
+	    }
+	}
+
 	/**
 	 * @tests java.nio.channels.FileLock#FileLock(FileChannel, long, long,
 	 *        boolean)

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.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/spi/AbstractSelectableChannelTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java Wed Nov 26 21:10:32 2008
@@ -120,6 +120,15 @@
         //test that sc.register invokes Selector.register()
         acceptKey = sc.register(acceptSelector2, SelectionKey.OP_READ, null);
         assertNull(acceptKey);
+        
+        // Regression test to ensure acceptance of a selector with empty
+        // interest set.
+        SocketChannel channel = SocketChannel.open();
+        channel.configureBlocking(false);
+        Selector selector = Selector.open();
+        channel.register(selector, 0);
+        selector.close();
+        channel.close();
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/.classpath
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/.classpath?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/.classpath (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/.classpath Wed Nov 26 21:10:32 2008
@@ -6,6 +6,6 @@
 	<classpathentry kind="src" output="bin/test" path="src/test/resources"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="lib" path="src/test/resources/jars/charset_provider.jar"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
 	<classpathentry kind="output" path="bin/main"/>
 </classpath>

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/build.xml?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/build.xml Wed Nov 26 21:10:32 2008
@@ -101,6 +101,9 @@
 
             <compilerarg line="${build.compilerarg}" />
 
+            <!-- Exclude unwanted data files -->
+            <excludesfile name="${basedir}/make/excludesfile" />
+
             <bootclasspath>
                 <fileset dir="${hy.jdk}/jre/lib/boot">
                     <include name="**/*.jar" />
@@ -138,7 +141,9 @@
             <metainf prefix="META-INF/services"
                 dir="${hy.nio_char.src.main.java}/org/apache/harmony/niochar"
                 includes="java.nio.charset.spi.CharsetProvider"/>
-            <fileset dir="${hy.nio_char.src.main.java}" />
+            <fileset dir="${hy.nio_char.src.main.java}">
+                <excludesfile name="${basedir}/make/excludesfile"/>
+            </fileset>
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 
             </manifest>

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CharacterCodingException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CharacterCodingException.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CharacterCodingException.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CharacterCodingException.java Wed Nov 26 21:10:32 2008
@@ -27,7 +27,7 @@
 public class CharacterCodingException extends IOException {
 
     /*
-     * This constant is used during deserialization to check the J2SE version
+     * This constant is used during deserialization to check the version
      * which created the serialized object.
      */
     private static final long serialVersionUID = 8421532232154627783L;

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/Charset.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/Charset.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/Charset.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/Charset.java Wed Nov 26 21:10:32 2008
@@ -37,6 +37,7 @@
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
+import java.util.Vector;
 
 import org.apache.harmony.niochar.CharsetProviderImpl;
 
@@ -61,12 +62,12 @@
  * as "java.nio.charset.spi.CharsetProvider" and located in the
  * "META-INF/services" sub folder of one or more classpaths. The files should be
  * encoded in "UTF-8". Each line of their content specifies the class name of a
- * charset provider which extends <code>java.nio.spi.CharsetProvider</code>.
- * A line should ends with '\r', '\n' or '\r\n'. Leading and trailing
- * whitespaces are trimmed. Blank lines, and lines (after trimmed) starting with
- * "#" which are regarded as comments, are both ignored. Duplicates of already
- * appeared names are also ignored. Both the configuration files and the
- * provider classes will be loaded using the thread context class loader.
+ * charset provider which extends <code>java.nio.spi.CharsetProvider</code>. A
+ * line should ends with '\r', '\n' or '\r\n'. Leading and trailing whitespaces
+ * are trimmed. Blank lines, and lines (after trimmed) starting with "#" which
+ * are regarded as comments, are both ignored. Duplicates of already appeared
+ * names are also ignored. Both the configuration files and the provider classes
+ * will be loaded using the thread context class loader.
  * </p>
  * <p>
  * This class is thread-safe.
@@ -106,7 +107,7 @@
     private final HashSet<String> aliasesSet;
 
     // cached Charset table
-    private static HashMap<String, Charset> cachedCharsetTable = new HashMap<String, Charset>();
+    private final static HashMap<String, Charset> cachedCharsetTable = new HashMap<String, Charset>();
 
     static {
         /*
@@ -122,8 +123,7 @@
     }
 
     /**
-     * Constructs a <code>Charset</code> object. Duplicated aliases are
-     * ignored.
+     * Constructs a <code>Charset</code> object. Duplicated aliases are ignored.
      * 
      * @param canonicalName
      *            the canonical name of the charset
@@ -313,8 +313,8 @@
      * Gets a map of all available charsets supported by the runtime.
      * <p>
      * The returned map contains mappings from canonical names to corresponding
-     * instances of <code>Charset</code>. The canonical names can be
-     * considered as case-insensitive.
+     * instances of <code>Charset</code>. The canonical names can be considered
+     * as case-insensitive.
      * </p>
      * 
      * @return an unmodifiable map of all available charsets supported by the
@@ -423,56 +423,60 @@
     }
 
     /*
-     * Gets a <code> Charset </code> instance for the specified charset name. If
+     * Gets a <code>Charset</code> instance for the specified charset name. If
      * the charset is not supported, returns null instead of throwing an
      * exception.
      */
-    private static Charset forNameInternal(String charsetName)
+    private synchronized static Charset forNameInternal(String charsetName)
             throws IllegalCharsetNameException {
+        Charset cs = cachedCharsetTable.get(charsetName);
+        if (null != cs) {
+            return cs;
+        }
+
         if (null == charsetName) {
             throw new IllegalArgumentException();
         }
         checkCharsetName(charsetName);
-        synchronized (Charset.class) {
-            // Try to get Charset from cachedCharsetTable
-            Charset cs = getCachedCharset(charsetName);
-            if (null != cs) {
-                return cs;
-            }
-            // Try built-in charsets
-            if (_builtInProvider == null) {
-                _builtInProvider = new CharsetProviderImpl();
-            }
-            cs = _builtInProvider.charsetForName(charsetName);
-            if (null != cs) {
-                cacheCharset(cs);
-                return cs;
-            }
-
-            // Collect all charsets provided by charset providers
-            ClassLoader contextClassLoader = getContextClassLoader();
-            Enumeration<URL> e = null;
-            try {
-                if (null != contextClassLoader) {
-                    e = contextClassLoader
-                            .getResources(PROVIDER_CONFIGURATION_FILE_NAME);
+        // try built-in charsets
+        if (_builtInProvider == null) {
+            _builtInProvider = new CharsetProviderImpl();
+        }
+        cs = _builtInProvider.charsetForName(charsetName);
+        if (null != cs) {
+            cacheCharset(cs);
+            return cs;
+        }
+
+        // collect all charsets provided by charset providers
+        ClassLoader contextClassLoader = getContextClassLoader();
+        Enumeration<URL> e = null;
+        try {
+            if (null != contextClassLoader) {
+                e = contextClassLoader
+                        .getResources(PROVIDER_CONFIGURATION_FILE_NAME);
+            } else {
+                getSystemClassLoader();
+                if (systemClassLoader == null) {
+                    // Non available during class library start-up phase
+                    e = new Vector<URL>().elements();
                 } else {
-                    getSystemClassLoader();
                     e = systemClassLoader
                             .getResources(PROVIDER_CONFIGURATION_FILE_NAME);
                 }
-                // Examine each configuration file
-                while (e.hasMoreElements()) {
-                    cs = searchConfiguredCharsets(charsetName,
-                            contextClassLoader, e.nextElement());
-                    if (null != cs) {
-                        cacheCharset(cs);
-                        return cs;
-                    }
+            }
+
+            // examine each configuration file
+            while (e.hasMoreElements()) {
+                cs = searchConfiguredCharsets(charsetName, contextClassLoader,
+                        e.nextElement());
+                if (null != cs) {
+                    cacheCharset(cs);
+                    return cs;
                 }
-            } catch (IOException ex) {
-                // Unexpected ClassLoader exception, ignore
             }
+        } catch (IOException ex) {
+            // Unexpected ClassLoader exception, ignore
         }
         return null;
     }
@@ -492,13 +496,6 @@
         }
     }
 
-    /*
-     * get cached charset reference by name
-     */
-    private static Charset getCachedCharset(String name) {
-        return cachedCharsetTable.get(name);
-    }
-
     /**
      * Gets a <code>Charset</code> instance for the specified charset name.
      * 
@@ -628,13 +625,12 @@
      * @return the result of the encoding
      */
     public final ByteBuffer encode(CharBuffer buffer) {
-        try 
-        {
+        try {
             return this.newEncoder()
-                     .onMalformedInput(CodingErrorAction.REPLACE)
-                     .onUnmappableCharacter(CodingErrorAction.REPLACE)
-                     .encode(buffer);
-                                     
+                    .onMalformedInput(CodingErrorAction.REPLACE)
+                    .onUnmappableCharacter(CodingErrorAction.REPLACE).encode(
+                            buffer);
+
         } catch (CharacterCodingException ex) {
             throw new Error(ex.getMessage(), ex);
         }
@@ -669,16 +665,16 @@
      */
     public final CharBuffer decode(ByteBuffer buffer) {
 
-		try {
-			return this.newDecoder()
-					.onMalformedInput(CodingErrorAction.REPLACE)
-					.onUnmappableCharacter(CodingErrorAction.REPLACE)
-					.decode(buffer);
-
-		} catch (CharacterCodingException ex) {
-			throw new Error(ex.getMessage(), ex);
-		}
-	}
+        try {
+            return this.newDecoder()
+                    .onMalformedInput(CodingErrorAction.REPLACE)
+                    .onUnmappableCharacter(CodingErrorAction.REPLACE).decode(
+                            buffer);
+
+        } catch (CharacterCodingException ex) {
+            throw new Error(ex.getMessage(), ex);
+        }
+    }
 
     /*
      * -------------------------------------------------------------------

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CharsetDecoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CharsetDecoder.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CharsetDecoder.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CharsetDecoder.java Wed Nov 26 21:10:32 2008
@@ -90,10 +90,7 @@
  * @see java.nio.charset.CharsetEncoder
  */
 public abstract class CharsetDecoder {
-    /*
-     * --------------------------------------- Consts
-     * ---------------------------------------
-     */
+
     /*
      * internal status consts
      */
@@ -105,10 +102,6 @@
 
     private static final int FLUSH = 3;
 
-    /*
-     * --------------------------------------- Instance variables
-     * ---------------------------------------
-     */
     // average number of chars for one byte
     private float averChars;
 
@@ -130,10 +123,6 @@
     // the current status
     private int status;
 
-    /*
-     * --------------------------------------- Constructor
-     * ---------------------------------------
-     */
     /**
      * Construct a new <code>CharsetDecoder</code> using given
      * <code>Charset</code>, average number and maximum number of characters
@@ -172,10 +161,6 @@
         replace = "\ufffd"; //$NON-NLS-1$
     }
 
-    /*
-     * --------------------------------------- Methods
-     * ---------------------------------------
-     */
     /**
      * get the average number of characters created by this decoder for single
      * input byte

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java Wed Nov 26 21:10:32 2008
@@ -89,10 +89,7 @@
  * @see java.nio.charset.CharsetDecoder
  */
 public abstract class CharsetEncoder {
-    /*
-     * --------------------------------------- Consts
-     * ---------------------------------------
-     */
+
     /*
      * internal status consts
      */
@@ -104,10 +101,6 @@
 
     private static final int FLUSH = 3;
 
-    /*
-     * --------------------------------------- Instance variables
-     * ---------------------------------------
-     */
     // the Charset which creates this encoder
     private Charset cs;
 
@@ -133,11 +126,6 @@
     // checking
     private CharsetDecoder decoder;
 
-    /*
-     * --------------------------------------- Constructors
-     * ---------------------------------------
-     */
-
     /**
      * Construct a new <code>CharsetEncoder</code> using given
      * <code>Charset</code>, average number and maximum number of bytes
@@ -203,10 +191,6 @@
         replaceWith(replacement);
     }
 
-    /*
-     * --------------------------------------- Methods
-     * ---------------------------------------
-     */
     /**
      * get the average number of bytes created by this encoder for single input
      * character

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CoderMalfunctionError.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CoderMalfunctionError.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CoderMalfunctionError.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CoderMalfunctionError.java Wed Nov 26 21:10:32 2008
@@ -23,7 +23,7 @@
 public class CoderMalfunctionError extends Error {
 
     /*
-     * This constant is used during deserialization to check the J2SE version
+     * This constant is used during deserialization to check the version
      * which created the serialized object.
      */
     private static final long serialVersionUID = -1151412348057794301L;

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CoderResult.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CoderResult.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CoderResult.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CoderResult.java Wed Nov 26 21:10:32 2008
@@ -254,17 +254,12 @@
         }
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods overriding parent class Object
-     * -------------------------------------------------------------------
-     */
-
     /**
      * Returns a text description of this result.
      * 
      * @return a text description of this result
      */
+    @Override
     public String toString() {
         String dsc = null;
         switch (this.type) {

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CodingErrorAction.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CodingErrorAction.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CodingErrorAction.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/CodingErrorAction.java Wed Nov 26 21:10:32 2008
@@ -58,6 +58,7 @@
      * 
      * @return a text description of this action indication.
      */
+    @Override
     public String toString() {
         return "Action: " + this.action; //$NON-NLS-1$
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java Wed Nov 26 21:10:32 2008
@@ -25,7 +25,7 @@
 public class IllegalCharsetNameException extends IllegalArgumentException {
 
     /*
-     * This constant is used during deserialization to check the J2SE version
+     * This constant is used during deserialization to check the version
      * which created the serialized object.
      */
     private static final long serialVersionUID = 1457525358470002989L;

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/MalformedInputException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/MalformedInputException.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/MalformedInputException.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/MalformedInputException.java Wed Nov 26 21:10:32 2008
@@ -26,7 +26,7 @@
 public class MalformedInputException extends CharacterCodingException {
 
     /*
-     * This constant is used during deserialization to check the J2SE version
+     * This constant is used during deserialization to check the version
      * which created the serialized object.
      */
     private static final long serialVersionUID = -3438823399834806194L;
@@ -58,6 +58,7 @@
      * 
      * @return a message describing this exception
      */
+    @Override
     public String getMessage() {
         // niochar.05=Malformed input length is {0}.
         return Messages.getString("niochar.05", this.inputLength); //$NON-NLS-1$

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java Wed Nov 26 21:10:32 2008
@@ -25,7 +25,7 @@
 public class UnmappableCharacterException extends CharacterCodingException {
 
     /*
-     * This constant is used during deserialization to check the J2SE version
+     * This constant is used during deserialization to check the version
      * which created the serialized object.
      */
     private static final long serialVersionUID = -7026962371537706123L;
@@ -57,6 +57,7 @@
      * 
      * @return a message describing this exception
      */
+    @Override
     public String getMessage() {
         // niochar.0A=The unmappable character length is {0}.
         return Messages.getString("niochar.0A", this.inputLength); //$NON-NLS-1$

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/UnsupportedCharsetException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/UnsupportedCharsetException.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/UnsupportedCharsetException.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/UnsupportedCharsetException.java Wed Nov 26 21:10:32 2008
@@ -25,7 +25,7 @@
 public class UnsupportedCharsetException extends IllegalArgumentException {
 
     /*
-     * This constant is used during deserialization to check the J2SE version
+     * This constant is used during deserialization to check the version
      * which created the serialized object.
      */
     private static final long serialVersionUID = 1490765524727386367L;

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/CharsetProviderImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/CharsetProviderImpl.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/CharsetProviderImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/CharsetProviderImpl.java Wed Nov 26 21:10:32 2008
@@ -31,47 +31,64 @@
 
 /**
  * This class is an implementation of the java.nio.charset.spi.CharsetProvider
- * class, in spite of the fact that it is abstract. It is a base class of
- * a concrete character set provider implementation
- * Please note, a derived class should define the getPackageName() and 
- * getCharsetsInfo() methods.
- * The first of them has to return a string with a package name where 
- * the derived class is located.
- * The second one has to construct an array, the structure of which is 
- * described below.
- * See CharsetProviderImplStd or CharsetProviderImplExt for example.
+ * class, in spite of the fact that it is abstract. It is a base class of a
+ * concrete character set provider implementation Please note, a derived class
+ * should define the getPackageName() and getCharsetsInfo() methods. The first
+ * of them has to return a string with a package name where the derived class is
+ * located. The second one has to construct an array, the structure of which is
+ * described below. See CharsetProviderImplStd or CharsetProviderImplExt for
+ * example.
  */
 public class CharsetProviderImpl extends CharsetProvider {
 
+    /**
+     * Flags whether the default providers have got the native implementation
+     * loaded. These are optional and used to improve performance in some
+     * circumstances.
+     */
+    private static boolean HAS_LOADED_NATIVES = false;
+
     static {
-    	System.loadLibrary("hycharset");
+        try {
+            System.loadLibrary("hyniochar"); //$NON-NLS-1$
+            HAS_LOADED_NATIVES = true;
+        } catch (UnsatisfiedLinkError e) {
+            // Ignore - leave as natives unavailable.
+        }
     }
 
     /**
-     * The named index of the 0th element of
-     * the <code>charsets[]</code> array.
+     * The named index of the 0th element of the <code>charsets[]</code> array.
      * It means a charset class name.
      */
-    protected static final int CHARSET_CLASS = 0; 
+    protected static final int CHARSET_CLASS = 0;
 
     /**
-     * The named index of the 1st element of
-     * the <code>charsets[]</code> array.
+     * The named index of the 1st element of the <code>charsets[]</code> array.
      * It means a charset instance.
      */
-    protected static final int CHARSET_INSTANCE = 1; 
-    
+    protected static final int CHARSET_INSTANCE = 1;
+
     /**
-     * The named index of the 2nd element of
-     * the <code>charsets[]</code> array.
+     * The named index of the 2nd element of the <code>charsets[]</code> array.
      * It means a charset aliases array.
      */
-    protected static final int CHARSET_ALIASES = 2; 
+    protected static final int CHARSET_ALIASES = 2;
+
+    /**
+     * Answers whether the provider has loaded the native implementation of the
+     * encoders/decoders.
+     * 
+     * @return true if the natives are loaded.
+     */
+    public static boolean hasLoadedNatives() {
+        return HAS_LOADED_NATIVES;
+    }
 
     /**
      * A cache of the charset instances.
      */
-    protected Map cache;
+    protected Map<String, Object[]> cache;
 
     /**
      * An array returned by <code>getCharsetsInfo()</code>.
@@ -83,8 +100,11 @@
      */
     protected String packageName;
 
+    /**
+     * Default constructor for the built-in charset provider implementation.
+     */
     public CharsetProviderImpl() {
-        cache = Collections.synchronizedMap(new HashMap());
+        cache = Collections.synchronizedMap(new HashMap<String, Object[]>());
         charsets = getCharsetsInfo();
         packageName = getPackageName();
         for (int i = 0; i < charsets.length; i++) {
@@ -95,75 +115,105 @@
         }
     }
 
+    /**
+     * Answers an iterator over the list of available charsets.
+     * 
+     * @return available charsets.
+     */
+    @Override
     public Iterator<Charset> charsets() {
         ArrayList<Charset> list = new ArrayList<Charset>();
         for (int i = 0; i < charsets.length; i++) {
-            list.add(charsetForName(((String[]) charsets[i][CHARSET_ALIASES])[0]));
+            list
+                    .add(charsetForName(((String[]) charsets[i][CHARSET_ALIASES])[0]));
         }
         return list.iterator();
     }
 
+    /**
+     * Answers the charset with the given canonical or alias name.
+     * 
+     * Subsequent requests for the same charset will answer the same instance.
+     * If the charset is unavailable the method returns <code>null</code>.
+     * 
+     * @param charsetName
+     *            the name of a character set.
+     * @return the charset requested, or <code>null</code> if unavailable.
+     */
+    @Override
     public Charset charsetForName(String charsetName) {
-        Object arr[] = (Object[]) cache.get(charsetName.toUpperCase());
+        Object arr[] = cache.get(charsetName.toUpperCase());
         if (arr == null) {
-        	return null;
+            return null;
         }
         // Make an instance of the found charset.
         if (arr[CHARSET_INSTANCE] == null) {
-            final String className = packageName + "." + (String) arr[CHARSET_CLASS];
+            final String className = packageName
+                    + "." + (String) arr[CHARSET_CLASS]; //$NON-NLS-1$
             final String canonicalName = ((String[]) arr[CHARSET_ALIASES])[0];
             final String aliases[] = (String[]) arr[CHARSET_ALIASES];
-            arr[CHARSET_INSTANCE] = AccessController.doPrivileged(
-                    new PrivilegedAction() {
+            arr[CHARSET_INSTANCE] = AccessController
+                    .doPrivileged(new PrivilegedAction<Object>() {
                         public Object run() {
                             try {
-                                Class cls = Class.forName(className);
-                                Constructor ctor = cls.getConstructor(
-                                        new Class[] { String.class, String[].class });
+                                Class<?> cls = Class.forName(className);
+                                Constructor<?> ctor = cls
+                                        .getConstructor(new Class[] {
+                                                String.class, String[].class });
                                 ctor.setAccessible(true);
-                                return ctor.newInstance(new Object[] { 
+                                return ctor.newInstance(new Object[] {
                                         canonicalName, aliases });
                             } catch (Exception e) {
                                 return null;
                             }
                         }
-                    }
-            );
+                    });
         }
         return (Charset) arr[CHARSET_INSTANCE];
     }
-    
-    public final void putCharsets(Map map) {
-        Object[][] charsets = getCharsetsInfo();
-        for (int i = 0; i < charsets.length; i++) {
-            final String canonicalName = ((String[])charsets[i][CHARSET_ALIASES])[0];
-        	Charset cs = charsetForName(canonicalName);
-        	if(cs != null) {
+
+    /**
+     * A helper method for answering all the available charsets in this
+     * provider.
+     * 
+     * The method adds to the given map by storing charset canonical names as
+     * the keys, with associated charsets as the value.
+     * 
+     * @param map
+     *            for storing the descriptions of the charsets.
+     */
+    public final void putCharsets(Map<String, Charset> map) {
+        Object[][] charsetInfo = getCharsetsInfo();
+        for (int i = 0; i < charsetInfo.length; i++) {
+            final String canonicalName = ((String[]) charsetInfo[i][CHARSET_ALIASES])[0];
+            Charset cs = charsetForName(canonicalName);
+            if (cs != null) {
                 map.put(canonicalName, cs);
-        	}
-       	}
+            }
+        }
     }
-    
 
     protected String getPackageName() {
-        return "org.apache.harmony.niochar.charset";
+        return "org.apache.harmony.niochar.charset"; //$NON-NLS-1$
     }
 
     protected Object[][] getCharsetsInfo() {
-        // The next charset aliases corresponds IANA registry 
-        // http://www.iana.org/assignments/character-sets.
-        // 
-        //
-        // Array structure:
-        //
-        // charsetsInfo[][0] - String: A charset class name.
-        //                     The named index is CHARSET_CLASS.
-        // charsetsInfo[][1] - Charset: A charset instance.
-        //                     The named index is CHARSET_INSTANCE.
-        // charsetsInfo[][2] - String[]: A charset aliases array.
-        //                     The named index is CHARSET_ALIASES.
-        //                     THE FIRST ELEMENT OF THE ALIASES ARRAY MUST BE 
-        //                     A CANONICAL CHARSET NAME.
+        /* The next charset aliases corresponds IANA registry 
+         * http://www.iana.org/assignments/character-sets.
+         * 
+         *
+         * Array structure:
+         *
+         * charsetsInfo[][0] - String: A charset class name.
+         *                     The named index is CHARSET_CLASS.
+         * charsetsInfo[][1] - Charset: A charset instance.
+         *                     The named index is CHARSET_INSTANCE.
+         * charsetsInfo[][2] - String[]: A charset aliases array.
+         *                     The named index is CHARSET_ALIASES.
+         *                     THE FIRST ELEMENT OF THE ALIASES ARRAY MUST BE 
+         *                     A CANONICAL CHARSET NAME.
+         */
+        @SuppressWarnings("nls")
         Object charsetsInfo[][] = {
             { "US_ASCII",    null,new String[] { "US-ASCII", 
                                                  "ANSI_X3.4-1968", 
@@ -270,8 +320,8 @@
                                   
             { "UTF_16",      null,new String[] { "UTF-16",
                                                  "UTF16",
-            		                             "UTF_16" } },
-            		          
+                                                 "UTF_16" } },
+                              
             { "UTF_16LE",    null,new String[] { "UTF-16LE",
                                                  "X-UTF-16LE",
                                                  "UTF_16LE" } },
@@ -586,15 +636,15 @@
                                                   "cp1098"} },
 
             { "additional.x_MacCyrillic",           null, new String[] { "x-mac-cyrillic",
-            		                                          "x-MacCyrillic",
+                                                              "x-MacCyrillic",
                                                               "MacCyrillic"} },
 
             { "additional.x_MacGreek",              null, new String[] { "x-mac-greek",
-            		                                          "x-MacGreek",
+                                                              "x-MacGreek",
                                                               "MacGreek"} },
 
             { "additional.x_MacTurkish",              null, new String[] { "x-mac-turkish",
-            		                                          "x-MacTurkish",
+                                                              "x-MacTurkish",
                                                               "MacTurkish"} },
 
             { "additional.windows_31j",            null, new String[] { "Shift_JIS",

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1250.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1250.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1250.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1250.java Wed Nov 26 21:10:32 2008
@@ -17,14 +17,15 @@
 
 package org.apache.harmony.niochar.charset;
 
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
 import java.nio.charset.Charset;
-import java.nio.charset.CoderResult;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
-import java.nio.CharBuffer;
-import java.nio.ByteBuffer;
+import java.nio.charset.CoderResult;
 
 import org.apache.harmony.nio.AddressUtil;
+import org.apache.harmony.niochar.CharsetProviderImpl;
 
 public class CP_1250 extends Charset {
 
@@ -50,12 +51,12 @@
 
 		}
 
-		public native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
+		private native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
 
 
 		protected CoderResult decodeLoop(ByteBuffer bb, CharBuffer cb){
                         int cbRemaining = cb.remaining();
-		        if(bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
+		        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
 		            int toProceed = bb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -135,7 +136,7 @@
                                                                                                                           
 		protected CoderResult encodeLoop(CharBuffer cb, ByteBuffer bb){
                         int bbRemaining = bb.remaining();
-                        if(bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
+                        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
 		            int toProceed = cb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -362,4 +363,4 @@
                  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
                 };
 	}         
-}
\ No newline at end of file
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1251.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1251.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1251.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1251.java Wed Nov 26 21:10:32 2008
@@ -17,14 +17,15 @@
 
 package org.apache.harmony.niochar.charset;
 
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
 import java.nio.charset.Charset;
-import java.nio.charset.CoderResult;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
-import java.nio.CharBuffer;
-import java.nio.ByteBuffer;
+import java.nio.charset.CoderResult;
 
 import org.apache.harmony.nio.AddressUtil;
+import org.apache.harmony.niochar.CharsetProviderImpl;
 
 public class CP_1251 extends Charset {
 
@@ -50,12 +51,12 @@
 
 		}
 
-		public native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
+		private native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
 
 
 		protected CoderResult decodeLoop(ByteBuffer bb, CharBuffer cb){
                         int cbRemaining = cb.remaining();
-		        if(bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
+		        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
 		            int toProceed = bb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -135,7 +136,7 @@
                                                                                                                           
 		protected CoderResult encodeLoop(CharBuffer cb, ByteBuffer bb){
                         int bbRemaining = bb.remaining();
-                        if(bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
+                        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
 		            int toProceed = cb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -345,4 +346,4 @@
                  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
                 };
 	}         
-}
\ No newline at end of file
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1252.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1252.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1252.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1252.java Wed Nov 26 21:10:32 2008
@@ -17,14 +17,15 @@
 
 package org.apache.harmony.niochar.charset;
 
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
 import java.nio.charset.Charset;
-import java.nio.charset.CoderResult;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
-import java.nio.CharBuffer;
-import java.nio.ByteBuffer;
+import java.nio.charset.CoderResult;
 
 import org.apache.harmony.nio.AddressUtil;
+import org.apache.harmony.niochar.CharsetProviderImpl;
 
 public class CP_1252 extends Charset {
 
@@ -50,12 +51,12 @@
 
 		}
 
-		public native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
+		private native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
 
 
 		protected CoderResult decodeLoop(ByteBuffer bb, CharBuffer cb){
                         int cbRemaining = cb.remaining();
-		        if(bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
+		        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
 		            int toProceed = bb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -135,7 +136,7 @@
                                                                                                                           
 		protected CoderResult encodeLoop(CharBuffer cb, ByteBuffer bb){
                         int bbRemaining = bb.remaining();
-                        if(bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
+                        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
 		            int toProceed = cb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -362,4 +363,4 @@
                  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
                 };
 	}         
-}
\ No newline at end of file
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1253.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1253.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1253.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1253.java Wed Nov 26 21:10:32 2008
@@ -17,14 +17,15 @@
 
 package org.apache.harmony.niochar.charset;
 
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
 import java.nio.charset.Charset;
-import java.nio.charset.CoderResult;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
-import java.nio.CharBuffer;
-import java.nio.ByteBuffer;
+import java.nio.charset.CoderResult;
 
 import org.apache.harmony.nio.AddressUtil;
+import org.apache.harmony.niochar.CharsetProviderImpl;
 
 public class CP_1253 extends Charset {
 
@@ -50,12 +51,12 @@
 
 		}
 
-		public native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
+		private native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
 
 
 		protected CoderResult decodeLoop(ByteBuffer bb, CharBuffer cb){
                         int cbRemaining = cb.remaining();
-		        if(bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
+		        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
 		            int toProceed = bb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -151,7 +152,7 @@
                                                                                                                           
 		protected CoderResult encodeLoop(CharBuffer cb, ByteBuffer bb){
                         int bbRemaining = bb.remaining();
-                        if(bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
+                        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
 		            int toProceed = cb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -378,4 +379,4 @@
                  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
                 };
 	}         
-}
\ No newline at end of file
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1254.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1254.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1254.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1254.java Wed Nov 26 21:10:32 2008
@@ -17,14 +17,15 @@
 
 package org.apache.harmony.niochar.charset;
 
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
 import java.nio.charset.Charset;
-import java.nio.charset.CoderResult;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
-import java.nio.CharBuffer;
-import java.nio.ByteBuffer;
+import java.nio.charset.CoderResult;
 
 import org.apache.harmony.nio.AddressUtil;
+import org.apache.harmony.niochar.CharsetProviderImpl;
 
 public class CP_1254 extends Charset {
 
@@ -50,12 +51,12 @@
 
 		}
 
-		public native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
+		private native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
 
 
 		protected CoderResult decodeLoop(ByteBuffer bb, CharBuffer cb){
                         int cbRemaining = cb.remaining();
-		        if(bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
+		        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
 		            int toProceed = bb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -135,7 +136,7 @@
                                                                                                                           
 		protected CoderResult encodeLoop(CharBuffer cb, ByteBuffer bb){
                         int bbRemaining = bb.remaining();
-                        if(bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
+                        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
 		            int toProceed = cb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -362,4 +363,4 @@
                  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
                 };
 	}         
-}
\ No newline at end of file
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1257.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1257.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1257.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/CP_1257.java Wed Nov 26 21:10:32 2008
@@ -17,14 +17,15 @@
 
 package org.apache.harmony.niochar.charset;
 
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
 import java.nio.charset.Charset;
-import java.nio.charset.CoderResult;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
-import java.nio.CharBuffer;
-import java.nio.ByteBuffer;
+import java.nio.charset.CoderResult;
 
 import org.apache.harmony.nio.AddressUtil;
+import org.apache.harmony.niochar.CharsetProviderImpl;
 
 public class CP_1257 extends Charset {
 
@@ -50,12 +51,12 @@
 
 		}
 
-		public native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
+		private native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
 
 
 		protected CoderResult decodeLoop(ByteBuffer bb, CharBuffer cb){
                         int cbRemaining = cb.remaining();
-		        if(bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
+		        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
 		            int toProceed = bb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -151,7 +152,7 @@
                                                                                                                           
 		protected CoderResult encodeLoop(CharBuffer cb, ByteBuffer bb){
                         int bbRemaining = bb.remaining();
-                        if(bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
+                        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
 		            int toProceed = cb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -378,4 +379,4 @@
                  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
                 };
 	}         
-}
\ No newline at end of file
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/IBM866.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/IBM866.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/IBM866.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/IBM866.java Wed Nov 26 21:10:32 2008
@@ -17,14 +17,15 @@
 
 package org.apache.harmony.niochar.charset;
 
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
 import java.nio.charset.Charset;
-import java.nio.charset.CoderResult;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
-import java.nio.CharBuffer;
-import java.nio.ByteBuffer;
+import java.nio.charset.CoderResult;
 
 import org.apache.harmony.nio.AddressUtil;
+import org.apache.harmony.niochar.CharsetProviderImpl;
 
 public class IBM866 extends Charset {
 
@@ -50,12 +51,12 @@
 
 		}
 
-		public native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
+		private native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
 
 
 		protected CoderResult decodeLoop(ByteBuffer bb, CharBuffer cb){
                         int cbRemaining = cb.remaining();
-		        if(bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
+		        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
 		            int toProceed = bb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -148,7 +149,7 @@
                                                                                                                           
 		protected CoderResult encodeLoop(CharBuffer cb, ByteBuffer bb){
                         int bbRemaining = bb.remaining();
-                        if(bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
+                        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
 		            int toProceed = cb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -375,4 +376,4 @@
                  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
                 };
 	}         
-}
\ No newline at end of file
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/ISO_8859_1.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/ISO_8859_1.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/ISO_8859_1.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/ISO_8859_1.java Wed Nov 26 21:10:32 2008
@@ -25,6 +25,7 @@
 import java.nio.charset.CoderResult;
 
 import org.apache.harmony.nio.AddressUtil;
+import org.apache.harmony.niochar.CharsetProviderImpl;
 
 
 public class ISO_8859_1 extends Charset {
@@ -51,7 +52,7 @@
 
 		}
 
-		public native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
+		private native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
 
 
 		protected CoderResult decodeLoop(ByteBuffer bb, CharBuffer cb) {
@@ -79,7 +80,7 @@
 						return CoderResult.OVERFLOW;
 					}
 					return CoderResult.UNDERFLOW;
-				} else if (bb.isDirect()) {
+				} else if (CharsetProviderImpl.hasLoadedNatives() && bb.isDirect()) {
 					int toProceed = bbRemaining;
 					boolean throwOverflow = false;
 					int cbPos = cb.position();
@@ -170,7 +171,7 @@
 						return CoderResult.malformedForLength(1);
 					}
 					return CoderResult.unmappableForLength(1);
-				} else if (bb.isDirect()) {
+				} else if (CharsetProviderImpl.hasLoadedNatives() && bb.isDirect()) {
 					int toProceed = cbRemaining;
 					boolean throwOverflow = false;
 					int cbPos = cb.position();

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/ISO_8859_13.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/ISO_8859_13.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/ISO_8859_13.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/ISO_8859_13.java Wed Nov 26 21:10:32 2008
@@ -17,14 +17,15 @@
 
 package org.apache.harmony.niochar.charset;
 
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
 import java.nio.charset.Charset;
-import java.nio.charset.CoderResult;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
-import java.nio.CharBuffer;
-import java.nio.ByteBuffer;
+import java.nio.charset.CoderResult;
 
 import org.apache.harmony.nio.AddressUtil;
+import org.apache.harmony.niochar.CharsetProviderImpl;
 
 public class ISO_8859_13 extends Charset {
 
@@ -50,12 +51,12 @@
 
 		}
 
-		public native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
+		private native int nDecode(char[] array, int arrPosition, int remaining, long outAddr, int absolutePos);
 
 
 		protected CoderResult decodeLoop(ByteBuffer bb, CharBuffer cb){
                         int cbRemaining = cb.remaining();
-		        if(bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
+		        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && bb.hasRemaining() && cb.hasArray()){
 		            int toProceed = bb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -131,7 +132,7 @@
                                                                                                                           
 		protected CoderResult encodeLoop(CharBuffer cb, ByteBuffer bb){
                         int bbRemaining = bb.remaining();
-                        if(bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
+                        if(CharsetProviderImpl.hasLoadedNatives() && bb.isDirect() && cb.hasRemaining() && cb.hasArray()){
 		            int toProceed = cb.remaining();
 		            int cbPos = cb.position();
 		            int bbPos = bb.position();
@@ -324,4 +325,4 @@
                  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
                 };
 	}         
-}
\ No newline at end of file
+}