Merge
authorlana
Thu, 01 Jan 2015 16:14:01 -0800
changeset 28264 7cf8753380ea
parent 28254 02bcf0e47786 (current diff)
parent 28263 9c48c9617c7c (diff)
child 28265 a88cb2d641ff
Merge
--- a/jdk/src/java.base/share/classes/java/math/BigDecimal.java	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/math/BigDecimal.java	Thu Jan 01 16:14:01 2015 -0800
@@ -393,7 +393,7 @@
      * <p>Note that if the sequence of characters is already available
      * within a character array, using this constructor is faster than
      * converting the {@code char} array to string and using the
-     * {@code BigDecimal(String)} constructor .
+     * {@code BigDecimal(String)} constructor.
      *
      * @param  in {@code char} array that is the source of characters.
      * @param  offset first character in the array to inspect.
@@ -466,7 +466,8 @@
                     } else if (c == '.') {   // have dot
                         // have dot
                         if (dot) // two dots
-                            throw new NumberFormatException();
+                            throw new NumberFormatException("Character array"
+                                + " contains more than one decimal point.");
                         dot = true;
                     } else if (Character.isDigit(c)) { // slow path
                         int digit = Character.digit(c, 10);
@@ -488,14 +489,16 @@
                         exp = parseExp(in, offset, len);
                         // Next test is required for backwards compatibility
                         if ((int) exp != exp) // overflow
-                            throw new NumberFormatException();
+                            throw new NumberFormatException("Exponent overflow.");
                         break; // [saves a test]
                     } else {
-                        throw new NumberFormatException();
+                        throw new NumberFormatException("Character " + c
+                            + " is neither a decimal digit number, decimal point, nor"
+                            + " \"e\" notation exponential mark.");
                     }
                 }
                 if (prec == 0) // no digits found
-                    throw new NumberFormatException();
+                    throw new NumberFormatException("No digits found.");
                 // Adjust scale if exp is not zero.
                 if (exp != 0) { // had significant exponent
                     scl = adjustScale(scl, exp);
@@ -541,22 +544,24 @@
                     if (c == '.') {
                         // have dot
                         if (dot) // two dots
-                            throw new NumberFormatException();
+                            throw new NumberFormatException("Character array"
+                                + " contains more than one decimal point.");
                         dot = true;
                         continue;
                     }
                     // exponent expected
                     if ((c != 'e') && (c != 'E'))
-                        throw new NumberFormatException();
+                        throw new NumberFormatException("Character array"
+                            + " is missing \"e\" notation exponential mark.");
                     exp = parseExp(in, offset, len);
                     // Next test is required for backwards compatibility
                     if ((int) exp != exp) // overflow
-                        throw new NumberFormatException();
+                        throw new NumberFormatException("Exponent overflow.");
                     break; // [saves a test]
                 }
                 // here when no characters left
                 if (prec == 0) // no digits found
-                    throw new NumberFormatException();
+                    throw new NumberFormatException("No digits found.");
                 // Adjust scale if exp is not zero.
                 if (exp != 0) { // had significant exponent
                     scl = adjustScale(scl, exp);
@@ -592,10 +597,10 @@
                     }
                 }
             }
-        } catch (ArrayIndexOutOfBoundsException e) {
-            throw new NumberFormatException();
-        } catch (NegativeArraySizeException e) {
-            throw new NumberFormatException();
+        } catch (ArrayIndexOutOfBoundsException | NegativeArraySizeException e) {
+            NumberFormatException nfe = new NumberFormatException();
+            nfe.initCause(e);
+            throw nfe;
         }
         this.scale = scl;
         this.precision = prec;
@@ -627,7 +632,7 @@
             len--;
         }
         if (len <= 0) // no exponent digits
-            throw new NumberFormatException();
+            throw new NumberFormatException("No exponent digits.");
         // skip leading zeros in the exponent
         while (len > 10 && (c=='0' || (Character.digit(c, 10) == 0))) {
             offset++;
@@ -635,7 +640,7 @@
             len--;
         }
         if (len > 10) // too many nonzero exponent digits
-            throw new NumberFormatException();
+            throw new NumberFormatException("Too many nonzero exponent digits.");
         // c now holds first digit of exponent
         for (;; len--) {
             int v;
@@ -644,7 +649,7 @@
             } else {
                 v = Character.digit(c, 10);
                 if (v < 0) // not a digit
-                    throw new NumberFormatException();
+                    throw new NumberFormatException("Not a digit.");
             }
             exp = exp * 10 + v;
             if (len == 1)
