Merge "Improve change-markers and diffs in some of j.u.concurrent."
diff --git a/ojluni/src/main/java/java/io/ObjectStreamField.java b/ojluni/src/main/java/java/io/ObjectStreamField.java
index 957972e..ff485d8 100644
--- a/ojluni/src/main/java/java/io/ObjectStreamField.java
+++ b/ojluni/src/main/java/java/io/ObjectStreamField.java
@@ -162,14 +162,16 @@
      */
     @CallerSensitive
     public Class<?> getType() {
-        /* BEGIN Android-removed: Security manager is always null on Android.
+        // BEGIN Android-removed: Security manager is always null on Android.
+        /*
         if (System.getSecurityManager() != null) {
              Class<?> caller = Reflection.getCallerClass();
             if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), type.getClassLoader())) {
                 ReflectUtil.checkPackageAccess(type);
             }
         }
-        END Android-removed: Security manager is always null on Android. */
+        */
+        // END Android-removed: Security manager is always null on Android.
         return type;
     }
 
diff --git a/ojluni/src/main/java/java/security/cert/X509CRL.java b/ojluni/src/main/java/java/security/cert/X509CRL.java
index a233b44..927852b 100644
--- a/ojluni/src/main/java/java/security/cert/X509CRL.java
+++ b/ojluni/src/main/java/java/security/cert/X509CRL.java
@@ -241,16 +241,17 @@
     public void verify(PublicKey key, Provider sigProvider)
         throws CRLException, NoSuchAlgorithmException,
         InvalidKeyException, SignatureException {
-        // BEGIN Android-changed
-        // TODO(31294527): was X509CRLImpl.verify(this, key, sigProvider);
+        // Android-changed: Eliminate infinite recursion in default implementation.
         // As the javadoc says, this "default implementation" was introduced as to avoid breaking
         // providers that generate concrete subclasses of this class.
         // The method X509Impl in the original definition calls this method, thus entering an
-        // infinite loop. This strange behaviour was checked to be not specific to libcore by
-        // running a test with vogar --mode=jvm .
+        // infinite recursive loop. This strange behaviour was checked to be not specific to
+        // libcore by running a test with vogar --mode=jvm .  See b/31294527.
+        // This is fixed upstream in OpenJDK 10.
+        //
+        // X509CRLImpl.verify(this, key, sigProvider);
         throw new UnsupportedOperationException(
                 "X509CRL instance doesn't not support X509CRL#verify(PublicKey, Provider)");
-        // END Android-changed
     }
 
     /**
diff --git a/ojluni/src/main/java/java/security/cert/X509Certificate.java b/ojluni/src/main/java/java/security/cert/X509Certificate.java
index 042eefd..f7cb9ef 100644
--- a/ojluni/src/main/java/java/security/cert/X509Certificate.java
+++ b/ojluni/src/main/java/java/security/cert/X509Certificate.java
@@ -673,11 +673,11 @@
     public void verify(PublicKey key, Provider sigProvider)
         throws CertificateException, NoSuchAlgorithmException,
         InvalidKeyException, SignatureException {
-        // Android-changed: Use Certificate default implementation that
-        // throws UnsupportedOperationException.
+        // Android-changed: Eliminate infinite recursion in default implementation.
         // The method X509CertImpl calls this method, thus entering an
-        // infinite loop. This strange behaviour was checked to be not
-        // specific to libcore by running a test with vogar --mode=jvm
+        // infinite recursive loop. This strange behaviour was checked to be not
+        // specific to libcore by running a test with vogar --mode=jvm.
+        // This is fixed upstream in OpenJDK 10.
         //
         // X509CertImpl.verify(this, key, sigProvider);
         super.verify(key, sigProvider);
diff --git a/ojluni/src/main/java/java/sql/CallableStatement.java b/ojluni/src/main/java/java/sql/CallableStatement.java
index b4769e3..d58c88b 100644
--- a/ojluni/src/main/java/java/sql/CallableStatement.java
+++ b/ojluni/src/main/java/java/sql/CallableStatement.java
@@ -296,6 +296,7 @@
      *             or <code>getBigDecimal(String parameterName)</code>
      * @see #setBigDecimal
      */
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
     @Deprecated
     BigDecimal getBigDecimal(int parameterIndex, int scale)
         throws SQLException;
