Merge
authorsherman
Thu, 20 Feb 2014 09:57:26 -0800
changeset 22998 e60a93872ff7
parent 22997 7d2259be8e79 (current diff)
parent 22996 0ce70f4ef909 (diff)
child 22999 8212fb968f9b
Merge
--- a/jdk/make/CompileLaunchers.gmk	Thu Feb 20 09:52:50 2014 -0800
+++ b/jdk/make/CompileLaunchers.gmk	Thu Feb 20 09:57:26 2014 -0800
@@ -159,7 +159,6 @@
           -DFULL_VERSION='"$(FULL_VERSION)"' \
           -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
           -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"' \
-          -DLIBARCHNAME='"$(OPENJDK_TARGET_CPU_LEGACY)"' \
           -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \
           -DPROGNAME='"$1"' $(DPACKAGEPATH) \
           $2, \
--- a/jdk/src/share/classes/com/sun/jndi/dns/DnsClient.java	Thu Feb 20 09:52:50 2014 -0800
+++ b/jdk/src/share/classes/com/sun/jndi/dns/DnsClient.java	Thu Feb 20 09:57:26 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, 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
@@ -411,8 +411,7 @@
                     udpSocket.receive(ipkt);
                     long end = System.currentTimeMillis();
 
-                    byte[] data = new byte[ipkt.getLength()];
-                    data = ipkt.getData();
+                    byte[] data = ipkt.getData();
                     if (isMatchResponse(data, xid)) {
                         return data;
                     }
--- a/jdk/src/share/classes/com/sun/jndi/dns/ResourceRecord.java	Thu Feb 20 09:52:50 2014 -0800
+++ b/jdk/src/share/classes/com/sun/jndi/dns/ResourceRecord.java	Thu Feb 20 09:57:26 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, 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
@@ -25,8 +25,13 @@
 
 package com.sun.jndi.dns;
 
+import javax.naming.CommunicationException;
 import javax.naming.InvalidNameException;
 
+import java.io.IOException;
+
+import java.nio.charset.StandardCharsets;
+
 
 /**
  * The ResourceRecord class represents a DNS resource record.
@@ -84,6 +89,11 @@
         null, "IN", null, null, "HS"
     };
 
+    /*
+     * Maximum number of compression references in labels.
+     * Used to detect compression loops.
+     */
+    private static final int MAXIMUM_COMPRESSION_REFERENCES = 16;
 
     byte[] msg;                 // DNS message
     int msgLen;                 // msg size (in octets)
@@ -110,12 +120,12 @@
      * false, the rdata is not decoded (and getRdata() will return null)
      * unless this is an SOA record.
      *
-     * @throws InvalidNameException if a decoded domain name isn't valid.
+     * @throws CommunicationException if a decoded domain name isn't valid.
      * @throws ArrayIndexOutOfBoundsException given certain other corrupt data.
      */
     ResourceRecord(byte[] msg, int msgLen, int offset,
                    boolean qSection, boolean decodeRdata)
