提交 9be4aae8 编写于 作者: L lana

Merge

# #
# 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. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -231,15 +231,35 @@ ifeq ($(PLATFORM), windows) ...@@ -231,15 +231,35 @@ ifeq ($(PLATFORM), windows)
# Temporary disk area # Temporary disk area
TEMP_DISK=C:/temp TEMP_DISK=C:/temp
# GNU Make or MKS overrides $(PROCESSOR_ARCHITECTURE) to always # GNU Make or MKS overrides $(PROCESSOR_ARCHITECTURE) to always
# return "x86". Use the first word of $(PROCESSOR_IDENTIFIER) instead. # return "x86". Use the first word of $(PROCESSOR_IDENTIFIER) instead.
PROC_ARCH:=$(word 1, $(PROCESSOR_IDENTIFIER)) # And sometimes PROCESSOR_IDENTIFIER is not defined at all
PROC_ARCH:=$(subst x86,X86,$(PROC_ARCH)) # (in some restricted shells), so we use uname if we have to.
PROC_ARCH:=$(subst Intel64,X64,$(PROC_ARCH)) ifeq ($(PROCESSOR_IDENTIFIER),)
PROC_ARCH:=$(subst em64t,X64,$(PROC_ARCH)) PROC_ARCH:=$(shell uname -m)
PROC_ARCH:=$(subst EM64T,X64,$(PROC_ARCH)) else
PROC_ARCH:=$(subst amd64,X64,$(PROC_ARCH)) PROC_ARCH:=$(word 1, $(PROCESSOR_IDENTIFIER))
PROC_ARCH:=$(subst AMD64,X64,$(PROC_ARCH)) endif
PROC_ARCH:=$(subst ia64,IA64,$(PROC_ARCH)) # 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 ifndef ARCH_DATA_MODEL
ifeq ($(PROC_ARCH),IA64) ifeq ($(PROC_ARCH),IA64)
ARCH_DATA_MODEL=64 ARCH_DATA_MODEL=64
......
...@@ -34,6 +34,7 @@ JAVA_JAVA_java = \ ...@@ -34,6 +34,7 @@ JAVA_JAVA_java = \
java/lang/Thread.java \ java/lang/Thread.java \
java/lang/Character.java \ java/lang/Character.java \
java/lang/CharacterData.java \ java/lang/CharacterData.java \
java/lang/CharacterName.java \
sun/misc/ASCIICaseInsensitiveComparator.java \ sun/misc/ASCIICaseInsensitiveComparator.java \
sun/misc/VM.java \ sun/misc/VM.java \
sun/misc/Signal.java \ sun/misc/Signal.java \
......
...@@ -384,6 +384,27 @@ clean:: ...@@ -384,6 +384,27 @@ clean::
$(RM) $(GENSRCDIR)/java/lang/CharacterDataUndefined.java $(RM) $(GENSRCDIR)/java/lang/CharacterDataUndefined.java
$(RM) $(GENSRCDIR)/java/lang/CharacterDataPrivateUse.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 # End of rules to create $(GENSRCDIR)/java/lang/CharacterDataXX.java
# #
......
...@@ -823,6 +823,10 @@ module jar-tool { ...@@ -823,6 +823,10 @@ module jar-tool {
include sun.tools.jar.**; include sun.tools.jar.**;
} }
module policytool {
include sun.security.tools.policytool.*;
}
module security-tools { module security-tools {
include sun.security.tools.**; include sun.security.tools.**;
......
# #
# 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. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -47,5 +47,5 @@ include $(BUILDDIR)/common/Classes.gmk ...@@ -47,5 +47,5 @@ include $(BUILDDIR)/common/Classes.gmk
build: build:
$(call make-launcher, keytool, sun.security.tools.KeyTool, , ) $(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, , )
此差异已折叠。
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(); }
}
}
}
}
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();
}
}
}
...@@ -35,6 +35,8 @@ import java.io.BufferedWriter; ...@@ -35,6 +35,8 @@ import java.io.BufferedWriter;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.File; import java.io.File;
import build.tools.generatecharacter.CharacterName;
/** /**
* This program generates the source code for the class java.lang.Character. * This program generates the source code for the class java.lang.Character.
* It also generates native C code that can perform the same operations. * It also generates native C code that can perform the same operations.
......
...@@ -525,11 +525,11 @@ public class DnsClient { ...@@ -525,11 +525,11 @@ public class DnsClient {
} }
byte[] pkt; byte[] pkt;
if ((pkt = (byte[]) resps.get(xid)) != null) { if ((pkt = (byte[]) resps.get(xid)) != null) {
checkResponseCode(new Header(pkt, pkt.length));
synchronized (queuesLock) { synchronized (queuesLock) {
resps.remove(xid); resps.remove(xid);
reqs.remove(xid); reqs.remove(xid);
} }
checkResponseCode(new Header(pkt, pkt.length));
if (debug) { if (debug) {
dprint("FOUND (" + Thread.currentThread() + dprint("FOUND (" + Thread.currentThread() +
...@@ -562,12 +562,12 @@ public class DnsClient { ...@@ -562,12 +562,12 @@ public class DnsClient {
dprint("XID MATCH:" + xid); dprint("XID MATCH:" + xid);
} }
checkResponseCode(hdr);
// remove the response for the xid if received by some other thread. // remove the response for the xid if received by some other thread.
synchronized (queuesLock) { synchronized (queuesLock) {
resps.remove(xid); resps.remove(xid);
reqs.remove(xid); reqs.remove(xid);
} }
checkResponseCode(hdr);
return true; return true;
} }
......
...@@ -117,7 +117,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { ...@@ -117,7 +117,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
* size check or synchronization. * size check or synchronization.
*/ */
void expandCapacity(int minimumCapacity) { void expandCapacity(int minimumCapacity) {
int newCapacity = value.length * 2; int newCapacity = value.length * 2 + 2;
if (newCapacity - minimumCapacity < 0) if (newCapacity - minimumCapacity < 0)
newCapacity = minimumCapacity; newCapacity = minimumCapacity;
if (newCapacity < 0) { if (newCapacity < 0) {
......
/*
* 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
}
}
...@@ -2491,6 +2491,8 @@ public final class URI ...@@ -2491,6 +2491,8 @@ public final class URI
// Tell whether the given character is permitted by the given mask pair // Tell whether the given character is permitted by the given mask pair
private static boolean match(char c, long lowMask, long highMask) { 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) if (c < 64)
return ((1L << c) & lowMask) != 0; return ((1L << c) & lowMask) != 0;
if (c < 128) if (c < 128)
......
...@@ -76,7 +76,7 @@ class JarVerifier { ...@@ -76,7 +76,7 @@ class JarVerifier {
private ByteArrayOutputStream baos; private ByteArrayOutputStream baos;
/** The ManifestDigester object */ /** The ManifestDigester object */
private ManifestDigester manDig; private volatile ManifestDigester manDig;
/** the bytes for the manDig object */ /** the bytes for the manDig object */
byte manifestRawBytes[] = null; byte manifestRawBytes[] = null;
......
...@@ -29,6 +29,7 @@ import java.security.AccessController; ...@@ -29,6 +29,7 @@ import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.text.CharacterIterator; import java.text.CharacterIterator;
import java.text.Normalizer; import java.text.Normalizer;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -200,8 +201,9 @@ import java.util.Arrays; ...@@ -200,8 +201,9 @@ import java.util.Arrays;
* <td>Equivalent to java.lang.Character.isMirrored()</td></tr> * <td>Equivalent to java.lang.Character.isMirrored()</td></tr>
* *
* <tr><th>&nbsp;</th></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> * <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> * <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> * <tr><td valign="top" headers="construct unicode"><tt>\p{Lu}</tt></td>
...@@ -527,25 +529,40 @@ import java.util.Arrays; ...@@ -527,25 +529,40 @@ import java.util.Arrays;
* while not equal, compile into the same pattern, which matches the character * while not equal, compile into the same pattern, which matches the character
* with hexadecimal value <tt>0x2014</tt>. * with hexadecimal value <tt>0x2014</tt>.
* *
* <a name="ubc"> <p>Unicode blocks and categories are written with the * <a name="ubc">
* <tt>\p</tt> and <tt>\P</tt> constructs as in * <p>Unicode scripts, blocks and categories are written with the <tt>\p</tt> and
* Perl. <tt>\p{</tt><i>prop</i><tt>}</tt> matches if the input has the * <tt>\P</tt> constructs as in Perl. <tt>\p{</tt><i>prop</i><tt>}</tt> matches if
* property <i>prop</i>, while <tt>\P{</tt><i>prop</i><tt>}</tt> does not match if * the input has the property <i>prop</i>, while <tt>\P{</tt><i>prop</i><tt>}</tt>
* the input has that property. Blocks are specified with the prefix * does not match if the input has that property.
* <tt>In</tt>, as in <tt>InMongolian</tt>. Categories may be specified with * <p>
* the optional prefix <tt>Is</tt>: Both <tt>\p{L}</tt> and <tt>\p{IsL}</tt> * Scripts are specified either with the prefix {@code Is}, as in
* denote the category of Unicode letters. Blocks and categories can be used * {@code IsHiragana}, or by using the {@code script} keyword (or its short
* both inside and outside of a character class. * 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 * <p> The supported categories are those of
* <a href="http://www.unicode.org/unicode/standard/standard.html"> * <a href="http://www.unicode.org/unicode/standard/standard.html">
* <i>The Unicode Standard</i></a> in the version specified by the * <i>The Unicode Standard</i></a> in the version specified by the
* {@link java.lang.Character Character} class. The category names are those * {@link java.lang.Character Character} class. The category names are those
* defined in the Standard, both normative and informative. * 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 * The block names supported by <code>Pattern</code> are the valid block names
* accepted and defined by * accepted and defined by
* {@link java.lang.Character.UnicodeBlock#forName(String) UnicodeBlock.forName}. * {@link java.lang.Character.UnicodeBlock#forName(String) UnicodeBlock.forName}.
* * <p>
* <a name="jcc"> <p>Categories that behave like the java.lang.Character * <a name="jcc"> <p>Categories that behave like the java.lang.Character
* boolean is<i>methodname</i> methods (except for the deprecated ones) are * 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 * 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) { ...@@ -2488,12 +2505,34 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
name = new String(temp, i, j-i-1); name = new String(temp, i, j-i-1);
} }
if (name.startsWith("In")) { int i = name.indexOf('=');
node = unicodeBlockPropertyFor(name.substring(2)); 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 { } 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); name = name.substring(2);
node = charPropertyNodeFor(name); node = CharPropertyNames.charPropertyFor(name);
if (node == null)
node = unicodeScriptPropertyFor(name);
} else {
node = charPropertyNodeFor(name);
}
} }
if (maybeComplement) { if (maybeComplement) {
if (node instanceof Category || node instanceof Block) if (node instanceof Category || node instanceof Block)
...@@ -2503,6 +2542,21 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2503,6 +2542,21 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
return node; 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. * 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) { ...@@ -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. * Node class that matches a Unicode category.
*/ */
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -66,19 +66,24 @@ class GZIPInputStream extends InflaterInputStream { ...@@ -66,19 +66,24 @@ class GZIPInputStream extends InflaterInputStream {
* Creates a new input stream with the specified buffer size. * Creates a new input stream with the specified buffer size.
* @param in the input stream * @param in the input stream
* @param size the input buffer size * @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 IOException if an I/O error has occurred
* @exception IllegalArgumentException if size is <= 0 * @exception IllegalArgumentException if size is <= 0
*/ */
public GZIPInputStream(InputStream in, int size) throws IOException { public GZIPInputStream(InputStream in, int size) throws IOException {
super(in, new Inflater(true), size); super(in, new Inflater(true), size);
usesDefaultInflater = true; usesDefaultInflater = true;
readHeader(); readHeader(in);
crc.reset();
} }
/** /**
* Creates a new input stream with a default buffer size. * Creates a new input stream with a default buffer size.
* @param in the input stream * @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 * @exception IOException if an I/O error has occurred
*/ */
public GZIPInputStream(InputStream in) throws IOException { public GZIPInputStream(InputStream in) throws IOException {
...@@ -94,26 +99,30 @@ class GZIPInputStream extends InflaterInputStream { ...@@ -94,26 +99,30 @@ class GZIPInputStream extends InflaterInputStream {
* @param len the maximum number of bytes read * @param len the maximum number of bytes read
* @return the actual number of bytes read, or -1 if the end of the * @return the actual number of bytes read, or -1 if the end of the
* compressed input stream is reached * compressed input stream is reached
*
* @exception NullPointerException If <code>buf</code> is <code>null</code>. * @exception NullPointerException If <code>buf</code> is <code>null</code>.
* @exception IndexOutOfBoundsException If <code>off</code> is negative, * @exception IndexOutOfBoundsException If <code>off</code> is negative,
* <code>len</code> is negative, or <code>len</code> is greater than * <code>len</code> is negative, or <code>len</code> is greater than
* <code>buf.length - off</code> * <code>buf.length - off</code>
* @exception IOException if an I/O error has occurred or the compressed * @exception ZipException if the compressed input data is corrupt.
* input data is corrupt * @exception IOException if an I/O error has occurred.
*
*/ */
public int read(byte[] buf, int off, int len) throws IOException { public int read(byte[] buf, int off, int len) throws IOException {
ensureOpen(); ensureOpen();
if (eos) { if (eos) {
return -1; return -1;
} }
len = super.read(buf, off, len); int n = super.read(buf, off, len);
if (len == -1) { if (n == -1) {
readTrailer(); if (readTrailer())
eos = true; eos = true;
else
return this.read(buf, off, len);
} else { } else {
crc.update(buf, off, len); crc.update(buf, off, n);
} }
return len; return n;
} }
/** /**
...@@ -144,48 +153,61 @@ class GZIPInputStream extends InflaterInputStream { ...@@ -144,48 +153,61 @@ class GZIPInputStream extends InflaterInputStream {
private final static int FCOMMENT = 16; // File comment 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 { private int readHeader(InputStream this_in) throws IOException {
CheckedInputStream in = new CheckedInputStream(this.in, crc); CheckedInputStream in = new CheckedInputStream(this_in, crc);
crc.reset(); crc.reset();
// Check header magic // Check header magic
if (readUShort(in) != GZIP_MAGIC) { if (readUShort(in) != GZIP_MAGIC) {
throw new IOException("Not in GZIP format"); throw new ZipException("Not in GZIP format");
} }
// Check compression method // Check compression method
if (readUByte(in) != 8) { if (readUByte(in) != 8) {
throw new IOException("Unsupported compression method"); throw new ZipException("Unsupported compression method");
} }
// Read flags // Read flags
int flg = readUByte(in); int flg = readUByte(in);
// Skip MTIME, XFL, and OS fields // Skip MTIME, XFL, and OS fields
skipBytes(in, 6); skipBytes(in, 6);
int n = 2 + 2 + 6;
// Skip optional extra field // Skip optional extra field
if ((flg & FEXTRA) == FEXTRA) { if ((flg & FEXTRA) == FEXTRA) {
skipBytes(in, readUShort(in)); int m = readUShort(in);
skipBytes(in, m);
n += m + 2;
} }
// Skip optional file name // Skip optional file name
if ((flg & FNAME) == FNAME) { if ((flg & FNAME) == FNAME) {
while (readUByte(in) != 0) ; do {
n++;
} while (readUByte(in) != 0);
} }
// Skip optional file comment // Skip optional file comment
if ((flg & FCOMMENT) == FCOMMENT) { if ((flg & FCOMMENT) == FCOMMENT) {
while (readUByte(in) != 0) ; do {
n++;
} while (readUByte(in) != 0);
} }
// Check optional header CRC // Check optional header CRC
if ((flg & FHCRC) == FHCRC) { if ((flg & FHCRC) == FHCRC) {
int v = (int)crc.getValue() & 0xffff; int v = (int)crc.getValue() & 0xffff;
if (readUShort(in) != v) { 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; InputStream in = this.in;
int n = inf.getRemaining(); int n = inf.getRemaining();
if (n > 0) { if (n > 0) {
...@@ -196,7 +218,25 @@ class GZIPInputStream extends InflaterInputStream { ...@@ -196,7 +218,25 @@ class GZIPInputStream extends InflaterInputStream {
if ((readUInt(in) != crc.getValue()) || if ((readUInt(in) != crc.getValue()) ||
// rfc1952; ISIZE is the input size modulo 2^32 // rfc1952; ISIZE is the input size modulo 2^32
(readUInt(in) != (inf.getBytesWritten() & 0xffffffffL))) (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 { ...@@ -231,7 +271,6 @@ class GZIPInputStream extends InflaterInputStream {
return b; return b;
} }
private byte[] tmpbuf = new byte[128]; private byte[] tmpbuf = new byte[128];
/* /*
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -54,25 +54,82 @@ class GZIPOutputStream extends DeflaterOutputStream { ...@@ -54,25 +54,82 @@ class GZIPOutputStream extends DeflaterOutputStream {
/** /**
* Creates a new output stream with the specified buffer size. * 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 out the output stream
* @param size the output buffer size * @param size the output buffer size
* @exception IOException If an I/O error has occurred. * @exception IOException If an I/O error has occurred.
* @exception IllegalArgumentException if size is <= 0 * @exception IllegalArgumentException if size is <= 0
*/ */
public GZIPOutputStream(OutputStream out, int size) throws IOException { 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; usesDefaultDeflater = true;
writeHeader(); writeHeader();
crc.reset(); crc.reset();
} }
/** /**
* Creates a new output stream with a default buffer size. * 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 * @param out the output stream
* @exception IOException If an I/O error has occurred. * @exception IOException If an I/O error has occurred.
*/ */
public GZIPOutputStream(OutputStream out) throws IOException { 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 { ...@@ -122,22 +179,19 @@ class GZIPOutputStream extends DeflaterOutputStream {
/* /*
* Writes GZIP member header. * 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 { 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)
});
} }
/* /*
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -40,7 +40,7 @@ class ZipException extends IOException { ...@@ -40,7 +40,7 @@ class ZipException extends IOException {
private static final long serialVersionUID = 8000196834066748623L; 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. * as its error detail message.
*/ */
public ZipException() { public ZipException() {
...@@ -48,7 +48,7 @@ class ZipException extends IOException { ...@@ -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. * message.
* *
* @param s the detail message. * @param s the detail message.
......
...@@ -58,25 +58,22 @@ input streams. ...@@ -58,25 +58,22 @@ input streams.
PKWARE ZIP File Format Specification</a> - Language Encoding Flag (EFS) to PKWARE ZIP File Format Specification</a> - Language Encoding Flag (EFS) to
encode ZIP entry filename and comment fields using UTF-8. encode ZIP entry filename and comment fields using UTF-8.
<p> <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> ZLIB Compressed Data Format Specification version 3.3</a>
&nbsp; &nbsp;
<a href="http://www.isi.edu/in-notes/rfc1950.ps"> <a href="http://www.ietf.org/rfc/rfc1950.txt.pdf">(pdf)</a>
(PostScript)</a>
(RFC 1950) (RFC 1950)
<p> <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> DEFLATE Compressed Data Format Specification version 1.3</a>
&nbsp; &nbsp;
<a href="http://www.isi.edu/in-notes/rfc1951.ps"> <a href="http://www.ietf.org/rfc/rfc1951.txt.pdf">(pdf)</a>
(PostScript)</a>
(RFC 1951) (RFC 1951)
<p> <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> GZIP file format specification version 4.3</a>
&nbsp; &nbsp;
<a href="http://www.isi.edu/in-notes/rfc1952.ps"> <a href="http://www.ietf.org/rfc/rfc1952.txt.pdf">(pdf)</a>
(PostScript)</a>
(RFC 1952) (RFC 1952)
<p> <p>
<li>CRC-32 checksum is described in RFC 1952 (above) <li>CRC-32 checksum is described in RFC 1952 (above)
......
...@@ -34,7 +34,7 @@ import javax.naming.directory.SearchControls; ...@@ -34,7 +34,7 @@ import javax.naming.directory.SearchControls;
* of events fired when objects named in a directory context changes. * of events fired when objects named in a directory context changes.
*<p> *<p>
* The methods in this interface support identification of objects by * 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. * search filters.
* *
*<P>Using the search filter, it is possible to register interest in objects *<P>Using the search filter, it is possible to register interest in objects
......
...@@ -27,7 +27,7 @@ package javax.naming.ldap; ...@@ -27,7 +27,7 @@ package javax.naming.ldap;
/** /**
* This interface represents an LDAPv3 control as defined in * 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> *<p>
* The LDAPv3 protocol uses controls to send and receive additional data * The LDAPv3 protocol uses controls to send and receive additional data
* to affect the behavior of predefined operations. * to affect the behavior of predefined operations.
......
...@@ -37,7 +37,7 @@ import com.sun.naming.internal.ResourceManager; ...@@ -37,7 +37,7 @@ import com.sun.naming.internal.ResourceManager;
/** /**
* This abstract class represents a factory for creating LDAPv3 controls. * This abstract class represents a factory for creating LDAPv3 controls.
* LDAPv3 controls are defined in * 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> *<p>
* When a service provider receives a response control, it uses control * When a service provider receives a response control, it uses control
* factories to return the specific/appropriate control class implementation. * factories to return the specific/appropriate control class implementation.
......
...@@ -29,7 +29,7 @@ import javax.naming.NamingException; ...@@ -29,7 +29,7 @@ import javax.naming.NamingException;
/** /**
* This interface represents an LDAPv3 extended operation request as defined in * 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> * <pre>
* ExtendedRequest ::= [APPLICATION 23] SEQUENCE { * ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
* requestName [0] LDAPOID, * requestName [0] LDAPOID,
......
...@@ -27,7 +27,7 @@ package javax.naming.ldap; ...@@ -27,7 +27,7 @@ package javax.naming.ldap;
/** /**
* This interface represents an LDAP extended operation response as defined in * 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> * <pre>
* ExtendedResponse ::= [APPLICATION 24] SEQUENCE { * ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
* COMPONENTS OF LDAPResult, * COMPONENTS OF LDAPResult,
......
...@@ -29,7 +29,7 @@ import javax.naming.NamingException; ...@@ -29,7 +29,7 @@ import javax.naming.NamingException;
/** /**
* This interface represents an unsolicited notification as defined in * 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 * An unsolicited notification is sent by the LDAP server to the LDAP
* client without any provocation from the client. * client without any provocation from the client.
* Its format is that of an extended response (<tt>ExtendedResponse</tt>). * Its format is that of an extended response (<tt>ExtendedResponse</tt>).
......
...@@ -30,7 +30,7 @@ import javax.naming.event.NamingListener; ...@@ -30,7 +30,7 @@ import javax.naming.event.NamingListener;
/** /**
* This interface is for handling <tt>UnsolicitedNotificationEvent</tt>. * This interface is for handling <tt>UnsolicitedNotificationEvent</tt>.
* "Unsolicited notification" is defined in * "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. * It allows the server to send unsolicited notifications to the client.
* A <tt>UnsolicitedNotificationListener</tt> must: * A <tt>UnsolicitedNotificationListener</tt> must:
*<ol> *<ol>
......
...@@ -83,7 +83,7 @@ import java.io.Serializable; ...@@ -83,7 +83,7 @@ import java.io.Serializable;
* doc flavor's MIME type is one of the standard media types telling how to * 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 * interpret the sequence of characters or bytes. For a list of standard media
* types, see the Internet Assigned Numbers Authority's (IANA's) <A * 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, * Directory</A>. Interface {@link Doc Doc} provides two utility operations,
* {@link Doc#getReaderForText() getReaderForText} and * {@link Doc#getReaderForText() getReaderForText} and
* {@link Doc#getStreamForBytes() getStreamForBytes()}, to help a * {@link Doc#getStreamForBytes() getStreamForBytes()}, to help a
......
...@@ -25,9 +25,6 @@ ...@@ -25,9 +25,6 @@
package sun.jvmstat.monitor; package sun.jvmstat.monitor;
import sun.management.counter.Units;
import sun.management.counter.Variability;
/** /**
* The base class for Instrumentation Monitoring Objects. This base class * The base class for Instrumentation Monitoring Objects. This base class
* provides implementations of the {@link Monitor} methods that are common * provides implementations of the {@link Monitor} methods that are common
......
...@@ -25,9 +25,6 @@ ...@@ -25,9 +25,6 @@
package sun.jvmstat.monitor; package sun.jvmstat.monitor;
import sun.management.counter.Units;
import sun.management.counter.Variability;
/** /**
* Interface provided by Instrumentation Monitoring Objects. * Interface provided by Instrumentation Monitoring Objects.
* *
......
/*
* 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;
}
/*
* 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;
}
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
package sun.jvmstat.perfdata.monitor; package sun.jvmstat.perfdata.monitor;
import sun.jvmstat.monitor.*; import sun.jvmstat.monitor.*;
import sun.management.counter.Units;
import sun.management.counter.Variability;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** /**
......
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
package sun.jvmstat.perfdata.monitor; package sun.jvmstat.perfdata.monitor;
import sun.jvmstat.monitor.*; import sun.jvmstat.monitor.*;
import sun.management.counter.Units;
import sun.management.counter.Variability;
import java.nio.IntBuffer; import java.nio.IntBuffer;
/** /**
......
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
package sun.jvmstat.perfdata.monitor; package sun.jvmstat.perfdata.monitor;
import sun.jvmstat.monitor.*; import sun.jvmstat.monitor.*;
import sun.management.counter.Units;
import sun.management.counter.Variability;
import java.nio.LongBuffer; import java.nio.LongBuffer;
/** /**
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
package sun.jvmstat.perfdata.monitor; package sun.jvmstat.perfdata.monitor;
import sun.jvmstat.monitor.*; import sun.jvmstat.monitor.*;
import sun.management.counter.Variability;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** /**
......
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
package sun.jvmstat.perfdata.monitor; package sun.jvmstat.perfdata.monitor;
import sun.jvmstat.monitor.*; import sun.jvmstat.monitor.*;
import sun.management.counter.Units;
import sun.management.counter.Variability;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.charset.Charset; import java.nio.charset.Charset;
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
package sun.jvmstat.perfdata.monitor; package sun.jvmstat.perfdata.monitor;
import sun.jvmstat.monitor.*; import sun.jvmstat.monitor.*;
import sun.management.counter.Variability;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** /**
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
package sun.jvmstat.perfdata.monitor.v1_0; package sun.jvmstat.perfdata.monitor.v1_0;
import sun.management.counter.Units;
import sun.management.counter.Variability;
import sun.jvmstat.monitor.*; import sun.jvmstat.monitor.*;
import sun.jvmstat.perfdata.monitor.*; import sun.jvmstat.perfdata.monitor.*;
import java.util.*; import java.util.*;
......
...@@ -27,8 +27,6 @@ package sun.jvmstat.perfdata.monitor.v2_0; ...@@ -27,8 +27,6 @@ package sun.jvmstat.perfdata.monitor.v2_0;
import sun.jvmstat.monitor.*; import sun.jvmstat.monitor.*;
import sun.jvmstat.perfdata.monitor.*; import sun.jvmstat.perfdata.monitor.*;
import sun.management.counter.Units;
import sun.management.counter.Variability;
import java.util.*; import java.util.*;
import java.util.regex.*; import java.util.regex.*;
import java.nio.*; import java.nio.*;
......
...@@ -44,20 +44,17 @@ final class CompletedFuture<V> implements Future<V> { ...@@ -44,20 +44,17 @@ final class CompletedFuture<V> implements Future<V> {
this.exc = exc; this.exc = exc;
} }
@SuppressWarnings("unchecked")
static <V> CompletedFuture<V> withResult(V result) { static <V> CompletedFuture<V> withResult(V result) {
return new CompletedFuture<V>(result, null); return new CompletedFuture<V>(result, null);
} }
@SuppressWarnings("unchecked")
static <V> CompletedFuture<V> withFailure(Throwable exc) { static <V> CompletedFuture<V> withFailure(Throwable exc) {
// exception must be IOException or SecurityException // exception must be IOException or SecurityException
if (!(exc instanceof IOException) && !(exc instanceof SecurityException)) if (!(exc instanceof IOException) && !(exc instanceof SecurityException))
exc = new IOException(exc); 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) { static <V> CompletedFuture<V> withResult(V result, Throwable exc) {
if (exc == null) { if (exc == null) {
return withResult(result); return withResult(result);
......
...@@ -429,7 +429,7 @@ public class BatchEnvironment extends sun.tools.javac.BatchEnvironment { ...@@ -429,7 +429,7 @@ public class BatchEnvironment extends sun.tools.javac.BatchEnvironment {
st.hasMoreTokens();) { st.hasMoreTokens();) {
String elt = st.nextToken(); String elt = st.nextToken();
if (jarParent != null) if (jarParent != null)
elt = new File(jarParent, elt).toString(); elt = new File(jarParent, elt).getCanonicalPath();
addFile(elt, warn); addFile(elt, warn);
} }
} finally { } finally {
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -344,16 +344,13 @@ public class KrbAsReq extends KrbKdcReq { ...@@ -344,16 +344,13 @@ public class KrbAsReq extends KrbKdcReq {
princName = cname; princName = cname;
EncryptionKey key = null; EncryptionKey key = null;
int[] tktETypes = null; int[] tktETypes = EType.getDefaults("default_tkt_enctypes");
if (pa_exists && pa_etype != EncryptedData.ETYPE_NULL) { if (pa_exists && pa_etype != EncryptedData.ETYPE_NULL) {
if (DEBUG) { if (DEBUG) {
System.out.println("Pre-Authenticaton: find key for etype = " + pa_etype); System.out.println("Pre-Authenticaton: find key for etype = " + pa_etype);
} }
key = EncryptionKey.findKey(pa_etype, keys); key = EncryptionKey.findKey(pa_etype, keys);
tktETypes = new int[1];
tktETypes[0] = pa_etype;
} else { } else {
tktETypes = EType.getDefaults("default_tkt_enctypes", keys);
key = EncryptionKey.findKey(tktETypes[0], keys); key = EncryptionKey.findKey(tktETypes[0], keys);
} }
......
...@@ -57,11 +57,20 @@ import java.io.IOException; ...@@ -57,11 +57,20 @@ import java.io.IOException;
* specification available at * specification available at
* <a href="http://www.ietf.org/rfc/rfc4120.txt"> * <a href="http://www.ietf.org/rfc/rfc4120.txt">
* http://www.ietf.org/rfc/rfc4120.txt</a>. * 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 { public class KerberosTime implements Cloneable {
private long kerberosTime; // milliseconds since epoch, a Date.getTime() value 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 long syncTime;
private static boolean DEBUG = Krb5.DEBUG; private static boolean DEBUG = Krb5.DEBUG;
...@@ -77,9 +86,13 @@ public class KerberosTime implements Cloneable { ...@@ -77,9 +86,13 @@ public class KerberosTime implements Cloneable {
kerberosTime = time; kerberosTime = time;
} }
private KerberosTime(long time, int micro) {
kerberosTime = time;
microSeconds = micro;
}
public Object clone() { public Object clone() {
return new KerberosTime(kerberosTime); return new KerberosTime(kerberosTime, microSeconds);
} }
// This constructor is used in the native code // This constructor is used in the native code
...@@ -109,8 +122,8 @@ public class KerberosTime implements Cloneable { ...@@ -109,8 +122,8 @@ public class KerberosTime implements Cloneable {
// | | | | | | | // | | | | | | |
// 0 4 6 8 | | | // 0 4 6 8 | | |
// 10 | | // 10 | |
// 12 | // 12 |
// 14 // 14
if (time.length() != 15) if (time.length() != 15)
throw new Asn1Exception(Krb5.ASN1_BAD_TIMEFORMAT); throw new Asn1Exception(Krb5.ASN1_BAD_TIMEFORMAT);
...@@ -148,11 +161,8 @@ public class KerberosTime implements Cloneable { ...@@ -148,11 +161,8 @@ public class KerberosTime implements Cloneable {
public KerberosTime(boolean initToNow) { public KerberosTime(boolean initToNow) {
if (initToNow) { if (initToNow) {
Date temp = new Date(); setNow();
setTime(temp);
} }
else
kerberosTime = 0;
} }
/** /**
...@@ -192,10 +202,12 @@ public class KerberosTime implements Cloneable { ...@@ -192,10 +202,12 @@ public class KerberosTime implements Cloneable {
public void setTime(Date time) { public void setTime(Date time) {
kerberosTime = time.getTime(); // (time.getTimezoneOffset() * 60000L); kerberosTime = time.getTime(); // (time.getTimezoneOffset() * 60000L);
microSeconds = 0;
} }
public void setTime(long time) { public void setTime(long time) {
kerberosTime = time; kerberosTime = time;
microSeconds = 0;
} }
public Date toDate() { public Date toDate() {
...@@ -205,16 +217,18 @@ public class KerberosTime implements Cloneable { ...@@ -205,16 +217,18 @@ public class KerberosTime implements Cloneable {
} }
public void setNow() { public void setNow() {
Date temp = new Date(); long microElapsed = System.nanoTime() / 1000 - initMicro;
setTime(temp); setTime(initMilli + microElapsed/1000);
microSeconds = (int)(microElapsed % 1000);
} }
public int getMicroSeconds() { public int getMicroSeconds() {
Long temp_long = new Long((kerberosTime % 1000L) * 1000L); Long temp_long = new Long((kerberosTime % 1000L) * 1000L);
return temp_long.intValue(); return temp_long.intValue() + microSeconds;
} }
public void setMicroSeconds(int usec) { public void setMicroSeconds(int usec) {
microSeconds = usec % 1000;
Integer temp_int = new Integer(usec); Integer temp_int = new Integer(usec);
long temp_long = temp_int.longValue() / 1000L; long temp_long = temp_int.longValue() / 1000L;
kerberosTime = kerberosTime - (kerberosTime % 1000L) + temp_long; kerberosTime = kerberosTime - (kerberosTime % 1000L) + temp_long;
...@@ -222,6 +236,7 @@ public class KerberosTime implements Cloneable { ...@@ -222,6 +236,7 @@ public class KerberosTime implements Cloneable {
public void setMicroSeconds(Integer usec) { public void setMicroSeconds(Integer usec) {
if (usec != null) { if (usec != null) {
microSeconds = usec.intValue() % 1000;
long temp_long = usec.longValue() / 1000L; long temp_long = usec.longValue() / 1000L;
kerberosTime = kerberosTime - (kerberosTime % 1000L) + temp_long; kerberosTime = kerberosTime - (kerberosTime % 1000L) + temp_long;
} }
...@@ -262,7 +277,9 @@ public class KerberosTime implements Cloneable { ...@@ -262,7 +277,9 @@ public class KerberosTime implements Cloneable {
} }
public boolean greaterThan(KerberosTime time) { public boolean greaterThan(KerberosTime time) {
return kerberosTime > time.kerberosTime; return kerberosTime > time.kerberosTime ||
kerberosTime == time.kerberosTime &&
microSeconds > time.microSeconds;
} }
public boolean equals(Object obj) { public boolean equals(Object obj) {
...@@ -274,15 +291,17 @@ public class KerberosTime implements Cloneable { ...@@ -274,15 +291,17 @@ public class KerberosTime implements Cloneable {
return false; return false;
} }
return kerberosTime == ((KerberosTime)obj).kerberosTime; return kerberosTime == ((KerberosTime)obj).kerberosTime &&
microSeconds == ((KerberosTime)obj).microSeconds;
} }
public int hashCode() { 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() { public boolean isZero() {
return kerberosTime == 0; return kerberosTime == 0 && microSeconds == 0;
} }
public int getSeconds() { public int getSeconds() {
......
...@@ -518,6 +518,7 @@ public class X509Factory extends CertificateFactorySpi { ...@@ -518,6 +518,7 @@ public class X509Factory extends CertificateFactorySpi {
// Step 2: Read the rest of header, determine the line end // Step 2: Read the rest of header, determine the line end
int end; int end;
StringBuffer header = new StringBuffer("-----");
while (true) { while (true) {
int next = is.read(); int next = is.read();
if (next == -1) { if (next == -1) {
...@@ -540,6 +541,7 @@ public class X509Factory extends CertificateFactorySpi { ...@@ -540,6 +541,7 @@ public class X509Factory extends CertificateFactorySpi {
} }
break; break;
} }
header.append((char)next);
} }
// Step 3: Read the data // Step 3: Read the data
...@@ -559,6 +561,7 @@ public class X509Factory extends CertificateFactorySpi { ...@@ -559,6 +561,7 @@ public class X509Factory extends CertificateFactorySpi {
} }
// Step 4: Consume the footer // Step 4: Consume the footer
StringBuffer footer = new StringBuffer("-");
while (true) { while (true) {
int next = is.read(); int next = is.read();
// Add next == '\n' for maximum safety, in case endline // Add next == '\n' for maximum safety, in case endline
...@@ -566,13 +569,34 @@ public class X509Factory extends CertificateFactorySpi { ...@@ -566,13 +569,34 @@ public class X509Factory extends CertificateFactorySpi {
if (next == -1 || next == end || next == '\n') { if (next == -1 || next == end || next == '\n') {
break; break;
} }
if (next != '\r') footer.append((char)next);
} }
checkHeaderFooter(header.toString(), footer.toString());
BASE64Decoder decoder = new BASE64Decoder(); BASE64Decoder decoder = new BASE64Decoder();
return decoder.decodeBuffer(new String(data, 0, pos)); 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 * 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 * encoding and will read all of the sub-sections in a recursive way
......
...@@ -1486,7 +1486,7 @@ public class JarSigner { ...@@ -1486,7 +1486,7 @@ public class JarSigner {
for (int i=0; i<len; i++) { for (int i=0; i<len; i++) {
switch (bs[i]) { switch (bs[i]) {
case '\r': case '\r':
if (i < len && bs[i+1] == '\n') i++; if (i < len - 1 && bs[i+1] == '\n') i++;
// fallthrough // fallthrough
case '\n': case '\n':
if (newline) return i+1; //+1 to get length if (newline) return i+1; //+1 to get length
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* questions. * questions.
*/ */
package sun.security.tools; package sun.security.tools.policytool;
import java.io.*; import java.io.*;
import java.util.LinkedList; import java.util.LinkedList;
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
package sun.tools.jstat; package sun.tools.jstat;
import sun.jvmstat.monitor.*; import sun.jvmstat.monitor.*;
import sun.management.counter.Variability;
/** /**
* A class implementing the ExpressionEvaluator to resolve unresolved * A class implementing the ExpressionEvaluator to resolve unresolved
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册