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

Merge

......@@ -41,7 +41,7 @@ import javax.print.attribute.standard.PageRanges;
import sun.java2d.*;
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
// all of the RasterPrinterJob functions. RasterPrinterJob will
// break down printing to pieces that aren't necessary under MacOSX
......
......@@ -384,7 +384,7 @@ public final class Spliterators {
*/
private static void checkFromToBounds(int arrayLength, int origin, int fence) {
if (origin > fence) {
throw new IllegalArgumentException(
throw new ArrayIndexOutOfBoundsException(
"origin(" + origin + ") > fence(" + fence + ")");
}
if (origin < 0) {
......
......@@ -259,7 +259,35 @@ public class ByteVector {
if (c >= '\001' && c <= '\177') {
data[len++] = (byte) c;
} else {
length = len;
return encodeUTF8(s, i, 65535);
}
}
length = len;
return this;
}
/**
* Puts an UTF8 string into this byte vector. The byte vector is
* automatically enlarged if necessary. The string length is encoded in two
* bytes before the encoded characters, if there is space for that (i.e. if
* this.length - i - 2 >= 0).
*
* @param s
* the String to encode.
* @param i
* the index of the first character to encode. The previous
* characters are supposed to have already been encoded, using
* only one byte per character.
* @param maxByteLength
* the maximum byte length of the encoded string, including the
* already encoded characters.
* @return this byte vector.
*/
ByteVector encodeUTF8(final String s, int i, int maxByteLength) {
int charLength = s.length();
int byteLength = i;
char c;
for (int j = i; j < charLength; ++j) {
c = s.charAt(j);
if (c >= '\001' && c <= '\177') {
......@@ -270,16 +298,18 @@ public class ByteVector {
byteLength += 2;
}
}
if (byteLength > 65535) {
if (byteLength > maxByteLength) {
throw new IllegalArgumentException();
}
data[length] = (byte) (byteLength >>> 8);
data[length + 1] = (byte) byteLength;
if (length + 2 + byteLength > data.length) {
length = len;
enlarge(2 + byteLength);
data = this.data;
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') {
......@@ -293,9 +323,6 @@ public class ByteVector {
data[len++] = (byte) (0x80 | c & 0x3F);
}
}
break;
}
}
length = len;
return this;
}
......
......@@ -716,7 +716,8 @@ public class ClassWriter extends ClassVisitor {
sourceFile = newUTF8(file);
}
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 {
}
if (sourceDebug != null) {
++attributeCount;
size += sourceDebug.length + 4;
size += sourceDebug.length + 6;
newUTF8("SourceDebugExtension");
}
if (enclosingMethodOwner != 0) {
......@@ -946,9 +947,9 @@ public class ClassWriter extends ClassVisitor {
out.putShort(newUTF8("SourceFile")).putInt(2).putShort(sourceFile);
}
if (sourceDebug != null) {
int len = sourceDebug.length - 2;
int len = sourceDebug.length;
out.putShort(newUTF8("SourceDebugExtension")).putInt(len);
out.putByteArray(sourceDebug.data, 2, len);
out.putByteArray(sourceDebug.data, 0, len);
}
if (enclosingMethodOwner != 0) {
out.putShort(newUTF8("EnclosingMethod")).putInt(4);
......
......@@ -99,8 +99,8 @@ final class Frame {
* 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
* 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
* UNINITIALIZED types, a tag and an index in the type table.
* one of the constants defined below, or for OBJECT and UNINITIALIZED
* types, a tag and an index in the type table.
*
* Output frames can contain types of any kind and with a positive or
* negative dimension (and even unassigned types, represented by 0 - which
......@@ -537,7 +537,7 @@ final class Frame {
/**
* The types that are initialized in the basic block. A constructor
* 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
* algorithm since, during this phase, the local variables and the operand
* stack are not completely computed. It is therefore necessary to store the
......@@ -1446,6 +1446,7 @@ final class Frame {
// if t is the NULL type, merge(u,t)=u, so there is no change
return false;
} 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 t is also a reference type, and if u and t have the
// same dimension merge(u,t) = dim(t) | common parent of the
......@@ -1458,9 +1459,13 @@ final class Frame {
v = OBJECT | cw.addType("java/lang/Object");
}
} else if ((t & BASE_KIND) == OBJECT || (t & DIM) != 0) {
// if t is any other reference or array type,
// merge(u,t)=java/lang/Object
v = OBJECT | cw.addType("java/lang/Object");
// if t is any other reference or array type, the merged type
// is Object, or min(dim(u), dim(t)) | java/lang/Object is u
// 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 {
// if t is any other type, merge(u,t)=TOP
v = TOP;
......
......@@ -240,6 +240,7 @@ public class AnalyzerAdapter extends MethodVisitor {
locals.add(types[i].getInternalName());
}
}
maxLocals = locals.size();
}
@Override
......@@ -519,12 +520,12 @@ public class AnalyzerAdapter extends MethodVisitor {
// ------------------------------------------------------------------------
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;
}
private void set(final int local, final Object type) {
maxLocals = Math.max(maxLocals, local);
maxLocals = Math.max(maxLocals, local + 1);
while (local >= locals.size()) {
locals.add(Opcodes.TOP);
}
......
......@@ -556,6 +556,8 @@ public class InsnList {
AbstractInsnNode prev;
AbstractInsnNode remove;
InsnListIterator(int index) {
if (index == size()) {
next = null;
......@@ -577,13 +579,23 @@ public class InsnList {
AbstractInsnNode result = next;
prev = result;
next = result.next;
remove = result;
return result;
}
public void remove() {
InsnList.this.remove(prev);
if (remove != null) {
if (remove == next) {
next = next.next;
} else {
prev = prev.prev;
}
InsnList.this.remove(remove);
remove = null;
} else {
throw new IllegalStateException();
}
}
public boolean hasPrevious() {
return prev != null;
......@@ -593,6 +605,7 @@ public class InsnList {
AbstractInsnNode result = prev;
next = result;
prev = result.prev;
remove = result;
return result;
}
......@@ -619,6 +632,7 @@ public class InsnList {
public void add(Object o) {
InsnList.this.insertBefore(next, (AbstractInsnNode) o);
prev = (AbstractInsnNode) o;
remove = null;
}
public void set(Object o) {
......
......@@ -404,7 +404,7 @@ public class Analyzer<V extends Value> implements Opcodes {
* instruction of the method. The size of the returned array is
* equal to the number of instructions (and labels) of the method. A
* 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.
*/
public Frame<V>[] getFrames() {
......
......@@ -111,7 +111,7 @@ public abstract class Interpreter<V extends Value> {
* the bytecode instruction to be interpreted.
* @return the result of the interpretation of the given instruction.
* @throws AnalyzerException
* if an error occurred during the interpretation.
* if an error occured during the interpretation.
*/
public abstract V newOperation(AbstractInsnNode insn)
throws AnalyzerException;
......@@ -130,7 +130,7 @@ public abstract class Interpreter<V extends Value> {
* @return the result of the interpretation of the given instruction. The
* returned value must be <tt>equal</tt> to the given value.
* @throws AnalyzerException
* if an error occurred during the interpretation.
* if an error occured during the interpretation.
*/
public abstract V copyOperation(AbstractInsnNode insn, V value)
throws AnalyzerException;
......@@ -151,7 +151,7 @@ public abstract class Interpreter<V extends Value> {
* the argument of the instruction to be interpreted.
* @return the result of the interpretation of the given instruction.
* @throws AnalyzerException
* if an error occurred during the interpretation.
* if an error occured during the interpretation.
*/
public abstract V unaryOperation(AbstractInsnNode insn, V value)
throws AnalyzerException;
......@@ -175,7 +175,7 @@ public abstract class Interpreter<V extends Value> {
* the second argument of the instruction to be interpreted.
* @return the result of the interpretation of the given instruction.
* @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)
throws AnalyzerException;
......@@ -196,7 +196,7 @@ public abstract class Interpreter<V extends Value> {
* the third argument of the instruction to be interpreted.
* @return the result of the interpretation of the given instruction.
* @throws AnalyzerException
* if an error occurred during the interpretation.
* if an error occured during the interpretation.
*/
public abstract V ternaryOperation(AbstractInsnNode insn, V value1,
V value2, V value3) throws AnalyzerException;
......@@ -214,7 +214,7 @@ public abstract class Interpreter<V extends Value> {
* the arguments of the instruction to be interpreted.
* @return the result of the interpretation of the given instruction.
* @throws AnalyzerException
* if an error occurred during the interpretation.
* if an error occured during the interpretation.
*/
public abstract V naryOperation(AbstractInsnNode insn,
List<? extends V> values) throws AnalyzerException;
......@@ -232,7 +232,7 @@ public abstract class Interpreter<V extends Value> {
* @param expected
* the expected return type of the analyzed method.
* @throws AnalyzerException
* if an error occurred during the interpretation.
* if an error occured during the interpretation.
*/
public abstract void returnOperation(AbstractInsnNode insn, V value,
V expected) throws AnalyzerException;
......
......@@ -99,7 +99,7 @@ public class CheckAnnotationAdapter extends AnnotationVisitor {
}
if (value instanceof Type) {
int sort = ((Type) value).getSort();
if (sort != Type.OBJECT && sort != Type.ARRAY) {
if (sort == Type.METHOD) {
throw new IllegalArgumentException("Invalid annotation value");
}
}
......
......@@ -166,6 +166,11 @@ public class Textifier extends Printer {
*/
protected Map<Label, String> labelNames;
/**
* Class access flags
*/
private int access;
private int valueNumber = 0;
/**
......@@ -245,6 +250,7 @@ public class Textifier extends Printer {
public void visit(final int version, final int access, final String name,
final String signature, final String superName,
final String[] interfaces) {
this.access = access;
int major = version & 0xFFFF;
int minor = version >>> 16;
buf.setLength(0);
......@@ -447,6 +453,11 @@ public class Textifier extends Printer {
if ((access & Opcodes.ACC_BRIDGE) != 0) {
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);
appendDescriptor(METHOD_DESCRIPTOR, desc);
......@@ -856,7 +867,6 @@ public class Textifier extends Printer {
appendDescriptor(INTERNAL_NAME, owner);
buf.append('.').append(name).append(' ');
appendDescriptor(METHOD_DESCRIPTOR, desc);
buf.append(' ').append(itf ? "itf" : "");
buf.append('\n');
text.add(buf.toString());
}
......@@ -869,26 +879,35 @@ public class Textifier extends Printer {
buf.append(name);
appendDescriptor(METHOD_DESCRIPTOR, desc);
buf.append(" [");
buf.append('\n');
buf.append(tab3);
appendHandle(bsm);
buf.append('\n');
buf.append(tab3).append("// arguments:");
if (bsmArgs.length == 0) {
buf.append(" none");
} else {
buf.append('\n').append(tab3);
buf.append('\n');
for (int i = 0; i < bsmArgs.length; i++) {
buf.append(tab3);
Object cst = bsmArgs[i];
if (cst instanceof String) {
Printer.appendString(buf, (String) cst);
} 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) {
appendHandle((Handle) cst);
} else {
buf.append(cst);
}
buf.append(", ");
buf.append(", \n");
}
buf.setLength(buf.length() - 2);
buf.setLength(buf.length() - 3);
}
buf.append('\n');
buf.append(tab2).append("]\n");
......@@ -1234,10 +1253,10 @@ public class Textifier extends Printer {
* a handle, non null.
*/
protected void appendHandle(final Handle h) {
buf.append('\n').append(tab3);
int tag = h.getTag();
buf.append("// handle kind 0x").append(Integer.toHexString(tag))
.append(" : ");
boolean isMethodHandle = false;
switch (tag) {
case Opcodes.H_GETFIELD:
buf.append("GETFIELD");
......@@ -1253,18 +1272,23 @@ public class Textifier extends Printer {
break;
case Opcodes.H_INVOKEINTERFACE:
buf.append("INVOKEINTERFACE");
isMethodHandle = true;
break;
case Opcodes.H_INVOKESPECIAL:
buf.append("INVOKESPECIAL");
isMethodHandle = true;
break;
case Opcodes.H_INVOKESTATIC:
buf.append("INVOKESTATIC");
isMethodHandle = true;
break;
case Opcodes.H_INVOKEVIRTUAL:
buf.append("INVOKEVIRTUAL");
isMethodHandle = true;
break;
case Opcodes.H_NEWINVOKESPECIAL:
buf.append("NEWINVOKESPECIAL");
isMethodHandle = true;
break;
}
buf.append('\n');
......@@ -1272,9 +1296,13 @@ public class Textifier extends Printer {
appendDescriptor(INTERNAL_NAME, h.getOwner());
buf.append('.');
buf.append(h.getName());
if(!isMethodHandle){
buf.append('(');
}
appendDescriptor(HANDLE_DESCRIPTOR, h.getDesc());
buf.append(')').append('\n');
if(!isMethodHandle){
buf.append(')');
}
}
/**
......
Path: .
Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/ASM_5_0_BETA
URL: svn://svn.forge.objectweb.org/svnroot/asm/trunk/asm
Repository Root: svn://svn.forge.objectweb.org/svnroot/asm
Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/asm-svn-2014-03-12
URL: file:///svnroot/asm/trunk/asm
Repository Root: file:///svnroot/asm
Repository UUID: 271bd773-ee82-43a6-9b2b-1890ed8ce7f9
Revision: 1700
Revision: 1721
Node Kind: directory
Schedule: normal
Last Changed Author: ebruneton
Last Changed Rev: 1700
Last Changed Date: 2013-10-29 20:22:52 +0100 (Tue, 29 Oct 2013)
Last Changed Rev: 1721
Last Changed Date: 2014-03-02 17:25:35 +0100 (Sun, 02 Mar 2014)
......@@ -2430,6 +2430,8 @@ public final class SunGraphics2D
surfaceData = NullSurfaceData.theInstance;
}
invalidatePipe();
// this will recalculate the composite clip
setDevClip(surfaceData.getBounds());
......
......@@ -549,14 +549,13 @@ public class Config {
previous = line.substring(1).trim();
}
} else {
if (previous == null) {
throw new KrbException(
"Config file must starts with a section");
}
// Lines before the first section are ignored
if (previous != null) {
v.add(previous);
previous = line;
}
}
}
if (previous != null) {
v.add(previous);
v.add("}");
......
......@@ -94,9 +94,6 @@ public final class PKIXCertPathValidator extends CertPathValidatorSpi {
X509Certificate firstCert = certList.get(0);
// check trusted certificate's subject
selector.setSubject(firstCert.getIssuerX500Principal());
// check the validity period
selector.setValidityPeriod(firstCert.getNotBefore(),
firstCert.getNotAfter());
/*
* Facilitate certification path construction with authority
* 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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -83,6 +83,7 @@ void AwtDesktopProperties::GetSystemProperties() {
HDC dc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
if (dc != NULL) {
try {
SetFontProperty(dc, ANSI_FIXED_FONT, TEXT("win.ansiFixed.font"));
SetFontProperty(dc, ANSI_VAR_FONT, TEXT("win.ansiVar.font"));
SetFontProperty(dc, DEVICE_DEFAULT_FONT, TEXT("win.deviceDefault.font"));
......@@ -90,6 +91,11 @@ void AwtDesktopProperties::GetSystemProperties() {
SetFontProperty(dc, OEM_FIXED_FONT, TEXT("win.oemFixed.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);
}
}
......@@ -206,25 +212,36 @@ void AwtDesktopProperties::GetXPStyleProperties() {
LPTSTR value;
value = getXPStylePropFromReg(TEXT("ThemeActive"));
try {
SetBooleanProperty(TEXT("win.xpstyle.themeActive"), (value != NULL && *value == _T('1')));
if (value != NULL) {
free(value);
value = NULL;
}
value = getXPStylePropFromReg(TEXT("DllName"));
if (value != NULL) {
SetStringProperty(TEXT("win.xpstyle.dllName"), value);
free(value);
value = NULL;
}
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);
}
}
catch (std::bad_alloc&) {
if (value != NULL) {
free(value);
}
throw;
}
}
......@@ -564,11 +581,14 @@ void AwtDesktopProperties::GetOtherParameters() {
// Shell Icon BPP - only honored on platforms before XP
value = getWindowsPropFromReg(TEXT("Control Panel\\Desktop\\WindowMetrics"),
TEXT("Shell Icon BPP"), &valueType);
try {
if (value != NULL) {
if (valueType == REG_SZ) {
SetStringProperty(TEXT("win.icon.shellIconBPP"), value);
}
free(value);
value = NULL;
}
......@@ -586,13 +606,28 @@ void AwtDesktopProperties::GetOtherParameters() {
}
free(value);
}
}
catch (std::bad_alloc&) {
if (value != NULL) {
free(value);
}
throw;
}
LPTSTR valueName = TEXT("PlaceN");
LPTSTR valueNameBuf = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, (lstrlen(valueName) + 1), sizeof(TCHAR));
lstrcpy(valueNameBuf, valueName);
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);
int i = 0;
......@@ -601,6 +636,8 @@ void AwtDesktopProperties::GetOtherParameters() {
propKeyBuf[25] = valueNameBuf[5];
LPTSTR key = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32\\PlacesBar");
try {
value = NULL;
if ((value = getWindowsPropFromReg(key, valueNameBuf, &valueType)) != NULL) {
if (valueType == REG_DWORD) {
// Value is a CSIDL
......@@ -611,10 +648,19 @@ void AwtDesktopProperties::GetOtherParameters() {
}
free(value);
}
}
catch (std::bad_alloc&) {
if (value != NULL) {
free(value);
}
free(propKeyBuf);
free(valueNameBuf);
throw;
}
} while (value != NULL);
free(valueNameBuf);
free(propKeyBuf);
free(valueNameBuf);
}
void AwtDesktopProperties::GetSoundEvents() {
......@@ -656,14 +702,26 @@ UINT AwtDesktopProperties::GetIntegerParameter(UINT spi) {
void AwtDesktopProperties::SetStringProperty(LPCTSTR propName, LPTSTR value) {
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,
AwtDesktopProperties::setStringPropertyID,
key, JNU_NewStringPlatform(GetEnv(), value));
key, jValue);
GetEnv()->DeleteLocalRef(jValue);
GetEnv()->DeleteLocalRef(key);
}
void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setIntegerPropertyID,
key, (jint)value);
......@@ -672,6 +730,9 @@ void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) {
void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setBooleanPropertyID,
key, value ? JNI_TRUE : JNI_FALSE);
......@@ -680,6 +741,9 @@ void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) {
void AwtDesktopProperties::SetColorProperty(LPCTSTR propName, DWORD value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setColorPropertyID,
key, GetRValue(value), GetGValue(value),
......@@ -720,6 +784,11 @@ void AwtDesktopProperties::SetFontProperty(HDC dc, int fontID,
else {
fontName = JNU_NewStringPlatform(GetEnv(), face);
}
if (fontName == NULL) {
delete[] face;
throw std::bad_alloc();
}
jint pointSize = metrics.tmHeight -
metrics.tmInternalLeading;
jint style = java_awt_Font_PLAIN;
......@@ -732,11 +801,16 @@ void AwtDesktopProperties::SetFontProperty(HDC dc, int fontID,
}
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
GetEnv()->DeleteLocalRef(fontName);
delete[] face;
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setFontPropertyID,
key, fontName, style, pointSize);
GetEnv()->DeleteLocalRef(fontName);
GetEnv()->DeleteLocalRef(key);
GetEnv()->DeleteLocalRef(fontName);
}
}
delete[] face;
......@@ -750,7 +824,9 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon
jint style;
fontName = JNU_NewStringPlatform(GetEnv(), font.lfFaceName);
if (fontName == NULL) {
throw std::bad_alloc();
}
#if 0
HDC hdc;
int pixelsPerInch = GetDeviceCaps(hdc, LOGPIXELSY);
......@@ -773,22 +849,31 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon
}
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
GetEnv()->DeleteLocalRef(fontName);
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self, AwtDesktopProperties::setFontPropertyID,
key, fontName, style, pointSize);
GetEnv()->DeleteLocalRef(fontName);
GetEnv()->DeleteLocalRef(key);
GetEnv()->DeleteLocalRef(fontName);
}
void AwtDesktopProperties::SetSoundProperty(LPCTSTR propName, LPCTSTR winEventName) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
jstring event = JNU_NewStringPlatform(GetEnv(), winEventName);
if (event == NULL) {
GetEnv()->DeleteLocalRef(key);
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setSoundPropertyID,
key, event);
GetEnv()->DeleteLocalRef(key);
GetEnv()->DeleteLocalRef(event);
GetEnv()->DeleteLocalRef(key);
}
void AwtDesktopProperties::PlayWindowsSound(LPCTSTR event) {
......@@ -814,24 +899,37 @@ Java_sun_awt_windows_WDesktopProperties_initIDs(JNIEnv *env, jclass cls) {
AwtDesktopProperties::pDataID = env->GetFieldID(cls, "pData", "J");
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);
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);
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);
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);
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);
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);
CHECK_NULL(AwtDesktopProperties::setSoundPropertyID);
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.
*
* 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) {
TRY;
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);
CHECK_NULL(AwtEvent::targetID);
AwtEvent::xID = env->GetFieldID(cls, "x", "I");
DASSERT(AwtEvent::xID != NULL);
CHECK_NULL(AwtEvent::xID);
AwtEvent::yID = env->GetFieldID(cls, "y", "I");
DASSERT(AwtEvent::yID != NULL);
CHECK_NULL(AwtEvent::yID);
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.
*
* 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) {
TRY;
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);
CHECK_NULL(AwtMouseEvent::xID);
AwtMouseEvent::yID = env->GetFieldID(cls, "y", "I");
DASSERT(AwtMouseEvent::yID != NULL);
CHECK_NULL(AwtMouseEvent::yID);
AwtMouseEvent::buttonID = env->GetFieldID(cls, "button", "I");
DASSERT(AwtMouseEvent::buttonID != NULL);
CHECK_NULL(AwtMouseEvent::buttonID);
CATCH_BAD_ALLOC;
}
......
......@@ -229,15 +229,6 @@ sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java solaris-all
java/security/KeyPairGenerator/SolarisShortDSA.java 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
......
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -23,7 +23,7 @@
/*
test
@bug 6998877
@bug 6998877 8022531
@summary After double-click on the folder names, FileNameOverrideTest FAILED
@author Sergey.Bylokhov@oracle.com area=awt.filedialog
@library ../../regtesthelpers
......@@ -59,7 +59,8 @@ public class SaveFileNameOverrideTest extends Applet implements ActionListener {
String[] instructions = {
"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"
};
......
#!/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.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -25,7 +25,7 @@
#
# @test
# @bug 6282388
# @bug 6282388 8030640
# @summary Tests that AWT use correct toolkit to be wrapped into HeadlessToolkit
# @author artem.ananiev@sun.com: area=awt.headless
# @compile TestWrapped.java
......@@ -59,30 +59,14 @@ pass()
# Checking for proper OS
OS=`uname -s`
case "$OS" in
SunOS )
VAR="One value for Sun"
DEFAULT_JDK=/usr/local/java/jdk1.2/solaris
SunOS | Linux | Darwin | CYGWIN* )
FILESEP="/"
;;
Linux )
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
Windows* )
FILESEP="\\"
;;
Darwin)
VAR="Lets not forget about Mac"
DEFAULT_JDK=$(/usr/libexec/java_home)
FILESEP="/"
;;
# catch all other OSs
* )
echo "Unrecognized system! $OS"
......@@ -113,8 +97,7 @@ if [ -z "${TESTJAVA}" ] ; then
# THIS IS THE JDK BEING TESTED.
if [ -n "$1" ] ;
then TESTJAVA=$1
else echo "no JDK specified on command line so using default!"
TESTJAVA=$DEFAULT_JDK
else fail "no JDK specified on command line!"
fi
TESTSRC=.
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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -23,7 +23,7 @@
/*
@test
@bug 7154072
@bug 7154072 7161320
@summary Tests that key events with modifiers are not swallowed.
@author anton.tarasov: area=awt.focus
@library ../../../regtesthelpers
......@@ -49,6 +49,11 @@ public class SwallowKeyEvents {
static Robot r;
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.pack();
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 {
// ^ kdc# ^ timeout
static final Pattern re = Pattern.compile(
">>> 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:
......@@ -101,7 +123,7 @@ public class BadKdc {
fw.write("[libdefaults]\n" +
"default_realm = " + OneKDC.REALM + "\n" +
"kdc_timeout = 2000\n");
"kdc_timeout = " + toReal(2000) + "\n");
fw.write("[realms]\n" + OneKDC.REALM + " = {\n" +
"kdc = " + OneKDC.KDCHOST + ":" + p1 + "\n" +
"kdc = " + OneKDC.KDCHOST + ":" + p2 + "\n" +
......@@ -184,7 +206,8 @@ public class BadKdc {
Matcher m = re.matcher(line);
if (m.find()) {
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('-');
......
......@@ -28,14 +28,21 @@
* @summary krb5 should not try to access unavailable kdc too often
*/
import java.io.*;
import java.security.Security;
public class BadKdc1 {
public static void main(String[] args)
throws Exception {
// 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(
"121212222222(32){1,2}1222(32){1,2}", // 1 2
// The above line means try kdc1 for 2 seconds then kdc1
......
......@@ -35,7 +35,12 @@ public class BadKdc2 {
public static void main(String[] args)
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(
"121212222222(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 {
test1(5000, 2); // 2 2
// For tryLess
Security.setProperty("krb5.kdc.bad.policy", "tryless");
Security.setProperty("krb5.kdc.bad.policy", "tryless:1," + BadKdc.toReal(5000));
rewriteMaxRetries(4);
test1(4000, 7); // 1 1 1 1 2 1 2
test1(4000, 4); // 1 2 1 2
......@@ -94,7 +94,7 @@ public class MaxRetries {
* @param count the expected total try
*/
private static void test1(int timeout, int count) throws Exception {
String timeoutTag = "timeout=" + timeout;
String timeoutTag = "timeout=" + BadKdc.toReal(timeout);
ByteArrayOutputStream bo = new ByteArrayOutputStream();
PrintStream oldout = System.out;
System.setOut(new PrintStream(bo));
......@@ -192,12 +192,12 @@ public class MaxRetries {
if (s.startsWith("[realms]")) {
// Reconfig global setting
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 = ")) {
if (value != -1) {
// Reconfig for realm
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
fw.write(" kdc = localhost:33333\n");
......
......@@ -63,7 +63,7 @@ public class TcpTimeout {
"udp_preference_limit = 1\n" +
"max_retries = 2\n" +
"default_realm = " + OneKDC.REALM + "\n" +
"kdc_timeout = 5000\n");
"kdc_timeout = " + BadKdc.toReal(5000) + "\n");
fw.write("[realms]\n" + OneKDC.REALM + " = {\n" +
"kdc = " + OneKDC.KDCHOST + ":" + p1 + "\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.
先完成此消息的编辑!
想要评论请 注册