Merge
diff --git a/.hgtags b/.hgtags
index e84a382..e69afa1 100644
--- a/.hgtags
+++ b/.hgtags
@@ -432,6 +432,7 @@
f94ea276f608b22d78281d70361092ba4864038e jdk8u51-b31
887dde3afb3bb233958775de22eafb3328af6437 jdk8u51-b32
dc7b827522bc3a804f7e8951cc27414f19a7c427 jdk8u51-b33
+55ecfc5067721bd27282a14419e5784f7c7d212d jdk8u51-b34
5c31204d19e5976f025026db3d5c17331e8c44db jdk8u60-b00
c46daef6edb5385d11876ed40f292a4b62e96867 jdk8u60-b01
c10fd784956cc7099657181029ac3e790267b678 jdk8u60-b02
@@ -496,6 +497,11 @@
e6d562c0f079dfd1e21c3734b2dca16f4b2e2494 jdk8u66-b17
fd2fe69089aca0f187901a5f6f8bfe261ff17f5b jdk8u66-b18
f712dceafb546ea5833aeea507b5736e7e45f1ae jdk8u66-b31
+74cfe16ae44c1c6d511dbeabf13a516da3799d55 jdk8u66-b32
+ea7a705eab9e6495d08a92ff21e0370b68374c54 jdk8u66-b33
+72ab45285f0e8293aa63e889bc75f0287b6e0436 jdk8u66-b34
+e169a214f1f096af6b57169eeb0ba66ee5e9caa3 jdk8u66-b35
+430a8d04d8358206b682323f61405f951f43c773 jdk8u66-b36
9a2747ef337bdee71bc8225dea77eb403cca1179 jdk8u71-b00
e8b5e10a19d66a77d04f12d4677e6fec66f79651 jdk8u71-b01
25d689a73bc037e1710f95f6d4acf0671d22047d jdk8u71-b02
@@ -534,3 +540,10 @@
9a843dc6f959f62c61014a3a71ec9aa329f1daf1 jdk8u74-b00
e829ab80dfd828803aa8837411900faeaa1254a5 jdk8u74-b01
32c49f4a16599e376e4e46bb33c7bcc486e52ff3 jdk8u74-b02
+1d4b343084874b1afa1cdd504b9b1e50bab7f121 jdk8u72-b31
+7cfd2c51c501df909833aa0fb6e40c50c61621ed jdk8u75-b00
+9e00a43602f87930c2318b2567002871ad9c59dd jdk8u75-b01
+9de301db625bb1b462aad3ebd8347118b94bb728 jdk8u75-b02
+dcacefa73649a2d821267b6bff1d70aa10a06801 jdk8u75-b03
+de91f05824c5398cb2d2f666ff404aaa165498de jdk8u75-b04
+4138b3f27ffea524185a604c3f4f149c7e5ba780 jdk8u75-b05
diff --git a/src/share/classes/com/sun/crypto/provider/GaloisCounterMode.java b/src/share/classes/com/sun/crypto/provider/GaloisCounterMode.java
index 37bf6f4..df98d93 100644
--- a/src/share/classes/com/sun/crypto/provider/GaloisCounterMode.java
+++ b/src/share/classes/com/sun/crypto/provider/GaloisCounterMode.java
@@ -519,11 +519,17 @@
byte[] sOut = new byte[s.length];
GCTR gctrForSToTag = new GCTR(embeddedCipher, this.preCounterBlock);
gctrForSToTag.doFinal(s, 0, s.length, sOut, 0);
+
+ // check entire authentication tag for time-consistency
+ int mismatch = 0;
for (int i = 0; i < tagLenBytes; i++) {
- if (tag[i] != sOut[i]) {
- throw new AEADBadTagException("Tag mismatch!");
- }
+ mismatch |= tag[i] ^ sOut[i];
}
+
+ if (mismatch != 0) {
+ throw new AEADBadTagException("Tag mismatch!");
+ }
+
return len;
}
diff --git a/src/share/classes/java/io/ObjectInputStream.java b/src/share/classes/java/io/ObjectInputStream.java
index 61e76e3..02aff0f 100644
--- a/src/share/classes/java/io/ObjectInputStream.java
+++ b/src/share/classes/java/io/ObjectInputStream.java
@@ -1890,6 +1890,8 @@
if (obj == null || handles.lookupException(passHandle) != null) {
defaultReadFields(null, slotDesc); // skip field values
} else if (slotDesc.hasReadObjectMethod()) {
+ ThreadDeath t = null;
+ boolean reset = false;
SerialCallbackContext oldContext = curContext;
if (oldContext != null)
oldContext.check();
@@ -1908,10 +1910,19 @@
*/
handles.markException(passHandle, ex);
} finally {
- curContext.setUsed();
- if (oldContext!= null)
- oldContext.check();
- curContext = oldContext;
+ do {
+ try {
+ curContext.setUsed();
+ if (oldContext!= null)
+ oldContext.check();
+ curContext = oldContext;
+ reset = true;
+ } catch (ThreadDeath x) {
+ t = x; // defer until reset is true
+ }
+ } while (!reset);
+ if (t != null)
+ throw t;
}
/*
diff --git a/src/share/classes/sun/security/jgss/wrapper/GSSNameElement.java b/src/share/classes/sun/security/jgss/wrapper/GSSNameElement.java
index 387284b..9dd7108 100644
--- a/src/share/classes/sun/security/jgss/wrapper/GSSNameElement.java
+++ b/src/share/classes/sun/security/jgss/wrapper/GSSNameElement.java
@@ -159,7 +159,9 @@
int atPos = krbName.lastIndexOf('@');
if (atPos != -1) {
String atRealm = krbName.substring(atPos);
- if (nameType.equals(GSSUtil.NT_GSS_KRB5_PRINCIPAL)
+ // getNativeNameType() can modify NT_GSS_KRB5_PRINCIPAL to null
+ if ((nameType == null
+ || nameType.equals(GSSUtil.NT_GSS_KRB5_PRINCIPAL))
&& new String(nameBytes).endsWith(atRealm)) {
// Created from Kerberos name with realm, no need to check
} else {
diff --git a/src/share/classes/sun/security/provider/DSA.java b/src/share/classes/sun/security/provider/DSA.java
index 2145230..071b5b0 100644
--- a/src/share/classes/sun/security/provider/DSA.java
+++ b/src/share/classes/sun/security/provider/DSA.java
@@ -94,6 +94,18 @@
this.md = md;
}
+ private static void checkKey(DSAParams params, int digestLen, String mdAlgo)
+ throws InvalidKeyException {
+ // FIPS186-3 states in sec4.2 that a hash function which provides
+ // a lower security strength than the (L, N) pair ordinarily should
+ // not be used.
+ int valueN = params.getQ().bitLength();
+ if (valueN > digestLen) {
+ throw new InvalidKeyException("The security strength of " +
+ mdAlgo + " digest algorithm is not sufficient for this key size");
+ }
+ }
+
/**
* Initialize the DSA object with a DSA private key.
*
@@ -118,6 +130,12 @@
throw new InvalidKeyException("DSA private key lacks parameters");
}
+ // check key size against hash output size for signing
+ // skip this check for verification to minimize impact on existing apps
+ if (md.getAlgorithm() != "NullDigest20") {
+ checkKey(params, md.getDigestLength()*8, md.getAlgorithm());
+ }
+
this.params = params;
this.presetX = priv.getX();
this.presetY = null;
@@ -148,7 +166,6 @@
if (params == null) {
throw new InvalidKeyException("DSA public key lacks parameters");
}
-
this.params = params;
this.presetY = pub.getY();
this.presetX = null;
@@ -349,20 +366,13 @@
return t5.mod(q);
}
- // NOTE: This following impl is defined in FIPS 186-3 AppendixB.2.2.
- // Original DSS algos such as SHA1withDSA and RawDSA uses a different
- // algorithm defined in FIPS 186-1 Sec3.2, and thus need to override this.
+ // NOTE: This following impl is defined in FIPS 186-4 AppendixB.2.1.
protected BigInteger generateK(BigInteger q) {
SecureRandom random = getSigningRandom();
- byte[] kValue = new byte[q.bitLength()/8];
+ byte[] kValue = new byte[(q.bitLength() + 7)/8 + 8];
- while (true) {
- random.nextBytes(kValue);
- BigInteger k = new BigInteger(1, kValue).mod(q);
- if (k.signum() > 0 && k.compareTo(q) < 0) {
- return k;
- }
- }
+ random.nextBytes(kValue);
+ return new BigInteger(1, kValue).mod(q.subtract(BigInteger.ONE)).add(BigInteger.ONE);
}
// Use the application-specified SecureRandom Object if provided.
@@ -429,214 +439,10 @@
}
}
- static class LegacyDSA extends DSA {
- /* The random seed used to generate k */
- private int[] kSeed;
- /* The random seed used to generate k (specified by application) */
- private byte[] kSeedAsByteArray;
- /*
- * The random seed used to generate k
- * (prevent the same Kseed from being used twice in a row
- */
- private int[] kSeedLast;
-
- public LegacyDSA(MessageDigest md) throws NoSuchAlgorithmException {
- super(md);
- }
-
- @Deprecated
- protected void engineSetParameter(String key, Object param) {
- if (key.equals("KSEED")) {
- if (param instanceof byte[]) {
- kSeed = byteArray2IntArray((byte[])param);
- kSeedAsByteArray = (byte[])param;
- } else {
- debug("unrecognized param: " + key);
- throw new InvalidParameterException("kSeed not a byte array");
- }
- } else {
- throw new InvalidParameterException("Unsupported parameter");
- }
- }
-
- @Deprecated
- protected Object engineGetParameter(String key) {
- if (key.equals("KSEED")) {
- return kSeedAsByteArray;
- } else {
- return null;
- }
- }
-
- /*
- * Please read bug report 4044247 for an alternative, faster,
- * NON-FIPS approved method to generate K
- */
- @Override
- protected BigInteger generateK(BigInteger q) {
- BigInteger k = null;
-
- // The application specified a kSeed for us to use.
- // Note: we dis-allow usage of the same Kseed twice in a row
- if (kSeed != null && !Arrays.equals(kSeed, kSeedLast)) {
- k = generateKUsingKSeed(kSeed, q);
- if (k.signum() > 0 && k.compareTo(q) < 0) {
- kSeedLast = kSeed.clone();
- return k;
- }
- }
-
- // The application did not specify a Kseed for us to use.
- // We'll generate a new Kseed by getting random bytes from
- // a SecureRandom object.
- SecureRandom random = getSigningRandom();
-
- while (true) {
- int[] seed = new int[5];
-
- for (int i = 0; i < 5; i++) seed[i] = random.nextInt();
-
- k = generateKUsingKSeed(seed, q);
- if (k.signum() > 0 && k.compareTo(q) < 0) {
- kSeedLast = seed;
- return k;
- }
- }
- }
-
- /**
- * Compute k for the DSA signature as defined in the original DSS,
- * i.e. FIPS186.
- *
- * @param seed the seed for generating k. This seed should be
- * secure. This is what is referred to as the KSEED in the DSA
- * specification.
- *
- * @param g the g parameter from the DSA key pair.
- */
- private BigInteger generateKUsingKSeed(int[] seed, BigInteger q) {
-
- // check out t in the spec.
- int[] t = { 0xEFCDAB89, 0x98BADCFE, 0x10325476,
- 0xC3D2E1F0, 0x67452301 };
- //
- int[] tmp = SHA_7(seed, t);
- byte[] tmpBytes = new byte[tmp.length * 4];
- for (int i = 0; i < tmp.length; i++) {
- int k = tmp[i];
- for (int j = 0; j < 4; j++) {
- tmpBytes[(i * 4) + j] = (byte) (k >>> (24 - (j * 8)));
- }
- }
- BigInteger k = new BigInteger(1, tmpBytes).mod(q);
- return k;
- }
-
- // Constants for each round
- private static final int round1_kt = 0x5a827999;
- private static final int round2_kt = 0x6ed9eba1;
- private static final int round3_kt = 0x8f1bbcdc;
- private static final int round4_kt = 0xca62c1d6;
-
- /**
- * Computes set 1 thru 7 of SHA-1 on m1. */
- static int[] SHA_7(int[] m1, int[] h) {
-
- int[] W = new int[80];
- System.arraycopy(m1,0,W,0,m1.length);
- int temp = 0;
-
- for (int t = 16; t <= 79; t++){
- temp = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16];
- W[t] = ((temp << 1) | (temp >>>(32 - 1)));
- }
-
- int a = h[0],b = h[1],c = h[2], d = h[3], e = h[4];
- for (int i = 0; i < 20; i++) {
- temp = ((a<<5) | (a>>>(32-5))) +
- ((b&c)|((~b)&d))+ e + W[i] + round1_kt;
- e = d;
- d = c;
- c = ((b<<30) | (b>>>(32-30)));
- b = a;
- a = temp;
- }
-
- // Round 2
- for (int i = 20; i < 40; i++) {
- temp = ((a<<5) | (a>>>(32-5))) +
- (b ^ c ^ d) + e + W[i] + round2_kt;
- e = d;
- d = c;
- c = ((b<<30) | (b>>>(32-30)));
- b = a;
- a = temp;
- }
-
- // Round 3
- for (int i = 40; i < 60; i++) {
- temp = ((a<<5) | (a>>>(32-5))) +
- ((b&c)|(b&d)|(c&d)) + e + W[i] + round3_kt;
- e = d;
- d = c;
- c = ((b<<30) | (b>>>(32-30)));
- b = a;
- a = temp;
- }
-
- // Round 4
- for (int i = 60; i < 80; i++) {
- temp = ((a<<5) | (a>>>(32-5))) +
- (b ^ c ^ d) + e + W[i] + round4_kt;
- e = d;
- d = c;
- c = ((b<<30) | (b>>>(32-30)));
- b = a;
- a = temp;
- }
- int[] md = new int[5];
- md[0] = h[0] + a;
- md[1] = h[1] + b;
- md[2] = h[2] + c;
- md[3] = h[3] + d;
- md[4] = h[4] + e;
- return md;
- }
-
- /*
- * Utility routine for converting a byte array into an int array
- */
- private int[] byteArray2IntArray(byte[] byteArray) {
-
- int j = 0;
- byte[] newBA;
- int mod = byteArray.length % 4;
-
- // guarantee that the incoming byteArray is a multiple of 4
- // (pad with 0's)
- switch (mod) {
- case 3: newBA = new byte[byteArray.length + 1]; break;
- case 2: newBA = new byte[byteArray.length + 2]; break;
- case 1: newBA = new byte[byteArray.length + 3]; break;
- default: newBA = new byte[byteArray.length + 0]; break;
- }
- System.arraycopy(byteArray, 0, newBA, 0, byteArray.length);
-
- // copy each set of 4 bytes in the byte array into an integer
- int[] newSeed = new int[newBA.length / 4];
- for (int i = 0; i < newBA.length; i += 4) {
- newSeed[j] = newBA[i + 3] & 0xFF;
- newSeed[j] |= (newBA[i + 2] << 8) & 0xFF00;
- newSeed[j] |= (newBA[i + 1] << 16) & 0xFF0000;
- newSeed[j] |= (newBA[i + 0] << 24) & 0xFF000000;
- j++;
- }
-
- return newSeed;
- }
- }
-
- public static final class SHA1withDSA extends LegacyDSA {
+ /**
+ * Standard SHA1withDSA implementation.
+ */
+ public static final class SHA1withDSA extends DSA {
public SHA1withDSA() throws NoSuchAlgorithmException {
super(MessageDigest.getInstance("SHA-1"));
}
@@ -649,7 +455,7 @@
* not, a SignatureException is thrown when sign()/verify() is called
* per JCA spec.
*/
- public static final class RawDSA extends LegacyDSA {
+ public static final class RawDSA extends DSA {
// Internal special-purpose MessageDigest impl for RawDSA
// Only override whatever methods used
// NOTE: no clone support
diff --git a/src/share/native/sun/font/layout/DeviceTables.cpp b/src/share/native/sun/font/layout/DeviceTables.cpp
index df4df19..7ea3032 100644
--- a/src/share/native/sun/font/layout/DeviceTables.cpp
+++ b/src/share/native/sun/font/layout/DeviceTables.cpp
@@ -45,9 +45,12 @@
le_int16 DeviceTable::getAdjustment(const LEReferenceTo<DeviceTable>&base, le_uint16 ppem, LEErrorCode &success) const
{
+ le_int16 result = 0;
+ if (LE_FAILURE(success)) {
+ return result;
+ }
le_uint16 start = SWAPW(startSize);
le_uint16 format = SWAPW(deltaFormat) - 1;
- le_int16 result = 0;
if (ppem >= start && ppem <= SWAPW(endSize) && format < FORMAT_COUNT) {
le_uint16 sizeIndex = ppem - start;
diff --git a/src/share/native/sun/font/layout/LigatureSubstProc.cpp b/src/share/native/sun/font/layout/LigatureSubstProc.cpp
index 5a94563..76131fd 100644
--- a/src/share/native/sun/font/layout/LigatureSubstProc.cpp
+++ b/src/share/native/sun/font/layout/LigatureSubstProc.cpp
@@ -71,6 +71,10 @@
{
LEErrorCode success = LE_NO_ERROR;
const LigatureSubstitutionStateEntry *entry = entryTable.getAlias(index, success);
+ if (LE_FAILURE(success)) {
+ currGlyph++;
+ return 0;
+ }
ByteOffset newState = SWAPW(entry->newStateOffset);
le_uint16 flags = SWAPW(entry->flags);
@@ -91,6 +95,10 @@
if (actionOffset != 0) {
LEReferenceTo<LigatureActionEntry> ap(stHeader, success, actionOffset);
+ if (LE_FAILURE(success)) {
+ currGlyph++;
+ return newState;
+ }
LigatureActionEntry action;
le_int32 offset, i = 0, j = 0;
le_int32 stack[nComponents];
@@ -101,6 +109,10 @@
if (j++ > 0) {
ap.addObject(success);
+ if (LE_FAILURE(success)) {
+ currGlyph++;
+ return newState;
+ }
}
action = SWAPL(*ap.getAlias());
@@ -124,9 +136,17 @@
return newState; // get out! bad font
}
i += SWAPW(offsetTable.getObject(LE_GET_GLYPH(glyphStorage[componentGlyph]), success));
+ if (LE_FAILURE(success)) {
+ currGlyph++;
+ return newState;
+ }
if (action & (lafLast | lafStore)) {
LEReferenceTo<TTGlyphID> ligatureOffset(stHeader, success, i);
+ if (LE_FAILURE(success)) {
+ currGlyph++;
+ return newState;
+ }
TTGlyphID ligatureGlyph = SWAPW(*ligatureOffset.getAlias());
glyphStorage[componentGlyph] = LE_SET_GLYPH(glyphStorage[componentGlyph], ligatureGlyph);
diff --git a/src/share/native/sun/font/layout/LigatureSubstProc2.cpp b/src/share/native/sun/font/layout/LigatureSubstProc2.cpp
index 77e9073..20c73d4 100644
--- a/src/share/native/sun/font/layout/LigatureSubstProc2.cpp
+++ b/src/share/native/sun/font/layout/LigatureSubstProc2.cpp
@@ -95,6 +95,10 @@
if (actionOffset != 0) {
LEReferenceTo<LigatureActionEntry> ap(stHeader, success, ligActionOffset); // byte offset
+ if (LE_FAILURE(success)) {
+ currGlyph+= dir;
+ return nextStateIndex;
+ }
ap.addObject(ligActionIndex, success);
LEReferenceToArrayOf<TTGlyphID> ligatureTable(stHeader, success, ligatureOffset, LE_UNBOUNDED_ARRAY);
LigatureActionEntry action;
@@ -114,6 +118,10 @@
if (j++ > 0) {
ap.addObject(success);
}
+ if (LE_FAILURE(success)) {
+ currGlyph+= dir;
+ return nextStateIndex;
+ }
action = SWAPL(*ap.getAlias());
@@ -129,9 +137,17 @@
return nextStateIndex; // get out! bad font
}
i += SWAPW(componentTable(LE_GET_GLYPH(glyphStorage[componentGlyph]) + (SignExtend(offset, lafComponentOffsetMask)),success));
+ if (LE_FAILURE(success)) {
+ currGlyph+= dir;
+ return nextStateIndex;
+ }
if (action & (lafLast | lafStore)) {
TTGlyphID ligatureGlyph = SWAPW(ligatureTable(i,success));
+ if (LE_FAILURE(success)) {
+ currGlyph+= dir;
+ return nextStateIndex;
+ }
glyphStorage[componentGlyph] = LE_SET_GLYPH(glyphStorage[componentGlyph], ligatureGlyph);
if(mm==nComponents) {
LE_DEBUG_BAD_FONT("exceeded nComponents");
diff --git a/src/share/native/sun/font/layout/StateTableProcessor2.cpp b/src/share/native/sun/font/layout/StateTableProcessor2.cpp
index 9aa097a..ab74b23 100644
--- a/src/share/native/sun/font/layout/StateTableProcessor2.cpp
+++ b/src/share/native/sun/font/layout/StateTableProcessor2.cpp
@@ -60,6 +60,7 @@
entryTableOffset = SWAPL(stHeader->entryTableOffset);
classTable = LEReferenceTo<LookupTable>(stHeader, success, classTableOffset);
+ if (LE_FAILURE(success)) return;
format = SWAPW(classTable->format);
stateArray = LEReferenceToArrayOf<EntryTableIndex2>(stHeader, success, stateArrayOffset, LE_UNBOUNDED_ARRAY);
diff --git a/src/share/native/sun/java2d/cmm/lcms/cmscgats.c b/src/share/native/sun/java2d/cmm/lcms/cmscgats.c
index 0dedc27..664a3c9 100644
--- a/src/share/native/sun/java2d/cmm/lcms/cmscgats.c
+++ b/src/share/native/sun/java2d/cmm/lcms/cmscgats.c
@@ -2545,9 +2545,11 @@
for (i=0; i < t->nSamples; i++) {
fld = GetDataFormat(it8, i);
+ if (fld != NULL) {
if (cmsstrcasecmp(fld, cSample) == 0)
return i;
}
+ }
return -1;
diff --git a/src/solaris/native/sun/awt/fontpath.c b/src/solaris/native/sun/awt/fontpath.c
index 674931b..3d1d020 100644
--- a/src/solaris/native/sun/awt/fontpath.c
+++ b/src/solaris/native/sun/awt/fontpath.c
@@ -1155,8 +1155,8 @@
continue;
}
pattern = (*FcNameParse)((FcChar8 *)fcName);
+ (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
if (pattern == NULL) {
- (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
closeFontConfig(libfontconfig, JNI_FALSE);
return;
}
@@ -1174,7 +1174,6 @@
fontset = (*FcFontSort)(NULL, pattern, FcTrue, NULL, &result);
if (fontset == NULL) {
(*FcPatternDestroy)(pattern);
- (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
closeFontConfig(libfontconfig, JNI_FALSE);
return;
}
@@ -1206,7 +1205,6 @@
}
(*FcPatternDestroy)(pattern);
(*FcFontSetDestroy)(fontset);
- (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
closeFontConfig(libfontconfig, JNI_FALSE);
return;
}
@@ -1248,8 +1246,6 @@
free(file);
(*FcPatternDestroy)(pattern);
(*FcFontSetDestroy)(fontset);
- (*env)->ReleaseStringUTFChars(env,
- fcNameStr, (const char*)fcName);
closeFontConfig(libfontconfig, JNI_FALSE);
return;
}
@@ -1297,6 +1293,16 @@
if (includeFallbacks) {
fcFontArr =
(*env)->NewObjectArray(env, fontCount, fcFontClass, NULL);
+ if (IS_NULL(fcFontArr)) {
+ free(family);
+ free(fullname);
+ free(styleStr);
+ free(file);
+ (*FcPatternDestroy)(pattern);
+ (*FcFontSetDestroy)(fontset);
+ closeFontConfig(libfontconfig, JNI_FALSE);
+ return;
+ }
(*env)->SetObjectField(env,fcCompFontObj, fcAllFontsID, fcFontArr);
}
fn=0;
@@ -1305,18 +1311,23 @@
if (family[j] != NULL) {
jobject fcFont =
(*env)->NewObject(env, fcFontClass, fcFontCons);
+ if (IS_NULL(fcFont)) break;
jstr = (*env)->NewStringUTF(env, (const char*)family[j]);
+ if (IS_NULL(jstr)) break;
(*env)->SetObjectField(env, fcFont, familyNameID, jstr);
if (file[j] != NULL) {
jstr = (*env)->NewStringUTF(env, (const char*)file[j]);
+ if (IS_NULL(jstr)) break;
(*env)->SetObjectField(env, fcFont, fontFileID, jstr);
}
if (styleStr[j] != NULL) {
jstr = (*env)->NewStringUTF(env, (const char*)styleStr[j]);
+ if (IS_NULL(jstr)) break;
(*env)->SetObjectField(env, fcFont, styleNameID, jstr);
}
if (fullname[j] != NULL) {
jstr = (*env)->NewStringUTF(env, (const char*)fullname[j]);
+ if (IS_NULL(jstr)) break;
(*env)->SetObjectField(env, fcFont, fullNameID, jstr);
}
if (fn==0) {
@@ -1330,7 +1341,6 @@
}
}
}
- (*env)->ReleaseStringUTFChars (env, fcNameStr, (const char*)fcName);
(*FcFontSetDestroy)(fontset);
(*FcPatternDestroy)(pattern);
free(family);
diff --git a/src/windows/classes/sun/awt/windows/WPathGraphics.java b/src/windows/classes/sun/awt/windows/WPathGraphics.java
index c3410a9..31d9c28 100644
--- a/src/windows/classes/sun/awt/windows/WPathGraphics.java
+++ b/src/windows/classes/sun/awt/windows/WPathGraphics.java
@@ -494,24 +494,48 @@
*/
float fontSize = font.getSize2D();
+ double devResX = wPrinterJob.getXRes();
+ double devResY = wPrinterJob.getYRes();
+
+ double fontDevScaleY = devResY / DEFAULT_USER_RES;
+
+ int orient = getPageFormat().getOrientation();
+ if (orient == PageFormat.LANDSCAPE ||
+ orient == PageFormat.REVERSE_LANDSCAPE)
+ {
+ double tmp = devResX;
+ devResX = devResY;
+ devResY = tmp;
+ }
+
+ double devScaleX = devResX / DEFAULT_USER_RES;
+ double devScaleY = devResY / DEFAULT_USER_RES;
+ fontTransform.scale(1.0/devScaleX, 1.0/devScaleY);
+
Point2D.Double pty = new Point2D.Double(0.0, 1.0);
fontTransform.deltaTransform(pty, pty);
double scaleFactorY = Math.sqrt(pty.x*pty.x+pty.y*pty.y);
- float scaledFontSizeY = (float)(fontSize * scaleFactorY);
+ float scaledFontSizeY = (float)(fontSize * scaleFactorY * fontDevScaleY);
Point2D.Double ptx = new Point2D.Double(1.0, 0.0);
fontTransform.deltaTransform(ptx, ptx);
double scaleFactorX = Math.sqrt(ptx.x*ptx.x+ptx.y*ptx.y);
- float scaledFontSizeX = (float)(fontSize * scaleFactorX);
float awScale = getAwScale(scaleFactorX, scaleFactorY);
int iangle = getAngle(ptx);
+ ptx = new Point2D.Double(1.0, 0.0);
+ deviceTransform.deltaTransform(ptx, ptx);
+ double advanceScaleX = Math.sqrt(ptx.x*ptx.x+ptx.y*ptx.y);
+ pty = new Point2D.Double(0.0, 1.0);
+ deviceTransform.deltaTransform(pty, pty);
+ double advanceScaleY = Math.sqrt(pty.x*pty.x+pty.y*pty.y);
+
Font2D font2D = FontUtilities.getFont2D(font);
if (font2D instanceof TrueTypeFont) {
textOut(str, font, (TrueTypeFont)font2D, frc,
scaledFontSizeY, iangle, awScale,
- deviceTransform, scaleFactorX,
+ advanceScaleX, advanceScaleY,
x, y, devpos.x, devpos.y, targetW);
} else if (font2D instanceof CompositeFont) {
/* Composite fonts are made up of multiple fonts and each
@@ -542,7 +566,7 @@
PhysicalFont slotFont = compFont.getSlotFont(slot);
textOut(substr, font, slotFont, frc,
scaledFontSizeY, iangle, awScale,
- deviceTransform, scaleFactorX,
+ advanceScaleX, advanceScaleY,
userx, usery, devx, devy, 0f);
Rectangle2D bds = font.getStringBounds(substr, frc);
float xAdvance = (float)bds.getWidth();
@@ -635,18 +659,42 @@
*/
float fontSize = font.getSize2D();
+ double devResX = wPrinterJob.getXRes();
+ double devResY = wPrinterJob.getYRes();
+
+ double fontDevScaleY = devResY / DEFAULT_USER_RES;
+
+ int orient = getPageFormat().getOrientation();
+ if (orient == PageFormat.LANDSCAPE ||
+ orient == PageFormat.REVERSE_LANDSCAPE)
+ {
+ double tmp = devResX;
+ devResX = devResY;
+ devResY = tmp;
+ }
+
+ double devScaleX = devResX / DEFAULT_USER_RES;
+ double devScaleY = devResY / DEFAULT_USER_RES;
+ fontTransform.scale(1.0/devScaleX, 1.0/devScaleY);
+
Point2D.Double pty = new Point2D.Double(0.0, 1.0);
fontTransform.deltaTransform(pty, pty);
double scaleFactorY = Math.sqrt(pty.x*pty.x+pty.y*pty.y);
- float scaledFontSizeY = (float)(fontSize * scaleFactorY);
+ float scaledFontSizeY = (float)(fontSize * scaleFactorY * fontDevScaleY);
- Point2D.Double pt = new Point2D.Double(1.0, 0.0);
- fontTransform.deltaTransform(pt, pt);
- double scaleFactorX = Math.sqrt(pt.x*pt.x+pt.y*pt.y);
- float scaledFontSizeX = (float)(fontSize * scaleFactorX);
+ Point2D.Double ptx = new Point2D.Double(1.0, 0.0);
+ fontTransform.deltaTransform(ptx, ptx);
+ double scaleFactorX = Math.sqrt(ptx.x*ptx.x+ptx.y*ptx.y);
float awScale = getAwScale(scaleFactorX, scaleFactorY);
- int iangle = getAngle(pt);
+ int iangle = getAngle(ptx);
+
+ ptx = new Point2D.Double(1.0, 0.0);
+ deviceTransform.deltaTransform(ptx, ptx);
+ double advanceScaleX = Math.sqrt(ptx.x*ptx.x+ptx.y*ptx.y);
+ pty = new Point2D.Double(0.0, 1.0);
+ deviceTransform.deltaTransform(pty, pty);
+ double advanceScaleY = Math.sqrt(pty.x*pty.x+pty.y*pty.y);
int numGlyphs = gv.getNumGlyphs();
int[] glyphCodes = gv.getGlyphCodes(0, numGlyphs, null);
@@ -705,8 +753,7 @@
* rotation element of the deviceTransform.
*/
AffineTransform advanceTransform =
- new AffineTransform(deviceTransform);
- advanceTransform.rotate(iangle*Math.PI/1800.0);
+ AffineTransform.getScaleInstance(advanceScaleX, advanceScaleY);
float[] glyphAdvPos = new float[glyphPos.length];
advanceTransform.transform(glyphPos, 0, //source
@@ -784,8 +831,7 @@
Font font, PhysicalFont font2D,
FontRenderContext frc,
float deviceSize, int rotation, float awScale,
- AffineTransform deviceTransform,
- double scaleFactorX,
+ double scaleFactorX, double scaleFactorY,
float userx, float usery,
float devx, float devy, float targetW) {
@@ -826,8 +872,7 @@
* See earlier comment in printGlyphVector() for details.
*/
AffineTransform advanceTransform =
- new AffineTransform(deviceTransform);
- advanceTransform.rotate(rotation*Math.PI/1800.0);
+ AffineTransform.getScaleInstance(scaleFactorX, scaleFactorY);
float[] glyphAdvPos = new float[glyphPos.length];
advanceTransform.transform(glyphPos, 0, //source
@@ -841,11 +886,11 @@
/* If 2D and GDI agree on the advance of the string we do not
* need to explicitly assign glyph positions.
* If we are to use the GDI advance, require it to agree with
- * JDK to a precision of <= 0.2% - ie 1 pixel in 500
+ * JDK to a precision of <= 1.0% - ie 1 pixel in 100
* discrepancy after rounding the 2D advance to the
* nearest pixel and is greater than one pixel in total.
- * ie strings < 500 pixels in length will be OK so long
- * as they differ by only 1 pixel even though that is > 0.02%
+ * ie strings < 100 pixels in length will be OK so long
+ * as they differ by only 1 pixel even though that is > 1%
* The bounds from 2D are in user space so need to
* be scaled to device space for comparison with GDI.
* scaleX is the scale from user space to device space needed for this.
@@ -863,7 +908,7 @@
if (ratio < 1) {
ratio = 1/ratio;
}
- return diff <= 1 || ratio < 1.002;
+ return diff <= 1 || ratio < 1.01;
}
return true;
}
diff --git a/test/com/sun/jdi/CatchPatternTest.sh b/test/com/sun/jdi/CatchPatternTest.sh
index c2e18fb..68e7799 100644
--- a/test/com/sun/jdi/CatchPatternTest.sh
+++ b/test/com/sun/jdi/CatchPatternTest.sh
@@ -35,44 +35,44 @@
cat <<EOF > $classname.java.1
public class $classname {
public void bark(int i) {
- System.out.println(" bark: " + i);
- switch (i) {
- case 0:
- throw new IllegalArgumentException("IllegalArgumentException");
- case 1:
- throw new ArithmeticException("ArithmeticException");
- case 2:
- throw new IllegalMonitorStateException("IllegalMonitorStateException");
- case 3:
- throw new IndexOutOfBoundsException("IndexOutOfBoundsException");
- default:
- throw new Error("should not happen");
- }
+ System.out.println(" bark: " + i);
+ switch (i) {
+ case 0:
+ throw new IllegalArgumentException("IllegalArgumentException");
+ case 1:
+ throw new ArithmeticException("ArithmeticException");
+ case 2:
+ throw new IllegalMonitorStateException("IllegalMonitorStateException");
+ case 3:
+ throw new IndexOutOfBoundsException("IndexOutOfBoundsException");
+ default:
+ throw new Error("should not happen");
+ }
}
public void loop(int max) {
- for (int i = 0; i <= max; i++) {
- try {
- bark(i);
- } catch(RuntimeException re) {
- System.out.println(" loop: " + re.getMessage() +
- " caught and ignored.");
- }
- }
+ for (int i = 0; i <= max; i++) {
+ try {
+ bark(i);
+ } catch(RuntimeException re) {
+ System.out.println(" loop: " + re.getMessage() +
+ " caught and ignored.");
+ }
+ }
}
public void partOne() {
loop(2);
- System.out.println("partOne completed");
+ System.out.println("partOne completed");
}
public void partTwo() {
loop(3);
- System.out.println("partTwo completed");
+ System.out.println("partTwo completed");
}
public static void main(String[] args) {
- System.out.println("Howdy!");
+ System.out.println("Howdy!");
$classname my = new $classname();
- my.partOne();
- my.partTwo();
- System.out.println("Goodbye from $classname!");
+ my.partOne();
+ my.partTwo();
+ System.out.println("Goodbye from $classname!");
}
}
EOF
diff --git a/test/com/sun/jdi/GetLocalVariables4Test.sh b/test/com/sun/jdi/GetLocalVariables4Test.sh
index 45ae52f..0eeb421 100644
--- a/test/com/sun/jdi/GetLocalVariables4Test.sh
+++ b/test/com/sun/jdi/GetLocalVariables4Test.sh
@@ -39,12 +39,12 @@
public class GetLocalVariables4Targ {
public static void main(String[] args) {
System.out.println("Howdy!");
- int i = 0;
- try {
- i = 16 / i;
- } catch(Exception e) {
- System.out.println("e should be visible"); // @1 breakpoint
- }
+ int i = 0;
+ try {
+ i = 16 / i;
+ } catch(Exception e) {
+ System.out.println("e should be visible"); // @1 breakpoint
+ }
System.out.println("Goodbye from GetLocalVariables4Targ!");
}
}
diff --git a/test/com/sun/jdi/JdbReadTwiceTest.sh b/test/com/sun/jdi/JdbReadTwiceTest.sh
index 58be020..a166f2c 100644
--- a/test/com/sun/jdi/JdbReadTwiceTest.sh
+++ b/test/com/sun/jdi/JdbReadTwiceTest.sh
@@ -204,22 +204,6 @@
clean
fi
-
-if [ ! -r c:/ ] ; then
- # Can't make a file unreadable under MKS.
- echo
- echo "+++++++++++++++++++++++++++++++++++"
- echo "Read an unreadable file - verify the read fails."
- # If the file exists, we try to read it. The
- # read will fail.
- mkFiles $HOME/jdb.ini
- chmod a-r $HOME/jdb.ini
- doit
- failIfNot 1 "open: $HOME/jdb.ini"
- clean
-fi
-
-
echo
echo "+++++++++++++++++++++++++++++++++++"
echo "Read a directory - verify the read fails"
@@ -239,8 +223,8 @@
doit
failIfNot 1 "from $fred"
- if [ ! -r c:/ ] ; then
- # Can't make a file unreadable under MKS
+ if [ "$canMakeUnreadable" = "Yes" ]
+ then
chmod a-r $fred
doit
failIfNot 1 "open: $fred"
diff --git a/test/com/sun/jdi/NullLocalVariable.sh b/test/com/sun/jdi/NullLocalVariable.sh
index 63bca95..39ac84f 100644
--- a/test/com/sun/jdi/NullLocalVariable.sh
+++ b/test/com/sun/jdi/NullLocalVariable.sh
@@ -40,10 +40,10 @@
public static final void main(String args[]) {
try {
System.out.println("hi!"); // @1 breakpoint
- } catch (Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
} finally {
- System.out.println("done");
+ System.out.println("done");
}
}
}
@@ -54,11 +54,11 @@
dojdbCmds()
{
#set -x
- cmd stop at badscope:4 ; $sleepcmd
- runToBkpt ; $sleepcmd
- cmd next ; $sleepcmd
- cmd next ; $sleepcmd
- cmd locals ; $sleepcmd
+ cmd stop at badscope:4 ; $sleepcmd
+ runToBkpt ; $sleepcmd
+ cmd next ; $sleepcmd
+ cmd next ; $sleepcmd
+ cmd locals ; $sleepcmd
cmd cont
}
@@ -71,7 +71,7 @@
for ii in . $TESTSRC $TESTSRC/.. ; do
if [ -r "$ii/ShellScaffold.sh" ] ; then
- . $ii/ShellScaffold.sh
+ . $ii/ShellScaffold.sh
break
fi
done
diff --git a/test/com/sun/jdi/PrivateTransportTest.sh b/test/com/sun/jdi/PrivateTransportTest.sh
index ee8051f..7f4b002 100644
--- a/test/com/sun/jdi/PrivateTransportTest.sh
+++ b/test/com/sun/jdi/PrivateTransportTest.sh
@@ -67,9 +67,9 @@
# is given on the command line, tell the user that and use a default.
# THIS IS THE JDK BEING TESTED.
if [ -n "$1" ] ; then
- TESTJAVA=$1
+ TESTJAVA=$1
else
- TESTJAVA=$JAVA_HOME
+ TESTJAVA=$JAVA_HOME
fi
TESTSRC=.
TESTCLASSES=.
diff --git a/test/com/sun/jdi/RedefineFinal.sh b/test/com/sun/jdi/RedefineFinal.sh
index 80ec525..eb63de3 100644
--- a/test/com/sun/jdi/RedefineFinal.sh
+++ b/test/com/sun/jdi/RedefineFinal.sh
@@ -42,15 +42,15 @@
public final class $1 {
public int m1(int i) {
- // @1 uncomment System.out.println("I'm here");
- return m2(i, 1000);
+ // @1 uncomment System.out.println("I'm here");
+ return m2(i, 1000);
}
public int m2(int i, int j) {
- if (i < 0 || j < 0) { // @1 breakpoint
+ if (i < 0 || j < 0) { // @1 breakpoint
throw new IllegalArgumentException();
- }
- return i+j;
+ }
+ return i+j;
}
$1() {
@@ -59,7 +59,7 @@
}
public static void main(String args[]) {
- new $1();
+ new $1();
}
}
EOF
diff --git a/test/com/sun/jdi/RedefineIntConstantToLong.sh b/test/com/sun/jdi/RedefineIntConstantToLong.sh
index ab921c0..990b69e 100644
--- a/test/com/sun/jdi/RedefineIntConstantToLong.sh
+++ b/test/com/sun/jdi/RedefineIntConstantToLong.sh
@@ -44,18 +44,18 @@
public long m1(int i) {
long r=0;
r = m2(i * 2); // @1 commentout
- // @1 uncomment r =m2(i * 2L);
+ // @1 uncomment r =m2(i * 2L);
return r;
}
public long m2(int j) {
- System.out.println(System.getProperty("line.separator") +
+ System.out.println(System.getProperty("line.separator") +
"**** public long m2(int j) with value: " + j);
return j;
}
public long m2(long j) {
- System.out.println(System.getProperty("line.separator") +
+ System.out.println(System.getProperty("line.separator") +
"**** public long m2(long j) with value: " + j);
return j;
}
@@ -66,7 +66,7 @@
r1 = m1(1000);
r2 = 0; // @1 breakpoint
r2 = m1(1000);
- if (r1 != r2) { // @1 breakpoint
+ if (r1 != r2) { // @1 breakpoint
throw new Exception("FAILURE: Expected value: " + r1 + " Actual value: " + r2);
} else {
System.out.println("SUCCESS: Expected value: " + r1 + " Actual value: " + r2);
@@ -74,7 +74,7 @@
}
public static void main(String args[]) throws Exception {
- new $1().doit();
+ new $1().doit();
}
}
EOF
diff --git a/test/com/sun/jdi/StringConvertTest.sh b/test/com/sun/jdi/StringConvertTest.sh
index c86ab3d..1d863a2 100644
--- a/test/com/sun/jdi/StringConvertTest.sh
+++ b/test/com/sun/jdi/StringConvertTest.sh
@@ -23,7 +23,7 @@
# questions.
#
-# @test @(#)StringConvertTest.sh 1.6 03/04/09
+# @test
# @bug 4511950 4843082
# @summary 1. jdb's expression evaluation doesn't perform string conversion properly
# 2. TTY: run on expression evaluation
diff --git a/test/com/sun/jdi/SuspendNoFlagTest.sh b/test/com/sun/jdi/SuspendNoFlagTest.sh
index 7608cb5..dd4a24e 100644
--- a/test/com/sun/jdi/SuspendNoFlagTest.sh
+++ b/test/com/sun/jdi/SuspendNoFlagTest.sh
@@ -68,9 +68,9 @@
# is given on the command line, tell the user that and use a default.
# THIS IS THE JDK BEING TESTED.
if [ -n "$1" ] ; then
- TESTJAVA=$1
+ TESTJAVA=$1
else
- TESTJAVA=$JAVA_HOME
+ TESTJAVA=$JAVA_HOME
fi
TESTSRC=.
TESTCLASSES=.
diff --git a/test/java/awt/print/PrinterJob/PrintTextTest.html b/test/java/awt/print/PrinterJob/PrintTextTest.html
new file mode 100644
index 0000000..1ef0918
--- /dev/null
+++ b/test/java/awt/print/PrinterJob/PrintTextTest.html
@@ -0,0 +1,46 @@
+<!--
+ Copyright (c) 2015, 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.
+-->
+
+<html>
+<body>
+<applet code="PrintTextTest.class" width=400 height=100></applet>
+This tests that printed text renders similarly to on-screen,
+under a variety of APIs and graphics and font transforms
+Print to your preferred printer. Collect the output.
+Refer to the onscreen buttons to cycle through the on-screen
+content
+For each page, confirm that the printed content corresponds to
+the on-screen rendering for that *same* page.
+Some cases may look odd but its intentional. Verify
+it looks the same on screen and on the printer.
+Note that text does not scale linearly from screen to printer
+so some differences are normal and not a bug.
+The easiest way to spot real problems is to check that
+any underlines are the same length as the underlined text
+and that any rotations are the same in each case.
+Note that each on-screen page is printed in both portrait
+and landscape mode
+So for example, Page 1/Portrait, and Page 1/Landscape when
+rotated to view properly, should both match Page 1 on screen.;
+</body>
+</html>
diff --git a/test/java/awt/print/PrinterJob/PrintTextTest.java b/test/java/awt/print/PrinterJob/PrintTextTest.java
new file mode 100644
index 0000000..3ce4c72
--- /dev/null
+++ b/test/java/awt/print/PrinterJob/PrintTextTest.java
@@ -0,0 +1,395 @@
+/*
+ * Copyright (c) 2015, 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 6425068 7157659 8132890
+ * @summary Confirm that text prints where we expect to the length we expect.
+ * @run applet/manual=yesno PrintTextTest.html
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.text.*;
+import java.util.*;
+import java.awt.font.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+import javax.swing.*;
+
+public class PrintTextTest extends JApplet {
+ public void start() {
+ StandalonePrintTextTest.main(null);
+ }
+}
+
+class StandalonePrintTextTest extends Component implements Printable {
+
+ static int preferredSize;
+ Font textFont;
+ AffineTransform gxTx;
+ String page;
+ boolean useFM;
+
+ public static void main(String args[]) {
+
+ PrinterJob pjob = PrinterJob.getPrinterJob();
+ PageFormat portrait = pjob.defaultPage();
+ portrait.setOrientation(PageFormat.PORTRAIT);
+ preferredSize = (int)portrait.getImageableWidth();
+
+ PageFormat landscape = pjob.defaultPage();
+ landscape.setOrientation(PageFormat.LANDSCAPE);
+
+ Book book = new Book();
+
+ JTabbedPane p = new JTabbedPane();
+
+ int page = 1;
+ Font font = new Font("Dialog", Font.PLAIN, 18);
+ String name = "Page " + new Integer(page++);
+ StandalonePrintTextTest ptt = new StandalonePrintTextTest(name, font, null, false);
+ p.add(name, ptt);
+ book.append(ptt, portrait);
+ book.append(ptt, landscape);
+
+ font = new Font("Dialog", Font.PLAIN, 18);
+ name = "Page " + new Integer(page++);
+ ptt = new StandalonePrintTextTest(name, font, null, true);
+ p.add(name, ptt);
+ book.append(ptt, portrait);
+ book.append(ptt, landscape);
+
+ font = new Font("Lucida Sans", Font.PLAIN, 18);
+ name = "Page " + new Integer(page++);
+ ptt = new StandalonePrintTextTest(name, font, null, false);
+ p.add(name, ptt);
+ book.append(ptt, portrait);
+ book.append(ptt, landscape);
+
+ font = new Font("Lucida Sans", Font.PLAIN, 18);
+ AffineTransform rotTx = AffineTransform.getRotateInstance(0.15);
+ rotTx.translate(60,0);
+ name = "Page " + new Integer(page++);
+ ptt = new StandalonePrintTextTest(name, font, rotTx, false);
+ p.add(name, ptt);
+ book.append(ptt, portrait);
+ book.append(ptt, landscape);
+
+ font = new Font("Dialog", Font.PLAIN, 18);
+ AffineTransform scaleTx = AffineTransform.getScaleInstance(1.25, 1.25);
+ name = "Page " + new Integer(page++);
+ ptt = new StandalonePrintTextTest(name, font, scaleTx, false);
+ p.add(name, ptt);
+ book.append(ptt, portrait);
+ book.append(ptt, landscape);
+
+ font = new Font("Dialog", Font.PLAIN, 18);
+ scaleTx = AffineTransform.getScaleInstance(-1.25, 1.25);
+ scaleTx.translate(-preferredSize/1.25, 0);
+ name = "Page " + new Integer(page++);
+ ptt = new StandalonePrintTextTest(name, font, scaleTx, false);
+ p.add(name, ptt);
+ book.append(ptt, portrait);
+ book.append(ptt, landscape);
+
+ font = new Font("Dialog", Font.PLAIN, 18);
+ scaleTx = AffineTransform.getScaleInstance(1.25, -1.25);
+ scaleTx.translate(0, -preferredSize/1.25);
+ name = "Page " + new Integer(page++);
+ ptt = new StandalonePrintTextTest(name, font, scaleTx, false);
+ p.add(name, ptt);
+ book.append(ptt, portrait);
+ book.append(ptt, landscape);
+
+ font = font.deriveFont(rotTx);
+ name = "Page " + new Integer(page++);
+ ptt = new StandalonePrintTextTest(name, font, null, false);
+ p.add(ptt, BorderLayout.CENTER);
+ p.add(name, ptt);
+ book.append(ptt, portrait);
+ book.append(ptt, landscape);
+
+ font = new Font("Monospaced", Font.PLAIN, 12);
+ name = "Page " + new Integer(page++);
+ ptt = new StandalonePrintTextTest(name, font, null, false);
+ p.add(ptt, BorderLayout.CENTER);
+ p.add(name, ptt);
+ book.append(ptt, portrait);
+ book.append(ptt, landscape);
+
+ Font xfont = font.deriveFont(AffineTransform.getScaleInstance(1.5, 1));
+ name = "Page " + new Integer(page++);
+ ptt = new StandalonePrintTextTest(name, xfont, null, false);
+ p.add(ptt, BorderLayout.CENTER);
+ p.add(name, ptt);
+ book.append(ptt, portrait);
+ book.append(ptt, landscape);
+
+ Font yfont = font.deriveFont(AffineTransform.getScaleInstance(1, 1.5));
+ name = "Page " + new Integer(page++);
+ ptt = new StandalonePrintTextTest(name, yfont, null, false);
+ p.add(ptt, BorderLayout.CENTER);
+ p.add(name, ptt);
+ book.append(ptt, portrait);
+ book.append(ptt, landscape);
+
+ if (System.getProperty("os.name").startsWith("Windows")) {
+ font = new Font("MS Gothic", Font.PLAIN, 12);
+ name = "Page " + new Integer(page++);
+ ptt = new PrintJAText(name, font, null, true);
+ p.add(ptt, BorderLayout.CENTER);
+ p.add(name, ptt);
+ book.append(ptt, portrait);
+ book.append(ptt, landscape);
+
+ font = new Font("MS Gothic", Font.PLAIN, 12);
+ name = "Page " + new Integer(page++);
+ rotTx = AffineTransform.getRotateInstance(0.15);
+ ptt = new PrintJAText(name, font, rotTx, true);
+ p.add(ptt, BorderLayout.CENTER);
+ p.add(name, ptt);
+ book.append(ptt, portrait);
+ book.append(ptt, landscape);
+ }
+
+ pjob.setPageable(book);
+
+ JFrame f = new JFrame();
+ f.add(BorderLayout.CENTER, p);
+ f.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {System.exit(0);}
+ });
+ f.pack();
+ f.show();
+
+ try {
+ if (pjob.printDialog()) {
+ pjob.print();
+ }
+ } catch (PrinterException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+
+ public StandalonePrintTextTest(String page, Font font, AffineTransform gxTx,
+ boolean fm) {
+ this.page = page;
+ textFont = font;
+ this.gxTx = gxTx;
+ this.useFM = fm;
+ setBackground(Color.white);
+ }
+
+ public static AttributedCharacterIterator getIterator(String s) {
+ return new AttributedString(s).getIterator();
+ }
+
+ static String orient(PageFormat pf) {
+ if (pf.getOrientation() == PageFormat.PORTRAIT) {
+ return "Portrait";
+ } else {
+ return "Landscape";
+ }
+ }
+
+ public int print(Graphics g, PageFormat pf, int pageIndex) {
+
+ Graphics2D g2d = (Graphics2D)g;
+ g2d.translate(pf.getImageableX(), pf.getImageableY());
+ g.drawString(page+" "+orient(pf),50,20);
+ g.translate(0, 25);
+ paint(g);
+ return PAGE_EXISTS;
+ }
+
+ public Dimension getMinimumSize() {
+ return getPreferredSize();
+ }
+
+ public Dimension getPreferredSize() {
+ return new Dimension(preferredSize, preferredSize);
+ }
+
+ public void paint(Graphics g) {
+
+ /* fill with white before any transformation is applied */
+ g.setColor(Color.white);
+ g.fillRect(0, 0, getSize().width, getSize().height);
+
+
+ Graphics2D g2d = (Graphics2D) g;
+ if (gxTx != null) {
+ g2d.transform(gxTx);
+ }
+ if (useFM) {
+ g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+ RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+ }
+
+ g.setFont(textFont);
+ FontMetrics fm = g.getFontMetrics();
+
+ String s;
+ int LS = 30;
+ int ix=10, iy=LS+10;
+ g.setColor(Color.black);
+
+ s = "drawString(String str, int x, int y)";
+ g.drawString(s, ix, iy);
+ if (!textFont.isTransformed()) {
+ g.drawLine(ix, iy+1, ix+fm.stringWidth(s), iy+1);
+ }
+
+ iy += LS;
+ s = "drawString(AttributedCharacterIterator iterator, int x, int y)";
+ g.drawString(getIterator(s), ix, iy);
+
+ iy += LS;
+ s = "\tdrawChars(\t\r\nchar[], int off, int len, int x, int y\t)";
+ g.drawChars(s.toCharArray(), 0, s.length(), ix, iy);
+ if (!textFont.isTransformed()) {
+ g.drawLine(ix, iy+1, ix+fm.stringWidth(s), iy+1);
+ }
+
+ iy += LS;
+ s = "drawBytes(byte[], int off, int len, int x, int y)";
+ byte data[] = new byte[s.length()];
+ for (int i = 0; i < data.length; i++) {
+ data[i] = (byte) s.charAt(i);
+ }
+ g.drawBytes(data, 0, data.length, ix, iy);
+
+ Font f = g2d.getFont();
+ FontRenderContext frc = g2d.getFontRenderContext();
+
+ iy += LS;
+ s = "drawString(String s, float x, float y)";
+ g2d.drawString(s, (float) ix, (float) iy);
+ if (!textFont.isTransformed()) {
+ g.drawLine(ix, iy+1, ix+fm.stringWidth(s), iy+1);
+ }
+
+ iy += LS;
+ s = "drawString(AttributedCharacterIterator iterator, "+
+ "float x, float y)";
+ g2d.drawString(getIterator(s), (float) ix, (float) iy);
+
+ iy += LS;
+ s = "drawGlyphVector(GlyphVector g, float x, float y)";
+ GlyphVector gv = f.createGlyphVector(frc, s);
+ g2d.drawGlyphVector(gv, ix, iy);
+ Point2D adv = gv.getGlyphPosition(gv.getNumGlyphs());
+ if (!textFont.isTransformed()) {
+ g.drawLine(ix, iy+1, ix+(int)adv.getX(), iy+1);
+ }
+
+ iy += LS;
+ s = "GlyphVector with position adjustments";
+
+ gv = f.createGlyphVector(frc, s);
+ int ng = gv.getNumGlyphs();
+ adv = gv.getGlyphPosition(ng);
+ for (int i=0; i<ng; i++) {
+ Point2D gp = gv.getGlyphPosition(i);
+ double gx = gp.getX();
+ double gy = gp.getY();
+ if (i % 2 == 0) {
+ gy+=5;
+ } else {
+ gy-=5;
+ }
+ gp.setLocation(gx, gy);
+ gv.setGlyphPosition(i, gp);
+ }
+ g2d.drawGlyphVector(gv, ix, iy);
+ if (!textFont.isTransformed()) {
+ g.drawLine(ix, iy+1, ix+(int)adv.getX(), iy+1);
+ }
+
+ iy +=LS;
+ s = "drawString: \u0924\u094d\u0930 \u0915\u0948\u0930\u0947 End.";
+ g.drawString(s, ix, iy);
+ if (!textFont.isTransformed()) {
+ g.drawLine(ix, iy+1, ix+fm.stringWidth(s), iy+1);
+ }
+
+ iy += LS;
+ s = "TextLayout 1: \u0924\u094d\u0930 \u0915\u0948\u0930\u0947 End.";
+ TextLayout tl = new TextLayout(s, new HashMap(), frc);
+ tl.draw(g2d, ix, iy);
+
+ iy += LS;
+ s = "TextLayout 2: \u0924\u094d\u0930 \u0915\u0948\u0930\u0947 End.";
+ tl = new TextLayout(s, f, frc);
+ tl.draw(g2d, ix, iy);
+ }
+}
+
+class PrintJAText extends StandalonePrintTextTest {
+
+
+ public PrintJAText(String page, Font font, AffineTransform gxTx,
+ boolean fm) {
+ super(page, font, gxTx, fm);
+ }
+
+ private static final String TEXT =
+ "\u3042\u3044\u3046\u3048\u304a\u30a4\u30ed\u30cf" +
+ "\u30cb\u30db\u30d8\u30c8\u4e00\u4e01\u4e02\u4e05\uff08";
+
+
+ public void paint(Graphics g) {
+
+ /* fill with white before any transformation is applied */
+ g.setColor(Color.white);
+ g.fillRect(0, 0, getSize().width, getSize().height);
+
+
+ Graphics2D g2d = (Graphics2D) g;
+ if (gxTx != null) {
+ g2d.transform(gxTx);
+ }
+ if (useFM) {
+ g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+ RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+ }
+
+ String text = TEXT + TEXT + TEXT;
+ g.setColor(Color.black);
+ int y = 20;
+ float origSize = 7f;
+ for (int i=0;i<11;i++) {
+ float size = origSize+(i*0.1f);
+ g2d.translate(0, size+6);
+ Font f = textFont.deriveFont(size);
+ g2d.setFont(f);
+ FontMetrics fontMetrics = g2d.getFontMetrics();
+ int stringWidth = fontMetrics.stringWidth(text);
+ g.drawLine(0, y+1, stringWidth, y+1);
+ g.drawString(text, 0, y);
+ y +=10;
+ }
+ }
+}
diff --git a/test/java/security/Signature/TestInitSignWithMyOwnRandom.java b/test/java/security/Signature/TestInitSignWithMyOwnRandom.java
index 2a2121e..0d2d7fd 100644
--- a/test/java/security/Signature/TestInitSignWithMyOwnRandom.java
+++ b/test/java/security/Signature/TestInitSignWithMyOwnRandom.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, 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
@@ -55,9 +55,9 @@
int count = 0;
- public int nextInt() {
+ @Override
+ public void nextBytes(byte[] rs) {
count++;
- return 0;
}
public boolean isUsed() {
diff --git a/test/javax/security/auth/SubjectDomainCombiner/Optimize.java b/test/javax/security/auth/SubjectDomainCombiner/Optimize.java
index 99ec943..df5adef 100644
--- a/test/javax/security/auth/SubjectDomainCombiner/Optimize.java
+++ b/test/javax/security/auth/SubjectDomainCombiner/Optimize.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -37,13 +37,16 @@
ProtectionDomain pd1 = new ProtectionDomain(
new CodeSource(null, (java.security.cert.Certificate[]) null),
- new Permissions());
+ new Permissions(),
+ null, null);
ProtectionDomain pd2 = new ProtectionDomain(
new CodeSource(null, (java.security.cert.Certificate[]) null),
- new Permissions());
+ new Permissions(),
+ null, null);
ProtectionDomain pd3 = new ProtectionDomain(
new CodeSource(null, (java.security.cert.Certificate[]) null),
- new Permissions());
+ new Permissions(),
+ null, null);
ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};
diff --git a/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java b/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java
index b679c11..f754148 100644
--- a/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java
+++ b/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java
@@ -57,10 +57,6 @@
}
public void main(Provider p) throws Exception {
- // MD5 is used in this test case, don't disable MD5 algorithm.
- Security.setProperty(
- "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024");
-
String testWithoutSunEC = System.getProperty("testWithoutSunEC");
if (p.getService("KeyFactory", "EC") == null) {
diff --git a/test/sun/security/provider/DSA/TestDSA2.java b/test/sun/security/provider/DSA/TestDSA2.java
index 247c8f2..f714f9b 100644
--- a/test/sun/security/provider/DSA/TestDSA2.java
+++ b/test/sun/security/provider/DSA/TestDSA2.java
@@ -50,7 +50,7 @@
public static void main(String[] args) throws Exception {
boolean[] expectedToPass = { true, true, true };
test(1024, expectedToPass);
- boolean[] expectedToPass2 = { true, true, true };
+ boolean[] expectedToPass2 = { false, true, true };
test(2048, expectedToPass2);
}