harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r633384 [15/15] - in /harmony/enhanced/classlib/branches/java6: depends/build/platform/ depends/files/ depends/files/bcprov/ doc/ doc/classlib/ make/ make/linux.ia64/ make/linux.ppc32/ make/linux.ppc64/ make/linux.x86.libstdc++6/ make/linux...
Date Tue, 04 Mar 2008 08:02:45 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/security-kernel/src/main/java/java/security/AccessController.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security-kernel/src/main/java/java/security/AccessController.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security-kernel/src/main/java/java/security/AccessController.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security-kernel/src/main/java/java/security/AccessController.java Tue Mar  4 00:02:13 2008
@@ -23,251 +23,275 @@
  * 
  * Checks access to system resources. Supports marking of code as priveleged.
  * Makes context snapshots to allow checking from other contexts.
- * 
  */
-
 public final class AccessController {
-	static {
-		// Initialize vm-internal caches
-		initializeInternal();
-	}
-
-	private static native void initializeInternal();
-
-	/**
-	 * Prevents this class from being instantiated.
-	 */
-	private AccessController() {
-	}
-
-	/**
-	 * This native must be implemented to use the reference implementation of
-	 * this class. It is used by checkPermission() and getContext(), which call
-	 * this native with depth = 1.
-	 * 
-	 * Returns an array of ProtectionDomain from the classes on the stack, from
-	 * the specified depth up to the first privileged frame, or the end of the
-	 * stack if there is not a privileged frame. The array may be larger than
-	 * required, but must be null terminated. As bootstrap classes have all
-	 * permissions, bootstrap class frames SHOULD be skipped. Bootstrap class
-	 * frames MUST be skipped if the ProtectionDomain of bootstrap classes is
-	 * null. Duplicate ProtectionDomains SHOULD be removed.
-	 * 
-	 * The first element of the result is the AccessControlContext, which may be
-	 * null, either from the privileged frame, or from the current Thread if
-	 * there is not a privileged frame.
-	 * 
-	 * A privileged frame is any frame running one of the following methods:
-	 * 
-	 * <code><ul>
-	 * <li>java/security/AccessController.doPrivileged(Ljava/security/PrivilegedAction;)Ljava/lang/Object;</li>
-	 * <li>java/security/AccessController.doPrivileged(Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object;</li>
-	 * <li>java/security/AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;</li>
-	 * <li>java/security/AccessController.doPrivileged(Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;</li>
-	 * </ul></code>
-	 * 
-	 * @param depth
-	 *            The stack depth at which to start. Depth 0 is the current
-	 *            frame (the caller of this native).
-	 * 
-	 * @return an Object[] where the first element is AccessControlContext, and
-	 *         the other elements are ProtectionsDomain.
-	 */
-
-	private static native Object[] getProtectionDomains(int depth);
-
-	/**
-	 * Checks whether the running program is allowed to access the resource
-	 * being guarded by the given Permission argument.
-	 * 
-	 * 
-	 * @param perm
-	 *            the permission to check
-	 * @exception AccessControlException
-	 *                if access is not allowed.
-	 */
-	public static void checkPermission(Permission perm)
-			throws AccessControlException {
-		if (perm == null)
-			throw new NullPointerException();
-		Object[] domains = getProtectionDomains(1);
-		AccessControlContext acc = (AccessControlContext) domains[0];
-		ProtectionDomain[] pDomains = null;
-		if (acc != null && acc.domainCombiner != null) {
-			pDomains = acc.domainCombiner.combine(toArrayOfProtectionDomains(
-					domains, null), acc.domainsArray);
-		} else {
-			pDomains = toArrayOfProtectionDomains(domains, acc);
-		}
-		for (int i = 0, length = pDomains.length; i < length; i++) {
-			if (!pDomains[i].implies(perm)) {
-				throw new AccessControlException("Access Denied " + perm, perm);
-			}
-		}
-	}
-
-	/**
-	 * Used to keep the context live during doPrivileged().
-	 * 
-	 * 
-	 * @see #doPrivileged(PrivilegedAction<T>, AccessControlContext)
-	 */
-	private static void keepalive(AccessControlContext context) {
-	}
-
-	/**
-	 * Answers the access controller context of the current thread, including
-	 * the inherited ones. It basically retrieves all the protection domains
-	 * from the calling stack and creates an <code>AccessControlContext</code>
-	 * with them.
-	 * 
-	 * 
-	 * @see AccessControlContext
-	 */
-	public static AccessControlContext getContext() {
-		Object[] domains = getProtectionDomains(1);
-		AccessControlContext acc = (AccessControlContext) domains[0];
-		ProtectionDomain[] pDomains = null;
-		if (acc != null && acc.domainCombiner != null) {
-			pDomains = acc.domainCombiner.combine(toArrayOfProtectionDomains(
-					domains, null), acc.domainsArray);
-			AccessControlContext result = new AccessControlContext(pDomains,
-					false);
-			result.domainCombiner = acc.domainCombiner;
-			return result;
-		}
-		return new AccessControlContext(
-				toArrayOfProtectionDomains(domains, acc), false);
-	}
-
-	private static ProtectionDomain[] toArrayOfProtectionDomains(
-			Object[] domains, AccessControlContext acc) {
-		int len = 0, size = domains.length - 1;
-		int extra = acc == null ? 0 : acc.domainsArray.length;
-		ProtectionDomain[] answer = new ProtectionDomain[size + extra];
-		for (int i = 1; i <= size; i++) {
-			boolean found = false;
-			if ((answer[len] = (ProtectionDomain) domains[i]) == null)
-				break;
-			if (acc != null) {
-				for (int j = 0; j < acc.domainsArray.length; j++) {
-					if (answer[len] == acc.domainsArray[j]) {
-						found = true;
-						break;
-					}
-				}
-			}
-			if (!found)
-				len++;
-		}
-		if (len == 0 && acc != null)
-			return acc.domainsArray;
-		else if (len < size) {
-			ProtectionDomain[] copy = new ProtectionDomain[len + extra];
-			System.arraycopy(answer, 0, copy, 0, len);
-			answer = copy;
-		}
-		if (acc != null)
-			System.arraycopy(acc.domainsArray, 0, answer, len,
-					acc.domainsArray.length);
-		return answer;
-	}
-
-	/**
-	 * Performs the privileged action specified by <code>action</code>.
-	 * <p>
-	 * When permission checks are made, if the permission has been granted by
-	 * all frames below and including the one representing the call to this
-	 * method, then the permission is granted. In otherwords, the check stops
-	 * here.
-	 * 
-	 * Any unchecked exception generated by this method will propagate up the
-	 * chain.
-	 * 
-	 * 
-	 * @see #doPrivileged(PrivilegedAction<T>)
-	 */
-	public static <T> T doPrivileged(PrivilegedAction<T> action) {
-		return action.run();
-	}
-
-	/**
-	 * Performs the privileged action specified by <code>action</code>.
-	 * <p>
-	 * When permission checks are made, if the permission has been granted by
-	 * all frames below and including the one representing the call to this
-	 * method, then the permission is granted iff it is granted by the
-	 * AccessControlContext <code>context</code>. In otherwords, no more
-	 * checking of the current stack is performed. Instead, the passed in
-	 * context is checked.
-	 * 
-	 * Any unchecked exception generated by this method will propagate up the
-	 * chain.
-	 * 
-	 * 
-	 * @see #doPrivileged(PrivilegedAction<T>)
-	 */
-	public static <T> T doPrivileged(PrivilegedAction<T> action,
-			AccessControlContext context) {
-		T result = action.run();
-		keepalive(context);
-		return result;
-	}
-
-	/**
-	 * Performs the privileged action specified by <code>action</code>.
-	 * <p>
-	 * When permission checks are made, if the permission has been granted by
-	 * all frames below and including the one representing the call to this
-	 * method, then the permission is granted. In otherwords, the check stops
-	 * here.
-	 * 
-	 * Any unchecked exception generated by this method will propagate up the
-	 * chain. However, checked exceptions will be caught an re-thrown as
-	 * PrivilegedActionExceptions
-	 * 
-	 * 
-	 * @see #doPrivileged(PrivilegedAction<T>)
-	 */
-	public static <T> T doPrivileged(PrivilegedExceptionAction<T> action)
-			throws PrivilegedActionException {
-		try {
-			return action.run();
-		} catch (RuntimeException ex) {
-			throw ex;
-		} catch (Exception ex) {
-			throw new PrivilegedActionException(ex);
-		}
-	}
-
-	/**
-	 * Performs the privileged action specified by <code>action</code>.
-	 * <p>
-	 * When permission checks are made, if the permission has been granted by
-	 * all frames below and including the one representing the call to this
-	 * method, then the permission is granted iff it is granted by the
-	 * AccessControlContext <code>context</code>. In otherwords, no more
-	 * checking of the current stack is performed. Instead, the passed in
-	 * context is checked.
-	 * 
-	 * Any unchecked exception generated by this method will propagate up the
-	 * chain. However, checked exceptions will be caught an re-thrown as
-	 * PrivilegedActionExceptions
-	 * 
-	 * 
-	 * @see #doPrivileged(PrivilegedAction<T>)
-	 */
-	public static <T> T doPrivileged(PrivilegedExceptionAction<T> action,
-			AccessControlContext context) throws PrivilegedActionException {
-		try {
-			T result = action.run();
-			keepalive(context);
-			return result;
-		} catch (RuntimeException ex) {
-			throw ex;
-		} catch (Exception ex) {
-			throw new PrivilegedActionException(ex);
-		}
-	}
+    static {
+        // Initialize vm-internal caches
+        initializeInternal();
+    }
+
+    private static native void initializeInternal();
+
+    /**
+     * Prevents this class from being instantiated.
+     */
+    private AccessController() {
+    }
+
+    /**
+     * This native must be implemented to use the reference implementation of
+     * this class. It is used by checkPermission() and getContext(), which call
+     * this native with depth = 1.
+     * 
+     * Returns an array of ProtectionDomain from the classes on the stack, from
+     * the specified depth up to the first privileged frame, or the end of the
+     * stack if there is not a privileged frame. The array may be larger than
+     * required, but must be null terminated. As bootstrap classes have all
+     * permissions, bootstrap class frames SHOULD be skipped. Bootstrap class
+     * frames MUST be skipped if the ProtectionDomain of bootstrap classes is
+     * null. Duplicate ProtectionDomains SHOULD be removed.
+     * 
+     * The first element of the result is the AccessControlContext, which may be
+     * null, either from the privileged frame, or from the current Thread if
+     * there is not a privileged frame.
+     * 
+     * A privileged frame is any frame running one of the following methods:
+     * 
+     * <code><ul>
+     * <li>java/security/AccessController.doPrivileged(Ljava/security/PrivilegedAction;)Ljava/lang/Object;</li>
+     * <li>java/security/AccessController.doPrivileged(Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object;</li>
+     * <li>java/security/AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;</li>
+     * <li>java/security/AccessController.doPrivileged(Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;</li>
+     * </ul></code>
+     * 
+     * @param depth
+     *            The stack depth at which to start. Depth 0 is the current
+     *            frame (the caller of this native).
+     * 
+     * @return an Object[] where the first element is AccessControlContext, and
+     *         the other elements are ProtectionsDomain.
+     */
+
+    private static native Object[] getProtectionDomains(int depth);
+
+    /**
+     * Checks whether the running program is allowed to access the resource
+     * being guarded by the given Permission argument.
+     * 
+     * 
+     * @param perm
+     *            the permission to check
+     * @exception AccessControlException
+     *                if access is not allowed.
+     */
+    public static void checkPermission(Permission perm)
+            throws AccessControlException {
+        if (perm == null)
+            throw new NullPointerException();
+        Object[] domains = getProtectionDomains(1);
+        AccessControlContext acc = (AccessControlContext) domains[0];
+        ProtectionDomain[] pDomains = null;
+        if (acc != null && acc.domainCombiner != null) {
+            pDomains = acc.domainCombiner.combine(toArrayOfProtectionDomains(
+                    domains, null), acc.domainsArray);
+        } else {
+            pDomains = toArrayOfProtectionDomains(domains, acc);
+        }
+        for (int i = 0, length = pDomains.length; i < length; i++) {
+            if (!pDomains[i].implies(perm)) {
+                throw new AccessControlException("Access Denied " + perm, perm); //$NON-NLS-1$
+            }
+        }
+    }
+
+    /**
+     * Used to keep the context live during doPrivileged().
+     * 
+     * @see #doPrivileged(PrivilegedAction, AccessControlContext)
+     */
+    private static void keepalive(AccessControlContext context) {
+    }
+
+    /**
+     * Answers the access controller context of the current thread, including
+     * the inherited ones. It basically retrieves all the protection domains
+     * from the calling stack and creates an <code>AccessControlContext</code>
+     * with them.
+     * 
+     * @return the access control context of the current thread
+     * @see AccessControlContext
+     */
+    public static AccessControlContext getContext() {
+        Object[] domains = getProtectionDomains(1);
+        AccessControlContext acc = (AccessControlContext) domains[0];
+        ProtectionDomain[] pDomains = null;
+        if (acc != null && acc.domainCombiner != null) {
+            pDomains = acc.domainCombiner.combine(toArrayOfProtectionDomains(
+                    domains, null), acc.domainsArray);
+            AccessControlContext result = new AccessControlContext(pDomains,
+                    false);
+            result.domainCombiner = acc.domainCombiner;
+            return result;
+        }
+        return new AccessControlContext(
+                toArrayOfProtectionDomains(domains, acc), false);
+    }
+
+    private static ProtectionDomain[] toArrayOfProtectionDomains(
+            Object[] domains, AccessControlContext acc) {
+        int len = 0, size = domains.length - 1;
+        int extra = acc == null ? 0 : acc.domainsArray.length;
+        ProtectionDomain[] answer = new ProtectionDomain[size + extra];
+        for (int i = 1; i <= size; i++) {
+            boolean found = false;
+            if ((answer[len] = (ProtectionDomain) domains[i]) == null)
+                break;
+            if (acc != null) {
+                for (int j = 0; j < acc.domainsArray.length; j++) {
+                    if (answer[len] == acc.domainsArray[j]) {
+                        found = true;
+                        break;
+                    }
+                }
+            }
+            if (!found)
+                len++;
+        }
+        if (len == 0 && acc != null)
+            return acc.domainsArray;
+        else if (len < size) {
+            ProtectionDomain[] copy = new ProtectionDomain[len + extra];
+            System.arraycopy(answer, 0, copy, 0, len);
+            answer = copy;
+        }
+        if (acc != null)
+            System.arraycopy(acc.domainsArray, 0, answer, len,
+                    acc.domainsArray.length);
+        return answer;
+    }
+
+    /**
+     * Performs the privileged action specified by <code>action</code>.
+     * 
+     * When permission checks are made, if the permission has been granted by
+     * all frames below and including the one representing the call to this
+     * method, then the permission is granted. In otherwords, the check stops
+     * here.
+     * 
+     * Any unchecked exception generated by this method will propagate up the
+     * chain.
+     * 
+     * @param action
+     *            the action being performed
+     * @param <T>
+     *            the return type for the privileged action
+     * @return the result of evaluating the action
+     * 
+     * @see #doPrivileged(PrivilegedAction)
+     */
+    public static <T> T doPrivileged(PrivilegedAction<T> action) {
+        return action.run();
+    }
+
+    /**
+     * Performs the privileged action specified by <code>action</code>.
+     * 
+     * When permission checks are made, if the permission has been granted by
+     * all frames below and including the one representing the call to this
+     * method, then the permission is granted iff it is granted by the
+     * AccessControlContext <code>context</code>. In otherwords, no more
+     * checking of the current stack is performed. Instead, the passed in
+     * context is checked.
+     * 
+     * Any unchecked exception generated by this method will propagate up the
+     * chain.
+     * 
+     * @param action
+     *            the action being performed
+     * @param <T>
+     *            the return type for the privileged action
+     * @param context
+     *            the context being checked for the privileged action
+     * @return the result of evaluating the action
+     * 
+     * @see #doPrivileged(PrivilegedAction)
+     */
+    public static <T> T doPrivileged(PrivilegedAction<T> action,
+            AccessControlContext context) {
+        T result = action.run();
+        keepalive(context);
+        return result;
+    }
+
+    /**
+     * Performs the privileged action specified by <code>action</code>.
+     * 
+     * When permission checks are made, if the permission has been granted by
+     * all frames below and including the one representing the call to this
+     * method, then the permission is granted. In otherwords, the check stops
+     * here.
+     * 
+     * Any unchecked exception generated by this method will propagate up the
+     * chain. However, checked exceptions will be caught an re-thrown as
+     * PrivilegedActionExceptions.
+     * 
+     * @param action
+     *            the action being performed
+     * @param <T>
+     *            the return type for the privileged action
+     * @return the result of evaluating the action
+     * @throws PrivilegedActionException
+     *             if a checked exception was thrown
+     * @see #doPrivileged(PrivilegedAction)
+     */
+    public static <T> T doPrivileged(PrivilegedExceptionAction<T> action)
+            throws PrivilegedActionException {
+        try {
+            return action.run();
+        } catch (RuntimeException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            throw new PrivilegedActionException(ex);
+        }
+    }
+
+    /**
+     * Performs the privileged action specified by <code>action</code>.
+     * 
+     * When permission checks are made, if the permission has been granted by
+     * all frames below and including the one representing the call to this
+     * method, then the permission is granted iff it is granted by the
+     * AccessControlContext <code>context</code>. In otherwords, no more
+     * checking of the current stack is performed. Instead, the passed in
+     * context is checked.
+     * 
+     * Any unchecked exception generated by this method will propagate up the
+     * chain. However, checked exceptions will be caught an re-thrown as
+     * PrivilegedActionExceptions
+     * 
+     * @param action
+     *            the action being performed
+     * @param <T>
+     *            the return type for the privileged action
+     * @param context
+     *            the context being checked for the privileged action
+     * @return the result of evaluating the action
+     * @throws PrivilegedActionException
+     *             if a checked exception was thrown
+     * 
+     * @see #doPrivileged(PrivilegedAction)
+     */
+    public static <T> T doPrivileged(PrivilegedExceptionAction<T> action,
+            AccessControlContext context) throws PrivilegedActionException {
+        try {
+            T result = action.run();
+            keepalive(context);
+            return result;
+        } catch (RuntimeException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            throw new PrivilegedActionException(ex);
+        }
+    }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/MessageDigest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/MessageDigest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/MessageDigest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/MessageDigest.java Tue Mar  4 00:02:13 2008
@@ -15,11 +15,6 @@
  *  limitations under the License.
  */
 
-/**
-* @author Boris V. Kuznetsov
-* @version $Revision$
-*/
-
 package java.security;
 
 import java.nio.ByteBuffer;
@@ -27,14 +22,8 @@
 import org.apache.harmony.security.fortress.Engine;
 import org.apache.harmony.security.internal.nls.Messages;
 
-
-/**
- * @com.intel.drl.spec_ref
- * 
- */
-
 public abstract class MessageDigest extends MessageDigestSpi {
-    
+
     // The service name
     private static final String SERVICE = "MessageDigest"; //$NON-NLS-1$
 
@@ -49,7 +38,7 @@
 
     /**
      * @com.intel.drl.spec_ref
-     *  
+     * 
      */
     protected MessageDigest(String algorithm) {
         this.algorithm = algorithm;
@@ -57,7 +46,7 @@
 
     /**
      * @com.intel.drl.spec_ref
-     *  
+     * 
      */
     public static MessageDigest getInstance(String algorithm)
             throws NoSuchAlgorithmException {
@@ -82,16 +71,18 @@
 
     /**
      * @com.intel.drl.spec_ref
-     *  
+     * 
      */
     public static MessageDigest getInstance(String algorithm, String provider)
             throws NoSuchAlgorithmException, NoSuchProviderException {
         if ((provider == null) || (provider.length() == 0)) {
-            throw new IllegalArgumentException(Messages.getString("security.02")); //$NON-NLS-1$
+            throw new IllegalArgumentException(Messages
+                    .getString("security.02")); //$NON-NLS-1$
         }
         Provider p = Security.getProvider(provider);
         if (p == null) {
-            throw new NoSuchProviderException(Messages.getString("security.03", provider)); //$NON-NLS-1$
+            throw new NoSuchProviderException(Messages.getString(
+                    "security.03", provider)); //$NON-NLS-1$
         }
         return getInstance(algorithm, p);
     }
@@ -115,7 +106,8 @@
     public static MessageDigest getInstance(String algorithm, Provider provider)
             throws NoSuchAlgorithmException {
         if (provider == null) {
-            throw new IllegalArgumentException(Messages.getString("security.04")); //$NON-NLS-1$
+            throw new IllegalArgumentException(Messages
+                    .getString("security.04")); //$NON-NLS-1$
         }
         if (algorithm == null) {
             throw new NullPointerException(Messages.getString("security.01")); //$NON-NLS-1$
@@ -139,20 +131,17 @@
     /**
      * Puts the receiver back in an initial state, such that it is ready to
      * compute a new hash.
-     * 
-     * @see java.security.MessageDigest.Wrapper#engineReset()
      */
     public void reset() {
         engineReset();
     }
 
     /**
-     * Includes the argument in the hash value computed
-     * by the receiver.
-     *
-     * @param arg0 byte
-     *             the byte to feed to the hash algorithm
-     *
+     * Includes the argument in the hash value computed by the receiver.
+     * 
+     * @param arg0
+     *            byte the byte to feed to the hash algorithm
+     * 
      * @see #reset()
      */
     public void update(byte arg0) {
@@ -161,11 +150,11 @@
 
     /**
      * @com.intel.drl.spec_ref
-     *  
+     * 
      */
     public void update(byte[] input, int offset, int len) {
         if (input == null ||
-                // offset < 0 || len < 0 ||
+        // offset < 0 || len < 0 ||
                 // checks for negative values are commented out intentionally
                 // see HARMONY-1120 for details
                 (long) offset + (long) len > input.length) {
@@ -177,7 +166,7 @@
 
     /**
      * @com.intel.drl.spec_ref
-     *  
+     * 
      */
     public void update(byte[] input) {
         if (input == null) {
@@ -200,11 +189,11 @@
 
     /**
      * @com.intel.drl.spec_ref
-     *  
+     * 
      */
     public int digest(byte[] buf, int offset, int len) throws DigestException {
         if (buf == null ||
-                // offset < 0 || len < 0 ||
+        // offset < 0 || len < 0 ||
                 // checks for negative values are commented out intentionally
                 // see HARMONY-1148 for details
                 (long) offset + (long) len > buf.length) {
@@ -216,7 +205,7 @@
 
     /**
      * @com.intel.drl.spec_ref
-     *  
+     * 
      */
     public byte[] digest(byte[] input) {
         update(input);
@@ -299,7 +288,7 @@
 
     /**
      * @com.intel.drl.spec_ref
-     *  
+     * 
      */
     public Object clone() throws CloneNotSupportedException {
         if (this instanceof Cloneable) {
@@ -311,7 +300,7 @@
 
     /**
      * @com.intel.drl.spec_ref
-     *  
+     * 
      */
     public final void update(ByteBuffer input) {
         engineUpdate(input);
@@ -323,7 +312,7 @@
      * 
      */
     private static class MessageDigestImpl extends MessageDigest {
-        
+
         // MessageDigestSpi implementation
         private MessageDigestSpi spiImpl;
 

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.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/acl/AclNotFoundExceptionTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.java Tue Mar  4 00:02:13 2008
@@ -38,12 +38,12 @@
     }
 
     /**
-     * check default constructor 
-     */    
+     * @tests java.security.acl.AclNotFoundException#AclNotFoundException()
+     */
     public void testAclNotFoundException() {
-        assertNotNull(new AclNotFoundException());
-        assertNull(new AclNotFoundException().getMessage());
-        assertNull(new AclNotFoundException().getCause());
+        AclNotFoundException ex = new AclNotFoundException();
+        assertNull(ex.getMessage());
+        assertNull(ex.getCause());
     }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.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/acl/LastOwnerExceptionTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.java Tue Mar  4 00:02:13 2008
@@ -15,11 +15,6 @@
  *  limitations under the License.
  */
 
-/**
-* @author Aleksei Y. Semenov
-* @version $Revision$
-*/
-
 package org.apache.harmony.security.tests.java.security.acl;
 
 import java.security.acl.LastOwnerException;
@@ -37,10 +32,13 @@
         junit.textui.TestRunner.run(LastOwnerExceptionTest.class);
     }
 
+    /**
+     * @tests java.security.acl.LastOwnerException#LastOwnerException()
+     */
     public void testLastOwnerException() {
-        assertNotNull(new LastOwnerException());
-        assertNull(new LastOwnerException().getMessage());
-        assertNull(new LastOwnerException().getCause());
+        LastOwnerException ex = new LastOwnerException();
+        assertNull(ex.getMessage());
+        assertNull(ex.getCause());
     }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.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/acl/NotOwnerExceptionTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.java Tue Mar  4 00:02:13 2008
@@ -15,11 +15,6 @@
  *  limitations under the License.
  */
 
-/**
-* @author Aleksei Y. Semenov
-* @version $Revision$
-*/
-
 package org.apache.harmony.security.tests.java.security.acl;
 
 import java.security.acl.NotOwnerException;
@@ -37,10 +32,13 @@
         junit.textui.TestRunner.run(NotOwnerExceptionTest.class);
     }
 
+    /**
+     * @tests java.security.acl.NotOwnerException#NotOwnerException()
+     */
     public void testNotOwnerException() {
-        assertNotNull(new NotOwnerException());
-        assertNull(new NotOwnerException().getMessage());
-        assertNull(new NotOwnerException().getCause());
+        NotOwnerException ex = new NotOwnerException();
+        assertNull(ex.getMessage());
+        assertNull(ex.getCause());
     }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/sound/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sound/build.xml?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sound/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sound/build.xml Tue Mar  4 00:02:13 2008
@@ -83,6 +83,8 @@
                target="${hy.javac.target}"
                debug="${hy.javac.debug}">
 
+            <compilerarg line="${build.compilerarg}" />
+
             <bootclasspath>
                 <fileset dir="${hy.jdk}/jre/lib/boot">
                     <include name="**/*.jar" />

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=633384&r1=633383&r2=633384&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 Tue Mar  4 00:02:13 2008
@@ -382,6 +382,9 @@
             throw new IllegalArgumentException(Messages.getString("sql.3")); //$NON-NLS-1$
         }
 
+        // omit trailing whitespaces
+        s = s.trim();
+
         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$
         ParsePosition pp = new ParsePosition(0);
 

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties Tue Mar  4 00:02:13 2008
@@ -68,5 +68,6 @@
 rowset.5=There are conflicts between rowset and data source
 rowset.6=Errors in the process of Writing Back RowData
 rowset.7=Not a valid cursor
-rowset.8=The Result Set Type is TYPE_FORWARD_ONLY 
-rowset.9=PageSize can not larger than MaxRows
+rowset.8=The ResultSet type is TYPE_FORWARD_ONLY 
+rowset.9=PageSize can not be larger than MaxRows
+rowset.10=Data type mismatch

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRow.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRow.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRow.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRow.java Tue Mar  4 00:02:13 2008
@@ -122,6 +122,14 @@
         return new CachedRow(originalColumnData);
     }
 
+    public void setOriginal() {
+        isUpdate = false;
+        isDelete = false;
+        isInsert = false;
+        mask.flip(0, columnData.length);
+        originalColumnData = columnData.clone();
+    }
+
     public Object getObject(int columnIndex) {
         return columnData[columnIndex - 1];
     }

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=633384&r1=633383&r2=633384&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 Tue Mar  4 00:02:13 2008
@@ -37,8 +37,10 @@
 import java.sql.SQLXML;
 import java.sql.Savepoint;
 import java.sql.Statement;
+import java.sql.Struct;
 import java.sql.Time;
 import java.sql.Timestamp;
+import java.sql.Types;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collection;
@@ -99,15 +101,50 @@
     // TODO where is it initialized
     private CachedRowSetImpl originalResultSet;
 
-    private Object currentColumn;
-
     private SQLWarning sqlwarn;
 
+    private Class[] columnTypes;
+
+    private static Map<Integer, Class> TYPE_MAPPING = initialTypeMapping();
+
+    public static final String PROVIDER_ID = "Apache Harmony HYOptimisticProvider"; //$NON-NLS-1$
+
     public CachedRowSetImpl(String providerID) throws SyncFactoryException {
         syncProvider = SyncFactory.getInstance(providerID);
         initialProperties();
     }
 
+    private static Map<Integer, Class> initialTypeMapping() {
+        HashMap<Integer, Class> map = new HashMap<Integer, Class>();
+        map.put(Integer.valueOf(Types.ARRAY), Array.class);
+        map.put(Integer.valueOf(Types.BIGINT), Long.class);
+        map.put(Integer.valueOf(Types.BINARY), byte[].class);
+        map.put(Integer.valueOf(Types.BIT), Boolean.class);
+        map.put(Integer.valueOf(Types.BLOB), Blob.class);
+        map.put(Integer.valueOf(Types.BOOLEAN), Boolean.class);
+        map.put(Integer.valueOf(Types.CHAR), String.class);
+        map.put(Integer.valueOf(Types.CLOB), Clob.class);
+        map.put(Integer.valueOf(Types.DATE), Date.class);
+        map.put(Integer.valueOf(Types.DECIMAL), BigDecimal.class);
+        map.put(Integer.valueOf(Types.DOUBLE), Double.class);
+        map.put(Integer.valueOf(Types.FLOAT), Double.class);
+        map.put(Integer.valueOf(Types.INTEGER), Integer.class);
+        map.put(Integer.valueOf(Types.LONGVARBINARY), byte[].class);
+        map.put(Integer.valueOf(Types.LONGVARCHAR), String.class);
+        map.put(Integer.valueOf(Types.NUMERIC), BigDecimal.class);
+        map.put(Integer.valueOf(Types.REAL), Float.class);
+        map.put(Integer.valueOf(Types.REF), Ref.class);
+        map.put(Integer.valueOf(Types.SMALLINT), Short.class);
+        map.put(Integer.valueOf(Types.STRUCT), Struct.class);
+        map.put(Integer.valueOf(Types.TIME), Time.class);
+        map.put(Integer.valueOf(Types.TIMESTAMP), Timestamp.class);
+        map.put(Integer.valueOf(Types.TINYINT), Byte.class);
+        map.put(Integer.valueOf(Types.VARBINARY), byte[].class);
+        map.put(Integer.valueOf(Types.VARCHAR), String.class);
+
+        return map;
+    }
+
     private void initialProperties() {
         try {
             setEscapeProcessing(true);
@@ -129,7 +166,7 @@
     }
 
     public CachedRowSetImpl() throws SyncFactoryException {
-        this("Apache Harmony HYOptimisticProvider");
+        this(PROVIDER_ID);
     }
 
     public void setRows(ArrayList<CachedRow> data, int cloumnCount) {
@@ -179,7 +216,7 @@
     public boolean columnUpdated(int idx) throws SQLException {
         if (currentRow == null || idx > meta.getColumnCount()) {
             // rowset.0 = Not a valid position
-            throw new SQLException(Messages.getString("rowset.0"));
+            throw new SQLException(Messages.getString("rowset.0")); //$NON-NLS-1$
         }
         return currentRow.getUpdateMask(idx - 1);
     }
@@ -195,7 +232,7 @@
             }
         }
         // rowset.1=Not a valid column name
-        throw new SQLException(Messages.getString("rowset.1"));
+        throw new SQLException(Messages.getString("rowset.1")); //$NON-NLS-1$
     }
 
     public void commit() throws SQLException {
@@ -209,7 +246,7 @@
              * the attribute of BaseRowSet which are needed to deep copy
              */
             // BaseRowSet.params <Hashtable>
-            Object[] paramsObjArray = super.getParams().clone();
+            Object[] paramsObjArray = super.getParams();
             Hashtable<Object, Object> paramsHashtable = new Hashtable<Object, Object>();
             for (int i = 0; i < paramsObjArray.length; i++) {
                 paramsHashtable.put(Integer.valueOf(i), paramsObjArray[i]);
@@ -301,7 +338,6 @@
         CachedRowSetImpl output = (CachedRowSetImpl) createCopy();
 
         // clean up rows data
-        output.currentColumn = null;
         output.currentRow = null;
         output.currentRowIndex = 0;
         output.insertRow = null;
@@ -411,6 +447,14 @@
     private void doPopulate(ResultSet rs, boolean isPaging) throws SQLException {
         meta = copyMetaData(rs.getMetaData());
 
+        columnCount = meta.getColumnCount();
+        // initial columnTypes
+        columnTypes = new Class[columnCount];
+        for (int i = 1; i <= columnTypes.length; ++i) {
+            columnTypes[i - 1] = TYPE_MAPPING.get(Integer.valueOf(meta
+                    .getColumnType(i)));
+        }
+
         /*
          * this method not support paging, so before readData set pageSize and
          * maxRowsto 0 and restore previous values after readData
@@ -529,11 +573,11 @@
     public void setPageSize(int size) throws SQLException {
         if (size < 0) {
             // rowset.2=Negative page size
-            throw new SQLException(Messages.getString("rowset.2"));
+            throw new SQLException(Messages.getString("rowset.2")); //$NON-NLS-1$
         }
         if ((getMaxRows() != 0) && (getMaxRows() < size)) {
             // rowset.9=PageSize can not larger than MaxRows
-            throw new SQLException(Messages.getString("rowset.9"));
+            throw new SQLException(Messages.getString("rowset.9")); //$NON-NLS-1$
         }
         pageSize = size;
     }
@@ -545,7 +589,7 @@
     public void setTableName(String tabName) throws SQLException {
         if (tabName == null) {
             // rowset.3=Table name should not be null
-            throw new SQLException("rowset.3");
+            throw new SQLException("rowset.3"); //$NON-NLS-1$
         }
         tableName = tabName;
     }
@@ -648,7 +692,7 @@
 
         if (checkType && getType() == ResultSet.TYPE_FORWARD_ONLY) {
             // rowset.8=The Result Set Type is TYPE_FORWARD_ONLY
-            throw new SQLException(Messages.getString("rowset.8"));
+            throw new SQLException(Messages.getString("rowset.8")); //$NON-NLS-1$
         }
 
         if (row < 0) {
@@ -741,7 +785,8 @@
     }
 
     public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
-        throw new NotImplementedException();
+        // TODO re-implement it
+        return (BigDecimal) getObject(columnIndex);
     }
 
     public BigDecimal getBigDecimal(int columnIndex, int scale)
@@ -896,6 +941,7 @@
     }
 
     public Object getObject(int columnIndex) throws SQLException {
+        // TODO re-implement it
         return currentRow.getObject(columnIndex);
     }
 
@@ -952,12 +998,19 @@
         return (String) value;
     }
 
-    private boolean checkCursorValid() throws SQLException {
+    private void checkColumnValid(int columnIndex) throws SQLException {
+        if (columnIndex <= 0 || columnIndex > meta.getColumnCount()) {
+            // sql.27=Invalid column index :{0}
+            throw new SQLException(Messages.getString("sql.27", Integer //$NON-NLS-1$
+                    .valueOf(columnIndex)));
+        }
+    }
+
+    private void checkCursorValid() throws SQLException {
         if ((currentRowIndex <= 0) || (currentRowIndex > rows.size())) {
             // rowset.7=Not a valid cursor
             throw new SQLException(Messages.getString("rowset.7")); //$NON-NLS-1$
         }
-        return false;
     }
 
     public String getString(String columnName) throws SQLException {
@@ -1022,7 +1075,7 @@
         checkValidRow();
         if (currentRow != insertRow) {
             // rowset.4=Not an insert row
-            throw new SQLException(Messages.getString("rowset.4"));
+            throw new SQLException(Messages.getString("rowset.4")); //$NON-NLS-1$
         }
         insertRow.setInsert();
         rows.add(insertRow);
@@ -1134,21 +1187,21 @@
     public boolean rowUpdated() throws SQLException {
         if (!currentRow.isUpdate()) {
             return false;
-        } else {
-            boolean sign = false;
-            for (int i = 0; i < meta.getColumnCount(); ++i) {
-                sign = currentRow.getUpdateMask(i) | sign;
-            }
-            return sign;
         }
+
+        boolean sign = false;
+        for (int i = 0; i < meta.getColumnCount(); ++i) {
+            sign = currentRow.getUpdateMask(i) | sign;
+        }
+        return sign;
     }
 
     public void updateArray(int columnIndex, Array x) throws SQLException {
-        throw new NotImplementedException();
+        updateByType(columnIndex, x);
     }
 
     public void updateArray(String columnName, Array x) throws SQLException {
-        throw new NotImplementedException();
+        updateArray(getIndexByName(columnName), x);
     }
 
     public void updateAsciiStream(int columnIndex, InputStream x, int length)
@@ -1158,12 +1211,16 @@
 
     public void updateAsciiStream(String columnName, InputStream x, int length)
             throws SQLException {
-        throw new NotImplementedException();
+        updateAsciiStream(getIndexByName(columnName), x, length);
     }
 
     public void updateBigDecimal(int columnIndex, BigDecimal x)
             throws SQLException {
-        currentRow.updateObject(columnIndex, x);
+        if (x == null) {
+            throw new NullPointerException();
+        }
+
+        updateByType(columnIndex, x);
     }
 
     public void updateBigDecimal(String columnName, BigDecimal x)
@@ -1178,39 +1235,39 @@
 
     public void updateBinaryStream(String columnName, InputStream x, int length)
             throws SQLException {
-        throw new NotImplementedException();
+        updateBinaryStream(getIndexByName(columnName), x, length);
     }
 
     public void updateBlob(int columnIndex, Blob x) throws SQLException {
-        throw new NotImplementedException();
+        updateByType(columnIndex, x);
     }
 
     public void updateBlob(String columnName, Blob x) throws SQLException {
-        throw new NotImplementedException();
+        updateBlob(getIndexByName(columnName), x);
     }
 
     public void updateBoolean(int columnIndex, boolean x) throws SQLException {
-        throw new NotImplementedException();
+        updateByType(columnIndex, Boolean.valueOf(x));
     }
 
     public void updateBoolean(String columnName, boolean x) throws SQLException {
-        throw new NotImplementedException();
+        updateBoolean(getIndexByName(columnName), x);
     }
 
     public void updateByte(int columnIndex, byte x) throws SQLException {
-        throw new NotImplementedException();
+        updateByType(columnIndex, Byte.valueOf(x));
     }
 
     public void updateByte(String columnName, byte x) throws SQLException {
-        throw new NotImplementedException();
+        updateByte(getIndexByName(columnName), x);
     }
 
     public void updateBytes(int columnIndex, byte[] x) throws SQLException {
-        throw new NotImplementedException();
+        updateByType(columnIndex, x);
     }
 
     public void updateBytes(String columnName, byte[] x) throws SQLException {
-        throw new NotImplementedException();
+        updateBytes(getIndexByName(columnName), x);
     }
 
     public void updateCharacterStream(int columnIndex, Reader x, int length)
@@ -1220,19 +1277,19 @@
 
     public void updateCharacterStream(String columnName, Reader reader,
             int length) throws SQLException {
-        throw new NotImplementedException();
+        updateCharacterStream(getIndexByName(columnName), reader, length);
     }
 
     public void updateClob(int columnIndex, Clob x) throws SQLException {
-        throw new NotImplementedException();
+        updateByType(columnIndex, x);
     }
 
     public void updateClob(String columnName, Clob x) throws SQLException {
-        throw new NotImplementedException();
+        updateClob(getIndexByName(columnName), x);
     }
 
     public void updateDate(int columnIndex, Date x) throws SQLException {
-        currentRow.updateObject(columnIndex, x);
+        updateByType(columnIndex, x);
     }
 
     public void updateDate(String columnName, Date x) throws SQLException {
@@ -1240,7 +1297,7 @@
     }
 
     public void updateDouble(int columnIndex, double x) throws SQLException {
-        currentRow.updateObject(columnIndex, x);
+        updateByType(columnIndex, Double.valueOf(x));
     }
 
     public void updateDouble(String columnName, double x) throws SQLException {
@@ -1248,7 +1305,7 @@
     }
 
     public void updateFloat(int columnIndex, float x) throws SQLException {
-        currentRow.updateObject(columnIndex, x);
+        updateByType(columnIndex, Float.valueOf(x));
     }
 
     public void updateFloat(String columnName, float x) throws SQLException {
@@ -1256,7 +1313,7 @@
     }
 
     public void updateInt(int columnIndex, int x) throws SQLException {
-        currentRow.updateObject(columnIndex, x);
+        updateByType(columnIndex, Integer.valueOf(x));
     }
 
     public void updateInt(String columnName, int x) throws SQLException {
@@ -1264,7 +1321,7 @@
     }
 
     public void updateLong(int columnIndex, long x) throws SQLException {
-        currentRow.updateObject(columnIndex, x);
+        updateByType(columnIndex, Long.valueOf(x));
     }
 
     public void updateLong(String columnName, long x) throws SQLException {
@@ -1272,37 +1329,65 @@
     }
 
     public void updateNull(int columnIndex) throws SQLException {
-        throw new NotImplementedException();
+        checkCursorValid();
+        checkColumnValid(columnIndex);
+        currentRow.updateObject(columnIndex, null);
     }
 
     public void updateNull(String columnName) throws SQLException {
-        throw new NotImplementedException();
+        updateNull(getIndexByName(columnName));
     }
 
+    /**
+     * note check type compatibility
+     */
     public void updateObject(int columnIndex, Object x) throws SQLException {
-        throw new NotImplementedException();
+        checkValidRow();
+        checkColumnValid(columnIndex);
+        currentRow.updateObject(columnIndex, x);
     }
 
     public void updateObject(int columnIndex, Object x, int scale)
             throws SQLException {
-        throw new NotImplementedException();
+        checkValidRow();
+        checkColumnValid(columnIndex);
+        Class type = columnTypes[columnIndex - 1];
+        // ava.sql.Types.DECIMA or java.sql.Types.NUMERIC types
+        if (type.equals(BigDecimal.class)) {
+            /*
+             * TODO ri doesn't check type of x and only support BigDecimal,
+             * should we follow ri here? If not, uncomment below fragment of
+             * code
+             */
+            // if (x instanceof BigDecimal) {
+            x = ((BigDecimal) x).setScale(scale);
+            // } else if (x instanceof Double) {
+            // x = new BigDecimal(((Double) x).doubleValue());
+            // x = ((BigDecimal) x).setScale(scale);
+            // } else if (x instanceof Float) {
+            // x = new BigDecimal(((Float) x).doubleValue());
+            // x = ((BigDecimal) x).setScale(scale);
+            // }
+        }
+
+        currentRow.updateObject(columnIndex, x);
     }
 
     public void updateObject(String columnName, Object x) throws SQLException {
-        throw new NotImplementedException();
+        updateObject(getIndexByName(columnName), x);
     }
 
     public void updateObject(String columnName, Object x, int scale)
             throws SQLException {
-        throw new NotImplementedException();
+        updateObject(getIndexByName(columnName), x, scale);
     }
 
     public void updateRef(int columnIndex, Ref x) throws SQLException {
-        throw new NotImplementedException();
+        updateByType(columnIndex, x);
     }
 
     public void updateRef(String columnName, Ref x) throws SQLException {
-        throw new NotImplementedException();
+        updateRef(getIndexByName(columnName), x);
     }
 
     public void updateRow() throws SQLException {
@@ -1316,15 +1401,199 @@
     }
 
     public void updateShort(int columnIndex, short x) throws SQLException {
-        throw new NotImplementedException();
+        updateByType(columnIndex, Short.valueOf(x));
     }
 
     public void updateShort(String columnName, short x) throws SQLException {
-        throw new NotImplementedException();
+        updateShort(getIndexByName(columnName), x);
     }
 
     public void updateString(int columnIndex, String x) throws SQLException {
-        currentRow.updateObject(columnIndex, x);
+        updateByType(columnIndex, x);
+    }
+
+    /**
+     * Check type compatibility and update value
+     * 
+     * @param columnIndex
+     * @param value
+     * @throws SQLException
+     */
+    private void updateByType(int columnIndex, Object value)
+            throws SQLException {
+        checkValidRow();
+        checkColumnValid(columnIndex);
+        currentRow.updateObject(columnIndex, convertUpdateValue(columnIndex,
+                value));
+    }
+
+    /**
+     * Convert <code>value</code> to the JDBC type of the
+     * <code>columnIndex</code>. The columnIndex is not checked in this
+     * method, so caller must be sure the <code>columnIndex</code> is valid,
+     * or invoke <code>checkColumnValid</code> before invoke this method.
+     * 
+     * TODO any better ways to do this?
+     * 
+     * @param columnIndex
+     *            index of column to be updated
+     * @param value
+     *            the new value to be updated
+     */
+    private Object convertUpdateValue(int columnIndex, Object value)
+            throws SQLException {
+        
+        if (value == null) {
+            return value;
+        }
+        
+        Class type = columnTypes[columnIndex - 1];
+
+        /*
+         * TODO if type == null, the type mapping is not supported by Harmony
+         * now, leave this type check to JDBC driver
+         */
+
+        if (type == null || type.isInstance(value)) {
+            return value;
+        }
+
+        if (type.equals(Integer.class)) {
+            if (value instanceof Integer || value instanceof Short
+                    || value instanceof Byte) {
+                return value;
+            }
+
+            if (value instanceof Long) {
+                long l = ((Long) value).longValue();
+                if (l >= Integer.MIN_VALUE && l <= Integer.MAX_VALUE) {
+                    return (int) l;
+                }
+            }
+
+            if (value instanceof BigDecimal) {
+                BigDecimal bigDecimal = (BigDecimal) value;
+                try {
+                    return bigDecimal.intValueExact();
+
+                } catch (ArithmeticException e) {
+                    // TODO load from resource file
+                    throw new SQLException("Data Type Mismatch"); //$NON-NLS-1$
+                }
+            }
+
+            if (value instanceof String) {
+                return value;
+            }
+        }
+
+        if (type.equals(Short.class)) {
+            if (value instanceof Short || value instanceof Byte) {
+                return value;
+            }
+            if (value instanceof Long) {
+                long l = ((Long) value).longValue();
+                if (l >= Short.MIN_VALUE && l <= Short.MAX_VALUE) {
+                    return (short) l;
+                }
+            }
+            if (value instanceof Integer) {
+                int i = ((Integer) value).intValue();
+                if (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE) {
+                    return (short) i;
+                }
+            }
+            if (value instanceof BigDecimal) {
+                BigDecimal bigDecimal = (BigDecimal) value;
+                try {
+                    return bigDecimal.intValueExact();
+
+                } catch (ArithmeticException e) {
+                    // TODO load from resource file
+                    throw new SQLException("Data Type Mismatch"); //$NON-NLS-1$
+                }
+            }
+            if (value instanceof String) {
+                return value;
+            }
+        }
+
+        if (type.equals(Byte.class)) {
+            if (value instanceof Byte) {
+                return value;
+            }
+            if (value instanceof Long) {
+                long l = ((Long) value).longValue();
+                if (l >= Byte.MIN_VALUE && l <= Byte.MAX_VALUE) {
+                    return (byte) l;
+                }
+            }
+            if (value instanceof Integer) {
+                int i = ((Integer) value).intValue();
+                if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) {
+                    return (byte) i;
+                }
+            }
+            if (value instanceof Short) {
+                int i = ((Short) value).shortValue();
+                if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) {
+                    return (byte) i;
+                }
+            }
+            if (value instanceof BigDecimal) {
+                BigDecimal bigDecimal = (BigDecimal) value;
+                try {
+                    return bigDecimal.byteValueExact();
+
+                } catch (ArithmeticException e) {
+                    // TODO load from resource file
+                    throw new SQLException("Data Type Mismatch"); //$NON-NLS-1$
+                }
+            }
+            if (value instanceof String) {
+                return value;
+            }
+        }
+
+        if (type.equals(Long.class)) {
+            if (value instanceof Integer || value instanceof Short
+                    || value instanceof Byte || value instanceof Long) {
+                return value;
+            }
+            if (value instanceof BigDecimal) {
+                BigDecimal bigDecimal = (BigDecimal) value;
+                try {
+                    return bigDecimal.longValueExact();
+
+                } catch (ArithmeticException e) {
+                    // rowset.10=Data Type Mismatch
+                    throw new SQLException(Messages.getString("rowset.10")); //$NON-NLS-1$
+                }
+            }
+            if (value instanceof String) {
+                return value;
+            }
+        }
+
+        if (type.equals(Float.class) || type.equals(Double.class)) {
+            if (value instanceof Float || value instanceof Double
+                    || value instanceof BigDecimal) {
+                return value;
+            }
+            if (value instanceof Number) {
+                return ((Number) value).longValue();
+            }
+            if (value instanceof String) {
+                return value;
+            }
+        }
+
+        if (type.equals(BigDecimal.class)) {
+            return value;
+        }
+
+        // rowset.10=Data Type Mismatch
+        throw new SQLException(Messages.getString("rowset.10")); //$NON-NLS-1$
     }
 
     public void updateString(String columnName, String x) throws SQLException {
@@ -1332,7 +1601,7 @@
     }
 
     public void updateTime(int columnIndex, Time x) throws SQLException {
-        currentRow.updateObject(columnIndex, x);
+        updateByType(columnIndex, x);
     }
 
     public void updateTime(String columnName, Time x) throws SQLException {
@@ -1341,7 +1610,7 @@
 
     public void updateTimestamp(int columnIndex, Timestamp x)
             throws SQLException {
-        currentRow.updateObject(columnIndex, x);
+        updateByType(columnIndex, x);
     }
 
     public void updateTimestamp(String columnName, Timestamp x)

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java Tue Mar  4 00:02:13 2008
@@ -443,12 +443,13 @@
         assertEquals(crset.getFetchDirection(), copy.getFetchDirection());
         assertEquals(crset.getPageSize(), copy.getPageSize());
 
+        assertEquals(crset.isBeforeFirst(), copy.isBeforeFirst());
+        assertEquals(crset.isAfterLast(), copy.isAfterLast());
+        assertEquals(crset.isFirst(), copy.isFirst());
+        assertEquals(crset.isLast(), copy.isLast());
+        assertEquals(crset.getRow(), copy.getRow());
+
         // TODO uncomment them after implemented
-        // assertEquals(crset.isBeforeFirst(), crsetCopy.isBeforeFirst());
-        // assertEquals(crset.isAfterLast(), crsetCopy.isAfterLast());
-        // assertEquals(crset.isFirst(), crsetCopy.isFirst());
-        // assertEquals(crset.isLast(), crsetCopy.isLast());
-        // assertEquals(crset.getRow(), copy.getRow());
         // assertNotSame(crset.getWarnings(), copy.getWarnings());
         // assertEquals(crset.getStatement(), copy.getStatement());
         // try {
@@ -720,8 +721,8 @@
         rs.next();
         rs.next();
         rs.next();
-        // TODO: Uncomment it when Writer is implemented fully.
-        // assertEquals("copyTest3", rs.getString(2));
+
+        assertEquals("copyTest3", rs.getString(2));
 
         reloadCachedRowSet();
         crset.absolute(2);
@@ -729,14 +730,10 @@
         crsetCopy = crset.createCopy();
 
         assertEquals(crset.isReadOnly(), crsetCopy.isReadOnly());
-        // TODO uncomment when isBeforeFirst is implemented
-        // assertEquals(crset.isBeforeFirst(), crsetCopy.isBeforeFirst());
-        // TODO uncomment when isAfterLast is implemented
-        // assertEquals(crset.isAfterLast(), crsetCopy.isAfterLast());
-        // TODO uncomment when isFirst is implemented
-        // assertEquals(crset.isFirst(), crsetCopy.isFirst());
-        // TODO uncomment when isLast is implemented
-        // assertEquals(crset.isLast(), crsetCopy.isLast());
+        assertEquals(crset.isBeforeFirst(), crsetCopy.isBeforeFirst());
+        assertEquals(crset.isAfterLast(), crsetCopy.isAfterLast());
+        assertEquals(crset.isFirst(), crsetCopy.isFirst());
+        assertEquals(crset.isLast(), crsetCopy.isLast());
 
         assertEquals(crset.size(), crsetCopy.size());
         // different metaData object
@@ -848,10 +845,9 @@
              * it, and all resource would be released after connection closed.
              */
             crset.acceptChanges(conn);
-            // TODO: wait the implementation of Writer
-            // fail("Should throw SyncProviderException");
+            fail("Should throw SyncProviderException");
         } catch (SyncProviderException e) {
-            // expected
+            // expected, TODO test SyncProviderException
         }
 
         assertEquals("updated", copy.getString(2));
@@ -1150,6 +1146,8 @@
         assertNull(noInitialCrset.getCommand());
         assertEquals(ResultSet.CONCUR_UPDATABLE, noInitialCrset
                 .getConcurrency());
+        assertEquals(0, crset.getRow());
+        
         // TODO uncomment after impelemented
         // try {
         // crset.getCursorName();
@@ -1169,7 +1167,6 @@
         // } catch (SQLException e) {
         // // expected
         // }
-        // assertEquals(0, crset.getRow());
         // assertNull(crset.getStatement());
 
         assertEquals(true, noInitialCrset.getEscapeProcessing());

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=633384&r1=633383&r2=633384&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 Tue Mar  4 00:02:13 2008
@@ -339,6 +339,11 @@
             }
         }
 
+        // Regression test for HARMONY-5506
+        String date = "1970-01-01 22:17:59.0                 ";
+        Timestamp t = Timestamp.valueOf(date);
+        assertEquals(80279000,t.getTime());
+
     } // end method testValueOfString
 
     /*

Modified: harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/Bidi.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/Bidi.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/Bidi.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/Bidi.java Tue Mar  4 00:02:13 2008
@@ -33,7 +33,6 @@
  * obtained from the run index. The level of any particular run indicates the
  * direction of the text as well as the nesting level. Left-to-right runs have
  * even levels while right-to-left runs have odd levels.
- * 
  */
 public final class Bidi {
     /**
@@ -86,9 +85,9 @@
      * 
      * @param paragraph
      * 
-     * @see TextAttribute.BIDI_EMBEDDING
-     * @see TextAttribute.NUMERIC_SHAPING
-     * @see TextAttribute.RUN_DIRECTION
+     * @see java.awt.font.TextAttribute#BIDI_EMBEDDING
+     * @see java.awt.font.TextAttribute#NUMERIC_SHAPING
+     * @see java.awt.font.TextAttribute#RUN_DIRECTION
      */
     public Bidi(AttributedCharacterIterator paragraph) {
         if (paragraph == null) {

Modified: harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/CollationElementIterator.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/CollationElementIterator.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/CollationElementIterator.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/CollationElementIterator.java Tue Mar  4 00:02:13 2008
@@ -55,13 +55,13 @@
  * 
  * <p>
  * <code>
- * Since the character '\u0086' is a composed character of 'a' and 'e', the iterator
- * returns two collation elements for the single character '\u0086'
+ * Since the character '&#92;u0086' is a composed character of 'a' and 'e', the iterator
+ * returns two collation elements for the single character '&#92;u0086'
  * </code>
  * </p>
  * <p>
  * <code>
- * "\u0086b" -> the first
+ * "&#92;u0086b" -> the first
  * collation element is collation_element('a'), the second collation element is
  * collation_element('e'), and the third collation element is
  * collation_element('b').

Modified: harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/MessageFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/MessageFormat.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/MessageFormat.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/MessageFormat.java Tue Mar  4 00:02:13 2008
@@ -39,8 +39,6 @@
 
     private static final long serialVersionUID = 6479157306784022952L;
 
-    private static com.ibm.icu.text.MessageFormat format;
-
     private Locale locale = Locale.getDefault();
 
     transient private String[] strings;
@@ -453,12 +451,7 @@
                 }
             }
         }
-        if (format == null) {
-            format = new com.ibm.icu.text.MessageFormat(template);
-        } else if (!template.equals(format.toPattern())){
-            format.applyPattern(template);
-        }
-        return format.format(objects);
+        return com.ibm.icu.text.MessageFormat.format(template, objects);
     }
 
     /**



Mime
View raw message