提交 d2887df9 编写于 作者: L lana

Merge

...@@ -59,3 +59,4 @@ e6a5d095c356a547cf5b3c8885885aca5e91e09b jdk7-b77 ...@@ -59,3 +59,4 @@ e6a5d095c356a547cf5b3c8885885aca5e91e09b jdk7-b77
69ef657320ad5c35cfa12e4d8322d877e778f8b3 jdk7-b82 69ef657320ad5c35cfa12e4d8322d877e778f8b3 jdk7-b82
9027c6b9d7e2c9ca04a1add691b5b50d0f22b1aa jdk7-b83 9027c6b9d7e2c9ca04a1add691b5b50d0f22b1aa jdk7-b83
7cb9388bb1a16365fa5118c5efa38b1cd58be40d jdk7-b84 7cb9388bb1a16365fa5118c5efa38b1cd58be40d jdk7-b84
b396584a3e64988839cca21ea1f7fbdcc9248783 jdk7-b85
...@@ -687,13 +687,13 @@ endif ...@@ -687,13 +687,13 @@ endif
###################################################### ######################################################
sane-alt_outputdir: sane-alt_outputdir:
ifdef ALT_OUTPUTDIR ifdef ALT_OUTPUTDIR
@if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -ci '^([a-z]:)?/'` -ne 1 ]; then \ @if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
$(ECHO) "ERROR: ALT_OUTPUTDIR must be an Absolute Path Name, \n" \ $(ECHO) "ERROR: ALT_OUTPUTDIR must be an Absolute Path Name, \n" \
" not a Relative Path Name. \n" \ " not a Relative Path Name. \n" \
"" >> $(ERROR_FILE) ; \ "" >> $(ERROR_FILE) ; \
fi fi
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
@if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -ci '^([a-z]:)'` -ne 1 ]; then \ @if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -c '^([A-Za-z]:)'` -ne 1 ]; then \
$(ECHO) "ERROR: On windows, ALT_OUTPUTDIR must contain the drive letter. \n" \ $(ECHO) "ERROR: On windows, ALT_OUTPUTDIR must contain the drive letter. \n" \
"" >> $(ERROR_FILE) ; \ "" >> $(ERROR_FILE) ; \
fi fi
...@@ -742,7 +742,7 @@ sane-outputdir: ...@@ -742,7 +742,7 @@ sane-outputdir:
###################################################### ######################################################
sane-alt_bootdir: sane-alt_bootdir:
ifdef ALT_BOOTDIR ifdef ALT_BOOTDIR
@if [ `$(ECHO) $(subst \,/,$(ALT_BOOTDIR)) | $(EGREP) -ci '^([a-z]:)?/'` -ne 1 ]; then \ @if [ `$(ECHO) $(subst \,/,$(ALT_BOOTDIR)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
$(ECHO) "ERROR: ALT_BOOTDIR must be an Absolute Path Name, \n" \ $(ECHO) "ERROR: ALT_BOOTDIR must be an Absolute Path Name, \n" \
" not a Relative Path Name. \n" \ " not a Relative Path Name. \n" \
" The current value of ALT_BOOTDIR is \n" \ " The current value of ALT_BOOTDIR is \n" \
...@@ -772,7 +772,7 @@ sane-bootdir: ...@@ -772,7 +772,7 @@ sane-bootdir:
###################################################### ######################################################
sane-local-bootdir: sane-local-bootdir:
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
@if [ `$(ECHO) $(BOOTDIR) | $(EGREP) -ci '^J:'` -ne 0 ]; then \ @if [ `$(ECHO) $(BOOTDIR) | $(EGREP) -c '^[jJ]:'` -ne 0 ]; then \
$(ECHO) "WARNING: Your BOOTDIR is located on the J: drive. Often the J:\n" \ $(ECHO) "WARNING: Your BOOTDIR is located on the J: drive. Often the J:\n" \
" drive is mapped over a network. Using a mapped drive for\n" \ " drive is mapped over a network. Using a mapped drive for\n" \
" the BOOTDIR may significantly slow down the build process.\n" \ " the BOOTDIR may significantly slow down the build process.\n" \
...@@ -789,7 +789,7 @@ endif ...@@ -789,7 +789,7 @@ endif
###################################################### ######################################################
sane-cacerts: sane-cacerts:
ifdef ALT_CACERTS_FILE ifdef ALT_CACERTS_FILE
@if [ `$(ECHO) $(subst \,/,$(ALT_CACERTS_FILE)) | $(EGREP) -ci '^([a-z]:)?/'` -ne 1 ]; then \ @if [ `$(ECHO) $(subst \,/,$(ALT_CACERTS_FILE)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
$(ECHO) "ERROR: ALT_CACERTS_FILE must be an Absolute Path Name, \n" \ $(ECHO) "ERROR: ALT_CACERTS_FILE must be an Absolute Path Name, \n" \
" not a Relative Path Name. \n" \ " not a Relative Path Name. \n" \
" The current value of ALT_CACERTS_FILE is \n" \ " The current value of ALT_CACERTS_FILE is \n" \
...@@ -1538,7 +1538,7 @@ endif ...@@ -1538,7 +1538,7 @@ endif
sane-mozilla: sane-mozilla:
ifeq ($(ARCH_DATA_MODEL), 32) ifeq ($(ARCH_DATA_MODEL), 32)
ifdef ALT_MOZILLA_HEADERS_PATH ifdef ALT_MOZILLA_HEADERS_PATH
@if [ `$(ECHO) $(subst \,/,$(ALT_MOZILLA_HEADERS_PATH)) | $(EGREP) -ci '^([a-z]:)?/'` -ne 1 ]; then \ @if [ `$(ECHO) $(subst \,/,$(ALT_MOZILLA_HEADERS_PATH)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
$(ECHO) "ERROR: ALT_MOZILLA_HEADERS_PATH must be an Absolute Path Name, \n" \ $(ECHO) "ERROR: ALT_MOZILLA_HEADERS_PATH must be an Absolute Path Name, \n" \
" not a Relative Path Name. \n" \ " not a Relative Path Name. \n" \
" The current value of ALT_MOZILLA_HEADERS_PATH is \n" \ " The current value of ALT_MOZILLA_HEADERS_PATH is \n" \
......
...@@ -135,9 +135,8 @@ $(BUILDTOOLCLASSDIR)/%.class : $(BUILDTOOL_SOURCE_ROOT)/%.java ...@@ -135,9 +135,8 @@ $(BUILDTOOLCLASSDIR)/%.class : $(BUILDTOOL_SOURCE_ROOT)/%.java
$(CLASSANALYZER_JAR_FILE): $(BUILDTOOL_MANIFEST_FILE) $(FILES_class) $(CLASSANALYZER_JAR_FILE): $(BUILDTOOL_MANIFEST_FILE) $(FILES_class)
@$(prep-target) @$(prep-target)
$(CD) $(BUILDTOOLCLASSDIR) && \ $(BOOT_JAR_CMD) cfm $@ $(BUILDTOOL_MANIFEST_FILE) \
$(BOOT_JAR_CMD) cfm $@ $(BUILDTOOL_MANIFEST_FILE) \ -C $(BUILDTOOLCLASSDIR) $(PKGDIR) $(BOOT_JAR_JFLAGS) || $(RM) $@
$(PKGDIR) $(BOOT_JAR_JFLAGS) || $(RM) $@
@$(java-vm-cleanup) @$(java-vm-cleanup)
$(BUILDTOOLJARDIR)/classfile.jar: $(FILES_classfile_class) $(BUILDTOOLJARDIR)/classfile.jar: $(FILES_classfile_class)
......
/* /*
* Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -33,6 +33,7 @@ import java.io.IOException; ...@@ -33,6 +33,7 @@ import java.io.IOException;
/** /**
* LDAP (RFC-1960) and LDAPv3 (RFC-2254) search filters. * LDAP (RFC-1960) and LDAPv3 (RFC-2254) search filters.
* *
* @author Xuelei Fan
* @author Vincent Ryan * @author Vincent Ryan
* @author Jagane Sundar * @author Jagane Sundar
* @author Rosanna Lee * @author Rosanna Lee
...@@ -258,7 +259,7 @@ final class Filter { ...@@ -258,7 +259,7 @@ final class Filter {
byte[] answer = new byte[j]; byte[] answer = new byte[j];
System.arraycopy(tbuf, 0, answer, 0, j); System.arraycopy(tbuf, 0, answer, 0, j);
if (dbg) { if (dbg) {
Ber.dumpBER(System.err, null, answer, 0, j); Ber.dumpBER(System.err, "", answer, 0, j);
} }
return answer; return answer;
} }
...@@ -330,7 +331,7 @@ final class Filter { ...@@ -330,7 +331,7 @@ final class Filter {
} }
valueStart = eq + 1; // value starts after equal sign valueStart = eq + 1; // value starts after equal sign
valueEnd = filtEnd; valueEnd = filtEnd;
typeStart = filtStart; // beginning of string typeStart = filtStart; // beginning of string
...@@ -355,20 +356,199 @@ final class Filter { ...@@ -355,20 +356,199 @@ final class Filter {
break; break;
default: default:
typeEnd = eq; typeEnd = eq;
//initializing ftype to make the compiler happy
ftype = 0x00;
break;
}
if (dbg) {
System.err.println("type: " + typeStart + ", " + typeEnd);
System.err.println("value: " + valueStart + ", " + valueEnd);
}
// check validity of type
//
// RFC4512 defines the type as the following ABNF:
// attr = attributedescription
// attributedescription = attributetype options
// attributetype = oid
// oid = descr / numericoid
// descr = keystring
// keystring = leadkeychar *keychar
// leadkeychar = ALPHA
// keychar = ALPHA / DIGIT / HYPHEN
// numericoid = number 1*( DOT number )
// number = DIGIT / ( LDIGIT 1*DIGIT )
// options = *( SEMI option )
// option = 1*keychar
//
// And RFC4515 defines the extensible type as the following ABNF:
// attr [dnattrs] [matchingrule] / [dnattrs] matchingrule
int optionsStart = -1;
int extensibleStart = -1;
if ((filter[typeStart] >= '0' && filter[typeStart] <= '9') ||
(filter[typeStart] >= 'A' && filter[typeStart] <= 'Z') ||
(filter[typeStart] >= 'a' && filter[typeStart] <= 'z')) {
boolean isNumericOid =
filter[typeStart] >= '0' && filter[typeStart] <= '9';
for (int i = typeStart + 1; i < typeEnd; i++) {
// ';' is an indicator of attribute options
if (filter[i] == ';') {
if (isNumericOid && filter[i - 1] == '.') {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
// attribute options
optionsStart = i;
break;
}
// ':' is an indicator of extensible rules
if (filter[i] == ':' && ftype == LDAP_FILTER_EXT) {
if (isNumericOid && filter[i - 1] == '.') {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
// extensible matching
extensibleStart = i;
break;
}
if (isNumericOid) {
// numeric object identifier
if ((filter[i] == '.' && filter[i - 1] == '.') ||
(filter[i] != '.' &&
!(filter[i] >= '0' && filter[i] <= '9'))) {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
} else {
// descriptor
if (filter[i] != '-' &&
!(filter[i] >= '0' && filter[i] <= '9') &&
!(filter[i] >= 'A' && filter[i] <= 'Z') &&
!(filter[i] >= 'a' && filter[i] <= 'z')) {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
}
}
} else if (ftype == LDAP_FILTER_EXT && filter[typeStart] == ':') {
// extensible matching
extensibleStart = typeStart;
} else {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
// check attribute options
if (optionsStart > 0) {
for (int i = optionsStart + 1; i < typeEnd; i++) {
if (filter[i] == ';') {
if (filter[i - 1] == ';') {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
continue;
}
// ':' is an indicator of extensible rules
if (filter[i] == ':' && ftype == LDAP_FILTER_EXT) {
if (filter[i - 1] == ';') {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
// extensible matching
extensibleStart = i;
break;
}
if (filter[i] != '-' &&
!(filter[i] >= '0' && filter[i] <= '9') &&
!(filter[i] >= 'A' && filter[i] <= 'Z') &&
!(filter[i] >= 'a' && filter[i] <= 'z')) {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
}
}
// check extensible matching
if (extensibleStart > 0) {
boolean isMatchingRule = false;
for (int i = extensibleStart + 1; i < typeEnd; i++) {
if (filter[i] == ':') {
throw new InvalidSearchFilterException(
"invalid attribute description");
} else if ((filter[i] >= '0' && filter[i] <= '9') ||
(filter[i] >= 'A' && filter[i] <= 'Z') ||
(filter[i] >= 'a' && filter[i] <= 'z')) {
boolean isNumericOid = filter[i] >= '0' && filter[i] <= '9';
i++;
for (int j = i; j < typeEnd; j++, i++) {
// allows no more than two extensible rules
if (filter[j] == ':') {
if (isMatchingRule) {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
if (isNumericOid && filter[j - 1] == '.') {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
isMatchingRule = true;
break;
}
if (isNumericOid) {
// numeric object identifier
if ((filter[j] == '.' && filter[j - 1] == '.') ||
(filter[j] != '.' &&
!(filter[j] >= '0' && filter[j] <= '9'))) {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
} else {
// descriptor
if (filter[j] != '-' &&
!(filter[j] >= '0' && filter[j] <= '9') &&
!(filter[j] >= 'A' && filter[j] <= 'Z') &&
!(filter[j] >= 'a' && filter[j] <= 'z')) {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
}
}
} else {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
}
}
// ensure the latest byte is not isolated
if (filter[typeEnd - 1] == '.' || filter[typeEnd - 1] == ';' ||
filter[typeEnd - 1] == ':') {
throw new InvalidSearchFilterException(
"invalid attribute description");
}
if (typeEnd == eq) { // filter type is of "equal"
if (findUnescaped(filter, '*', valueStart, valueEnd) == -1) { if (findUnescaped(filter, '*', valueStart, valueEnd) == -1) {
ftype = LDAP_FILTER_EQUALITY; ftype = LDAP_FILTER_EQUALITY;
} else if (filter[valueStart] == '*' && valueStart == (valueEnd - 1)) { } else if (filter[valueStart] == '*' &&
valueStart == (valueEnd - 1)) {
ftype = LDAP_FILTER_PRESENT; ftype = LDAP_FILTER_PRESENT;
} else { } else {
encodeSubstringFilter(ber, filter, encodeSubstringFilter(ber, filter,
typeStart, typeEnd, valueStart, valueEnd); typeStart, typeEnd, valueStart, valueEnd);
return; return;
} }
break;
}
if (dbg) {
System.err.println("type: " + typeStart + ", " + typeEnd);
System.err.println("value: " + valueStart + ", " + valueEnd);
} }
if (ftype == LDAP_FILTER_PRESENT) { if (ftype == LDAP_FILTER_PRESENT) {
...@@ -379,7 +559,7 @@ final class Filter { ...@@ -379,7 +559,7 @@ final class Filter {
} else { } else {
ber.beginSeq(ftype); ber.beginSeq(ftype);
ber.encodeOctetString(filter, Ber.ASN_OCTET_STR, ber.encodeOctetString(filter, Ber.ASN_OCTET_STR,
typeStart, typeEnd-typeStart); typeStart, typeEnd - typeStart);
ber.encodeOctetString( ber.encodeOctetString(
unescapeFilterValue(filter, valueStart, valueEnd), unescapeFilterValue(filter, valueStart, valueEnd),
Ber.ASN_OCTET_STR); Ber.ASN_OCTET_STR);
...@@ -623,7 +803,8 @@ final class Filter { ...@@ -623,7 +803,8 @@ final class Filter {
// //
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
private static final boolean dbg = false; // private static final boolean dbg = false;
private static final boolean dbg = true;
private static int dbgIndent = 0; private static int dbgIndent = 0;
private static void dprint(String msg) { private static void dprint(String msg) {
......
...@@ -614,14 +614,15 @@ public final class AlphaComposite implements Composite { ...@@ -614,14 +614,15 @@ public final class AlphaComposite implements Composite {
} }
private AlphaComposite(int rule, float alpha) { private AlphaComposite(int rule, float alpha) {
if (alpha < 0.0f || alpha > 1.0f) {
throw new IllegalArgumentException("alpha value out of range");
}
if (rule < MIN_RULE || rule > MAX_RULE) { if (rule < MIN_RULE || rule > MAX_RULE) {
throw new IllegalArgumentException("unknown composite rule"); throw new IllegalArgumentException("unknown composite rule");
} }
this.rule = rule; if (alpha >= 0.0f && alpha <= 1.0f) {
this.extraAlpha = alpha; this.rule = rule;
this.extraAlpha = alpha;
} else {
throw new IllegalArgumentException("alpha value out of range");
}
} }
/** /**
......
...@@ -27,8 +27,12 @@ package java.lang; ...@@ -27,8 +27,12 @@ package java.lang;
import java.util.Iterator; import java.util.Iterator;
/** Implementing this interface allows an object to be the target of /**
* the "foreach" statement. * Implementing this interface allows an object to be the target of
* the "foreach" statement.
*
* @param <T> the type of elements returned by the iterator
*
* @since 1.5 * @since 1.5
*/ */
public interface Iterable<T> { public interface Iterable<T> {
......
...@@ -1492,7 +1492,7 @@ public final class String ...@@ -1492,7 +1492,7 @@ public final class String
*/ */
public int hashCode() { public int hashCode() {
int h = hash; int h = hash;
if (h == 0) { if (h == 0 && count > 0) {
int off = offset; int off = offset;
char val[] = value; char val[] = value;
int len = count; int len = count;
......
...@@ -129,7 +129,8 @@ class IdentityScope extends Identity { ...@@ -129,7 +129,8 @@ class IdentityScope extends Identity {
/** /**
* Returns the system's identity scope. * Returns the system's identity scope.
* *
* @return the system's identity scope. * @return the system's identity scope, or {@code null} if none has been
* set.
* *
* @see #setSystemScope * @see #setSystemScope
*/ */
......
...@@ -103,6 +103,8 @@ package java.util; ...@@ -103,6 +103,8 @@ package java.util;
* <a href="{@docRoot}/../technotes/guides/collections/index.html"> * <a href="{@docRoot}/../technotes/guides/collections/index.html">
* Java Collections Framework</a>. * Java Collections Framework</a>.
* *
* @param <E> the type of elements in this collection
*
* @author Josh Bloch * @author Josh Bloch
* @author Neal Gafter * @author Neal Gafter
* @see Set * @see Set
......
...@@ -253,7 +253,7 @@ final class DualPivotQuicksort { ...@@ -253,7 +253,7 @@ final class DualPivotQuicksort {
a[less] = ak; a[less] = ak;
} }
less++; less++;
} else { // (a[k] > pivot1) - Move a[k] to right part } else { // (a[k] > pivot1) - Move a[k] to right part
/* /*
* We know that pivot1 == a[e3] == pivot2. Thus, we know * We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop * that great will still be >= k when the following loop
...@@ -531,7 +531,7 @@ final class DualPivotQuicksort { ...@@ -531,7 +531,7 @@ final class DualPivotQuicksort {
a[less] = ak; a[less] = ak;
} }
less++; less++;
} else { // (a[k] > pivot1) - Move a[k] to right part } else { // (a[k] > pivot1) - Move a[k] to right part
/* /*
* We know that pivot1 == a[e3] == pivot2. Thus, we know * We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop * that great will still be >= k when the following loop
...@@ -826,7 +826,7 @@ final class DualPivotQuicksort { ...@@ -826,7 +826,7 @@ final class DualPivotQuicksort {
a[less] = ak; a[less] = ak;
} }
less++; less++;
} else { // (a[k] > pivot1) - Move a[k] to right part } else { // (a[k] > pivot1) - Move a[k] to right part
/* /*
* We know that pivot1 == a[e3] == pivot2. Thus, we know * We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop * that great will still be >= k when the following loop
...@@ -1119,7 +1119,7 @@ final class DualPivotQuicksort { ...@@ -1119,7 +1119,7 @@ final class DualPivotQuicksort {
a[less] = ak; a[less] = ak;
} }
less++; less++;
} else { // (a[k] > pivot1) - Move a[k] to right part } else { // (a[k] > pivot1) - Move a[k] to right part
/* /*
* We know that pivot1 == a[e3] == pivot2. Thus, we know * We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop * that great will still be >= k when the following loop
...@@ -1414,7 +1414,7 @@ final class DualPivotQuicksort { ...@@ -1414,7 +1414,7 @@ final class DualPivotQuicksort {
a[less] = ak; a[less] = ak;
} }
less++; less++;
} else { // (a[k] > pivot1) - Move a[k] to right part } else { // (a[k] > pivot1) - Move a[k] to right part
/* /*
* We know that pivot1 == a[e3] == pivot2. Thus, we know * We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop * that great will still be >= k when the following loop
...@@ -1531,7 +1531,7 @@ final class DualPivotQuicksort { ...@@ -1531,7 +1531,7 @@ final class DualPivotQuicksort {
* Sorts the specified range of the array into ascending order. The range * Sorts the specified range of the array into ascending order. The range
* to be sorted extends from the index {@code fromIndex}, inclusive, to * to be sorted extends from the index {@code fromIndex}, inclusive, to
* the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex}, * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* the range to be sorted is empty and the call is a no-op). * the range to be sorted is empty and the call is a no-op).
* *
* <p>The {@code <} relation does not provide a total order on all float * <p>The {@code <} relation does not provide a total order on all float
* values: {@code -0.0f == 0.0f} is {@code true} and a {@code Float.NaN} * values: {@code -0.0f == 0.0f} is {@code true} and a {@code Float.NaN}
...@@ -1787,7 +1787,7 @@ final class DualPivotQuicksort { ...@@ -1787,7 +1787,7 @@ final class DualPivotQuicksort {
a[less] = ak; a[less] = ak;
} }
less++; less++;
} else { // (a[k] > pivot1) - Move a[k] to right part } else { // (a[k] > pivot1) - Move a[k] to right part
/* /*
* We know that pivot1 == a[e3] == pivot2. Thus, we know * We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop * that great will still be >= k when the following loop
...@@ -2160,7 +2160,7 @@ final class DualPivotQuicksort { ...@@ -2160,7 +2160,7 @@ final class DualPivotQuicksort {
a[less] = ak; a[less] = ak;
} }
less++; less++;
} else { // (a[k] > pivot1) - Move a[k] to right part } else { // (a[k] > pivot1) - Move a[k] to right part
/* /*
* We know that pivot1 == a[e3] == pivot2. Thus, we know * We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop * that great will still be >= k when the following loop
......
...@@ -41,6 +41,8 @@ package java.util; ...@@ -41,6 +41,8 @@ package java.util;
* <a href="{@docRoot}/../technotes/guides/collections/index.html"> * <a href="{@docRoot}/../technotes/guides/collections/index.html">
* Java Collections Framework</a>. * Java Collections Framework</a>.
* *
* @param <E> the type of elements returned by this iterator
*
* @author Josh Bloch * @author Josh Bloch
* @see Collection * @see Collection
* @see ListIterator * @see ListIterator
......
...@@ -89,6 +89,8 @@ package java.util; ...@@ -89,6 +89,8 @@ package java.util;
* <a href="{@docRoot}/../technotes/guides/collections/index.html"> * <a href="{@docRoot}/../technotes/guides/collections/index.html">
* Java Collections Framework</a>. * Java Collections Framework</a>.
* *
* @param <E> the type of elements in this list
*
* @author Josh Bloch * @author Josh Bloch
* @author Neal Gafter * @author Neal Gafter
* @see Collection * @see Collection
......
...@@ -3058,7 +3058,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE { ...@@ -3058,7 +3058,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
return; return;
} }
/* Use lock specific to the font system */ /* Use lock specific to the font system */
synchronized (lucidaFontName) { synchronized (this) {
if (FontUtilities.debugFonts()) { if (FontUtilities.debugFonts()) {
Thread.dumpStack(); Thread.dumpStack();
FontUtilities.getLogger() FontUtilities.getLogger()
...@@ -3194,7 +3194,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE { ...@@ -3194,7 +3194,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
return; return;
} }
/* Use lock specific to the font system */ /* Use lock specific to the font system */
synchronized (lucidaFontName) { synchronized (this) {
if (FontUtilities.debugFonts()) { if (FontUtilities.debugFonts()) {
Thread.dumpStack(); Thread.dumpStack();
FontUtilities.getLogger().info("loadAllFontFiles() called"); FontUtilities.getLogger().info("loadAllFontFiles() called");
......
...@@ -59,10 +59,15 @@ abstract class AbstractWatchKey extends WatchKey { ...@@ -59,10 +59,15 @@ abstract class AbstractWatchKey extends WatchKey {
// pending events // pending events
private List<WatchEvent<?>> events; private List<WatchEvent<?>> events;
// maps a context to the last event for the context (iff the last queued
// event for the context is an ENTRY_MODIFY event).
private Map<Object,WatchEvent<?>> lastModifyEvents;
protected AbstractWatchKey(AbstractWatchService watcher) { protected AbstractWatchKey(AbstractWatchService watcher) {
this.watcher = watcher; this.watcher = watcher;
this.state = State.READY; this.state = State.READY;
this.events = new ArrayList<WatchEvent<?>>(); this.events = new ArrayList<WatchEvent<?>>();
this.lastModifyEvents = new HashMap<Object,WatchEvent<?>>();
} }
final AbstractWatchService watcher() { final AbstractWatchService watcher() {
...@@ -86,6 +91,7 @@ abstract class AbstractWatchKey extends WatchKey { ...@@ -86,6 +91,7 @@ abstract class AbstractWatchKey extends WatchKey {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final void signalEvent(WatchEvent.Kind<?> kind, Object context) { final void signalEvent(WatchEvent.Kind<?> kind, Object context) {
boolean isModify = (kind == StandardWatchEventKind.ENTRY_MODIFY);
synchronized (this) { synchronized (this) {
int size = events.size(); int size = events.size();
if (size > 0) { if (size > 0) {
...@@ -100,17 +106,43 @@ abstract class AbstractWatchKey extends WatchKey { ...@@ -100,17 +106,43 @@ abstract class AbstractWatchKey extends WatchKey {
return; return;
} }
// if this is a modify event and the last entry for the context
// is a modify event then we simply increment the count
if (!lastModifyEvents.isEmpty()) {
if (isModify) {
WatchEvent<?> ev = lastModifyEvents.get(context);
if (ev != null) {
assert ev.kind() == StandardWatchEventKind.ENTRY_MODIFY;
((Event<?>)ev).increment();
return;
}
} else {
// not a modify event so remove from the map as the
// last event will no longer be a modify event.
lastModifyEvents.remove(context);
}
}
// if the list has reached the limit then drop pending events // if the list has reached the limit then drop pending events
// and queue an OVERFLOW event // and queue an OVERFLOW event
if (size >= MAX_EVENT_LIST_SIZE) { if (size >= MAX_EVENT_LIST_SIZE) {
events.clear();
kind = StandardWatchEventKind.OVERFLOW; kind = StandardWatchEventKind.OVERFLOW;
isModify = false;
context = null; context = null;
} }
} }
// non-repeated event // non-repeated event
events.add(new Event<Object>((WatchEvent.Kind<Object>)kind, context)); Event<Object> ev =
new Event<Object>((WatchEvent.Kind<Object>)kind, context);
if (isModify) {
lastModifyEvents.put(context, ev);
} else if (kind == StandardWatchEventKind.OVERFLOW) {
// drop all pending events
events.clear();
lastModifyEvents.clear();
}
events.add(ev);
signal(); signal();
} }
} }
...@@ -120,6 +152,7 @@ abstract class AbstractWatchKey extends WatchKey { ...@@ -120,6 +152,7 @@ abstract class AbstractWatchKey extends WatchKey {
synchronized (this) { synchronized (this) {
List<WatchEvent<?>> result = events; List<WatchEvent<?>> result = events;
events = new ArrayList<WatchEvent<?>>(); events = new ArrayList<WatchEvent<?>>();
lastModifyEvents.clear();
return result; return result;
} }
} }
......
/* /*
* Portions Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. * Portions Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -36,9 +36,9 @@ import sun.security.krb5.Config; ...@@ -36,9 +36,9 @@ import sun.security.krb5.Config;
import sun.security.krb5.EncryptedData; import sun.security.krb5.EncryptedData;
import sun.security.krb5.EncryptionKey; import sun.security.krb5.EncryptionKey;
import sun.security.krb5.KrbException; import sun.security.krb5.KrbException;
import sun.security.krb5.Asn1Exception;
import sun.security.krb5.KrbCryptoException; import sun.security.krb5.KrbCryptoException;
import javax.crypto.*; import javax.crypto.*;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -48,6 +48,23 @@ import java.util.ArrayList; ...@@ -48,6 +48,23 @@ import java.util.ArrayList;
public abstract class EType { public abstract class EType {
private static final boolean DEBUG = Krb5.DEBUG; private static final boolean DEBUG = Krb5.DEBUG;
private static final boolean ALLOW_WEAK_CRYPTO;
static {
boolean allowed = true;
try {
Config cfg = Config.getInstance();
String temp = cfg.getDefault("allow_weak_crypto", "libdefaults");
if (temp != null && temp.equals("false")) allowed = false;
} catch (Exception exc) {
if (DEBUG) {
System.out.println ("Exception in getting allow_weak_crypto, " +
"using default value " +
exc.getMessage());
}
}
ALLOW_WEAK_CRYPTO = allowed;
}
public static EType getInstance (int eTypeConst) public static EType getInstance (int eTypeConst)
throws KdcErrException { throws KdcErrException {
...@@ -163,6 +180,10 @@ public abstract class EType { ...@@ -163,6 +180,10 @@ public abstract class EType {
return result; return result;
} }
// Note: the first 2 entries of BUILTIN_ETYPES and BUILTIN_ETYPES_NOAES256
// should be kept DES-related. They will be removed when allow_weak_crypto
// is set to false.
private static final int[] BUILTIN_ETYPES = new int[] { private static final int[] BUILTIN_ETYPES = new int[] {
EncryptedData.ETYPE_DES_CBC_MD5, EncryptedData.ETYPE_DES_CBC_MD5,
EncryptedData.ETYPE_DES_CBC_CRC, EncryptedData.ETYPE_DES_CBC_CRC,
...@@ -189,10 +210,17 @@ public abstract class EType { ...@@ -189,10 +210,17 @@ public abstract class EType {
} catch (Exception e) { } catch (Exception e) {
// should not happen // should not happen
} }
int[] result;
if (allowed < 256) { if (allowed < 256) {
return BUILTIN_ETYPES_NOAES256; result = BUILTIN_ETYPES_NOAES256;
} else {
result = BUILTIN_ETYPES;
} }
return BUILTIN_ETYPES; if (!ALLOW_WEAK_CRYPTO) {
// The first 2 etypes are now weak ones
return Arrays.copyOfRange(result, 2, result.length);
}
return result;
} }
/** /**
...@@ -207,9 +235,7 @@ public abstract class EType { ...@@ -207,9 +235,7 @@ public abstract class EType {
if (DEBUG) { if (DEBUG) {
System.out.println("Exception while getting " + System.out.println("Exception while getting " +
configName + exc.getMessage()); configName + exc.getMessage());
System.out.println("Using defaults " + System.out.println("Using default builtin etypes");
"des-cbc-md5, des-cbc-crc, des3-cbc-sha1," +
" aes128cts, aes256cts, rc4-hmac");
} }
return getBuiltInDefaults(); return getBuiltInDefaults();
} }
......
...@@ -29,9 +29,9 @@ import java.io.*; ...@@ -29,9 +29,9 @@ import java.io.*;
import java.security.*; import java.security.*;
import java.security.cert.Certificate; import java.security.cert.Certificate;
import java.security.cert.CertificateFactory; import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.util.*; import java.util.*;
import sun.misc.IOUtils;
import sun.security.pkcs.EncryptedPrivateKeyInfo; import sun.security.pkcs.EncryptedPrivateKeyInfo;
...@@ -677,50 +677,39 @@ abstract class JavaKeyStore extends KeyStoreSpi { ...@@ -677,50 +677,39 @@ abstract class JavaKeyStore extends KeyStoreSpi {
entry.date = new Date(dis.readLong()); entry.date = new Date(dis.readLong());
// Read the private key // Read the private key
try { entry.protectedPrivKey =
entry.protectedPrivKey = new byte[dis.readInt()]; IOUtils.readFully(dis, dis.readInt(), true);
} catch (OutOfMemoryError e) {
throw new IOException("Keysize too big");
}
dis.readFully(entry.protectedPrivKey);
// Read the certificate chain // Read the certificate chain
int numOfCerts = dis.readInt(); int numOfCerts = dis.readInt();
try { if (numOfCerts > 0) {
if (numOfCerts > 0) { List<Certificate> certs = new ArrayList<>(
entry.chain = new Certificate[numOfCerts]; numOfCerts > 10 ? 10 : numOfCerts);
} for (int j = 0; j < numOfCerts; j++) {
} catch (OutOfMemoryError e) { if (xVersion == 2) {
throw new IOException // read the certificate type, and instantiate a
("Too many certificates in chain"); // certificate factory of that type (reuse
} // existing factory if possible)
for (int j = 0; j < numOfCerts; j++) { String certType = dis.readUTF();
if (xVersion == 2) { if (cfs.containsKey(certType)) {
// read the certificate type, and instantiate a // reuse certificate factory
// certificate factory of that type (reuse cf = cfs.get(certType);
// existing factory if possible) } else {
String certType = dis.readUTF(); // create new certificate factory
if (cfs.containsKey(certType)) { cf = CertificateFactory.getInstance(certType);
// reuse certificate factory // store the certificate factory so we can
cf = cfs.get(certType); // reuse it later
} else { cfs.put(certType, cf);
// create new certificate factory }
cf = CertificateFactory.getInstance(certType);
// store the certificate factory so we can
// reuse it later
cfs.put(certType, cf);
} }
// instantiate the certificate
encoded = IOUtils.readFully(dis, dis.readInt(), true);
bais = new ByteArrayInputStream(encoded);
certs.add(cf.generateCertificate(bais));
bais.close();
} }
// instantiate the certificate // We can be sure now that numOfCerts of certs are read
try { entry.chain = certs.toArray(new Certificate[numOfCerts]);
encoded = new byte[dis.readInt()];
} catch (OutOfMemoryError e) {
throw new IOException("Certificate too big");
}
dis.readFully(encoded);
bais = new ByteArrayInputStream(encoded);
entry.chain[j] = cf.generateCertificate(bais);
bais.close();
} }
// Add the entry to the list // Add the entry to the list
...@@ -753,12 +742,7 @@ abstract class JavaKeyStore extends KeyStoreSpi { ...@@ -753,12 +742,7 @@ abstract class JavaKeyStore extends KeyStoreSpi {
cfs.put(certType, cf); cfs.put(certType, cf);
} }
} }
try { encoded = IOUtils.readFully(dis, dis.readInt(), true);
encoded = new byte[dis.readInt()];
} catch (OutOfMemoryError e) {
throw new IOException("Certificate too big");
}
dis.readFully(encoded);
bais = new ByteArrayInputStream(encoded); bais = new ByteArrayInputStream(encoded);
entry.cert = cf.generateCertificate(bais); entry.cert = cf.generateCertificate(bais);
bais.close(); bais.close();
......
/* /*
* Copyright (c) 2007-2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2007-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -375,7 +375,8 @@ public final class TimestampedSigner extends ContentSigner { ...@@ -375,7 +375,8 @@ public final class TimestampedSigner extends ContentSigner {
} }
if (!isSigner) { if (!isSigner) {
keyPurposes = cert.getExtendedKeyUsage(); keyPurposes = cert.getExtendedKeyUsage();
if (! keyPurposes.contains(KP_TIMESTAMPING_OID)) { if (keyPurposes == null ||
! keyPurposes.contains(KP_TIMESTAMPING_OID)) {
throw new CertificateException( throw new CertificateException(
"Certificate is not valid for timestamping"); "Certificate is not valid for timestamping");
} }
......
...@@ -117,11 +117,6 @@ policy.ignoreIdentityScope=false ...@@ -117,11 +117,6 @@ policy.ignoreIdentityScope=false
# #
keystore.type=jks keystore.type=jks
#
# Class to instantiate as the system scope:
#
system.scope=sun.security.provider.IdentityDatabase
# #
# List of comma-separated packages that start with or equal this string # List of comma-separated packages that start with or equal this string
# will cause a security exception to be thrown when # will cause a security exception to be thrown when
......
...@@ -624,8 +624,11 @@ class UnixPath ...@@ -624,8 +624,11 @@ class UnixPath
public boolean endsWith(Path other) { public boolean endsWith(Path other) {
UnixPath that = checkPath(other); UnixPath that = checkPath(other);
int thisLen = path.length;
int thatLen = that.path.length;
// other path is longer // other path is longer
if (that.path.length > path.length) if (thatLen > thisLen)
return false; return false;
// other path is absolute so this path must be absolute // other path is absolute so this path must be absolute
...@@ -643,10 +646,10 @@ class UnixPath ...@@ -643,10 +646,10 @@ class UnixPath
if (thatOffsetCount == thisOffsetCount) { if (thatOffsetCount == thisOffsetCount) {
if (thisOffsetCount == 0) if (thisOffsetCount == 0)
return true; return true;
int expectedLen = path.length; int expectedLen = thisLen;
if (this.isAbsolute() && !that.isAbsolute()) if (this.isAbsolute() && !that.isAbsolute())
expectedLen--; expectedLen--;
if (that.path.length != expectedLen) if (thatLen != expectedLen)
return false; return false;
} else { } else {
// this path has more elements so given path must be relative // this path has more elements so given path must be relative
...@@ -658,7 +661,9 @@ class UnixPath ...@@ -658,7 +661,9 @@ class UnixPath
// compare bytes // compare bytes
int thisPos = offsets[thisOffsetCount - thatOffsetCount]; int thisPos = offsets[thisOffsetCount - thatOffsetCount];
int thatPos = that.offsets[0]; int thatPos = that.offsets[0];
while (thatPos < that.path.length) { if ((thatLen - thatPos) != (thisLen - thisPos))
return false;
while (thatPos < thatLen) {
if (this.path[thisPos++] != that.path[thatPos++]) if (this.path[thisPos++] != that.path[thatPos++])
return false; return false;
} }
......
...@@ -414,9 +414,9 @@ Java_java_io_UnixFileSystem_getSpace(JNIEnv *env, jobject this, ...@@ -414,9 +414,9 @@ Java_java_io_UnixFileSystem_getSpace(JNIEnv *env, jobject this,
jlong rv = 0L; jlong rv = 0L;
WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) { WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
struct statvfs fsstat; struct statvfs64 fsstat;
memset(&fsstat, 0, sizeof(struct statvfs)); memset(&fsstat, 0, sizeof(fsstat));
if (statvfs(path, &fsstat) == 0) { if (statvfs64(path, &fsstat) == 0) {
switch(t) { switch(t) {
case java_io_FileSystem_SPACE_TOTAL: case java_io_FileSystem_SPACE_TOTAL:
rv = jlong_mul(long_to_jlong(fsstat.f_frsize), rv = jlong_mul(long_to_jlong(fsstat.f_frsize),
......
# #
# Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved. # Copyright 1995-2010 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -37,25 +37,19 @@ GET= ...@@ -37,25 +37,19 @@ GET=
AWK = awk AWK = awk
CAT = cat CAT = cat
CD = cd CD = cd
CHMOD = chmod
CP = cp CP = cp
CUT = cut CUT = cut
ECHO = echo ECHO = echo
EGREP = egrep EGREP = egrep
EXPAND = expand EXPAND = expand
EXPR = expr
KILL = /usr/bin/kill
MKDIR = mkdir MKDIR = mkdir
NOHUP = nohup
PWD = pwd PWD = pwd
SED = sed SED = sed
SLEEP = sleep
SORT = sort SORT = sort
TEE = tee TEE = tee
UNAME = uname UNAME = uname
UNIQ = uniq UNIQ = uniq
WC = wc WC = wc
XHOST = xhost
ZIP = zip ZIP = zip
# Get OS name from uname # Get OS name from uname
...@@ -211,66 +205,6 @@ ifdef JPRT_ARCHIVE_BUNDLE ...@@ -211,66 +205,6 @@ ifdef JPRT_ARCHIVE_BUNDLE
ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE) ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE)
endif endif
# DISPLAY settings for virtual frame buffer
START_XVFB = start-Xvfb.sh
NOHUP_OUTPUT = $(ABS_TEST_OUTPUT_DIR)/start-Xvfb.nohup-output.txt
DISPLAY_PID_FILE=$(ABS_TEST_OUTPUT_DIR)/xvfb-display-number.txt
DISPLAY_SLEEP_TIME=10
DISPLAY_MAX_SLEEPS=10
ifeq ($(OS_NAME),solaris)
VIRTUAL_FRAME_BUFFER = true
endif
ifeq ($(OS_NAME),linux)
VIRTUAL_FRAME_BUFFER = true
endif
# Does not work yet, display dies as soon as it gets used. :^(
VIRTUAL_FRAME_BUFFER = false
# Are we using a VIRTUAL_FRAME_BUFFER (Xvfb)
ifeq ($(VIRTUAL_FRAME_BUFFER),true)
PREP_DISPLAY = \
$(CP) $(START_XVFB) $(ABS_TEST_OUTPUT_DIR); \
$(CHMOD) a+x $(ABS_TEST_OUTPUT_DIR)/$(START_XVFB); \
( $(CD) $(ABS_TEST_OUTPUT_DIR) && \
$(NOHUP) $(ABS_TEST_OUTPUT_DIR)/$(START_XVFB) $(DISPLAY_PID_FILE) > $(NOHUP_OUTPUT) 2>&1 && \
$(SLEEP) $(DISPLAY_SLEEP_TIME) ) & \
count=1; \
while [ ! -s $(DISPLAY_PID_FILE) ] ; do \
$(ECHO) "Sleeping $(DISPLAY_SLEEP_TIME) more seconds, DISPLAY not ready"; \
$(SLEEP) $(DISPLAY_SLEEP_TIME); \
count=`$(EXPR) $${count} '+' 1`; \
if [ $${count} -gt $(DISPLAY_MAX_SLEEPS) ] ; then \
$(ECHO) "ERROR: DISPLAY not ready, giving up on DISPLAY"; \
exit 9; \
fi; \
done ; \
DISPLAY=":`$(CAT) $(DISPLAY_PID_FILE)`"; \
export DISPLAY; \
$(CAT) $(NOHUP_OUTPUT); \
$(ECHO) "Prepared DISPLAY=$${DISPLAY}"; \
$(XHOST) || \
( $(ECHO) "ERROR: No display" ; exit 8)
KILL_DISPLAY = \
( \
DISPLAY=":`$(CAT) $(DISPLAY_PID_FILE)`"; \
export DISPLAY; \
if [ -s "$(DISPLAY_PID_FILE)" ] ; then \
$(KILL) `$(CAT) $(DISPLAY_PID_FILE)` > /dev/null 2>&1; \
$(KILL) -9 `$(CAT) $(DISPLAY_PID_FILE)` > /dev/null 2>&1; \
fi; \
$(ECHO) "Killed DISPLAY=$${DISPLAY}"; \
)
else
PREP_DISPLAY = $(ECHO) "VIRTUAL_FRAME_BUFFER=$(VIRTUAL_FRAME_BUFFER)"
KILL_DISPLAY = $(ECHO) "VIRTUAL_FRAME_BUFFER=$(VIRTUAL_FRAME_BUFFER)"
endif
# How to create the test bundle (pass or fail, we want to create this) # How to create the test bundle (pass or fail, we want to create this)
# Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed. # Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed.
ZIP_UP_RESULTS = ( $(MKDIR) -p `dirname $(ARCHIVE_BUNDLE)` \ ZIP_UP_RESULTS = ( $(MKDIR) -p `dirname $(ARCHIVE_BUNDLE)` \
...@@ -327,7 +261,7 @@ BUNDLE_UP_AND_EXIT = \ ...@@ -327,7 +261,7 @@ BUNDLE_UP_AND_EXIT = \
$(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \ $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \
fi; \ fi; \
$(CAT) $(STATS_TXT); \ $(CAT) $(STATS_TXT); \
$(ZIP_UP_RESULTS) && $(KILL_DISPLAY) ; \ $(ZIP_UP_RESULTS) ; \
$(TESTEXIT) \ $(TESTEXIT) \
) )
...@@ -629,7 +563,6 @@ jtreg_tests: prep $(PRODUCT_HOME) $(JTREG) $(EXCLUDELIST) ...@@ -629,7 +563,6 @@ jtreg_tests: prep $(PRODUCT_HOME) $(JTREG) $(EXCLUDELIST)
( \ ( \
( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)"); \ ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)"); \
export JT_HOME; \ export JT_HOME; \
$(PREP_DISPLAY) && \
$(shell $(GETMIXEDPATH) "$(JTREG)") \ $(shell $(GETMIXEDPATH) "$(JTREG)") \
$(JTREG_BASIC_OPTIONS) \ $(JTREG_BASIC_OPTIONS) \
-r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport \ -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport \
......
########################################################################### ###########################################################################
# #
# Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2009-2010 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -431,6 +431,12 @@ java/lang/ClassLoader/deadlock/TestCrossDelegate.sh generic-all ...@@ -431,6 +431,12 @@ java/lang/ClassLoader/deadlock/TestCrossDelegate.sh generic-all
# jdk_management # jdk_management
# Fails on linux: KO: StringMonitor notification missed or not emitted
javax/management/monitor/NonComparableAttributeValueTest.java generic-all
# Port conflict? Fails with communication error
sun/management/jmxremote/bootstrap/PasswordFilePermissionTest.sh generic-all
# Fails on Windows 2000, Test failed for iiop java.lang.NullPointerException # Fails on Windows 2000, Test failed for iiop java.lang.NullPointerException
# at org.omg.stub.javax.management.remote.rmi._RMIConnectionImpl_Tie._invoke(Unknown Source) # at org.omg.stub.javax.management.remote.rmi._RMIConnectionImpl_Tie._invoke(Unknown Source)
# at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:653) # at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:653)
...@@ -583,6 +589,9 @@ javax/print/attribute/MediaMappingsTest.java generic-all ...@@ -583,6 +589,9 @@ javax/print/attribute/MediaMappingsTest.java generic-all
# Suspect many of these tests auffer from using fixed ports, no concrete # Suspect many of these tests auffer from using fixed ports, no concrete
# evidence. # evidence.
# Times out on Windows X64
sun/net/www/http/KeepAliveStream/KeepAliveStreamCloseWithWrongContentLength.java generic-all
# Dies on Solaris 10 sparc and sparcv9, Linux -ea -esa with # Dies on Solaris 10 sparc and sparcv9, Linux -ea -esa with
# Interrupted or IO exception, maybe writing to non-unique named file? # Interrupted or IO exception, maybe writing to non-unique named file?
com/sun/net/httpserver/bugs/B6373555.java generic-all com/sun/net/httpserver/bugs/B6373555.java generic-all
...@@ -736,6 +745,13 @@ java/net/ProxySelector/B6737819.java generic-all ...@@ -736,6 +745,13 @@ java/net/ProxySelector/B6737819.java generic-all
# Suspect many of these tests auffer from using fixed ports, no concrete # Suspect many of these tests auffer from using fixed ports, no concrete
# evidence. # evidence.
# Occasionally Failing with java.lang.AssertionError on Windows X64
# at sun.nio.ch.PendingIoCache.clearPendingIoMap(PendingIoCache.java:144)
#java/nio/channels/FileChannel/ReleaseOnCloseDeadlock.java windows-all
# Some kind of sleep/wake problem on Windows X64
java/nio/channels/Selector/Wakeup.java windows-all
# Fails with -ea -esa, Assertion error, but only on Solaris 10 machines? # Fails with -ea -esa, Assertion error, but only on Solaris 10 machines?
com/sun/nio/sctp/SctpChannel/Send.java generic-all com/sun/nio/sctp/SctpChannel/Send.java generic-all
com/sun/nio/sctp/SctpChannel/Shutdown.java generic-all com/sun/nio/sctp/SctpChannel/Shutdown.java generic-all
...@@ -932,6 +948,18 @@ java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java generic-all ...@@ -932,6 +948,18 @@ java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java generic-all
# jdk_security # jdk_security
# Unknown problem, could be a jtreg -samevm issue?
# Error while cleaning up threads after test
java/security/Security/SynchronizedAccess.java generic-all
# Failing on Solaris X64 (-d64 -server) with:
# GSSException: Failure unspecified at GSS-API level
# (Mechanism level: Specified version of key is not available (44))
sun/security/krb5/auto/BasicKrb5Test.java generic-all
# Solaris X86 failures, readjar.jks: No such file or directory
sun/security/tools/keytool/readjar.sh generic-all
# Fails with -ea -esa, but only on Solaris sparc? Suspect it is timing out # Fails with -ea -esa, but only on Solaris sparc? Suspect it is timing out
sun/security/tools/keytool/standard.sh generic-all sun/security/tools/keytool/standard.sh generic-all
...@@ -1256,6 +1284,13 @@ tools/jar/index/MetaInf.java windows-all ...@@ -1256,6 +1284,13 @@ tools/jar/index/MetaInf.java windows-all
# jdk_util # jdk_util
# Fails with assertion error on windows
# 11 separate stacktraces created... file reuse problem?
java/util/zip/ZipFile/ReadLongZipFileName.java generic-all
# Recent failure on all platforms
sun/util/resources/TimeZone/Bug6317929.java generic-all
# Fails with -ea -esa on all platforms with Assertion error # Fails with -ea -esa on all platforms with Assertion error
java/util/ResourceBundle/Test4300693.java generic-all java/util/ResourceBundle/Test4300693.java generic-all
......
/*
* Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/**
* @test
* @bug 6916202
* @summary More cases of invalid ldap filters accepted and processed
* @run main/othervm InvalidLdapFilters valid (cn=Babs)
* @run main/othervm InvalidLdapFilters valid (&(cn=Bob))
* @run main/othervm InvalidLdapFilters valid (&(objectClass=*)(uid=*))
* @run main/othervm InvalidLdapFilters valid (|(cn=Bob))
* @run main/othervm InvalidLdapFilters valid (|(objectClass=*)(uid=*))
* @run main/othervm InvalidLdapFilters valid (!(cn=Tim))
* @run main/othervm InvalidLdapFilters valid (!(!(cn=Tim)))
* @run main/othervm InvalidLdapFilters valid (!(&(objectClass=*)(uid=*)))
* @run main/othervm InvalidLdapFilters valid (!(|(objectClass=*)(uid=*)))
* @run main/othervm InvalidLdapFilters valid (o=univ*of*mich*)
* @run main/othervm InvalidLdapFilters valid (seeAlso=)
* @run main/othervm InvalidLdapFilters valid (cn:caseExactMatch:=Flintstone)
* @run main/othervm InvalidLdapFilters valid (cn:=Betty)
* @run main/othervm InvalidLdapFilters valid (sn:dn:2.4.6.8.10:=Barney)
* @run main/othervm InvalidLdapFilters valid (o:dn:=Ace)
* @run main/othervm InvalidLdapFilters valid (:1.2.3:=Wilma)
* @run main/othervm InvalidLdapFilters valid (:DN:2.4.6.8.10:=Dino)
* @run main/othervm InvalidLdapFilters valid (1.2.3=abc)
* @run main/othervm InvalidLdapFilters valid (cn;lang-de;lang-en=abc)
* @run main/othervm InvalidLdapFilters valid (owner=abc)
* @run main/othervm InvalidLdapFilters valid (sn;lang-en:dn:2.4.6.8.10:=Barney)
* @run main/othervm InvalidLdapFilters valid
(&(objectClass=Person)(|(sn=Jensen)(cn=Bab*)))
* @run main/othervm InvalidLdapFilters invalid "(&(cn=Robert Dean)))"
* @run main/othervm InvalidLdapFilters invalid (&|(cn=Bob))
* @run main/othervm InvalidLdapFilters invalid (&&(cn=Bob))
* @run main/othervm InvalidLdapFilters invalid (|&(cn=Bob))
* @run main/othervm InvalidLdapFilters invalid (||(cn=Bob))
* @run main/othervm InvalidLdapFilters invalid (:1.2.:=Wilma)
* @run main/othervm InvalidLdapFilters invalid (::DN:2.4.6.8.10:=Dino)
* @run main/othervm InvalidLdapFilters invalid (:DN::2.4.6.8.10:=Dino)
* @run main/othervm InvalidLdapFilters invalid (:DN:2.4.6.8.10::=Dino)
* @run main/othervm InvalidLdapFilters invalid (:DN:2.4.6..8.10:=Dino)
* @run main/othervm InvalidLdapFilters invalid (:DN:2.4.6.8.:=Dino)
* @run main/othervm InvalidLdapFilters invalid (1.2.;::=abc)
* @run main/othervm InvalidLdapFilters invalid (1.2.3;::=abc)
* @run main/othervm InvalidLdapFilters invalid (1.2.3;x;=abc)
* @run main/othervm InvalidLdapFilters invalid (1.2.3:x::=abc)
* @run main/othervm InvalidLdapFilters invalid (1.2.3:x=abc)
* @run main/othervm InvalidLdapFilters invalid (sn;:dn:2.4.6.8.10:=Barney)
* @run main/othervm InvalidLdapFilters invalid "\"((objectClass=*)&(uid=*))\""
* @run main/othervm InvalidLdapFilters invalid "&(objectClass=*)(uid=*)"
* @run main/othervm InvalidLdapFilters invalid "(:DN:2.4.6.8.10:cn:=Dino)"
* @run main/othervm InvalidLdapFilters invalid "(:DN:2.4.6.8.10:cn=Dino)"
* @run main/othervm InvalidLdapFilters invalid
"((objectCategory=person)(cn=u)(!(cn=u2*)))"
* @run main/othervm InvalidLdapFilters invalid
"((&(objectClass=user)(cn=andy*)(cn=steve*)(cn=bob*)))"
*
* @author Xuelei Fan
*/
import java.io.*;
import javax.naming.*;
import javax.naming.directory.*;
import java.util.Properties;
import java.util.Hashtable;
import java.net.Socket;
import java.net.ServerSocket;
public class InvalidLdapFilters {
// Should we run the client or server in a separate thread?
//
// Both sides can throw exceptions, but do you have a preference
// as to which side should be the main thread.
static boolean separateServerThread = true;
// use any free port by default
volatile int serverPort = 0;
// Is the server ready to serve?
volatile static boolean serverReady = false;
// Define the server side of the test.
//
// If the server prematurely exits, serverReady will be set to true
// to avoid infinite hangs.
void doServerSide() throws Exception {
ServerSocket serverSock = new ServerSocket(serverPort);
// signal client, it's ready to accecpt connection
serverPort = serverSock.getLocalPort();
serverReady = true;
// accept a connection
Socket socket = serverSock.accept();
System.out.println("Server: Connection accepted");
InputStream is = socket.getInputStream();
OutputStream os = socket.getOutputStream();
// read the bindRequest
while (is.read() != -1) {
// ignore
is.skip(is.available());
break;
}
byte[] bindResponse = {0x30, 0x0C, 0x02, 0x01, 0x01, 0x61, 0x07, 0x0A,
0x01, 0x00, 0x04, 0x00, 0x04, 0x00};
// write bindResponse
os.write(bindResponse);
os.flush();
// ignore any more request.
while (is.read() != -1) {
// ignore
is.skip(is.available());
}
is.close();
os.close();
socket.close();
serverSock.close();
}
// Define the client side of the test.
//
// If the server prematurely exits, serverReady will be set to true
// to avoid infinite hangs.
void doClientSide() throws Exception {
// Wait for server to get started.
while (!serverReady) {
Thread.sleep(50);
}
// set up the environment for creating the initial context
Hashtable<Object, Object> env = new Hashtable<Object, Object>();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:" + serverPort);
env.put("com.sun.jndi.ldap.read.timeout", "1000");
// env.put(Context.SECURITY_AUTHENTICATION, "simple");
// env.put(Context.SECURITY_PRINCIPAL,"cn=root");
// env.put(Context.SECURITY_CREDENTIALS,"root");
// create initial context
DirContext context = new InitialDirContext(env);
// searching
SearchControls scs = new SearchControls();
scs.setSearchScope(SearchControls.SUBTREE_SCOPE);
try {
NamingEnumeration answer =
context.search("o=sun,c=us", searchFilter, scs);
} catch (InvalidSearchFilterException isfe) {
if (filterIsValid) {
// unexpected filter exception.
throw new Exception("Unexpected ISFE", isfe);
} else {
// ignore, it is the expected filter exception.
System.out.println("Expected exception: " + isfe.getMessage());
}
} catch (NamingException ne) {
// maybe a read timeout exception, as the server does not response.
if (filterIsValid) {
System.out.println("Expected exception: " + ne.getMessage());
} else {
throw new Exception("Not an InvalidSearchFilterException", ne);
}
}
context.close();
}
private static boolean filterIsValid;
private static String searchFilter;
private static void parseArguments(String[] args) {
System.out.println("arguments length: " + args.length);
if (args[0].equals("valid")) {
filterIsValid = true;
}
searchFilter = args[1];
}
/*
* ============================================================
* The remainder is just support stuff
*/
// client and server thread
Thread clientThread = null;
Thread serverThread = null;
// client and server exceptions
volatile Exception serverException = null;
volatile Exception clientException = null;
void startServer(boolean newThread) throws Exception {
if (newThread) {
serverThread = new Thread() {
public void run() {
try {
doServerSide();
} catch (Exception e) {
/*
* Our server thread just died.
*
* Release the client, if not active already...
*/
System.err.println("Server died...");
System.err.println(e);
serverReady = true;
serverException = e;
}
}
};
serverThread.start();
} else {
doServerSide();
}
}
void startClient(boolean newThread) throws Exception {
if (newThread) {
clientThread = new Thread() {
public void run() {
try {
doClientSide();
} catch (Exception e) {
/*
* Our client thread just died.
*/
System.err.println("Client died...");
clientException = e;
}
}
};
clientThread.start();
} else {
doClientSide();
}
}
// Primary constructor, used to drive remainder of the test.
InvalidLdapFilters() throws Exception {
if (separateServerThread) {
startServer(true);
startClient(false);
} else {
startClient(true);
startServer(false);
}
/*
* Wait for other side to close down.
*/
if (separateServerThread) {
serverThread.join();
} else {
clientThread.join();
}
/*
* When we get here, the test is pretty much over.
*
* If the main thread excepted, that propagates back
* immediately. If the other thread threw an exception, we
* should report back.
*/
if (serverException != null) {
System.out.print("Server Exception:");
throw serverException;
}
if (clientException != null) {
System.out.print("Client Exception:");
throw clientException;
}
}
public static void main(String[] args) throws Exception {
// parse the customized arguments
parseArguments(args);
// start the test
new InvalidLdapFilters();
}
}
/*
* @test
* @bug 6918065
* @summary Test for passing NaN as alpha
* should throw IllegalArgumentException
*/
import java.awt.*;
public class TestAlphaCompositeForNaN {
public static void main(String[] args) {
try {
AlphaComposite a = AlphaComposite.getInstance(AlphaComposite.DST, Float.NaN);
System.out.println("Failed");
throw new RuntimeException(a + " failed to throw IllegalArgumentException for alpha = " + Float.NaN);
}
catch (IllegalArgumentException ie) {
System.out.println("Passed");
System.out.println("Caught " + ie);
}
}
}
...@@ -28,27 +28,33 @@ import java.util.*; ...@@ -28,27 +28,33 @@ import java.util.*;
/** /**
* Invokes Files.walkFileTree to traverse a file tree and prints * Invokes Files.walkFileTree to traverse a file tree and prints
* each of the directories and files. The -L option causes symbolic * each of the directories and files. The -follow option causes symbolic
* links to be followed. * links to be followed and the -printCycles option will print links
* where the target of the link is an ancestor directory.
*/ */
public class PrintFileTree { public class PrintFileTree {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
boolean followLinks = false; boolean followLinks = false;
Path dir; boolean printCycles = false;
int i = 0;
if (args[0].equals("-L")) { while (i < (args.length-1)) {
followLinks = true; switch (args[i]) {
dir = Paths.get(args[1]); case "-follow" : followLinks = true; break;
} else { case "-printCycles" : printCycles = true; break;
dir = Paths.get(args[0]); default:
throw new RuntimeException(args[i] + " not recognized");
}
i++;
} }
Path dir = Paths.get(args[i]);
Set<FileVisitOption> options = new HashSet<FileVisitOption>(); Set<FileVisitOption> options = new HashSet<FileVisitOption>();
if (followLinks) if (followLinks)
options.add(FileVisitOption.FOLLOW_LINKS); options.add(FileVisitOption.FOLLOW_LINKS);
final boolean reportCycles = printCycles;
Files.walkFileTree(dir, options, Integer.MAX_VALUE, new FileVisitor<FileRef>() { Files.walkFileTree(dir, options, Integer.MAX_VALUE, new FileVisitor<FileRef>() {
public FileVisitResult preVisitDirectory(FileRef dir) { public FileVisitResult preVisitDirectory(FileRef dir) {
System.out.println(dir); System.out.println(dir);
...@@ -59,7 +65,8 @@ public class PrintFileTree { ...@@ -59,7 +65,8 @@ public class PrintFileTree {
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;
} }
public FileVisitResult visitFile(FileRef file, BasicFileAttributes attrs) { public FileVisitResult visitFile(FileRef file, BasicFileAttributes attrs) {
System.out.println(file); if (!attrs.isDirectory() || reportCycles)
System.out.println(file);
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;
} }
public FileVisitResult postVisitDirectory(FileRef dir, IOException exc) { public FileVisitResult postVisitDirectory(FileRef dir, IOException exc) {
......
...@@ -61,12 +61,20 @@ find "$ROOT" > out2 ...@@ -61,12 +61,20 @@ find "$ROOT" > out2
diff out1 out2 diff out1 out2
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
# repeat test following links (use -follow instead of -L # repeat test following links. Some versions of find(1) output
# to allow running on older systems) # cycles (sym links to ancestor directories), other versions do
$JAVA PrintFileTree -L "$ROOT" > out1 # not. For that reason we run PrintFileTree with the -printCycles
find "$ROOT" -follow > out2 # option when the output without this option differs to find(1).
find "$ROOT" -follow > out1
$JAVA PrintFileTree -follow "$ROOT" > out2
diff out1 out2 diff out1 out2
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi if [ $? != 0 ];
then
# re-run printing cycles to stdout
$JAVA PrintFileTree -follow -printCycles "$ROOT" > out2
diff out1 out2
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
fi
# test SKIP_SIBLINGS # test SKIP_SIBLINGS
$JAVA SkipSiblings "$ROOT" $JAVA SkipSiblings "$ROOT"
......
...@@ -197,7 +197,7 @@ public class CheckPermissions { ...@@ -197,7 +197,7 @@ public class CheckPermissions {
} }
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
Path dir = Paths.get(System.getProperty("test.src", ".")); Path dir = Paths.get(System.getProperty("test.dir", "."));
Path file = dir.resolve("file1234").createFile(); Path file = dir.resolve("file1234").createFile();
try { try {
LoggingSecurityManager.install(); LoggingSecurityManager.install();
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/* @test /* @test
* @bug 4313887 6838333 * @bug 4313887 6838333 6925932
* @summary Unit test for java.nio.file.Path path operations * @summary Unit test for java.nio.file.Path path operations
*/ */
...@@ -614,17 +614,34 @@ public class PathOps { ...@@ -614,17 +614,34 @@ public class PathOps {
test("/foo") test("/foo")
.ends("foo") .ends("foo")
.ends("/foo") .ends("/foo")
.notEnds("/"); .notEnds("fool");
test("/foo/bar") test("/foo/bar")
.ends("bar") .ends("bar")
.ends("foo/bar") .ends("foo/bar")
.ends("/foo/bar") .ends("/foo/bar")
.notEnds("/bar"); .notEnds("ar")
.notEnds("barack")
.notEnds("/bar")
.notEnds("o/bar");
test("foo") test("foo")
.ends("foo"); .ends("foo")
.notEnds("oo")
.notEnds("oola");
test("foo/bar") test("foo/bar")
.ends("bar") .ends("bar")
.ends("foo/bar"); .ends("foo/bar")
.notEnds("r")
.notEnds("barmaid")
.notEnds("/bar");
test("foo/bar/gus")
.ends("gus")
.ends("bar/gus")
.ends("foo/bar/gus")
.notEnds("g")
.notEnds("/gus")
.notEnds("r/gus")
.notEnds("barack/gus")
.notEnds("bar/gust");
// elements // elements
test("a/b/c") test("a/b/c")
......
...@@ -22,22 +22,74 @@ ...@@ -22,22 +22,74 @@
*/ */
/* @test /* @test
* @bug 6907760 * @bug 6907760 6929532
* @summary Check that the OVERFLOW event is not retrieved with other events * @summary Tests WatchService behavior when lots of events are pending
* @library .. * @library ..
* @run main/timeout=180 LotsOfEvents
*/ */
import java.nio.file.*; import java.nio.file.*;
import static java.nio.file.StandardWatchEventKind.*; import static java.nio.file.StandardWatchEventKind.*;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.io.OutputStream;
import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class OverflowEventIsLoner { public class LotsOfEvents {
static void drainEvents(WatchService watcher, static final Random rand = new Random();
WatchEvent.Kind<?> expectedKind,
int count) public static void main(String[] args) throws Exception {
Path dir = TestUtil.createTemporaryDirectory();
try {
testOverflowEvent(dir);
testModifyEventsQueuing(dir);
} finally {
TestUtil.removeAll(dir);
}
}
/**
* Tests that OVERFLOW events are not retreived with other events.
*/
static void testOverflowEvent(Path dir)
throws IOException, InterruptedException
{
WatchService watcher = dir.getFileSystem().newWatchService();
try {
dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE);
// create a lot of files
int n = 1024;
Path[] files = new Path[n];
for (int i=0; i<n; i++) {
files[i] = dir.resolve("foo" + i).createFile();
}
// give time for events to accumulate (improve chance of overflow)
Thread.sleep(1000);
// check that we see the create events (or overflow)
drainAndCheckOverflowEvents(watcher, ENTRY_CREATE, n);
// delete the files
for (int i=0; i<n; i++) {
files[i].delete();
}
// give time for events to accumulate (improve chance of overflow)
Thread.sleep(1000);
// check that we see the delete events (or overflow)
drainAndCheckOverflowEvents(watcher, ENTRY_DELETE, n);
} finally {
watcher.close();
}
}
static void drainAndCheckOverflowEvents(WatchService watcher,
WatchEvent.Kind<?> expectedKind,
int count)
throws IOException, InterruptedException throws IOException, InterruptedException
{ {
// wait for key to be signalled - the timeout is long to allow for // wait for key to be signalled - the timeout is long to allow for
...@@ -50,7 +102,7 @@ public class OverflowEventIsLoner { ...@@ -50,7 +102,7 @@ public class OverflowEventIsLoner {
int nread = 0; int nread = 0;
boolean gotOverflow = false; boolean gotOverflow = false;
do { while (key != null) {
List<WatchEvent<?>> events = key.pollEvents(); List<WatchEvent<?>> events = key.pollEvents();
for (WatchEvent<?> event: events) { for (WatchEvent<?> event: events) {
WatchEvent.Kind<?> kind = event.kind(); WatchEvent.Kind<?> kind = event.kind();
...@@ -70,53 +122,101 @@ public class OverflowEventIsLoner { ...@@ -70,53 +122,101 @@ public class OverflowEventIsLoner {
if (!key.reset()) if (!key.reset())
throw new RuntimeException("Key is no longer valid"); throw new RuntimeException("Key is no longer valid");
key = watcher.poll(2, TimeUnit.SECONDS); key = watcher.poll(2, TimeUnit.SECONDS);
} while (key != null); }
// check that all expected events were received or there was an overflow // check that all expected events were received or there was an overflow
if (nread < count && !gotOverflow) if (nread < count && !gotOverflow)
throw new RuntimeException("Insufficient events"); throw new RuntimeException("Insufficient events");
} }
/**
* Tests that check that ENTRY_MODIFY events are queued efficiently
*/
static void testModifyEventsQueuing(Path dir)
throws IOException, InterruptedException
{
// this test uses a random number of files
final int nfiles = 5 + rand.nextInt(10);
DirectoryEntry[] entries = new DirectoryEntry[nfiles];
for (int i=0; i<nfiles; i++) {
entries[i] = new DirectoryEntry(dir.resolve("foo" + i));
// "some" of the files exist, some do not.
entries[i].deleteIfExists();
if (rand.nextBoolean())
entries[i].create();
}
static void test(Path dir) throws IOException, InterruptedException {
WatchService watcher = dir.getFileSystem().newWatchService(); WatchService watcher = dir.getFileSystem().newWatchService();
try { try {
WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE); dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
// create a lot of files // do several rounds of noise and test
int n = 1024; for (int round=0; round<10; round++) {
Path[] files = new Path[n];
for (int i=0; i<n; i++) {
files[i] = dir.resolve("foo" + i).createFile();
}
// give time for events to accumulate (improve chance of overflow) // make some noise!!!
Thread.sleep(1000); for (int i=0; i<100; i++) {
DirectoryEntry entry = entries[rand.nextInt(nfiles)];
// check that we see the create events (or overflow) int action = rand.nextInt(10);
drainEvents(watcher, ENTRY_CREATE, n); switch (action) {
case 0 : entry.create(); break;
case 1 : entry.deleteIfExists(); break;
default: entry.modifyIfExists();
}
}
// delete the files // process events and ensure that we don't get repeated modify
for (int i=0; i<n; i++) { // events for the same file.
files[i].delete(); WatchKey key = watcher.poll(15, TimeUnit.SECONDS);
while (key != null) {
Set<Path> modified = new HashSet<Path>();
for (WatchEvent<?> event: key.pollEvents()) {
WatchEvent.Kind<?> kind = event.kind();
Path file = (kind == OVERFLOW) ? null : (Path)event.context();
if (kind == ENTRY_MODIFY) {
boolean added = modified.add(file);
if (!added) {
throw new RuntimeException(
"ENTRY_MODIFY events not queued efficiently");
}
} else {
if (file != null) modified.remove(file);
}
}
if (!key.reset())
throw new RuntimeException("Key is no longer valid");
key = watcher.poll(2, TimeUnit.SECONDS);
}
} }
// give time for events to accumulate (improve chance of overflow)
Thread.sleep(1000);
// check that we see the delete events (or overflow)
drainEvents(watcher, ENTRY_DELETE, n);
} finally { } finally {
watcher.close(); watcher.close();
} }
} }
public static void main(String[] args) throws Exception { static class DirectoryEntry {
Path dir = TestUtil.createTemporaryDirectory(); private final Path file;
try { DirectoryEntry(Path file) {
test(dir); this.file = file;
} finally { }
TestUtil.removeAll(dir); void create() throws IOException {
if (file.notExists())
file.createFile();
}
void deleteIfExists() throws IOException {
file.deleteIfExists();
}
void modifyIfExists() throws IOException {
if (file.exists()) {
OutputStream out = file.newOutputStream(StandardOpenOption.APPEND);
try {
out.write("message".getBytes());
} finally {
out.close();
}
}
} }
} }
} }
/*
* Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6921001
* @summary The default system identity scope is now null.
*/
import java.security.*;
public class NoDefaultSystemScope {
public static void main(String args[]) throws Exception {
IdentityScope s = IdentityScope.getSystemScope();
if (s != null) {
throw new Exception("The default system scope should be null");
}
System.out.println("TEST PASSED");
}
}
/*
* Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6844909
* @run main/othervm WeakCrypto
* @summary support allow_weak_crypto in krb5.conf
*/
import java.io.File;
import sun.security.krb5.internal.crypto.EType;
import sun.security.krb5.EncryptedData;
public class WeakCrypto {
public static void main(String[] args) throws Exception {
System.setProperty("java.security.krb5.conf",
System.getProperty("test.src", ".") +
File.separator +
"weakcrypto.conf");
int[] etypes = EType.getBuiltInDefaults();
for (int i=0, length = etypes.length; i<length; i++) {
if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC ||
etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 ||
etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) {
throw new Exception("DES should not appear");
}
}
}
}
[libdefaults]
allow_weak_crypto = false
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册