This commit is contained in:
Phil Race 2014-12-20 10:11:14 -08:00
commit 22f59ce99e
55 changed files with 831 additions and 357 deletions

View File

@ -758,8 +758,8 @@ class TzdbZoneRulesProvider {
if (endYear == Year.MAX_VALUE) {
endYear = startYear;
lastRules.add(new TransRule(endYear, rule));
lastRulesStartYear = Math.max(startYear, lastRulesStartYear);
}
lastRulesStartYear = Math.max(startYear, lastRulesStartYear);
} else {
if (endYear == Year.MAX_VALUE) {
//endYear = zoneEnd.getYear();

View File

@ -2345,7 +2345,7 @@ public class ObjectInputStream
skipped++;
n--;
}
return skipped + skip(n);
return skipped + in.skip(n);
}
public int available() throws IOException {

View File

@ -43,9 +43,8 @@ import java.util.Locale;
* supported by the Java runtime environment itself.
*
* <h3>Packaging of Locale Sensitive Service Provider Implementations</h3>
* Implementations of these locale sensitive services are packaged using the
* <a href="../../../../technotes/guides/extensions/index.html">Java Extension Mechanism</a>
* as installed extensions. A provider identifies itself with a
* Implementations of these locale sensitive services can be made available
* by adding them to the application's class path. A provider identifies itself with a
* provider-configuration file in the resource directory META-INF/services,
* using the fully qualified provider interface class name as the file name.
* The file should contain a list of fully-qualified concrete provider class names,

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
# 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
@ -46,11 +46,7 @@ java.launcher.opt.footer =\ -cp <class search path of directories and zip
\ -verbose:[class|gc|jni]\n\
\ enable verbose output\n\
\ -version print product version and exit\n\
\ -version:<value>\n\
\ require the specified version to run\n\
\ -showversion print product version and continue\n\
\ -jre-restrict-search | -no-jre-restrict-search\n\
\ include/exclude user private JREs in the version search\n\
\ -? -help print this help message\n\
\ -X print help on non-standard options\n\
\ -ea[:<packagename>...|:<classname>]\n\

View File

@ -77,7 +77,8 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
public P run() {
P delegate = null;
for (LocaleServiceProvider provider : ServiceLoader.loadInstalled(c)) {
for (LocaleServiceProvider provider :
ServiceLoader.load(c, ClassLoader.getSystemClassLoader())) {
if (delegate == null) {
try {
delegate =

View File

@ -168,6 +168,13 @@ static jlong threadStackSize = 0; /* stack size of the new thread */
static jlong maxHeapSize = 0; /* max heap size */
static jlong initialHeapSize = 0; /* inital heap size */
/*
* A minimum -Xss stack size suitable for all platforms.
*/
#ifndef STACK_SIZE_MINIMUM
#define STACK_SIZE_MINIMUM (32 * KB)
#endif
/*
* Entry point.
*/
@ -766,6 +773,14 @@ AddOption(char *str, void *info)
jlong tmp;
if (parse_size(str + 4, &tmp)) {
threadStackSize = tmp;
/*
* Make sure the thread stack size is big enough that we won't get a stack
* overflow before the JVM startup code can check to make sure the stack
* is big enough.
*/
if (threadStackSize < STACK_SIZE_MINIMUM) {
threadStackSize = STACK_SIZE_MINIMUM;
}
}
}

View File

@ -55,9 +55,8 @@ recognition.</P>
<H4><A NAME="Packaging"></A>Packaging Input Methods</H4>
<P>Input methods are packaged as installed extensions, as specified
by the <A HREF="../../../../../technotes/guides/extensions/index.html">Extension
Mechanism</A>. The main JAR file of an input method must contain the
<P>Input methods can be made available by adding them to the application's
class path. The main JAR file of an input method must contain the
file:</P>
<PRE> META-INF/services/java.awt.im.spi.InputMethodDescriptor</PRE>

View File

@ -259,7 +259,8 @@ class ExecutableInputMethodManager extends InputMethodManager
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Object run() {
for (InputMethodDescriptor descriptor :
ServiceLoader.loadInstalled(InputMethodDescriptor.class)) {
ServiceLoader.load(InputMethodDescriptor.class,
ClassLoader.getSystemClassLoader())) {
ClassLoader cl = descriptor.getClass().getClassLoader();
javaInputMethodLocatorList.add(new InputMethodLocator(descriptor, cl, null));
}

View File

@ -29,7 +29,6 @@ import java.util.Iterator;
import java.util.ServiceLoader;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.PropertyPermission;
import java.util.concurrent.CopyOnWriteArrayList;
import sun.reflect.CallerSensitive;
import sun.reflect.Reflection;
@ -89,6 +88,8 @@ public class DriverManager {
private static volatile java.io.PrintStream logStream = null;
// Used in println() to synchronize logWriter
private final static Object logSync = new Object();
// Used in ensureDriversInitialized() to synchronize driversInitialized
private final static Object lockForInitDrivers = new Object();
private static volatile boolean driversInitialized;
private static final String JDBC_DRIVERS_PROPERTY = "jdbc.drivers";
@ -280,11 +281,13 @@ public class DriverManager {
println("DriverManager.getDriver(\"" + url + "\")");
ensureDriversInitialized();
Class<?> callerClass = Reflection.getCallerClass();
// Walk through the loaded registeredDrivers attempting to locate someone
// who understands the given URL.
for (DriverInfo aDriver : getRegisteredDrivers()) {
for (DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if (isDriverAllowed(aDriver.driver, callerClass)) {
@ -384,8 +387,7 @@ public class DriverManager {
* @see SecurityManager#checkPermission
*/
@CallerSensitive
public static synchronized void deregisterDriver(Driver driver)
throws SQLException {
public static void deregisterDriver(Driver driver) throws SQLException {
if (driver == null) {
return;
}
@ -398,22 +400,24 @@ public class DriverManager {
println("DriverManager.deregisterDriver: " + driver);
DriverInfo aDriver = new DriverInfo(driver, null);
if (registeredDrivers.contains(aDriver)) {
if (isDriverAllowed(driver, Reflection.getCallerClass())) {
DriverInfo di = registeredDrivers.get(registeredDrivers.indexOf(aDriver));
// If a DriverAction was specified, Call it to notify the
// driver that it has been deregistered
if (di.action() != null) {
di.action().deregister();
}
registeredDrivers.remove(aDriver);
synchronized (lockForInitDrivers) {
if (registeredDrivers.contains(aDriver)) {
if (isDriverAllowed(driver, Reflection.getCallerClass())) {
DriverInfo di = registeredDrivers.get(registeredDrivers.indexOf(aDriver));
// If a DriverAction was specified, Call it to notify the
// driver that it has been deregistered
if (di.action() != null) {
di.action().deregister();
}
registeredDrivers.remove(aDriver);
} else {
// If the caller does not have permission to load the driver then
// throw a SecurityException.
throw new SecurityException();
}
} else {
// If the caller does not have permission to load the driver then
// throw a SecurityException.
throw new SecurityException();
println(" couldn't find driver to unload");
}
} else {
println(" couldn't find driver to unload");
}
}
@ -430,10 +434,12 @@ public class DriverManager {
public static java.util.Enumeration<Driver> getDrivers() {
java.util.Vector<Driver> result = new java.util.Vector<>();
ensureDriversInitialized();
Class<?> callerClass = Reflection.getCallerClass();
// Walk through the loaded registeredDrivers.
for (DriverInfo aDriver : getRegisteredDrivers()) {
for (DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if (isDriverAllowed(aDriver.driver, callerClass)) {
@ -557,92 +563,82 @@ public class DriverManager {
return result;
}
/*
* Return the registered java.sql.Drivers and call loadInitialDrivers
* if needed
*/
private static CopyOnWriteArrayList<DriverInfo> getRegisteredDrivers() {
// Check to see if we need to load the initial drivers
if (!driversInitialized) {
loadInitialDrivers();
}
return registeredDrivers;
}
/*
* Load the initial JDBC drivers by checking the System property
* jdbc.properties and then use the {@code ServiceLoader} mechanism
* jdbc.drivers and then use the {@code ServiceLoader} mechanism
*/
private synchronized static void loadInitialDrivers() {
String drivers;
private static void ensureDriversInitialized() {
if (driversInitialized) {
return;
}
try {
drivers = AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return System.getProperty(JDBC_DRIVERS_PROPERTY);
synchronized (lockForInitDrivers) {
if (driversInitialized) {
return;
}
String drivers;
try {
drivers = AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return System.getProperty(JDBC_DRIVERS_PROPERTY);
}
});
} catch (Exception ex) {
drivers = null;
}
// If the driver is packaged as a Service Provider, load it.
// Get all the drivers through the classloader
// exposed as a java.sql.Driver.class service.
// ServiceLoader.load() replaces the sun.misc.Providers()
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
ServiceLoader<Driver> loadedDrivers = ServiceLoader.load(Driver.class);
Iterator<Driver> driversIterator = loadedDrivers.iterator();
/* Load these drivers, so that they can be instantiated.
* It may be the case that the driver class may not be there
* i.e. there may be a packaged driver with the service class
* as implementation of java.sql.Driver but the actual class
* may be missing. In that case a java.util.ServiceConfigurationError
* will be thrown at runtime by the VM trying to locate
* and load the service.
*
* Adding a try catch block to catch those runtime errors
* if driver not available in classpath but it's
* packaged as service and that service is there in classpath.
*/
try {
while (driversIterator.hasNext()) {
driversIterator.next();
}
} catch (Throwable t) {
// Do nothing
}
return null;
}
});
} catch (Exception ex) {
drivers = null;
}
// If the driver is packaged as a Service Provider, load it.
// Get all the drivers through the classloader
// exposed as a java.sql.Driver.class service.
// ServiceLoader.load() replaces the sun.misc.Providers()
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
println("DriverManager.initialize: jdbc.drivers = " + drivers);
ServiceLoader<Driver> loadedDrivers = ServiceLoader.load(Driver.class);
Iterator<Driver> driversIterator = loadedDrivers.iterator();
/* Load these drivers, so that they can be instantiated.
* It may be the case that the driver class may not be there
* i.e. there may be a packaged driver with the service class
* as implementation of java.sql.Driver but the actual class
* may be missing. In that case a java.util.ServiceConfigurationError
* will be thrown at runtime by the VM trying to locate
* and load the service.
*
* Adding a try catch block to catch those runtime errors
* if driver not available in classpath but it's
* packaged as service and that service is there in classpath.
*/
try{
while(driversIterator.hasNext()) {
driversIterator.next();
if (drivers != null && !drivers.equals("")) {
String[] driversList = drivers.split(":");
println("number of Drivers:" + driversList.length);
for (String aDriver : driversList) {
try {
println("DriverManager.Initialize: loading " + aDriver);
Class.forName(aDriver, true,
ClassLoader.getSystemClassLoader());
} catch (Exception ex) {
println("DriverManager.Initialize: load failed: " + ex);
}
} catch(Throwable t) {
// Do nothing
}
return null;
}
});
println("DriverManager.initialize: jdbc.drivers = " + drivers);
if (drivers == null || drivers.equals("")) {
return;
driversInitialized = true;
println("JDBC DriverManager initialized");
}
String[] driversList = drivers.split(":");
println("number of Drivers:" + driversList.length);
for (String aDriver : driversList) {
try {
println("DriverManager.Initialize: loading " + aDriver);
Class.forName(aDriver, true,
ClassLoader.getSystemClassLoader());
} catch (Exception ex) {
println("DriverManager.Initialize: load failed: " + ex);
}
}
driversInitialized = true;
println("JDBC DriverManager initialized");
}
@ -666,11 +662,13 @@ public class DriverManager {
println("DriverManager.getConnection(\"" + url + "\")");
ensureDriversInitialized();
// Walk through the loaded registeredDrivers attempting to make a connection.
// Remember the first exception that gets raised so we can reraise it.
SQLException reason = null;
for (DriverInfo aDriver : getRegisteredDrivers()) {
for (DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if (isDriverAllowed(aDriver.driver, callerCL)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@ -159,6 +159,7 @@ public final class RSACipher extends CipherSpi {
}
// see JCE spec
@SuppressWarnings("deprecation")
protected void engineInit(int opmode, Key key,
AlgorithmParameterSpec params, SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
@ -369,6 +370,7 @@ public final class RSACipher extends CipherSpi {
}
// see JCE spec
@SuppressWarnings("deprecation")
protected java.security.Key engineUnwrap(byte[] wrappedKey,
String algorithm,
int type) throws InvalidKeyException, NoSuchAlgorithmException {

View File

@ -584,16 +584,24 @@ final class Config {
}
private String parseLine() throws IOException {
String s = parseWord();
// allow quoted string as part of line
String s = null;
while (true) {
int token = nextToken();
if ((token == TT_EOL) || (token == TT_EOF)) {
break;
}
if (token != TT_WORD) {
if (token != TT_WORD && token != '\"') {
throw excToken("Unexpected value");
}
s = s + " " + st.sval;
if (s == null) {
s = st.sval;
} else {
s = s + " " + st.sval;
}
}
if (s == null) {
throw excToken("Unexpected empty line");
}
return s;
}
@ -653,7 +661,9 @@ final class Config {
//
private String parseLibrary(String keyword) throws IOException {
String lib = parseStringEntry(keyword);
checkDup(keyword);
parseEquals();
String lib = parseLine();
lib = expand(lib);
int i = lib.indexOf("/$ISA/");
if (i != -1) {

View File

@ -178,6 +178,7 @@ public class NativeRSACipher extends CipherSpi {
// see JCE spec
@Override
@SuppressWarnings("deprecation")
protected synchronized void engineInit(int opmode, Key newKey,
AlgorithmParameterSpec params, SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
@ -331,6 +332,7 @@ public class NativeRSACipher extends CipherSpi {
// see JCE spec
@Override
@SuppressWarnings("deprecation")
protected synchronized Key engineUnwrap(byte[] wrappedKey,
String wrappedKeyAlgorithm, int wrappedKeyType)
throws InvalidKeyException, NoSuchAlgorithmException {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2010, 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
@ -141,8 +141,9 @@ public class Arguments {
public Arguments(String[] args) throws IllegalArgumentException {
int argc = 0;
if (args.length < 1) {
throw new IllegalArgumentException("invalid argument count");
if (args.length == 0) {
help = true;
return;
}
if ((args[0].compareTo("-?") == 0)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -238,7 +238,7 @@ public class ThreadReferenceImpl extends ObjectReferenceImpl
}
public void stop(ObjectReference throwable) throws InvalidTypeException {
validateMirror(throwable);
validateMirrorOrNull(throwable);
// Verify that the given object is a Throwable instance
List<ReferenceType> list = vm.classesByName("java.lang.Throwable");
ClassTypeImpl throwableClass = (ClassTypeImpl)list.get(0);

View File

@ -353,7 +353,6 @@ public class RegistryContext implements Context, Referenceable {
/**
* Wrap a RemoteException inside a NamingException.
*/
@SuppressWarnings("deprecation")
public static NamingException wrapRemoteException(RemoteException re) {
NamingException ne;
@ -365,8 +364,7 @@ public class RegistryContext implements Context, Referenceable {
ne = new NoPermissionException();
} else if (re instanceof StubNotFoundException ||
re instanceof UnknownHostException ||
re instanceof SocketSecurityException) {
re instanceof UnknownHostException) {
ne = new ConfigurationException();
} else if (re instanceof ExportException ||
@ -414,11 +412,10 @@ public class RegistryContext implements Context, Referenceable {
* Attempts to install a security manager if none is currently in
* place.
*/
@SuppressWarnings("deprecation")
private static void installSecurityMgr() {
try {
System.setSecurityManager(new RMISecurityManager());
System.setSecurityManager(new SecurityManager());
} catch (Exception e) {
}
}

View File

@ -135,10 +135,6 @@ java/lang/instrument/RetransformBigClass.sh generic-all
# jdk_management
# 8044591
com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationContentTest.java generic-all
com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationTest.java generic-all
# 8058492
java/lang/management/ThreadMXBean/FindDeadlocks.java generic-all
@ -303,25 +299,6 @@ com/sun/jdi/RedefinePop.sh generic-all
# jdk_util
# 8051641
sun/util/calendar/zi/TestZoneInfo310.java generic-all
# 8062588
java/util/Locale/LocaleProviders.sh generic-all
java/util/PluggableLocale/BreakIteratorProviderTest.sh generic-all
java/util/PluggableLocale/CalendarDataProviderTest.sh generic-all
java/util/PluggableLocale/CalendarNameProviderTest.sh generic-all
java/util/PluggableLocale/CollatorProviderTest.sh generic-all
java/util/PluggableLocale/CurrencyNameProviderTest.sh generic-all
java/util/PluggableLocale/DateFormatProviderTest.sh generic-all
java/util/PluggableLocale/DateFormatSymbolsProviderTest.sh generic-all
java/util/PluggableLocale/DecimalFormatSymbolsProviderTest.sh generic-all
java/util/PluggableLocale/GenericTest.sh generic-all
java/util/PluggableLocale/LocaleNameProviderTest.sh generic-all
java/util/PluggableLocale/NumberFormatProviderTest.sh generic-all
java/util/PluggableLocale/TimeZoneNameProviderTest.sh generic-all
java/util/ResourceBundle/Bug6299235Test.sh generic-all
# 8062512
java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java generic-all

View File

@ -0,0 +1,169 @@
/*
* 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
* 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 8048819
* @summary This test stressful verifies the assertion of "The secret keys generated
* by all involved parties should be the same." for javax.crypto.KeyAgreement
* @run main SameDHKeyStressTest
*/
import java.security.AlgorithmParameterGenerator;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.spec.AlgorithmParameterSpec;
import java.util.Arrays;
import javax.crypto.KeyAgreement;
import javax.crypto.SecretKey;
import javax.crypto.spec.DHGenParameterSpec;
import javax.crypto.spec.DHParameterSpec;
public class SameDHKeyStressTest {
static final String[] ALGORITHMS = {"DH", "DiffieHellman", "dh", "diffieHELLMAN"};
static final String[] SECRET_ALOGRITHMS = {"DES", "DESede", "blowfish"};
static final int[] NUMBER_OF_PARTIES = {2, 3, 4};
static final String[] PA_NAMES = {"Alice", "Bob", "Carol", "David"};
public static void main(String args[]) {
int failedCnt = 0;
StringBuilder failedList = new StringBuilder("Failed List:");
for (String algorithm : ALGORITHMS) {
for (int numOfParties : NUMBER_OF_PARTIES) {
for (String secretAlgorithm : SECRET_ALOGRITHMS) {
if (!runTest(algorithm, numOfParties, secretAlgorithm)) {
failedCnt++;
failedList.append("\n Altorightm = ").append(algorithm).
append(" Number of Parties = ").append(numOfParties).
append(" Secret Algorithm = ").append(secretAlgorithm);
}
}
}
} //end of for loop
if (failedCnt > 0) {
System.out.println(failedList);
throw new RuntimeException("SameDHKeyStressTest Failed");
}
}
public static boolean runTest(String algo, int numParties, String secretAlgo) {
KAParticipant[] parties = new KAParticipant[numParties];
Key[] keyArchives = new Key[numParties];
try {
// generate AlogirhtmParameterSpec
AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH","SunJCE");
AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64);
apg.init(aps);
DHParameterSpec spec = apg.generateParameters().
getParameterSpec(DHParameterSpec.class);
//initilize all KeyAgreement participants
for (int i = 0; i < numParties; i++) {
parties[i] = new KAParticipant(PA_NAMES[i], algo);
parties[i].initialize(spec);
keyArchives[i] = parties[i].getPublicKey();
}
// Do all phases in the KeyAgreement for all participants
Key[] keyBuffer = new Key[numParties];
boolean lastPhase = false;
for (int j = 0; j < numParties - 1; j++) {
if (j == numParties - 2) {
lastPhase = true;
}
for (int k = 0; k < numParties; k++) {
if (k == numParties - 1) {
keyBuffer[k] = parties[k].doPhase(keyArchives[0], lastPhase);
} else {
keyBuffer[k] = parties[k].doPhase(keyArchives[k + 1], lastPhase);
}
}
System.arraycopy(keyBuffer, 0, keyArchives, 0, numParties);
}
//Comparison: The secret keys generated by all involved parties should be the same
SecretKey[] sKeys = new SecretKey[numParties];
for (int n = 0; n < numParties; n++) {
sKeys[n] = parties[n].generateSecret(secretAlgo);
}
for (int q = 0; q < numParties - 1; q++) {
if (!Arrays.equals(sKeys[q].getEncoded(), sKeys[q + 1].getEncoded())) {
return false;
}
}
return true;
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
}
}
class KAParticipant {
private String name = null;
private String algorithm = null;
private KeyPairGenerator keyGen = null;
private KeyPair keys = null;
private KeyAgreement ka = null;
public KAParticipant(String pName, String algo) throws NoSuchAlgorithmException, NoSuchProviderException {
name = pName;
algorithm = algo;
keyGen = KeyPairGenerator.getInstance(algo,"SunJCE");
ka = KeyAgreement.getInstance(algo,"SunJCE");
}
public void initialize(AlgorithmParameterSpec spec) throws InvalidAlgorithmParameterException, InvalidKeyException {
keyGen.initialize(spec);
keys = keyGen.generateKeyPair();
ka.init(keys.getPrivate());
}
public Key doPhase(Key key, boolean lastPhase) throws InvalidKeyException {
return ka.doPhase(key, lastPhase);
}
public Key getPublicKey() {
return keys.getPublic();
}
public byte[] generateSecret() {
return ka.generateSecret();
}
public SecretKey generateSecret(String algo) throws java.lang.IllegalStateException,
java.security.NoSuchAlgorithmException,
java.security.InvalidKeyException {
return ka.generateSecret(algo);
}
}

View File

@ -26,6 +26,7 @@
* @bug 7036199
* @summary Check that GarbageCollectionNotification contents are reasonable
* @author Frederic Parain
* @requires vm.opt.ExplicitGCInvokesConcurrent == null | vm.opt.ExplicitGCInvokesConcurrent == false
* @run main/othervm GarbageCollectionNotificationContentTest
*/

View File

@ -26,6 +26,7 @@
* @bug 7036199
* @summary Check that GarbageCollection notification are thrown by every GarbageCollectorMXBean
* @author Frederic Parain
* @requires vm.opt.ExplicitGCInvokesConcurrent == null | vm.opt.ExplicitGCInvokesConcurrent == false
* @run main/othervm GarbageCollectionNotificationTest
*/

View File

@ -41,7 +41,7 @@ import jdk.testlibrary.Utils;
* @summary Test for VirtualMachine.startManagementAgent and VirtualMachine.startLocalManagementAgent
* @library /lib/testlibrary
* @run build Application SimpleProvider jdk.testlibrary.*
* @run main StartManagementAgent
* @run main/timeout=300 StartManagementAgent
*/
/*

View File

@ -0,0 +1,91 @@
/*
* 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.
*/
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
/*
* @test
* @bug 8067870
* @summary verifies java.io.ObjectInputStream.PeekInputStream.skip works
* as intended
*/
public class PeekInputStreamTest {
public static void main(String[] args) throws ReflectiveOperationException,
IOException {
InputStream pin = createPeekInputStream(
new ByteArrayInputStream(new byte[]{1, 2, 3, 4}));
peek(pin);
if (pin.skip(1) != 1 || pin.read() != 2)
throw new AssertionError();
InputStream pin1 = createPeekInputStream(
new ByteArrayInputStream(new byte[]{1, 2, 3, 4}));
if (pin1.skip(1) != 1 || pin1.read() != 2)
throw new AssertionError();
InputStream pin2 = createPeekInputStream(
new ByteArrayInputStream(new byte[]{1, 2, 3, 4}));
if (pin2.skip(0) != 0 || pin2.read() != 1)
throw new AssertionError();
InputStream pin3 = createPeekInputStream(
new ByteArrayInputStream(new byte[]{1, 2, 3, 4}));
if (pin3.skip(2) != 2 || pin3.read() != 3)
throw new AssertionError();
InputStream pin4 = createPeekInputStream(
new ByteArrayInputStream(new byte[]{1, 2, 3, 4}));
if (pin4.skip(3) != 3 || pin4.read() != 4)
throw new AssertionError();
InputStream pin5 = createPeekInputStream(
new ByteArrayInputStream(new byte[]{1, 2, 3, 4}));
if (pin5.skip(16) != 4 || pin5.read() != -1)
throw new AssertionError();
}
private static InputStream createPeekInputStream(InputStream underlying)
throws ReflectiveOperationException {
Class<? extends InputStream> clazz =
Class.forName("java.io.ObjectInputStream$PeekInputStream")
.asSubclass(InputStream.class);
Constructor<? extends InputStream> ctr =
clazz.getDeclaredConstructor(InputStream.class);
ctr.setAccessible(true);
return ctr.newInstance(underlying);
}
private static void peek(InputStream pin)
throws ReflectiveOperationException {
Method p = pin.getClass().getDeclaredMethod("peek");
p.setAccessible(true);
p.invoke(pin);
}
}

View File

@ -79,24 +79,15 @@ public class ParallelTransformerLoaderAgent
throws IllegalClassFormatException
{
String tName = Thread.currentThread().getName();
// In 160_03 and older, transform() is called
// with the "system_loader_lock" held and that
// prevents the bootstrap class loaded from
// running in parallel. If we add a slight sleep
// delay here when the transform() call is not
// main or TestThread, then the deadlock in
// 160_03 and older is much more reproducible.
if (!tName.equals("main") && !tName.equals("TestThread")) {
System.out.println("Thread '" + tName +
"' has called transform()");
try {
Thread.sleep(500);
} catch (InterruptedException ie) {
}
}
// load additional classes when called from other threads
if (!tName.equals("main"))
// Load additional classes when called from thread 'TestThread'
// When a class is loaded during a callback handling the boot loader, we can
// run into ClassCircularityError if the ClassFileLoadHook is set early enough
// to catch classes needed during class loading, e.g.
// sun.misc.URLClassPath$JarLoader$2.
// The goal of the test is to stress class loading on the test class loaders.
if (tName.equals("TestThread") && loader != null)
{
loadClasses(3);
}

View File

@ -29,17 +29,21 @@
* @author Mandy Chung
* @author Jaroslav Bachorik
*
* @library /lib/testlibrary
* @build jdk.testlibrary.*
* @run main/othervm Locks
*/
import java.lang.management.*;
import java.util.concurrent.Phaser;
import jdk.testlibrary.LockFreeLogManager;
public class Locks {
private static final Object objA = new Object();
private static final Object objB = new Object();
private static final Object objC = new Object();
private static final ThreadMXBean tm = ManagementFactory.getThreadMXBean();
private static final LockFreeLogManager logger = new LockFreeLogManager();
private static boolean testFailed = false;
@ -126,14 +130,14 @@ public class Locks {
public void run() {
synchronized(objA) {
// stop here for LockBThread to hold objB
System.out.println("LockAThread about to block on objB");
log("LockAThread about to block on objB");
p.arriveAndAwaitAdvance(); // Phase 1 (blocking)
synchronized(objB) {
dummyCounter++;
};
}
p.arriveAndAwaitAdvance(); // Phase 2 (blocking)
System.out.println("LockAThread about to exit");
log("LockAThread about to exit");
// Make sure the current thread is not holding any lock
assertNoLock(this);
}
@ -147,7 +151,7 @@ public class Locks {
}
public void run() {
synchronized(objB) {
System.out.println("LockBThread about to block on objC");
log("LockBThread about to block on objC");
p.arriveAndAwaitAdvance(); // Phase 1 (blocking)
// Signal main thread about to block on objC
synchronized(objC) {
@ -155,14 +159,14 @@ public class Locks {
};
}
p.arriveAndAwaitAdvance(); // Phase 2 (blocking)
System.out.println("LockBThread about to exit");
log("LockBThread about to exit");
// Make sure the current thread is not holding any lock
assertNoLock(this);
}
}
private static WaitingThread waiter;
private static Object ready = new Object();
private static final Object ready = new Object();
private static CheckerThread checker;
static class WaitingThread extends Thread {
private final Phaser p;
@ -173,9 +177,10 @@ public class Locks {
super("WaitingThread");
this.p = p;
}
@Override
public void run() {
synchronized(objC) {
System.out.println("WaitingThread about to wait on objC");
log("WaitingThread about to wait on objC");
try {
// Signal checker thread, about to wait on objC.
waiting = false;
@ -188,13 +193,13 @@ public class Locks {
}
// block until CheckerThread finishes checking
System.out.println("WaitingThread about to block on ready");
log("WaitingThread about to block on ready");
// signal checker thread that it is about acquire
// object ready.
p.arriveAndAwaitAdvance(); // Phase 2 (waiting)
synchronized(ready) {
dummyCounter++;
};
}
}
synchronized(objC) {
try {
@ -208,7 +213,7 @@ public class Locks {
testFailed = true;
}
}
System.out.println("WaitingThread about to exit waiting on objC 2");
log("WaitingThread about to exit waiting on objC 2");
}
public void waitForWaiting() {
@ -321,10 +326,10 @@ public class Locks {
private static ThreadInfo findOwnerInfo(ThreadInfo[] infos, String lock)
throws Exception {
ThreadInfo ownerInfo = null;
for (int i = 0; i < infos.length; i++) {
String blockedLock = infos[i].getLockName();
for (ThreadInfo info : infos) {
String blockedLock = info.getLockName();
if (lock.equals(blockedLock)) {
long threadId = infos[i].getLockOwnerId();
long threadId = info.getLockOwnerId();
if (threadId == -1) {
throw new RuntimeException("TEST FAILED: " +
lock + " expected to have owner");
@ -355,14 +360,17 @@ public class Locks {
throws Exception {
ThreadInfo ownerInfo = null;
// Find the thread who is blocking on lock
for (int i = 0; i < infos.length; i++) {
String blockedLock = infos[i].getLockName();
for (ThreadInfo info : infos) {
String blockedLock = info.getLockName();
if (lock.equals(blockedLock)) {
System.out.print(infos[i].getThreadName() +
" blocked on " + blockedLock);
ownerInfo = infos[i];
log("%s blocked on %s", info.getThreadName(), blockedLock);
ownerInfo = info;
}
}
if (ownerInfo == null) {
throw new RuntimeException("TEST FAILED: " +
"Can't retrieve ThreadInfo for the blocked thread");
}
long[] threads = new long[10];
int count = 0;
@ -370,14 +378,18 @@ public class Locks {
while (ownerInfo != null && ownerInfo.getThreadState() == Thread.State.BLOCKED) {
ownerInfo = findOwnerInfo(infos, lock);
threads[count++] = ownerInfo.getThreadId();
System.out.println(" Owner = " + ownerInfo.getThreadName() +
" id = " + ownerInfo.getThreadId());
log(" Owner = %s id = %d",
ownerInfo.getThreadName(),
ownerInfo.getThreadId()
);
lock = ownerInfo.getLockName();
System.out.print(ownerInfo.getThreadName() + " Id = " +
ownerInfo.getThreadId() +
" blocked on " + lock);
log("%s Id = %d blocked on %s",
ownerInfo.getThreadName(),
ownerInfo.getThreadId(),
lock
);
}
System.out.println();
log("");
if (count != expectedThreads.length) {
throw new RuntimeException("TEST FAILED: " +
@ -385,10 +397,15 @@ public class Locks {
}
for (int i = 0; i < count; i++) {
if (threads[i] != expectedThreads[i]) {
System.out.println("TEST FAILED: " +
"Unexpected thread in the chain " + threads[i] +
" expected to be " + expectedThreads[i]);
log("TEST FAILED: Unexpected thread in the chain %s expected to be %s",
threads[i],
expectedThreads[i]
);
}
}
}
private static void log(String format, Object ... args) {
logger.log(format + "%n", args);
}
}

View File

@ -30,7 +30,7 @@
* @author Peter Jones
*
* @build NotExtending_Stub NotExtending_Skel
* @run main/othervm/timeout=240 NotExtending
* @run main/othervm NotExtending
*/
@ -46,9 +46,16 @@ public class NotExtending implements Remote {
/** true if the hashValue field has been initialized */
private boolean hashValueInitialized = false;
public NotExtending() throws RemoteException {
// no declared constructor - rely on implicit no-arg contructor
public Remote export() throws RemoteException {
stub = UnicastRemoteObject.exportObject(this);
setHashValue(stub.hashCode());
return stub;
}
public void unexport() throws RemoteException {
UnicastRemoteObject.unexportObject(this, true);
}
private void setHashValue(int value) {
@ -58,12 +65,11 @@ public class NotExtending implements Remote {
public int hashCode() {
/*
* Test fails with a RuntimeException if the hashCode() method is
* called (during the export procedure) before the correct hash
* value has been initialized.
* Test fails if the hashCode() method is called (during export)
* before the correct hash value has been initialized.
*/
if (!hashValueInitialized) {
throw new RuntimeException(
throw new AssertionError(
"hashCode() invoked before hashValue initialized");
}
return hashValue;
@ -74,69 +80,40 @@ public class NotExtending implements Remote {
}
public static void main(String[] args) throws Exception {
/*
* The following line is required with the JDK 1.2 VM so that the
* VM can exit gracefully when this test completes. Otherwise, the
* conservative garbage collector will find a handle to the server
* object on the native stack and not clear the weak reference to
* it in the RMI runtime's object table.
*/
Object dummy = new Object();
NotExtending server = null;
NotExtending server;
try {
/*
* Verify that hashCode() is not invoked before it is
* initialized. Tests bugid 4102938.
*/
server = new NotExtending();
Remote stub = server.export();
System.err.println("Server exported without invoking hashCode().");
/*
* Verify that passing stub to server's equals() method
* returns true.
*/
if (server.equals(server.stub)) {
System.err.println(
"Passing stub to server's equals() method succeeded.");
if (server.equals(stub)) {
System.err.println("server.equals(stub) returns true");
} else {
throw new RuntimeException(
"passing stub to server's equals() method failed");
throw new AssertionError("server.equals(stub) returns false");
}
/*
* Verify that passing server to stub's equals() method
* returns true. Tests bugid 4099660.
*/
if (server.stub.equals(server)) {
System.err.println(
"Passing server to stub's equals() method succeeded.");
if (stub.equals(server)) {
System.err.println("stub.equals(server) returns true");
} else {
throw new RuntimeException(
"passing server to stub's equals() method failed");
throw new AssertionError("stub.equals(server) returns false");
}
} finally {
server = null;
flushCachedRefs();
}
}
/**
* Force desperate garbage collection so that soft references
* will be cleared.
*
* This method is required with the JDK 1.1.x RMI runtime so that the
* VM can exit gracefully when this test completes. See bugid 4006356.
*/
public static void flushCachedRefs() {
java.util.Vector chain = new java.util.Vector();
try {
while (true) {
int[] hungry = new int[65536];
chain.addElement(hungry);
if (server != null) {
server.unexport();
}
} catch (OutOfMemoryError e) {
}
}
}

View File

@ -137,7 +137,7 @@ echo "DEFFMTCTRY=${DEFFMTCTRY}"
runTest()
{
RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${TESTCLASSES} -Djava.locale.providers=$PREFLIST LocaleProviders $METHODNAME $PARAM1 $PARAM2 $PARAM3"
RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${TESTCLASSES}${PS}${SPICLASSES} -Djava.locale.providers=$PREFLIST LocaleProviders $METHODNAME $PARAM1 $PARAM2 $PARAM3"
echo ${RUNCMD}
${RUNCMD}
result=$?
@ -189,6 +189,7 @@ else
PARAM2=zh
PARAM3=CN
fi
SPICLASSES=
runTest
# testing SPI is NOT selected, as there is none.
@ -197,6 +198,7 @@ PREFLIST=SPI,JRE
PARAM1=JRE
PARAM2=en
PARAM3=US
SPICLASSES=
runTest
# testing the order, variaton #1. This assumes en_GB DateFormat data are available both in JRE & CLDR
@ -205,6 +207,7 @@ PREFLIST=CLDR,JRE
PARAM1=CLDR
PARAM2=en
PARAM3=GB
SPICLASSES=
runTest
# testing the order, variaton #2. This assumes en_GB DateFormat data are available both in JRE & CLDR
@ -213,6 +216,7 @@ PREFLIST=JRE,CLDR
PARAM1=JRE
PARAM2=en
PARAM3=GB
SPICLASSES=
runTest
# testing the order, variaton #3 for non-existent locale in JRE assuming "haw" is not in JRE.
@ -221,6 +225,7 @@ PREFLIST=JRE,CLDR
PARAM1=CLDR
PARAM2=haw
PARAM3=GB
SPICLASSES=
runTest
# testing the order, variaton #4 for the bug 7196799. CLDR's "zh" data should be used in "zh_CN"
@ -229,6 +234,7 @@ PREFLIST=CLDR
PARAM1=CLDR
PARAM2=zh
PARAM3=CN
SPICLASSES=
runTest
# testing FALLBACK provider. SPI and invalid one cases.
@ -237,16 +243,19 @@ PREFLIST=SPI
PARAM1=FALLBACK
PARAM2=en
PARAM3=US
SPICLASSES=
runTest
PREFLIST=FOO
PARAM1=JRE
PARAM2=en
PARAM3=US
SPICLASSES=
runTest
PREFLIST=BAR,SPI
PARAM1=FALLBACK
PARAM2=en
PARAM3=US
SPICLASSES=
runTest
# testing 7198834 fix. Only works on Windows Vista or upper.
@ -255,22 +264,25 @@ PREFLIST=HOST
PARAM1=
PARAM2=
PARAM3=
SPICLASSES=
runTest
# testing 8000245 fix.
METHODNAME=tzNameTest
PREFLIST="JRE -Djava.ext.dirs=${SPIDIR}"
PREFLIST=JRE
PARAM1=Europe/Moscow
PARAM2=
PARAM3=
SPICLASSES=${SPIDIR}
runTest
# testing 8000615 fix.
METHODNAME=tzNameTest
PREFLIST="JRE -Djava.ext.dirs=${SPIDIR}"
PREFLIST=JRE
PARAM1=America/Los_Angeles
PARAM2=
PARAM3=
SPICLASSES=${SPIDIR}
runTest
# testing 8001440 fix.
@ -279,6 +291,7 @@ PREFLIST=CLDR
PARAM1=
PARAM2=
PARAM3=
SPICLASSES=
runTest
# testing 8010666 fix.
@ -289,15 +302,17 @@ then
PARAM1=
PARAM2=
PARAM3=
SPICLASSES=
runTest
fi
# testing 8013086 fix.
METHODNAME=bug8013086Test
PREFLIST="JRE,SPI -Djava.ext.dirs=${SPIDIR}"
PREFLIST=JRE,SPI
PARAM1=ja
PARAM2=JP
PARAM3=
SPICLASSES=${SPIDIR}
runTest
# testing 8013903 fix. (Windows only)
@ -306,12 +321,14 @@ PREFLIST=HOST,JRE
PARAM1=
PARAM2=
PARAM3=
SPICLASSES=
runTest
METHODNAME=bug8013903Test
PREFLIST=HOST
PARAM1=
PARAM2=
PARAM3=
SPICLASSES=
runTest
# testing 8027289 fix, if the platform format default is zh_CN
@ -323,12 +340,14 @@ if [ "${DEFFMTLANG}" = "zh" ] && [ "${DEFFMTCTRY}" = "CN" ]; then
PARAM1=FFE5
PARAM2=
PARAM3=
SPICLASSES=
runTest
METHODNAME=bug8027289Test
PREFLIST=HOST
PARAM1=00A5
PARAM2=
PARAM3=
SPICLASSES=
runTest
fi

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440
# @bug 4052440 8062588
# @summary BreakIteratorProvider tests
# @run shell ExecTest.sh foo BreakIteratorProviderTest true
# @run shell ExecTest.sh foo BreakIteratorProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 7058207 8000986
# @bug 7058207 8000986 8062588
# @summary CalendarDataProvider tests
# @run shell ExecTest.sh bar CalendarDataProviderTest true
# @run shell ExecTest.sh bar CalendarDataProviderTest

View File

@ -22,6 +22,6 @@
#
# @test
# @bug 8000986
# @bug 8000986 8062588
# @summary CalendarNameProvider tests
# @run shell ExecTest.sh bar CalendarNameProviderTest true
# @run shell ExecTest.sh bar CalendarNameProviderTest

View File

@ -36,13 +36,13 @@ public class ClasspathTest {
ClasspathTest() {
/*
* Since providers can only be loaded from the extension directory,
* this test will fail if they are loaded from classpath.
* Since providers can be loaded from the application's classpath,
* this test will fail if they are NOT loaded from classpath.
*/
Locale OSAKA = new Locale("ja", "JP", "osaka");
List<Locale> availableLocales = Arrays.asList(Locale.getAvailableLocales());
if (availableLocales.contains(OSAKA)) {
throw new RuntimeException("LSS providers were loaded from the class path.");
if (!availableLocales.contains(OSAKA)) {
throw new RuntimeException("LSS providers were NOT loaded from the class path.");
}
}
}

View File

@ -23,7 +23,6 @@
#
#
# @test
# @bug 6388652
# @summary Checks whether providers can only be loaded from extension directories,
# not from classpath.
# @run shell ExecTest.sh bar ClasspathTest false
# @bug 6388652 8062588
# @summary Checks whether providers can be loaded from classpath.
# @run shell ExecTest.sh bar ClasspathTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440
# @bug 4052440 8062588
# @summary CollatorProvider tests
# @run shell ExecTest.sh foo CollatorProviderTest true
# @run shell ExecTest.sh foo CollatorProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440 7199750 8000997
# @bug 4052440 7199750 8000997 8062588
# @summary CurrencyNameProvider tests
# @run shell ExecTest.sh bar CurrencyNameProviderTest true
# @run shell ExecTest.sh bar CurrencyNameProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440 7003643
# @bug 4052440 7003643 8062588
# @summary DateFormatProvider tests
# @run shell ExecTest.sh foo DateFormatProviderTest true
# @run shell ExecTest.sh foo DateFormatProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440 7200341
# @bug 4052440 7200341 8062588
# @summary DateFormatSymbolsProvider tests
# @run shell ExecTest.sh foo DateFormatSymbolsProviderTest true
# @run shell ExecTest.sh foo DateFormatSymbolsProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440
# @bug 4052440 8062588
# @summary DecimalFormatSymbolsProvider tests
# @run shell ExecTest.sh foo DecimalFormatSymbolsProviderTest true
# @run shell ExecTest.sh foo DecimalFormatSymbolsProviderTest

View File

@ -76,14 +76,6 @@ case "$OS" in
;;
esac
# set classpath and extension directory variables
if [ -d ${TESTJAVA}${FS}lib${FS}ext ]
then
EXTDIRS="${TESTJAVA}${FS}lib${FS}ext${PS}${TESTCLASSES}"
else
EXTDIRS="${TESTJAVA}${FS}jre${FS}lib${FS}ext${PS}${TESTCLASSES}"
fi
case "$1" in
"foo" )
cp ${TESTSRC}${FS}fooprovider.jar ${TESTCLASSES}
@ -122,12 +114,7 @@ else
fi
# run
if [ "$3" = "true" ]
then
RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Djava.ext.dirs=${EXTDIRS} $2 "
else
RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${CLASSPATHARG} $2 "
fi
RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${CLASSPATHARG} $2 "
echo ${RUNCMD}
${RUNCMD}

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440
# @bug 4052440 8062588
# @summary Generic tests for the pluggable locales feature
# @run shell ExecTest.sh foobar GenericTest true
# @run shell ExecTest.sh foobar GenericTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440 8000273
# @bug 4052440 8000273 8062588
# @summary LocaleNameProvider tests
# @run shell ExecTest.sh bar LocaleNameProviderTest true
# @run shell ExecTest.sh bar LocaleNameProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440 7003643
# @bug 4052440 7003643 8062588
# @summary NumberFormatProvider tests
# @run shell ExecTest.sh foo NumberFormatProviderTest true
# @run shell ExecTest.sh foo NumberFormatProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440 8003267
# @bug 4052440 8003267 8062588
# @summary TimeZoneNameProvider tests
# @run shell ExecTest.sh bar TimeZoneNameProviderTest true
# @run shell ExecTest.sh bar TimeZoneNameProviderTest

View File

@ -55,27 +55,14 @@ if [ -z "${TESTJAVA}" ]; then
exit 1
fi
# See if TESTJAVA points to JRE or JDK
if [ -d "${TESTJAVA}${FILESEP}jre" ]; then
JRE_EXT_DIR=${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}ext
else
JRE_EXT_DIR=${TESTJAVA}${FILESEP}lib${FILESEP}ext
fi
if [ -d "${JRE_EXT_DIR}" ]; then
NEW_EXT_DIR="${JRE_EXT_DIR}${PATHSEP}${TESTSRC}"
else
NEW_EXT_DIR=${TESTSRC}
fi
echo "TESTJAVA=${TESTJAVA}"
echo "TESTSRC=${TESTSRC}"
echo "TESTCLASSES=${TESTCLASSES}"
echo "NEW_EXT_DIR=${NEW_EXT_DIR}"
cd ${TESTSRC}
${TESTJAVA}/bin/java ${TESTVMOPTS} -cp ${TESTCLASSES} -Djava.ext.dirs=${NEW_EXT_DIR} Bug6299235Test
echo
${TESTJAVA}/bin/java ${TESTVMOPTS} -cp ${TESTCLASSES}${PATHSEP}${TESTSRC}${FILESEP}awtres.jar Bug6299235Test
if [ $? -ne 0 ]
then

View File

@ -112,8 +112,10 @@ public class OutputAnalyzerTest {
}
String stdoutPattern = "[a]";
String stdoutByLinePattern = "a*";
String stderrPattern = "[b]";
String nonExistingPattern = "[c]";
String byLinePattern = "[ab]*";
// Should match
try {
@ -148,6 +150,19 @@ public class OutputAnalyzerTest {
// expected
}
if (output.shouldMatchByLine(byLinePattern) != 1) {
throw new Exception("shouldMatchByLine() should find one line");
}
try {
output.shouldMatchByLine(nonExistingPattern);
throw new Exception("shouldMatchByLine() failed to throw exception");
} catch (RuntimeException e) {
// expected
}
if (output.stdoutShouldMatchByLine(stdoutByLinePattern) != 1) {
throw new Exception("stdoutShouldMatchByLine() should find one line");
}
// Should not match
try {
output.shouldNotMatch(nonExistingPattern);

View File

@ -25,13 +25,9 @@ package jdk.testlibrary;
import static jdk.testlibrary.Asserts.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -414,8 +410,12 @@ public final class OutputAnalyzer {
* @return Contents of the output buffer as list of strings
*/
public List<String> asLines() {
return asLines(getOutput());
}
private List<String> asLines(String buffer) {
List<String> l = new ArrayList<>();
String[] a = getOutput().split(Utils.NEW_LINE);
String[] a = buffer.split(Utils.NEW_LINE);
for (String string : a) {
l.add(string);
}
@ -444,6 +444,13 @@ public final class OutputAnalyzer {
return shouldMatchByLine(null, null, pattern);
}
/**
* @see #stdoutShouldMatchByLine(String, String, String)
*/
public int stdoutShouldMatchByLine(String pattern) {
return stdoutShouldMatchByLine(null, null, pattern);
}
/**
* @see #shouldMatchByLine(String, String, String)
*/
@ -474,7 +481,30 @@ public final class OutputAnalyzer {
* @return Count of lines which match the {@code pattern}
*/
public int shouldMatchByLine(String from, String to, String pattern) {
List<String> lines = asLines();
return shouldMatchByLine(getOutput(), from, to, pattern);
}
/**
* Verify that the stdout contents of output buffer matches the
* {@code pattern} line by line. The whole stdout could be matched or
* just a subset of it.
*
* @param from
* The line from where stdout will be matched.
* Set {@code from} to null for matching from the first line.
* @param to
* The line until where stdout will be matched.
* Set {@code to} to null for matching until the last line.
* @param pattern
* Matching pattern
* @return Count of lines which match the {@code pattern}
*/
public int stdoutShouldMatchByLine(String from, String to, String pattern) {
return shouldMatchByLine(getStdout(), from, to, pattern);
}
private int shouldMatchByLine(String buffer, String from, String to, String pattern) {
List<String> lines = asLines(buffer);
int fromIndex = 0;
if (from != null) {
@ -500,4 +530,5 @@ public final class OutputAnalyzer {
return matchedCount;
}
}

View File

@ -22,8 +22,8 @@
*/
/**
* @test
* @bug 6581254 6986789 7196009
* @summary Allow '~', '+' and quoted paths in config file
* @bug 6581254 6986789 7196009 8062170
* @summary Allow '~', '+', and quoted paths in config file
* @author Valerie Peng
*/
@ -34,7 +34,7 @@ import java.lang.reflect.*;
public class ConfigShortPath {
private static final String[] configNames = {
"csp.cfg", "cspPlus.cfg", "cspQuotedPath.cfg"
"csp.cfg", "cspPlus.cfg", "cspSpace.cfg", "cspQuotedPath.cfg"
};
public static void main(String[] args) throws Exception {

View File

@ -0,0 +1,5 @@
showInfo = false
name = test
library = C:\pki DLL\x64\acpkcs211.dll

View File

@ -168,10 +168,8 @@ public final class JpsHelper {
}
/**
* Verify jps output contains pids and programs' name information.
* The function will discard any lines that come before the first line with pid.
* This can happen if the JVM outputs a warning message for some reason
* before running jps.
* Verify jps stdout contains only pids and programs' name information.
* jps stderr may contain VM warning messages which will be ignored.
*
* The output can look like:
* 35536 Jps
@ -180,8 +178,10 @@ public final class JpsHelper {
*/
public static void verifyJpsOutput(OutputAnalyzer output, String regex) throws Exception {
output.shouldHaveExitValue(0);
int matchedCount = output.shouldMatchByLineFrom(regex, regex);
int matchedCount = output.stdoutShouldMatchByLine(regex);
assertGreaterThan(matchedCount , 0, "Found no lines matching pattern: " + regex);
output.stderrShouldNotMatch("[E|e]xception");
output.stderrShouldNotMatch("[E|e]rror");
}
/**

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2004, 2011, 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
@ -22,9 +22,9 @@
#
# @test
# @bug 4990825
# @bug 4990825 6364329
# @run shell jstatHelp.sh
# @summary Test that output of 'jstat -?' matches the usage.out file
# @summary Test that output of 'jstat -?', 'jstat -help' and 'jstat' matches the usage.out file
. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
@ -38,7 +38,7 @@ ${JSTAT} -J-XX:+UsePerfData -? > jstat.out 2>&1
diff -w jstat.out ${TESTSRC}/usage.out
if [ $? != 0 ]
then
echo "Output of jstat -? differ from expected output. Failed."
echo "Output of jstat -? differs from expected output. Failed."
exit 1
fi
@ -48,7 +48,17 @@ ${JSTAT} -J-XX:+UsePerfData -help > jstat.out 2>&1
diff -w jstat.out ${TESTSRC}/usage.out
if [ $? != 0 ]
then
echo "Output of jstat -help differ from expected output. Failed."
echo "Output of jstat -help differs from expected output. Failed."
exit 1
fi
rm -f jstat.out 2>/dev/null
${JSTAT} -J-XX:+UsePerfData > jstat.out 2>&1
diff -w jstat.out ${TESTSRC}/usage.out
if [ $? != 0 ]
then
echo "Output of jstat differs from expected output. Failed."
exit 1
fi

View File

@ -126,6 +126,14 @@ class Rule {
});
rules.clear();
for (int i = 0; i < n; i++) {
if (i != 0 && recs[i -1].getSave() == recs[i].getSave()) {
// we have two recs back to back with same saving for the same year.
if (recs[i].isLastRule()) {
continue;
} else if (recs[i - 1].isLastRule()) {
rules.remove(rules.size() - 1);
}
}
rules.add(recs[i]);
}
return rules;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 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
@ -51,9 +51,6 @@ public class JarEntryTime {
static void extractJar(File jarFile, boolean useExtractionTime) throws Throwable {
String javahome = System.getProperty("java.home");
if (javahome.endsWith("jre")) {
javahome = javahome.substring(0, javahome.length() - 4);
}
String jarcmd = javahome + File.separator + "bin" + File.separator + "jar";
String[] args;
if (useExtractionTime) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 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
@ -45,7 +45,7 @@
* a. if LD_LIBRARY_PATH64 is set it will override LD_LIBRARY_PATH
* b. LD_LIBRARY_PATH32 is ignored if set
* 5. no extra symlink exists on Solaris ie.
* jre/lib/$arch/libjvm.so -> client/libjvm.so
* lib/$arch/libjvm.so -> client/libjvm.so
* TODO:
* a. perhaps we need to add a test to audit all environment variables are
* in pristine condition after the launch, there may be a few that the
@ -267,7 +267,7 @@ public class ExecutionEnvironment extends TestHelper {
}
File symLink = null;
String libPathPrefix = isSDK ? "jre/lib" : "/lib";
String libPathPrefix = "/lib";
symLink = new File(JAVAHOME, libPathPrefix +
getJreArch() + "/" + LIBJVM);
if (symLink.exists()) {

View File

@ -1,15 +1,14 @@
#!/bin/sh
# @test MultipleJRE.sh
# @bug 4811102 4953711 4955505 4956301 4991229 4998210 5018605 6387069 6733959
# @bug 4811102 4953711 4955505 4956301 4991229 4998210 5018605 6387069 6733959 8058407 8067421
# @build PrintVersion
# @build UglyPrintVersion
# @build ZipMeUp
# @run shell MultipleJRE.sh
# @summary Verify Multiple JRE version support has been removed
# @author Joseph E. Kowalski
#
# Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2003, 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
@ -90,6 +89,36 @@ TestSyntax() {
fi
}
#
# Shell routine to ensure help page does not include mjre options
#
TestHelp() {
mess="`$JAVA -help 2>&1`"
# make sure it worked
if [ $? -ne 0 ]; then
echo "java -help failed ????"
exit 1
fi
echo $mess | grep '\-version:<value>' > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "help message contains obsolete option version:<value>"
exit 1
fi
echo $mess | grep '\-jre-restrict-search' > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "help message contains obsolete option jre-restrict-search"
exit 1
fi
echo $mess | grep '\-no-jre-restrict-search' > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "help message contains obsolete option no-jre-restrict-search"
exit 1
fi
}
#
# Just as the name says. We sprinkle these in the appropriate location
# in the test file system and they just say who they are pretending to be.
@ -457,7 +486,8 @@ fi
LaunchVM "" "${RELEASE}"
# Going to silently ignore JRE-Version setting in jar file manifest
#LaunchVM "" "warning: The jarfile JRE-Version"
# Verify help does not contain obsolete options
TestHelp
exit 0

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -27,12 +27,9 @@
* This stub simply prints out the java version string. It is used
* by MultipleJRE.sh.
*/
import sun.misc.Version;
public class PrintVersion {
public static void main(String argv[]) {
Version.print();
}
public static void main(String argv[]) {
System.out.println(System.getProperty("java.version"));
}
}

View File

@ -67,10 +67,7 @@ public class TestHelper {
static final String JAVAHOME = System.getProperty("java.home");
static final String JAVA_BIN;
static final String JAVA_JRE_BIN;
static final String JAVA_LIB;
static final String JAVA_JRE_LIB;
static final boolean isSDK = JAVAHOME.endsWith("jre");
static final String javaCmd;
static final String javawCmd;
static final String javacCmd;
@ -135,17 +132,10 @@ public class TestHelper {
}
compiler = ToolProvider.getSystemJavaCompiler();
File binDir = (isSDK)
? new File((new File(JAVAHOME)).getParentFile(), "bin")
: new File(JAVAHOME, "bin");
File binDir = new File(JAVAHOME, "bin");
JAVA_BIN = binDir.getAbsolutePath();
JAVA_JRE_BIN = new File(JAVAHOME, "bin").getAbsolutePath();
File libDir = (isSDK)
? new File((new File(JAVAHOME)).getParentFile(), "lib")
: new File(JAVAHOME, "lib");
File libDir = new File(JAVAHOME, "lib");
JAVA_LIB = libDir.getAbsolutePath();
JAVA_JRE_LIB = new File(JAVAHOME, "lib").getAbsolutePath();
File javaCmdFile = (isWindows)
? new File(binDir, "java.exe")
@ -191,11 +181,11 @@ public class TestHelper {
}
private static boolean haveVmVariant(String type) {
if (isWindows) {
File vmDir = new File(JAVA_JRE_BIN, type);
File vmDir = new File(JAVA_BIN, type);
File jvmFile = new File(vmDir, LIBJVM);
return jvmFile.exists();
} else {
File vmDir = new File(JAVA_JRE_LIB, type);
File vmDir = new File(JAVA_LIB, type);
File vmArchDir = new File(vmDir, getJreArch());
File jvmFile = new File(vmArchDir, LIBJVM);
return jvmFile.exists();

View File

@ -0,0 +1,158 @@
/*
* 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 6762191
* @summary Setting stack size to 16K causes segmentation fault
* @compile TooSmallStackSize.java
* @run main TooSmallStackSize
*/
/*
* The primary purpose of this test is to make sure we can run with a 16k stack
* size without crashing. Also this test will determine the minimum allowed
* stack size for the platform (as provided by the JVM error message when a very
* small stack is used), and then verify that the JVM can be launched with that stack
* size without a crash or any error messages.
*/
public class TooSmallStackSize extends TestHelper {
/* for debugging. Normally false. */
static final boolean verbose = false;
static void printTestOutput(TestResult tr) {
System.out.println("*** exitValue = " + tr.exitValue);
for (String x : tr.testOutput) {
System.out.println(x);
}
}
/*
* Returns the minimum stack size this platform will allowed based on the
* contents of the error message the JVM outputs when too small of a
* -Xss size was used.
*
* The TestResult argument must contain the result of having already run
* the JVM with too small of a stack size.
*/
static String getMinStackAllowed(TestResult tr) {
/*
* The JVM output will contain in one of the lines:
* "The stack size specified is too small, Specify at least 100k"
* Although the actual size will vary. We need to extract this size
* string from the output and return it.
*/
String matchStr = "Specify at least ";
for (String x : tr.testOutput) {
int match_idx = x.indexOf(matchStr);
if (match_idx >= 0) {
int size_start_idx = match_idx + matchStr.length();
int k_start_idx = x.indexOf("k", size_start_idx);
return x.substring(size_start_idx, k_start_idx + 1); // include the "k"
}
}
System.out.println("FAILED: Could not get the stack size from the output");
throw new RuntimeException("test fails");
}
/*
* Run the JVM with the specified stack size.
*
* Returns the minimum allowed stack size gleaned from the error message,
* if there is an error message. Otherwise returns the stack size passed in.
*/
static String checkStack(String stackSize) {
String min_stack_allowed;
TestResult tr;
if (verbose)
System.out.println("*** Testing " + stackSize);
tr = doExec(javaCmd, "-Xss" + stackSize, "-version");
if (verbose)
printTestOutput(tr);
if (tr.isOK()) {
System.out.println("PASSED: got no error message with stack size of " + stackSize);
min_stack_allowed = stackSize;
} else {
if (tr.contains("The stack size specified is too small")) {
System.out.println("PASSED: got expected error message with stack size of " + stackSize);
min_stack_allowed = getMinStackAllowed(tr);
} else {
// Likely a crash
System.out.println("FAILED: Did not get expected error message with stack size of " + stackSize);
throw new RuntimeException("test fails");
}
}
return min_stack_allowed;
}
/*
* Run the JVM with the minimum allowed stack size. This should always succeed.
*/
static void checkMinStackAllowed(String stackSize) {
TestResult tr = null;
if (verbose)
System.out.println("*** Testing " + stackSize);
tr = doExec(javaCmd, "-Xss" + stackSize, "-version");
if (verbose)
printTestOutput(tr);
if (tr.isOK()) {
System.out.println("PASSED: VM launched with minimum allowed stack size of " + stackSize);
} else {
// Likely a crash
System.out.println("FAILED: VM failed to launch with minimum allowed stack size of " + stackSize);
throw new RuntimeException("test fails");
}
}
public static void main(String... args) {
/*
* The result of a 16k stack size should be a quick exit with a complaint
* that the stack size is too small. However, for some win32 builds, the
* stack is always at least 64k, and this also sometimes is the minimum
* allowed size, so we won't see an error in this case.
*
* This test case will also produce a crash on some platforms if the fix
* for 6762191 is not yet in place.
*/
checkStack("16k");
/*
* Try with a 32k stack size, which is the size that the launcher will
* set to if you try setting to anything smaller. This should produce the same
* result as setting to 16k if the fix for 6762191 is in place.
*/
String min_stack_allowed = checkStack("32k");
/*
* Try again with a the minimum stack size that was given in the error message
*/
checkMinStackAllowed(min_stack_allowed);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -30,12 +30,8 @@
*/
package reallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongpackagename;
import sun.misc.Version;
public class UglyPrintVersion {
public static void main(String argv[]) {
Version.print();
}
public static void main(String argv[]) {
System.out.println(System.getProperty("java.version"));
}
}