提交 0963f6fc 编写于 作者: L lana

Merge

...@@ -373,6 +373,10 @@ fc4f5546417071c70cffd89ca83302309f6f7da9 jdk8u40-b17 ...@@ -373,6 +373,10 @@ fc4f5546417071c70cffd89ca83302309f6f7da9 jdk8u40-b17
5c31204d19e5976f025026db3d5c17331e8c44db jdk8u40-b19 5c31204d19e5976f025026db3d5c17331e8c44db jdk8u40-b19
7784dab075ed82be2275f4694164bbb9cc1cde3f jdk8u40-b20 7784dab075ed82be2275f4694164bbb9cc1cde3f jdk8u40-b20
564bca490631e4ed4f7993e6633ed9ee62067624 jdk8u40-b21 564bca490631e4ed4f7993e6633ed9ee62067624 jdk8u40-b21
d168113f9841a77b3cee3a6a45fcd85b7351ac90 jdk8u40-b22
41fe61722ce96b75dd3a1ba5072473122e21e5a0 jdk8u40-b23
9d903721276c8684706db7ecfb6cda568e9f4f69 jdk8u40-b24
f0d5cb59b0e6a67fa102465458cc4725c6e59089 jdk8u40-b25
5c31204d19e5976f025026db3d5c17331e8c44db jdk8u60-b00 5c31204d19e5976f025026db3d5c17331e8c44db jdk8u60-b00
c46daef6edb5385d11876ed40f292a4b62e96867 jdk8u60-b01 c46daef6edb5385d11876ed40f292a4b62e96867 jdk8u60-b01
c10fd784956cc7099657181029ac3e790267b678 jdk8u60-b02 c10fd784956cc7099657181029ac3e790267b678 jdk8u60-b02
......
0x00 U+0000
0x01 U+0001
0x02 U+0002
0x03 U+0003
0x04 U+009c
0x05 U+0009
0x06 U+0086
0x07 U+007f
0x08 U+0097
0x09 U+008d
0x0a U+008e
0x0b U+000b
0x0c U+000c
0x0d U+000d
0x0e U+000e
0x0f U+000f
0x10 U+0010
0x11 U+0011
0x12 U+0012
0x13 U+0013
0x14 U+009d
0x15 U+000a
0x16 U+0008
0x17 U+0087
0x18 U+0018
0x19 U+0019
0x1a U+0092
0x1b U+008f
0x1c U+001c
0x1d U+001d
0x1e U+001e
0x1f U+001f
0x20 U+0080
0x21 U+0081
0x22 U+0082
0x23 U+0083
0x24 U+0084
0x25 U+000a
0x26 U+0017
0x27 U+001b
0x28 U+0088
0x29 U+0089
0x2a U+008a
0x2b U+008b
0x2c U+008c
0x2d U+0005
0x2e U+0006
0x2f U+0007
0x30 U+0090
0x31 U+0091
0x32 U+0016
0x33 U+0093
0x34 U+0094
0x35 U+0095
0x36 U+0096
0x37 U+0004
0x38 U+0098
0x39 U+0099
0x3a U+009a
0x3b U+009b
0x3c U+0014
0x3d U+0015
0x3e U+009e
0x3f U+001a
0x40 U+0020
0x41 U+00a0
0x42 U+04d9
0x43 U+0493
0x44 U+0451
0x45 U+0454
0x46 U+0455
0x47 U+0456
0x48 U+049b
0x49 U+0458
0x4a U+005b
0x4b U+002e
0x4c U+003c
0x4d U+0028
0x4e U+002b
0x4f U+0021
0x50 U+0026
0x51 U+04a3
0x52 U+04e9
0x53 U+04b1
0x54 U+04af
0x55 U+045e
0x56 U+04bb
0x57 U+042a
0x58 U+2116
0x59 U+04d8
0x5a U+005d
0x5b U+0024
0x5c U+002a
0x5d U+0029
0x5e U+003b
0x5f U+005e
0x60 U+002d
0x61 U+002f
0x62 U+0492
0x63 U+0401
0x64 U+0404
0x65 U+0405
0x66 U+0406
0x67 U+049a
0x68 U+0408
0x69 U+04a2
0x6a U+007c
0x6b U+002c
0x6c U+0025
0x6d U+005f
0x6e U+003e
0x6f U+003f
0x70 U+04e8
0x71 U+04b0
0x72 U+04ae
0x73 U+00ad
0x74 U+040e
0x75 U+04ba
0x76 U+044e
0x77 U+0430
0x78 U+0431
0x79 U+0060
0x7a U+003a
0x7b U+0023
0x7c U+0040
0x7d U+0027
0x7e U+003d
0x7f U+0022
0x80 U+0446
0x81 U+0061
0x82 U+0062
0x83 U+0063
0x84 U+0064
0x85 U+0065
0x86 U+0066
0x87 U+0067
0x88 U+0068
0x89 U+0069
0x8a U+0434
0x8b U+0435
0x8c U+0444
0x8d U+0433
0x8e U+0445
0x8f U+0438
0x90 U+0439
0x91 U+006a
0x92 U+006b
0x93 U+006c
0x94 U+006d
0x95 U+006e
0x96 U+006f
0x97 U+0070
0x98 U+0071
0x99 U+0072
0x9a U+043a
0x9b U+043b
0x9c U+043c
0x9d U+043d
0x9e U+043e
0x9f U+043f
0xa0 U+044f
0xa1 U+007e
0xa2 U+0073
0xa3 U+0074
0xa4 U+0075
0xa5 U+0076
0xa6 U+0077
0xa7 U+0078
0xa8 U+0079
0xa9 U+007a
0xaa U+0440
0xab U+0441
0xac U+0442
0xad U+0443
0xae U+0436
0xaf U+0432
0xb0 U+044c
0xb1 U+044b
0xb2 U+0437
0xb3 U+0448
0xb4 U+044d
0xb5 U+0449
0xb6 U+0447
0xb7 U+044a
0xb8 U+042e
0xb9 U+0410
0xba U+0411
0xbb U+0426
0xbc U+0414
0xbd U+0415
0xbe U+0424
0xbf U+0413
0xc0 U+007b
0xc1 U+0041
0xc2 U+0042
0xc3 U+0043
0xc4 U+0044
0xc5 U+0045
0xc6 U+0046
0xc7 U+0047
0xc8 U+0048
0xc9 U+0049
0xca U+0425
0xcb U+0418
0xcc U+0419
0xcd U+041a
0xce U+041b
0xcf U+041c
0xd0 U+007d
0xd1 U+004a
0xd2 U+004b
0xd3 U+004c
0xd4 U+004d
0xd5 U+004e
0xd6 U+004f
0xd7 U+0050
0xd8 U+0051
0xd9 U+0052
0xda U+041d
0xdb U+041e
0xdc U+041f
0xdd U+042f
0xde U+0420
0xdf U+0421
0xe0 U+005c
0xe1 U+20ac
0xe2 U+0053
0xe3 U+0054
0xe4 U+0055
0xe5 U+0056
0xe6 U+0057
0xe7 U+0058
0xe8 U+0059
0xe9 U+005a
0xea U+0422
0xeb U+0423
0xec U+0416
0xed U+0412
0xee U+042c
0xef U+042b
0xf0 U+0030
0xf1 U+0031
0xf2 U+0032
0xf3 U+0033
0xf4 U+0034
0xf5 U+0035
0xf6 U+0036
0xf7 U+0037
0xf8 U+0038
0xf9 U+0039
0xfa U+0417
0xfb U+0428
0xfc U+042d
0xfd U+0429
0xfe U+0427
0xff U+009f
...@@ -22,6 +22,7 @@ IBM1146 IBM01146 Cp1146 false sun.nio.cs.ext ...@@ -22,6 +22,7 @@ IBM1146 IBM01146 Cp1146 false sun.nio.cs.ext
IBM1147 IBM01147 Cp1147 false sun.nio.cs.ext IBM1147 IBM01147 Cp1147 false sun.nio.cs.ext
IBM1148 IBM01148 Cp1148 false sun.nio.cs.ext IBM1148 IBM01148 Cp1148 false sun.nio.cs.ext
IBM1149 IBM01149 Cp1149 false sun.nio.cs.ext IBM1149 IBM01149 Cp1149 false sun.nio.cs.ext
IBM1166 x-IBM1166 Cp1166 false sun.nio.cs.ext
IBM273 IBM273 Cp273 false sun.nio.cs.ext IBM273 IBM273 Cp273 false sun.nio.cs.ext
IBM277 IBM277 Cp277 false sun.nio.cs.ext IBM277 IBM277 Cp277 false sun.nio.cs.ext
IBM278 IBM278 Cp278 false sun.nio.cs.ext IBM278 IBM278 Cp278 false sun.nio.cs.ext
......
...@@ -195,7 +195,7 @@ public class AquaIcon { ...@@ -195,7 +195,7 @@ public class AquaIcon {
AquaPainter.create(JRSUIState.getInstance()); AquaPainter.create(JRSUIState.getInstance());
initIconPainter(painter); initIconPainter(painter);
g.setClip(new Rectangle(x, y, width, height)); g.clipRect(x, y, width, height);
painter.paint(g, c, x, y, width, height); painter.paint(g, c, x, y, width, height);
g.dispose(); g.dispose();
} }
......
...@@ -43,7 +43,6 @@ public final class CGraphicsDevice extends GraphicsDevice ...@@ -43,7 +43,6 @@ public final class CGraphicsDevice extends GraphicsDevice
* therefore methods, which is using this id should be ready to it. * therefore methods, which is using this id should be ready to it.
*/ */
private volatile int displayID; private volatile int displayID;
private volatile Insets screenInsets;
private volatile double xResolution; private volatile double xResolution;
private volatile double yResolution; private volatile double yResolution;
private volatile int scale; private volatile int scale;
...@@ -120,7 +119,13 @@ public final class CGraphicsDevice extends GraphicsDevice ...@@ -120,7 +119,13 @@ public final class CGraphicsDevice extends GraphicsDevice
} }
public Insets getScreenInsets() { public Insets getScreenInsets() {
return screenInsets; // the insets are queried synchronously and are not cached
// since there are no Quartz or Cocoa means to receive notifications
// on insets changes (e.g. when the Dock is resized):
// the existing CGDisplayReconfigurationCallBack is not notified
// as well as the NSApplicationDidChangeScreenParametersNotification
// is fired on the Dock location changes only
return nativeGetScreenInsets(displayID);
} }
public int getScaleFactor() { public int getScaleFactor() {
...@@ -135,7 +140,6 @@ public final class CGraphicsDevice extends GraphicsDevice ...@@ -135,7 +140,6 @@ public final class CGraphicsDevice extends GraphicsDevice
public void displayChanged() { public void displayChanged() {
xResolution = nativeGetXResolution(displayID); xResolution = nativeGetXResolution(displayID);
yResolution = nativeGetYResolution(displayID); yResolution = nativeGetYResolution(displayID);
screenInsets = nativeGetScreenInsets(displayID);
scale = (int) nativeGetScaleFactor(displayID); scale = (int) nativeGetScaleFactor(displayID);
//TODO configs/fullscreenWindow/modes? //TODO configs/fullscreenWindow/modes?
} }
......
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -28,9 +29,7 @@ ...@@ -28,9 +29,7 @@
package com.sun.crypto.provider; package com.sun.crypto.provider;
import java.util.Arrays; import java.security.ProviderException;
import java.security.*;
import static com.sun.crypto.provider.AESConstants.AES_BLOCK_SIZE;
/** /**
* This class represents the GHASH function defined in NIST 800-38D * This class represents the GHASH function defined in NIST 800-38D
...@@ -44,62 +43,90 @@ import static com.sun.crypto.provider.AESConstants.AES_BLOCK_SIZE; ...@@ -44,62 +43,90 @@ import static com.sun.crypto.provider.AESConstants.AES_BLOCK_SIZE;
*/ */
final class GHASH { final class GHASH {
private static final byte P128 = (byte) 0xe1; //reduction polynomial private static long getLong(byte[] buffer, int offset) {
long result = 0;
private static boolean getBit(byte[] b, int pos) { int end = offset + 8;
int p = pos / 8; for (int i = offset; i < end; ++i) {
pos %= 8; result = (result << 8) + (buffer[i] & 0xFF);
int i = (b[p] >>> (7 - pos)) & 1; }
return i != 0; return result;
} }
private static void shift(byte[] b) { private static void putLong(byte[] buffer, int offset, long value) {
byte temp, temp2; int end = offset + 8;
temp2 = 0; for (int i = end - 1; i >= offset; --i) {
for (int i = 0; i < b.length; i++) { buffer[i] = (byte) value;
temp = (byte) ((b[i] & 0x01) << 7); value >>= 8;
b[i] = (byte) ((b[i] & 0xff) >>> 1);
b[i] = (byte) (b[i] | temp2);
temp2 = temp;
} }
} }
// Given block X and Y, returns the muliplication of X * Y private static final int AES_BLOCK_SIZE = 16;
private static byte[] blockMult(byte[] x, byte[] y) {
if (x.length != AES_BLOCK_SIZE || y.length != AES_BLOCK_SIZE) { // Multiplies state0, state1 by V0, V1.
throw new RuntimeException("illegal input sizes"); private void blockMult(long V0, long V1) {
long Z0 = 0;
long Z1 = 0;
long X;
// Separate loops for processing state0 and state1.
X = state0;
for (int i = 0; i < 64; i++) {
// Zi+1 = Zi if bit i of x is 0
long mask = X >> 63;
Z0 ^= V0 & mask;
Z1 ^= V1 & mask;
// Save mask for conditional reduction below.
mask = (V1 << 63) >> 63;
// V = rightshift(V)
long carry = V0 & 1;
V0 = V0 >>> 1;
V1 = (V1 >>> 1) | (carry << 63);
// Conditional reduction modulo P128.
V0 ^= 0xe100000000000000L & mask;
X <<= 1;
} }
byte[] z = new byte[AES_BLOCK_SIZE];
byte[] v = y.clone(); X = state1;
// calculate Z1-Z127 and V1-V127 for (int i = 64; i < 127; i++) {
for (int i = 0; i < 127; i++) {
// Zi+1 = Zi if bit i of x is 0 // Zi+1 = Zi if bit i of x is 0
if (getBit(x, i)) { long mask = X >> 63;
for (int n = 0; n < z.length; n++) { Z0 ^= V0 & mask;
z[n] ^= v[n]; Z1 ^= V1 & mask;
}
} // Save mask for conditional reduction below.
boolean lastBitOfV = getBit(v, 127); mask = (V1 << 63) >> 63;
shift(v);
if (lastBitOfV) v[0] ^= P128; // V = rightshift(V)
long carry = V0 & 1;
V0 = V0 >>> 1;
V1 = (V1 >>> 1) | (carry << 63);
// Conditional reduction.
V0 ^= 0xe100000000000000L & mask;
X <<= 1;
} }
// calculate Z128 // calculate Z128
if (getBit(x, 127)) { long mask = X >> 63;
for (int n = 0; n < z.length; n++) { Z0 ^= V0 & mask;
z[n] ^= v[n]; Z1 ^= V1 & mask;
}
} // Save result.
return z; state0 = Z0;
state1 = Z1;
} }
// hash subkey H; should not change after the object has been constructed // hash subkey H; should not change after the object has been constructed
private final byte[] subkeyH; private final long subkeyH0, subkeyH1;
// buffer for storing hash // buffer for storing hash
private byte[] state; private long state0, state1;
// variables for save/restore calls // variables for save/restore calls
private byte[] stateSave = null; private long stateSave0, stateSave1;
/** /**
* Initializes the cipher in the specified mode with the given key * Initializes the cipher in the specified mode with the given key
...@@ -114,8 +141,8 @@ final class GHASH { ...@@ -114,8 +141,8 @@ final class GHASH {
if ((subkeyH == null) || subkeyH.length != AES_BLOCK_SIZE) { if ((subkeyH == null) || subkeyH.length != AES_BLOCK_SIZE) {
throw new ProviderException("Internal error"); throw new ProviderException("Internal error");
} }
this.subkeyH = subkeyH; this.subkeyH0 = getLong(subkeyH, 0);
this.state = new byte[AES_BLOCK_SIZE]; this.subkeyH1 = getLong(subkeyH, 8);
} }
/** /**
...@@ -124,31 +151,33 @@ final class GHASH { ...@@ -124,31 +151,33 @@ final class GHASH {
* this object for different data w/ the same H. * this object for different data w/ the same H.
*/ */
void reset() { void reset() {
Arrays.fill(state, (byte) 0); state0 = 0;
state1 = 0;
} }
/** /**
* Save the current snapshot of this GHASH object. * Save the current snapshot of this GHASH object.
*/ */
void save() { void save() {
stateSave = state.clone(); stateSave0 = state0;
stateSave1 = state1;
} }
/** /**
* Restores this object using the saved snapshot. * Restores this object using the saved snapshot.
*/ */
void restore() { void restore() {
state = stateSave; state0 = stateSave0;
state1 = stateSave1;
} }
private void processBlock(byte[] data, int ofs) { private void processBlock(byte[] data, int ofs) {
if (data.length - ofs < AES_BLOCK_SIZE) { if (data.length - ofs < AES_BLOCK_SIZE) {
throw new RuntimeException("need complete block"); throw new RuntimeException("need complete block");
} }
for (int n = 0; n < state.length; n++) { state0 ^= getLong(data, ofs);
state[n] ^= data[ofs + n]; state1 ^= getLong(data, ofs + 8);
} blockMult(subkeyH0, subkeyH1);
state = blockMult(state, subkeyH);
} }
void update(byte[] in) { void update(byte[] in) {
...@@ -169,10 +198,10 @@ final class GHASH { ...@@ -169,10 +198,10 @@ final class GHASH {
} }
byte[] digest() { byte[] digest() {
try { byte[] result = new byte[AES_BLOCK_SIZE];
return state.clone(); putLong(result, 0, state0);
} finally { putLong(result, 8, state1);
reset(); reset();
} return result;
} }
} }
...@@ -4801,41 +4801,61 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> { ...@@ -4801,41 +4801,61 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
if (dividendHi >= divisor) { if (dividendHi >= divisor) {
return null; return null;
} }
final int shift = Long.numberOfLeadingZeros(divisor); final int shift = Long.numberOfLeadingZeros(divisor);
divisor <<= shift; divisor <<= shift;
final long v1 = divisor >>> 32; final long v1 = divisor >>> 32;
final long v0 = divisor & LONG_MASK; final long v0 = divisor & LONG_MASK;
long q1, q0;
long r_tmp;
long tmp = dividendLo << shift; long tmp = dividendLo << shift;
long u1 = tmp >>> 32; long u1 = tmp >>> 32;
long u0 = tmp & LONG_MASK; long u0 = tmp & LONG_MASK;
tmp = (dividendHi << shift) | (dividendLo >>> 64 - shift); tmp = (dividendHi << shift) | (dividendLo >>> 64 - shift);
long u2 = tmp & LONG_MASK; long u2 = tmp & LONG_MASK;
tmp = divWord(tmp,v1); long q1, r_tmp;
q1 = tmp & LONG_MASK; if (v1 == 1) {
r_tmp = tmp >>> 32; q1 = tmp;
r_tmp = 0;
} else if (tmp >= 0) {
q1 = tmp / v1;
r_tmp = tmp - q1 * v1;
} else {
long[] rq = divRemNegativeLong(tmp, v1);
q1 = rq[1];
r_tmp = rq[0];
}
while(q1 >= DIV_NUM_BASE || unsignedLongCompare(q1*v0, make64(r_tmp, u1))) { while(q1 >= DIV_NUM_BASE || unsignedLongCompare(q1*v0, make64(r_tmp, u1))) {
q1--; q1--;
r_tmp += v1; r_tmp += v1;
if (r_tmp >= DIV_NUM_BASE) if (r_tmp >= DIV_NUM_BASE)
break; break;
} }
tmp = mulsub(u2,u1,v1,v0,q1); tmp = mulsub(u2,u1,v1,v0,q1);
u1 = tmp & LONG_MASK; u1 = tmp & LONG_MASK;
tmp = divWord(tmp,v1); long q0;
q0 = tmp & LONG_MASK; if (v1 == 1) {
r_tmp = tmp >>> 32; q0 = tmp;
r_tmp = 0;
} else if (tmp >= 0) {
q0 = tmp / v1;
r_tmp = tmp - q0 * v1;
} else {
long[] rq = divRemNegativeLong(tmp, v1);
q0 = rq[1];
r_tmp = rq[0];
}
while(q0 >= DIV_NUM_BASE || unsignedLongCompare(q0*v0,make64(r_tmp,u0))) { while(q0 >= DIV_NUM_BASE || unsignedLongCompare(q0*v0,make64(r_tmp,u0))) {
q0--; q0--;
r_tmp += v1; r_tmp += v1;
if (r_tmp >= DIV_NUM_BASE) if (r_tmp >= DIV_NUM_BASE)
break; break;
} }
if((int)q1 < 0) { if((int)q1 < 0) {
// result (which is positive and unsigned here) // result (which is positive and unsigned here)
// can't fit into long due to sign bit is used for value // can't fit into long due to sign bit is used for value
...@@ -4858,10 +4878,13 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> { ...@@ -4858,10 +4878,13 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
} }
} }
} }
long q = make64(q1,q0); long q = make64(q1,q0);
q*=sign; q*=sign;
if (roundingMode == ROUND_DOWN && scale == preferredScale) if (roundingMode == ROUND_DOWN && scale == preferredScale)
return valueOf(q, scale); return valueOf(q, scale);
long r = mulsub(u1, u0, v1, v0, q0) >>> shift; long r = mulsub(u1, u0, v1, v0, q0) >>> shift;
if (r != 0) { if (r != 0) {
boolean increment = needIncrement(divisor >>> shift, roundingMode, sign, q, r); boolean increment = needIncrement(divisor >>> shift, roundingMode, sign, q, r);
...@@ -4904,28 +4927,35 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> { ...@@ -4904,28 +4927,35 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
} }
} }
private static long divWord(long n, long dLong) { /**
long r; * Calculate the quotient and remainder of dividing a negative long by
long q; * another long.
if (dLong == 1) { *
q = (int)n; * @param n the numerator; must be negative
return (q & LONG_MASK); * @param d the denominator; must not be unity
} * @return a two-element {@long} array with the remainder and quotient in
* the initial and final elements, respectively
*/
private static long[] divRemNegativeLong(long n, long d) {
assert n < 0 : "Non-negative numerator " + n;
assert d != 1 : "Unity denominator";
// Approximate the quotient and remainder // Approximate the quotient and remainder
q = (n >>> 1) / (dLong >>> 1); long q = (n >>> 1) / (d >>> 1);
r = n - q*dLong; long r = n - q * d;
// Correct the approximation // Correct the approximation
while (r < 0) { while (r < 0) {
r += dLong; r += d;
q--; q--;
} }
while (r >= dLong) { while (r >= d) {
r -= dLong; r -= d;
q++; q++;
} }
// n - q*dlong == r && 0 <= r <dLong, hence we're done.
return (r << 32) | (q & LONG_MASK); // n - q*d == r && 0 <= r < d, hence we're done.
return new long[] {r, q};
} }
private static long make64(long hi, long lo) { private static long make64(long hi, long lo) {
......
...@@ -388,14 +388,13 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { ...@@ -388,14 +388,13 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
} }
while (iProxy.hasNext()) { while (iProxy.hasNext()) {
p = iProxy.next(); p = iProxy.next();
if (p == null || p == Proxy.NO_PROXY) { if (p == null || p.type() != Proxy.Type.SOCKS) {
super.connect(epoint, remainingMillis(deadlineMillis)); super.connect(epoint, remainingMillis(deadlineMillis));
return; return;
} }
if (p.type() != Proxy.Type.SOCKS)
throw new SocketException("Unknown proxy type : " + p.type());
if (!(p.address() instanceof InetSocketAddress)) if (!(p.address() instanceof InetSocketAddress))
throw new SocketException("Unknow address type for proxy: " + p); throw new SocketException("Unknown address type for proxy: " + p);
// Use getHostString() to avoid reverse lookups // Use getHostString() to avoid reverse lookups
server = ((InetSocketAddress) p.address()).getHostString(); server = ((InetSocketAddress) p.address()).getHostString();
serverPort = ((InetSocketAddress) p.address()).getPort(); serverPort = ((InetSocketAddress) p.address()).getPort();
...@@ -703,13 +702,12 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { ...@@ -703,13 +702,12 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
} }
while (iProxy.hasNext()) { while (iProxy.hasNext()) {
p = iProxy.next(); p = iProxy.next();
if (p == null || p == Proxy.NO_PROXY) { if (p == null || p.type() != Proxy.Type.SOCKS) {
return; return;
} }
if (p.type() != Proxy.Type.SOCKS)
throw new SocketException("Unknown proxy type : " + p.type());
if (!(p.address() instanceof InetSocketAddress)) if (!(p.address() instanceof InetSocketAddress))
throw new SocketException("Unknow address type for proxy: " + p); throw new SocketException("Unknown address type for proxy: " + p);
// Use getHostString() to avoid reverse lookups // Use getHostString() to avoid reverse lookups
server = ((InetSocketAddress) p.address()).getHostString(); server = ((InetSocketAddress) p.address()).getHostString();
serverPort = ((InetSocketAddress) p.address()).getPort(); serverPort = ((InetSocketAddress) p.address()).getPort();
......
...@@ -144,10 +144,14 @@ class ComparableTimSort { ...@@ -144,10 +144,14 @@ class ComparableTimSort {
* large) stack lengths for smaller arrays. The "magic numbers" in the * large) stack lengths for smaller arrays. The "magic numbers" in the
* computation below must be changed if MIN_MERGE is decreased. See * computation below must be changed if MIN_MERGE is decreased. See
* the MIN_MERGE declaration above for more information. * the MIN_MERGE declaration above for more information.
* The maximum value of 49 allows for an array up to length
* Integer.MAX_VALUE-4, if array is filled by the worst case stack size
* increasing scenario. More explanations are given in section 4 of:
* http://envisage-project.eu/wp-content/uploads/2015/02/sorting.pdf
*/ */
int stackLen = (len < 120 ? 5 : int stackLen = (len < 120 ? 5 :
len < 1542 ? 10 : len < 1542 ? 10 :
len < 119151 ? 24 : 40); len < 119151 ? 24 : 49);
runBase = new int[stackLen]; runBase = new int[stackLen];
runLen = new int[stackLen]; runLen = new int[stackLen];
} }
......
...@@ -174,10 +174,14 @@ class TimSort<T> { ...@@ -174,10 +174,14 @@ class TimSort<T> {
* large) stack lengths for smaller arrays. The "magic numbers" in the * large) stack lengths for smaller arrays. The "magic numbers" in the
* computation below must be changed if MIN_MERGE is decreased. See * computation below must be changed if MIN_MERGE is decreased. See
* the MIN_MERGE declaration above for more information. * the MIN_MERGE declaration above for more information.
* The maximum value of 49 allows for an array up to length
* Integer.MAX_VALUE-4, if array is filled by the worst case stack size
* increasing scenario. More explanations are given in section 4 of:
* http://envisage-project.eu/wp-content/uploads/2015/02/sorting.pdf
*/ */
int stackLen = (len < 120 ? 5 : int stackLen = (len < 120 ? 5 :
len < 1542 ? 10 : len < 1542 ? 10 :
len < 119151 ? 24 : 40); len < 119151 ? 24 : 49);
runBase = new int[stackLen]; runBase = new int[stackLen];
runLen = new int[stackLen]; runLen = new int[stackLen];
} }
......
...@@ -180,8 +180,7 @@ class ZipEntry implements ZipConstants, Cloneable { ...@@ -180,8 +180,7 @@ class ZipEntry implements ZipConstants, Cloneable {
* @since 1.8 * @since 1.8
*/ */
public ZipEntry setLastModifiedTime(FileTime time) { public ZipEntry setLastModifiedTime(FileTime time) {
Objects.requireNonNull(name, "time"); this.mtime = Objects.requireNonNull(time, "lastModifiedTime");
this.mtime = time;
this.time = time.to(TimeUnit.MILLISECONDS); this.time = time.to(TimeUnit.MILLISECONDS);
return this; return this;
} }
...@@ -227,8 +226,7 @@ class ZipEntry implements ZipConstants, Cloneable { ...@@ -227,8 +226,7 @@ class ZipEntry implements ZipConstants, Cloneable {
* @since 1.8 * @since 1.8
*/ */
public ZipEntry setLastAccessTime(FileTime time) { public ZipEntry setLastAccessTime(FileTime time) {
Objects.requireNonNull(name, "time"); this.atime = Objects.requireNonNull(time, "lastAccessTime");
this.atime = time;
return this; return this;
} }
...@@ -265,8 +263,7 @@ class ZipEntry implements ZipConstants, Cloneable { ...@@ -265,8 +263,7 @@ class ZipEntry implements ZipConstants, Cloneable {
* @since 1.8 * @since 1.8
*/ */
public ZipEntry setCreationTime(FileTime time) { public ZipEntry setCreationTime(FileTime time) {
Objects.requireNonNull(name, "time"); this.ctime = Objects.requireNonNull(time, "creationTime");
this.ctime = time;
return this; return this;
} }
......
...@@ -3738,12 +3738,6 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -3738,12 +3738,6 @@ public abstract class JComponent extends Container implements Serializable,
* @param listener the PropertyChangeListener to be added * @param listener the PropertyChangeListener to be added
*/ */
public void addPropertyChangeListener(PropertyChangeListener listener) { public void addPropertyChangeListener(PropertyChangeListener listener) {
if (accessibleContainerHandler == null) {
accessibleContainerHandler = new AccessibleContainerHandler();
}
if (propertyListenersCount++ == 0) {
JComponent.this.addContainerListener(accessibleContainerHandler);
}
super.addPropertyChangeListener(listener); super.addPropertyChangeListener(listener);
} }
...@@ -3755,9 +3749,6 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -3755,9 +3749,6 @@ public abstract class JComponent extends Container implements Serializable,
* @param listener the PropertyChangeListener to be removed * @param listener the PropertyChangeListener to be removed
*/ */
public void removePropertyChangeListener(PropertyChangeListener listener) { public void removePropertyChangeListener(PropertyChangeListener listener) {
if (--propertyListenersCount == 0) {
JComponent.this.removeContainerListener(accessibleContainerHandler);
}
super.removePropertyChangeListener(listener); super.removePropertyChangeListener(listener);
} }
......
...@@ -475,7 +475,8 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement ...@@ -475,7 +475,8 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
} }
// Then the y: // Then the y:
y = s.height + yOffset; // Prefer dropping down y = s.height + yOffset; // Prefer dropping down
if (position.y + y + pmSize.height >= screenBounds.height && if (position.y + y + pmSize.height >= screenBounds.height
+ screenBounds.y &&
// popup doesn't fit - place it wherever there's more room // popup doesn't fit - place it wherever there's more room
screenBounds.height - s.height < 2*(position.y screenBounds.height - s.height < 2*(position.y
- screenBounds.y)) { - screenBounds.y)) {
......
/* /*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -872,9 +872,10 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -872,9 +872,10 @@ public class JTree extends JComponent implements Scrollable, Accessible
if(treeModelListener != null) if(treeModelListener != null)
treeModel.addTreeModelListener(treeModelListener); treeModel.addTreeModelListener(treeModelListener);
// Mark the root as expanded, if it isn't a leaf. // Mark the root as expanded, if it isn't a leaf.
if(treeModel.getRoot() != null && Object treeRoot = treeModel.getRoot();
!treeModel.isLeaf(treeModel.getRoot())) { if(treeRoot != null &&
expandedState.put(new TreePath(treeModel.getRoot()), !treeModel.isLeaf(treeRoot)) {
expandedState.put(new TreePath(treeRoot),
Boolean.TRUE); Boolean.TRUE);
} }
} }
...@@ -3223,6 +3224,9 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -3223,6 +3224,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
int count = indexs.length; int count = indexs.length;
Object parent = model.getRoot(); Object parent = model.getRoot();
if (parent == null)
return null;
TreePath parentPath = new TreePath(parent); TreePath parentPath = new TreePath(parent);
for(int counter = 0; counter < count; counter++) { for(int counter = 0; counter < count; counter++) {
...@@ -3798,8 +3802,9 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -3798,8 +3802,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
if (parent.getPathCount() == 1) { if (parent.getPathCount() == 1) {
// New root, remove everything! // New root, remove everything!
clearToggledPaths(); clearToggledPaths();
if(treeModel.getRoot() != null && Object treeRoot = treeModel.getRoot();
!treeModel.isLeaf(treeModel.getRoot())) { if(treeRoot != null &&
!treeModel.isLeaf(treeRoot)) {
// Mark the root as expanded, if it isn't a leaf. // Mark the root as expanded, if it isn't a leaf.
expandedState.put(parent, Boolean.TRUE); expandedState.put(parent, Boolean.TRUE);
} }
...@@ -4283,7 +4288,11 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -4283,7 +4288,11 @@ public class JTree extends JComponent implements Scrollable, Accessible
if (model == null) { if (model == null) {
return null; return null;
} }
TreePath path = new TreePath(model.getRoot()); Object treeRoot = model.getRoot();
if (treeRoot == null)
return null;
TreePath path = new TreePath(treeRoot);
if (JTree.this.isVisible(path)) { if (JTree.this.isVisible(path)) {
TreeCellRenderer r = JTree.this.getCellRenderer(); TreeCellRenderer r = JTree.this.getCellRenderer();
TreeUI ui = JTree.this.getUI(); TreeUI ui = JTree.this.getUI();
...@@ -4296,8 +4305,8 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -4296,8 +4305,8 @@ public class JTree extends JComponent implements Scrollable, Accessible
boolean expanded = JTree.this.isExpanded(path); boolean expanded = JTree.this.isExpanded(path);
return r.getTreeCellRendererComponent(JTree.this, return r.getTreeCellRendererComponent(JTree.this,
model.getRoot(), selected, expanded, treeRoot, selected, expanded,
model.isLeaf(model.getRoot()), row, hasFocus); model.isLeaf(treeRoot), row, hasFocus);
} }
} }
return null; return null;
...@@ -4350,8 +4359,11 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -4350,8 +4359,11 @@ public class JTree extends JComponent implements Scrollable, Accessible
return 1; // the root node return 1; // the root node
} }
Object treeRoot = model.getRoot();
if (treeRoot == null)
return 0;
// return the root's first set of children count // return the root's first set of children count
return model.getChildCount(model.getRoot()); return model.getChildCount(treeRoot);
} }
/** /**
...@@ -4365,9 +4377,17 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -4365,9 +4377,17 @@ public class JTree extends JComponent implements Scrollable, Accessible
if (model == null) { if (model == null) {
return null; return null;
} }
Object treeRoot = model.getRoot();
if (treeRoot == null) {
return null;
}
if (isRootVisible()) { if (isRootVisible()) {
if (i == 0) { // return the root node Accessible if (i == 0) { // return the root node Accessible
Object[] objPath = { model.getRoot() }; Object[] objPath = { treeRoot };
if (objPath[0] == null)
return null;
TreePath path = new TreePath(objPath); TreePath path = new TreePath(objPath);
return new AccessibleJTreeNode(JTree.this, path, JTree.this); return new AccessibleJTreeNode(JTree.this, path, JTree.this);
} else { } else {
...@@ -4376,12 +4396,14 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -4376,12 +4396,14 @@ public class JTree extends JComponent implements Scrollable, Accessible
} }
// return Accessible for one of root's child nodes // return Accessible for one of root's child nodes
int count = model.getChildCount(model.getRoot()); int count = model.getChildCount(treeRoot);
if (i < 0 || i >= count) { if (i < 0 || i >= count) {
return null; return null;
} }
Object obj = model.getChild(model.getRoot(), i); Object obj = model.getChild(treeRoot, i);
Object[] objPath = { model.getRoot(), obj }; if (obj == null)
return null;
Object[] objPath = { treeRoot, obj };
TreePath path = new TreePath(objPath); TreePath path = new TreePath(objPath);
return new AccessibleJTreeNode(JTree.this, path, JTree.this); return new AccessibleJTreeNode(JTree.this, path, JTree.this);
} }
...@@ -4420,6 +4442,9 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -4420,6 +4442,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
public int getAccessibleSelectionCount() { public int getAccessibleSelectionCount() {
Object[] rootPath = new Object[1]; Object[] rootPath = new Object[1];
rootPath[0] = treeModel.getRoot(); rootPath[0] = treeModel.getRoot();
if (rootPath[0] == null)
return 0;
TreePath childPath = new TreePath(rootPath); TreePath childPath = new TreePath(rootPath);
if (JTree.this.isPathSelected(childPath)) { if (JTree.this.isPathSelected(childPath)) {
return 1; return 1;
...@@ -4442,6 +4467,8 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -4442,6 +4467,8 @@ public class JTree extends JComponent implements Scrollable, Accessible
if (i == 0) { if (i == 0) {
Object[] rootPath = new Object[1]; Object[] rootPath = new Object[1];
rootPath[0] = treeModel.getRoot(); rootPath[0] = treeModel.getRoot();
if (rootPath[0] == null)
return null;
TreePath childPath = new TreePath(rootPath); TreePath childPath = new TreePath(rootPath);
if (JTree.this.isPathSelected(childPath)) { if (JTree.this.isPathSelected(childPath)) {
return new AccessibleJTreeNode(JTree.this, childPath, JTree.this); return new AccessibleJTreeNode(JTree.this, childPath, JTree.this);
...@@ -4461,6 +4488,8 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -4461,6 +4488,8 @@ public class JTree extends JComponent implements Scrollable, Accessible
if (i == 0) { if (i == 0) {
Object[] rootPath = new Object[1]; Object[] rootPath = new Object[1];
rootPath[0] = treeModel.getRoot(); rootPath[0] = treeModel.getRoot();
if (rootPath[0] == null)
return false;
TreePath childPath = new TreePath(rootPath); TreePath childPath = new TreePath(rootPath);
return JTree.this.isPathSelected(childPath); return JTree.this.isPathSelected(childPath);
} else { } else {
...@@ -4482,6 +4511,8 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -4482,6 +4511,8 @@ public class JTree extends JComponent implements Scrollable, Accessible
if (model != null) { if (model != null) {
if (i == 0) { if (i == 0) {
Object[] objPath = {model.getRoot()}; Object[] objPath = {model.getRoot()};
if (objPath[0] == null)
return;
TreePath path = new TreePath(objPath); TreePath path = new TreePath(objPath);
JTree.this.addSelectionPath(path); JTree.this.addSelectionPath(path);
} }
...@@ -4500,6 +4531,8 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -4500,6 +4531,8 @@ public class JTree extends JComponent implements Scrollable, Accessible
if (model != null) { if (model != null) {
if (i == 0) { if (i == 0) {
Object[] objPath = {model.getRoot()}; Object[] objPath = {model.getRoot()};
if (objPath[0] == null)
return;
TreePath path = new TreePath(objPath); TreePath path = new TreePath(objPath);
JTree.this.removeSelectionPath(path); JTree.this.removeSelectionPath(path);
} }
...@@ -4525,6 +4558,8 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -4525,6 +4558,8 @@ public class JTree extends JComponent implements Scrollable, Accessible
TreeModel model = JTree.this.getModel(); TreeModel model = JTree.this.getModel();
if (model != null) { if (model != null) {
Object[] objPath = {model.getRoot()}; Object[] objPath = {model.getRoot()};
if (objPath[0] == null)
return;
TreePath path = new TreePath(objPath); TreePath path = new TreePath(objPath);
JTree.this.addSelectionPath(path); JTree.this.addSelectionPath(path);
} }
......
...@@ -1031,6 +1031,14 @@ public class ExtendedCharsets ...@@ -1031,6 +1031,14 @@ public class ExtendedCharsets
"ebcdic-s-871+euro" "ebcdic-s-871+euro"
}); });
charset("x-IBM1166", "IBM1166",
new String[] {
"cp1166", // JDK historical
"ibm1166",
"ibm-1166",
"1166"
});
charset("IBM290", "IBM290", charset("IBM290", "IBM290",
new String[] { new String[] {
"cp290", "cp290",
......
...@@ -104,7 +104,7 @@ HELP_ABOUT_DIALOG_JAVA_VERSION=Java VM\u30D0\u30FC\u30B8\u30E7\u30F3:<br>{0} ...@@ -104,7 +104,7 @@ HELP_ABOUT_DIALOG_JAVA_VERSION=Java VM\u30D0\u30FC\u30B8\u30E7\u30F3:<br>{0}
HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME=\u30DE\u30B9\u30C8\u30D8\u30C3\u30C9\u56F3\u5F62 HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME=\u30DE\u30B9\u30C8\u30D8\u30C3\u30C9\u56F3\u5F62
HELP_ABOUT_DIALOG_MASTHEAD_TITLE=JConsole\u306B\u3064\u3044\u3066 HELP_ABOUT_DIALOG_MASTHEAD_TITLE=JConsole\u306B\u3064\u3044\u3066
HELP_ABOUT_DIALOG_TITLE=JConsole: \u60C5\u5831 HELP_ABOUT_DIALOG_TITLE=JConsole: \u60C5\u5831
HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL=http://docs.oracle.com/javase/{0}/docs/technotes/guides/management/jconsole.html HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL=https://docs.oracle.com/javase/{0}/docs/technotes/guides/management/jconsole.html
HELP_MENU_ABOUT_TITLE=JConsole\u306B\u3064\u3044\u3066(&A) HELP_MENU_ABOUT_TITLE=JConsole\u306B\u3064\u3044\u3066(&A)
HELP_MENU_USER_GUIDE_TITLE=\u30AA\u30F3\u30E9\u30A4\u30F3\u30FB\u30E6\u30FC\u30B6\u30FC\u30FB\u30AC\u30A4\u30C9(&U) HELP_MENU_USER_GUIDE_TITLE=\u30AA\u30F3\u30E9\u30A4\u30F3\u30FB\u30E6\u30FC\u30B6\u30FC\u30FB\u30AC\u30A4\u30C9(&U)
HELP_MENU_TITLE=\u30D8\u30EB\u30D7(&H) HELP_MENU_TITLE=\u30D8\u30EB\u30D7(&H)
......
...@@ -104,7 +104,7 @@ HELP_ABOUT_DIALOG_JAVA_VERSION=Java VM \u7248\u672C:<br>{0} ...@@ -104,7 +104,7 @@ HELP_ABOUT_DIALOG_JAVA_VERSION=Java VM \u7248\u672C:<br>{0}
HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME=\u62A5\u5934\u56FE HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME=\u62A5\u5934\u56FE
HELP_ABOUT_DIALOG_MASTHEAD_TITLE=\u5173\u4E8E JConsole HELP_ABOUT_DIALOG_MASTHEAD_TITLE=\u5173\u4E8E JConsole
HELP_ABOUT_DIALOG_TITLE=JConsole: \u5173\u4E8E HELP_ABOUT_DIALOG_TITLE=JConsole: \u5173\u4E8E
HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL=http://docs.oracle.com/javase/{0}/docs/technotes/guides/management/jconsole.html HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL=https://docs.oracle.com/javase/{0}/docs/technotes/guides/management/jconsole.html
HELP_MENU_ABOUT_TITLE=\u5173\u4E8E JConsole(&A) HELP_MENU_ABOUT_TITLE=\u5173\u4E8E JConsole(&A)
HELP_MENU_USER_GUIDE_TITLE=\u8054\u673A\u7528\u6237\u6307\u5357(&U) HELP_MENU_USER_GUIDE_TITLE=\u8054\u673A\u7528\u6237\u6307\u5357(&U)
HELP_MENU_TITLE=\u5E2E\u52A9(&H) HELP_MENU_TITLE=\u5E2E\u52A9(&H)
......
/* /*
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -464,11 +464,6 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_receive0 ...@@ -464,11 +464,6 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_receive0
union sctp_notification *snp; union sctp_notification *snp;
jboolean allocated = JNI_FALSE; jboolean allocated = JNI_FALSE;
if (rv > SCTP_NOTIFICATION_SIZE) {
JNU_ThrowInternalError(env, "should not reach here");
return -1;
}
if (!(msg->msg_flags & MSG_EOR) && length < SCTP_NOTIFICATION_SIZE) { if (!(msg->msg_flags & MSG_EOR) && length < SCTP_NOTIFICATION_SIZE) {
char* newBuf; char* newBuf;
int rvSAVE = rv; int rvSAVE = rv;
......
...@@ -272,14 +272,10 @@ static jlong processCreate( ...@@ -272,14 +272,10 @@ static jlong processCreate(
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE}; FALSE, FALSE, FALSE};
{ /* These three should not be closed by CloseHandle! */
/* Extraction of current process standard IOE handles */ stdIOE[0] = GetStdHandle(STD_INPUT_HANDLE);
DWORD idsIOE[3] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, STD_ERROR_HANDLE}; stdIOE[1] = GetStdHandle(STD_OUTPUT_HANDLE);
int i; stdIOE[2] = GetStdHandle(STD_ERROR_HANDLE);
for (i = 0; i < 3; ++i)
/* Should not be closed by CloseHandle! */
stdIOE[i] = GetStdHandle(idsIOE[i]);
}
prepareIOEHandleState(stdIOE, inherit); prepareIOEHandleState(stdIOE, inherit);
{ {
...@@ -308,11 +304,16 @@ static jlong processCreate( ...@@ -308,11 +304,16 @@ static jlong processCreate(
if (success) { if (success) {
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
DWORD processFlag = CREATE_UNICODE_ENVIRONMENT; DWORD processFlag = CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT;
/* Suppress popping-up of a console window for non-console applications */ /* If the standard I/O is inherited, CREATE_NO_WINDOW must not be used. */
if (GetConsoleWindow() == NULL) if (GetConsoleWindow() != NULL &&
processFlag |= CREATE_NO_WINDOW; (si.hStdInput == stdIOE[0] ||
si.hStdOutput == stdIOE[1] ||
si.hStdError == (redirectErrorStream ? stdIOE[1] : stdIOE[2])))
{
processFlag &= ~CREATE_NO_WINDOW;
}
si.dwFlags = STARTF_USESTDHANDLES; si.dwFlags = STARTF_USESTDHANDLES;
if (!CreateProcessW( if (!CreateProcessW(
......
/*
* Copyright (c) 2015, Red Hat, Inc.
* 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 8069072
* @summary Test vectors for com.sun.crypto.provider.GHASH
*/
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
public class TestGHASH {
private final Constructor<?> GHASH;
private final Method UPDATE;
private final Method DIGEST;
TestGHASH(String className) throws Exception {
Class<?> cls = Class.forName(className);
GHASH = cls.getDeclaredConstructor(byte[].class);
GHASH.setAccessible(true);
UPDATE = cls.getDeclaredMethod("update", byte[].class);
UPDATE.setAccessible(true);
DIGEST = cls.getDeclaredMethod("digest");
DIGEST.setAccessible(true);
}
private Object newGHASH(byte[] H) throws Exception {
return GHASH.newInstance(H);
}
private void updateGHASH(Object hash, byte[] data)
throws Exception {
UPDATE.invoke(hash, data);
}
private byte[] digestGHASH(Object hash) throws Exception {
return (byte[]) DIGEST.invoke(hash);
}
private static final String HEX_DIGITS = "0123456789abcdef";
private static String hex(byte[] bs) {
StringBuilder sb = new StringBuilder(2 * bs.length);
for (byte b : bs) {
sb.append(HEX_DIGITS.charAt((b >> 4) & 0xF));
sb.append(HEX_DIGITS.charAt(b & 0xF));
}
return sb.toString();
}
private static byte[] bytes(String hex) {
if ((hex.length() & 1) != 0) {
throw new AssertionError();
}
byte[] result = new byte[hex.length() / 2];
for (int i = 0; i < result.length; ++i) {
int a = HEX_DIGITS.indexOf(hex.charAt(2 * i));
int b = HEX_DIGITS.indexOf(hex.charAt(2 * i + 1));
if ((a | b) < 0) {
if (a < 0) {
throw new AssertionError(
"bad character " + (int) hex.charAt(2 * i));
}
throw new AssertionError(
"bad character " + (int) hex.charAt(2 * i + 1));
}
result[i] = (byte) ((a << 4) | b);
}
return result;
}
private static byte[] bytes(long L0, long L1) {
return ByteBuffer.allocate(16)
.putLong(L0)
.putLong(L1)
.array();
}
private void check(int testCase, String H, String A,
String C, String expected) throws Exception {
int lenA = A.length() * 4;
while ((A.length() % 32) != 0) {
A += '0';
}
int lenC = C.length() * 4;
while ((C.length() % 32) != 0) {
C += '0';
}
Object hash = newGHASH(bytes(H));
updateGHASH(hash, bytes(A));
updateGHASH(hash, bytes(C));
updateGHASH(hash, bytes(lenA, lenC));
byte[] digest = digestGHASH(hash);
String actual = hex(digest);
if (!expected.equals(actual)) {
throw new AssertionError(String.format("%d: expected %s, got %s",
testCase, expected, actual));
}
}
public static void main(String[] args) throws Exception {
TestGHASH test;
if (args.length == 0) {
test = new TestGHASH("com.sun.crypto.provider.GHASH");
} else {
test = new TestGHASH(args[0]);
}
// Test vectors from David A. McGrew, John Viega,
// "The Galois/Counter Mode of Operation (GCM)", 2005.
// <http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf>
test.check(1, "66e94bd4ef8a2c3b884cfa59ca342b2e", "", "",
"00000000000000000000000000000000");
test.check(2,
"66e94bd4ef8a2c3b884cfa59ca342b2e", "",
"0388dace60b6a392f328c2b971b2fe78",
"f38cbb1ad69223dcc3457ae5b6b0f885");
test.check(3,
"b83b533708bf535d0aa6e52980d53b78", "",
"42831ec2217774244b7221b784d0d49c" +
"e3aa212f2c02a4e035c17e2329aca12e" +
"21d514b25466931c7d8f6a5aac84aa05" +
"1ba30b396a0aac973d58e091473f5985",
"7f1b32b81b820d02614f8895ac1d4eac");
test.check(4,
"b83b533708bf535d0aa6e52980d53b78",
"feedfacedeadbeeffeedfacedeadbeef" + "abaddad2",
"42831ec2217774244b7221b784d0d49c" +
"e3aa212f2c02a4e035c17e2329aca12e" +
"21d514b25466931c7d8f6a5aac84aa05" +
"1ba30b396a0aac973d58e091",
"698e57f70e6ecc7fd9463b7260a9ae5f");
test.check(5, "b83b533708bf535d0aa6e52980d53b78",
"feedfacedeadbeeffeedfacedeadbeef" + "abaddad2",
"61353b4c2806934a777ff51fa22a4755" +
"699b2a714fcdc6f83766e5f97b6c7423" +
"73806900e49f24b22b097544d4896b42" +
"4989b5e1ebac0f07c23f4598",
"df586bb4c249b92cb6922877e444d37b");
}
}
/*
* 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 8067846
* @summary Test for send failed notification
*/
import com.sun.nio.sctp.*;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import static java.lang.System.out;
import static java.nio.ByteBuffer.*;
public class SendFailed {
static final SocketAddress remoteAddress = new InetSocketAddress("127.0.0.1", 3000);
static final int[] bufferSizes =
{ 20, 49, 50, 51, 100, 101, 1024, 1025, 4095, 4096, 4097, 8191, 8192, 8193};
void test(String[] args) throws IOException {
SocketAddress address = null;
if (!Util.isSCTPSupported()) {
out.println("SCTP protocol is not supported");
out.println("Test cannot be run");
return;
}
System.out.println("remote address: " + remoteAddress);
System.out.println("Note, remote address should not be up");
/* combinations with various buffer sizes, and offsets */
for (int send=0; send < bufferSizes.length; send++) {
for (int recv=0; recv < bufferSizes.length; recv++) {
for (boolean direct : new boolean[] {true, false})
runWithManyOffsets(bufferSizes[send], bufferSizes[recv], direct);
}
}
}
void runWithManyOffsets(int sendBufferSize, int recvBufferSize, boolean direct)
throws IOException
{
doTest(sendBufferSize, recvBufferSize, direct, 0);
doTest(sendBufferSize, recvBufferSize, direct, 1);
doTest(sendBufferSize, recvBufferSize, direct, 3);
doTest(sendBufferSize, recvBufferSize, direct, 7);
doTest(sendBufferSize, recvBufferSize, direct, 9);
doTest(sendBufferSize, recvBufferSize, direct, 13);
doTest(sendBufferSize, recvBufferSize, direct, 15);
}
void doTest(int sendBufferSize, int recvBufferSize, boolean direct, int offset)
throws IOException
{
debug("%n--- Testing with send size:[%d], recv size:[%d], offset:[%d] "
+ ", direct [%s]. ", sendBufferSize, recvBufferSize, offset, direct);
try (SctpMultiChannel channel = SctpMultiChannel.open()) {
MessageInfo messageInfo = MessageInfo.createOutgoing(remoteAddress, 0);
ByteBuffer sendBuffer = filledBuffer(sendBufferSize, direct);
debug("%nAttempting to send to %s. ", remoteAddress);
int sent = channel.send(sendBuffer, messageInfo);
sendBuffer.flip();
SendFailedNotificationHandler handler =
new SendFailedNotificationHandler();
ByteBuffer recvBuffer = direct ? allocateDirect(recvBufferSize)
: allocate((recvBufferSize));
channel.receive(recvBuffer, null, handler);
// verify sent buffer received by send failed notification
ByteBuffer buffer = handler.getSendFailedByteBuffer();
check(buffer.remaining() == sent);
check(buffer.position() == 0);
check(buffer.limit() == sent);
assertSameContent(sendBuffer, handler.getSendFailedByteBuffer());
}
}
class SendFailedNotificationHandler extends AbstractNotificationHandler<Object>
{
/** Reference to the buffer captured in send failed notification */
private ByteBuffer sentBuffer;
@Override
public HandlerResult handleNotification(
Notification notification, Object attachment) {
fail("Unknown notification type");
return HandlerResult.CONTINUE;
}
@Override
public HandlerResult handleNotification(
AssociationChangeNotification notification, Object attachment) {
AssociationChangeNotification.AssocChangeEvent event = notification.event();
debug("%nAssociationChangeNotification");
debug("%n Association: %s. ", notification.association());
debug("%n Event: %s. ", event);
return HandlerResult.CONTINUE;
}
@Override
public HandlerResult handleNotification(
SendFailedNotification notification, Object attachment) {
debug("%nSendFailedNotification: %s. ", notification);
sentBuffer = notification.buffer();
return HandlerResult.RETURN;
}
public ByteBuffer getSendFailedByteBuffer() {
return sentBuffer;
}
@Override
public HandlerResult handleNotification(
PeerAddressChangeNotification pacn, Object attachment)
{
debug("%nPeerAddressChangeNotification: %s", pacn);
return HandlerResult.CONTINUE;
}
@Override
public HandlerResult handleNotification(
ShutdownNotification notification, Object attachment) {
debug("%nShutdownNotification");
debug("%n Association: %s. ", notification.association());
return HandlerResult.CONTINUE;
}
}
static ByteBuffer filledBuffer(int size, boolean direct) {
ByteBuffer buffer = direct ? allocateDirect(size) : allocate((size));
for (int i=0; i< size; i++)
buffer.put((byte)i);
buffer.flip();
return buffer;
}
static void assertSameContent(ByteBuffer bb1, ByteBuffer bb2) {
if (!bb1.equals(bb2))
throw new RuntimeException("Buffers are not equal; bb1: " + bb1 + ", bb2: " + bb2);
}
//--------------------- Infrastructure ---------------------------
boolean debug = true;
volatile int passed = 0, failed = 0;
void pass() {passed++;}
void fail() {failed++; Thread.dumpStack();}
void fail(String msg) {System.err.println(msg); fail();}
void unexpected(Throwable t) {failed++; t.printStackTrace();}
void check(boolean cond) {if (cond) pass(); else fail();}
void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);}
void debug(String message, Object... args) {if(debug) { out.printf(message, args); } }
public static void main(String[] args) throws Throwable {
Class<?> k = new Object(){}.getClass().getEnclosingClass();
try {k.getMethod("instanceMain",String[].class)
.invoke( k.newInstance(), (Object) args);}
catch (Throwable e) {throw e.getCause();}}
public void instanceMain(String[] args) throws Throwable {
try {test(args);} catch (Throwable t) {unexpected(t);}
out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
if (failed > 0) throw new AssertionError("Some tests failed");}
}
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 4851776 4907265 6177836 6876282 * @bug 4851776 4907265 6177836 6876282 8066842
* @summary Some tests for the divide methods. * @summary Some tests for the divide methods.
* @author Joseph D. Darcy * @author Joseph D. Darcy
*/ */
...@@ -358,6 +358,57 @@ public class DivideTests { ...@@ -358,6 +358,57 @@ public class DivideTests {
return failures; return failures;
} }
private static int divideByOneTests() {
int failures = 0;
//problematic divisor: one with scale 17
BigDecimal one = BigDecimal.ONE.setScale(17);
RoundingMode rounding = RoundingMode.UNNECESSARY;
long[][] unscaledAndScale = new long[][] {
{ Long.MAX_VALUE, 17},
{-Long.MAX_VALUE, 17},
{ Long.MAX_VALUE, 0},
{-Long.MAX_VALUE, 0},
{ Long.MAX_VALUE, 100},
{-Long.MAX_VALUE, 100}
};
for (long[] uas : unscaledAndScale) {
long unscaled = uas[0];
int scale = (int)uas[1];
BigDecimal noRound = null;
try {
noRound = BigDecimal.valueOf(unscaled, scale).
divide(one, RoundingMode.UNNECESSARY);
} catch (ArithmeticException e) {
failures++;
System.err.println("ArithmeticException for value " + unscaled
+ " and scale " + scale + " without rounding");
}
BigDecimal roundDown = null;
try {
roundDown = BigDecimal.valueOf(unscaled, scale).
divide(one, RoundingMode.DOWN);
} catch (ArithmeticException e) {
failures++;
System.err.println("ArithmeticException for value " + unscaled
+ " and scale " + scale + " with rounding down");
}
if (noRound != null && roundDown != null
&& noRound.compareTo(roundDown) != 0) {
failures++;
System.err.println("Equality failure for value " + unscaled
+ " and scale " + scale);
}
}
return failures;
}
public static void main(String argv[]) { public static void main(String argv[]) {
int failures = 0; int failures = 0;
...@@ -366,10 +417,11 @@ public class DivideTests { ...@@ -366,10 +417,11 @@ public class DivideTests {
failures += properScaleTests(); failures += properScaleTests();
failures += trailingZeroTests(); failures += trailingZeroTests();
failures += scaledRoundedDivideTests(); failures += scaledRoundedDivideTests();
failures += divideByOneTests();
if (failures > 0) { if (failures > 0) {
throw new RuntimeException("Incurred " + failures + throw new RuntimeException("Incurred " + failures +
" failures while testing exact divide."); " failures while testing division.");
} }
} }
} }
/*
* 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 7178362
* @run main/othervm BadProxySelector
*/
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.ServerSocket;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.io.*;
public class BadProxySelector {
public static void main(String[] args) throws Exception {
ProxySelector.setDefault(new HTTPProxySelector());
try (ServerSocket ss = new ServerSocket(0);
Socket s1 = new Socket(ss.getInetAddress(), ss.getLocalPort());
Socket s2 = ss.accept()) {
}
ProxySelector.setDefault(new NullHTTPProxySelector());
try (ServerSocket ss = new ServerSocket(0);
Socket s1 = new Socket(ss.getInetAddress(), ss.getLocalPort());
Socket s2 = ss.accept()) {
}
}
// always returns bogus HTTP proxies
private static class HTTPProxySelector extends ProxySelector {
@Override
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {}
@Override
public List<Proxy> select(URI uri) {
List<Proxy> proxies = new ArrayList<>();
proxies.add(new Proxy(Proxy.Type.HTTP,
new InetSocketAddress("localhost", 0)));
proxies.add(new Proxy(Proxy.Type.HTTP,
new InetSocketAddress("localhost", 0)));
return proxies;
}
}
private static class NullHTTPProxySelector extends ProxySelector {
@Override
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {}
@Override
public List<Proxy> select(URI uri) {
List<Proxy> proxies = new ArrayList<>();
proxies.add(null);
proxies.add(new Proxy(Proxy.Type.HTTP,
new InetSocketAddress("localhost", 0)));
return proxies;
}
}
}
...@@ -135,6 +135,7 @@ public class RegisteredCharsets { ...@@ -135,6 +135,7 @@ public class RegisteredCharsets {
"x-IBM1122", "x-IBM1122",
"x-IBM1123", "x-IBM1123",
"x-IBM1124", "x-IBM1124",
"x-IBM1166",
"x-IBM875", "x-IBM875",
"x-IBM921", "x-IBM921",
"x-IBM922", "x-IBM922",
...@@ -863,6 +864,14 @@ public class RegisteredCharsets { ...@@ -863,6 +864,14 @@ public class RegisteredCharsets {
"1124" "1124"
} ); } );
aliasCheck("x-IBM1166" ,
new String[] {
"cp1166", // JDK historical
"ibm1166",
"ibm-1166",
"1166"
} );
aliasCheck("IBM273" , aliasCheck("IBM273" ,
new String[] { new String[] {
"cp273", // JDK historical "cp273", // JDK historical
......
...@@ -674,6 +674,12 @@ public class SunioAlias { ...@@ -674,6 +674,12 @@ public class SunioAlias {
aliasTable.put("cp1124", "Cp1124"); aliasTable.put("cp1124", "Cp1124");
aliasTable.put("1124", "Cp1124"); aliasTable.put("1124", "Cp1124");
// MIBenum: ????
aliasTable.put("ibm1166", "Cp1166");
aliasTable.put("ibm-1166", "Cp1166");
aliasTable.put("cp1166", "Cp1166");
aliasTable.put("1166", "Cp1166");
// MIBenum: ???? // MIBenum: ????
aliasTable.put("ibm1381", "Cp1381"); /* MDA */ aliasTable.put("ibm1381", "Cp1381"); /* MDA */
aliasTable.put("ibm-1381", "Cp1381"); /* MDA */ aliasTable.put("ibm-1381", "Cp1381"); /* MDA */
......
/*
* 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 8072909
* @run main/othervm -Xms385m TimSortStackSize2 67108864
* @summary Test TimSort stack size on big arrays
* big tests not for regular execution on all platforms:
* run main/othervm -Xmx8g TimSortStackSize2 1073741824
* run main/othervm -Xmx16g TimSortStackSize2 2147483644
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.function.Consumer;
public class TimSortStackSize2 {
public static void main(String[] args) {
int lengthOfTest = Integer.parseInt(args[0]);
boolean passed = doTest("TimSort", lengthOfTest,
(Integer [] a) -> Arrays.sort(a));
passed = doTest("ComparableTimSort", lengthOfTest, (Integer [] a) ->
Arrays.sort(a, (Object first, Object second) -> {
return ((Comparable<Object>)first).compareTo(second);
}))
&& passed;
if ( !passed ){
throw new RuntimeException();
}
}
private static boolean doTest(final String msg, final int lengthOfTest,
final Consumer<Integer[]> c){
Integer [] a = null;
try {
a = new TimSortStackSize2(lengthOfTest).createArray();
long begin = System.nanoTime();
c.accept(a);
long end = System.nanoTime();
System.out.println(msg + " OK. Time: " + (end - begin) + "ns");
} catch (ArrayIndexOutOfBoundsException e){
System.out.println(msg + " broken:");
e.printStackTrace();
return false;
} finally {
a = null;
}
return true;
}
private static final int MIN_MERGE = 32;
private final int minRun;
private final int length;
private final List<Long> runs = new ArrayList<Long>();
public TimSortStackSize2(final int len) {
this.length = len;
minRun = minRunLength(len);
fillRunsJDKWorstCase();
}
private static int minRunLength(int n) {
assert n >= 0;
int r = 0; // Becomes 1 if any 1 bits are shifted off
while (n >= MIN_MERGE) {
r |= (n & 1);
n >>= 1;
}
return n + r;
}
/**
* Adds a sequence x_1, ..., x_n of run lengths to <code>runs</code> such that:<br>
* 1. X = x_1 + ... + x_n <br>
* 2. x_j >= minRun for all j <br>
* 3. x_1 + ... + x_{j-2} < x_j < x_1 + ... + x_{j-1} for all j <br>
* These conditions guarantee that TimSort merges all x_j's one by one
* (resulting in X) using only merges on the second-to-last element.
* @param X The sum of the sequence that should be added to runs.
*/
private void generateJDKWrongElem(long X) {
for(long newTotal; X >= 2 * minRun + 1; X = newTotal) {
//Default strategy
newTotal = X / 2 + 1;
//Specialized strategies
if(3 * minRun + 3 <= X && X <= 4*minRun+1) {
// add x_1=MIN+1, x_2=MIN, x_3=X-newTotal to runs
newTotal = 2 * minRun + 1;
} else if (5 * minRun + 5 <= X && X <= 6 * minRun + 5) {
// add x_1=MIN+1, x_2=MIN, x_3=MIN+2, x_4=X-newTotal to runs
newTotal = 3 * minRun + 3;
} else if (8 * minRun + 9 <= X && X <= 10 * minRun + 9) {
// add x_1=MIN+1, x_2=MIN, x_3=MIN+2, x_4=2MIN+2, x_5=X-newTotal to runs
newTotal = 5 * minRun + 5;
} else if (13 * minRun + 15 <= X && X <= 16 * minRun + 17) {
// add x_1=MIN+1, x_2=MIN, x_3=MIN+2, x_4=2MIN+2, x_5=3MIN+4, x_6=X-newTotal to runs
newTotal = 8 * minRun + 9;
}
runs.add(0, X - newTotal);
}
runs.add(0, X);
}
/**
* Fills <code>runs</code> with a sequence of run lengths of the form<br>
* Y_n x_{n,1} x_{n,2} ... x_{n,l_n} <br>
* Y_{n-1} x_{n-1,1} x_{n-1,2} ... x_{n-1,l_{n-1}} <br>
* ... <br>
* Y_1 x_{1,1} x_{1,2} ... x_{1,l_1}<br>
* The Y_i's are chosen to satisfy the invariant throughout execution,
* but the x_{i,j}'s are merged (by <code>TimSort.mergeCollapse</code>)
* into an X_i that violates the invariant.
* X is the sum of all run lengths that will be added to <code>runs</code>.
*/
private void fillRunsJDKWorstCase() {
long runningTotal = 0;
long Y = minRun + 4;
long X = minRun;
while (runningTotal + Y + X <= length) {
runningTotal += X + Y;
generateJDKWrongElem(X);
runs.add(0, Y);
// X_{i+1} = Y_i + x_{i,1} + 1, since runs.get(1) = x_{i,1}
X = Y + runs.get(1) + 1;
// Y_{i+1} = X_{i+1} + Y_i + 1
Y += X + 1;
}
if (runningTotal + X <= length) {
runningTotal += X;
generateJDKWrongElem(X);
}
runs.add(length - runningTotal);
}
private Integer [] createArray() {
Integer [] a = new Integer[length];
Arrays.fill(a, 0);
int endRun = -1;
for (long len : runs) {
a[endRun += len] = 1;
}
a[length - 1] = 0;
return a;
}
}
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/** /**
* @test * @test
* @bug 4759491 6303183 7012868 8015666 8023713 * @bug 4759491 6303183 7012868 8015666 8023713 8068790
* @summary Test ZOS and ZIS timestamp in extra field correctly * @summary Test ZOS and ZIS timestamp in extra field correctly
*/ */
...@@ -69,6 +69,8 @@ public class TestExtraTime { ...@@ -69,6 +69,8 @@ public class TestExtraTime {
test(mtime, atime, ctime, tz, extra); test(mtime, atime, ctime, tz, extra);
} }
} }
testNullHandling();
} }
static void test(FileTime mtime, FileTime atime, FileTime ctime, static void test(FileTime mtime, FileTime atime, FileTime ctime,
...@@ -154,4 +156,26 @@ public class TestExtraTime { ...@@ -154,4 +156,26 @@ public class TestExtraTime {
} }
} }
} }
static void testNullHandling() {
ZipEntry ze = new ZipEntry("TestExtraTime.java");
try {
ze.setLastAccessTime(null);
throw new RuntimeException("setLastAccessTime(null) should throw NPE");
} catch (NullPointerException ignored) {
// pass
}
try {
ze.setCreationTime(null);
throw new RuntimeException("setCreationTime(null) should throw NPE");
} catch (NullPointerException ignored) {
// pass
}
try {
ze.setLastModifiedTime(null);
throw new RuntimeException("setLastModifiedTime(null) should throw NPE");
} catch (NullPointerException ignored) {
// pass
}
}
} }
/*
* 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 8069268
@summary Tests that only one ContainerListener exists for AccessibleJComponent of JRootPane
@author Vivi An
*/
import javax.swing.*;
import java.awt.event.*;
import javax.accessibility.*;
public class bug8069268{
public static void main(String[] args) throws Exception {
TestableRootPane rootPane = new TestableRootPane();
// Get accesibleContext and then AccessibleJComponent, call the function
// addPropertyChangeListener to trigger container listener to be added
AccessibleContext acc = rootPane.getAccessibleContext();
JComponent.AccessibleJComponent accJ = (JComponent.AccessibleJComponent) acc;
accJ.addPropertyChangeListener(null);
// Test how many container listener(s) exist(s), should only have 1
if (!rootPane.testContainerListener())
throw new RuntimeException("Failed test for bug 8069268");
}
private static class TestableRootPane extends JRootPane {
public boolean testContainerListener() {
boolean result = false;
ContainerListener[] listeners = getContainerListeners();
System.out.println("ContainerListener number is " + listeners.length);
result = (listeners.length == 1) ? true : false;
return result;
}
}
}
/*
* 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 8071705
* @summary Java application menu misbehaves when running multiple screen stacked vertically
* @build bug8071705
* @run main/othervm bug8071705
*/
import java.awt.Dimension;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.KeyEvent;
import java.util.concurrent.CountDownLatch;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
public class bug8071705 {
public static void main(String[] args) throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final boolean [] result = new boolean[1];
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = createGUI();
GraphicsDevice[] devices = checkScreens();
// check if we have more than one and if they are stacked
// vertically
GraphicsDevice device = checkConfigs(devices);
if (device == null) {
// just pass the test
frame.dispose();
result[0] = true;
latch.countDown();
} else {
FrameListener listener =
new FrameListener(device, latch, result);
frame.addComponentListener(listener);
frame.setVisible(true);
}
}
});
latch.await();
if (result[0] == false) {
throw new RuntimeException("popup menu rendered in wrong position");
}
System.out.println("OK");
}
private static GraphicsDevice[] checkScreens() {
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
return ge.getScreenDevices();
}
private static JFrame createGUI() {
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Some menu");
menuBar.add(menu);
for (int i = 0; i < 10; i++) {
menu.add(new JMenuItem("Some menu #" + i));
}
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setMinimumSize(new Dimension(200, 200));
frame.setJMenuBar(menuBar);
return frame;
}
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {
GraphicsDevice correctDevice = null;
if (devices.length < 2) {
return correctDevice;
}
Toolkit toolkit = Toolkit.getDefaultToolkit();
Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
int halfScreen = screenBounds.height/2;
for(int i = 0; i < devices.length; i++) {
if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
GraphicsConfiguration conf =
devices[i].getDefaultConfiguration();
Rectangle bounds = conf.getBounds();
if (bounds.y >= halfScreen) {
// found
correctDevice = devices[i];
break;
}
}
}
return correctDevice;
}
private static class FrameListener extends ComponentAdapter {
private GraphicsDevice device;
private CountDownLatch latch;
private boolean [] result;
public FrameListener(GraphicsDevice device,
CountDownLatch latch,
boolean [] result)
{
this.device = device;
this.latch = latch;
this.result = result;
}
@Override
public void componentShown(ComponentEvent e) {
JFrame frame = (JFrame) e.getComponent();
runActualTest(device, latch, frame, result);
frame.setVisible(false);
frame.dispose();
latch.countDown();
}
}
private static Rectangle setLocation(JFrame frame, GraphicsDevice device) {
GraphicsConfiguration conf = device.getDefaultConfiguration();
Rectangle bounds = conf.getBounds();
// put just below half screen
int x = bounds.x + bounds.width/2;
int y = bounds.y + bounds.height/2;
frame.setLocation(x, y);
return bounds;
}
private static void runActualTest(GraphicsDevice device,
CountDownLatch latch,
JFrame frame,
boolean [] result)
{
Rectangle screenBounds = setLocation(frame, device);
JMenu menu = frame.getJMenuBar().getMenu(0);
menu.doClick();
Point location = menu.getLocationOnScreen();
JPopupMenu pm = menu.getPopupMenu();
Dimension pmSize = pm.getSize();
int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY");
int height = location.y + yOffset + pmSize.height + menu.getHeight();
int available = screenBounds.y + screenBounds.height - height;
if (available > 0) {
Point origin = pm.getLocationOnScreen();
if (origin.y < location.y) {
// growing upward, wrong!
result[0] = false;
} else {
// growing downward, ok!
result[0] = true;
}
} else {
// there is no space, growing upward would be ok, so we pass
result[0] = true;
}
}
}
/*
* 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.
*/
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
/*
* @test
* @bug 8072676
* @summary Checks if the tree painter doesn't expand existing clip
* @author Anton Nashatyrev
*/
public class TreeClipTest {
static boolean passed = true;
static boolean checkImage(BufferedImage img, int clipY) {
for (int y = clipY; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
if ((img.getRGB(x,y) & 0xFFFFFF) != 0xFFFFFF) {
return false;
}
}
}
return true;
}
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("JTree");
DefaultMutableTreeNode parent;
parent = new DefaultMutableTreeNode("colors");
root.add(parent);
parent.add(new DefaultMutableTreeNode("blue"));
DefaultTreeModel model = new DefaultTreeModel(root);
JTree tree = new JTree(model);
BufferedImage img = new BufferedImage(50, 50, BufferedImage.TYPE_INT_ARGB);
for (int clipY = 1; clipY < 50; clipY++) {
Graphics2D ig = img.createGraphics();
ig.setColor(Color.WHITE);
ig.fillRect(0,0,1000, 1000);
tree.setSize(200,200);
ig.setClip(0,0,1000,clipY);
tree.paint(ig);
ig.dispose();
if (!checkImage(img, clipY)) {
System.err.println("Failed with clipY=" + clipY);
passed = false;
try {
ImageIO.write(img, "PNG", new File("failedResult.png"));
} catch (IOException e) {
e.printStackTrace();
}
return;
}
}
}
});
if (!passed) {
throw new RuntimeException("Test failed.");
} else {
System.out.println("Passed.");
}
}
}
\ No newline at end of file
...@@ -196,6 +196,7 @@ public class CheckHistoricalNames { ...@@ -196,6 +196,7 @@ public class CheckHistoricalNames {
checkMappedName("IBM1122", "Cp1122"); checkMappedName("IBM1122", "Cp1122");
checkMappedName("IBM1123", "Cp1123"); checkMappedName("IBM1123", "Cp1123");
checkMappedName("IBM1124", "Cp1124"); checkMappedName("IBM1124", "Cp1124");
checkMappedName("IBM1166", "Cp1166");
checkMappedName("IBM01140", "Cp1140"); checkMappedName("IBM01140", "Cp1140");
checkMappedName("IBM01141", "Cp1141"); checkMappedName("IBM01141", "Cp1141");
checkMappedName("IBM01142", "Cp1142"); checkMappedName("IBM01142", "Cp1142");
......
/* /*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* @summary Verify that the RSA KeyPairGenerator works * @summary Verify that the RSA KeyPairGenerator works
* @author Andreas Sterbenz * @author Andreas Sterbenz
* @library .. * @library ..
* @run main/othervm TestKeyPairGenerator
*/ */
import java.io.*; import java.io.*;
......
# #
# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
# #
# @test # @test
# @bug 7133495 # @bug 7133495 8041740
# @summary [macosx] KeyChain KeyStore implementation retrieves only one private key entry # @summary [macosx] KeyChain KeyStore implementation retrieves only one private key entry
if [ "${TESTJAVA}" = "" ] ; then if [ "${TESTJAVA}" = "" ] ; then
...@@ -49,8 +49,10 @@ PWD="xxxxxx" ...@@ -49,8 +49,10 @@ PWD="xxxxxx"
KEYTOOL="${TESTJAVA}/bin/keytool -storetype KeychainStore -keystore NONE -storepass $PWD" KEYTOOL="${TESTJAVA}/bin/keytool -storetype KeychainStore -keystore NONE -storepass $PWD"
TEMPORARY_P12="$TESTCLASSES/7133495.p12" TEMPORARY_P12="$TESTCLASSES/7133495.p12"
TEMPORARY_KC="$TESTCLASSES/7133495.keychain" TEMPORARY_KC="$TESTCLASSES/7133495.keychain"
TEMPORARY_LIST="$TESTCLASSES/7133495.tmp"
CLEANUP_P12="rm -f $TEMPORARY_P12" CLEANUP_P12="rm -f $TEMPORARY_P12"
CLEANUP_KC="security delete-keychain $TEMPORARY_KC" CLEANUP_KC="security delete-keychain $TEMPORARY_KC"
CLEANUP_LIST="rm -f $TEMPORARY_LIST"
# Count the number of private key entries in the Keychain keystores # Count the number of private key entries in the Keychain keystores
...@@ -115,6 +117,15 @@ if [ $? -ne 0 ]; then ...@@ -115,6 +117,15 @@ if [ $? -ne 0 ]; then
fi fi
echo "Imported keypairs from PKCS12 keystore into the keychain" echo "Imported keypairs from PKCS12 keystore into the keychain"
# Adjust the keychain search order
echo "\"$TEMPORARY_KC\"" > $TEMPORARY_LIST
security list-keychains >> $TEMPORARY_LIST
security list-keychains -s `xargs < ${TEMPORARY_LIST}`
`$CLEANUP_LIST`
echo "Temporary keychain search order:"
security list-keychains
# Recount the number of private key entries in the Keychain keystores # Recount the number of private key entries in the Keychain keystores
COUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l` COUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册