This commit is contained in:
Lana Steuck 2010-06-01 21:36:00 -07:00
commit 2c036dc823
71 changed files with 7151 additions and 355 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 20010, 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
@ -231,15 +231,35 @@ ifeq ($(PLATFORM), windows)
# Temporary disk area
TEMP_DISK=C:/temp
# GNU Make or MKS overrides $(PROCESSOR_ARCHITECTURE) to always
# return "x86". Use the first word of $(PROCESSOR_IDENTIFIER) instead.
PROC_ARCH:=$(word 1, $(PROCESSOR_IDENTIFIER))
PROC_ARCH:=$(subst x86,X86,$(PROC_ARCH))
PROC_ARCH:=$(subst Intel64,X64,$(PROC_ARCH))
PROC_ARCH:=$(subst em64t,X64,$(PROC_ARCH))
PROC_ARCH:=$(subst EM64T,X64,$(PROC_ARCH))
PROC_ARCH:=$(subst amd64,X64,$(PROC_ARCH))
PROC_ARCH:=$(subst AMD64,X64,$(PROC_ARCH))
PROC_ARCH:=$(subst ia64,IA64,$(PROC_ARCH))
# return "x86". Use the first word of $(PROCESSOR_IDENTIFIER) instead.
# And sometimes PROCESSOR_IDENTIFIER is not defined at all
# (in some restricted shells), so we use uname if we have to.
ifeq ($(PROCESSOR_IDENTIFIER),)
PROC_ARCH:=$(shell uname -m)
else
PROC_ARCH:=$(word 1, $(PROCESSOR_IDENTIFIER))
endif
# Cover all the possibilities, MKS uname, CYGWIN uname, PROCESSOR_IDENTIFIER
# Get: X86, X64, or IA64
PROC_ARCH:=$(patsubst 386,X86,$(PROC_ARCH))
PROC_ARCH:=$(patsubst 486,X86,$(PROC_ARCH))
PROC_ARCH:=$(patsubst 586,X86,$(PROC_ARCH))
PROC_ARCH:=$(patsubst 686,X86,$(PROC_ARCH))
PROC_ARCH:=$(patsubst i386,X86,$(PROC_ARCH))
PROC_ARCH:=$(patsubst i486,X86,$(PROC_ARCH))
PROC_ARCH:=$(patsubst i586,X86,$(PROC_ARCH))
PROC_ARCH:=$(patsubst i686,X86,$(PROC_ARCH))
PROC_ARCH:=$(patsubst x86,X86,$(PROC_ARCH))
PROC_ARCH:=$(patsubst intel64,X64,$(PROC_ARCH))
PROC_ARCH:=$(patsubst Intel64,X64,$(PROC_ARCH))
PROC_ARCH:=$(patsubst INTEL64,X64,$(PROC_ARCH))
PROC_ARCH:=$(patsubst em64t,X64,$(PROC_ARCH))
PROC_ARCH:=$(patsubst EM64T,X64,$(PROC_ARCH))
PROC_ARCH:=$(patsubst amd64,X64,$(PROC_ARCH))
PROC_ARCH:=$(patsubst AMD64,X64,$(PROC_ARCH))
PROC_ARCH:=$(patsubst 8664,X64,$(PROC_ARCH))
PROC_ARCH:=$(patsubst x86_64,X64,$(PROC_ARCH))
PROC_ARCH:=$(patsubst ia64,IA64,$(PROC_ARCH))
ifndef ARCH_DATA_MODEL
ifeq ($(PROC_ARCH),IA64)
ARCH_DATA_MODEL=64

View File

@ -34,6 +34,7 @@ JAVA_JAVA_java = \
java/lang/Thread.java \
java/lang/Character.java \
java/lang/CharacterData.java \
java/lang/CharacterName.java \
sun/misc/ASCIICaseInsensitiveComparator.java \
sun/misc/VM.java \
sun/misc/Signal.java \

View File

@ -384,6 +384,27 @@ clean::
$(RM) $(GENSRCDIR)/java/lang/CharacterDataUndefined.java
$(RM) $(GENSRCDIR)/java/lang/CharacterDataPrivateUse.java
#
# Rules to generate classes/java/lang/uniName.dat
#
UNINAME = $(CLASSBINDIR)/java/lang/uniName.dat
GENERATEUNINAME_JARFILE = $(BUILDTOOLJARDIR)/generatecharacter.jar
build: $(UNINAME)
$(UNINAME): $(UNICODEDATA)/UnicodeData.txt \
$(GENERATECHARACTER_JARFILE)
@$(prep-target)
$(BOOT_JAVA_CMD) -classpath $(GENERATECHARACTER_JARFILE) \
build.tools.generatecharacter.CharacterName \
$(UNICODEDATA)/UnicodeData.txt $(UNINAME)
clean::
$(RM) $(UNINAME)
#
# End of rules to create $(GENSRCDIR)/java/lang/CharacterDataXX.java
#

View File

@ -823,6 +823,10 @@ module jar-tool {
include sun.tools.jar.**;
}
module policytool {
include sun.security.tools.policytool.*;
}
module security-tools {
include sun.security.tools.**;

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 2010, 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
@ -47,5 +47,5 @@ include $(BUILDDIR)/common/Classes.gmk
build:
$(call make-launcher, keytool, sun.security.tools.KeyTool, , )
$(call make-launcher, policytool, sun.security.tools.PolicyTool, , )
$(call make-launcher, policytool, sun.security.tools.policytool.PolicyTool, , )

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,100 @@
package build.tools.generatecharacter;
import java.io.*;
import java.nio.*;
import java.util.*;
import java.util.zip.*;
public class CharacterName {
public static void main(String[] args) {
FileReader reader = null;
try {
if (args.length != 2) {
System.err.println("Usage: java CharacterName UniocdeData.txt uniName.dat");
System.exit(1);
}
reader = new FileReader(args[0]);
BufferedReader bfr = new BufferedReader(reader);
String line = null;
StringBuilder namePool = new StringBuilder();
byte[] cpPoolBytes = new byte[0x100000];
ByteBuffer cpBB = ByteBuffer.wrap(cpPoolBytes);
int lastCp = 0;
int cpNum = 0;
while ((line = bfr.readLine()) != null) {
if (line.startsWith("#"))
continue;
UnicodeSpec spec = UnicodeSpec.parse(line);
if (spec != null) {
int cp = spec.getCodePoint();
String name = spec.getName();
cpNum++;
if (name.equals("<control>") && spec.getOldName() != null) {
if (spec.getOldName().length() != 0)
name = spec.getOldName();
else
continue;
} else if (name.startsWith("<")) {
/*
3400 <CJK Ideograph Extension A, First>
4db5 <CJK Ideograph Extension A, Last>
4e00 <CJK Ideograph, First>
9fc3 <CJK Ideograph, Last>
ac00 <Hangul Syllable, First>
d7a3 <Hangul Syllable, Last>
d800 <Non Private Use High Surrogate, First>
db7f <Non Private Use High Surrogate, Last>
db80 <Private Use High Surrogate, First>
dbff <Private Use High Surrogate, Last>
dc00 <Low Surrogate, First>
dfff <Low Surrogate, Last>
e000 <Private Use, First>
f8ff <Private Use, Last>
20000 <CJK Ideograph Extension B, First>
2a6d6 <CJK Ideograph Extension B, Last>
f0000 <Plane 15 Private Use, First>
ffffd <Plane 15 Private Use, Last>
*/
continue;
}
if (cp == lastCp + 1) {
cpBB.put((byte)name.length());
} else {
cpBB.put((byte)0); // segment start flag
cpBB.putInt((name.length() << 24) | (cp & 0xffffff));
}
namePool.append(name);
lastCp = cp;
}
}
byte[] namePoolBytes = namePool.toString().getBytes("ASCII");
int cpLen = cpBB.position();
int total = cpLen + namePoolBytes.length;
DataOutputStream dos = new DataOutputStream(
new DeflaterOutputStream(
new FileOutputStream(args[1])));
dos.writeInt(total); // total
dos.writeInt(cpLen); // nameOff
dos.write(cpPoolBytes, 0, cpLen);
dos.write(namePoolBytes);
dos.close();
} catch (Throwable e) {
System.out.println("Unexpected exception:");
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (Throwable ee) { ee.printStackTrace(); }
}
}
}
}

View File

