This commit is contained in:
Lana Steuck 2015-01-12 12:24:30 -08:00
commit 2f8699112f
64 changed files with 1728 additions and 390 deletions

View File

@ -53,24 +53,21 @@ endif
# Find the default set of src dirs for a native library.
# Param 1 - module name
# Param 2 - library name
define FindSrcDirsForLib
FindSrcDirsForLib = \
$(call uniq, $(wildcard \
$(JDK_TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS)/native/lib$(strip $2) \
$(JDK_TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/native/lib$(strip $2) \
$(JDK_TOPDIR)/src/$(strip $1)/share/native/lib$(strip $2)))
endef
################################################################################
# Find lib dir for module
# Param 1 - module name
ifeq ($(OPENJDK_TARGET_OS_TYPE), unix)
define FindLibDirForModule
$(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)$(OPENJDK_TARGET_CPU_LIBDIR)
endef
FindLibDirForModule = \
$(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)$(OPENJDK_TARGET_CPU_LIBDIR)
else
define FindLibDirForModule
$(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
endef
FindLibDirForModule = \
$(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
endif
################################################################################
@ -78,11 +75,10 @@ endif
# Param 1 - module name
# Param 2 - library name
# Param 3 - subdir for library
define FindLib
$(strip \
$(call FindLibDirForModule, $(strip $1))$(strip $3)/$(LIBRARY_PREFIX)$(strip $2)$(SHARED_LIBRARY_SUFFIX) \
)
endef
FindLib = \
$(call FindLibDirForModule, \
$(strip $1))$(strip $3)/$(LIBRARY_PREFIX)$(strip $2)$(SHARED_LIBRARY_SUFFIX)
################################################################################
# Define the header include flags needed to compile against it.

View File

@ -17,10 +17,10 @@ java.security.sasl
java.smartcardio
java.sql
java.sql.rowset
java.transaction
java.xml
java.xml.bind
java.xml.crypto
java.xml.soap
java.xml.ws
jdk.charsets
jdk.deploy

View File

@ -48,6 +48,8 @@ class FilterOutputStream extends OutputStream {
*/
protected OutputStream out;
private boolean closed;
/**
* Creates an output stream filter built on top of the specified
* underlying output stream.
@ -144,9 +146,9 @@ class FilterOutputStream extends OutputStream {
* Closes this output stream and releases any system resources
* associated with the stream.
* <p>
* The <code>close</code> method of <code>FilterOutputStream</code>
* calls its <code>flush</code> method, and then calls the
* <code>close</code> method of its underlying output stream.
* When not already closed, the {@code close} method of {@code
* FilterOutputStream} calls its {@code flush} method, and then
* calls the {@code close} method of its underlying output stream.
*
* @exception IOException if an I/O error occurs.
* @see java.io.FilterOutputStream#flush()
@ -154,6 +156,9 @@ class FilterOutputStream extends OutputStream {
*/
@SuppressWarnings("try")
public void close() throws IOException {
if (closed)
return;
closed = true;
try (OutputStream ostream = out) {
flush();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2015, 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
@ -34,9 +34,13 @@ import static java.lang.annotation.ElementType.*;
* or because a better alternative exists. Compilers warn when a
* deprecated program element is used or overridden in non-deprecated code.
*
* <p>Use of the &#64;Deprecated annotation on a local variable
* declaration or on a parameter declaration or a package declaration
* has no effect.
*
* @author Neal Gafter
* @since 1.5
* @jls 9.6.3.6 @Deprecated
* @jls 9.6.4.6 @Deprecated
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)

View File

@ -265,24 +265,41 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
// Constructors
/**
* Translates a byte array containing the two's-complement binary
* representation of a BigInteger into a BigInteger. The input array is
* Translates a byte sub-array containing the two's-complement binary
* representation of a BigInteger into a BigInteger. The sub-array is
* specified via an offset into the array and a length. The sub-array is
* assumed to be in <i>big-endian</i> byte-order: the most significant
* byte is in the zeroth element.
* byte is the element at index {@code off}. The {@code val} array is
* assumed to be unchanged for the duration of the constructor call.
*
* @param val big-endian two's-complement binary representation of
* BigInteger.
* An {@code IndexOutOfBoundsException} is thrown if the length of the array
* {@code val} is non-zero and either {@code off} is negative, {@code len}
* is negative, or {@code off+len} is greater than the length of
* {@code val}.
*
* @param val byte array containing a sub-array which is the big-endian
* two's-complement binary representation of a BigInteger.
* @param off the start offset of the binary representation.
* @param len the number of bytes to use.
* @throws NumberFormatException {@code val} is zero bytes long.
* @throws IndexOutOfBoundsException if the provided array offset and
* length would cause an index into the byte array to be
* negative or greater than or equal to the array length.
* @since 1.9
*/
public BigInteger(byte[] val) {
if (val.length == 0)
public BigInteger(byte[] val, int off, int len) {
if (val.length == 0) {
throw new NumberFormatException("Zero length BigInteger");
} else if ((off < 0) || (off >= val.length) || (len < 0) ||
(len > val.length - off)) { // 0 <= off < val.length
throw new IndexOutOfBoundsException();
}
if (val[0] < 0) {
mag = makePositive(val);
if (val[off] < 0) {
mag = makePositive(val, off, len);
signum = -1;
} else {
mag = stripLeadingZeroBytes(val);
mag = stripLeadingZeroBytes(val, off, len);
signum = (mag.length == 0 ? 0 : 1);
}
if (mag.length >= MAX_MAG_LENGTH) {
@ -290,11 +307,28 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
}
}
/**
* Translates a byte array containing the two's-complement binary
* representation of a BigInteger into a BigInteger. The input array is
* assumed to be in <i>big-endian</i> byte-order: the most significant
* byte is in the zeroth element. The {@code val} array is assumed to be
* unchanged for the duration of the constructor call.
*
* @param val big-endian two's-complement binary representation of a
* BigInteger.
* @throws NumberFormatException {@code val} is zero bytes long.
*/
public BigInteger(byte[] val) {
this(val, 0, val.length);
}
/**
* This private constructor translates an int array containing the
* two's-complement binary representation of a BigInteger into a
* BigInteger. The input array is assumed to be in <i>big-endian</i>
* int-order: the most significant int is in the zeroth element.
* int-order: the most significant int is in the zeroth element. The
* {@code val} array is assumed to be unchanged for the duration of
* the constructor call.
*/
private BigInteger(int[] val) {
if (val.length == 0)
@ -315,24 +349,44 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
/**
* Translates the sign-magnitude representation of a BigInteger into a
* BigInteger. The sign is represented as an integer signum value: -1 for
* negative, 0 for zero, or 1 for positive. The magnitude is a byte array
* in <i>big-endian</i> byte-order: the most significant byte is in the
* zeroth element. A zero-length magnitude array is permissible, and will
* result in a BigInteger value of 0, whether signum is -1, 0 or 1.
* negative, 0 for zero, or 1 for positive. The magnitude is a sub-array of
* a byte array in <i>big-endian</i> byte-order: the most significant byte
* is the element at index {@code off}. A zero value of the length
* {@code len} is permissible, and will result in a BigInteger value of 0,
* whether signum is -1, 0 or 1. The {@code magnitude} array is assumed to
* be unchanged for the duration of the constructor call.
*
* An {@code IndexOutOfBoundsException} is thrown if the length of the array
* {@code magnitude} is non-zero and either {@code off} is negative,
* {@code len} is negative, or {@code off+len} is greater than the length of
* {@code magnitude}.
*
* @param signum signum of the number (-1 for negative, 0 for zero, 1
* for positive).
* @param magnitude big-endian binary representation of the magnitude of
* the number.
* @param off the start offset of the binary representation.
* @param len the number of bytes to use.
* @throws NumberFormatException {@code signum} is not one of the three
* legal values (-1, 0, and 1), or {@code signum} is 0 and
* {@code magnitude} contains one or more non-zero bytes.
* @throws IndexOutOfBoundsException if the provided array offset and
* length would cause an index into the byte array to be
* negative or greater than or equal to the array length.
* @since 1.9
*/
public BigInteger(int signum, byte[] magnitude) {
this.mag = stripLeadingZeroBytes(magnitude);
if (signum < -1 || signum > 1)
public BigInteger(int signum, byte[] magnitude, int off, int len) {
if (signum < -1 || signum > 1) {
throw(new NumberFormatException("Invalid signum value"));
} else if ((off < 0) || (len < 0) ||
(len > 0 &&
((off >= magnitude.length) ||
(len > magnitude.length - off)))) { // 0 <= off < magnitude.length
throw new IndexOutOfBoundsException();
}
// stripLeadingZeroBytes() returns a zero length array if len == 0
this.mag = stripLeadingZeroBytes(magnitude, off, len);
if (this.mag.length == 0) {
this.signum = 0;
@ -346,11 +400,34 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
}
}
/**
* Translates the sign-magnitude representation of a BigInteger into a
* BigInteger. The sign is represented as an integer signum value: -1 for
* negative, 0 for zero, or 1 for positive. The magnitude is a byte array
* in <i>big-endian</i> byte-order: the most significant byte is the
* zeroth element. A zero-length magnitude array is permissible, and will
* result in a BigInteger value of 0, whether signum is -1, 0 or 1. The
* {@code magnitude} array is assumed to be unchanged for the duration of
* the constructor call.
*
* @param signum signum of the number (-1 for negative, 0 for zero, 1
* for positive).
* @param magnitude big-endian binary representation of the magnitude of
* the number.
* @throws NumberFormatException {@code signum} is not one of the three
* legal values (-1, 0, and 1), or {@code signum} is 0 and
* {@code magnitude} contains one or more non-zero bytes.
*/
public BigInteger(int signum, byte[] magnitude) {
this(signum, magnitude, 0, magnitude.length);
}
/**
* A constructor for internal use that translates the sign-magnitude
* representation of a BigInteger into a BigInteger. It checks the
* arguments and copies the magnitude so this constructor would be
* safe for external use.
* safe for external use. The {@code magnitude} array is assumed to be
* unchanged for the duration of the constructor call.
*/
private BigInteger(int signum, int[] magnitude) {
this.mag = stripLeadingZeroInts(magnitude);
@ -467,7 +544,9 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
/*
* Constructs a new BigInteger using a char array with radix=10.
* Sign is precalculated outside and not allowed in the val.
* Sign is precalculated outside and not allowed in the val. The {@code val}
* array is assumed to be unchanged for the duration of the constructor
* call.
*/
BigInteger(char[] val, int sign, int len) {
int cursor = 0, numDigits;
@ -1035,11 +1114,12 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
/**
* This private constructor is for internal use and assumes that its
* arguments are correct.
* arguments are correct. The {@code magnitude} array is assumed to be
* unchanged for the duration of the constructor call.
*/
private BigInteger(byte[] magnitude, int signum) {
this.signum = (magnitude.length == 0 ? 0 : signum);
this.mag = stripLeadingZeroBytes(magnitude);
this.mag = stripLeadingZeroBytes(magnitude, 0, magnitude.length);
if (mag.length >= MAX_MAG_LENGTH) {
checkRange();
}
@ -3977,18 +4057,18 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
/**
* Returns a copy of the input array stripped of any leading zero bytes.
*/
private static int[] stripLeadingZeroBytes(byte a[]) {
int byteLength = a.length;
private static int[] stripLeadingZeroBytes(byte a[], int off, int len) {
int indexBound = off + len;
int keep;
// Find first nonzero byte
for (keep = 0; keep < byteLength && a[keep] == 0; keep++)
for (keep = off; keep < indexBound && a[keep] == 0; keep++)
;
// Allocate new array and copy relevant part of input array
int intLength = ((byteLength - keep) + 3) >>> 2;
int intLength = ((indexBound - keep) + 3) >>> 2;
int[] result = new int[intLength];
int b = byteLength - 1;
int b = indexBound - 1;
for (int i = intLength-1; i >= 0; i--) {
result[i] = a[b--] & 0xff;
int bytesRemaining = b - keep + 1;
@ -4003,27 +4083,27 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
* Takes an array a representing a negative 2's-complement number and
* returns the minimal (no leading zero bytes) unsigned whose value is -a.
*/
private static int[] makePositive(byte a[]) {
private static int[] makePositive(byte a[], int off, int len) {
int keep, k;
int byteLength = a.length;
int indexBound = off + len;
// Find first non-sign (0xff) byte of input
for (keep=0; keep < byteLength && a[keep] == -1; keep++)
for (keep=off; keep < indexBound && a[keep] == -1; keep++)
;
/* Allocate output array. If all non-sign bytes are 0x00, we must
* allocate space for one extra output byte. */
for (k=keep; k < byteLength && a[k] == 0; k++)
for (k=keep; k < indexBound && a[k] == 0; k++)
;
int extraByte = (k == byteLength) ? 1 : 0;
int intLength = ((byteLength - keep + extraByte) + 3) >>> 2;
int extraByte = (k == indexBound) ? 1 : 0;
int intLength = ((indexBound - keep + extraByte) + 3) >>> 2;
int result[] = new int[intLength];
/* Copy one's complement of input into output, leaving extra
* byte (if it exists) == 0x00 */
int b = byteLength - 1;
int b = indexBound - 1;
for (int i = intLength-1; i >= 0; i--) {
result[i] = a[b--] & 0xff;
int numBytesToTransfer = Math.min(3, b-keep+1);
@ -4248,7 +4328,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
message = "BigInteger: Signum not present in stream";
throw new java.io.StreamCorruptedException(message);
}
int[] mag = stripLeadingZeroBytes(magnitude);
int[] mag = stripLeadingZeroBytes(magnitude, 0, magnitude.length);
if ((mag.length == 0) != (sign == 0)) {
String message = "BigInteger: signum-magnitude mismatch";
if (fields.defaulted("magnitude"))

View File

@ -3727,29 +3727,29 @@ public final class Formatter implements Closeable, Flushable {
exp = new StringBuilder("+00");
}
}
return;
}
long adjusted = -(long) scale + (len - 1);
if (form == BigDecimalLayoutForm.DECIMAL_FLOAT) {
} else if (form == BigDecimalLayoutForm.DECIMAL_FLOAT) {
// count of padding zeros
int pad = scale - len;
if (pad >= 0) {
if (scale >= len) {
// 0.xxx form
mant.append("0.");
dot = true;
trailingZeros(mant, pad);
trailingZeros(mant, scale - len);
mant.append(coeff);
} else {
if (-pad < len) {
if (scale > 0) {
// xx.xx form
mant.append(coeff, 0, -pad);
int pad = len - scale;
mant.append(coeff, 0, pad);
mant.append('.');
dot = true;
mant.append(coeff, -pad, -pad + scale);
} else {
mant.append(coeff, pad, len);
} else { // scale < 0
// xx form
mant.append(coeff, 0, len);
trailingZeros(mant, -scale);
if (intVal.signum() != 0) {
trailingZeros(mant, -scale);
}
this.scale = 0;
}
}
@ -3762,6 +3762,7 @@ public final class Formatter implements Closeable, Flushable {
mant.append(coeff, 1, len);
}
exp = new StringBuilder();
long adjusted = -(long) scale + (len - 1);
if (adjusted != 0) {
long abs = Math.abs(adjusted);
// require sign

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2015, 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
@ -29,7 +29,7 @@ import java.security.spec.AlgorithmParameterSpec;
/**
* This class specifies the parameters used with the
* <a href="http://www.ietf.org/rfc/rfc2040.txt"><i>RC5</i></a>
* <a href="http://tools.ietf.org/html/rfc2040"><i>RC5</i></a>
* algorithm.
*
* <p> The parameters consist of a version number, a rounds count, a word
@ -37,7 +37,7 @@ import java.security.spec.AlgorithmParameterSpec;
*
* <p> This class can be used to initialize a <code>Cipher</code> object that
* implements the <i>RC5</i> algorithm as supplied by
* <a href="http://www.rsasecurity.com">RSA Security Inc.</a>,
* <a href="http://www.rsa.com">RSA Security LLC</a>,
* or any parties authorized by RSA Security.
*
* @author Jan Luehe

View File

@ -123,7 +123,7 @@ class FileDispatcherImpl extends FileDispatcher {
new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty("jdk.net.enableFastFileTransfer");
return System.getProperty("jdk.nio.enableFastFileTransfer");
}
});
boolean enable;

View File

@ -81,9 +81,17 @@ static int getAdapters (JNIEnv *env, IP_ADAPTER_ADDRESSES **adapters) {
DWORD ret, flags;
IP_ADAPTER_ADDRESSES *adapterInfo;
ULONG len;
char *error_msg_buf = NULL;
size_t error_msg_buf_size =
strlen("IP Helper Library GetAdaptersAddresses function failed"
" with error == ") + 10;
int _ret = 0;
adapterInfo = (IP_ADAPTER_ADDRESSES *)malloc (bufsize);
if (adapterInfo == NULL) {
JNU_ThrowByName(env, "java/lang/OutOfMemoryError", "Native heap allocation failure");
JNU_ThrowByName(env, "java/lang/OutOfMemoryError",
"Native heap allocation failure");
return -1;
}
@ -94,10 +102,12 @@ static int getAdapters (JNIEnv *env, IP_ADAPTER_ADDRESSES **adapters) {
ret = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
if (ret == ERROR_BUFFER_OVERFLOW) {
IP_ADAPTER_ADDRESSES * newAdapterInfo = (IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
IP_ADAPTER_ADDRESSES * newAdapterInfo =
(IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
if (newAdapterInfo == NULL) {
free(adapterInfo);
JNU_ThrowByName(env, "java/lang/OutOfMemoryError", "Native heap allocation failure");
JNU_ThrowByName(env, "java/lang/OutOfMemoryError",
"Native heap allocation failure");
return -1;
}
@ -109,8 +119,32 @@ static int getAdapters (JNIEnv *env, IP_ADAPTER_ADDRESSES **adapters) {
if (ret != ERROR_SUCCESS) {
free (adapterInfo);
JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetAdaptersAddresses function failed");
if (ret == ERROR_INSUFFICIENT_BUFFER) {
JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetAdaptersAddresses function failed "
"with ERROR_INSUFFICIENT_BUFFER");
} else if (ret == ERROR_ADDRESS_NOT_ASSOCIATED ) {
JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetAdaptersAddresses function failed "
"with ERROR_ADDRESS_NOT_ASSOCIATED");
} else {
error_msg_buf = (char *)malloc(error_msg_buf_size);
if (error_msg_buf != NULL) {
memset(error_msg_buf, 0, error_msg_buf_size);
_ret = _snprintf_s(error_msg_buf, error_msg_buf_size,
_TRUNCATE, "IP Helper Library GetAdaptersAddresses "
"function failed with error == %d", ret);
if (_ret != -1) {
JNU_ThrowByName(env, "java/lang/Error", error_msg_buf);
} else {
JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetAdaptersAddresses function failure");
}
} else {
JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetAdaptersAddresses function failed");
}
}
return -1;
}
*adapters = adapterInfo;
@ -126,9 +160,14 @@ IP_ADAPTER_ADDRESSES *getAdapter (JNIEnv *env, jint index) {
DWORD flags, val;
IP_ADAPTER_ADDRESSES *adapterInfo, *ptr, *ret;
ULONG len;
char *error_msg_buf = NULL;
size_t error_msg_buf_size =
strlen("IP Helper Library GetAdaptersAddresses function failed with error == ") + 10;
int _ret = 0;
adapterInfo = (IP_ADAPTER_ADDRESSES *)malloc (bufsize);
if (adapterInfo == NULL) {
JNU_ThrowByName(env, "java/lang/OutOfMemoryError", "Native heap allocation failure");
JNU_ThrowByName(env, "java/lang/OutOfMemoryError",
"Native heap allocation failure");
return NULL;
}
len = bufsize;
@ -137,10 +176,12 @@ IP_ADAPTER_ADDRESSES *getAdapter (JNIEnv *env, jint index) {
flags |= GAA_FLAG_INCLUDE_PREFIX;
val = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
if (val == ERROR_BUFFER_OVERFLOW) {
IP_ADAPTER_ADDRESSES * newAdapterInfo = (IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
IP_ADAPTER_ADDRESSES * newAdapterInfo =
(IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
if (newAdapterInfo == NULL) {
free(adapterInfo);
JNU_ThrowByName(env, "java/lang/OutOfMemoryError", "Native heap allocation failure");
JNU_ThrowByName(env, "java/lang/OutOfMemoryError",
"Native heap allocation failure");
return NULL;
}
@ -152,10 +193,35 @@ IP_ADAPTER_ADDRESSES *getAdapter (JNIEnv *env, jint index) {
if (val != ERROR_SUCCESS) {
free (adapterInfo);
JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetAdaptersAddresses function failed");
if (val == ERROR_INSUFFICIENT_BUFFER) {
JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetAdaptersAddresses function failed "
"with ERROR_INSUFFICIENT_BUFFER");
} else if (val == ERROR_ADDRESS_NOT_ASSOCIATED ) {
JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetAdaptersAddresses function failed "
"with ERROR_ADDRESS_NOT_ASSOCIATED");
} else {
error_msg_buf = (char *)malloc(error_msg_buf_size);
if (error_msg_buf != NULL) {
memset(error_msg_buf, 0, error_msg_buf_size);
_ret = _snprintf_s(error_msg_buf, error_msg_buf_size,
_TRUNCATE, "IP Helper Library GetAdaptersAddresses function failed "
"with error == %d", val);
if (_ret != -1) {
JNU_ThrowByName(env, "java/lang/Error", error_msg_buf);
} else {
JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetAdaptersAddresses function failure");
}
} else {
JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetAdaptersAddresses function failed");
}
}
return NULL;
}
ptr = adapterInfo;
ret = NULL;
while (ptr != NULL) {
@ -168,7 +234,8 @@ IP_ADAPTER_ADDRESSES *getAdapter (JNIEnv *env, jint index) {
ret = (IP_ADAPTER_ADDRESSES *) malloc(sizeof(IP_ADAPTER_ADDRESSES));
if (ret == NULL) {
free(adapterInfo);
JNU_ThrowByName(env, "java/lang/OutOfMemoryError", "Native heap allocation failure");
JNU_ThrowByName(env, "java/lang/OutOfMemoryError",
"Native heap allocation failure");
return NULL;
}

View File

@ -85,7 +85,7 @@ public interface ScriptEngineFactory {
public List<String> getNames();
/**
* Returns the name of the scripting langauge supported by this
* Returns the name of the scripting language supported by this
* <code>ScriptEngine</code>.
* @return The name of the supported language.
*/
@ -104,14 +104,15 @@ public interface ScriptEngineFactory {
* <ul>
* <li>ScriptEngine.ENGINE</li>
* <li>ScriptEngine.ENGINE_VERSION</li>
* <li>ScriptEngine.NAME</li>
* <li>ScriptEngine.LANGUAGE</li>
* <li>ScriptEngine.LANGUAGE_VERSION</li>
* <li>ScriptEngine.NAME</li>
* </ul>
* <p>
* The values for these keys are the Strings returned by <code>getEngineName</code>,
* <code>getEngineVersion</code>, <code>getName</code>, <code>getLanguageName</code> and
* <code>getLanguageVersion</code> respectively.<br><br>
* <code>getEngineVersion</code>, <code>getLanguageName</code>,
* <code>getLanguageVersion</code> for the first four keys respectively. For NAME, one of the Strings
* returned by <code>getNames</code> is returned.<br><br>
* A reserved key, <code><b>THREADING</b></code>, whose value describes the behavior of the engine
* with respect to concurrent execution of scripts and maintenance of state is also defined.
* These values for the <code><b>THREADING</b></code> key are:<br><br>

View File

@ -0,0 +1,196 @@
/*
* Copyright (c) 2000, 2001, 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 javax.transaction.xa;
/**
* The XAException is thrown by the Resource Manager (RM) to inform the
* Transaction Manager of an error encountered by the involved transaction.
*
*/
public class XAException extends Exception {
//private static final long serialVersionUID = -8249683284832867751L;
/**
* The error code with which to create the SystemException.
*
* @serial The error code for the exception
*/
public int errorCode;
/**
* Create an XAException.
*/
public XAException() {
super();
}
/**
* Create an XAException with a given string.
*
* @param s The <code>String</code> object containing the exception
* message.
*/
public XAException(String s) {
super(s);
}
/**
* Create an XAException with a given error code.
*
* @param errcode The error code identifying the exception.
*/
public XAException(int errcode) {
super();
errorCode = errcode;
}
/**
* The inclusive lower bound of the rollback codes.
*/
public final static int XA_RBBASE = 100;
/**
* Indicates that the rollback was caused by an unspecified reason.
*/
public final static int XA_RBROLLBACK = XA_RBBASE;
/**
* Indicates that the rollback was caused by a communication failure.
*/
public final static int XA_RBCOMMFAIL = XA_RBBASE + 1;
/**
* A deadlock was detected.
*/
public final static int XA_RBDEADLOCK = XA_RBBASE + 2;
/**
* A condition that violates the integrity of the resource was detected.
*/
public final static int XA_RBINTEGRITY = XA_RBBASE + 3;
/**
* The resource manager rolled back the transaction branch for a reason
* not on this list.
*/
public final static int XA_RBOTHER = XA_RBBASE + 4;
/**
* A protocol error occurred in the resource manager.
*/
public final static int XA_RBPROTO = XA_RBBASE + 5;
/**
* A transaction branch took too long.
*/
public final static int XA_RBTIMEOUT = XA_RBBASE + 6;
/**
* May retry the transaction branch.
*/
public final static int XA_RBTRANSIENT = XA_RBBASE + 7;
/**
* The inclusive upper bound of the rollback error code.
*/
public final static int XA_RBEND = XA_RBTRANSIENT;
/**
* Resumption must occur where the suspension occurred.
*/
public final static int XA_NOMIGRATE = 9;
/**
* The transaction branch may have been heuristically completed.
*/
public final static int XA_HEURHAZ = 8;
/**
* The transaction branch has been heuristically committed.
*/
public final static int XA_HEURCOM = 7;
/**
* The transaction branch has been heuristically rolled back.
*/
public final static int XA_HEURRB = 6;
/**
* The transaction branch has been heuristically committed and
* rolled back.
*/
public final static int XA_HEURMIX = 5;
/**
* Routine returned with no effect and may be reissued.
*/
public final static int XA_RETRY = 4;
/**
* The transaction branch was read-only and has been committed.
*/
public final static int XA_RDONLY = 3;
/**
* There is an asynchronous operation already outstanding.
*/
public final static int XAER_ASYNC = -2;
/**
* A resource manager error has occurred in the transaction branch.
*/
public final static int XAER_RMERR = -3;
/**
* The XID is not valid.
*/
public final static int XAER_NOTA = -4;
/**
* Invalid arguments were given.
*/
public final static int XAER_INVAL = -5;
/**
* Routine was invoked in an inproper context.
*/
public final static int XAER_PROTO = -6;
/**
* Resource manager is unavailable.
*/
public final static int XAER_RMFAIL = -7;
/**
* The XID already exists.
*/
public final static int XAER_DUPID = -8;
/**
* The resource manager is doing work outside a global transaction.
*/
public final static int XAER_OUTSIDE = -9;
}

View File

@ -0,0 +1,305 @@
/*
* Copyright (c) 2000, 2001, 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 javax.transaction.xa;
/**
* The XAResource interface is a Java mapping of the industry standard
* XA interface based on the X/Open CAE Specification (Distributed
* Transaction Processing: The XA Specification).
*
* <p>The XA interface defines the contract between a Resource Manager
* and a Transaction Manager in a distributed transaction processing
* (DTP) environment. A JDBC driver or a JMS provider implements
* this interface to support the association between a global transaction
* and a database or message service connection.
*
* <p>The XAResource interface can be supported by any transactional
* resource that is intended to be used by application programs in an
* environment where transactions are controlled by an external
* transaction manager. An example of such a resource is a database
* management system. An application may access data through multiple
* database connections. Each database connection is enlisted with
* the transaction manager as a transactional resource. The transaction
* manager obtains an XAResource for each connection participating
* in a global transaction. The transaction manager uses the
* <code>start</code> method
* to associate the global transaction with the resource, and it uses the
* <code>end</code> method to disassociate the transaction from
* the resource. The resource
* manager is responsible for associating the global transaction to all
* work performed on its data between the start and end method invocations.
*
* <p>At transaction commit time, the resource managers are informed by
* the transaction manager to prepare, commit, or rollback a transaction
* according to the two-phase commit protocol.</p>
*
*/
public interface XAResource {
/**
* Commits the global transaction specified by xid.
*
* @param xid A global transaction identifier
*
* @param onePhase If true, the resource manager should use a one-phase
* commit protocol to commit the work done on behalf of xid.
*
* @exception XAException An error has occurred. Possible XAExceptions
* are XA_HEURHAZ, XA_HEURCOM, XA_HEURRB, XA_HEURMIX, XAER_RMERR,
* XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.
*
* <P>If the resource manager did not commit the transaction and the
* paramether onePhase is set to true, the resource manager may throw
* one of the XA_RB* exceptions. Upon return, the resource manager has
* rolled back the branch's work and has released all held resources.
*/
void commit(Xid xid, boolean onePhase) throws XAException;
/**
* Ends the work performed on behalf of a transaction branch.
* The resource manager disassociates the XA resource from the
* transaction branch specified and lets the transaction
* complete.
*
* <p>If TMSUSPEND is specified in the flags, the transaction branch
* is temporarily suspended in an incomplete state. The transaction
* context is in a suspended state and must be resumed via the
* <code>start</code> method with TMRESUME specified.</p>
*
* <p>If TMFAIL is specified, the portion of work has failed.
* The resource manager may mark the transaction as rollback-only</p>
*
* <p>If TMSUCCESS is specified, the portion of work has completed
* successfully.</p>
*
* @param xid A global transaction identifier that is the same as
* the identifier used previously in the <code>start</code> method.
*
* @param flags One of TMSUCCESS, TMFAIL, or TMSUSPEND.
*
* @exception XAException An error has occurred. Possible XAException
* values are XAER_RMERR, XAER_RMFAILED, XAER_NOTA, XAER_INVAL,
* XAER_PROTO, or XA_RB*.
*/
void end(Xid xid, int flags) throws XAException;
/**
* Tells the resource manager to forget about a heuristically
* completed transaction branch.
*
* @param xid A global transaction identifier.
*
* @exception XAException An error has occurred. Possible exception
* values are XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or
* XAER_PROTO.
*/
void forget(Xid xid) throws XAException;
/**
* Obtains the current transaction timeout value set for this
* XAResource instance. If <CODE>XAResource.setTransactionTimeout</CODE>
* was not used prior to invoking this method, the return value
* is the default timeout set for the resource manager; otherwise,
* the value used in the previous <CODE>setTransactionTimeout</CODE>
* call is returned.
*
* @return the transaction timeout value in seconds.
*
* @exception XAException An error has occurred. Possible exception
* values are XAER_RMERR and XAER_RMFAIL.
*/
int getTransactionTimeout() throws XAException;
/**
* This method is called to determine if the resource manager
* instance represented by the target object is the same as the
* resouce manager instance represented by the parameter <i>xares</i>.
*
* @param xares An XAResource object whose resource manager instance
* is to be compared with the resource manager instance of the
* target object.
*
* @return <i>true</i> if it's the same RM instance; otherwise
* <i>false</i>.
*
* @exception XAException An error has occurred. Possible exception
* values are XAER_RMERR and XAER_RMFAIL.
*/
boolean isSameRM(XAResource xares) throws XAException;
/**
* Ask the resource manager to prepare for a transaction commit
* of the transaction specified in xid.
*
* @param xid A global transaction identifier.
*
* @exception XAException An error has occurred. Possible exception
* values are: XA_RB*, XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL,
* or XAER_PROTO.
*
* @return A value indicating the resource manager's vote on the
* outcome of the transaction. The possible values are: XA_RDONLY
* or XA_OK. If the resource manager wants to roll back the
* transaction, it should do so by raising an appropriate XAException
* in the prepare method.
*/
int prepare(Xid xid) throws XAException;
/**
* Obtains a list of prepared transaction branches from a resource
* manager. The transaction manager calls this method during recovery
* to obtain the list of transaction branches that are currently in
* prepared or heuristically completed states.
*
* @param flag One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS
* must be used when no other flags are set in the parameter.
*
* @exception XAException An error has occurred. Possible values are
* XAER_RMERR, XAER_RMFAIL, XAER_INVAL, and XAER_PROTO.
*
* @return The resource manager returns zero or more XIDs of the
* transaction branches that are currently in a prepared or
* heuristically completed state. If an error occurs during the
* operation, the resource manager should throw the appropriate
* XAException.
*/
Xid[] recover(int flag) throws XAException;
/**
* Informs the resource manager to roll back work done on behalf
* of a transaction branch.
*
* @param xid A global transaction identifier.
*
* @exception XAException An error has occurred.
*/
void rollback(Xid xid) throws XAException;
/**
* Sets the current transaction timeout value for this <CODE>XAResource</CODE>
* instance. Once set, this timeout value is effective until
* <code>setTransactionTimeout</code> is invoked again with a different
* value. To reset the timeout value to the default value used by the resource
* manager, set the value to zero.
*
* If the timeout operation is performed successfully, the method returns
* <i>true</i>; otherwise <i>false</i>. If a resource manager does not
* support explicitly setting the transaction timeout value, this method
* returns <i>false</i>.
*
* @param seconds The transaction timeout value in seconds.
*
* @return <i>true</i> if the transaction timeout value is set successfully;
* otherwise <i>false</i>.
*
* @exception XAException An error has occurred. Possible exception values
* are XAER_RMERR, XAER_RMFAIL, or XAER_INVAL.
*/
boolean setTransactionTimeout(int seconds) throws XAException;
/**
* Starts work on behalf of a transaction branch specified in
* <code>xid</code>.
*
* If TMJOIN is specified, the start applies to joining a transaction
* previously seen by the resource manager. If TMRESUME is specified,
* the start applies to resuming a suspended transaction specified in the
* parameter <code>xid</code>.
*
* If neither TMJOIN nor TMRESUME is specified and the transaction
* specified by <code>xid</code> has previously been seen by the resource
* manager, the resource manager throws the XAException exception with
* XAER_DUPID error code.
*
* @param xid A global transaction identifier to be associated
* with the resource.
*
* @param flags One of TMNOFLAGS, TMJOIN, or TMRESUME.
*
* @exception XAException An error has occurred. Possible exceptions
* are XA_RB*, XAER_RMERR, XAER_RMFAIL, XAER_DUPID, XAER_OUTSIDE,
* XAER_NOTA, XAER_INVAL, or XAER_PROTO.
*/
void start(Xid xid, int flags) throws XAException;
/**
* Ends a recovery scan.
*/
public final static int TMENDRSCAN = 0x00800000;
/**
* Disassociates the caller and marks the transaction branch
* rollback-only.
*/
public final static int TMFAIL = 0x20000000;
/**
* Caller is joining existing transaction branch.
*/
public final static int TMJOIN = 0x00200000;
/**
* Use TMNOFLAGS to indicate no flags value is selected.
*/
public final static int TMNOFLAGS = 0x00000000;
/**
* Caller is using one-phase optimization.
*/
public final static int TMONEPHASE = 0x40000000;
/**
* Caller is resuming association with a suspended
* transaction branch.
*/
public final static int TMRESUME = 0x08000000;
/**
* Starts a recovery scan.
*/
public final static int TMSTARTRSCAN = 0x01000000;
/**
* Disassociates caller from a transaction branch.
*/
public final static int TMSUCCESS = 0x04000000;
/**
* Caller is suspending (not ending) its association with
* a transaction branch.
*/
public final static int TMSUSPEND = 0x02000000;
/**
* The transaction branch has been read-only and has been committed.
*/
public final static int XA_RDONLY = 0x00000003;
/**
* The transaction work has been prepared normally.
*/
public final static int XA_OK = 0;
}

View File

@ -0,0 +1,70 @@
/*
* Copyright (c) 2000, 2002, 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 javax.transaction.xa;
/**
* The Xid interface is a Java mapping of the X/Open transaction identifier
* XID structure. This interface specifies three accessor methods to
* retrieve a global transaction format ID, global transaction ID,
* and branch qualifier. The Xid interface is used by the transaction
* manager and the resource managers. This interface is not visible to
* the application programs.
*/
public interface Xid {
/**
* Maximum number of bytes returned by getGtrid.
*/
final static int MAXGTRIDSIZE = 64;
/**
* Maximum number of bytes returned by getBqual.
*/
final static int MAXBQUALSIZE = 64;
/**
* Obtain the format identifier part of the XID.
*
* @return Format identifier. O means the OSI CCR format.
*/
int getFormatId();
/**
* Obtain the global transaction identifier part of XID as an array
* of bytes.
*
* @return Global transaction identifier.
*/
byte[] getGlobalTransactionId();
/**
* Obtain the transaction branch identifier part of XID as an array
* of bytes.
*
* @return Global transaction identifier.
*/
byte[] getBranchQualifier();
}

View File

@ -0,0 +1,41 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
Copyright (c) 2001, 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.
-->
</head>
<body bgcolor="white">
Provides the API that defines the contract between the transaction
manager and the resource manager, which allows the transaction
manager to enlist and delist resource objects (supplied by the
resource manager driver) in JTA transactions. The driver vendor
for a specific resource manager provides the implementation of
this API.
<p>
@since 1.4
</body>
</html>

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 1998, 1999, 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.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package javax.transaction;
/**
* This exception indicates that the request carried an invalid transaction
* context. For example, this exception could be raised if an error
* occured when trying to register a resource.
*/
@SuppressWarnings("serial") // serialVersionUID intentionally omitted
public class InvalidTransactionException extends java.rmi.RemoteException {
public InvalidTransactionException() {
super();
}
public InvalidTransactionException(String msg) {
super(msg);
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 1998, 1999, 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.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package javax.transaction;
/**
* This exception indicates that a request carried a null transaction context,
* but the target object requires an activate transaction.
*/
@SuppressWarnings("serial") // serialVersionUID intentionally omitted
public class TransactionRequiredException extends java.rmi.RemoteException {
public TransactionRequiredException() {
super();
}
public TransactionRequiredException(String msg) {
super(msg);
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 1998, 1999, 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.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package javax.transaction;
/**
* This exception indicates that the transaction associated with processing
* of the request has been rolled back, or marked to roll back. Thus the
* requested operation either could not be performed or was not performed
* because further computation on behalf of the transaction would be
* fruitless
*/
@SuppressWarnings("serial") // serialVersionUID intentionally omitted
public class TransactionRolledbackException extends java.rmi.RemoteException {
public TransactionRolledbackException() {
super();
}
public TransactionRolledbackException(String msg) {
super(msg);
}
}

View File

@ -0,0 +1,36 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
Copyright (c) 1999, 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.
-->
</head>
<body bgcolor="white">
Contains three exceptions thrown by the ORB machinery during unmarshalling.
<p>
@since 1.3
</body>
</html>

View File

@ -21,7 +21,7 @@
* under the License.
*/
/*
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
* $Id: DOMKeyValue.java 1333415 2012-05-03 12:03:51Z coheigea $
@ -33,20 +33,19 @@ import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.*;
import javax.xml.crypto.dsig.keyinfo.KeyValue;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.io.IOException;
import java.math.BigInteger;
import java.security.KeyException;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.security.PublicKey;
import java.security.interfaces.DSAParams;
import java.security.interfaces.DSAPublicKey;
import java.security.interfaces.ECPublicKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.DSAPublicKeySpec;
import java.security.spec.ECField;
import java.security.spec.ECFieldFp;
import java.security.spec.ECParameterSpec;
import java.security.spec.ECPoint;
import java.security.spec.ECPublicKeySpec;
@ -54,6 +53,7 @@ import java.security.spec.EllipticCurve;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import java.security.spec.RSAPublicKeySpec;
import java.util.Arrays;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -325,55 +325,112 @@ public abstract class DOMKeyValue extends DOMStructure implements KeyValue {
private byte[] ecPublicKey;
private KeyFactory eckf;
private ECParameterSpec ecParams;
private Method encodePoint, decodePoint, getCurveName,
getECParameterSpec;
// The supported curve, secp256r1
private static final Curve SECP256R1;
static {
final String name, oid, sfield, a, b, x, y, n;
name = "secp256r1 [NIST P-256, X9.62 prime256v1]";
oid = "1.2.840.10045.3.1.7";
sfield =
"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF";
a =
"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC";
b =
"5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B";
x =
"6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296";
y =
"4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5";
n =
"FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551";
final int h = 1;
BigInteger p = bigInt(sfield);
ECField field = new ECFieldFp(p);
EllipticCurve curve = new EllipticCurve(field, bigInt(a),
bigInt(b));
ECPoint g = new ECPoint(bigInt(x), bigInt(y));
SECP256R1 = new Curve(name, oid, curve, g, bigInt(n), h);
}
EC(PublicKey key) throws KeyException {
super(key);
ECPublicKey ecKey = (ECPublicKey)key;
ECPoint ecPoint = ecKey.getW();
ecParams = ecKey.getParams();
try {
AccessController.doPrivileged(
new PrivilegedExceptionAction<Void>() {
public Void run() throws
ClassNotFoundException, NoSuchMethodException
{
getMethods();
return null;
}
}
);
} catch (PrivilegedActionException pae) {
throw new KeyException("ECKeyValue not supported",
pae.getException());
}
Object[] args = new Object[] { ecPoint, ecParams.getCurve() };
try {
ecPublicKey = (byte[])encodePoint.invoke(null, args);
} catch (IllegalAccessException iae) {
throw new KeyException(iae);
} catch (InvocationTargetException ite) {
throw new KeyException(ite);
}
ecPublicKey = encodePoint(ecPoint, ecParams.getCurve());
}
EC(Element dmElem) throws MarshalException {
super(dmElem);
}
void getMethods() throws ClassNotFoundException, NoSuchMethodException {
Class<?> c = Class.forName("sun.security.util.ECParameters");
Class<?>[] params = new Class<?>[] { ECPoint.class,
EllipticCurve.class };
encodePoint = c.getMethod("encodePoint", params);
params = new Class<?>[] { ECParameterSpec.class };
getCurveName = c.getMethod("getCurveName", params);
params = new Class<?>[] { byte[].class, EllipticCurve.class };
decodePoint = c.getMethod("decodePoint", params);
c = Class.forName("sun.security.util.NamedCurve");
params = new Class<?>[] { String.class };
getECParameterSpec = c.getMethod("getECParameterSpec", params);
private static ECPoint decodePoint(byte[] data, EllipticCurve curve)
throws IOException {
if ((data.length == 0) || (data[0] != 4)) {
throw new IOException("Only uncompressed point format " +
"supported");
}
// Per ANSI X9.62, an encoded point is a 1 byte type followed by
// ceiling(log base 2 field-size / 8) bytes of x and the same of y.
int n = (data.length - 1) / 2;
if (n != ((curve.getField().getFieldSize() + 7) >> 3)) {
throw new IOException("Point does not match field size");
}
byte[] xb = Arrays.copyOfRange(data, 1, 1 + n);
byte[] yb = Arrays.copyOfRange(data, n + 1, n + 1 + n);
return new ECPoint(new BigInteger(1, xb), new BigInteger(1, yb));
}
private static byte[] encodePoint(ECPoint point, EllipticCurve curve) {
// get field size in bytes (rounding up)
int n = (curve.getField().getFieldSize() + 7) >> 3;
byte[] xb = trimZeroes(point.getAffineX().toByteArray());
byte[] yb = trimZeroes(point.getAffineY().toByteArray());
if ((xb.length > n) || (yb.length > n)) {
throw new RuntimeException("Point coordinates do not " +
"match field size");
}
byte[] b = new byte[1 + (n << 1)];
b[0] = 4; // uncompressed
System.arraycopy(xb, 0, b, n - xb.length + 1, xb.length);
System.arraycopy(yb, 0, b, b.length - yb.length, yb.length);
return b;
}
private static byte[] trimZeroes(byte[] b) {
int i = 0;
while ((i < b.length - 1) && (b[i] == 0)) {
i++;
}
if (i == 0) {
return b;
}
return Arrays.copyOfRange(b, i, b.length);
}
private static String getCurveOid(ECParameterSpec params) {
// Check that the params represent the secp256r1 curve
// If so, return the object identifier of the curve
int fieldSize = params.getCurve().getField().getFieldSize();
if (SECP256R1.getCurve().getField().getFieldSize() == fieldSize
&& SECP256R1.getCurve().equals(params.getCurve())
&& SECP256R1.getGenerator().equals(params.getGenerator())
&& SECP256R1.getOrder().equals(params.getOrder())
&& SECP256R1.getCofactor() == params.getCofactor()) {
return SECP256R1.getObjectId();
}
return null;
}
private static ECParameterSpec getECParameterSpec(String oid) {
if (oid.equals(SECP256R1.getObjectId())) {
return SECP256R1;
}
return null;
}
void marshalPublicKey(Node parent, Document doc, String dsPrefix,
@ -391,14 +448,11 @@ public abstract class DOMKeyValue extends DOMStructure implements KeyValue {
XMLDSIG_11_XMLNS,
prefix);
Object[] args = new Object[] { ecParams };
try {
String oid = (String) getCurveName.invoke(null, args);
DOMUtils.setAttribute(namedCurveElem, "URI", "urn:oid:" + oid);
} catch (IllegalAccessException iae) {
throw new MarshalException(iae);
} catch (InvocationTargetException ite) {
throw new MarshalException(ite);
String oid = getCurveOid(ecParams);
if (oid == null) {
throw new MarshalException("Invalid ECParameterSpec");
}
DOMUtils.setAttribute(namedCurveElem, "URI", "urn:oid:" + oid);
String qname = (prefix == null || prefix.length() == 0)
? "xmlns" : "xmlns:" + prefix;
namedCurveElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
@ -422,21 +476,6 @@ public abstract class DOMKeyValue extends DOMStructure implements KeyValue {
("unable to create EC KeyFactory: " + e.getMessage());
}
}
try {
AccessController.doPrivileged(
new PrivilegedExceptionAction<Void>() {
public Void run() throws
ClassNotFoundException, NoSuchMethodException
{
getMethods();
return null;
}
}
);
} catch (PrivilegedActionException pae) {
throw new MarshalException("ECKeyValue not supported",
pae.getException());
}
ECParameterSpec ecParams = null;
Element curElem = DOMUtils.getFirstChildElement(kvtElem);
if (curElem.getLocalName().equals("ECParameters")) {
@ -447,14 +486,9 @@ public abstract class DOMKeyValue extends DOMStructure implements KeyValue {
// strip off "urn:oid"
if (uri.startsWith("urn:oid:")) {
String oid = uri.substring(8);
try {
Object[] args = new Object[] { oid };
ecParams = (ECParameterSpec)
getECParameterSpec.invoke(null, args);
} catch (IllegalAccessException iae) {
throw new MarshalException(iae);
} catch (InvocationTargetException ite) {
throw new MarshalException(ite);
ecParams = getECParameterSpec(oid);
if (ecParams == null) {
throw new MarshalException("Invalid curve OID");
}
} else {
throw new MarshalException("Invalid NamedCurve URI");
@ -464,24 +498,43 @@ public abstract class DOMKeyValue extends DOMStructure implements KeyValue {
}
curElem = DOMUtils.getNextSiblingElement(curElem, "PublicKey");
ECPoint ecPoint = null;
try {
Object[] args = new Object[] { Base64.decode(curElem),
ecParams.getCurve() };
ecPoint = (ECPoint)decodePoint.invoke(null, args);
ecPoint = decodePoint(Base64.decode(curElem),
ecParams.getCurve());
} catch (Base64DecodingException bde) {
throw new MarshalException("Invalid EC PublicKey", bde);
} catch (IllegalAccessException iae) {
throw new MarshalException(iae);
} catch (InvocationTargetException ite) {
throw new MarshalException(ite);
} catch (IOException ioe) {
throw new MarshalException("Invalid EC Point", ioe);
}
/*
ecPoint = sun.security.util.ECParameters.decodePoint(
Base64.decode(curElem), ecParams.getCurve());
*/
ECPublicKeySpec spec = new ECPublicKeySpec(ecPoint, ecParams);
return generatePublicKey(eckf, spec);
}
static final class Curve extends ECParameterSpec {
private final String name;
private final String oid;
Curve(String name, String oid, EllipticCurve curve,
ECPoint g, BigInteger n, int h) {
super(curve, g, n, h);
this.name = name;
this.oid = oid;
}
private String getName() {
return name;
}
private String getObjectId() {
return oid;
}
}
}
private static BigInteger bigInt(String s) {
return new BigInteger(s, 16);
}
static final class Unknown extends DOMKeyValue {

View File

@ -154,6 +154,9 @@ com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java aix-all
com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java aix-all
javax/management/MBeanServer/OldMBeanServerTest.java aix-all
# 8042215
javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java generic-all
############################################################################
# jdk_math

View File

@ -75,13 +75,13 @@ ${TESTJAVA}${FS}bin${FS}java -version
mkdir bug
cp ${TESTSRC}${FS}bug.idl .
${TESTJAVA}${FS}bin${FS}idlj bug.idl
${COMPILEJAVA}${FS}bin${FS}idlj bug.idl
cp ${TESTSRC}${FS}JavaBug.java bug
chmod -fR 777 bug
${TESTJAVA}${FS}bin${FS}javac -d . bug${FS}*.java
${COMPILEJAVA}${FS}bin${FS}javac -d . bug${FS}*.java
${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp . bug/JavaBug > test.out 2>&1

View File

@ -55,8 +55,8 @@ PORT=1052
cp -r ${TESTSRC}${FS}*.java ${TESTSRC}${FS}Hello.idl .
echo "Testing...please wait"
${TESTJAVA}${FS}bin${FS}idlj -fall Hello.idl
${TESTJAVA}${FS}bin${FS}javac *.java HelloApp/*.java
${COMPILEJAVA}${FS}bin${FS}idlj -fall Hello.idl
${COMPILEJAVA}${FS}bin${FS}javac *.java HelloApp/*.java
echo "starting orbd"
${TESTJAVA}${FS}bin${FS}orbd -ORBInitialPort $PORT -ORBInitialHost localhost &

View File

@ -27,39 +27,52 @@
public class TestUtility {
private static final String digits = "0123456789abcdef";
private static final String DIGITS = "0123456789abcdef";
public TestUtility() {
private TestUtility() {
}
public static String hexDump(byte[] bytes) {
StringBuffer buf = new StringBuffer (bytes.length * 2);
int i;
StringBuilder buf = new StringBuilder(bytes.length * 2);
int i;
buf.append (" "); // four spaces
buf.append(" "); // four spaces
for (i = 0; i < bytes.length; i++) {
buf.append (digits.charAt ((bytes[i] >> 4) & 0x0f));
buf.append (digits.charAt (bytes[i] & 0x0f));
if (((i + 1) % 32) == 0) {
if ((i + 1) != bytes.length)
buf.append ("\n "); // line after four words
} else if (((i + 1) % 4) == 0)
buf.append (' '); // space between words
buf.append(DIGITS.charAt(bytes[i] >> 4 & 0x0f));
buf.append(DIGITS.charAt(bytes[i] & 0x0f));
if ((i + 1) % 32 == 0) {
if (i + 1 != bytes.length) {
buf.append("\n "); // line after four words
}
} else if ((i + 1) % 4 == 0) {
buf.append(' '); // space between words
}
}
return buf.toString ();
return buf.toString();
}
public static String hexDump(byte[] bytes, int index) {
StringBuilder buf = new StringBuilder(bytes.length * 2);
int i;
buf.append(" "); // four spaces
buf.append(DIGITS.charAt(bytes[index] >> 4 & 0x0f));
buf.append(DIGITS.charAt(bytes[index] & 0x0f));
return buf.toString();
}
public static boolean equalsBlock(byte[] b1, byte[] b2) {
if (b1.length != b2.length)
if (b1.length != b2.length) {
return false;
}
for (int i=0; i<b1.length; i++) {
if (b1[i] != b2[i])
for (int i = 0; i < b1.length; i++) {
if (b1[i] != b2[i]) {
return false;
}
}
return true;
@ -67,9 +80,10 @@ public class TestUtility {
public static boolean equalsBlock(byte[] b1, byte[] b2, int len) {
for (int i=0; i<len; i++) {
if (b1[i] != b2[i])
for (int i = 0; i < len; i++) {
if (b1[i] != b2[i]) {
return false;
}
}
return true;

View File

@ -25,7 +25,7 @@ import java.io.*;
/**
* @test
* @bug 7015589
* @bug 7015589 8054565
* @summary Test that buffering streams are considered closed even when the
* close or flush from the underlying stream fails.
*/
@ -165,7 +165,7 @@ public class FailingFlushAndClose {
}
}
static void testFailingClose(InputStream in) throws IOException {
static InputStream testFailingClose(InputStream in) throws IOException {
System.out.println(in.getClass());
in.read(new byte[100]);
try {
@ -176,9 +176,10 @@ public class FailingFlushAndClose {
in.read(new byte[100]);
fail("read did not fail");
} catch (IOException expected) { }
return in;
}
static void testFailingClose(OutputStream out) throws IOException {
static OutputStream testFailingClose(OutputStream out) throws IOException {
System.out.println(out.getClass());
out.write(1);
try {
@ -190,9 +191,10 @@ public class FailingFlushAndClose {
if (!(out instanceof BufferedOutputStream))
fail("write did not fail");
} catch (IOException expected) { }
return out;
}
static void testFailingFlush(OutputStream out) throws IOException {
static OutputStream testFailingFlush(OutputStream out) throws IOException {
System.out.println(out.getClass());
out.write(1);
try {
@ -206,9 +208,27 @@ public class FailingFlushAndClose {
fail("close did not fail");
} catch (IOException expected) { }
}
return out;
}
static void testFailingClose(Reader r) throws IOException {
static void closeAgain(InputStream in) throws IOException {
// assert the given stream should already be closed.
try {
in.close();
} catch (IOException expected) {
fail("unexpected IOException from subsequent close");
}
}
static void closeAgain(OutputStream out) throws IOException {
// assert the given stream should already be closed.
try {
out.close();
} catch (IOException expected) {
fail("unexpected IOException from subsequent close");
}
}
static Reader testFailingClose(Reader r) throws IOException {
System.out.println(r.getClass());
r.read(new char[100]);
try {
@ -219,9 +239,10 @@ public class FailingFlushAndClose {
r.read(new char[100]);
fail("read did not fail");
} catch (IOException expected) { }
return r;
}
static void testFailingClose(Writer w) throws IOException {
static Writer testFailingClose(Writer w) throws IOException {
System.out.println(w.getClass());
w.write("message");
try {
@ -232,9 +253,10 @@ public class FailingFlushAndClose {
w.write("another message");
fail("write did not fail");
} catch (IOException expected) { }
return w;
}
static void testFailingFlush(Writer w) throws IOException {
static Writer testFailingFlush(Writer w) throws IOException {
System.out.println(w.getClass());
w.write("message");
try {
@ -249,18 +271,38 @@ public class FailingFlushAndClose {
fail("close did not fail");
} catch (IOException expected) { }
}
return w;
}
static Reader closeAgain(Reader r) throws IOException {
// assert the given stream should already be closed.
try {
r.close();
} catch (IOException expected) {
fail("unexpected IOException from subsequent close");
}
return r;
}
static Writer closeAgain(Writer w) throws IOException {
// assert the given stream should already be closed.
try {
w.close();
} catch (IOException expected) {
fail("unexpected IOException from subsequent close");
}
return w;
}
public static void main(String[] args) throws IOException {
testFailingClose(new BufferedInputStream(new FailingCloseInputStream()));
testFailingClose(new BufferedOutputStream(new FailingCloseOutputStream()));
closeAgain(testFailingClose(new BufferedInputStream(new FailingCloseInputStream())));
closeAgain(testFailingClose(new BufferedOutputStream(new FailingCloseOutputStream())));
testFailingClose(new BufferedReader(new FailingCloseReader()));
testFailingClose(new BufferedWriter(new FailingCloseWriter()));
closeAgain(testFailingClose(new BufferedReader(new FailingCloseReader())));
closeAgain(testFailingClose(new BufferedWriter(new FailingCloseWriter())));
testFailingFlush(new BufferedOutputStream(new FailingFlushOutputStream()));
testFailingFlush(new BufferedWriter(new FailingFlushWriter()));
closeAgain(testFailingFlush(new BufferedOutputStream(new FailingFlushOutputStream())));
closeAgain(testFailingFlush(new BufferedWriter(new FailingFlushWriter())));
if (failed > 0)
throw new RuntimeException(failed + " test(s) failed - see log for details");

View File

@ -23,7 +23,7 @@
/*
* @test
* @bug 4181191 4161971 4227146 4194389 4823171 4624738 4812225 4837946
* @bug 4181191 4161971 4227146 4194389 4823171 4624738 4812225 4837946 4026465
* @summary tests methods in BigInteger
* @run main/timeout=400 BigIntegerTest
* @author madbot
@ -89,6 +89,120 @@ public class BigIntegerTest {
static Random rnd = new Random();
static boolean failure = false;
public static void constructor() {
int failCount = 0;
// --- guard condition tests for array indexing ---
int arrayLength = 23;
int halfLength = arrayLength/2;
byte[] array = new byte[arrayLength];
rnd.nextBytes(array);
int[][] offLen = new int[][] { // offset, length, num exceptions
{-1, arrayLength, 1}, // negative offset
{0, arrayLength, 0}, // OK
{1, arrayLength, 1}, // length overflow
{arrayLength - 1, 1, 0}, // OK
{arrayLength, 1, 1}, // offset overflow
{0, -1, 1}, // negative length
{halfLength, arrayLength - halfLength + 1, 1} // length overflow
};
// two's complement
for (int[] ol : offLen) {
int numExceptions = 0;
try {
BigInteger bi = new BigInteger(array, ol[0], ol[1]);
} catch (IndexOutOfBoundsException e) {
numExceptions++;
}
if (numExceptions != ol[2]) {
System.err.println("IndexOutOfBoundsException did not occur for "
+ " two's complement constructor with parameters offset "
+ ol[0] + " and length " + ol[1]);
failCount++;
}
}
// sign-magnitude
for (int[] ol : offLen) {
int numExceptions = 0;
try {
BigInteger bi = new BigInteger(1, array, ol[0], ol[1]);
} catch (IndexOutOfBoundsException e) {
numExceptions++;
}
if (numExceptions != ol[2]) {
System.err.println("IndexOutOfBoundsException did not occur for "
+ " sign-magnitude constructor with parameters offset "
+ ol[0] + " and length " + ol[1]);
failCount++;
}
}
// --- tests for creation of zero-valued BigIntegers ---
byte[] magZeroLength = new byte[0];
for (int signum = -1; signum <= 1; signum++) {
BigInteger bi = new BigInteger(signum, magZeroLength);
if (bi.compareTo(BigInteger.ZERO) != 0) {
System.err.println("A: Zero length BigInteger != 0 for signum " + signum);
failCount++;
}
}
for (int signum = -1; signum <= 1; signum++) {
BigInteger bi = new BigInteger(signum, magZeroLength, 0, 0);
if (bi.compareTo(BigInteger.ZERO) != 0) {
System.err.println("B: Zero length BigInteger != 0 for signum " + signum);
failCount++;
}
}
byte[] magNonZeroLength = new byte[42];
rnd.nextBytes(magNonZeroLength);
for (int signum = -1; signum <= 1; signum++) {
BigInteger bi = new BigInteger(signum, magNonZeroLength, 0, 0);
if (bi.compareTo(BigInteger.ZERO) != 0) {
System.err.println("C: Zero length BigInteger != 0 for signum " + signum);
failCount++;
}
}
// --- tests for accurate creation of non-zero BigIntegers ---
for (int i = 0; i < SIZE; i++) {
// create reference value via a different code path from those tested
BigInteger reference = new BigInteger(2 + rnd.nextInt(336), 4, rnd);
byte[] refArray = reference.toByteArray();
int refLen = refArray.length;
int factor = rnd.nextInt(5);
int objLen = refArray.length + factor*rnd.nextInt(refArray.length) + 1;
int offset = rnd.nextInt(objLen - refLen);
byte[] objArray = new byte[objLen];
System.arraycopy(refArray, 0, objArray, offset, refLen);
BigInteger twosComp = new BigInteger(objArray, offset, refLen);
if (twosComp.compareTo(reference) != 0) {
System.err.println("Two's-complement BigInteger not equal for offset " +
offset + " and length " + refLen);
failCount++;
}
boolean isNegative = rnd.nextBoolean();
BigInteger signMag = new BigInteger(isNegative ? -1 : 1, objArray, offset, refLen);
if (signMag.compareTo(isNegative ? reference.negate() : reference) != 0) {
System.err.println("Sign-magnitude BigInteger not equal for offset " +
offset + " and length " + refLen);
failCount++;
}
}
report("Constructor", failCount);
}
public static void pow(int order) {
int failCount1 = 0;
@ -961,6 +1075,8 @@ public class BigIntegerTest {
if (args.length >3)
order4 = (int)((Integer.parseInt(args[3]))* 3.333);
constructor();
prime();
nextProbablePrime();

View File

@ -25,7 +25,7 @@
* @bug 4652496
* @summary Test transferTo with different target channels
* @run main TransferToChannel
* @run main/othervm -Djdk.net.enableFastFileTransfer TransferToChannel
* @run main/othervm -Djdk.nio.enableFastFileTransfer TransferToChannel
*/
import java.nio.channels.FileChannel;

View File

@ -4,8 +4,8 @@
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
// test needs to communicate with the activation system
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
permission java.lang.RuntimePermission "getClassLoader";
};

View File

@ -1,10 +1,9 @@
/*
* security policy used by activation groups.
* security policy used by activation groups
*/
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
// test needs to communicate with the activation system
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -4,10 +4,6 @@
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
// allow remote objects to be exported on arbitrary ports.
permission java.net.SocketPermission "*:1024-", "connect,accept";
// allow exporting object with non-public remote interface
permission java.rmi.RMIPermission "exportRemoteInterface.ActivateMe";
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -1,13 +1,9 @@
/*
* security policy used activation groups
* security policy used by activation groups
*/
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
// test needs to communicate with the activation system
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
// allow exporting object with non-public remote interface
permission java.rmi.RMIPermission "exportRemoteInterface.ActivateMe";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -1,14 +1,15 @@
/*
* security policy used exec'ed activation groups
* security policy used by activation groups
*/
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
// need to load custom security manager and activation group from a new codebase
permission java.io.FilePermission ".${/}codebase1", "read,write,delete";
permission java.io.FilePermission ".${/}codebase1${/}-", "read,write";
permission java.io.FilePermission ".${/}codebase2", "read,write,delete";
permission java.io.FilePermission ".${/}codebase2${/}-", "read,write,delete";
// allow remote objects to be exported on arbitrary ports.
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
};

View File

@ -1,12 +1,13 @@
/*
* security policy used activation groups
* security policy used by activation groups
*/
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
// Needed because of bug#: 4182104
permission java.lang.RuntimePermission "modifyThreadGroup";
permission java.lang.RuntimePermission "modifyThread";
// allow remote objects to be exported on arbitrary ports.
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
};

View File

@ -1,8 +1,9 @@
/*
* security policy used exec'ed activation groups
* security policy used by activation groups
*/
grant {
// allow remote objects to be exported on arbitrary ports.
permission java.io.FilePermission "..${/}..${/}test.props", "read";
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -3,9 +3,7 @@
*/
grant {
// allow remote objects to be exported on arbitrary ports.
permission java.io.FilePermission "..${/}..${/}test.props", "read";
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
// allow exporting object with non-public remote interface
permission java.rmi.RMIPermission "exportRemoteInterface.ActivateMe";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -4,10 +4,6 @@
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
// allow remote objects to be exported on arbitrary ports.
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
// allow exporting object with non-public remote interface
permission java.rmi.RMIPermission "exportRemoteInterface.ActivateMe";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -1,13 +1,9 @@
/*
* security policy used by test activation groups
* security policy used by activation groups
*/
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
// allow remote objects to be exported on arbitrary ports.
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
// allow exporting of non-public remote interface
permission java.rmi.RMIPermission "exportRemoteInterface.ActivateMe";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -4,7 +4,6 @@
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
// allow remote objects to be exported on arbitrary ports.
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -1,8 +1,9 @@
/*
* security policy used by test activation groups
* security policy used by activation groups
*/
grant {
// test needs to communicate with the activation system
permission java.io.FilePermission "..${/}..${/}test.props", "read";
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -3,6 +3,7 @@
*/
grant {
// allow remote objects to be exported on arbitrary ports.
permission java.io.FilePermission "..${/}..${/}test.props", "read";
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -3,6 +3,7 @@
*/
grant {
// allow remote objects to be exported on arbitrary ports.
permission java.io.FilePermission "..${/}..${/}test.props", "read";
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -1,10 +1,9 @@
/*
* security policy used activation groups
* security policy used by activation groups
*/
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
// test needs to communicate with the activation system
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -4,7 +4,6 @@
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
// allow remote objects to be exported on arbitrary ports.
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -1,8 +1,9 @@
/*
* security policy used activation groups
* security policy used by activation groups
*/
grant {
// test needs to communicate with the activation system
permission java.io.FilePermission "..${/}..${/}test.props", "read";
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -1,10 +1,11 @@
/*
* security policy used by downloaded activation group
* security policy used by activation groups
*/
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.server";
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
};

View File

@ -4,10 +4,6 @@
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
// accomodate property used by this test.
permission java.util.PropertyPermission "test.message", "read";
// test needs to communicate with the activation system
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -1,13 +1,11 @@
/*
* security policy used by activation groups.
* security policy used by activation groups
*/
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
// give the group permission to create a class that the main test process can not create
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.provider";
// test needs to communicate with the activation system
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.provider";
};

View File

@ -4,8 +4,6 @@
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
// test needs to communicate with the activation system
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "unregisterGroup.port", "read";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -1,8 +1,9 @@
/*
* security policy used by activation groups.
* security policy used by activation groups
*/
grant {
// test needs to communicate with the activation system
permission java.io.FilePermission "..${/}..${/}test.props", "read";
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -1,11 +1,9 @@
/*
* security policy used by the rmid process exec'ed by a running
* instance of the test.
* security policy used by activation groups
*/
grant {
permission java.io.FilePermission "..${/}..${/}test.props", "read";
// test needs to communicate with the activation system
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
permission java.util.PropertyPermission "test.*", "read";
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2015, 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,7 +27,7 @@
* The RemoteServer.setLog method requires
* java.util.log.LoggingPermission("control").
* @author Ann Wollrath
* @run main/othervm/policy=java.policy SetLogPermission
* @run main/othervm/policy=security.policy SetLogPermission
*/
import java.rmi.server.RemoteServer;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2015, 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
@ -40,20 +40,6 @@ import java.rmi.registry.LocateRegistry;
* objects.
*/
public class ActivationLibrary {
/** time safeDestroy should wait before failing on shutdown rmid */
private static final int SAFE_WAIT_TIME;
static {
int slopFactor = 1;
try {
slopFactor = Integer.valueOf(
TestLibrary.getExtraProperty("jcov.sleep.multiplier","1"));
} catch (NumberFormatException ignore) {}
SAFE_WAIT_TIME = 60000 * slopFactor;
}
private static final String SYSTEM_NAME =
ActivationSystem.class.getName();
private static void mesg(Object mesg) {
System.err.println("ACTIVATION_LIBRARY: " + mesg.toString());
}
@ -63,20 +49,19 @@ public class ActivationLibrary {
*/
public static void deactivate(Remote remote,
ActivationID id) {
// We do as much as 50 deactivation trials, each separated by
// at least 100 milliseconds sleep time (max sleep time of 5 secs).
final long deactivateSleepTime = 100;
long stopTime = System.currentTimeMillis() + deactivateSleepTime * 50;
while (System.currentTimeMillis() < stopTime) {
final long POLLTIME_MS = 100L;
final long DEACTIVATE_TIME_MS = 30_000L;
long startTime = System.currentTimeMillis();
long deadline = TestLibrary.computeDeadline(startTime, DEACTIVATE_TIME_MS);
while (System.currentTimeMillis() < deadline) {
try {
if (Activatable.inactive(id) == true) {
mesg("inactive successful");
return;
} else {
mesg("inactive trial failed. Sleeping " +
deactivateSleepTime +
" milliseconds before next trial");
Thread.sleep(deactivateSleepTime);
Thread.sleep(POLLTIME_MS);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
@ -95,7 +80,8 @@ public class ActivationLibrary {
}
}
mesg("unable to inactivate after several attempts");
mesg("unable to inactivate after " +
(System.currentTimeMillis() - startTime) + "ms.");
mesg("unexporting object forcibly instead");
try {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2015, 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
@ -194,7 +194,7 @@ public class JavaVM {
throws InterruptedException, TimeoutException {
if (vm == null)
throw new IllegalStateException("can't wait for JavaVM that isn't running");
long deadline = computeDeadline(System.currentTimeMillis(), timeout);
long deadline = TestLibrary.computeDeadline(System.currentTimeMillis(), timeout);
while (true) {
try {
@ -218,21 +218,4 @@ public class JavaVM {
start();
return waitFor();
}
/**
* Computes a deadline from a timestamp and a timeout value.
* Maximum timeout (before multipliers are applied) is one hour.
*/
public static long computeDeadline(long timestamp, long timeout) {
final long MAX_TIMEOUT_MS = 3_600_000L;
if (timeout < 0L || timeout > MAX_TIMEOUT_MS) {
throw new IllegalArgumentException("timeout " + timeout + "ms out of range");
}
// TODO apply test.timeout.factor (and possibly jcov.sleep.multiplier)
// here instead of upstream
return timestamp + timeout;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2015, 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
@ -249,15 +249,15 @@ public class RMID extends JavaVM {
mesg("Starting rmid on port " + port + ".");
super.start();
int slopFactor = 1;
try {
slopFactor = Integer.valueOf(
TestLibrary.getExtraProperty("jcov.sleep.multiplier","1"));
} catch (NumberFormatException ignore) {}
waitTime = waitTime * slopFactor;
// int slopFactor = 1;
// try {
// slopFactor = Integer.valueOf(
// TestLibrary.getExtraProperty("jcov.sleep.multiplier","1"));
// } catch (NumberFormatException ignore) {}
// waitTime = waitTime * slopFactor;
long startTime = System.currentTimeMillis();
long deadline = computeDeadline(startTime, waitTime);
long deadline = TestLibrary.computeDeadline(startTime, waitTime);
while (true) {
try {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2015, 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
@ -135,7 +135,8 @@ public class TestLibrary {
*/
public static boolean checkIfRegistryRunning(int port, int msTimeout) {
long stopTime = System.currentTimeMillis() + msTimeout;
final long POLLTIME_MS = 100L;
long stopTime = computeDeadline(System.currentTimeMillis(), msTimeout);
do {
try {
Registry r = LocateRegistry.getRegistry(port);
@ -145,12 +146,12 @@ public class TestLibrary {
} catch (RemoteException e) {
// problem - not ready ? Try again
try {
Thread.sleep(500);
Thread.sleep(POLLTIME_MS);
} catch (InterruptedException ie) {
// not expected
}
}
} while (stopTime > System.currentTimeMillis());
} while (System.currentTimeMillis() < stopTime);
return false;
}
@ -169,6 +170,31 @@ public class TestLibrary {
}
}
public static double getTimeoutFactor() {
String prop = getProperty("test.timeout.factor", "1.0");
double timeoutFactor = 1.0;
try {
timeoutFactor = Double.parseDouble(prop);
} catch (NumberFormatException ignore) { }
return timeoutFactor;
}
/**
* Computes a deadline from a timestamp and a timeout value.
* Maximum timeout (before multipliers are applied) is one hour.
*/
public static long computeDeadline(long timestamp, long timeout) {
final long MAX_TIMEOUT_MS = 3_600_000L;
if (timeout < 0L || timeout > MAX_TIMEOUT_MS) {
throw new IllegalArgumentException("timeout " + timeout + "ms out of range");
}
return timestamp + (long)(timeout * getTimeoutFactor());
}
/**
* Property mutators
*/

View File

@ -1154,6 +1154,10 @@ public class Basic$Type$ extends Basic {
test("%.5f", "0.99960", val);
test("%.6f", "0.999600", val);
val = new BigDecimal(BigInteger.ZERO, 6);
test("%.4f", "0.0000", val);
val = new BigDecimal(BigInteger.ZERO, -6);
test("%.4f", "0.0000", val);
#end[BigDecimal]
#if[float]

View File

@ -26,6 +26,7 @@
* @bug 4906370 4962433 4973103 4989961 5005818 5031150 4970931 4989491 5002937
* 5005104 5007745 5061412 5055180 5066788 5088703 6317248 6318369 6320122
* 6344623 6369500 6534606 6282094 6286592 6476425 5063507 6469160 6476168
* 8059175
*
* @run shell/timeout=240 Basic.sh
*/

View File

@ -1154,6 +1154,11 @@ public class BasicBigDecimal extends Basic {
test("%.5f", "0.99960", val);
test("%.6f", "0.999600", val);
val = new BigDecimal(BigInteger.ZERO, 6);
test("%.4f", "0.0000", val);
val = new BigDecimal(BigInteger.ZERO, -6);
test("%.4f", "0.0000", val);

View File

@ -0,0 +1,121 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.PrintStream;
import java.lang.String;
import java.lang.System;
import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import javax.crypto.KeyGenerator;
import static java.lang.System.out;
/*
* @test
* @bug 8048607
* @compile ../../../com/sun/crypto/provider/Cipher/DES/TestUtility.java
* @summary Test key generation of DES and DESEDE
*/
public class TestKGParity {
private static final String[] ALGORITHM_ARR = {
"deS", "DesEDE"
};
public static void main(String argv[]) throws Exception {
TestKGParity test = new TestKGParity();
test.run();
}
private void run() throws Exception {
Provider[] providers = Security.getProviders();
for (Provider p : providers) {
String prvName = p.getName();
if (prvName.startsWith("SunJCE")
|| prvName.startsWith("SunPKCS11-")) {
for (String algorithm : ALGORITHM_ARR) {
if (!runTest(p, algorithm)) {
throw new RuntimeException(
"Test failed with provider/algorithm:"
+ p.getName() + "/" + algorithm);
} else {
out.println("Test passed with provider/algorithm:"
+ p.getName() + "/" + algorithm);
}
}
}
}
}
public boolean runTest(Provider p, String algo) throws Exception {
byte[] keyValue = null;
try {
// Initialization
SecureRandom sRdm = new SecureRandom();
KeyGenerator kg = KeyGenerator.getInstance(algo, p);
kg.init(sRdm);
// Generate a SecretKey and retrieve its value
keyValue = kg.generateKey().getEncoded();
// Verify its parity in the unit of byte
for (int i = 0; i < keyValue.length; i++) {
if (!checkParity(keyValue[i])) {
out.println("Testing: "
+ p.getName()
+ "/"
+ algo
+ " failed when verify its parity in the unit of byte:"
+ TestUtility.hexDump(keyValue, i));
return false;
}
}
return true;
} catch (Exception ex) {
out.println("Testing: " + p.getName() + "/" + algo
+ " failed with unexpected exception");
ex.printStackTrace();
throw ex;
}
}
private boolean checkParity(byte keyByte) {
boolean even = false;
byte[] PARITY_BIT_MASK = {
(byte) 0x40, (byte) 0x20, (byte) 0x10, (byte) 0x08,
(byte) 0x04, (byte) 0x02, (byte) 0x01
};
for (int i = 0; i < 7; i++) {
if ((keyByte & PARITY_BIT_MASK[i]) > 0) {
even = !even;
}
}
if (keyByte < 0) {
even = !even;
}
return even;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2015, 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,7 +24,8 @@
/*
* @test
* @bug 6239400
* @summary Tests NotificationBuffer doesn't hold locks when adding listeners.
* @summary Tests NotificationBuffer doesn't hold locks when adding listeners,
* if test times out then deadlock is suspected.
* @author Eamonn McManus
* @run clean NotificationBufferDeadlockTest
* @run build NotificationBufferDeadlockTest
@ -38,6 +39,7 @@ import java.net.MalformedURLException;
import java.util.List;
import java.util.Set;
import java.util.Vector;
import java.util.concurrent.CountDownLatch;
import javax.management.*;
import javax.management.remote.*;
@ -173,9 +175,7 @@ public class NotificationBufferDeadlockTest {
for (ObjectName name : names)
mbsc.invoke(name, "send", null, null);
if (!countListener.waiting(MAX_WAITING_TIME)) {
return "did not get " + names.size() + " notifs as expected\n";
}
countListener.waiting();
if (!sources.containsAll(names))
return "missing names: " + sources;
@ -202,13 +202,13 @@ public class NotificationBufferDeadlockTest {
}
};
t.start();
System.out.println("DeadlockTest-addNotificationListener waiting for the sending thread to die...");
try {
t.join(5000L);
t.join(); //if times out here then deadlock is suspected
System.out.println("DeadlockTest-addNotificationListener OK.");
} catch (Exception e) {
thisFailure = "Join exception: " + e;
}
if (t.isAlive())
thisFailure = "Deadlock detected";
}
public void send() {
@ -244,9 +244,9 @@ public class NotificationBufferDeadlockTest {
}
};
t.start();
t.join(5000);
if (t.isAlive())
failure = "Query deadlock detected";
System.out.println("CreateDuringQueryInvocationHandler-createMBeanIfQuery waiting for the creating thread to die...");
t.join(); // if times out here then deadlock is suspected
System.out.println("CreateDuringQueryInvocationHandler-createMBeanIfQuery OK");
}
}
@ -264,50 +264,30 @@ public class NotificationBufferDeadlockTest {
private static class MyListener implements NotificationListener {
public MyListener(int waitNB) {
this.waitNB= waitNB;
count = new CountDownLatch(waitNB);
}
public void handleNotification(Notification n, Object h) {
System.out.println("MyListener got: "+n.getSource()+" "+n.getType());
System.out.println("MyListener got: " + n.getSource() + " " + n.getType());
synchronized(this) {
if (TESTING_TYPE.equals(n.getType())) {
sources.add((ObjectName) n.getSource());
if (sources.size() == waitNB) {
this.notifyAll();
}
}
if (TESTING_TYPE.equals(n.getType())) {
sources.add((ObjectName) n.getSource());
count.countDown();
}
}
public boolean waiting(long timeout) {
final long startTime = System.currentTimeMillis();
long toWait = timeout;
synchronized(this) {
while(sources.size() < waitNB && toWait > 0) {
try {
this.wait(toWait);
} catch (InterruptedException ire) {
break;
}
toWait = timeout -
(System.currentTimeMillis() - startTime);
}
}
return sources.size() == waitNB;
public void waiting() throws InterruptedException {
System.out.println("MyListener-waiting ...");
count.await(); // if times out here then deadlock is suspected
System.out.println("MyListener-waiting done!");
}
private final int waitNB;
private final CountDownLatch count;
}
static String thisFailure;
static String failure;
static int nextNameIndex;
static final long MAX_WAITING_TIME = 10000;
private static MyListener countListener;
private static final List<ObjectName> sources = new Vector();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2015, 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,6 +24,7 @@
/**
* @test
* @bug 4635230 6283345 6303830 6824440 6867348 7094155 8038184 8038349 8046949
* 8046724
* @summary Basic unit tests for generating XML Signatures with JSR 105
* @compile -XDignore.symbol.file KeySelectors.java SignatureValidator.java
* X509KeySelector.java GenerationTests.java
@ -45,6 +46,13 @@ import java.security.cert.X509CRL;
import java.security.spec.KeySpec;
import java.security.spec.DSAPrivateKeySpec;
import java.security.spec.DSAPublicKeySpec;
import java.security.spec.ECField;
import java.security.spec.ECFieldFp;
import java.security.spec.ECParameterSpec;
import java.security.spec.ECPoint;
import java.security.spec.ECPrivateKeySpec;
import java.security.spec.ECPublicKeySpec;
import java.security.spec.EllipticCurve;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec;
import java.util.*;
@ -81,9 +89,10 @@ public class GenerationTests {
private static DocumentBuilder db;
private static CanonicalizationMethod withoutComments;
private static SignatureMethod dsaSha1, dsaSha256, rsaSha1,
rsaSha256, rsaSha384, rsaSha512;
rsaSha256, rsaSha384, rsaSha512,
ecdsaSha1;
private static DigestMethod sha1, sha256, sha384, sha512;
private static KeyInfo dsa1024, dsa2048, rsa, rsa1024;
private static KeyInfo dsa1024, dsa2048, rsa, rsa1024, p256ki;
private static KeySelector kvks = new KeySelectors.KeyValueKeySelector();
private static KeySelector sks;
private static Key signingKey;
@ -121,6 +130,7 @@ public class GenerationTests {
test_create_signature_enveloping_hmac_sha384();
test_create_signature_enveloping_hmac_sha512();
test_create_signature_enveloping_rsa();
test_create_signature_enveloping_p256_sha1();
test_create_signature_external_b64_dsa();
test_create_signature_external_dsa();
test_create_signature_keyname();
@ -175,6 +185,8 @@ public class GenerationTests {
(kifac.newKeyValue(getPublicKey("RSA", 512))));
rsa1024 = kifac.newKeyInfo(Collections.singletonList
(kifac.newKeyValue(getPublicKey("RSA", 1024))));
p256ki = kifac.newKeyInfo(Collections.singletonList
(kifac.newKeyValue(getECPublicKey())));
rsaSha1 = fac.newSignatureMethod(SignatureMethod.RSA_SHA1, null);
rsaSha256 = fac.newSignatureMethod
("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", null);
@ -182,6 +194,8 @@ public class GenerationTests {
("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384", null);
rsaSha512 = fac.newSignatureMethod
("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512", null);
ecdsaSha1 = fac.newSignatureMethod
("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1", null);
sks = new KeySelectors.SecretKeySelector("secret".getBytes("ASCII"));
httpUd = new HttpURIDereferencer();
@ -342,6 +356,13 @@ public class GenerationTests {
System.out.println();
}
static void test_create_signature_enveloping_p256_sha1() throws Exception {
System.out.println("* Generating signature-enveloping-p256-sha1.xml");
test_create_signature_enveloping(sha1, ecdsaSha1, p256ki,
getECPrivateKey(), kvks, false);
System.out.println();
}
static void test_create_signature_external_b64_dsa() throws Exception {
System.out.println("* Generating signature-external-b64-dsa.xml");
test_create_signature_external(dsaSha1, dsa1024, signingKey, kvks, true);
@ -1168,7 +1189,42 @@ public class GenerationTests {
"237008997971129772408397621801631622129297063463868593083106979716" +
"204903524890556839550490384015324575598723478554854070823335021842" +
"210112348400928769";
private static final String EC_X =
"335863644451761614592446380116804721648611739647823420286081723541" +
"6166183710";
private static final String EC_Y =
"951559601159729477487064127150143688502130342917782252098602422796" +
"95457910701";
private static final String EC_S =
"425976209773168452211813225517384419928639977904006759709292218082" +
"7440083936";
private static final ECParameterSpec EC_PARAMS;
static {
final String ec_sfield, ec_a, ec_b, ec_gx, ec_gy, ec_n;
ec_sfield =
"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF";
ec_a =
"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC";
ec_b =
"5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B";
ec_gx =
"6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296";
ec_gy =
"4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5";
ec_n =
"FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551";
final int ec_h = 1;
final ECField ec_field = new ECFieldFp(bigInt(ec_sfield));
final EllipticCurve ec_curve = new EllipticCurve(ec_field,
bigInt(ec_a), bigInt(ec_b));
final ECPoint ec_g = new ECPoint(bigInt(ec_gx), bigInt(ec_gy));
EC_PARAMS = new ECParameterSpec(ec_curve, ec_g, bigInt(ec_n), ec_h);
}
private static BigInteger bigInt(String s) {
return new BigInteger(s, 16);
}
private static PublicKey getPublicKey(String algo, int keysize)
throws Exception {
KeyFactory kf = KeyFactory.getInstance(algo);
@ -1197,6 +1253,14 @@ public class GenerationTests {
return kf.generatePublic(kspec);
}
private static PublicKey getECPublicKey() throws Exception {
KeyFactory kf = KeyFactory.getInstance("EC");
KeySpec kspec = new ECPublicKeySpec(new ECPoint(new BigInteger(EC_X),
new BigInteger(EC_Y)),
EC_PARAMS);
return kf.generatePublic(kspec);
}
private static PrivateKey getPrivateKey(String algo, int keysize)
throws Exception {
KeyFactory kf = KeyFactory.getInstance(algo);
@ -1223,6 +1287,12 @@ public class GenerationTests {
return kf.generatePrivate(kspec);
}
private static PrivateKey getECPrivateKey() throws Exception {
KeyFactory kf = KeyFactory.getInstance("EC");
KeySpec kspec = new ECPrivateKeySpec(new BigInteger(EC_S), EC_PARAMS);
return kf.generatePrivate(kspec);
}
private static SecretKey getSecretKey(final byte[] secret) {
return new SecretKey() {
public String getFormat() { return "RAW"; }

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2015, 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
@ -166,7 +166,6 @@ class KeySelectors {
throw new KeySelectorException("No KeyValue element found!");
}
//@@@FIXME: this should also work for key types other than DSA/RSA
static boolean algEquals(String algURI, String algName) {
if (algName.equalsIgnoreCase("DSA") &&
algURI.equals(SignatureMethod.DSA_SHA1) ||
@ -181,6 +180,10 @@ class KeySelectors {
algURI.equals
("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"))) {
return true;
} else if (algName.equalsIgnoreCase("EC") &&
(algURI.equals
("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1"))) {
return true;
} else {
return false;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,7 @@
/**
* @test
* @bug 4635230 6365103 6366054 6824440 7131084
* @bug 4635230 6365103 6366054 6824440 7131084 8046724
* @summary Basic unit tests for validating XML Signatures with JSR 105
* @compile -XDignore.symbol.file KeySelectors.java SignatureValidator.java
* X509KeySelector.java ValidationTests.java
@ -90,6 +90,7 @@ public class ValidationTests {
new Test("signature-enveloping-b64-dsa.xml", KVKS),
new Test("signature-enveloping-dsa.xml", KVKS),
new Test("signature-enveloping-rsa.xml", KVKS),
new Test("signature-enveloping-p256-sha1.xml", KVKS),
new Test("signature-enveloping-hmac-sha1.xml", SKKS),
new Test("signature-external-dsa.xml", KVKS),
new Test("signature-external-b64-dsa.xml", KVKS),

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1"/><Reference URI="#object"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>7/XTsHaBSOnJ/jXD5v0zL6VKYsk=</DigestValue></Reference></SignedInfo><SignatureValue>WiF/Hd0s7BiH36Ds/1iJcbKiXOUVBSGFteuTjXwBbezR43NAwpMmMX5c1su0A9hG9rVVzE/1DOlO
vuDVLBBblg==</SignatureValue><KeyInfo><KeyValue><ECKeyValue xmlns="http://www.w3.org/2009/xmldsig11#"><NamedCurve URI="urn:oid:1.2.840.10045.3.1.7"/><PublicKey>BAds672US3sCYunM2k2bEQLbuRxdQlNTvq+5fitOpDMe0mBdZV4J3yZaG0taziYIuAT9GJGfds+q
xtXOCNWe/60=</PublicKey></ECKeyValue></KeyValue></KeyInfo><Object Id="object">some text</Object></Signature>