harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r884518 [8/8] - in /harmony/enhanced/classlib/branches/java6: ./ depends/build/ depends/jars/ make/ modules/accessibility/make/ modules/accessibility/src/main/java/javax/accessibility/ modules/applet/src/main/java/org/apache/harmony/applet/...
Date Thu, 26 Nov 2009 11:12:56 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java
Thu Nov 26 11:12:49 2009
@@ -17,6 +17,7 @@
 
 package org.apache.harmony.security.tests.java.security;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -35,7 +36,7 @@
 	/**
 	 * @tests java.security.SecureClassLoader#getPermissions(java.security.CodeSource)
 	 */
-	public void test_getPermissionsLjava_security_CodeSource() {
+	public void test_getPermissionsLjava_security_CodeSource() throws IOException {
 		class MyClassLoader extends SecureClassLoader {
 			public PermissionCollection getPerms() {
 				return super.getPermissions(new CodeSource(null,
@@ -58,21 +59,49 @@
 		}
 		assertEquals("expected no permissions", 0, count);
 
-		byte[] bytes = null;
-		try {
-			File file = Support_GetLocal.getLocalFile("hyts_security.jar");
-			JarFile jar = new JarFile(file);
-			InputStream in = jar.getInputStream(jar
-					.getEntry("packA/SecurityTest.class"));
-			bytes = new byte[in.available()];
-			in.read(bytes);
-			in.close();
-		} catch (IOException e) {
-			fail("unexpected IOException : " + e);
-		}
-		Class c = myloader.define("packA.SecurityTest", bytes);
+        File file = Support_GetLocal.getLocalFile("hyts_security.jar");
+        JarFile jar = new JarFile(file);
+        InputStream in = jar.getInputStream(jar
+                .getEntry("packA/SecurityTest.class"));
+        byte[] bytes = drain(in);
+        Class c = myloader.define("packA.SecurityTest", bytes);
 		ProtectionDomain pd = c.getProtectionDomain();
 		assertNotNull("Expected dynamic policy", pd.getClassLoader());
 		assertNull("Expected null permissions", pd.getPermissions());
 	}
+
+    /*
+     * Drains the entire content from the given input stream and returns it as a
+     * byte[]. The stream is closed after being drained, or if an IOException
+     * occurs.
+     */
+    private byte[] drain(InputStream is) throws IOException {
+        try {
+            // Initial read
+            byte[] buffer = new byte[1024];
+            int count = is.read(buffer);
+            int nextByte = is.read();
+
+            // Did we get it all in one read?
+            if (nextByte == -1) {
+                byte[] dest = new byte[count];
+                System.arraycopy(buffer, 0, dest, 0, count);
+                return dest;
+            }
+
+            // Requires additional reads
+            ByteArrayOutputStream baos = new ByteArrayOutputStream(count * 2);
+            baos.write(buffer, 0, count);
+            baos.write(nextByte);
+            while (true) {
+                count = is.read(buffer);
+                if (count == -1) {
+                    return baos.toByteArray();
+                }
+                baos.write(buffer, 0, count);
+            }
+        } finally {
+            is.close();
+        }
+    }
 }
\ No newline at end of file

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
Thu Nov 26 11:12:49 2009
@@ -56,16 +56,17 @@
     public void test_impliesLjava_security_Permission() throws Exception{
 
         // Look for the tests classpath
-        URL classURL = this.getClass().getProtectionDomain().getCodeSource()
-                .getLocation();
+        URL classURL = this.getClass().getProtectionDomain().getCodeSource().getLocation();
         assertNotNull("Could not get this class' location", classURL);
 
         File policyFile = Support_GetLocal.createTempFile(".policy");
         policyFile.deleteOnExit();
 
         URL signedBKS = getResourceURL("PermissionCollection/signedBKS.jar");
+        String signedBKSPath = new File(signedBKS.getFile()).getCanonicalPath();
+        signedBKSPath = signedBKSPath.replace('\\', '/');
         URL keystoreBKS = getResourceURL("PermissionCollection/keystore.bks");
-        
+
         // Create the policy file (and save the existing one if any)
         FileOutputStream fileOut = null;
         try {
@@ -74,45 +75,50 @@
             StringBuilder towrite = new StringBuilder();
             towrite.append("grant {");
             towrite.append(linebreak);
-            towrite.append("permission java.io.FilePermission \"");
-            towrite.append(signedBKS.getFile());
+            towrite.append("    permission java.io.FilePermission \"");
+            towrite.append(signedBKSPath);
             towrite.append("\", \"read\";");
             towrite.append(linebreak);
-            towrite.append("permission java.lang.RuntimePermission \"getProtectionDomain\";");
+            towrite.append("    permission java.lang.RuntimePermission \"getProtectionDomain\";");
             towrite.append(linebreak);
-            towrite.append("permission java.security.SecurityPermission \"getPolicy\";");
+            towrite.append("    permission java.security.SecurityPermission \"getPolicy\";");
             towrite.append(linebreak);
             towrite.append("};");
             towrite.append(linebreak);
+            towrite.append(linebreak);
             towrite.append("grant codeBase \"");
             towrite.append(signedBKS.toExternalForm());
             towrite.append("\" signedBy \"eleanor\" {");
             towrite.append(linebreak);
-            towrite.append("permission java.io.FilePermission \"test1.txt\", \"write\";");
+            towrite.append("    permission java.io.FilePermission \"test1.txt\", \"write\";");
             towrite.append(linebreak);
-            towrite.append("permission mypackage.MyPermission \"essai\", signedBy \"eleanor,dylan\";");
+            towrite.append("    permission mypackage.MyPermission \"essai\", signedBy \"eleanor,dylan\";");
             towrite.append(linebreak);
             towrite.append("};");
             towrite.append(linebreak);
+            towrite.append(linebreak);
             towrite.append("grant codeBase \"");
             towrite.append(signedBKS.toExternalForm());
             towrite.append("\" signedBy \"eleanor\" {");
             towrite.append(linebreak);
-            towrite.append("permission java.io.FilePermission \"test2.txt\", \"write\";");
+            towrite.append("    permission java.io.FilePermission \"test2.txt\", \"write\";");
             towrite.append(linebreak);
             towrite.append("};");
             towrite.append(linebreak);
+            towrite.append(linebreak);
             towrite.append("grant codeBase \"");
             towrite.append(classURL.toExternalForm());
             towrite.append("\" {");
             towrite.append(linebreak);
-            towrite.append("permission java.security.AllPermission;");
+            towrite.append("    permission java.security.AllPermission;");
             towrite.append(linebreak);
             towrite.append("};");
             towrite.append(linebreak);
+            towrite.append(linebreak);
             towrite.append("keystore \"");
             towrite.append(keystoreBKS.toExternalForm());
-            towrite.append("\",\"BKS\";");            
+            towrite.append("\",\"BKS\";");
+            towrite.append(linebreak);
             fileOut.write(towrite.toString().getBytes());
             fileOut.flush();
         } finally {
@@ -122,14 +128,12 @@
         }
 
         // Copy mypermissionBKS.jar to the user directory so that it can be put
-        // in
-        // the classpath
+        // in the classpath.
         File jarFile = null;
         FileOutputStream fout = null;
         InputStream jis = null;
         try {
-            jis = Support_Resources
-                    .getResourceStream("PermissionCollection/mypermissionBKS.jar");
+            jis = Support_Resources.getResourceStream("PermissionCollection/mypermissionBKS.jar");
             jarFile = Support_GetLocal.createTempFile(".jar");
             jarFile.deleteOnExit();
             fout = new FileOutputStream(jarFile);
@@ -163,12 +167,10 @@
         StringTokenizer resultTokenizer = new StringTokenizer(result, ",");
 
         // Check the test result from the new VM process
-        assertEquals("Permission should be granted", "false", resultTokenizer
-                .nextToken());
-        assertEquals("signed Permission should be granted", "false",
-                resultTokenizer.nextToken());
-        assertEquals("Permission should not be granted", "false",
-                resultTokenizer.nextToken());
+        assertEquals("Permission should be granted for test1.txt", "true", resultTokenizer.nextToken());
+        assertEquals("Signed Permission should be granted for my permission", "true", resultTokenizer.nextToken());
+        assertEquals("signed Permission should be granted for text2.txt", "true", resultTokenizer.nextToken());
+        assertEquals("Permission should not be granted for text3.txt", "false", resultTokenizer.nextToken());
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/PermissionCollection_ImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/PermissionCollection_ImplTest.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/PermissionCollection_ImplTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/PermissionCollection_ImplTest.java
Thu Nov 26 11:12:49 2009
@@ -15,60 +15,61 @@
  *  limitations under the License.
  */
 
-/**
-* @author Alexey V. Varlamov
-*/
-
 package org.apache.harmony.security.tests.java.security;
+
 import java.security.Permission;
 import java.security.PermissionCollection;
-import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.List;
 
 import junit.framework.TestCase;
 
 /**
  * Tests for <code>PermissionCollection</code>
- * 
  */
-
 public class PermissionCollection_ImplTest extends TestCase {
     // Bare extension to instantiate abstract PermissionCollection class
-    private static final class RealPermissionCollection extends PermissionCollection
-    {
-        final private Collection col; 
-        public RealPermissionCollection(Collection col)
-        {
-            this.col = col;            
+    private static final class RealPermissionCollection extends
+            PermissionCollection {
+        final private Collection col;
+
+        public RealPermissionCollection(Collection<Permission> col) {
+            this.col = col;
+        }
+
+        public void add(Permission permission) {
         }
-        
-        public void add(Permission permission) {}
-        
-        public Enumeration elements() 
-        {
+
+        public Enumeration<Permission> elements() {
             return col == null ? null : Collections.enumeration(col);
         }
-        
-        public boolean implies(Permission permission) 
-        {
+
+        public boolean implies(Permission permission) {
             return false;
         }
     }
-    
+
     /** Test toString() transformation with different elements. */
-    public void testToString()
-    {
+    public void testToString() {
         // no elements
         PermissionCollection pc = new RealPermissionCollection(null);
-        String superString = pc.getClass().getName() + "@" + Integer.toHexString(pc.hashCode());
-        assertEquals("no elements", superString + " (\n)\n", pc.toString());
-        
+        try {
+            assertNotNull("No elements", pc.toString());
+        } catch (NullPointerException e) {
+            // Allowed
+        }
+
         // several elements
-        pc = new RealPermissionCollection(Arrays.asList(new Object[]{"aaa", "bbb", "ccc"}));
-        superString = pc.getClass().getName() + "@" + Integer.toHexString(pc.hashCode());
-        assertEquals("several elements", superString + " (\n aaa\n bbb\n ccc\n)\n", pc.toString());
+        List<Permission> bpList = new ArrayList<Permission>();
+        bpList.add(new RuntimePermission("aaa"));
+        bpList.add(new RuntimePermission("bbb"));
+        bpList.add(new RuntimePermission("ccc"));
+        String pcString = new RealPermissionCollection(bpList).toString();
+        assertTrue("Failed to find aaa", pcString.contains("aaa"));
+        assertTrue("Failed to find bbb", pcString.contains("bbb"));
+        assertTrue("Failed to find ccc", pcString.contains("ccc"));
     }
-   
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/javax/sound/sampled/AudioFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/javax/sound/sampled/AudioFormat.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/javax/sound/sampled/AudioFormat.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/javax/sound/sampled/AudioFormat.java
Thu Nov 26 11:12:49 2009
@@ -206,21 +206,25 @@
         
     }
 
+    @Override
+    @SuppressWarnings("nls")
     public String toString() {
 
         String ch;
         switch (channels) {
         case 1:
-            ch = "mono,"; //$NON-NLS-1$
+            ch = "mono,";
             break;
         case 2:
-            ch = "stereo,"; //$NON-NLS-1$
+            ch = "stereo,";
+            break;
         default:
-            ch = channels + " channels, "; //$NON-NLS-1$
-        }       
+            ch = channels + " channels, ";
+        }
 
-        return encoding + " " + sampleRate + " Hz, " + sampleSizeInBits + " bit, " //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
-            + ch + frameSize + " bytes/frame, " + frameRate + " frames/second"; //$NON-NLS-1$
//$NON-NLS-2$
+        return encoding + " " + sampleRate + " Hz, " + sampleSizeInBits
+                + " bit, " + ch + frameSize + " bytes/frame, " + frameRate
+                + " frames/second";
     }
     
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/org/apache/harmony/sound/utils/ProviderService.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/org/apache/harmony/sound/utils/ProviderService.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/org/apache/harmony/sound/utils/ProviderService.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/org/apache/harmony/sound/utils/ProviderService.java
Thu Nov 26 11:12:49 2009
@@ -17,6 +17,7 @@
 
 package org.apache.harmony.sound.utils;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
@@ -144,9 +145,7 @@
                             try {
                                 InputStream in = urls.nextElement()
                                         .openStream();
-                                bytes = new byte[in.available()];
-                                in.read(bytes);
-                                in.close();
+                                bytes = getAllBytesFromStreamAndClose(in);
                             } catch (IOException e) {
                                 continue;
                             }
@@ -173,5 +172,41 @@
     public static Properties getSoundProperties() {
         return devices;
     }
+    
+    /*
+     * Drains the entire content from the given input stream and returns it as a
+     * byte[]. The stream is closed after being drained, or if an IOException
+     * occurs.
+     */
+    private static byte[] getAllBytesFromStreamAndClose(InputStream is)
+            throws IOException {
+        try {
+            // Initial read
+            byte[] buffer = new byte[512];
+            int count = is.read(buffer);
+            int nextByte = is.read();
+
+            // Did we get it all in one read?
+            if (nextByte == -1) {
+                byte[] dest = new byte[count];
+                System.arraycopy(buffer, 0, dest, 0, count);
+                return dest;
+            }
+
+            // Requires additional reads
+            ByteArrayOutputStream baos = new ByteArrayOutputStream(count * 2);
+            baos.write(buffer, 0, count);
+            baos.write(nextByte);
+            while (true) {
+                count = is.read(buffer);
+                if (count == -1) {
+                    return baos.toByteArray();
+                }
+                baos.write(buffer, 0, count);
+            }
+        } finally {
+            is.close();
+        }
+    }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/Timestamp.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/Timestamp.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/Timestamp.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/Timestamp.java
Thu Nov 26 11:12:49 2009
@@ -204,7 +204,7 @@
             return 1;
         }
         
-        if(this.getNanos() > 0){
+        if (this.getNanos() % 1000000 > 0) {
             return 1;
         }
         return 0;

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java
Thu Nov 26 11:12:49 2009
@@ -153,7 +153,7 @@
 
     private boolean isNotifyListener = true;
 
-    protected static Map<Integer, Class<?>> TYPE_MAPPING = initialTypeMapping();
+    protected static final Map<Integer, Class<?>> TYPE_MAPPING = initialTypeMapping();
 
     public static final String PROVIDER_ID = "Apache Harmony HYOptimisticProvider"; //$NON-NLS-1$
 

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/XmlReaderImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/XmlReaderImpl.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/XmlReaderImpl.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/XmlReaderImpl.java
Thu Nov 26 11:12:49 2009
@@ -426,7 +426,7 @@
 
         private int parseInt(String value) throws SQLException {
             if (value == null) {
-                new SQLException(Messages.getString("rowset.27", value)); //$NON-NLS-1$
+                throw new SQLException(Messages.getString("rowset.27", value)); //$NON-NLS-1$
             }
 
             try {

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java
Thu Nov 26 11:12:49 2009
@@ -280,6 +280,7 @@
      */
     @SuppressWarnings("deprecation")
     public void testGetMinutes() {
+        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
         for (int i = 0; i < TIME_ARRAY.length; i++) {
             Timestamp theTimestamp = new Timestamp(TIME_ARRAY[i]);
             assertEquals(MINUTES_ARRAY[i], theTimestamp.getMinutes());
@@ -292,6 +293,7 @@
      */
     @SuppressWarnings("deprecation")
     public void testGetSeconds() {
+        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
         for (int i = 0; i < TIME_ARRAY.length; i++) {
             Timestamp theTimestamp = new Timestamp(TIME_ARRAY[i]);
             assertEquals(SECONDS_ARRAY[i], theTimestamp.getSeconds());
@@ -648,6 +650,11 @@
         assertEquals(0, timestamp.compareTo(date));
         timestamp.setNanos(10);
         assertEquals(1, timestamp.compareTo(date));
+        
+        long time = System.currentTimeMillis();
+        Date date2 = new Date(time);
+        Timestamp timestamp2 = new Timestamp(date2.getTime());
+        assertEquals(0, timestamp2.compareTo(date2));
     } // end method testcompareToObject
 
     /**

Propchange: harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/BasicSwingTestCase.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/BasicSwingTestCase.java:768152-824035
+/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/BasicSwingTestCase.java:768152-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/SwingTestCase.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/SwingTestCase.java:768152-824035
+/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/SwingTestCase.java:768152-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/text/parser/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/parser:768152-824035
+/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/parser:768152-884286

Modified: harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/Collator.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/Collator.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/Collator.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/Collator.java
Thu Nov 26 11:12:49 2009
@@ -157,21 +157,13 @@
 
     static {
         // CACHE_SIZE includes key and value, so needs to be double
-        String cacheSize = AccessController
-                .doPrivileged(new PrivilegedAction<String>() {
-                    public String run() {
-                        return System.getProperty("collator.cache"); //$NON-NLS-1$
+        Integer value = AccessController
+                .doPrivileged(new PrivilegedAction<Integer>() {
+                    public Integer run() {
+                        return Integer.getInteger("collator.cache"); //$NON-NLS-1$
                     }
                 });
-        if (cacheSize != null) {
-            try {
-                CACHE_SIZE = Integer.parseInt(cacheSize);
-            } catch (NumberFormatException e) {
-                CACHE_SIZE = 6;
-            }
-        } else {
-            CACHE_SIZE = 6;
-        }
+        CACHE_SIZE = value == null ? 6 : value.intValue();
     }
 
     private static Vector<Collator> cache = new Vector<Collator>(CACHE_SIZE);

Modified: harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/SimpleDateFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/SimpleDateFormat.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/SimpleDateFormat.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/SimpleDateFormat.java
Thu Nov 26 11:12:49 2009
@@ -762,7 +762,7 @@
                 dateFormatField = Field.YEAR;
                 int year = calendar.get(Calendar.YEAR);
                 if (count < 4) {
-                    appendNumber(buffer, 2, year %= 100);
+                    appendNumber(buffer, 2, year % 100);
                 } else {
                     appendNumber(buffer, count, year);
                 }

Modified: harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/org/apache/harmony/text/BidiRun.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/org/apache/harmony/text/BidiRun.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/org/apache/harmony/text/BidiRun.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/org/apache/harmony/text/BidiRun.java
Thu Nov 26 11:12:49 2009
@@ -47,9 +47,19 @@
 
     @Override
     public boolean equals(Object o) {
-        return o == null || o.getClass() != BidiRun.class ? false
-                : this.start == ((BidiRun) o).start
-                        && this.limit == ((BidiRun) o).limit
-                        && this.level == ((BidiRun) o).level;
+        if (o == null) {
+            return false;
+        }
+        if (!(o instanceof BidiRun)) {
+            return false;
+        }
+        BidiRun other = (BidiRun) o;
+        return start == other.start && limit == other.limit
+                && level == other.level;
+    }
+    
+    @Override
+    public int hashCode() {
+        return start ^ limit ^ level;
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLRecordProtocol.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLRecordProtocol.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLRecordProtocol.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLRecordProtocol.java
Thu Nov 26 11:12:49 2009
@@ -456,8 +456,8 @@
     }
 
     /**
-     * Shutdownes the protocol. It will be impossiblke to use the instance
-     * after the calling of this method.
+     * Shutdown the protocol. It will be impossible to use the 
+     * instance after the calling of this method. 
      */
     protected void shutdown() {
         session = null;
@@ -474,8 +474,8 @@
             activeReadState.shutdown();
         }
         activeReadState = null;
-        if (activeReadState != null) {
-            activeReadState.shutdown();
+        if (activeWriteState != null) {
+            activeWriteState.shutdown();
         }
         activeWriteState = null;
     }

Modified: harmony/enhanced/classlib/branches/java6/support/src/test/java/tests/support/Support_PermissionCollection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/support/src/test/java/tests/support/Support_PermissionCollection.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/support/src/test/java/tests/support/Support_PermissionCollection.java
(original)
+++ harmony/enhanced/classlib/branches/java6/support/src/test/java/tests/support/Support_PermissionCollection.java
Thu Nov 26 11:12:49 2009
@@ -43,13 +43,14 @@
 		PermissionCollection coll = Policy.getPolicy().getPermissions(pd);
 		Class<?> myPermission = Class.forName("mypackage.MyPermission");
 		BasicPermission myperm = (BasicPermission) myPermission.newInstance();
-		System.out.println(coll.implies(new java.io.FilePermission("test1.txt",
-				"write"))
+		System.out.println(
+		        coll.implies(new java.io.FilePermission("test1.txt", "write"))
 				+ ","
 				+ coll.implies(myperm)
+                + ","
+                + coll.implies(new java.io.FilePermission("test2.txt", "write"))
 				+ ","
-				+ coll
-						.implies(new java.io.FilePermission("test2.txt",
-								"write")) + ",");
+				+ coll.implies(new java.io.FilePermission("test3.txt", "read"))
+				+ ",");
 	}
 }
\ No newline at end of file



Mime
View raw message