@ -0,0 +1,214 @@
import java.util.regex.*;
import java.util.*;
import java.io.*;
public class CharacterScript {
// generate the code needed for j.l.C.UnicodeScript
static void fortest(String fmt, Object... o) {
//System.out.printf(fmt, o);
}
static void print(String fmt, Object... o) {
System.out.printf(fmt, o);
}
static void debug(String fmt, Object... o) {
//System.out.printf(fmt, o);
}
public static void main(String args[]){
try {
if (args.length != 1) {
System.out.println("java CharacterScript script.txt out");
System.exit(1);
}
int i, j;
BufferedReader sbfr = new BufferedReader(new FileReader(args[0]));
HashMap<String,Integer> scriptMap = new HashMap<String,Integer>();
String line = null;
Matcher m = Pattern.compile("(\\p{XDigit}+)(?:\\.{2}(\\p{XDigit}+))?\\s+;\\s+(\\w+)\\s+#.*").matcher("");
int prevS = -1;
int prevE = -1;
String prevN = null;
int[][] scripts = new int[1024][3];
int scriptSize = 0;
while ((line = sbfr.readLine()) != null) {
if (line.length() <= 1 || line.charAt(0) == '#') {
continue;
}
m.reset(line);
if (m.matches()) {
int start = Integer.parseInt(m.group(1), 16);
int end = (m.group(2)==null)?start
:Integer.parseInt(m.group(2), 16);
String name = m.group(3);
if (name.equals(prevN) && start == prevE + 1) {
prevE = end;
} else {
if (prevS != -1) {
if (scriptMap.get(prevN) == null) {
scriptMap.put(prevN, scriptMap.size());
}
scripts[scriptSize][0] = prevS;
scripts[scriptSize][1] = prevE;
scripts[scriptSize][2] = scriptMap.get(prevN);
scriptSize++;
}
debug("%x-%x\t%s%n", prevS, prevE, prevN);
prevS = start; prevE = end; prevN = name;
}
} else {
debug("Warning: Unrecognized line <%s>%n", line);
}
}
//last one.
if (scriptMap.get(prevN) == null) {
scriptMap.put(prevN, scriptMap.size());
}
scripts[scriptSize][0] = prevS;
scripts[scriptSize][1] = prevE;
scripts[scriptSize][2] = scriptMap.get(prevN);
scriptSize++;
debug("%x-%x\t%s%n", prevS, prevE, prevN);
debug("-----------------%n");
debug("Total scripts=%s%n", scriptMap.size());
debug("-----------------%n%n");
String[] names = new String[scriptMap.size()];
for (String name: scriptMap.keySet()) {
names[scriptMap.get(name).intValue()] = name;
}
for (j = 0; j < scriptSize; j++) {
for (int cp = scripts[j][0]; cp <= scripts[j][1]; cp++) {
String name = names[scripts[j][2]].toUpperCase(Locale.ENGLISH);;
if (cp > 0xffff)
System.out.printf("%05X %s%n", cp, name);
else
System.out.printf("%05X %s%n", cp, name);
}
}
Arrays.sort(scripts, 0, scriptSize,
new Comparator<int[]>() {
public int compare(int[] a1, int[] a2) {
return a1[0] - a2[0];
}
public boolean compare(Object obj) {
return obj == this;
}
});
// Consolidation: there are lots of "reserved" code points
// embedded in those otherwise "sequential" blocks.
// To make the lookup table smaller, we combine those
// separated segments with the assumption that the lookup
// implementation checks
// Character.getType() != Character.UNASSIGNED
// first (return UNKNOWN for unassigned)
ArrayList<int[]> list = new ArrayList();
list.add(scripts[0]);
int[] last = scripts[0];
for (i = 1; i < scriptSize; i++) {
if (scripts[i][0] != (last[1] + 1)) {
boolean isNotUnassigned = false;
for (int cp = last[1] + 1; cp < scripts[i][0]; cp++) {
if (Character.getType(cp) != Character.UNASSIGNED) {
isNotUnassigned = true;
debug("Warning: [%x] is ASSIGNED but in NON script%n", cp);
break;
}
}
if (isNotUnassigned) {
// surrogates only?
int[] a = new int[3];
a[0] = last[1] + 1;
a[1] = scripts[i][0] - 1;
a[2] = -1; // unknown
list.add(a);
} else {
if (last[2] == scripts[i][2]) {
//combine
last[1] = scripts[i][1];
continue;
} else {
// expand last
last[1] = scripts[i][0] - 1;
}
}
}
list.add(scripts[i]);
last = scripts[i];
}
for (i = 0; i < list.size(); i++) {
int[] a = (int[])list.get(i);
String name = "UNKNOWN";
if (a[2] != -1)
name = names[a[2]].toUpperCase(Locale.US);
debug("0x%05x, 0x%05x %s%n", a[0], a[1], name);
}
debug("--->total=%d%n", list.size());
//////////////////OUTPUT//////////////////////////////////
print("public class Scripts {%n%n");
print(" public static enum UnicodeScript {%n");
for (i = 0; i < names.length; i++) {
print(" /**%n * Unicode script \"%s\".%n */%n", names[i]);
print(" %s,%n%n", names[i].toUpperCase(Locale.US));
}
print(" /**%n * Unicode script \"Unknown\".%n */%n UNKNOWN;%n%n");
// lookup table
print(" private static final int[] scriptStarts = {%n");
for (int[] a : list) {
String name = "UNKNOWN";
if (a[2] != -1)
name = names[a[2]].toUpperCase(Locale.US);
if (a[0] < 0x10000)
print(" 0x%04X, // %04X..%04X; %s%n",
a[0], a[0], a[1], name);
else
print(" 0x%05X, // %05X..%05X; %s%n",
a[0], a[0], a[1], name);
}
last = list.get(list.size() -1);
if (last[1] != Character.MAX_CODE_POINT)
print(" 0x%05X // %05X..%06X; %s%n",
last[1] + 1, last[1] + 1, Character.MAX_CODE_POINT,
"UNKNOWN");
print("%n };%n%n");
print(" private static final UnicodeScript[] scripts = {%n");
for (int[] a : list) {
String name = "UNKNOWN";
if (a[2] != -1)
name = names[a[2]].toUpperCase(Locale.US);
print(" %s,%n", name);
}
if (last[1] != Character.MAX_CODE_POINT)
print(" UNKNOWN%n");
print(" };%n");
print(" }%n");
print("}%n");
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -35,6 +35,8 @@ import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.File;
import build.tools.generatecharacter.CharacterName;
/**
* This program generates the source code for the class java.lang.Character.
* It also generates native C code that can perform the same operations.

View File

@ -525,11 +525,11 @@ public class DnsClient {
}
byte[] pkt;
if ((pkt = (byte[]) resps.get(xid)) != null) {
checkResponseCode(new Header(pkt, pkt.length));
synchronized (queuesLock) {
resps.remove(xid);
reqs.remove(xid);
}
checkResponseCode(new Header(pkt, pkt.length));
if (debug) {
dprint("FOUND (" + Thread.currentThread() +
@ -562,12 +562,12 @@ public class DnsClient {
dprint("XID MATCH:" + xid);
}
checkResponseCode(hdr);
// remove the response for the xid if received by some other thread.
synchronized (queuesLock) {
resps.remove(xid);
reqs.remove(xid);
}
checkResponseCode(hdr);
return true;
}

View File

@ -117,7 +117,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
* size check or synchronization.
*/
void expandCapacity(int minimumCapacity) {
int newCapacity = value.length * 2;
int newCapacity = value.length * 2 + 2;
if (newCapacity - minimumCapacity < 0)
newCapacity = minimumCapacity;
if (newCapacity < 0) {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,106 @@
/*
* 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 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.
*/
package java.lang;
import java.io.DataInputStream;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.util.Arrays;
import java.util.zip.InflaterInputStream;
import java.security.AccessController;
import java.security.PrivilegedAction;
class CharacterName {
private static SoftReference<byte[]> refStrPool;
private static int[][] lookup;
private static synchronized byte[] initNamePool() {
byte[] strPool = null;
if (refStrPool != null && (strPool = refStrPool.get()) != null)
return strPool;
DataInputStream dis = null;
try {
dis = new DataInputStream(new InflaterInputStream(
AccessController.doPrivileged(new PrivilegedAction<InputStream>()
{
public InputStream run() {
return getClass().getResourceAsStream("uniName.dat");
}
})));
lookup = new int[(Character.MAX_CODE_POINT + 1) >> 8][];
int total = dis.readInt();
int cpEnd = dis.readInt();
byte ba[] = new byte[cpEnd];
dis.readFully(ba);
int nameOff = 0;
int cpOff = 0;
int cp = 0;
do {
int len = ba[cpOff++] & 0xff;
if (len == 0) {
len = ba[cpOff++] & 0xff;
// always big-endian
cp = ((ba[cpOff++] & 0xff) << 16) |
((ba[cpOff++] & 0xff) << 8) |
((ba[cpOff++] & 0xff));
} else {
cp++;
}
int hi = cp >> 8;
if (lookup[hi] == null) {
lookup[hi] = new int[0x100];
}
lookup[hi][cp&0xff] = (nameOff << 8) | len;
nameOff += len;
} while (cpOff < cpEnd);
strPool = new byte[total - cpEnd];
dis.readFully(strPool);
refStrPool = new SoftReference<byte[]>(strPool);
} catch (Exception x) {
throw new InternalError(x.getMessage());
} finally {
try {
if (dis != null)
dis.close();
} catch (Exception xx) {}
}
return strPool;
}
public static String get(int cp) {
byte[] strPool = null;
if (refStrPool == null || (strPool = refStrPool.get()) == null)
strPool = initNamePool();
int off = 0;
if (lookup[cp>>8] == null ||
(off = lookup[cp>>8][cp&0xff]) == 0)
return null;
return new String(strPool, 0, off >>> 8, off & 0xff); // ASCII
}
}

View File

@ -2491,6 +2491,8 @@ public final class URI
// Tell whether the given character is permitted by the given mask pair
private static boolean match(char c, long lowMask, long highMask) {
if (c == 0) // 0 doesn't have a slot in the mask. So, it never matches.
return false;
if (c < 64)
return ((1L << c) & lowMask) != 0;
if (c < 128)

View File

@ -76,7 +76,7 @@ class JarVerifier {
private ByteArrayOutputStream baos;
/** The ManifestDigester object */
private ManifestDigester manDig;
private volatile ManifestDigester manDig;
/** the bytes for the manDig object */
byte manifestRawBytes[] = null;

View File

@ -29,6 +29,7 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.CharacterIterator;
import java.text.Normalizer;
import java.util.Locale;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
@ -200,8 +201,9 @@ import java.util.Arrays;
* <td>Equivalent to java.lang.Character.isMirrored()</td></tr>
*
* <tr><th>&nbsp;</th></tr>
* <tr align="left"><th colspan="2" id="unicode">Classes for Unicode blocks and categories</th></tr>
*
* <tr align="left"><th colspan="2" id="unicode">Classes for Unicode scripts, blocks and categories</th></tr>
* * <tr><td valign="top" headers="construct unicode"><tt>\p{IsLatin}</tt></td>
* <td headers="matches">A Latin&nbsp;script character (simple <a href="#ubc">script</a>)</td></tr>
* <tr><td valign="top" headers="construct unicode"><tt>\p{InGreek}</tt></td>
* <td headers="matches">A character in the Greek&nbsp;block (simple <a href="#ubc">block</a>)</td></tr>
* <tr><td valign="top" headers="construct unicode"><tt>\p{Lu}</tt></td>
@ -527,25 +529,40 @@ import java.util.Arrays;
* while not equal, compile into the same pattern, which matches the character
* with hexadecimal value <tt>0x2014</tt>.
*
* <a name="ubc"> <p>Unicode blocks and categories are written with the
* <tt>\p</tt> and <tt>\P</tt> constructs as in
* Perl. <tt>\p{</tt><i>prop</i><tt>}</tt> matches if the input has the
* property <i>prop</i>, while <tt>\P{</tt><i>prop</i><tt>}</tt> does not match if
* the input has that property. Blocks are specified with the prefix
* <tt>In</tt>, as in <tt>InMongolian</tt>. Categories may be specified with
* the optional prefix <tt>Is</tt>: Both <tt>\p{L}</tt> and <tt>\p{IsL}</tt>
* denote the category of Unicode letters. Blocks and categories can be used
* both inside and outside of a character class.
*
* <a name="ubc">
* <p>Unicode scripts, blocks and categories are written with the <tt>\p</tt> and
* <tt>\P</tt> constructs as in Perl. <tt>\p{</tt><i>prop</i><tt>}</tt> matches if
* the input has the property <i>prop</i>, while <tt>\P{</tt><i>prop</i><tt>}</tt>
* does not match if the input has that property.
* <p>
* Scripts are specified either with the prefix {@code Is}, as in
* {@code IsHiragana}, or by using the {@code script} keyword (or its short
* form {@code sc})as in {@code script=Hiragana} or {@code sc=Hiragana}.
* <p>
* Blocks are specified with the prefix {@code In}, as in
* {@code InMongolian}, or by using the keyword {@code block} (or its short
* form {@code blk}) as in {@code block=Mongolian} or {@code blk=Mongolian}.
* <p>
* Categories may be specified with the optional prefix {@code Is}:
* Both {@code \p{L}} and {@code \p{IsL}} denote the category of Unicode
* letters. Same as scripts and blocks, categories can also be specified
* by using the keyword {@code general_category} (or its short form
* {@code gc}) as in {@code general_category=Lu} or {@code gc=Lu}.
* <p>
* Scripts, blocks and categories can be used both inside and outside of a
* character class.
* <p> The supported categories are those of
* <a href="http://www.unicode.org/unicode/standard/standard.html">
* <i>The Unicode Standard</i></a> in the version specified by the
* {@link java.lang.Character Character} class. The category names are those
* defined in the Standard, both normative and informative.
* The script names supported by <code>Pattern</code> are the valid script names
* accepted and defined by
* {@link java.lang.Character.UnicodeScript#forName(String) UnicodeScript.forName}.
* The block names supported by <code>Pattern</code> are the valid block names
* accepted and defined by
* {@link java.lang.Character.UnicodeBlock#forName(String) UnicodeBlock.forName}.
*
* <p>
* <a name="jcc"> <p>Categories that behave like the java.lang.Character
* boolean is<i>methodname</i> methods (except for the deprecated ones) are
* available through the same <tt>\p{</tt><i>prop</i><tt>}</tt> syntax where
@ -2488,12 +2505,34 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
name = new String(temp, i, j-i-1);
}
if (name.startsWith("In")) {
node = unicodeBlockPropertyFor(name.substring(2));
int i = name.indexOf('=');
if (i != -1) {
// property construct \p{name=value}
String value = name.substring(i + 1);
name = name.substring(0, i).toLowerCase(Locale.ENGLISH);
if ("sc".equals(name) || "script".equals(name)) {
node = unicodeScriptPropertyFor(value);
} else if ("blk".equals(name) || "block".equals(name)) {
node = unicodeBlockPropertyFor(value);
} else if ("gc".equals(name) || "general_category".equals(name)) {
node = charPropertyNodeFor(value);
} else {
throw error("Unknown Unicode property {name=<" + name + ">, "
+ "value=<" + value + ">}");
}
} else {
if (name.startsWith("Is"))
if (name.startsWith("In")) {
// \p{inBlockName}
node = unicodeBlockPropertyFor(name.substring(2));
} else if (name.startsWith("Is")) {
// \p{isGeneralCategory} and \p{isScriptName}
name = name.substring(2);
node = charPropertyNodeFor(name);
node = CharPropertyNames.charPropertyFor(name);
if (node == null)
node = unicodeScriptPropertyFor(name);
} else {
node = charPropertyNodeFor(name);
}
}
if (maybeComplement) {
if (node instanceof Category || node instanceof Block)
@ -2503,6 +2542,21 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
return node;
}
/**
* Returns a CharProperty matching all characters belong to
* a UnicodeScript.
*/
private CharProperty unicodeScriptPropertyFor(String name) {
final Character.UnicodeScript script;
try {
script = Character.UnicodeScript.forName(name);
} catch (IllegalArgumentException iae) {
throw error("Unknown character script name {" + name + "}");
}
return new Script(script);
}
/**
* Returns a CharProperty matching all characters in a UnicodeBlock.
*/
@ -3566,6 +3620,19 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
}
}
/**
* Node class that matches a Unicode script
*/
static final class Script extends CharProperty {
final Character.UnicodeScript script;
Script(Character.UnicodeScript script) {
this.script = script;
}
boolean isSatisfiedBy(int ch) {
return script == Character.UnicodeScript.of(ch);
}
}
/**
* Node class that matches a Unicode category.
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2010, 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
@ -66,19 +66,24 @@ class GZIPInputStream extends InflaterInputStream {
* Creates a new input stream with the specified buffer size.
* @param in the input stream
* @param size the input buffer size
*
* @exception ZipException if a GZIP format error has occurred or the
* compression method used is unsupported
* @exception IOException if an I/O error has occurred
* @exception IllegalArgumentException if size is <= 0
*/
public GZIPInputStream(InputStream in, int size) throws IOException {
super(in, new Inflater(true), size);
usesDefaultInflater = true;
readHeader();
crc.reset();
readHeader(in);
}
/**
* Creates a new input stream with a default buffer size.
* @param in the input stream
*
* @exception ZipException if a GZIP format error has occurred or the
* compression method used is unsupported
* @exception IOException if an I/O error has occurred
*/
public GZIPInputStream(InputStream in) throws IOException {
@ -94,26 +99,30 @@ class GZIPInputStream extends InflaterInputStream {
* @param len the maximum number of bytes read
* @return the actual number of bytes read, or -1 if the end of the
* compressed input stream is reached
*
* @exception NullPointerException If <code>buf</code> is <code>null</code>.
* @exception IndexOutOfBoundsException If <code>off</code> is negative,
* <code>len</code> is negative, or <code>len</code> is greater than
* <code>buf.length - off</code>
* @exception IOException if an I/O error has occurred or the compressed
* input data is corrupt
* @exception ZipException if the compressed input data is corrupt.
* @exception IOException if an I/O error has occurred.
*
*/
public int read(byte[] buf, int off, int len) throws IOException {
ensureOpen();
if (eos) {
return -1;
}
len = super.read(buf, off, len);
if (len == -1) {
readTrailer();
eos = true;
int n = super.read(buf, off, len);
if (n == -1) {
if (readTrailer())
eos = true;
else
return this.read(buf, off, len);
} else {
crc.update(buf, off, len);
crc.update(buf, off, n);
}
return len;
return n;
}
/**
@ -144,48 +153,61 @@ class GZIPInputStream extends InflaterInputStream {
private final static int FCOMMENT = 16; // File comment
/*
* Reads GZIP member header.
* Reads GZIP member header and returns the total byte number
* of this member header.
*/
private void readHeader() throws IOException {
CheckedInputStream in = new CheckedInputStream(this.in, crc);
private int readHeader(InputStream this_in) throws IOException {
CheckedInputStream in = new CheckedInputStream(this_in, crc);
crc.reset();
// Check header magic
if (readUShort(in) != GZIP_MAGIC) {
throw new IOException("Not in GZIP format");
throw new ZipException("Not in GZIP format");
}
// Check compression method
if (readUByte(in) != 8) {
throw new IOException("Unsupported compression method");
throw new ZipException("Unsupported compression method");
}
// Read flags
int flg = readUByte(in);
// Skip MTIME, XFL, and OS fields
skipBytes(in, 6);
int n = 2 + 2 + 6;
// Skip optional extra field
if ((flg & FEXTRA) == FEXTRA) {
skipBytes(in, readUShort(in));
int m = readUShort(in);
skipBytes(in, m);
n += m + 2;
}
// Skip optional file name
if ((flg & FNAME) == FNAME) {
while (readUByte(in) != 0) ;
do {
n++;
} while (readUByte(in) != 0);
}
// Skip optional file comment
if ((flg & FCOMMENT) == FCOMMENT) {
while (readUByte(in) != 0) ;
do {
n++;
} while (readUByte(in) != 0);
}
// Check optional header CRC
if ((flg & FHCRC) == FHCRC) {
int v = (int)crc.getValue() & 0xffff;
if (readUShort(in) != v) {
throw new IOException("Corrupt GZIP header");
throw new ZipException("Corrupt GZIP header");
}
n += 2;
}
crc.reset();
return n;
}
/*
* Reads GZIP member trailer.
* Reads GZIP member trailer and returns true if the eos
* reached, false if there are more (concatenated gzip
* data set)
*/
private void readTrailer() throws IOException {
private boolean readTrailer() throws IOException {
InputStream in = this.in;
int n = inf.getRemaining();
if (n > 0) {
@ -196,7 +218,25 @@ class GZIPInputStream extends InflaterInputStream {
if ((readUInt(in) != crc.getValue()) ||
// rfc1952; ISIZE is the input size modulo 2^32
(readUInt(in) != (inf.getBytesWritten() & 0xffffffffL)))
throw new IOException("Corrupt GZIP trailer");
throw new ZipException("Corrupt GZIP trailer");
// If there are more bytes available in "in" or
// the leftover in the "inf" is > 26 bytes:
// this.trailer(8) + next.header.min(10) + next.trailer(8)
// try concatenated case
if (this.in.available() > 0 || n > 26) {
int m = 8; // this.trailer
try {
m += readHeader(in); // next.header
} catch (IOException ze) {
return true; // ignore any malformed, do nothing
}
inf.reset();
if (n > m)
inf.setInput(buf, len - n + m, n - m);
return false;
}
return true;
}
/*
@ -231,7 +271,6 @@ class GZIPInputStream extends InflaterInputStream {
return b;
}
private byte[] tmpbuf = new byte[128];
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -54,25 +54,82 @@ class GZIPOutputStream extends DeflaterOutputStream {
/**
* Creates a new output stream with the specified buffer size.
*
* <p>The new output stream instance is created as if by invoking
* the 3-argument constructor GZIPOutputStream(out, size, false).
*
* @param out the output stream
* @param size the output buffer size
* @exception IOException If an I/O error has occurred.
* @exception IllegalArgumentException if size is <= 0
*/
public GZIPOutputStream(OutputStream out, int size) throws IOException {
super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size);
this(out, size, false);
}
/**
* Creates a new output stream with the specified buffer size and
* flush mode.
*
* @param out the output stream
* @param size the output buffer size
* @param syncFlush
* if {@code true} invocation of the inherited
* {@link DeflaterOutputStream#flush() flush()} method of
* this instance flushes the compressor with flush mode
* {@link Deflater#SYNC_FLUSH} before flushing the output
* stream, otherwise only flushes the output stream
* @exception IOException If an I/O error has occurred.
* @exception IllegalArgumentException if size is <= 0
*
* @since 1.7
*/
public GZIPOutputStream(OutputStream out, int size, boolean syncFlush)
throws IOException
{
super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true),
size,
syncFlush);
usesDefaultDeflater = true;
writeHeader();
crc.reset();
}
/**
* Creates a new output stream with a default buffer size.
*
* <p>The new output stream instance is created as if by invoking
* the 2-argument constructor GZIPOutputStream(out, false).
*
* @param out the output stream
* @exception IOException If an I/O error has occurred.
*/
public GZIPOutputStream(OutputStream out) throws IOException {
this(out, 512);
this(out, 512, false);
}
/**
* Creates a new output stream with a default buffer size and
* the specified flush mode.
*
* @param out the output stream
* @param syncFlush
* if {@code true} invocation of the inherited
* {@link DeflaterOutputStream#flush() flush()} method of
* this instance flushes the compressor with flush mode
* {@link Deflater#SYNC_FLUSH} before flushing the output
* stream, otherwise only flushes the output stream
*
* @exception IOException If an I/O error has occurred.
*
* @since 1.7
*/
public GZIPOutputStream(OutputStream out, boolean syncFlush)
throws IOException
{
this(out, 512, syncFlush);
}
/**
@ -122,22 +179,19 @@ class GZIPOutputStream extends DeflaterOutputStream {
/*
* Writes GZIP member header.
*/
private final static byte[] header = {
(byte) GZIP_MAGIC, // Magic number (short)
(byte)(GZIP_MAGIC >> 8), // Magic number (short)
Deflater.DEFLATED, // Compression method (CM)
0, // Flags (FLG)
0, // Modification time MTIME (int)
0, // Modification time MTIME (int)
0, // Modification time MTIME (int)
0, // Modification time MTIME (int)
0, // Extra flags (XFLG)
0 // Operating system (OS)
};
private void writeHeader() throws IOException {
out.write(header);
out.write(new byte[] {
(byte) GZIP_MAGIC, // Magic number (short)
(byte)(GZIP_MAGIC >> 8), // Magic number (short)
Deflater.DEFLATED, // Compression method (CM)
0, // Flags (FLG)
0, // Modification time MTIME (int)
0, // Modification time MTIME (int)
0, // Modification time MTIME (int)
0, // Modification time MTIME (int)
0, // Extra flags (XFLG)
0 // Operating system (OS)
});
}
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2010, 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,7 +40,7 @@ class ZipException extends IOException {
private static final long serialVersionUID = 8000196834066748623L;
/**
* Constructs an <code>ZipException</code> with <code>null</code>
* Constructs a <code>ZipException</code> with <code>null</code>
* as its error detail message.
*/
public ZipException() {
@ -48,7 +48,7 @@ class ZipException extends IOException {
}
/**
* Constructs an <code>ZipException</code> with the specified detail
* Constructs a <code>ZipException</code> with the specified detail
* message.
*
* @param s the detail message.

View File

@ -58,25 +58,22 @@ input streams.
PKWARE ZIP File Format Specification</a> - Language Encoding Flag (EFS) to
encode ZIP entry filename and comment fields using UTF-8.
<p>
<li><a href="http://www.isi.edu/in-notes/rfc1950.txt">
<li><a href="http://www.ietf.org/rfc/rfc1950.txt">
ZLIB Compressed Data Format Specification version 3.3</a>
&nbsp;
<a href="http://www.isi.edu/in-notes/rfc1950.ps">
(PostScript)</a>
<a href="http://www.ietf.org/rfc/rfc1950.txt.pdf">(pdf)</a>
(RFC 1950)
<p>
<li><a href="http://www.isi.edu/in-notes/rfc1951.txt">
<li><a href="http://www.ietf.org/rfc/rfc1951.txt">
DEFLATE Compressed Data Format Specification version 1.3</a>
&nbsp;
<a href="http://www.isi.edu/in-notes/rfc1951.ps">
(PostScript)</a>
<a href="http://www.ietf.org/rfc/rfc1951.txt.pdf">(pdf)</a>
(RFC 1951)
<p>
<li><a href="http://www.isi.edu/in-notes/rfc1952.txt">
<li><a href="http://www.ietf.org/rfc/rfc1952.txt">
GZIP file format specification version 4.3</a>
&nbsp;
<a href="http://www.isi.edu/in-notes/rfc1952.ps">
(PostScript)</a>
<a href="http://www.ietf.org/rfc/rfc1952.txt.pdf">(pdf)</a>
(RFC 1952)
<p>
<li>CRC-32 checksum is described in RFC 1952 (above)

View File

@ -34,7 +34,7 @@ import javax.naming.directory.SearchControls;
* of events fired when objects named in a directory context changes.
*<p>
* The methods in this interface support identification of objects by
* <A HREF="ftp://ftp.isi.edu/in-notes/rfc2254.txt">RFC 2254</a>
* <A HREF="http://www.ietf.org/rfc/rfc2254.txt">RFC 2254</a>
* search filters.
*
*<P>Using the search filter, it is possible to register interest in objects

View File

@ -27,7 +27,7 @@ package javax.naming.ldap;
/**
* This interface represents an LDAPv3 control as defined in
* <A HREF="ftp://ftp.isi.edu/in-notes/rfc2251.txt">RFC 2251</A>.
* <A HREF="http://www.ietf.org/rfc/rfc2251.txt">RFC 2251</A>.
*<p>
* The LDAPv3 protocol uses controls to send and receive additional data
* to affect the behavior of predefined operations.

View File

@ -37,7 +37,7 @@ import com.sun.naming.internal.ResourceManager;
/**
* This abstract class represents a factory for creating LDAPv3 controls.
* LDAPv3 controls are defined in
* <A HREF="ftp://ftp.isi.edu/in-notes/rfc2251.txt">RFC 2251</A>.
* <A HREF="http://www.ietf.org/rfc/rfc2251.txt">RFC 2251</A>.
*<p>
* When a service provider receives a response control, it uses control
* factories to return the specific/appropriate control class implementation.

View File

@ -29,7 +29,7 @@ import javax.naming.NamingException;
/**
* This interface represents an LDAPv3 extended operation request as defined in
* <A HREF="ftp://ftp.isi.edu/in-notes/rfc2251.txt">RFC 2251</A>.
* <A HREF="http://www.ietf.org/rfc/rfc2251.txt">RFC 2251</A>.
* <pre>
* ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
* requestName [0] LDAPOID,

View File

@ -27,7 +27,7 @@ package javax.naming.ldap;
/**
* This interface represents an LDAP extended operation response as defined in
* <A HREF="ftp://ftp.isi.edu/in-notes/rfc2251.txt">RFC 2251</A>.
* <A HREF="http://www.ietf.org/rfc/rfc2251.txt">RFC 2251</A>.
* <pre>
* ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
* COMPONENTS OF LDAPResult,

View File

@ -29,7 +29,7 @@ import javax.naming.NamingException;
/**
* This interface represents an unsolicited notification as defined in
* <A HREF="ftp://ftp.isi.edu/in-notes/rfc2251.txt">RFC 2251</A>.
* <A HREF="http://www.ietf.org/rfc/rfc2251.txt">RFC 2251</A>.
* An unsolicited notification is sent by the LDAP server to the LDAP
* client without any provocation from the client.
* Its format is that of an extended response (<tt>ExtendedResponse</tt>).

View File

@ -30,7 +30,7 @@ import javax.naming.event.NamingListener;
/**
* This interface is for handling <tt>UnsolicitedNotificationEvent</tt>.
* "Unsolicited notification" is defined in
* <A HREF="ftp://ftp.isi.edu/in-notes/rfc2251.txt">RFC 2251</A>.
* <A HREF="http://www.ietf.org/rfc/rfc2251.txt">RFC 2251</A>.
* It allows the server to send unsolicited notifications to the client.
* A <tt>UnsolicitedNotificationListener</tt> must:
*<ol>

View File

@ -83,7 +83,7 @@ import java.io.Serializable;
* doc flavor's MIME type is one of the standard media types telling how to
* interpret the sequence of characters or bytes. For a list of standard media
* types, see the Internet Assigned Numbers Authority's (IANA's) <A
* HREF="http://www.isi.edu/in-notes/iana/assignments/media-types/">Media Types
* HREF="http://www.iana.org/assignments/media-types/">Media Types
* Directory</A>. Interface {@link Doc Doc} provides two utility operations,
* {@link Doc#getReaderForText() getReaderForText} and
* {@link Doc#getStreamForBytes() getStreamForBytes()}, to help a

View File

@ -25,9 +25,6 @@
package sun.jvmstat.monitor;
import sun.management.counter.Units;
import sun.management.counter.Variability;
/**
* The base class for Instrumentation Monitoring Objects. This base class
* provides implementations of the {@link Monitor} methods that are common

View File

@ -25,9 +25,6 @@
package sun.jvmstat.monitor;
import sun.management.counter.Units;
import sun.management.counter.Variability;
/**
* Interface provided by Instrumentation Monitoring Objects.
*

View File

@ -0,0 +1,128 @@
/*
* Copyright 2003-2004 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 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.
*/
package sun.jvmstat.monitor;
/**
* Provides a typesafe enumeration for describing units of measurement
* attribute for instrumentation objects.
*
* @author Brian Doherty
*/
public class Units implements java.io.Serializable {
/* The enumeration values for this typesafe enumeration must be
* kept in synchronization with the Units enum in the perfData.hpp file
* in the HotSpot source base.
*/
private static final int NUNITS=8;
private static Units[] map = new Units[NUNITS];
private final String name;
private final int value;
/**
* An Invalid Units value.
*/
public static final Units INVALID = new Units("Invalid", 0);
/**
* Units attribute representing unit-less quantities.
*/
public static final Units NONE = new Units("None", 1);
/**
* Units attribute representing Bytes.
*/
public static final Units BYTES = new Units("Bytes", 2);
/**
* Units attribute representing Ticks.
*/
public static final Units TICKS = new Units("Ticks", 3);
/**
* Units attribute representing a count of events.
*/
public static final Units EVENTS = new Units("Events", 4);
/**
* Units attribute representing String data. Although not really
* a unit of measure, this Units value serves to distinguish String
* instrumentation objects from instrumentation objects of other types.
*/
public static final Units STRING = new Units("String", 5);
/**
* Units attribute representing Hertz (frequency).
*/
public static final Units HERTZ = new Units("Hertz", 6);
/**
* Returns a string describing this Unit of measurement attribute
*
* @return String - a descriptive string for this enum.
*/
public String toString() {
return name;
}
/**
* Returns the integer representation of this Units attribute
*
* @return int - an integer representation of this Units attribute.
*/
public int intValue() {
return value;
}
/**
* Maps an integer value to its corresponding Units attribute.
* If the integer value does not have a corresponding Units enum
* value, then {@link Units#INVALID} is returned.
*
* @param value an integer representation of counter Units
* @return Units - the Units object for the given <code>value</code>
* or {@link Units#INVALID} if out of range.
*/
public static Units toUnits(int value) {
if (value < 0 || value >= map.length || map[value] == null) {
return INVALID;
}
return map[value];
}
private Units(String name, int value) {
this.name = name;
this.value = value;
map[value] = this;
}
private static final long serialVersionUID = 6992337162326171013L;
}

View File

@ -0,0 +1,111 @@
/*
* Copyright 2003-2004 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 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.
*/
package sun.jvmstat.monitor;
/**
* Provides a typesafe enumeration for the Variability attribute for
* instrumentation objects.
*
* @author Brian Doherty
*/
public class Variability implements java.io.Serializable {
/* The enumeration values for this typesafe enumeration must be
* kept in synchronization with the Variability enum in the perfData.hpp file
* in the HotSpot source base.
*/
private static final int NATTRIBUTES = 4;
private static Variability[] map = new Variability[NATTRIBUTES];
private String name;
private int value;
/**
* An invalid Variablity value.
*/
public static final Variability INVALID = new Variability("Invalid",0);
/**
* Variability attribute representing Constant counters.
*/
public static final Variability CONSTANT = new Variability("Constant",1);
/**
* Variability attribute representing a Monotonically changing counters.
*/
public static final Variability MONOTONIC = new Variability("Monotonic",2);
/**
* Variability attribute representing Variable counters.
*/
public static final Variability VARIABLE = new Variability("Variable",3);
/**
* Returns a string describing this Variability attribute.
*
* @return String - a descriptive string for this enum.
*/
public String toString() {
return name;
}
/**
* Returns the integer representation of this Variability attribute.
*
* @return int - an integer representation of this Variability attribute.
*/
public int intValue() {
return value;
}
/**
* Maps an integer value its corresponding Variability attribute.
* If the integer value does not have a corresponding Variability enum
* value, the {@link Variability#INVALID} is returned
*
* @param value an integer representation of a Variability attribute
* @return Variability - The Variability object for the given
* <code>value</code> or {@link Variability#INVALID}
* if out of range.
*/
public static Variability toVariability(int value) {
if (value < 0 || value >= map.length || map[value] == null) {
return INVALID;
}
return map[value];
}
private Variability(String name, int value) {
this.name = name;
this.value = value;
map[value]=this;
}
private static final long serialVersionUID = 6992337162326171013L;
}

View File

@ -26,8 +26,6 @@
package sun.jvmstat.perfdata.monitor;
import sun.jvmstat.monitor.*;
import sun.management.counter.Units;
import sun.management.counter.Variability;
import java.nio.ByteBuffer;
/**

View File

@ -26,8 +26,6 @@
package sun.jvmstat.perfdata.monitor;
import sun.jvmstat.monitor.*;
import sun.management.counter.Units;
import sun.management.counter.Variability;
import java.nio.IntBuffer;
/**

View File

@ -26,8 +26,6 @@
package sun.jvmstat.perfdata.monitor;
import sun.jvmstat.monitor.*;
import sun.management.counter.Units;
import sun.management.counter.Variability;
import java.nio.LongBuffer;
/**

View File

@ -26,7 +26,6 @@
package sun.jvmstat.perfdata.monitor;
import sun.jvmstat.monitor.*;
import sun.management.counter.Variability;
import java.nio.ByteBuffer;
/**

View File

@ -26,8 +26,6 @@
package sun.jvmstat.perfdata.monitor;
import sun.jvmstat.monitor.*;
import sun.management.counter.Units;
import sun.management.counter.Variability;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;

View File

@ -26,7 +26,6 @@
package sun.jvmstat.perfdata.monitor;
import sun.jvmstat.monitor.*;
import sun.management.counter.Variability;
import java.nio.ByteBuffer;
/**

View File

@ -25,8 +25,6 @@
package sun.jvmstat.perfdata.monitor.v1_0;
import sun.management.counter.Units;
import sun.management.counter.Variability;
import sun.jvmstat.monitor.*;
import sun.jvmstat.perfdata.monitor.*;
import java.util.*;

View File

@ -27,8 +27,6 @@ package sun.jvmstat.perfdata.monitor.v2_0;
import sun.jvmstat.monitor.*;
import sun.jvmstat.perfdata.monitor.*;
import sun.management.counter.Units;
import sun.management.counter.Variability;
import java.util.*;
import java.util.regex.*;
import java.nio.*;

View File

@ -44,20 +44,17 @@ final class CompletedFuture<V> implements Future<V> {
this.exc = exc;
}
@SuppressWarnings("unchecked")
static <V> CompletedFuture<V> withResult(V result) {
return new CompletedFuture<V>(result, null);
}
@SuppressWarnings("unchecked")
static <V> CompletedFuture<V> withFailure(Throwable exc) {
// exception must be IOException or SecurityException
if (!(exc instanceof IOException) && !(exc instanceof SecurityException))
exc = new IOException(exc);
return new CompletedFuture(null, exc);
return new CompletedFuture<V>(null, exc);
}
@SuppressWarnings("unchecked")
static <V> CompletedFuture<V> withResult(V result, Throwable exc) {
if (exc == null) {
return withResult(result);

View File

@ -429,7 +429,7 @@ public class BatchEnvironment extends sun.tools.javac.BatchEnvironment {
st.hasMoreTokens();) {
String elt = st.nextToken();
if (jarParent != null)
elt = new File(jarParent, elt).toString();
elt = new File(jarParent, elt).getCanonicalPath();
addFile(elt, warn);
}
} finally {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2010, 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
@ -344,16 +344,13 @@ public class KrbAsReq extends KrbKdcReq {
princName = cname;
EncryptionKey key = null;
int[] tktETypes = null;
int[] tktETypes = EType.getDefaults("default_tkt_enctypes");
if (pa_exists && pa_etype != EncryptedData.ETYPE_NULL) {
if (DEBUG) {
System.out.println("Pre-Authenticaton: find key for etype = " + pa_etype);
}
key = EncryptionKey.findKey(pa_etype, keys);
tktETypes = new int[1];
tktETypes[0] = pa_etype;
} else {
tktETypes = EType.getDefaults("default_tkt_enctypes", keys);
key = EncryptionKey.findKey(tktETypes[0], keys);
}

View File

@ -57,11 +57,20 @@ import java.io.IOException;
* specification available at
* <a href="http://www.ietf.org/rfc/rfc4120.txt">
* http://www.ietf.org/rfc/rfc4120.txt</a>.
*
* The implementation also includes the microseconds info so that the
* same class can be used as a precise timestamp in Authenticator etc.
*/
public class KerberosTime implements Cloneable {
private long kerberosTime; // milliseconds since epoch, a Date.getTime() value
private int microSeconds; // the last three digits of the microsecond value
// The time when this class is loaded. Used in setNow()
private static final long initMilli = System.currentTimeMillis();
private static final long initMicro = System.nanoTime() / 1000;
private static long syncTime;
private static boolean DEBUG = Krb5.DEBUG;
@ -77,9 +86,13 @@ public class KerberosTime implements Cloneable {
kerberosTime = time;
}
private KerberosTime(long time, int micro) {
kerberosTime = time;
microSeconds = micro;
}
public Object clone() {
return new KerberosTime(kerberosTime);
return new KerberosTime(kerberosTime, microSeconds);
}
// This constructor is used in the native code
@ -109,8 +122,8 @@ public class KerberosTime implements Cloneable {
// | | | | | | |
// 0 4 6 8 | | |
// 10 | |
// 12 |
// 14
// 12 |
// 14
if (time.length() != 15)
throw new Asn1Exception(Krb5.ASN1_BAD_TIMEFORMAT);
@ -148,11 +161,8 @@ public class KerberosTime implements Cloneable {
public KerberosTime(boolean initToNow) {
if (initToNow) {
Date temp = new Date();
setTime(temp);
setNow();
}
else
kerberosTime = 0;
}
/**
@ -192,10 +202,12 @@ public class KerberosTime implements Cloneable {
public void setTime(Date time) {
kerberosTime = time.getTime(); // (time.getTimezoneOffset() * 60000L);
microSeconds = 0;
}
public void setTime(long time) {
kerberosTime = time;
microSeconds = 0;
}
public Date toDate() {
@ -205,16 +217,18 @@ public class KerberosTime implements Cloneable {
}
public void setNow() {
Date temp = new Date();
setTime(temp);
long microElapsed = System.nanoTime() / 1000 - initMicro;
setTime(initMilli + microElapsed/1000);
microSeconds = (int)(microElapsed % 1000);
}
public int getMicroSeconds() {
Long temp_long = new Long((kerberosTime % 1000L) * 1000L);
return temp_long.intValue();
return temp_long.intValue() + microSeconds;
}
public void setMicroSeconds(int usec) {
microSeconds = usec % 1000;
Integer temp_int = new Integer(usec);
long temp_long = temp_int.longValue() / 1000L;
kerberosTime = kerberosTime - (kerberosTime % 1000L) + temp_long;
@ -222,6 +236,7 @@ public class KerberosTime implements Cloneable {
public void setMicroSeconds(Integer usec) {
if (usec != null) {
microSeconds = usec.intValue() % 1000;
long temp_long = usec.longValue() / 1000L;
kerberosTime = kerberosTime - (kerberosTime % 1000L) + temp_long;
}
@ -262,7 +277,9 @@ public class KerberosTime implements Cloneable {
}
public boolean greaterThan(KerberosTime time) {
return kerberosTime > time.kerberosTime;
return kerberosTime > time.kerberosTime ||
kerberosTime == time.kerberosTime &&
microSeconds > time.microSeconds;
}
public boolean equals(Object obj) {
@ -274,15 +291,17 @@ public class KerberosTime implements Cloneable {
return false;
}
return kerberosTime == ((KerberosTime)obj).kerberosTime;
return kerberosTime == ((KerberosTime)obj).kerberosTime &&
microSeconds == ((KerberosTime)obj).microSeconds;
}
public int hashCode() {
return 37 * 17 + (int)(kerberosTime ^ (kerberosTime >>> 32));
int result = 37 * 17 + (int)(kerberosTime ^ (kerberosTime >>> 32));
return result * 17 + microSeconds;
}
public boolean isZero() {
return kerberosTime == 0;
return kerberosTime == 0 && microSeconds == 0;
}
public int getSeconds() {

View File

@ -518,6 +518,7 @@ public class X509Factory extends CertificateFactorySpi {
// Step 2: Read the rest of header, determine the line end
int end;
StringBuffer header = new StringBuffer("-----");
while (true) {
int next = is.read();
if (next == -1) {
@ -540,6 +541,7 @@ public class X509Factory extends CertificateFactorySpi {
}
break;
}
header.append((char)next);
}
// Step 3: Read the data
@ -559,6 +561,7 @@ public class X509Factory extends CertificateFactorySpi {
}
// Step 4: Consume the footer
StringBuffer footer = new StringBuffer("-");
while (true) {
int next = is.read();
// Add next == '\n' for maximum safety, in case endline
@ -566,13 +569,34 @@ public class X509Factory extends CertificateFactorySpi {
if (next == -1 || next == end || next == '\n') {
break;
}
if (next != '\r') footer.append((char)next);
}
checkHeaderFooter(header.toString(), footer.toString());
BASE64Decoder decoder = new BASE64Decoder();
return decoder.decodeBuffer(new String(data, 0, pos));
}
}
private static void checkHeaderFooter(String header,
String footer) throws IOException {
if (header.length() < 16 || !header.startsWith("-----BEGIN ") ||
!header.endsWith("-----")) {
throw new IOException("Illegal header: " + header);
}
if (footer.length() < 14 || !footer.startsWith("-----END ") ||
!footer.endsWith("-----")) {
throw new IOException("Illegal footer: " + footer);
}
String headerType = header.substring(11, header.length()-5);
String footerType = footer.substring(9, footer.length()-5);
if (!headerType.equals(footerType)) {
throw new IOException("Header and footer do not match: " +
header + " " + footer);
}
}
/**
* Read one BER data block. This method is aware of indefinite-length BER
* encoding and will read all of the sub-sections in a recursive way

View File

@ -1486,7 +1486,7 @@ public class JarSigner {
for (int i=0; i<len; i++) {
switch (bs[i]) {
case '\r':
if (i < len && bs[i+1] == '\n') i++;
if (i < len - 1 && bs[i+1] == '\n') i++;
// fallthrough
case '\n':
if (newline) return i+1; //+1 to get length

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2010, 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 @@
* questions.
*/
package sun.security.tools;
package sun.security.tools.policytool;
import java.io.*;
import java.util.LinkedList;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2010, 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
@ -155,12 +155,15 @@ public final class PKIXValidator extends Validator {
X500Principal prevIssuer = null;
for (int i = 0; i < chain.length; i++) {
X509Certificate cert = chain[i];
X500Principal dn = cert.getSubjectX500Principal();
if (i != 0 &&
!cert.getSubjectX500Principal().equals(prevIssuer)) {
!dn.equals(prevIssuer)) {
// chain is not ordered correctly, call builder instead
return doBuild(chain, otherCerts);
}
if (trustedCerts.contains(cert)) {
if (trustedSubjects.containsKey(dn)
&& trustedSubjects.get(dn).getPublicKey()
.equals(cert.getPublicKey())) {
if (i == 0) {
return new X509Certificate[] {chain[0]};
}

View File

@ -306,28 +306,28 @@ class Main {
for (int i = 0; i < flags.length(); i++) {
switch (flags.charAt(i)) {
case 'c':
if (xflag || tflag || uflag) {
if (xflag || tflag || uflag || iflag) {
usageError();
return false;
}
cflag = true;
break;
case 'u':
if (cflag || xflag || tflag) {
if (cflag || xflag || tflag || iflag) {
usageError();
return false;
}
uflag = true;
break;
case 'x':
if (cflag || uflag || tflag) {
if (cflag || uflag || tflag || iflag) {
usageError();
return false;
}
xflag = true;
break;
case 't':
if (cflag || uflag || xflag) {
if (cflag || uflag || xflag || iflag) {
usageError();
return false;
}
@ -349,6 +349,10 @@ class Main {
flag0 = true;
break;
case 'i':
if (cflag || uflag || xflag || tflag) {
usageError();
return false;
}
// do not increase the counter, files will contain rootjar
rootjar = args[count++];
iflag = true;

View File

@ -26,7 +26,6 @@
package sun.tools.jstat;
import sun.jvmstat.monitor.*;
import sun.management.counter.Variability;
/**
* A class implementing the ExpressionEvaluator to resolve unresolved

View File

@ -29,8 +29,6 @@ import java.util.*;
import java.io.*;
import sun.jvmstat.monitor.*;
import sun.jvmstat.monitor.event.*;
import sun.management.counter.Units;
import sun.management.counter.Variability;
import java.util.regex.PatternSyntaxException;
/**

View File

@ -28,8 +28,6 @@ package sun.tools.jstat;
import java.util.*;
import sun.jvmstat.monitor.*;
import sun.jvmstat.monitor.event.*;
import sun.management.counter.Variability;
import sun.management.counter.Units;
/**
* Application to output jvmstat statistics exported by a target Java

View File

@ -37,11 +37,14 @@ GET=
AWK = awk
CAT = cat
CD = cd
CHMOD = chmod
CP = cp
CUT = cut
DIRNAME = dirname
ECHO = echo
EGREP = egrep
EXPAND = expand
FIND = find
MKDIR = mkdir
PWD = pwd
SED = sed
@ -76,21 +79,25 @@ ifeq ($(UNAME_S), Linux)
endif
OS_VERSION := $(shell $(UNAME) -r)
endif
ifndef OS_NAME
ifneq ($(PROCESSOR_IDENTIFIER), )
OS_NAME = windows
SLASH_JAVA = J:
# A variety of ways to say X64 arch :^(
OS_ARCH:=$(word 1, $(PROCESSOR_IDENTIFIER))
EXESUFFIX = .exe
# These need to be different depending on MKS or CYGWIN
ifeq ($(findstring cygdrive,$(shell ($(CD) C:/ && $(PWD)))), )
GETMIXEDPATH = dosname -s
OS_VERSION := $(shell $(UNAME) -r)
else
GETMIXEDPATH = cygpath -m -s
OS_VERSION := $(shell $(UNAME) -s | $(CUT) -d'-' -f2)
endif
ifeq ($(OS_NAME),)
OS_NAME = windows
# GNU Make or MKS overrides $(PROCESSOR_ARCHITECTURE) to always
# return "x86". Use the first word of $(PROCESSOR_IDENTIFIER) instead.
ifeq ($(PROCESSOR_IDENTIFIER),)
PROC_ARCH:=$(shell $(UNAME) -m)
else
PROC_ARCH:=$(word 1, $(PROCESSOR_IDENTIFIER))
endif
OS_ARCH:=$(PROC_ARCH)
SLASH_JAVA = J:
EXESUFFIX = .exe
# These need to be different depending on MKS or CYGWIN
ifeq ($(findstring cygdrive,$(shell ($(CD) C:/ && $(PWD)))), )
GETMIXEDPATH = dosname -s
OS_VERSION := $(shell $(UNAME) -r)
else
GETMIXEDPATH = cygpath -m -s
OS_VERSION := $(shell $(UNAME) -s | $(CUT) -d'-' -f2)
endif
endif
@ -107,22 +114,27 @@ OS_ARCH2-amd64:=x64
#OS_ARCH2-x64:=amd64
# Try and use the arch names consistently
OS_ARCH:=$(subst x64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(subst X64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(subst AMD64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(subst amd64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(subst x86_64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(subst EM64T,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(subst em64t,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(subst intel64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(subst Intel64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(subst INTEL64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(subst IA64,ia64,$(OS_ARCH))
OS_ARCH:=$(subst X86,i586,$(OS_ARCH))
OS_ARCH:=$(subst x86,i586,$(OS_ARCH))
OS_ARCH:=$(subst i386,i586,$(OS_ARCH))
OS_ARCH:=$(subst i486,i586,$(OS_ARCH))
OS_ARCH:=$(subst i686,i586,$(OS_ARCH))
OS_ARCH:=$(patsubst x64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(patsubst X64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(patsubst AMD64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(patsubst amd64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(patsubst x86_64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(patsubst 8664,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(patsubst EM64T,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(patsubst em64t,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(patsubst intel64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(patsubst Intel64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(patsubst INTEL64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
OS_ARCH:=$(patsubst IA64,ia64,$(OS_ARCH))
OS_ARCH:=$(patsubst X86,i586,$(OS_ARCH))
OS_ARCH:=$(patsubst x86,i586,$(OS_ARCH))
OS_ARCH:=$(patsubst i386,i586,$(OS_ARCH))
OS_ARCH:=$(patsubst i486,i586,$(OS_ARCH))
OS_ARCH:=$(patsubst i686,i586,$(OS_ARCH))
OS_ARCH:=$(patsubst 386,i586,$(OS_ARCH))
OS_ARCH:=$(patsubst 486,i586,$(OS_ARCH))
OS_ARCH:=$(patsubst 586,i586,$(OS_ARCH))
OS_ARCH:=$(patsubst 686,i586,$(OS_ARCH))
# Default ARCH_DATA_MODEL settings
ARCH_DATA_MODEL-i586 = 32
@ -234,6 +246,11 @@ ifeq ($(OS_NAME),solaris)
endif
endif
# Macro to run make and set the shared library permissions
define SharedLibraryPermissions
$(MAKE) SHARED_LIBRARY_DIR=$1 UNIQUE_DIR=$@ shared_library_permissions
endef
# Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results)
ARCHIVE_BUNDLE = $(ABS_TEST_OUTPUT_DIR)/ARCHIVE_BUNDLE.zip
ifdef JPRT_ARCHIVE_BUNDLE
@ -242,7 +259,7 @@ endif
# 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.
ZIP_UP_RESULTS = ( $(MKDIR) -p `dirname $(ARCHIVE_BUNDLE)` \
ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` \
&& $(CD) $(ABS_TEST_OUTPUT_DIR) \
&& $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )
SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport/text/summary.txt
@ -483,6 +500,7 @@ jdk_nio1: java/nio/file
JDK_ALL_TARGETS += jdk_nio2
jdk_nio2: java/nio/Buffer java/nio/ByteOrder \
java/nio/channels java/nio/BufferPoolMXBean java/nio/MappedByteBuffer
$(call SharedLibraryPermissions,java/nio/channels)
$(call RunOthervmBatch)
# Stable othervm testruns (minus items from PROBLEM_LIST)
@ -516,6 +534,7 @@ jdk_security2: javax/crypto com/sun/crypto
# Using samevm has serious problems with these tests
JDK_ALL_TARGETS += jdk_security3
jdk_security3: com/sun/security lib/security javax/security sun/security
$(call SharedLibraryPermissions,sun/security)
$(call RunOthervmBatch)
# All security tests
@ -542,6 +561,7 @@ jdk_tools1: com/sun/jdi
# Using samevm has serious problems with these tests
JDK_ALL_TARGETS += jdk_tools2
jdk_tools2: com/sun/tools sun/jvmstat sun/tools tools vm com/sun/servicetag com/sun/tracing
$(call SharedLibraryPermissions,tools/launcher)
$(call RunOthervmBatch)
# All tools tests
@ -611,7 +631,26 @@ jtreg_tests: prep $(PRODUCT_HOME) $(JTREG) $(EXCLUDELIST)
) ; $(BUNDLE_UP_AND_EXIT) \
) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT)
PHONY_LIST += jtreg_tests
# Rule that may change execute permissions on shared library files.
# Files in repositories should never have execute permissions, but there
# are some tests that have pre-built shared libraries, and these windows
# dll files must have execute permission. Adding execute permission
# may happen automatically on windows when using certain versions of mercurial
# but it cannot be guaranteed. And blindly adding execute permission might
# be seen as a mercurial 'change', so we avoid adding execute permission to
# repository files. But testing from a plain source tree needs the chmod a+rx.
# Used on select directories and applying the chmod to all shared libraries
# not just dll files. On windows, this may not work with MKS if the files
# were installed with CYGWIN unzip or untar (MKS chmod may not do anything).
# And with CYGWIN and sshd service, you may need CYGWIN=ntsec for this to work.
#
shared_library_permissions: $(SHARED_LIBRARY_DIR)
if [ ! -d $(TEST_ROOT)/../.hg ] ; then \
$(FIND) $< \( -name \*.dll -o -name \*.DLL -o -name \*.so \) \
-exec $(CHMOD) a+rx {} \; ; \
fi
PHONY_LIST += jtreg_tests shared_library_permissions
################################################################
@ -644,7 +683,7 @@ PHONY_LIST += packtest packtest_stress
# perftest to collect statistics
# Expect JPRT to set JPRT_PACKTEST_HOME.
PERFTEST_HOME = ${TEST_ROOT}/perf
PERFTEST_HOME = $(TEST_ROOT)/perf
ifdef JPRT_PERFTEST_HOME
PERFTEST_HOME = $(JPRT_PERFTEST_HOME)
endif

View File

@ -356,10 +356,6 @@ java/lang/management/ThreadMXBean/ThreadStateTest.java generic-all
# RuntimeException: Uptime of the JVM is more than 30 minutes (32 minutes).
java/lang/management/RuntimeMXBean/UpTime.java generic-all
# Times out on solaris sparc occasionally, in samevm mode
java/lang/Runtime/exec/ExecWithDir.java generic-all
java/lang/ProcessBuilder/Basic.java generic-all
# Solaris sparc, samevm, java.lang.Exception: Read from closed pipe hangs
java/lang/Runtime/exec/SleepyCat.java generic-all
@ -431,6 +427,18 @@ java/lang/ClassLoader/deadlock/TestCrossDelegate.sh generic-all
# jdk_management
# Access denied messages on windows/mks, filed 6954450
sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh windows-all
# Filed 6951284, fails on linux 64bit Fedora 9, peak thread count differences
java/lang/management/ThreadMXBean/ResetPeakThreadCount.java generic-all
# Started failing on linux and solaris (filed 6950927)
# com.sun.tools.attach.AttachNotSupportedException:
# Unable to open socket file:
# target process not responding or HotSpot VM not loaded
sun/management/jmxremote/bootstrap/JvmstatCountersTest.java generic-all
# Fails on linux: KO: StringMonitor notification missed or not emitted
javax/management/monitor/NonComparableAttributeValueTest.java generic-all
@ -935,6 +943,19 @@ java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java generic-all
# jdk_security
# Filed 6951285, not sure how often this fails, last was Linux 64bit Fedora 9
sun/security/krb5/auto/MaxRetries.java generic-all
# Filed 6950930, fails on windows 32bit c1 and windows 64bit
sun/security/krb5/auto/IgnoreChannelBinding.java windows-all
# Filed 6950931, failing on all windows systems
sun/security/tools/jarsigner/crl.sh windows-all
# Filed 6950929, only seemed to fail on solaris sparcv9 (-d64)
# Failed on Linux -server 32bit too, making generic
sun/security/krb5/auto/BadKdc4.java generic-all
# Failing on Solaris i586, 3/9/2010, not a -samevm issue (jdk_security3)
sun/security/pkcs11/Secmod/AddPrivateKey.java solaris-i586
sun/security/pkcs11/ec/ReadCertificates.java solaris-i586
@ -986,12 +1007,6 @@ sun/security/krb5/auto/ok-as-delegate-xrealm.sh generic-all
# Fails on Windows 2000, ExceptionInInitializerError
sun/security/mscapi/AccessKeyStore.sh generic-all
# Fails on Windows 2000, UnsatisfiedLinkError: libnspr4.dll: Access is denied
sun/security/pkcs11/KeyAgreement/TestDH.java generic-all
# Fails on Windows 2000, UnsatisfiedLinkError: libnspr4.dll: Access is denied
sun/security/pkcs11/fips/ClientJSSEServerJSSE.java generic-all
# Fails on Solaris 10, KrbException: Additional pre-authentication required (25)
sun/security/krb5/auto/basic.sh generic-all
@ -1022,10 +1037,6 @@ com/sun/crypto/provider/Cipher/DES/PaddingTest.java generic-all
# Othervm, sparc, NoRouteToHostException: Cannot assign requested address
sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java generic-all
# ProviderException: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
# Does not seem to run on windows machines? dll missing?
sun/security/pkcs11/rsa/TestKeyPairGenerator.java generic-all
# Times out on windows X64, othervm mode
# Solaris sparc and sparcv9 -server, timeout
sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java generic-all
@ -1041,7 +1052,6 @@ sun/security/ssl/sanity/ciphersuites/CheckCipherSuites.java generic-all
sun/security/tools/jarsigner/oldsig.sh generic-all
# Various failures on Linux Fedora 9 X64, othervm mode
# Does not seem to run on windows machines? dll missing?
sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java generic-all
# Linux i586 -server, buffer too short to hold shared secret?
@ -1078,9 +1088,6 @@ java/security/Signature/TestInitSignWithMyOwnRandom.java generic-all
java/security/UnresolvedPermission/AccessorMethods.java generic-all
java/security/UnresolvedPermission/Equals.java generic-all
# Do not seem to run on windows machines? dll missing?
sun/security/krb5/auto/IgnoreChannelBinding.java windows-all
# Fails on OpenSolaris, missing classes, slow on Solaris sparc
sun/security/ec/TestEC.java generic-all
@ -1088,65 +1095,12 @@ sun/security/ec/TestEC.java generic-all
sun/security/mscapi/IsSunMSCAPIAvailable.sh windows-x64
sun/security/mscapi/RSAEncryptDecrypt.sh windows-x64
# Do not seem to run on windows machines? dll missing?
sun/security/pkcs11/Cipher/ReinitCipher.java windows-all
sun/security/pkcs11/Cipher/TestRSACipher.java windows-all
sun/security/pkcs11/Cipher/TestRSACipherWrap.java windows-all
sun/security/pkcs11/Cipher/TestSymmCiphers.java windows-all
sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java windows-all
# Do not seem to run on windows machines? dll missing?
sun/security/pkcs11/ec/ReadCertificates.java windows-all
sun/security/pkcs11/ec/ReadPKCS12.java windows-all
sun/security/pkcs11/ec/TestCurves.java windows-all
sun/security/pkcs11/ec/TestECDH.java windows-all
sun/security/pkcs11/ec/TestECDSA.java windows-all
sun/security/pkcs11/ec/TestECGenSpec.java windows-all
sun/security/pkcs11/ec/TestKeyFactory.java windows-all
sun/security/pkcs11/fips/TrustManagerTest.java windows-all
# Do not seem to run on windows machines? dll missing?
sun/security/pkcs11/KeyAgreement/TestShort.java windows-all
sun/security/pkcs11/KeyGenerator/DESParity.java windows-all
# Exception in test solaris-sparc -client -server, no windows
sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java windows-all solaris-all
# Do not seem to run on windows machines? dll missing?
sun/security/pkcs11/KeyStore/Basic.sh windows-all
sun/security/pkcs11/KeyStore/ClientAuth.sh windows-all
sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java solaris-all
# Solaris sparc client, fails to compile?
sun/security/pkcs11/KeyStore/SecretKeysBasic.sh solaris-all
# Do not seem to run on windows machines? dll missing?
sun/security/pkcs11/Mac/ReinitMac.java windows-all
sun/security/pkcs11/MessageDigest/ByteBuffers.java windows-all
sun/security/pkcs11/MessageDigest/DigestKAT.java windows-all
sun/security/pkcs11/MessageDigest/ReinitDigest.java windows-all
sun/security/pkcs11/Provider/ConfigQuotedString.sh windows-all
sun/security/pkcs11/Provider/Login.sh windows-all
sun/security/pkcs11/rsa/KeyWrap.java windows-all
sun/security/pkcs11/rsa/TestCACerts.java windows-all
sun/security/pkcs11/rsa/TestKeyFactory.java windows-all
sun/security/pkcs11/rsa/TestSignatures.java windows-all
sun/security/pkcs11/SampleTest.java windows-all
sun/security/pkcs11/Secmod/AddPrivateKey.java windows-all
sun/security/pkcs11/Secmod/AddTrustedCert.java windows-all
sun/security/pkcs11/Secmod/Crypto.java windows-all
sun/security/pkcs11/Secmod/GetPrivateKey.java windows-all
sun/security/pkcs11/Secmod/JksSetPrivateKey.java windows-all
sun/security/pkcs11/Secmod/TrustAnchors.java windows-all
sun/security/pkcs11/SecureRandom/Basic.java windows-all
sun/security/pkcs11/Serialize/SerializeProvider.java windows-all
sun/security/pkcs11/Signature/ByteBuffers.java windows-all
sun/security/pkcs11/Signature/ReinitSignature.java windows-all
sun/security/pkcs11/Signature/TestDSA.java windows-all
sun/security/pkcs11/tls/TestKeyMaterial.java windows-all
sun/security/pkcs11/tls/TestMasterSecret.java windows-all
sun/security/pkcs11/tls/TestPremaster.java windows-all
sun/security/pkcs11/tls/TestPRF.java windows-all
# Fails on OpenSolaris java.net.BindException: Address already in use
sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java generic-all
@ -1188,6 +1142,9 @@ java/text/Bidi/Bug6665028.java linux-x64
# jdk_tools
# Filed bug 6951287, failed on Linux 64bit, sometimes?
com/sun/jdi/PopAndInvokeTest.java generic-all
# Some of the tools tests kind of require "othervm" or if they don't will
# always be firing up another VM anyway due to the nature of tools testing.
# So most if not all tools tests are now being run with "othervm" mode.

View File

@ -0,0 +1,105 @@
/**
* @test
* @bug 6945564
* @summary Check that the j.l.Character.UnicodeScript
* @ignore don't run until #6903266 is integrated
*/
import java.io.*;
import java.lang.reflect.*;
import java.util.*;
import java.util.regex.*;
import java.lang.Character.UnicodeScript;
public class CheckScript {
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.out.println("java CharacterScript script.txt");
System.exit(1);
}
BufferedReader sbfr = new BufferedReader(new FileReader(args[0]));
Matcher m = Pattern.compile("(\\p{XDigit}+)(?:\\.{2}(\\p{XDigit}+))?\\s+;\\s+(\\w+)\\s+#.*").matcher("");
String line = null;
HashMap<String,ArrayList<Integer>> scripts = new HashMap<>();
while ((line = sbfr.readLine()) != null) {
if (line.length() <= 1 || line.charAt(0) == '#') {
continue;
}
m.reset(line);
if (m.matches()) {
int start = Integer.parseInt(m.group(1), 16);
int end = (m.group(2)==null)?start
:Integer.parseInt(m.group(2), 16);
String name = m.group(3).toLowerCase(Locale.ENGLISH);
ArrayList<Integer> ranges = scripts.get(name);
if (ranges == null) {
ranges = new ArrayList<Integer>();
scripts.put(name, ranges);
}
ranges.add(start);
ranges.add(end);
}
}
sbfr.close();
// check all defined ranges
Integer[] ZEROSIZEARRAY = new Integer[0];
for (String name : scripts.keySet()) {
System.out.println("Checking " + name + "...");
Integer[] ranges = scripts.get(name).toArray(ZEROSIZEARRAY);
Character.UnicodeScript expected =
Character.UnicodeScript.forName(name);
int off = 0;
while (off < ranges.length) {
int start = ranges[off++];
int end = ranges[off++];
for (int cp = start; cp <= end; cp++) {
Character.UnicodeScript script =
Character.UnicodeScript.of(cp);
if (script != expected) {
throw new RuntimeException(
"UnicodeScript failed: cp=" +
Integer.toHexString(cp) +
", of(cp)=<" + script + "> but <" +
expected + "> is expected");
}
}
}
}
// check all codepoints
for (int cp = 0; cp < Character.MAX_CODE_POINT; cp++) {
Character.UnicodeScript script = Character.UnicodeScript.of(cp);
if (script == Character.UnicodeScript.UNKNOWN) {
if (Character.getType(cp) != Character.UNASSIGNED &&
Character.getType(cp) != Character.SURROGATE &&
Character.getType(cp) != Character.PRIVATE_USE)
throw new RuntimeException(
"UnicodeScript failed: cp=" +
Integer.toHexString(cp) +
", of(cp)=<" + script + "> but UNKNOWN is expected");
} else {
Integer[] ranges =
scripts.get(script.name().toLowerCase(Locale.ENGLISH))
.toArray(ZEROSIZEARRAY);
int off = 0;
boolean found = false;
while (off < ranges.length) {
int start = ranges[off++];
int end = ranges[off++];
if (cp >= start && cp <= end)
found = true;
}
if (!found) {
throw new RuntimeException(
"UnicodeScript failed: cp=" +
Integer.toHexString(cp) +
", of(cp)=<" + script +
"> but NOT in ranges of this script");
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,7 @@
* 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958
* 4947220
* @summary Basic tests for Process and Environment Variable code
* @run main/othervm Basic
* @run main/othervm/timeout=300 Basic
* @author Martin Buchholz
*/

View File

@ -23,6 +23,7 @@
/* @test
* @bug 4750978
* @run main/othervm/timeout=300 ExecWithDir
* @summary Ensure that we can fork-and-exec repeatedly when a new working
* directory is specified
*/

View File

@ -0,0 +1,85 @@
/*
* Copyright 2010 Google 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 6952330
* @summary Test StringBuffer/StringBuilder capacity handling.
*/
import java.util.Random;
public class Capacity {
void test(String[] args) throws Throwable {
Random rnd = new Random();
int[] sizes = { 0, 1, rnd.nextInt(10), rnd.nextInt(1000) };
for (int size : sizes) {
equal(16, new StringBuffer().capacity());
equal(16, new StringBuilder().capacity());
StringBuffer buff = new StringBuffer(size);
StringBuilder bild = new StringBuilder(size);
equal(size, buff.capacity());
equal(size, bild.capacity());
buff.ensureCapacity(size);
bild.ensureCapacity(size);
equal(size, buff.capacity());
equal(size, bild.capacity());
buff.ensureCapacity(size+1);
bild.ensureCapacity(size+1);
equal(size*2+2, buff.capacity());
equal(size*2+2, bild.capacity());
size = buff.capacity();
buff.ensureCapacity(size*2+1);
bild.ensureCapacity(size*2+1);
equal(size*2+2, buff.capacity());
equal(size*2+2, bild.capacity());
size = buff.capacity();
int newSize = size * 2 + 3;
buff.ensureCapacity(newSize);
bild.ensureCapacity(newSize);
equal(newSize, buff.capacity());
equal(newSize, bild.capacity());
buff.ensureCapacity(0);
bild.ensureCapacity(0);
equal(newSize, buff.capacity());
equal(newSize, bild.capacity());
}
}
//--------------------- Infrastructure ---------------------------
volatile int passed = 0, failed = 0;
void pass() {passed++;}
void fail() {failed++; Thread.dumpStack();}
void fail(String msg) {System.err.println(msg); fail();}
void unexpected(Throwable t) {failed++; t.printStackTrace();}
void check(boolean cond) {if (cond) pass(); else fail();}
void equal(Object x, Object y) {
if (x == null ? y == null : x.equals(y)) pass();
else fail(x + " not equal to " + y);}
public static void main(String[] args) throws Throwable {
new Capacity().instanceMain(args);}
public void instanceMain(String[] args) throws Throwable {
try {test(args);} catch (Throwable t) {unexpected(t);}
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
if (failed > 0) throw new AssertionError("Some tests failed");}
}

View File

@ -1091,6 +1091,7 @@ public class Test {
test("").p("").sp("").z();
header("Emptiness");
// Components that may be empty
@ -1321,6 +1322,11 @@ public class Test {
.sp("//host/foo%20bar/a/b/c/resolve").s("http")
.pd("/foo bar/a/b/c/resolve").h("host")
.p("/foo%20bar/a/b/c/resolve").z();
// 6773270: java.net.URI fails to escape u0000
test("s", "a", "/\u0000", null)
.s("s").p("/%00").h("a")
.ta("s://a/%00").z();
}

View File

@ -0,0 +1,80 @@
/*
* Copyright (c) 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 6948781
* @summary CertificateFactory.generateCertificate doesn't throw
* CertificateException for malformed certificate
*/
import java.io.ByteArrayInputStream;
import java.security.cert.CertificateFactory;
import java.security.cert.CertificateException;
public class BadFooter {
public static void main(String[] args) throws Exception {
// The two sections below are identical, a self-signed cert generated
// for a fake principal:
// CN=Me, OU=Office, O=A-B-C, L=Backside, ST=Moon, C=EA
String cert =
"-----BEGIN CERTIFICATE-----\n" +
"MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1UEBhMCRUExDTALBgNVBAgT\n" +
"BE1vb24xETAPBgNVBAcTCEJhY2tzaWRlMQ4wDAYDVQQKEwVBLUItQzEPMA0GA1UECxMGT2ZmaWNl\n" +
"MQswCQYDVQQDEwJNZTAeFw0wNzAzMjIwMzU4NThaFw0wNzA2MjAwMzU4NThaMF0xCzAJBgNVBAYT\n" +
"AkVBMQ0wCwYDVQQIEwRNb29uMREwDwYDVQQHEwhCYWNrc2lkZTEOMAwGA1UEChMFQS1CLUMxDzAN\n" +
"BgNVBAsTBk9mZmljZTELMAkGA1UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
"EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
"t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/y\n" +
"IgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o6\n" +
"6oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7Om\n" +
"dZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA\n" +
"xc7ovvDeJ5yIkiEoz6U4jcFf5ZDSC+rUEsqGuARXHUF0PlIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
"OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
"PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
"OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
"-----BEGIN CERTIFICATE-----\n" +
"MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1UEBhMCRUExDTALBgNVBAgT\n" +
"BE1vb24xETAPBgNVBAcTCEJhY2tzaWRlMQ4wDAYDVQQKEwVBLUItQzEPMA0GA1UECxMGT2ZmaWNl\n" +
"MQswCQYDVQQDEwJNZTAeFw0wNzAzMjIwMzU4NThaFw0wNzA2MjAwMzU4NThaMF0xCzAJBgNVBAYT\n" +
"AkVBMQ0wCwYDVQQIEwRNb29uMREwDwYDVQQHEwhCYWNrc2lkZTEOMAwGA1UEChMFQS1CLUMxDzAN\n" +
"BgNVBAsTBk9mZmljZTELMAkGA1UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
"EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
"t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/y\n" +
"IgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o6\n" +
"6oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7Om\n" +
"dZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA\n" +
"xc7ovvDeJ5yIkiEoz6U4jcFf5ZDSC+rUEsqGuARXHUF0PlIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
"OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
"PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
"OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
"-----END CERTIFICATE-----\n";
try {
CertificateFactory.getInstance("X509").generateCertificates(
new ByteArrayInputStream(cert.getBytes()));
throw new Exception("Fail. certificate generation should fail");
} catch (CertificateException ce) {
ce.printStackTrace();
// This is the correct result
}
}
}

View File

@ -32,7 +32,7 @@
* 4872664 4803179 4892980 4900747 4945394 4938995 4979006 4994840 4997476
* 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940
* 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
* 6350801 6676425 6878475 6919132 6931676
* 6350801 6676425 6878475 6919132 6931676 6948903
*/
import java.util.regex.*;
@ -135,7 +135,7 @@ public class RegExTest {
surrogatesInClassTest();
namedGroupCaptureTest();
nonBmpClassComplementTest();
unicodePropertiesTest();
if (failure)
throw new RuntimeException("Failure in the RE handling.");
else
@ -3515,7 +3515,7 @@ public class RegExTest {
report("NamedGroupCapture");
}
// This is for bug 6919132
// This is for bug 6969132
private static void nonBmpClassComplementTest() throws Exception {
Pattern p = Pattern.compile("\\P{Lu}");
Matcher m = p.matcher(new String(new int[] {0x1d400}, 0, 1));
@ -3539,4 +3539,79 @@ public class RegExTest {
report("NonBmpClassComplement");
}
private static void unicodePropertiesTest() throws Exception {
// different forms
if (!Pattern.compile("\\p{IsLu}").matcher("A").matches() ||
!Pattern.compile("\\p{Lu}").matcher("A").matches() ||
!Pattern.compile("\\p{gc=Lu}").matcher("A").matches() ||
!Pattern.compile("\\p{general_category=Lu}").matcher("A").matches() ||
!Pattern.compile("\\p{IsLatin}").matcher("B").matches() ||
!Pattern.compile("\\p{sc=Latin}").matcher("B").matches() ||
!Pattern.compile("\\p{script=Latin}").matcher("B").matches() ||
!Pattern.compile("\\p{InBasicLatin}").matcher("c").matches() ||
!Pattern.compile("\\p{blk=BasicLatin}").matcher("c").matches() ||
!Pattern.compile("\\p{block=BasicLatin}").matcher("c").matches())
failCount++;
Matcher common = Pattern.compile("\\p{script=Common}").matcher("");
Matcher unknown = Pattern.compile("\\p{IsUnknown}").matcher("");
Matcher lastSM = common;
Character.UnicodeScript lastScript = Character.UnicodeScript.of(0);
Matcher latin = Pattern.compile("\\p{block=basic_latin}").matcher("");
Matcher greek = Pattern.compile("\\p{InGreek}").matcher("");
Matcher lastBM = latin;
Character.UnicodeBlock lastBlock = Character.UnicodeBlock.of(0);
for (int cp = 1; cp < Character.MAX_CODE_POINT; cp++) {
if (cp >= 0x30000 && (cp & 0x70) == 0){
continue; // only pick couple code points, they are the same
}
// Unicode Script
Character.UnicodeScript script = Character.UnicodeScript.of(cp);
Matcher m;
String str = new String(Character.toChars(cp));
if (script == lastScript) {
m = lastSM;
m.reset(str);
} else {
m = Pattern.compile("\\p{Is" + script.name() + "}").matcher(str);
}
if (!m.matches()) {
failCount++;
}
Matcher other = (script == Character.UnicodeScript.COMMON)? unknown : common;
other.reset(str);
if (other.matches()) {
failCount++;
}
lastSM = m;
lastScript = script;
// Unicode Block
Character.UnicodeBlock block = Character.UnicodeBlock.of(cp);
if (block == null) {
//System.out.printf("Not a Block: cp=%x%n", cp);
continue;
}
if (block == lastBlock) {
m = lastBM;
m.reset(str);
} else {
m = Pattern.compile("\\p{block=" + block.toString() + "}").matcher(str);
}
if (!m.matches()) {
failCount++;
}
other = (block == Character.UnicodeBlock.BASIC_LATIN)? greek : latin;
other.reset(str);
if (other.matches()) {
failCount++;
}
lastBM = m;
lastBlock = block;
}
report("unicodeProperties");
}
}

View File

@ -0,0 +1,100 @@
/*
* 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 4691425
* @summary Test the read and write of GZIPInput/OutputStream, including
* concatenated .gz inputstream
*/
import java.io.*;
import java.util.*;
import java.util.zip.*;
public class GZIPInputStreamRead {
public static void main(String[] args) throws Throwable {
Random rnd = new Random();
for (int i = 1; i < 100; i++) {
int members = rnd.nextInt(10) + 1;
ByteArrayOutputStream srcBAOS = new ByteArrayOutputStream();
ByteArrayOutputStream dstBAOS = new ByteArrayOutputStream();
for (int j = 0; j < members; j++) {
byte[] src = new byte[rnd.nextInt(8192) + 1];
rnd.nextBytes(src);
srcBAOS.write(src);
GZIPOutputStream gzos = new GZIPOutputStream(dstBAOS);
gzos.write(src);
gzos.close();
}
byte[] srcBytes = srcBAOS.toByteArray();
byte[] dstBytes = dstBAOS.toByteArray();
// try different size of buffer to read the
// GZIPInputStream
/* just for fun when running manually
for (int j = 1; j < 10; j++) {
test(srcBytes, dstBytes, j);
}
*/
for (int j = 0; j < 10; j++) {
int readBufSZ = rnd.nextInt(2048) + 1;
test(srcBytes,
dstBytes,
readBufSZ,
512); // the defualt buffer size
test(srcBytes,
dstBytes,
readBufSZ,
rnd.nextInt(4096) + 1);
}
}
}
private static void test(byte[] src, byte[] dst,
int readBufSize, int gzisBufSize)
throws Throwable
{
GZIPInputStream gzis = new GZIPInputStream(
new ByteArrayInputStream(dst),
gzisBufSize);
byte[] result = new byte[src.length + 10];
byte[] buf = new byte[readBufSize];
int n = 0;
int off = 0;
while ((n = gzis.read(buf, 0, buf.length)) != -1) {
System.arraycopy(buf, 0, result, off, n);
off += n;
// no range check, if overflow, let it fail
}
if (off != src.length || gzis.available() != 0 ||
!Arrays.equals(src, Arrays.copyOf(result, off))) {
throw new RuntimeException(
"GZIPInputStream reading failed! " +
", src.len=" + src.length +
", read=" + off);
}
gzis.close();
}
}

View File

@ -23,8 +23,8 @@
/**
* @test
* @bug 4206909
* @summary Test basic functionality of DeflaterOutputStream and InflaterInputStream including flush
* @bug 4206909 4813885
* @summary Test basic functionality of DeflaterOutputStream/InflaterInputStream and GZIPOutputStream/GZIPInputStream, including flush
*/
import java.io.*;
@ -79,23 +79,23 @@ public class InflateIn_DeflateOut {
}
private static class PairedOutputStream extends ByteArrayOutputStream {
private PairedInputStream pairedStream = null;
private PairedInputStream pairedStream = null;
public PairedOutputStream(PairedInputStream inputPair) {
super();
this.pairedStream = inputPair;
}
public void flush() {
if (count > 0) {
pairedStream.addBytes(buf, count);
reset();
public PairedOutputStream(PairedInputStream inputPair) {
super();
this.pairedStream = inputPair;
}
}
public void close() {
flush();
}
public void flush() {
if (count > 0) {
pairedStream.addBytes(buf, count);
reset();
}
}
public void close() {
flush();
}
}
private static boolean readFully(InputStream in, byte[] buf, int length)
@ -146,27 +146,20 @@ public class InflateIn_DeflateOut {
check(Arrays.equals(data, buf));
}
/** Check that written, flushed and read */
private static void WriteFlushRead() throws Throwable {
private static void check(InputStream is, OutputStream os)
throws Throwable
{
Random random = new Random(new Date().getTime());
PairedInputStream pis = new PairedInputStream();
InflaterInputStream iis = new InflaterInputStream(pis);
PairedOutputStream pos = new PairedOutputStream(pis);
pis.setPairedOutputStream(pos);
DeflaterOutputStream dos = new DeflaterOutputStream(pos, true);
// Large writes
// Large writes
for (int x = 0; x < 200 ; x++) {
// byte[] data = new byte[random.nextInt(1024 * 1024)];
byte[] data = new byte[1024];
byte[] buf = new byte[data.length];
random.nextBytes(data);
dos.write(data);
dos.flush();
check(readFully(iis, buf, buf.length));
os.write(data);
os.flush();
check(readFully(is, buf, buf.length));
check(Arrays.equals(data, buf));
}
@ -176,9 +169,9 @@ public class InflateIn_DeflateOut {
byte[] buf = new byte[data.length];
random.nextBytes(data);
dos.write(data);
dos.flush();
if (!readFully(iis, buf, buf.length)) {
os.write(data);
os.flush();
if (!readFully(is, buf, buf.length)) {
fail("Didn't read full buffer of " + buf.length);
}
check(Arrays.equals(data, buf));
@ -187,14 +180,62 @@ public class InflateIn_DeflateOut {
String quit = "QUIT\r\n";
// Close it out
dos.write(quit.getBytes());
dos.close();
os.write(quit.getBytes());
os.close();
StringBuilder sb = new StringBuilder();
check(readLineIfAvailable(iis, sb));
check(readLineIfAvailable(is, sb));
equal(sb.toString(), quit);
}
/** Check that written, flushed and read */
private static void WriteFlushRead() throws Throwable {
PairedInputStream pis = new PairedInputStream();
InflaterInputStream iis = new InflaterInputStream(pis);
PairedOutputStream pos = new PairedOutputStream(pis);
pis.setPairedOutputStream(pos);
DeflaterOutputStream dos = new DeflaterOutputStream(pos, true);
check(iis, dos);
}
private static void GZWriteFlushRead() throws Throwable {
PairedInputStream pis = new PairedInputStream();
PairedOutputStream pos = new PairedOutputStream(pis);
pis.setPairedOutputStream(pos);
GZIPOutputStream gos = new GZIPOutputStream(pos, true);
gos.flush(); // flush the head out, so gis can read
GZIPInputStream gis = new GZIPInputStream(pis);
check(gis, gos);
}
private static void checkLOP(InputStream is, OutputStream os)
throws Throwable
{
boolean flushed = false;
int count = 0;
// Do at least a certain number of lines, but too many without a
// flush means this test isn't testing anything
while ((count < 10 && flushed) || (count < 1000 && !flushed)) {
String command = "PING " + count + "\r\n";
os.write(command.getBytes());
StringBuilder buf = new StringBuilder();
if (!readLineIfAvailable(is, buf)) {
flushed = true;
os.flush();
check(readLineIfAvailable(is, buf));
}
equal(buf.toString(), command);
count++;
}
check(flushed);
}
/** Validate that we need to use flush at least once on a line
* oriented protocol */
private static void LineOrientedProtocol() throws Throwable {
@ -205,33 +246,27 @@ public class InflateIn_DeflateOut {
pis.setPairedOutputStream(pos);
DeflaterOutputStream dos = new DeflaterOutputStream(pos, true);
boolean flushed = false;
int count = 0;
checkLOP(iis, dos);
}
// Do at least a certain number of lines, but too many without a
// flush means this test isn't testing anything
while ((count < 10 && flushed) || (count < 1000 && !flushed)) {
String command = "PING " + count + "\r\n";
dos.write(command.getBytes());
private static void GZLineOrientedProtocol() throws Throwable {
PairedInputStream pis = new PairedInputStream();
PairedOutputStream pos = new PairedOutputStream(pis);
pis.setPairedOutputStream(pos);
StringBuilder buf = new StringBuilder();
if (!readLineIfAvailable(iis, buf)) {
flushed = true;
dos.flush();
check(readLineIfAvailable(iis, buf));
}
equal(buf.toString(), command);
count++;
}
check(flushed);
GZIPOutputStream gos = new GZIPOutputStream(pos, true);
gos.flush(); // flush the head out, so gis can read
GZIPInputStream gis = new GZIPInputStream(pis);
checkLOP(gis, gos);
}
public static void realMain(String[] args) throws Throwable {
WriteCloseRead();
WriteFlushRead();
LineOrientedProtocol();
GZWriteFlushRead();
GZLineOrientedProtocol();
}
//--------------------- Infrastructure ---------------------------

View File

@ -27,9 +27,9 @@
# @author Norbert Lindenberg
# @run shell Test4200310.sh
2>1 $TESTJAVA/bin/jar -tf "$TESTJAVA/jre/lib/rt.jar" > class-list
2>1 $TESTJAVA/bin/jar -tf "$TESTJAVA/jre/lib/charsets.jar" >> class-list
2>1 $TESTJAVA/bin/jar -tf "$TESTJAVA/jre/lib/ext/localedata.jar" >> class-list
2>&1 $TESTJAVA/bin/jar -tf "$TESTJAVA/jre/lib/rt.jar" > class-list
2>&1 $TESTJAVA/bin/jar -tf "$TESTJAVA/jre/lib/charsets.jar" >> class-list
2>&1 $TESTJAVA/bin/jar -tf "$TESTJAVA/jre/lib/ext/localedata.jar" >> class-list
duplicates=`grep '\.class$' class-list | sort | uniq -d`
rm -f class-list

View File

@ -23,7 +23,7 @@
#!/bin/sh
# @test
# @bug 6473331
# @bug 6473331 6485027 6934615
# @summary Test handling of the Class-Path attribute in jar file manifests
# for the rmic tool
# @author Andrey Ozerov
@ -65,26 +65,23 @@ EOF
Sys "$javac" pkg/A.java pkg/B.java
# NOTE: Certain lines below are commented out in order to work around
# bug 6485027, with alternative lines added as part of the workaround
# as indicated. In particular, the mutally referential JAR files are
# placed in the same directory instead of different directories, and
# javac is not expected to handle the extensions directories cases.
# NOTE: Previously, some lines were commented out and alternative lines
# provided, to work around javac bug 6485027. That bug, and related rmic
# bug 6934615 have now been fixed, so most of the workarounds have been
# removed. However, javac still does not evaluate jar class paths on
# the bootclasspath, including -extdirs.
#MkManifestWithClassPath "sub/B.zip"
MkManifestWithClassPath "B.zip" # 6485027 workaround
MkManifestWithClassPath "sub/B.zip"
Sys "$jar" cmf MANIFEST.MF A.jar pkg/A.class
#MkManifestWithClassPath "../A.jar"
MkManifestWithClassPath "A.jar" # 6485027 workaround
MkManifestWithClassPath "../A.jar"
Sys "$jar" cmf MANIFEST.MF B.zip pkg/B.class
Sys rm -rf pkg
Sys mkdir jars
Sys mv A.jar jars/.
#Sys mkdir jars/sub
#Sys mv B.zip jars/sub/.
Sys mv B.zip jars/. # 6485027 workaround
Sys mkdir jars/sub
Sys mv B.zip jars/sub/.
cat >MainI.java <<EOF
import pkg.*;
@ -121,26 +118,22 @@ Success "$java" -classpath "jars/A.jar${PS}." Main
Sys rm -f Main.class MainI.class Main_Stub.class
#Success "$javac" -classpath "jars/sub/B.zip" Main.java MainI.java
#Success "$rmic" -classpath "jars/sub/B.zip${PS}." Main
#Success "$java" -classpath "jars/sub/B.zip${PS}." Main
Success "$javac" -classpath "jars/B.zip" \
Main.java MainI.java # 6485027 workaround
Success "$rmic" -classpath "jars/B.zip${PS}." Main # 6485027 workaround
Success "$java" -classpath "jars/B.zip${PS}." Main # 6485027 workaround
Success "$javac" -classpath "jars/sub/B.zip" Main.java MainI.java
Success "$rmic" -classpath "jars/sub/B.zip${PS}." Main
Success "$java" -classpath "jars/sub/B.zip${PS}." Main
#Sys rm -f Main.class MainI.class Main_Stub.class
Sys rm -f Main_Stub.class # 6485027 workaround
Sys rm -f Main_Stub.class # javac -extdirs workaround
#Success "$javac" -extdirs "jars" -classpath None Main.java MainI.java
Success "$rmic" -extdirs "jars" -classpath . Main
Success "$java" -Djava.ext.dirs="jars" -cp . Main
#Sys rm -f Main_Stub.class
#
Sys rm -f Main_Stub.class
#Success "$javac" -extdirs "jars/sub" -classpath None Main.java MainI.java
#Success "$rmic" -extdirs "jars/sub" -classpath . Main
#Success "$java" -Djava.ext.dirs="jars/sub" -cp . Main
Success "$rmic" -extdirs "jars/sub" -classpath . Main
Success "$java" -Djava.ext.dirs="jars/sub" -cp . Main
Cleanup

View File

@ -0,0 +1,53 @@
/*
* 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 6882687
* @summary KerberosTime too imprecise
*/
import sun.security.krb5.internal.KerberosTime;
public class MicroTime {
public static void main(String[] args) throws Exception {
// We count how many different KerberosTime values
// can be acquired within one second.
KerberosTime t1 = new KerberosTime(true);
KerberosTime last = t1;
int count = 0;
while (true) {
KerberosTime t2 = new KerberosTime(true);
if (t2.getTime() - t1.getTime() > 1000) break;
if (!last.equals(t2)) {
last = t2;
count++;
}
}
// We believe a nice KerberosTime can at least tell the
// difference of 100 musec.
if (count < 10000) {
throw new Exception("What? only " + (1000000/count) +
" musec precision?");
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2010, 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
@ -403,8 +403,11 @@ public class KDC {
*/
private static char[] randomPassword() {
char[] pass = new char[32];
for (int i=0; i<32; i++)
for (int i=0; i<31; i++)
pass[i] = (char)secureRandom.nextInt();
// The last char cannot be a number, otherwise, keyForUser()
// believes it's a sign of kvno
pass[31] = 'Z';
return pass;
}
@ -740,6 +743,9 @@ public class KDC {
Field f = KDCReqBody.class.getDeclaredField("eType");
f.setAccessible(true);
eTypes = (int[])f.get(body);
if (eTypes.length < 2) {
throw new KrbException(Krb5.KDC_ERR_ETYPE_NOSUPP);
}
int eType = eTypes[0];
EncryptionKey ckey = keyForUser(body.cname, eType, false);

View File

@ -22,8 +22,8 @@
#
# @test
# @bug 6890876
# @summary jarsigner can add CRL info into signed jar
# @bug 6890876 6950931
# @summary jarsigner can add CRL info into signed jar (updated)
#
if [ "${TESTJAVA}" = "" ] ; then
@ -53,7 +53,7 @@ KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystor
JAR=$TESTJAVA${FS}bin${FS}jar
JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner
rm $KS $JFILE
rm $KS $JFILE 2> /dev/null
# Generates some crl files, each containing two entries
@ -63,8 +63,9 @@ $KT -alias a -gencrl -id 3:3 -id 4:4 -file crl2
$KT -alias b -dname CN=b -keyalg rsa -genkey -validity 300
$KT -alias b -gencrl -id 5:1 -id 6:2 -file crl3
$TESTJAVA${FS}bin${FS}jrunscript -e 'println(new File("crl1").toURI())' > uri
$KT -alias c -dname CN=c -keyalg rsa -genkey -validity 300 \
-ext crl=uri:file://`pwd`/crl1
-ext crl=uri:`cat uri`
echo A > A
@ -80,9 +81,9 @@ $KT -printcert -jarfile $JFILE | grep CRLs || exit 7
$JAR cvf $JFILE A
$JARSIGNER -keystore $KS -storepass changeit $JFILE a \
-crl crl1 -crl crl2 || exit 1
-crl crl1 -crl crl2 || exit 2
$JARSIGNER -keystore $KS -storepass changeit $JFILE b \
-crl crl3 -crl crl2 || exit 1
-crl crl3 -crl crl2 || exit 3
$JARSIGNER -keystore $KS -verify -debug -strict $JFILE || exit 3
$KT -printcert -jarfile $JFILE | grep CRLs || exit 4
CRLCOUNT=`$KT -printcert -jarfile $JFILE | grep SerialNumber | wc -l`

View File

@ -0,0 +1,63 @@
/*
* 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.
*/
/*
* This test is called by certreplace.sh
*/
import java.io.FileInputStream;
import java.security.KeyStore;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import sun.security.validator.Validator;
public class CertReplace {
private final static String cacerts = "certreplace.jks";
private final static String certs = "certreplace.certs";
public static void main(String[] args) throws Exception {
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(new FileInputStream(cacerts), "changeit".toCharArray());
Validator v = Validator.getInstance
(Validator.TYPE_PKIX, Validator.VAR_GENERIC, ks);
X509Certificate[] chain = createPath();
System.out.println(Arrays.toString(v.validate(chain)));
}
public static X509Certificate[] createPath() throws Exception {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
List list = new ArrayList();
for (Certificate c: cf.generateCertificates(
new FileInputStream(certs))) {
list.add((X509Certificate)c);
}
return (X509Certificate[]) list.toArray(new X509Certificate[0]);
}
}

View File

@ -0,0 +1,85 @@
#
# 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 6948803
# @summary CertPath validation regression caused by SHA1 replacement root
# and MD2 disable feature
#
if [ "${TESTSRC}" = "" ] ; then
TESTSRC="."
fi
if [ "${TESTJAVA}" = "" ] ; then
JAVAC_CMD=`which javac`
TESTJAVA=`dirname $JAVAC_CMD`/..
fi
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
Windows_* )
FS="\\"
;;
* )
FS="/"
;;
esac
KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit \
-keypass changeit -keystore certreplace.jks"
JAVAC=$TESTJAVA${FS}bin${FS}javac
JAVA=$TESTJAVA${FS}bin${FS}java
rm -rf certreplace.jks 2> /dev/null
# 1. Generate 3 aliases in a keystore: ca, int, user
$KT -genkeypair -alias ca -dname CN=CA -keyalg rsa -sigalg md2withrsa -ext bc
$KT -genkeypair -alias int -dname CN=Int -keyalg rsa
$KT -genkeypair -alias user -dname CN=User -keyalg rsa
# 2. Signing: ca -> int -> user
$KT -certreq -alias int | $KT -gencert -rfc -alias ca -ext bc \
| $KT -import -alias int
$KT -certreq -alias user | $KT -gencert -rfc -alias int \
| $KT -import -alias user
# 3. Create the certchain file
$KT -export -alias user -rfc > certreplace.certs
$KT -export -rfc -alias int >> certreplace.certs
$KT -export -rfc -alias ca >> certreplace.certs
# 4. Upgrade ca from MD2withRSA to SHA256withRSA, remove other aliases and
# make this keystore the cacerts file
$KT -selfcert -alias ca
$KT -delete -alias int
$KT -delete -alias user
# 5. Build and run test
$JAVAC -d . ${TESTSRC}${FS}CertReplace.java
$JAVA CertReplace