@@ -2438,4 +2439,6 @@
      */
      void setNClob(String parameterName, Reader reader)
        throws SQLException;
+
+    // Android-removed: JDBC 4.1 methods were removed immediately after the initial import.
 }
diff --git a/ojluni/src/main/java/java/sql/Connection.java b/ojluni/src/main/java/java/sql/Connection.java
index 3acfd12..b742388 100644
--- a/ojluni/src/main/java/java/sql/Connection.java
+++ b/ojluni/src/main/java/java/sql/Connection.java
@@ -1303,4 +1303,5 @@
  Struct createStruct(String typeName, Object[] attributes)
 throws SQLException;
 
+    // Android-removed: JDBC 4.1 methods were removed immediately after the initial import.
 }
diff --git a/ojluni/src/main/java/java/sql/DatabaseMetaData.java b/ojluni/src/main/java/java/sql/DatabaseMetaData.java
index 98101ce..8e7441c 100644
--- a/ojluni/src/main/java/java/sql/DatabaseMetaData.java
+++ b/ojluni/src/main/java/java/sql/DatabaseMetaData.java
@@ -3574,4 +3574,5 @@
      */
     int functionReturnsTable    = 2;
 
+    // Android-removed: JDBC 4.1 methods were removed immediately after the initial import.
 }
diff --git a/ojluni/src/main/java/java/sql/Date.java b/ojluni/src/main/java/java/sql/Date.java
index a64a42f..b96828a 100644
--- a/ojluni/src/main/java/java/sql/Date.java
+++ b/ojluni/src/main/java/java/sql/Date.java
@@ -52,7 +52,8 @@
      * @param day 1 to 31
      * @deprecated instead use the constructor <code>Date(long date)</code>
      */
-    @Deprecated // Android-added
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
+    @Deprecated
     public Date(int year, int month, int day) {
         super(year, month, day);
     }
@@ -172,6 +173,7 @@
 
     // Override all the time operations inherited from java.util.Date;
 
+   // Android-changed: Moved @deprecated to include a deprecation reason in the documentation.
    /**
     * @deprecated This method is deprecated and should not be used because SQL Date
     * values do not have a time component.
@@ -179,11 +181,13 @@
     * @exception java.lang.IllegalArgumentException if this method is invoked
     * @see #setHours
     */
-    @Deprecated // Android-added: changed javadoc to include deprecation note.
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
+    @Deprecated
     public int getHours() {
         throw new java.lang.IllegalArgumentException();
     }
 
+   // Android-changed: Moved @deprecated to include a deprecation reason in the documentation.
    /**
     * @deprecated This method is deprecated and should not be used because SQL Date
     * values do not have a time component.
@@ -191,11 +195,13 @@
     * @exception java.lang.IllegalArgumentException if this method is invoked
     * @see #setMinutes
     */
-    @Deprecated // Android-added: changed javadoc to include deprecation note.
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
+    @Deprecated
     public int getMinutes() {
         throw new java.lang.IllegalArgumentException();
     }
 
+   // Android-changed: Moved @deprecated to include a deprecation reason in the documentation.
    /**
     * @deprecated This method is deprecated and should not be used because SQL Date
     * values do not have a time component.
@@ -203,11 +209,13 @@
     * @exception java.lang.IllegalArgumentException if this method is invoked
     * @see #setSeconds
     */
-    @Deprecated // Android-added: changed javadoc to include deprecation note.
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
+    @Deprecated
     public int getSeconds() {
         throw new java.lang.IllegalArgumentException();
     }
 
