changeset 7169:234121258c57

Merge
author lana
date Fri, 05 Nov 2010 08:18:46 -0700
parents 2133c705b3a3 f5a0fca591f8
children 285c02ecbb8a
files
diffstat 10 files changed, 213 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/share/classes/com/sun/servicetag/SunConnection.java	Thu Nov 04 15:38:39 2010 -0700
+++ b/jdk/src/share/classes/com/sun/servicetag/SunConnection.java	Fri Nov 05 08:18:46 2010 -0700
@@ -51,8 +51,8 @@
  */
 class SunConnection {
 
-    private static String JDK_REGISTRATION_URL = "https://inventory.sun.com/";
-    private static String SANDBOX_TESTING_URL = "https://inventory-beta.sun.com/";
+    private static String JDK_REGISTRATION_URL = "https://hs-ws1.oracle.com/";
+    private static String SANDBOX_TESTING_URL = "https://hs-ws1-tst.oracle.com/";
     private static String REGISTRATION_WEB_PATH = "RegistrationWeb/register";
 
     // System properties for testing
--- a/jdk/src/share/classes/com/sun/servicetag/resources/register.html	Thu Nov 04 15:38:39 2010 -0700
+++ b/jdk/src/share/classes/com/sun/servicetag/resources/register.html	Fri Nov 05 08:18:46 2010 -0700
@@ -64,7 +64,7 @@
         </ul>
         <p class="style1">Product registration is FREE, quick and easy!</p>
         <blockquote>
-          <p class="style1">All you need is a Sun Developer Network or other Sun Online account. If you don't already have one, you will be prompted to create one. </p>
+          <p class="style1">All you need is an Oracle.com account. If you don't already have one, you will be prompted to create one. </p>
           <table width="708" border="0" cellspacing="0" cellpadding="3">
             <tr valign="top">
               <td width="126" height="35">
@@ -83,9 +83,9 @@
        <td bgcolor="#f1f7df">
        <p class="style3">Oracle Corporation respects your privacy. 
     We will use your personal information for communications 
-    and management of your Sun Online Account, the services 
-    and applications you access using your Sun Online Account, 
-    and the products and systems you register with your Sun Online Account.</p>
+    and management of your Oracle.com account, the services 
+    and applications you access using your Oracle.com account, 
+    and the products and systems you register with your Oracle.com account.</p>
                 <p class="style3">For more information on the data that will be collected as 
           part of the registration process and how it will be managed <br>
           see <a href="http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html">http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html</a>. <br>      
--- a/jdk/src/share/classes/com/sun/servicetag/resources/register_ja.html	Thu Nov 04 15:38:39 2010 -0700
+++ b/jdk/src/share/classes/com/sun/servicetag/resources/register_ja.html	Fri Nov 05 08:18:46 2010 -0700
@@ -59,7 +59,7 @@
         </ul>
         <p class="style1">製品登録は無料であり、迅速で簡単です。</p>
         <blockquote>
-          <p class="style1">必要になるのは、Sun 開発者向けネットワークアカウントまたはその他の Sun オンラインアカウントだけです。 まだアカウントがない場合は、アカウントの作成が求められます。 </p>
+          <p class="style1">必要になるのは、Oracle.com アカウントだけです。 まだアカウントがない場合は、アカウントの作成が求められます。 </p>
           <table width="708" border="0" cellspacing="0" cellpadding="3">
             <tr valign="top">
               <td width="126" height="35"><form name="form1" method="post" action="@@REGISTRATION_URL@@" enctype="text/xml">
@@ -75,7 +75,7 @@
    <tr>
        <td>&nbsp;</td>
 	<td bgcolor="#f1f7df">
-        <p class="style3">Oracle Corporation は、お客様のプライバシーを尊重します。 お客様の個人情報は、お客様の Sun オンラインアカウント、お客様が Sun オンラインアカウントを使用してアクセスするサービスとアプリケーション、およびお客様が Sun オンラインアカウントで登録する製品とシステムの通信と管理に使用します。</p>
+        <p class="style3">Oracle Corporation は、お客様のプライバシーを尊重します。 お客様の個人情報は、お客様の Oracle.com アカウント、お客様が Oracle.com アカウントを使用してアクセスするサービスとアプリケーション、およびお客様が Oracle.com アカウントで登録する製品とシステムの通信と管理に使用します。</p>
                 <p class="style3">登録の際に収集されるデータや、それらがどのように管理されるかについての詳細は、<br><a href="http://java.sun.com/javase/ja/registration/JDKRegistrationPrivacy.html">http://java.sun.com/javase/ja/registration/JDKRegistrationPrivacy.html</a> を参照してください。 <br> <br> Oracle のプライバシーポリシーについての詳細は、<a href="http://www.oracle.com/html/privacy.html">http://www.oracle.com/html/privacy.html</a> を参照するか、<a class="moz-txt-link-rfc2396E" href="mailto:privacy_ww@oracle.com">お問い合わせフォーム</a>からお問い合わせください。</p></td>
   </tr>
   <tr>
--- a/jdk/src/share/classes/com/sun/servicetag/resources/register_zh_CN.html	Thu Nov 04 15:38:39 2010 -0700
+++ b/jdk/src/share/classes/com/sun/servicetag/resources/register_zh_CN.html	Fri Nov 05 08:18:46 2010 -0700
@@ -60,7 +60,7 @@
         </ul>
 <p class="style1">产品注册是免费的,即快速又轻松!</p>
         <blockquote>
-<p class="style1">您需要具有 Sun 开发者网络或其他 Sun 联机帐户。如果您没有,系统将提示您创建一个。 </p>
+<p class="style1">您需要具有 Oracle.com 帐户。如果您没有,系统将提示您创建一个。 </p>
           <table width="708" border="0" cellspacing="0" cellpadding="3">
             <tr valign="top">
               <td width="126" height="35"><form name="form1" method="post" action="@@REGISTRATION_URL@@" enctype="text/xml">
@@ -76,7 +76,7 @@
     <tr>
        <td>&nbsp;</td>
 	<td bgcolor="#f1f7df">
-        <p class="style3">Oracle 尊重您的隐私。我们会将您的个人信息用于通信和 Sun 联机帐户的管理、Sun 联机帐户访问的服务和应用程序以及用于使用 Sun 联机帐户注册的产品和系统。</p>
+        <p class="style3">Oracle 尊重您的隐私。我们会将您的个人信息用于通信和 Oracle.com 帐户的管理、Oracle.com 帐户访问的服务和应用程序以及用于使用 Oracle.com 帐户注册的产品和系统。</p>
 <p class="style3">有关注册过程中收集的数据以及这些数据的管理方式的更多信息,<br>请访问 <a href="http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html">http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html</a>。<br> <br>有关 Oracle 隐私政策的更多信息,请访问 <a href="http://www.oracle.com/html/privacy.html">http://www.oracle.com/html/privacy.html</a> 或与 <a class="moz-txt-link-rfc2396E" href="mailto:privacy_ww@oracle.com">privacy_ww@oracle.com</a> 联系。</p></td>
   </tr>
   <tr>
--- a/jdk/src/share/classes/java/io/ByteArrayInputStream.java	Thu Nov 04 15:38:39 2010 -0700
+++ b/jdk/src/share/classes/java/io/ByteArrayInputStream.java	Fri Nov 05 08:18:46 2010 -0700
@@ -179,11 +179,14 @@
         } else if (off < 0 || len < 0 || len > b.length - off) {
             throw new IndexOutOfBoundsException();
         }
