Number is the superclass of classes
- * BigDecimal, BigInteger,
- * Byte, Double, Float,
- * Integer, Long, and Short.
- *
- * Subclasses of Number must provide methods to convert
- * the represented numeric value to byte, double,
- * float, int, long, and
- * short.
+ * The abstract class {@code Number} is the superclass of platform
+ * classes representing numeric values that are convertible to the
+ * primitive types {@code byte}, {@code double}, {@code float}, {@code
+ * int}, {@code long}, and {@code short}.
+ *
+ * The specific semantics of the conversion from the numeric value of
+ * a particular {@code Number} implementation to a given primitive
+ * type is defined by the {@code Number} implementation in question.
+ *
+ * For platform classes, the conversion is often analogous to a
+ * narrowing primitive conversion or a widening primitive conversion
+ * as defining in The Java™ Language Specification
+ * for converting between primitive types. Therefore, conversions may
+ * lose information about the overall magnitude of a numeric value, may
+ * lose precision, and may even return a result of a different sign
+ * than the input.
+ *
+ * See the documentation of a given {@code Number} implementation for
+ * conversion details.
*
* @author Lee Boynton
* @author Arthur van Hoff
- * @see java.lang.Byte
- * @see java.lang.Double
- * @see java.lang.Float
- * @see java.lang.Integer
- * @see java.lang.Long
- * @see java.lang.Short
+ * @jls 5.1.2 Widening Primitive Conversions
+ * @jls 5.1.3 Narrowing Primitive Conversions
* @since JDK1.0
*/
public abstract class Number implements java.io.Serializable {
/**
- * Returns the value of the specified number as an int.
- * This may involve rounding or truncation.
+ * Returns the value of the specified number as an {@code int},
+ * which may involve rounding or truncation.
*
* @return the numeric value represented by this object after conversion
- * to type int.
+ * to type {@code int}.
*/
public abstract int intValue();
/**
- * Returns the value of the specified number as a long.
- * This may involve rounding or truncation.
+ * Returns the value of the specified number as a {@code long},
+ * which may involve rounding or truncation.
*
* @return the numeric value represented by this object after conversion
- * to type long.
+ * to type {@code long}.
*/
public abstract long longValue();
/**
- * Returns the value of the specified number as a float.
- * This may involve rounding.
+ * Returns the value of the specified number as a {@code float},
+ * which may involve rounding.
*
* @return the numeric value represented by this object after conversion
- * to type float.
+ * to type {@code float}.
*/
public abstract float floatValue();
/**
- * Returns the value of the specified number as a double.
- * This may involve rounding.
+ * Returns the value of the specified number as a {@code double},
+ * which may involve rounding.
*
* @return the numeric value represented by this object after conversion
- * to type double.
+ * to type {@code double}.
*/
public abstract double doubleValue();
/**
- * Returns the value of the specified number as a byte.
- * This may involve rounding or truncation.
+ * Returns the value of the specified number as a {@code byte},
+ * which may involve rounding or truncation.
+ *
+ *
This implementation returns the result of {@link #intValue} cast
+ * to a {@code byte}.
*
* @return the numeric value represented by this object after conversion
- * to type byte.
+ * to type {@code byte}.
* @since JDK1.1
*/
public byte byteValue() {
@@ -96,11 +105,14 @@ public abstract class Number implements java.io.Serializable {
}
/**
- * Returns the value of the specified number as a short.
- * This may involve rounding or truncation.
+ * Returns the value of the specified number as a {@code short},
+ * which may involve rounding or truncation.
+ *
+ *
This implementation returns the result of {@link #intValue} cast
+ * to a {@code short}.
*
* @return the numeric value represented by this object after conversion
- * to type
+ * The RacingThreadsTest class uses three internal barriers to
+ * coordinate actions between the DriverThread and the WorkerThreads.
+ * These barriers should not be managed or used by your test's
+ * subclass and are only mentioned here to provide clarity about
+ * interactions between the DriverThread and the WorkerThreads.
+ * The following transaction diagram shows when the different
+ * RacingThreadsTest methods are called relative to the different
+ * barriers:
+ *
+ * short.
+ * to type {@code short}.
* @since JDK1.1
*/
public short shortValue() {
diff --git a/jdk/src/share/classes/java/lang/Short.java b/jdk/src/share/classes/java/lang/Short.java
index 5ff010da00e..15a00e17ff6 100644
--- a/jdk/src/share/classes/java/lang/Short.java
+++ b/jdk/src/share/classes/java/lang/Short.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, 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
@@ -321,8 +321,9 @@ public final class Short extends Number implements Comparable
+ *
+ *
+ * The RacingThreadsTest class provides many methods that can be
+ * overridden in order to provide test specific semantics at each
+ * identified test execution point. At a minimum, your test's
+ * subclass needs to override the
+ * "void executeRace(WorkerThread)"
+ * method in order to exercise your race condition and it needs to
+ * override the
+ * "void checkRaceResults(DriverThread)"
+ * method in order to check the results of the race. Your
+ * checkRaceResults() method should call the
+ * "int incAndGetFailCnt()"
+ * method when it detects a failure. It can also call the
+ * "void unexpectedException(Thread, Exception)"
+ * method if it detects an unexpected exception; this will cause
+ * an error message to be output and the failure count to be
+ * incremented. When the RacingThreadsTest.runTest() method is
+ * done running the races, if there is a non-zero failure count,
+ * then a RuntimeException will be thrown.
+ *
+ * public class MyRacingThreadsTest extends RacingThreadsTest
+ *
+ * DriverThread WorkerThread-0 WorkerThread-N-1
+ * --------------------- --------------------- ---------------------
+ * run(workers)
+ * oneTimeDriverInit()
+ * <start WorkerThreads> run() run()
+ * <top of race loop> : :
+ * perRaceDriverInit() oneTimeWorkerInit() oneTimeWorkerInit()
+ * : <top of race loop> <top of race loop>
+ * : perRaceWorkerInit() perRaceWorkerInit()
+ * startBarrier startBarrier startBarrier
+ * : executeRace() executeRace()
+ * finishBarrier finishBarrier finishBarrier
+ * checkRaceResults() : :
+ * resetBarrier resetBarrier resetBarrier
+ * perRaceDriverEpilog() perRaceWorkerEpilog() perRaceWorkerEpilog()
+ * <repeat race or done> <repeat race or done> <repeat race or done>
+ * : oneTimeWorkerEpilog() oneTimeWorkerEpilog()
+ * <join WorkerThreads> <WorkerThread ends> <WorkerThread ends>
+ * oneTimeDriverEpilog()
+ * <DriverThread ends>
+ *
+ *
+ * Just to be clear about the parallel parts of this infrastructure:
+ *
+ *
+ *
+ * Once the DriverThread has ended, the RacingThreadsTest.runTest()
+ * method checks the failure count. If there were no failures, then
+ * a "Test PASSed" message is printed. Otherwise, the failure count
+ * is printed, a "Test FAILed" message is printed and a RuntimeException
+ * is thrown.
+ */
+public class RacingThreadsTest {
+ /**
+ * name of the test
+ */
+ public final String TEST_NAME;
+ /**
+ * maximum number of test iterations (race loops)
+ */
+ public final int N_LOOPS;
+ /**
+ * the maximum number of seconds to execute the test loop
+ */
+ public final int N_SECS;
+ /**
+ * number of WorkerThreads
+ */
+ public final int N_THREADS;
+
+ /**
+ * Creates a test with the specified name and the specified number
+ * of WorkerThreads that execute the test code in parallel up to
+ * n_loops iterations or n_secs seconds. The RacingThreadsTest
+ * class is extended in order to provide the test specific variables
+ * and/or code.
+ * @param name the name of the test
+ * @param n_threads the number of WorkerThreads
+ * @param n_loops the maximum number of test iterations
+ * @param n_secs the maximum number of seconds to execute the test loop
+ */
+ RacingThreadsTest(String name, int n_threads, int n_loops, int n_secs) {
+ TEST_NAME = name;
+ N_THREADS = n_threads;
+ N_LOOPS = n_loops;
+ N_SECS = n_secs;
+
+ finishBarrier = new CyclicBarrier(N_THREADS + 1);
+ resetBarrier = new CyclicBarrier(N_THREADS + 1);
+ startBarrier = new CyclicBarrier(N_THREADS + 1);
+ }
+
+
+ /**
+ * Entry point for exercising the RacingThreadsTest class.
+ */
+ public static void main(String[] args) {
+ // a dummy test:
+ // - 2 threads
+ // - 3 loops
+ // - 2 seconds
+ // - standard DriverThread
+ // - standard WorkerThread
+ RacingThreadsTest test = new RacingThreadsTest("dummy", 2, 3, 2);
+ DriverThread driver = new DriverThread(test);
+ WorkerThread[] workers = new WorkerThread[2];
+ for (int i = 0; i < workers.length; i++) {
+ workers[i] = new WorkerThread(i, test);
+ }
+ test.runTest(driver, workers);
+ }
+
+ private static volatile boolean done = false; // test done flag
+
+ // # of fails; AtomicInteger since any WorkerThread can increment
+ private static final AtomicInteger failCnt = new AtomicInteger();
+ // # of loops; volatile is OK since only DriverThread increments
+ // but using AtomicInteger for consistency
+ private static final AtomicInteger loopCnt = new AtomicInteger();
+ private static boolean verbose
+ = Boolean.getBoolean("RacingThreadsTest.verbose");
+
+ // barriers for starting, finishing and resetting the race
+ private final CyclicBarrier finishBarrier;
+ private final CyclicBarrier resetBarrier;
+ private final CyclicBarrier startBarrier;
+
+
+ /**
+ * Get current done flag value.
+ * @return the current done flag value
+ */
+ public boolean getDone() {
+ return done;
+ }
+
+ /**
+ * Set done flag to specified value.
+ * @param v the new done flag value
+ */
+ public void setDone(boolean v) {
+ done = v;
+ }
+
+ /**
+ * Get current failure counter value.
+ * @return the current failure count
+ */
+ public int getFailCnt() {
+ return failCnt.get();
+ }
+
+ /**
+ * Increment and get current failure counter value.
+ * @return the current failure count after incrementing
+ */
+ public int incAndGetFailCnt() {
+ return failCnt.incrementAndGet();
+ }
+
+ /**
+ * Get current loop counter value.
+ * @return the current loop count
+ */
+ public int getLoopCnt() {
+ return loopCnt.get();
+ }
+
+ /**
+ * Increment and get current loop counter value.
+ * @return the current loop count after incrementing
+ */
+ public int incAndGetLoopCnt() {
+ return loopCnt.incrementAndGet();
+ }
+
+ /**
+ * Get current verbose flag value.
+ * @return the current verbose flag value
+ */
+ public boolean getVerbose() {
+ return verbose;
+ }
+
+ /**
+ * Set verbose flag to specified value.
+ * @param v the new verbose flag value
+ */
+ public void setVerbose(boolean v) {
+ verbose = v;
+ }
+
+ /**
+ * Run the test with the specified DriverThread and the
+ * specified WorkerThreads.
+ * @param driver the DriverThread for running the test
+ * @param workers the WorkerThreads for executing the race
+ * @exception RuntimeException the test has failed
+ */
+ public void runTest(DriverThread driver, WorkerThread[] workers) {
+ driver.run(workers);
+
+ try {
+ driver.join();
+ } catch (InterruptedException ie) {
+ unexpectedException(Thread.currentThread(), ie);
+ // fall through to test failed below
+ }
+
+ if (failCnt.get() == 0) {
+ System.out.println(TEST_NAME + ": Test PASSed.");
+ } else {
+ System.out.println(TEST_NAME + ": failCnt=" + failCnt.get());
+ System.out.println(TEST_NAME + ": Test FAILed.");
+ throw new RuntimeException("Test Failed");
+ }
+ }
+
+ /**
+ * Helper method for reporting an unexpected Exception and
+ * calling incAndGetFailCnt();
+ * @param t the Thread that caught the exception
+ * @param e the Exception that was caught
+ */
+ public void unexpectedException(Thread t, Exception e) {
+ System.err.println(t.getName() + ": ERROR: unexpected exception: " + e);
+ incAndGetFailCnt(); // ignore return
+ }
+
+
+ // The following methods are typically overridden by the subclass
+ // of RacingThreadsTest to provide test specific semantics at each
+ // identified test execution point:
+
+ /**
+ * Initialize 1-time items for the DriverThread.
+ * Called by the DriverThread before WorkerThreads are started.
+ * @param dt the DriverThread
+ */
+ public void oneTimeDriverInit(DriverThread dt) {
+ if (verbose)
+ System.out.println(dt.getName() + ": oneTimeDriverInit() called");
+ }
+
+ /**
+ * Initialize 1-time items for a WorkerThread. Called by a
+ * WorkerThread after oneTimeDriverInit() and before the
+ * WorkerThread checks in with startBarrier. May execute in
+ * parallel with perRaceDriverInit() or with another
+ * WorkerThread's oneTimeWorkerInit() call or another
+ * WorkerThread's perRaceWorkerInit() call.
+ * @param wt the WorkerThread
+ */
+ public void oneTimeWorkerInit(WorkerThread wt) {
+ if (verbose)
+ System.out.println(wt.getName() + ": oneTimeWorkerInit() called");
+ }
+
+ /**
+ * Initialize per-race items for the DriverThread. Called by the
+ * DriverThread before it checks in with startBarrier. May execute
+ * in parallel with oneTimeWorkerInit() and perRaceWorkerInit()
+ * calls. After any race except for the last race, this method may
+ * execute in parallel with perRaceWorkerEpilog().
+ * @param dt the DriverThread
+ */
+ public void perRaceDriverInit(DriverThread dt) {
+ if (verbose)
+ System.out.println(dt.getName() + ": perRaceDriverInit() called");
+ }
+
+ /**
+ * Initialize per-race items for a WorkerThread. Called by each
+ * WorkerThread before it checks in with startBarrier. On the first
+ * call, this method may execute in parallel with another
+ * WorkerThread's oneTimeWorkerInit() call. On any call, this method
+ * may execute in parallel with perRaceDriverInit() or another
+ * WorkerThread's perRaceWorkerInit() call. After any race except
+ * for the last race, this method may execute in parallel with
+ * perRaceDriverEpilog() or another WorkerThread's
+ * perRaceWorkerEpilog() call.
+ * @param wt the WorkerThread
+ */
+ public void perRaceWorkerInit(WorkerThread wt) {
+ if (verbose)
+ System.out.println(wt.getName() + ": perRaceWorkerInit() called");
+ }
+
+ /**
+ * Execute the race in a WorkerThread. Called by each WorkerThread
+ * after it has been released from startBarrier.
+ * @param wt the WorkerThread
+ */
+ public void executeRace(WorkerThread wt) {
+ if (verbose)
+ System.out.println(wt.getName() + ": executeRace() called");
+ }
+
+ /**
+ * Check race results in the DriverThread. Called by the DriverThread
+ * after it has been released from finishBarrier and before the
+ * DriverThread checks in with resetBarrier.
+ * @param dt the DriverThread
+ */
+ public void checkRaceResults(DriverThread dt) {
+ if (verbose)
+ System.out.println(dt.getName() + ": checkRaceResults() called");
+ }
+
+ /**
+ * Handle end-of-race items for the DriverThread. Called by the
+ * DriverThread after it has been released from resetBarrier and
+ * before the DriverThread checks in again with startBarrier. Can
+ * execute in parallel with perRaceWorkerEpilog(). If this is not
+ * the last race, can execute in parallel with perRaceWorkerInit().
+ * If this is the last race, can execute in parallel with
+ * oneTimeWorkerEpilog().
+ * @param dt the DriverThread
+ */
+ public void perRaceDriverEpilog(DriverThread dt) {
+ if (verbose)
+ System.out.println(dt.getName() + ": perRaceDriverEpilog() called");
+ }
+
+ /**
+ * Handle end-of-race items for a WorkerThread. Called by each
+ * WorkerThread after it has been released from resetBarrier and
+ * before the WorkerThread checks in again with startBarrier.
+ * Can execute in parallel with perRaceDriverEpilog() or another
+ * WorkerThread's perRaceWorkerEpilog() call. If this is not the
+ * last race, can execute in parallel with perRaceDriverInit(),
+ * or another WorkerThread's perRaceWorkerInit() call. If this
+ * is the last race, can execute in parallel with another
+ * WorkerThread's oneTimeWorkerEpilog() call.
+ * @param wt the WorkerThread
+ */
+ public void perRaceWorkerEpilog(WorkerThread wt) {
+ if (verbose)
+ System.out.println(wt.getName() + ": perRaceWorkerEpilog() called");
+ }
+
+ /**
+ * Handle end-of-test items for a WorkerThread. Called by each
+ * WorkerThread after it has detected that all races are done and
+ * before oneTimeDriverEpilog() is called. Can execute in parallel
+ * with perRaceDriverEpilog(), with another WorkerThread's
+ * perRaceWorkerEpilog() call or with another WorkerThread's
+ * oneTimeWorkerEpilog() call.
+ * @param wt the WorkerThread
+ */
+ public void oneTimeWorkerEpilog(WorkerThread wt) {
+ if (verbose)
+ System.out.println(wt.getName() + ": oneTimeWorkerEpilog() called");
+ }
+
+ /**
+ * Handle end-of-test items for the DriverThread. Called by the
+ * DriverThread after all the WorkerThreads have called
+ * oneTimeWorkerEpilog().
+ * @param dt the DriverThread
+ */
+ public void oneTimeDriverEpilog(DriverThread dt) {
+ if (verbose)
+ System.out.println(dt.getName() + ": oneTimeDriverEpilog() called");
+ }
+
+
+ /**
+ * DriverThread for executing the test.
+ */
+ public static class DriverThread extends Thread {
+ private final RacingThreadsTest test;
+
+ /**
+ * Create the test DriverThread that manages all the WorkerThreads.
+ * The DriverThread class can be extended to provide test specific
+ * variables and/or code. However, that is typically done in the
+ * subclass of RacingThreadsTest.
+ * @parameter test the RacingThreadsTest being run
+ */
+ DriverThread(RacingThreadsTest test) {
+ super("DriverThread");
+ this.test = test;
+ }
+
+ private void run(WorkerThread[] workers) {
+ System.out.println(getName() + ": is starting.");
+ System.out.println(getName() + ": # WorkerThreads: " + test.N_THREADS);
+ System.out.println(getName() + ": max # loops: " + test.N_LOOPS);
+ System.out.println(getName() + ": max # secs: " + test.N_SECS);
+
+ // initialize 1-time items for the DriverThread
+ test.oneTimeDriverInit(this);
+
+ // start all the threads
+ for (int i = 0; i < workers.length; i++) {
+ workers[i].start();
+ }
+
+ // All WorkerThreads call oneTimeWorkerInit() and
+ // perRaceWorkerInit() on the way to startBarrier.
+
+ long endTime = System.currentTimeMillis() + test.N_SECS * 1000;
+
+ for (; !test.getDone() && test.getLoopCnt() < test.N_LOOPS;
+ test.incAndGetLoopCnt()) {
+
+ if (test.getVerbose() && (test.N_LOOPS < 10 ||
+ (test.getLoopCnt() % (test.N_LOOPS / 10)) == 0)) {
+ System.out.println(getName() + ": race loop #"
+ + test.getLoopCnt());
+ }
+
+ // initialize per-race items for the DriverThread
+ test.perRaceDriverInit(this);
+
+ try {
+ // we've setup the race so start it when all
+ // WorkerThreads get to the startBarrier
+ test.startBarrier.await();
+ } catch (BrokenBarrierException bbe) {
+ test.unexpectedException(this, bbe);
+ return;
+ } catch (InterruptedException ie) {
+ test.unexpectedException(this, ie);
+ return;
+ }
+
+ // All WorkerThreads are racing via executeRace()
+ // at this point
+
+ // wait for all threads to finish the race
+ try {
+ test.finishBarrier.await();
+ } catch (BrokenBarrierException bbe) {
+ test.unexpectedException(this, bbe);
+ return;
+ } catch (InterruptedException ie) {
+ test.unexpectedException(this, ie);
+ return;
+ }
+ // All WorkerThreads are heading to resetBarrier at this
+ // point so we can check the race results before we reset
+ // for another race (or bail because we are done).
+
+ test.checkRaceResults(this);
+
+ if (test.getLoopCnt() + 1 >= test.N_LOOPS ||
+ System.currentTimeMillis() >= endTime) {
+ // This is the last loop or we're out of time.
+ // Let test threads know we are done before we release
+ // them from resetBarrier
+ test.setDone(true);
+ }
+
+ // release the WorkerThreads from resetBarrier
+ try {
+ test.resetBarrier.await();
+ } catch (BrokenBarrierException bbe) {
+ test.unexpectedException(this, bbe);
+ return;
+ } catch (InterruptedException ie) {
+ test.unexpectedException(this, ie);
+ return;
+ }
+
+ // All WorkerThreads call perRaceWorkerEpilog(). If
+ // this is not the last loop, then all WorkerThreads
+ // will also call perRaceWorkerInit() on the way to
+ // startBarrier. If this is the last loop, then all
+ // WorkerThreads will call oneTimeWorkerEpilog() on
+ // their way to ending.
+
+ // handle end-of-race items for the DriverThread
+ test.perRaceDriverEpilog(this);
+ }
+
+ System.out.println(getName() + ": completed " + test.getLoopCnt()
+ + " race loops.");
+ if (test.getLoopCnt() < test.N_LOOPS) {
+ System.out.println(getName() + ": race stopped @ " + test.N_SECS
+ + " seconds.");
+ }
+
+ for (int i = 0; i < workers.length; i++) {
+ try {
+ workers[i].join();
+ } catch (InterruptedException ie) {
+ test.unexpectedException(this, ie);
+ return;
+ }
+ }
+
+ // handle end-of-test items for the DriverThread
+ test.oneTimeDriverEpilog(this);
+
+ System.out.println(getName() + ": is done.");
+ }
+ }
+
+
+ /**
+ * WorkerThread for executing the race.
+ */
+ public static class WorkerThread extends Thread {
+ private final RacingThreadsTest test;
+ private final int workerNum;
+
+ /**
+ * Creates WorkerThread-N that executes the test code. The
+ * WorkerThread class can be extended to provide test thread
+ * specific variables and/or code.
+ * @param workerNum the number for the new WorkerThread
+ * @parameter test the RacingThreadsTest being run
+ */
+ WorkerThread(int workerNum, RacingThreadsTest test) {
+ super("WorkerThread-" + workerNum);
+ this.test = test;
+ this.workerNum = workerNum;
+ }
+
+ /**
+ * get the WorkerThread's number
+ * @return the WorkerThread's number
+ */
+ public int getWorkerNum() {
+ return workerNum;
+ }
+
+ /**
+ * Run the race in a WorkerThread.
+ */
+ public void run() {
+ System.out.println(getName() + ": is running.");
+
+ // initialize 1-time items for the WorkerThread
+ test.oneTimeWorkerInit(this);
+
+ while (!test.getDone()) {
+ // initialize per-race items for the WorkerThread
+ test.perRaceWorkerInit(this);
+
+ try {
+ test.startBarrier.await(); // wait for race to start
+ } catch (BrokenBarrierException bbe) {
+ test.unexpectedException(this, bbe);
+ return;
+ } catch (InterruptedException ie) {
+ test.unexpectedException(this, ie);
+ return;
+ }
+
+ // execute the race for the WorkerThread
+ test.executeRace(this);
+
+ try {
+ test.finishBarrier.await(); // this thread is done
+ } catch (BrokenBarrierException bbe) {
+ test.unexpectedException(this, bbe);
+ return;
+ } catch (InterruptedException ie) {
+ test.unexpectedException(this, ie);
+ return;
+ }
+
+ try {
+ test.resetBarrier.await(); // wait for race to reset
+ } catch (BrokenBarrierException bbe) {
+ test.unexpectedException(this, bbe);
+ return;
+ } catch (InterruptedException ie) {
+ test.unexpectedException(this, ie);
+ return;
+ }
+
+ // handle end-of-race items for the WorkerThread
+ test.perRaceWorkerEpilog(this);
+ }
+
+ // handle end-of-test items for the WorkerThread
+ test.oneTimeWorkerEpilog(this);
+
+ System.out.println(getName() + ": is ending.");
+ }
+ }
+}
diff --git a/jdk/test/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecException.java b/jdk/test/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecException.java
index 7dc9128598e..e3ecb33d91c 100644
--- a/jdk/test/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecException.java
+++ b/jdk/test/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -23,7 +23,8 @@
/**
* @test
- * @bug 4508341
+ * @bug 4508341 7055362
+ * @library ../../../java/security/testlibrary
* @summary Test the error conditions of
* EncryptedPrivateKeyInfo.getKeySpec(...) methods.
* @author Valerie Peng
@@ -97,7 +98,16 @@ public class GetKeySpecException {
}
}
- public static void main(String[] argv) throws Exception {
+ public static void main(String[] args) throws Exception {
+ ProvidersSnapshot snapshot = ProvidersSnapshot.create();
+ try {
+ main0(args);
+ } finally {
+ snapshot.restore();
+ }
+ }
+
+ public static void main0(String[] args) throws Exception {
if ((GOOD_PARAMS == null) || (BAD_PARAMS == null)) {
throw new Exception("Static parameter generation failed");
}
diff --git a/jdk/test/javax/crypto/JceSecurity/SunJCE_BC_LoadOrdering.java b/jdk/test/javax/crypto/JceSecurity/SunJCE_BC_LoadOrdering.java
index 434b3d3f039..c2991bbcc07 100644
--- a/jdk/test/javax/crypto/JceSecurity/SunJCE_BC_LoadOrdering.java
+++ b/jdk/test/javax/crypto/JceSecurity/SunJCE_BC_LoadOrdering.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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
@@ -23,7 +23,8 @@
/*
* @test
- * @bug 6377058
+ * @bug 6377058 7055362
+ * @library ../../../java/security/testlibrary
* @summary SunJCE depends on sun.security.provider.SignatureImpl
* behaviour, BC can't load into 1st slot.
* @author Brad R. Wetmore
@@ -35,7 +36,16 @@ import java.io.*;
public class SunJCE_BC_LoadOrdering {
- public static void main(String args[]) throws Exception {
+ public static void main(String[] args) throws Exception {
+ ProvidersSnapshot snapshot = ProvidersSnapshot.create();
+ try {
+ main0(args);
+ } finally {
+ snapshot.restore();
+ }
+ }
+
+ public static void main0(String[] args) throws Exception {
/*
* Generate a random key, and encrypt the data
*/
diff --git a/jdk/test/sun/security/krb5/tools/ktmissing.sh b/jdk/test/sun/security/krb5/tools/ktmissing.sh
new file mode 100644
index 00000000000..6410abab7fa
--- /dev/null
+++ b/jdk/test/sun/security/krb5/tools/ktmissing.sh
@@ -0,0 +1,51 @@
+#
+# Copyright (c) 2011, 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 7043737
+# @summary klist does not detect non-existing keytab
+# @run shell ktmissing.sh
+#
+
+OS=`uname -s`
+case "$OS" in
+ CYGWIN* )
+ FS="/"
+ ;;
+ Windows_* )
+ FS="\\"
+ ;;
+ * )
+ FS="/"
+ echo "Unsupported system!"
+ exit 0;
+ ;;
+esac
+
+${TESTJAVA}${FS}bin${FS}klist -k this_file_does_not_exist && exit 1
+
+echo ABC > this_is_not_a_keytab
+
+${TESTJAVA}${FS}bin${FS}klist -k this_is_not_a_keytab && exit 2
+
+exit 0
diff --git a/jdk/test/sun/security/pkcs11/fips/ClientJSSEServerJSSE.java b/jdk/test/sun/security/pkcs11/fips/ClientJSSEServerJSSE.java
index 5362f59071e..e32febeecbe 100644
--- a/jdk/test/sun/security/pkcs11/fips/ClientJSSEServerJSSE.java
+++ b/jdk/test/sun/security/pkcs11/fips/ClientJSSEServerJSSE.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, 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,10 +25,10 @@
* @test
* @bug 6313675 6323647
* @summary Verify that all ciphersuites work in FIPS mode
+ * @library ..
* @ignore JSSE supported cipher suites are changed with CR 6916074,
* need to update this test case in JDK 7 soon
* @author Andreas Sterbenz
- * @library ..
*/
import java.security.*;
diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/InterruptedIO.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/InterruptedIO.java
deleted file mode 100644
index e87ed351ef7..00000000000
--- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/InterruptedIO.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (c) 2001, 2003, 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 4393337
- * @summary [TEST RUNS ON SOLARIS ONLY] Throw an InterruptedIOException
- * when read on SSLSocket is * interrupted.
- */
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.Socket;
-import javax.net.ssl.*;
-
-/**
- * Interrupts an SSL socket that is blocked on a read. An
- * InterruptedIOException will be thrown and handled within the test if the
- * test completes correctly.
- */
-
-public class InterruptedIO {
-
- /**
- * Starts a client and a server thread. Gives the client enough time to
- * block in a read, then interrupts it.
- */
- public static void main(String[] args) throws Exception {
-
- String reason =
- "Test valid only on SunOS.\n" +
- "=========================\n" +
- "It was determined that Thread.interrupt() could \n" +
- "not be reliably return InterruptedIOException \n" +
- "on non-Solaris implementations. Thread.interrupt() \n" +
- "API was updated in merlin (JDK 1.4) to reflect this.\n";
- System.out.println(reason);
-
- String osName = System.getProperty("os.name", "");
- if (!osName.equalsIgnoreCase("SunOS")) {
- System.out.println("Ignoring test on '" + osName + "'");
- return;
- }
-
- String testRoot = System.getProperty("test.src", ".");
- System.setProperty("javax.net.ssl.keyStore",
- testRoot +
- "/../../../../../../../etc/keystore");
- System.setProperty("javax.net.ssl.keyStorePassword",
- "passphrase");
- System.setProperty("javax.net.ssl.trustStore",
- testRoot +
- "/../../../../../../../etc/truststore");
-
- Server server = new Server();
- server.start();
-
- Client client = new Client(server.getPort()); // Will do handshake
- client.start(); // Will block in read
-
- // sleep for 5 seconds
- System.out.println("Main - Pausing for 5 seconds...");
- Thread.sleep(5 * 1000);
-
- System.out.println("Main - Interrupting client reader thread");
- client.interrupt();
- client.join(); // Wait for client thread to complete
-
- if (client.failed())
- throw new Exception("Main - Test InterruptedIO failed "
- + "on client side.");
- else
- System.out.println("Main - Test InterruptedIO successful!");
- }
-
- /**
- * Accepts an incoming SSL Connection. Then blocks in a read.
- */
- static class Server extends Thread {
-
- private SSLServerSocket ss;
-
- public Server() throws Exception {
- ss = (SSLServerSocket) SSLServerSocketFactory.getDefault().
- createServerSocket(0);
- }
-
- public int getPort() {
- return ss.getLocalPort();
- }
-
- public void run() {
- try {
- System.out.println("Server - Will accept connections on port "
- + getPort());
- Socket s = ss.accept();
- InputStream is = s.getInputStream();
- // We want the client to block so deadlock
- is.read();
- } catch (IOException e) {
- // Happens when client closese connection.
- // If an error occurs, Client will detect problem
- }
- }
- }
-
- /**
- * Initiates an SSL connection to a server. Then blocks in a read. It
- * should be interrupted by another thread. An InterruptedIOException
- * is expected to be thrown.
- */
- static class Client extends Thread {
-
- private SSLSocket socket;
- private InputStream inStream;
- private boolean failed = false;
-
- public Client(int port) throws Exception {
- socket = (SSLSocket) SSLSocketFactory.getDefault().
- createSocket("localhost", port);
- inStream = socket.getInputStream();
- System.out.println("Client - "
- + "Connected to: localhost" + ":" + port);
- System.out.println("Client - "
- + "Doing SSL Handshake...");
- socket.startHandshake(); // Asynchronous call
- System.out.println("Client - Done with SSL Handshake");
- }
-
- public void run() {
-
- try {
- System.out.println("Client - Reading from input stream ...");
- if (inStream.read() == -1) {
- System.out.println("Client - End-of-stream detected");
- failed = true;
- }
- } catch (InterruptedIOException e) {
- System.out.println("Client - "
- + "As expected, InterruptedIOException "
- + "was thrown. Message: "
- + e.getMessage());
- } catch (Exception e) {
- System.out.println("Client - Unexpected exception:");
- e.printStackTrace();
- failed = true;
- } finally {
- try {
- socket.close();
- } catch (IOException e) {
- // Squelch it
- }
- }
- }
-
- public boolean failed() {
- return failed;
- }
-
- }
-
-}
diff --git a/jdk/test/tools/launcher/ExecutionEnvironment.java b/jdk/test/tools/launcher/ExecutionEnvironment.java
index fec9f6a0ba8..720df5e126e 100644
--- a/jdk/test/tools/launcher/ExecutionEnvironment.java
+++ b/jdk/test/tools/launcher/ExecutionEnvironment.java
@@ -299,8 +299,8 @@ public class ExecutionEnvironment {
if (TestHelper.is32Bit) {
tr = TestHelper.doExec(TestHelper.javaCmd, "-client", "-version");
- if (!tr.matches("Java.*Client VM.*")) {
- System.out.println("FAIL: the expected vm -client did launch");
+ if (!tr.matches(".*Client VM.*")) {
+ System.out.println("FAIL: the expected vm -client did not launch");
System.out.println(tr);
errors++;
} else {
@@ -308,8 +308,8 @@ public class ExecutionEnvironment {
}
}
tr = TestHelper.doExec(TestHelper.javaCmd, "-server", "-version");
- if (!tr.matches("Java.*Server VM.*")) {
- System.out.println("FAIL: the expected vm -server did launch");
+ if (!tr.matches(".*Server VM.*")) {
+ System.out.println("FAIL: the expected vm -server did not launch");
System.out.println(tr);
errors++;
} else {
diff --git a/jdk/test/tools/launcher/VersionCheck.java b/jdk/test/tools/launcher/VersionCheck.java
index a1bca7593d1..acef7bbea00 100644
--- a/jdk/test/tools/launcher/VersionCheck.java
+++ b/jdk/test/tools/launcher/VersionCheck.java
@@ -132,7 +132,7 @@ public class VersionCheck {
StringBuilder out = new StringBuilder();
// remove the HotSpot line
for (String x : alist) {
- if (!x.contains("HotSpot")) {
+ if (!x.matches(".*Client.*VM.*|.*Server.*VM.*")) {
out = out.append(x + "\n");
}
}