提交 830d7a16 编写于 作者: L lana

Merge

...@@ -41,7 +41,7 @@ import javax.print.attribute.standard.PageRanges; ...@@ -41,7 +41,7 @@ import javax.print.attribute.standard.PageRanges;
import sun.java2d.*; import sun.java2d.*;
import sun.print.*; import sun.print.*;
final class CPrinterJob extends RasterPrinterJob { public final class CPrinterJob extends RasterPrinterJob {
// NOTE: This uses RasterPrinterJob as a base, but it doesn't use // NOTE: This uses RasterPrinterJob as a base, but it doesn't use
// all of the RasterPrinterJob functions. RasterPrinterJob will // all of the RasterPrinterJob functions. RasterPrinterJob will
// break down printing to pieces that aren't necessary under MacOSX // break down printing to pieces that aren't necessary under MacOSX
......
...@@ -384,7 +384,7 @@ public final class Spliterators { ...@@ -384,7 +384,7 @@ public final class Spliterators {
*/ */
private static void checkFromToBounds(int arrayLength, int origin, int fence) { private static void checkFromToBounds(int arrayLength, int origin, int fence) {
if (origin > fence) { if (origin > fence) {
throw new IllegalArgumentException( throw new ArrayIndexOutOfBoundsException(
"origin(" + origin + ") > fence(" + fence + ")"); "origin(" + origin + ") > fence(" + fence + ")");
} }
if (origin < 0) { if (origin < 0) {
......
...@@ -259,41 +259,68 @@ public class ByteVector { ...@@ -259,41 +259,68 @@ public class ByteVector {
if (c >= '\001' && c <= '\177') { if (c >= '\001' && c <= '\177') {
data[len++] = (byte) c; data[len++] = (byte) c;
} else { } else {
int byteLength = i; length = len;
for (int j = i; j < charLength; ++j) { return encodeUTF8(s, i, 65535);
c = s.charAt(j); }
if (c >= '\001' && c <= '\177') { }
byteLength++; length = len;
} else if (c > '\u07FF') { return this;
byteLength += 3; }
} else {
byteLength += 2; /**
} * Puts an UTF8 string into this byte vector. The byte vector is
} * automatically enlarged if necessary. The string length is encoded in two
if (byteLength > 65535) { * bytes before the encoded characters, if there is space for that (i.e. if
throw new IllegalArgumentException(); * this.length - i - 2 >= 0).
} *
data[length] = (byte) (byteLength >>> 8); * @param s
data[length + 1] = (byte) byteLength; * the String to encode.
if (length + 2 + byteLength > data.length) { * @param i
length = len; * the index of the first character to encode. The previous
enlarge(2 + byteLength); * characters are supposed to have already been encoded, using
data = this.data; * only one byte per character.
} * @param maxByteLength
for (int j = i; j < charLength; ++j) { * the maximum byte length of the encoded string, including the
c = s.charAt(j); * already encoded characters.
if (c >= '\001' && c <= '\177') { * @return this byte vector.
data[len++] = (byte) c; */
} else if (c > '\u07FF') { ByteVector encodeUTF8(final String s, int i, int maxByteLength) {
data[len++] = (byte) (0xE0 | c >> 12 & 0xF); int charLength = s.length();
data[len++] = (byte) (0x80 | c >> 6 & 0x3F); int byteLength = i;
data[len++] = (byte) (0x80 | c & 0x3F); char c;
} else { for (int j = i; j < charLength; ++j) {
data[len++] = (byte) (0xC0 | c >> 6 & 0x1F); c = s.charAt(j);
data[len++] = (byte) (0x80 | c & 0x3F); if (c >= '\001' && c <= '\177') {
} byteLength++;
} } else if (c > '\u07FF') {
break; byteLength += 3;
} else {
byteLength += 2;
}
}
if (byteLength > maxByteLength) {
throw new IllegalArgumentException();
}
int start = length - i - 2;
if (start >= 0) {
data[start] = (byte) (byteLength >>> 8);
data[start + 1] = (byte) byteLength;
}
if (length + byteLength - i > data.length) {
enlarge(byteLength - i);
}
int len = length;
for (int j = i; j < charLength; ++j) {
c = s.charAt(j);
if (c >= '\001' && c <= '\177') {
data[len++] = (byte) c;
} else if (c > '\u07FF') {
data[len++] = (byte) (0xE0 | c >> 12 & 0xF);
data[len++] = (byte) (0x80 | c >> 6 & 0x3F);
data[len++] = (byte) (0x80 | c & 0x3F);
} else {
data[len++] = (byte) (0xC0 | c >> 6 & 0x1F);
data[len++] = (byte) (0x80 | c & 0x3F);
} }
} }
length = len; length = len;
......
...@@ -716,7 +716,8 @@ public class ClassWriter extends ClassVisitor { ...@@ -716,7 +716,8 @@ public class ClassWriter extends ClassVisitor {
sourceFile = newUTF8(file); sourceFile = newUTF8(file);
} }
if (debug != null) { if (debug != null) {
sourceDebug = new ByteVector().putUTF8(debug); sourceDebug = new ByteVector().encodeUTF8(debug, 0,
Integer.MAX_VALUE);
} }
} }
...@@ -857,7 +858,7 @@ public class ClassWriter extends ClassVisitor { ...@@ -857,7 +858,7 @@ public class ClassWriter extends ClassVisitor {
} }
if (sourceDebug != null) { if (sourceDebug != null) {
++attributeCount; ++attributeCount;
size += sourceDebug.length + 4; size += sourceDebug.length + 6;
newUTF8("SourceDebugExtension"); newUTF8("SourceDebugExtension");
} }
if (enclosingMethodOwner != 0) { if (enclosingMethodOwner != 0) {
...@@ -946,9 +947,9 @@ public class ClassWriter extends ClassVisitor { ...@@ -946,9 +947,9 @@ public class ClassWriter extends ClassVisitor {
out.putShort(newUTF8("SourceFile")).putInt(2).putShort(sourceFile); out.putShort(newUTF8("SourceFile")).putInt(2).putShort(sourceFile);
} }
if (sourceDebug != null) { if (sourceDebug != null) {
int len = sourceDebug.length - 2; int len = sourceDebug.length;
out.putShort(newUTF8("SourceDebugExtension")).putInt(len); out.putShort(newUTF8("SourceDebugExtension")).putInt(len);
out.putByteArray(sourceDebug.data, 2, len); out.putByteArray(sourceDebug.data, 0, len);
} }
if (enclosingMethodOwner != 0) { if (enclosingMethodOwner != 0) {
out.putShort(newUTF8("EnclosingMethod")).putInt(4); out.putShort(newUTF8("EnclosingMethod")).putInt(4);
......
...@@ -99,8 +99,8 @@ final class Frame { ...@@ -99,8 +99,8 @@ final class Frame {
* stack types. VALUE depends on KIND. For LOCAL types, it is an index in * stack types. VALUE depends on KIND. For LOCAL types, it is an index in
* the input local variable types. For STACK types, it is a position * the input local variable types. For STACK types, it is a position
* relatively to the top of input frame stack. For BASE types, it is either * relatively to the top of input frame stack. For BASE types, it is either
* one of the constants defined in FrameVisitor, or for OBJECT and * one of the constants defined below, or for OBJECT and UNINITIALIZED
* UNINITIALIZED types, a tag and an index in the type table. * types, a tag and an index in the type table.
* *
* Output frames can contain types of any kind and with a positive or * Output frames can contain types of any kind and with a positive or
* negative dimension (and even unassigned types, represented by 0 - which * negative dimension (and even unassigned types, represented by 0 - which
...@@ -537,7 +537,7 @@ final class Frame { ...@@ -537,7 +537,7 @@ final class Frame {
/** /**
* The types that are initialized in the basic block. A constructor * The types that are initialized in the basic block. A constructor
* invocation on an UNINITIALIZED or UNINITIALIZED_THIS type must replace * invocation on an UNINITIALIZED or UNINITIALIZED_THIS type must replace
* <i>every occurrence</i> of this type in the local variables and in the * <i>every occurence</i> of this type in the local variables and in the
* operand stack. This cannot be done during the first phase of the * operand stack. This cannot be done during the first phase of the
* algorithm since, during this phase, the local variables and the operand * algorithm since, during this phase, the local variables and the operand
* stack are not completely computed. It is therefore necessary to store the * stack are not completely computed. It is therefore necessary to store the
...@@ -1446,6 +1446,7 @@ final class Frame { ...@@ -1446,6 +1446,7 @@ final class Frame {
// if t is the NULL type, merge(u,t)=u, so there is no change // if t is the NULL type, merge(u,t)=u, so there is no change
return false; return false;
} else if ((t & (DIM | BASE_KIND)) == (u & (DIM | BASE_KIND))) { } else if ((t & (DIM | BASE_KIND)) == (u & (DIM | BASE_KIND))) {
// if t and u have the same dimension and same base kind
if ((u & BASE_KIND) == OBJECT) { if ((u & BASE_KIND) == OBJECT) {
// if t is also a reference type, and if u and t have the // if t is also a reference type, and if u and t have the
// same dimension merge(u,t) = dim(t) | common parent of the // same dimension merge(u,t) = dim(t) | common parent of the
...@@ -1458,9 +1459,13 @@ final class Frame { ...@@ -1458,9 +1459,13 @@ final class Frame {
v = OBJECT | cw.addType("java/lang/Object"); v = OBJECT | cw.addType("java/lang/Object");
} }
} else if ((t & BASE_KIND) == OBJECT || (t & DIM) != 0) { } else if ((t & BASE_KIND) == OBJECT || (t & DIM) != 0) {
// if t is any other reference or array type, // if t is any other reference or array type, the merged type
// merge(u,t)=java/lang/Object // is Object, or min(dim(u), dim(t)) | java/lang/Object is u
v = OBJECT | cw.addType("java/lang/Object"); // and t have different array dimensions
int tdim = t & DIM;
int udim = u & DIM;
v = (udim != tdim ? Math.min(tdim, udim) : 0) | OBJECT
| cw.addType("java/lang/Object");
} else { } else {
// if t is any other type, merge(u,t)=TOP // if t is any other type, merge(u,t)=TOP
v = TOP; v = TOP;
......
...@@ -240,6 +240,7 @@ public class AnalyzerAdapter extends MethodVisitor { ...@@ -240,6 +240,7 @@ public class AnalyzerAdapter extends MethodVisitor {
locals.add(types[i].getInternalName()); locals.add(types[i].getInternalName());
} }
} }
maxLocals = locals.size();
} }
@Override @Override
...@@ -519,12 +520,12 @@ public class AnalyzerAdapter extends MethodVisitor { ...@@ -519,12 +520,12 @@ public class AnalyzerAdapter extends MethodVisitor {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
private Object get(final int local) { private Object get(final int local) {
maxLocals = Math.max(maxLocals, local); maxLocals = Math.max(maxLocals, local + 1);
return local < locals.size() ? locals.get(local) : Opcodes.TOP; return local < locals.size() ? locals.get(local) : Opcodes.TOP;
} }
private void set(final int local, final Object type) { private void set(final int local, final Object type) {
maxLocals = Math.max(maxLocals, local); maxLocals = Math.max(maxLocals, local + 1);
while (local >= locals.size()) { while (local >= locals.size()) {
locals.add(Opcodes.TOP); locals.add(Opcodes.TOP);
} }
......
...@@ -556,6 +556,8 @@ public class InsnList { ...@@ -556,6 +556,8 @@ public class InsnList {
AbstractInsnNode prev; AbstractInsnNode prev;
AbstractInsnNode remove;
InsnListIterator(int index) { InsnListIterator(int index) {
if (index == size()) { if (index == size()) {
next = null; next = null;
...@@ -577,12 +579,22 @@ public class InsnList { ...@@ -577,12 +579,22 @@ public class InsnList {
AbstractInsnNode result = next; AbstractInsnNode result = next;
prev = result; prev = result;
next = result.next; next = result.next;
remove = result;
return result; return result;
} }
public void remove() { public void remove() {
InsnList.this.remove(prev); if (remove != null) {
prev = prev.prev; if (remove == next) {
next = next.next;
} else {
prev = prev.prev;
}
InsnList.this.remove(remove);
remove = null;
} else {
throw new IllegalStateException();
}
} }
public boolean hasPrevious() { public boolean hasPrevious() {
...@@ -593,6 +605,7 @@ public class InsnList { ...@@ -593,6 +605,7 @@ public class InsnList {
AbstractInsnNode result = prev; AbstractInsnNode result = prev;
next = result; next = result;
prev = result.prev; prev = result.prev;
remove = result;
return result; return result;
} }
...@@ -619,6 +632,7 @@ public class InsnList { ...@@ -619,6 +632,7 @@ public class InsnList {
public void add(Object o) { public void add(Object o) {
InsnList.this.insertBefore(next, (AbstractInsnNode) o); InsnList.this.insertBefore(next, (AbstractInsnNode) o);
prev = (AbstractInsnNode) o; prev = (AbstractInsnNode) o;
remove = null;
} }
public void set(Object o) { public void set(Object o) {
......
...@@ -404,7 +404,7 @@ public class Analyzer<V extends Value> implements Opcodes { ...@@ -404,7 +404,7 @@ public class Analyzer<V extends Value> implements Opcodes {
* instruction of the method. The size of the returned array is * instruction of the method. The size of the returned array is
* equal to the number of instructions (and labels) of the method. A * equal to the number of instructions (and labels) of the method. A
* given frame is <tt>null</tt> if the corresponding instruction * given frame is <tt>null</tt> if the corresponding instruction
* cannot be reached, or if an error occurred during the analysis of * cannot be reached, or if an error occured during the analysis of
* the method. * the method.
*/ */
public Frame<V>[] getFrames() { public Frame<V>[] getFrames() {
......
...@@ -111,7 +111,7 @@ public abstract class Interpreter<V extends Value> { ...@@ -111,7 +111,7 @@ public abstract class Interpreter<V extends Value> {
* the bytecode instruction to be interpreted. * the bytecode instruction to be interpreted.
* @return the result of the interpretation of the given instruction. * @return the result of the interpretation of the given instruction.
* @throws AnalyzerException * @throws AnalyzerException
* if an error occurred during the interpretation. * if an error occured during the interpretation.
*/ */
public abstract V newOperation(AbstractInsnNode insn) public abstract V newOperation(AbstractInsnNode insn)
throws AnalyzerException; throws AnalyzerException;
...@@ -130,7 +130,7 @@ public abstract class Interpreter<V extends Value> { ...@@ -130,7 +130,7 @@ public abstract class Interpreter<V extends Value> {
* @return the result of the interpretation of the given instruction. The * @return the result of the interpretation of the given instruction. The
* returned value must be <tt>equal</tt> to the given value. * returned value must be <tt>equal</tt> to the given value.
* @throws AnalyzerException * @throws AnalyzerException
* if an error occurred during the interpretation. * if an error occured during the interpretation.
*/ */
public abstract V copyOperation(AbstractInsnNode insn, V value) public abstract V copyOperation(AbstractInsnNode insn, V value)
throws AnalyzerException; throws AnalyzerException;
...@@ -151,7 +151,7 @@ public abstract class Interpreter<V extends Value> { ...@@ -151,7 +151,7 @@ public abstract class Interpreter<V extends Value> {
* the argument of the instruction to be interpreted. * the argument of the instruction to be interpreted.
* @return the result of the interpretation of the given instruction. * @return the result of the interpretation of the given instruction.
* @throws AnalyzerException * @throws AnalyzerException
* if an error occurred during the interpretation. * if an error occured during the interpretation.
*/ */
public abstract V unaryOperation(AbstractInsnNode insn, V value) public abstract V unaryOperation(AbstractInsnNode insn, V value)
throws AnalyzerException; throws AnalyzerException;
...@@ -175,7 +175,7 @@ public abstract class Interpreter<V extends Value> { ...@@ -175,7 +175,7 @@ public abstract class Interpreter<V extends Value> {
* the second argument of the instruction to be interpreted. * the second argument of the instruction to be interpreted.
* @return the result of the interpretation of the given instruction. * @return the result of the interpretation of the given instruction.
* @throws AnalyzerException * @throws AnalyzerException
* if an error occurred during the interpretation. * if an error occured during the interpretation.
*/ */
public abstract V binaryOperation(AbstractInsnNode insn, V value1, V value2) public abstract V binaryOperation(AbstractInsnNode insn, V value1, V value2)
throws AnalyzerException; throws AnalyzerException;
...@@ -196,7 +196,7 @@ public abstract class Interpreter<V extends Value> { ...@@ -196,7 +196,7 @@ public abstract class Interpreter<V extends Value> {
* the third argument of the instruction to be interpreted. * the third argument of the instruction to be interpreted.
* @return the result of the interpretation of the given instruction. * @return the result of the interpretation of the given instruction.
* @throws AnalyzerException * @throws AnalyzerException
* if an error occurred during the interpretation. * if an error occured during the interpretation.
*/ */
public abstract V ternaryOperation(AbstractInsnNode insn, V value1, public abstract V ternaryOperation(AbstractInsnNode insn, V value1,
V value2, V value3) throws AnalyzerException; V value2, V value3) throws AnalyzerException;
...@@ -214,7 +214,7 @@ public abstract class Interpreter<V extends Value> { ...@@ -214,7 +214,7 @@ public abstract class Interpreter<V extends Value> {
* the arguments of the instruction to be interpreted. * the arguments of the instruction to be interpreted.
* @return the result of the interpretation of the given instruction. * @return the result of the interpretation of the given instruction.
* @throws AnalyzerException * @throws AnalyzerException
* if an error occurred during the interpretation. * if an error occured during the interpretation.
*/ */
public abstract V naryOperation(AbstractInsnNode insn, public abstract V naryOperation(AbstractInsnNode insn,
List<? extends V> values) throws AnalyzerException; List<? extends V> values) throws AnalyzerException;
...@@ -232,7 +232,7 @@ public abstract class Interpreter<V extends Value> { ...@@ -232,7 +232,7 @@ public abstract class Interpreter<V extends Value> {
* @param expected * @param expected
* the expected return type of the analyzed method. * the expected return type of the analyzed method.
* @throws AnalyzerException * @throws AnalyzerException
* if an error occurred during the interpretation. * if an error occured during the interpretation.
*/ */
public abstract void returnOperation(AbstractInsnNode insn, V value, public abstract void returnOperation(AbstractInsnNode insn, V value,
V expected) throws AnalyzerException; V expected) throws AnalyzerException;
......
...@@ -99,7 +99,7 @@ public class CheckAnnotationAdapter extends AnnotationVisitor { ...@@ -99,7 +99,7 @@ public class CheckAnnotationAdapter extends AnnotationVisitor {
} }
if (value instanceof Type) { if (value instanceof Type) {
int sort = ((Type) value).getSort(); int sort = ((Type) value).getSort();
if (sort != Type.OBJECT && sort != Type.ARRAY) { if (sort == Type.METHOD) {
throw new IllegalArgumentException("Invalid annotation value"); throw new IllegalArgumentException("Invalid annotation value");
} }
} }
......
...@@ -166,6 +166,11 @@ public class Textifier extends Printer { ...@@ -166,6 +166,11 @@ public class Textifier extends Printer {
*/ */
protected Map<Label, String> labelNames; protected Map<Label, String> labelNames;
/**
* Class access flags
*/
private int access;
private int valueNumber = 0; private int valueNumber = 0;
/** /**
...@@ -245,6 +250,7 @@ public class Textifier extends Printer { ...@@ -245,6 +250,7 @@ public class Textifier extends Printer {
public void visit(final int version, final int access, final String name, public void visit(final int version, final int access, final String name,
final String signature, final String superName, final String signature, final String superName,
final String[] interfaces) { final String[] interfaces) {
this.access = access;
int major = version & 0xFFFF; int major = version & 0xFFFF;
int minor = version >>> 16; int minor = version >>> 16;
buf.setLength(0); buf.setLength(0);
...@@ -447,6 +453,11 @@ public class Textifier extends Printer { ...@@ -447,6 +453,11 @@ public class Textifier extends Printer {
if ((access & Opcodes.ACC_BRIDGE) != 0) { if ((access & Opcodes.ACC_BRIDGE) != 0) {
buf.append("bridge "); buf.append("bridge ");
} }
if ((this.access & Opcodes.ACC_INTERFACE) != 0
&& (access & Opcodes.ACC_ABSTRACT) == 0
&& (access & Opcodes.ACC_STATIC) == 0) {
buf.append("default ");
}
buf.append(name); buf.append(name);
appendDescriptor(METHOD_DESCRIPTOR, desc); appendDescriptor(METHOD_DESCRIPTOR, desc);
...@@ -856,7 +867,6 @@ public class Textifier extends Printer { ...@@ -856,7 +867,6 @@ public class Textifier extends Printer {
appendDescriptor(INTERNAL_NAME, owner); appendDescriptor(INTERNAL_NAME, owner);
buf.append('.').append(name).append(' '); buf.append('.').append(name).append(' ');
appendDescriptor(METHOD_DESCRIPTOR, desc); appendDescriptor(METHOD_DESCRIPTOR, desc);
buf.append(' ').append(itf ? "itf" : "");
buf.append('\n'); buf.append('\n');
text.add(buf.toString()); text.add(buf.toString());
} }
...@@ -869,26 +879,35 @@ public class Textifier extends Printer { ...@@ -869,26 +879,35 @@ public class Textifier extends Printer {
buf.append(name); buf.append(name);
appendDescriptor(METHOD_DESCRIPTOR, desc); appendDescriptor(METHOD_DESCRIPTOR, desc);
buf.append(" ["); buf.append(" [");
buf.append('\n');
buf.append(tab3);
appendHandle(bsm); appendHandle(bsm);
buf.append('\n');
buf.append(tab3).append("// arguments:"); buf.append(tab3).append("// arguments:");
if (bsmArgs.length == 0) { if (bsmArgs.length == 0) {
buf.append(" none"); buf.append(" none");
} else { } else {
buf.append('\n').append(tab3); buf.append('\n');
for (int i = 0; i < bsmArgs.length; i++) { for (int i = 0; i < bsmArgs.length; i++) {
buf.append(tab3);
Object cst = bsmArgs[i]; Object cst = bsmArgs[i];
if (cst instanceof String) { if (cst instanceof String) {
Printer.appendString(buf, (String) cst); Printer.appendString(buf, (String) cst);
} else if (cst instanceof Type) { } else if (cst instanceof Type) {
buf.append(((Type) cst).getDescriptor()).append(".class"); Type type = (Type) cst;
if(type.getSort() == Type.METHOD){
appendDescriptor(METHOD_DESCRIPTOR, type.getDescriptor());
} else {
buf.append(type.getDescriptor()).append(".class");
}
} else if (cst instanceof Handle) { } else if (cst instanceof Handle) {
appendHandle((Handle) cst); appendHandle((Handle) cst);
} else { } else {
buf.append(cst); buf.append(cst);
} }
buf.append(", "); buf.append(", \n");
} }
buf.setLength(buf.length() - 2); buf.setLength(buf.length() - 3);
} }
buf.append('\n'); buf.append('\n');
buf.append(tab2).append("]\n"); buf.append(tab2).append("]\n");
...@@ -1234,10 +1253,10 @@ public class Textifier extends Printer { ...@@ -1234,10 +1253,10 @@ public class Textifier extends Printer {
* a handle, non null. * a handle, non null.
*/ */
protected void appendHandle(final Handle h) { protected void appendHandle(final Handle h) {
buf.append('\n').append(tab3);
int tag = h.getTag(); int tag = h.getTag();
buf.append("// handle kind 0x").append(Integer.toHexString(tag)) buf.append("// handle kind 0x").append(Integer.toHexString(tag))
.append(" : "); .append(" : ");
boolean isMethodHandle = false;
switch (tag) { switch (tag) {
case Opcodes.H_GETFIELD: case Opcodes.H_GETFIELD:
buf.append("GETFIELD"); buf.append("GETFIELD");
...@@ -1253,18 +1272,23 @@ public class Textifier extends Printer { ...@@ -1253,18 +1272,23 @@ public class Textifier extends Printer {
break; break;
case Opcodes.H_INVOKEINTERFACE: case Opcodes.H_INVOKEINTERFACE:
buf.append("INVOKEINTERFACE"); buf.append("INVOKEINTERFACE");
isMethodHandle = true;
break; break;
case Opcodes.H_INVOKESPECIAL: case Opcodes.H_INVOKESPECIAL:
buf.append("INVOKESPECIAL"); buf.append("INVOKESPECIAL");
isMethodHandle = true;
break; break;
case Opcodes.H_INVOKESTATIC: case Opcodes.H_INVOKESTATIC:
buf.append("INVOKESTATIC"); buf.append("INVOKESTATIC");
isMethodHandle = true;
break; break;
case Opcodes.H_INVOKEVIRTUAL: case Opcodes.H_INVOKEVIRTUAL:
buf.append("INVOKEVIRTUAL"); buf.append("INVOKEVIRTUAL");
isMethodHandle = true;
break; break;
case Opcodes.H_NEWINVOKESPECIAL: case Opcodes.H_NEWINVOKESPECIAL:
buf.append("NEWINVOKESPECIAL"); buf.append("NEWINVOKESPECIAL");
isMethodHandle = true;
break; break;
} }
buf.append('\n'); buf.append('\n');
...@@ -1272,9 +1296,13 @@ public class Textifier extends Printer { ...@@ -1272,9 +1296,13 @@ public class Textifier extends Printer {
appendDescriptor(INTERNAL_NAME, h.getOwner()); appendDescriptor(INTERNAL_NAME, h.getOwner());
buf.append('.'); buf.append('.');
buf.append(h.getName()); buf.append(h.getName());
buf.append('('); if(!isMethodHandle){
buf.append('(');
}
appendDescriptor(HANDLE_DESCRIPTOR, h.getDesc()); appendDescriptor(HANDLE_DESCRIPTOR, h.getDesc());
buf.append(')').append('\n'); if(!isMethodHandle){
buf.append(')');
}
} }
/** /**
......
Path: . Path: .
Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/ASM_5_0_BETA Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/asm-svn-2014-03-12
URL: svn://svn.forge.objectweb.org/svnroot/asm/trunk/asm URL: file:///svnroot/asm/trunk/asm
Repository Root: svn://svn.forge.objectweb.org/svnroot/asm Repository Root: file:///svnroot/asm
Repository UUID: 271bd773-ee82-43a6-9b2b-1890ed8ce7f9 Repository UUID: 271bd773-ee82-43a6-9b2b-1890ed8ce7f9
Revision: 1700 Revision: 1721
Node Kind: directory Node Kind: directory
Schedule: normal Schedule: normal
Last Changed Author: ebruneton Last Changed Author: ebruneton
Last Changed Rev: 1700 Last Changed Rev: 1721
Last Changed Date: 2013-10-29 20:22:52 +0100 (Tue, 29 Oct 2013) Last Changed Date: 2014-03-02 17:25:35 +0100 (Sun, 02 Mar 2014)
...@@ -2430,6 +2430,8 @@ public final class SunGraphics2D ...@@ -2430,6 +2430,8 @@ public final class SunGraphics2D
surfaceData = NullSurfaceData.theInstance; surfaceData = NullSurfaceData.theInstance;
} }
invalidatePipe();
// this will recalculate the composite clip // this will recalculate the composite clip
setDevClip(surfaceData.getBounds()); setDevClip(surfaceData.getBounds());
......
...@@ -549,12 +549,11 @@ public class Config { ...@@ -549,12 +549,11 @@ public class Config {
previous = line.substring(1).trim(); previous = line.substring(1).trim();
} }
} else { } else {
if (previous == null) { // Lines before the first section are ignored
throw new KrbException( if (previous != null) {
"Config file must starts with a section"); v.add(previous);
previous = line;
} }
v.add(previous);
previous = line;
} }
} }
if (previous != null) { if (previous != null) {
......
...@@ -94,9 +94,6 @@ public final class PKIXCertPathValidator extends CertPathValidatorSpi { ...@@ -94,9 +94,6 @@ public final class PKIXCertPathValidator extends CertPathValidatorSpi {
X509Certificate firstCert = certList.get(0); X509Certificate firstCert = certList.get(0);
// check trusted certificate's subject // check trusted certificate's subject
selector.setSubject(firstCert.getIssuerX500Principal()); selector.setSubject(firstCert.getIssuerX500Principal());
// check the validity period
selector.setValidityPeriod(firstCert.getNotBefore(),
firstCert.getNotAfter());
/* /*
* Facilitate certification path construction with authority * Facilitate certification path construction with authority
* key identifier and subject key identifier. * key identifier and subject key identifier.
......
/* /*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2014, 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
...@@ -83,13 +83,19 @@ void AwtDesktopProperties::GetSystemProperties() { ...@@ -83,13 +83,19 @@ void AwtDesktopProperties::GetSystemProperties() {
HDC dc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL); HDC dc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
if (dc != NULL) { if (dc != NULL) {
SetFontProperty(dc, ANSI_FIXED_FONT, TEXT("win.ansiFixed.font")); try {
SetFontProperty(dc, ANSI_VAR_FONT, TEXT("win.ansiVar.font")); SetFontProperty(dc, ANSI_FIXED_FONT, TEXT("win.ansiFixed.font"));
SetFontProperty(dc, DEVICE_DEFAULT_FONT, TEXT("win.deviceDefault.font")); SetFontProperty(dc, ANSI_VAR_FONT, TEXT("win.ansiVar.font"));
SetFontProperty(dc, DEFAULT_GUI_FONT, TEXT("win.defaultGUI.font")); SetFontProperty(dc, DEVICE_DEFAULT_FONT, TEXT("win.deviceDefault.font"));
SetFontProperty(dc, OEM_FIXED_FONT, TEXT("win.oemFixed.font")); SetFontProperty(dc, DEFAULT_GUI_FONT, TEXT("win.defaultGUI.font"));
SetFontProperty(dc, SYSTEM_FONT, TEXT("win.system.font")); SetFontProperty(dc, OEM_FIXED_FONT, TEXT("win.oemFixed.font"));
SetFontProperty(dc, SYSTEM_FIXED_FONT, TEXT("win.systemFixed.font")); SetFontProperty(dc, SYSTEM_FONT, TEXT("win.system.font"));
SetFontProperty(dc, SYSTEM_FIXED_FONT, TEXT("win.systemFixed.font"));
}
catch (std::bad_alloc&) {
DeleteDC(dc);
throw;
}
DeleteDC(dc); DeleteDC(dc);
} }
} }
...@@ -206,24 +212,35 @@ void AwtDesktopProperties::GetXPStyleProperties() { ...@@ -206,24 +212,35 @@ void AwtDesktopProperties::GetXPStyleProperties() {
LPTSTR value; LPTSTR value;
value = getXPStylePropFromReg(TEXT("ThemeActive")); value = getXPStylePropFromReg(TEXT("ThemeActive"));
SetBooleanProperty(TEXT("win.xpstyle.themeActive"), (value != NULL && *value == _T('1'))); try {
if (value != NULL) { SetBooleanProperty(TEXT("win.xpstyle.themeActive"), (value != NULL && *value == _T('1')));
free(value); if (value != NULL) {
} free(value);
value = getXPStylePropFromReg(TEXT("DllName")); value = NULL;
if (value != NULL) { }
SetStringProperty(TEXT("win.xpstyle.dllName"), value); value = getXPStylePropFromReg(TEXT("DllName"));
free(value); if (value != NULL) {
} SetStringProperty(TEXT("win.xpstyle.dllName"), value);
value = getXPStylePropFromReg(TEXT("SizeName")); free(value);
if (value != NULL) { value = NULL;
SetStringProperty(TEXT("win.xpstyle.sizeName"), value); }
free(value); value = getXPStylePropFromReg(TEXT("SizeName"));
if (value != NULL) {
SetStringProperty(TEXT("win.xpstyle.sizeName"), value);
free(value);
value = NULL;
}
value = getXPStylePropFromReg(TEXT("ColorName"));
if (value != NULL) {
SetStringProperty(TEXT("win.xpstyle.colorName"), value);
free(value);
}
} }
value = getXPStylePropFromReg(TEXT("ColorName")); catch (std::bad_alloc&) {
if (value != NULL) { if (value != NULL) {
SetStringProperty(TEXT("win.xpstyle.colorName"), value); free(value);
free(value); }
throw;
} }
} }
...@@ -564,27 +581,37 @@ void AwtDesktopProperties::GetOtherParameters() { ...@@ -564,27 +581,37 @@ void AwtDesktopProperties::GetOtherParameters() {
// Shell Icon BPP - only honored on platforms before XP // Shell Icon BPP - only honored on platforms before XP
value = getWindowsPropFromReg(TEXT("Control Panel\\Desktop\\WindowMetrics"), value = getWindowsPropFromReg(TEXT("Control Panel\\Desktop\\WindowMetrics"),
TEXT("Shell Icon BPP"), &valueType); TEXT("Shell Icon BPP"), &valueType);
if (value != NULL) {
if (valueType == REG_SZ) { try {
SetStringProperty(TEXT("win.icon.shellIconBPP"), value); if (value != NULL) {
if (valueType == REG_SZ) {
SetStringProperty(TEXT("win.icon.shellIconBPP"), value);
}
free(value);
value = NULL;
} }
free(value);
}
// The following registry settings control the file chooser places bar // The following registry settings control the file chooser places bar
// under the Windows L&F. These settings are not present by default, but // under the Windows L&F. These settings are not present by default, but
// can be enabled using the TweakUI tool from Microsoft. For more info, // can be enabled using the TweakUI tool from Microsoft. For more info,
// see http://msdn.microsoft.com/msdnmag/issues/1100/Registry/ // see http://msdn.microsoft.com/msdnmag/issues/1100/Registry/
// NoPlacesBar is a REG_DWORD, with values 0 or 1 // NoPlacesBar is a REG_DWORD, with values 0 or 1
value = getWindowsPropFromReg(TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32"), value = getWindowsPropFromReg(TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32"),
TEXT("NoPlacesBar"), &valueType); TEXT("NoPlacesBar"), &valueType);
if (value != NULL) { if (value != NULL) {
if (valueType == REG_DWORD) { if (valueType == REG_DWORD) {
SetBooleanProperty(TEXT("win.comdlg.noPlacesBar"), (BOOL)((int)*value != 0)); SetBooleanProperty(TEXT("win.comdlg.noPlacesBar"), (BOOL)((int)*value != 0));
}
free(value);
} }
free(value); }
catch (std::bad_alloc&) {
if (value != NULL) {
free(value);
}
throw;
} }
LPTSTR valueName = TEXT("PlaceN"); LPTSTR valueName = TEXT("PlaceN");
...@@ -592,7 +619,15 @@ void AwtDesktopProperties::GetOtherParameters() { ...@@ -592,7 +619,15 @@ void AwtDesktopProperties::GetOtherParameters() {
lstrcpy(valueNameBuf, valueName); lstrcpy(valueNameBuf, valueName);
LPTSTR propKey = TEXT("win.comdlg.placesBarPlaceN"); LPTSTR propKey = TEXT("win.comdlg.placesBarPlaceN");
LPTSTR propKeyBuf = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, (lstrlen(propKey) + 1), sizeof(TCHAR));
LPTSTR propKeyBuf;
try {
propKeyBuf = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, (lstrlen(propKey) + 1), sizeof(TCHAR));
}
catch (std::bad_alloc&) {
free(valueNameBuf);
throw;
}
lstrcpy(propKeyBuf, propKey); lstrcpy(propKeyBuf, propKey);
int i = 0; int i = 0;
...@@ -601,20 +636,31 @@ void AwtDesktopProperties::GetOtherParameters() { ...@@ -601,20 +636,31 @@ void AwtDesktopProperties::GetOtherParameters() {
propKeyBuf[25] = valueNameBuf[5]; propKeyBuf[25] = valueNameBuf[5];
LPTSTR key = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32\\PlacesBar"); LPTSTR key = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32\\PlacesBar");
if ((value = getWindowsPropFromReg(key, valueNameBuf, &valueType)) != NULL) { try {
if (valueType == REG_DWORD) { value = NULL;
// Value is a CSIDL if ((value = getWindowsPropFromReg(key, valueNameBuf, &valueType)) != NULL) {
SetIntegerProperty(propKeyBuf, (int)*value); if (valueType == REG_DWORD) {
} else { // Value is a CSIDL
// Value is a path SetIntegerProperty(propKeyBuf, (int)*value);
SetStringProperty(propKeyBuf, value); } else {
// Value is a path
SetStringProperty(propKeyBuf, value);
}
free(value);
} }
free(value); }
catch (std::bad_alloc&) {
if (value != NULL) {
free(value);
}
free(propKeyBuf);
free(valueNameBuf);
throw;
} }
} while (value != NULL); } while (value != NULL);
free(valueNameBuf);
free(propKeyBuf); free(propKeyBuf);
free(valueNameBuf);
} }
void AwtDesktopProperties::GetSoundEvents() { void AwtDesktopProperties::GetSoundEvents() {
...@@ -656,14 +702,26 @@ UINT AwtDesktopProperties::GetIntegerParameter(UINT spi) { ...@@ -656,14 +702,26 @@ UINT AwtDesktopProperties::GetIntegerParameter(UINT spi) {
void AwtDesktopProperties::SetStringProperty(LPCTSTR propName, LPTSTR value) { void AwtDesktopProperties::SetStringProperty(LPCTSTR propName, LPTSTR value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
jstring jValue = JNU_NewStringPlatform(GetEnv(), value);
if (jValue == NULL) {
GetEnv()->DeleteLocalRef(key);
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self, GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setStringPropertyID, AwtDesktopProperties::setStringPropertyID,
key, JNU_NewStringPlatform(GetEnv(), value)); key, jValue);
GetEnv()->DeleteLocalRef(jValue);
GetEnv()->DeleteLocalRef(key); GetEnv()->DeleteLocalRef(key);
} }
void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) { void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self, GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setIntegerPropertyID, AwtDesktopProperties::setIntegerPropertyID,
key, (jint)value); key, (jint)value);
...@@ -672,6 +730,9 @@ void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) { ...@@ -672,6 +730,9 @@ void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) {
void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) { void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self, GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setBooleanPropertyID, AwtDesktopProperties::setBooleanPropertyID,
key, value ? JNI_TRUE : JNI_FALSE); key, value ? JNI_TRUE : JNI_FALSE);
...@@ -680,6 +741,9 @@ void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) { ...@@ -680,6 +741,9 @@ void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) {
void AwtDesktopProperties::SetColorProperty(LPCTSTR propName, DWORD value) { void AwtDesktopProperties::SetColorProperty(LPCTSTR propName, DWORD value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self, GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setColorPropertyID, AwtDesktopProperties::setColorPropertyID,
key, GetRValue(value), GetGValue(value), key, GetRValue(value), GetGValue(value),
...@@ -720,6 +784,11 @@ void AwtDesktopProperties::SetFontProperty(HDC dc, int fontID, ...@@ -720,6 +784,11 @@ void AwtDesktopProperties::SetFontProperty(HDC dc, int fontID,
else { else {
fontName = JNU_NewStringPlatform(GetEnv(), face); fontName = JNU_NewStringPlatform(GetEnv(), face);
} }
if (fontName == NULL) {
delete[] face;
throw std::bad_alloc();
}
jint pointSize = metrics.tmHeight - jint pointSize = metrics.tmHeight -
metrics.tmInternalLeading; metrics.tmInternalLeading;
jint style = java_awt_Font_PLAIN; jint style = java_awt_Font_PLAIN;
...@@ -732,11 +801,16 @@ void AwtDesktopProperties::SetFontProperty(HDC dc, int fontID, ...@@ -732,11 +801,16 @@ void AwtDesktopProperties::SetFontProperty(HDC dc, int fontID,
} }
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
GetEnv()->DeleteLocalRef(fontName);
delete[] face;
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self, GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setFontPropertyID, AwtDesktopProperties::setFontPropertyID,
key, fontName, style, pointSize); key, fontName, style, pointSize);
GetEnv()->DeleteLocalRef(fontName);
GetEnv()->DeleteLocalRef(key); GetEnv()->DeleteLocalRef(key);
GetEnv()->DeleteLocalRef(fontName);
} }
} }
delete[] face; delete[] face;
...@@ -750,7 +824,9 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon ...@@ -750,7 +824,9 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon
jint style; jint style;
fontName = JNU_NewStringPlatform(GetEnv(), font.lfFaceName); fontName = JNU_NewStringPlatform(GetEnv(), font.lfFaceName);
if (fontName == NULL) {
throw std::bad_alloc();
}
#if 0 #if 0
HDC hdc; HDC hdc;
int pixelsPerInch = GetDeviceCaps(hdc, LOGPIXELSY); int pixelsPerInch = GetDeviceCaps(hdc, LOGPIXELSY);
...@@ -773,22 +849,31 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon ...@@ -773,22 +849,31 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon
} }
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
GetEnv()->DeleteLocalRef(fontName);
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self, AwtDesktopProperties::setFontPropertyID, GetEnv()->CallVoidMethod(self, AwtDesktopProperties::setFontPropertyID,
key, fontName, style, pointSize); key, fontName, style, pointSize);
GetEnv()->DeleteLocalRef(fontName);
GetEnv()->DeleteLocalRef(key); GetEnv()->DeleteLocalRef(key);
GetEnv()->DeleteLocalRef(fontName);
} }
void AwtDesktopProperties::SetSoundProperty(LPCTSTR propName, LPCTSTR winEventName) { void AwtDesktopProperties::SetSoundProperty(LPCTSTR propName, LPCTSTR winEventName) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
jstring event = JNU_NewStringPlatform(GetEnv(), winEventName); jstring event = JNU_NewStringPlatform(GetEnv(), winEventName);
if (event == NULL) {
GetEnv()->DeleteLocalRef(key);
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self, GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setSoundPropertyID, AwtDesktopProperties::setSoundPropertyID,
key, event); key, event);
GetEnv()->DeleteLocalRef(key);
GetEnv()->DeleteLocalRef(event); GetEnv()->DeleteLocalRef(event);
GetEnv()->DeleteLocalRef(key);
} }
void AwtDesktopProperties::PlayWindowsSound(LPCTSTR event) { void AwtDesktopProperties::PlayWindowsSound(LPCTSTR event) {
...@@ -814,24 +899,37 @@ Java_sun_awt_windows_WDesktopProperties_initIDs(JNIEnv *env, jclass cls) { ...@@ -814,24 +899,37 @@ Java_sun_awt_windows_WDesktopProperties_initIDs(JNIEnv *env, jclass cls) {
AwtDesktopProperties::pDataID = env->GetFieldID(cls, "pData", "J"); AwtDesktopProperties::pDataID = env->GetFieldID(cls, "pData", "J");
DASSERT(AwtDesktopProperties::pDataID != 0); DASSERT(AwtDesktopProperties::pDataID != 0);
CHECK_NULL(AwtDesktopProperties::pDataID);
AwtDesktopProperties::setBooleanPropertyID = env->GetMethodID(cls, "setBooleanProperty", "(Ljava/lang/String;Z)V"); AwtDesktopProperties::setBooleanPropertyID =
env->GetMethodID(cls, "setBooleanProperty", "(Ljava/lang/String;Z)V");
DASSERT(AwtDesktopProperties::setBooleanPropertyID != 0); DASSERT(AwtDesktopProperties::setBooleanPropertyID != 0);
CHECK_NULL(AwtDesktopProperties::setBooleanPropertyID);
AwtDesktopProperties::setIntegerPropertyID = env->GetMethodID(cls, "setIntegerProperty", "(Ljava/lang/String;I)V"); AwtDesktopProperties::setIntegerPropertyID =
env->GetMethodID(cls, "setIntegerProperty", "(Ljava/lang/String;I)V");
DASSERT(AwtDesktopProperties::setIntegerPropertyID != 0); DASSERT(AwtDesktopProperties::setIntegerPropertyID != 0);
CHECK_NULL(AwtDesktopProperties::setIntegerPropertyID);
AwtDesktopProperties::setStringPropertyID = env->GetMethodID(cls, "setStringProperty", "(Ljava/lang/String;Ljava/lang/String;)V"); AwtDesktopProperties::setStringPropertyID =
env->GetMethodID(cls, "setStringProperty", "(Ljava/lang/String;Ljava/lang/String;)V");
DASSERT(AwtDesktopProperties::setStringPropertyID != 0); DASSERT(AwtDesktopProperties::setStringPropertyID != 0);
CHECK_NULL(AwtDesktopProperties::setStringPropertyID);
AwtDesktopProperties::setColorPropertyID = env->GetMethodID(cls, "setColorProperty", "(Ljava/lang/String;III)V"); AwtDesktopProperties::setColorPropertyID =
env->GetMethodID(cls, "setColorProperty", "(Ljava/lang/String;III)V");
DASSERT(AwtDesktopProperties::setColorPropertyID != 0); DASSERT(AwtDesktopProperties::setColorPropertyID != 0);
CHECK_NULL(AwtDesktopProperties::setColorPropertyID);
AwtDesktopProperties::setFontPropertyID = env->GetMethodID(cls, "setFontProperty", "(Ljava/lang/String;Ljava/lang/String;II)V"); AwtDesktopProperties::setFontPropertyID =
env->GetMethodID(cls, "setFontProperty", "(Ljava/lang/String;Ljava/lang/String;II)V");
DASSERT(AwtDesktopProperties::setFontPropertyID != 0); DASSERT(AwtDesktopProperties::setFontPropertyID != 0);
CHECK_NULL(AwtDesktopProperties::setFontPropertyID);
AwtDesktopProperties::setSoundPropertyID = env->GetMethodID(cls, "setSoundProperty", "(Ljava/lang/String;Ljava/lang/String;)V"); AwtDesktopProperties::setSoundPropertyID =
env->GetMethodID(cls, "setSoundProperty", "(Ljava/lang/String;Ljava/lang/String;)V");
DASSERT(AwtDesktopProperties::setSoundPropertyID != 0); DASSERT(AwtDesktopProperties::setSoundPropertyID != 0);
CHECK_NULL(AwtDesktopProperties::setSoundPropertyID);
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
......
/* /*
* Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2014, 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
...@@ -45,12 +45,16 @@ Java_java_awt_Event_initIDs(JNIEnv *env, jclass cls) { ...@@ -45,12 +45,16 @@ Java_java_awt_Event_initIDs(JNIEnv *env, jclass cls) {
TRY; TRY;
AwtEvent::targetID = env->GetFieldID(cls, "target", "Ljava/lang/Object;"); AwtEvent::targetID = env->GetFieldID(cls, "target", "Ljava/lang/Object;");
AwtEvent::xID = env->GetFieldID(cls, "x", "I");
AwtEvent::yID = env->GetFieldID(cls, "y", "I");
DASSERT(AwtEvent::targetID != NULL); DASSERT(AwtEvent::targetID != NULL);
CHECK_NULL(AwtEvent::targetID);
AwtEvent::xID = env->GetFieldID(cls, "x", "I");
DASSERT(AwtEvent::xID != NULL); DASSERT(AwtEvent::xID != NULL);
CHECK_NULL(AwtEvent::xID);
AwtEvent::yID = env->GetFieldID(cls, "y", "I");
DASSERT(AwtEvent::yID != NULL); DASSERT(AwtEvent::yID != NULL);
CHECK_NULL(AwtEvent::yID);
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
......
/* /*
* Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2014, 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
...@@ -45,12 +45,16 @@ Java_java_awt_event_MouseEvent_initIDs(JNIEnv *env, jclass cls) { ...@@ -45,12 +45,16 @@ Java_java_awt_event_MouseEvent_initIDs(JNIEnv *env, jclass cls) {
TRY; TRY;
AwtMouseEvent::xID = env->GetFieldID(cls, "x", "I"); AwtMouseEvent::xID = env->GetFieldID(cls, "x", "I");
AwtMouseEvent::yID = env->GetFieldID(cls, "y", "I");
AwtMouseEvent::buttonID = env->GetFieldID(cls, "button", "I");
DASSERT(AwtMouseEvent::xID != NULL); DASSERT(AwtMouseEvent::xID != NULL);
CHECK_NULL(AwtMouseEvent::xID);
AwtMouseEvent::yID = env->GetFieldID(cls, "y", "I");
DASSERT(AwtMouseEvent::yID != NULL); DASSERT(AwtMouseEvent::yID != NULL);
CHECK_NULL(AwtMouseEvent::yID);
AwtMouseEvent::buttonID = env->GetFieldID(cls, "button", "I");
DASSERT(AwtMouseEvent::buttonID != NULL); DASSERT(AwtMouseEvent::buttonID != NULL);
CHECK_NULL(AwtMouseEvent::buttonID);
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
......
...@@ -229,15 +229,6 @@ sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java solaris-all ...@@ -229,15 +229,6 @@ sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java solaris-all
java/security/KeyPairGenerator/SolarisShortDSA.java solaris-all java/security/KeyPairGenerator/SolarisShortDSA.java solaris-all
sun/security/tools/keytool/standard.sh solaris-all sun/security/tools/keytool/standard.sh solaris-all
# 8000439: NPG: REGRESSION : sun/security/krb5/auto/MaxRetries.java fails with timeout
sun/security/krb5/auto/MaxRetries.java solaris-sparcv9
# 8006690: sun/security/krb5/auto/BadKdc1.java fails intermittently
sun/security/krb5/auto/BadKdc1.java solaris-sparcv9
sun/security/krb5/auto/BadKdc2.java solaris-sparcv9
sun/security/krb5/auto/BadKdc3.java solaris-sparcv9
sun/security/krb5/auto/BadKdc4.java solaris-sparcv9
############################################################################ ############################################################################
# jdk_sound # jdk_sound
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2014, 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 @@
/* /*
test test
@bug 6998877 @bug 6998877 8022531
@summary After double-click on the folder names, FileNameOverrideTest FAILED @summary After double-click on the folder names, FileNameOverrideTest FAILED
@author Sergey.Bylokhov@oracle.com area=awt.filedialog @author Sergey.Bylokhov@oracle.com area=awt.filedialog
@library ../../regtesthelpers @library ../../regtesthelpers
...@@ -59,7 +59,8 @@ public class SaveFileNameOverrideTest extends Applet implements ActionListener { ...@@ -59,7 +59,8 @@ public class SaveFileNameOverrideTest extends Applet implements ActionListener {
String[] instructions = { String[] instructions = {
"1) Click on 'Show File Dialog' button. A file dialog will come up.", "1) Click on 'Show File Dialog' button. A file dialog will come up.",
"2) Double-click on '" + clickDirName + "' and click OK.", "2) Double-click on '" + clickDirName + "' and click a confirmation",
" button, it can be 'OK', 'Save' or any other platform-dependent name.",
"3) See result of the test below" "3) See result of the test below"
}; };
......
#!/bin/ksh -p #!/bin/ksh -p
# #
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2012, 2014, 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
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
# #
# @test # @test
# @bug 6282388 # @bug 6282388 8030640
# @summary Tests that AWT use correct toolkit to be wrapped into HeadlessToolkit # @summary Tests that AWT use correct toolkit to be wrapped into HeadlessToolkit
# @author artem.ananiev@sun.com: area=awt.headless # @author artem.ananiev@sun.com: area=awt.headless
# @compile TestWrapped.java # @compile TestWrapped.java
...@@ -59,30 +59,14 @@ pass() ...@@ -59,30 +59,14 @@ pass()
# Checking for proper OS # Checking for proper OS
OS=`uname -s` OS=`uname -s`
case "$OS" in case "$OS" in
SunOS ) SunOS | Linux | Darwin | CYGWIN* )
VAR="One value for Sun"
DEFAULT_JDK=/usr/local/java/jdk1.2/solaris
FILESEP="/" FILESEP="/"
;; ;;
Linux ) Windows* )
VAR="A different value for Linux"
DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386
FILESEP="/"
;;
Windows* | CYGWIN* )
VAR="A different value for Win32"
DEFAULT_JDK=/usr/local/java/jdk1.2/win32
FILESEP="\\" FILESEP="\\"
;; ;;
Darwin)
VAR="Lets not forget about Mac"
DEFAULT_JDK=$(/usr/libexec/java_home)
FILESEP="/"
;;
# catch all other OSs # catch all other OSs
* ) * )
echo "Unrecognized system! $OS" echo "Unrecognized system! $OS"
...@@ -113,8 +97,7 @@ if [ -z "${TESTJAVA}" ] ; then ...@@ -113,8 +97,7 @@ if [ -z "${TESTJAVA}" ] ; then
# THIS IS THE JDK BEING TESTED. # THIS IS THE JDK BEING TESTED.
if [ -n "$1" ] ; if [ -n "$1" ] ;
then TESTJAVA=$1 then TESTJAVA=$1
else echo "no JDK specified on command line so using default!" else fail "no JDK specified on command line!"
TESTJAVA=$DEFAULT_JDK
fi fi
TESTSRC=. TESTSRC=.
TESTCLASSES=. TESTCLASSES=.
......
/* /*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2014, 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 @@
/* /*
@test @test
@bug 7154072 @bug 7154072 7161320
@summary Tests that key events with modifiers are not swallowed. @summary Tests that key events with modifiers are not swallowed.
@author anton.tarasov: area=awt.focus @author anton.tarasov: area=awt.focus
@library ../../../regtesthelpers @library ../../../regtesthelpers
...@@ -49,6 +49,11 @@ public class SwallowKeyEvents { ...@@ -49,6 +49,11 @@ public class SwallowKeyEvents {
static Robot r; static Robot r;
public static void main(String[] args) { public static void main(String[] args) {
if (sun.awt.OSInfo.getOSType() == sun.awt.OSInfo.OSType.WINDOWS) {
System.out.println("Skipped. Test not for MS Windows.");
return;
}
f.add(t); f.add(t);
f.pack(); f.pack();
f.setVisible(true); f.setVisible(true);
......
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test 8037857
* @summary tests for stream and spliterator factory methods
* @run testng StreamAndSpliterator
*/
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Spliterators;
import static org.testng.Assert.assertNotNull;
public class StreamAndSpliterator {
@Test
public void testStreamNPEs() {
assertThrowsNPE(() -> Arrays.stream((int[]) null, 0, 0));
assertThrowsNPE(() -> Arrays.stream((long[]) null, 0, 0));
assertThrowsNPE(() -> Arrays.stream((double[]) null, 0, 0));
assertThrowsNPE(() -> Arrays.stream((String[]) null, 0, 0));
}
@Test
public void testStreamAIOBEs() {
// origin > fence
assertThrowsAIOOB(() -> Arrays.stream(new int[]{}, 1, 0));
assertThrowsAIOOB(() -> Arrays.stream(new long[]{}, 1, 0));
assertThrowsAIOOB(() -> Arrays.stream(new double[]{}, 1, 0));
assertThrowsAIOOB(() -> Arrays.stream(new String[]{}, 1, 0));
// bad origin
assertThrowsAIOOB(() -> Arrays.stream(new int[]{}, -1, 0));
assertThrowsAIOOB(() -> Arrays.stream(new long[]{}, -1, 0));
assertThrowsAIOOB(() -> Arrays.stream(new double[]{}, -1, 0));
assertThrowsAIOOB(() -> Arrays.stream(new String[]{}, -1, 0));
// bad fence
assertThrowsAIOOB(() -> Arrays.stream(new int[]{}, 0, 1));
assertThrowsAIOOB(() -> Arrays.stream(new long[]{}, 0, 1));
assertThrowsAIOOB(() -> Arrays.stream(new double[]{}, 0, 1));
assertThrowsAIOOB(() -> Arrays.stream(new String[]{}, 0, 1));
}
@Test
public void testSpliteratorNPEs() {
assertThrowsNPE(() -> Arrays.spliterator((int[]) null, 0, 0));
assertThrowsNPE(() -> Arrays.spliterator((long[]) null, 0, 0));
assertThrowsNPE(() -> Arrays.spliterator((double[]) null, 0, 0));
assertThrowsNPE(() -> Arrays.spliterator((String[]) null, 0, 0));
}
@Test
public void testSpliteratorAIOBEs() {
// origin > fence
assertThrowsAIOOB(() -> Arrays.spliterator(new int[]{}, 1, 0));
assertThrowsAIOOB(() -> Arrays.spliterator(new long[]{}, 1, 0));
assertThrowsAIOOB(() -> Arrays.spliterator(new double[]{}, 1, 0));
assertThrowsAIOOB(() -> Arrays.spliterator(new String[]{}, 1, 0));
// bad origin
assertThrowsAIOOB(() -> Arrays.spliterator(new int[]{}, -1, 0));
assertThrowsAIOOB(() -> Arrays.spliterator(new long[]{}, -1, 0));
assertThrowsAIOOB(() -> Arrays.spliterator(new double[]{}, -1, 0));
assertThrowsAIOOB(() -> Arrays.spliterator(new String[]{}, -1, 0));
// bad fence
assertThrowsAIOOB(() -> Arrays.spliterator(new int[]{}, 0, 1));
assertThrowsAIOOB(() -> Arrays.spliterator(new long[]{}, 0, 1));
assertThrowsAIOOB(() -> Arrays.spliterator(new double[]{}, 0, 1));
assertThrowsAIOOB(() -> Arrays.spliterator(new String[]{}, 0, 1));
}
@Test
public void testSpliteratorNPEsFromSpliterators() {
assertThrowsNPE(() -> Spliterators.spliterator((int[]) null, 0, 0, 0));
assertThrowsNPE(() -> Spliterators.spliterator((long[]) null, 0, 0, 0));
assertThrowsNPE(() -> Spliterators.spliterator((double[]) null, 0, 0, 0));
assertThrowsNPE(() -> Spliterators.spliterator((String[]) null, 0, 0, 0));
}
@Test
public void testSpliteratorAIOBEsFromSpliterators() {
// origin > fence
assertThrowsAIOOB(() -> Spliterators.spliterator(new int[]{}, 1, 0, 0));
assertThrowsAIOOB(() -> Spliterators.spliterator(new long[]{}, 1, 0, 0));
assertThrowsAIOOB(() -> Spliterators.spliterator(new double[]{}, 1, 0, 0));
assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, 1, 0, 0));
// bad origin
assertThrowsAIOOB(() -> Spliterators.spliterator(new int[]{}, -1, 0, 0));
assertThrowsAIOOB(() -> Spliterators.spliterator(new long[]{}, -1, 0, 0));
assertThrowsAIOOB(() -> Spliterators.spliterator(new double[]{}, -1, 0, 0));
assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, -1, 0, 0));
// bad fence
assertThrowsAIOOB(() -> Spliterators.spliterator(new int[]{}, 0, 1, 0));
assertThrowsAIOOB(() -> Spliterators.spliterator(new long[]{}, 0, 1, 0));
assertThrowsAIOOB(() -> Spliterators.spliterator(new double[]{}, 0, 1, 0));
assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, 0, 1, 0));
}
void assertThrowsNPE(Runnable r) {
NullPointerException caught = null;
try {
r.run();
}
catch (NullPointerException e) {
caught = e;
}
assertNotNull(caught, "NullPointerException not thrown");
}
void assertThrowsAIOOB(Runnable r) {
ArrayIndexOutOfBoundsException caught = null;
try {
r.run();
}
catch (ArrayIndexOutOfBoundsException e) {
caught = e;
}
assertNotNull(caught, "ArrayIndexOutOfBoundsException not thrown");
}
}
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8036022
* @summary Test verifies that drawing shapes with XOR composite
* does not trigger an InternalError in GDI surface data.
* @run main/othervm -Dsun.java2d.d3d=True DrawXORModeTest
*/
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Stroke;
import java.awt.geom.Line2D;
import java.util.concurrent.CountDownLatch;
public class DrawXORModeTest extends Component {
public static void main(String[] args) {
final DrawXORModeTest c = new DrawXORModeTest();
final Frame f = new Frame("XOR mode test");
f.add(c);
f.pack();
f.setVisible(true);
try {
c.checkResult();
} finally {
f.dispose();
}
}
@Override
public void paint(Graphics g) {
if (g == null || !(g instanceof Graphics2D)) {
return;
}
g.setColor(Color.white);
g.setXORMode(Color.black);
Graphics2D dg = (Graphics2D) g;
Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER,
10.0f,
new float[]{1.0f, 1.0f},
0.0f);
dg.setStroke(stroke);
try {
dg.draw(new Line2D.Float(10, 10, 20, 20));
} catch (Throwable e) {
synchronized (this) {
theError = e;
}
} finally {
didDraw.countDown();
}
}
@Override
public Dimension getPreferredSize() {
return new Dimension(400, 100);
}
public void checkResult() {
try {
didDraw.await();
} catch (InterruptedException e) {
}
synchronized (this) {
if (theError != null) {
System.out.println("Error: " + theError);
throw new RuntimeException("Test FAILED.");
}
}
System.out.println("Test PASSED.");
}
private Throwable theError = null;
private final CountDownLatch didDraw = new CountDownLatch(1);
}
...@@ -39,7 +39,29 @@ public class BadKdc { ...@@ -39,7 +39,29 @@ public class BadKdc {
// ^ kdc# ^ timeout // ^ kdc# ^ timeout
static final Pattern re = Pattern.compile( static final Pattern re = Pattern.compile(
">>> KDCCommunication: kdc=kdc.rabbit.hole UDP:(\\d)...., " + ">>> KDCCommunication: kdc=kdc.rabbit.hole UDP:(\\d)...., " +
"timeout=(\\d)000,"); "timeout=(\\d+),");
// Ratio for timeout values of all timeout tests. Not final so that
// each test can choose their own.
static float ratio = 2f;
static void setRatio(float ratio) {
BadKdc.ratio = ratio;
}
static float getRatio() {
return ratio;
}
// Gets real timeout value. This method is called when writing krb5.conf
static int toReal(int from) {
return (int)(from * ratio + .5);
}
// De-ratio a millisecond value to second
static int toSymbolicSec(int from) {
return (int)(from / ratio / 1000f + 0.5);
}
/* /*
* There are several cases this test fails: * There are several cases this test fails:
...@@ -101,7 +123,7 @@ public class BadKdc { ...@@ -101,7 +123,7 @@ public class BadKdc {
fw.write("[libdefaults]\n" + fw.write("[libdefaults]\n" +
"default_realm = " + OneKDC.REALM + "\n" + "default_realm = " + OneKDC.REALM + "\n" +
"kdc_timeout = 2000\n"); "kdc_timeout = " + toReal(2000) + "\n");
fw.write("[realms]\n" + OneKDC.REALM + " = {\n" + fw.write("[realms]\n" + OneKDC.REALM + " = {\n" +
"kdc = " + OneKDC.KDCHOST + ":" + p1 + "\n" + "kdc = " + OneKDC.KDCHOST + ":" + p1 + "\n" +
"kdc = " + OneKDC.KDCHOST + ":" + p2 + "\n" + "kdc = " + OneKDC.KDCHOST + ":" + p2 + "\n" +
...@@ -184,7 +206,8 @@ public class BadKdc { ...@@ -184,7 +206,8 @@ public class BadKdc {
Matcher m = re.matcher(line); Matcher m = re.matcher(line);
if (m.find()) { if (m.find()) {
System.out.println(line); System.out.println(line);
sb.append(m.group(1)).append(m.group(2)); sb.append(m.group(1))
.append(toSymbolicSec(Integer.parseInt(m.group(2))));
} }
} }
if (failed) sb.append('-'); if (failed) sb.append('-');
......
...@@ -28,14 +28,21 @@ ...@@ -28,14 +28,21 @@
* @summary krb5 should not try to access unavailable kdc too often * @summary krb5 should not try to access unavailable kdc too often
*/ */
import java.io.*;
import java.security.Security; import java.security.Security;
public class BadKdc1 { public class BadKdc1 {
public static void main(String[] args) public static void main(String[] args)
throws Exception { throws Exception {
Security.setProperty("krb5.kdc.bad.policy", "tryLess");
// 5 sec is default timeout for tryLess
if (BadKdc.getRatio() > 2.5) {
Security.setProperty("krb5.kdc.bad.policy",
"tryLess:1," + BadKdc.toReal(2000));
} else {
Security.setProperty("krb5.kdc.bad.policy", "tryLess");
}
BadKdc.go( BadKdc.go(
"121212222222(32){1,2}1222(32){1,2}", // 1 2 "121212222222(32){1,2}1222(32){1,2}", // 1 2
// The above line means try kdc1 for 2 seconds then kdc1 // The above line means try kdc1 for 2 seconds then kdc1
......
...@@ -35,7 +35,12 @@ public class BadKdc2 { ...@@ -35,7 +35,12 @@ public class BadKdc2 {
public static void main(String[] args) public static void main(String[] args)
throws Exception { throws Exception {
Security.setProperty("krb5.kdc.bad.policy", "tryLess:2,1000");
// 1 sec is too short.
BadKdc.setRatio(3.0f);
Security.setProperty(
"krb5.kdc.bad.policy", "tryLess:2," + BadKdc.toReal(1000));
BadKdc.go( BadKdc.go(
"121212222222(32){1,2}11112121(32){1,2}", // 1 2 "121212222222(32){1,2}11112121(32){1,2}", // 1 2
"11112121(32){1,2}11112121(32){1,2}", // 1 2 "11112121(32){1,2}11112121(32){1,2}", // 1 2
......
...@@ -60,7 +60,7 @@ public class MaxRetries { ...@@ -60,7 +60,7 @@ public class MaxRetries {
test1(5000, 2); // 2 2 test1(5000, 2); // 2 2
// For tryLess // For tryLess
Security.setProperty("krb5.kdc.bad.policy", "tryless"); Security.setProperty("krb5.kdc.bad.policy", "tryless:1," + BadKdc.toReal(5000));
rewriteMaxRetries(4); rewriteMaxRetries(4);
test1(4000, 7); // 1 1 1 1 2 1 2 test1(4000, 7); // 1 1 1 1 2 1 2
test1(4000, 4); // 1 2 1 2 test1(4000, 4); // 1 2 1 2
...@@ -94,7 +94,7 @@ public class MaxRetries { ...@@ -94,7 +94,7 @@ public class MaxRetries {
* @param count the expected total try * @param count the expected total try
*/ */
private static void test1(int timeout, int count) throws Exception { private static void test1(int timeout, int count) throws Exception {
String timeoutTag = "timeout=" + timeout; String timeoutTag = "timeout=" + BadKdc.toReal(timeout);
ByteArrayOutputStream bo = new ByteArrayOutputStream(); ByteArrayOutputStream bo = new ByteArrayOutputStream();
PrintStream oldout = System.out; PrintStream oldout = System.out;
System.setOut(new PrintStream(bo)); System.setOut(new PrintStream(bo));
...@@ -192,12 +192,12 @@ public class MaxRetries { ...@@ -192,12 +192,12 @@ public class MaxRetries {
if (s.startsWith("[realms]")) { if (s.startsWith("[realms]")) {
// Reconfig global setting // Reconfig global setting
fw.write("max_retries = 2\n"); fw.write("max_retries = 2\n");
fw.write("kdc_timeout = 5000\n"); fw.write("kdc_timeout = " + BadKdc.toReal(5000) + "\n");
} else if (s.trim().startsWith("kdc = ")) { } else if (s.trim().startsWith("kdc = ")) {
if (value != -1) { if (value != -1) {
// Reconfig for realm // Reconfig for realm
fw.write(" max_retries = " + value + "\n"); fw.write(" max_retries = " + value + "\n");
fw.write(" kdc_timeout = " + (value*1000) + "\n"); fw.write(" kdc_timeout = " + BadKdc.toReal(value*1000) + "\n");
} }
// Add a bad KDC as the first candidate // Add a bad KDC as the first candidate
fw.write(" kdc = localhost:33333\n"); fw.write(" kdc = localhost:33333\n");
......
...@@ -63,7 +63,7 @@ public class TcpTimeout { ...@@ -63,7 +63,7 @@ public class TcpTimeout {
"udp_preference_limit = 1\n" + "udp_preference_limit = 1\n" +
"max_retries = 2\n" + "max_retries = 2\n" +
"default_realm = " + OneKDC.REALM + "\n" + "default_realm = " + OneKDC.REALM + "\n" +
"kdc_timeout = 5000\n"); "kdc_timeout = " + BadKdc.toReal(5000) + "\n");
fw.write("[realms]\n" + OneKDC.REALM + " = {\n" + fw.write("[realms]\n" + OneKDC.REALM + " = {\n" +
"kdc = " + OneKDC.KDCHOST + ":" + p1 + "\n" + "kdc = " + OneKDC.KDCHOST + ":" + p1 + "\n" +
"kdc = " + OneKDC.KDCHOST + ":" + p2 + "\n" + "kdc = " + OneKDC.KDCHOST + ":" + p2 + "\n" +
......
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8036971
* @compile -XDignore.symbol.file ExtraLines.java
* @run main/othervm ExtraLines
* @summary krb5.conf does not accept directive lines before the first section
*/
import sun.security.krb5.Config;
import java.nio.file.*;
import java.util.Objects;
public class ExtraLines {
public static void main(String[] args) throws Exception {
Path base = Paths.get("krb5.conf");
Path include = Paths.get("included.conf");
String baseConf = "include " + include.toAbsolutePath().toString()
+ "\n[x]\na = b\n";
String includeConf = "[y]\nc = d\n";
Files.write(include, includeConf.getBytes());
Files.write(base, baseConf.getBytes());
System.setProperty("java.security.krb5.conf", base.toString());
Config.refresh();
if (!Objects.equals(Config.getInstance().get("x", "a"), "b")) {
throw new Exception("Failed");
}
}
}
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8021804
* @summary CertPath should validate even if the validity period of the
* root cert does not include the validity period of a subordinate
* cert.
*/
import java.io.ByteArrayInputStream;
import java.security.cert.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
public class Validity {
/*
* Subject: OU=TestOrg, CN=TestCA
* Issuer: OU=TestOrg, CN=TestCA
* Validity
* Not Before: Feb 26 21:33:55 2014 GMT
Not After : Feb 26 21:33:55 2024 GMT
* Version 1
*/
static String CACertStr =
"-----BEGIN CERTIFICATE-----\n" +
"MIIBvTCCASYCCQCQRiTo4lBCFjANBgkqhkiG9w0BAQUFADAjMRAwDgYDVQQLDAdU\n" +
"ZXN0T3JnMQ8wDQYDVQQDDAZUZXN0Q0EwHhcNMTQwMjI2MjEzMzU1WhcNMjQwMjI2\n" +
"MjEzMzU1WjAjMRAwDgYDVQQLDAdUZXN0T3JnMQ8wDQYDVQQDDAZUZXN0Q0EwgZ8w\n" +
"DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOtKS4ZrsM3ansd61ZxitcrN0w184I+A\n" +
"z0kyrSP1eMtlam+cC2U91NpTz11FYV4XUfBhqqxaXW043AWTUer8pS90Pt4sCrUX\n" +
"COx1+QA1M3ZhbZ4sTM7XQ90JbGaBJ/sEza9mlQP7hQ2yQO/hATKbP6J5qvgG2sT2\n" +
"S2WYjEgwNwmFAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAQ/CXEpnx2WY4LJtv4jwE\n" +
"4jIVirur3pdzV5oBhPyqqHMsyhQBkukCfX7uD7L5wN1+xuM81DfANpIxlnUfybp5\n" +
"CpjcmktLpmyK4kJ6XnSd2blbLOIpsr9x6FqxPxpVDlyw/ySHYrIG/GZdsLHgmzGn\n" +
"B06jeYzH8OLf879VxAxSsPc=\n" +
"-----END CERTIFICATE-----";
/*
* Subject: OU=TestOrg, CN=TestEE0
* Issuer: OU=TestOrg, CN=TestCA
* Validity
* Not Before: Feb 26 22:55:12 2014 GMT
* Not After : Feb 25 22:55:12 2025 GMT
* Version 1
*/
static String EECertStr =
"-----BEGIN CERTIFICATE-----\n" +
"MIIBtjCCAR8CAQQwDQYJKoZIhvcNAQEFBQAwIzEQMA4GA1UECwwHVGVzdE9yZzEP\n" +
"MA0GA1UEAwwGVGVzdENBMB4XDTE0MDIyNjIyNTUxMloXDTI1MDIyNTIyNTUxMlow\n" +
"JDEQMA4GA1UECwwHVGVzdE9yZzEQMA4GA1UEAwwHVGVzdEVFMDCBnzANBgkqhkiG\n" +
"9w0BAQEFAAOBjQAwgYkCgYEAt8xz9W3ruCTHjSOtTX6cxsUZ0nRP6EavEfzgcOYh\n" +
"CXGA0gr+viSHq3c2vQBxiRny2hm5rLcqpPo+2OxZtw/ajxfyrV6d/r8YyQLBvyl3\n" +
"xdCZdOkG1DCM1oFAQDaSRt9wN5Zm5kyg7uMig5Y4L45fP9Yee4x6Xyh36qYbsR89\n" +
"rFMCAwEAATANBgkqhkiG9w0BAQUFAAOBgQDZrPqSo08va1m9TOWOztTuWilGdjK/\n" +
"2Ed2WXg8utIpy6uAV+NaOYtHQ7ULQBVRNmwg9nKghbVbh+E/xpoihjl1x7OXass4\n" +
"TbwXA5GKFIFpNtDvATQ/QQZoCuCzw1FW/mH0Q7UEQ/9/iJdDad6ebkapeMwtj/8B\n" +
"s2IZV7s85CEOXw==\n" +
"-----END CERTIFICATE-----";
public static void main(String[] args) throws Exception {
String[] certStrs = {EECertStr};
String[] trustedCertStrs = {CACertStr};
runTest(certStrs, trustedCertStrs);
System.out.println("Test passed.");
}
private static void runTest(String[] certStrs,
String[] trustedCertStrs)
throws Exception {
CertificateFactory cf = CertificateFactory.getInstance("X509");
// Generate the CertPath from the certs named in certStrs
ArrayList<X509Certificate> certs = new ArrayList<>();
for (String certStr : certStrs) {
certs.add(generateCert(certStr, cf));
}
CertPath cp = cf.generateCertPath(certs);
// Generate the set of Trust Anchors from the certs named in
// trustedCertStrs
Set<TrustAnchor> trustAnchors = new HashSet<>();
for (String trustedCertStr : trustedCertStrs) {
TrustAnchor ta = new TrustAnchor(generateCert(trustedCertStr, cf),
null);
trustAnchors.add(ta);
}
PKIXParameters params = new PKIXParameters(trustAnchors);
params.setDate(new Date(114, 3, 1)); // 2014-03-01
params.setRevocationEnabled(false);
// Attempt to validate the CertPath. If no exception thrown, successful.
CertPathValidator cpv = CertPathValidator.getInstance("PKIX");
cpv.validate(cp, params);
System.out.println("CertPath validation successful.");
}
private static X509Certificate generateCert(String certStr,
CertificateFactory cf)
throws Exception {
ByteArrayInputStream stream
= new ByteArrayInputStream(certStr.getBytes());
return (X509Certificate) cf.generateCertificate(stream);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册