+   // Android-changed: Moved @deprecated to include a deprecation reason in the documentation.
    /**
     * @deprecated This method is deprecated and should not be used because SQL Date
     * values do not have a time component.
@@ -215,11 +223,13 @@
     * @exception java.lang.IllegalArgumentException if this method is invoked
     * @see #getHours
     */
-    @Deprecated // Android-added: changed javadoc to include deprecation note.
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
+    @Deprecated
     public void setHours(int i) {
         throw new java.lang.IllegalArgumentException();
     }
 
+   // Android-changed: Moved @deprecated to include a deprecation reason in the documentation.
    /**
     * @deprecated This method is deprecated and should not be used because SQL Date
     * values do not have a time component.
@@ -227,11 +237,13 @@
     * @exception java.lang.IllegalArgumentException if this method is invoked
     * @see #getMinutes
     */
-    @Deprecated // Android-added: changed javadoc to include deprecation note.
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
+    @Deprecated
     public void setMinutes(int i) {
         throw new java.lang.IllegalArgumentException();
     }
 
+   // Android-changed: Moved @deprecated to include a deprecation reason in the documentation.
    /**
     * @deprecated This method is deprecated and should not be used because SQL Date
     * values do not have a time component.
@@ -239,7 +251,8 @@
     * @exception java.lang.IllegalArgumentException if this method is invoked
     * @see #getSeconds
     */
-    @Deprecated // Android-added: changed javadoc to include deprecation note.
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
+    @Deprecated
     public void setSeconds(int i) {
         throw new java.lang.IllegalArgumentException();
     }
diff --git a/ojluni/src/main/java/java/sql/Driver.java b/ojluni/src/main/java/java/sql/Driver.java
index a9bdc7d..3970b1c 100644
--- a/ojluni/src/main/java/java/sql/Driver.java
+++ b/ojluni/src/main/java/java/sql/Driver.java
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2014 The Android Open Source Project
  * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -153,4 +154,5 @@
      */
     boolean jdbcCompliant();
 
+    // Android-removed: JDBC 4.1 methods were removed immediately after the initial import.
 }
diff --git a/ojluni/src/main/java/java/sql/DriverManager.java b/ojluni/src/main/java/java/sql/DriverManager.java
index e7d9c94..b4ccb22 100644
--- a/ojluni/src/main/java/java/sql/DriverManager.java
+++ b/ojluni/src/main/java/java/sql/DriverManager.java
@@ -36,6 +36,7 @@
 
 import sun.reflect.CallerSensitive;
 
+// Android-changed line 2 of the javadoc to "{@code DataSource}".
 /**
  * <P>The basic service for managing a set of JDBC drivers.<br>
  * <B>NOTE:</B> The {@code DataSource} interface, new in the
@@ -80,7 +81,6 @@
  * @see Driver
  * @see Connection
  */
-// Android-changed line 2 of the javadoc to "{@code DataSource}"
 public class DriverManager {
 
 
@@ -188,6 +188,7 @@
     @CallerSensitive
     public static Connection getConnection(String url,
         java.util.Properties info) throws SQLException {
+        // Android-changed: Used VMStack to get the caller's ClassLoader rather than Class.
         return (getConnection(url, info, VMStack.getCallingClassLoader()));
     }
 
@@ -216,6 +217,7 @@
             info.put("password", password);
         }
 
+        // Android-changed: Used VMStack to get the caller's ClassLoader rather than Class.
         return (getConnection(url, info, VMStack.getCallingClassLoader()));
     }
 
@@ -234,6 +236,7 @@
         throws SQLException {
 
         java.util.Properties info = new java.util.Properties();
+        // Android-changed: Used VMStack to get the caller's ClassLoader rather than Class.
         return (getConnection(url, info, VMStack.getCallingClassLoader()));
     }
 
@@ -254,6 +257,7 @@
 
         println("DriverManager.getDriver(\"" + url + "\")");
 