--- a/jdk/src/java.base/share/classes/sun/security/provider/DSA.java	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/provider/DSA.java	Thu Jan 01 16:14:01 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -117,7 +117,6 @@
         if (params == null) {
             throw new InvalidKeyException("DSA private key lacks parameters");
         }
-        checkKey(params);
 
         this.params = params;
         this.presetX = priv.getX();
@@ -149,7 +148,6 @@
         if (params == null) {
             throw new InvalidKeyException("DSA public key lacks parameters");
         }
-        checkKey(params);
 
         this.params = params;
         this.presetY = pub.getY();
@@ -291,16 +289,6 @@
         return null;
     }
 
-    protected void checkKey(DSAParams params) throws InvalidKeyException {
-        // FIPS186-3 states in sec4.2 that a hash function which provides
-        // a lower security strength than the (L, N) pair ordinarily should
-        // not be used.
-        int valueN = params.getQ().bitLength();
-        if (valueN > md.getDigestLength()*8) {
-            throw new InvalidKeyException("Key is too strong for this signature algorithm");
-        }
-    }
-
     private BigInteger generateR(BigInteger p, BigInteger q, BigInteger g,
                          BigInteger k) {
         BigInteger temp = g.modPow(k, p);
@@ -480,14 +468,6 @@
            }
         }
 
-        @Override
-        protected void checkKey(DSAParams params) throws InvalidKeyException {
-            int valueL = params.getP().bitLength();
-            if (valueL > 1024) {
-                throw new InvalidKeyException("Key is too long for this algorithm");
-            }
-        }
-
         /*
          * Please read bug report 4044247 for an alternative, faster,
          * NON-FIPS approved method to generate K
--- a/jdk/src/java.base/share/native/libzip/Deflater.c	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/src/java.base/share/native/libzip/Deflater.c	Thu Jan 01 16:14:01 2015 -0800
@@ -76,10 +76,11 @@
         JNU_ThrowOutOfMemoryError(env, 0);
         return jlong_zero;
     } else {
-        char *msg;
-        switch (deflateInit2(strm, level, Z_DEFLATED,
-                             nowrap ? -MAX_WBITS : MAX_WBITS,
-                             DEF_MEM_LEVEL, strategy)) {
+        const char *msg;
+        int ret = deflateInit2(strm, level, Z_DEFLATED,
+                               nowrap ? -MAX_WBITS : MAX_WBITS,
+                               DEF_MEM_LEVEL, strategy);
+        switch (ret) {
           case Z_OK:
             return ptr_to_jlong(strm);
           case Z_MEM_ERROR:
@@ -91,7 +92,11 @@
             JNU_ThrowIllegalArgumentException(env, 0);
             return jlong_zero;
           default:
-            msg = strm->msg;
+            msg = ((strm->msg != NULL) ? strm->msg :
+                   (ret == Z_VERSION_ERROR) ?
+                   "zlib returned Z_VERSION_ERROR: "
+                   "compile time and runtime zlib implementations differ" :
+                   "unknown error initializing zlib library");
             free(strm);
             JNU_ThrowInternalError(env, msg);
             return jlong_zero;
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AliasFileParser.java	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AliasFileParser.java	Thu Jan 01 16:14:01 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -42,7 +42,7 @@
  */
 public class AliasFileParser {
     private static final String ALIAS = "alias";
-    private static final boolean DEBUG = false;
+    // 8028357 removed old, inefficient debug logging
 
     // other variables
     private URL inputfile;
@@ -64,21 +64,12 @@
         }
     }
 
