mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-19 03:17:40 +00:00
Merge
This commit is contained in:
commit
5afd120610
@ -30,8 +30,6 @@ SUNWprivate_1.1 {
|
||||
Java_sun_tools_attach_VirtualMachineImpl_checkPermissions;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_close;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_connect;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_getLinuxThreadsManager;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_isLinuxThreads;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_open;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_sendQuitTo;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_sendQuitToChildrenOf;
|
||||
|
||||
@ -176,6 +176,9 @@ SUNWprivate_1.1 {
|
||||
Java_java_lang_ProcessHandleImpl_00024Info_info0;
|
||||
Java_java_lang_ProcessImpl_init;
|
||||
Java_java_lang_ProcessImpl_forkAndExec;
|
||||
Java_java_lang_ref_Reference_getAndClearReferencePendingList;
|
||||
Java_java_lang_ref_Reference_hasReferencePendingList;
|
||||
Java_java_lang_ref_Reference_waitForReferencePendingList;
|
||||
Java_java_lang_reflect_Array_get;
|
||||
Java_java_lang_reflect_Array_getBoolean;
|
||||
Java_java_lang_reflect_Array_getByte;
|
||||
|
||||
@ -410,6 +410,10 @@ int NET_Read(int s, void* buf, size_t len) {
|
||||
BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
|
||||
}
|
||||
|
||||
int NET_NonBlockingRead(int s, void* buf, size_t len) {
|
||||
BLOCKING_IO_RETURN_INT(s, recv(s, buf, len, MSG_NONBLOCK));
|
||||
}
|
||||
|
||||
int NET_ReadV(int s, const struct iovec * vector, int count) {
|
||||
BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
|
||||
}
|
||||
@ -503,8 +507,8 @@ int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
|
||||
* Auto restarts with adjusted timeout if interrupted by
|
||||
* signal other than our wakeup signal.
|
||||
*/
|
||||
int NET_Timeout(int s, long timeout) {
|
||||
long prevtime = 0, newtime;
|
||||
int NET_Timeout0(int s, long timeout, long currentTime) {
|
||||
long prevtime = currentTime, newtime;
|
||||
struct timeval t;
|
||||
fdEntry_t *fdEntry = getFdEntry(s);
|
||||
|
||||
@ -516,14 +520,6 @@ int NET_Timeout(int s, long timeout) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pick up current time as may need to adjust timeout
|
||||
*/
|
||||
if (timeout > 0) {
|
||||
gettimeofday(&t, NULL);
|
||||
prevtime = t.tv_sec * 1000 + t.tv_usec / 1000;
|
||||
}
|
||||
|
||||
for(;;) {
|
||||
struct pollfd pfd;
|
||||
int rv;
|
||||
|
||||
@ -367,6 +367,10 @@ int NET_Read(int s, void* buf, size_t len) {
|
||||
BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
|
||||
}
|
||||
|
||||
int NET_NonBlockingRead(int s, void* buf, size_t len) {
|
||||
BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT) );
|
||||
}
|
||||
|
||||
int NET_ReadV(int s, const struct iovec * vector, int count) {
|
||||
BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
|
||||
}
|
||||
@ -406,8 +410,8 @@ int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
|
||||
* Auto restarts with adjusted timeout if interrupted by
|
||||
* signal other than our wakeup signal.
|
||||
*/
|
||||
int NET_Timeout(int s, long timeout) {
|
||||
long prevtime = 0, newtime;
|
||||
int NET_Timeout0(int s, long timeout, long currentTime) {
|
||||
long prevtime = currentTime, newtime;
|
||||
struct timeval t;
|
||||
fdEntry_t *fdEntry = getFdEntry(s);
|
||||
|
||||
@ -419,14 +423,6 @@ int NET_Timeout(int s, long timeout) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pick up current time as may need to adjust timeout
|
||||
*/
|
||||
if (timeout > 0) {
|
||||
gettimeofday(&t, NULL);
|
||||
prevtime = t.tv_sec * 1000 + t.tv_usec / 1000;
|
||||
}
|
||||
|
||||
for(;;) {
|
||||
struct pollfd pfd;
|
||||
int rv;
|
||||
|
||||
@ -371,6 +371,10 @@ int NET_Read(int s, void* buf, size_t len) {
|
||||
BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
|
||||
}
|
||||
|
||||
int NET_NonBlockingRead(int s, void* buf, size_t len) {
|
||||
BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT));
|
||||
}
|
||||
|
||||
int NET_ReadV(int s, const struct iovec * vector, int count) {
|
||||
BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
|
||||
}
|
||||
@ -410,8 +414,8 @@ int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
|
||||
* Auto restarts with adjusted timeout if interrupted by
|
||||
* signal other than our wakeup signal.
|
||||
*/
|
||||
int NET_Timeout(int s, long timeout) {
|
||||
long prevtime = 0, newtime;
|
||||
int NET_Timeout0(int s, long timeout, long currentTime) {
|
||||
long prevtime = currentTime, newtime;
|
||||
struct timeval t, *tp = &t;
|
||||
fd_set fds;
|
||||
fd_set* fdsp = NULL;
|
||||
@ -432,9 +436,6 @@ int NET_Timeout(int s, long timeout) {
|
||||
*/
|
||||
if (timeout > 0) {
|
||||
/* Timed */
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
prevtime = now.tv_sec * 1000 + now.tv_usec / 1000;
|
||||
t.tv_sec = timeout / 1000;
|
||||
t.tv_usec = (timeout % 1000) * 1000;
|
||||
} else if (timeout < 0) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2016, 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
|
||||
@ -110,22 +110,6 @@ public abstract class Reference<T> {
|
||||
private transient Reference<T> discovered; /* used by VM */
|
||||
|
||||
|
||||
/* Object used to synchronize with the garbage collector. The collector
|
||||
* must acquire this lock at the beginning of each collection cycle. It is
|
||||
* therefore critical that any code holding this lock complete as quickly
|
||||
* as possible, allocate no new objects, and avoid calling user code.
|
||||
*/
|
||||
private static class Lock { }
|
||||
private static Lock lock = new Lock();
|
||||
|
||||
|
||||
/* List of References waiting to be enqueued. The collector adds
|
||||
* References to this list, while the Reference-handler thread removes
|
||||
* them. This list is protected by the above lock object. The
|
||||
* list uses the discovered field to link its elements.
|
||||
*/
|
||||
private static Reference<Object> pending = null;
|
||||
|
||||
/* High-priority thread to enqueue pending References
|
||||
*/
|
||||
private static class ReferenceHandler extends Thread {
|
||||
@ -139,10 +123,9 @@ public abstract class Reference<T> {
|
||||
}
|
||||
|
||||
static {
|
||||
// pre-load and initialize InterruptedException and Cleaner classes
|
||||
// so that we don't get into trouble later in the run loop if there's
|
||||
// memory shortage while loading/initializing them lazily.
|
||||
ensureClassInitialized(InterruptedException.class);
|
||||
// pre-load and initialize Cleaner class so that we don't
|
||||
// get into trouble later in the run loop if there's
|
||||
// memory shortage while loading/initializing it lazily.
|
||||
ensureClassInitialized(Cleaner.class);
|
||||
}
|
||||
|
||||
@ -152,72 +135,80 @@ public abstract class Reference<T> {
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
tryHandlePending(true);
|
||||
processPendingReferences();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try handle pending {@link Reference} if there is one.<p>
|
||||
* Return {@code true} as a hint that there might be another
|
||||
* {@link Reference} pending or {@code false} when there are no more pending
|
||||
* {@link Reference}s at the moment and the program can do some other
|
||||
* useful work instead of looping.
|
||||
*
|
||||
* @param waitForNotify if {@code true} and there was no pending
|
||||
* {@link Reference}, wait until notified from VM
|
||||
* or interrupted; if {@code false}, return immediately
|
||||
* when there is no pending {@link Reference}.
|
||||
* @return {@code true} if there was a {@link Reference} pending and it
|
||||
* was processed, or we waited for notification and either got it
|
||||
* or thread was interrupted before being notified;
|
||||
* {@code false} otherwise.
|
||||
/* Atomically get and clear (set to null) the VM's pending list.
|
||||
*/
|
||||
static boolean tryHandlePending(boolean waitForNotify) {
|
||||
Reference<Object> r;
|
||||
Cleaner c;
|
||||
try {
|
||||
synchronized (lock) {
|
||||
if (pending != null) {
|
||||
r = pending;
|
||||
// 'instanceof' might throw OutOfMemoryError sometimes
|
||||
// so do this before un-linking 'r' from the 'pending' chain...
|
||||
c = r instanceof Cleaner ? (Cleaner) r : null;
|
||||
// unlink 'r' from 'pending' chain
|
||||
pending = r.discovered;
|
||||
r.discovered = null;
|
||||
} else {
|
||||
// The waiting on the lock may cause an OutOfMemoryError
|
||||
// because it may try to allocate exception objects.
|
||||
if (waitForNotify) {
|
||||
lock.wait();
|
||||
}
|
||||
// retry if waited
|
||||
return waitForNotify;
|
||||
private static native Reference<Object> getAndClearReferencePendingList();
|
||||
|
||||
/* Test whether the VM's pending list contains any entries.
|
||||
*/
|
||||
private static native boolean hasReferencePendingList();
|
||||
|
||||
/* Wait until the VM's pending list may be non-null.
|
||||
*/
|
||||
private static native void waitForReferencePendingList();
|
||||
|
||||
private static final Object processPendingLock = new Object();
|
||||
private static boolean processPendingActive = false;
|
||||
|
||||
private static void processPendingReferences() {
|
||||
// Only the singleton reference processing thread calls
|
||||
// waitForReferencePendingList() and getAndClearReferencePendingList().
|
||||
// These are separate operations to avoid a race with other threads
|
||||
// that are calling waitForReferenceProcessing().
|
||||
waitForReferencePendingList();
|
||||
Reference<Object> pendingList;
|
||||
synchronized (processPendingLock) {
|
||||
pendingList = getAndClearReferencePendingList();
|
||||
processPendingActive = true;
|
||||
}
|
||||
while (pendingList != null) {
|
||||
Reference<Object> ref = pendingList;
|
||||
pendingList = ref.discovered;
|
||||
ref.discovered = null;
|
||||
|
||||
if (ref instanceof Cleaner) {
|
||||
((Cleaner)ref).clean();
|
||||
// Notify any waiters that progress has been made.
|
||||
// This improves latency for nio.Bits waiters, which
|
||||
// are the only important ones.
|
||||
synchronized (processPendingLock) {
|
||||
processPendingLock.notifyAll();
|
||||
}
|
||||
} else {
|
||||
ReferenceQueue<? super Object> q = ref.queue;
|
||||
if (q != ReferenceQueue.NULL) q.enqueue(ref);
|
||||
}
|
||||
} catch (OutOfMemoryError x) {
|
||||
// Give other threads CPU time so they hopefully drop some live references
|
||||
// and GC reclaims some space.
|
||||
// Also prevent CPU intensive spinning in case 'r instanceof Cleaner' above
|
||||
// persistently throws OOME for some time...
|
||||
Thread.yield();
|
||||
// retry
|
||||
return true;
|
||||
} catch (InterruptedException x) {
|
||||
// retry
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fast path for cleaners
|
||||
if (c != null) {
|
||||
c.clean();
|
||||
return true;
|
||||
// Notify any waiters of completion of current round.
|
||||
synchronized (processPendingLock) {
|
||||
processPendingActive = false;
|
||||
processPendingLock.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
ReferenceQueue<? super Object> q = r.queue;
|
||||
if (q != ReferenceQueue.NULL) q.enqueue(r);
|
||||
return true;
|
||||
// Wait for progress in reference processing.
|
||||
//
|
||||
// Returns true after waiting (for notification from the reference
|
||||
// processing thread) if either (1) the VM has any pending
|
||||
// references, or (2) the reference processing thread is
|
||||
// processing references. Otherwise, returns false immediately.
|
||||
private static boolean waitForReferenceProcessing()
|
||||
throws InterruptedException
|
||||
{
|
||||
synchronized (processPendingLock) {
|
||||
if (processPendingActive || hasReferencePendingList()) {
|
||||
// Wait for progress, not necessarily completion.
|
||||
processPendingLock.wait();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
@ -236,8 +227,10 @@ public abstract class Reference<T> {
|
||||
// provide access in SharedSecrets
|
||||
SharedSecrets.setJavaLangRefAccess(new JavaLangRefAccess() {
|
||||
@Override
|
||||
public boolean tryHandlePendingReference() {
|
||||
return tryHandlePending(false);
|
||||
public boolean waitForReferenceProcessing()
|
||||
throws InterruptedException
|
||||
{
|
||||
return Reference.waitForReferenceProcessing();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -131,23 +131,38 @@ class Bits { // package-private
|
||||
}
|
||||
|
||||
final JavaLangRefAccess jlra = SharedSecrets.getJavaLangRefAccess();
|
||||
|
||||
// retry while helping enqueue pending Reference objects
|
||||
// which includes executing pending Cleaner(s) which includes
|
||||
// Cleaner(s) that free direct buffer memory
|
||||
while (jlra.tryHandlePendingReference()) {
|
||||
if (tryReserveMemory(size, cap)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// trigger VM's Reference processing
|
||||
System.gc();
|
||||
|
||||
// a retry loop with exponential back-off delays
|
||||
// (this gives VM some time to do it's job)
|
||||
boolean interrupted = false;
|
||||
try {
|
||||
|
||||
// Retry allocation until success or there are no more
|
||||
// references (including Cleaners that might free direct
|
||||
// buffer memory) to process and allocation still fails.
|
||||
boolean refprocActive;
|
||||
do {
|
||||
try {
|
||||
refprocActive = jlra.waitForReferenceProcessing();
|
||||
} catch (InterruptedException e) {
|
||||
// Defer interrupts and keep trying.
|
||||
interrupted = true;
|
||||
refprocActive = true;
|
||||
}
|
||||
if (tryReserveMemory(size, cap)) {
|
||||
return;
|
||||
}
|
||||
} while (refprocActive);
|
||||
|
||||
// trigger VM's Reference processing
|
||||
System.gc();
|
||||
|
||||
// A retry loop with exponential back-off delays.
|
||||
// Sometimes it would suffice to give up once reference
|
||||
// processing is complete. But if there are many threads
|
||||
// competing for memory, this gives more opportunities for
|
||||
// any given thread to make progress. In particular, this
|
||||
// seems to be enough for a stress test like
|
||||
// DirectBufferAllocTest to (usually) succeed, while
|
||||
// without it that test likely fails. Since failure here
|
||||
// ends in OOME, there's no need to hurry.
|
||||
long sleepTime = 1;
|
||||
int sleeps = 0;
|
||||
while (true) {
|
||||
@ -157,14 +172,14 @@ class Bits { // package-private
|
||||
if (sleeps >= MAX_SLEEPS) {
|
||||
break;
|
||||
}
|
||||
if (!jlra.tryHandlePendingReference()) {
|
||||
try {
|
||||
try {
|
||||
if (!jlra.waitForReferenceProcessing()) {
|
||||
Thread.sleep(sleepTime);
|
||||
sleepTime <<= 1;
|
||||
sleeps++;
|
||||
} catch (InterruptedException e) {
|
||||
interrupted = true;
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
interrupted = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -536,19 +536,6 @@ class JarFile extends ZipFile {
|
||||
* @return an ordered {@code Stream} of entries in this jar file
|
||||
* @throws IllegalStateException if the jar file has been closed
|
||||
* @since 1.8
|
||||
*
|
||||
* @apiNote A versioned view of the stream obtained from a {@code JarFile}
|
||||
* configured to process a multi-release jar file can be created with code
|
||||
* similar to the following:
|
||||
* <pre>
|
||||
* {@code
|
||||
* Stream<JarEntry> versionedStream(JarFile jf) {
|
||||
* return jf.stream().map(JarEntry::getName)
|
||||
* .filter(name -> !name.startsWith("META-INF/versions/"))
|
||||
* .map(jf::getJarEntry);
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public Stream<JarEntry> stream() {
|
||||
return StreamSupport.stream(Spliterators.spliterator(
|
||||
@ -571,7 +558,7 @@ class JarFile extends ZipFile {
|
||||
|
||||
private ZipEntry getVersionedEntry(ZipEntry ze) {
|
||||
ZipEntry vze = null;
|
||||
if (BASE_VERSION_MAJOR < versionMajor && !ze.isDirectory()) {
|
||||
if (BASE_VERSION_MAJOR < versionMajor) {
|
||||
String name = ze.getName();
|
||||
if (!name.startsWith(META_INF)) {
|
||||
vze = searchForVersionedEntry(versionMajor, name);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2016, 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
|
||||
@ -28,12 +28,12 @@ package jdk.internal.misc;
|
||||
public interface JavaLangRefAccess {
|
||||
|
||||
/**
|
||||
* Help ReferenceHandler thread process next pending
|
||||
* {@link java.lang.ref.Reference}
|
||||
* Wait for progress in {@link java.lang.ref.Reference}
|
||||
* processing. If there aren't any pending {@link
|
||||
* java.lang.ref.Reference}s, return immediately.
|
||||
*
|
||||
* @return {@code true} if there was a pending reference and it
|
||||
* was enqueue-ed or {@code false} if there was no
|
||||
* pending reference
|
||||
* @return {@code true} if there were any pending
|
||||
* {@link java.lang.ref.Reference}s, {@code false} otherwise.
|
||||
*/
|
||||
boolean tryHandlePendingReference();
|
||||
boolean waitForReferenceProcessing() throws InterruptedException;
|
||||
}
|
||||
|
||||
@ -1197,6 +1197,9 @@ public final class Unsafe {
|
||||
if (hostClass == null || data == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (hostClass.isArray() || hostClass.isPrimitive()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
return defineAnonymousClass0(hostClass, data, cpPatches);
|
||||
}
|
||||
|
||||
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.util.jar;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class VersionedStream {
|
||||
private static final String META_INF_VERSIONS = "META-INF/versions/";
|
||||
|
||||
/**
|
||||
* Returns a stream of versioned entries, derived from the base names of
|
||||
* all entries in a multi-release {@code JarFile} that are present either in
|
||||
* the base directory or in any versioned directory with a version number
|
||||
* less than or equal to the {@code Runtime.Version::major} that the
|
||||
* {@code JarFile} was opened with. These versioned entries are aliases
|
||||
* for the real entries -- i.e. the names are base names and the content
|
||||
* may come from a versioned directory entry. If the {@code jarFile} is not
|
||||
* a multi-release jar, a stream of all entries is returned.
|
||||
*
|
||||
* @param jf the input JarFile
|
||||
* @return stream of entries
|
||||
* @since 9
|
||||
*/
|
||||
public static Stream<JarEntry> stream(JarFile jf) {
|
||||
if (jf.isMultiRelease()) {
|
||||
int version = jf.getVersion().major();
|
||||
return jf.stream()
|
||||
.map(je -> getBaseSuffix(je, version))
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.map(jf::getJarEntry);
|
||||
}
|
||||
return jf.stream();
|
||||
}
|
||||
|
||||
private static String getBaseSuffix(JarEntry je, int version) {
|
||||
String name = je.getName();
|
||||
if (name.startsWith(META_INF_VERSIONS)) {
|
||||
int len = META_INF_VERSIONS.length();
|
||||
int index = name.indexOf('/', len);
|
||||
if (index == -1 || index == (name.length() - 1)) {
|
||||
// filter out META-INF/versions/* and META-INF/versions/*/
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if (Integer.parseInt(name, len, index, 10) > version) {
|
||||
// not an integer
|
||||
return null;
|
||||
}
|
||||
} catch (NumberFormatException x) {
|
||||
// silently remove malformed entries
|
||||
return null;
|
||||
}
|
||||
// We know name looks like META-INF/versions/*/*
|
||||
return name.substring(index + 1);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@ -143,7 +143,8 @@ module java.base {
|
||||
exports jdk.internal.org.objectweb.asm.signature to
|
||||
jdk.scripting.nashorn;
|
||||
exports jdk.internal.loader to
|
||||
java.instrument;
|
||||
java.instrument,
|
||||
java.logging;
|
||||
exports jdk.internal.math to
|
||||
java.desktop;
|
||||
exports jdk.internal.module to
|
||||
|
||||
@ -125,7 +125,9 @@ public class JarURLConnection extends java.net.JarURLConnection {
|
||||
* to get the jarFile, and set it as our permission.
|
||||
*/
|
||||
if (getUseCaches()) {
|
||||
boolean oldUseCaches = jarFileURLConnection.getUseCaches();
|
||||
jarFileURLConnection = factory.getConnection(jarFile);
|
||||
jarFileURLConnection.setUseCaches(oldUseCaches);
|
||||
}
|
||||
|
||||
if ((entryName != null)) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2016, 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
|
||||
@ -125,7 +125,7 @@ public final class OCSP {
|
||||
("Exception while encoding OCSPRequest", e);
|
||||
}
|
||||
OCSPResponse ocspResponse = check(Collections.singletonList(certId),
|
||||
responderURI, issuerCert, null, null,
|
||||
responderURI, new OCSPResponse.IssuerInfo(issuerCert), null, null,
|
||||
Collections.<Extension>emptyList());
|
||||
return (RevocationStatus)ocspResponse.getSingleResponse(certId);
|
||||
}
|
||||
@ -173,7 +173,8 @@ public final class OCSP {
|
||||
("Exception while encoding OCSPRequest", e);
|
||||
}
|
||||
OCSPResponse ocspResponse = check(Collections.singletonList(certId),
|
||||
responderURI, issuerCert, responderCert, date, extensions);
|
||||
responderURI, new OCSPResponse.IssuerInfo(issuerCert),
|
||||
responderCert, date, extensions);
|
||||
return (RevocationStatus) ocspResponse.getSingleResponse(certId);
|
||||
}
|
||||
|
||||
@ -182,7 +183,7 @@ public final class OCSP {
|
||||
*
|
||||
* @param certIds the CertIds to be checked
|
||||
* @param responderURI the URI of the OCSP responder
|
||||
* @param issuerCert the issuer's certificate
|
||||
* @param issuerInfo the issuer's certificate and/or subject and public key
|
||||
* @param responderCert the OCSP responder's certificate
|
||||
* @param date the time the validity of the OCSP responder's certificate
|
||||
* should be checked against. If null, the current time is used.
|
||||
@ -195,8 +196,8 @@ public final class OCSP {
|
||||
* @throws CertPathValidatorException if an exception occurs while
|
||||
* encoding the OCSP Request or validating the OCSP Response
|
||||
*/
|
||||
static OCSPResponse check(List<CertId> certIds, URI responderURI,
|
||||
X509Certificate issuerCert,
|
||||
static OCSPResponse check(List<CertId> certIds, URI responderURI,
|
||||
OCSPResponse.IssuerInfo issuerInfo,
|
||||
X509Certificate responderCert, Date date,
|
||||
List<Extension> extensions)
|
||||
throws IOException, CertPathValidatorException
|
||||
@ -214,7 +215,7 @@ public final class OCSP {
|
||||
ocspResponse = new OCSPResponse(response);
|
||||
|
||||
// verify the response
|
||||
ocspResponse.verify(certIds, issuerCert, responderCert, date,
|
||||
ocspResponse.verify(certIds, issuerInfo, responderCert, date,
|
||||
nonce);
|
||||
} catch (IOException ioe) {
|
||||
throw new CertPathValidatorException(
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2016, 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
|
||||
@ -41,6 +41,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
@ -373,8 +374,8 @@ public final class OCSPResponse {
|
||||
}
|
||||
}
|
||||
|
||||
void verify(List<CertId> certIds, X509Certificate issuerCert,
|
||||
X509Certificate responderCert, Date date, byte[] nonce)
|
||||
void verify(List<CertId> certIds, IssuerInfo issuerInfo,
|
||||
X509Certificate responderCert, Date date, byte[] nonce)
|
||||
throws CertPathValidatorException
|
||||
{
|
||||
switch (responseStatus) {
|
||||
@ -414,7 +415,9 @@ public final class OCSPResponse {
|
||||
// Add the Issuing CA cert and/or Trusted Responder cert to the list
|
||||
// of certs from the OCSP response
|
||||
try {
|
||||
certs.add(X509CertImpl.toImpl(issuerCert));
|
||||
if (issuerInfo.getCertificate() != null) {
|
||||
certs.add(X509CertImpl.toImpl(issuerInfo.getCertificate()));
|
||||
}
|
||||
if (responderCert != null) {
|
||||
certs.add(X509CertImpl.toImpl(responderCert));
|
||||
}
|
||||
@ -464,7 +467,10 @@ public final class OCSPResponse {
|
||||
// Check whether the signer cert returned by the responder is trusted
|
||||
if (signerCert != null) {
|
||||
// Check if the response is signed by the issuing CA
|
||||
if (signerCert.equals(issuerCert)) {
|
||||
if (signerCert.getSubjectX500Principal().equals(
|
||||
issuerInfo.getName()) &&
|
||||
signerCert.getPublicKey().equals(
|
||||
issuerInfo.getPublicKey())) {
|
||||
if (debug != null) {
|
||||
debug.println("OCSP response is signed by the target's " +
|
||||
"Issuing CA");
|
||||
@ -481,7 +487,7 @@ public final class OCSPResponse {
|
||||
|
||||
// Check if the response is signed by an authorized responder
|
||||
} else if (signerCert.getIssuerX500Principal().equals(
|
||||
issuerCert.getSubjectX500Principal())) {
|
||||
issuerInfo.getName())) {
|
||||
|
||||
// Check for the OCSPSigning key purpose
|
||||
try {
|
||||
@ -502,7 +508,8 @@ public final class OCSPResponse {
|
||||
// Check algorithm constraints specified in security property
|
||||
// "jdk.certpath.disabledAlgorithms".
|
||||
AlgorithmChecker algChecker = new AlgorithmChecker(
|
||||
new TrustAnchor(issuerCert, null));
|
||||
new TrustAnchor(issuerInfo.getName(),
|
||||
issuerInfo.getPublicKey(), null));
|
||||
algChecker.init(false);
|
||||
algChecker.check(signerCert, Collections.<String>emptySet());
|
||||
|
||||
@ -540,7 +547,7 @@ public final class OCSPResponse {
|
||||
|
||||
// verify the signature
|
||||
try {
|
||||
signerCert.verify(issuerCert.getPublicKey());
|
||||
signerCert.verify(issuerInfo.getPublicKey());
|
||||
if (debug != null) {
|
||||
debug.println("OCSP response is signed by an " +
|
||||
"Authorized Responder");
|
||||
@ -971,4 +978,86 @@ public final class OCSPResponse {
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class that allows consumers to pass in issuer information. This
|
||||
* will always consist of the issuer's name and public key, but may also
|
||||
* contain a certificate if the originating data is in that form.
|
||||
*/
|
||||
static final class IssuerInfo {
|
||||
private final X509Certificate certificate;
|
||||
private final X500Principal name;
|
||||
private final PublicKey pubKey;
|
||||
|
||||
IssuerInfo(X509Certificate issuerCert) {
|
||||
certificate = Objects.requireNonNull(issuerCert,
|
||||
"Constructor requires non-null certificate");
|
||||
name = certificate.getSubjectX500Principal();
|
||||
pubKey = certificate.getPublicKey();
|
||||
}
|
||||
|
||||
IssuerInfo(X500Principal subjectName, PublicKey key) {
|
||||
certificate = null;
|
||||
name = Objects.requireNonNull(subjectName,
|
||||
"Constructor requires non-null subject");
|
||||
pubKey = Objects.requireNonNull(key,
|
||||
"Constructor requires non-null public key");
|
||||
}
|
||||
|
||||
IssuerInfo(TrustAnchor anchor) {
|
||||
certificate = anchor.getTrustedCert();
|
||||
if (certificate != null) {
|
||||
name = certificate.getSubjectX500Principal();
|
||||
pubKey = certificate.getPublicKey();
|
||||
} else {
|
||||
name = anchor.getCA();
|
||||
pubKey = anchor.getCAPublicKey();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the certificate in this IssuerInfo if present.
|
||||
*
|
||||
* @return the {@code X509Certificate} used to create this IssuerInfo
|
||||
* object, or {@code null} if a certificate was not used in its
|
||||
* creation.
|
||||
*/
|
||||
X509Certificate getCertificate() {
|
||||
return certificate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this issuer.
|
||||
*
|
||||
* @return an {@code X500Principal} corresponding to this issuer's
|
||||
* name. If derived from an issuer's {@code X509Certificate} this
|
||||
* would be equivalent to the certificate subject name.
|
||||
*/
|
||||
X500Principal getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the public key for this issuer.
|
||||
*
|
||||
* @return a {@code PublicKey} for this issuer.
|
||||
*/
|
||||
PublicKey getPublicKey() {
|
||||
return pubKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a string representation of this IssuerInfo.
|
||||
*
|
||||
* @return a {@code String} form of this IssuerInfo object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Issuer Info:\n");
|
||||
sb.append("Name: ").append(name.toString()).append("\n");
|
||||
sb.append("Public Key:\n").append(pubKey.toString()).append("\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, 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
|
||||
@ -61,12 +61,12 @@ class RevocationChecker extends PKIXRevocationChecker {
|
||||
private List<CertStore> certStores;
|
||||
private Map<X509Certificate, byte[]> ocspResponses;
|
||||
private List<Extension> ocspExtensions;
|
||||
private boolean legacy;
|
||||
private final boolean legacy;
|
||||
private LinkedList<CertPathValidatorException> softFailExceptions =
|
||||
new LinkedList<>();
|
||||
|
||||
// state variables
|
||||
private X509Certificate issuerCert;
|
||||
private OCSPResponse.IssuerInfo issuerInfo;
|
||||
private PublicKey prevPubKey;
|
||||
private boolean crlSignFlag;
|
||||
private int certIndex;
|
||||
@ -301,9 +301,9 @@ class RevocationChecker extends PKIXRevocationChecker {
|
||||
CertPathValidatorException("forward checking not supported");
|
||||
}
|
||||
if (anchor != null) {
|
||||
issuerCert = anchor.getTrustedCert();
|
||||
prevPubKey = (issuerCert != null) ? issuerCert.getPublicKey()
|
||||
: anchor.getCAPublicKey();
|
||||
issuerInfo = new OCSPResponse.IssuerInfo(anchor);
|
||||
prevPubKey = issuerInfo.getPublicKey();
|
||||
|
||||
}
|
||||
crlSignFlag = true;
|
||||
if (params != null && params.certPath() != null) {
|
||||
@ -437,7 +437,7 @@ class RevocationChecker extends PKIXRevocationChecker {
|
||||
private void updateState(X509Certificate cert)
|
||||
throws CertPathValidatorException
|
||||
{
|
||||
issuerCert = cert;
|
||||
issuerInfo = new OCSPResponse.IssuerInfo(cert);
|
||||
|
||||
// Make new public key if parameters are missing
|
||||
PublicKey pubKey = cert.getPublicKey();
|
||||
@ -708,14 +708,8 @@ class RevocationChecker extends PKIXRevocationChecker {
|
||||
OCSPResponse response = null;
|
||||
CertId certId = null;
|
||||
try {
|
||||
if (issuerCert != null) {
|
||||
certId = new CertId(issuerCert,
|
||||
currCert.getSerialNumberObject());
|
||||
} else {
|
||||
// must be an anchor name and key
|
||||
certId = new CertId(anchor.getCA(), anchor.getCAPublicKey(),
|
||||
currCert.getSerialNumberObject());
|
||||
}
|
||||
certId = new CertId(issuerInfo.getName(), issuerInfo.getPublicKey(),
|
||||
currCert.getSerialNumberObject());
|
||||
|
||||
// check if there is a cached OCSP response available
|
||||
byte[] responseBytes = ocspResponses.get(cert);
|
||||
@ -732,8 +726,8 @@ class RevocationChecker extends PKIXRevocationChecker {
|
||||
nonce = ext.getValue();
|
||||
}
|
||||
}
|
||||
response.verify(Collections.singletonList(certId), issuerCert,
|
||||
responderCert, params.date(), nonce);
|
||||
response.verify(Collections.singletonList(certId), issuerInfo,
|
||||
responderCert, params.date(), nonce);
|
||||
|
||||
} else {
|
||||
URI responderURI = (this.responderURI != null)
|
||||
@ -746,8 +740,8 @@ class RevocationChecker extends PKIXRevocationChecker {
|
||||
}
|
||||
|
||||
response = OCSP.check(Collections.singletonList(certId),
|
||||
responderURI, issuerCert, responderCert,
|
||||
null, ocspExtensions);
|
||||
responderURI, issuerInfo,
|
||||
responderCert, null, ocspExtensions);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new CertPathValidatorException(
|
||||
|
||||
@ -281,6 +281,18 @@ JVM_GetSystemPackage(JNIEnv *env, jstring name);
|
||||
JNIEXPORT jobjectArray JNICALL
|
||||
JVM_GetSystemPackages(JNIEnv *env);
|
||||
|
||||
/*
|
||||
* java.lang.ref.Reference
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL
|
||||
JVM_GetAndClearReferencePendingList(JNIEnv *env);
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
JVM_HasReferencePendingList(JNIEnv *env);
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JVM_WaitForReferencePendingList(JNIEnv *env);
|
||||
|
||||
/*
|
||||
* java.io.ObjectInputStream
|
||||
*/
|
||||
|
||||
45
jdk/src/java.base/share/native/libjava/Reference.c
Normal file
45
jdk/src/java.base/share/native/libjava/Reference.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "jvm.h"
|
||||
#include "java_lang_ref_Reference.h"
|
||||
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_java_lang_ref_Reference_getAndClearReferencePendingList(JNIEnv *env, jclass ignore)
|
||||
{
|
||||
return JVM_GetAndClearReferencePendingList(env);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_java_lang_ref_Reference_hasReferencePendingList(JNIEnv *env, jclass ignore)
|
||||
{
|
||||
return JVM_HasReferencePendingList(env);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_lang_ref_Reference_waitForReferencePendingList(JNIEnv *env, jclass ignore)
|
||||
{
|
||||
JVM_WaitForReferencePendingList(env);
|
||||
}
|
||||
@ -112,6 +112,9 @@ GetXUsagePath(char *buf, jint bufsize);
|
||||
jboolean
|
||||
GetApplicationHome(char *buf, jint bufsize);
|
||||
|
||||
jboolean
|
||||
GetApplicationHomeFromDll(char *buf, jint bufsize);
|
||||
|
||||
#define GetArch() GetArchPath(CURRENT_DATA_MODEL)
|
||||
|
||||
/*
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
if (1) { \
|
||||
do { \
|
||||
_result = _cmd; \
|
||||
} while((_result == -1) && (errno == EINTR)); \
|
||||
} while((_result == -1) && (errno == EINTR)); \
|
||||
return _result; \
|
||||
} \
|
||||
} while(0)
|
||||
@ -44,6 +44,10 @@ int NET_Read(int s, void* buf, size_t len) {
|
||||
RESTARTABLE_RETURN_INT(recv(s, buf, len, 0));
|
||||
}
|
||||
|
||||
int NET_NonBlockingRead(int s, void* buf, size_t len) {
|
||||
RESTARTABLE_RETURN_INT(recv(s, buf, len, MSG_DONTWAIT));
|
||||
}
|
||||
|
||||
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
|
||||
struct sockaddr *from, socklen_t *fromlen) {
|
||||
RESTARTABLE_RETURN_INT(recvfrom(s, buf, len, flags, from, fromlen));
|
||||
@ -86,19 +90,14 @@ int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
|
||||
RESTARTABLE_RETURN_INT(poll(ufds, nfds, timeout));
|
||||
}
|
||||
|
||||
int NET_Timeout(int s, long timeout) {
|
||||
int NET_Timeout0(int s, long timeout, long currentTime) {
|
||||
int result;
|
||||
struct timeval t;
|
||||
long prevtime, newtime;
|
||||
long prevtime = currentTime, newtime;
|
||||
struct pollfd pfd;
|
||||
pfd.fd = s;
|
||||
pfd.events = POLLIN;
|
||||
|
||||
if (timeout > 0) {
|
||||
gettimeofday(&t, NULL);
|
||||
prevtime = (t.tv_sec * 1000) + t.tv_usec / 1000;
|
||||
}
|
||||
|
||||
for(;;) {
|
||||
result = poll(&pfd, 1, timeout);
|
||||
if (result < 0 && errno == EINTR) {
|
||||
|
||||
@ -128,13 +128,20 @@ findZoneinfoFile(char *buf, size_t size, const char *dir)
|
||||
char *dbuf = NULL;
|
||||
char *tz = NULL;
|
||||
int res;
|
||||
long name_max = 0;
|
||||
|
||||
dirp = opendir(dir);
|
||||
if (dirp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
entry = (struct dirent64 *) malloc((size_t) pathconf(dir, _PC_NAME_MAX));
|
||||
name_max = pathconf(dir, _PC_NAME_MAX);
|
||||
// If pathconf did not work, fall back to a mimimum buffer size.
|
||||
if (name_max < 1024) {
|
||||
name_max = 1024;
|
||||
}
|
||||
|
||||
entry = (struct dirent64 *)malloc(offsetof(struct dirent64, d_name) + name_max + 1);
|
||||
if (entry == NULL) {
|
||||
(void) closedir(dirp);
|
||||
return NULL;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,8 +25,49 @@
|
||||
#include "java.h"
|
||||
|
||||
/*
|
||||
* If app is "/foo/bin/javac", or "/foo/bin/sparcv9/javac" then put
|
||||
* "/foo" into buf.
|
||||
* Find the last occurrence of a string
|
||||
*/
|
||||
char* findLastPathComponent(char *buffer, const char *comp) {
|
||||
char* t = buffer;
|
||||
char* p = NULL;
|
||||
size_t l = JLI_StrLen(comp);
|
||||
t = JLI_StrStr(t, comp);
|
||||
|
||||
while (t != NULL) {
|
||||
p = t;
|
||||
t += l;
|
||||
t = JLI_StrStr(t, comp);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
* Removes the trailing file name and any intermediate platform
|
||||
* directories, if any, and its enclosing directory.
|
||||
* Ex: if a buffer contains "/foo/bin/javac" or "/foo/bin/x64/javac", the
|
||||
* truncated resulting buffer will contain "/foo".
|
||||
*/
|
||||
jboolean
|
||||
TruncatePath(char *buf)
|
||||
{
|
||||
// try bin directory, maybe an executable
|
||||
char *p = findLastPathComponent(buf, "/bin/");
|
||||
if (p != NULL) {
|
||||
*p = '\0';
|
||||
return JNI_TRUE;
|
||||
}
|
||||
// try lib directory, maybe a library
|
||||
p = findLastPathComponent(buf, "/lib/");
|
||||
if (p != NULL) {
|
||||
*p = '\0';
|
||||
return JNI_TRUE;
|
||||
}
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieves the path to the JRE home by locating the executable file
|
||||
* of the current process and then truncating the path to the executable
|
||||
*/
|
||||
jboolean
|
||||
GetApplicationHome(char *buf, jint bufsize)
|
||||
@ -38,26 +79,27 @@ GetApplicationHome(char *buf, jint bufsize)
|
||||
} else {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
if (JLI_StrRChr(buf, '/') == 0) {
|
||||
buf[0] = '\0';
|
||||
return JNI_FALSE;
|
||||
}
|
||||
*(JLI_StrRChr(buf, '/')) = '\0'; /* executable file */
|
||||
if (JLI_StrLen(buf) < 4 || JLI_StrRChr(buf, '/') == 0) {
|
||||
buf[0] = '\0';
|
||||
return JNI_FALSE;
|
||||
}
|
||||
if (JLI_StrCmp("/bin", buf + JLI_StrLen(buf) - 4) != 0)
|
||||
*(JLI_StrRChr(buf, '/')) = '\0'; /* sparcv9 or amd64 */
|
||||
if (JLI_StrLen(buf) < 4 || JLI_StrCmp("/bin", buf + JLI_StrLen(buf) - 4) != 0) {
|
||||
buf[0] = '\0';
|
||||
return JNI_FALSE;
|
||||
}
|
||||
*(JLI_StrRChr(buf, '/')) = '\0'; /* bin */
|
||||
|
||||
return JNI_TRUE;
|
||||
return TruncatePath(buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieves the path to the JRE home by locating the
|
||||
* shared library and then truncating the path to it.
|
||||
*/
|
||||
jboolean
|
||||
GetApplicationHomeFromDll(char *buf, jint bufsize)
|
||||
{
|
||||
/* try to find ourselves instead */
|
||||
Dl_info info;
|
||||
if (dladdr((void*)&GetApplicationHomeFromDll, &info) != 0) {
|
||||
char *path = realpath(info.dli_fname, buf);
|
||||
if (path == buf) {
|
||||
return TruncatePath(buf);
|
||||
}
|
||||
}
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if the named program exists
|
||||
*/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2016, 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
|
||||
@ -666,6 +666,7 @@ static jboolean
|
||||
GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative)
|
||||
{
|
||||
char libjava[MAXPATHLEN];
|
||||
struct stat s;
|
||||
|
||||
if (GetApplicationHome(path, pathsize)) {
|
||||
/* Is JRE co-located with the application? */
|
||||
@ -688,6 +689,14 @@ GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative)
|
||||
}
|
||||
}
|
||||
|
||||
if (GetApplicationHomeFromDll(path, pathsize)) {
|
||||
JLI_Snprintf(libjava, sizeof(libjava), "%s/lib/%s/" JAVA_DLL, path, arch);
|
||||
if (stat(libjava, &s) == 0) {
|
||||
JLI_TraceLauncher("JRE path is %s\n", path);
|
||||
return JNI_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!speculative)
|
||||
JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL);
|
||||
return JNI_FALSE;
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
|
||||
#include "java_net_SocketInputStream.h"
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* SocketInputStream
|
||||
*/
|
||||
@ -52,6 +51,40 @@ Java_java_net_SocketInputStream_init(JNIEnv *env, jclass cls) {
|
||||
IO_fd_fdID = NET_GetFileDescriptorID(env);
|
||||
}
|
||||
|
||||
static int NET_ReadWithTimeout(JNIEnv *env, int fd, char *bufP, int len, long timeout) {
|
||||
int result = 0;
|
||||
long prevtime = NET_GetCurrentTime(), newtime;
|
||||
while (timeout > 0) {
|
||||
result = NET_TimeoutWithCurrentTime(fd, timeout, prevtime);
|
||||
if (result <= 0) {
|
||||
if (result == 0) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException", "Read timed out");
|
||||
} else if (result == -1) {
|
||||
if (errno == EBADF) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
|
||||
} else if (errno == ENOMEM) {
|
||||
JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
|
||||
} else {
|
||||
JNU_ThrowByNameWithMessageAndLastError
|
||||
(env, JNU_JAVANETPKG "SocketException", "select/poll failed");
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
result = NET_NonBlockingRead(fd, bufP, len);
|
||||
if (result == -1 && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) {
|
||||
newtime = NET_GetCurrentTime();
|
||||
timeout -= newtime - prevtime;
|
||||
if (timeout > 0) {
|
||||
prevtime = newtime;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_SocketInputStream
|
||||
* Method: socketRead0
|
||||
@ -98,32 +131,18 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
|
||||
} else {
|
||||
bufP = BUF;
|
||||
}
|
||||
|
||||
if (timeout) {
|
||||
nread = NET_Timeout(fd, timeout);
|
||||
if (nread <= 0) {
|
||||
if (nread == 0) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
|
||||
"Read timed out");
|
||||
} else if (nread == -1) {
|
||||
if (errno == EBADF) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
|
||||
} else if (errno == ENOMEM) {
|
||||
JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
|
||||
} else {
|
||||
JNU_ThrowByNameWithMessageAndLastError
|
||||
(env, JNU_JAVANETPKG "SocketException", "select/poll failed");
|
||||
}
|
||||
}
|
||||
nread = NET_ReadWithTimeout(env, fd, bufP, len, timeout);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
if (bufP != BUF) {
|
||||
free(bufP);
|
||||
}
|
||||
return -1;
|
||||
return nread;
|
||||
}
|
||||
} else {
|
||||
nread = NET_Read(fd, bufP, len);
|
||||
}
|
||||
|
||||
nread = NET_Read(fd, bufP, len);
|
||||
|
||||
if (nread <= 0) {
|
||||
if (nread < 0) {
|
||||
|
||||
@ -143,7 +162,6 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
|
||||
JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
|
||||
"Operation interrupted");
|
||||
break;
|
||||
|
||||
default:
|
||||
JNU_ThrowByNameWithMessageAndLastError
|
||||
(env, JNU_JAVANETPKG "SocketException", "Read failed");
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
#include <netdb.h>
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifndef _ALLBSD_SOURCE
|
||||
#include <values.h>
|
||||
@ -1669,3 +1670,18 @@ NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
|
||||
|
||||
return timeout;
|
||||
}
|
||||
|
||||
long NET_GetCurrentTime() {
|
||||
struct timeval time;
|
||||
gettimeofday(&time, NULL);
|
||||
return (time.tv_sec * 1000 + time.tv_usec / 1000);
|
||||
}
|
||||
|
||||
int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime) {
|
||||
return NET_Timeout0(s, timeout, currentTime);
|
||||
}
|
||||
|
||||
int NET_Timeout(int s, long timeout) {
|
||||
long currentTime = (timeout > 0) ? NET_GetCurrentTime() : 0;
|
||||
return NET_Timeout0(s, timeout, currentTime);
|
||||
}
|
||||
|
||||
@ -35,7 +35,11 @@
|
||||
#include <sys/poll.h>
|
||||
|
||||
int NET_Timeout(int s, long timeout);
|
||||
int NET_Timeout0(int s, long timeout, long currentTime);
|
||||
int NET_Read(int s, void* buf, size_t len);
|
||||
int NET_NonBlockingRead(int s, void* buf, size_t len);
|
||||
int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime);
|
||||
long NET_GetCurrentTime();
|
||||
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
|
||||
struct sockaddr *from, socklen_t *fromlen);
|
||||
int NET_ReadV(int s, const struct iovec * vector, int count);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2016, 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
|
||||
@ -348,7 +348,6 @@ GetJREPath(char *path, jint pathsize)
|
||||
|
||||
JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL);
|
||||
return JNI_FALSE;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -423,11 +422,11 @@ TruncatePath(char *buf)
|
||||
*JLI_StrRChr(buf, '\\') = '\0'; /* remove .exe file name */
|
||||
if ((cp = JLI_StrRChr(buf, '\\')) == 0) {
|
||||
/* This happens if the application is in a drive root, and
|
||||
* there is no bin directory. */
|
||||
* there is no bin directory. */
|
||||
buf[0] = '\0';
|
||||
return JNI_FALSE;
|
||||
}
|
||||
*cp = '\0'; /* remove the bin\ part */
|
||||
*cp = '\0'; /* remove the bin\ part */
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
@ -449,16 +448,16 @@ GetApplicationHome(char *buf, jint bufsize)
|
||||
jboolean
|
||||
GetApplicationHomeFromDll(char *buf, jint bufsize)
|
||||
{
|
||||
HMODULE hModule;
|
||||
DWORD dwFlags =
|
||||
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
|
||||
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT;
|
||||
HMODULE module;
|
||||
DWORD flags = GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
|
||||
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT;
|
||||
|
||||
if (GetModuleHandleEx(dwFlags, (LPCSTR)&GetJREPath, &hModule) == 0) {
|
||||
return JNI_FALSE;
|
||||
};
|
||||
GetModuleFileName(hModule, buf, bufsize);
|
||||
return TruncatePath(buf);
|
||||
if (GetModuleHandleEx(flags, (LPCSTR)&GetJREPath, &module) != 0) {
|
||||
if (GetModuleFileName(module, buf, bufsize) != 0) {
|
||||
return TruncatePath(buf);
|
||||
}
|
||||
}
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -54,7 +54,4 @@ extern jlong Counter2Micros(jlong counts);
|
||||
|
||||
int UnsetEnv(char *name);
|
||||
|
||||
jboolean
|
||||
GetApplicationHomeFromDll(char *buf, jint bufsize);
|
||||
|
||||
#endif /* JAVA_MD_H */
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2016, 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
|
||||
@ -24,13 +24,22 @@
|
||||
*/
|
||||
|
||||
package java.util.logging;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Module;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.function.Function;
|
||||
import jdk.internal.loader.ClassLoaderValue;
|
||||
|
||||
/**
|
||||
* The Level class defines a set of standard logging levels that
|
||||
@ -177,6 +186,10 @@ public class Level implements java.io.Serializable {
|
||||
*/
|
||||
public static final Level ALL = new Level("ALL", Integer.MIN_VALUE, defaultBundle);
|
||||
|
||||
private static final Level[] standardLevels = {
|
||||
OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a named Level with a given integer value.
|
||||
* <p>
|
||||
@ -267,7 +280,8 @@ public class Level implements java.io.Serializable {
|
||||
// or its defining class loader, if it's unnamed module,
|
||||
// of this Level instance that can be a custom Level subclass;
|
||||
Module module = this.getClass().getModule();
|
||||
ResourceBundle rb = ResourceBundle.getBundle(resourceBundleName, newLocale, module);
|
||||
ResourceBundle rb = ResourceBundle.getBundle(resourceBundleName,
|
||||
newLocale, module);
|
||||
|
||||
final String localizedName = rb.getString(name);
|
||||
final boolean isDefaultBundle = defaultBundle.equals(resourceBundleName);
|
||||
@ -350,12 +364,12 @@ public class Level implements java.io.Serializable {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
KnownLevel level;
|
||||
Optional<Level> level;
|
||||
|
||||
// Look for a known Level with the given non-localized name.
|
||||
level = KnownLevel.findByName(name);
|
||||
if (level != null) {
|
||||
return level.mirroredLevel;
|
||||
level = KnownLevel.findByName(name, KnownLevel::mirrored);
|
||||
if (level.isPresent()) {
|
||||
return level.get();
|
||||
}
|
||||
|
||||
// Now, check if the given name is an integer. If so,
|
||||
@ -363,21 +377,24 @@ public class Level implements java.io.Serializable {
|
||||
// if necessary create one.
|
||||
try {
|
||||
int x = Integer.parseInt(name);
|
||||
level = KnownLevel.findByValue(x);
|
||||
if (level == null) {
|
||||
level = KnownLevel.findByValue(x, KnownLevel::mirrored);
|
||||
if (!level.isPresent()) {
|
||||
// add new Level
|
||||
Level levelObject = new Level(name, x);
|
||||
level = KnownLevel.findByValue(x);
|
||||
// There's no need to use a reachability fence here because
|
||||
// KnownLevel keeps a strong reference on the level when
|
||||
// level.getClass() == Level.class.
|
||||
return KnownLevel.findByValue(x, KnownLevel::mirrored).get();
|
||||
}
|
||||
return level.mirroredLevel;
|
||||
} catch (NumberFormatException ex) {
|
||||
// Not an integer.
|
||||
// Drop through.
|
||||
}
|
||||
|
||||
level = KnownLevel.findByLocalizedLevelName(name);
|
||||
if (level != null) {
|
||||
return level.mirroredLevel;
|
||||
level = KnownLevel.findByLocalizedLevelName(name,
|
||||
KnownLevel::mirrored);
|
||||
if (level.isPresent()) {
|
||||
return level.get();
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -408,15 +425,13 @@ public class Level implements java.io.Serializable {
|
||||
// Serialization magic to prevent "doppelgangers".
|
||||
// This is a performance optimization.
|
||||
private Object readResolve() {
|
||||
KnownLevel o = KnownLevel.matches(this);
|
||||
if (o != null) {
|
||||
return o.levelObject;
|
||||
Optional<Level> level = KnownLevel.matches(this);
|
||||
if (level.isPresent()) {
|
||||
return level.get();
|
||||
}
|
||||
|
||||
// Woops. Whoever sent us this object knows
|
||||
// about a new log level. Add it to our list.
|
||||
Level level = new Level(this.name, this.value, this.resourceBundleName);
|
||||
return level;
|
||||
return new Level(this.name, this.value, this.resourceBundleName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -450,12 +465,12 @@ public class Level implements java.io.Serializable {
|
||||
// Check that name is not null.
|
||||
name.length();
|
||||
|
||||
KnownLevel level;
|
||||
Optional<Level> level;
|
||||
|
||||
// Look for a known Level with the given non-localized name.
|
||||
level = KnownLevel.findByName(name);
|
||||
if (level != null) {
|
||||
return level.levelObject;
|
||||
level = KnownLevel.findByName(name, KnownLevel::referent);
|
||||
if (level.isPresent()) {
|
||||
return level.get();
|
||||
}
|
||||
|
||||
// Now, check if the given name is an integer. If so,
|
||||
@ -463,13 +478,16 @@ public class Level implements java.io.Serializable {
|
||||
// if necessary create one.
|
||||
try {
|
||||
int x = Integer.parseInt(name);
|
||||
level = KnownLevel.findByValue(x);
|
||||
if (level == null) {
|
||||
// add new Level
|
||||
Level levelObject = new Level(name, x);
|
||||
level = KnownLevel.findByValue(x);
|
||||
level = KnownLevel.findByValue(x, KnownLevel::referent);
|
||||
if (level.isPresent()) {
|
||||
return level.get();
|
||||
}
|
||||
return level.levelObject;
|
||||
// add new Level.
|
||||
Level levelObject = new Level(name, x);
|
||||
// There's no need to use a reachability fence here because
|
||||
// KnownLevel keeps a strong reference on the level when
|
||||
// level.getClass() == Level.class.
|
||||
return KnownLevel.findByValue(x, KnownLevel::referent).get();
|
||||
} catch (NumberFormatException ex) {
|
||||
// Not an integer.
|
||||
// Drop through.
|
||||
@ -478,9 +496,9 @@ public class Level implements java.io.Serializable {
|
||||
// Finally, look for a known level with the given localized name,
|
||||
// in the current default locale.
|
||||
// This is relatively expensive, but not excessively so.
|
||||
level = KnownLevel.findByLocalizedLevelName(name);
|
||||
if (level != null) {
|
||||
return level.levelObject;
|
||||
level = KnownLevel.findByLocalizedLevelName(name, KnownLevel::referent);
|
||||
if (level .isPresent()) {
|
||||
return level.get();
|
||||
}
|
||||
|
||||
// OK, we've tried everything and failed
|
||||
@ -530,22 +548,67 @@ public class Level implements java.io.Serializable {
|
||||
// If Level.getName, Level.getLocalizedName, Level.getResourceBundleName methods
|
||||
// were final, the following KnownLevel implementation can be removed.
|
||||
// Future API change should take this into consideration.
|
||||
static final class KnownLevel {
|
||||
static final class KnownLevel extends WeakReference<Level> {
|
||||
private static Map<String, List<KnownLevel>> nameToLevels = new HashMap<>();
|
||||
private static Map<Integer, List<KnownLevel>> intToLevels = new HashMap<>();
|
||||
final Level levelObject; // instance of Level class or Level subclass
|
||||
private static final ReferenceQueue<Level> QUEUE = new ReferenceQueue<>();
|
||||
|
||||
// CUSTOM_LEVEL_CLV is used to register custom level instances with
|
||||
// their defining class loader, so that they are garbage collected
|
||||
// if and only if their class loader is no longer strongly
|
||||
// referenced.
|
||||
private static final ClassLoaderValue<List<Level>> CUSTOM_LEVEL_CLV =
|
||||
new ClassLoaderValue<>();
|
||||
|
||||
final Level mirroredLevel; // mirror of the custom Level
|
||||
KnownLevel(Level l) {
|
||||
this.levelObject = l;
|
||||
super(l, QUEUE);
|
||||
if (l.getClass() == Level.class) {
|
||||
this.mirroredLevel = l;
|
||||
} else {
|
||||
// this mirrored level object is hidden
|
||||
this.mirroredLevel = new Level(l.name, l.value, l.resourceBundleName, false);
|
||||
this.mirroredLevel = new Level(l.name, l.value,
|
||||
l.resourceBundleName, false);
|
||||
}
|
||||
}
|
||||
|
||||
Optional<Level> mirrored() {
|
||||
return Optional.of(mirroredLevel);
|
||||
}
|
||||
|
||||
Optional<Level> referent() {
|
||||
return Optional.ofNullable(get());
|
||||
}
|
||||
|
||||
private void remove() {
|
||||
Optional.ofNullable(nameToLevels.get(mirroredLevel.name))
|
||||
.ifPresent((x) -> x.remove(this));
|
||||
Optional.ofNullable(intToLevels.get(mirroredLevel.value))
|
||||
.ifPresent((x) -> x.remove(this));
|
||||
}
|
||||
|
||||
// Remove all stale KnownLevel instances
|
||||
static synchronized void purge() {
|
||||
Reference<? extends Level> ref;
|
||||
while ((ref = QUEUE.poll()) != null) {
|
||||
if (ref instanceof KnownLevel) {
|
||||
((KnownLevel)ref).remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerWithClassLoader(Level customLevel) {
|
||||
PrivilegedAction<ClassLoader> pa =
|
||||
() -> customLevel.getClass().getClassLoader();
|
||||
PrivilegedAction<String> pn = customLevel.getClass()::getName;
|
||||
final String name = AccessController.doPrivileged(pn);
|
||||
final ClassLoader cl = AccessController.doPrivileged(pa);
|
||||
CUSTOM_LEVEL_CLV.computeIfAbsent(cl, (c, v) -> new ArrayList<>())
|
||||
.add(customLevel);
|
||||
}
|
||||
|
||||
static synchronized void add(Level l) {
|
||||
purge();
|
||||
// the mirroredLevel object is always added to the list
|
||||
// before the custom Level instance
|
||||
KnownLevel o = new KnownLevel(l);
|
||||
@ -562,24 +625,36 @@ public class Level implements java.io.Serializable {
|
||||
intToLevels.put(l.value, list);
|
||||
}
|
||||
list.add(o);
|
||||
|
||||
// keep the custom level reachable from its class loader
|
||||
// This will ensure that custom level values are not GC'ed
|
||||
// until there class loader is GC'ed.
|
||||
if (o.mirroredLevel != l) {
|
||||
registerWithClassLoader(l);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Returns a KnownLevel with the given non-localized name.
|
||||
static synchronized KnownLevel findByName(String name) {
|
||||
List<KnownLevel> list = nameToLevels.get(name);
|
||||
if (list != null) {
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
static synchronized Optional<Level> findByName(String name,
|
||||
Function<KnownLevel, Optional<Level>> selector) {
|
||||
purge();
|
||||
return nameToLevels.getOrDefault(name, Collections.emptyList())
|
||||
.stream()
|
||||
.map(selector)
|
||||
.flatMap(Optional::stream)
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
// Returns a KnownLevel with the given value.
|
||||
static synchronized KnownLevel findByValue(int value) {
|
||||
List<KnownLevel> list = intToLevels.get(value);
|
||||
if (list != null) {
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
static synchronized Optional<Level> findByValue(int value,
|
||||
Function<KnownLevel, Optional<Level>> selector) {
|
||||
purge();
|
||||
return intToLevels.getOrDefault(value, Collections.emptyList())
|
||||
.stream()
|
||||
.map(selector)
|
||||
.flatMap(Optional::stream)
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
// Returns a KnownLevel with the given localized name matching
|
||||
@ -587,32 +662,34 @@ public class Level implements java.io.Serializable {
|
||||
// from the resourceBundle associated with the Level object).
|
||||
// This method does not call Level.getLocalizedName() that may
|
||||
// be overridden in a subclass implementation
|
||||
static synchronized KnownLevel findByLocalizedLevelName(String name) {
|
||||
for (List<KnownLevel> levels : nameToLevels.values()) {
|
||||
for (KnownLevel l : levels) {
|
||||
String lname = l.levelObject.getLocalizedLevelName();
|
||||
if (name.equals(lname)) {
|
||||
return l;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
static synchronized Optional<Level> findByLocalizedLevelName(String name,
|
||||
Function<KnownLevel, Optional<Level>> selector) {
|
||||
purge();
|
||||
return nameToLevels.values().stream()
|
||||
.flatMap(List::stream)
|
||||
.map(selector)
|
||||
.flatMap(Optional::stream)
|
||||
.filter(l -> name.equals(l.getLocalizedLevelName()))
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
static synchronized KnownLevel matches(Level l) {
|
||||
static synchronized Optional<Level> matches(Level l) {
|
||||
purge();
|
||||
List<KnownLevel> list = nameToLevels.get(l.name);
|
||||
if (list != null) {
|
||||
for (KnownLevel level : list) {
|
||||
Level other = level.mirroredLevel;
|
||||
for (KnownLevel ref : list) {
|
||||
Level levelObject = ref.get();
|
||||
if (levelObject == null) continue;
|
||||
Level other = ref.mirroredLevel;
|
||||
if (l.value == other.value &&
|
||||
(l.resourceBundleName == other.resourceBundleName ||
|
||||
(l.resourceBundleName != null &&
|
||||
l.resourceBundleName.equals(other.resourceBundleName)))) {
|
||||
return level;
|
||||
return Optional.of(levelObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2016, 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
|
||||
@ -1707,25 +1707,6 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ObjectInputStream deserialize(ObjectName name, byte[] data) throws InstanceNotFoundException,
|
||||
OperationsException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ObjectInputStream deserialize(String className, byte[] data) throws OperationsException,
|
||||
ReflectionException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ObjectInputStream deserialize(String className, ObjectName loaderName,
|
||||
byte[] data) throws InstanceNotFoundException, OperationsException,
|
||||
ReflectionException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public ClassLoaderRepository getClassLoaderRepository() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2016, 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
|
||||
@ -94,32 +94,6 @@ public interface MBeanServerInterceptor extends MBeanServer {
|
||||
throws ReflectionException, MBeanException,
|
||||
InstanceNotFoundException;
|
||||
|
||||
/**
|
||||
* This method should never be called.
|
||||
* Usually throws UnsupportedOperationException.
|
||||
*/
|
||||
@Deprecated
|
||||
public ObjectInputStream deserialize(ObjectName name, byte[] data)
|
||||
throws InstanceNotFoundException, OperationsException;
|
||||
|
||||
/**
|
||||
* This method should never be called.
|
||||
* Usually throws UnsupportedOperationException.
|
||||
*/
|
||||
@Deprecated
|
||||
public ObjectInputStream deserialize(String className, byte[] data)
|
||||
throws OperationsException, ReflectionException;
|
||||
|
||||
/**
|
||||
* This method should never be called.
|
||||
* Usually hrows UnsupportedOperationException.
|
||||
*/
|
||||
@Deprecated
|
||||
public ObjectInputStream deserialize(String className,
|
||||
ObjectName loaderName, byte[] data)
|
||||
throws InstanceNotFoundException, OperationsException,
|
||||
ReflectionException;
|
||||
|
||||
/**
|
||||
* This method should never be called.
|
||||
* Usually throws UnsupportedOperationException.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2016, 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
|
||||
@ -655,6 +655,8 @@ public interface MBeanServer extends MBeanServerConnection {
|
||||
* used for the de-serialization.
|
||||
* @param data The byte array to be de-sererialized.
|
||||
*
|
||||
* @implSpec This method throws {@link UnsupportedOperationException} by default.
|
||||
*
|
||||
* @return The de-serialized object stream.
|
||||
*
|
||||
* @exception InstanceNotFoundException The MBean specified is not
|
||||
@ -665,10 +667,11 @@ public interface MBeanServer extends MBeanServerConnection {
|
||||
* @deprecated Use {@link #getClassLoaderFor getClassLoaderFor} to
|
||||
* obtain the appropriate class loader for deserialization.
|
||||
*/
|
||||
@Deprecated
|
||||
public ObjectInputStream deserialize(ObjectName name, byte[] data)
|
||||
throws InstanceNotFoundException, OperationsException;
|
||||
|
||||
@Deprecated(since="1.5")
|
||||
default public ObjectInputStream deserialize(ObjectName name, byte[] data)
|
||||
throws InstanceNotFoundException, OperationsException {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>De-serializes a byte array in the context of a given MBean
|
||||
@ -682,6 +685,8 @@ public interface MBeanServer extends MBeanServerConnection {
|
||||
* used for the de-serialization.
|
||||
* @param data The byte array to be de-sererialized.
|
||||
*
|
||||
* @implSpec This method throws {@link UnsupportedOperationException} by default.
|
||||
*
|
||||
* @return The de-serialized object stream.
|
||||
*
|
||||
* @exception OperationsException Any of the usual Input/Output
|
||||
@ -692,9 +697,11 @@ public interface MBeanServer extends MBeanServerConnection {
|
||||
* @deprecated Use {@link #getClassLoaderRepository} to obtain the
|
||||
* class loader repository and use it to deserialize.
|
||||
*/
|
||||
@Deprecated
|
||||
public ObjectInputStream deserialize(String className, byte[] data)
|
||||
throws OperationsException, ReflectionException;
|
||||
@Deprecated(since="1.5")
|
||||
default public ObjectInputStream deserialize(String className, byte[] data)
|
||||
throws OperationsException, ReflectionException {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -711,6 +718,8 @@ public interface MBeanServer extends MBeanServerConnection {
|
||||
* loading the specified class. If null, the MBean Server's class
|
||||
* loader will be used.
|
||||
*
|
||||
* @implSpec This method throws {@link UnsupportedOperationException} by default.
|
||||
*
|
||||
* @return The de-serialized object stream.
|
||||
*
|
||||
* @exception InstanceNotFoundException The specified class loader
|
||||
@ -723,12 +732,14 @@ public interface MBeanServer extends MBeanServerConnection {
|
||||
* @deprecated Use {@link #getClassLoader getClassLoader} to obtain
|
||||
* the class loader for deserialization.
|
||||
*/
|
||||
@Deprecated
|
||||
public ObjectInputStream deserialize(String className,
|
||||
@Deprecated(since="1.5")
|
||||
default public ObjectInputStream deserialize(String className,
|
||||
ObjectName loaderName,
|
||||
byte[] data)
|
||||
throws InstanceNotFoundException, OperationsException,
|
||||
ReflectionException;
|
||||
ReflectionException {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Return the {@link java.lang.ClassLoader} that was used for
|
||||
|
||||
@ -308,10 +308,6 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
||||
|
||||
//-- native methods
|
||||
|
||||
static native boolean isLinuxThreads();
|
||||
|
||||
static native int getLinuxThreadsManager(int pid) throws IOException;
|
||||
|
||||
static native void sendQuitToChildrenOf(int pid) throws IOException;
|
||||
|
||||
static native void sendQuitTo(int pid) throws IOException;
|
||||
|
||||
@ -194,113 +194,6 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_connect
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_tools_attach_VirtualMachineImpl
|
||||
* Method: isLinuxThreads
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_sun_tools_attach_VirtualMachineImpl_isLinuxThreads
|
||||
(JNIEnv *env, jclass cls)
|
||||
{
|
||||
# ifndef _CS_GNU_LIBPTHREAD_VERSION
|
||||
# define _CS_GNU_LIBPTHREAD_VERSION 3
|
||||
# endif
|
||||
size_t n;
|
||||
char* s;
|
||||
jboolean res;
|
||||
|
||||
n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0);
|
||||
if (n <= 0) {
|
||||
/* glibc before 2.3.2 only has LinuxThreads */
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
s = (char *)malloc(n);
|
||||
if (s == NULL) {
|
||||
JNU_ThrowOutOfMemoryError(env, "malloc failed");
|
||||
return JNI_TRUE;
|
||||
}
|
||||
confstr(_CS_GNU_LIBPTHREAD_VERSION, s, n);
|
||||
|
||||
/*
|
||||
* If the LIBPTHREAD version include "NPTL" then we know we
|
||||
* have the new threads library and not LinuxThreads
|
||||
*/
|
||||
res = (jboolean)(strstr(s, "NPTL") == NULL);
|
||||
free(s);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* Structure and callback function used to count the children of
|
||||
* a given process, and record the pid of the "manager thread".
|
||||
*/
|
||||
typedef struct {
|
||||
pid_t ppid;
|
||||
int count;
|
||||
pid_t mpid;
|
||||
} ChildCountContext;
|
||||
|
||||
static void ChildCountCallback(const pid_t pid, void* user_data) {
|
||||
ChildCountContext* context = (ChildCountContext*)user_data;
|
||||
if (getParent(pid) == context->ppid) {
|
||||
context->count++;
|
||||
/*
|
||||
* Remember the pid of the first child. If the final count is
|
||||
* one then this is the pid of the LinuxThreads manager.
|
||||
*/
|
||||
if (context->count == 1) {
|
||||
context->mpid = pid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_tools_attach_VirtualMachineImpl
|
||||
* Method: getLinuxThreadsManager
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_getLinuxThreadsManager
|
||||
(JNIEnv *env, jclass cls, jint pid)
|
||||
{
|
||||
ChildCountContext context;
|
||||
|
||||
/*
|
||||
* Iterate over all processes to find how many children 'pid' has
|
||||
*/
|
||||
context.ppid = pid;
|
||||
context.count = 0;
|
||||
context.mpid = (pid_t)0;
|
||||
forEachProcess(ChildCountCallback, (void*)&context);
|
||||
|
||||
/*
|
||||
* If there's no children then this is likely the pid of the primordial
|
||||
* created by the launcher - in that case the LinuxThreads manager is the
|
||||
* parent of this process.
|
||||
*/
|
||||
if (context.count == 0) {
|
||||
pid_t parent = getParent(pid);
|
||||
if ((int)parent > 0) {
|
||||
return (jint)parent;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* There's one child so this is likely the embedded VM case where the
|
||||
* the primordial thread == LinuxThreads initial thread. The LinuxThreads
|
||||
* manager in that case is the child.
|
||||
*/
|
||||
if (context.count == 1) {
|
||||
return (jint)context.mpid;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we get here it's most likely we were given the wrong pid
|
||||
*/
|
||||
JNU_ThrowIOException(env, "Unable to get pid of LinuxThreads manager thread");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Structure and callback function used to send a QUIT signal to all
|
||||
* children of a given process
|
||||
|
||||
@ -993,32 +993,39 @@ implements ReferenceType {
|
||||
return minorVersion;
|
||||
}
|
||||
|
||||
private void getConstantPoolInfo() {
|
||||
private byte[] getConstantPoolInfo() {
|
||||
JDWP.ReferenceType.ConstantPool jdwpCPool;
|
||||
if (!vm.canGetConstantPool()) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
if (constantPoolInfoGotten) {
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
jdwpCPool = JDWP.ReferenceType.ConstantPool.process(vm, this);
|
||||
} catch (JDWPException exc) {
|
||||
if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) {
|
||||
constanPoolCount = 0;
|
||||
constantPoolBytesRef = null;
|
||||
constantPoolInfoGotten = true;
|
||||
return;
|
||||
} else {
|
||||
throw exc.toJDIException();
|
||||
}
|
||||
if (constantPoolBytesRef == null) {
|
||||
return null;
|
||||
}
|
||||
byte[] cpbytes = constantPoolBytesRef.get();
|
||||
if (cpbytes != null) {
|
||||
return cpbytes;
|
||||
}
|
||||
byte[] cpbytes;
|
||||
constanPoolCount = jdwpCPool.count;
|
||||
cpbytes = jdwpCPool.bytes;
|
||||
constantPoolBytesRef = new SoftReference<byte[]>(cpbytes);
|
||||
constantPoolInfoGotten = true;
|
||||
}
|
||||
|
||||
try {
|
||||
jdwpCPool = JDWP.ReferenceType.ConstantPool.process(vm, this);
|
||||
} catch (JDWPException exc) {
|
||||
if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) {
|
||||
constanPoolCount = 0;
|
||||
constantPoolBytesRef = null;
|
||||
constantPoolInfoGotten = true;
|
||||
return null;
|
||||
} else {
|
||||
throw exc.toJDIException();
|
||||
}
|
||||
}
|
||||
byte[] cpbytes;
|
||||
constanPoolCount = jdwpCPool.count;
|
||||
cpbytes = jdwpCPool.bytes;
|
||||
constantPoolBytesRef = new SoftReference<byte[]>(cpbytes);
|
||||
constantPoolInfoGotten = true;
|
||||
return cpbytes;
|
||||
}
|
||||
|
||||
public int constantPoolCount() {
|
||||
@ -1031,13 +1038,13 @@ implements ReferenceType {
|
||||
}
|
||||
|
||||
public byte[] constantPool() {
|
||||
byte[] cpbytes;
|
||||
try {
|
||||
getConstantPoolInfo();
|
||||
cpbytes = getConstantPoolInfo();
|
||||
} catch (RuntimeException exc) {
|
||||
throw exc;
|
||||
}
|
||||
if (constantPoolBytesRef != null) {
|
||||
byte[] cpbytes = constantPoolBytesRef.get();
|
||||
if (cpbytes != null) {
|
||||
/*
|
||||
* Arrays are always modifiable, so it is a little unsafe
|
||||
* to return the cached bytecodes directly; instead, we
|
||||
|
||||
@ -55,6 +55,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import jdk.tools.jlink.internal.BasicImageWriter;
|
||||
import jdk.tools.jlink.internal.plugins.FileCopierPlugin.SymImageFile;
|
||||
import jdk.tools.jlink.internal.ExecutableImage;
|
||||
@ -159,7 +160,7 @@ public final class DefaultImageBuilder implements ImageBuilder {
|
||||
}
|
||||
i++;
|
||||
}
|
||||
props.setProperty("MODULES", builder.toString());
|
||||
props.setProperty("MODULES", quote(builder.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -188,7 +189,8 @@ public final class DefaultImageBuilder implements ImageBuilder {
|
||||
|
||||
storeFiles(modules, release);
|
||||
|
||||
if (Files.getFileStore(root).supportsFileAttributeView(PosixFileAttributeView.class)) {
|
||||
if (root.getFileSystem().supportedFileAttributeViews()
|
||||
.contains("posix")) {
|
||||
// launchers in the bin directory need execute permission.
|
||||
// On Windows, "bin" also subdirectories containing jvm.dll.
|
||||
if (Files.isDirectory(bin)) {
|
||||
@ -217,19 +219,38 @@ public final class DefaultImageBuilder implements ImageBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// Parse version string and return a string that includes only version part
|
||||
// leaving "pre", "build" information. See also: java.lang.Runtime.Version.
|
||||
private static String parseVersion(String str) {
|
||||
return Runtime.Version.parse(str).
|
||||
version().
|
||||
stream().
|
||||
map(Object::toString).
|
||||
collect(Collectors.joining("."));
|
||||
}
|
||||
|
||||
private static String quote(String str) {
|
||||
return "\"" + str + "\"";
|
||||
}
|
||||
|
||||
private Properties releaseProperties(ResourcePool pool) throws IOException {
|
||||
Properties props = new Properties();
|
||||
Optional<ResourcePoolModule> javaBase = pool.moduleView().findModule("java.base");
|
||||
javaBase.ifPresent(mod -> {
|
||||
// fill release information available from transformed "java.base" module!
|
||||
ModuleDescriptor desc = mod.descriptor();
|
||||
desc.osName().ifPresent(s -> props.setProperty("OS_NAME", s));
|
||||
desc.osVersion().ifPresent(s -> props.setProperty("OS_VERSION", s));
|
||||
desc.osArch().ifPresent(s -> props.setProperty("OS_ARCH", s));
|
||||
props.setProperty("JAVA_VERSION", System.getProperty("java.version"));
|
||||
desc.osName().ifPresent(s -> {
|
||||
props.setProperty("OS_NAME", quote(s));
|
||||
this.targetOsName = s;
|
||||
});
|
||||
desc.osVersion().ifPresent(s -> props.setProperty("OS_VERSION", quote(s)));
|
||||
desc.osArch().ifPresent(s -> props.setProperty("OS_ARCH", quote(s)));
|
||||
desc.version().ifPresent(s -> props.setProperty("JAVA_VERSION",
|
||||
quote(parseVersion(s.toString()))));
|
||||
desc.version().ifPresent(s -> props.setProperty("JAVA_FULL_VERSION",
|
||||
quote(s.toString())));
|
||||
});
|
||||
|
||||
this.targetOsName = props.getProperty("OS_NAME");
|
||||
if (this.targetOsName == null) {
|
||||
throw new PluginException("TargetPlatform attribute is missing for java.base module");
|
||||
}
|
||||
@ -282,8 +303,8 @@ public final class DefaultImageBuilder implements ImageBuilder {
|
||||
StandardOpenOption.CREATE_NEW)) {
|
||||
writer.write(sb.toString());
|
||||
}
|
||||
if (Files.getFileStore(root.resolve("bin"))
|
||||
.supportsFileAttributeView(PosixFileAttributeView.class)) {
|
||||
if (root.resolve("bin").getFileSystem()
|
||||
.supportedFileAttributeViews().contains("posix")) {
|
||||
setExecutable(cmd);
|
||||
}
|
||||
// generate .bat file for Windows
|
||||
|
||||
@ -159,7 +159,6 @@ javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java 8042215
|
||||
|
||||
# jdk_net
|
||||
|
||||
|
||||
java/net/MulticastSocket/NoLoopbackPackets.java 7122846 macosx-all
|
||||
java/net/MulticastSocket/SetLoopbackMode.java 7122846 macosx-all
|
||||
|
||||
@ -217,66 +216,6 @@ sun/security/tools/keytool/ListKeychainStore.sh 8156889 macosx-a
|
||||
|
||||
sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java 8026393 generic-all
|
||||
|
||||
sun/security/pkcs11/Cipher/ReinitCipher.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Cipher/TestRSACipher.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Cipher/TestRSACipherWrap.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Cipher/TestRawRSACipher.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Cipher/TestSymmCiphers.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/KeyAgreement/TestDH.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/KeyAgreement/TestInterop.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/KeyAgreement/TestShort.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java 8077138 windows-all
|
||||
sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java 8077138 windows-all
|
||||
sun/security/pkcs11/KeyGenerator/DESParity.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/KeyPairGenerator/TestDH2048.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/KeyStore/SecretKeysBasic.sh 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Mac/MacKAT.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Mac/MacSameTest.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Mac/ReinitMac.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/MessageDigest/ByteBuffers.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/MessageDigest/DigestKAT.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/MessageDigest/ReinitDigest.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/MessageDigest/TestCloning.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Provider/ConfigQuotedString.sh 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Provider/Login.sh 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/SampleTest.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Secmod/AddPrivateKey.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Secmod/AddTrustedCert.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Secmod/Crypto.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Secmod/GetPrivateKey.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Secmod/JksSetPrivateKey.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Secmod/LoadKeystore.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/SecureRandom/Basic.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/SecureRandom/TestDeserialization.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Serialize/SerializeProvider.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Signature/ByteBuffers.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Signature/ReinitSignature.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Signature/TestDSA.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Signature/TestDSAKeyLength.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/Signature/TestRSAKeyLength.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/ec/ReadCertificates.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/ec/ReadPKCS12.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/ec/TestCurves.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/ec/TestECDH.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/ec/TestECDH2.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/ec/TestECDSA.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/ec/TestECDSA2.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/ec/TestECGenSpec.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/rsa/KeyWrap.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/rsa/TestCACerts.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/rsa/TestKeyFactory.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/rsa/TestKeyPairGenerator.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/rsa/TestSignatures.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/tls/TestKeyMaterial.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/tls/TestLeadingZeroesP11.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/tls/TestMasterSecret.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/tls/TestPRF.java 8077138,8023434 windows-all
|
||||
sun/security/pkcs11/tls/TestPremaster.java 8077138,8023434 windows-all
|
||||
|
||||
sun/security/krb5/auto/HttpNegotiateServer.java 8038079 generic-all
|
||||
|
||||
sun/security/ssl/SSLSocketImpl/AsyncSSLSocketClose.java 8161232 macosx-all
|
||||
@ -312,8 +251,6 @@ tools/pack200/CommandLineTests.java 7143279,8059906
|
||||
|
||||
tools/launcher/FXLauncherTest.java 8068049 linux-all,macosx-all
|
||||
|
||||
tools/pack200/Pack200Props.java 8155857 generic-all
|
||||
|
||||
############################################################################
|
||||
|
||||
# jdk_jdi
|
||||
@ -328,9 +265,6 @@ com/sun/jdi/GetLocalVariables4Test.sh 8067354 windows-
|
||||
|
||||
com/sun/jdi/sde/SourceDebugExtensionTest.java 8158066 windows-all
|
||||
|
||||
com/sun/jdi/ClassesByName2Test.java 8160833 generic-all
|
||||
com/sun/jdi/RedefineCrossEvent.java 8160833 generic-all
|
||||
|
||||
############################################################################
|
||||
|
||||
# jdk_time
|
||||
@ -357,9 +291,11 @@ sun/tools/jcmd/TestJcmdSanity.java 8031482 windows-
|
||||
|
||||
sun/tools/jhsdb/BasicLauncherTest.java 8160376 macosx-all
|
||||
|
||||
sun/tools/jhsdb/HeapDumpTest.java 8160376 macosx-all
|
||||
|
||||
sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java 8160376 macosx-all
|
||||
|
||||
sun/tools/jps/TestJpsJar.java 8160923 generic-all
|
||||
sun/tools/jps/TestJpsJar.java 8165500 generic-all
|
||||
|
||||
sun/tools/jps/TestJpsJarRelative.java 6456333 generic-all
|
||||
|
||||
|
||||
104
jdk/test/com/sun/jdi/ConstantPoolInfoGC.java
Normal file
104
jdk/test/com/sun/jdi/ConstantPoolInfoGC.java
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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 6822627
|
||||
* @summary Test that ReferenceType.constantPool does not produce an NPE
|
||||
*
|
||||
* @author Egor Ushakov
|
||||
*
|
||||
* @modules jdk.jdi/com.sun.tools.jdi
|
||||
* @run build TestScaffold VMConnection
|
||||
* @run compile -g ConstantPoolInfoGC.java
|
||||
* @run main/othervm ConstantPoolInfoGC
|
||||
*/
|
||||
|
||||
import com.sun.jdi.ReferenceType;
|
||||
import com.sun.tools.jdi.ReferenceTypeImpl;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
|
||||
/********** target program **********/
|
||||
|
||||
class ConstantPoolGCTarg {
|
||||
public static void main(String[] args){
|
||||
System.out.println("Anything");
|
||||
}
|
||||
}
|
||||
|
||||
/********** test program **********/
|
||||
|
||||
public class ConstantPoolInfoGC extends TestScaffold {
|
||||
ReferenceType targetClass;
|
||||
|
||||
ConstantPoolInfoGC(String args[]) {
|
||||
super(args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new ConstantPoolInfoGC(args).startTests();
|
||||
}
|
||||
|
||||
/********** test core **********/
|
||||
|
||||
protected void runTests() throws Exception {
|
||||
targetClass = startToMain("ConstantPoolGCTarg").location().declaringType();
|
||||
|
||||
if (vm().canGetConstantPool()) {
|
||||
byte[] cpbytes = targetClass.constantPool();
|
||||
|
||||
// imitate SoftReference cleared
|
||||
Field constantPoolBytesRef = ReferenceTypeImpl.class.getDeclaredField("constantPoolBytesRef");
|
||||
constantPoolBytesRef.setAccessible(true);
|
||||
Reference softRef = (Reference) constantPoolBytesRef.get(targetClass);
|
||||
softRef.clear();
|
||||
|
||||
byte[] cpbytes2 = targetClass.constantPool();
|
||||
if (!Arrays.equals(cpbytes, cpbytes2)) {
|
||||
failure("Consequent constantPool results vary, first was : " + cpbytes + ", now: " + cpbytes2);
|
||||
};
|
||||
|
||||
} else {
|
||||
System.out.println("can get constant pool version not supported");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* resume until end
|
||||
*/
|
||||
listenUntilVMDisconnect();
|
||||
|
||||
/*
|
||||
* deal with results of test
|
||||
* if anything has called failure("foo") testFailed will be true
|
||||
*/
|
||||
if (!testFailed) {
|
||||
println("ConstantPoolInfoGC: passed");
|
||||
} else {
|
||||
throw new Exception("ConstantPoolInfoGC: failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,11 +101,8 @@ public class GetModuleTest {
|
||||
return new Object[][] {
|
||||
|
||||
{ GetModuleTest.class, null },
|
||||
{ GetModuleTest[].class, null },
|
||||
{ Object.class, null },
|
||||
{ Object[].class, null },
|
||||
{ Component.class, null },
|
||||
{ Component[].class, null },
|
||||
|
||||
};
|
||||
}
|
||||
@ -117,7 +114,7 @@ public class GetModuleTest {
|
||||
public void testGetModuleOnVMAnonymousClass(Class<?> hostClass, String ignore) {
|
||||
|
||||
// choose a class name in the same package as the host class
|
||||
String prefix = packageName(hostClass);
|
||||
String prefix = hostClass.getPackageName();
|
||||
if (prefix.length() > 0)
|
||||
prefix = prefix.replace('.', '/') + "/";
|
||||
String className = prefix + "Anon";
|
||||
@ -136,17 +133,6 @@ public class GetModuleTest {
|
||||
assertTrue(anonClass.getModule() == hostClass.getModule());
|
||||
}
|
||||
|
||||
private static String packageName(Class<?> c) {
|
||||
if (c.isArray()) {
|
||||
return packageName(c.getComponentType());
|
||||
} else {
|
||||
String name = c.getName();
|
||||
int dot = name.lastIndexOf('.');
|
||||
if (dot == -1) return "";
|
||||
return name.substring(0, dot);
|
||||
}
|
||||
}
|
||||
|
||||
private static int constantPoolSize(byte[] classFile) {
|
||||
return ((classFile[8] & 0xFF) << 8) | (classFile[9] & 0xFF);
|
||||
}
|
||||
|
||||
@ -57,9 +57,9 @@ public class VMAnonymousClass {
|
||||
@Test public void testJavaLangInvoke() throws Throwable { test("java/lang/invoke"); }
|
||||
@Test public void testProhibitedJavaPkg() throws Throwable {
|
||||
try {
|
||||
test("java/prohibited");
|
||||
} catch (SecurityException e) {
|
||||
return;
|
||||
test("java/prohibited");
|
||||
} catch (IllegalArgumentException e) {
|
||||
return;
|
||||
}
|
||||
throw new RuntimeException("Expected SecurityException");
|
||||
}
|
||||
@ -72,10 +72,17 @@ public class VMAnonymousClass {
|
||||
if (pkg.equals("java/prohibited")) {
|
||||
VMAnonymousClass sampleclass = new VMAnonymousClass();
|
||||
host_class = (Class)sampleclass.getClass();
|
||||
} else if (pkg.equals("java/lang")) {
|
||||
host_class = Object.class;
|
||||
} else if (pkg.equals("java/util")) {
|
||||
host_class = java.util.ArrayList.class;
|
||||
} else if (pkg.equals("jdk/internal/misc")) {
|
||||
host_class = jdk.internal.misc.Signal.class;
|
||||
} else if (pkg.equals("java/lang/invoke")) {
|
||||
host_class = java.lang.invoke.CallSite.class;
|
||||
} else {
|
||||
host_class = Object.class;
|
||||
throw new RuntimeException("Unexpected pkg: " + pkg);
|
||||
}
|
||||
|
||||
// Define VM anonymous class
|
||||
Class anonClass = unsafe.defineAnonymousClass(host_class, bytes, null);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2016, 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
|
||||
@ -26,27 +26,28 @@
|
||||
* @bug 4530538
|
||||
* @summary Basic unit test of ThreadInfo.getLockName()
|
||||
* and ThreadInfo.getLockOwnerName()
|
||||
* @library /lib/testlibrary
|
||||
* @author Mandy Chung
|
||||
* @author Jaroslav Bachorik
|
||||
*
|
||||
* @library /lib/testlibrary
|
||||
* @modules java.management
|
||||
* @build jdk.testlibrary.*
|
||||
* @run main/othervm Locks
|
||||
*/
|
||||
|
||||
import java.lang.management.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Phaser;
|
||||
import java.util.function.Predicate;
|
||||
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;
|
||||
private static final Object OBJA = new Object();
|
||||
private static final Object OBJB = new Object();
|
||||
private static final EnhancedWaiter OBJC = new EnhancedWaiter();
|
||||
private static final ThreadMXBean TM = ManagementFactory.getThreadMXBean();
|
||||
private static final LockFreeLogManager LOGGER = new LockFreeLogManager();
|
||||
|
||||
private static String getLockName(Object lock) {
|
||||
if (lock == null) return null;
|
||||
@ -56,67 +57,103 @@ public class Locks {
|
||||
}
|
||||
|
||||
private static void assertNoLock(Thread t) {
|
||||
long tid = t.getId();
|
||||
ThreadInfo info = tm.getThreadInfo(tid);
|
||||
String result = info.getLockName();
|
||||
|
||||
if (result != null) {
|
||||
throw new RuntimeException("Thread " + t.getName() + " is not supposed to hold any lock. " +
|
||||
"Currently owning lock: " + result);
|
||||
if (t == null) {
|
||||
return;
|
||||
}
|
||||
Optional<ThreadInfo> result = Arrays.asList(
|
||||
TM.getThreadInfo(TM.getAllThreadIds(), true, true)).
|
||||
stream().
|
||||
filter(tInfo -> (tInfo != null && tInfo.getLockOwnerName() != null)
|
||||
? tInfo.getLockOwnerName().equals(t.getName()) : false).
|
||||
findAny();
|
||||
if (result.isPresent()) {
|
||||
throw new RuntimeException("Thread " + t.getName() + " is not "
|
||||
+ "supposed to be hold any lock. Currently owning lock : "
|
||||
+ result.get().getLockName());
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkBlockedObject(Thread t, Object lock, Thread owner,
|
||||
Thread.State expectedState) {
|
||||
long tid = t.getId();
|
||||
ThreadInfo info = tm.getThreadInfo(tid);
|
||||
String result = info.getLockName();
|
||||
String expectedLock = (lock != null ? getLockName(lock) : null);
|
||||
String expectedOwner = (owner != null ? owner.getName() : null);
|
||||
/*
|
||||
* Handy debug function to check if error condition is because of test code or not.
|
||||
*/
|
||||
private static void printStackTrace(Thread thread) {
|
||||
if (thread == null) {
|
||||
return;
|
||||
}
|
||||
StackTraceElement[] stackTrace = thread.getStackTrace();
|
||||
log("Stack dump : Thread -> " + thread.getName());
|
||||
for (StackTraceElement stackTraceEl : stackTrace) {
|
||||
log("\t" + stackTraceEl.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (lock != null) {
|
||||
if (expectedState == Thread.State.BLOCKED) {
|
||||
int retryCount=0;
|
||||
while(info.getThreadState() != Thread.State.BLOCKED) {
|
||||
if (retryCount++ > 500) {
|
||||
throw new RuntimeException("Thread " + t.getName() +
|
||||
" is expected to block on " + expectedLock +
|
||||
" but got " + result +
|
||||
" Thread.State = " + info.getThreadState());
|
||||
}
|
||||
goSleep(100);
|
||||
info = tm.getThreadInfo(tid);
|
||||
result = info.getLockName();
|
||||
private static void assertThreadState(Thread t, Thread.State expectedState) {
|
||||
long tid = t.getId();
|
||||
if (expectedState == Thread.State.BLOCKED
|
||||
&& TM.getThreadInfo(tid).getThreadState() != Thread.State.BLOCKED) {
|
||||
int retryCount = 0;
|
||||
printStackTrace(t);
|
||||
while (TM.getThreadInfo(tid).getThreadState() != Thread.State.BLOCKED) {
|
||||
if (retryCount++ > 500) {
|
||||
printStackTrace(t);
|
||||
throw new RuntimeException("Thread " + t.getName() + " is at "
|
||||
+ TM.getThreadInfo(tid).getThreadState() + " state but is expected to "
|
||||
+ "be in Thread.State = " + expectedState);
|
||||
}
|
||||
}
|
||||
if (expectedState == Thread.State.WAITING &&
|
||||
info.getThreadState() != Thread.State.WAITING) {
|
||||
throw new RuntimeException("Thread " + t.getName() +
|
||||
" is expected to wait on " + expectedLock +
|
||||
" but got " + result +
|
||||
" Thread.State = " + info.getThreadState());
|
||||
goSleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
if ((result != null && !result.equals(expectedLock)) ||
|
||||
(result == null && expectedLock != null)) {
|
||||
throw new RuntimeException("Thread " + t.getName() + " is blocked on " +
|
||||
expectedLock + " but got " + result);
|
||||
}
|
||||
result = info.getLockOwnerName();
|
||||
if ((result != null && !result.equals(expectedOwner)) ||
|
||||
(result == null && expectedOwner != null)) {
|
||||
throw new RuntimeException("Owner of " + lock + " should be " +
|
||||
expectedOwner + " but got " + result);
|
||||
if (!TM.getThreadInfo(tid).getThreadState().equals(expectedState)) {
|
||||
printStackTrace(t);
|
||||
throw new RuntimeException("Thread " + t.getName() + " is at "
|
||||
+ TM.getThreadInfo(tid).getThreadState() + " state but is expected to "
|
||||
+ "be in Thread.State = " + expectedState);
|
||||
}
|
||||
}
|
||||
|
||||
private static void goSleep(long ms) {
|
||||
/*
|
||||
* Do slow check if thread is blocked on a lock. It is possible that last thread
|
||||
* to come out of Phaser might still be in Phaser call stack (Unsafe.park) and
|
||||
* hence might eventually acquire expected lock.
|
||||
*/
|
||||
private static void checkBlockedObject(Thread t, Object lock, Thread owner) {
|
||||
long tid = t.getId();
|
||||
String result = TM.getThreadInfo(tid).getLockName();
|
||||
final String expectedLock = (lock != null ? getLockName(lock) : null);
|
||||
Predicate<String> p = (res) -> ((res != null && !res.equals(expectedLock))
|
||||
|| (res == null && expectedLock != null));
|
||||
|
||||
if (p.test(result)) {
|
||||
printStackTrace(t);
|
||||
int retryCount = 0;
|
||||
while (p.test(result)) {
|
||||
if (retryCount++ > 500) {
|
||||
printStackTrace(t);
|
||||
throw new RuntimeException("Thread " + t.getName() + " is blocked on "
|
||||
+ expectedLock + " but got " + result);
|
||||
}
|
||||
goSleep(100);
|
||||
result = TM.getThreadInfo(tid).getLockName();
|
||||
}
|
||||
}
|
||||
|
||||
result = TM.getThreadInfo(tid).getLockOwnerName();
|
||||
final String expectedOwner = (owner != null ? owner.getName() : null);
|
||||
|
||||
p = (res) -> ((res != null && !res.equals(expectedOwner))
|
||||
|| (res == null && expectedOwner != null));
|
||||
if (p.test(result)) {
|
||||
printStackTrace(t);
|
||||
throw new RuntimeException("Owner of " + lock + " should be "
|
||||
+ expectedOwner + " but got " + result);
|
||||
}
|
||||
}
|
||||
|
||||
private static void goSleep(long ms){
|
||||
try {
|
||||
Thread.sleep(ms);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
testFailed = true;
|
||||
} catch (InterruptedException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,14 +165,15 @@ public class Locks {
|
||||
super("LockAThread");
|
||||
this.p = p;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized(objA) {
|
||||
// stop here for LockBThread to hold objB
|
||||
log("LockAThread about to block on objB");
|
||||
synchronized(OBJA) {
|
||||
// block here while LockBThread holds OBJB
|
||||
log("LockAThread about to block on OBJB");
|
||||
p.arriveAndAwaitAdvance(); // Phase 1 (blocking)
|
||||
synchronized(objB) {
|
||||
synchronized(OBJB) {
|
||||
dummyCounter++;
|
||||
};
|
||||
}
|
||||
}
|
||||
p.arriveAndAwaitAdvance(); // Phase 2 (blocking)
|
||||
log("LockAThread about to exit");
|
||||
@ -150,14 +188,15 @@ public class Locks {
|
||||
super("LockBThread");
|
||||
this.p = p;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized(objB) {
|
||||
log("LockBThread about to block on objC");
|
||||
synchronized(OBJB) {
|
||||
log("LockBThread about to block on OBJC");
|
||||
p.arriveAndAwaitAdvance(); // Phase 1 (blocking)
|
||||
// Signal main thread about to block on objC
|
||||
synchronized(objC) {
|
||||
// Signal main thread about to block on OBJC
|
||||
synchronized(OBJC) {
|
||||
dummyCounter++;
|
||||
};
|
||||
}
|
||||
}
|
||||
p.arriveAndAwaitAdvance(); // Phase 2 (blocking)
|
||||
log("LockBThread about to exit");
|
||||
@ -166,9 +205,30 @@ public class Locks {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Must be invoked from within a synchronized context
|
||||
*/
|
||||
private static class EnhancedWaiter {
|
||||
|
||||
boolean isNotified = false;
|
||||
|
||||
public void doWait() throws InterruptedException {
|
||||
while (!isNotified) {
|
||||
wait();
|
||||
}
|
||||
isNotified = false;
|
||||
}
|
||||
|
||||
public void doNotify() {
|
||||
isNotified = true;
|
||||
notify();
|
||||
}
|
||||
}
|
||||
|
||||
private static WaitingThread waiter;
|
||||
private static final Object ready = new Object();
|
||||
private static CheckerThread checker;
|
||||
|
||||
static class WaitingThread extends Thread {
|
||||
private final Phaser p;
|
||||
|
||||
@ -180,17 +240,16 @@ public class Locks {
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized(objC) {
|
||||
log("WaitingThread about to wait on objC");
|
||||
synchronized(OBJC) {
|
||||
log("WaitingThread about to wait on OBJC");
|
||||
try {
|
||||
// Signal checker thread, about to wait on objC.
|
||||
// Signal checker thread, about to wait on OBJC.
|
||||
waiting = false;
|
||||
p.arriveAndAwaitAdvance(); // Phase 1 (waiting)
|
||||
waiting = true;
|
||||
objC.wait();
|
||||
OBJC.doWait();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
testFailed = true;
|
||||
throw new RuntimeException(e); // Do not continue test
|
||||
}
|
||||
|
||||
// block until CheckerThread finishes checking
|
||||
@ -202,19 +261,18 @@ public class Locks {
|
||||
dummyCounter++;
|
||||
}
|
||||
}
|
||||
synchronized(objC) {
|
||||
synchronized(OBJC) {
|
||||
try {
|
||||
// signal checker thread, about to wait on objC
|
||||
// signal checker thread, about to wait on OBJC
|
||||
waiting = false;
|
||||
p.arriveAndAwaitAdvance(); // Phase 3 (waiting)
|
||||
waiting = true;
|
||||
objC.wait();
|
||||
OBJC.doWait();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
testFailed = true;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
log("WaitingThread about to exit waiting on objC 2");
|
||||
log("WaitingThread about to exit waiting on OBJC 2");
|
||||
}
|
||||
|
||||
public void waitForWaiting() {
|
||||
@ -241,85 +299,87 @@ public class Locks {
|
||||
super("CheckerThread");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (ready) {
|
||||
// wait until WaitingThread about to wait for objC
|
||||
synchronized(ready) {
|
||||
// wait until WaitingThread about to wait for OBJC
|
||||
waiter.waitForWaiting(); // Phase 1 (waiting)
|
||||
checkBlockedObject(waiter, objC, null, Thread.State.WAITING);
|
||||
assertThreadState(waiter, Thread.State.WAITING);
|
||||
checkBlockedObject(waiter, OBJC, null);
|
||||
|
||||
synchronized (objC) {
|
||||
objC.notify();
|
||||
synchronized(OBJC) {
|
||||
OBJC.doNotify();
|
||||
}
|
||||
|
||||
// wait for waiter thread to about to enter
|
||||
// synchronized object ready.
|
||||
waiter.waitForBlocked(); // Phase 2 (waiting)
|
||||
checkBlockedObject(waiter, ready, this, Thread.State.BLOCKED);
|
||||
assertThreadState(waiter, Thread.State.BLOCKED);
|
||||
checkBlockedObject(waiter, ready, this);
|
||||
}
|
||||
|
||||
// wait for signal from waiting thread that it is about
|
||||
// wait for objC.
|
||||
// wait for OBJC.
|
||||
waiter.waitForWaiting(); // Phase 3 (waiting)
|
||||
synchronized(objC) {
|
||||
checkBlockedObject(waiter, objC, Thread.currentThread(), Thread.State.WAITING);
|
||||
objC.notify();
|
||||
synchronized(OBJC) {
|
||||
assertThreadState(waiter, Thread.State.WAITING);
|
||||
checkBlockedObject(waiter, OBJC, Thread.currentThread());
|
||||
OBJC.doNotify();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
Thread mainThread = Thread.currentThread();
|
||||
|
||||
// Test uncontested case
|
||||
LockAThread t1;
|
||||
LockBThread t2;
|
||||
|
||||
Phaser p = new Phaser(3);
|
||||
synchronized(objC) {
|
||||
// Make sure the main thread is not holding any lock
|
||||
assertNoLock(mainThread);
|
||||
|
||||
// Test deadlock case
|
||||
// t1 holds lockA and attempts to lock B
|
||||
// t2 holds lockB and attempts to lock C
|
||||
|
||||
t1 = new LockAThread(p);
|
||||
t1.start();
|
||||
|
||||
t2 = new LockBThread(p);
|
||||
t2.start();
|
||||
|
||||
p.arriveAndAwaitAdvance(); // Phase 1 (blocking)
|
||||
checkBlockedObject(t2, objC, mainThread, Thread.State.BLOCKED);
|
||||
checkBlockedObject(t1, objB, t2, Thread.State.BLOCKED);
|
||||
|
||||
long[] expectedThreads = new long[3];
|
||||
expectedThreads[0] = t1.getId(); // blocked on lockB
|
||||
expectedThreads[1] = t2.getId(); // owner of lockB blocking on lockC
|
||||
expectedThreads[2] = mainThread.getId(); // owner of lockC
|
||||
findThreadsBlockedOn(objB, expectedThreads);
|
||||
}
|
||||
p.arriveAndAwaitAdvance(); // Phase 2 (blocking)
|
||||
|
||||
p = new Phaser(2);
|
||||
// Test Object.wait() case
|
||||
waiter = new WaitingThread(p);
|
||||
waiter.start();
|
||||
|
||||
checker = new CheckerThread();
|
||||
checker.start();
|
||||
|
||||
try {
|
||||
waiter.join();
|
||||
checker.join();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
testFailed = true;
|
||||
}
|
||||
Thread mainThread = Thread.currentThread();
|
||||
|
||||
if (testFailed) {
|
||||
throw new RuntimeException("TEST FAILED.");
|
||||
// Test uncontested case
|
||||
LockAThread t1;
|
||||
LockBThread t2;
|
||||
|
||||
Phaser p = new Phaser(3);
|
||||
synchronized(OBJC) {
|
||||
// Make sure the main thread is not holding any lock
|
||||
assertNoLock(mainThread);
|
||||
|
||||
// Test deadlock case
|
||||
// t1 holds lockA and attempts to lock B
|
||||
// t2 holds lockB and attempts to lock C
|
||||
t1 = new LockAThread(p);
|
||||
t1.start();
|
||||
|
||||
t2 = new LockBThread(p);
|
||||
t2.start();
|
||||
|
||||
p.arriveAndAwaitAdvance(); // Phase 1 (blocking)
|
||||
assertThreadState(t2, Thread.State.BLOCKED);
|
||||
checkBlockedObject(t2, OBJC, mainThread);
|
||||
assertThreadState(t1, Thread.State.BLOCKED);
|
||||
checkBlockedObject(t1, OBJB, t2);
|
||||
|
||||
long[] expectedThreads = new long[3];
|
||||
expectedThreads[0] = t1.getId(); // blocked on lockB
|
||||
expectedThreads[1] = t2.getId(); // owner of lockB blocking on lockC
|
||||
expectedThreads[2] = mainThread.getId(); // owner of lockC
|
||||
findThreadsBlockedOn(OBJB, expectedThreads);
|
||||
}
|
||||
p.arriveAndAwaitAdvance(); // Phase 2 (blocking)
|
||||
|
||||
p = new Phaser(2);
|
||||
// Test Object.wait() case
|
||||
waiter = new WaitingThread(p);
|
||||
waiter.start();
|
||||
|
||||
checker = new CheckerThread();
|
||||
checker.start();
|
||||
|
||||
try {
|
||||
waiter.join();
|
||||
checker.join();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} finally { // log all the messages to STDOUT
|
||||
System.out.println(LOGGER.toString());
|
||||
}
|
||||
System.out.println("Test passed.");
|
||||
}
|
||||
@ -335,9 +395,9 @@ public class Locks {
|
||||
throw new RuntimeException("TEST FAILED: " +
|
||||
lock + " expected to have owner");
|
||||
}
|
||||
for (int j = 0; j < infos.length; j++) {
|
||||
if (infos[j].getThreadId() == threadId) {
|
||||
ownerInfo = infos[j];
|
||||
for (ThreadInfo info1 : infos) {
|
||||
if (info1.getThreadId() == threadId) {
|
||||
ownerInfo = info1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -349,11 +409,11 @@ public class Locks {
|
||||
throws Exception {
|
||||
String lock = getLockName(o);
|
||||
// Check with ThreadInfo with no stack trace (i.e. no safepoint)
|
||||
ThreadInfo[] infos = tm.getThreadInfo(tm.getAllThreadIds());
|
||||
ThreadInfo[] infos = TM.getThreadInfo(TM.getAllThreadIds());
|
||||
doCheck(infos, lock, expectedThreads);
|
||||
|
||||
// Check with ThreadInfo with stack trace
|
||||
infos = tm.getThreadInfo(tm.getAllThreadIds(), 1);
|
||||
infos = TM.getThreadInfo(TM.getAllThreadIds(), 1);
|
||||
doCheck(infos, lock, expectedThreads);
|
||||
}
|
||||
|
||||
@ -376,7 +436,7 @@ public class Locks {
|
||||
long[] threads = new long[10];
|
||||
int count = 0;
|
||||
threads[count++] = ownerInfo.getThreadId();
|
||||
while (ownerInfo != null && ownerInfo.getThreadState() == Thread.State.BLOCKED) {
|
||||
while (ownerInfo.getThreadState() == Thread.State.BLOCKED) {
|
||||
ownerInfo = findOwnerInfo(infos, lock);
|
||||
threads[count++] = ownerInfo.getThreadId();
|
||||
log(" Owner = %s id = %d",
|
||||
@ -407,6 +467,6 @@ public class Locks {
|
||||
}
|
||||
|
||||
private static void log(String format, Object ... args) {
|
||||
logger.log(format + "%n", args);
|
||||
LOGGER.log(format + "%n", args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,292 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2016, 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 8132926
|
||||
* @summary PKIXParameters built with public key form of TrustAnchor causes
|
||||
* NPE during cert path building/validation
|
||||
* @run main ValWithAnchorByName
|
||||
*/
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.CertPath;
|
||||
import java.security.cert.CertPathValidator;
|
||||
import java.security.cert.PKIXParameters;
|
||||
import java.security.cert.PKIXRevocationChecker;
|
||||
import java.security.cert.TrustAnchor;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
// To get certpath debugging, add -Djava.security.debug=certpath
|
||||
|
||||
public class ValWithAnchorByName {
|
||||
|
||||
// The following certificates and OCSP responses were captured from
|
||||
// a test run that used certificates and responses generated by
|
||||
// sun.security.testlibrary.CertificateBuilder and
|
||||
// sun.security.testlibrary.SimpleOCSPServer.
|
||||
|
||||
// Subject: CN=SSLCertificate, O=SomeCompany
|
||||
// Issuer: CN=Intermediate CA Cert, O=SomeCompany
|
||||
// Validity: Tue Aug 30 14:37:19 PDT 2016 to Wed Aug 30 14:37:19 PDT 2017
|
||||
private static final String EE_CERT =
|
||||
"-----BEGIN CERTIFICATE-----\n" +
|
||||
"MIIDnTCCAoWgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTEUMBIGA1UEChMLU29t\n" +
|
||||
"ZUNvbXBhbnkxHTAbBgNVBAMTFEludGVybWVkaWF0ZSBDQSBDZXJ0MB4XDTE2MDgz\n" +
|
||||
"MDIxMzcxOVoXDTE3MDgzMDIxMzcxOVowLzEUMBIGA1UEChMLU29tZUNvbXBhbnkx\n" +
|
||||
"FzAVBgNVBAMTDlNTTENlcnRpZmljYXRlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" +
|
||||
"MIIBCgKCAQEAjgv8KKE4CO0rbCjRLA1hXjRiSq30jeusCJ8frbRG+QOBgQ3j6jgc\n" +
|
||||
"vk5wG1aTu7R4AFn0/HRDMzP9ZbRlZVIbJUTd8YiaNyZeyWapPnxHWrPCd5e1xopk\n" +
|
||||
"ElieDdEH5FiLGtIrWy56CGA1hfQb1vUVYegyeY+TTtMFVHt0PrmMk4ZRgj/GtVNp\n" +
|
||||
"BQQYIzaYAcrcWMeCn30ZrhaGAL1hsdgmEVV1wsTD4JeNMSwLwMYem7fg8ondGZIR\n" +
|
||||
"kZuGtuSdOHu4Xz+mgDNXTeX/Bp/dQFucxCG+FOOM9Hoz72RY2W8YqgL38RlnwYWp\n" +
|
||||
"nUNxhXWFH6vyINRQVEu3IgahR6HXjxM7LwIDAQABo4G8MIG5MBQGA1UdEQQNMAuC\n" +
|
||||
"CWxvY2FsaG9zdDAyBggrBgEFBQcBAQQmMCQwIgYIKwYBBQUHMAGGFmh0dHA6Ly9s\n" +
|
||||
"b2NhbGhvc3Q6NDIzMzMwHwYDVR0jBBgwFoAUYT525lwHCI4CmuWs8a7poaeKRJ4w\n" +
|
||||
"HQYDVR0OBBYEFCaQnOX4L1ovqyfeKuoay+kI+lXgMA4GA1UdDwEB/wQEAwIFoDAd\n" +
|
||||
"BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEB\n" +
|
||||
"AD8dqQIqFasJcL8lm4mPTsBl0JgNiN8tQcXM7VCvcH+yDvEyh9vudDjuhpSORqPq\n" +
|
||||
"f1o/EvJ+gfs269mBnYQujYRvmSd6EAcBntv5zn6amOh03o6PqTY9KaUC/mL9hB84\n" +
|
||||
"Y5/LYioP16sME7egKnlrGUgKh0ZvGzm7c3SYx3Z5YoeFBOkZajc7Jm+cBw/uBQkF\n" +
|
||||
"a9mLEczIvOgkq1wto8vr2ptH1gEuvFRcorN3muvq34bk40G08+AHlP3fCLFpI3FA\n" +
|
||||
"IStJLJZRcO+Ib4sOcKuaBGnuMo/QVOCEMDUs6RgiWtSd93OZKFIUOASVp6YIkcSs\n" +
|
||||
"5/rmc06sICqBjLfPEB68Jjw=\n" +
|
||||
"-----END CERTIFICATE-----";
|
||||
|
||||
// Subject: CN=Intermediate CA Cert, O=SomeCompany
|
||||
// Issuer: CN=Root CA Cert, O=SomeCompany
|
||||
// Validity: Sun Aug 07 14:37:19 PDT 2016 to Tue Aug 07 14:37:19 PDT 2018
|
||||
private static final String INT_CA_CERT =
|
||||
"-----BEGIN CERTIFICATE-----\n" +
|
||||
"MIIDdjCCAl6gAwIBAgIBZDANBgkqhkiG9w0BAQsFADAtMRQwEgYDVQQKEwtTb21l\n" +
|
||||
"Q29tcGFueTEVMBMGA1UEAxMMUm9vdCBDQSBDZXJ0MB4XDTE2MDgwNzIxMzcxOVoX\n" +
|
||||
"DTE4MDgwNzIxMzcxOVowNTEUMBIGA1UEChMLU29tZUNvbXBhbnkxHTAbBgNVBAMT\n" +
|
||||
"FEludGVybWVkaWF0ZSBDQSBDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n" +
|
||||
"CgKCAQEAnJR5CnE7GKlQjigExSJ6hHu302mc0PcA6TDgsIitPYD/r8RBbBuE51OQ\n" +
|
||||
"7IP7AXmfPUV3/+pO/uxx6mgY5O6XeUl7KadhVPtPcL0BVVevCSOdTMVa3iV4zRpa\n" +
|
||||
"C6Uy2ouUFnafKnDtlbieggyETUoNgVNJYA9L0XNhtSnENoLHC4Pq0v8OsNtsOWFR\n" +
|
||||
"NiMTOA49NNDBw85WgPyFAxjqO4z0J0zxdWq3W4rSMB8xrkulv2Rvj3GcfYJK/ab8\n" +
|
||||
"V1IJ6PMWCpujASY3BzvYPnN7BKuBjbWJPgZdPYfX1cxeG80u0tOuMfWWiNONSMSA\n" +
|
||||
"7m9y304QA0gKqlrFFn9U4hU89kv1IwIDAQABo4GYMIGVMA8GA1UdEwEB/wQFMAMB\n" +
|
||||
"Af8wMgYIKwYBBQUHAQEEJjAkMCIGCCsGAQUFBzABhhZodHRwOi8vbG9jYWxob3N0\n" +
|
||||
"OjM5MTM0MB8GA1UdIwQYMBaAFJNMsejEyJUB9tiWycVczvpiMVQZMB0GA1UdDgQW\n" +
|
||||
"BBRhPnbmXAcIjgKa5azxrumhp4pEnjAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcN\n" +
|
||||
"AQELBQADggEBAE4nOFdW9OirPnRvxihQXYL9CXLuGQz5tr0XgN8wSY6Un9b6CRiK\n" +
|
||||
"7obgIGimVdhvUC1qdRcwJqgOfJ2/jR5/5Qo0TVp+ww4dHNdUoj73tagJ7jTu0ZMz\n" +
|
||||
"5Zdp0uwd4RD/syvTeVcbPc3m4awtgEvRgzpDMcSeKPZWInlo7fbnowKSAUAfO8de\n" +
|
||||
"0cDkxEBkzPIzGNu256cdLZOqOK9wLJ9mQ0zKgi/2NsldNc2pl/6jkGpA6uL5lJsm\n" +
|
||||
"fo9sDusWNHV1YggqjDQ19hrf40VuuC9GFl/qAW3marMuEzY/NiKVUxty1q1s48SO\n" +
|
||||
"g5LoEPDDkbygOt7ICL3HYG1VufhC1Q2YY9c=\n" +
|
||||
"-----END CERTIFICATE-----";
|
||||
|
||||
// Subject: CN=Root CA Cert, O=SomeCompany
|
||||
// Issuer: CN=Root CA Cert, O=SomeCompany
|
||||
// Validity: Fri Jul 08 14:37:18 PDT 2016 to Fri Jun 28 14:37:18 PDT 2019
|
||||
private static final String ROOT_CA_CERT =
|
||||
"-----BEGIN CERTIFICATE-----\n" +
|
||||
"MIIDODCCAiCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAtMRQwEgYDVQQKEwtTb21l\n" +
|
||||
"Q29tcGFueTEVMBMGA1UEAxMMUm9vdCBDQSBDZXJ0MB4XDTE2MDcwODIxMzcxOFoX\n" +
|
||||
"DTE5MDYyODIxMzcxOFowLTEUMBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMT\n" +
|
||||
"DFJvb3QgQ0EgQ2VydDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIlN\n" +
|
||||
"M3WYEqkU2elXEZrV9QSDbDKwyaLEHafLFciH8Edoag3q/7jEzFJxI7JZ831tdbWQ\n" +
|
||||
"Bm6Hgo+8pvetOFW1BckL8eIjyOONP2CKfFaeMaozsWi1cgxa+rjpU/Rekc+zBqvv\n" +
|
||||
"y4Sr97TwT6nQiLlgjC1nCfR1SVpO51qoDChS7n785rsKEZxw/p+kkVWSZffU7zN9\n" +
|
||||
"c645cPg//L/kjiyeKMkaquGQOYS68gQgy8YZXQv1E3l/8e8Ci1s1DYA5wpCbaBqg\n" +
|
||||
"Tw84Rr4zlUEQBgXzQlRt+mPzeaDpdG1EeGkXrcdkZ+0EMELoOVXOEn6VNsz6vT3I\n" +
|
||||
"KrnvQBSnN06xq/iWwC0CAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSME\n" +
|
||||
"GDAWgBSTTLHoxMiVAfbYlsnFXM76YjFUGTAdBgNVHQ4EFgQUk0yx6MTIlQH22JbJ\n" +
|
||||
"xVzO+mIxVBkwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQAAi+Nl\n" +
|
||||
"sxP9t2IhiZIHRJGSBZuQlXIjwYIwbq3ZWc/ApZ+0oxtl7DYQi5uRNt8/opcGNCHc\n" +
|
||||
"IY0fG93SbkDubXbxPYBW6D/RUjbz59ZryaP5ym55p1MjHTOqy+AM8g41xNTJikc3\n" +
|
||||
"UUFXXnckeFbawijCsb7vf71owzKuxgBXi9n1rmXXtncKoA/LrUVXoUlKefdgDnsU\n" +
|
||||
"sl3Q29eibE3HSqziMMoAOLm0jjekFGWIgLeTtyRYR1d0dNaUwsHTrQpPjxxUTn1x\n" +
|
||||
"sAPpXKfzPnsYAZeeiaaE75GwbWlHzrNinvxdZQd0zctpfBJfVqD/+lWANlw+rOaK\n" +
|
||||
"J2GyCaJINsyaI/I2\n" +
|
||||
"-----END CERTIFICATE-----";
|
||||
|
||||
// OCSP Response Status: successful (0x0)
|
||||
// Response Type: Basic OCSP Response
|
||||
// Version: 1 (0x0)
|
||||
// Responder Id: CN=Intermediate CA Cert, O=SomeCompany
|
||||
// Produced At: Sep 6 21:37:20 2016 GMT
|
||||
// Responses:
|
||||
// Certificate ID:
|
||||
// Hash Algorithm: sha1
|
||||
// Issuer Name Hash: 7ED23D4396152EAB7D0C4AD8C1CA1418AA05DD54
|
||||
// Issuer Key Hash: 613E76E65C07088E029AE5ACF1AEE9A1A78A449E
|
||||
// Serial Number: 1000
|
||||
// Cert Status: good
|
||||
// This Update: Sep 6 21:37:20 2016 GMT
|
||||
// Next Update: Sep 6 22:37:19 2016 GMT
|
||||
private static final String EE_OCSP_RESP =
|
||||
"MIIFbAoBAKCCBWUwggVhBgkrBgEFBQcwAQEEggVSMIIFTjCBtaE3MDUxFDASBgNV\n" +
|
||||
"BAoTC1NvbWVDb21wYW55MR0wGwYDVQQDExRJbnRlcm1lZGlhdGUgQ0EgQ2VydBgP\n" +
|
||||
"MjAxNjA5MDYyMTM3MjBaMGUwYzA7MAkGBSsOAwIaBQAEFH7SPUOWFS6rfQxK2MHK\n" +
|
||||
"FBiqBd1UBBRhPnbmXAcIjgKa5azxrumhp4pEngICEACAABgPMjAxNjA5MDYyMTM3\n" +
|
||||
"MjBaoBEYDzIwMTYwOTA2MjIzNzE5WqECMAAwDQYJKoZIhvcNAQELBQADggEBAF13\n" +
|
||||
"cLwxDG8UYPIbzID86vZGOWUuv5c35VnvebMk/ajAUdpItDYshIQVi90Z8BB2TEi/\n" +
|
||||
"wtx1aNkIv7db0uQ0NnRfvME8vG2PWbty36CNAYr/M5UVzUmELH2sGTyf2fKfNIUK\n" +
|
||||
"Iya/NRxCqxLAc34NYH0YyGJ9VcDjbEMNSBAHIqDdBNqKUPnjn454yoivU2oEs294\n" +
|
||||
"cGePMx3QLyPepMwUss8nW74yIF7vxfJ+KFDBGWNuZDRfXScsGIoeM0Vt9B+4fmnV\n" +
|
||||
"nP4Dw6l3IwmQH4ppjg08qTKvyrXcF2dPDWa98Xw6bA5G085Z/b/6/6GpkvKx/q6i\n" +
|
||||
"UqKwF7q5hkDcB+N4/5SgggN+MIIDejCCA3YwggJeoAMCAQICAWQwDQYJKoZIhvcN\n" +
|
||||
"AQELBQAwLTEUMBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMTDFJvb3QgQ0Eg\n" +
|
||||
"Q2VydDAeFw0xNjA4MDcyMTM3MTlaFw0xODA4MDcyMTM3MTlaMDUxFDASBgNVBAoT\n" +
|
||||
"C1NvbWVDb21wYW55MR0wGwYDVQQDExRJbnRlcm1lZGlhdGUgQ0EgQ2VydDCCASIw\n" +
|
||||
"DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJyUeQpxOxipUI4oBMUieoR7t9Np\n" +
|
||||
"nND3AOkw4LCIrT2A/6/EQWwbhOdTkOyD+wF5nz1Fd//qTv7scepoGOTul3lJeymn\n" +
|
||||
"YVT7T3C9AVVXrwkjnUzFWt4leM0aWgulMtqLlBZ2nypw7ZW4noIMhE1KDYFTSWAP\n" +
|
||||
"S9FzYbUpxDaCxwuD6tL/DrDbbDlhUTYjEzgOPTTQwcPOVoD8hQMY6juM9CdM8XVq\n" +
|
||||
"t1uK0jAfMa5Lpb9kb49xnH2CSv2m/FdSCejzFgqbowEmNwc72D5zewSrgY21iT4G\n" +
|
||||
"XT2H19XMXhvNLtLTrjH1lojTjUjEgO5vct9OEANICqpaxRZ/VOIVPPZL9SMCAwEA\n" +
|
||||
"AaOBmDCBlTAPBgNVHRMBAf8EBTADAQH/MDIGCCsGAQUFBwEBBCYwJDAiBggrBgEF\n" +
|
||||
"BQcwAYYWaHR0cDovL2xvY2FsaG9zdDozOTEzNDAfBgNVHSMEGDAWgBSTTLHoxMiV\n" +
|
||||
"AfbYlsnFXM76YjFUGTAdBgNVHQ4EFgQUYT525lwHCI4CmuWs8a7poaeKRJ4wDgYD\n" +
|
||||
"VR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQBOJzhXVvToqz50b8YoUF2C\n" +
|
||||
"/Qly7hkM+ba9F4DfMEmOlJ/W+gkYiu6G4CBoplXYb1AtanUXMCaoDnydv40ef+UK\n" +
|
||||
"NE1afsMOHRzXVKI+97WoCe407tGTM+WXadLsHeEQ/7Mr03lXGz3N5uGsLYBL0YM6\n" +
|
||||
"QzHEnij2ViJ5aO3256MCkgFAHzvHXtHA5MRAZMzyMxjbtuenHS2TqjivcCyfZkNM\n" +
|
||||
"yoIv9jbJXTXNqZf+o5BqQOri+ZSbJn6PbA7rFjR1dWIIKow0NfYa3+NFbrgvRhZf\n" +
|
||||
"6gFt5mqzLhM2PzYilVMbctatbOPEjoOS6BDww5G8oDreyAi9x2BtVbn4QtUNmGPX";
|
||||
|
||||
// OCSP Response Status: successful (0x0)
|
||||
// Response Type: Basic OCSP Response
|
||||
// Version: 1 (0x0)
|
||||
// Responder Id: O = SomeCompany, CN = Root CA Cert
|
||||
// Produced At: Sep 6 21:37:20 2016 GMT
|
||||
// Responses:
|
||||
// Certificate ID:
|
||||
// Hash Algorithm: sha1
|
||||
// Issuer Name Hash: C8ED9F4E9AC0052A978257C569E6A7C9C45F5CB5
|
||||
// Issuer Key Hash: 934CB1E8C4C89501F6D896C9C55CCEFA62315419
|
||||
// Serial Number: 64
|
||||
// Cert Status: good
|
||||
// This Update: Sep 6 21:37:20 2016 GMT
|
||||
// Next Update: Sep 6 22:37:19 2016 GMT
|
||||
private static final String INT_CA_OCSP_RESP =
|
||||
"MIIFJQoBAKCCBR4wggUaBgkrBgEFBQcwAQEEggULMIIFBzCBrKEvMC0xFDASBgNV\n" +
|
||||
"BAoTC1NvbWVDb21wYW55MRUwEwYDVQQDEwxSb290IENBIENlcnQYDzIwMTYwOTA2\n" +
|
||||
"MjEzNzIwWjBkMGIwOjAJBgUrDgMCGgUABBTI7Z9OmsAFKpeCV8Vp5qfJxF9ctQQU\n" +
|
||||
"k0yx6MTIlQH22JbJxVzO+mIxVBkCAWSAABgPMjAxNjA5MDYyMTM3MjBaoBEYDzIw\n" +
|
||||
"MTYwOTA2MjIzNzE5WqECMAAwDQYJKoZIhvcNAQELBQADggEBAAgs8jpuEejPD8qO\n" +
|
||||
"+xckvqMz/5pItOHaSB0xyPNpIapqjcDkLktJdBVq5XJWernO9DU+P7yr7TDbvo6h\n" +
|
||||
"P5jBZklLz16Z1aRlEyow2jhelVjNl6nxoiij/6LOGK4tLHa8fK7hTB4Ykw22Bxzt\n" +
|
||||
"LcbrU5jgUDhdZkTrs+rWM8nw7mVWIQYQfwzCMDZ5a02MxzhdwggJGRzqMrbhY/Q7\n" +
|
||||
"RRUK3ohSgzHmLjVkvA0KeM/Px7EefzbEbww08fSsLybmBoIEbcckWSHkkXx4cuIR\n" +
|
||||
"T9FiTz4Ms4r8qzPCo61qeklE2I5lfnfieROADV6sfwbul/0U1HqKhHVaxJ8yYw+T\n" +
|
||||
"/FMxrUKgggNAMIIDPDCCAzgwggIgoAMCAQICAQEwDQYJKoZIhvcNAQELBQAwLTEU\n" +
|
||||
"MBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMTDFJvb3QgQ0EgQ2VydDAeFw0x\n" +
|
||||
"NjA3MDgyMTM3MThaFw0xOTA2MjgyMTM3MThaMC0xFDASBgNVBAoTC1NvbWVDb21w\n" +
|
||||
"YW55MRUwEwYDVQQDEwxSb290IENBIENlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IB\n" +
|
||||
"DwAwggEKAoIBAQCJTTN1mBKpFNnpVxGa1fUEg2wysMmixB2nyxXIh/BHaGoN6v+4\n" +
|
||||
"xMxScSOyWfN9bXW1kAZuh4KPvKb3rThVtQXJC/HiI8jjjT9ginxWnjGqM7FotXIM\n" +
|
||||
"Wvq46VP0XpHPswar78uEq/e08E+p0Ii5YIwtZwn0dUlaTudaqAwoUu5+/Oa7ChGc\n" +
|
||||
"cP6fpJFVkmX31O8zfXOuOXD4P/y/5I4snijJGqrhkDmEuvIEIMvGGV0L9RN5f/Hv\n" +
|
||||
"AotbNQ2AOcKQm2gaoE8POEa+M5VBEAYF80JUbfpj83mg6XRtRHhpF63HZGftBDBC\n" +
|
||||
"6DlVzhJ+lTbM+r09yCq570AUpzdOsav4lsAtAgMBAAGjYzBhMA8GA1UdEwEB/wQF\n" +
|
||||
"MAMBAf8wHwYDVR0jBBgwFoAUk0yx6MTIlQH22JbJxVzO+mIxVBkwHQYDVR0OBBYE\n" +
|
||||
"FJNMsejEyJUB9tiWycVczvpiMVQZMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0B\n" +
|
||||
"AQsFAAOCAQEAAIvjZbMT/bdiIYmSB0SRkgWbkJVyI8GCMG6t2VnPwKWftKMbZew2\n" +
|
||||
"EIubkTbfP6KXBjQh3CGNHxvd0m5A7m128T2AVug/0VI28+fWa8mj+cpueadTIx0z\n" +
|
||||
"qsvgDPIONcTUyYpHN1FBV153JHhW2sIowrG+73+9aMMyrsYAV4vZ9a5l17Z3CqAP\n" +
|
||||
"y61FV6FJSnn3YA57FLJd0NvXomxNx0qs4jDKADi5tI43pBRliIC3k7ckWEdXdHTW\n" +
|
||||
"lMLB060KT48cVE59cbAD6Vyn8z57GAGXnommhO+RsG1pR86zYp78XWUHdM3LaXwS\n" +
|
||||
"X1ag//pVgDZcPqzmiidhsgmiSDbMmiPyNg==";
|
||||
|
||||
// Do path validation as if it is always Tue, 06 Sep 2016 22:12:21 GMT
|
||||
// This value is within the lifetimes of all certificates and both OCSP
|
||||
// responses.
|
||||
private static final Date EVAL_DATE = new Date(1473199941000L);
|
||||
|
||||
private static final Base64.Decoder DECODER = Base64.getMimeDecoder();
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
TrustAnchor anchor;
|
||||
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
||||
X509Certificate rootCert = generateCertificate(cf, ROOT_CA_CERT);
|
||||
X509Certificate eeCert = generateCertificate(cf, EE_CERT);
|
||||
X509Certificate intCaCert = generateCertificate(cf, INT_CA_CERT);
|
||||
List<X509Certificate> certList = new ArrayList<X509Certificate>() {{
|
||||
add(eeCert);
|
||||
add(intCaCert);
|
||||
}};
|
||||
|
||||
System.out.println("==== Certificate Path =====");
|
||||
for (X509Certificate c : certList) {
|
||||
System.out.println(c + "\n");
|
||||
}
|
||||
System.out.println("===========================");
|
||||
|
||||
System.out.println("===== Test 1: TA(X509Certificate) =====");
|
||||
anchor = new TrustAnchor(rootCert, null);
|
||||
runTest(cf, certList, anchor);
|
||||
|
||||
System.out.println("===== Test 2: TA(X500Principal, PublicKey =====");
|
||||
anchor = new TrustAnchor(rootCert.getSubjectX500Principal(),
|
||||
rootCert.getPublicKey(), null);
|
||||
runTest(cf, certList, anchor);
|
||||
|
||||
System.out.println("===== Test 3: TA(String, PublicKey =====");
|
||||
anchor = new TrustAnchor(rootCert.getSubjectX500Principal().getName(),
|
||||
rootCert.getPublicKey(), null);
|
||||
runTest(cf, certList, anchor);
|
||||
}
|
||||
|
||||
private static void runTest(CertificateFactory cf,
|
||||
List<X509Certificate> certList, TrustAnchor anchor)
|
||||
throws Exception {
|
||||
CertPath path = cf.generateCertPath(certList);
|
||||
CertPathValidator validator = CertPathValidator.getInstance("PKIX");
|
||||
|
||||
System.out.println(anchor);
|
||||
|
||||
// Attach the OCSP responses to a PKIXParameters object
|
||||
PKIXRevocationChecker pkrev =
|
||||
(PKIXRevocationChecker)validator.getRevocationChecker();
|
||||
Map<X509Certificate, byte[]> responseMap = new HashMap<>();
|
||||
responseMap.put(certList.get(0), DECODER.decode(EE_OCSP_RESP));
|
||||
responseMap.put(certList.get(1), DECODER.decode(INT_CA_OCSP_RESP));
|
||||
pkrev.setOcspResponses(responseMap);
|
||||
PKIXParameters params =
|
||||
new PKIXParameters(Collections.singleton(anchor));
|
||||
params.addCertPathChecker(pkrev);
|
||||
params.setDate(EVAL_DATE);
|
||||
|
||||
validator.validate(path, params);
|
||||
}
|
||||
|
||||
private static X509Certificate generateCertificate(CertificateFactory cf,
|
||||
String encoded) throws CertificateException {
|
||||
ByteArrayInputStream is = new ByteArrayInputStream(encoded.getBytes());
|
||||
return (X509Certificate)cf.generateCertificate(is);
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
# JDBC unit tests uses TestNG
|
||||
TestNG.dirs = .
|
||||
othervm.dirs = test/sql/othervm
|
||||
|
||||
|
||||
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
package test.sql.othervm;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.CharArrayReader;
|
||||
import java.io.CharArrayWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Driver;
|
||||
import java.sql.DriverManager;
|
||||
import java.util.Enumeration;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class DriverManagerInitTests {
|
||||
|
||||
/**
|
||||
* Validate that when DriverManager loads the initial JDBC drivers, that the
|
||||
* output from DriverManager.println is available by verifying that the
|
||||
* String "JDBC DriverManager initialized" is found
|
||||
*/
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
CharArrayWriter cw = new CharArrayWriter();
|
||||
PrintWriter pw = new PrintWriter(cw);
|
||||
DriverManager.setLogWriter(pw);
|
||||
Enumeration<Driver> drivers = DriverManager.getDrivers();
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new CharArrayReader(cw.toCharArray()))) {
|
||||
boolean result
|
||||
= reader.lines().anyMatch(
|
||||
line -> line.matches(".*JDBC DriverManager initialized.*"));
|
||||
assertTrue(result);
|
||||
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(DriverManagerInitTests.class.getName()).log(Level.SEVERE, null, ex);
|
||||
fail();
|
||||
}
|
||||
|
||||
// Check to verify that we are not initializing a 2nd time
|
||||
cw = new CharArrayWriter();
|
||||
pw = new PrintWriter(cw);
|
||||
DriverManager.setLogWriter(pw);
|
||||
drivers = DriverManager.getDrivers();
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new CharArrayReader(cw.toCharArray()))) {
|
||||
boolean result
|
||||
= reader.lines().noneMatch(
|
||||
line -> line.matches(".*JDBC DriverManager initialized.*"));
|
||||
assertTrue(result);
|
||||
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(DriverManagerInitTests.class.getName()).log(Level.SEVERE, null, ex);
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -50,110 +50,110 @@ public class Bug4322313 extends IntlTest {
|
||||
|
||||
Object[][] valids = {
|
||||
/* given ID offset format('z'), ('Z') index */
|
||||
{"GMT+03:04", new Long(-184 * mpm), "GMT+03:04", "+0304", new Integer(9)},
|
||||
{"GMT+13:42", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(9)},
|
||||
{"GMT+00:00", new Long(0), "GMT+00:00", "+0000", new Integer(9)},
|
||||
{"GMT+1:11", new Long(-71 * mpm), "GMT+01:11", "+0111", new Integer(8)},
|
||||
{"GMT +13:42", new Long(0), "GMT", "+0000", new Integer(3)},
|
||||
{" GMT", new Long(0), "GMT", "+0000", new Integer(4)},
|
||||
{"+0304", new Long(-184 * mpm), "GMT+03:04", "+0304", new Integer(5)},
|
||||
{"+1342", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(5)},
|
||||
{"+0000", new Long(0), "GMT+00:00", "+0000", new Integer(5)},
|
||||
{" +1342", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(6)},
|
||||
{"GMT+03:04", -184L * mpm, "GMT+03:04", "+0304", 9},
|
||||
{"GMT+13:42", -822L * mpm, "GMT+13:42", "+1342", 9},
|
||||
{"GMT+00:00", 0L, "GMT+00:00", "+0000", 9},
|
||||
{"GMT+1:11", -71L * mpm, "GMT+01:11", "+0111", 8},
|
||||
{"GMT +13:42", 0L, "GMT", "+0000", 3},
|
||||
{" GMT", 0L, "GMT", "+0000", 4},
|
||||
{"+0304", -184L * mpm, "GMT+03:04", "+0304", 5},
|
||||
{"+1342", -822L * mpm, "GMT+13:42", "+1342", 5},
|
||||
{"+0000", 0L, "GMT+00:00", "+0000", 5},
|
||||
{" +1342", -822L * mpm, "GMT+13:42", "+1342", 6},
|
||||
/* ISO-LATIN-1 digits */
|
||||
{"GMT+\u0030\u0031:\u0032\u0033", new Long(-83 * mpm), "GMT+01:23", "+0123", new Integer(9)},
|
||||
{"GMT+\u0030\u0031:\u0032\u0033", -83L * mpm, "GMT+01:23", "+0123", 9},
|
||||
|
||||
/* In fact, this test case is skipped because TimeZone class can't
|
||||
* recognize TimeZone IDs like "+00234" or "-00234".
|
||||
*/
|
||||
{"+00234", new Long(-23 * mpm), "GMT+00:23", "+0023", new Integer(5)},
|
||||
{"+00234", -23L * mpm, "GMT+00:23", "+0023", 5},
|
||||
|
||||
{"GMT-03:04", new Long(184 * mpm), "GMT-03:04", "-0304", new Integer(9)},
|
||||
{"GMT-13:42", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(9)},
|
||||
{"GMT-00:00", new Long(0), "GMT+00:00", "+0000", new Integer(9)},
|
||||
{"GMT-1:11", new Long(71 * mpm), "GMT-01:11", "-0111", new Integer(8)},
|
||||
{"GMT -13:42", new Long(0), "GMT", "+0000", new Integer(3)},
|
||||
{"-0304", new Long(184 * mpm), "GMT-03:04", "-0304", new Integer(5)},
|
||||
{"-1342", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(5)},
|
||||
{" -1342", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(6)},
|
||||
{"GMT-03:04", 184L * mpm, "GMT-03:04", "-0304", 9},
|
||||
{"GMT-13:42", 822L * mpm, "GMT-13:42", "-1342", 9},
|
||||
{"GMT-00:00", 0L, "GMT+00:00", "+0000", 9},
|
||||
{"GMT-1:11", 71L * mpm, "GMT-01:11", "-0111", 8},
|
||||
{"GMT -13:42", 0L, "GMT", "+0000", 3},
|
||||
{"-0304", 184L * mpm, "GMT-03:04", "-0304", 5},
|
||||
{"-1342", 822L * mpm, "GMT-13:42", "-1342", 5},
|
||||
{" -1342", 822L * mpm, "GMT-13:42", "-1342", 6},
|
||||
/* ISO-LATIN-1 digits */
|
||||
{"GMT-\u0030\u0031:\u0032\u0033", new Long(83 * mpm), "GMT-01:23", "-0123", new Integer(9)},
|
||||
{"GMT-\u0030\u0031:\u0032\u0033", 83L * mpm, "GMT-01:23", "-0123", 9},
|
||||
/* In fact, this test case is skipped because TimeZone class can't
|
||||
* recognize TimeZone IDs like "+00234" or "-00234".
|
||||
*/
|
||||
{"-00234", new Long(23 * mpm), "GMT+00:23", "-0023", new Integer(5)},
|
||||
{"-00234", 23L * mpm, "GMT+00:23", "-0023", 5},
|
||||
};
|
||||
|
||||
Object[][] invalids = {
|
||||
/* given ID error index */
|
||||
{"GMT+8", new Integer(5)},
|
||||
{"GMT+18", new Integer(6)},
|
||||
{"GMT+208", new Integer(6)},
|
||||
{"GMT+0304", new Integer(6)},
|
||||
{"GMT+42195", new Integer(5)},
|
||||
{"GMT+5:8", new Integer(7)},
|
||||
{"GMT+23:60", new Integer(8)},
|
||||
{"GMT+11:1", new Integer(8)},
|
||||
{"GMT+24:13", new Integer(5)},
|
||||
{"GMT+421:950", new Integer(5)},
|
||||
{"GMT+0a:0A", new Integer(5)},
|
||||
{"GMT+ 13:42", new Integer(4)},
|
||||
{"GMT+13 :42", new Integer(6)},
|
||||
{"GMT+13: 42", new Integer(7)},
|
||||
{"GMT+-13:42", new Integer(4)},
|
||||
{"G M T", new Integer(0)},
|
||||
{"+8", new Integer(2)},
|
||||
{"+18", new Integer(3)},
|
||||
{"+208", new Integer(4)},
|
||||
{"+2360", new Integer(4)},
|
||||
{"+2413", new Integer(2)},
|
||||
{"+42195", new Integer(2)},
|
||||
{"+0AbC", new Integer(2)},
|
||||
{"+ 1342", new Integer(1)},
|
||||
{"+-1342", new Integer(1)},
|
||||
{"1342", new Integer(0)},
|
||||
{"GMT+8", 5},
|
||||
{"GMT+18", 6},
|
||||
{"GMT+208", 6},
|
||||
{"GMT+0304", 6},
|
||||
{"GMT+42195", 5},
|
||||
{"GMT+5:8", 7},
|
||||
{"GMT+23:60", 8},
|
||||
{"GMT+11:1", 8},
|
||||
{"GMT+24:13", 5},
|
||||
{"GMT+421:950", 5},
|
||||
{"GMT+0a:0A", 5},
|
||||
{"GMT+ 13:42", 4},
|
||||
{"GMT+13 :42", 6},
|
||||
{"GMT+13: 42", 7},
|
||||
{"GMT+-13:42", 4},
|
||||
{"G M T", 0},
|
||||
{"+8", 2},
|
||||
{"+18", 3},
|
||||
{"+208", 4},
|
||||
{"+2360", 4},
|
||||
{"+2413", 2},
|
||||
{"+42195", 2},
|
||||
{"+0AbC", 2},
|
||||
{"+ 1342", 1},
|
||||
{"+-1342", 1},
|
||||
{"1342", 0},
|
||||
/* Arabic-Indic digits */
|
||||
{"GMT+\u0660\u0661:\u0662\u0663", new Integer(4)},
|
||||
{"GMT+\u0660\u0661:\u0662\u0663", 4},
|
||||
/* Extended Arabic-Indic digits */
|
||||
{"GMT+\u06f0\u06f1:\u06f2\u06f3", new Integer(4)},
|
||||
{"GMT+\u06f0\u06f1:\u06f2\u06f3", 4},
|
||||
/* Devanagari digits */
|
||||
{"GMT+\u0966\u0967:\u0968\u0969", new Integer(4)},
|
||||
{"GMT+\u0966\u0967:\u0968\u0969", 4},
|
||||
/* Fullwidth digits */
|
||||
{"GMT+\uFF10\uFF11:\uFF12\uFF13", new Integer(4)},
|
||||
{"GMT+\uFF10\uFF11:\uFF12\uFF13", 4},
|
||||
|
||||
{"GMT-8", new Integer(5)},
|
||||
{"GMT-18", new Integer(6)},
|
||||
{"GMT-208", new Integer(6)},
|
||||
{"GMT-0304", new Integer(6)},
|
||||
{"GMT-42195", new Integer(5)},
|
||||
{"GMT-5:8", new Integer(7)},
|
||||
{"GMT-23:60", new Integer(8)},
|
||||
{"GMT-11:1", new Integer(8)},
|
||||
{"GMT-24:13", new Integer(5)},
|
||||
{"GMT-421:950", new Integer(5)},
|
||||
{"GMT-0a:0A", new Integer(5)},
|
||||
{"GMT- 13:42", new Integer(4)},
|
||||
{"GMT-13 :42", new Integer(6)},
|
||||
{"GMT-13: 42", new Integer(7)},
|
||||
{"GMT-+13:42", new Integer(4)},
|
||||
{"-8", new Integer(2)},
|
||||
{"-18", new Integer(3)},
|
||||
{"-208", new Integer(4)},
|
||||
{"-2360", new Integer(4)},
|
||||
{"-2413", new Integer(2)},
|
||||
{"-42195", new Integer(2)},
|
||||
{"-0AbC", new Integer(2)},
|
||||
{"- 1342", new Integer(1)},
|
||||
{"--1342", new Integer(1)},
|
||||
{"-802", new Integer(2)},
|
||||
{"GMT-8", 5},
|
||||
{"GMT-18", 6},
|
||||
{"GMT-208", 6},
|
||||
{"GMT-0304", 6},
|
||||
{"GMT-42195", 5},
|
||||
{"GMT-5:8", 7},
|
||||
{"GMT-23:60", 8},
|
||||
{"GMT-11:1", 8},
|
||||
{"GMT-24:13", 5},
|
||||
{"GMT-421:950", 5},
|
||||
{"GMT-0a:0A", 5},
|
||||
{"GMT- 13:42", 4},
|
||||
{"GMT-13 :42", 6},
|
||||
{"GMT-13: 42", 7},
|
||||
{"GMT-+13:42", 4},
|
||||
{"-8", 2},
|
||||
{"-18", 3},
|
||||
{"-208", 4},
|
||||
{"-2360", 4},
|
||||
{"-2413", 2},
|
||||
{"-42195", 2},
|
||||
{"-0AbC", 2},
|
||||
{"- 1342", 1},
|
||||
{"--1342", 1},
|
||||
{"-802", 2},
|
||||
/* Arabic-Indic digits */
|
||||
{"GMT-\u0660\u0661:\u0662\u0663", new Integer(4)},
|
||||
{"GMT-\u0660\u0661:\u0662\u0663", 4},
|
||||
/* Extended Arabic-Indic digits */
|
||||
{"GMT-\u06f0\u06f1:\u06f2\u06f3", new Integer(4)},
|
||||
{"GMT-\u06f0\u06f1:\u06f2\u06f3", 4},
|
||||
/* Devanagari digits */
|
||||
{"GMT-\u0966\u0967:\u0968\u0969", new Integer(4)},
|
||||
{"GMT-\u0966\u0967:\u0968\u0969", 4},
|
||||
/* Fullwidth digits */
|
||||
{"GMT-\uFF10\uFF11:\uFF12\uFF13", new Integer(4)},
|
||||
{"GMT-\uFF10\uFF11:\uFF12\uFF13", 4},
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Bug4736959 {
|
||||
/**
|
||||
* 4736959: JSpinner won't work for AM/PM field
|
||||
|
||||
@ -685,8 +685,8 @@ public class Bug4823811 {
|
||||
testNumberFormatFormatting(nfEG, -456, "456-", "ar_EG");
|
||||
|
||||
System.out.println("*** DecimalFormat.parse test in ar_EG");
|
||||
testNumberFormatParsing(nfEG, "123-", new Long(-123), "ar_EG");
|
||||
testNumberFormatParsing(nfEG, "123--", new Long(-123), "ar_EG");
|
||||
testNumberFormatParsing(nfEG, "123-", -123L, "ar_EG");
|
||||
testNumberFormatParsing(nfEG, "123--",-123L, "ar_EG");
|
||||
testNumberFormatParsingCheckException(nfEG, "-123", 0, "ar_EG");
|
||||
|
||||
System.out.println("*** DecimalFormat.format test in en_US");
|
||||
@ -694,8 +694,8 @@ public class Bug4823811 {
|
||||
testNumberFormatFormatting(nfUS, -456, "-456", "en_US");
|
||||
|
||||
System.out.println("*** DecimalFormat.parse test in en_US");
|
||||
testNumberFormatParsing(nfUS, "123-", new Long(123), "en_US");
|
||||
testNumberFormatParsing(nfUS, "-123", new Long(-123), "en_US");
|
||||
testNumberFormatParsing(nfUS, "123-", 123L, "en_US");
|
||||
testNumberFormatParsing(nfUS, "-123",-123L, "en_US");
|
||||
testNumberFormatParsingCheckException(nfUS, "--123", 0, "en_US");
|
||||
}
|
||||
|
||||
|
||||
@ -55,6 +55,7 @@ public class Bug4845901 {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static void testParse(SimpleDateFormat sdf, String str, int expectedHour) {
|
||||
try {
|
||||
Date parsedDate = sdf.parse(str);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2016, 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
|
||||
@ -37,6 +37,7 @@ public class Bug6609750 {
|
||||
Locale defaultLocale = Locale.getDefault();
|
||||
Locale.setDefault(Locale.US);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Date[] dates = {
|
||||
new Date(9-1900, Calendar.JUNE, 12),
|
||||
new Date(99-1900, Calendar.JUNE, 12),
|
||||
|
||||
@ -66,6 +66,7 @@ public class Bug6683975 {
|
||||
System.err.println("\tth_TH: " + str_th_TH);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Date date = new Date(2008-1900, Calendar.SEPTEMBER, 30, 8, 0, 0);
|
||||
str_th = df_th.format(date);
|
||||
if (!expected_th[style].equals(str_th)) {
|
||||
|
||||
@ -41,7 +41,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
}
|
||||
|
||||
public void Test4029195() {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Date today = new Date();
|
||||
|
||||
logln("today: " + today);
|
||||
@ -74,19 +74,20 @@ public class DateFormatRegression extends IntlTest {
|
||||
public void Test4052408() {
|
||||
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT,
|
||||
DateFormat.SHORT, Locale.US);
|
||||
@SuppressWarnings("deprecation")
|
||||
Date date = new Date(97, Calendar.MAY, 3, 8, 55);
|
||||
String str;
|
||||
logln(str = fmt.format(date));
|
||||
|
||||
if (!str.equals("5/3/97 8:55 AM"))
|
||||
errln("Fail: Test broken; Want 5/3/97 8:55 AM Got " + str);
|
||||
Hashtable expected = new Hashtable();
|
||||
expected.put(new Integer(DateFormat.MONTH_FIELD), "5");
|
||||
expected.put(new Integer(DateFormat.DATE_FIELD), "3");
|
||||
expected.put(new Integer(DateFormat.YEAR_FIELD), "97");
|
||||
expected.put(new Integer(DateFormat.HOUR1_FIELD), "8");
|
||||
expected.put(new Integer(DateFormat.MINUTE_FIELD), "55");
|
||||
expected.put(new Integer(DateFormat.AM_PM_FIELD), "AM");
|
||||
Map<Integer,String> expected = new HashMap<>();
|
||||
expected.put(DateFormat.MONTH_FIELD, "5");
|
||||
expected.put(DateFormat.DATE_FIELD, "3");
|
||||
expected.put(DateFormat.YEAR_FIELD, "97");
|
||||
expected.put(DateFormat.HOUR1_FIELD, "8");
|
||||
expected.put(DateFormat.MINUTE_FIELD, "55");
|
||||
expected.put(DateFormat.AM_PM_FIELD, "AM");
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
String fieldNames[] = {
|
||||
@ -120,7 +121,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
", \"" + str + "\", " +
|
||||
pos.getBeginIndex() + ", " +
|
||||
pos.getEndIndex());
|
||||
String exp = (String) expected.get(new Integer(i));
|
||||
String exp = expected.get(i);
|
||||
if ((exp == null && str.length() == 0) ||
|
||||
str.equals(exp))
|
||||
logln(" ok");
|
||||
@ -135,6 +136,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
/**
|
||||
* Verify the function of the [s|g]et2DigitYearStart() API.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void Test4056591() {
|
||||
try {
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("yyMMdd", Locale.US);
|
||||
@ -255,6 +257,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
if (!ok) errln("Fail: Lenient not working");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void Test4065240() {
|
||||
Date curDate;
|
||||
DateFormat shortdate, fulldate;
|
||||
@ -297,6 +300,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
|
||||
Currently this bug breaks MessageFormat.toPattern
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void Test4071441() {
|
||||
DateFormat fmtA = DateFormat.getInstance();
|
||||
DateFormat fmtB = DateFormat.getInstance();
|
||||
@ -488,6 +492,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
public void Test4101483() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("z", Locale.US);
|
||||
FieldPosition fp = new FieldPosition(DateFormat.TIMEZONE_FIELD);
|
||||
@SuppressWarnings("deprecation")
|
||||
Date d= new Date(9234567890L);
|
||||
StringBuffer buf = new StringBuffer("");
|
||||
logln(sdf.format(d, buf, fp).toString());
|
||||
@ -508,6 +513,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
public void Test4103340() {
|
||||
// choose a date that is the FIRST of some month
|
||||
// and some arbitrary time
|
||||
@SuppressWarnings("deprecation")
|
||||
Date d=new Date(97, 3, 1, 1, 1, 1);
|
||||
SimpleDateFormat df=new SimpleDateFormat("MMMM", Locale.US);
|
||||
|
||||
@ -538,6 +544,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
sdf.applyPattern(pattern);
|
||||
logln("pattern: \"" + pattern + "\"");
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Object[] DATA = {
|
||||
"time 10:30", new ParsePosition(10), new Date(70, Calendar.JANUARY, 1, 10, 30),
|
||||
"time 10:x", new ParsePosition(0), null,
|
||||
@ -698,6 +705,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
String pattern = "'TO_DATE('''dd'-'MM'-'yyyy HH:mm:ss''' , ''DD-MM-YYYY HH:MI:SS'')'";
|
||||
logln("pattern=" + pattern);
|
||||
SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US);
|
||||
@SuppressWarnings("deprecation")
|
||||
String result = format.format(new Date(1998-1900, Calendar.JUNE, 30, 13, 30, 0));
|
||||
if (!result.equals("TO_DATE('30-06-1998 13:30:00' , 'DD-MM-YYYY HH:MI:SS')")) {
|
||||
errln("Fail: result=" + result);
|
||||
@ -711,6 +719,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
* 'z' at end of date format throws index exception in SimpleDateFormat
|
||||
* CANNOT REPRODUCE THIS BUG ON 1.2FCS
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void Test4151706() {
|
||||
SimpleDateFormat fmt =
|
||||
new SimpleDateFormat("EEEE, dd-MMM-yy HH:mm:ss z", Locale.US);
|
||||
@ -755,6 +764,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
* Confirm that "EST"(GMT-5:00) and "CST"(GMT-6:00) are used in US
|
||||
* as "EST" or "CST", not Australian "EST" and "CST".
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void Test4406615() {
|
||||
Locale savedLocale = Locale.getDefault();
|
||||
TimeZone savedTimeZone = TimeZone.getDefault();
|
||||
@ -823,6 +833,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
* greater than "99", are treated as literal years. So "1/2/3456"
|
||||
* becomes 3456 AD. Likewise, "1/2/-3" becomes -3 AD == 2 BC.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
Object[] DATA = {
|
||||
"02/29/00", new Date(2000-1900, Calendar.FEBRUARY, 29),
|
||||
"01/23/01", new Date(2001-1900, Calendar.JANUARY, 23),
|
||||
@ -878,6 +889,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
DateFormat fmt = new SimpleDateFormat(pattern,
|
||||
DateFormatSymbols.getInstance(Locale.US));
|
||||
fmt.getCalendar().setLenient(false);
|
||||
@SuppressWarnings("deprecation")
|
||||
Date d = new Date(2000-1900, Calendar.FEBRUARY, 29);
|
||||
String s = fmt.format(d);
|
||||
logln(d + " x " + pattern + " => " + s);
|
||||
@ -957,6 +969,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void Test4253490() throws ParseException {
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("S", Locale.US);
|
||||
|
||||
@ -1026,6 +1039,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
public void Test4250359() {
|
||||
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT,
|
||||
Locale.US);
|
||||
@SuppressWarnings("deprecation")
|
||||
Date d = new Date(1999-1900, Calendar.DECEMBER, 25,
|
||||
1, 2, 3);
|
||||
String s = df.format(d);
|
||||
@ -1052,6 +1066,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
// pick up another time zone when L10N is done to that file.
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("yy/MM/dd hh:ss zzz", Locale.JAPAN);
|
||||
@SuppressWarnings("deprecation")
|
||||
String result = fmt.format(new Date(1999, 0, 1));
|
||||
logln("format()=>" + result);
|
||||
if (!result.endsWith("PST")) {
|
||||
|
||||
@ -104,7 +104,7 @@ public class DateFormatRoundTripTest extends IntlTest {
|
||||
String pat = null;
|
||||
Date date = null;
|
||||
|
||||
Vector newArgs = new Vector();
|
||||
List<String> newArgs = new ArrayList<>();
|
||||
for (int i=0; i<args.length; ++i) {
|
||||
if (args[i].equals("-locale")
|
||||
&& (i+1) < args.length) {
|
||||
@ -131,13 +131,13 @@ public class DateFormatRoundTripTest extends IntlTest {
|
||||
seed = Long.parseLong(args[i+1]);
|
||||
++i;
|
||||
} else {
|
||||
newArgs.addElement(args[i]);
|
||||
newArgs.add(args[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (newArgs.size() != args.length) {
|
||||
args = new String[newArgs.size()];
|
||||
newArgs.copyInto(args);
|
||||
newArgs.addAll(Arrays.asList(args));
|
||||
}
|
||||
|
||||
new DateFormatRoundTripTest(random, seed, infinite, date, pat, loc).run(args);
|
||||
@ -193,6 +193,7 @@ public class DateFormatRoundTripTest extends IntlTest {
|
||||
* Return the Date of this test case; must be called with the default
|
||||
* zone set to this TestCase's zone.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
Date getDate() {
|
||||
if (_date == null) {
|
||||
// Date constructor will work right iff we are in the target zone
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
*/
|
||||
import java.text.DateFormatSymbols;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class DateFormatSymbolsCloneTest extends DateFormatSymbols {
|
||||
private int value;
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ import static java.util.Calendar.*;
|
||||
public class NonGregorianFormatTest {
|
||||
static int errors;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static final Object[][] JAPANESE_EN = {
|
||||
{ "GGGG yyyy MMMM d", "Showa 1 December 31", new Date(1926-1900, DECEMBER, 31) },
|
||||
{ "GGGG yyyy MMMM d", "Showa 64 January 6", new Date(1989-1900, JANUARY, 6) },
|
||||
@ -58,6 +59,7 @@ public class NonGregorianFormatTest {
|
||||
{ "Gyy.MM.dd", "H01.01.01" },
|
||||
};
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static final Object[][] BUDDHIST_EN = {
|
||||
{ "GGGG yyyy MMMM d", "B.E. 2469 December 31", new Date(1926-1900, DECEMBER, 31) },
|
||||
{ "GGGG yyyy MMMM d", "B.E. 2532 January 6", new Date(1989-1900, JANUARY, 6) },
|
||||
@ -71,6 +73,7 @@ public class NonGregorianFormatTest {
|
||||
|
||||
static final String FULL_DATE_FORMAT_JA = "GGGGyyyy'\u5e74'M'\u6708'd'\u65e5'";
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static final Object[][] JAPANESE_JA = {
|
||||
{ FULL_DATE_FORMAT_JA, "\u662d\u548c\u5143\u5e7412\u670831\u65e5", new Date(1926-1900, DECEMBER, 31) },
|
||||
{ FULL_DATE_FORMAT_JA, "\u662d\u548c64\u5e741\u67086\u65e5", new Date(1989-1900, JANUARY, 6) },
|
||||
@ -93,6 +96,7 @@ public class NonGregorianFormatTest {
|
||||
{ "Gyy.MM.dd", "H01.01.01" },
|
||||
};
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static final Object[][] BUDDHIST_JA = {
|
||||
{ FULL_DATE_FORMAT_JA, "\u4ecf\u66a62469\u5e7412\u670831\u65e5", new Date(1926-1900, DECEMBER, 31) },
|
||||
{ FULL_DATE_FORMAT_JA, "\u4ecf\u66a62532\u5e741\u67086\u65e5", new Date(1989-1900, JANUARY, 6) },
|
||||
@ -137,6 +141,7 @@ public class NonGregorianFormatTest {
|
||||
locale == Locale.ENGLISH ? BUDDHIST_EN : BUDDHIST_JA);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void testRoundTrip(Locale calendarLocale) {
|
||||
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL,
|
||||
DateFormat.FULL,
|
||||
|
||||
@ -60,6 +60,7 @@ public class bug4358730 extends IntlTest {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||
|
||||
for (int i = 0; i < datasize; i++) {
|
||||
@SuppressWarnings("deprecation")
|
||||
Date d = new Date(year[i]-1900, 10, 15);
|
||||
for (int j = 0; j < nPatterns; j++) {
|
||||
sdf.applyPattern(patterns[j]);
|
||||
|
||||
@ -98,7 +98,7 @@ public class Bug4185816Test extends IntlTest {
|
||||
final InputStream is = HexDumpReader.getStreamFromHexDump(fileName + ".txt");
|
||||
final ObjectInputStream in = new ObjectInputStream(is);
|
||||
final MessageFormat form = (MessageFormat)in.readObject();
|
||||
final Object[] testArgs = {new Long(12373), "MyDisk"};
|
||||
final Object[] testArgs = {12373L, "MyDisk"};
|
||||
final String result = form.format(testArgs);
|
||||
in.close();
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -56,18 +56,19 @@ public class LargeMessageFormat {
|
||||
|
||||
private static void testFormat() {
|
||||
// construct large argument array
|
||||
@SuppressWarnings("deprecation")
|
||||
Object[] sample = {
|
||||
new Integer(0), // replace with running count below
|
||||
0, // replace with running count below
|
||||
"hello",
|
||||
new Date(89, 10, 9),
|
||||
new Integer(567890),
|
||||
new Double(1234.50)
|
||||
567890,
|
||||
1234.50
|
||||
};
|
||||
int samples = sample.length;
|
||||
Object[] arguments = new Object[REPEATS * (samples + 1)];
|
||||
for (int i = 0; i < REPEATS; i++) {
|
||||
System.arraycopy(sample, 0, arguments, i * samples, samples);
|
||||
arguments[i * samples] = new Integer(i);
|
||||
arguments[i * samples] = i;
|
||||
}
|
||||
|
||||
// construct large template
|
||||
|
||||
@ -136,7 +136,7 @@ public class MessageRegression extends IntlTest {
|
||||
try {
|
||||
logln("Apply with pattern : " + pattern1);
|
||||
messageFormatter.applyPattern(pattern1);
|
||||
Object[] params = {new Integer(7)};
|
||||
Object[] params = {7};
|
||||
String tempBuffer = messageFormatter.format(params);
|
||||
if (!tempBuffer.equals("Impossible {1} has occurred -- status code is 7 and message is {2}."))
|
||||
errln("Tests arguments < substitution failed. Formatted text=" +
|
||||
@ -455,7 +455,7 @@ public class MessageRegression extends IntlTest {
|
||||
errln("argument0: \"" + objs[0] + "\"");
|
||||
mf.setLocale(Locale.US);
|
||||
mf.applyPattern("{0,number,#.##}, {0,number,#.#}");
|
||||
Object[] oldobjs = {new Double(3.1415)};
|
||||
Object[] oldobjs = {3.1415};
|
||||
String result = mf.format( oldobjs );
|
||||
logln("pattern: \"" + mf.toPattern() + "\"");
|
||||
logln("text for parsing: \"" + result + "\"");
|
||||
@ -481,7 +481,7 @@ public class MessageRegression extends IntlTest {
|
||||
ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
|
||||
form1.setFormat(1, fileform);
|
||||
form2.setFormat(0, fileform);
|
||||
Object[] testArgs = {new Long(12373), "MyDisk"};
|
||||
Object[] testArgs = {12373L, "MyDisk"};
|
||||
logln(form1.format(testArgs));
|
||||
logln(form2.format(testArgs));
|
||||
}
|
||||
@ -531,7 +531,7 @@ public class MessageRegression extends IntlTest {
|
||||
};
|
||||
|
||||
for (int i=0; i<3; i++) {
|
||||
String out = mf.format(new Object[]{new Integer(i)});
|
||||
String out = mf.format(new Object[]{i});
|
||||
if (SUFFIX[i] == null) {
|
||||
if (!out.equals(PREFIX[i]))
|
||||
errln("" + i + ": Got \"" + out + "\"; Want \"" + PREFIX[i] + "\"");
|
||||
@ -607,8 +607,7 @@ public class MessageRegression extends IntlTest {
|
||||
*/
|
||||
public void Test4169959() {
|
||||
// This works
|
||||
logln(MessageFormat.format( "This will {0}",
|
||||
new String[]{"work"} ) );
|
||||
logln(MessageFormat.format( "This will {0}", "work"));
|
||||
|
||||
// This fails
|
||||
logln(MessageFormat.format( "This will {0}",
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2016, 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
|
||||
@ -52,7 +52,7 @@ public class MessageTest extends IntlTest {
|
||||
|
||||
public void TestMSGPatternTest() {
|
||||
Object[] testArgs = {
|
||||
new Double (1), new Double(3456),
|
||||
1D, 3456D,
|
||||
"Disk", new Date(10000000000L)};
|
||||
|
||||
String[] testCases = {
|
||||
|
||||
@ -118,7 +118,7 @@ public class BigDecimalCompatibilityTest {
|
||||
bd = bd.divide(new BigDecimal(multiplier));
|
||||
}
|
||||
catch (ArithmeticException e) {
|
||||
bd = bd.divide(new BigDecimal(multiplier), BigDecimal.ROUND_HALF_EVEN);
|
||||
bd = bd.divide(new BigDecimal(multiplier), RoundingMode.HALF_EVEN);
|
||||
}
|
||||
check(num, bd, multiplier);
|
||||
}
|
||||
|
||||
@ -793,7 +793,7 @@ public class BigDecimalFormat extends IntlTest {
|
||||
formatted.setLength(0);
|
||||
from = "123456789";
|
||||
to = sep_zero.substring(0, 399) + ",123,456,789";
|
||||
nf.format(new Long(from), formatted, new FieldPosition(0));
|
||||
nf.format(123456789L, formatted, new FieldPosition(0));
|
||||
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@ -810,7 +810,7 @@ public class BigDecimalFormat extends IntlTest {
|
||||
from = "123456789";
|
||||
to = "-" + nonsep_zero.substring(0, 300) + "123456789." +
|
||||
nonsep_zero.substring(0, 340);
|
||||
nf.format(new Long(from), formatted, new FieldPosition(0));
|
||||
nf.format(123456789L, formatted, new FieldPosition(0));
|
||||
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@ -827,7 +827,7 @@ public class BigDecimalFormat extends IntlTest {
|
||||
from = Long.toString(Long.MAX_VALUE);
|
||||
to = sep_zero.substring(0, 373) +
|
||||
"19,807,040,619,342,712,359,383,728,129";
|
||||
nf.format(new Long(from), formatted, new FieldPosition(0));
|
||||
nf.format(Long.MAX_VALUE, formatted, new FieldPosition(0));
|
||||
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@ -844,7 +844,7 @@ public class BigDecimalFormat extends IntlTest {
|
||||
from = Long.toString(Long.MAX_VALUE);
|
||||
to = "-1.9807040628566084396238503936" +
|
||||
nonsep_zero.substring(0, 312) + "E28";
|
||||
nf.format(new Long(from), formatted, new FieldPosition(0));
|
||||
nf.format(Long.MAX_VALUE, formatted, new FieldPosition(0));
|
||||
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@ -862,7 +862,7 @@ public class BigDecimalFormat extends IntlTest {
|
||||
to = "-19807040619342712361531211776" +
|
||||
nonsep_zero.substring(0, 280) + "." +
|
||||
nonsep_zero.substring(0, 340) + "E-280";
|
||||
nf.format(new Long(from), formatted, new FieldPosition(0));
|
||||
nf.format(Long.MIN_VALUE, formatted, new FieldPosition(0));
|
||||
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@ -880,7 +880,7 @@ public class BigDecimalFormat extends IntlTest {
|
||||
to = sep_zero.substring(0, 373) +
|
||||
"19,807,040,628,566,084,398,385,987,584." +
|
||||
nonsep_zero.substring(0, 340);
|
||||
nf.format(new Long(from), formatted, new FieldPosition(0));
|
||||
nf.format(Long.MIN_VALUE, formatted, new FieldPosition(0));
|
||||
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
|
||||
}
|
||||
|
||||
|
||||
@ -199,15 +199,15 @@ public class BigDecimalParse extends IntlTest {
|
||||
|
||||
// From: 1000.000
|
||||
// To: Double.POSITIVE_INFINITY
|
||||
check("1000.000", new Double(Double.POSITIVE_INFINITY));
|
||||
check("1000.000", Double.POSITIVE_INFINITY);
|
||||
|
||||
// From: -1000
|
||||
// To: Double.NEGATIVE_INFINITY
|
||||
check("-1000", new Double(Double.NEGATIVE_INFINITY));
|
||||
check("-1000", Double.NEGATIVE_INFINITY);
|
||||
|
||||
// From: -0.00
|
||||
// To: Double.NaN
|
||||
check("-0.00", new Double(Double.NaN));
|
||||
check("-0.00", Double.NaN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,31 +220,31 @@ public class BigDecimalParse extends IntlTest {
|
||||
|
||||
// From: 1000.000
|
||||
// To: Double.POSITIVE_INFINITY
|
||||
check("1000.000", new Double(Double.POSITIVE_INFINITY));
|
||||
check("1000.000", Double.POSITIVE_INFINITY);
|
||||
|
||||
// From: -1000.000
|
||||
// To: Double.NEGATIVE_INFINITY
|
||||
check("-1000.000", new Double(Double.NEGATIVE_INFINITY));
|
||||
check("-1000.000", Double.NEGATIVE_INFINITY);
|
||||
|
||||
// From: 0.0
|
||||
// To: Double.NaN
|
||||
check("0.0", new Double(Double.NaN));
|
||||
check("0.0", Double.NaN);
|
||||
|
||||
// From: -0.0 (Double)
|
||||
// To: Double.NaN
|
||||
check("-0.0", new Double(Double.NaN));
|
||||
check("-0.0", Double.NaN);
|
||||
|
||||
// From: Double.NaN
|
||||
// To: Double.NaN
|
||||
check("\ufffd", new Double(Double.NaN));
|
||||
check("\ufffd", Double.NaN);
|
||||
|
||||
// From: Double.POSITIVE_INFINITY
|
||||
// To: Double.NaN
|
||||
check("\u221e", new Double(Double.POSITIVE_INFINITY));
|
||||
check("\u221e", Double.POSITIVE_INFINITY);
|
||||
|
||||
// From: Double.NEGATIVE_INFINITY
|
||||
// To: Double.NaN
|
||||
check("-\u221e", new Double(Double.NEGATIVE_INFINITY));
|
||||
check("-\u221e", Double.NEGATIVE_INFINITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -257,15 +257,15 @@ public class BigDecimalParse extends IntlTest {
|
||||
|
||||
// From: 1000
|
||||
// To: Double.POSITIVE_INFINITY
|
||||
check("1000", new Double(Double.POSITIVE_INFINITY));
|
||||
check("1000", Double.POSITIVE_INFINITY);
|
||||
|
||||
// From: -1000
|
||||
// To: Double.NEGATIVE_INFINITY
|
||||
check("-1000", new Double(Double.NEGATIVE_INFINITY));
|
||||
check("-1000", Double.NEGATIVE_INFINITY);
|
||||
|
||||
// From: -000 (Long)
|
||||
// To: Double.NaN
|
||||
check("-000", new Double(Double.NaN));
|
||||
check("-000", Double.NaN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -350,20 +350,20 @@ public class BigDecimalParse extends IntlTest {
|
||||
{
|
||||
new BigDecimal("0"), new BigDecimal("0.0"), new BigDecimal("5"),
|
||||
new BigDecimal("5.0"), new BigDecimal("5.1"),
|
||||
new Double(Double.POSITIVE_INFINITY), new Double(Double.NaN),
|
||||
Double.POSITIVE_INFINITY, Double.NaN,
|
||||
new BigDecimal("0"), new BigDecimal("0.0"),
|
||||
new BigDecimal("-5"), new BigDecimal("-5.0"),
|
||||
new BigDecimal("-5.1"),
|
||||
new Double(Double.NEGATIVE_INFINITY), new Double(Double.NaN),
|
||||
Double.NEGATIVE_INFINITY, Double.NaN,
|
||||
},
|
||||
{
|
||||
new BigDecimal("0"), new BigDecimal("0.0"),
|
||||
new BigDecimal("-5"), new BigDecimal("-5.0"),
|
||||
new BigDecimal("-5.1"),
|
||||
new Double(Double.NEGATIVE_INFINITY), new Double(Double.NaN),
|
||||
Double.NEGATIVE_INFINITY, Double.NaN,
|
||||
new BigDecimal("0"), new BigDecimal("0.0"), new BigDecimal("5"),
|
||||
new BigDecimal("5.0"), new BigDecimal("5.1"),
|
||||
new Double(Double.POSITIVE_INFINITY),
|
||||
Double.POSITIVE_INFINITY,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -47,12 +47,12 @@ public class Bug4208135 {
|
||||
df.applyPattern("0.#E0");
|
||||
|
||||
df.setDecimalSeparatorAlwaysShown(true);
|
||||
checkFormat(new Double(0.0), "0.E0");
|
||||
checkFormat(new Double(10.0), "1.E1");
|
||||
checkFormat(new Double(1000.0), "1.E3");
|
||||
checkFormat(new Long(0), "0.E0");
|
||||
checkFormat(new Long(10), "1.E1");
|
||||
checkFormat(new Long(1000), "1.E3");
|
||||
checkFormat(0.0, "0.E0");
|
||||
checkFormat(10.0, "1.E1");
|
||||
checkFormat(1000.0, "1.E3");
|
||||
checkFormat(0L, "0.E0");
|
||||
checkFormat(10L, "1.E1");
|
||||
checkFormat(1000L, "1.E3");
|
||||
checkFormat(new BigDecimal("0.0"), "0.E0");
|
||||
checkFormat(new BigDecimal("10.0"), "1.E1");
|
||||
checkFormat(new BigDecimal("1000.0"), "1.E3");
|
||||
@ -61,12 +61,12 @@ public class Bug4208135 {
|
||||
checkFormat(new BigInteger("1000"), "1.E3");
|
||||
|
||||
df.setDecimalSeparatorAlwaysShown(false);
|
||||
checkFormat(new Double(0.0), "0E0");
|
||||
checkFormat(new Double(10.0), "1E1");
|
||||
checkFormat(new Double(1000.0), "1E3");
|
||||
checkFormat(new Long(0), "0E0");
|
||||
checkFormat(new Long(10), "1E1");
|
||||
checkFormat(new Long(1000), "1E3");
|
||||
checkFormat(0.0, "0E0");
|
||||
checkFormat(10.0, "1E1");
|
||||
checkFormat(1000.0, "1E3");
|
||||
checkFormat(0L, "0E0");
|
||||
checkFormat(10L, "1E1");
|
||||
checkFormat(1000L, "1E3");
|
||||
checkFormat(new BigDecimal("0.0"), "0E0");
|
||||
checkFormat(new BigDecimal("10.0"), "1E1");
|
||||
checkFormat(new BigDecimal("1000.0"), "1E3");
|
||||
@ -77,12 +77,12 @@ public class Bug4208135 {
|
||||
df.applyPattern("0.###");
|
||||
|
||||
df.setDecimalSeparatorAlwaysShown(true);
|
||||
checkFormat(new Double(0.0), "0.");
|
||||
checkFormat(new Double(10.0), "10.");
|
||||
checkFormat(new Double(1000.0), "1000.");
|
||||
checkFormat(new Long(0), "0.");
|
||||
checkFormat(new Long(10), "10.");
|
||||
checkFormat(new Long(1000), "1000.");
|
||||
checkFormat(0.0, "0.");
|
||||
checkFormat(10.0, "10.");
|
||||
checkFormat(1000.0, "1000.");
|
||||
checkFormat(0L, "0.");
|
||||
checkFormat(10L, "10.");
|
||||
checkFormat(1000L, "1000.");
|
||||
checkFormat(new BigDecimal("0.0"), "0.");
|
||||
checkFormat(new BigDecimal("10.0"), "10.");
|
||||
checkFormat(new BigDecimal("1000.0"), "1000.");
|
||||
@ -91,12 +91,12 @@ public class Bug4208135 {
|
||||
checkFormat(new BigInteger("1000"), "1000.");
|
||||
|
||||
df.setDecimalSeparatorAlwaysShown(false);
|
||||
checkFormat(new Double(0.0), "0");
|
||||
checkFormat(new Double(10.0), "10");
|
||||
checkFormat(new Double(1000.0), "1000");
|
||||
checkFormat(new Long(0), "0");
|
||||
checkFormat(new Long(10), "10");
|
||||
checkFormat(new Long(1000), "1000");
|
||||
checkFormat(0.0, "0");
|
||||
checkFormat(10.0, "10");
|
||||
checkFormat(1000.0, "1000");
|
||||
checkFormat(0L, "0");
|
||||
checkFormat(10L, "10");
|
||||
checkFormat(1000L, "1000");
|
||||
checkFormat(new BigDecimal("0.0"), "0");
|
||||
checkFormat(new BigDecimal("10.0"), "10");
|
||||
checkFormat(new BigDecimal("1000.0"), "1000");
|
||||
|
||||
@ -51,20 +51,20 @@ public class Bug4833877 {
|
||||
/*
|
||||
* Test for double/Double
|
||||
*/
|
||||
checkFormat(new Double(252.5252525252525), "1,010.10101010101");
|
||||
checkParse("-1,010.10101010101", new Double(-252.5252525252525));
|
||||
checkFormat(252.5252525252525, "1,010.10101010101");
|
||||
checkParse("-1,010.10101010101", -252.5252525252525);
|
||||
|
||||
checkFormat(new Double(-2222.2222), "-8,888.8888");
|
||||
checkParse("8888.8888", new Double(2222.2222));
|
||||
checkFormat(-2222.2222, "-8,888.8888");
|
||||
checkParse("8888.8888", 2222.2222);
|
||||
|
||||
/*
|
||||
* Test for long/Long
|
||||
*/
|
||||
checkFormat(new Long(1000), "4,000");
|
||||
checkParse("-4,000", new Long(-1000));
|
||||
checkFormat(1000L, "4,000");
|
||||
checkParse("-4,000", -1000L);
|
||||
|
||||
checkFormat(new Long(-250), "-1,000");
|
||||
checkParse("1000", new Long(250));
|
||||
checkFormat(-250L, "-1,000");
|
||||
checkParse("1000", 250L);
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
@ -104,20 +104,20 @@ public class Bug4833877 {
|
||||
/*
|
||||
* Test for double/Double
|
||||
*/
|
||||
checkFormat(new Double(252.5252525252525), "-1,010.10101010101");
|
||||
checkParse("-1,010.10101010101", new Double(252.5252525252525));
|
||||
checkFormat(252.5252525252525, "-1,010.10101010101");
|
||||
checkParse("-1,010.10101010101", 252.5252525252525);
|
||||
|
||||
checkFormat(new Double(-2222.2222), "8,888.8888");
|
||||
checkParse("8888.8888", new Double(-2222.2222));
|
||||
checkFormat(-2222.2222, "8,888.8888");
|
||||
checkParse("8888.8888", -2222.2222);
|
||||
|
||||
/*
|
||||
* Test for long/Long
|
||||
*/
|
||||
checkFormat(new Long(1000), "-4,000");
|
||||
checkParse("-4,000", new Long(1000));
|
||||
checkFormat(1000L, "-4,000");
|
||||
checkParse("-4,000", 1000L);
|
||||
|
||||
checkFormat(new Long(-250), "1,000");
|
||||
checkParse("1000", new Long(-250));
|
||||
checkFormat(-250L, "1,000");
|
||||
checkParse("1000", -250L);
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
@ -157,30 +157,30 @@ public class Bug4833877 {
|
||||
/*
|
||||
* Test for double/Double
|
||||
*/
|
||||
checkFormat(new Double(3333.3333333), "-9,999.9999999");
|
||||
checkParse("-10,000.00000000000", new Double(3333.3333333333335));// rounding error
|
||||
checkFormat(3333.3333333, "-9,999.9999999");
|
||||
checkParse("-10,000.00000000000", 3333.3333333333335);// rounding error
|
||||
|
||||
df.setParseIntegerOnly(true);
|
||||
checkFormat(new Double(-3333.3333333), "9,999.9999999");
|
||||
checkParse("10,000.00000000000", new Long(-3333));
|
||||
checkFormat(-3333.3333333, "9,999.9999999");
|
||||
checkParse("10,000.00000000000", -3333L);
|
||||
df.setParseIntegerOnly(false);
|
||||
checkFormat(new Double(-3333.3333333), "9,999.9999999");
|
||||
checkParse("10,000.00000000000", new Double(-3333.3333333333335));// rounding error
|
||||
checkFormat(-3333.3333333, "9,999.9999999");
|
||||
checkParse("10,000.00000000000", -3333.3333333333335);// rounding error
|
||||
|
||||
/*
|
||||
* Test for long/Long
|
||||
*/
|
||||
checkFormat(new Long(3333), "-9,999");
|
||||
checkFormat(3333L, "-9,999");
|
||||
df.setParseIntegerOnly(true);
|
||||
checkParse("-10,000", new Long(3333));
|
||||
checkParse("-10,000", 3333L);
|
||||
df.setParseIntegerOnly(false);
|
||||
checkParse("-10000", new Double(3333.3333333333335));// rounding error
|
||||
checkParse("-10000", 3333.3333333333335);// rounding error
|
||||
|
||||
checkFormat(new Long(-3333), "9,999");
|
||||
checkFormat(-3333L, "9,999");
|
||||
df.setParseIntegerOnly(true);
|
||||
checkParse("10,000", new Long(-3333));
|
||||
checkParse("10,000", -3333L);
|
||||
df.setParseIntegerOnly(false);
|
||||
checkParse("10000", new Double(-3333.3333333333335));// rounding error
|
||||
checkParse("10000", -3333.3333333333335);// rounding error
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
@ -225,20 +225,20 @@ public class Bug4833877 {
|
||||
/*
|
||||
* Test for double/Double
|
||||
*/
|
||||
checkFormat(new Double(252.5252525252525), "1.01010101010101E3");
|
||||
checkParse("-1.01010101010101E3", new Double(-2.525252525252525E2));
|
||||
checkFormat(252.5252525252525, "1.01010101010101E3");
|
||||
checkParse("-1.01010101010101E3", -2.525252525252525E2);
|
||||
|
||||
checkFormat(new Double(-2222.2222), "-8.8888888E3");
|
||||
checkParse("8888.8888", new Double(2.2222222E3));
|
||||
checkFormat(-2222.2222, "-8.8888888E3");
|
||||
checkParse("8888.8888", 2.2222222E3);
|
||||
|
||||
/*
|
||||
* Test for long/Long
|
||||
*/
|
||||
checkFormat(new Long(1000), "4E3");
|
||||
checkParse("-4E3", new Long(-1000));
|
||||
checkFormat(1000L, "4E3");
|
||||
checkParse("-4E3", -1000L);
|
||||
|
||||
checkFormat(new Long(-250), "-1E3");
|
||||
checkParse("1000", new Long(250));
|
||||
checkFormat(-250L, "-1E3");
|
||||
checkParse("1000", 250L);
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
@ -279,20 +279,20 @@ public class Bug4833877 {
|
||||
/*
|
||||
* Test for double/Double
|
||||
*/
|
||||
checkFormat(new Double(252.5252525252525), "-1.01010101010101E3");
|
||||
checkParse("-1.01010101010101E3", new Double(2.525252525252525E2));
|
||||
checkFormat(252.5252525252525, "-1.01010101010101E3");
|
||||
checkParse("-1.01010101010101E3", 2.525252525252525E2);
|
||||
|
||||
checkFormat(new Double(-2222.2222), "8.8888888E3");
|
||||
checkParse("8888.8888", new Double(-2.2222222E3));
|
||||
checkFormat(-2222.2222, "8.8888888E3");
|
||||
checkParse("8888.8888", -2.2222222E3);
|
||||
|
||||
/*
|
||||
* Test for long/Long
|
||||
*/
|
||||
checkFormat(new Long(1000), "-4E3");
|
||||
checkParse("-4E3", new Long(1000));
|
||||
checkFormat(1000L, "-4E3");
|
||||
checkParse("-4E3", 1000L);
|
||||
|
||||
checkFormat(new Long(-250), "1E3");
|
||||
checkParse("1000", new Long(-250));
|
||||
checkFormat(-250L, "1E3");
|
||||
checkParse("1000", -250L);
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
@ -333,30 +333,30 @@ public class Bug4833877 {
|
||||
/*
|
||||
* Test for double/Double
|
||||
*/
|
||||
checkFormat(new Double(3333.3333333), "-9.9999999999E3");
|
||||
checkParse("-1.00000000000000E3", new Double(3.33333333333333333E2));
|
||||
checkFormat(3333.3333333, "-9.9999999999E3");
|
||||
checkParse("-1.00000000000000E3", 3.33333333333333333E2);
|
||||
|
||||
df.setParseIntegerOnly(true);
|
||||
checkFormat(new Double(-3333.3333333), "9.9999999999E3");
|
||||
checkParse("10.00000000000000E3", new Long(-3));
|
||||
checkFormat(-3333.3333333, "9.9999999999E3");
|
||||
checkParse("10.00000000000000E3",-3L);
|
||||
df.setParseIntegerOnly(false);
|
||||
checkFormat(new Double(-3333.3333333), "9.9999999999E3");
|
||||
checkParse("10.00000000000000E3", new Double(-3.33333333333333333E3));
|
||||
checkFormat(-3333.3333333, "9.9999999999E3");
|
||||
checkParse("10.00000000000000E3", -3.33333333333333333E3);
|
||||
|
||||
/*
|
||||
* Test for long/Long
|
||||
*/
|
||||
checkFormat(new Long(3333), "-9.999E3");
|
||||
checkFormat(3333L, "-9.999E3");
|
||||
df.setParseIntegerOnly(true);
|
||||
checkParse("-1.0E4", new Long(0));
|
||||
checkParse("-1.0E4", 0L);
|
||||
df.setParseIntegerOnly(false);
|
||||
checkParse("-1.0E4", new Double(3333.3333333333335));
|
||||
checkParse("-1.0E4", 3333.3333333333335);
|
||||
|
||||
checkFormat(new Long(-3333), "9.999E3");
|
||||
checkFormat(-3333L, "9.999E3");
|
||||
df.setParseIntegerOnly(true);
|
||||
checkParse("10.0E4", new Long(-3));
|
||||
checkParse("10.0E4", -3L);
|
||||
df.setParseIntegerOnly(false);
|
||||
checkParse("10.0E4", new Double(-33333.3333333333336));
|
||||
checkParse("10.0E4", -33333.3333333333336);
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
|
||||
@ -71,47 +71,47 @@ public class Bug4838107 extends IntlTest {
|
||||
dfs = df.getDecimalFormatSymbols();
|
||||
|
||||
/* Test with default pattern */
|
||||
test(new Double(1234), "1,234");
|
||||
test(new Double(0.1234), "0.123"); // rounded
|
||||
test(new Double(-1234), "-1,234");
|
||||
test(new Double(-0.1234), "-0.123"); // rounded
|
||||
test(1234D, "1,234");
|
||||
test(0.1234, "0.123"); // rounded
|
||||
test(-1234D, "-1,234");
|
||||
test(-0.1234, "-0.123"); // rounded
|
||||
|
||||
test(new Double(Double.POSITIVE_INFINITY), "\u221e");
|
||||
test(new Double(Double.NEGATIVE_INFINITY), "-\u221e");
|
||||
test(new Double(Double.NaN), "\ufffd"); // without prefix and suffix
|
||||
test(new Double(0.0), "0");
|
||||
test(new Double(-0.0), "-0"); // with the minus sign
|
||||
test(Double.POSITIVE_INFINITY, "\u221e");
|
||||
test(Double.NEGATIVE_INFINITY, "-\u221e");
|
||||
test(Double.NaN, "\ufffd"); // without prefix and suffix
|
||||
test(0.0, "0");
|
||||
test(-0.0, "-0"); // with the minus sign
|
||||
|
||||
/* Specify a pattern and the minus sign. */
|
||||
prepareFormatter("<P>#.###E00<S>", 'm');
|
||||
test(new Double(1234), "<P>1.234E03<S>");
|
||||
test(new Double(0.1234), "<P>1.234Em01<S>");
|
||||
test(new Double(-1234), "m<P>1.234E03<S>");
|
||||
test(new Double(-0.1234), "m<P>1.234Em01<S>");
|
||||
test(1234D, "<P>1.234E03<S>");
|
||||
test(0.1234, "<P>1.234Em01<S>");
|
||||
test(-1234D, "m<P>1.234E03<S>");
|
||||
test(-0.1234, "m<P>1.234Em01<S>");
|
||||
|
||||
prepareFormatter("<P>#.###E00<S>;#.###E00", 'm');
|
||||
test(new Double(1234), "<P>1.234E03<S>");
|
||||
test(new Double(0.1234), "<P>1.234Em01<S>");
|
||||
test(new Double(-1234), "1.234E03");
|
||||
test(new Double(-0.1234), "1.234Em01");
|
||||
test(1234D, "<P>1.234E03<S>");
|
||||
test(0.1234, "<P>1.234Em01<S>");
|
||||
test(-1234D, "1.234E03");
|
||||
test(-0.1234, "1.234Em01");
|
||||
|
||||
prepareFormatter("#.###E00;<P>#.###E00<S>", 'm');
|
||||
test(new Double(1234), "1.234E03");
|
||||
test(new Double(0.1234), "1.234Em01");
|
||||
test(new Double(-1234), "<P>1.234E03<S>");
|
||||
test(new Double(-0.1234), "<P>1.234Em01<S>");
|
||||
test(1234D, "1.234E03");
|
||||
test(0.1234, "1.234Em01");
|
||||
test(-1234D, "<P>1.234E03<S>");
|
||||
test(-0.1234, "<P>1.234Em01<S>");
|
||||
|
||||
prepareFormatter("<P>#.###E00<S>;<p>-#.###E00<s>", 'm');
|
||||
test(new Double(1234), "<P>1.234E03<S>");
|
||||
test(new Double(0.1234), "<P>1.234Em01<S>");
|
||||
test(new Double(-1234), "<p>m1.234E03<s>");
|
||||
test(new Double(-0.1234), "<p>m1.234Em01<s>");
|
||||
test(1234D, "<P>1.234E03<S>");
|
||||
test(0.1234, "<P>1.234Em01<S>");
|
||||
test(-1234D, "<p>m1.234E03<s>");
|
||||
test(-0.1234, "<p>m1.234Em01<s>");
|
||||
|
||||
test(new Double(Double.POSITIVE_INFINITY), "<P>\u221e<S>");
|
||||
test(new Double(Double.NEGATIVE_INFINITY), "<p>m\u221e<s>");
|
||||
test(new Double(Double.NaN), "\ufffd"); // without prefix and suffix
|
||||
test(new Double(0.0), "<P>0E00<S>");
|
||||
test(new Double(-0.0), "<p>m0E00<s>"); // with the minus sign
|
||||
test(Double.POSITIVE_INFINITY, "<P>\u221e<S>");
|
||||
test(Double.NEGATIVE_INFINITY, "<p>m\u221e<s>");
|
||||
test(Double.NaN, "\ufffd"); // without prefix and suffix
|
||||
test(0.0, "<P>0E00<S>");
|
||||
test(-0.0, "<p>m0E00<s>"); // with the minus sign
|
||||
}
|
||||
|
||||
static void test_BigDecimal() {
|
||||
@ -151,19 +151,19 @@ public class Bug4838107 extends IntlTest {
|
||||
dfs = df.getDecimalFormatSymbols();
|
||||
|
||||
/* Test with default pattern */
|
||||
test(new Long(123456789), "123,456,789");
|
||||
test(new Long(-123456789), "-123,456,789");
|
||||
test(123456789L, "123,456,789");
|
||||
test(-123456789L, "-123,456,789");
|
||||
|
||||
test(new Long(0), "0");
|
||||
test(new Long(-0), "0");
|
||||
test(0L, "0");
|
||||
test(-0L, "0");
|
||||
|
||||
/* Specify a pattern and the minus sign. */
|
||||
prepareFormatter("<P>#,###<S>;<p>-#,###<s>", 'm');
|
||||
test(new Long(123456789), "<P>123,456,789<S>");
|
||||
test(new Long(-123456789), "<p>m123,456,789<s>");
|
||||
test(123456789L, "<P>123,456,789<S>");
|
||||
test(-123456789L, "<p>m123,456,789<s>");
|
||||
|
||||
test(new Long(0), "<P>0<S>");
|
||||
test(new Long(-0), "<P>0<S>");
|
||||
test(0L, "<P>0<S>");
|
||||
test(-0L, "<P>0<S>");
|
||||
}
|
||||
|
||||
static void test_BigInteger() {
|
||||
|
||||
@ -84,7 +84,7 @@ public class Bug4944439 {
|
||||
}
|
||||
|
||||
int index = s.indexOf('.');
|
||||
Long l = new Long(s.substring(0, index));
|
||||
Long l = Long.valueOf(s.substring(0, index));
|
||||
if (!l.equals(number)) {
|
||||
err = true;
|
||||
System.err.println("Failed: DecimalFormat.parse(" + s +
|
||||
@ -101,7 +101,7 @@ public class Bug4944439 {
|
||||
number.getClass().getName());
|
||||
}
|
||||
|
||||
Double d = new Double(s);
|
||||
Double d = Double.valueOf(s);
|
||||
if (!d.equals(number)) {
|
||||
err = true;
|
||||
System.err.println("Failed: DecimalFormat.parse(" + s +
|
||||
|
||||
@ -35,6 +35,7 @@ public class Bug4990596 {
|
||||
new DecimalFormat().format(new MutableInteger(0));
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class MutableInteger extends Number {
|
||||
public int value;
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ public class Bug6278616 {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
|
||||
for (int j = 0; j < ints.length; j++) {
|
||||
String s_i = nf.format(new Integer(ints[j]));
|
||||
String s_i = nf.format(ints[j]);
|
||||
String s_ai = nf.format(new AtomicInteger(ints[j]));
|
||||
if (!s_i.equals(s_ai)) {
|
||||
throw new RuntimeException("format(AtomicInteger " + s_ai +
|
||||
@ -57,7 +57,7 @@ public class Bug6278616 {
|
||||
}
|
||||
|
||||
for (int j = 0; j < longs.length; j++) {
|
||||
String s_l = nf.format(new Long(longs[j]));
|
||||
String s_l = nf.format(longs[j]);
|
||||
String s_al = nf.format(new AtomicLong(longs[j]));
|
||||
if (!s_l.equals(s_al)) {
|
||||
throw new RuntimeException("format(AtomicLong " + s_al +
|
||||
|
||||
@ -289,7 +289,7 @@ public class NumberRegression extends IntlTest {
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
Double d = (Double)df.parse("123.55456", pos=new ParsePosition(0));
|
||||
if (!d.toString().equals("123.55456")) {
|
||||
errln("Result -> " + d.doubleValue());
|
||||
errln("Result -> " + d);
|
||||
}
|
||||
Locale.setDefault(savedLocale);
|
||||
}
|
||||
@ -395,11 +395,11 @@ public class NumberRegression extends IntlTest {
|
||||
Locale.setDefault(Locale.US);
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
String str = "0.1234";
|
||||
Double d1 = new Double(str);
|
||||
Double d1 = 0.1234;
|
||||
Double d2 = (Double) df.parse(str, new ParsePosition(0));
|
||||
logln(d1.toString());
|
||||
if (d2.doubleValue() != d1.doubleValue())
|
||||
errln("Bug 4095713 test failed, new double value : " + d2.doubleValue());
|
||||
errln("Bug 4095713 test failed, new double value : " + d2);
|
||||
Locale.setDefault(savedLocale);
|
||||
}
|
||||
|
||||
@ -870,7 +870,7 @@ public class NumberRegression extends IntlTest {
|
||||
DecimalFormat fmt = new DecimalFormat("#,##0.00");
|
||||
StringBuffer formatted = new StringBuffer();
|
||||
FieldPosition field = new FieldPosition(0);
|
||||
Double num = new Double(1234.5);
|
||||
Double num = 1234.5;
|
||||
fmt.format(num, formatted, field);
|
||||
if (field.getBeginIndex() != 0 && field.getEndIndex() != 5)
|
||||
errln("Format 1234.5 failed. Begin index: " + field.getBeginIndex() + " End index: " + field.getEndIndex());
|
||||
@ -1416,7 +1416,7 @@ public class NumberRegression extends IntlTest {
|
||||
DecimalFormat fmt = new DecimalFormat("#",
|
||||
DecimalFormatSymbols.getInstance(Locale.US));
|
||||
for (int i=0; i<DATA.length; i+=3) {
|
||||
double in = Double.valueOf(DATA[i]).doubleValue();
|
||||
double in = Double.valueOf(DATA[i]);
|
||||
String pat = DATA[i+1];
|
||||
String exp = DATA[i+2];
|
||||
fmt.applyPattern(pat);
|
||||
@ -1622,7 +1622,7 @@ public class NumberRegression extends IntlTest {
|
||||
String str = Long.toString(DATA[i]);
|
||||
for (int m = 1; m <= 100; m++) {
|
||||
fmt.setMultiplier(m);
|
||||
long n = ((Number) fmt.parse(str)).longValue();
|
||||
long n = fmt.parse(str).longValue();
|
||||
if (n > 0 != DATA[i] > 0) {
|
||||
errln("\"" + str + "\" parse(x " + fmt.getMultiplier() +
|
||||
") => " + n);
|
||||
@ -1637,15 +1637,15 @@ public class NumberRegression extends IntlTest {
|
||||
*/
|
||||
public void Test4217661() {
|
||||
Object[] DATA = {
|
||||
new Double(0.001), "0",
|
||||
new Double(1.001), "1",
|
||||
new Double(0.006), "0.01",
|
||||
new Double(1.006), "1.01",
|
||||
0.001, "0",
|
||||
1.001, "1",
|
||||
0.006, "0.01",
|
||||
1.006, "1.01",
|
||||
};
|
||||
NumberFormat fmt = NumberFormat.getInstance(Locale.US);
|
||||
fmt.setMaximumFractionDigits(2);
|
||||
for (int i=0; i<DATA.length; i+=2) {
|
||||
String s = fmt.format(((Double) DATA[i]).doubleValue());
|
||||
String s = fmt.format((Double) DATA[i]);
|
||||
if (!s.equals(DATA[i+1])) {
|
||||
errln("FAIL: Got " + s + ", exp " + DATA[i+1]);
|
||||
}
|
||||
@ -1804,6 +1804,7 @@ public class NumberRegression extends IntlTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class myformat implements Serializable
|
||||
{
|
||||
DateFormat _dateFormat = DateFormat.getDateInstance();
|
||||
@ -1817,6 +1818,7 @@ class myformat implements Serializable
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class MyNumberFormatTest extends NumberFormat {
|
||||
public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
|
||||
return new StringBuffer("");
|
||||
@ -1825,6 +1827,6 @@ class MyNumberFormatTest extends NumberFormat {
|
||||
return new StringBuffer("");
|
||||
}
|
||||
public Number parse(String text, ParsePosition parsePosition) {
|
||||
return new Integer(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,11 +130,11 @@ public class NumberRoundTrip extends IntlTest {
|
||||
}
|
||||
|
||||
public void doTest(NumberFormat fmt, double value) {
|
||||
doTest(fmt, new Double(value));
|
||||
doTest(fmt, Double.valueOf(value));
|
||||
}
|
||||
|
||||
public void doTest(NumberFormat fmt, long value) {
|
||||
doTest(fmt, new Long(value));
|
||||
doTest(fmt, Long.valueOf(value));
|
||||
}
|
||||
|
||||
static double proportionalError(Number a, Number b) {
|
||||
|
||||
@ -403,7 +403,7 @@ public class NumberTest extends IntlTest
|
||||
float[] parseExpected = { 0, 0, 12345, -12345 };
|
||||
|
||||
for (int i = 0; i < parseInput.length; i++) {
|
||||
float result = ((Number) format.parse(parseInput[i])).floatValue();
|
||||
float result = format.parse(parseInput[i]).floatValue();
|
||||
if (result != parseExpected[i]) {
|
||||
errln("FAIL: Expected " + parseExpected[i] + ", got " + result);
|
||||
}
|
||||
|
||||
@ -62,6 +62,7 @@ public class SerializationLoadTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class CheckDecimalFormat implements Serializable
|
||||
{
|
||||
DecimalFormat _decFormat = (DecimalFormat)NumberFormat.getInstance();
|
||||
@ -73,6 +74,7 @@ class CheckDecimalFormat implements Serializable
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class CheckDecimalFormatSymbols implements Serializable
|
||||
{
|
||||
DecimalFormatSymbols _decFormatSymbols = new DecimalFormatSymbols();
|
||||
|
||||
@ -57,6 +57,7 @@ public class SerializationSaveTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class CheckDecimalFormat implements Serializable
|
||||
{
|
||||
DecimalFormat _decFormat = (DecimalFormat)NumberFormat.getInstance();
|
||||
@ -68,6 +69,7 @@ class CheckDecimalFormat implements Serializable
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class CheckDecimalFormatSymbols implements Serializable
|
||||
{
|
||||
DecimalFormatSymbols _decFormatSymbols = new DecimalFormatSymbols();
|
||||
|
||||
@ -37,6 +37,7 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.text.AttributedCharacterIterator.Attribute;
|
||||
|
||||
/**
|
||||
* FormatTester creates Formats, and tests the resulting FieldPositions
|
||||
@ -94,7 +95,6 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
* Any lines starting with {@code '#'} are comment lines and ignored.
|
||||
*/
|
||||
public class FormatIteratorTest extends IntlTest {
|
||||
private static HashMap attrs;
|
||||
private Format format;
|
||||
private Object value;
|
||||
private String text;
|
||||
@ -143,30 +143,31 @@ public class FormatIteratorTest extends IntlTest {
|
||||
"dateFormat.props"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void _test(File file) {
|
||||
try {
|
||||
attrs = new HashMap();
|
||||
logln("testing: " + file);
|
||||
PParser parser = new PParser();
|
||||
Hashtable contents = parser.parse(new BufferedReader(
|
||||
Map<String,Object> contents = parser.parse(new BufferedReader(
|
||||
new FileReader(file)));
|
||||
Vector test = (Vector)contents.get("tests");
|
||||
List<Object> test = (List)contents.get("tests");
|
||||
|
||||
for (int counter = 0; counter < test.size(); counter++) {
|
||||
logln("creating: " + (counter / 2));
|
||||
|
||||
AttributedCharacterIterator iterator =
|
||||
create((Hashtable)test.get(counter));
|
||||
create((Map)test.get(counter));
|
||||
|
||||
logln("verifying: " + (counter / 2));
|
||||
verify(iterator, (Hashtable)test.get(++counter));
|
||||
verify(iterator, (Map)test.get(++counter));
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
errln("Error reading: " + ioe);
|
||||
}
|
||||
}
|
||||
|
||||
public void verify(AttributedCharacterIterator iterator,Hashtable table) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void verify(AttributedCharacterIterator iterator,Map<String,Object> table) {
|
||||
int length = Integer.parseInt((String)table.get("length"));
|
||||
|
||||
// Verify the text
|
||||
@ -185,10 +186,10 @@ public class FormatIteratorTest extends IntlTest {
|
||||
for (int counter = 0; counter < length; counter++) {
|
||||
iterator.setIndex(counter);
|
||||
if (!verifyAttributes(iterator.getAttributes().keySet(),
|
||||
makeAttributes((Vector)table.get(Integer.
|
||||
makeAttributes((List)table.get(Integer.
|
||||
toString(counter))))) {
|
||||
errln("Attributes don't match at " + counter + " expecting " +
|
||||
makeAttributes((Vector)table.get(Integer.toString
|
||||
makeAttributes((List)table.get(Integer.toString
|
||||
(counter))) + " got " +
|
||||
iterator.getAttributes().keySet());
|
||||
}
|
||||
@ -196,10 +197,10 @@ public class FormatIteratorTest extends IntlTest {
|
||||
for (int counter = length - 1; counter >= 0; counter--) {
|
||||
iterator.setIndex(counter);
|
||||
if (!verifyAttributes(iterator.getAttributes().keySet(),
|
||||
makeAttributes((Vector)table.get(Integer.
|
||||
makeAttributes((List)table.get(Integer.
|
||||
toString(counter))))) {
|
||||
errln("Attributes don't match at " + counter + " expecting " +
|
||||
makeAttributes((Vector)table.get(Integer.toString
|
||||
makeAttributes((List)table.get(Integer.toString
|
||||
(counter))) + " got " +
|
||||
iterator.getAttributes().keySet());
|
||||
}
|
||||
@ -207,31 +208,33 @@ public class FormatIteratorTest extends IntlTest {
|
||||
verifyLimits(iterator, table);
|
||||
|
||||
text = escapeIfNecessary((String)table.get("text"));
|
||||
Vector fps = (Vector)table.get("fieldPositions");
|
||||
List<Object> fps = (List)table.get("fieldPositions");
|
||||
|
||||
if (fps != null) {
|
||||
for (int counter = 0; counter < fps.size(); counter++) {
|
||||
verifyFieldPosition(counter, (Hashtable)fps.get(counter));
|
||||
verifyFieldPosition(counter,(Map)fps.get(counter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void verifyLimits(AttributedCharacterIterator iterator,
|
||||
Hashtable table) {
|
||||
Vector limits = (Vector)table.get("limits");
|
||||
Map<String,Object> table) {
|
||||
List<Object> limits = (List)table.get("limits");
|
||||
|
||||
if (limits != null) {
|
||||
for (int counter = 0; counter < limits.size(); counter++) {
|
||||
verifyLimit(iterator, (Hashtable)limits.get(counter));
|
||||
verifyLimit(iterator, (Map)limits.get(counter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyLimit(AttributedCharacterIterator iterator,
|
||||
Hashtable table) {
|
||||
Map<String,Object> table) {
|
||||
int begin = Integer.parseInt((String)table.get("begin"));
|
||||
int end = Integer.parseInt((String)table.get("end"));
|
||||
Set attrs = makeAttributes((Vector)table.get("attributes"));
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Attribute> attrs = makeAttributes((List)table.get("attributes"));
|
||||
String begin2S = (String)table.get("begin2");
|
||||
int begin2 = (begin2S != null) ? Integer.parseInt(begin2S) : begin;
|
||||
String end2S = (String)table.get("end2");
|
||||
@ -262,9 +265,9 @@ public class FormatIteratorTest extends IntlTest {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean verifyAttributes(Set a, Set b) {
|
||||
boolean aEmpty = (a.size() == 0);
|
||||
boolean bEmpty = (b.size() == 0);
|
||||
private boolean verifyAttributes(Set<Attribute> a, Set<Attribute> b) {
|
||||
boolean aEmpty = a.isEmpty();
|
||||
boolean bEmpty = b.isEmpty();
|
||||
|
||||
if (aEmpty && bEmpty) {
|
||||
return true;
|
||||
@ -284,14 +287,14 @@ public class FormatIteratorTest extends IntlTest {
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
private void verifyFieldPosition(int index, Hashtable table) {
|
||||
private void verifyFieldPosition(int index, Map<String,Object> table) {
|
||||
Object o = table.get("field");
|
||||
int begin = Integer.parseInt((String)table.get("begin"));
|
||||
int end = Integer.parseInt((String)table.get("end"));
|
||||
|
||||
if (o != null) {
|
||||
FieldPosition fp = new FieldPosition(((Integer)
|
||||
lookupField((String)o)).intValue());
|
||||
lookupField((String)o)));
|
||||
|
||||
verifyFieldPosition(fp, begin, end, index);
|
||||
}
|
||||
@ -322,11 +325,11 @@ public class FormatIteratorTest extends IntlTest {
|
||||
}
|
||||
}
|
||||
|
||||
public AttributedCharacterIterator create(Hashtable table) {
|
||||
public AttributedCharacterIterator create(Map<String,Object> table) {
|
||||
format = (Format)createInstance((String)table.get("class"),
|
||||
((Vector)table.get("args")).toArray());
|
||||
((List)table.get("args")).toArray());
|
||||
value = createInstance((String)table.get("valueClass"),
|
||||
((Vector)table.get("valueArgs")).toArray());
|
||||
((List)table.get("valueArgs")).toArray());
|
||||
|
||||
logln("Created format: " + format + " value " + value);
|
||||
AttributedCharacterIterator aci = format.
|
||||
@ -343,11 +346,12 @@ public class FormatIteratorTest extends IntlTest {
|
||||
private Object createInstance(String className, Object[] args) {
|
||||
if (className.equals("java.lang.reflect.Array")) {
|
||||
for (int counter = 0; counter < args.length; counter++) {
|
||||
if (args[counter] instanceof Vector) {
|
||||
Vector v = (Vector)args[counter];
|
||||
if (args[counter] instanceof List) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> v = (List<Object>)args[counter];
|
||||
|
||||
args[counter] = createInstance((String)v.get(0),
|
||||
((Vector)v.get(1)).toArray());
|
||||
((List)v.get(1)).toArray());
|
||||
}
|
||||
}
|
||||
return args;
|
||||
@ -361,9 +365,9 @@ public class FormatIteratorTest extends IntlTest {
|
||||
} else if (className.equals("java.util.concurrent.atomic.AtomicLong")) {
|
||||
return new AtomicLong(Long.valueOf((String)args[0]));
|
||||
} else {
|
||||
Class klass = lookupClass(className);
|
||||
Constructor cons = klass.getConstructor(
|
||||
new Class[] { String.class });
|
||||
Class<?> klass = lookupClass(className);
|
||||
Constructor<?> cons = klass.getConstructor(
|
||||
new Class<?>[] { String.class });
|
||||
Object value = cons.newInstance(args);
|
||||
|
||||
return value;
|
||||
@ -374,20 +378,20 @@ public class FormatIteratorTest extends IntlTest {
|
||||
}
|
||||
}
|
||||
|
||||
private Class lookupClass(String name) throws ClassNotFoundException {
|
||||
private Class<?> lookupClass(String name) throws ClassNotFoundException {
|
||||
try {
|
||||
Class klass = Class.forName(name);
|
||||
Class<?> klass = Class.forName(name);
|
||||
|
||||
return klass;
|
||||
} catch (ClassNotFoundException e1) {}
|
||||
|
||||
try {
|
||||
Class klass = Class.forName("java.lang." + name);
|
||||
Class<?> klass = Class.forName("java.lang." + name);
|
||||
|
||||
return klass;
|
||||
} catch (ClassNotFoundException e1) {}
|
||||
|
||||
Class klass = Class.forName("java.text." + name);
|
||||
Class<?> klass = Class.forName("java.text." + name);
|
||||
|
||||
return klass;
|
||||
}
|
||||
@ -397,7 +401,7 @@ public class FormatIteratorTest extends IntlTest {
|
||||
|
||||
try {
|
||||
int dotIndex = name.indexOf('.');
|
||||
Class klass = lookupClass(name.substring(0, dotIndex));
|
||||
Class<?> klass = lookupClass(name.substring(0, dotIndex));
|
||||
String fieldName = name.substring(dotIndex + 1);
|
||||
Field[] fields = klass.getFields();
|
||||
|
||||
@ -429,8 +433,8 @@ public class FormatIteratorTest extends IntlTest {
|
||||
return string;
|
||||
}
|
||||
|
||||
public Set makeAttributes(Vector names) {
|
||||
HashSet set = new HashSet(Math.max(1, names.size()));
|
||||
public Set<Attribute> makeAttributes(List<Object> names) {
|
||||
Set<Attribute> set = new HashSet<>(Math.max(1, names.size()));
|
||||
|
||||
for (int counter = 0; counter < names.size(); counter++) {
|
||||
set.add(makeAttribute((String)names.get(counter)));
|
||||
|
||||
@ -58,7 +58,7 @@ public class PParser {
|
||||
public PParser() {
|
||||
}
|
||||
|
||||
public Hashtable parse(Reader r) throws IOException {
|
||||
public Map<String,Object> parse(Reader r) throws IOException {
|
||||
this.reader = r;
|
||||
bufferedToken = false;
|
||||
lineNumber = 0;
|
||||
@ -91,23 +91,23 @@ public class PParser {
|
||||
}
|
||||
|
||||
protected Object parseArray() throws IOException {
|
||||
Vector array = new Vector();
|
||||
int token;
|
||||
List<Object> array = new ArrayList<>();
|
||||
int token;
|
||||
|
||||
while ((token = getToken()) != CLOSE_ARRAY) {
|
||||
if (token == MORE) {
|
||||
token = getToken();
|
||||
}
|
||||
if (token != CLOSE_ARRAY) {
|
||||
array.addElement(parseValue(token));
|
||||
array.add(parseValue(token));
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
protected Hashtable parsePair() throws IOException {
|
||||
Hashtable ht = new Hashtable(11);
|
||||
int token;
|
||||
protected Map<String,Object> parsePair() throws IOException {
|
||||
Map<String,Object> ht = new HashMap<>(11);
|
||||
int token;
|
||||
|
||||
while ((token = getToken()) != CLOSE_PAIR) {
|
||||
if (token != STRING) {
|
||||
@ -133,11 +133,12 @@ public class PParser {
|
||||
}
|
||||
|
||||
protected int getToken() throws IOException {
|
||||
int token = getToken(false, false);
|
||||
int token = getToken(false, false);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
@SuppressWarnings("fallthrough")
|
||||
protected int getToken(boolean wantsWS, boolean inString)
|
||||
throws IOException {
|
||||
if (bufferedToken) {
|
||||
@ -225,31 +226,26 @@ public class PParser {
|
||||
throw new RuntimeException(errorString + " at line " + lineNumber + " column " + column);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void dump(Object o) {
|
||||
if (o instanceof String) {
|
||||
System.out.print(o);
|
||||
} else if(o instanceof Vector) {
|
||||
Enumeration e = ((Vector)o).elements();
|
||||
|
||||
} else if(o instanceof List) {
|
||||
dump(" (");
|
||||
while (e.hasMoreElements()) {
|
||||
dump(e.nextElement());
|
||||
((List)o).forEach((l) -> {
|
||||
dump(l);
|
||||
dump(" -- ");
|
||||
}
|
||||
});
|
||||
dump(" )");
|
||||
} else {
|
||||
Hashtable ht = (Hashtable)o;
|
||||
Enumeration e = ht.keys();
|
||||
|
||||
Map<String,Object> ht = (Map<String,Object>)o;
|
||||
dump(" {");
|
||||
while (e.hasMoreElements()) {
|
||||
Object key = e.nextElement();
|
||||
|
||||
dump(key);
|
||||
ht.keySet().forEach(l -> {
|
||||
dump(l);
|
||||
dump(" = ");
|
||||
dump(ht.get(key));
|
||||
dump(ht.get(l));
|
||||
dump(";");
|
||||
}
|
||||
});
|
||||
dump(" }");
|
||||
}
|
||||
}
|
||||
@ -259,9 +255,9 @@ public class PParser {
|
||||
System.out.println("need filename");
|
||||
} else {
|
||||
try {
|
||||
FileReader fr = new FileReader(args[0]);
|
||||
PParser parser = new PParser();
|
||||
Hashtable ht = parser.parse(fr);
|
||||
FileReader fr = new FileReader(args[0]);
|
||||
PParser parser = new PParser();
|
||||
Map<String,Object> ht = parser.parse(fr);
|
||||
|
||||
dump(ht);
|
||||
System.out.println();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2016, 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,12 +22,20 @@
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8026027
|
||||
* @bug 8026027 6543126
|
||||
* @summary Test Level.parse to look up custom levels by name and its
|
||||
* localized name
|
||||
*
|
||||
@ -41,23 +49,168 @@ public class CustomLevel extends Level {
|
||||
|
||||
private static final List<Level> levels = new ArrayList<>();
|
||||
private static final String RB_NAME = "myresource";
|
||||
private static final String OTHERRB_NAME = "myresource2";
|
||||
|
||||
private static class CustomLevelReference extends WeakReference<Level> {
|
||||
final String name;
|
||||
final int value;
|
||||
final String resourceBundleName;
|
||||
public CustomLevelReference(Level level, ReferenceQueue<Level> queue) {
|
||||
super(level, queue);
|
||||
name = level.getName();
|
||||
value = level.intValue();
|
||||
resourceBundleName = level.getResourceBundleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CustomLevelReference(\"" + name + "\", " + value + ", \""
|
||||
+ resourceBundleName + "\")";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
setupCustomLevels();
|
||||
setUpCustomLevelsOtherLoader();
|
||||
|
||||
// Level.parse will return the custom Level instance
|
||||
ResourceBundle rb = ResourceBundle.getBundle(RB_NAME);
|
||||
for (Level level : levels) {
|
||||
final ResourceBundle rb = getResourceBundle(level);
|
||||
String name = level.getName();
|
||||
if (!name.equals("WARNING") && !name.equals("INFO")) {
|
||||
Level l = Level.parse(name);
|
||||
if (!name.equals("WARNING") && !name.equals("INFO")
|
||||
&& !name.equals("SEVERE")) {
|
||||
// custom level whose name doesn't conflict with any standard one
|
||||
checkCustomLevel(Level.parse(name), level);
|
||||
checkCustomLevel(l, level);
|
||||
} else if (l != Level.WARNING && l != Level.INFO && l != Level.SEVERE
|
||||
|| !name.equals(l.getName())) {
|
||||
throw new RuntimeException("Unexpected level " + formatLevel(l));
|
||||
}
|
||||
System.out.println("Level.parse found expected level: "
|
||||
+ formatLevel(l));
|
||||
String localizedName = rb.getString(level.getName());
|
||||
Level l = Level.parse(localizedName);
|
||||
l = Level.parse(localizedName);
|
||||
if (l != level) {
|
||||
throw new RuntimeException("Unexpected level " + l + " " + l.getClass());
|
||||
throw new RuntimeException("Unexpected level " + l + " "
|
||||
+ l.getClass() + " for " + localizedName
|
||||
+ " in " + rb.getBaseBundleName());
|
||||
}
|
||||
}
|
||||
|
||||
final long otherLevelCount = levels.stream()
|
||||
.filter(CustomLevel::isCustomLoader)
|
||||
.count();
|
||||
|
||||
// Now verify that custom level instances are correctly
|
||||
// garbage collected when no longer referenced
|
||||
ReferenceQueue<Level> queue = new ReferenceQueue<>();
|
||||
List<CustomLevelReference> refs = new ArrayList<>();
|
||||
List<CustomLevelReference> customRefs = new ArrayList<>();
|
||||
int otherLevels = 0;
|
||||
while (!levels.isEmpty()) {
|
||||
Level l = levels.stream().findAny().get();
|
||||
boolean isCustomLoader = isCustomLoader(l);
|
||||
if (isCustomLoader) otherLevels++;
|
||||
|
||||
CustomLevelReference ref = new CustomLevelReference(l, queue);
|
||||
if (isCustomLoader) {
|
||||
customRefs.add(ref);
|
||||
} else {
|
||||
refs.add(ref);
|
||||
}
|
||||
|
||||
// remove strong references to l
|
||||
levels.remove(l);
|
||||
l = null;
|
||||
|
||||
// Run gc and wait for garbage collection
|
||||
if (otherLevels == otherLevelCount) {
|
||||
if (customRefs.size() != otherLevelCount) {
|
||||
throw new RuntimeException("Test bug: customRefs.size() != "
|
||||
+ otherLevelCount);
|
||||
}
|
||||
waitForGC(customRefs, queue);
|
||||
}
|
||||
}
|
||||
if (otherLevelCount != otherLevels || otherLevelCount == 0) {
|
||||
throw new RuntimeException("Test bug: "
|
||||
+ "no or wrong count of levels loaded from custom loader");
|
||||
}
|
||||
if (!customRefs.isEmpty()) {
|
||||
throw new RuntimeException(
|
||||
"Test bug: customRefs.size() should be empty!");
|
||||
}
|
||||
while (!refs.isEmpty()) {
|
||||
final Reference<?> ref = refs.remove(0);
|
||||
if (ref.get() == null) {
|
||||
throw new RuntimeException("Unexpected garbage collection for "
|
||||
+ ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void waitForGC(List<CustomLevelReference> customRefs,
|
||||
ReferenceQueue<Level> queue)
|
||||
throws InterruptedException
|
||||
{
|
||||
while (!customRefs.isEmpty()) {
|
||||
Reference<? extends Level> ref2;
|
||||
do {
|
||||
System.gc();
|
||||
Thread.sleep(100);
|
||||
} while ((ref2 = queue.poll()) == null);
|
||||
|
||||
// Check garbage collected reference
|
||||
if (!customRefs.contains(ref2)) {
|
||||
throw new RuntimeException("Unexpected reference: " + ref2);
|
||||
}
|
||||
CustomLevelReference ref = customRefs.remove(customRefs.indexOf(ref2));
|
||||
System.out.println(ref2 + " garbage collected");
|
||||
final String name = ref.name;
|
||||
Level l;
|
||||
try {
|
||||
l = Level.parse(name);
|
||||
if (!name.equals("SEVERE")
|
||||
&& !name.equals("INFO")
|
||||
|| !name.equals(l.getName())) {
|
||||
throw new RuntimeException("Unexpected level "
|
||||
+ formatLevel(l));
|
||||
} else {
|
||||
if (l == Level.WARNING || l == Level.INFO
|
||||
|| l == Level.SEVERE) {
|
||||
System.out.println("Level.parse found expected level: "
|
||||
+ formatLevel(l));
|
||||
} else {
|
||||
throw new RuntimeException("Unexpected level "
|
||||
+ formatLevel(l));
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException iae) {
|
||||
if (!name.equals("WARNING")
|
||||
&& !name.equals("INFO")
|
||||
&& !name.equals("SEVERE")) {
|
||||
System.out.println("Level.parse fired expected exception: "
|
||||
+ iae);
|
||||
} else {
|
||||
throw iae;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isCustomLoader(Level level) {
|
||||
final ClassLoader cl = level.getClass().getClassLoader();
|
||||
return cl != null
|
||||
&& cl != ClassLoader.getPlatformClassLoader()
|
||||
&& cl != ClassLoader.getSystemClassLoader();
|
||||
}
|
||||
|
||||
static ResourceBundle getResourceBundle(Level level) {
|
||||
return isCustomLoader(level)
|
||||
? ResourceBundle.getBundle(OTHERRB_NAME, Locale.getDefault(),
|
||||
level.getClass().getClassLoader())
|
||||
: ResourceBundle.getBundle(RB_NAME);
|
||||
}
|
||||
|
||||
private static void setupCustomLevels() throws IOException {
|
||||
@ -67,22 +220,53 @@ public class CustomLevel extends Level {
|
||||
levels.add(new CustomLevel("WARNING", 1010, RB_NAME));
|
||||
levels.add(new CustomLevel("INFO", 1000, RB_NAME));
|
||||
}
|
||||
|
||||
static void setUpCustomLevelsOtherLoader()
|
||||
throws MalformedURLException,
|
||||
ClassNotFoundException, NoSuchMethodException,
|
||||
IllegalAccessException, InvocationTargetException
|
||||
{
|
||||
final String classes = System.getProperty("test.classes",
|
||||
"build/classes");
|
||||
final String sources = System.getProperty("test.src",
|
||||
"src");
|
||||
final URL curl = new File(classes).toURI().toURL();
|
||||
final URL surl = new File(sources).toURI().toURL();
|
||||
URLClassLoader loader = new URLClassLoader(new URL[] {curl, surl},
|
||||
ClassLoader.getPlatformClassLoader());
|
||||
Class<?> customLevelClass = Class.forName("CustomLevel", false, loader);
|
||||
Method m = customLevelClass.getMethod("setUpCustomLevelsOtherLoader",
|
||||
List.class);
|
||||
m.invoke(null, levels);
|
||||
}
|
||||
|
||||
public static void setUpCustomLevelsOtherLoader(List<Level> levels) {
|
||||
levels.add(new CustomLevel("OTHEREMERGENCY", 1091, OTHERRB_NAME));
|
||||
levels.add(new CustomLevel("OTHERALERT", 1061, OTHERRB_NAME));
|
||||
levels.add(new CustomLevel("OTHERCRITICAL", 1031, OTHERRB_NAME));
|
||||
levels.add(new CustomLevel("SEVERE", 1011, OTHERRB_NAME));
|
||||
levels.add(new CustomLevel("INFO", 1000, OTHERRB_NAME));
|
||||
}
|
||||
|
||||
static void checkCustomLevel(Level level, Level expected) {
|
||||
// Level value must be the same
|
||||
if (!level.equals(expected)) {
|
||||
throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected));
|
||||
throw new RuntimeException(formatLevel(level) + " != "
|
||||
+ formatLevel(expected));
|
||||
}
|
||||
|
||||
if (!level.getName().equals(expected.getName())) {
|
||||
throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected));
|
||||
throw new RuntimeException(formatLevel(level) + " != "
|
||||
+ formatLevel(expected));
|
||||
}
|
||||
|
||||
// Level.parse is expected to return the custom Level
|
||||
if (level != expected) {
|
||||
throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected));
|
||||
throw new RuntimeException(formatLevel(level) + " != "
|
||||
+ formatLevel(expected));
|
||||
}
|
||||
|
||||
ResourceBundle rb = ResourceBundle.getBundle(RB_NAME);
|
||||
final ResourceBundle rb = getResourceBundle(level);
|
||||
String name = rb.getString(level.getName());
|
||||
if (!level.getLocalizedName().equals(name)) {
|
||||
// must have the same localized name
|
||||
|
||||
5
jdk/test/java/util/logging/Level/myresource2.properties
Normal file
5
jdk/test/java/util/logging/Level/myresource2.properties
Normal file
@ -0,0 +1,5 @@
|
||||
OTHEREMERGENCY=localized.otheremergency
|
||||
OTHERALERT=localized.otheralert
|
||||
OTHERCRITICAL=localized.othercritical
|
||||
SEVERE=localized.severe
|
||||
INFO=localized.info.2
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +30,7 @@
|
||||
* @key intermittent
|
||||
* @summary Datagram Transport Layer Security (DTLS)
|
||||
* @modules java.base/sun.security.util
|
||||
* jdk.crypto.ec
|
||||
* @build DTLSOverDatagram
|
||||
* @run main/othervm CipherSuite TLS_RSA_WITH_AES_128_CBC_SHA
|
||||
* @run main/othervm CipherSuite TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS buffer overflow and underflow status when dealing with
|
||||
* application data.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.base/sun.security.util
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
* -Dtest.mode=norm DTLSBufferOverflowUnderflowTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS application data exchange using each of the supported
|
||||
* cipher suites.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
* -Dtest.mode=norm DTLSDataExchangeTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS engines closing using each of the supported
|
||||
* cipher suites.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
* -Dtest.mode=norm DTLSEnginesClosureTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS engines handshake using each of the supported
|
||||
* cipher suites.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
* -Dtest.mode=norm DTLSHandshakeTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS engines handshake using each of the supported
|
||||
* cipher suites with replicated packets check.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
* -Dtest.mode=norm DTLSHandshakeWithReplicatedPacketsTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS incorrect app data packages unwrapping.
|
||||
* @key randomness
|
||||
* @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
* -Dtest.mode=norm DTLSIncorrectAppDataTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
@ -28,6 +28,14 @@
|
||||
* cipher suites with different maximum fragment length. Testing of
|
||||
* MFLN extension.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
* -Dtest.mode=norm DTLSMFLNTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
@ -26,6 +26,13 @@
|
||||
* @bug 8043758
|
||||
* @summary Testing DTLS engines do not enable RC4 ciphers by default.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS DTLSNotEnabledRC4Test
|
||||
*/
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS engines re-handshaking using each of the supported
|
||||
* cipher suites.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
* -Dtest.mode=norm DTLSRehandshakeTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
@ -28,6 +28,13 @@
|
||||
* is taken randomly from the supporetd ciphers list.
|
||||
* @key randomness
|
||||
* @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
* DTLSRehandshakeWithCipherChangeTest
|
||||
*/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
@ -28,6 +28,14 @@
|
||||
* cipher suites with application data exchange before and after
|
||||
* re-handshake and closing of the engines.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
* -Dtest.mode=norm DTLSRehandshakeWithDataExTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
@ -28,6 +28,14 @@
|
||||
* data exchange.
|
||||
* @key randomness
|
||||
* @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
* -Dtest.mode=norm DTLSSequenceNumberTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,13 @@
|
||||
* @summary Testing that try to enable unsupported ciphers
|
||||
* causes IllegalArgumentException.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLS DTLSUnsupportedCiphersTest
|
||||
*/
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS buffer overflow and underflow status when dealing with
|
||||
* application data.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
* -Dtest.mode=norm DTLSv10BufferOverflowUnderflowTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS application data exchange using each of the supported
|
||||
* cipher suites.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
* -Dtest.mode=norm DTLSv10DataExchangeTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS engines closing using each of the supported
|
||||
* cipher suites.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
* -Dtest.mode=norm DTLSv10EnginesClosureTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS engines handshake using each of the supported
|
||||
* cipher suites.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
* -Dtest.mode=norm DTLSv10HandshakeTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS engines handshake using each of the supported
|
||||
* cipher suites with replicated packets check.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /javax/net/ssl/DTLS
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
* -Dtest.mode=norm DTLSv10HandshakeWithReplicatedPacketsTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS incorrect app data packages unwrapping.
|
||||
* @key randomness
|
||||
* @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon /javax/net/ssl/DTLS
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
* -Dtest.mode=norm DTLSIncorrectAppDataTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
@ -28,6 +28,14 @@
|
||||
* cipher suites with different maximum fragment length. Testing of
|
||||
* MFLN extension.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
* -Dtest.mode=norm DTLSv10MFLNTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
@ -26,6 +26,13 @@
|
||||
* @bug 8043758
|
||||
* @summary Testing DTLS engines do not enable RC4 ciphers by default.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0 DTLSv10NotEnabledRC4Test
|
||||
*/
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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,6 +27,14 @@
|
||||
* @summary Testing DTLS engines re-handshaking using each of the supported
|
||||
* cipher suites.
|
||||
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
|
||||
* @modules java.security.jgss
|
||||
* jdk.security.auth
|
||||
* java.security.jgss/sun.security.krb5
|
||||
* java.security.jgss/sun.security.krb5.internal.crypto
|
||||
* java.security.jgss/sun.security.krb5.internal.ccache
|
||||
* java.security.jgss/sun.security.krb5.internal
|
||||
* java.security.jgss/sun.security.krb5.internal.ktab
|
||||
* java.base/sun.security.util
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
* -Dtest.mode=norm DTLSv10RehandshakeTest
|
||||
* @run main/othervm -Dtest.security.protocol=DTLSv1.0
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user