+        // Android-changed: Used VMStack to get the caller's ClassLoader rather than Class.
         ClassLoader callerClassLoader = VMStack.getCallingClassLoader();
 
         // Walk through the loaded registeredDrivers attempting to locate someone
@@ -261,6 +265,7 @@
         for (DriverInfo aDriver : registeredDrivers) {
             // If the caller does not have permission to load the driver then
             // skip it.
+            // Android-changed: Pass caller's ClassLoader rather than Class.
             if(isDriverAllowed(aDriver.driver, callerClassLoader)) {
                 try {
                     if(aDriver.driver.acceptsURL(url)) {
@@ -326,6 +331,7 @@
 
         DriverInfo aDriver = new DriverInfo(driver);
         if(registeredDrivers.contains(aDriver)) {
+            // Android-changed: Pass caller's ClassLoader rather than Class.
             if (isDriverAllowed(driver, VMStack.getCallingClassLoader())) {
                  registeredDrivers.remove(aDriver);
             } else {
@@ -351,12 +357,14 @@
     public static java.util.Enumeration<Driver> getDrivers() {
         java.util.Vector<Driver> result = new java.util.Vector<Driver>();
 
+        // Android-changed: Used VMStack to get the caller's ClassLoader rather than Class.
         ClassLoader callerClassLoader = VMStack.getCallingClassLoader();
 
         // Walk through the loaded registeredDrivers.
         for(DriverInfo aDriver : registeredDrivers) {
             // If the caller does not have permission to load the driver then
             // skip it.
+            // Android-changed: Pass caller's ClassLoader rather than Class.
             if(isDriverAllowed(aDriver.driver, callerClassLoader)) {
                 result.addElement(aDriver.driver);
             } else {
@@ -389,6 +397,7 @@
         return (loginTimeout);
     }
 
+    // Android-changed: Added reason to @deprecated to improve the documentation.
     /**
      * Sets the logging/tracing PrintStream that is used
      * by the <code>DriverManager</code>
@@ -408,7 +417,8 @@
      * @see SecurityManager#checkPermission
      * @see #getLogStream
      */
-    @Deprecated // Android-added, also changed deprecation comment to include a reason.
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
+    @Deprecated
     public static void setLogStream(java.io.PrintStream out) {
 
         SecurityManager sec = System.getSecurityManager();
@@ -423,6 +433,7 @@
             logWriter = null;
     }
 
+    // Android-changed: Added reason to @deprecated to improve the documentation.
     /**
      * Retrieves the logging/tracing PrintStream that is used by the <code>DriverManager</code>
      * and all drivers.
@@ -431,7 +442,8 @@
      * @deprecated Use {@code getLogWriter} instead.
      * @see #setLogStream
      */
-    @Deprecated // Android-added, also changed deprecation comment to include a reason.
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
+    @Deprecated
     public static java.io.PrintStream getLogStream() {
         return logStream;
     }
@@ -454,6 +466,17 @@
 
     //------------------------------------------------------------------------
 
+    // BEGIN Android-removed: Unused method
+/*
+    // Indicates whether the class object that would be created if the code calling
+    // DriverManager is accessible.
+    private static boolean isDriverAllowed(Driver driver, Class<?> caller) {
+        ClassLoader callerCL = caller != null ? caller.getClassLoader() : null;
+        return isDriverAllowed(driver, callerCL);
+    }
+*/
+    // END Android-removed: Unused method
+
     private static boolean isDriverAllowed(Driver driver, ClassLoader classLoader) {
         boolean result = false;
         if(driver != null) {
@@ -535,6 +558,7 @@
 
 
     //  Worker method called by the public getConnection() methods.
+    // Android-changed: Use ClassLoader instead of Class.
     private static Connection getConnection(
         String url, java.util.Properties info, ClassLoader callerCL) throws SQLException {
         /*
@@ -543,6 +567,8 @@
          * classloader, so that the JDBC driver class outside rt.jar
          * can be loaded from here.
          */
+        // Android-removed: ClassLoader already provided by the caller.
+        // ClassLoader callerCL = caller != null ? caller.getClassLoader() : null;
         synchronized (DriverManager.class) {
             // synchronize loading of the correct classloader.
             if (callerCL == null) {
diff --git a/ojluni/src/main/java/java/sql/PreparedStatement.java b/ojluni/src/main/java/java/sql/PreparedStatement.java
index 0763390..ef57f69 100644
--- a/ojluni/src/main/java/java/sql/PreparedStatement.java
+++ b/ojluni/src/main/java/java/sql/PreparedStatement.java
@@ -317,6 +317,7 @@
     void setAsciiStream(int parameterIndex, java.io.InputStream x, int length)
             throws SQLException;
 
+    // Android-changed: Added reason to @deprecated to improve the documentation.
     /**
      * Sets the designated parameter to the given input stream, which
      * will have the specified number of bytes.
@@ -343,8 +344,9 @@
      * this method is called on a closed <code>PreparedStatement</code>
      * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
      * this method
-     * @deprecated Deprecated.
+     * @deprecated Use setCharacterStream
      */
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
     @Deprecated
     void setUnicodeStream(int parameterIndex, java.io.InputStream x,
                           int length) throws SQLException;
diff --git a/ojluni/src/main/java/java/sql/ResultSet.java b/ojluni/src/main/java/java/sql/ResultSet.java
index 0b1f6a0..f9ca407 100644
--- a/ojluni/src/main/java/java/sql/ResultSet.java
+++ b/ojluni/src/main/java/java/sql/ResultSet.java
@@ -343,6 +343,7 @@
      */
     double getDouble(int columnIndex) throws SQLException;
 
+    // Android-changed: Added reason to @deprecated to improve the documentation.
     /**
      * Retrieves the value of the designated column in the current row
      * of this <code>ResultSet</code> object as
@@ -360,6 +361,7 @@
      * @deprecated Use {@code getBigDecimal(int columnIndex)}
      *             or {@code getBigDecimal(String columnLabel)}
      */
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
     @Deprecated
     BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException;
 
@@ -480,6 +482,7 @@
      * @deprecated use <code>getCharacterStream</code> in place of
      *              <code>getUnicodeStream</code>
      */
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
     @Deprecated
     java.io.InputStream getUnicodeStream(int columnIndex) throws SQLException;
 
@@ -631,6 +634,7 @@
      */
     double getDouble(String columnLabel) throws SQLException;
 
+    // Android-changed: Added reason to @deprecated to improve the documentation.
     /**
      * Retrieves the value of the designated column in the current row
      * of this <code>ResultSet</code> object as
@@ -648,6 +652,7 @@
      * @deprecated Use {@code getBigDecimal(int columnIndex)}
      *             or {@code getBigDecimal(String columnLabel)}
      */
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
     @Deprecated
     BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException;
 
@@ -766,6 +771,7 @@
      * this method
      * @deprecated use <code>getCharacterStream</code> instead
      */
+    // Android-added: @Deprecated annotation from OpenJDK8u121-b13 to fix build warnings.
     @Deprecated
     java.io.InputStream getUnicodeStream(String columnLabel) throws SQLException;
 
@@ -4083,4 +4089,5 @@
      */
     void updateNClob(String columnLabel,  Reader reader) throws SQLException;
 
+    // Android-removed: JDBC 4.1 methods were removed immediately after the initial import.
 }
diff --git a/ojluni/src/main/java/java/sql/SQLPermission.java b/ojluni/src/main/java/java/sql/SQLPermission.java
index 505202c..d90cf64 100644
--- a/ojluni/src/main/java/java/sql/SQLPermission.java
+++ b/ojluni/src/main/java/java/sql/SQLPermission.java
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2014 The Android Open Source Project
  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -23,6 +24,7 @@
  * questions.
  */
 
+
 package java.sql;
 
 import java.security.*;
diff --git a/ojluni/src/main/java/java/sql/Statement.java b/ojluni/src/main/java/java/sql/Statement.java
index 40cd97c..5915114 100644
--- a/ojluni/src/main/java/java/sql/Statement.java
+++ b/ojluni/src/main/java/java/sql/Statement.java
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2014 The Android Open Source Project
  * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -1030,4 +1031,5 @@
         boolean isPoolable()
                 throws SQLException;
 
+    // Android-removed: JDBC 4.1 methods were removed immediately after the initial import.
 }
diff --git a/ojluni/src/main/java/java/sql/Time.java b/ojluni/src/main/java/java/sql/Time.java
index 4960ce5..1300003 100644
--- a/ojluni/src/main/java/java/sql/Time.java
+++ b/ojluni/src/main/java/java/sql/Time.java
@@ -144,6 +144,7 @@
 
     // Override all the date operations inherited from java.util.Date;
 
+   // Android-changed: Moved @deprecated to include a deprecation reason in the documentation.
    /**
     * @deprecated This method is deprecated and should not be used because SQL <code>TIME</code>
     * values do not have a year component.
@@ -152,12 +153,12 @@
     *           method is invoked
     * @see #setYear
     */
-    // Android-changed javadoc, @deprecated tag now has a reason.
     @Deprecated
     public int getYear() {
         throw new java.lang.IllegalArgumentException();
     }
 
+   // Android-changed: Moved @deprecated to include a deprecation reason in the documentation.
    /**
     * @deprecated This method is deprecated and should not be used because SQL <code>TIME</code>
     * values do not have a month component.
@@ -166,12 +167,12 @@
     *           method is invoked
     * @see #setMonth
     */
-    // Android-changed javadoc, @deprecated tag now has a reason.
     @Deprecated
     public int getMonth() {
         throw new java.lang.IllegalArgumentException();
     }
 
+   // Android-changed: Moved @deprecated to include a deprecation reason in the documentation.
    /**
     * @deprecated This method is deprecated and should not be used because SQL <code>TIME</code>
     * values do not have a day component.
@@ -179,12 +180,12 @@
     * @exception java.lang.IllegalArgumentException if this
     *           method is invoked
     */
-    // Android-changed javadoc, @deprecated tag now has a reason.
     @Deprecated
     public int getDay() {
         throw new java.lang.IllegalArgumentException();
     }
 
+   // Android-changed: Moved @deprecated to include a deprecation reason in the documentation.
    /**
     * @deprecated This method is deprecated and should not be used because SQL <code>TIME</code>
     * values do not have a date component.
@@ -193,12 +194,12 @@
     *           method is invoked
     * @see #setDate
     */
-    // Android-changed javadoc, @deprecated tag now has a reason.
     @Deprecated
     public int getDate() {
         throw new java.lang.IllegalArgumentException();
     }
 
+   // Android-changed: Moved @deprecated to include a deprecation reason in the documentation.
    /**
     * @deprecated This method is deprecated and should not be used because SQL <code>TIME</code>
     * values do not have a year component.
@@ -207,12 +208,12 @@
     *           method is invoked
     * @see #getYear
     */
-    // Android-changed javadoc, @deprecated tag now has a reason.
     @Deprecated
     public void setYear(int i) {
         throw new java.lang.IllegalArgumentException();
     }
 
+   // Android-changed: Moved @deprecated to include a deprecation reason in the documentation.
    /**
     * @deprecated This method is deprecated and should not be used because SQL <code>TIME</code>
     * values do not have a month component.
@@ -221,12 +222,12 @@
     *           method is invoked
     * @see #getMonth
     */
-    // Android-changed javadoc, @deprecated tag now has a reason.
     @Deprecated
     public void setMonth(int i) {
         throw new java.lang.IllegalArgumentException();
     }
 
+   // Android-changed: Moved @deprecated to include a deprecation reason in the documentation.
    /**
     * @deprecated This method is deprecated and should not be used because SQL <code>TIME</code>
     * values do not have a date component.
diff --git a/ojluni/src/main/java/java/util/concurrent/Executors.java b/ojluni/src/main/java/java/util/concurrent/Executors.java
index 9244136..565fdeb 100644
--- a/ojluni/src/main/java/java/util/concurrent/Executors.java
+++ b/ojluni/src/main/java/java/util/concurrent/Executors.java
@@ -341,6 +341,7 @@
         return new DelegatedScheduledExecutorService(executor);
     }
 
+    // Android-changed: Removed references to SecurityManager from javadoc.
     /**
      * Returns a default thread factory used to create new threads.
      * This factory creates all new threads used by an Executor in the
@@ -358,6 +359,7 @@
         return new DefaultThreadFactory();
     }
 
+    // Android-changed: Dropped documentation for legacy security code.
     /**
      * Legacy security code; do not use.
      */
@@ -424,6 +426,7 @@
             public Object call() throws Exception { return action.run(); }};
     }
 
+    // Android-changed: Dropped documentation for legacy security code.
     /**
      * Legacy security code; do not use.
      */
@@ -433,6 +436,7 @@
         return new PrivilegedCallable<T>(callable);
     }
 
+    // Android-changed: Dropped documentation for legacy security code.
     /**
      * Legacy security code; do not use.
      */
@@ -497,19 +501,20 @@
         final ClassLoader ccl;
 
         PrivilegedCallableUsingCurrentClassLoader(Callable<T> task) {
-            // BEGIN Android-removed
-            // SecurityManager sm = System.getSecurityManager();
-            // if (sm != null) {
-            //     // Calls to getContextClassLoader from this class
-            //     // never trigger a security check, but we check
-            //     // whether our callers have this permission anyways.
-            //     sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
+            // Android-removed: System.getSecurityManager always returns null.
+            /*
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null) {
+                // Calls to getContextClassLoader from this class
+                // never trigger a security check, but we check
+                // whether our callers have this permission anyways.
+                sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
 
-            //     // Whether setContextClassLoader turns out to be necessary
-            //     // or not, we fail fast if permission is not available.
-            //     sm.checkPermission(new RuntimePermission("setContextClassLoader"));
-            // }
-            // END Android-removed
+                // Whether setContextClassLoader turns out to be necessary
+                // or not, we fail fast if permission is not available.
+                sm.checkPermission(new RuntimePermission("setContextClassLoader"));
+            }
+            */
             this.task = task;
             this.acc = AccessController.getContext();
             this.ccl = Thread.currentThread().getContextClassLoader();
@@ -579,18 +584,19 @@
 
         PrivilegedThreadFactory() {
             super();
-            // BEGIN Android-removed
-            // SecurityManager sm = System.getSecurityManager();
-            // if (sm != null) {
-            //     // Calls to getContextClassLoader from this class
-            //     // never trigger a security check, but we check
-            //     // whether our callers have this permission anyways.
-            //     sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
+            // Android-removed: System.getSecurityManager always returns null.
+            /*
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null) {
+                // Calls to getContextClassLoader from this class
+                // never trigger a security check, but we check
+                // whether our callers have this permission anyways.
+                sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
 
-            //     // Fail fast
-            //     sm.checkPermission(new RuntimePermission("setContextClassLoader"));
-            // }
-            // END Android-removed
+                // Fail fast
+                sm.checkPermission(new RuntimePermission("setContextClassLoader"));
+            }
+            */
             this.acc = AccessController.getContext();
             this.ccl = Thread.currentThread().getContextClassLoader();
         }
diff --git a/ojluni/src/main/java/sun/security/jca/Providers.java b/ojluni/src/main/java/sun/security/jca/Providers.java
index fe9fd55..a9634f0 100644
--- a/ojluni/src/main/java/sun/security/jca/Providers.java
+++ b/ojluni/src/main/java/sun/security/jca/Providers.java
@@ -291,7 +291,7 @@
      *
      * @hide
      */
-    public static final int DEFAULT_MAXIMUM_ALLOWABLE_TARGET_API_LEVEL_FOR_BC_DEPRECATION = 26;
+    public static final int DEFAULT_MAXIMUM_ALLOWABLE_TARGET_API_LEVEL_FOR_BC_DEPRECATION = 27;
 
     private static int maximumAllowableApiLevelForBcDeprecation =
             DEFAULT_MAXIMUM_ALLOWABLE_TARGET_API_LEVEL_FOR_BC_DEPRECATION;
diff --git a/tools/upstream/src/main/java/libcore/StandardRepositories.java b/tools/upstream/src/main/java/libcore/StandardRepositories.java
index 36478dd..82b039c 100644
--- a/tools/upstream/src/main/java/libcore/StandardRepositories.java
+++ b/tools/upstream/src/main/java/libcore/StandardRepositories.java
@@ -34,12 +34,14 @@
     private final List<Repository> historicUpstreams;
     private final Repository defaultUpstream;
     private final Repository jsr166Upstream;
+    private final Repository javaSqlUpstream;
     private final OjluniRepository ojluni;
 
     private StandardRepositories(Path buildTop, Path upstreamRoot) {
         this.historicUpstreams = openJdkLegacy(upstreamRoot, Arrays.asList("8u60", "7u40"));
         this.defaultUpstream = openJdkLegacy(upstreamRoot, "8u121-b13");
         this.jsr166Upstream = openJdk9(upstreamRoot, "9b113+");
+        this.javaSqlUpstream = openJdkLegacy(upstreamRoot, "7u40");
         this.ojluni = new OjluniRepository(buildTop);
     }
 
@@ -90,7 +92,7 @@
             )));
 
     public Repository currentUpstream(Path relPath) {
-        boolean isJsr166 = relPath.toString().startsWith("java/util/concurrent");
+        boolean isJsr166 = relPath.startsWith("java/util/concurrent/");
         String ju = "java/util/";
         String suffix = ".java";
         if (!isJsr166 && relPath.startsWith(ju)) {
@@ -100,7 +102,13 @@
                 isJsr166 = juFilesFromJsr166.contains(name);
             }
         }
-        return isJsr166 ? jsr166Upstream : defaultUpstream;
+        if (isJsr166) {
+            return jsr166Upstream;
+        } else if (relPath.startsWith("java/sql/") || relPath.startsWith("javax/sql/")) {
+            return javaSqlUpstream;
+        } else {
+            return defaultUpstream;
+        }
     }
 
 }
diff --git a/tools/upstream/upstream-diff b/tools/upstream/upstream-diff
index f52fdb5..359ffee 100755
--- a/tools/upstream/upstream-diff
+++ b/tools/upstream/upstream-diff
@@ -51,6 +51,7 @@
 
 import argparse
 import os
+import os.path
 import subprocess
 import sys
 
@@ -73,9 +74,17 @@
 
 def main():
     parser = argparse.ArgumentParser(
-        description='Compare files between libcore/ojluni and ${OJLUNI_UPSTREAMS}.')
+        description='Compare files between libcore/ojluni and ${OJLUNI_UPSTREAMS}.',
+        formatter_class=argparse.ArgumentDefaultsHelpFormatter, # include default values in help
+    )
+    upstreams = os.environ['OJLUNI_UPSTREAMS']
+    # natsort.natsorted() would be a nicer sort order, but I'd rather avoid the dependency
+    repositories = ['ojluni'] + sorted(
+        [d for d in os.listdir(upstreams) if os.path.isdir(os.path.join(upstreams, d))]
+    )
     parser.add_argument('-r', '--repositories', default='ojluni,expected',
-                    help='Comma-separated list of >= 2 repositories to compare.')
+                    help='Comma-separated list of 2-3 repositories, to compare, in order; '
+                          'available repositories: ' + ' '.join(repositories) + '.')
     parser.add_argument('-d', '--diff', default='meld',
                         help='Application to use for diffing.')
     parser.add_argument('rel_path', nargs="+",