-    private void logln(String s) {
-        if (DEBUG) {
-            System.err.println(s);
-        }
-    }
-
     /**
      * method to get the next token as a Token type
      */
     private void nextToken() throws IOException {
         st.nextToken();
         currentToken = new Token(st.ttype, st.sval);
-
-        logln("Read token: type = " + currentToken.ttype
-              + " string = " + currentToken.sval);
     }
 
     /**
@@ -90,8 +81,6 @@
 
         if ((currentToken.ttype == ttype)
                 && (currentToken.sval.compareTo(token) == 0)) {
-            logln("matched type: " + ttype + " and token = "
-                  + currentToken.sval);
             nextToken();
         } else {
             throw new SyntaxException(st.lineno());
@@ -105,7 +94,6 @@
      */
     private void match(int ttype) throws IOException, SyntaxException {
         if (currentToken.ttype == ttype) {
-            logln("matched type: " + ttype + ", token = " + currentToken.sval);
             nextToken();
         } else {
             throw new SyntaxException(st.lineno());
@@ -157,8 +145,6 @@
             } while ((currentToken.ttype != StreamTokenizer.TT_EOF)
                      && (currentToken.sval.compareTo(ALIAS) != 0));
 
-            logln("adding map entry for " + name + " values = " + aliases);
-
             map.put(name, aliases);
         }
     }
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/CountedTimerTaskUtils.java	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/CountedTimerTaskUtils.java	Thu Jan 01 16:14:01 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -35,7 +35,7 @@
  */
 public class CountedTimerTaskUtils {
 
-    private static final boolean DEBUG = false;
+    // 8028357 removed old, inefficient debug logging
 
     /**
      * Reschedule a CountedTimeTask at a different interval. Probably not
@@ -58,14 +58,6 @@
         long lastRun = oldTask.scheduledExecutionTime();
         long expired = now - lastRun;
 
-        if (DEBUG) {
-            System.err.println("computing timer delay: "
-                               + " oldInterval = " + oldInterval
-                               + " newInterval = " + newInterval
-                               + " samples = " + oldTask.executionCount()
-                               + " expired = " + expired);
-        }
-
         /*
          * check if original task ever ran - if not, then lastRun is
          * undefined and we simply set the delay to 0.
@@ -76,12 +68,6 @@
             delay = remainder >= 0 ? remainder : 0;
         }
 
-        if (DEBUG) {
-            System.err.println("rescheduling sampler task: interval = "
-                               + newInterval
-                               + " delay = " + delay);
-        }
-
         timer.schedule(newTask, delay, newInterval);
     }
 }
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java	Thu Jan 01 16:14:01 2015 -0800
@@ -44,7 +44,8 @@
  */
 public class PerfDataBuffer extends PerfDataBufferImpl {
 
-    private static final boolean DEBUG = false;
+    // 8028357 removed old, inefficient debug logging
+
     private static final int syncWaitMs =
             Integer.getInteger("sun.jvmstat.perdata.syncWaitMs", 5000);
     private static final ArrayList<Monitor> EMPTY_LIST = new ArrayList<Monitor>(0);
@@ -268,18 +269,13 @@
          * loop waiting for the ticks counter to be non zero. This is
          * an indication that the jvm is initialized.
          */
-        log("synchWithTarget: " + lvmid + " ");
         while (ticks.longValue() == 0) {
-            log(".");
-
             try { Thread.sleep(20); } catch (InterruptedException e) { }
 
             if (System.currentTimeMillis() > timeLimit) {
-                lognl("failed: " + lvmid);
                 throw new MonitorException("Could Not Synchronize with target");
             }
         }
-        lognl("success: " + lvmid);
     }
 
     /**
@@ -291,24 +287,18 @@
                       throws MonitorException {
         Monitor monitor = null;
 
-        log("polling for: " + lvmid + "," + name + " ");
-
         pollForEntry = nextEntry;
         while ((monitor = map.get(name)) == null) {
-            log(".");
 
             try { Thread.sleep(20); } catch (InterruptedException e) { }
 
             long t = System.currentTimeMillis();
             if ((t > timeLimit) || (overflow.intValue() > 0)) {
-                lognl("failed: " + lvmid + "," + name);
-                dumpAll(map, lvmid);
                 throw new MonitorException("Could not find expected counter");
             }
 
             getNewMonitors(map);
         }
-        lognl("success: " + lvmid + "," + name);
         return monitor;
     }
 
@@ -481,8 +471,6 @@
 
         // check for the end of the buffer
         if (nextEntry == buffer.limit()) {
-            lognl("getNextMonitorEntry():"
-                  + " nextEntry == buffer.limit(): returning");
             return null;
         }
 
@@ -614,37 +602,4 @@
         nextEntry = entryStart + entryLength;
         return monitor;
     }
-
-    /**
-     * Method to dump debugging information
-     */
-    private void dumpAll(Map<String, Monitor> map, int lvmid) {
-        if (DEBUG) {
-            Set<String> keys = map.keySet();
-
-            System.err.println("Dump for " + lvmid);
-            int j = 0;
-            for (Iterator<String> i = keys.iterator(); i.hasNext(); j++) {
-                Monitor monitor = map.get(i.next());
-                System.err.println(j + "\t" + monitor.getName()
-                                   + "=" + monitor.getValue());
-            }
-            System.err.println("nextEntry = " + nextEntry
-                               + " pollForEntry = " + pollForEntry);
-            System.err.println("Buffer info:");
-            System.err.println("buffer = " + buffer);
-        }
-    }
-
-    private void lognl(String s) {
-        if (DEBUG) {
-            System.err.println(s);
-        }
-    }
-
-    private void log(String s) {
-        if (DEBUG) {
-            System.err.print(s);
-        }
-    }
 }
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java	Thu Jan 01 16:14:01 2015 -0800
@@ -62,7 +62,8 @@
  */
 public class PerfDataBuffer extends PerfDataBufferImpl {
 
-    private static final boolean DEBUG = false;
+    // 8028357 removed old, inefficient debug logging
+
     private static final int syncWaitMs =
             Integer.getInteger("sun.jvmstat.perdata.syncWaitMs", 5000);
     private static final ArrayList<Monitor> EMPTY_LIST = new ArrayList<>(0);
@@ -264,20 +265,15 @@
         long timeLimit = System.currentTimeMillis() + syncWaitMs;
 
         // loop waiting for the accessible indicater to be non-zero
-        log("synchWithTarget: " + lvmid + " ");
         while (!prologue.isAccessible()) {
 
-            log(".");
-
             // give the target jvm a chance to complete initializatoin
             try { Thread.sleep(20); } catch (InterruptedException e) { }
 
             if (System.currentTimeMillis() > timeLimit) {
-                logln("failed: " + lvmid);
                 throw new MonitorException("Could not synchronize with target");
             }
         }
-        logln("success: " + lvmid);
     }
 
     /**
@@ -306,8 +302,6 @@
 
         // check for end of the buffer
         if (nextEntry == buffer.limit()) {
-            logln("getNextMonitorEntry():"
-                  + " nextEntry == buffer.limit(): returning");
             return null;
         }
 
@@ -346,9 +340,6 @@
         byte varByte = buffer.get();
         int dataOffset = buffer.getInt();
 
-        dump_entry_fixed(entryStart, nameOffset, vectorLength, typeCodeByte,
-                         flags, unitsByte, varByte, dataOffset);
-
         // convert common attributes to their object types
         Units units = Units.toUnits(unitsByte);
         Variability variability = Variability.toVariability(varByte);
@@ -439,8 +430,6 @@
         // set the position to the start of the data item
         buffer.position(entryStart + dataOffset);
 
-        dump_entry_variable(name, buffer, dataSize);
-
         if (vectorLength == 0) {
             // create a scalar Monitor object
             if (typeCode == TypeCode.LONG) {
@@ -514,103 +503,4 @@
         nextEntry = entryStart + entryLength;
         return monitor;
     }
-
-    /**
-     * Method to dump debugging information
-     */
-    private void dumpAll(Map<String, Monitor> map, int lvmid) {
-        if (DEBUG) {
-            Set<String> keys = map.keySet();
-
-            System.err.println("Dump for " + lvmid);
-            int j = 0;
-            for (Iterator<String> i = keys.iterator(); i.hasNext(); j++) {
-                Monitor monitor = map.get(i.next());
-                System.err.println(j + "\t" + monitor.getName()
-                                   + "=" + monitor.getValue());
-            }
-            System.err.println("nextEntry = " + nextEntry);
-            System.err.println("Buffer info:");
-            System.err.println("buffer = " + buffer);
-        }
-    }
-
-    /**
-     * Method to dump the fixed portion of an entry.
-     */
-    private void dump_entry_fixed(int entry_start, int nameOffset,
-                                  int vectorLength, byte typeCodeByte,
-                                  byte flags, byte unitsByte, byte varByte,
-                                  int dataOffset) {
-        if (DEBUG) {
-            System.err.println("Entry at offset: 0x"
-                               + Integer.toHexString(entry_start));
-            System.err.println("\tname_offset = 0x"
-                               + Integer.toHexString(nameOffset));
-            System.err.println("\tvector_length = 0x"
-                               + Integer.toHexString(vectorLength));
-            System.err.println("\tdata_type = 0x"
-                               + Integer.toHexString(typeCodeByte));
-            System.err.println("\tflags = 0x"
-                               + Integer.toHexString(flags));
-            System.err.println("\tdata_units = 0x"
-                               + Integer.toHexString(unitsByte));
-            System.err.println("\tdata_variability = 0x"
-                               + Integer.toHexString(varByte));
-            System.err.println("\tdata_offset = 0x"
-                               + Integer.toHexString(dataOffset));
-        }
-    }
-
-    private void dump_entry_variable(String name, ByteBuffer bb, int size) {
-        if (DEBUG) {
-            char[] toHex = new char[] { '0', '1', '2', '3',
-                                        '4', '5', '6', '7',
-                                        '8', '9', 'a', 'b',
-                                        'c', 'd', 'e', 'f' };
-
-            ByteBuffer data = bb.slice();
-            data.limit(size);
-
-            System.err.println("\tname = " + name);
-            System.err.println("\tdata = ");
-
-            int count=0;
-            while (data.hasRemaining()) {
-                byte b = data.get();
-                byte high = (byte)((b >> 8) & 0x0f);
-                byte low = (byte)(b & 0x0f);
-
-                if (count % 16 == 0) {
-                    System.err.print("\t\t" + Integer.toHexString(count / 16)
-                                     + ": ");
-                }
-
-                System.err.print(String.valueOf(toHex[high])
-                                 + String.valueOf(toHex[low]));
-
-                count++;
-                if (count % 16 == 0) {
-                    System.err.println();
-                } else {
-                    System.err.print(" ");
-                }
-            }
-            if (count % 16 != 0) {
-                System.err.println();
-            }
-        }
-    }
-
-    private void logln(String s) {
-        if (DEBUG) {
-            System.err.println(s);
-        }
-    }
-
-    private void log(String s) {
-        if (DEBUG) {
-            System.err.print(s);
-        }
-    }
 }