+
         if (pos >= count) {
             return -1;
         }
-        if (pos + len > count) {
-            len = count - pos;
+
+        int avail = count - pos;
+        if (len > avail) {
+            len = avail;
         }
         if (len <= 0) {
             return 0;
@@ -206,14 +209,13 @@
      * @return  the actual number of bytes skipped.
      */
     public synchronized long skip(long n) {
-        if (pos + n > count) {
-            n = count - pos;
+        long k = count - pos;
+        if (n < k) {
+            k = n < 0 ? 0 : n;
         }
-        if (n < 0) {
-            return 0;
-        }
-        pos += n;
-        return n;
+
+        pos += k;
+        return k;
     }
 
     /**
--- a/jdk/src/share/classes/java/lang/Thread.java	Thu Nov 04 15:38:39 2010 -0700
+++ b/jdk/src/share/classes/java/lang/Thread.java	Fri Nov 05 08:18:46 2010 -0700
@@ -229,7 +229,7 @@
      * after setting this thread's interrupt status.
      */
     private volatile Interruptible blocker;
-    private Object blockerLock = new Object();
+    private final Object blockerLock = new Object();
 
     /* Set the blocker field; invoked via sun.misc.SharedSecrets from java.nio code
      */
@@ -688,16 +688,19 @@
             throw new IllegalThreadStateException();
 
         /* Notify the group that this thread is about to be started
-         * so that it can be added to the group's list of threads. */
+         * so that it can be added to the group's list of threads
+         * and the group's unstarted count can be decremented. */
         group.threadStarting(this);
 
-        boolean failed = true;
+        boolean started = false;
         try {
             start0();
-            failed = false;
+            started = true;
         } finally {
             try {
-                group.threadStarted(this, failed);
+                if (!started) {
+                    group.threadStartFailed(this);
+                }
             } catch (Throwable ignore) {
                 /* do nothing. If start0 threw a Throwable then
                   it will be passed up the call stack */
--- a/jdk/src/share/classes/java/lang/ThreadGroup.java	Thu Nov 04 15:38:39 2010 -0700
+++ b/jdk/src/share/classes/java/lang/ThreadGroup.java	Fri Nov 05 08:18:46 2010 -0700
@@ -870,9 +870,16 @@
     /**
      * Notifies the group that the thread {@code t} is about to be
      * started and adds the thread to this thread group.
+     *
+     * The thread is now a fully fledged member of the group, even though
+     * it hasn't been started yet. It will prevent the group from being
+     * destroyed so the unstarted Threads count is decremented.
      */
     void threadStarting(Thread t) {
-        add(t);
+        synchronized (this) {
+            add(t);
+            nUnstartedThreads--;
+        }
     }
 
     /**
@@ -907,12 +914,10 @@
     }
 
     /**
-     * Notifies the group that the thread {@code t} has completed
+     * Notifies the group that the thread {@code t} has failed
      * an attempt to start.
      *
-     * <p> If the thread has been started successfully
-     * then the group has its unstarted Threads count decremented.
-     * Otherwise the state of this thread group is rolled back as if the
+     * <p> The state of this thread group is rolled back as if the
      * attempt to start the thread has never occurred. The thread is again
      * considered an unstarted member of the thread group, and a subsequent
      * attempt to start the thread is permitted.
@@ -923,16 +928,10 @@
      * @param  failed
      *         true if the thread could not be started successfully
      */
-    void threadStarted(Thread t, boolean failed) {
+    void threadStartFailed(Thread t) {
         synchronized(this) {
-            if (failed) {
-                remove(t);
-            } else {
-                if (destroyed) {
-                    return;
-                }
-                nUnstartedThreads--;
-            }
+            remove(t);
+            nUnstartedThreads++;
         }
     }
 
--- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java	Thu Nov 04 15:38:39 2010 -0700
+++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java	Fri Nov 05 08:18:46 2010 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -291,7 +291,24 @@
             if (tracing)
                 logger.trace("connect",idstr + " getting connection...");
             Object credentials = usemap.get(CREDENTIALS);
-            connection = getConnection(stub, credentials, checkStub);
+
+            try {
+                connection = getConnection(stub, credentials, checkStub);
+            } catch (java.rmi.RemoteException re) {
+                if (jmxServiceURL != null) {
+                    final String pro = jmxServiceURL.getProtocol();
+                    final String path = jmxServiceURL.getURLPath();
+
+                    if ("rmi".equals(pro) &&
+                        path.startsWith("/jndi/iiop:")) {
+                        MalformedURLException mfe = new MalformedURLException(
+                              "Protocol is rmi but JNDI scheme is iiop: " + jmxServiceURL);
+                        mfe.initCause(re);
+                        throw mfe;
+                    }
+                }
+                throw re;
+            }
 
             // Always use one of:
             //   ClassLoader provided in Map at connect time,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/ByteArrayInputStream/Skip.java	Fri Nov 05 08:18:46 2010 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/* @test
+ * @bug 6720170
+ * @summary check for ByteArrayInputStream.skip
+ */
+
+import java.io.*;
+
+public class Skip {
+    private static void dotest(InputStream in, int curpos, long total,
+                               long toskip, long expected)
+        throws Exception
+    {
+        System.err.println("\nCurrently at pos = " + curpos +
+                           "\nTotal bytes in the stream = " + total +
+                           "\nNumber of bytes to skip = " + toskip +
+                           "\nNumber of bytes that should be skipped = " +
+                           expected);
+
+        // position to curpos; EOF if negative
+        in.reset();
+        int avail = curpos >= 0 ? curpos : in.available();
+        long n = in.skip(avail);
+        if (n != avail) {
+            throw new RuntimeException("Unexpected number of bytes skipped = " + n);
+        }
+
+        long skipped = in.skip(toskip);
+        System.err.println("actual number skipped: "+ skipped);
+
+        if (skipped != expected) {
+            throw new RuntimeException("Unexpected number of bytes skipped = " + skipped);
+        }
+    }
+
+    public static void main(String argv[]) throws Exception {
+        int total = 1024;
+        ByteArrayInputStream in = new ByteArrayInputStream(new byte[total]);
+
+        /* test for skip */
+        dotest(in,  0, total, 23, 23);
+        dotest(in,  10, total, 23, 23);
+
+        /* test for negative skip */
+        dotest(in,  0, total, -23,  0);
+
+        /* check for skip after EOF */
+        dotest(in, -1, total,  20,  0);
+
+        /* check for skip beyond EOF starting from before EOF */
+        dotest(in,  0, total, total+20, total);
+
+        /* check for skip if the pos + toskip causes integer overflow */
+        dotest(in, 10, total, Long.MAX_VALUE, total-10);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java	Fri Nov 05 08:18:46 2010 -0700
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary NPE IN RMIConnector.connect
+ * @bug 6984520
+ * @run clean RMIConnector_NPETest
+ * @run build RMIConnector_NPETest
+ * @run main RMIConnector_NPETest
+ */
+
+import java.io.*;
+import java.lang.management.*;
+import java.rmi.registry.*;
+import javax.management.*;
+import javax.management.remote.*;
+import javax.management.remote.rmi.*;
+
+public class RMIConnector_NPETest  {
+
+    public static void main(String argv[]) throws Exception {
+        boolean testFailed = false;
+        String rmidCmd = System.getProperty("java.home") + File.separator +
+            "bin" + File.separator + "rmid -port 3333";
+        String stopRmidCmd = System.getProperty("java.home") + File.separator +
+                "bin" + File.separator + "rmid -stop -port 3333";
+    try {
+        //start an rmid daemon and give it some time
+        System.out.println("Starting rmid");
+        Runtime.getRuntime().exec(rmidCmd);
+        Thread.sleep(5000);
+
+        MBeanServer mbs = MBeanServerFactory.createMBeanServer();
+        RMIJRMPServerImpl rmiserver = new RMIJRMPServerImpl(3333, null, null, null);
+        rmiserver.setMBeanServer(mbs);
+        RMIConnector agent = new RMIConnector(rmiserver, null);
+        agent.connect();
+    } catch(NullPointerException npe) {
+        npe.printStackTrace();
+        testFailed = true;
+    } catch (Exception e) {
+        // OK
+    } finally {
+        System.out.println("Stopping rmid");
+        Runtime.getRuntime().exec(stopRmidCmd);
+        }
+
+    if(testFailed)
+        throw new Exception("Test failed");
+
+    }
+}