-            throws InvalidNameException {
+            throws CommunicationException {
 
         this.msg = msg;
         this.msgLen = msgLen;
@@ -235,7 +245,7 @@
      * Decodes the binary format of the RR.
      * May throw ArrayIndexOutOfBoundsException given corrupt data.
      */
-    private void decode(boolean decodeRdata) throws InvalidNameException {
+    private void decode(boolean decodeRdata) throws CommunicationException {
         int pos = offset;       // index of next unread octet
 
         name = new DnsName();                           // NAME
@@ -316,7 +326,7 @@
     /*
      * Returns the name encoded at msg[pos], including the root label.
      */
-    private DnsName decodeName(int pos) throws InvalidNameException {
+    private DnsName decodeName(int pos) throws CommunicationException {
         DnsName n = new DnsName();
         decodeName(pos, n);
         return n;
@@ -326,22 +336,39 @@
      * Prepends to "n" the domain name encoded at msg[pos], including the root
      * label.  Returns the index into "msg" following the name.
      */
-    private int decodeName(int pos, DnsName n) throws InvalidNameException {
-        if (msg[pos] == 0) {                            // end of name
-            n.add(0, "");
-            return (pos + 1);
-        } else if ((msg[pos] & 0xC0) != 0) {            // name compression
-            decodeName(getUShort(pos) & 0x3FFF, n);
-            return (pos + 2);
-        } else {                                        // append a label
-            int len = msg[pos++];
-            try {
-                n.add(0, new String(msg, pos, len, "ISO-8859-1"));
-            } catch (java.io.UnsupportedEncodingException e) {
-                // assert false : "ISO-Latin-1 charset unavailable";
+    private int decodeName(int pos, DnsName n) throws CommunicationException {
+        int endPos = -1;
+        int level = 0;
+        try {
+            while (true) {
+                if (level > MAXIMUM_COMPRESSION_REFERENCES)
+                    throw new IOException("Too many compression references");
+                int typeAndLen = msg[pos] & 0xFF;
+                if (typeAndLen == 0) {                  // end of name
+                    ++pos;
+                    n.add(0, "");
+                    break;
+                } else if (typeAndLen <= 63) {          // regular label
+                    ++pos;
+                    n.add(0, new String(msg, pos, typeAndLen,
+                        StandardCharsets.ISO_8859_1));
+                    pos += typeAndLen;
+                } else if ((typeAndLen & 0xC0) == 0xC0) { // name compression
+                    ++level;
+                    endPos = pos + 2;
+                    pos = getUShort(pos) & 0x3FFF;
+                } else
+                    throw new IOException("Invalid label type: " + typeAndLen);
             }
-            return decodeName(pos + len, n);
+        } catch (IOException | InvalidNameException e) {
+            CommunicationException ce =new CommunicationException(
+                "DNS error: malformed packet");
+            ce.initCause(e);
+            throw ce;
         }
+        if (endPos == -1)
+            endPos = pos;
+        return endPos;
     }
 
     /*
@@ -352,7 +379,7 @@
      * The rdata of records with unknown type/class combinations is
      * returned in a newly-allocated byte array.
      */
-    private Object decodeRdata(int pos) throws InvalidNameException {
+    private Object decodeRdata(int pos) throws CommunicationException {
         if (rrclass == CLASS_INTERNET) {
             switch (rrtype) {
             case TYPE_A:
@@ -386,7 +413,7 @@
     /*
      * Returns the rdata of an MX record that is encoded at msg[pos].
      */
-    private String decodeMx(int pos) throws InvalidNameException {
+    private String decodeMx(int pos) throws CommunicationException {
         int preference = getUShort(pos);
         pos += 2;
         DnsName name = decodeName(pos);
@@ -396,7 +423,7 @@
     /*
      * Returns the rdata of an SOA record that is encoded at msg[pos].
      */
-    private String decodeSoa(int pos) throws InvalidNameException {
+    private String decodeSoa(int pos) throws CommunicationException {
         DnsName mname = new DnsName();
         pos = decodeName(pos, mname);
         DnsName rname = new DnsName();
@@ -421,7 +448,7 @@
      * Returns the rdata of an SRV record that is encoded at msg[pos].
      * See RFC 2782.
      */
-    private String decodeSrv(int pos) throws InvalidNameException {
+    private String decodeSrv(int pos) throws CommunicationException {
         int priority = getUShort(pos);
         pos += 2;
         int weight =   getUShort(pos);
@@ -436,7 +463,7 @@
      * Returns the rdata of an NAPTR record that is encoded at msg[pos].
      * See RFC 2915.
      */
-    private String decodeNaptr(int pos) throws InvalidNameException {
+    private String decodeNaptr(int pos) throws CommunicationException {
         int order = getUShort(pos);
         pos += 2;
         int preference = getUShort(pos);
--- a/jdk/src/share/classes/java/util/ArrayPrefixHelpers.java	Thu Feb 20 09:52:50 2014 -0800
+++ b/jdk/src/share/classes/java/util/ArrayPrefixHelpers.java	Thu Feb 20 09:57:26 2014 -0800
@@ -128,7 +128,6 @@
             this.lo = lo; this.hi = hi;
         }
 
-        @SuppressWarnings("unchecked")
         public final void compute() {
             final BinaryOperator<T> fn;
             final T[] a;
@@ -142,9 +141,9 @@
                     if (lt == null) {                // first pass
                         int mid = (l + h) >>> 1;
                         f = rt = t.right =
-                                new CumulateTask<>(t, fn, a, org, fnc, th, mid, h);
+                                new CumulateTask<T>(t, fn, a, org, fnc, th, mid, h);
                         t = lt = t.left  =
-                                new CumulateTask<>(t, fn, a, org, fnc, th, l, mid);
+                                new CumulateTask<T>(t, fn, a, org, fnc, th, l, mid);
                     }
                     else {                           // possibly refork
                         T pin = t.in;
@@ -213,7 +212,9 @@
                         sum = t.in;
                     t.out = sum;
                     for (CumulateTask<T> par;;) {             // propagate
-                        if ((par = (CumulateTask<T>)t.getCompleter()) == null) {
+                        @SuppressWarnings("unchecked") CumulateTask<T> partmp
+                            = (CumulateTask<T>)t.getCompleter();
+                        if ((par = partmp) == null) {
                             if ((state & FINISHED) != 0)      // enable join
                                 t.quietlyComplete();
                             break outer;
@@ -245,6 +246,7 @@
                 }
             }
         }
+        private static final long serialVersionUID = 5293554502939613543L;
     }
 
     static final class LongCumulateTask extends CountedCompleter<Void> {
@@ -394,6 +396,7 @@
                 }
             }
         }
+        private static final long serialVersionUID = -5074099945909284273L;
     }
 
     static final class DoubleCumulateTask extends CountedCompleter<Void> {
@@ -543,6 +546,7 @@
                 }
             }
         }
+        private static final long serialVersionUID = -586947823794232033L;
     }
 
     static final class IntCumulateTask extends CountedCompleter<Void> {
@@ -692,5 +696,6 @@
                 }
             }
         }
+        private static final long serialVersionUID = 3731755594596840961L;
     }
 }
--- a/jdk/src/share/classes/java/util/stream/DoubleStream.java	Thu Feb 20 09:52:50 2014 -0800
+++ b/jdk/src/share/classes/java/util/stream/DoubleStream.java	Thu Feb 20 09:57:26 2014 -0800
@@ -330,7 +330,7 @@
      * <pre>{@code
      *     double result = identity;
      *     for (double element : this stream)
-     *         result = accumulator.apply(result, element)
+     *         result = accumulator.applyAsDouble(result, element)
      *     return result;
      * }</pre>
      *
@@ -391,7 +391,7 @@
      *             result = element;
      *         }
      *         else
-     *             result = accumulator.apply(result, element);
+     *             result = accumulator.applyAsDouble(result, element);
      *     }
      *     return foundAny ? OptionalDouble.of(result) : OptionalDouble.empty();
      * }</pre>
--- a/jdk/src/share/classes/java/util/stream/IntStream.java	Thu Feb 20 09:52:50 2014 -0800
+++ b/jdk/src/share/classes/java/util/stream/IntStream.java	Thu Feb 20 09:57:26 2014 -0800
@@ -323,7 +323,7 @@
      * <pre>{@code
      *     int result = identity;
      *     for (int element : this stream)
-     *         result = accumulator.apply(result, element)
+     *         result = accumulator.applyAsInt(result, element)
      *     return result;
      * }</pre>
      *
@@ -384,7 +384,7 @@
      *             result = element;
      *         }
      *         else
-     *             result = accumulator.apply(result, element);
+     *             result = accumulator.applyAsInt(result, element);
      *     }
      *     return foundAny ? OptionalInt.of(result) : OptionalInt.empty();
      * }</pre>
--- a/jdk/src/share/classes/java/util/stream/LongStream.java	Thu Feb 20 09:52:50 2014 -0800
+++ b/jdk/src/share/classes/java/util/stream/LongStream.java	Thu Feb 20 09:57:26 2014 -0800
@@ -328,7 +328,7 @@
      * <pre>{@code
      *     long result = identity;
      *     for (long element : this stream)
-     *         result = accumulator.apply(result, element)
+     *         result = accumulator.applyAsLong(result, element)
      *     return result;
      * }</pre>
      *
@@ -389,7 +389,7 @@
      *             result = element;
      *         }
      *         else
-     *             result = accumulator.apply(result, element);
+     *             result = accumulator.applyAsLong(result, element);
      *     }
      *     return foundAny ? OptionalLong.of(result) : OptionalLong.empty();
      * }</pre>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/jndi/dns/Parser.java	Thu Feb 20 09:57:26 2014 -0800
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2014, Red Hat, Inc.
+ * 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 8035105
+ * @summary DNS resource record parsing
+ */
+
+import com.sun.jndi.dns.ResourceRecord;
+import javax.naming.CommunicationException;
+import javax.naming.InvalidNameException;;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import java.io.IOException;
+
+import static java.nio.charset.StandardCharsets.ISO_8859_1;
+
+public class Parser {
+    static Constructor<ResourceRecord> rrConstructor;
+    static {
+        try {
+            rrConstructor = ResourceRecord.class.getDeclaredConstructor(
+                byte[].class, int.class, int.class, boolean.class,
+                boolean.class);
+            rrConstructor.setAccessible(true);
+        } catch (Exception e) {
+            throw new AssertionError(e);
+        }
+    }
+
+    static ResourceRecord parse(String data, int offset, boolean qSection)
+        throws Throwable {
+        byte[] bytes = data.getBytes(ISO_8859_1);
+        try {
+            return rrConstructor.newInstance(
+                bytes, bytes.length, offset, qSection, !qSection);
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    public static void main(String[] args) throws Throwable {
+        ResourceRecord rr;
+
+        rr = parse("\003www\007example\003com\000\000\002\000\001",
+            0, true);
+        if (!rr.getName().toString().equals("www.example.com."))
+            throw new AssertionError(rr.getName().toString());
+        if (rr.getRrclass() != 1)
+            throw new AssertionError("RCLASS: " + rr.getRrclass());
+        if (rr.getType() != 2)
+            throw new AssertionError("RTYPE: " + rr.getType());
+
+        String longLabel = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" +
+            "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
+
+        rr = parse("\077" + longLabel + "\077" + longLabel +
+            "\077" + longLabel + "\061" + longLabel.substring(0, 49) +
+            "\007example\003com\000\000\002\000\001",
+             0, true);
+        if (!rr.getName().toString().equals(longLabel +
+            '.' + longLabel + '.' + longLabel +
+            '.' + longLabel.substring(0, 49) + ".example.com."))
+            throw new AssertionError(rr.getName().toString());
+        if (rr.getRrclass() != 1)
+            throw new AssertionError("RCLASS: " + rr.getRrclass());
+        if (rr.getType() != 2)
+            throw new AssertionError("RTYPE: " + rr.getType());
+
+        rr = parse("1-2-3-4-5-6-" +
+            "\003www\007example\003com\000\000\002\000\001" +
+            "\300\014\000\002\000\001\000\001\121\200" +
+            "\000\005\002ns\300\020",
+            33, false);
+        if (!rr.getName().toString().equals("www.example.com."))
+            throw new AssertionError(rr.getName().toString());
+        if (rr.getRrclass() != 1)
+            throw new AssertionError("RCLASS: " + rr.getRrclass());
+        if (rr.getType() != 2)
+            throw new AssertionError("RTYPE: " + rr.getType());
+        if (!rr.getRdata().toString().equals("ns.example.com."))
+            throw new AssertionError("RDATA: " + rr.getRdata());
+
+        try {
+            parse("1-2-3-4-5-6-" +
+                "\003www\007example\003com\000\000\002\000\001" +
+                "\300\014\000\002\000\001\300\051\300\047" +
+                "\000\005\002ns\300\051",
+                33, false);
+            throw new AssertionError();
+        } catch (CommunicationException e) {
+            if (!e.getMessage().equals("DNS error: malformed packet")
+                || e.getCause().getClass() != IOException.class
+                || !e.getCause().getMessage().equals(
+                    "Too many compression references"))
+                throw e;
+        }
+
+        try {
+            String longLabel62 = "\076" + longLabel.substring(1);
+            parse(longLabel62 + longLabel62 + longLabel62 + longLabel62 +
+                "\002XX\000\000\002\000\001", 0, true);
+            throw new AssertionError();
+        } catch (CommunicationException e) {
+            if (!e.getMessage().equals("DNS error: malformed packet")
+                || e.getCause().getClass() != InvalidNameException.class
+                || !e.getCause().getMessage().equals("Name too long"))
+                throw e;
+        }
+        try {
+            parse("\100Y" + longLabel + "\000\000\002\000\001", 0, true);
+            throw new AssertionError();
+        } catch (CommunicationException e) {
+            if (!e.getMessage().equals("DNS error: malformed packet")
+                || e.getCause().getClass() != IOException.class
+                || !e.getCause().getMessage().equals("Invalid label type: 64"))
+                throw e;
+        }
+    }
+}
--- a/jdk/test/com/sun/net/httpserver/bugs/6725892/Test.java	Thu Feb 20 09:52:50 2014 -0800
+++ b/jdk/test/com/sun/net/httpserver/bugs/6725892/Test.java	Thu Feb 20 09:57:26 2014 -0800
@@ -68,7 +68,7 @@
 
         try {
             InetSocketAddress addr = new InetSocketAddress (0);
-            s1 = HttpServer.create (addr, 0);
+            s1 = HttpServer.create (addr, 100);
             HttpHandler h = new Handler ();
             HttpContext c1 = s1.createContext ("/", h);
             s1.setExecutor(exec);
--- a/jdk/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java	Thu Feb 20 09:52:50 2014 -0800
+++ b/jdk/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java	Thu Feb 20 09:57:26 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, 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
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4183169
+ * @bug 4183169 8032050
  * @summary Minor problem with the way ReliableLog handles IOExceptions.
  *
  * @author Laird Dornin; code borrowed from Ann Wollrath
@@ -36,6 +36,7 @@
 import java.rmi.activation.*;
 import java.rmi.*;
 import java.util.Properties;
+import java.util.concurrent.TimeoutException;
 
 /**
  * The test creates an rmid with a special security manager.  After
@@ -51,7 +52,7 @@
  * (after that time, the test will fail).
  */
 public class ShutdownGracefully
-    extends Activatable implements Runnable, RegisteringActivatable
+    extends Activatable implements RegisteringActivatable
 {
     private static RegisteringActivatable registering = null;
 
@@ -61,6 +62,8 @@
 
         RMID rmid = null;
 
+        // Save exception if there is a exception or expected behavior
+        Exception exception = null;
         System.err.println("\nRegression test for bug/rfe 4183169\n");
 
         try {
@@ -132,101 +135,37 @@
             desc = new ActivationDesc(secondGroupID,
                 "ShutdownGracefully", null, null);
 
+            /*
+             * registration request is expected to be failed. succeeded case
+             * should be recorded. And raise error after clean up  rmid.
+             */
             try {
                 registering = (RegisteringActivatable)
                     Activatable.register(desc);
-
-                System.err.println("second activate and deactivate " +
-                                   "object via method call");
+                System.err.println("The registration request succeeded unexpectedly");
+                exception = new RuntimeException("The registration request succeeded unexpectedly");
             } catch (ActivationException e) {
                 System.err.println("received exception from registration " +
                                    "call that should have failed...");
-            }
-
-            /*
-             * no longer needed because the security manager
-             * throws an exception during snapshot
-             */
-            /*
-            try {
-                registering.shutdown();
-
-                System.err.println("received exception from remote " +
-                                   "call that should have failed...");
-            } catch (RemoteException e) {
-            }
-            */
-
-        } catch (Exception e) {
-            TestLibrary.bomb("\nfailure: unexpected exception ", e);
-        } finally {
-            try {
-                Thread.sleep(4000);
-            } catch (InterruptedException e) {
-            }
-
-            registering = null;
-
-            // Need to make sure that rmid goes away by itself
-            JavaVM rmidProcess = rmid;
-            if (rmidProcess != null) {
+                // Need wait rmid process terminates.
                 try {
-                    Runnable waitThread =
-                        new ShutdownDetectThread(rmidProcess);
-
-                    synchronized (waitThread) {
-                        (new Thread(waitThread)).start();
-                        waitThread.wait(SHUTDOWN_TIMEOUT);
-                        System.err.println("rmid has shutdown");
-
-                        if (!rmidDone) {
-                            // ensure that this rmid does not infect
-                            // other tests.
-                            rmidProcess.destroy();
-                            TestLibrary.bomb("rmid did not shutdown " +
-                                             "gracefully in time");
-                        }
-                    }
-                } catch (Exception e) {
-                    TestLibrary.bomb("exception waiting for rmid " +
-                                     "to shut down");
+                    int exitCode = rmid.waitFor(SHUTDOWN_TIMEOUT);
+                    System.err.println("RMID has exited gracefully with exitcode:" + exitCode);
+                    rmid = null;
+                } catch (TimeoutException te) {
+                    System.err.println("RMID process has not exited in given time");
+                    exception = te;
                 }
             }
-            // else rmid should be down
-        }
-
-        System.err.println
-            ("\nsuccess: ShutdownGracefully test passed ");
-    }
-
-    private static boolean rmidDone = false;
-
-    /**
-     * class that waits for rmid to exit
-     */
-    private static class ShutdownDetectThread implements Runnable {
-        private JavaVM rmidProcess = null;
-
-        ShutdownDetectThread(JavaVM rmidProcess) {
-            this.rmidProcess = rmidProcess;
+        } catch (Exception e) {
+            System.err.println("Exception thrown:" + e);
+            exception = e;
+        } finally {
+            if (rmid != null)
+                rmid.destroy();
         }
-        public void run() {
-            System.err.println("waiting for rmid to shutdown");
-
-            try {
-                rmidProcess.waitFor();
-            } catch (InterruptedException e) {
-                // should not happen
-            }
-
-            synchronized (this) {
-                // notify parent thread when rmid has exited
-                this.notify();
-                rmidDone = true;
-            }
-
-            RMID.removeLog();
-        }
+        if (exception != null)
+            TestLibrary.bomb("\nexception thrown in test: ", exception);
     }
 
     /**
@@ -240,23 +179,12 @@
     }
 
     /**
-     * Spawns a thread to deactivate the object.
+     * Deactivates the object. We need to unexport forcibly because this call
+     * in-progress on this object, which is the same object that we are trying
+     * to deactivate.
      */
     public void shutdown() throws Exception {
-        (new Thread(this, "ShutdownGracefully")).start();
-    }
-
-    /**
-     * Thread to deactivate object. First attempts to make object
-     * inactive (via the inactive method).  If that fails (the
-     * object may still have pending/executing calls), then
-     * unexport the object forcibly.
-     */
-    public void run() {
-        try {
-            Thread.sleep(50 * 1000);
-        } catch (InterruptedException e) {
-        }
+        Activatable.unexportObject(this, true);
         ActivationLibrary.deactivate(this, getID());
     }
 }
--- a/jdk/test/java/rmi/testlibrary/JavaVM.java	Thu Feb 20 09:52:50 2014 -0800
+++ b/jdk/test/java/rmi/testlibrary/JavaVM.java	Thu Feb 20 09:57:26 2014 -0800
@@ -26,6 +26,7 @@
 import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.StringTokenizer;
+import java.util.concurrent.TimeoutException;
 
 /**
  * RMI regression test utility class that uses Runtime.exec to spawn a
@@ -173,6 +174,40 @@
     }
 
     /**
+     * Causes the current thread to wait the vm process to exit, if necessary,
+     * wait until the vm process has terminated, or the specified waiting time
+     * elapses. Release allocated input/output after vm process has terminated.
+     * @param timeout the maximum milliseconds to wait.
+     * @return exit value for vm process.
+     * @throws InterruptedException if the current thread is interrupted
+     *         while waiting.
+     * @throws TimeoutException if subprocess does not end after timeout
+     *         milliseconds passed
+     */
+    public int waitFor(long timeout)
+            throws InterruptedException, TimeoutException {
+        if (vm == null)
+            throw new IllegalStateException("can't wait for JavaVM that isn't running");
+        long startTime = System.currentTimeMillis();
+        long rem = timeout;
+
+        do {
+            try {
+                int status = vm.exitValue();
+                outPipe.join();
+                errPipe.join();
+                return status;
+            } catch (IllegalThreadStateException ex) {
+                if (rem > 0) {
+                    Thread.sleep(Math.min(rem, 100));
+                }
+            }
+            rem = timeout - (System.currentTimeMillis() - startTime);
+        } while (rem > 0);
+        throw new TimeoutException();
+    }
+
+    /**
      * Starts the subprocess, waits for it to exit, and returns its exit status.
      */
     public int execute() throws IOException, InterruptedException {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/xml/jaxp/parsers/8027359/FragmentScannerBufferLimitTest.java	Thu Feb 20 09:57:26 2014 -0800
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2014, SAP AG. 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 8034087 8027359
+ * @summary XML parser may overwrite element content if that content falls onto the border of an entity scanner buffer
+ * @run main FragmentScannerBufferLimitTest
+ */
+import java.io.*;
+
+import javax.xml.parsers.*;
+import javax.xml.transform.*;
+import org.w3c.dom.*;
+import org.xml.sax.*;
+
+/**
+ * Test for overwriting of XML element content by the XML parser when reading over buffer
+ * limits.
+ *
+ * We create a simple XML document of the form:
+ *
+ * <?xml version=\"1.1\"?>
+ * <ROOT>
+ *    <FILLER>ffffffff...fffff</FILLER>
+ *    <TEST>content</TEST><TEST2>content2</TEST2>
+ *    <FILLER>ffffffff...fffffffff</FILLER>
+ * </ROOT>
+ *
+ * What's important here is, that the test content is at the border of an entity scanner
+ * buffer (XMLEntityScanner uses 8192 byte buffers). That's why there are filler elements
+ * of sufficient length that ensure there is a buffer break inside the test content
+ * and there is enough to read to require another buffer read after the content has been
+ * read.
+ *
+ * With the faulty implementation, the test content gets overwritten with characters
+ * read from the next buffer, i.e. 'f's.
+ *
+ * @author steffen.schreiber@sap.com
+ */
+public class FragmentScannerBufferLimitTest {
+
+    static int errCount = 0;
+
+    /**
+     * Check the test content.
+     */
+    public static void main(String[] args) throws ParserConfigurationException,
+            SAXException, IOException, TransformerConfigurationException,
+            TransformerException, TransformerFactoryConfigurationError {
+
+        String testString = "<TEST>content</TEST><TEST2>content2</TEST2>";
+
+        for (int i = 0; i < testString.length(); i++) {
+            test(createDocument(testString.toString(), i), ""+ i);
+        }
+
+        if (errCount == 0) {
+            System.out.println("OK");
+        }
+        else {
+            System.out.println("ERROR");
+            throw new RuntimeException("Parsing error: element content has been overwritten");
+        }
+    }
+
+    /**
+     * Create the test XML document.
+     * @param testString the test content string
+     * @param bufferLimitPosition the position in the string where the buffer should break
+     * @return the document
+     */
+    private static String createDocument(String testString, int bufferLimitPosition) throws UnsupportedEncodingException {
+        StringBuilder result = new StringBuilder();
+        result.append("<?xml version=\"1.1\"?>");
+        result.append("<ROOT>");
+
+        int fillerLength = 8192 - bufferLimitPosition;
+        createFiller(result, fillerLength);
+
+        result.append(testString);
+
+        createFiller(result, 9000);
+        result.append("</ROOT>");
+        return result.toString();
+    }
+
+    /**
+     * Create the filler element of the given length.
+     * @param buffer the output buffer
+     * @param length the required length of the element, including the element tags
+     */
+    private static void createFiller(StringBuilder buffer, int length) {
+        buffer.append("<FILLER>");
+        int fillLength = length - "<FILLER></FILLER>".length();
+        for (int i=0; i<fillLength; i++) {
+            buffer.append('f');
+        }
+        buffer.append("</FILLER>");
+    }
+
+
+    private static void test(String document, String testName) throws SAXException, IOException, ParserConfigurationException {
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        DocumentBuilder builder = factory.newDocumentBuilder();
+
+        Document doc = builder.parse(new ByteArrayInputStream(document.getBytes("UTF-8")));
+
+        // check that there is the root node
+        NodeList roots = doc.getElementsByTagName("ROOT");
+        assert roots.getLength() == 1;
+        Node root = roots.item(0);
+
+        // check that root has children "FILLER" and "TEST"
+        NodeList children = root.getChildNodes();
+        assert children.getLength() == 4;
+        assert children.item(0).getNodeName().equals("FILLER");
+        assert children.item(1).getNodeName().equals("TEST");
+        assert children.item(2).getNodeName().equals("TEST2");
+        assert children.item(3).getNodeName().equals("FILLER");
+
+        // check that the test node has content "content"
+        checkContent(children.item(1).getTextContent(), "content", document);
+        checkContent(children.item(2).getTextContent(), "content2", document);
+    }
+
+    private static void checkContent(String found, String expected, String document) {
+        if (! (found.equals(expected))) {
+            errCount++;
+            int bufferStart = "<?xml version=\"1.1\"?><ROOT>".length() +1;
+            int bufferStart2 = bufferStart + 8192;
+            System.err.println("\nError:: expected \"" + expected
+                    + "\", but found \"" + found + "\"!");
+            System.err.println("Buffer was (probably): [ ... "
+                    + document.substring(bufferStart2 - 20, bufferStart2) + "] ["
+                    + document.substring(bufferStart2, bufferStart2 + 30) + " ... ]");
+        }
+    }
+}