--- a/jdk/test/ProblemList.txt	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/test/ProblemList.txt	Thu Jan 01 16:14:01 2015 -0800
@@ -120,6 +120,10 @@
 
 # jdk_lang
 
+# 8029891
+java/lang/ClassLoader/deadlock/GetResource.java                 generic-all
+
+
 ############################################################################
 
 # jdk_instrument
@@ -264,7 +268,7 @@
 
 # Tests take too long, on sparcs see 7143279
 # also see 8059906
-tools/pack200/CommandLineTests.java
+tools/pack200/CommandLineTests.java                             generic-all
 tools/pack200/Pack200Test.java                                  solaris-all,macosx-all
 
 # 8007410
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/smartcardio/CommandAPDUTest.java	Thu Jan 01 16:14:01 2015 -0800
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2007, 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
+ * 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 8049021
+ * @summary Test different constructors for CommandAPDU and check CLA,INS,NC,NE,
+ * P1,and P2
+ * @run testng CommandAPDUTest
+ */
+import java.nio.ByteBuffer;
+import javax.smartcardio.CommandAPDU;
+import static org.testng.Assert.*;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+public class CommandAPDUTest {
+
+    static final byte[] C1 = {(byte) 0x00, (byte) 0xA4, (byte) 0x04,
+        (byte) 0x00, (byte) 0x07, (byte) 0xA0, (byte) 0x00, (byte) 0x00,
+        (byte) 0x00, (byte) 0x62, (byte) 0x81, (byte) 0x01, (byte) 0x00};
+    static int cla, ins, nc, ne, p1, p2;
+    static byte[] apdu, data;
+    static CommandAPDU cm1, cm2, cm3, cm4, cm5, cm6, cm7, cm8, cm9;
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        //expected values of apdu, data, headers, nc, ne
+        CommandAPDU capdu = new CommandAPDU(C1);
+        apdu = capdu.getBytes();
+        data = capdu.getData();
+
+        cla = capdu.getCLA();
+        if (cla != (C1[0] & 0xff)) {
+            throw new RuntimeException("Failure: cla is not right");
+        }
+
+        ins = capdu.getINS();
+        if (ins != (C1[1] & 0xff)) {
+            throw new RuntimeException("Failure: ins is not right");
+        }
+
+        p1 = capdu.getP1();
+        if (p1 != (C1[2] & 0xff)) {
+            throw new RuntimeException("Failure: p1 is not right");
+        }
+
+        p2 = capdu.getP2();
+        if (p2 != (C1[3] & 0xff)) {
+            throw new RuntimeException("Failure: p2 is not right");
+        }
+
+        nc = capdu.getNc();
+        ne = capdu.getNe();
+
+        //Test on following constructors
+        cm1 = new CommandAPDU(apdu);
+        cm2 = new CommandAPDU(cla, ins, p1, p2);
+        cm3 = new CommandAPDU(cla, ins, p1, p2, data);
+        cm4 = new CommandAPDU(cla, ins, p1, p2, data, ne);
+        cm5 = new CommandAPDU(cla, ins, p1, p2, ne);
+        cm6 = new CommandAPDU(ByteBuffer.wrap(apdu));
+        cm7 = new CommandAPDU(apdu, 0, apdu.length);
+        cm8 = new CommandAPDU(cla, ins, p1, p2, data, 0, nc);
+        cm9 = new CommandAPDU(cla, ins, p1, p2, data, 0, nc, ne);
+    }
+
+    @Test(dataProvider = "provider1")
+    public static void testHeaders(CommandAPDU cm) {
+        assertEquals(cla, cm.getCLA());
+        assertEquals(ins, cm.getINS());
+        assertEquals(p1, cm.getP1());
+        assertEquals(p2, cm.getP2());
+    }
+
+    @Test(dataProvider = "provider2")
+    public static void testAPDU(CommandAPDU cm) {
+        assertEquals(apdu, cm.getBytes());
+    }
+
+    @Test(dataProvider = "provider3")
+    public static void testData(CommandAPDU cm) {
+        assertEquals(data, cm.getData());
+    }
+
+    @Test(dataProvider = "provider3")
+    public static void testNC(CommandAPDU cm) {
+        assertEquals(nc, cm.getNc());
+    }
+
+    @Test(dataProvider = "provider4")
+    public static void testNE(CommandAPDU cm) {
+        assertEquals(ne, cm.getNe());
+    }
+
+    @DataProvider
+    public Object[][] provider1() {
+        return new Object[][]{{cm1}, {cm2}, {cm3}, {cm4}, {cm5}, {cm6}, {cm7},
+        {cm8}, {cm9}};
+    }
+
+    @DataProvider
+    public Object[][] provider2() {
+        return new Object[][]{{cm1}, {cm6}, {cm7}};
+    }
+
+    @DataProvider
+    public Object[][] provider3() {
+        return new Object[][]{{cm1}, {cm3}, {cm4}, {cm6}, {cm7}, {cm8}, {cm9}};
+    }
+
+    @DataProvider
+    public Object[][] provider4() {
+        return new Object[][]{{cm1}, {cm4}, {cm5}, {cm6}, {cm7}, {cm9}};
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/smartcardio/ResponseAPDUTest.java	Thu Jan 01 16:14:01 2015 -0800
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2007, 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
+ * 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 8049021
+ * @summary Construct ResponseAPDU from byte array and check NR< SW, SW1 and SW2
+ * @run testng ResponseAPDUTest
+ */
+import javax.smartcardio.ResponseAPDU;
+import static org.testng.Assert.*;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ResponseAPDUTest {
+
+    static final byte[] R1 = {(byte) 0x07, (byte) 0xA0, (byte) 0x00,
+        (byte) 0x00, (byte) 0x00, (byte) 0x62, (byte) 0x81, (byte) 0x01,
+        (byte) 0x04, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x24,
+        (byte) 0x05, (byte) 0x00, (byte) 0x0B, (byte) 0x04, (byte) 0xB0,
+        (byte) 0x25, (byte) 0x90, (byte) 0x00};
+    static final ResponseAPDU RAPDU = new ResponseAPDU(R1);
+    static byte[] expectedData;
+    static int expectedNr, expectedSw1, expectedSw2, expectedSw;
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        //expected values for data,nr,sw1,sw2 and sw
+
+        int apduLen = R1.length;
+        expectedData = new byte[apduLen - 2];
+        for (int i = 0; i < (apduLen - 2); i++) {
+            expectedData[i] = R1[i];
+        }
+
+        expectedNr = expectedData.length;
+        expectedSw1 = R1[apduLen - 2] & 0xff;
+        expectedSw2 = R1[apduLen - 1] & 0xff;
+        expectedSw = (expectedSw1 << 8) | expectedSw2;
+    }
+
+    @Test
+    public static void test() {
+        assertEquals(RAPDU.getBytes(), R1);
+        assertEquals(RAPDU.getData(), expectedData);
+        assertEquals(RAPDU.getNr(), expectedNr);
+        assertEquals(RAPDU.getSW(), expectedSw);
+        assertEquals(RAPDU.getSW1(), expectedSw1);
+        assertEquals(RAPDU.getSW2(), expectedSw2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/smartcardio/TerminalFactorySpiTest.java	Thu Jan 01 16:14:01 2015 -0800
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2007, 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
+ * 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 8049021
+ * @summary Test if we can write new provider for smart card
+ * @run main/othervm/policy=policy TerminalFactorySpiTest
+ */
+import java.security.Provider;
+import java.security.Security;
+import java.util.Arrays;
+import javax.smartcardio.CardTerminals;
+import javax.smartcardio.TerminalFactory;
+import javax.smartcardio.TerminalFactorySpi;
+
+public class TerminalFactorySpiTest {
+
+    static boolean callMethod = false;
+
+    public static void main(String[] args) throws Exception {
+        Provider myProvider = new MyProvider();
+        Security.addProvider(myProvider);
+        System.out.println(Arrays.asList(Security.getProviders()));
+
+        TerminalFactory.getInstance("MyType", new Object()).terminals();
+        if (!callMethod) {
+            throw new RuntimeException("Expected engineTerminals() not called");
+        }
+    }
+
+    public static class MyProvider extends Provider {
+
+        MyProvider() {
+            super("MyProvider", 1.0d, "smart Card Example");
+            put("TerminalFactory.MyType", "TerminalFactorySpiTest$MyTerminalFactorySpi");
+        }
+    }
+
+    public static class MyTerminalFactorySpi extends TerminalFactorySpi {
+
+        public MyTerminalFactorySpi(Object ob) {
+        }
+
+        protected CardTerminals engineTerminals() {
+            System.out.println("MyTerminalFactory.engineTerminals()");
+            callMethod = true;
+            return null;
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/smartcardio/policy	Thu Jan 01 16:14:01 2015 -0800
@@ -0,0 +1,4 @@
+grant {
+        permission java.security.SecurityPermission "insertProvider.MyProvider";
+        permission java.security.SecurityPermission "putProviderProperty.MyProvider";
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/rmi/rmic/iiopCompilation/IIOPCompilation.java	Thu Jan 01 16:14:01 2015 -0800
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 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
+ * 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 8065957
+ * @library ../../../../java/rmi/testlibrary
+ * @build TestLibrary
+ * @summary Compiles a PortableRemoteObject with rmic -iiop and ensures that stub and tie classes are generated.
+ * @run main IIOPCompilation
+ * @author Felix Yang
+ *
+ */
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.rmi.PortableRemoteObject;
+
+public class IIOPCompilation {
+
+    public static void main(String args[]) throws IOException, InterruptedException {
+        IIOPCompilation test = new IIOPCompilation();
+        test.doTest();
+    }
+
+    private void doTest() throws IOException, InterruptedException {
+        String className = DummyImpl.class.getName();
+        int exitCode = runRmic(className);
+        if (exitCode != 0) {
+            throw new RuntimeException("Rmic failed. The exit code is " + exitCode);
+        }
+
+        // Check the stub class generated correctly
+        String stubFile = "_" + Dummy.class.getName() + "_Stub.class";
+        assertFileExists(stubFile);
+
+        // Check the tie class generated correctly
+        String tieFile = "_" + className + "_Tie.class";
+        assertFileExists(tieFile);
+    }
+
+    private void assertFileExists(String fileName) throws FileNotFoundException {
+        if (!new File(fileName).exists()) {
+            throw new FileNotFoundException(fileName + " doesn't exist!");
+        }
+    }
+
+    private int runRmic(String classname) throws IOException, InterruptedException {
+        String rmicProgramStr = TestLibrary.getProperty("java.home", "") + File.separator + "bin" + File.separator + "rmic";
+        String testClasses = TestLibrary.getProperty("test.classes", "");
+        List<String> command = Arrays.asList(rmicProgramStr, "-iiop", "-classpath", testClasses, classname);
+        System.out.println("Running command: " + command);
+
+        Process p = null;
+        try {
+            p = new ProcessBuilder(command).inheritIO().start();
+            p.waitFor();
+            return p.exitValue();
+        } finally {
+            if (p != null && p.isAlive()) {
+                p.destroy();
+            }
+        }
+    }
+}
+
+interface Dummy extends java.rmi.Remote {
+}
+
+class DummyImpl extends PortableRemoteObject implements Dummy {
+    public DummyImpl() throws RemoteException {
+    }
+}
--- a/jdk/test/sun/security/provider/DSA/TestDSA2.java	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/test/sun/security/provider/DSA/TestDSA2.java	Thu Jan 01 16:14:01 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -50,7 +50,7 @@
     public static void main(String[] args) throws Exception {
         boolean[] expectedToPass = { true, true, true };
         test(1024, expectedToPass);
-        boolean[] expectedToPass2 = { false, true, true };
+        boolean[] expectedToPass2 = { true, true, true };
         test(2048, expectedToPass2);
     }
 
--- a/jdk/test/tools/pack200/Pack200Test.java	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/test/tools/pack200/Pack200Test.java	Thu Jan 01 16:14:01 2015 -0800
@@ -127,7 +127,7 @@
         // select the jars carefully, adding more jars will increase the
         // testing time, especially for jprt.
         jarList.add(Utils.createRtJar());
-        jarList.add(Utils.locateJar("golden.jar"));
+        jarList.add(Utils.getGoldenJar());
         System.out.println(jarList);
         doPackUnpack();
     }
--- a/jdk/test/tools/pack200/PackTestZip64.java	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/test/tools/pack200/PackTestZip64.java	Thu Jan 01 16:14:01 2015 -0800
@@ -52,7 +52,7 @@
         // make a copy of the test specimen to local directory
         File testFile = new File("tools_java.jar");
         // Add a large number of small files to the golden jar
-        generateLargeJar(testFile, Utils.locateJar("golden.jar"));
+        generateLargeJar(testFile, Utils.getGoldenJar());
 
         List<String> cmdsList = new ArrayList<>();
 
--- a/jdk/test/tools/pack200/RepackTest.java	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/test/tools/pack200/RepackTest.java	Thu Jan 01 16:14:01 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -50,7 +50,7 @@
 
         // make a copy of the test specimen to local directory
         File testFile = new File("src_tools.jar");
-        Utils.copyFile(Utils.locateJar("golden.jar"), testFile);
+        Utils.copyFile(Utils.getGoldenJar(), testFile);
         List<String> cmdsList = new ArrayList<>();
 
         // case 1:
--- a/jdk/test/tools/pack200/TimeStamp.java	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/test/tools/pack200/TimeStamp.java	Thu Jan 01 16:14:01 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -54,7 +54,7 @@
     public static void main(String... args) throws IOException {
 
         // make a local copy of our test file
-        File srcFile = Utils.locateJar("golden.jar");
+        File srcFile = Utils.getGoldenJar();
         File goldenFile = new File("golden.jar");
         Utils.copyFile(srcFile, goldenFile);
 
--- a/jdk/test/tools/pack200/Utils.java	Tue Dec 30 13:19:59 2014 -0800
+++ b/jdk/test/tools/pack200/Utils.java	Thu Jan 01 16:14:01 2015 -0800
@@ -63,7 +63,7 @@
             System.getProperty("os.name").startsWith("Windows");
     static final boolean Is64Bit =
             System.getProperty("sun.arch.data.model", "32").equals("64");
-    static final File   JavaSDK =  new File(JavaHome).getParentFile();
+    static final File   JavaSDK =  new File(JavaHome);
 
     static final String PACK_FILE_EXT   = ".pack";
     static final String JAVA_FILE_EXT   = ".java";
@@ -82,11 +82,7 @@
         if (VerifierJar.exists()) {
             return;
         }
-        File srcDir = new File(TEST_SRC_DIR, VERIFIER_DIR_NAME);
-        if (!srcDir.exists()) {
-            // if not available try one level above
-            srcDir = new File(TEST_SRC_DIR.getParentFile(), VERIFIER_DIR_NAME);
-        }
+        File srcDir = new File(getVerifierDir(), "src");
         List<File> javaFileList = findFiles(srcDir, createFilter(JAVA_FILE_EXT));
         File tmpFile = File.createTempFile("javac", ".tmp");
         XCLASSES.mkdirs();
@@ -115,6 +111,18 @@
             ".");
     }
 
+    private static File getVerifierDir() {
+        File srcDir = new File(TEST_SRC_DIR, VERIFIER_DIR_NAME);
+        if (!srcDir.exists()) {
+            // if not available try one level above
+            srcDir = new File(TEST_SRC_DIR.getParentFile(), VERIFIER_DIR_NAME);
+        }
+        return srcDir;
+    }
+
+    static File getGoldenJar() {
+        return new File(new File(getVerifierDir(), "data"), "golden.jar");
+    }
     static void dirlist(File dir) {
         File[] files = dir.listFiles();
         System.out.println("--listing " + dir.getAbsolutePath() + "---");
@@ -564,7 +572,8 @@
         File rtJar = new File("rt.jar");
         cmdList.clear();
         cmdList.add(getJarCmd());
-        cmdList.add("cvf");
+        // cmdList.add("cvf"); too noisy
+        cmdList.add("cf");
         cmdList.add(rtJar.getName());
         cmdList.add("-C");
         cmdList.add("out");
@@ -574,24 +583,4 @@
         recursiveDelete(new File("out"));
         return rtJar;
     }
-    private static List<File> locaterCache = null;
-    // search the source dir and jdk dir for requested file and returns
-    // the first location it finds.
-    static File locateJar(String name) {
-        try {
-            if (locaterCache == null) {
-                locaterCache = new ArrayList<File>();
-                locaterCache.addAll(findFiles(TEST_SRC_DIR, createFilter(JAR_FILE_EXT)));
-                locaterCache.addAll(findFiles(JavaSDK, createFilter(JAR_FILE_EXT)));
-            }
-            for (File f : locaterCache) {
-                if (f.getName().equals(name)) {
-                    return f;
-                }
-            }
-            throw new IOException("file not found: " + name);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
 }