() {
- @Override
- public boolean accept(Path entry) {
- return true;
- }
- });
+ return provider(dir).newDirectoryStream(dir, AcceptAllFilter.FILTER);
}
/**
diff --git a/jdk/src/share/classes/java/security/Security.java b/jdk/src/share/classes/java/security/Security.java
index b9dd1441d63..f8890e62fec 100644
--- a/jdk/src/share/classes/java/security/Security.java
+++ b/jdk/src/share/classes/java/security/Security.java
@@ -814,7 +814,7 @@ public final class Security {
public Void run() {
try {
/* Get the class via the bootstrap class loader. */
- Class cl = Class.forName(
+ Class> cl = Class.forName(
"java.lang.SecurityManager", false, null);
Field f = null;
boolean accessible = false;
diff --git a/jdk/src/share/classes/java/text/BreakIterator.java b/jdk/src/share/classes/java/text/BreakIterator.java
index e00e09adc31..6010784dbaf 100644
--- a/jdk/src/share/classes/java/text/BreakIterator.java
+++ b/jdk/src/share/classes/java/text/BreakIterator.java
@@ -443,7 +443,7 @@ public abstract class BreakIterator implements Cloneable
/**
* Returns a new BreakIterator instance
- * for word breaks
+ * for word breaks
* for the {@linkplain Locale#getDefault() default locale}.
* @return A break iterator for word breaks
*/
@@ -454,7 +454,7 @@ public abstract class BreakIterator implements Cloneable
/**
* Returns a new BreakIterator instance
- * for word breaks
+ * for word breaks
* for the given locale.
* @param locale the desired locale
* @return A break iterator for word breaks
@@ -470,7 +470,7 @@ public abstract class BreakIterator implements Cloneable
/**
* Returns a new BreakIterator instance
- * for line breaks
+ * for line breaks
* for the {@linkplain Locale#getDefault() default locale}.
* @return A break iterator for line breaks
*/
@@ -481,7 +481,7 @@ public abstract class BreakIterator implements Cloneable
/**
* Returns a new BreakIterator instance
- * for line breaks
+ * for line breaks
* for the given locale.
* @param locale the desired locale
* @return A break iterator for line breaks
@@ -497,7 +497,7 @@ public abstract class BreakIterator implements Cloneable
/**
* Returns a new BreakIterator instance
- * for character breaks
+ * for character breaks
* for the {@linkplain Locale#getDefault() default locale}.
* @return A break iterator for character breaks
*/
@@ -508,7 +508,7 @@ public abstract class BreakIterator implements Cloneable
/**
* Returns a new BreakIterator instance
- * for character breaks
+ * for character breaks
* for the given locale.
* @param locale the desired locale
* @return A break iterator for character breaks
@@ -524,7 +524,7 @@ public abstract class BreakIterator implements Cloneable
/**
* Returns a new BreakIterator instance
- * for sentence breaks
+ * for sentence breaks
* for the {@linkplain Locale#getDefault() default locale}.
* @return A break iterator for sentence breaks
*/
@@ -535,7 +535,7 @@ public abstract class BreakIterator implements Cloneable
/**
* Returns a new BreakIterator instance
- * for sentence breaks
+ * for sentence breaks
* for the given locale.
* @param locale the desired locale
* @return A break iterator for sentence breaks
diff --git a/jdk/src/share/classes/java/util/Collections.java b/jdk/src/share/classes/java/util/Collections.java
index d15a4292ddd..04e642e1c00 100644
--- a/jdk/src/share/classes/java/util/Collections.java
+++ b/jdk/src/share/classes/java/util/Collections.java
@@ -2351,6 +2351,64 @@ public class Collections {
}
}
+ /**
+ * Returns a dynamically typesafe view of the specified queue.
+ * Any attempt to insert an element of the wrong type will result in
+ * an immediate {@link ClassCastException}. Assuming a queue contains
+ * no incorrectly typed elements prior to the time a dynamically typesafe
+ * view is generated, and that all subsequent access to the queue
+ * takes place through the view, it is guaranteed that the
+ * queue cannot contain an incorrectly typed element.
+ *
+ * A discussion of the use of dynamically typesafe views may be
+ * found in the documentation for the {@link #checkedCollection
+ * checkedCollection} method.
+ *
+ *
The returned queue will be serializable if the specified queue
+ * is serializable.
+ *
+ *
Since {@code null} is considered to be a value of any reference
+ * type, the returned queue permits insertion of {@code null} elements
+ * whenever the backing queue does.
+ *
+ * @param queue the queue for which a dynamically typesafe view is to be
+ * returned
+ * @param type the type of element that {@code queue} is permitted to hold
+ * @return a dynamically typesafe view of the specified queue
+ * @since 1.8
+ */
+ public static Queue checkedQueue(Queue queue, Class type) {
+ return new CheckedQueue<>(queue, type);
+ }
+
+ /**
+ * @serial include
+ */
+ static class CheckedQueue
+ extends CheckedCollection
+ implements Queue, Serializable
+ {
+ private static final long serialVersionUID = 1433151992604707767L;
+ final Queue queue;
+
+ CheckedQueue(Queue queue, Class elementType) {
+ super(queue, elementType);
+ this.queue = queue;
+ }
+
+ public E element() {return queue.element();}
+ public boolean equals(Object o) {return o == this || c.equals(o);}
+ public int hashCode() {return c.hashCode();}
+ public E peek() {return queue.peek();}
+ public E poll() {return queue.poll();}
+ public E remove() {return queue.remove();}
+
+ public boolean offer(E e) {
+ typeCheck(e);
+ return add(e);
+ }
+ }
+
/**
* Returns a dynamically typesafe view of the specified set.
* Any attempt to insert an element of the wrong type will result in
@@ -3143,6 +3201,102 @@ public class Collections {
}
}
+ /**
+ * Returns the empty sorted set (immutable). This set is serializable.
+ *
+ * This example illustrates the type-safe way to obtain an empty sorted
+ * set:
+ *
+ * SortedSet<String> s = Collections.emptySortedSet();
+ *
+ * Implementation note: Implementations of this method need not
+ * create a separate SortedSet object for each call.
+ *
+ * @since 1.8
+ */
+ @SuppressWarnings("unchecked")
+ public static final SortedSet emptySortedSet() {
+ return (SortedSet) new EmptySortedSet<>();
+ }
+
+ /**
+ * @serial include
+ */
+ private static class EmptySortedSet
+ extends AbstractSet
+ implements SortedSet, Serializable
+ {
+ private static final long serialVersionUID = 6316515401502265487L;
+ public Iterator iterator() { return emptyIterator(); }
+ public int size() {return 0;}
+ public boolean isEmpty() {return true;}
+ public boolean contains(Object obj) {return false;}
+ public boolean containsAll(Collection> c) { return c.isEmpty(); }
+ public Object[] toArray() { return new Object[0]; }
+
+ public E[] toArray(E[] a) {
+ if (a.length > 0)
+ a[0] = null;
+ return a;
+ }
+
+ // Preserves singleton property
+ private Object readResolve() {
+ return new EmptySortedSet<>();
+ }
+
+ public Comparator comparator() {
+ return null;
+ }
+
+ public SortedSet subSet(Object fromElement, Object toElement) {
+ Objects.requireNonNull(fromElement);
+ Objects.requireNonNull(toElement);
+
+ if (!(fromElement instanceof Comparable) ||
+ !(toElement instanceof Comparable))
+ {
+ throw new ClassCastException();
+ }
+
+ if ((((Comparable)fromElement).compareTo(toElement) >= 0) ||
+ (((Comparable)toElement).compareTo(fromElement) < 0))
+ {
+ throw new IllegalArgumentException();
+ }
+
+ return emptySortedSet();
+ }
+
+ public SortedSet headSet(Object toElement) {
+ Objects.requireNonNull(toElement);
+
+ if (!(toElement instanceof Comparable)) {
+ throw new ClassCastException();
+ }
+
+ return emptySortedSet();
+ }
+
+ public SortedSet tailSet(Object fromElement) {
+ Objects.requireNonNull(fromElement);
+
+ if (!(fromElement instanceof Comparable)) {
+ throw new ClassCastException();
+ }
+
+ return emptySortedSet();
+ }
+
+ public E first() {
+ throw new NoSuchElementException();
+ }
+
+ public E last() {
+ throw new NoSuchElementException();
+ }
+ }
+
/**
* The empty list (immutable). This list is serializable.
*
diff --git a/jdk/src/share/classes/java/util/CurrencyData.properties b/jdk/src/share/classes/java/util/CurrencyData.properties
index 5cfc1397e6e..b943993522f 100644
--- a/jdk/src/share/classes/java/util/CurrencyData.properties
+++ b/jdk/src/share/classes/java/util/CurrencyData.properties
@@ -71,7 +71,7 @@ all=ADP020-AED784-AFA004-AFN971-ALL008-AMD051-ANG532-AOA973-ARS032-ATS040-AUD036
#
# The table is based on the following web sites:
# http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/db_en.html
-# http://www.bsi-global.com/iso4217currency
+# http://www.currency-iso.org/iso_index/iso_tables.htm
# http://www.cia.gov/cia/publications/factbook/indexgeo.html
# AFGHANISTAN
@@ -105,7 +105,7 @@ AU=AUD
# AUSTRIA
AT=EUR
# AZERBAIJAN
-AZ=AZM;2005-12-31-20-00-00;AZN
+AZ=AZN
# BAHAMAS
BS=BSD
# BAHRAIN
@@ -378,7 +378,7 @@ MS=XCD
# MOROCCO
MA=MAD
# MOZAMBIQUE
-MZ=MZM;2006-06-30-22-00-00;MZN
+MZ=MZN
# MYANMAR
MM=MMK
# NAMIBIA
@@ -440,7 +440,7 @@ QA=QAR
# REUNION
RE=EUR
# ROMANIA
-RO=ROL;2005-06-30-21-00-00;RON
+RO=RON
# RUSSIAN FEDERATION
RU=RUB
# RWANDA
@@ -532,7 +532,7 @@ TT=TTD
# TUNISIA
TN=TND
# TURKEY
-TR=TRL;2004-12-31-22-00-00;TRY
+TR=TRY
# TURKMENISTAN
TM=TMT
# TURKS AND CAICOS ISLANDS
@@ -558,7 +558,7 @@ UZ=UZS
# VANUATU
VU=VUV
# VENEZUELA
-VE=VEB;2008-01-01-04-00-00;VEF
+VE=VEF
# VIET NAM
VN=VND
# VIRGIN ISLANDS, BRITISH
diff --git a/jdk/src/share/classes/javax/net/ssl/HttpsURLConnection.java b/jdk/src/share/classes/javax/net/ssl/HttpsURLConnection.java
index fbd8fca1372..5027b9a5788 100644
--- a/jdk/src/share/classes/javax/net/ssl/HttpsURLConnection.java
+++ b/jdk/src/share/classes/javax/net/ssl/HttpsURLConnection.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, 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
@@ -347,6 +347,9 @@ class HttpsURLConnection extends HttpURLConnection
* @param sf the SSL socket factory
* @throws IllegalArgumentException if the SSLSocketFactory
* parameter is null.
+ * @throws SecurityException if a security manager exists and its
+ * checkSetFactory method does not allow
+ * a socket factory to be specified.
* @see #getSSLSocketFactory()
*/
public void setSSLSocketFactory(SSLSocketFactory sf) {
@@ -355,6 +358,10 @@ class HttpsURLConnection extends HttpURLConnection
"no SSLSocketFactory specified");
}
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkSetFactory();
+ }
sslSocketFactory = sf;
}
diff --git a/jdk/src/share/classes/javax/net/ssl/SSLEngine.java b/jdk/src/share/classes/javax/net/ssl/SSLEngine.java
index 2eea55121cb..411626cd7a1 100644
--- a/jdk/src/share/classes/javax/net/ssl/SSLEngine.java
+++ b/jdk/src/share/classes/javax/net/ssl/SSLEngine.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -538,7 +538,7 @@ public abstract class SSLEngine {
* If this SSLEngine has not yet started its initial
* handshake, this method will automatically start the handshake.
*
- * This method will attempt to produce one SSL/TLS packet, and will
+ * This method will attempt to produce SSL/TLS records, and will
* consume as much source data as possible, but will never consume
* more than the sum of the bytes remaining in each buffer. Each
* ByteBuffer's position is updated to reflect the
diff --git a/jdk/src/share/classes/javax/swing/JTable.java b/jdk/src/share/classes/javax/swing/JTable.java
index 386b2a4628a..6314cb0a207 100644
--- a/jdk/src/share/classes/javax/swing/JTable.java
+++ b/jdk/src/share/classes/javax/swing/JTable.java
@@ -1828,6 +1828,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* table. While the {@code autoCreateRowSorter} property remains
* {@code true}, every time the model is changed, a new {@code
* TableRowSorter} is created and set as the table's row sorter.
+ * The default value for the {@code autoCreateRowSorter}
+ * property is {@code false}.
*
* @param autoCreateRowSorter whether or not a {@code RowSorter}
* should be automatically created
diff --git a/jdk/src/share/classes/javax/swing/JTree.java b/jdk/src/share/classes/javax/swing/JTree.java
index 13a40562ebe..c5ca4b6dc70 100644
--- a/jdk/src/share/classes/javax/swing/JTree.java
+++ b/jdk/src/share/classes/javax/swing/JTree.java
@@ -1838,7 +1838,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
* nodes, or null if nothing is currently selected
*/
public TreePath[] getSelectionPaths() {
- return getSelectionModel().getSelectionPaths();
+ TreePath[] selectionPaths = getSelectionModel().getSelectionPaths();
+
+ return (selectionPaths != null && selectionPaths.length > 0) ? selectionPaths : null;
}
/**
diff --git a/jdk/src/share/classes/javax/swing/text/DefaultCaret.java b/jdk/src/share/classes/javax/swing/text/DefaultCaret.java
index ecbfdf0d6f4..464fff6822e 100644
--- a/jdk/src/share/classes/javax/swing/text/DefaultCaret.java
+++ b/jdk/src/share/classes/javax/swing/text/DefaultCaret.java
@@ -1326,7 +1326,7 @@ public class DefaultCaret extends Rectangle implements Caret, FocusListener, Mou
if ( ! SwingUtilities2.canCurrentEventAccessSystemClipboard() ) {
return;
}
- if (this.dot != this.mark && component != null) {
+ if (this.dot != this.mark && component != null && component.hasFocus()) {
Clipboard clip = getSystemSelection();
if (clip != null) {
String selectedText;
diff --git a/jdk/src/share/classes/javax/swing/text/html/HTMLDocument.java b/jdk/src/share/classes/javax/swing/text/html/HTMLDocument.java
index 5fc8c0f2bf4..a1f99e9cae8 100644
--- a/jdk/src/share/classes/javax/swing/text/html/HTMLDocument.java
+++ b/jdk/src/share/classes/javax/swing/text/html/HTMLDocument.java
@@ -1181,7 +1181,12 @@ public class HTMLDocument extends DefaultStyledDocument {
public void insertAfterStart(Element elem, String htmlText) throws
BadLocationException, IOException {
verifyParser();
- if (elem != null && elem.isLeaf()) {
+
+ if (elem == null || htmlText == null) {
+ return;
+ }
+
+ if (elem.isLeaf()) {
throw new IllegalArgumentException
("Can not insert HTML after start of a leaf");
}
diff --git a/jdk/src/share/classes/sun/awt/image/OffScreenImageSource.java b/jdk/src/share/classes/sun/awt/image/OffScreenImageSource.java
index 7e8e2dbc795..2b85b6b6d84 100644
--- a/jdk/src/share/classes/sun/awt/image/OffScreenImageSource.java
+++ b/jdk/src/share/classes/sun/awt/image/OffScreenImageSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2011, 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
@@ -185,7 +185,7 @@ public class OffScreenImageSource implements ImageProducer {
theConsumer.setDimensions(image.getWidth(), image.getHeight());
theConsumer.setProperties(properties);
sendPixels();
- theConsumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
+ theConsumer.imageComplete(ImageConsumer.STATICIMAGEDONE);
} catch (NullPointerException e) {
if (theConsumer != null) {
theConsumer.imageComplete(ImageConsumer.IMAGEERROR);
diff --git a/jdk/src/share/classes/sun/misc/VM.java b/jdk/src/share/classes/sun/misc/VM.java
index bcec901e706..e1fb584bb2c 100644
--- a/jdk/src/share/classes/sun/misc/VM.java
+++ b/jdk/src/share/classes/sun/misc/VM.java
@@ -371,6 +371,12 @@ public class VM {
private final static int JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010;
private final static int JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020;
+ /*
+ * Returns the first non-null class loader up the execution stack,
+ * or null if only code from the null class loader is on the stack.
+ */
+ public static native ClassLoader latestUserDefinedLoader();
+
static {
initialize();
}
diff --git a/jdk/src/share/classes/sun/net/ResourceManager.java b/jdk/src/share/classes/sun/net/ResourceManager.java
index 11bfc464819..068b8484728 100644
--- a/jdk/src/share/classes/sun/net/ResourceManager.java
+++ b/jdk/src/share/classes/sun/net/ResourceManager.java
@@ -41,13 +41,14 @@ public class ResourceManager {
/* default maximum number of udp sockets per VM
* when a security manager is enabled.
- * The default is 1024 which is high enough to be useful
+ * The default is 25 which is high enough to be useful
* but low enough to be well below the maximum number
- * of port numbers actually available on all OSes for
- * such sockets (5000 on some versions of windows)
+ * of port numbers actually available on all OSes
+ * when multiplied by the maximum feasible number of VM processes
+ * that could practically be spawned.
*/
- private static final int DEFAULT_MAX_SOCKETS = 1024;
+ private static final int DEFAULT_MAX_SOCKETS = 25;
private static final int maxSockets;
private static final AtomicInteger numSockets;
diff --git a/jdk/src/share/classes/sun/nio/ch/Util.java b/jdk/src/share/classes/sun/nio/ch/Util.java
index 9aa7c162854..fafc48f3552 100644
--- a/jdk/src/share/classes/sun/nio/ch/Util.java
+++ b/jdk/src/share/classes/sun/nio/ch/Util.java
@@ -363,10 +363,10 @@ class Util {
try {
Class> cl = Class.forName("java.nio.DirectByteBuffer");
Constructor> ctor = cl.getDeclaredConstructor(
- new Class[] { int.class,
- long.class,
- FileDescriptor.class,
- Runnable.class });
+ new Class>[] { int.class,
+ long.class,
+ FileDescriptor.class,
+ Runnable.class });
ctor.setAccessible(true);
directByteBufferConstructor = ctor;
} catch (ClassNotFoundException |
@@ -408,10 +408,10 @@ class Util {
try {
Class> cl = Class.forName("java.nio.DirectByteBufferR");
Constructor> ctor = cl.getDeclaredConstructor(
- new Class[] { int.class,
- long.class,
- FileDescriptor.class,
- Runnable.class });
+ new Class>[] { int.class,
+ long.class,
+ FileDescriptor.class,
+ Runnable.class });
ctor.setAccessible(true);
directByteBufferRConstructor = ctor;
} catch (ClassNotFoundException |
diff --git a/jdk/src/share/classes/sun/nio/cs/CESU_8.java b/jdk/src/share/classes/sun/nio/cs/CESU_8.java
new file mode 100644
index 00000000000..40711f83d86
--- /dev/null
+++ b/jdk/src/share/classes/sun/nio/cs/CESU_8.java
@@ -0,0 +1,604 @@
+/*
+ * Copyright (c) 2011, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.nio.cs;
+
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.CodingErrorAction;
+
+/* Legal CESU-8 Byte Sequences
+ *
+ * # Code Points Bits Bit/Byte pattern
+ * 1 7 0xxxxxxx
+ * U+0000..U+007F 00..7F
+ *
+ * 2 11 110xxxxx 10xxxxxx
+ * U+0080..U+07FF C2..DF 80..BF
+ *
+ * 3 16 1110xxxx 10xxxxxx 10xxxxxx
+ * U+0800..U+0FFF E0 A0..BF 80..BF
+ * U+1000..U+FFFF E1..EF 80..BF 80..BF
+ *
+ */
+
+class CESU_8 extends Unicode
+{
+ public CESU_8() {
+ super("CESU-8", StandardCharsets.aliases_CESU_8);
+ }
+
+ public String historicalName() {
+ return "CESU8";
+ }
+
+ public CharsetDecoder newDecoder() {
+ return new Decoder(this);
+ }
+
+ public CharsetEncoder newEncoder() {
+ return new Encoder(this);
+ }
+
+ private static final void updatePositions(Buffer src, int sp,
+ Buffer dst, int dp) {
+ src.position(sp - src.arrayOffset());
+ dst.position(dp - dst.arrayOffset());
+ }
+
+ private static class Decoder extends CharsetDecoder
+ implements ArrayDecoder {
+ private Decoder(Charset cs) {
+ super(cs, 1.0f, 1.0f);
+ }
+
+ private static boolean isNotContinuation(int b) {
+ return (b & 0xc0) != 0x80;
+ }
+
+ // [E0] [A0..BF] [80..BF]
+ // [E1..EF] [80..BF] [80..BF]
+ private static boolean isMalformed3(int b1, int b2, int b3) {
+ return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
+ (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80;
+ }
+
+ // only used when there is only one byte left in src buffer
+ private static boolean isMalformed3_2(int b1, int b2) {
+ return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
+ (b2 & 0xc0) != 0x80;
+ }
+
+
+ // [F0] [90..BF] [80..BF] [80..BF]
+ // [F1..F3] [80..BF] [80..BF] [80..BF]
+ // [F4] [80..8F] [80..BF] [80..BF]
+ // only check 80-be range here, the [0xf0,0x80...] and [0xf4,0x90-...]
+ // will be checked by Character.isSupplementaryCodePoint(uc)
+ private static boolean isMalformed4(int b2, int b3, int b4) {
+ return (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 ||
+ (b4 & 0xc0) != 0x80;
+ }
+
+ // only used when there is less than 4 bytes left in src buffer
+ private static boolean isMalformed4_2(int b1, int b2) {
+ return (b1 == 0xf0 && b2 == 0x90) ||
+ (b2 & 0xc0) != 0x80;
+ }
+
+ private static boolean isMalformed4_3(int b3) {
+ return (b3 & 0xc0) != 0x80;
+ }
+
+ private static CoderResult malformedN(ByteBuffer src, int nb) {
+ switch (nb) {
+ case 1:
+ case 2: // always 1
+ return CoderResult.malformedForLength(1);
+ case 3:
+ int b1 = src.get();
+ int b2 = src.get(); // no need to lookup b3
+ return CoderResult.malformedForLength(
+ ((b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
+ isNotContinuation(b2)) ? 1 : 2);
+ case 4: // we don't care the speed here
+ b1 = src.get() & 0xff;
+ b2 = src.get() & 0xff;
+ if (b1 > 0xf4 ||
+ (b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) ||
+ (b1 == 0xf4 && (b2 & 0xf0) != 0x80) ||
+ isNotContinuation(b2))
+ return CoderResult.malformedForLength(1);
+ if (isNotContinuation(src.get()))
+ return CoderResult.malformedForLength(2);
+ return CoderResult.malformedForLength(3);
+ default:
+ assert false;
+ return null;
+ }
+ }
+
+ private static CoderResult malformed(ByteBuffer src, int sp,
+ CharBuffer dst, int dp,
+ int nb)
+ {
+ src.position(sp - src.arrayOffset());
+ CoderResult cr = malformedN(src, nb);
+ updatePositions(src, sp, dst, dp);
+ return cr;
+ }
+
+
+ private static CoderResult malformed(ByteBuffer src,
+ int mark, int nb)
+ {
+ src.position(mark);
+ CoderResult cr = malformedN(src, nb);
+ src.position(mark);
+ return cr;
+ }
+
+ private static CoderResult malformedForLength(ByteBuffer src,
+ int sp,
+ CharBuffer dst,
+ int dp,
+ int malformedNB)
+ {
+ updatePositions(src, sp, dst, dp);
+ return CoderResult.malformedForLength(malformedNB);
+ }
+
+ private static CoderResult malformedForLength(ByteBuffer src,
+ int mark,
+ int malformedNB)
+ {
+ src.position(mark);
+ return CoderResult.malformedForLength(malformedNB);
+ }
+
+
+ private static CoderResult xflow(Buffer src, int sp, int sl,
+ Buffer dst, int dp, int nb) {
+ updatePositions(src, sp, dst, dp);
+ return (nb == 0 || sl - sp < nb)
+ ? CoderResult.UNDERFLOW : CoderResult.OVERFLOW;
+ }
+
+ private static CoderResult xflow(Buffer src, int mark, int nb) {
+ src.position(mark);
+ return (nb == 0 || src.remaining() < nb)
+ ? CoderResult.UNDERFLOW : CoderResult.OVERFLOW;
+ }
+
+ private CoderResult decodeArrayLoop(ByteBuffer src,
+ CharBuffer dst)
+ {
+ // This method is optimized for ASCII input.
+ byte[] sa = src.array();
+ int sp = src.arrayOffset() + src.position();
+ int sl = src.arrayOffset() + src.limit();
+
+ char[] da = dst.array();
+ int dp = dst.arrayOffset() + dst.position();
+ int dl = dst.arrayOffset() + dst.limit();
+ int dlASCII = dp + Math.min(sl - sp, dl - dp);
+
+ // ASCII only loop
+ while (dp < dlASCII && sa[sp] >= 0)
+ da[dp++] = (char) sa[sp++];
+ while (sp < sl) {
+ int b1 = sa[sp];
+ if (b1 >= 0) {
+ // 1 byte, 7 bits: 0xxxxxxx
+ if (dp >= dl)
+ return xflow(src, sp, sl, dst, dp, 1);
+ da[dp++] = (char) b1;
+ sp++;
+ } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
+ // 2 bytes, 11 bits: 110xxxxx 10xxxxxx
+ if (sl - sp < 2 || dp >= dl)
+ return xflow(src, sp, sl, dst, dp, 2);
+ int b2 = sa[sp + 1];
+ if (isNotContinuation(b2))
+ return malformedForLength(src, sp, dst, dp, 1);
+ da[dp++] = (char) (((b1 << 6) ^ b2)
+ ^
+ (((byte) 0xC0 << 6) ^
+ ((byte) 0x80 << 0)));
+ sp += 2;
+ } else if ((b1 >> 4) == -2) {
+ // 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
+ int srcRemaining = sl - sp;
+ if (srcRemaining < 3 || dp >= dl) {
+ if (srcRemaining > 1 && isMalformed3_2(b1, sa[sp + 1]))
+ return malformedForLength(src, sp, dst, dp, 1);
+ return xflow(src, sp, sl, dst, dp, 3);
+ }
+ int b2 = sa[sp + 1];
+ int b3 = sa[sp + 2];
+ if (isMalformed3(b1, b2, b3))
+ return malformed(src, sp, dst, dp, 3);
+ da[dp++] = (char)
+ ((b1 << 12) ^
+ (b2 << 6) ^
+ (b3 ^
+ (((byte) 0xE0 << 12) ^
+ ((byte) 0x80 << 6) ^
+ ((byte) 0x80 << 0))));
+ sp += 3;
+ } else {
+ return malformed(src, sp, dst, dp, 1);
+ }
+ }
+ return xflow(src, sp, sl, dst, dp, 0);
+ }
+
+ private CoderResult decodeBufferLoop(ByteBuffer src,
+ CharBuffer dst)
+ {
+ int mark = src.position();
+ int limit = src.limit();
+ while (mark < limit) {
+ int b1 = src.get();
+ if (b1 >= 0) {
+ // 1 byte, 7 bits: 0xxxxxxx
+ if (dst.remaining() < 1)
+ return xflow(src, mark, 1); // overflow
+ dst.put((char) b1);
+ mark++;
+ } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
+ // 2 bytes, 11 bits: 110xxxxx 10xxxxxx
+ if (limit - mark < 2|| dst.remaining() < 1)
+ return xflow(src, mark, 2);
+ int b2 = src.get();
+ if (isNotContinuation(b2))
+ return malformedForLength(src, mark, 1);
+ dst.put((char) (((b1 << 6) ^ b2)
+ ^
+ (((byte) 0xC0 << 6) ^
+ ((byte) 0x80 << 0))));
+ mark += 2;
+ } else if ((b1 >> 4) == -2) {
+ // 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
+ int srcRemaining = limit - mark;
+ if (srcRemaining < 3 || dst.remaining() < 1) {
+ if (srcRemaining > 1 && isMalformed3_2(b1, src.get()))
+ return malformedForLength(src, mark, 1);
+ return xflow(src, mark, 3);
+ }
+ int b2 = src.get();
+ int b3 = src.get();
+ if (isMalformed3(b1, b2, b3))
+ return malformed(src, mark, 3);
+ dst.put((char)
+ ((b1 << 12) ^
+ (b2 << 6) ^
+ (b3 ^
+ (((byte) 0xE0 << 12) ^
+ ((byte) 0x80 << 6) ^
+ ((byte) 0x80 << 0)))));
+ mark += 3;
+ } else {
+ return malformed(src, mark, 1);
+ }
+ }
+ return xflow(src, mark, 0);
+ }
+
+ protected CoderResult decodeLoop(ByteBuffer src,
+ CharBuffer dst)
+ {
+ if (src.hasArray() && dst.hasArray())
+ return decodeArrayLoop(src, dst);
+ else
+ return decodeBufferLoop(src, dst);
+ }
+
+ private static ByteBuffer getByteBuffer(ByteBuffer bb, byte[] ba, int sp)
+ {
+ if (bb == null)
+ bb = ByteBuffer.wrap(ba);
+ bb.position(sp);
+ return bb;
+ }
+
+ // returns -1 if there is/are malformed byte(s) and the
+ // "action" for malformed input is not REPLACE.
+ public int decode(byte[] sa, int sp, int len, char[] da) {
+ final int sl = sp + len;
+ int dp = 0;
+ int dlASCII = Math.min(len, da.length);
+ ByteBuffer bb = null; // only necessary if malformed
+
+ // ASCII only optimized loop
+ while (dp < dlASCII && sa[sp] >= 0)
+ da[dp++] = (char) sa[sp++];
+
+ while (sp < sl) {
+ int b1 = sa[sp++];
+ if (b1 >= 0) {
+ // 1 byte, 7 bits: 0xxxxxxx
+ da[dp++] = (char) b1;
+ } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
+ // 2 bytes, 11 bits: 110xxxxx 10xxxxxx
+ if (sp < sl) {
+ int b2 = sa[sp++];
+ if (isNotContinuation(b2)) {
+ if (malformedInputAction() != CodingErrorAction.REPLACE)
+ return -1;
+ da[dp++] = replacement().charAt(0);
+ sp--; // malformedN(bb, 2) always returns 1
+ } else {
+ da[dp++] = (char) (((b1 << 6) ^ b2)^
+ (((byte) 0xC0 << 6) ^
+ ((byte) 0x80 << 0)));
+ }
+ continue;
+ }
+ if (malformedInputAction() != CodingErrorAction.REPLACE)
+ return -1;
+ da[dp++] = replacement().charAt(0);
+ return dp;
+ } else if ((b1 >> 4) == -2) {
+ // 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
+ if (sp + 1 < sl) {
+ int b2 = sa[sp++];
+ int b3 = sa[sp++];
+ if (isMalformed3(b1, b2, b3)) {
+ if (malformedInputAction() != CodingErrorAction.REPLACE)
+ return -1;
+ da[dp++] = replacement().charAt(0);
+ sp -=3;
+ bb = getByteBuffer(bb, sa, sp);
+ sp += malformedN(bb, 3).length();
+ } else {
+ da[dp++] = (char)((b1 << 12) ^
+ (b2 << 6) ^
+ (b3 ^
+ (((byte) 0xE0 << 12) ^
+ ((byte) 0x80 << 6) ^
+ ((byte) 0x80 << 0))));
+ }
+ continue;
+ }
+ if (malformedInputAction() != CodingErrorAction.REPLACE)
+ return -1;
+ if (sp < sl && isMalformed3_2(b1, sa[sp])) {
+ da[dp++] = replacement().charAt(0);
+ continue;
+
+ }
+ da[dp++] = replacement().charAt(0);
+ return dp;
+ } else {
+ if (malformedInputAction() != CodingErrorAction.REPLACE)
+ return -1;
+ da[dp++] = replacement().charAt(0);
+ }
+ }
+ return dp;
+ }
+ }
+
+ private static class Encoder extends CharsetEncoder
+ implements ArrayEncoder {
+
+ private Encoder(Charset cs) {
+ super(cs, 1.1f, 3.0f);
+ }
+
+ public boolean canEncode(char c) {
+ return !Character.isSurrogate(c);
+ }
+
+ public boolean isLegalReplacement(byte[] repl) {
+ return ((repl.length == 1 && repl[0] >= 0) ||
+ super.isLegalReplacement(repl));
+ }
+
+ private static CoderResult overflow(CharBuffer src, int sp,
+ ByteBuffer dst, int dp) {
+ updatePositions(src, sp, dst, dp);
+ return CoderResult.OVERFLOW;
+ }
+
+ private static CoderResult overflow(CharBuffer src, int mark) {
+ src.position(mark);
+ return CoderResult.OVERFLOW;
+ }
+
+ private static void to3Bytes(byte[] da, int dp, char c) {
+ da[dp] = (byte)(0xe0 | ((c >> 12)));
+ da[dp + 1] = (byte)(0x80 | ((c >> 6) & 0x3f));
+ da[dp + 2] = (byte)(0x80 | (c & 0x3f));
+ }
+
+ private static void to3Bytes(ByteBuffer dst, char c) {
+ dst.put((byte)(0xe0 | ((c >> 12))));
+ dst.put((byte)(0x80 | ((c >> 6) & 0x3f)));
+ dst.put((byte)(0x80 | (c & 0x3f)));
+ }
+
+ private Surrogate.Parser sgp;
+ private char[] c2;
+ private CoderResult encodeArrayLoop(CharBuffer src,
+ ByteBuffer dst)
+ {
+ char[] sa = src.array();
+ int sp = src.arrayOffset() + src.position();
+ int sl = src.arrayOffset() + src.limit();
+
+ byte[] da = dst.array();
+ int dp = dst.arrayOffset() + dst.position();
+ int dl = dst.arrayOffset() + dst.limit();
+ int dlASCII = dp + Math.min(sl - sp, dl - dp);
+
+ // ASCII only loop
+ while (dp < dlASCII && sa[sp] < '\u0080')
+ da[dp++] = (byte) sa[sp++];
+ while (sp < sl) {
+ char c = sa[sp];
+ if (c < 0x80) {
+ // Have at most seven bits
+ if (dp >= dl)
+ return overflow(src, sp, dst, dp);
+ da[dp++] = (byte)c;
+ } else if (c < 0x800) {
+ // 2 bytes, 11 bits
+ if (dl - dp < 2)
+ return overflow(src, sp, dst, dp);
+ da[dp++] = (byte)(0xc0 | (c >> 6));
+ da[dp++] = (byte)(0x80 | (c & 0x3f));
+ } else if (Character.isSurrogate(c)) {
+ // Have a surrogate pair
+ if (sgp == null)
+ sgp = new Surrogate.Parser();
+ int uc = sgp.parse(c, sa, sp, sl);
+ if (uc < 0) {
+ updatePositions(src, sp, dst, dp);
+ return sgp.error();
+ }
+ if (dl - dp < 6)
+ return overflow(src, sp, dst, dp);
+ to3Bytes(da, dp, Character.highSurrogate(uc));
+ dp += 3;
+ to3Bytes(da, dp, Character.lowSurrogate(uc));
+ dp += 3;
+ sp++; // 2 chars
+ } else {
+ // 3 bytes, 16 bits
+ if (dl - dp < 3)
+ return overflow(src, sp, dst, dp);
+ to3Bytes(da, dp, c);
+ dp += 3;
+ }
+ sp++;
+ }
+ updatePositions(src, sp, dst, dp);
+ return CoderResult.UNDERFLOW;
+ }
+
+ private CoderResult encodeBufferLoop(CharBuffer src,
+ ByteBuffer dst)
+ {
+ int mark = src.position();
+ while (src.hasRemaining()) {
+ char c = src.get();
+ if (c < 0x80) {
+ // Have at most seven bits
+ if (!dst.hasRemaining())
+ return overflow(src, mark);
+ dst.put((byte)c);
+ } else if (c < 0x800) {
+ // 2 bytes, 11 bits
+ if (dst.remaining() < 2)
+ return overflow(src, mark);
+ dst.put((byte)(0xc0 | (c >> 6)));
+ dst.put((byte)(0x80 | (c & 0x3f)));
+ } else if (Character.isSurrogate(c)) {
+ // Have a surrogate pair
+ if (sgp == null)
+ sgp = new Surrogate.Parser();
+ int uc = sgp.parse(c, src);
+ if (uc < 0) {
+ src.position(mark);
+ return sgp.error();
+ }
+ if (dst.remaining() < 6)
+ return overflow(src, mark);
+ to3Bytes(dst, Character.highSurrogate(uc));
+ to3Bytes(dst, Character.lowSurrogate(uc));
+ mark++; // 2 chars
+ } else {
+ // 3 bytes, 16 bits
+ if (dst.remaining() < 3)
+ return overflow(src, mark);
+ to3Bytes(dst, c);
+ }
+ mark++;
+ }
+ src.position(mark);
+ return CoderResult.UNDERFLOW;
+ }
+
+ protected final CoderResult encodeLoop(CharBuffer src,
+ ByteBuffer dst)
+ {
+ if (src.hasArray() && dst.hasArray())
+ return encodeArrayLoop(src, dst);
+ else
+ return encodeBufferLoop(src, dst);
+ }
+
+ // returns -1 if there is malformed char(s) and the
+ // "action" for malformed input is not REPLACE.
+ public int encode(char[] sa, int sp, int len, byte[] da) {
+ int sl = sp + len;
+ int dp = 0;
+ int dlASCII = dp + Math.min(len, da.length);
+
+ // ASCII only optimized loop
+ while (dp < dlASCII && sa[sp] < '\u0080')
+ da[dp++] = (byte) sa[sp++];
+
+ while (sp < sl) {
+ char c = sa[sp++];
+ if (c < 0x80) {
+ // Have at most seven bits
+ da[dp++] = (byte)c;
+ } else if (c < 0x800) {
+ // 2 bytes, 11 bits
+ da[dp++] = (byte)(0xc0 | (c >> 6));
+ da[dp++] = (byte)(0x80 | (c & 0x3f));
+ } else if (Character.isSurrogate(c)) {
+ if (sgp == null)
+ sgp = new Surrogate.Parser();
+ int uc = sgp.parse(c, sa, sp - 1, sl);
+ if (uc < 0) {
+ if (malformedInputAction() != CodingErrorAction.REPLACE)
+ return -1;
+ da[dp++] = replacement()[0];
+ } else {
+ to3Bytes(da, dp, Character.highSurrogate(uc));
+ dp += 3;
+ to3Bytes(da, dp, Character.lowSurrogate(uc));
+ dp += 3;
+ sp++; // 2 chars
+ }
+ } else {
+ // 3 bytes, 16 bits
+ to3Bytes(da, dp, c);
+ dp += 3;
+ }
+ }
+ return dp;
+ }
+ }
+}
diff --git a/jdk/src/share/classes/sun/nio/cs/UTF_8.java b/jdk/src/share/classes/sun/nio/cs/UTF_8.java
index 56d6bcc7b6d..1f7edaad2d8 100644
--- a/jdk/src/share/classes/sun/nio/cs/UTF_8.java
+++ b/jdk/src/share/classes/sun/nio/cs/UTF_8.java
@@ -72,8 +72,8 @@ class UTF_8 extends Unicode
return new Encoder(this);
}
- static final void updatePositions(Buffer src, int sp,
- Buffer dst, int dp) {
+ private static final void updatePositions(Buffer src, int sp,
+ Buffer dst, int dp) {
src.position(sp - src.arrayOffset());
dst.position(dp - dst.arrayOffset());
}
@@ -88,11 +88,6 @@ class UTF_8 extends Unicode
return (b & 0xc0) != 0x80;
}
- // [C2..DF] [80..BF]
- private static boolean isMalformed2(int b1, int b2) {
- return (b1 & 0x1e) == 0x0 || (b2 & 0xc0) != 0x80;
- }
-
// [E0] [A0..BF] [80..BF]
// [E1..EF] [80..BF] [80..BF]
private static boolean isMalformed3(int b1, int b2, int b3) {
@@ -100,6 +95,12 @@ class UTF_8 extends Unicode
(b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80;
}
+ // only used when there is only one byte left in src buffer
+ private static boolean isMalformed3_2(int b1, int b2) {
+ return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
+ (b2 & 0xc0) != 0x80;
+ }
+
// [F0] [90..BF] [80..BF] [80..BF]
// [F1..F3] [80..BF] [80..BF] [80..BF]
// [F4] [80..8F] [80..BF] [80..BF]
@@ -110,6 +111,16 @@ class UTF_8 extends Unicode
(b4 & 0xc0) != 0x80;
}
+ // only used when there is less than 4 bytes left in src buffer
+ private static boolean isMalformed4_2(int b1, int b2) {
+ return (b1 == 0xf0 && b2 == 0x90) ||
+ (b2 & 0xc0) != 0x80;
+ }
+
+ private static boolean isMalformed4_3(int b3) {
+ return (b3 & 0xc0) != 0x80;
+ }
+
private static CoderResult lookupN(ByteBuffer src, int n)
{
for (int i = 1; i < n; i++) {
@@ -122,28 +133,14 @@ class UTF_8 extends Unicode
private static CoderResult malformedN(ByteBuffer src, int nb) {
switch (nb) {
case 1:
- int b1 = src.get();
- if ((b1 >> 2) == -2) {
- // 5 bytes 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
- if (src.remaining() < 4)
- return CoderResult.UNDERFLOW;
- return lookupN(src, 5);
- }
- if ((b1 >> 1) == -2) {
- // 6 bytes 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
- if (src.remaining() < 5)
- return CoderResult.UNDERFLOW;
- return lookupN(src, 6);
- }
- return CoderResult.malformedForLength(1);
case 2: // always 1
return CoderResult.malformedForLength(1);
case 3:
- b1 = src.get();
+ int b1 = src.get();
int b2 = src.get(); // no need to lookup b3
return CoderResult.malformedForLength(
((b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
- isNotContinuation(b2))?1:2);
+ isNotContinuation(b2)) ? 1 : 2);
case 4: // we don't care the speed here
b1 = src.get() & 0xff;
b2 = src.get() & 0xff;
@@ -171,6 +168,7 @@ class UTF_8 extends Unicode
return cr;
}
+
private static CoderResult malformed(ByteBuffer src,
int mark, int nb)
{
@@ -180,18 +178,36 @@ class UTF_8 extends Unicode
return cr;
}
+ private static CoderResult malformedForLength(ByteBuffer src,
+ int sp,
+ CharBuffer dst,
+ int dp,
+ int malformedNB)
+ {
+ updatePositions(src, sp, dst, dp);
+ return CoderResult.malformedForLength(malformedNB);
+ }
+
+ private static CoderResult malformedForLength(ByteBuffer src,
+ int mark,
+ int malformedNB)
+ {
+ src.position(mark);
+ return CoderResult.malformedForLength(malformedNB);
+ }
+
+
private static CoderResult xflow(Buffer src, int sp, int sl,
Buffer dst, int dp, int nb) {
updatePositions(src, sp, dst, dp);
return (nb == 0 || sl - sp < nb)
- ?CoderResult.UNDERFLOW:CoderResult.OVERFLOW;
+ ? CoderResult.UNDERFLOW : CoderResult.OVERFLOW;
}
private static CoderResult xflow(Buffer src, int mark, int nb) {
- CoderResult cr = (nb == 0 || src.remaining() < (nb - 1))
- ?CoderResult.UNDERFLOW:CoderResult.OVERFLOW;
src.position(mark);
- return cr;
+ return (nb == 0 || src.remaining() < nb)
+ ? CoderResult.UNDERFLOW : CoderResult.OVERFLOW;
}
private CoderResult decodeArrayLoop(ByteBuffer src,
@@ -210,7 +226,6 @@ class UTF_8 extends Unicode
// ASCII only loop
while (dp < dlASCII && sa[sp] >= 0)
da[dp++] = (char) sa[sp++];
-
while (sp < sl) {
int b1 = sa[sp];
if (b1 >= 0) {
@@ -219,13 +234,20 @@ class UTF_8 extends Unicode
return xflow(src, sp, sl, dst, dp, 1);
da[dp++] = (char) b1;
sp++;
- } else if ((b1 >> 5) == -2) {
+ } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
+ // [C2..DF] [80..BF]
if (sl - sp < 2 || dp >= dl)
return xflow(src, sp, sl, dst, dp, 2);
int b2 = sa[sp + 1];
- if (isMalformed2(b1, b2))
- return malformed(src, sp, dst, dp, 2);
+ // Now we check the first byte of 2-byte sequence as
+ // if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0)
+ // no longer need to check b1 against c1 & c0 for
+ // malformed as we did in previous version
+ // (b1 & 0x1e) == 0x0 || (b2 & 0xc0) != 0x80;
+ // only need to check the second byte b2.
+ if (isNotContinuation(b2))
+ return malformedForLength(src, sp, dst, dp, 1);
da[dp++] = (char) (((b1 << 6) ^ b2)
^
(((byte) 0xC0 << 6) ^
@@ -233,24 +255,37 @@ class UTF_8 extends Unicode
sp += 2;
} else if ((b1 >> 4) == -2) {
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
- if (sl - sp < 3 || dp >= dl)
+ int srcRemaining = sl - sp;
+ if (srcRemaining < 3 || dp >= dl) {
+ if (srcRemaining > 1 && isMalformed3_2(b1, sa[sp + 1]))
+ return malformedForLength(src, sp, dst, dp, 1);
return xflow(src, sp, sl, dst, dp, 3);
+ }
int b2 = sa[sp + 1];
int b3 = sa[sp + 2];
if (isMalformed3(b1, b2, b3))
return malformed(src, sp, dst, dp, 3);
- da[dp++] = (char)
+ char c = (char)
((b1 << 12) ^
(b2 << 6) ^
(b3 ^
(((byte) 0xE0 << 12) ^
((byte) 0x80 << 6) ^
((byte) 0x80 << 0))));
+ if (Character.isSurrogate(c))
+ return malformedForLength(src, sp, dst, dp, 3);
+ da[dp++] = c;
sp += 3;
} else if ((b1 >> 3) == -2) {
// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- if (sl - sp < 4 || dl - dp < 2)
+ int srcRemaining = sl - sp;
+ if (srcRemaining < 4 || dl - dp < 2) {
+ if (srcRemaining > 1 && isMalformed4_2(b1, sa[sp + 1]))
+ return malformedForLength(src, sp, dst, dp, 1);
+ if (srcRemaining > 2 && isMalformed4_3(sa[sp + 2]))
+ return malformedForLength(src, sp, dst, dp, 2);
return xflow(src, sp, sl, dst, dp, 4);
+ }
int b2 = sa[sp + 1];
int b3 = sa[sp + 2];
int b4 = sa[sp + 3];
@@ -289,38 +324,51 @@ class UTF_8 extends Unicode
return xflow(src, mark, 1); // overflow
dst.put((char) b1);
mark++;
- } else if ((b1 >> 5) == -2) {
+ } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
if (limit - mark < 2|| dst.remaining() < 1)
return xflow(src, mark, 2);
int b2 = src.get();
- if (isMalformed2(b1, b2))
- return malformed(src, mark, 2);
- dst.put((char) (((b1 << 6) ^ b2)
+ if (isNotContinuation(b2))
+ return malformedForLength(src, mark, 1);
+ dst.put((char) (((b1 << 6) ^ b2)
^
(((byte) 0xC0 << 6) ^
((byte) 0x80 << 0))));
mark += 2;
} else if ((b1 >> 4) == -2) {
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
- if (limit - mark < 3 || dst.remaining() < 1)
+ int srcRemaining = limit - mark;
+ if (srcRemaining < 3 || dst.remaining() < 1) {
+ if (srcRemaining > 1 && isMalformed3_2(b1, src.get()))
+ return malformedForLength(src, mark, 1);
return xflow(src, mark, 3);
+ }
int b2 = src.get();
int b3 = src.get();
if (isMalformed3(b1, b2, b3))
return malformed(src, mark, 3);
- dst.put((char)
- ((b1 << 12) ^
- (b2 << 6) ^
- (b3 ^
- (((byte) 0xE0 << 12) ^
- ((byte) 0x80 << 6) ^
- ((byte) 0x80 << 0)))));
+ char c = (char)
+ ((b1 << 12) ^
+ (b2 << 6) ^
+ (b3 ^
+ (((byte) 0xE0 << 12) ^
+ ((byte) 0x80 << 6) ^
+ ((byte) 0x80 << 0))));
+ if (Character.isSurrogate(c))
+ return malformedForLength(src, mark, 3);
+ dst.put(c);
mark += 3;
} else if ((b1 >> 3) == -2) {
// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- if (limit - mark < 4 || dst.remaining() < 2)
+ int srcRemaining = limit - mark;
+ if (srcRemaining < 4 || dst.remaining() < 2) {
+ if (srcRemaining > 1 && isMalformed4_2(b1, src.get()))
+ return malformedForLength(src, mark, 1);
+ if (srcRemaining > 2 && isMalformed4_3(src.get()))
+ return malformedForLength(src, mark, 2);
return xflow(src, mark, 4);
+ }
int b2 = src.get();
int b3 = src.get();
int b4 = src.get();
@@ -364,7 +412,7 @@ class UTF_8 extends Unicode
return bb;
}
- // returns -1 if there is malformed byte(s) and the
+ // returns -1 if there is/are malformed byte(s) and the
// "action" for malformed input is not REPLACE.
public int decode(byte[] sa, int sp, int len, char[] da) {
final int sl = sp + len;
@@ -381,11 +429,11 @@ class UTF_8 extends Unicode
if (b1 >= 0) {
// 1 byte, 7 bits: 0xxxxxxx
da[dp++] = (char) b1;
- } else if ((b1 >> 5) == -2) {
+ } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
if (sp < sl) {
int b2 = sa[sp++];
- if (isMalformed2(b1, b2)) {
+ if (isNotContinuation(b2)) {
if (malformedInputAction() != CodingErrorAction.REPLACE)
return -1;
da[dp++] = replacement().charAt(0);
@@ -410,21 +458,33 @@ class UTF_8 extends Unicode
if (malformedInputAction() != CodingErrorAction.REPLACE)
return -1;
da[dp++] = replacement().charAt(0);
- sp -=3;
+ sp -= 3;
bb = getByteBuffer(bb, sa, sp);
sp += malformedN(bb, 3).length();
} else {
- da[dp++] = (char)((b1 << 12) ^
+ char c = (char)((b1 << 12) ^
(b2 << 6) ^
(b3 ^
(((byte) 0xE0 << 12) ^
((byte) 0x80 << 6) ^
((byte) 0x80 << 0))));
+ if (Character.isSurrogate(c)) {
+ if (malformedInputAction() != CodingErrorAction.REPLACE)
+ return -1;
+ da[dp++] = replacement().charAt(0);
+ } else {
+ da[dp++] = c;
+ }
}
continue;
}
if (malformedInputAction() != CodingErrorAction.REPLACE)
return -1;
+ if (sp < sl && isMalformed3_2(b1, sa[sp])) {
+ da[dp++] = replacement().charAt(0);
+ continue;
+
+ }
da[dp++] = replacement().charAt(0);
return dp;
} else if ((b1 >> 3) == -2) {
@@ -458,28 +518,29 @@ class UTF_8 extends Unicode
}
if (malformedInputAction() != CodingErrorAction.REPLACE)
return -1;
+
+ if (sp < sl && isMalformed4_2(b1, sa[sp])) {
+ da[dp++] = replacement().charAt(0);
+ continue;
+ }
+ sp++;
+ if (sp < sl && isMalformed4_3(sa[sp])) {
+ da[dp++] = replacement().charAt(0);
+ continue;
+ }
da[dp++] = replacement().charAt(0);
return dp;
} else {
if (malformedInputAction() != CodingErrorAction.REPLACE)
return -1;
da[dp++] = replacement().charAt(0);
- sp--;
- bb = getByteBuffer(bb, sa, sp);
- CoderResult cr = malformedN(bb, 1);
- if (!cr.isError()) {
- // leading byte for 5 or 6-byte, but don't have enough
- // bytes in buffer to check. Consumed rest as malformed.
- return dp;
- }
- sp += cr.length();
}
}
return dp;
}
}
- private static class Encoder extends CharsetEncoder
+ private static final class Encoder extends CharsetEncoder
implements ArrayEncoder {
private Encoder(Charset cs) {
diff --git a/jdk/src/share/classes/sun/nio/cs/standard-charsets b/jdk/src/share/classes/sun/nio/cs/standard-charsets
index 06120fee8f3..245713500a6 100644
--- a/jdk/src/share/classes/sun/nio/cs/standard-charsets
+++ b/jdk/src/share/classes/sun/nio/cs/standard-charsets
@@ -63,6 +63,10 @@ charset UTF-8 UTF_8
alias UTF8 # JDK historical
alias unicode-1-1-utf-8
+charset CESU-8 CESU_8
+ alias CESU8
+ alias csCESU-8
+
charset UTF-16 UTF_16
alias UTF_16 # JDK historical
alias utf16
diff --git a/jdk/src/share/classes/sun/print/PSPrinterJob.java b/jdk/src/share/classes/sun/print/PSPrinterJob.java
index 722537ea571..d4a0ffacb20 100644
--- a/jdk/src/share/classes/sun/print/PSPrinterJob.java
+++ b/jdk/src/share/classes/sun/print/PSPrinterJob.java
@@ -68,14 +68,18 @@ import javax.print.attribute.standard.Sides;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
import java.io.CharConversionException;
import java.io.File;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Enumeration;
@@ -673,15 +677,38 @@ public class PSPrinterJob extends RasterPrinterJob {
private class PrinterSpooler implements java.security.PrivilegedAction {
PrinterException pex;
+ private void handleProcessFailure(final Process failedProcess,
+ final String[] execCmd, final int result) throws IOException {
+ try (StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw)) {
+ pw.append("error=").append(Integer.toString(result));
+ pw.append(" running:");
+ for (String arg: execCmd) {
+ pw.append(" '").append(arg).append("'");
+ }
+ try (InputStream is = failedProcess.getErrorStream();
+ InputStreamReader isr = new InputStreamReader(is);
+ BufferedReader br = new BufferedReader(isr)) {
+ while (br.ready()) {
+ pw.println();
+ pw.append("\t\t").append(br.readLine());
+ }
+ } finally {
+ pw.flush();
+ throw new IOException(sw.toString());
+ }
+ }
+ }
+
public Object run() {
+ if (spoolFile == null || !spoolFile.exists()) {
+ pex = new PrinterException("No spool file");
+ return null;
+ }
try {
/**
* Spool to the printer.
*/
- if (spoolFile == null || !spoolFile.exists()) {
- pex = new PrinterException("No spool file");
- return null;
- }
String fileName = spoolFile.getAbsolutePath();
String execCmd[] = printExecCmd(mDestination, mOptions,
mNoJobSheet, getJobNameInt(),
@@ -689,12 +716,16 @@ public class PSPrinterJob extends RasterPrinterJob {
Process process = Runtime.getRuntime().exec(execCmd);
process.waitFor();
- spoolFile.delete();
-
+ final int result = process.exitValue();
+ if (0 != result) {
+ handleProcessFailure(process, execCmd, result);
+ }
} catch (IOException ex) {
pex = new PrinterIOException(ex);
} catch (InterruptedException ie) {
pex = new PrinterException(ie.toString());
+ } finally {
+ spoolFile.delete();
}
return null;
}
diff --git a/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java b/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java
index 4878609c088..db18eb3364d 100644
--- a/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java
+++ b/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java
@@ -38,13 +38,23 @@ import java.rmi.server.ServerNotActiveException;
import java.rmi.registry.Registry;
import java.rmi.server.RMIClientSocketFactory;
import java.rmi.server.RMIServerSocketFactory;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.CodeSource;
+import java.security.Policy;
import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.ProtectionDomain;
import java.text.MessageFormat;
+import sun.rmi.server.LoaderHandler;
import sun.rmi.server.UnicastServerRef;
import sun.rmi.server.UnicastServerRef2;
import sun.rmi.transport.LiveRef;
import sun.rmi.transport.ObjectTable;
import sun.rmi.transport.Target;
+import sun.security.action.GetPropertyAction;
/**
* A "registry" exists on every node that allows RMI connections to
@@ -325,6 +335,19 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
URL[] urls = sun.misc.URLClassPath.pathToURLs(envcp);
ClassLoader cl = new URLClassLoader(urls);
+ String codebaseProperty = null;
+ String prop = java.security.AccessController.doPrivileged(
+ new GetPropertyAction("java.rmi.server.codebase"));
+ if (prop != null && prop.trim().length() > 0) {
+ codebaseProperty = prop;
+ }
+ URL[] codebaseURLs = null;
+ if (codebaseProperty != null) {
+ codebaseURLs = sun.misc.URLClassPath.pathToURLs(codebaseProperty);
+ } else {
+ codebaseURLs = new URL[0];
+ }
+
/*
* Fix bugid 4242317: Classes defined by this class loader should
* be annotated with the value of the "java.rmi.server.codebase"
@@ -334,11 +357,19 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
Thread.currentThread().setContextClassLoader(cl);
- int regPort = Registry.REGISTRY_PORT;
- if (args.length >= 1) {
- regPort = Integer.parseInt(args[0]);
+ final int regPort = (args.length >= 1) ? Integer.parseInt(args[0])
+ : Registry.REGISTRY_PORT;
+ try {
+ registry = AccessController.doPrivileged(
+ new PrivilegedExceptionAction() {
+ public RegistryImpl run() throws RemoteException {
+ return new RegistryImpl(regPort);
+ }
+ }, getAccessControlContext(codebaseURLs));
+ } catch (PrivilegedActionException ex) {
+ throw (RemoteException) ex.getException();
}
- registry = new RegistryImpl(regPort);
+
// prevent registry from exiting
while (true) {
try {
@@ -358,4 +389,48 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
}
System.exit(1);
}
+
+ /**
+ * Generates an AccessControlContext from several URLs.
+ * The approach used here is taken from the similar method
+ * getAccessControlContext() in the sun.applet.AppletPanel class.
+ */
+ private static AccessControlContext getAccessControlContext(URL[] urls) {
+ // begin with permissions granted to all code in current policy
+ PermissionCollection perms = AccessController.doPrivileged(
+ new java.security.PrivilegedAction() {
+ public PermissionCollection run() {
+ CodeSource codesource = new CodeSource(null,
+ (java.security.cert.Certificate[]) null);
+ Policy p = java.security.Policy.getPolicy();
+ if (p != null) {
+ return p.getPermissions(codesource);
+ } else {
+ return new Permissions();
+ }
+ }
+ });
+
+ /*
+ * Anyone can connect to the registry and the registry can connect
+ * to and possibly download stubs from anywhere. Downloaded stubs and
+ * related classes themselves are more tightly limited by RMI.
+ */
+ perms.add(new SocketPermission("*", "connect,accept"));
+
+ perms.add(new RuntimePermission("accessClassInPackage.sun.*"));
+
+ // add permissions required to load from codebase URL path
+ LoaderHandler.addPermissionsForURLs(urls, perms, false);
+
+ /*
+ * Create an AccessControlContext that consists of a single
+ * protection domain with only the permissions calculated above.
+ */
+ ProtectionDomain pd = new ProtectionDomain(
+ new CodeSource((urls.length > 0 ? urls[0] : null),
+ (java.security.cert.Certificate[]) null),
+ perms);
+ return new AccessControlContext(new ProtectionDomain[] { pd });
+ }
}
diff --git a/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java b/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java
index 541c7840e08..52d9ee55172 100644
--- a/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java
+++ b/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java
@@ -1031,9 +1031,9 @@ public final class LoaderHandler {
* loader. A given permission is only added to the collection if
* it is not already implied by the collection.
*/
- private static void addPermissionsForURLs(URL[] urls,
- PermissionCollection perms,
- boolean forLoader)
+ public static void addPermissionsForURLs(URL[] urls,
+ PermissionCollection perms,
+ boolean forLoader)
{
for (int i = 0; i < urls.length; i++) {
URL url = urls[i];
diff --git a/jdk/src/share/classes/sun/rmi/server/MarshalInputStream.java b/jdk/src/share/classes/sun/rmi/server/MarshalInputStream.java
index b67e72b9108..cb32017b4ad 100644
--- a/jdk/src/share/classes/sun/rmi/server/MarshalInputStream.java
+++ b/jdk/src/share/classes/sun/rmi/server/MarshalInputStream.java
@@ -109,14 +109,6 @@ public class MarshalInputStream extends ObjectInputStream {
}
}
- /**
- * Load the "rmi" native library.
- */
- static {
- java.security.AccessController.doPrivileged(
- new sun.security.action.LoadLibraryAction("rmi"));
- }
-
/**
* Create a new MarshalInputStream object.
*/
@@ -262,7 +254,9 @@ public class MarshalInputStream extends ObjectInputStream {
* Returns the first non-null class loader up the execution stack, or null
* if only code from the null class loader is on the stack.
*/
- private static native ClassLoader latestUserDefinedLoader();
+ private static ClassLoader latestUserDefinedLoader() {
+ return sun.misc.VM.latestUserDefinedLoader();
+ }
/**
* Fix for 4179055: Need to assist resolving sun stubs; resolve
diff --git a/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java b/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java
index 9a0c1afb578..fe199a23137 100644
--- a/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java
+++ b/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java
@@ -390,6 +390,12 @@ public class UnicastServerRef extends UnicastRef
ObjectInput in;
try {
in = call.getInputStream();
+ try {
+ Class> clazz = Class.forName("sun.rmi.transport.DGCImpl_Skel");
+ if (clazz.isAssignableFrom(skel.getClass())) {
+ ((MarshalInputStream)in).useCodebaseOnly();
+ }
+ } catch (ClassNotFoundException ignore) { }
hash = in.readLong();
} catch (Exception readEx) {
throw new UnmarshalException("error unmarshalling call header",
diff --git a/jdk/src/share/classes/sun/security/pkcs/PKCS7.java b/jdk/src/share/classes/sun/security/pkcs/PKCS7.java
index 4cdf35dba0e..a3198784729 100644
--- a/jdk/src/share/classes/sun/security/pkcs/PKCS7.java
+++ b/jdk/src/share/classes/sun/security/pkcs/PKCS7.java
@@ -27,6 +27,7 @@ package sun.security.pkcs;
import java.io.*;
import java.math.BigInteger;
+import java.net.URI;
import java.util.*;
import java.security.cert.X509Certificate;
import java.security.cert.CertificateException;
@@ -35,6 +36,7 @@ import java.security.cert.CRLException;
import java.security.cert.CertificateFactory;
import java.security.*;
+import sun.security.timestamp.*;
import sun.security.util.*;
import sun.security.x509.AlgorithmId;
import sun.security.x509.CertificateIssuerName;
@@ -68,6 +70,30 @@ public class PKCS7 {
private Principal[] certIssuerNames;
+ /*
+ * Random number generator for creating nonce values
+ */
+ private static final SecureRandom RANDOM;
+ static {
+ SecureRandom tmp = null;
+ try {
+ tmp = SecureRandom.getInstance("SHA1PRNG");
+ } catch (NoSuchAlgorithmException e) {
+ // should not happen
+ }
+ RANDOM = tmp;
+ }
+
+ /*
+ * Object identifier for the timestamping key purpose.
+ */
+ private static final String KP_TIMESTAMPING_OID = "1.3.6.1.5.5.7.3.8";
+
+ /*
+ * Object identifier for extendedKeyUsage extension
+ */
+ private static final String EXTENDED_KEY_USAGE_OID = "2.5.29.37";
+
/**
* Unmarshals a PKCS7 block from its encoded form, parsing the
* encoded bytes from the InputStream.
@@ -733,4 +759,164 @@ public class PKCS7 {
public boolean isOldStyle() {
return this.oldStyle;
}
+
+ /**
+ * Assembles a PKCS #7 signed data message that optionally includes a
+ * signature timestamp.
+ *
+ * @param signature the signature bytes
+ * @param signerChain the signer's X.509 certificate chain
+ * @param content the content that is signed; specify null to not include
+ * it in the PKCS7 data
+ * @param signatureAlgorithm the name of the signature algorithm
+ * @param tsaURI the URI of the Timestamping Authority; or null if no
+ * timestamp is requested
+ * @return the bytes of the encoded PKCS #7 signed data message
+ * @throws NoSuchAlgorithmException The exception is thrown if the signature
+ * algorithm is unrecognised.
+ * @throws CertificateException The exception is thrown if an error occurs
+ * while processing the signer's certificate or the TSA's
+ * certificate.
+ * @throws IOException The exception is thrown if an error occurs while
+ * generating the signature timestamp or while generating the signed
+ * data message.
+ */
+ public static byte[] generateSignedData(byte[] signature,
+ X509Certificate[] signerChain,
+ byte[] content,
+ String signatureAlgorithm,
+ URI tsaURI)
+ throws CertificateException, IOException, NoSuchAlgorithmException
+ {
+
+ // Generate the timestamp token
+ PKCS9Attributes unauthAttrs = null;
+ if (tsaURI != null) {
+ // Timestamp the signature
+ HttpTimestamper tsa = new HttpTimestamper(tsaURI);
+ byte[] tsToken = generateTimestampToken(tsa, signature);
+
+ // Insert the timestamp token into the PKCS #7 signer info element
+ // (as an unsigned attribute)
+ unauthAttrs =
+ new PKCS9Attributes(new PKCS9Attribute[]{
+ new PKCS9Attribute(
+ PKCS9Attribute.SIGNATURE_TIMESTAMP_TOKEN_STR,
+ tsToken)});
+ }
+
+ // Create the SignerInfo
+ X500Name issuerName =
+ X500Name.asX500Name(signerChain[0].getIssuerX500Principal());
+ BigInteger serialNumber = signerChain[0].getSerialNumber();
+ String encAlg = AlgorithmId.getEncAlgFromSigAlg(signatureAlgorithm);
+ String digAlg = AlgorithmId.getDigAlgFromSigAlg(signatureAlgorithm);
+ SignerInfo signerInfo = new SignerInfo(issuerName, serialNumber,
+ AlgorithmId.get(digAlg), null,
+ AlgorithmId.get(encAlg),
+ signature, unauthAttrs);
+
+ // Create the PKCS #7 signed data message
+ SignerInfo[] signerInfos = {signerInfo};
+ AlgorithmId[] algorithms = {signerInfo.getDigestAlgorithmId()};
+ // Include or exclude content
+ ContentInfo contentInfo = (content == null)
+ ? new ContentInfo(ContentInfo.DATA_OID, null)
+ : new ContentInfo(content);
+ PKCS7 pkcs7 = new PKCS7(algorithms, contentInfo,
+ signerChain, signerInfos);
+ ByteArrayOutputStream p7out = new ByteArrayOutputStream();
+ pkcs7.encodeSignedData(p7out);
+
+ return p7out.toByteArray();
+ }
+
+ /**
+ * Requests, processes and validates a timestamp token from a TSA using
+ * common defaults. Uses the following defaults in the timestamp request:
+ * SHA-1 for the hash algorithm, a 64-bit nonce, and request certificate
+ * set to true.
+ *
+ * @param tsa the timestamping authority to use
+ * @param toBeTimestamped the token that is to be timestamped
+ * @return the encoded timestamp token
+ * @throws IOException The exception is thrown if an error occurs while
+ * communicating with the TSA.
+ * @throws CertificateException The exception is thrown if the TSA's
+ * certificate is not permitted for timestamping.
+ */
+ private static byte[] generateTimestampToken(Timestamper tsa,
+ byte[] toBeTimestamped)
+ throws IOException, CertificateException
+ {
+ // Generate a timestamp
+ MessageDigest messageDigest = null;
+ TSRequest tsQuery = null;
+ try {
+ // SHA-1 is always used.
+ messageDigest = MessageDigest.getInstance("SHA-1");
+ tsQuery = new TSRequest(toBeTimestamped, messageDigest);
+ } catch (NoSuchAlgorithmException e) {
+ // ignore
+ }
+
+ // Generate a nonce
+ BigInteger nonce = null;
+ if (RANDOM != null) {
+ nonce = new BigInteger(64, RANDOM);
+ tsQuery.setNonce(nonce);
+ }
+ tsQuery.requestCertificate(true);
+
+ TSResponse tsReply = tsa.generateTimestamp(tsQuery);
+ int status = tsReply.getStatusCode();
+ // Handle TSP error
+ if (status != 0 && status != 1) {
+ throw new IOException("Error generating timestamp: " +
+ tsReply.getStatusCodeAsText() + " " +
+ tsReply.getFailureCodeAsText());
+ }
+ PKCS7 tsToken = tsReply.getToken();
+
+ TimestampToken tst = tsReply.getTimestampToken();
+ if (!tst.getHashAlgorithm().getName().equals("SHA")) {
+ throw new IOException("Digest algorithm not SHA-1 in "
+ + "timestamp token");
+ }
+ if (!MessageDigest.isEqual(tst.getHashedMessage(),
+ tsQuery.getHashedMessage())) {
+ throw new IOException("Digest octets changed in timestamp token");
+ }
+
+ BigInteger replyNonce = tst.getNonce();
+ if (replyNonce == null && nonce != null) {
+ throw new IOException("Nonce missing in timestamp token");
+ }
+ if (replyNonce != null && !replyNonce.equals(nonce)) {
+ throw new IOException("Nonce changed in timestamp token");
+ }
+
+ // Examine the TSA's certificate (if present)
+ for (SignerInfo si: tsToken.getSignerInfos()) {
+ X509Certificate cert = si.getCertificate(tsToken);
+ if (cert == null) {
+ // Error, we've already set tsRequestCertificate = true
+ throw new CertificateException(
+ "Certificate not included in timestamp token");
+ } else {
+ if (!cert.getCriticalExtensionOIDs().contains(
+ EXTENDED_KEY_USAGE_OID)) {
+ throw new CertificateException(
+ "Certificate is not valid for timestamping");
+ }
+ List keyPurposes = cert.getExtendedKeyUsage();
+ if (keyPurposes == null ||
+ !keyPurposes.contains(KP_TIMESTAMPING_OID)) {
+ throw new CertificateException(
+ "Certificate is not valid for timestamping");
+ }
+ }
+ }
+ return tsReply.getEncodedToken();
+ }
}
diff --git a/jdk/src/share/classes/sun/security/pkcs/SignerInfo.java b/jdk/src/share/classes/sun/security/pkcs/SignerInfo.java
index c04b05ffdec..1d327706d78 100644
--- a/jdk/src/share/classes/sun/security/pkcs/SignerInfo.java
+++ b/jdk/src/share/classes/sun/security/pkcs/SignerInfo.java
@@ -28,10 +28,14 @@ package sun.security.pkcs;
import java.io.OutputStream;
import java.io.IOException;
import java.math.BigInteger;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.CertPath;
import java.security.cert.X509Certificate;
import java.security.*;
import java.util.ArrayList;
+import sun.security.timestamp.TimestampToken;
import sun.security.util.*;
import sun.security.x509.AlgorithmId;
import sun.security.x509.X500Name;
@@ -51,6 +55,8 @@ public class SignerInfo implements DerEncoder {
AlgorithmId digestAlgorithmId;
AlgorithmId digestEncryptionAlgorithmId;
byte[] encryptedDigest;
+ Timestamp timestamp;
+ private boolean hasTimestamp = true;
PKCS9Attributes authenticatedAttributes;
PKCS9Attributes unauthenticatedAttributes;
@@ -442,6 +448,62 @@ public class SignerInfo implements DerEncoder {
return unauthenticatedAttributes;
}
+ /*
+ * Extracts a timestamp from a PKCS7 SignerInfo.
+ *
+ * Examines the signer's unsigned attributes for a
+ * signatureTimestampToken attribute. If present,
+ * then it is parsed to extract the date and time at which the
+ * timestamp was generated.
+ *
+ * @param info A signer information element of a PKCS 7 block.
+ *
+ * @return A timestamp token or null if none is present.
+ * @throws IOException if an error is encountered while parsing the
+ * PKCS7 data.
+ * @throws NoSuchAlgorithmException if an error is encountered while
+ * verifying the PKCS7 object.
+ * @throws SignatureException if an error is encountered while
+ * verifying the PKCS7 object.
+ * @throws CertificateException if an error is encountered while generating
+ * the TSA's certpath.
+ */
+ public Timestamp getTimestamp()
+ throws IOException, NoSuchAlgorithmException, SignatureException,
+ CertificateException
+ {
+ if (timestamp != null || !hasTimestamp)
+ return timestamp;
+
+ if (unauthenticatedAttributes == null) {
+ hasTimestamp = false;
+ return null;
+ }
+ PKCS9Attribute tsTokenAttr =
+ unauthenticatedAttributes.getAttribute(
+ PKCS9Attribute.SIGNATURE_TIMESTAMP_TOKEN_OID);
+ if (tsTokenAttr == null) {
+ hasTimestamp = false;
+ return null;
+ }
+
+ PKCS7 tsToken = new PKCS7((byte[])tsTokenAttr.getValue());
+ // Extract the content (an encoded timestamp token info)
+ byte[] encTsTokenInfo = tsToken.getContentInfo().getData();
+ // Extract the signer (the Timestamping Authority)
+ // while verifying the content
+ SignerInfo[] tsa = tsToken.verify(encTsTokenInfo);
+ // Expect only one signer
+ ArrayList chain = tsa[0].getCertificateChain(tsToken);
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ CertPath tsaChain = cf.generateCertPath(chain);
+ // Create a timestamp token info object
+ TimestampToken tsTokenInfo = new TimestampToken(encTsTokenInfo);
+ // Create a timestamp object
+ timestamp = new Timestamp(tsTokenInfo.getDate(), tsaChain);
+ return timestamp;
+ }
+
public String toString() {
HexDumpEncoder hexDump = new HexDumpEncoder();
@@ -467,5 +529,4 @@ public class SignerInfo implements DerEncoder {
}
return out;
}
-
}
diff --git a/jdk/src/share/classes/sun/security/pkcs/PKCS10.java b/jdk/src/share/classes/sun/security/pkcs10/PKCS10.java
similarity index 99%
rename from jdk/src/share/classes/sun/security/pkcs/PKCS10.java
rename to jdk/src/share/classes/sun/security/pkcs10/PKCS10.java
index 6303c8b9adf..c5418c67d07 100644
--- a/jdk/src/share/classes/sun/security/pkcs/PKCS10.java
+++ b/jdk/src/share/classes/sun/security/pkcs10/PKCS10.java
@@ -24,7 +24,7 @@
*/
-package sun.security.pkcs;
+package sun.security.pkcs10;
import java.io.PrintStream;
import java.io.IOException;
diff --git a/jdk/src/share/classes/sun/security/pkcs/PKCS10Attribute.java b/jdk/src/share/classes/sun/security/pkcs10/PKCS10Attribute.java
similarity index 97%
rename from jdk/src/share/classes/sun/security/pkcs/PKCS10Attribute.java
rename to jdk/src/share/classes/sun/security/pkcs10/PKCS10Attribute.java
index a83813157b0..c7cac3baa25 100644
--- a/jdk/src/share/classes/sun/security/pkcs/PKCS10Attribute.java
+++ b/jdk/src/share/classes/sun/security/pkcs10/PKCS10Attribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,11 +23,12 @@
* questions.
*/
-package sun.security.pkcs;
+package sun.security.pkcs10;
import java.io.OutputStream;
import java.io.IOException;
+import sun.security.pkcs.PKCS9Attribute;
import sun.security.util.*;
/**
diff --git a/jdk/src/share/classes/sun/security/pkcs/PKCS10Attributes.java b/jdk/src/share/classes/sun/security/pkcs10/PKCS10Attributes.java
similarity index 98%
rename from jdk/src/share/classes/sun/security/pkcs/PKCS10Attributes.java
rename to jdk/src/share/classes/sun/security/pkcs10/PKCS10Attributes.java
index 8279ae237eb..d35f3a7fe29 100644
--- a/jdk/src/share/classes/sun/security/pkcs/PKCS10Attributes.java
+++ b/jdk/src/share/classes/sun/security/pkcs10/PKCS10Attributes.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
* questions.
*/
-package sun.security.pkcs;
+package sun.security.pkcs10;
import java.io.IOException;
import java.io.OutputStream;
diff --git a/jdk/src/share/classes/sun/security/pkcs11/Config.java b/jdk/src/share/classes/sun/security/pkcs11/Config.java
index dbed2cf8f4c..08cb6de40c9 100644
--- a/jdk/src/share/classes/sun/security/pkcs11/Config.java
+++ b/jdk/src/share/classes/sun/security/pkcs11/Config.java
@@ -192,6 +192,11 @@ final class Config {
// works only for NSS providers created via the Secmod API
private boolean nssUseSecmodTrust = false;
+ // Flag to indicate whether the X9.63 encoding for EC points shall be used
+ // (true) or whether that encoding shall be wrapped in an ASN.1 OctetString
+ // (false).
+ private boolean useEcX963Encoding = false;
+
private Config(String filename, InputStream in) throws IOException {
if (in == null) {
if (filename.startsWith("--")) {
@@ -320,6 +325,10 @@ final class Config {
return nssUseSecmodTrust;
}
+ boolean getUseEcX963Encoding() {
+ return useEcX963Encoding;
+ }
+
private static String expand(final String s) throws IOException {
try {
return PropertyExpander.expand(s);
@@ -440,6 +449,8 @@ final class Config {
parseNSSArgs(word);
} else if (word.equals("nssUseSecmodTrust")) {
nssUseSecmodTrust = parseBooleanEntry(word);
+ } else if (word.equals("useEcX963Encoding")) {
+ useEcX963Encoding = parseBooleanEntry(word);
} else {
throw new ConfigurationException
("Unknown keyword '" + word + "', line " + st.lineno());
diff --git a/jdk/src/share/classes/sun/security/pkcs11/KeyCache.java b/jdk/src/share/classes/sun/security/pkcs11/KeyCache.java
index 359156f7dc9..1687649e10e 100644
--- a/jdk/src/share/classes/sun/security/pkcs11/KeyCache.java
+++ b/jdk/src/share/classes/sun/security/pkcs11/KeyCache.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -48,7 +48,7 @@ import sun.security.util.Cache;
*/
final class KeyCache {
- private final Cache strongCache;
+ private final Cache strongCache;
private WeakReference> cacheReference;
@@ -77,7 +77,7 @@ final class KeyCache {
}
synchronized P11Key get(Key key) {
- P11Key p11Key = (P11Key)strongCache.get(new IdentityWrapper(key));
+ P11Key p11Key = strongCache.get(new IdentityWrapper(key));
if (p11Key != null) {
return p11Key;
}
@@ -94,8 +94,8 @@ final class KeyCache {
Map map =
(cacheReference == null) ? null : cacheReference.get();
if (map == null) {
- map = new IdentityHashMap();
- cacheReference = new WeakReference>(map);
+ map = new IdentityHashMap<>();
+ cacheReference = new WeakReference<>(map);
}
map.put(key, p11Key);
}
diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java b/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java
index d44231a6bf2..ef6cf3a1ef5 100644
--- a/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java
@@ -203,14 +203,20 @@ final class P11ECKeyFactory extends P11KeyFactory {
private PublicKey generatePublic(ECPoint point, ECParameterSpec params) throws PKCS11Exception {
byte[] encodedParams = ECParameters.encodeParameters(params);
- byte[] encodedPoint = null;
- DerValue pkECPoint = new DerValue(DerValue.tag_OctetString,
- ECParameters.encodePoint(point, params.getCurve()));
+ byte[] encodedPoint =
+ ECParameters.encodePoint(point, params.getCurve());
- try {
- encodedPoint = pkECPoint.toByteArray();
- } catch (IOException e) {
- throw new IllegalArgumentException("Could not DER encode point", e);
+ // Check whether the X9.63 encoding of an EC point shall be wrapped
+ // in an ASN.1 OCTET STRING
+ if (!token.config.getUseEcX963Encoding()) {
+ try {
+ encodedPoint =
+ new DerValue(DerValue.tag_OctetString, encodedPoint)
+ .toByteArray();
+ } catch (IOException e) {
+ throw new
+ IllegalArgumentException("Could not DER encode point", e);
+ }
}
CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11Key.java b/jdk/src/share/classes/sun/security/pkcs11/P11Key.java
index 54ccd3213c2..bbce8982e90 100644
--- a/jdk/src/share/classes/sun/security/pkcs11/P11Key.java
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11Key.java
@@ -1028,28 +1028,21 @@ abstract class P11Key implements Key {
try {
params = P11ECKeyFactory.decodeParameters
(attributes[1].getByteArray());
-
- /*
- * An uncompressed EC point may be in either of two formats.
- * First try the OCTET STRING encoding:
- * 04 04
- *
- * Otherwise try the raw encoding:
- * 04
- */
byte[] ecKey = attributes[0].getByteArray();
- try {
+ // Check whether the X9.63 encoding of an EC point is wrapped
+ // in an ASN.1 OCTET STRING
+ if (!token.config.getUseEcX963Encoding()) {
DerValue wECPoint = new DerValue(ecKey);
- if (wECPoint.getTag() != DerValue.tag_OctetString)
- throw new IOException("Unexpected tag: " +
- wECPoint.getTag());
+ if (wECPoint.getTag() != DerValue.tag_OctetString) {
+ throw new IOException("Could not DER decode EC point." +
+ " Unexpected tag: " + wECPoint.getTag());
+ }
w = P11ECKeyFactory.decodePoint
(wECPoint.getDataBytes(), params.getCurve());
- } catch (IOException e) {
- // Failover
+ } else {
w = P11ECKeyFactory.decodePoint(ecKey, params.getCurve());
}
diff --git a/jdk/src/share/classes/sun/security/provider/X509Factory.java b/jdk/src/share/classes/sun/security/provider/X509Factory.java
index 0260ff5c7bf..28b7aa55666 100644
--- a/jdk/src/share/classes/sun/security/provider/X509Factory.java
+++ b/jdk/src/share/classes/sun/security/provider/X509Factory.java
@@ -64,8 +64,10 @@ public class X509Factory extends CertificateFactorySpi {
private static final int ENC_MAX_LENGTH = 4096 * 1024; // 4 MB MAX
- private static final Cache certCache = Cache.newSoftMemoryCache(750);
- private static final Cache crlCache = Cache.newSoftMemoryCache(750);
+ private static final Cache certCache
+ = Cache.newSoftMemoryCache(750);
+ private static final Cache crlCache
+ = Cache.newSoftMemoryCache(750);
/**
* Generates an X.509 certificate object and initializes it with
@@ -90,7 +92,7 @@ public class X509Factory extends CertificateFactorySpi {
try {
byte[] encoding = readOneBlock(is);
if (encoding != null) {
- X509CertImpl cert = (X509CertImpl)getFromCache(certCache, encoding);
+ X509CertImpl cert = getFromCache(certCache, encoding);
if (cert != null) {
return cert;
}
@@ -151,7 +153,7 @@ public class X509Factory extends CertificateFactorySpi {
} else {
encoding = c.getEncoded();
}
- X509CertImpl newC = (X509CertImpl)getFromCache(certCache, encoding);
+ X509CertImpl newC = getFromCache(certCache, encoding);
if (newC != null) {
return newC;
}
@@ -181,7 +183,7 @@ public class X509Factory extends CertificateFactorySpi {
} else {
encoding = c.getEncoded();
}
- X509CRLImpl newC = (X509CRLImpl)getFromCache(crlCache, encoding);
+ X509CRLImpl newC = getFromCache(crlCache, encoding);
if (newC != null) {
return newC;
}
@@ -198,18 +200,17 @@ public class X509Factory extends CertificateFactorySpi {
/**
* Get the X509CertImpl or X509CRLImpl from the cache.
*/
- private static synchronized Object getFromCache(Cache cache,
+ private static synchronized V getFromCache(Cache cache,
byte[] encoding) {
Object key = new Cache.EqualByteArray(encoding);
- Object value = cache.get(key);
- return value;
+ return cache.get(key);
}
/**
* Add the X509CertImpl or X509CRLImpl to the cache.
*/
- private static synchronized void addToCache(Cache cache, byte[] encoding,
- Object value) {
+ private static synchronized void addToCache(Cache cache,
+ byte[] encoding, V value) {
if (encoding.length > ENC_MAX_LENGTH) {
return;
}
@@ -361,7 +362,7 @@ public class X509Factory extends CertificateFactorySpi {
try {
byte[] encoding = readOneBlock(is);
if (encoding != null) {
- X509CRLImpl crl = (X509CRLImpl)getFromCache(crlCache, encoding);
+ X509CRLImpl crl = getFromCache(crlCache, encoding);
if (crl != null) {
return crl;
}
@@ -669,6 +670,23 @@ public class X509Factory extends CertificateFactorySpi {
bout.write(midByte);
bout.write(lowByte);
length = (highByte << 16) | (midByte << 8) | lowByte;
+ } else if (n == 0x84) {
+ int highByte = is.read();
+ int nextByte = is.read();
+ int midByte = is.read();
+ int lowByte = is.read();
+ if (lowByte == -1) {
+ throw new IOException("Incomplete BER/DER length info");
+ }
+ if (highByte > 127) {
+ throw new IOException("Invalid BER/DER data (a little huge?)");
+ }
+ bout.write(highByte);
+ bout.write(nextByte);
+ bout.write(midByte);
+ bout.write(lowByte);
+ length = (highByte << 24 ) | (nextByte << 16) |
+ (midByte << 8) | lowByte;
} else { // ignore longer length forms
throw new IOException("Invalid BER/DER data (too huge?)");
}
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/CertStoreHelper.java b/jdk/src/share/classes/sun/security/provider/certpath/CertStoreHelper.java
index 891919a4bb1..8670778ee7e 100644
--- a/jdk/src/share/classes/sun/security/provider/certpath/CertStoreHelper.java
+++ b/jdk/src/share/classes/sun/security/provider/certpath/CertStoreHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, 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
@@ -27,32 +27,87 @@ package sun.security.provider.certpath;
import java.net.URI;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.security.AccessController;
import java.security.NoSuchAlgorithmException;
import java.security.InvalidAlgorithmParameterException;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.security.cert.CertStore;
import java.security.cert.X509CertSelector;
import java.security.cert.X509CRLSelector;
import javax.security.auth.x500.X500Principal;
import java.io.IOException;
+import sun.security.util.Cache;
+
/**
- * Helper used by URICertStore when delegating to another CertStore to
- * fetch certs and CRLs.
+ * Helper used by URICertStore and others when delegating to another CertStore
+ * to fetch certs and CRLs.
*/
-public interface CertStoreHelper {
+public abstract class CertStoreHelper {
+
+ private static final int NUM_TYPES = 2;
+ private final static Map classMap = new HashMap<>(NUM_TYPES);
+ static {
+ classMap.put(
+ "LDAP",
+ "sun.security.provider.certpath.ldap.LDAPCertStoreHelper");
+ classMap.put(
+ "SSLServer",
+ "sun.security.provider.certpath.ssl.SSLServerCertStoreHelper");
+ };
+ private static Cache cache
+ = Cache.newSoftMemoryCache(NUM_TYPES);
+
+ public static CertStoreHelper getInstance(final String type)
+ throws NoSuchAlgorithmException
+ {
+ CertStoreHelper helper = cache.get(type);
+ if (helper != null) {
+ return helper;
+ }
+ final String cl = classMap.get(type);
+ if (cl == null) {
+ throw new NoSuchAlgorithmException(type + " not available");
+ }
+ try {
+ helper = AccessController.doPrivileged(
+ new PrivilegedExceptionAction() {
+ public CertStoreHelper run() throws ClassNotFoundException {
+ try {
+ Class> c = Class.forName(cl, true, null);
+ CertStoreHelper csh
+ = (CertStoreHelper)c.newInstance();
+ cache.put(type, csh);
+ return csh;
+ } catch (InstantiationException e) {
+ throw new AssertionError(e);
+ } catch (IllegalAccessException e) {
+ throw new AssertionError(e);
+ }
+ }
+ });
+ return helper;
+ } catch (PrivilegedActionException e) {
+ throw new NoSuchAlgorithmException(type + " not available",
+ e.getException());
+ }
+ }
/**
* Returns a CertStore using the given URI as parameters.
*/
- CertStore getCertStore(URI uri)
+ public abstract CertStore getCertStore(URI uri)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException;
/**
* Wraps an existing X509CertSelector when needing to avoid DN matching
* issues.
*/
- X509CertSelector wrap(X509CertSelector selector,
+ public abstract X509CertSelector wrap(X509CertSelector selector,
X500Principal certSubject,
String dn)
throws IOException;
@@ -61,7 +116,7 @@ public interface CertStoreHelper {
* Wraps an existing X509CRLSelector when needing to avoid DN matching
* issues.
*/
- X509CRLSelector wrap(X509CRLSelector selector,
+ public abstract X509CRLSelector wrap(X509CRLSelector selector,
Collection certIssuers,
String dn)
throws IOException;
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/URICertStore.java b/jdk/src/share/classes/sun/security/provider/certpath/URICertStore.java
index 321f9153ec3..6fb7bc72af3 100644
--- a/jdk/src/share/classes/sun/security/provider/certpath/URICertStore.java
+++ b/jdk/src/share/classes/sun/security/provider/certpath/URICertStore.java
@@ -30,8 +30,6 @@ import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URLConnection;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
@@ -102,8 +100,7 @@ class URICertStore extends CertStoreSpi {
private final CertificateFactory factory;
// cached Collection of X509Certificates (may be empty, never null)
- private Collection certs =
- Collections.emptySet();
+ private Collection certs = Collections.emptySet();
// cached X509CRL (may be null)
private X509CRL crl;
@@ -120,35 +117,10 @@ class URICertStore extends CertStoreSpi {
// true if URI is ldap
private boolean ldap = false;
+ private CertStoreHelper ldapHelper;
private CertStore ldapCertStore;
private String ldapPath;
- /**
- * Holder class to lazily load LDAPCertStoreHelper if present.
- */
- private static class LDAP {
- private static final String CERT_STORE_HELPER =
- "sun.security.provider.certpath.ldap.LDAPCertStoreHelper";
- private static final CertStoreHelper helper =
- AccessController.doPrivileged(
- new PrivilegedAction() {
- public CertStoreHelper run() {
- try {
- Class> c = Class.forName(CERT_STORE_HELPER, true, null);
- return (CertStoreHelper)c.newInstance();
- } catch (ClassNotFoundException cnf) {
- return null;
- } catch (InstantiationException e) {
- throw new AssertionError(e);
- } catch (IllegalAccessException e) {
- throw new AssertionError(e);
- }
- }});
- static CertStoreHelper helper() {
- return helper;
- }
- }
-
/**
* Creates a URICertStore.
*
@@ -164,10 +136,9 @@ class URICertStore extends CertStoreSpi {
this.uri = ((URICertStoreParameters) params).uri;
// if ldap URI, use an LDAPCertStore to fetch certs and CRLs
if (uri.getScheme().toLowerCase(Locale.ENGLISH).equals("ldap")) {
- if (LDAP.helper() == null)
- throw new NoSuchAlgorithmException("LDAP not present");
ldap = true;
- ldapCertStore = LDAP.helper().getCertStore(uri);
+ ldapHelper = CertStoreHelper.getInstance("LDAP");
+ ldapCertStore = ldapHelper.getCertStore(uri);
ldapPath = uri.getPath();
// strip off leading '/'
if (ldapPath.charAt(0) == '/') {
@@ -185,14 +156,14 @@ class URICertStore extends CertStoreSpi {
* Returns a URI CertStore. This method consults a cache of
* CertStores (shared per JVM) using the URI as a key.
*/
- private static final Cache certStoreCache =
- Cache.newSoftMemoryCache(CACHE_SIZE);
+ private static final Cache
+ certStoreCache = Cache.newSoftMemoryCache(CACHE_SIZE);
static synchronized CertStore getInstance(URICertStoreParameters params)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
if (debug != null) {
debug.println("CertStore URI:" + params.uri);
}
- CertStore ucs = (CertStore) certStoreCache.get(params);
+ CertStore ucs = certStoreCache.get(params);
if (ucs == null) {
ucs = new UCS(new URICertStore(params), null, "URI", params);
certStoreCache.put(params, ucs);
@@ -251,7 +222,7 @@ class URICertStore extends CertStoreSpi {
if (ldap) {
X509CertSelector xsel = (X509CertSelector) selector;
try {
- xsel = LDAP.helper().wrap(xsel, xsel.getSubject(), ldapPath);
+ xsel = ldapHelper.wrap(xsel, xsel.getSubject(), ldapPath);
} catch (IOException ioe) {
throw new CertStoreException(ioe);
}
@@ -273,62 +244,49 @@ class URICertStore extends CertStoreSpi {
return getMatchingCerts(certs, selector);
}
lastChecked = time;
- InputStream in = null;
try {
URLConnection connection = uri.toURL().openConnection();
if (lastModified != 0) {
connection.setIfModifiedSince(lastModified);
}
- in = connection.getInputStream();
long oldLastModified = lastModified;
- lastModified = connection.getLastModified();
- if (oldLastModified != 0) {
- if (oldLastModified == lastModified) {
- if (debug != null) {
- debug.println("Not modified, using cached copy");
- }
- return getMatchingCerts(certs, selector);
- } else if (connection instanceof HttpURLConnection) {
- // some proxy servers omit last modified
- HttpURLConnection hconn = (HttpURLConnection) connection;
- if (hconn.getResponseCode()
- == HttpURLConnection.HTTP_NOT_MODIFIED) {
+ try (InputStream in = connection.getInputStream()) {
+ lastModified = connection.getLastModified();
+ if (oldLastModified != 0) {
+ if (oldLastModified == lastModified) {
if (debug != null) {
debug.println("Not modified, using cached copy");
}
return getMatchingCerts(certs, selector);
+ } else if (connection instanceof HttpURLConnection) {
+ // some proxy servers omit last modified
+ HttpURLConnection hconn = (HttpURLConnection)connection;
+ if (hconn.getResponseCode()
+ == HttpURLConnection.HTTP_NOT_MODIFIED) {
+ if (debug != null) {
+ debug.println("Not modified, using cached copy");
+ }
+ return getMatchingCerts(certs, selector);
+ }
}
}
- }
- if (debug != null) {
- debug.println("Downloading new certificates...");
- }
- // Safe cast since factory is an X.509 certificate factory
- certs = (Collection)
- factory.generateCertificates(in);
- return getMatchingCerts(certs, selector);
- } catch (IOException e) {
- if (debug != null) {
- debug.println("Exception fetching certificates:");
- e.printStackTrace();
- }
- } catch (CertificateException e) {
- if (debug != null) {
- debug.println("Exception fetching certificates:");
- e.printStackTrace();
- }
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- // ignore
+ if (debug != null) {
+ debug.println("Downloading new certificates...");
}
+ // Safe cast since factory is an X.509 certificate factory
+ certs = (Collection)
+ factory.generateCertificates(in);
+ }
+ return getMatchingCerts(certs, selector);
+ } catch (IOException | CertificateException e) {
+ if (debug != null) {
+ debug.println("Exception fetching certificates:");
+ e.printStackTrace();
}
}
// exception, forget previous values
lastModified = 0;
- certs = Collections.emptySet();
+ certs = Collections.emptySet();
return certs;
}
@@ -343,8 +301,7 @@ class URICertStore extends CertStoreSpi {
if (selector == null) {
return certs;
}
- List matchedCerts =
- new ArrayList(certs.size());
+ List matchedCerts = new ArrayList<>(certs.size());
for (X509Certificate cert : certs) {
if (selector.match(cert)) {
matchedCerts.add(cert);
@@ -374,7 +331,7 @@ class URICertStore extends CertStoreSpi {
if (ldap) {
X509CRLSelector xsel = (X509CRLSelector) selector;
try {
- xsel = LDAP.helper().wrap(xsel, null, ldapPath);
+ xsel = ldapHelper.wrap(xsel, null, ldapPath);
} catch (IOException ioe) {
throw new CertStoreException(ioe);
}
@@ -395,61 +352,48 @@ class URICertStore extends CertStoreSpi {
return getMatchingCRLs(crl, selector);
}
lastChecked = time;
- InputStream in = null;
try {
URLConnection connection = uri.toURL().openConnection();
if (lastModified != 0) {
connection.setIfModifiedSince(lastModified);
}
- in = connection.getInputStream();
long oldLastModified = lastModified;
- lastModified = connection.getLastModified();
- if (oldLastModified != 0) {
- if (oldLastModified == lastModified) {
- if (debug != null) {
- debug.println("Not modified, using cached copy");
- }
- return getMatchingCRLs(crl, selector);
- } else if (connection instanceof HttpURLConnection) {
- // some proxy servers omit last modified
- HttpURLConnection hconn = (HttpURLConnection) connection;
- if (hconn.getResponseCode()
- == HttpURLConnection.HTTP_NOT_MODIFIED) {
+ try (InputStream in = connection.getInputStream()) {
+ lastModified = connection.getLastModified();
+ if (oldLastModified != 0) {
+ if (oldLastModified == lastModified) {
if (debug != null) {
debug.println("Not modified, using cached copy");
}
return getMatchingCRLs(crl, selector);
+ } else if (connection instanceof HttpURLConnection) {
+ // some proxy servers omit last modified
+ HttpURLConnection hconn = (HttpURLConnection)connection;
+ if (hconn.getResponseCode()
+ == HttpURLConnection.HTTP_NOT_MODIFIED) {
+ if (debug != null) {
+ debug.println("Not modified, using cached copy");
+ }
+ return getMatchingCRLs(crl, selector);
+ }
}
}
- }
- if (debug != null) {
- debug.println("Downloading new CRL...");
- }
- crl = (X509CRL) factory.generateCRL(in);
- return getMatchingCRLs(crl, selector);
- } catch (IOException e) {
- if (debug != null) {
- debug.println("Exception fetching CRL:");
- e.printStackTrace();
- }
- } catch (CRLException e) {
- if (debug != null) {
- debug.println("Exception fetching CRL:");
- e.printStackTrace();
- }
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- // ignore
+ if (debug != null) {
+ debug.println("Downloading new CRL...");
}
+ crl = (X509CRL) factory.generateCRL(in);
+ }
+ return getMatchingCRLs(crl, selector);
+ } catch (IOException | CRLException e) {
+ if (debug != null) {
+ debug.println("Exception fetching CRL:");
+ e.printStackTrace();
}
}
// exception, forget previous values
lastModified = 0;
crl = null;
- return Collections.emptyList();
+ return Collections.emptyList();
}
/**
@@ -459,9 +403,9 @@ class URICertStore extends CertStoreSpi {
private static Collection getMatchingCRLs
(X509CRL crl, CRLSelector selector) {
if (selector == null || (crl != null && selector.match(crl))) {
- return Collections.singletonList(crl);
+ return Collections.singletonList(crl);
} else {
- return Collections.emptyList();
+ return Collections.emptyList();
}
}
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/X509CertificatePair.java b/jdk/src/share/classes/sun/security/provider/certpath/X509CertificatePair.java
index 20d05f71be8..3228b7ed62e 100644
--- a/jdk/src/share/classes/sun/security/provider/certpath/X509CertificatePair.java
+++ b/jdk/src/share/classes/sun/security/provider/certpath/X509CertificatePair.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -79,7 +79,8 @@ public class X509CertificatePair {
private X509Certificate reverse;
private byte[] encoded;
- private static final Cache cache = Cache.newSoftMemoryCache(750);
+ private static final Cache cache
+ = Cache.newSoftMemoryCache(750);
/**
* Creates an empty instance of X509CertificatePair.
@@ -114,7 +115,7 @@ public class X509CertificatePair {
*
* For internal use only, external code should use generateCertificatePair.
*/
- private X509CertificatePair(byte[] encoded)throws CertificateException {
+ private X509CertificatePair(byte[] encoded) throws CertificateException {
try {
parse(new DerValue(encoded));
this.encoded = encoded;
@@ -138,7 +139,7 @@ public class X509CertificatePair {
public static synchronized X509CertificatePair generateCertificatePair
(byte[] encoded) throws CertificateException {
Object key = new Cache.EqualByteArray(encoded);
- X509CertificatePair pair = (X509CertificatePair)cache.get(key);
+ X509CertificatePair pair = cache.get(key);
if (pair != null) {
return pair;
}
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStore.java b/jdk/src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStore.java
index d86404d0802..eb20b3f704d 100644
--- a/jdk/src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStore.java
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStore.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -103,7 +103,7 @@ import sun.security.action.GetPropertyAction;
* @author Steve Hanna
* @author Andreas Sterbenz
*/
-public class LDAPCertStore extends CertStoreSpi {
+public final class LDAPCertStore extends CertStoreSpi {
private static final Debug debug = Debug.getInstance("certpath");
@@ -160,7 +160,7 @@ public class LDAPCertStore extends CertStoreSpi {
*/
private boolean prefetchCRLs = false;
- private final Cache valueCache;
+ private final Cache valueCache;
private int cacheHits = 0;
private int cacheMisses = 0;
@@ -207,10 +207,11 @@ public class LDAPCertStore extends CertStoreSpi {
* Returns an LDAP CertStore. This method consults a cache of
* CertStores (shared per JVM) using the LDAP server/port as a key.
*/
- private static final Cache certStoreCache = Cache.newSoftMemoryCache(185);
+ private static final Cache
+ certStoreCache = Cache.newSoftMemoryCache(185);
static synchronized CertStore getInstance(LDAPCertStoreParameters params)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
- CertStore lcs = (CertStore) certStoreCache.get(params);
+ CertStore lcs = certStoreCache.get(params);
if (lcs == null) {
lcs = CertStore.getInstance("LDAP", params);
certStoreCache.put(params, lcs);
@@ -232,7 +233,7 @@ public class LDAPCertStore extends CertStoreSpi {
private void createInitialDirContext(String server, int port)
throws InvalidAlgorithmParameterException {
String url = "ldap://" + server + ":" + port;
- Hashtable env = new Hashtable();
+ Hashtable env = new Hashtable<>();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, url);
@@ -283,7 +284,7 @@ public class LDAPCertStore extends CertStoreSpi {
LDAPRequest(String name) {
this.name = name;
- requestedAttributes = new ArrayList(5);
+ requestedAttributes = new ArrayList<>(5);
}
String getName() {
@@ -311,7 +312,7 @@ public class LDAPCertStore extends CertStoreSpi {
+ cacheMisses);
}
String cacheKey = name + "|" + attrId;
- byte[][] values = (byte[][])valueCache.get(cacheKey);
+ byte[][] values = valueCache.get(cacheKey);
if (values != null) {
cacheHits++;
return values;
@@ -347,7 +348,7 @@ public class LDAPCertStore extends CertStoreSpi {
System.out.println("LDAP requests: " + requests);
}
}
- valueMap = new HashMap(8);
+ valueMap = new HashMap<>(8);
String[] attrIds = requestedAttributes.toArray(STRING0);
Attributes attrs;
try {
@@ -429,10 +430,10 @@ public class LDAPCertStore extends CertStoreSpi {
int n = encodedCert.length;
if (n == 0) {
- return Collections.emptySet();
+ return Collections.emptySet();
}
- List certs = new ArrayList(n);
+ List certs = new ArrayList<>(n);
/* decode certs and check if they satisfy selector */
for (int i = 0; i < n; i++) {
ByteArrayInputStream bais = new ByteArrayInputStream(encodedCert[i]);
@@ -477,11 +478,10 @@ public class LDAPCertStore extends CertStoreSpi {
int n = encodedCertPair.length;
if (n == 0) {
- return Collections.emptySet();
+ return Collections.emptySet();
}
- List certPairs =
- new ArrayList(n);
+ List certPairs = new ArrayList<>(n);
/* decode each cert pair and add it to the Collection */
for (int i = 0; i < n; i++) {
try {
@@ -528,8 +528,7 @@ public class LDAPCertStore extends CertStoreSpi {
getCertPairs(request, CROSS_CERT);
// Find Certificates that match and put them in a list
- ArrayList matchingCerts =
- new ArrayList();
+ ArrayList matchingCerts = new ArrayList<>();
for (X509CertificatePair certPair : certPairs) {
X509Certificate cert;
if (forward != null) {
@@ -587,7 +586,7 @@ public class LDAPCertStore extends CertStoreSpi {
int basicConstraints = xsel.getBasicConstraints();
String subject = xsel.getSubjectAsString();
String issuer = xsel.getIssuerAsString();
- HashSet certs = new HashSet();
+ HashSet certs = new HashSet<>();
if (debug != null) {
debug.println("LDAPCertStore.engineGetCertificates() basicConstraints: "
+ basicConstraints);
@@ -706,10 +705,10 @@ public class LDAPCertStore extends CertStoreSpi {
int n = encodedCRL.length;
if (n == 0) {
- return Collections.emptySet();
+ return Collections.emptySet();
}
- List crls = new ArrayList(n);
+ List crls = new ArrayList<>(n);
/* decode each crl and check if it matches selector */
for (int i = 0; i < n; i++) {
try {
@@ -765,13 +764,13 @@ public class LDAPCertStore extends CertStoreSpi {
throw new CertStoreException("need X509CRLSelector to find CRLs");
}
X509CRLSelector xsel = (X509CRLSelector) selector;
- HashSet crls = new HashSet();
+ HashSet crls = new HashSet<>();
// Look in directory entry for issuer of cert we're checking.
Collection issuerNames;
X509Certificate certChecking = xsel.getCertificateChecking();
if (certChecking != null) {
- issuerNames = new HashSet();
+ issuerNames = new HashSet<>();
X500Principal issuer = certChecking.getIssuerX500Principal();
issuerNames.add(issuer.getName(X500Principal.RFC2253));
} else {
@@ -796,7 +795,7 @@ public class LDAPCertStore extends CertStoreSpi {
issuerName = (String)nameObject;
}
// If all we want is CA certs, try to get the (probably shorter) ARL
- Collection entryCRLs = Collections.emptySet();
+ Collection entryCRLs = Collections.emptySet();
if (certChecking == null || certChecking.getBasicConstraints() != -1) {
LDAPRequest request = new LDAPRequest(issuerName);
request.addRequestedAttribute(CROSS_CERT);
@@ -1028,9 +1027,9 @@ public class LDAPCertStore extends CertStoreSpi {
throws IOException {
this.selector = selector == null ? new X509CRLSelector() : selector;
this.certIssuers = certIssuers;
- issuerNames = new HashSet();
+ issuerNames = new HashSet<>();
issuerNames.add(ldapDN);
- issuers = new HashSet();
+ issuers = new HashSet<>();
issuers.add(new X500Name(ldapDN).asX500Principal());
}
// we only override the get (accessor methods) since the set methods
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStoreHelper.java b/jdk/src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStoreHelper.java
index 7eb65d5a7a8..5ec100c6a1d 100644
--- a/jdk/src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStoreHelper.java
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStoreHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, 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
@@ -41,11 +41,9 @@ import sun.security.provider.certpath.CertStoreHelper;
* LDAP implementation of CertStoreHelper.
*/
-public class LDAPCertStoreHelper
- implements CertStoreHelper
+public final class LDAPCertStoreHelper
+ extends CertStoreHelper
{
- public LDAPCertStoreHelper() { }
-
@Override
public CertStore getCertStore(URI uri)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/ssl/SSLServerCertStore.java b/jdk/src/share/classes/sun/security/provider/certpath/ssl/SSLServerCertStore.java
new file mode 100644
index 00000000000..5109e132d22
--- /dev/null
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ssl/SSLServerCertStore.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2011, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.provider.certpath.ssl;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.security.GeneralSecurityException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.Provider;
+import java.security.cert.CertificateException;
+import java.security.cert.CertSelector;
+import java.security.cert.CertStore;
+import java.security.cert.CertStoreException;
+import java.security.cert.CertStoreParameters;
+import java.security.cert.CertStoreSpi;
+import java.security.cert.CRLSelector;
+import java.security.cert.X509Certificate;
+import java.security.cert.X509CRL;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+/**
+ * A CertStore that retrieves an SSL server's certificate chain.
+ */
+public final class SSLServerCertStore extends CertStoreSpi {
+
+ private final URI uri;
+
+ SSLServerCertStore(URI uri) throws InvalidAlgorithmParameterException {
+ super(null);
+ this.uri = uri;
+ }
+
+ public synchronized Collection engineGetCertificates
+ (CertSelector selector) throws CertStoreException
+ {
+ try {
+ SSLContext sc = SSLContext.getInstance("SSL");
+ GetChainTrustManager xtm = new GetChainTrustManager();
+ sc.init(null, new TrustManager[] { xtm }, null);
+ HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+ HttpsURLConnection.setDefaultHostnameVerifier(
+ new HostnameVerifier() {
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ });
+ uri.toURL().openConnection().connect();
+ return getMatchingCerts(xtm.serverChain, selector);
+ } catch (GeneralSecurityException | IOException e) {
+ throw new CertStoreException(e);
+ }
+ }
+
+ private static List getMatchingCerts
+ (List certs, CertSelector selector)
+ {
+ // if selector not specified, all certs match
+ if (selector == null) {
+ return certs;
+ }
+ List matchedCerts = new ArrayList<>(certs.size());
+ for (X509Certificate cert : certs) {
+ if (selector.match(cert)) {
+ matchedCerts.add(cert);
+ }
+ }
+ return matchedCerts;
+ }
+
+ public Collection engineGetCRLs(CRLSelector selector)
+ throws CertStoreException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ static synchronized CertStore getInstance(URI uri)
+ throws InvalidAlgorithmParameterException
+ {
+ return new CS(new SSLServerCertStore(uri), null, "SSLServer", null);
+ }
+
+ /*
+ * An X509TrustManager that simply stores a reference to the server's
+ * certificate chain.
+ */
+ private static class GetChainTrustManager implements X509TrustManager {
+ private List serverChain;
+
+ public X509Certificate[] getAcceptedIssuers() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void checkClientTrusted(X509Certificate[] chain,
+ String authType)
+ throws CertificateException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void checkServerTrusted(X509Certificate[] chain,
+ String authType)
+ throws CertificateException
+ {
+ this.serverChain = (chain == null)
+ ? Collections.emptyList()
+ : Arrays.asList(chain);
+ }
+ }
+
+ /**
+ * This class allows the SSLServerCertStore to be accessed as a CertStore.
+ */
+ private static class CS extends CertStore {
+ protected CS(CertStoreSpi spi, Provider p, String type,
+ CertStoreParameters params)
+ {
+ super(spi, p, type, params);
+ }
+ }
+}
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/ssl/SSLServerCertStoreHelper.java b/jdk/src/share/classes/sun/security/provider/certpath/ssl/SSLServerCertStoreHelper.java
new file mode 100644
index 00000000000..fd36adfbad1
--- /dev/null
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ssl/SSLServerCertStoreHelper.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.provider.certpath.ssl;
+
+import java.net.URI;
+import java.util.Collection;
+import java.security.NoSuchAlgorithmException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.cert.CertStore;
+import java.security.cert.X509CertSelector;
+import java.security.cert.X509CRLSelector;
+import javax.security.auth.x500.X500Principal;
+import java.io.IOException;
+
+import sun.security.provider.certpath.CertStoreHelper;
+
+/**
+ * SSL implementation of CertStoreHelper.
+ */
+public final class SSLServerCertStoreHelper extends CertStoreHelper {
+
+ @Override
+ public CertStore getCertStore(URI uri)
+ throws NoSuchAlgorithmException, InvalidAlgorithmParameterException
+ {
+ return SSLServerCertStore.getInstance(uri);
+ }
+
+ @Override
+ public X509CertSelector wrap(X509CertSelector selector,
+ X500Principal certSubject,
+ String ldapDN)
+ throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public X509CRLSelector wrap(X509CRLSelector selector,
+ Collection certIssuers,
+ String ldapDN)
+ throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java b/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java
index 34f3be6d6a5..6be00b8e2d1 100644
--- a/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java
+++ b/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, 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
@@ -69,12 +69,38 @@ class AppOutputStream extends OutputStream {
// check if the Socket is invalid (error or closed)
c.checkWrite();
+ /*
+ * By default, we counter chosen plaintext issues on CBC mode
+ * ciphersuites in SSLv3/TLS1.0 by sending one byte of application
+ * data in the first record of every payload, and the rest in
+ * subsequent record(s). Note that the issues have been solved in
+ * TLS 1.1 or later.
+ *
+ * It is not necessary to split the very first application record of
+ * a freshly negotiated TLS session, as there is no previous
+ * application data to guess. To improve compatibility, we will not
+ * split such records.
+ *
+ * This avoids issues in the outbound direction. For a full fix,
+ * the peer must have similar protections.
+ */
+ boolean isFirstRecordOfThePayload = true;
+
// Always flush at the end of each application level record.
// This lets application synchronize read and write streams
// however they like; if we buffered here, they couldn't.
try {
do {
- int howmuch = Math.min(len, r.availableDataBytes());
+ int howmuch;
+ if (isFirstRecordOfThePayload && c.needToSplitPayload()) {
+ howmuch = Math.min(0x01, r.availableDataBytes());
+ } else {
+ howmuch = Math.min(len, r.availableDataBytes());
+ }
+
+ if (isFirstRecordOfThePayload && howmuch != 0) {
+ isFirstRecordOfThePayload = false;
+ }
// NOTE: *must* call c.writeRecord() even for howmuch == 0
if (howmuch > 0) {
diff --git a/jdk/src/share/classes/sun/security/ssl/CipherBox.java b/jdk/src/share/classes/sun/security/ssl/CipherBox.java
index 91f9f36198d..4305b44635b 100644
--- a/jdk/src/share/classes/sun/security/ssl/CipherBox.java
+++ b/jdk/src/share/classes/sun/security/ssl/CipherBox.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, 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
@@ -112,6 +112,11 @@ final class CipherBox {
*/
private SecureRandom random;
+ /**
+ * Is the cipher of CBC mode?
+ */
+ private final boolean isCBCMode;
+
/**
* Fixed masks of various block size, as the initial decryption IVs
* for TLS 1.1 or later.
@@ -128,6 +133,7 @@ final class CipherBox {
private CipherBox() {
this.protocolVersion = ProtocolVersion.DEFAULT;
this.cipher = null;
+ this.isCBCMode = false;
}
/**
@@ -148,6 +154,7 @@ final class CipherBox {
random = JsseJce.getSecureRandom();
}
this.random = random;
+ this.isCBCMode = bulkCipher.isCBCMode;
/*
* RFC 4346 recommends two algorithms used to generated the
@@ -305,9 +312,11 @@ final class CipherBox {
byte[] buf = null;
int limit = bb.limit();
if (bb.hasArray()) {
+ int arrayOffset = bb.arrayOffset();
buf = bb.array();
- System.arraycopy(buf, pos,
- buf, pos + prefix.length, limit - pos);
+ System.arraycopy(buf, arrayOffset + pos,
+ buf, arrayOffset + pos + prefix.length,
+ limit - pos);
bb.limit(limit + prefix.length);
} else {
buf = new byte[limit - pos];
@@ -491,9 +500,10 @@ final class CipherBox {
byte[] buf = null;
int limit = bb.limit();
if (bb.hasArray()) {
+ int arrayOffset = bb.arrayOffset();
buf = bb.array();
- System.arraycopy(buf, pos + blockSize,
- buf, pos, limit - pos - blockSize);
+ System.arraycopy(buf, arrayOffset + pos + blockSize,
+ buf, arrayOffset + pos, limit - pos - blockSize);
bb.limit(limit - blockSize);
} else {
buf = new byte[limit - pos - blockSize];
@@ -691,4 +701,12 @@ final class CipherBox {
}
}
+ /*
+ * Does the cipher use CBC mode?
+ *
+ * @return true if the cipher use CBC mode, false otherwise.
+ */
+ boolean isCBCMode() {
+ return isCBCMode;
+ }
}
diff --git a/jdk/src/share/classes/sun/security/ssl/CipherSuite.java b/jdk/src/share/classes/sun/security/ssl/CipherSuite.java
index 116afa43d70..bbf66ade7e1 100644
--- a/jdk/src/share/classes/sun/security/ssl/CipherSuite.java
+++ b/jdk/src/share/classes/sun/security/ssl/CipherSuite.java
@@ -420,10 +420,16 @@ final class CipherSuite implements Comparable {
// exportable under 512/40 bit rules
final boolean exportable;
+ // Is the cipher algorithm of Cipher Block Chaining (CBC) mode?
+ final boolean isCBCMode;
+
BulkCipher(String transformation, int keySize,
int expandedKeySize, int ivSize, boolean allowed) {
this.transformation = transformation;
- this.algorithm = transformation.split("/")[0];
+ String[] splits = transformation.split("/");
+ this.algorithm = splits[0];
+ this.isCBCMode =
+ splits.length <= 1 ? false : "CBC".equalsIgnoreCase(splits[1]);
this.description = this.algorithm + "/" + (keySize << 3);
this.keySize = keySize;
this.ivSize = ivSize;
@@ -436,7 +442,10 @@ final class CipherSuite implements Comparable {
BulkCipher(String transformation, int keySize,
int ivSize, boolean allowed) {
this.transformation = transformation;
- this.algorithm = transformation.split("/")[0];
+ String[] splits = transformation.split("/");
+ this.algorithm = splits[0];
+ this.isCBCMode =
+ splits.length <= 1 ? false : "CBC".equalsIgnoreCase(splits[1]);
this.description = this.algorithm + "/" + (keySize << 3);
this.keySize = keySize;
this.ivSize = ivSize;
diff --git a/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java b/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java
index 60a428396e4..707fd04f8d3 100644
--- a/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java
+++ b/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -46,6 +46,7 @@ import sun.misc.HexDumpEncoder;
*/
final class EngineOutputRecord extends OutputRecord {
+ private SSLEngineImpl engine;
private EngineWriter writer;
private boolean finishedMsg = false;
@@ -62,6 +63,7 @@ final class EngineOutputRecord extends OutputRecord {
*/
EngineOutputRecord(byte type, SSLEngineImpl engine) {
super(type, recordSize(type));
+ this.engine = engine;
writer = engine.writer;
}
@@ -227,11 +229,50 @@ final class EngineOutputRecord extends OutputRecord {
* implementations are fragile and don't like to see empty
* records, so this increases robustness.
*/
- int length = Math.min(ea.getAppRemaining(), maxDataSize);
- if (length == 0) {
+ if (ea.getAppRemaining() == 0) {
return;
}
+ /*
+ * By default, we counter chosen plaintext issues on CBC mode
+ * ciphersuites in SSLv3/TLS1.0 by sending one byte of application
+ * data in the first record of every payload, and the rest in
+ * subsequent record(s). Note that the issues have been solved in
+ * TLS 1.1 or later.
+ *
+ * It is not necessary to split the very first application record of
+ * a freshly negotiated TLS session, as there is no previous
+ * application data to guess. To improve compatibility, we will not
+ * split such records.
+ *
+ * Because of the compatibility, we'd better produce no more than
+ * SSLSession.getPacketBufferSize() net data for each wrap. As we
+ * need a one-byte record at first, the 2nd record size should be
+ * equal to or less than Record.maxDataSizeMinusOneByteRecord.
+ *
+ * This avoids issues in the outbound direction. For a full fix,
+ * the peer must have similar protections.
+ */
+ int length;
+ if (engine.needToSplitPayload(writeCipher, protocolVersion)) {
+ write(ea, writeMAC, writeCipher, 0x01);
+ ea.resetLim(); // reset application data buffer limit
+ length = Math.min(ea.getAppRemaining(),
+ maxDataSizeMinusOneByteRecord);
+ } else {
+ length = Math.min(ea.getAppRemaining(), maxDataSize);
+ }
+
+ // Don't bother to really write empty records.
+ if (length > 0) {
+ write(ea, writeMAC, writeCipher, length);
+ }
+
+ return;
+ }
+
+ void write(EngineArgs ea, MAC writeMAC, CipherBox writeCipher,
+ int length) throws IOException {
/*
* Copy out existing buffer values.
*/
diff --git a/jdk/src/share/classes/sun/security/ssl/MAC.java b/jdk/src/share/classes/sun/security/ssl/MAC.java
index 8002148a994..ae5c9d43bc0 100644
--- a/jdk/src/share/classes/sun/security/ssl/MAC.java
+++ b/jdk/src/share/classes/sun/security/ssl/MAC.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, 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
@@ -172,10 +172,10 @@ final class MAC {
* when there are only 2^8 sequence numbers left.
*/
return (block != null && mac != null &&
- block[0] == 0xFF && block[1] == 0xFF &&
- block[2] == 0xFF && block[3] == 0xFF &&
- block[4] == 0xFF && block[5] == 0xFF &&
- block[6] == 0xFF);
+ block[0] == (byte)0xFF && block[1] == (byte)0xFF &&
+ block[2] == (byte)0xFF && block[3] == (byte)0xFF &&
+ block[4] == (byte)0xFF && block[5] == (byte)0xFF &&
+ block[6] == (byte)0xFF);
}
/*
@@ -192,7 +192,7 @@ final class MAC {
* only 2^48 sequence numbers left.
*/
return (block != null && mac != null &&
- block[0] == 0xFF && block[1] == 0xFF);
+ block[0] == (byte)0xFF && block[1] == (byte)0xFF);
}
// increment the sequence number in the block array
diff --git a/jdk/src/share/classes/sun/security/ssl/Record.java b/jdk/src/share/classes/sun/security/ssl/Record.java
index 1378e107afc..92c8a3ebbe0 100644
--- a/jdk/src/share/classes/sun/security/ssl/Record.java
+++ b/jdk/src/share/classes/sun/security/ssl/Record.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, 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
@@ -67,6 +67,23 @@ interface Record {
+ maxPadding // padding
+ trailerSize; // MAC
+ static final boolean enableCBCProtection =
+ Debug.getBooleanProperty("jsse.enableCBCProtection", true);
+
+ /*
+ * For CBC protection in SSL3/TLS1, we break some plaintext into two
+ * packets. Max application data size for the second packet.
+ */
+ static final int maxDataSizeMinusOneByteRecord =
+ maxDataSize // max data size
+ - ( // max one byte record size
+ headerSize // header
+ + maxIVLength // iv
+ + 1 // one byte data
+ + maxPadding // padding
+ + trailerSize // MAC
+ );
+
/*
* The maximum large record size.
*
diff --git a/jdk/src/share/classes/sun/security/ssl/SSLEngineImpl.java b/jdk/src/share/classes/sun/security/ssl/SSLEngineImpl.java
index 461cbaa2054..8616a71ef13 100644
--- a/jdk/src/share/classes/sun/security/ssl/SSLEngineImpl.java
+++ b/jdk/src/share/classes/sun/security/ssl/SSLEngineImpl.java
@@ -308,6 +308,11 @@ final public class SSLEngineImpl extends SSLEngine {
private Object unwrapLock;
Object writeLock;
+ /*
+ * Is it the first application record to write?
+ */
+ private boolean isFirstAppOutputRecord = true;
+
/*
* Class and subclass dynamic debugging support
*/
@@ -612,6 +617,9 @@ final public class SSLEngineImpl extends SSLEngine {
// See comment above.
oldCipher.dispose();
+
+ // reset the flag of the first application record
+ isFirstAppOutputRecord = true;
}
/*
@@ -1286,9 +1294,35 @@ final public class SSLEngineImpl extends SSLEngine {
}
}
+ /*
+ * turn off the flag of the first application record if we really
+ * consumed at least byte.
+ */
+ if (isFirstAppOutputRecord && ea.deltaApp() > 0) {
+ isFirstAppOutputRecord = false;
+ }
+
return hsStatus;
}
+ /*
+ * Need to split the payload except the following cases:
+ *
+ * 1. protocol version is TLS 1.1 or later;
+ * 2. bulk cipher does not use CBC mode, including null bulk cipher suites.
+ * 3. the payload is the first application record of a freshly
+ * negotiated TLS session.
+ * 4. the CBC protection is disabled;
+ *
+ * More details, please refer to
+ * EngineOutputRecord.write(EngineArgs, MAC, CipherBox).
+ */
+ boolean needToSplitPayload(CipherBox cipher, ProtocolVersion protocol) {
+ return (protocol.v <= ProtocolVersion.TLS10.v) &&
+ cipher.isCBCMode() && !isFirstAppOutputRecord &&
+ Record.enableCBCProtection;
+ }
+
/*
* Non-application OutputRecords go through here.
*/
diff --git a/jdk/src/share/classes/sun/security/ssl/SSLSessionContextImpl.java b/jdk/src/share/classes/sun/security/ssl/SSLSessionContextImpl.java
index ce1336bf122..7d0ea3faf97 100644
--- a/jdk/src/share/classes/sun/security/ssl/SSLSessionContextImpl.java
+++ b/jdk/src/share/classes/sun/security/ssl/SSLSessionContextImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, 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
@@ -43,11 +43,14 @@ import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import sun.security.util.Cache;
+import sun.security.util.Cache.CacheVisitor;
final class SSLSessionContextImpl implements SSLSessionContext {
- private Cache sessionCache; // session cache, session id as key
- private Cache sessionHostPortCache; // session cache, "host:port" as key
+ private Cache sessionCache;
+ // session cache, session id as key
+ private Cache sessionHostPortCache;
+ // session cache, "host:port" as key
private int cacheLimit; // the max cache size
private int timeout; // timeout in seconds
@@ -71,8 +74,7 @@ final class SSLSessionContextImpl implements SSLSessionContext {
throw new NullPointerException("session id cannot be null");
}
- SSLSessionImpl sess =
- (SSLSessionImpl)sessionCache.get(new SessionId(sessionId));
+ SSLSessionImpl sess = sessionCache.get(new SessionId(sessionId));
if (!isTimedout(sess)) {
return sess;
}
@@ -157,8 +159,7 @@ final class SSLSessionContextImpl implements SSLSessionContext {
return null;
}
- SSLSessionImpl sess =
- (SSLSessionImpl)sessionHostPortCache.get(getKey(hostname, port));
+ SSLSessionImpl sess = sessionHostPortCache.get(getKey(hostname, port));
if (!isTimedout(sess)) {
return sess;
}
@@ -193,7 +194,7 @@ final class SSLSessionContextImpl implements SSLSessionContext {
// package-private method, remove a cached SSLSession
void remove(SessionId key) {
- SSLSessionImpl s = (SSLSessionImpl)sessionCache.get(key);
+ SSLSessionImpl s = sessionCache.get(key);
if (s != null) {
sessionCache.remove(key);
sessionHostPortCache.remove(
@@ -233,17 +234,17 @@ final class SSLSessionContextImpl implements SSLSessionContext {
}
final class SessionCacheVisitor
- implements sun.security.util.Cache.CacheVisitor {
+ implements Cache.CacheVisitor {
Vector ids = null;
- // public void visit(java.util.Map map) {}
- public void visit(java.util.Map map) {
- ids = new Vector(map.size());
+ // public void visit(java.util.Map map) {}
+ public void visit(java.util.Map map) {
+ ids = new Vector<>(map.size());
- for (Object key : map.keySet()) {
- SSLSessionImpl value = (SSLSessionImpl)map.get(key);
+ for (SessionId key : map.keySet()) {
+ SSLSessionImpl value = map.get(key);
if (!isTimedout(value)) {
- ids.addElement(((SessionId)key).getId());
+ ids.addElement(key.getId());
}
}
}
diff --git a/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java b/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java
index 5bfdd46c074..814f7d2933a 100644
--- a/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java
+++ b/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java
@@ -369,6 +369,11 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
/* Class and subclass dynamic debugging support */
private static final Debug debug = Debug.getInstance("ssl");
+ /*
+ * Is it the first application record to write?
+ */
+ private boolean isFirstAppOutputRecord = true;
+
//
// CONSTRUCTORS AND INITIALIZATION CODE
//
@@ -802,8 +807,35 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
if (connectionState < cs_ERROR) {
checkSequenceNumber(writeMAC, r.contentType());
}
+
+ // turn off the flag of the first application record
+ if (isFirstAppOutputRecord &&
+ r.contentType() == Record.ct_application_data) {
+ isFirstAppOutputRecord = false;
+ }
}
+ /*
+ * Need to split the payload except the following cases:
+ *
+ * 1. protocol version is TLS 1.1 or later;
+ * 2. bulk cipher does not use CBC mode, including null bulk cipher suites.
+ * 3. the payload is the first application record of a freshly
+ * negotiated TLS session.
+ * 4. the CBC protection is disabled;
+ *
+ * More details, please refer to AppOutputStream.write(byte[], int, int).
+ */
+ boolean needToSplitPayload() {
+ writeLock.lock();
+ try {
+ return (protocolVersion.v <= ProtocolVersion.TLS10.v) &&
+ writeCipher.isCBCMode() && !isFirstAppOutputRecord &&
+ Record.enableCBCProtection;
+ } finally {
+ writeLock.unlock();
+ }
+ }
/*
* Read an application data record. Alerts and handshake
@@ -2030,6 +2062,9 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
// See comment above.
oldCipher.dispose();
+
+ // reset the flag of the first application record
+ isFirstAppOutputRecord = true;
}
/*
diff --git a/jdk/src/share/classes/sun/security/timestamp/HttpTimestamper.java b/jdk/src/share/classes/sun/security/timestamp/HttpTimestamper.java
index 54958f726c8..a4a1921bb29 100644
--- a/jdk/src/share/classes/sun/security/timestamp/HttpTimestamper.java
+++ b/jdk/src/share/classes/sun/security/timestamp/HttpTimestamper.java
@@ -28,13 +28,13 @@ package sun.security.timestamp;
import java.io.BufferedInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.net.URI;
import java.net.URL;
import java.net.HttpURLConnection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import sun.misc.IOUtils;
+import sun.security.util.Debug;
/**
* A timestamper that communicates with a Timestamping Authority (TSA)
@@ -58,20 +58,23 @@ public class HttpTimestamper implements Timestamper {
private static final String TS_REPLY_MIME_TYPE =
"application/timestamp-reply";
- private static final boolean DEBUG = false;
+ private static final Debug debug = Debug.getInstance("ts");
/*
- * HTTP URL identifying the location of the TSA
+ * HTTP URI identifying the location of the TSA
*/
- private String tsaUrl = null;
+ private URI tsaURI = null;
/**
* Creates a timestamper that connects to the specified TSA.
*
- * @param tsa The location of the TSA. It must be an HTTP URL.
+ * @param tsa The location of the TSA. It must be an HTTP URI.
+ * @throws IllegalArgumentException if tsaURI is not an HTTP URI
*/
- public HttpTimestamper(String tsaUrl) {
- this.tsaUrl = tsaUrl;
+ public HttpTimestamper(URI tsaURI) {
+ if (!tsaURI.getScheme().equalsIgnoreCase("http"))
+ throw new IllegalArgumentException("TSA must be an HTTP URI");
+ this.tsaURI = tsaURI;
}
/**
@@ -85,7 +88,7 @@ public class HttpTimestamper implements Timestamper {
public TSResponse generateTimestamp(TSRequest tsQuery) throws IOException {
HttpURLConnection connection =
- (HttpURLConnection) new URL(tsaUrl).openConnection();
+ (HttpURLConnection) tsaURI.toURL().openConnection();
connection.setDoOutput(true);
connection.setUseCaches(false); // ignore cache
connection.setRequestProperty("Content-Type", TS_QUERY_MIME_TYPE);
@@ -93,15 +96,15 @@ public class HttpTimestamper implements Timestamper {
// Avoids the "hang" when a proxy is required but none has been set.
connection.setConnectTimeout(CONNECT_TIMEOUT);
- if (DEBUG) {
+ if (debug != null) {
Set>> headers =
- connection.getRequestProperties().entrySet();
- System.out.println(connection.getRequestMethod() + " " + tsaUrl +
+ connection.getRequestProperties().entrySet();
+ debug.println(connection.getRequestMethod() + " " + tsaURI +
" HTTP/1.1");
- for (Map.Entry> entry : headers) {
- System.out.println(" " + entry);
+ for (Map.Entry> e : headers) {
+ debug.println(" " + e);
}
- System.out.println();
+ debug.println();
}
connection.connect(); // No HTTP authentication is performed
@@ -112,8 +115,8 @@ public class HttpTimestamper implements Timestamper {
byte[] request = tsQuery.encode();
output.write(request, 0, request.length);
output.flush();
- if (DEBUG) {
- System.out.println("sent timestamp query (length=" +
+ if (debug != null) {
+ debug.println("sent timestamp query (length=" +
request.length + ")");
}
} finally {
@@ -127,17 +130,17 @@ public class HttpTimestamper implements Timestamper {
byte[] replyBuffer = null;
try {
input = new BufferedInputStream(connection.getInputStream());
- if (DEBUG) {
+ if (debug != null) {
String header = connection.getHeaderField(0);
- System.out.println(header);
+ debug.println(header);
int i = 1;
while ((header = connection.getHeaderField(i)) != null) {
String key = connection.getHeaderFieldKey(i);
- System.out.println(" " + ((key==null) ? "" : key + ": ") +
+ debug.println(" " + ((key==null) ? "" : key + ": ") +
header);
i++;
}
- System.out.println();
+ debug.println();
}
verifyMimeType(connection.getContentType());
@@ -145,8 +148,8 @@ public class HttpTimestamper implements Timestamper {
int contentLength = connection.getContentLength();
replyBuffer = IOUtils.readFully(input, contentLength, false);
- if (DEBUG) {
- System.out.println("received timestamp response (length=" +
+ if (debug != null) {
+ debug.println("received timestamp response (length=" +
total + ")");
}
} finally {
diff --git a/jdk/src/share/classes/sun/security/timestamp/TSRequest.java b/jdk/src/share/classes/sun/security/timestamp/TSRequest.java
index 241811f5333..9b322192cca 100644
--- a/jdk/src/share/classes/sun/security/timestamp/TSRequest.java
+++ b/jdk/src/share/classes/sun/security/timestamp/TSRequest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -27,10 +27,13 @@ package sun.security.timestamp;
import java.io.IOException;
import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Extension;
import sun.security.util.DerValue;
import sun.security.util.DerOutputStream;
import sun.security.util.ObjectIdentifier;
+import sun.security.x509.AlgorithmId;
/**
* This class provides a timestamp request, as defined in
@@ -64,24 +67,9 @@ import sun.security.util.ObjectIdentifier;
public class TSRequest {
- private static final ObjectIdentifier SHA1_OID;
- private static final ObjectIdentifier MD5_OID;
- static {
- ObjectIdentifier sha1 = null;
- ObjectIdentifier md5 = null;
- try {
- sha1 = new ObjectIdentifier("1.3.14.3.2.26");
- md5 = new ObjectIdentifier("1.2.840.113549.2.5");
- } catch (IOException ioe) {
- // should not happen
- }
- SHA1_OID = sha1;
- MD5_OID = md5;
- }
-
private int version = 1;
- private ObjectIdentifier hashAlgorithmId = null;
+ private AlgorithmId hashAlgorithmId = null;
private byte[] hashValue;
@@ -94,30 +82,21 @@ public class TSRequest {
private X509Extension[] extensions = null;
/**
- * Constructs a timestamp request for the supplied hash value..
+ * Constructs a timestamp request for the supplied data.
*
- * @param hashValue The hash value. This is the data to be timestamped.
- * @param hashAlgorithm The name of the hash algorithm.
+ * @param toBeTimeStamped The data to be timestamped.
+ * @param messageDigest The MessageDigest of the hash algorithm to use.
+ * @throws NoSuchAlgorithmException if the hash algorithm is not supported
*/
- public TSRequest(byte[] hashValue, String hashAlgorithm) {
+ public TSRequest(byte[] toBeTimeStamped, MessageDigest messageDigest)
+ throws NoSuchAlgorithmException {
- // Check the common hash algorithms
- if ("MD5".equalsIgnoreCase(hashAlgorithm)) {
- hashAlgorithmId = MD5_OID;
- // Check that the hash value matches the hash algorithm
- assert hashValue.length == 16;
+ this.hashAlgorithmId = AlgorithmId.get(messageDigest.getAlgorithm());
+ this.hashValue = messageDigest.digest(toBeTimeStamped);
+ }
- } else if ("SHA-1".equalsIgnoreCase(hashAlgorithm) ||
- "SHA".equalsIgnoreCase(hashAlgorithm) ||
- "SHA1".equalsIgnoreCase(hashAlgorithm)) {
- hashAlgorithmId = SHA1_OID;
- // Check that the hash value matches the hash algorithm
- assert hashValue.length == 20;
-
- }
- // Clone the hash value
- this.hashValue = new byte[hashValue.length];
- System.arraycopy(hashValue, 0, this.hashValue, 0, hashValue.length);
+ public byte[] getHashedMessage() {
+ return hashValue.clone();
}
/**
@@ -176,9 +155,7 @@ public class TSRequest {
// encode messageImprint
DerOutputStream messageImprint = new DerOutputStream();
- DerOutputStream hashAlgorithm = new DerOutputStream();
- hashAlgorithm.putOID(hashAlgorithmId);
- messageImprint.write(DerValue.tag_Sequence, hashAlgorithm);
+ hashAlgorithmId.encode(messageImprint);
messageImprint.putOctetString(hashValue);
request.write(DerValue.tag_Sequence, messageImprint);
diff --git a/jdk/src/share/classes/sun/security/timestamp/TSResponse.java b/jdk/src/share/classes/sun/security/timestamp/TSResponse.java
index afb8084fed7..0cf223d492a 100644
--- a/jdk/src/share/classes/sun/security/timestamp/TSResponse.java
+++ b/jdk/src/share/classes/sun/security/timestamp/TSResponse.java
@@ -27,6 +27,7 @@ package sun.security.timestamp;
import java.io.IOException;
import sun.security.pkcs.PKCS7;
+import sun.security.util.Debug;
import sun.security.util.DerValue;
/**
@@ -175,18 +176,20 @@ public class TSResponse {
*/
public static final int SYSTEM_FAILURE = 25;
- private static final boolean DEBUG = false;
+ private static final Debug debug = Debug.getInstance("ts");
private int status;
private String[] statusString = null;
- private int failureInfo = -1;
+ private boolean[] failureInfo = null;
private byte[] encodedTsToken = null;
private PKCS7 tsToken = null;
+ private TimestampToken tstInfo;
+
/**
* Constructs an object to store the response to a timestamp request.
*
@@ -215,11 +218,11 @@ public class TSResponse {
}
/**
- * Retrieve the failure code returned by the TSA.
+ * Retrieve the failure info returned by the TSA.
*
- * @return If -1 then no failure code was received.
+ * @return the failure info, or null if no failure code was received.
*/
- public int getFailureCode() {
+ public boolean[] getFailureInfo() {
return failureInfo;
}
@@ -250,42 +253,38 @@ public class TSResponse {
}
}
+ private boolean isSet(int position) {
+ return failureInfo[position];
+ }
+
public String getFailureCodeAsText() {
- if (failureInfo == -1) {
- return null;
+ if (failureInfo == null) {
+ return "";
}
- switch (failureInfo) {
+ try {
+ if (isSet(BAD_ALG))
+ return "Unrecognized or unsupported algorithm identifier.";
+ if (isSet(BAD_REQUEST))
+ return "The requested transaction is not permitted or " +
+ "supported.";
+ if (isSet(BAD_DATA_FORMAT))
+ return "The data submitted has the wrong format.";
+ if (isSet(TIME_NOT_AVAILABLE))
+ return "The TSA's time source is not available.";
+ if (isSet(UNACCEPTED_POLICY))
+ return "The requested TSA policy is not supported by the TSA.";
+ if (isSet(UNACCEPTED_EXTENSION))
+ return "The requested extension is not supported by the TSA.";
+ if (isSet(ADD_INFO_NOT_AVAILABLE))
+ return "The additional information requested could not be " +
+ "understood or is not available.";
+ if (isSet(SYSTEM_FAILURE))
+ return "The request cannot be handled due to system failure.";
+ } catch (ArrayIndexOutOfBoundsException ex) {}
- case BAD_ALG:
- return "Unrecognized or unsupported alrorithm identifier.";
-
- case BAD_REQUEST:
- return "The requested transaction is not permitted or supported.";
-
- case BAD_DATA_FORMAT:
- return "The data submitted has the wrong format.";
-
- case TIME_NOT_AVAILABLE:
- return "The TSA's time source is not available.";
-
- case UNACCEPTED_POLICY:
- return "The requested TSA policy is not supported by the TSA.";
-
- case UNACCEPTED_EXTENSION:
- return "The requested extension is not supported by the TSA.";
-
- case ADD_INFO_NOT_AVAILABLE:
- return "The additional information requested could not be " +
- "understood or is not available.";
-
- case SYSTEM_FAILURE:
- return "The request cannot be handled due to system failure.";
-
- default:
- return ("unknown status code " + status);
- }
+ return ("unknown failure code");
}
/**
@@ -297,6 +296,10 @@ public class TSResponse {
return tsToken;
}
+ public TimestampToken getTimestampToken() {
+ return tstInfo;
+ }
+
/**
* Retrieve the ASN.1 BER encoded timestamp token returned by the TSA.
*
@@ -323,29 +326,30 @@ public class TSResponse {
// Parse status
- DerValue status = derValue.data.getDerValue();
- // Parse status
- this.status = status.data.getInteger();
- if (DEBUG) {
- System.out.println("timestamp response: status=" + this.status);
+ DerValue statusInfo = derValue.data.getDerValue();
+ this.status = statusInfo.data.getInteger();
+ if (debug != null) {
+ debug.println("timestamp response: status=" + this.status);
}
// Parse statusString, if present
- if (status.data.available() > 0) {
- DerValue[] strings = status.data.getSequence(1);
- statusString = new String[strings.length];
- for (int i = 0; i < strings.length; i++) {
- statusString[i] = strings[i].data.getUTF8String();
+ if (statusInfo.data.available() > 0) {
+ byte tag = (byte)statusInfo.data.peekByte();
+ if (tag == DerValue.tag_SequenceOf) {
+ DerValue[] strings = statusInfo.data.getSequence(1);
+ statusString = new String[strings.length];
+ for (int i = 0; i < strings.length; i++) {
+ statusString[i] = strings[i].getUTF8String();
+ if (debug != null) {
+ debug.println("timestamp response: statusString=" +
+ statusString[i]);
+ }
+ }
}
}
// Parse failInfo, if present
- if (status.data.available() > 0) {
- byte[] failInfo = status.data.getBitString();
- int failureInfo = (new Byte(failInfo[0])).intValue();
- if (failureInfo < 0 || failureInfo > 25 || failInfo.length != 1) {
- throw new IOException("Bad encoding for timestamp response: " +
- "unrecognized value for the failInfo element");
- }
- this.failureInfo = failureInfo;
+ if (statusInfo.data.available() > 0) {
+ this.failureInfo
+ = statusInfo.data.getUnalignedBitString().toBooleanArray();
}
// Parse timeStampToken, if present
@@ -353,6 +357,7 @@ public class TSResponse {
DerValue timestampToken = derValue.data.getDerValue();
encodedTsToken = timestampToken.toByteArray();
tsToken = new PKCS7(encodedTsToken);
+ tstInfo = new TimestampToken(tsToken.getContentInfo().getData());
}
// Check the format of the timestamp response
diff --git a/jdk/src/share/classes/sun/security/x509/CertAndKeyGen.java b/jdk/src/share/classes/sun/security/tools/CertAndKeyGen.java
similarity index 95%
rename from jdk/src/share/classes/sun/security/x509/CertAndKeyGen.java
rename to jdk/src/share/classes/sun/security/tools/CertAndKeyGen.java
index f1560c716ad..4c32a33b4f7 100644
--- a/jdk/src/share/classes/sun/security/x509/CertAndKeyGen.java
+++ b/jdk/src/share/classes/sun/security/tools/CertAndKeyGen.java
@@ -23,7 +23,7 @@
* questions.
*/
-package sun.security.x509;
+package sun.security.tools;
import java.io.IOException;
import java.security.cert.X509Certificate;
@@ -32,7 +32,19 @@ import java.security.cert.CertificateEncodingException;
import java.security.*;
import java.util.Date;
-import sun.security.pkcs.PKCS10;
+import sun.security.pkcs10.PKCS10;
+import sun.security.x509.AlgorithmId;
+import sun.security.x509.CertificateAlgorithmId;
+import sun.security.x509.CertificateIssuerName;
+import sun.security.x509.CertificateSerialNumber;
+import sun.security.x509.CertificateSubjectName;
+import sun.security.x509.CertificateValidity;
+import sun.security.x509.CertificateVersion;
+import sun.security.x509.CertificateX509Key;
+import sun.security.x509.X500Name;
+import sun.security.x509.X509CertImpl;
+import sun.security.x509.X509CertInfo;
+import sun.security.x509.X509Key;
/**
diff --git a/jdk/src/share/classes/sun/security/tools/JarSigner.java b/jdk/src/share/classes/sun/security/tools/JarSigner.java
index ac2ffde9e58..fe3944f4b29 100644
--- a/jdk/src/share/classes/sun/security/tools/JarSigner.java
+++ b/jdk/src/share/classes/sun/security/tools/JarSigner.java
@@ -1277,11 +1277,10 @@ public class JarSigner {
System.out.println(rb.getString("TSA.location.") + tsaUrl);
}
if (tsaCert != null) {
- String certUrl =
- TimestampedSigner.getTimestampingUrl(tsaCert);
- if (certUrl != null) {
+ URI tsaURI = TimestampedSigner.getTimestampingURI(tsaCert);
+ if (tsaURI != null) {
System.out.println(rb.getString("TSA.location.") +
- certUrl);
+ tsaURI);
}
System.out.println(rb.getString("TSA.certificate.") +
printCert("", tsaCert, false, 0, false));
diff --git a/jdk/src/share/classes/sun/security/tools/KeyTool.java b/jdk/src/share/classes/sun/security/tools/KeyTool.java
index 2e67bcea23b..0d928209807 100644
--- a/jdk/src/share/classes/sun/security/tools/KeyTool.java
+++ b/jdk/src/share/classes/sun/security/tools/KeyTool.java
@@ -38,10 +38,12 @@ import java.security.Signature;
import java.security.Timestamp;
import java.security.UnrecoverableEntryException;
import java.security.UnrecoverableKeyException;
+import java.security.NoSuchAlgorithmException;
import java.security.Principal;
import java.security.Provider;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
+import java.security.cert.CertStoreException;
import java.security.cert.CRL;
import java.security.cert.X509Certificate;
import java.security.cert.CertificateException;
@@ -63,23 +65,16 @@ import java.security.cert.X509CRLSelector;
import javax.security.auth.x500.X500Principal;
import sun.misc.BASE64Encoder;
import sun.security.util.ObjectIdentifier;
-import sun.security.pkcs.PKCS10;
+import sun.security.pkcs10.PKCS10;
+import sun.security.pkcs10.PKCS10Attribute;
import sun.security.provider.X509Factory;
+import sun.security.provider.certpath.CertStoreHelper;
import sun.security.util.Password;
-import sun.security.util.PathList;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
import sun.misc.BASE64Decoder;
-import sun.security.pkcs.PKCS10Attribute;
import sun.security.pkcs.PKCS9Attribute;
-import sun.security.provider.certpath.ldap.LDAPCertStoreHelper;
import sun.security.util.DerValue;
import sun.security.x509.*;
@@ -917,18 +912,13 @@ public final class KeyTool {
// Perform the specified command
if (command == CERTREQ) {
- PrintStream ps = null;
if (filename != null) {
- ps = new PrintStream(new FileOutputStream
- (filename));
- out = ps;
- }
- try {
- doCertReq(alias, sigAlgName, out);
- } finally {
- if (ps != null) {
- ps.close();
+ try (PrintStream ps = new PrintStream(new FileOutputStream
+ (filename))) {
+ doCertReq(alias, sigAlgName, ps);
}
+ } else {
+ doCertReq(alias, sigAlgName, out);
}
if (verbose && filename != null) {
MessageFormat form = new MessageFormat(rb.getString
@@ -941,18 +931,13 @@ public final class KeyTool {
doDeleteEntry(alias);
kssave = true;
} else if (command == EXPORTCERT) {
- PrintStream ps = null;
if (filename != null) {
- ps = new PrintStream(new FileOutputStream
- (filename));
- out = ps;
- }
- try {
- doExportCert(alias, out);
- } finally {
- if (ps != null) {
- ps.close();
+ try (PrintStream ps = new PrintStream(new FileOutputStream
+ (filename))) {
+ doExportCert(alias, ps);
}
+ } else {
+ doExportCert(alias, out);
}
if (filename != null) {
MessageFormat form = new MessageFormat(rb.getString
@@ -973,16 +958,12 @@ public final class KeyTool {
doGenSecretKey(alias, keyAlgName, keysize);
kssave = true;
} else if (command == IDENTITYDB) {
- InputStream inStream = System.in;
if (filename != null) {
- inStream = new FileInputStream(filename);
- }
- try {
- doImportIdentityDatabase(inStream);
- } finally {
- if (inStream != System.in) {
- inStream.close();
+ try (InputStream inStream = new FileInputStream(filename)) {
+ doImportIdentityDatabase(inStream);
}
+ } else {
+ doImportIdentityDatabase(System.in);
}
} else if (command == IMPORTCERT) {
InputStream inStream = System.in;
@@ -1101,29 +1082,21 @@ public final class KeyTool {
if (alias == null) {
alias = keyAlias;
}
- PrintStream ps = null;
if (filename != null) {
- ps = new PrintStream(new FileOutputStream(filename));
- out = ps;
- }
- try {
- doGenCRL(out);
- } finally {
- if (ps != null) {
- ps.close();
+ try (PrintStream ps =
+ new PrintStream(new FileOutputStream(filename))) {
+ doGenCRL(ps);
}
+ } else {
+ doGenCRL(out);
}
} else if (command == PRINTCERTREQ) {
- InputStream inStream = System.in;
if (filename != null) {
- inStream = new FileInputStream(filename);
- }
- try {
- doPrintCertReq(inStream, out);
- } finally {
- if (inStream != System.in) {
- inStream.close();
+ try (InputStream inStream = new FileInputStream(filename)) {
+ doPrintCertReq(inStream, out);
}
+ } else {
+ doPrintCertReq(System.in, out);
}
} else if (command == PRINTCRL) {
doPrintCRL(filename, out);
@@ -2070,12 +2043,13 @@ public final class KeyTool {
}
}
} else { // must be LDAP, and uri is not null
+ // Lazily load LDAPCertStoreHelper if present
+ CertStoreHelper helper = CertStoreHelper.getInstance("LDAP");
String path = uri.getPath();
if (path.charAt(0) == '/') path = path.substring(1);
- LDAPCertStoreHelper h = new LDAPCertStoreHelper();
- CertStore s = h.getCertStore(uri);
+ CertStore s = helper.getCertStore(uri);
X509CRLSelector sel =
- h.wrap(new X509CRLSelector(), null, path);
+ helper.wrap(new X509CRLSelector(), null, path);
return s.getCRLs(sel);
}
}
@@ -2259,18 +2233,12 @@ public final class KeyTool {
int pos = 0;
while (entries.hasMoreElements()) {
JarEntry je = entries.nextElement();
- InputStream is = null;
- try {
- is = jf.getInputStream(je);
+ try (InputStream is = jf.getInputStream(je)) {
while (is.read(buffer) != -1) {
// we just read. this will throw a SecurityException
// if a signature/digest check fails. This also
// populate the signers
}
- } finally {
- if (is != null) {
- is.close();
- }
}
CodeSigner[] signers = je.getCodeSigners();
if (signers != null) {
@@ -2316,85 +2284,52 @@ public final class KeyTool {
out.println(rb.getString("Not.a.signed.jar.file"));
}
} else if (sslserver != null) {
- SSLContext sc = SSLContext.getInstance("SSL");
- final boolean[] certPrinted = new boolean[1];
- sc.init(null, new TrustManager[] {
- new X509TrustManager() {
-
- public java.security.cert.X509Certificate[] getAcceptedIssuers() {
- return null;
- }
-
- public void checkClientTrusted(
- java.security.cert.X509Certificate[] certs, String authType) {
- }
-
- public void checkServerTrusted(
- java.security.cert.X509Certificate[] certs, String authType) {
- for (int i=0; i 0) {
- certPrinted[0] = true;
- }
- }
- }
- }, null);
- HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
- HttpsURLConnection.setDefaultHostnameVerifier(
- new HostnameVerifier() {
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
- });
- // HTTPS instead of raw SSL, so that -Dhttps.proxyHost and
- // -Dhttps.proxyPort can be used. Since we only go through
- // the handshake process, an HTTPS server is not needed.
- // This program should be able to deal with any SSL-based
- // network service.
- Exception ex = null;
+ // Lazily load SSLCertStoreHelper if present
+ CertStoreHelper helper = CertStoreHelper.getInstance("SSLServer");
+ CertStore cs = helper.getCertStore(new URI("https://" + sslserver));
+ Collection extends Certificate> chain;
try {
- new URL("https://" + sslserver).openConnection().connect();
- } catch (Exception e) {
- ex = e;
- }
- // If the certs are not printed out, we consider it an error even
- // if the URL connection is successful.
- if (!certPrinted[0]) {
- Exception e = new Exception(
- rb.getString("No.certificate.from.the.SSL.server"));
- if (ex != null) {
- e.initCause(ex);
+ chain = cs.getCertificates(null);
+ if (chain.isEmpty()) {
+ // If the certs are not retrieved, we consider it an error
+ // even if the URL connection is successful.
+ throw new Exception(rb.getString(
+ "No.certificate.from.the.SSL.server"));
+ }
+ } catch (CertStoreException cse) {
+ if (cse.getCause() instanceof IOException) {
+ throw new Exception(rb.getString(
+ "No.certificate.from.the.SSL.server"),
+ cse.getCause());
+ } else {
+ throw cse;
+ }
+ }
+
+ int i = 0;
+ for (Certificate cert : chain) {
+ try {
+ if (rfc) {
+ dumpCert(cert, out);
+ } else {
+ out.println("Certificate #" + i++);
+ out.println("====================================");
+ printX509Cert((X509Certificate)cert, out);
+ out.println();
+ }
+ } catch (Exception e) {
+ if (debug) {
+ e.printStackTrace();
+ }
}
- throw e;
}
} else {
- InputStream inStream = System.in;
if (filename != null) {
- inStream = new FileInputStream(filename);
- }
- try {
- printCertFromStream(inStream, out);
- } finally {
- if (inStream != System.in) {
- inStream.close();
+ try (FileInputStream inStream = new FileInputStream(filename)) {
+ printCertFromStream(inStream, out);
}
+ } else {
+ printCertFromStream(System.in, out);
}
}
}
@@ -2590,9 +2525,7 @@ public final class KeyTool {
X509Certificate cert = null;
try {
cert = (X509Certificate)cf.generateCertificate(in);
- } catch (ClassCastException cce) {
- throw new Exception(rb.getString("Input.not.an.X.509.certificate"));
- } catch (CertificateException ce) {
+ } catch (ClassCastException | CertificateException ce) {
throw new Exception(rb.getString("Input.not.an.X.509.certificate"));
}
@@ -3441,16 +3374,10 @@ public final class KeyTool {
if (!file.exists()) {
return null;
}
- FileInputStream fis = null;
KeyStore caks = null;
- try {
- fis = new FileInputStream(file);
+ try (FileInputStream fis = new FileInputStream(file)) {
caks = KeyStore.getInstance(JKS);
caks.load(fis, null);
- } finally {
- if (fis != null) {
- fis.close();
- }
}
return caks;
}
diff --git a/jdk/src/share/classes/sun/security/util/PathList.java b/jdk/src/share/classes/sun/security/tools/PathList.java
similarity index 97%
rename from jdk/src/share/classes/sun/security/util/PathList.java
rename to jdk/src/share/classes/sun/security/tools/PathList.java
index 4d1fa71d704..f059a5ea1aa 100644
--- a/jdk/src/share/classes/sun/security/util/PathList.java
+++ b/jdk/src/share/classes/sun/security/tools/PathList.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
* questions.
*/
-package sun.security.util;
+package sun.security.tools;
import java.io.File;
import java.io.IOException;
diff --git a/jdk/src/share/classes/sun/security/tools/TimestampedSigner.java b/jdk/src/share/classes/sun/security/tools/TimestampedSigner.java
index 94a6a8b158c..4848a40dcbc 100644
--- a/jdk/src/share/classes/sun/security/tools/TimestampedSigner.java
+++ b/jdk/src/share/classes/sun/security/tools/TimestampedSigner.java
@@ -25,22 +25,14 @@
package sun.security.tools;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.math.BigInteger;
import java.net.URI;
-import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import java.security.Principal;
-import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
-import java.util.List;
import com.sun.jarsigner.*;
-import java.util.Arrays;
-import sun.security.pkcs.*;
-import sun.security.timestamp.*;
+import sun.security.pkcs.PKCS7;
import sun.security.util.*;
import sun.security.x509.*;
@@ -56,36 +48,12 @@ import sun.security.x509.*;
public final class TimestampedSigner extends ContentSigner {
- /*
- * Random number generator for creating nonce values
- */
- private static final SecureRandom RANDOM;
- static {
- SecureRandom tmp = null;
- try {
- tmp = SecureRandom.getInstance("SHA1PRNG");
- } catch (NoSuchAlgorithmException e) {
- // should not happen
- }
- RANDOM = tmp;
- }
-
/*
* Object identifier for the subject information access X.509 certificate
* extension.
*/
private static final String SUBJECT_INFO_ACCESS_OID = "1.3.6.1.5.5.7.1.11";
- /*
- * Object identifier for the timestamping key purpose.
- */
- private static final String KP_TIMESTAMPING_OID = "1.3.6.1.5.5.7.3.8";
-
- /*
- * Object identifier for extendedKeyUsage extension
- */
- private static final String EXTENDED_KEY_USAGE_OID = "2.5.29.37";
-
/*
* Object identifier for the timestamping access descriptors.
*/
@@ -100,26 +68,6 @@ public final class TimestampedSigner extends ContentSigner {
AD_TIMESTAMPING_Id = tmp;
}
- /*
- * Location of the TSA.
- */
- private String tsaUrl = null;
-
- /*
- * TSA's X.509 certificate.
- */
- private X509Certificate tsaCertificate = null;
-
- /*
- * Generates an SHA-1 hash value for the data to be timestamped.
- */
- private MessageDigest messageDigest = null;
-
- /*
- * Parameters for the timestamping protocol.
- */
- private boolean tsRequestCertificate = true;
-
/**
* Instantiates a content signer that supports timestamped signatures.
*/
@@ -134,7 +82,7 @@ public final class TimestampedSigner extends ContentSigner {
* and optionally the content that was signed, are packaged into a PKCS #7
* signed data message.
*
- * @param parameters The non-null input parameters.
+ * @param params The non-null input parameters.
* @param omitContent true if the content should be omitted from the
* signed data message. Otherwise the content is included.
* @param applyTimestamp true if the signature should be timestamped.
@@ -151,98 +99,41 @@ public final class TimestampedSigner extends ContentSigner {
* @throws NullPointerException The exception is thrown if parameters is
* null.
*/
- public byte[] generateSignedData(ContentSignerParameters parameters,
+ public byte[] generateSignedData(ContentSignerParameters params,
boolean omitContent, boolean applyTimestamp)
throws NoSuchAlgorithmException, CertificateException, IOException {
- if (parameters == null) {
+ if (params == null) {
throw new NullPointerException();
}
- // Parse the signature algorithm to extract the digest and key
- // algorithms. The expected format is:
+ // Parse the signature algorithm to extract the digest
+ // algorithm. The expected format is:
// "with"
// or "withand"
- String signatureAlgorithm = parameters.getSignatureAlgorithm();
- String keyAlgorithm =
- AlgorithmId.getEncAlgFromSigAlg(signatureAlgorithm);
- String digestAlgorithm =
- AlgorithmId.getDigAlgFromSigAlg(signatureAlgorithm);
- AlgorithmId digestAlgorithmId = AlgorithmId.get(digestAlgorithm);
+ String signatureAlgorithm = params.getSignatureAlgorithm();
- // Examine signer's certificate
- X509Certificate[] signerCertificateChain =
- parameters.getSignerCertificateChain();
- Principal issuerName = signerCertificateChain[0].getIssuerDN();
- if (!(issuerName instanceof X500Name)) {
- // must extract the original encoded form of DN for subsequent
- // name comparison checks (converting to a String and back to
- // an encoded DN could cause the types of String attribute
- // values to be changed)
- X509CertInfo tbsCert = new
- X509CertInfo(signerCertificateChain[0].getTBSCertificate());
- issuerName = (Principal)
- tbsCert.get(CertificateIssuerName.NAME + "." +
- CertificateIssuerName.DN_NAME);
- }
- BigInteger serialNumber = signerCertificateChain[0].getSerialNumber();
+ X509Certificate[] signerChain = params.getSignerCertificateChain();
+ byte[] signature = params.getSignature();
// Include or exclude content
- byte[] content = parameters.getContent();
- ContentInfo contentInfo;
- if (omitContent) {
- contentInfo = new ContentInfo(ContentInfo.DATA_OID, null);
- } else {
- contentInfo = new ContentInfo(content);
- }
+ byte[] content = (omitContent == true) ? null : params.getContent();
- // Generate the timestamp token
- byte[] signature = parameters.getSignature();
- SignerInfo signerInfo = null;
+ URI tsaURI = null;
if (applyTimestamp) {
-
- tsaCertificate = parameters.getTimestampingAuthorityCertificate();
- URI tsaUri = parameters.getTimestampingAuthority();
- if (tsaUri != null) {
- tsaUrl = tsaUri.toString();
- } else {
+ tsaURI = params.getTimestampingAuthority();
+ if (tsaURI == null) {
// Examine TSA cert
- String certUrl = getTimestampingUrl(tsaCertificate);
- if (certUrl == null) {
+ tsaURI = getTimestampingURI(
+ params.getTimestampingAuthorityCertificate());
+ if (tsaURI == null) {
throw new CertificateException(
"Subject Information Access extension not found");
}
- tsaUrl = certUrl;
}
-
- // Timestamp the signature
- byte[] tsToken = generateTimestampToken(signature);
-
- // Insert the timestamp token into the PKCS #7 signer info element
- // (as an unsigned attribute)
- PKCS9Attributes unsignedAttrs =
- new PKCS9Attributes(new PKCS9Attribute[]{
- new PKCS9Attribute(
- PKCS9Attribute.SIGNATURE_TIMESTAMP_TOKEN_STR,
- tsToken)});
- signerInfo = new SignerInfo((X500Name)issuerName, serialNumber,
- digestAlgorithmId, null, AlgorithmId.get(keyAlgorithm),
- signature, unsignedAttrs);
- } else {
- signerInfo = new SignerInfo((X500Name)issuerName, serialNumber,
- digestAlgorithmId, AlgorithmId.get(keyAlgorithm), signature);
}
-
- SignerInfo[] signerInfos = {signerInfo};
- AlgorithmId[] algorithms = {digestAlgorithmId};
-
- // Create the PKCS #7 signed data message
- PKCS7 p7 = new PKCS7(algorithms, contentInfo, signerCertificateChain,
- null, signerInfos);
- ByteArrayOutputStream p7out = new ByteArrayOutputStream();
- p7.encodeSignedData(p7out);
-
- return p7out.toByteArray();
+ return PKCS7.generateSignedData(signature, signerChain, content,
+ params.getSignatureAlgorithm(), tsaURI);
}
/**
@@ -253,9 +144,9 @@ public final class TimestampedSigner extends ContentSigner {
* accessLocation field should contain an HTTP or HTTPS URL.
*
* @param tsaCertificate An X.509 certificate for the TSA.
- * @return An HTTP or HTTPS URL or null if none was found.
+ * @return An HTTP or HTTPS URI or null if none was found.
*/
- public static String getTimestampingUrl(X509Certificate tsaCertificate) {
+ public static URI getTimestampingURI(X509Certificate tsaCertificate) {
if (tsaCertificate == null) {
return null;
@@ -282,7 +173,7 @@ public final class TimestampedSigner extends ContentSigner {
uri = (URIName) location.getName();
if (uri.getScheme().equalsIgnoreCase("http") ||
uri.getScheme().equalsIgnoreCase("https")) {
- return uri.getName();
+ return uri.getURI();
}
}
}
@@ -292,97 +183,4 @@ public final class TimestampedSigner extends ContentSigner {
}
return null;
}
-
- /*
- * Returns a timestamp token from a TSA for the given content.
- * Performs a basic check on the token to confirm that it has been signed
- * by a certificate that is permitted to sign timestamps.
- *
- * @param toBeTimestamped The data to be timestamped.
- * @throws IOException The exception is throw if an error occurs while
- * communicating with the TSA.
- * @throws CertificateException The exception is throw if the TSA's
- * certificate is not permitted for timestamping.
- */
- private byte[] generateTimestampToken(byte[] toBeTimestamped)
- throws CertificateException, IOException {
-
- // Generate hash value for the data to be timestamped
- // SHA-1 is always used.
- if (messageDigest == null) {
- try {
- messageDigest = MessageDigest.getInstance("SHA-1");
- } catch (NoSuchAlgorithmException e) {
- // ignore
- }
- }
- byte[] digest = messageDigest.digest(toBeTimestamped);
-
- // Generate a timestamp
- TSRequest tsQuery = new TSRequest(digest, "SHA-1");
- // Generate a nonce
- BigInteger nonce = null;
- if (RANDOM != null) {
- nonce = new BigInteger(64, RANDOM);
- tsQuery.setNonce(nonce);
- }
- tsQuery.requestCertificate(tsRequestCertificate);
-
- Timestamper tsa = new HttpTimestamper(tsaUrl); // use supplied TSA
- TSResponse tsReply = tsa.generateTimestamp(tsQuery);
- int status = tsReply.getStatusCode();
- // Handle TSP error
- if (status != 0 && status != 1) {
- int failureCode = tsReply.getFailureCode();
- if (failureCode == -1) {
- throw new IOException("Error generating timestamp: " +
- tsReply.getStatusCodeAsText());
- } else {
- throw new IOException("Error generating timestamp: " +
- tsReply.getStatusCodeAsText() + " " +
- tsReply.getFailureCodeAsText());
- }
- }
- PKCS7 tsToken = tsReply.getToken();
-
- TimestampToken tst = new TimestampToken(tsToken.getContentInfo().getData());
- if (!tst.getHashAlgorithm().equals(
- new AlgorithmId(new ObjectIdentifier("1.3.14.3.2.26")))) {
- throw new IOException("Digest algorithm not SHA-1 in timestamp token");
- }
- if (!Arrays.equals(tst.getHashedMessage(), digest)) {
- throw new IOException("Digest octets changed in timestamp token");
- }
-
- BigInteger replyNonce = tst.getNonce();
- if (replyNonce == null && nonce != null) {
- throw new IOException("Nonce missing in timestamp token");
- }
- if (replyNonce != null && !replyNonce.equals(nonce)) {
- throw new IOException("Nonce changed in timestamp token");
- }
-
- // Examine the TSA's certificate (if present)
- for (SignerInfo si: tsToken.getSignerInfos()) {
- X509Certificate cert = si.getCertificate(tsToken);
- if (cert == null) {
- // Error, we've already set tsRequestCertificate = true
- throw new CertificateException(
- "Certificate not included in timestamp token");
- } else {
- if (!cert.getCriticalExtensionOIDs().contains(
- EXTENDED_KEY_USAGE_OID)) {
- throw new CertificateException(
- "Certificate is not valid for timestamping");
- }
- List keyPurposes = cert.getExtendedKeyUsage();
- if (keyPurposes == null ||
- ! keyPurposes.contains(KP_TIMESTAMPING_OID)) {
- throw new CertificateException(
- "Certificate is not valid for timestamping");
- }
- }
- }
- return tsReply.getEncodedToken();
- }
}
diff --git a/jdk/src/share/classes/sun/security/util/BigInt.java b/jdk/src/share/classes/sun/security/util/BigInt.java
deleted file mode 100644
index 4713cc4d9fb..00000000000
--- a/jdk/src/share/classes/sun/security/util/BigInt.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (c) 1996, 2006, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.util;
-
-import java.math.BigInteger;
-
-
-/**
- * A low-overhead arbitrary-precision unsigned integer.
- * This is intended for use with ASN.1 parsing, and printing of
- * such parsed values. Convert to "BigInteger" if you need to do
- * arbitrary precision arithmetic, rather than just represent
- * the number as a wrapped array of bytes.
- *
- * NOTE: This class may eventually disappear, to
- * be supplanted by big-endian byte arrays which hold both signed
- * and unsigned arbitrary-precision integers.
- *
- * @author David Brownell
- */
-public final class BigInt {
-
- // Big endian -- MSB first.
- private byte[] places;
-
- /**
- * Constructs a "Big" integer from a set of (big-endian) bytes.
- * Leading zeroes should be stripped off.
- *
- * @param data a sequence of bytes, most significant bytes/digits
- * first. CONSUMED.
- */
- public BigInt(byte[] data) { places = data.clone(); }
-
- /**
- * Constructs a "Big" integer from a "BigInteger", which must be
- * positive (or zero) in value.
- */
- public BigInt(BigInteger i) {
- byte[] temp = i.toByteArray();
-
- if ((temp[0] & 0x80) != 0)
- throw new IllegalArgumentException("negative BigInteger");
-
- // XXX we assume exactly _one_ sign byte is used...
-
- if (temp[0] != 0)
- places = temp;
- else {
- places = new byte[temp.length - 1];
- for (int j = 1; j < temp.length; j++)
- places[j - 1] = temp[j];
- }
- }
-
- /**
- * Constructs a "Big" integer from a normal Java integer.
- *
- * @param i the java primitive integer
- */
- public BigInt(int i) {
- if (i < (1 << 8)) {
- places = new byte[1];
- places[0] = (byte) i;
- } else if (i < (1 << 16)) {
- places = new byte[2];
- places[0] = (byte) (i >> 8);
- places[1] = (byte) i;
- } else if (i < (1 << 24)) {
- places = new byte[3];
- places[0] = (byte) (i >> 16);
- places[1] = (byte) (i >> 8);
- places[2] = (byte) i;
- } else {
- places = new byte[4];
- places[0] = (byte) (i >> 24);
- places[1] = (byte) (i >> 16);
- places[2] = (byte) (i >> 8);
- places[3] = (byte) i;
- }
- }
-
- /**
- * Converts the "big" integer to a java primitive integer.
- *
- * @excpet NumberFormatException if 32 bits is insufficient.
- */
- public int toInt() {
- if (places.length > 4)
- throw new NumberFormatException("BigInt.toLong, too big");
- int retval = 0, i = 0;
- for (; i < places.length; i++)
- retval = (retval << 8) + ((int)places[i] & 0xff);
- return retval;
- }
-
- /**
- * Returns a hexadecimal printed representation. The value is
- * formatted to fit on lines of at least 75 characters, with
- * embedded newlines. Words are separated for readability,
- * with eight words (32 bytes) per line.
- */
- public String toString() { return hexify(); }
-
- /**
- * Returns a BigInteger value which supports many arithmetic
- * operations. Assumes negative values will never occur.
- */
- public BigInteger toBigInteger()
- { return new BigInteger(1, places); }
-
- /**
- * Returns the data as a byte array. The most significant bit
- * of the array is bit zero (as in java.math.BigInteger).
- */
- public byte[] toByteArray() { return places.clone(); }
-
- private static final String digits = "0123456789abcdef";
- private String hexify() {
- if (places.length == 0)
- return " 0 ";
-
- StringBuffer buf = new StringBuffer(places.length * 2);
- buf.append(" "); // four spaces
- for (int i = 0; i < places.length; i++) {
- buf.append(digits.charAt((places[i] >> 4) & 0x0f));
- buf.append(digits.charAt(places[i] & 0x0f));
- if (((i + 1) % 32) == 0) {
- if ((i + 1) != places.length)
- buf.append("\n "); // line after four words
- } else if (((i + 1) % 4) == 0)
- buf.append(' '); // space between words
- }
- return buf.toString();
- }
-
- /**
- * Returns true iff the parameter is a numerically equivalent
- * BigInt.
- *
- * @param other the object being compared with this one.
- */
- public boolean equals(Object other) {
- if (other instanceof BigInt)
- return equals((BigInt) other);
- return false;
- }
-
- /**
- * Returns true iff the parameter is numerically equivalent.
- *
- * @param other the BigInt being compared with this one.
- */
- public boolean equals(BigInt other) {
- if (this == other)
- return true;
-
- byte[] otherPlaces = other.toByteArray();
- if (places.length != otherPlaces.length)
- return false;
- for (int i = 0; i < places.length; i++)
- if (places[i] != otherPlaces[i])
- return false;
- return true;
- }
-
- /**
- * Returns a hashcode for this BigInt.
- *
- * @return a hashcode for this BigInt.
- */
- public int hashCode() {
- return hexify().hashCode();
- }
-}
diff --git a/jdk/src/share/classes/sun/security/util/Cache.java b/jdk/src/share/classes/sun/security/util/Cache.java
index 7c7f072b5de..8037324928a 100644
--- a/jdk/src/share/classes/sun/security/util/Cache.java
+++ b/jdk/src/share/classes/sun/security/util/Cache.java
@@ -43,7 +43,7 @@ import java.lang.ref.*;
*
* . optional lifetime, specified in seconds.
*
- * . save for concurrent use by multiple threads
+ * . safe for concurrent use by multiple threads
*
* . values are held by either standard references or via SoftReferences.
* SoftReferences have the advantage that they are automatically cleared
@@ -69,7 +69,7 @@ import java.lang.ref.*;
*
* @author Andreas Sterbenz
*/
-public abstract class Cache {
+public abstract class Cache {
protected Cache() {
// empty
@@ -88,12 +88,12 @@ public abstract class Cache {
/**
* Add an entry to the cache.
*/
- public abstract void put(Object key, Object value);
+ public abstract void put(K key, V value);
/**
* Get a value from the cache.
*/
- public abstract Object get(Object key);
+ public abstract V get(Object key);
/**
* Remove an entry from the cache.
@@ -113,14 +113,14 @@ public abstract class Cache {
/**
* accept a visitor
*/
- public abstract void accept(CacheVisitor visitor);
+ public abstract void accept(CacheVisitor visitor);
/**
* Return a new memory cache with the specified maximum size, unlimited
* lifetime for entries, with the values held by SoftReferences.
*/
- public static Cache newSoftMemoryCache(int size) {
- return new MemoryCache(true, size);
+ public static Cache newSoftMemoryCache(int size) {
+ return new MemoryCache<>(true, size);
}
/**
@@ -128,23 +128,24 @@ public abstract class Cache {
* specified maximum lifetime (in seconds), with the values held
* by SoftReferences.
*/
- public static Cache newSoftMemoryCache(int size, int timeout) {
- return new MemoryCache(true, size, timeout);
+ public static Cache newSoftMemoryCache(int size, int timeout) {
+ return new MemoryCache<>(true, size, timeout);
}
/**
* Return a new memory cache with the specified maximum size, unlimited
* lifetime for entries, with the values held by standard references.
*/
- public static Cache newHardMemoryCache(int size) {
- return new MemoryCache(false, size);
+ public static Cache newHardMemoryCache(int size) {
+ return new MemoryCache<>(false, size);
}
/**
* Return a dummy cache that does nothing.
*/
- public static Cache newNullCache() {
- return NullCache.INSTANCE;
+ @SuppressWarnings("unchecked")
+ public static Cache newNullCache() {
+ return (Cache) NullCache.INSTANCE;
}
/**
@@ -152,8 +153,8 @@ public abstract class Cache {
* specified maximum lifetime (in seconds), with the values held
* by standard references.
*/
- public static Cache newHardMemoryCache(int size, int timeout) {
- return new MemoryCache(false, size, timeout);
+ public static Cache newHardMemoryCache(int size, int timeout) {
+ return new MemoryCache<>(false, size, timeout);
}
/**
@@ -193,15 +194,15 @@ public abstract class Cache {
}
}
- public interface CacheVisitor {
- public void visit(Map map);
+ public interface CacheVisitor {
+ public void visit(Map map);
}
}
-class NullCache extends Cache {
+class NullCache extends Cache {
- final static Cache INSTANCE = new NullCache();
+ final static Cache INSTANCE = new NullCache<>();
private NullCache() {
// empty
@@ -215,11 +216,11 @@ class NullCache extends Cache {
// empty
}
- public void put(Object key, Object value) {
+ public void put(K key, V value) {
// empty
}
- public Object get(Object key) {
+ public V get(Object key) {
return null;
}
@@ -235,23 +236,26 @@ class NullCache extends Cache {
// empty
}
- public void accept(CacheVisitor visitor) {
+ public void accept(CacheVisitor visitor) {
// empty
}
}
-class MemoryCache extends Cache {
+class MemoryCache extends Cache {
private final static float LOAD_FACTOR = 0.75f;
// XXXX
private final static boolean DEBUG = false;
- private final Map cacheMap;
+ private final Map> cacheMap;
private int maxSize;
private long lifetime;
- private final ReferenceQueue queue;
+
+ // ReferenceQueue is of type V instead of Cache
+ // to allow SoftCacheEntry to extend SoftReference
+ private final ReferenceQueue queue;
public MemoryCache(boolean soft, int maxSize) {
this(soft, maxSize, 0);
@@ -260,10 +264,13 @@ class MemoryCache extends Cache {
public MemoryCache(boolean soft, int maxSize, int lifetime) {
this.maxSize = maxSize;
this.lifetime = lifetime * 1000;
- this.queue = soft ? new ReferenceQueue() : null;
+ if (soft)
+ this.queue = new ReferenceQueue<>();
+ else
+ this.queue = null;
+
int buckets = (int)(maxSize / LOAD_FACTOR) + 1;
- cacheMap = new LinkedHashMap(buckets,
- LOAD_FACTOR, true);
+ cacheMap = new LinkedHashMap<>(buckets, LOAD_FACTOR, true);
}
/**
@@ -279,16 +286,17 @@ class MemoryCache extends Cache {
}
int startSize = cacheMap.size();
while (true) {
- CacheEntry entry = (CacheEntry)queue.poll();
+ @SuppressWarnings("unchecked")
+ CacheEntry entry = (CacheEntry)queue.poll();
if (entry == null) {
break;
}
- Object key = entry.getKey();
+ K key = entry.getKey();
if (key == null) {
// key is null, entry has already been removed
continue;
}
- CacheEntry currentEntry = cacheMap.remove(key);
+ CacheEntry currentEntry = cacheMap.remove(key);
// check if the entry in the map corresponds to the expired
// entry. If not, readd the entry
if ((currentEntry != null) && (entry != currentEntry)) {
@@ -314,9 +322,9 @@ class MemoryCache extends Cache {
}
int cnt = 0;
long time = System.currentTimeMillis();
- for (Iterator t = cacheMap.values().iterator();
+ for (Iterator> t = cacheMap.values().iterator();
t.hasNext(); ) {
- CacheEntry entry = t.next();
+ CacheEntry entry = t.next();
if (entry.isValid(time) == false) {
t.remove();
cnt++;
@@ -339,7 +347,7 @@ class MemoryCache extends Cache {
if (queue != null) {
// if this is a SoftReference cache, first invalidate() all
// entries so that GC does not have to enqueue them
- for (CacheEntry entry : cacheMap.values()) {
+ for (CacheEntry entry : cacheMap.values()) {
entry.invalidate();
}
while (queue.poll() != null) {
@@ -349,12 +357,12 @@ class MemoryCache extends Cache {
cacheMap.clear();
}
- public synchronized void put(Object key, Object value) {
+ public synchronized void put(K key, V value) {
emptyQueue();
long expirationTime = (lifetime == 0) ? 0 :
System.currentTimeMillis() + lifetime;
- CacheEntry newEntry = newEntry(key, value, expirationTime, queue);
- CacheEntry oldEntry = cacheMap.put(key, newEntry);
+ CacheEntry newEntry = newEntry(key, value, expirationTime, queue);
+ CacheEntry oldEntry = cacheMap.put(key, newEntry);
if (oldEntry != null) {
oldEntry.invalidate();
return;
@@ -362,8 +370,8 @@ class MemoryCache extends Cache {
if (maxSize > 0 && cacheMap.size() > maxSize) {
expungeExpiredEntries();
if (cacheMap.size() > maxSize) { // still too large?
- Iterator t = cacheMap.values().iterator();
- CacheEntry lruEntry = t.next();
+ Iterator> t = cacheMap.values().iterator();
+ CacheEntry lruEntry = t.next();
if (DEBUG) {
System.out.println("** Overflow removal "
+ lruEntry.getKey() + " | " + lruEntry.getValue());
@@ -374,9 +382,9 @@ class MemoryCache extends Cache {
}
}
- public synchronized Object get(Object key) {
+ public synchronized V get(Object key) {
emptyQueue();
- CacheEntry entry = cacheMap.get(key);
+ CacheEntry entry = cacheMap.get(key);
if (entry == null) {
return null;
}
@@ -393,7 +401,7 @@ class MemoryCache extends Cache {
public synchronized void remove(Object key) {
emptyQueue();
- CacheEntry entry = cacheMap.remove(key);
+ CacheEntry entry = cacheMap.remove(key);
if (entry != null) {
entry.invalidate();
}
@@ -402,9 +410,9 @@ class MemoryCache extends Cache {
public synchronized void setCapacity(int size) {
expungeExpiredEntries();
if (size > 0 && cacheMap.size() > size) {
- Iterator t = cacheMap.values().iterator();
+ Iterator> t = cacheMap.values().iterator();
for (int i = cacheMap.size() - size; i > 0; i--) {
- CacheEntry lruEntry = t.next();
+ CacheEntry lruEntry = t.next();
if (DEBUG) {
System.out.println("** capacity reset removal "
+ lruEntry.getKey() + " | " + lruEntry.getValue());
@@ -431,60 +439,61 @@ class MemoryCache extends Cache {
}
// it is a heavyweight method.
- public synchronized void accept(CacheVisitor visitor) {
+ public synchronized void accept(CacheVisitor visitor) {
expungeExpiredEntries();
- Map cached = getCachedEntries();
+ Map cached = getCachedEntries();
visitor.visit(cached);
}
- private Map getCachedEntries() {
- Map kvmap = new HashMap(cacheMap.size());
+ private Map getCachedEntries() {
+ Map kvmap = new HashMap<>(cacheMap.size());
- for (CacheEntry entry : cacheMap.values()) {
+ for (CacheEntry entry : cacheMap.values()) {
kvmap.put(entry.getKey(), entry.getValue());
}
return kvmap;
}
- protected CacheEntry newEntry(Object key, Object value,
- long expirationTime, ReferenceQueue queue) {
+ protected CacheEntry newEntry(K key, V value,
+ long expirationTime, ReferenceQueue queue) {
if (queue != null) {
- return new SoftCacheEntry(key, value, expirationTime, queue);
+ return new SoftCacheEntry<>(key, value, expirationTime, queue);
} else {
- return new HardCacheEntry(key, value, expirationTime);
+ return new HardCacheEntry<>(key, value, expirationTime);
}
}
- private static interface CacheEntry {
+ private static interface CacheEntry {
boolean isValid(long currentTime);
void invalidate();
- Object getKey();
+ K getKey();
- Object getValue();
+ V getValue();
}
- private static class HardCacheEntry implements CacheEntry {
+ private static class HardCacheEntry implements CacheEntry {
- private Object key, value;
+ private K key;
+ private V value;
private long expirationTime;
- HardCacheEntry(Object key, Object value, long expirationTime) {
+ HardCacheEntry(K key, V value, long expirationTime) {
this.key = key;
this.value = value;
this.expirationTime = expirationTime;
}
- public Object getKey() {
+ public K getKey() {
return key;
}
- public Object getValue() {
+ public V getValue() {
return value;
}
@@ -503,24 +512,25 @@ class MemoryCache extends Cache {
}
}
- private static class SoftCacheEntry
- extends SoftReference implements CacheEntry {
+ private static class SoftCacheEntry
+ extends SoftReference
+ implements CacheEntry {
- private Object key;
+ private K key;
private long expirationTime;
- SoftCacheEntry(Object key, Object value, long expirationTime,
- ReferenceQueue queue) {
+ SoftCacheEntry(K key, V value, long expirationTime,
+ ReferenceQueue queue) {
super(value, queue);
this.key = key;
this.expirationTime = expirationTime;
}
- public Object getKey() {
+ public K getKey() {
return key;
}
- public Object getValue() {
+ public V getValue() {
return get();
}
diff --git a/jdk/src/share/classes/sun/security/util/Debug.java b/jdk/src/share/classes/sun/security/util/Debug.java
index 5701a80cf9f..3356cf856e1 100644
--- a/jdk/src/share/classes/sun/security/util/Debug.java
+++ b/jdk/src/share/classes/sun/security/util/Debug.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -80,6 +80,7 @@ public class Debug {
System.err.println("policy loading and granting");
System.err.println("provider security provider debugging");
System.err.println("scl permissions SecureClassLoader assigns");
+ System.err.println("ts timestamping");
System.err.println();
System.err.println("The following can be used with access:");
System.err.println();
diff --git a/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java b/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java
index 1c818f8945b..715a5da356b 100644
--- a/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java
+++ b/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java
@@ -35,7 +35,6 @@ import java.util.*;
import java.util.jar.*;
import sun.security.pkcs.*;
-import sun.security.timestamp.TimestampToken;
import sun.misc.BASE64Decoder;
import sun.security.jca.Providers;
@@ -485,7 +484,7 @@ public class SignatureFileVerifier {
signers = new ArrayList();
}
// Append the new code signer
- signers.add(new CodeSigner(certChain, getTimestamp(info)));
+ signers.add(new CodeSigner(certChain, info.getTimestamp()));
if (debug != null) {
debug.println("Signature Block Certificate: " +
@@ -500,62 +499,6 @@ public class SignatureFileVerifier {
}
}
- /*
- * Examines a signature timestamp token to generate a timestamp object.
- *
- * Examines the signer's unsigned attributes for a
- * signatureTimestampToken attribute. If present,
- * then it is parsed to extract the date and time at which the
- * timestamp was generated.
- *
- * @param info A signer information element of a PKCS 7 block.
- *
- * @return A timestamp token or null if none is present.
- * @throws IOException if an error is encountered while parsing the
- * PKCS7 data.
- * @throws NoSuchAlgorithmException if an error is encountered while
- * verifying the PKCS7 object.
- * @throws SignatureException if an error is encountered while
- * verifying the PKCS7 object.
- * @throws CertificateException if an error is encountered while generating
- * the TSA's certpath.
- */
- private Timestamp getTimestamp(SignerInfo info)
- throws IOException, NoSuchAlgorithmException, SignatureException,
- CertificateException {
-
- Timestamp timestamp = null;
-
- // Extract the signer's unsigned attributes
- PKCS9Attributes unsignedAttrs = info.getUnauthenticatedAttributes();
- if (unsignedAttrs != null) {
- PKCS9Attribute timestampTokenAttr =
- unsignedAttrs.getAttribute("signatureTimestampToken");
- if (timestampTokenAttr != null) {
- PKCS7 timestampToken =
- new PKCS7((byte[])timestampTokenAttr.getValue());
- // Extract the content (an encoded timestamp token info)
- byte[] encodedTimestampTokenInfo =
- timestampToken.getContentInfo().getData();
- // Extract the signer (the Timestamping Authority)
- // while verifying the content
- SignerInfo[] tsa =
- timestampToken.verify(encodedTimestampTokenInfo);
- // Expect only one signer
- ArrayList chain =
- tsa[0].getCertificateChain(timestampToken);
- CertPath tsaChain = certificateFactory.generateCertPath(chain);
- // Create a timestamp token info object
- TimestampToken timestampTokenInfo =
- new TimestampToken(encodedTimestampTokenInfo);
- // Create a timestamp object
- timestamp =
- new Timestamp(timestampTokenInfo.getDate(), tsaChain);
- }
- }
- return timestamp;
- }
-
// for the toHex function
private static final char[] hexc =
{'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
diff --git a/jdk/src/share/classes/sun/swing/SwingUtilities2.java b/jdk/src/share/classes/sun/swing/SwingUtilities2.java
index fc7fbf43f13..2094ec0c11d 100644
--- a/jdk/src/share/classes/sun/swing/SwingUtilities2.java
+++ b/jdk/src/share/classes/sun/swing/SwingUtilities2.java
@@ -524,56 +524,67 @@ public class SwingUtilities2 {
}
// If we get here we're not printing
- AATextInfo info = drawTextAntialiased(c);
- if (info != null && (g instanceof Graphics2D)) {
+ if (g instanceof Graphics2D) {
+ AATextInfo info = drawTextAntialiased(c);
Graphics2D g2 = (Graphics2D)g;
- Object oldContrast = null;
- Object oldAAValue = g2.getRenderingHint(KEY_TEXT_ANTIALIASING);
- if (info.aaHint != oldAAValue) {
- g2.setRenderingHint(KEY_TEXT_ANTIALIASING, info.aaHint);
- } else {
- oldAAValue = null;
- }
- if (info.lcdContrastHint != null) {
- oldContrast = g2.getRenderingHint(KEY_TEXT_LCD_CONTRAST);
- if (info.lcdContrastHint.equals(oldContrast)) {
- oldContrast = null;
- } else {
- g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST,
- info.lcdContrastHint);
- }
- }
-
boolean needsTextLayout = ((c != null) &&
(c.getClientProperty(TextAttribute.NUMERIC_SHAPING) != null));
+
if (needsTextLayout) {
synchronized(charsBufferLock) {
int length = syncCharsBuffer(text);
needsTextLayout = isComplexLayout(charsBuffer, 0, length);
}
}
- if (needsTextLayout) {
+
+ if (info != null) {
+ Object oldContrast = null;
+ Object oldAAValue = g2.getRenderingHint(KEY_TEXT_ANTIALIASING);
+ if (info.aaHint != oldAAValue) {
+ g2.setRenderingHint(KEY_TEXT_ANTIALIASING, info.aaHint);
+ } else {
+ oldAAValue = null;
+ }
+ if (info.lcdContrastHint != null) {
+ oldContrast = g2.getRenderingHint(KEY_TEXT_LCD_CONTRAST);
+ if (info.lcdContrastHint.equals(oldContrast)) {
+ oldContrast = null;
+ } else {
+ g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST,
+ info.lcdContrastHint);
+ }
+ }
+
+ if (needsTextLayout) {
+ TextLayout layout = createTextLayout(c, text, g2.getFont(),
+ g2.getFontRenderContext());
+ layout.draw(g2, x, y);
+ } else {
+ g.drawString(text, x, y);
+ }
+
+ if (oldAAValue != null) {
+ g2.setRenderingHint(KEY_TEXT_ANTIALIASING, oldAAValue);
+ }
+ if (oldContrast != null) {
+ g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST, oldContrast);
+ }
+
+ return;
+ }
+
+ if (needsTextLayout){
TextLayout layout = createTextLayout(c, text, g2.getFont(),
g2.getFontRenderContext());
layout.draw(g2, x, y);
- } else {
- g.drawString(text, x, y);
+ return;
}
+ }
- if (oldAAValue != null) {
- g2.setRenderingHint(KEY_TEXT_ANTIALIASING, oldAAValue);
- }
- if (oldContrast != null) {
- g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST, oldContrast);
- }
- }
- else {
- g.drawString(text, x, y);
- }
+ g.drawString(text, x, y);
}
-
/**
* Draws the string at the specified location underlining the specified
* character.
diff --git a/jdk/src/share/classes/sun/text/resources/CollationData_th.java b/jdk/src/share/classes/sun/text/resources/CollationData_th.java
index 0adc262c4db..311a11f1a0b 100644
--- a/jdk/src/share/classes/sun/text/resources/CollationData_th.java
+++ b/jdk/src/share/classes/sun/text/resources/CollationData_th.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -103,18 +103,13 @@ public class CollationData_th extends ListResourceBundle {
//
// Normal vowels
//
+ + "< \u0E4D " // NIKHAHIT
+ "< \u0E30 " // SARA A
+ "< \u0E31 " // MAI HAN-AKAT
+ "< \u0E32 " // SARA AA
- // Normalizer will decompose this character to \u0e4d\u0e32. This is
- // a Bad Thing, because we want the separate characters to sort
- // differently than this individual one. Since there's no public way to
- // set the decomposition to be used when creating a collator, there's
- // no way around this right now.
- // It's best to go ahead and leave the character in, because it occurs
- // this way a lot more often than it occurs as separate characters.
- + "< \u0E33 " // SARA AM
+ // Normalizer will decompose this character to \u0e4d\u0e32.
+ + "< \u0E33 = \u0E4D\u0E32 " // SARA AM
+ "< \u0E34 " // SARA I
@@ -133,62 +128,58 @@ public class CollationData_th extends ListResourceBundle {
+ "< \u0E43 " // SARA AI MAIMUAN
+ "< \u0E44 " // SARA AI MAIMALAI
- //
- // Digits
- //
- + "< \u0E50 " // DIGIT ZERO
- + "< \u0E51 " // DIGIT ONE
- + "< \u0E52 " // DIGIT TWO
- + "< \u0E53 " // DIGIT THREE
- + "< \u0E54 " // DIGIT FOUR
- + "< \u0E55 " // DIGIT FIVE
- + "< \u0E56 " // DIGIT SIX
- + "< \u0E57 " // DIGIT SEVEN
- + "< \u0E58 " // DIGIT EIGHT
- + "< \u0E59 " // DIGIT NINE
- // Sorta tonal marks, but maybe not really
- + "< \u0E4D " // NIKHAHIT
+ //according to CLDR, it's after 0e44
+ + "< \u0E3A " // PHINTHU
- //
- // Thai symbols are supposed to sort "after white space".
- // I'm treating this as making them sort just after the normal Latin-1
- // symbols, which are in turn after the white space.
- //
- + "&'\u007d'" // right-brace
- + "< \u0E2F " // PAIYANNOI (ellipsis, abbreviation)
- + "< \u0E46 " // MAIYAMOK
- + "< \u0E4F " // FONGMAN
- + "< \u0E5A " // ANGKHANKHU
- + "< \u0E5B " // KHOMUT
- + "< \u0E3F " // CURRENCY SYMBOL BAHT
- // These symbols are supposed to be "after all characters"
- + "< \u0E4E " // YAMAKKAN
- // This rare symbol also comes after all characters. But when it is
- // used in combination with RU and LU, the combination is treated as
- // a separate letter, ala "CH" sorting after "C" in traditional Spanish.
+ // This rare symbol comes after all characters.
+ "< \u0E45 " // LAKKHANGYAO
- + "& \u0E24 < \u0E24\u0E45 "
- + "& \u0E26 < \u0E26\u0E45 "
+ + "& \u0E32 , \0E45 " // According to CLDR, 0E45 is after 0E32 in tertiary level
- // Tonal marks are primary ignorables but are treated as secondary
- // differences
+
+
+
+ // Below are thai puntuation marks and Tonal(Accent) marks. According to CLDR 1.9 and
+ // ISO/IEC 14651, Annex C, C.2.1 Thai ordering principles, 0E2F to 0E5B are punctuaion marks that need to be ignored
+ // in the first three leveles. 0E4E to 0E4B are tonal marks to be compared in secondary level.
+ // In real implmentation, set puncutation marks in tertiary as there is no fourth level in Java.
+ // Set all these special marks after \u0301, the accute accent.
+ "& \u0301 " // acute accent
+
+ //puncutation marks
+ + ", \u0E2F " // PAIYANNOI (ellipsis, abbreviation)
+ + ", \u0E46 " // MAIYAMOK
+ + ", \u0E4F " // FONGMAN
+ + ", \u0E5A " // ANGKHANKHU
+ + ", \u0E5B " // KHOMUT
+
+ //tonal marks
+ + "; \u0E4E " // YAMAKKAN
+ + "; \u0E4C " // THANTHAKHAT
+ "; \u0E47 " // MAITAIKHU
+ "; \u0E48 " // MAI EK
+ "; \u0E49 " // MAI THO
+ "; \u0E4A " // MAI TRI
+ "; \u0E4B " // MAI CHATTAWA
- + "; \u0E4C " // THANTHAKHAT
+
+ //
+ // Digits are equal to their corresponding Arabic digits in the first level
+ //
+ + "& 0 = \u0E50 " // DIGIT ZERO
+ + "& 1 = \u0E51 " // DIGIT ONE
+ + "& 2 = \u0E52 " // DIGIT TWO
+ + "& 3 = \u0E53 " // DIGIT THREE
+ + "& 4 = \u0E54 " // DIGIT FOUR
+ + "& 5 = \u0E55 " // DIGIT FIVE
+ + "& 6 = \u0E56 " // DIGIT SIX
+ + "& 7 = \u0E57 " // DIGIT SEVEN
+ + "& 8 = \u0E58 " // DIGIT EIGHT
+ + "& 9 = \u0E59 " // DIGIT NINE
- // These are supposed to be ignored, so I'm treating them as controls
- + "& \u0001 "
- + "= \u0E3A " // PHINTHU
- + "= '.' " // period
- }
+ }
};
}
}
diff --git a/jdk/src/share/classes/sun/util/resources/CalendarData_lv.properties b/jdk/src/share/classes/sun/util/resources/CalendarData_lv.properties
index 36167c9c604..126532a799c 100644
--- a/jdk/src/share/classes/sun/util/resources/CalendarData_lv.properties
+++ b/jdk/src/share/classes/sun/util/resources/CalendarData_lv.properties
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -23,21 +23,45 @@
# questions.
#
-# (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
-# (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
#
-# The original version of this source code and documentation
-# is copyrighted and owned by Taligent, Inc., a wholly-owned
-# subsidiary of IBM. These materials are provided under terms
-# of a License Agreement between Taligent and Sun. This technology
-# is protected by multiple US and International patents.
+# COPYRIGHT AND PERMISSION NOTICE
#
-# This notice and attribution to Taligent may not be removed.
-# Taligent is a registered trademark of Taligent, Inc.
+# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+# Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of the Unicode data files and any associated documentation (the
+# "Data Files") or Unicode software and any associated documentation
+# (the "Software") to deal in the Data Files or Software without
+# restriction, including without limitation the rights to use, copy,
+# modify, merge, publish, distribute, and/or sell copies of the Data
+# Files or Software, and to permit persons to whom the Data Files or
+# Software are furnished to do so, provided that (a) the above copyright
+# notice(s) and this permission notice appear with all copies of the
+# Data Files or Software, (b) both the above copyright notice(s) and
+# this permission notice appear in associated documentation, and (c)
+# there is clear notice in each modified Data File or in the Software as
+# well as in the documentation associated with the Data File(s) or
+# Software that the data or software has been modified.
+#
+# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR
+# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
+# SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder
+# shall not be used in advertising or otherwise to promote the sale, use
+# or other dealings in these Data Files or Software without prior
+# written authorization of the copyright holder.
-
-# This bundle is empty because the data of the base bundle
-# is adequate for this locale.
-# The bundle is necessary to prevent the resource
-# bundle lookup from falling back to the default
-# locale.
+#
+# Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+#
+firstDayOfWeek=2
+minimalDaysInFirstWeek=4
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java
index c4862dc75aa..9a194512dfb 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java
@@ -103,6 +103,8 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
"Eastern Daylight Time", "EDT"};
String EST_NSW[] = new String[] {"Eastern Standard Time (New South Wales)", "EST",
"Eastern Summer Time (New South Wales)", "EST"};
+ String FET[] = new String[] {"Further-eastern European Time", "FET",
+ "Further-eastern European Summer Time", "FEST"};
String GHMT[] = new String[] {"Ghana Mean Time", "GMT",
"Ghana Summer Time", "GHST"};
String GAMBIER[] = new String[] {"Gambier Time", "GAMT",
@@ -186,7 +188,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
String SAMOA[] = new String[] {"Samoa Standard Time", "SST",
"Samoa Daylight Time", "SDT"};
String WST_SAMOA[] = new String[] {"West Samoa Time", "WST",
- "West Samoa Summer Time", "WSST"};
+ "West Samoa Daylight Time", "WSDT"};
String ChST[] = new String[] {"Chamorro Standard Time", "ChST",
"Chamorro Daylight Time", "ChDT"};
String VICTORIA[] = new String[] {"Eastern Standard Time (Victoria)", "EST",
@@ -511,6 +513,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
"Tajikistan Summer Time", "TJST"}},
{"Asia/Gaza", EET},
{"Asia/Harbin", CTT},
+ {"Asia/Hebron", EET},
{"Asia/Ho_Chi_Minh", ICT},
{"Asia/Hong_Kong", HKT},
{"Asia/Hovd", new String[] {"Hovd Time", "HOVT",
@@ -674,9 +677,8 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
{"Europe/Isle_of_Man", GMTBST},
{"Europe/Istanbul", EET},
{"Europe/Jersey", GMTBST},
- {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
- "Kaliningrad Summer Time", "KALST"}},
- {"Europe/Kiev", EET},
+ {"Europe/Kaliningrad", FET},
+ {"Europe/Kiev", FET},
{"Europe/Lisbon", WET},
{"Europe/Ljubljana", CET},
{"Europe/London", GMTBST},
@@ -684,7 +686,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", EET},
+ {"Europe/Minsk", FET},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -697,14 +699,14 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
"Samara Summer Time", "SAMST"}},
{"Europe/San_Marino", CET},
{"Europe/Sarajevo", CET},
- {"Europe/Simferopol", EET},
+ {"Europe/Simferopol", FET},
{"Europe/Skopje", CET},
{"Europe/Sofia", EET},
{"Europe/Stockholm", CET},
{"Europe/Tallinn", EET},
{"Europe/Tirane", CET},
{"Europe/Tiraspol", EET},
- {"Europe/Uzhgorod", EET},
+ {"Europe/Uzhgorod", FET},
{"Europe/Vaduz", CET},
{"Europe/Vatican", CET},
{"Europe/Vienna", CET},
@@ -713,7 +715,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
"Volgograd Summer Time", "VOLST"}},
{"Europe/Warsaw", CET},
{"Europe/Zagreb", CET},
- {"Europe/Zaporozhye", EET},
+ {"Europe/Zaporozhye", FET},
{"Europe/Zurich", CET},
{"GB", GMTBST},
{"GB-Eire", GMTBST},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java
index 763f7f51fb1..cd6dce69060 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java
@@ -103,6 +103,8 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle {
"\u00d6stliche Sommerzeit", "EDT"};
String EST_NSW[] = new String[] {"\u00d6stliche Normalzeit (New South Wales)", "EST",
"\u00d6stliche Sommerzeit (New South Wales)", "EST"};
+ String FET[] = new String[] {"Further-eastern European Time", "FET",
+ "Further-eastern European Summer Time", "FEST"};
String GHMT[] = new String[] {"Ghanaische Normalzeit", "GMT",
"Ghanaische Sommerzeit", "GHST"};
String GAMBIER[] = new String[] {"Gambier Zeit", "GAMT",
@@ -186,7 +188,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle {
String SAMOA[] = new String[] {"Samoa Normalzeit", "SST",
"Samoa Sommerzeit", "SDT"};
String WST_SAMOA[] = new String[] {"West Samoa Zeit", "WST",
- "West Samoa Sommerzeit", "WSST"};
+ "West Samoa Sommerzeit", "WSDT"};
String ChST[] = new String[] {"Chamorro Normalzeit", "ChST",
"Chamorro Sommerzeit", "ChDT"};
String VICTORIA[] = new String[] {"\u00d6stliche Normalzeit (Victoria)", "EST",
@@ -511,6 +513,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle {
"Tadschikische Sommerzeit", "TJST"}},
{"Asia/Gaza", EET},
{"Asia/Harbin", CTT},
+ {"Asia/Hebron", EET},
{"Asia/Ho_Chi_Minh", ICT},
{"Asia/Hong_Kong", HKT},
{"Asia/Hovd", new String[] {"Hovd Zeit", "HOVT",
@@ -674,9 +677,8 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle {
{"Europe/Isle_of_Man", GMTBST},
{"Europe/Istanbul", EET},
{"Europe/Jersey", GMTBST},
- {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
- "Kaliningrad Summer Time", "KALST"}},
- {"Europe/Kiev", EET},
+ {"Europe/Kaliningrad", FET},
+ {"Europe/Kiev", FET},
{"Europe/Lisbon", WET},
{"Europe/Ljubljana", CET},
{"Europe/London", GMTBST},
@@ -684,7 +686,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle {
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", EET},
+ {"Europe/Minsk", FET},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -697,14 +699,14 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle {
"Samarische Sommerzeit", "SAMST"}},
{"Europe/San_Marino", CET},
{"Europe/Sarajevo", CET},
- {"Europe/Simferopol", EET},
+ {"Europe/Simferopol", FET},
{"Europe/Skopje", CET},
{"Europe/Sofia", EET},
{"Europe/Stockholm", CET},
{"Europe/Tallinn", EET},
{"Europe/Tirane", CET},
{"Europe/Tiraspol", EET},
- {"Europe/Uzhgorod", EET},
+ {"Europe/Uzhgorod", FET},
{"Europe/Vaduz", CET},
{"Europe/Vatican", CET},
{"Europe/Vienna", CET},
@@ -713,7 +715,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle {
"Wolgograder Sommerzeit", "VOLST"}},
{"Europe/Warsaw", CET},
{"Europe/Zagreb", CET},
- {"Europe/Zaporozhye", EET},
+ {"Europe/Zaporozhye", FET},
{"Europe/Zurich", CET},
{"GB", GMTBST},
{"GB-Eire", GMTBST},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java
index 1c09f1e585c..ba28d638990 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java
@@ -103,6 +103,8 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle {
"Hora de verano Oriental", "EDT"};
String EST_NSW[] = new String[] {"Hora est\u00e1ndar Oriental (Nueva Gales del Sur)", "EST",
"Hora de verano Oriental (Nueva Gales del Sur)", "EST"};
+ String FET[] = new String[] {"Further-eastern European Time", "FET",
+ "Further-eastern European Summer Time", "FEST"};
String GHMT[] = new String[] {"Hora central de Ghana", "GMT",
"Hora de verano de Ghana", "GHST"};
String GAMBIER[] = new String[] {"Hora de Gambier", "GAMT",
@@ -186,7 +188,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle {
String SAMOA[] = new String[] {"Hora est\u00e1ndar de Samoa", "SST",
"Hora de verano de Samoa", "SDT"};
String WST_SAMOA[] = new String[] {"Hora de Samoa Occidental", "WST",
- "Hora de verano de Samoa Occidental", "WSST"};
+ "Hora de verano de Samoa Occidental", "WSDT"};
String ChST[] = new String[] {"Hora est\u00e1ndar de Chamorro", "ChST",
"Hora de verano de Chamorro", "ChDT"};
String VICTORIA[] = new String[] {"Hora est\u00e1ndar del Este (Victoria)", "EST",
@@ -511,6 +513,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle {
"Hora de verano de Tajikist\u00e1n", "TJST"}},
{"Asia/Gaza", EET},
{"Asia/Harbin", CTT},
+ {"Asia/Hebron", EET},
{"Asia/Ho_Chi_Minh", ICT},
{"Asia/Hong_Kong", HKT},
{"Asia/Hovd", new String[] {"Hora de Hovd", "HOVT",
@@ -674,9 +677,8 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle {
{"Europe/Isle_of_Man", GMTBST},
{"Europe/Istanbul", EET},
{"Europe/Jersey", GMTBST},
- {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
- "Kaliningrad Summer Time", "KALST"}},
- {"Europe/Kiev", EET},
+ {"Europe/Kaliningrad", FET},
+ {"Europe/Kiev", FET},
{"Europe/Lisbon", WET},
{"Europe/Ljubljana", CET},
{"Europe/London", GMTBST},
@@ -684,7 +686,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle {
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", EET},
+ {"Europe/Minsk", FET},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -697,14 +699,14 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle {
"Hora de verano de Samara", "SAMST"}},
{"Europe/San_Marino", CET},
{"Europe/Sarajevo", CET},
- {"Europe/Simferopol", EET},
+ {"Europe/Simferopol", FET},
{"Europe/Skopje", CET},
{"Europe/Sofia", EET},
{"Europe/Stockholm", CET},
{"Europe/Tallinn", EET},
{"Europe/Tirane", CET},
{"Europe/Tiraspol", EET},
- {"Europe/Uzhgorod", EET},
+ {"Europe/Uzhgorod", FET},
{"Europe/Vaduz", CET},
{"Europe/Vatican", CET},
{"Europe/Vienna", CET},
@@ -713,7 +715,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle {
"Hora de verano de Volgogrado", "VOLST"}},
{"Europe/Warsaw", CET},
{"Europe/Zagreb", CET},
- {"Europe/Zaporozhye", EET},
+ {"Europe/Zaporozhye", FET},
{"Europe/Zurich", CET},
{"GB", GMTBST},
{"GB-Eire", GMTBST},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java
index fba1e827b0a..1cb8bbcf4b8 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java
@@ -103,6 +103,8 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle {
"Heure avanc\u00e9e de l'Est", "EDT"} ;
String EST_NSW[] = new String[] {"Heure normale de l'Est (Nouvelle-Galles du Sud)", "EST",
"Heure d'\u00e9t\u00e9 de l'Est (Nouvelle-Galles du Sud)", "EST"} ;
+ String FET[] = new String[] {"Further-eastern European Time", "FET",
+ "Further-eastern European Summer Time", "FEST"};
String GHMT[] = new String[] {"Heure du Ghana", "GMT",
"Heure d'\u00e9t\u00e9 du Ghana", "GHST"};
String GAMBIER[] = new String[] {"Heure de Gambi", "GAMT",
@@ -186,7 +188,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle {
String SAMOA[] = new String[] {"Heure standard de Samoa", "SST",
"Heure avanc\u00e9e de Samoa", "SDT"};
String WST_SAMOA[] = new String[] {"Heure des Samoas occidentales", "WST",
- "Heure d'\u00e9t\u00e9 des Samoas occidentales", "WSST"} ;
+ "Heure d'\u00e9t\u00e9 des Samoas occidentales", "WSDT"} ;
String ChST[] = new String[] {"Heure normale des \u00eeles Mariannes", "ChST",
"Heure d'\u00e9t\u00e9 des \u00eeles Mariannes", "ChDT"};
String VICTORIA[] = new String[] {"Heure standard d'Australie orientale (Victoria)", "EST",
@@ -511,6 +513,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle {
"Heure d'\u00e9t\u00e9 du Tadjikistan", "TJST"}},
{"Asia/Gaza", EET},
{"Asia/Harbin", CTT},
+ {"Asia/Hebron", EET},
{"Asia/Ho_Chi_Minh", ICT},
{"Asia/Hong_Kong", HKT},
{"Asia/Hovd", new String[] {"Heure de Hovd", "HOVT",
@@ -674,9 +677,8 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle {
{"Europe/Isle_of_Man", GMTBST},
{"Europe/Istanbul", EET},
{"Europe/Jersey", GMTBST},
- {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
- "Kaliningrad Summer Time", "KALST"}},
- {"Europe/Kiev", EET},
+ {"Europe/Kaliningrad", FET},
+ {"Europe/Kiev", FET},
{"Europe/Lisbon", WET},
{"Europe/Ljubljana", CET},
{"Europe/London", GMTBST},
@@ -684,7 +686,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle {
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", EET},
+ {"Europe/Minsk", FET},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -697,14 +699,14 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle {
"Heure d'\u00e9t\u00e9 de Samara", "SAMST"}},
{"Europe/San_Marino", CET},
{"Europe/Sarajevo", CET},
- {"Europe/Simferopol", EET},
+ {"Europe/Simferopol", FET},
{"Europe/Skopje", CET},
{"Europe/Sofia", EET},
{"Europe/Stockholm", CET},
{"Europe/Tallinn", EET},
{"Europe/Tirane", CET},
{"Europe/Tiraspol", EET},
- {"Europe/Uzhgorod", EET},
+ {"Europe/Uzhgorod", FET},
{"Europe/Vaduz", CET},
{"Europe/Vatican", CET},
{"Europe/Vienna", CET},
@@ -713,7 +715,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle {
"Heure d'\u00e9t\u00e9 de Volgograd", "VOLST"}},
{"Europe/Warsaw", CET},
{"Europe/Zagreb", CET},
- {"Europe/Zaporozhye", EET},
+ {"Europe/Zaporozhye", FET},
{"Europe/Zurich", CET},
{"GB", GMTBST},
{"GB-Eire", GMTBST},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java
index c2bb1d673f0..216f9dc5f72 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java
@@ -103,6 +103,8 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle {
"Ora legale USA orientale", "EDT"};
String EST_NSW[] = new String[] {"Ora solare dell'Australia orientale (Nuovo Galles del Sud)", "EST",
"Ora estiva dell'Australia orientale (Nuovo Galles del Sud)", "EST"};
+ String FET[] = new String[] {"Further-eastern European Time", "FET",
+ "Further-eastern European Summer Time", "FEST"};
String GHMT[] = new String[] {"Ora media del Ghana", "GMT",
"Ora legale del Ghana", "GHST"};
String GAMBIER[] = new String[] {"Ora di Gambier", "GAMT",
@@ -186,7 +188,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle {
String SAMOA[] = new String[] {"Ora standard di Samoa", "SST",
"Ora legale di Samoa", "SDT"};
String WST_SAMOA[] = new String[] {"Ora di Samoa", "WST",
- "Ora estiva di Samoa", "WSST"};
+ "Ora estiva di Samoa", "WSDT"};
String ChST[] = new String[] {"Ora standard di Chamorro", "ChST",
"Ora legale di Chamorro", "ChDT"};
String VICTORIA[] = new String[] {"Ora orientale standard (Victoria)", "EST",
@@ -511,6 +513,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle {
"Ora estiva del Tagikistan", "TJST"}},
{"Asia/Gaza", EET},
{"Asia/Harbin", CTT},
+ {"Asia/Hebron", EET},
{"Asia/Ho_Chi_Minh", ICT},
{"Asia/Hong_Kong", HKT},
{"Asia/Hovd", new String[] {"Ora di Hovd", "HOVT",
@@ -674,9 +677,8 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle {
{"Europe/Isle_of_Man", GMTBST},
{"Europe/Istanbul", EET},
{"Europe/Jersey", GMTBST},
- {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
- "Kaliningrad Summer Time", "KALST"}},
- {"Europe/Kiev", EET},
+ {"Europe/Kaliningrad", FET},
+ {"Europe/Kiev", FET},
{"Europe/Lisbon", WET},
{"Europe/Ljubljana", CET},
{"Europe/London", GMTBST},
@@ -684,7 +686,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle {
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", EET},
+ {"Europe/Minsk", FET},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -697,14 +699,14 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle {
"Ora estiva di Samara", "SAMST"}},
{"Europe/San_Marino", CET},
{"Europe/Sarajevo", CET},
- {"Europe/Simferopol", EET},
+ {"Europe/Simferopol", FET},
{"Europe/Skopje", CET},
{"Europe/Sofia", EET},
{"Europe/Stockholm", CET},
{"Europe/Tallinn", EET},
{"Europe/Tirane", CET},
{"Europe/Tiraspol", EET},
- {"Europe/Uzhgorod", EET},
+ {"Europe/Uzhgorod", FET},
{"Europe/Vaduz", CET},
{"Europe/Vatican", CET},
{"Europe/Vienna", CET},
@@ -713,7 +715,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle {
"Ora estiva di Volgograd", "VOLST"}},
{"Europe/Warsaw", CET},
{"Europe/Zagreb", CET},
- {"Europe/Zaporozhye", EET},
+ {"Europe/Zaporozhye", FET},
{"Europe/Zurich", CET},
{"GB", GMTBST},
{"GB-Eire", GMTBST},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java
index a0d9d7c863f..fdf98fc5b4d 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java
@@ -103,6 +103,8 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle {
"\u6771\u90e8\u590f\u6642\u9593", "EDT"};
String EST_NSW[] = new String[] {"\u6771\u90e8\u6a19\u6e96\u6642 (\u30cb\u30e5\u30fc\u30b5\u30a6\u30b9\u30a6\u30a7\u30fc\u30eb\u30ba)", "EST",
"\u6771\u90e8\u590f\u6642\u9593 (\u30cb\u30e5\u30fc\u30b5\u30a6\u30b9\u30a6\u30a7\u30fc\u30eb\u30ba)", "EST"};
+ String FET[] = new String[] {"Further-eastern European Time", "FET",
+ "Further-eastern European Summer Time", "FEST"};
String GHMT[] = new String[] {"\u30ac\u30fc\u30ca\u6a19\u6e96\u6642", "GMT",
"\u30ac\u30fc\u30ca\u590f\u6642\u9593", "GHST"};
String GAMBIER[] = new String[] {"\u30ac\u30f3\u30d3\u30a2\u6642\u9593", "GAMT",
@@ -186,7 +188,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle {
String SAMOA[] = new String[] {"\u30b5\u30e2\u30a2\u6a19\u6e96\u6642", "SST",
"\u30b5\u30e2\u30a2\u590f\u6642\u9593", "SDT"};
String WST_SAMOA[] = new String[] {"\u897f\u30b5\u30e2\u30a2\u6642\u9593", "WST",
- "\u897f\u30b5\u30e2\u30a2\u590f\u6642\u9593", "WSST"};
+ "\u897f\u30b5\u30e2\u30a2\u590f\u6642\u9593", "WSDT"};
String ChST[] = new String[] {"\u30b0\u30a2\u30e0\u6a19\u6e96\u6642", "ChST",
"\u30b0\u30a2\u30e0\u590f\u6642\u9593", "ChDT"};
String VICTORIA[] = new String[] {"\u6771\u90e8\u6a19\u6e96\u6642 (\u30d3\u30af\u30c8\u30ea\u30a2)", "EST",
@@ -511,6 +513,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle {
"\u30bf\u30b8\u30ad\u30b9\u30bf\u30f3\u590f\u6642\u9593", "TJST"}},
{"Asia/Gaza", EET},
{"Asia/Harbin", CTT},
+ {"Asia/Hebron", EET},
{"Asia/Ho_Chi_Minh", ICT},
{"Asia/Hong_Kong", HKT},
{"Asia/Hovd", new String[] {"\u30db\u30d6\u30c9\u6642\u9593", "HOVT",
@@ -674,9 +677,8 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle {
{"Europe/Isle_of_Man", GMTBST},
{"Europe/Istanbul", EET},
{"Europe/Jersey", GMTBST},
- {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
- "Kaliningrad Summer Time", "KALST"}},
- {"Europe/Kiev", EET},
+ {"Europe/Kaliningrad", FET},
+ {"Europe/Kiev", FET},
{"Europe/Lisbon", WET},
{"Europe/Ljubljana", CET},
{"Europe/London", GMTBST},
@@ -684,7 +686,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle {
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", EET},
+ {"Europe/Minsk", FET},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -697,14 +699,14 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle {
"\u30b5\u30de\u30e9\u590f\u6642\u9593", "SAMST"}},
{"Europe/San_Marino", CET},
{"Europe/Sarajevo", CET},
- {"Europe/Simferopol", EET},
+ {"Europe/Simferopol", FET},
{"Europe/Skopje", CET},
{"Europe/Sofia", EET},
{"Europe/Stockholm", CET},
{"Europe/Tallinn", EET},
{"Europe/Tirane", CET},
{"Europe/Tiraspol", EET},
- {"Europe/Uzhgorod", EET},
+ {"Europe/Uzhgorod", FET},
{"Europe/Vaduz", CET},
{"Europe/Vatican", CET},
{"Europe/Vienna", CET},
@@ -713,7 +715,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle {
"\u30dc\u30eb\u30b4\u30b0\u30e9\u30fc\u30c9\u590f\u6642\u9593", "VOLST"}},
{"Europe/Warsaw", CET},
{"Europe/Zagreb", CET},
- {"Europe/Zaporozhye", EET},
+ {"Europe/Zaporozhye", FET},
{"Europe/Zurich", CET},
{"GB", GMTBST},
{"GB-Eire", GMTBST},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java
index 2079655f736..060e6b3105f 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java
@@ -103,6 +103,8 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle {
"\ub3d9\ubd80 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "EDT"};
String EST_NSW[] = new String[] {"\ub3d9\ubd80 \ud45c\uc900\uc2dc(\ub274 \uc0ac\uc6b0\uc2a4 \uc6e8\uc77c\uc988)", "EST",
"\ub3d9\ubd80 \uc77c\uad11\uc808\uc57d\uc2dc\uac04(\ub274 \uc0ac\uc6b0\uc2a4 \uc6e8\uc77c\uc988)", "EST"};
+ String FET[] = new String[] {"Further-eastern European Time", "FET",
+ "Further-eastern European Summer Time", "FEST"};
String GHMT[] = new String[] {"\uac00\ub098 \ud45c\uc900\uc2dc", "GMT",
"\uac00\ub098 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "GHST"};
String GAMBIER[] = new String[] {"\uac10\ube44\uc544 \uc2dc\uac04", "GAMT",
@@ -186,7 +188,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle {
String SAMOA[] = new String[] {"\uc0ac\ubaa8\uc544 \ud45c\uc900\uc2dc", "SST",
"\uc0ac\ubaa8\uc544 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "SDT"};
String WST_SAMOA[] = new String[] {"\uc11c\uc0ac\ubaa8\uc544 \uc2dc\uac04", "WST",
- "\uc11c\uc0ac\ubaa8\uc544 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "WSST"};
+ "\uc11c\uc0ac\ubaa8\uc544 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "WSDT"};
String ChST[] = new String[] {"\ucc28\ubaa8\ub85c \ud45c\uc900\uc2dc", "ChST",
"\ucc28\ubaa8\ub85c \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "ChDT"};
String VICTORIA[] = new String[] {"\ub3d9\ubd80 \ud45c\uc900\uc2dc(\ube45\ud1a0\ub9ac\uc544)", "EST",
@@ -511,6 +513,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle {
"\ud0c0\uc9c0\ud0a4\uc2a4\ud0c4 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "TJST"}},
{"Asia/Gaza", EET},
{"Asia/Harbin", CTT},
+ {"Asia/Hebron", EET},
{"Asia/Ho_Chi_Minh", ICT},
{"Asia/Hong_Kong", HKT},
{"Asia/Hovd", new String[] {"Hovd \uc2dc\uac04", "HOVT",
@@ -674,9 +677,8 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle {
{"Europe/Isle_of_Man", GMTBST},
{"Europe/Istanbul", EET},
{"Europe/Jersey", GMTBST},
- {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
- "Kaliningrad Summer Time", "KALST"}},
- {"Europe/Kiev", EET},
+ {"Europe/Kaliningrad", FET},
+ {"Europe/Kiev", FET},
{"Europe/Lisbon", WET},
{"Europe/Ljubljana", CET},
{"Europe/London", GMTBST},
@@ -684,7 +686,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle {
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", EET},
+ {"Europe/Minsk", FET},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -697,14 +699,14 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle {
"\uc0ac\ub9c8\ub77c \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "SAMST"}},
{"Europe/San_Marino", CET},
{"Europe/Sarajevo", CET},
- {"Europe/Simferopol", EET},
+ {"Europe/Simferopol", FET},
{"Europe/Skopje", CET},
{"Europe/Sofia", EET},
{"Europe/Stockholm", CET},
{"Europe/Tallinn", EET},
{"Europe/Tirane", CET},
{"Europe/Tiraspol", EET},
- {"Europe/Uzhgorod", EET},
+ {"Europe/Uzhgorod", FET},
{"Europe/Vaduz", CET},
{"Europe/Vatican", CET},
{"Europe/Vienna", CET},
@@ -713,7 +715,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle {
"\ubcfc\uace0\uadf8\ub77c\ub4dc \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "VOLST"}},
{"Europe/Warsaw", CET},
{"Europe/Zagreb", CET},
- {"Europe/Zaporozhye", EET},
+ {"Europe/Zaporozhye", FET},
{"Europe/Zurich", CET},
{"GB", GMTBST},
{"GB-Eire", GMTBST},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java
index 89191d0674f..31356369a9f 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java
@@ -101,6 +101,8 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle {
"Hor\u00e1rio de luz natural oriental", "EDT"};
String EST_NSW[] = new String[] {"Fuso hor\u00e1rio padr\u00e3o oriental (Nova Gales do Sul)", "EST",
"Fuso hor\u00e1rio de ver\u00e3o oriental (Nova Gales do Sul)", "EST"};
+ String FET[] = new String[] {"Further-eastern European Time", "FET",
+ "Further-eastern European Summer Time", "FEST"};
String GHMT[] = new String[] {"Fuso hor\u00e1rio do meridiano de Gana", "GMT",
"Fuso hor\u00e1rio de ver\u00e3o de Gana", "GHST"};
String GAMBIER[] = new String[] {"Fuso hor\u00e1rio de Gambier", "GAMT",
@@ -184,7 +186,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle {
String SAMOA[] = new String[] {"Fuso hor\u00e1rio padr\u00e3o de Samoa", "SST",
"Hor\u00e1rio de luz natural de Samoa", "SDT"};
String WST_SAMOA[] = new String[] {"Fuso hor\u00e1rio de Samoa Ocidental", "WST",
- "Fuso hor\u00e1rio de ver\u00e3o de Samoa Ocidental", "WSST"};
+ "Fuso hor\u00e1rio de ver\u00e3o de Samoa Ocidental", "WSDT"};
String ChST[] = new String[] {"Fuso hor\u00e1rio padr\u00e3o de Chamorro", "ChST",
"Hor\u00e1rio de luz natural de Chamorro", "ChDT"};
String VICTORIA[] = new String[] {"Fuso hor\u00e1rio padr\u00e3o oriental (Victoria)", "EST",
@@ -511,6 +513,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle {
"Fuso hor\u00e1rio de ver\u00e3o do Tadjiquist\u00e3o", "TJST"}},
{"Asia/Gaza", EET},
{"Asia/Harbin", CTT},
+ {"Asia/Hebron", EET},
{"Asia/Ho_Chi_Minh", ICT},
{"Asia/Hong_Kong", HKT},
{"Asia/Hovd", new String[] {"Fuso hor\u00e1rio de Hovd", "HOVT",
@@ -674,9 +677,8 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle {
{"Europe/Isle_of_Man", GMTBST},
{"Europe/Istanbul", EET},
{"Europe/Jersey", GMTBST},
- {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
- "Kaliningrad Summer Time", "KALST"}},
- {"Europe/Kiev", EET},
+ {"Europe/Kaliningrad", FET},
+ {"Europe/Kiev", FET},
{"Europe/Lisbon", WET},
{"Europe/Ljubljana", CET},
{"Europe/London", GMTBST},
@@ -684,7 +686,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle {
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", EET},
+ {"Europe/Minsk", FET},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -697,14 +699,14 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle {
"Fuso hor\u00e1rio de ver\u00e3o de Samara", "SAMST"}},
{"Europe/San_Marino", CET},
{"Europe/Sarajevo", CET},
- {"Europe/Simferopol", EET},
+ {"Europe/Simferopol", FET},
{"Europe/Skopje", CET},
{"Europe/Sofia", EET},
{"Europe/Stockholm", CET},
{"Europe/Tallinn", EET},
{"Europe/Tirane", CET},
{"Europe/Tiraspol", EET},
- {"Europe/Uzhgorod", EET},
+ {"Europe/Uzhgorod", FET},
{"Europe/Vaduz", CET},
{"Europe/Vatican", CET},
{"Europe/Vienna", CET},
@@ -713,7 +715,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle {
"Fuso hor\u00e1rio de ver\u00e3o de Volgogrado", "VOLST"}},
{"Europe/Warsaw", CET},
{"Europe/Zagreb", CET},
- {"Europe/Zaporozhye", EET},
+ {"Europe/Zaporozhye", FET},
{"Europe/Zurich", CET},
{"GB", GMTBST},
{"GB-Eire", GMTBST},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java
index 007e5534a13..f399e0d69b4 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java
@@ -103,6 +103,8 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle {
"Eastern, sommartid", "EDT"};
String EST_NSW[] = new String[] {"Eastern, normaltid (Nya Sydwales)", "EST",
"Eastern, sommartid (Nya Sydwales)", "EST"};
+ String FET[] = new String[] {"Further-eastern European Time", "FET",
+ "Further-eastern European Summer Time", "FEST"};
String GHMT[] = new String[] {"Ghana, normaltid", "GMT",
"Ghana, sommartid", "GHST"};
String GAMBIER[] = new String[] {"Gambier, normaltid", "GAMT",
@@ -186,7 +188,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle {
String SAMOA[] = new String[] {"Samoa, normaltid", "SST",
"Samoa, sommartid", "SDT"};
String WST_SAMOA[] = new String[] {"V\u00e4stsamoansk tid", "WST",
- "V\u00e4stsamoansk sommartid", "WSST"};
+ "V\u00e4stsamoansk sommartid", "WSDT"};
String ChST[] = new String[] {"Chamorro, normaltid", "ChST",
"Chamorro, sommartid", "ChDT"};
String VICTORIA[] = new String[] {"\u00d6stlig normaltid (Victoria)", "EST",
@@ -511,6 +513,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle {
"Tadzjikistan, sommartid", "TJST"}},
{"Asia/Gaza", EET},
{"Asia/Harbin", CTT},
+ {"Asia/Hebron", EET},
{"Asia/Ho_Chi_Minh", ICT},
{"Asia/Hong_Kong", HKT},
{"Asia/Hovd", new String[] {"Hovd, normaltid", "HOVT",
@@ -674,9 +677,8 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle {
{"Europe/Isle_of_Man", GMTBST},
{"Europe/Istanbul", EET},
{"Europe/Jersey", GMTBST},
- {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
- "Kaliningrad Summer Time", "KALST"}},
- {"Europe/Kiev", EET},
+ {"Europe/Kaliningrad", FET},
+ {"Europe/Kiev", FET},
{"Europe/Lisbon", WET},
{"Europe/Ljubljana", CET},
{"Europe/London", GMTBST},
@@ -684,7 +686,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle {
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", EET},
+ {"Europe/Minsk", FET},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -697,14 +699,14 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle {
"Samara, sommartid", "SAMST"}},
{"Europe/San_Marino", CET},
{"Europe/Sarajevo", CET},
- {"Europe/Simferopol", EET},
+ {"Europe/Simferopol", FET},
{"Europe/Skopje", CET},
{"Europe/Sofia", EET},
{"Europe/Stockholm", CET},
{"Europe/Tallinn", EET},
{"Europe/Tirane", CET},
{"Europe/Tiraspol", EET},
- {"Europe/Uzhgorod", EET},
+ {"Europe/Uzhgorod", FET},
{"Europe/Vaduz", CET},
{"Europe/Vatican", CET},
{"Europe/Vienna", CET},
@@ -713,7 +715,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle {
"Volgograd, sommartid", "VOLST"}},
{"Europe/Warsaw", CET},
{"Europe/Zagreb", CET},
- {"Europe/Zaporozhye", EET},
+ {"Europe/Zaporozhye", FET},
{"Europe/Zurich", CET},
{"GB", GMTBST},
{"GB-Eire", GMTBST},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java
index d7521372bbd..28dd24f85f5 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java
@@ -103,6 +103,8 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle {
"\u4e1c\u90e8\u590f\u4ee4\u65f6", "EDT"};
String EST_NSW[] = new String[] {"\u4e1c\u90e8\u6807\u51c6\u65f6\u95f4\uff08\u65b0\u5357\u5a01\u5c14\u65af\uff09", "EST",
"\u4e1c\u90e8\u590f\u4ee4\u65f6\uff08\u65b0\u5357\u5a01\u5c14\u65af\uff09", "EST"};
+ String FET[] = new String[] {"Further-eastern European Time", "FET",
+ "Further-eastern European Summer Time", "FEST"};
String GHMT[] = new String[] {"\u52a0\u7eb3\u65f6\u95f4", "GMT",
"\u52a0\u7eb3\u590f\u4ee4\u65f6", "GHST"};
String GAMBIER[] = new String[] {"\u5188\u6bd4\u4e9a\u65f6\u95f4", "GAMT",
@@ -186,7 +188,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle {
String SAMOA[] = new String[] {"\u8428\u6469\u4e9a\u7fa4\u5c9b\u6807\u51c6\u65f6\u95f4", "SST",
"\u8428\u6469\u4e9a\u7fa4\u5c9b\u590f\u4ee4\u65f6", "SDT"};
String WST_SAMOA[] = new String[] {"\u897f\u8428\u6469\u4e9a\u65f6\u95f4", "WST",
- "\u897f\u8428\u6469\u4e9a\u590f\u4ee4\u65f6", "WSST"};
+ "\u897f\u8428\u6469\u4e9a\u590f\u4ee4\u65f6", "WSDT"};
String ChST[] = new String[] {"Chamorro \u6807\u51c6\u65f6\u95f4", "ChST",
"Chamorro \u590f\u4ee4\u65f6", "ChDT"};
String VICTORIA[] = new String[] {"\u4e1c\u90e8\u6807\u51c6\u65f6\u95f4\uff08\u7ef4\u591a\u5229\u4e9a\uff09", "EST",
@@ -511,6 +513,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle {
"\u5854\u5409\u514b\u65af\u5766\u590f\u4ee4\u65f6", "TJST"}},
{"Asia/Gaza", EET},
{"Asia/Harbin", CTT},
+ {"Asia/Hebron", EET},
{"Asia/Ho_Chi_Minh", ICT},
{"Asia/Hong_Kong", HKT},
{"Asia/Hovd", new String[] {"\u79d1\u5e03\u591a\u65f6\u95f4", "HOVT",
@@ -674,9 +677,8 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle {
{"Europe/Isle_of_Man", GMTBST},
{"Europe/Istanbul", EET},
{"Europe/Jersey", GMTBST},
- {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
- "Kaliningrad Summer Time", "KALST"}},
- {"Europe/Kiev", EET},
+ {"Europe/Kaliningrad", FET},
+ {"Europe/Kiev", FET},
{"Europe/Lisbon", WET},
{"Europe/Ljubljana", CET},
{"Europe/London", GMTBST},
@@ -684,7 +686,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle {
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", EET},
+ {"Europe/Minsk", FET},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -697,14 +699,14 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle {
"\u6c99\u9a6c\u62c9\u590f\u4ee4\u65f6", "SAMST"}},
{"Europe/San_Marino", CET},
{"Europe/Sarajevo", CET},
- {"Europe/Simferopol", EET},
+ {"Europe/Simferopol", FET},
{"Europe/Skopje", CET},
{"Europe/Sofia", EET},
{"Europe/Stockholm", CET},
{"Europe/Tallinn", EET},
{"Europe/Tirane", CET},
{"Europe/Tiraspol", EET},
- {"Europe/Uzhgorod", EET},
+ {"Europe/Uzhgorod", FET},
{"Europe/Vaduz", CET},
{"Europe/Vatican", CET},
{"Europe/Vienna", CET},
@@ -713,7 +715,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle {
"\u4f0f\u5c14\u52a0\u683c\u52d2\u590f\u4ee4\u65f6", "VOLST"}},
{"Europe/Warsaw", CET},
{"Europe/Zagreb", CET},
- {"Europe/Zaporozhye", EET},
+ {"Europe/Zaporozhye", FET},
{"Europe/Zurich", CET},
{"GB", GMTBST},
{"GB-Eire", GMTBST},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java
index 9a7fbe9479a..bafb87e408e 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java
@@ -103,6 +103,8 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle {
"\u6771\u65b9\u65e5\u5149\u7bc0\u7d04\u6642\u9593", "EDT"};
String EST_NSW[] = new String[] {"\u6771\u65b9\u6a19\u6e96\u6642\u9593 (\u65b0\u5357\u5a01\u723e\u65af)", "EST",
"\u6771\u65b9\u590f\u4ee4\u6642\u9593 (\u65b0\u5357\u5a01\u723e\u65af)", "EST"};
+ String FET[] = new String[] {"Further-eastern European Time", "FET",
+ "Further-eastern European Summer Time", "FEST"};
String GHMT[] = new String[] {"\u8fe6\u7d0d\u5e73\u5747\u6642\u9593", "GMT",
"\u8fe6\u7d0d\u590f\u4ee4\u6642\u9593", "GHST"};
String GAMBIER[] = new String[] {"\u7518\u6bd4\u723e\u6642\u9593", "GAMT",
@@ -186,7 +188,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle {
String SAMOA[] = new String[] {"\u85a9\u6469\u4e9e\u6a19\u6e96\u6642\u9593", "SST",
"\u85a9\u6469\u4e9e\u65e5\u5149\u7bc0\u7d04\u6642\u9593", "SDT"};
String WST_SAMOA[] = new String[] {"\u897f\u85a9\u6469\u4e9e\u6642\u9593", "WST",
- "\u897f\u85a9\u6469\u4e9e\u590f\u4ee4\u6642\u9593", "WSST"};
+ "\u897f\u85a9\u6469\u4e9e\u590f\u4ee4\u6642\u9593", "WSDT"};
String ChST[] = new String[] {"\u67e5\u83ab\u6d1b\u6a19\u6e96\u6642\u9593", "ChST",
"\u67e5\u83ab\u6d1b\u65e5\u5149\u7bc0\u7d04\u6642\u9593", "ChDT"};
String VICTORIA[] = new String[] {"\u6771\u90e8\u6a19\u6e96\u6642\u9593 (\u7dad\u591a\u5229\u4e9e\u90a6)", "EST",
@@ -511,6 +513,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle {
"\u5854\u5409\u514b\u590f\u4ee4\u6642\u9593", "TJST"}},
{"Asia/Gaza", EET},
{"Asia/Harbin", CTT},
+ {"Asia/Hebron", EET},
{"Asia/Ho_Chi_Minh", ICT},
{"Asia/Hong_Kong", HKT},
{"Asia/Hovd", new String[] {"\u4faf\u5fb7 (Hovd) \u6642\u9593", "HOVT",
@@ -675,9 +678,8 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle {
{"Europe/Isle_of_Man", GMTBST},
{"Europe/Istanbul", EET},
{"Europe/Jersey", GMTBST},
- {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
- "Kaliningrad Summer Time", "KALST"}},
- {"Europe/Kiev", EET},
+ {"Europe/Kaliningrad", FET},
+ {"Europe/Kiev", FET},
{"Europe/Lisbon", WET},
{"Europe/Ljubljana", CET},
{"Europe/London", GMTBST},
@@ -685,7 +687,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle {
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", EET},
+ {"Europe/Minsk", FET},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -698,14 +700,14 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle {
"\u6c99\u99ac\u62c9\u590f\u4ee4\u6642\u9593", "SAMST"}},
{"Europe/San_Marino", CET},
{"Europe/Sarajevo", CET},
- {"Europe/Simferopol", EET},
+ {"Europe/Simferopol", FET},
{"Europe/Skopje", CET},
{"Europe/Sofia", EET},
{"Europe/Stockholm", CET},
{"Europe/Tallinn", EET},
{"Europe/Tirane", CET},
{"Europe/Tiraspol", EET},
- {"Europe/Uzhgorod", EET},
+ {"Europe/Uzhgorod", FET},
{"Europe/Vaduz", CET},
{"Europe/Vatican", CET},
{"Europe/Vienna", CET},
@@ -714,7 +716,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle {
"\u4f0f\u723e\u52a0\u683c\u52d2\u590f\u4ee4\u6642\u9593", "VOLST"}},
{"Europe/Warsaw", CET},
{"Europe/Zagreb", CET},
- {"Europe/Zaporozhye", EET},
+ {"Europe/Zaporozhye", FET},
{"Europe/Zurich", CET},
{"GB", GMTBST},
{"GB-Eire", GMTBST},
diff --git a/jdk/src/share/classes/sun/util/xml/XMLUtils.java b/jdk/src/share/classes/sun/util/xml/XMLUtils.java
index ab7ca851396..07677334db8 100644
--- a/jdk/src/share/classes/sun/util/xml/XMLUtils.java
+++ b/jdk/src/share/classes/sun/util/xml/XMLUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -76,7 +76,7 @@ public class XMLUtils {
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
- Element propertiesElement = (Element)doc.getChildNodes().item(1);
+ Element propertiesElement = doc.getDocumentElement();
String xmlVersion = propertiesElement.getAttribute("version");
if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0)
throw new InvalidPropertiesFormatException(
diff --git a/jdk/src/share/demo/jfc/TransparentRuler/README.txt b/jdk/src/share/demo/jfc/TransparentRuler/README.txt
index ddcf9de1d5e..0b66bd213c2 100644
--- a/jdk/src/share/demo/jfc/TransparentRuler/README.txt
+++ b/jdk/src/share/demo/jfc/TransparentRuler/README.txt
@@ -1,14 +1,10 @@
To run the Ruler demo:
- java -jar Ruler.jar
+ java -jar TransparentRuler.jar
These instructions assume that this installation's version of the java
command is in your path. If it isn't, then you should either
specify the complete path to the java command or update your
PATH environment variable as described in the installation
instructions for the Java(TM) SE Development Kit.
-
-KNOWN ISSUES:
-Context menu is clipped with the window shape. The issues are:
-CR 7027486 JPopupMenu doesn't take window shape into account
diff --git a/jdk/src/share/javavm/export/jvm.h b/jdk/src/share/javavm/export/jvm.h
index d1dfefca47f..8d833ebeeac 100644
--- a/jdk/src/share/javavm/export/jvm.h
+++ b/jdk/src/share/javavm/export/jvm.h
@@ -1424,7 +1424,8 @@ typedef struct {
*/
unsigned int thread_park_blocker : 1;
unsigned int post_vm_init_hook_enabled : 1;
- unsigned int : 30;
+ unsigned int pending_list_uses_discovered_field : 1;
+ unsigned int : 29;
unsigned int : 32;
unsigned int : 32;
} jdk_version_info;
diff --git a/jdk/src/share/lib/security/sunpkcs11-solaris.cfg b/jdk/src/share/lib/security/sunpkcs11-solaris.cfg
index daf03a447a3..3b3f7fa82f9 100644
--- a/jdk/src/share/lib/security/sunpkcs11-solaris.cfg
+++ b/jdk/src/share/lib/security/sunpkcs11-solaris.cfg
@@ -11,6 +11,9 @@ library = /usr/lib/$ISA/libpkcs11.so
handleStartupErrors = ignoreAll
+# Use the X9.63 encoding for EC points (do not wrap in an ASN.1 OctetString).
+useEcX963Encoding = true
+
attributes = compatibility
disabledMechanisms = {
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp b/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
index 17c48a4ceac..cee146d4db4 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
@@ -1112,11 +1112,14 @@ void unpacker::read_Utf8_values(entry* cpMap, int len) {
uint size3 = suffix * 3;
if (suffix == 0) continue; // done with empty string
chars.malloc(size3);
+ CHECK;
byte* chp = chars.ptr;
band saved_band = cp_Utf8_big_chars;
cp_Utf8_big_chars.readData(suffix);
+ CHECK;
for (int j = 0; j < suffix; j++) {
unsigned short ch = cp_Utf8_big_chars.getInt();
+ CHECK;
chp = store_Utf8_char(chp, ch);
}
chars.realloc(chp - chars.ptr);
@@ -1134,10 +1137,12 @@ void unpacker::read_Utf8_values(entry* cpMap, int len) {
CHECK;
int prevlen = 0; // previous string length (in chars)
tmallocs.add(bigbuf.ptr); // free after this block
+ CHECK;
cp_Utf8_prefix.rewind();
for (i = 0; i < len; i++) {
bytes& chars = allsuffixes[i];
int prefix = (i < PREFIX_SKIP_2)? 0: cp_Utf8_prefix.getInt();
+ CHECK;
int suffix = (int)chars.len;
byte* fillp;
// by induction, the buffer is already filled with the prefix
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp b/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp
index 0f770d8064a..e5197e1a3f1 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -52,7 +52,7 @@ void* must_malloc(size_t size) {
if (msize >= 0 && msize < sizeof(int))
msize = sizeof(int); // see 0xbaadf00d below
#endif
- void* ptr = (msize > PSIZE_MAX) ? null : malloc(msize);
+ void* ptr = (msize > PSIZE_MAX || msize <= 0) ? null : malloc(msize);
if (ptr != null) {
memset(ptr, 0, size);
} else {
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/utils.h b/jdk/src/share/native/com/sun/java/util/jar/pack/utils.h
index d24e5b50ea8..89619316a0e 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/utils.h
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/utils.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -33,7 +33,7 @@ void mtrace(char c, void* ptr, size_t size);
#endif
// overflow management
-#define OVERFLOW ((size_t)-1)
+#define OVERFLOW ((uint)-1)
#define PSIZE_MAX (OVERFLOW/2) /* normal size limit */
inline size_t scale_size(size_t size, size_t scale) {
diff --git a/jdk/src/share/native/common/jdk_util.c b/jdk/src/share/native/common/jdk_util.c
index e737982893e..8fe32bfcfaf 100644
--- a/jdk/src/share/native/common/jdk_util.c
+++ b/jdk/src/share/native/common/jdk_util.c
@@ -101,5 +101,5 @@ JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
// Advertise presence of sun.misc.PostVMInitHook:
// future optimization: detect if this is enabled.
info->post_vm_init_hook_enabled = 1;
-
+ info->pending_list_uses_discovered_field = 1;
}
diff --git a/jdk/src/share/native/java/io/ObjectInputStream.c b/jdk/src/share/native/java/io/ObjectInputStream.c
index 8b8a710e614..1e288e911ec 100644
--- a/jdk/src/share/native/java/io/ObjectInputStream.c
+++ b/jdk/src/share/native/java/io/ObjectInputStream.c
@@ -173,16 +173,3 @@ Java_java_io_ObjectInputStream_bytesToDoubles(JNIEnv *env,
(*env)->ReleasePrimitiveArrayCritical(env, dst, doubles, 0);
}
-/*
- * Class: java_io_ObjectInputStream
- * Method: latestUserDefinedLoader
- * Signature: ()Ljava/lang/ClassLoader;
- *
- * Returns the first non-null class loader up the execution stack, or null
- * if only code from the null class loader is on the stack.
- */
-JNIEXPORT jobject JNICALL
-Java_java_io_ObjectInputStream_latestUserDefinedLoader(JNIEnv *env, jclass cls)
-{
- return JVM_LatestUserDefinedLoader(env);
-}
diff --git a/jdk/src/share/native/sun/java2d/loops/TransformHelper.c b/jdk/src/share/native/sun/java2d/loops/TransformHelper.c
index a5117747476..23bba354756 100644
--- a/jdk/src/share/native/sun/java2d/loops/TransformHelper.c
+++ b/jdk/src/share/native/sun/java2d/loops/TransformHelper.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, 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
@@ -284,7 +284,7 @@ Java_sun_java2d_loops_TransformHelper_Transform
TransformHelperFunc *pHelperFunc;
TransformInterpFunc *pInterpFunc;
jdouble xorig, yorig;
- jint numedges;
+ jlong numedges;
jint *pEdges;
jint edgebuf[2 + MAXEDGES * 2];
union {
@@ -379,19 +379,44 @@ Java_sun_java2d_loops_TransformHelper_Transform
}
Region_IntersectBounds(&clipInfo, &dstInfo.bounds);
- numedges = (dstInfo.bounds.y2 - dstInfo.bounds.y1);
- if (numedges > MAXEDGES) {
- pEdges = malloc((2 + 2 * numedges) * sizeof (*pEdges));
- if (pEdges == NULL) {
- SurfaceData_InvokeUnlock(env, dstOps, &dstInfo);
- SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
- /* edgeArray should already contain zeros for min/maxy */
- return;
- }
+ numedges = (((jlong) dstInfo.bounds.y2) - ((jlong) dstInfo.bounds.y1));
+ if (numedges <= 0) {
+ pEdges = NULL;
+ } else if (!JNU_IsNull(env, edgeArray)) {
+ /*
+ * Ideally Java should allocate an array large enough, but if
+ * we ever have a miscommunication about the number of edge
+ * lines, or if the Java array calculation should overflow to
+ * a positive number and succeed in allocating an array that
+ * is too small, we need to verify that it can still hold the
+ * number of integers that we plan to store to be safe.
+ */
+ jsize edgesize = (*env)->GetArrayLength(env, edgeArray);
+ /* (edgesize/2 - 1) should avoid any overflow or underflow. */
+ pEdges = (((edgesize / 2) - 1) >= numedges)
+ ? (*env)->GetPrimitiveArrayCritical(env, edgeArray, NULL)
+ : NULL;
+ } else if (numedges > MAXEDGES) {
+ /* numedges variable (jlong) can be at most ((1<<32)-1) */
+ /* memsize can overflow a jint, but not a jlong */
+ jlong memsize = ((numedges * 2) + 2) * sizeof(*pEdges);
+ pEdges = (memsize == ((size_t) memsize))
+ ? malloc((size_t) memsize)
+ : NULL;
} else {
pEdges = edgebuf;
}
+ if (pEdges == NULL) {
+ if (numedges > 0) {
+ JNU_ThrowInternalError(env, "Unable to allocate edge list");
+ }
+ SurfaceData_InvokeUnlock(env, dstOps, &dstInfo);
+ SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
+ /* edgeArray should already contain zeros for min/maxy */
+ return;
+ }
+
Transform_GetInfo(env, itxform, &itxInfo);
if (!Region_IsEmpty(&clipInfo)) {
@@ -500,14 +525,14 @@ Java_sun_java2d_loops_TransformHelper_Transform
} else {
pEdges[0] = pEdges[1] = 0;
}
- SurfaceData_InvokeUnlock(env, dstOps, &dstInfo);
- SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
+
if (!JNU_IsNull(env, edgeArray)) {
- (*env)->SetIntArrayRegion(env, edgeArray, 0, 2+numedges*2, pEdges);
- }
- if (pEdges != edgebuf) {
+ (*env)->ReleasePrimitiveArrayCritical(env, edgeArray, pEdges, 0);
+ } else if (pEdges != edgebuf) {
free(pEdges);
}
+ SurfaceData_InvokeUnlock(env, dstOps, &dstInfo);
+ SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
}
static void
diff --git a/jdk/src/share/native/sun/misc/VM.c b/jdk/src/share/native/sun/misc/VM.c
index 8744da78403..2dbeb985d81 100644
--- a/jdk/src/share/native/sun/misc/VM.c
+++ b/jdk/src/share/native/sun/misc/VM.c
@@ -111,6 +111,11 @@ Java_sun_misc_VM_getThreadStateValues(JNIEnv *env, jclass cls,
get_thread_state_info(env, JAVA_THREAD_STATE_TERMINATED, values, names);
}
+JNIEXPORT jobject JNICALL
+Java_sun_misc_VM_latestUserDefinedLoader(JNIEnv *env, jclass cls) {
+ return JVM_LatestUserDefinedLoader(env);
+}
+
typedef void (JNICALL *GetJvmVersionInfo_fp)(JNIEnv*, jvm_version_info*, size_t);
JNIEXPORT void JNICALL
diff --git a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_convert.c b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_convert.c
index c32a278b585..34080238b1b 100644
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_convert.c
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_convert.c
@@ -273,7 +273,7 @@ CK_VERSION_PTR jVersionToCKVersionPtr(JNIEnv *env, jobject jVersion)
/* allocate memory for CK_VERSION pointer */
ckpVersion = (CK_VERSION_PTR) malloc(sizeof(CK_VERSION));
if (ckpVersion == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
ckpVersion->major = jByteToCKByte(jMajor);
@@ -326,7 +326,7 @@ CK_DATE * jDateObjectPtrToCKDatePtr(JNIEnv *env, jobject jDate)
/* allocate memory for CK_DATE pointer */
ckpDate = (CK_DATE *) malloc(sizeof(CK_DATE));
if (ckpDate == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
@@ -340,7 +340,7 @@ CK_DATE * jDateObjectPtrToCKDatePtr(JNIEnv *env, jobject jDate)
jTempChars = (jchar*) malloc((ckLength) * sizeof(jchar));
if (jTempChars == NULL) {
free(ckpDate);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
(*env)->GetCharArrayRegion(env, jYear, 0, ckLength, jTempChars);
@@ -364,7 +364,7 @@ CK_DATE * jDateObjectPtrToCKDatePtr(JNIEnv *env, jobject jDate)
jTempChars = (jchar*) malloc((ckLength) * sizeof(jchar));
if (jTempChars == NULL) {
free(ckpDate);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
(*env)->GetCharArrayRegion(env, jMonth, 0, ckLength, jTempChars);
@@ -388,7 +388,7 @@ CK_DATE * jDateObjectPtrToCKDatePtr(JNIEnv *env, jobject jDate)
jTempChars = (jchar*) malloc((ckLength) * sizeof(jchar));
if (jTempChars == NULL) {
free(ckpDate);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
(*env)->GetCharArrayRegion(env, jDay, 0, ckLength, jTempChars);
@@ -558,7 +558,7 @@ CK_TLS_PRF_PARAMS jTlsPrfParamsToCKTlsPrfParam(JNIEnv *env, jobject jParam)
if (ckParam.pulOutputLen == NULL) {
free(ckParam.pSeed);
free(ckParam.pLabel);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return ckParam;
}
jByteArrayToCKByteArray(env, jOutput, &(ckParam.pOutput), ckParam.pulOutputLen);
@@ -665,7 +665,7 @@ CK_SSL3_KEY_MAT_PARAMS jSsl3KeyMatParamToCKSsl3KeyMatParam(JNIEnv *env, jobject
if (ckParam.pReturnedKeyMaterial == NULL) {
free(ckParam.RandomInfo.pClientRandom);
free(ckParam.RandomInfo.pServerRandom);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return ckParam;
}
@@ -1013,7 +1013,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
ckpParam = (CK_SSL3_MASTER_KEY_DERIVE_PARAMS_PTR) malloc(sizeof(CK_SSL3_MASTER_KEY_DERIVE_PARAMS));
if (ckpParam == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
@@ -1040,7 +1040,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
ckpParam = (CK_SSL3_KEY_MAT_PARAMS_PTR) malloc(sizeof(CK_SSL3_KEY_MAT_PARAMS));
if (ckpParam == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
@@ -1067,7 +1067,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
ckpParam = (CK_TLS_PRF_PARAMS_PTR) malloc(sizeof(CK_TLS_PRF_PARAMS));
if (ckpParam == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
@@ -1094,7 +1094,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
ckpParam = (CK_AES_CTR_PARAMS_PTR) malloc(sizeof(CK_AES_CTR_PARAMS));
if (ckpParam == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
@@ -1121,7 +1121,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
ckpParam = (CK_RSA_PKCS_OAEP_PARAMS_PTR) malloc(sizeof(CK_RSA_PKCS_OAEP_PARAMS));
if (ckpParam == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
@@ -1148,7 +1148,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
ckpParam = (CK_PBE_PARAMS_PTR) malloc(sizeof(CK_PBE_PARAMS));
if (ckpParam == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
@@ -1175,7 +1175,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
ckpParam = (CK_PKCS5_PBKD2_PARAMS_PTR) malloc(sizeof(CK_PKCS5_PBKD2_PARAMS));
if (ckpParam == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
@@ -1202,7 +1202,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
ckpParam = (CK_RSA_PKCS_PSS_PARAMS_PTR) malloc(sizeof(CK_RSA_PKCS_PSS_PARAMS));
if (ckpParam == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
@@ -1229,7 +1229,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
ckpParam = (CK_ECDH1_DERIVE_PARAMS_PTR) malloc(sizeof(CK_ECDH1_DERIVE_PARAMS));
if (ckpParam == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
@@ -1256,7 +1256,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
ckpParam = (CK_ECDH2_DERIVE_PARAMS_PTR) malloc(sizeof(CK_ECDH2_DERIVE_PARAMS));
if (ckpParam == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
@@ -1283,7 +1283,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
ckpParam = (CK_X9_42_DH1_DERIVE_PARAMS_PTR) malloc(sizeof(CK_X9_42_DH1_DERIVE_PARAMS));
if (ckpParam == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
@@ -1310,7 +1310,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
ckpParam = (CK_X9_42_DH2_DERIVE_PARAMS_PTR) malloc(sizeof(CK_X9_42_DH2_DERIVE_PARAMS));
if (ckpParam == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
diff --git a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_digest.c b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_digest.c
index b7288c1c842..d33e4e206f3 100644
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_digest.c
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_digest.c
@@ -131,7 +131,7 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestSingle
/* always use single part op, even for large data */
bufP = (CK_BYTE_PTR) malloc((size_t)jInLen);
if (bufP == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return 0;
}
}
@@ -190,7 +190,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestUpdate
bufLen = min(MAX_HEAP_BUFFER_LEN, jInLen);
bufP = (CK_BYTE_PTR) malloc((size_t)bufLen);
if (bufP == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
}
diff --git a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_dual.c b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_dual.c
index 1d030c51e86..a76e4042f9b 100644
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_dual.c
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_dual.c
@@ -92,7 +92,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestEn
ckpEncryptedPart = (CK_BYTE_PTR) malloc(ckEncryptedPartLength * sizeof(CK_BYTE));
if (ckpEncryptedPart == NULL) {
free(ckpPart);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
@@ -144,7 +144,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptD
ckpPart = (CK_BYTE_PTR) malloc(ckPartLength * sizeof(CK_BYTE));
if (ckpPart == NULL) {
free(ckpEncryptedPart);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
@@ -196,7 +196,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignEncr
ckpEncryptedPart = (CK_BYTE_PTR) malloc(ckEncryptedPartLength * sizeof(CK_BYTE));
if (ckpEncryptedPart == NULL) {
free(ckpPart);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
@@ -248,7 +248,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptV
ckpPart = (CK_BYTE_PTR) malloc(ckPartLength * sizeof(CK_BYTE));
if (ckpPart == NULL) {
free(ckpEncryptedPart);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
diff --git a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_general.c b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_general.c
index a48c08b4db6..14085a16213 100644
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_general.c
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_general.c
@@ -71,7 +71,10 @@ jfieldID mech_pParameterID;
jclass jByteArrayClass;
jclass jLongClass;
+JavaVM* jvm = NULL;
+
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
+ jvm = vm;
return JNI_VERSION_1_4;
}
@@ -351,7 +354,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetSlotList
ckpSlotList = (CK_SLOT_ID_PTR) malloc(ckTokenNumber * sizeof(CK_SLOT_ID));
if (ckpSlotList == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
@@ -652,7 +655,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetMechanismList
ckpMechanismList = (CK_MECHANISM_TYPE_PTR)
malloc(ckMechanismNumber * sizeof(CK_MECHANISM_TYPE));
if (ckpMechanismList == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
diff --git a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_keymgmt.c b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_keymgmt.c
index 7f987fb3c26..e74230f17a6 100644
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_keymgmt.c
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_keymgmt.c
@@ -165,7 +165,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Generate
if (ckMechanism.pParameter != NULL_PTR) {
free(ckMechanism.pParameter);
}
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
ckpPublicKeyHandle = ckpKeyHandles; /* first element of array is Public Key */
@@ -253,7 +253,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1WrapKey
if (ckMechanism.pParameter != NULL_PTR) {
free(ckMechanism.pParameter);
}
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
diff --git a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_mutex.c b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_mutex.c
index 6bc1edcd99c..29c80b8a799 100644
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_mutex.c
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_mutex.c
@@ -92,7 +92,7 @@ CK_C_INITIALIZE_ARGS_PTR makeCKInitArgsAdapter(JNIEnv *env, jobject jInitArgs)
/* convert the Java InitArgs object to a pointer to a CK_C_INITIALIZE_ARGS structure */
ckpInitArgs = (CK_C_INITIALIZE_ARGS_PTR) malloc(sizeof(CK_C_INITIALIZE_ARGS));
if (ckpInitArgs == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL_PTR;
}
@@ -141,7 +141,7 @@ CK_C_INITIALIZE_ARGS_PTR makeCKInitArgsAdapter(JNIEnv *env, jobject jInitArgs)
ckpGlobalInitArgs = (CK_C_INITIALIZE_ARGS_PTR) malloc(sizeof(CK_C_INITIALIZE_ARGS));
if (ckpGlobalInitArgs == NULL) {
free(ckpInitArgs);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL_PTR;
}
@@ -178,9 +178,8 @@ CK_C_INITIALIZE_ARGS_PTR makeCKInitArgsAdapter(JNIEnv *env, jobject jInitArgs)
*/
CK_RV callJCreateMutex(CK_VOID_PTR_PTR ppMutex)
{
- JavaVM *jvm;
+ extern JavaVM *jvm;
JNIEnv *env;
- jsize actualNumberVMs;
jint returnValue;
jthrowable pkcs11Exception;
jclass pkcs11ExceptionClass;
@@ -196,8 +195,7 @@ CK_RV callJCreateMutex(CK_VOID_PTR_PTR ppMutex)
/* Get the currently running Java VM */
- returnValue = JNI_GetCreatedJavaVMs(&jvm, (jsize) 1, &actualNumberVMs);
- if ((returnValue != 0) || (actualNumberVMs <= 0)) { return rv ;} /* there is no VM running */
+ if (jvm == NULL) { return rv ;} /* there is no VM running */
/* Determine, if current thread is already attached */
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
@@ -273,9 +271,8 @@ CK_RV callJCreateMutex(CK_VOID_PTR_PTR ppMutex)
*/
CK_RV callJDestroyMutex(CK_VOID_PTR pMutex)
{
- JavaVM *jvm;
+ extern JavaVM *jvm;
JNIEnv *env;
- jsize actualNumberVMs;
jint returnValue;
jthrowable pkcs11Exception;
jclass pkcs11ExceptionClass;
@@ -291,8 +288,7 @@ CK_RV callJDestroyMutex(CK_VOID_PTR pMutex)
/* Get the currently running Java VM */
- returnValue = JNI_GetCreatedJavaVMs(&jvm, (jsize) 1, &actualNumberVMs);
- if ((returnValue != 0) || (actualNumberVMs <= 0)) { return rv ; } /* there is no VM running */
+ if (jvm == NULL) { return rv ; } /* there is no VM running */
/* Determine, if current thread is already attached */
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
@@ -367,9 +363,8 @@ CK_RV callJDestroyMutex(CK_VOID_PTR pMutex)
*/
CK_RV callJLockMutex(CK_VOID_PTR pMutex)
{
- JavaVM *jvm;
+ extern JavaVM *jvm;
JNIEnv *env;
- jsize actualNumberVMs;
jint returnValue;
jthrowable pkcs11Exception;
jclass pkcs11ExceptionClass;
@@ -385,8 +380,7 @@ CK_RV callJLockMutex(CK_VOID_PTR pMutex)
/* Get the currently running Java VM */
- returnValue = JNI_GetCreatedJavaVMs(&jvm, (jsize) 1, &actualNumberVMs);
- if ((returnValue != 0) || (actualNumberVMs <= 0)) { return rv ; } /* there is no VM running */
+ if (jvm == NULL) { return rv ; } /* there is no VM running */
/* Determine, if current thread is already attached */
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
@@ -457,9 +451,8 @@ CK_RV callJLockMutex(CK_VOID_PTR pMutex)
*/
CK_RV callJUnlockMutex(CK_VOID_PTR pMutex)
{
- JavaVM *jvm;
+ extern JavaVM *jvm;
JNIEnv *env;
- jsize actualNumberVMs;
jint returnValue;
jthrowable pkcs11Exception;
jclass pkcs11ExceptionClass;
@@ -475,8 +468,7 @@ CK_RV callJUnlockMutex(CK_VOID_PTR pMutex)
/* Get the currently running Java VM */
- returnValue = JNI_GetCreatedJavaVMs(&jvm, (jsize) 1, &actualNumberVMs);
- if ((returnValue != 0) || (actualNumberVMs <= 0)) { return rv ; } /* there is no VM running */
+ if (jvm == NULL) { return rv ; } /* there is no VM running */
/* Determine, if current thread is already attached */
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
diff --git a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_objmgmt.c b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_objmgmt.c
index aea03eeba0d..910453eacd7 100644
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_objmgmt.c
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_objmgmt.c
@@ -258,7 +258,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetAttributeVa
ckpAttributes[i].pValue = (void *) malloc(ckBufferLength);
if (ckpAttributes[i].pValue == NULL) {
freeCKAttributeArray(ckpAttributes, i);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
ckpAttributes[i].ulValueLen = ckBufferLength;
@@ -390,7 +390,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1FindObje
ckMaxObjectLength = jLongToCKULong(jMaxObjectCount);
ckpObjectHandleArray = (CK_OBJECT_HANDLE_PTR) malloc(sizeof(CK_OBJECT_HANDLE) * ckMaxObjectLength);
if (ckpObjectHandleArray == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
diff --git a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_sessmgmt.c b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_sessmgmt.c
index 1b7538a49a3..524fde013af 100644
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_sessmgmt.c
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_sessmgmt.c
@@ -98,7 +98,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1OpenSession
if (jNotify != NULL) {
notifyEncapsulation = (NotifyEncapsulation *) malloc(sizeof(NotifyEncapsulation));
if (notifyEncapsulation == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return 0L;
}
notifyEncapsulation->jApplicationData = (jApplication != NULL)
@@ -301,7 +301,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetOpera
ckpState = (CK_BYTE_PTR) malloc(ckStateLength);
if (ckpState == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
@@ -435,7 +435,7 @@ void putNotifyEntry(JNIEnv *env, CK_SESSION_HANDLE hSession, NotifyEncapsulation
newNode = (NotifyListNode *) malloc(sizeof(NotifyListNode));
if (newNode == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
newNode->hSession = hSession;
@@ -558,9 +558,8 @@ CK_RV notifyCallback(
)
{
NotifyEncapsulation *notifyEncapsulation;
- JavaVM *jvm;
+ extern JavaVM *jvm;
JNIEnv *env;
- jsize actualNumberVMs;
jint returnValue;
jlong jSessionHandle;
jlong jEvent;
@@ -577,8 +576,7 @@ CK_RV notifyCallback(
notifyEncapsulation = (NotifyEncapsulation *) pApplication;
/* Get the currently running Java VM */
- returnValue = JNI_GetCreatedJavaVMs(&jvm, (jsize) 1, &actualNumberVMs);
- if ((returnValue != 0) || (actualNumberVMs <= 0)) { return rv ; } /* there is no VM running */
+ if (jvm == NULL) { return rv ; } /* there is no VM running */
/* Determine, if current thread is already attached */
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
diff --git a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_sign.c b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_sign.c
index e4a43937f51..e07bcf59d59 100644
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_sign.c
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_sign.c
@@ -132,7 +132,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Sign
ckpSignature = (CK_BYTE_PTR) malloc(ckSignatureLength * sizeof(CK_BYTE));
if (ckpSignature == NULL) {
free(ckpData);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
@@ -146,7 +146,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Sign
ckpSignature = (CK_BYTE_PTR) malloc(256 * sizeof(CK_BYTE));
if (ckpSignature == NULL) {
free(ckpData);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
rv = (*ckpFunctions->C_Sign)(ckSessionHandle, ckpData, ckDataLength, ckpSignature, &ckSignatureLength);
@@ -156,7 +156,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Sign
ckpSignature = (CK_BYTE_PTR) malloc(ckSignatureLength * sizeof(CK_BYTE));
if (ckpSignature == NULL) {
free(ckpData);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
rv = (*ckpFunctions->C_Sign)(ckSessionHandle, ckpData, ckDataLength, ckpSignature, &ckSignatureLength);
@@ -210,7 +210,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignUpdate
bufLen = min(MAX_HEAP_BUFFER_LEN, jInLen);
bufP = (CK_BYTE_PTR) malloc((size_t)bufLen);
if (bufP == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
}
@@ -270,7 +270,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignFina
if (rv == CKR_BUFFER_TOO_SMALL) {
bufP = (CK_BYTE_PTR) malloc(ckSignatureLength);
if (bufP == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
rv = (*ckpFunctions->C_SignFinal)(ckSessionHandle, bufP, &ckSignatureLength);
@@ -355,7 +355,7 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignRecover
} else {
inBufP = (CK_BYTE_PTR) malloc((size_t)jInLen);
if (inBufP == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return 0;
}
}
@@ -373,7 +373,7 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignRecover
if (inBufP != INBUF) {
free(inBufP);
}
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return 0;
}
rv = (*ckpFunctions->C_SignRecover)(ckSessionHandle, inBufP, jInLen, outBufP, &ckSignatureLength);
@@ -508,7 +508,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1VerifyUpdate
bufLen = min(MAX_HEAP_BUFFER_LEN, jInLen);
bufP = (CK_BYTE_PTR) malloc((size_t)bufLen);
if (bufP == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
}
@@ -638,7 +638,7 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1VerifyRecover
} else {
inBufP = (CK_BYTE_PTR) malloc((size_t)jInLen);
if (inBufP == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return 0;
}
}
@@ -656,7 +656,7 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1VerifyRecover
outBufP = (CK_BYTE_PTR) malloc(ckDataLength);
if (outBufP == NULL) {
if (inBufP != INBUF) { free(inBufP); }
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return 0;
}
rv = (*ckpFunctions->C_VerifyRecover)(ckSessionHandle, inBufP, jInLen, outBufP, &ckDataLength);
diff --git a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_util.c b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_util.c
index 36a4b15943a..9436f1ece4c 100644
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_util.c
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_util.c
@@ -213,28 +213,52 @@ jlong ckAssertReturnValueOK(JNIEnv *env, CK_RV returnValue)
return jErrorCode ;
}
+
/*
- * This function simply throws an IOException
- *
- * @param env Used to call JNI funktions and to get the Exception class.
- * @param message The message string of the Exception object.
+ * Throws a Java Exception by name
*/
-void throwIOException(JNIEnv *env, const char *message)
+void throwByName(JNIEnv *env, const char *name, const char *msg)
{
- JNU_ThrowByName(env, CLASS_IO_EXCEPTION, message);
+ jclass cls = (*env)->FindClass(env, name);
+
+ if (cls != 0) /* Otherwise an exception has already been thrown */
+ (*env)->ThrowNew(env, cls, msg);
+}
+
+/*
+ * Throws java.lang.OutOfMemoryError
+ */
+void throwOutOfMemoryError(JNIEnv *env, const char *msg)
+{
+ throwByName(env, "java/lang/OutOfMemoryError", msg);
+}
+
+/*
+ * Throws java.lang.NullPointerException
+ */
+void throwNullPointerException(JNIEnv *env, const char *msg)
+{
+ throwByName(env, "java/lang/NullPointerException", msg);
+}
+
+/*
+ * Throws java.io.IOException
+ */
+void throwIOException(JNIEnv *env, const char *msg)
+{
+ throwByName(env, "java/io/IOException", msg);
}
/*
* This function simply throws a PKCS#11RuntimeException with the given
- * string as its message. If the message is NULL, the exception is created
- * using the default constructor.
+ * string as its message.
*
* @param env Used to call JNI funktions and to get the Exception class.
* @param jmessage The message string of the Exception object.
*/
void throwPKCS11RuntimeException(JNIEnv *env, const char *message)
{
- JNU_ThrowByName(env, CLASS_PKCS11RUNTIMEEXCEPTION, message);
+ throwByName(env, CLASS_PKCS11RUNTIMEEXCEPTION, message);
}
/*
@@ -318,7 +342,7 @@ void jBooleanArrayToCKBBoolArray(JNIEnv *env, const jbooleanArray jArray, CK_BBO
*ckpLength = (*env)->GetArrayLength(env, jArray);
jpTemp = (jboolean*) malloc((*ckpLength) * sizeof(jboolean));
if (jpTemp == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
(*env)->GetBooleanArrayRegion(env, jArray, 0, *ckpLength, jpTemp);
@@ -330,7 +354,7 @@ void jBooleanArrayToCKBBoolArray(JNIEnv *env, const jbooleanArray jArray, CK_BBO
*ckpArray = (CK_BBOOL*) malloc ((*ckpLength) * sizeof(CK_BBOOL));
if (*ckpArray == NULL) {
free(jpTemp);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
for (i=0; i<(*ckpLength); i++) {
@@ -360,7 +384,7 @@ void jByteArrayToCKByteArray(JNIEnv *env, const jbyteArray jArray, CK_BYTE_PTR *
*ckpLength = (*env)->GetArrayLength(env, jArray);
jpTemp = (jbyte*) malloc((*ckpLength) * sizeof(jbyte));
if (jpTemp == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
(*env)->GetByteArrayRegion(env, jArray, 0, *ckpLength, jpTemp);
@@ -376,7 +400,7 @@ void jByteArrayToCKByteArray(JNIEnv *env, const jbyteArray jArray, CK_BYTE_PTR *
*ckpArray = (CK_BYTE_PTR) malloc ((*ckpLength) * sizeof(CK_BYTE));
if (*ckpArray == NULL) {
free(jpTemp);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
for (i=0; i<(*ckpLength); i++) {
@@ -407,7 +431,7 @@ void jLongArrayToCKULongArray(JNIEnv *env, const jlongArray jArray, CK_ULONG_PTR
*ckpLength = (*env)->GetArrayLength(env, jArray);
jTemp = (jlong*) malloc((*ckpLength) * sizeof(jlong));
if (jTemp == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
(*env)->GetLongArrayRegion(env, jArray, 0, *ckpLength, jTemp);
@@ -419,7 +443,7 @@ void jLongArrayToCKULongArray(JNIEnv *env, const jlongArray jArray, CK_ULONG_PTR
*ckpArray = (CK_ULONG_PTR) malloc (*ckpLength * sizeof(CK_ULONG));
if (*ckpArray == NULL) {
free(jTemp);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
for (i=0; i<(*ckpLength); i++) {
@@ -449,7 +473,7 @@ void jCharArrayToCKCharArray(JNIEnv *env, const jcharArray jArray, CK_CHAR_PTR *
*ckpLength = (*env)->GetArrayLength(env, jArray);
jpTemp = (jchar*) malloc((*ckpLength) * sizeof(jchar));
if (jpTemp == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
(*env)->GetCharArrayRegion(env, jArray, 0, *ckpLength, jpTemp);
@@ -461,7 +485,7 @@ void jCharArrayToCKCharArray(JNIEnv *env, const jcharArray jArray, CK_CHAR_PTR *
*ckpArray = (CK_CHAR_PTR) malloc (*ckpLength * sizeof(CK_CHAR));
if (*ckpArray == NULL) {
free(jpTemp);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
for (i=0; i<(*ckpLength); i++) {
@@ -491,7 +515,7 @@ void jCharArrayToCKUTF8CharArray(JNIEnv *env, const jcharArray jArray, CK_UTF8CH
*ckpLength = (*env)->GetArrayLength(env, jArray);
jTemp = (jchar*) malloc((*ckpLength) * sizeof(jchar));
if (jTemp == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
(*env)->GetCharArrayRegion(env, jArray, 0, *ckpLength, jTemp);
@@ -503,7 +527,7 @@ void jCharArrayToCKUTF8CharArray(JNIEnv *env, const jcharArray jArray, CK_UTF8CH
*ckpArray = (CK_UTF8CHAR_PTR) malloc (*ckpLength * sizeof(CK_UTF8CHAR));
if (*ckpArray == NULL) {
free(jTemp);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
for (i=0; i<(*ckpLength); i++) {
@@ -538,7 +562,7 @@ void jStringToCKUTF8CharArray(JNIEnv *env, const jstring jArray, CK_UTF8CHAR_PTR
*ckpArray = (CK_UTF8CHAR_PTR) malloc((*ckpLength + 1) * sizeof(CK_UTF8CHAR));
if (*ckpArray == NULL) {
(*env)->ReleaseStringUTFChars(env, (jstring) jArray, pCharArray);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
strcpy((char*)*ckpArray, pCharArray);
@@ -571,7 +595,7 @@ void jAttributeArrayToCKAttributeArray(JNIEnv *env, jobjectArray jArray, CK_ATTR
*ckpLength = jLongToCKULong(jLength);
*ckpArray = (CK_ATTRIBUTE_PTR) malloc(*ckpLength * sizeof(CK_ATTRIBUTE));
if (*ckpArray == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
TRACE1(", converting %d attibutes", jLength);
@@ -613,7 +637,7 @@ jbyteArray ckByteArrayToJByteArray(JNIEnv *env, const CK_BYTE_PTR ckpArray, CK_U
} else {
jpTemp = (jbyte*) malloc((ckLength) * sizeof(jbyte));
if (jpTemp == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
for (i=0; iCallBooleanMethod(env, jObject, jValueMethod);
ckpValue = (CK_BBOOL *) malloc(sizeof(CK_BBOOL));
if (ckpValue == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
*ckpValue = jBooleanToCKBBool(jValue);
@@ -842,7 +866,7 @@ CK_BYTE_PTR jByteObjectToCKBytePtr(JNIEnv *env, jobject jObject)
jValue = (*env)->CallByteMethod(env, jObject, jValueMethod);
ckpValue = (CK_BYTE_PTR) malloc(sizeof(CK_BYTE));
if (ckpValue == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
*ckpValue = jByteToCKByte(jValue);
@@ -871,7 +895,7 @@ CK_ULONG* jIntegerObjectToCKULongPtr(JNIEnv *env, jobject jObject)
jValue = (*env)->CallIntMethod(env, jObject, jValueMethod);
ckpValue = (CK_ULONG *) malloc(sizeof(CK_ULONG));
if (ckpValue == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
*ckpValue = jLongToCKLong(jValue);
@@ -900,7 +924,7 @@ CK_ULONG* jLongObjectToCKULongPtr(JNIEnv *env, jobject jObject)
jValue = (*env)->CallLongMethod(env, jObject, jValueMethod);
ckpValue = (CK_ULONG *) malloc(sizeof(CK_ULONG));
if (ckpValue == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
*ckpValue = jLongToCKULong(jValue);
@@ -930,7 +954,7 @@ CK_CHAR_PTR jCharObjectToCKCharPtr(JNIEnv *env, jobject jObject)
jValue = (*env)->CallCharMethod(env, jObject, jValueMethod);
ckpValue = (CK_CHAR_PTR) malloc(sizeof(CK_CHAR));
if (ckpValue == NULL) {
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return NULL;
}
*ckpValue = jCharToCKChar(jValue);
@@ -1087,7 +1111,7 @@ void jObjectToPrimitiveCKObjectPtrPtr(JNIEnv *env, jobject jObject, CK_VOID_PTR
malloc((strlen(exceptionMsgPrefix) + strlen(classNameString) + 1));
if (exceptionMsg == NULL) {
(*env)->ReleaseStringUTFChars(env, jClassNameString, classNameString);
- JNU_ThrowOutOfMemoryError(env, 0);
+ throwOutOfMemoryError(env, 0);
return;
}
strcpy(exceptionMsg, exceptionMsgPrefix);
diff --git a/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h b/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h
index ff6d550d523..bf3adf86a9d 100644
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h
@@ -228,7 +228,6 @@
#define CLASS_PKCS11EXCEPTION "sun/security/pkcs11/wrapper/PKCS11Exception"
#define CLASS_PKCS11RUNTIMEEXCEPTION "sun/security/pkcs11/wrapper/PKCS11RuntimeException"
#define CLASS_FILE_NOT_FOUND_EXCEPTION "java/io/FileNotFoundException"
-#define CLASS_IO_EXCEPTION "java/io/IOException"
#define CLASS_C_INITIALIZE_ARGS "sun/security/pkcs11/wrapper/CK_C_INITIALIZE_ARGS"
#define CLASS_CREATEMUTEX "sun/security/pkcs11/wrapper/CK_CREATEMUTEX"
#define CLASS_DESTROYMUTEX "sun/security/pkcs11/wrapper/CK_DESTROYMUTEX"
@@ -280,6 +279,8 @@
*/
jlong ckAssertReturnValueOK(JNIEnv *env, CK_RV returnValue);
+void throwOutOfMemoryError(JNIEnv *env, const char *message);
+void throwNullPointerException(JNIEnv *env, const char *message);
void throwIOException(JNIEnv *env, const char *message);
void throwPKCS11RuntimeException(JNIEnv *env, const char *message);
void throwDisconnectedRuntimeException(JNIEnv *env);
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java
index 7dd3812899e..6375a7b0cfb 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java
@@ -466,12 +466,16 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
if (true) {
switch(e.getID()) {
case PaintEvent.UPDATE:
- log.finer("XCP coalescePaintEvent : UPDATE : add : x = " +
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("XCP coalescePaintEvent : UPDATE : add : x = " +
r.x + ", y = " + r.y + ", width = " + r.width + ",height = " + r.height);
+ }
return;
case PaintEvent.PAINT:
- log.finer("XCP coalescePaintEvent : PAINT : add : x = " +
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("XCP coalescePaintEvent : PAINT : add : x = " +
r.x + ", y = " + r.y + ", width = " + r.width + ",height = " + r.height);
+ }
return;
}
}
@@ -1248,7 +1252,9 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
* ButtonPress, ButtonRelease, KeyPress, KeyRelease, EnterNotify, LeaveNotify, MotionNotify
*/
protected boolean isEventDisabled(XEvent e) {
- enableLog.finest("Component is {1}, checking for disabled event {0}", e, (isEnabled()?"enabled":"disable"));
+ if (enableLog.isLoggable(PlatformLogger.FINEST)) {
+ enableLog.finest("Component is {1}, checking for disabled event {0}", e, (isEnabled()?"enabled":"disable"));
+ }
if (!isEnabled()) {
switch (e.get_type()) {
case XConstants.ButtonPress:
@@ -1258,7 +1264,9 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
case XConstants.EnterNotify:
case XConstants.LeaveNotify:
case XConstants.MotionNotify:
- enableLog.finer("Event {0} is disable", e);
+ if (enableLog.isLoggable(PlatformLogger.FINER)) {
+ enableLog.finer("Event {0} is disable", e);
+ }
return true;
}
}
diff --git a/jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java b/jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java
index 272fda8d702..7ad7386070a 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java
@@ -678,7 +678,7 @@ public class WrapperGenerator {
public void writeToString(StructType stp, PrintWriter pw) {
int type;
pw.println("\n\n\tString getName() {\n\t\treturn \"" + stp.getName()+ "\"; \n\t}");
- pw.println("\n\n\tString getFieldsAsString() {\n\t\tString ret=\"\";\n");
+ pw.println("\n\n\tString getFieldsAsString() {\n\t\tStringBuilder ret = new StringBuilder(" + stp.getNumFields() * 40 + ");\n");
for (Enumeration e = stp.getMembers() ; e.hasMoreElements() ;) {
AtomicType tp = (AtomicType) e.nextElement();
@@ -688,24 +688,24 @@ public class WrapperGenerator {
if ((name != null) && (name.length() > 0))
{
if (type == AtomicType.TYPE_ATOM) {
- pw.println("\t\tret += \"\"+\"" + name + " = \" + XAtom.get(get_" + name + "()) +\", \";");
+ pw.println("\t\tret.append(\"" + name + " = \" ).append( XAtom.get(get_" + name + "()) ).append(\", \");");
} else if (name.equals("type")) {
- pw.println("\t\tret += \"\"+\"type = \" + XlibWrapper.eventToString[get_type()] +\", \";");
+ pw.println("\t\tret.append(\"type = \").append( XlibWrapper.eventToString[get_type()] ).append(\", \");");
} else if (name.equals("window")){
- pw.println("\t\tret += \"\"+\"window = \" + getWindow(get_window()) + \", \";");
+ pw.println("\t\tret.append(\"window = \" ).append( getWindow(get_window()) ).append(\", \");");
} else if (type == AtomicType.TYPE_ARRAY) {
- pw.print("\t\tret += \"{\"");
+ pw.print("\t\tret.append(\"{\")");
for (int i = 0; i < tp.getArrayLength(); i++) {
- pw.print(" + get_" + name + "(" + i + ") + \" \"");
+ pw.print("\n\t\t.append( get_" + name + "(" + i + ") ).append(\" \")");
}
- pw.println(" + \"}\";");
+ pw.println(".append( \"}\");");
} else {
- pw.println("\t\tret += \"\"+\"" + name +" = \" + get_"+ name+"() +\", \";");
+ pw.println("\t\tret.append(\"" + name +" = \").append( get_"+ name+"() ).append(\", \");");
}
}
}
- pw.println("\t\treturn ret;\n\t}\n\n");
+ pw.println("\t\treturn ret.toString();\n\t}\n\n");
}
public void writeStubs(StructType stp, PrintWriter pw) {
diff --git a/jdk/src/solaris/classes/sun/print/UnixPrintJob.java b/jdk/src/solaris/classes/sun/print/UnixPrintJob.java
index 912442a6540..206650de40e 100644
--- a/jdk/src/solaris/classes/sun/print/UnixPrintJob.java
+++ b/jdk/src/solaris/classes/sun/print/UnixPrintJob.java
@@ -38,7 +38,9 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.IOException;
+import java.io.PrintWriter;
import java.io.Reader;
+import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.util.Vector;
@@ -955,23 +957,49 @@ public class UnixPrintJob implements CancelablePrintJob {
private class PrinterSpooler implements java.security.PrivilegedAction {
PrintException pex;
+ private void handleProcessFailure(final Process failedProcess,
+ final String[] execCmd, final int result) throws IOException {
+ try (StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw)) {
+ pw.append("error=").append(Integer.toString(result));
+ pw.append(" running:");
+ for (String arg: execCmd) {
+ pw.append(" '").append(arg).append("'");
+ }
+ try (InputStream is = failedProcess.getErrorStream();
+ InputStreamReader isr = new InputStreamReader(is);
+ BufferedReader br = new BufferedReader(isr)) {
+ while (br.ready()) {
+ pw.println();
+ pw.append("\t\t").append(br.readLine());
+ }
+ } finally {
+ pw.flush();
+ throw new IOException(sw.toString());
+ }
+ }
+ }
+
public Object run() {
+ if (spoolFile == null || !spoolFile.exists()) {
+ pex = new PrintException("No spool file");
+ notifyEvent(PrintJobEvent.JOB_FAILED);
+ return null;
+ }
try {
/**
* Spool to the printer.
*/
- if (spoolFile == null || !spoolFile.exists()) {
- pex = new PrintException("No spool file");
- notifyEvent(PrintJobEvent.JOB_FAILED);
- return null;
- }
String fileName = spoolFile.getAbsolutePath();
String execCmd[] = printExecCmd(mDestination, mOptions,
mNoJobSheet, jobName, copies, fileName);
Process process = Runtime.getRuntime().exec(execCmd);
process.waitFor();
- spoolFile.delete();
+ final int result = process.exitValue();
+ if (0 != result) {
+ handleProcessFailure(process, execCmd, result);
+ }
notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
} catch (IOException ex) {
notifyEvent(PrintJobEvent.JOB_FAILED);
@@ -981,6 +1009,7 @@ public class UnixPrintJob implements CancelablePrintJob {
notifyEvent(PrintJobEvent.JOB_FAILED);
pex = new PrintException(ie);
} finally {
+ spoolFile.delete();
notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
}
return null;
diff --git a/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java b/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java
index f65a571abd2..e60765900b5 100644
--- a/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java
+++ b/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java
@@ -189,7 +189,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
if (printServices == null) {
return new PrintService[0];
} else {
- return printServices;
+ return (PrintService[])printServices.clone();
}
}
diff --git a/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_config.h b/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_config.h
index bb031656aee..e312c2bc6dc 100644
--- a/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_config.h
+++ b/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_config.h
@@ -32,7 +32,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/jdk/src/solaris/native/sun/nio/fs/genSolarisConstants.c b/jdk/src/solaris/native/sun/nio/fs/genSolarisConstants.c
index df463986093..346bfbbe542 100644
--- a/jdk/src/solaris/native/sun/nio/fs/genSolarisConstants.c
+++ b/jdk/src/solaris/native/sun/nio/fs/genSolarisConstants.c
@@ -27,7 +27,7 @@
#include
#include
#include
-#include
+#include
#include
/**
diff --git a/jdk/src/solaris/native/sun/nio/fs/genUnixConstants.c b/jdk/src/solaris/native/sun/nio/fs/genUnixConstants.c
index ea48d4d07d8..56984a7e352 100644
--- a/jdk/src/solaris/native/sun/nio/fs/genUnixConstants.c
+++ b/jdk/src/solaris/native/sun/nio/fs/genUnixConstants.c
@@ -26,7 +26,7 @@
#include
#include
#include
-#include
+#include
#include
/**
diff --git a/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c b/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c
index b445899f73b..b763bc25bb4 100644
--- a/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c
+++ b/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c
@@ -40,7 +40,7 @@ void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName) {
if (fAddress == NULL) {
char errorMessage[256];
snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName);
- JNU_ThrowNullPointerException(env, errorMessage);
+ throwNullPointerException(env, errorMessage);
return NULL;
}
return fAddress;
@@ -69,7 +69,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_Secmod_nssLoadLibrary
dprintf2("-handle: %u (0X%X)\n", hModule, hModule);
if (hModule == NULL) {
- JNU_ThrowIOException(env, dlerror());
+ throwIOException(env, dlerror());
return 0;
}
diff --git a/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.c b/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.c
index 67e452da340..c7379810fab 100644
--- a/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.c
+++ b/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.c
@@ -51,12 +51,40 @@ FPTR_SCardBeginTransaction scardBeginTransaction;
FPTR_SCardEndTransaction scardEndTransaction;
FPTR_SCardControl scardControl;
+/*
+ * Throws a Java Exception by name
+ */
+void throwByName(JNIEnv *env, const char *name, const char *msg)
+{
+ jclass cls = (*env)->FindClass(env, name);
+
+ if (cls != 0) /* Otherwise an exception has already been thrown */
+ (*env)->ThrowNew(env, cls, msg);
+}
+
+/*
+ * Throws java.lang.NullPointerException
+ */
+void throwNullPointerException(JNIEnv *env, const char *msg)
+{
+ throwByName(env, "java/lang/NullPointerException", msg);
+}
+
+/*
+ * Throws java.io.IOException
+ */
+void throwIOException(JNIEnv *env, const char *msg)
+{
+ throwByName(env, "java/io/IOException", msg);
+}
+
+
void *findFunction(JNIEnv *env, void *hModule, char *functionName) {
void *fAddress = dlsym(hModule, functionName);
if (fAddress == NULL) {
char errorMessage[256];
snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName);
- JNU_ThrowNullPointerException(env, errorMessage);
+ throwNullPointerException(env, errorMessage);
return NULL;
}
return fAddress;
@@ -69,7 +97,7 @@ JNIEXPORT void JNICALL Java_sun_security_smartcardio_PlatformPCSC_initialize
(*env)->ReleaseStringUTFChars(env, jLibName, libName);
if (hModule == NULL) {
- JNU_ThrowIOException(env, dlerror());
+ throwIOException(env, dlerror());
return;
}
scardEstablishContext = (FPTR_SCardEstablishContext)findFunction(env, hModule, "SCardEstablishContext");
diff --git a/jdk/src/windows/classes/java/lang/ProcessImpl.java b/jdk/src/windows/classes/java/lang/ProcessImpl.java
index 05891161a42..88486e5f472 100644
--- a/jdk/src/windows/classes/java/lang/ProcessImpl.java
+++ b/jdk/src/windows/classes/java/lang/ProcessImpl.java
@@ -60,10 +60,11 @@ final class ProcessImpl extends Process {
throws IOException
{
if (append) {
+ String path = f.getPath();
SecurityManager sm = System.getSecurityManager();
if (sm != null)
- sm.checkWrite(f.getPath());
- long handle = openForAtomicAppend(f.getPath());
+ sm.checkWrite(path);
+ long handle = openForAtomicAppend(path);
final FileDescriptor fd = new FileDescriptor();
fdAccess.setHandle(fd, handle);
return AccessController.doPrivileged(
diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java
index 50a51a6f94b..d37db9e925b 100644
--- a/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java
+++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java
@@ -486,7 +486,7 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface {
int dataType = 0;
int scanStride = width;
- if (dcm.getPixelSize() == 24 || dcm.getPixelSize() == 32) {
+ if (dcm.getPixelSize() > 16) {
dataType = DataBuffer.TYPE_INT;
} else {
// 15, 16
diff --git a/jdk/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java b/jdk/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java
index 9a461f92c82..02309ff01b2 100644
--- a/jdk/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java
+++ b/jdk/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java
@@ -124,26 +124,27 @@ class WindowsDirectoryStream
private boolean atEof;
private String first;
private Path nextEntry;
+ private String prefix;
WindowsDirectoryIterator(String first) {
atEof = false;
this.first = first;
+ if (dir.needsSlashWhenResolving()) {
+ prefix = dir.toString() + "\\";
+ } else {
+ prefix = dir.toString();
+ }
+ }
+
+ // links to self and parent directories are ignored
+ private boolean isSelfOrParent(String name) {
+ return name.equals(".") || name.equals("..");
}
// applies filter and also ignores "." and ".."
private Path acceptEntry(String s, BasicFileAttributes attrs) {
- if (s.equals(".") || s.equals(".."))
- return null;
- if (dir.needsSlashWhenResolving()) {
- StringBuilder sb = new StringBuilder(dir.toString());
- sb.append('\\');
- sb.append(s);
- s = sb.toString();
- } else {
- s = dir + s;
- }
Path entry = WindowsPath
- .createFromNormalizedPath(dir.getFileSystem(), s, attrs);
+ .createFromNormalizedPath(dir.getFileSystem(), prefix + s, attrs);
try {
if (filter.accept(entry))
return entry;
@@ -157,7 +158,7 @@ class WindowsDirectoryStream
private Path readNextEntry() {
// handle first element returned by search
if (first != null) {
- nextEntry = acceptEntry(first, null);
+ nextEntry = isSelfOrParent(first) ? null : acceptEntry(first, null);
first = null;
if (nextEntry != null)
return nextEntry;
@@ -184,6 +185,10 @@ class WindowsDirectoryStream
return null;
}
+ // ignore link to self and parent directories
+ if (isSelfOrParent(name))
+ continue;
+
// grab the attributes from the WIN32_FIND_DATA structure
// (needs to be done while holding closeLock because close
// will release the buffer)
diff --git a/jdk/src/windows/classes/sun/nio/fs/WindowsPathParser.java b/jdk/src/windows/classes/sun/nio/fs/WindowsPathParser.java
index f1158e5f7de..c45858b4ae9 100644
--- a/jdk/src/windows/classes/sun/nio/fs/WindowsPathParser.java
+++ b/jdk/src/windows/classes/sun/nio/fs/WindowsPathParser.java
@@ -120,12 +120,18 @@ class WindowsPathParser {
off = next;
} else {
if (isLetter(c0) && c1 == ':') {
- root = input.substring(0, 2);
- if (len > 2 && isSlash(input.charAt(2))) {
+ char c2;
+ if (len > 2 && isSlash(c2 = input.charAt(2))) {
+ // avoid concatenation when root is "D:\"
+ if (c2 == '\\') {
+ root = input.substring(0, 3);
+ } else {
+ root = input.substring(0, 2) + '\\';
+ }
off = 3;
- root += "\\";
type = WindowsPathType.ABSOLUTE;
} else {
+ root = input.substring(0, 2);
off = 2;
type = WindowsPathType.DRIVE_RELATIVE;
}
diff --git a/jdk/src/windows/native/sun/security/pkcs11/j2secmod_md.c b/jdk/src/windows/native/sun/security/pkcs11/j2secmod_md.c
index 4a8d7583a4c..fac24a6063f 100644
--- a/jdk/src/windows/native/sun/security/pkcs11/j2secmod_md.c
+++ b/jdk/src/windows/native/sun/security/pkcs11/j2secmod_md.c
@@ -37,7 +37,7 @@ void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName) {
if (fAddress == NULL) {
char errorMessage[256];
_snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName);
- JNU_ThrowNullPointerException(env, errorMessage);
+ throwNullPointerException(env, errorMessage);
return NULL;
}
return fAddress;
@@ -78,7 +78,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_Secmod_nssLoadLibrary
NULL
);
dprintf1("-error: %s\n", lpMsgBuf);
- JNU_ThrowIOException(env, (char*)lpMsgBuf);
+ throwIOException(env, (char*)lpMsgBuf);
LocalFree(lpMsgBuf);
return 0;
}
diff --git a/jdk/src/windows/native/sun/windows/awt_Window.cpp b/jdk/src/windows/native/sun/windows/awt_Window.cpp
index c742aca9000..83f6f0b9b1c 100644
--- a/jdk/src/windows/native/sun/windows/awt_Window.cpp
+++ b/jdk/src/windows/native/sun/windows/awt_Window.cpp
@@ -355,7 +355,7 @@ void AwtWindow::RepositionSecurityWarning(JNIEnv *env)
RECT rect;
CalculateWarningWindowBounds(env, &rect);
- ::SetWindowPos(warningWindow, IsAlwaysOnTop() ? HWND_TOPMOST : GetHWnd(),
+ ::SetWindowPos(warningWindow, IsAlwaysOnTop() ? HWND_TOPMOST : HWND_NOTOPMOST,
rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE |
@@ -835,7 +835,7 @@ void AwtWindow::StartSecurityAnimation(AnimationKind kind)
if (securityAnimationKind == akShow) {
::SetWindowPos(warningWindow,
- IsAlwaysOnTop() ? HWND_TOPMOST : GetHWnd(),
+ IsAlwaysOnTop() ? HWND_TOPMOST : HWND_NOTOPMOST,
0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE |
SWP_SHOWWINDOW | SWP_NOOWNERZORDER);
diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt
index c2fd9fc0cfc..5b483f97cb4 100644
--- a/jdk/test/ProblemList.txt
+++ b/jdk/test/ProblemList.txt
@@ -377,6 +377,12 @@ java/net/ipv6tests/UdpTest.java linux-all
# 7081476
java/net/InetSocketAddress/B6469803.java generic-all
+# 7102670
+java/net/InetAddress/CheckJNI.java linux-all
+
+# failing on vista 32/64 on nightly
+# 7102702
+java/net/PortUnreachableException/OneExceptionOnly.java windows-all
############################################################################
# jdk_io
@@ -484,9 +490,6 @@ sun/security/pkcs11/ec/TestECDSA.java solaris-i586
#sun/security/pkcs11/ec/TestKeyFactory.java solaris-i586
sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java solaris-i586
-# Directly references PKCS11 class
-sun/security/pkcs11/Provider/Absolute.java windows-x64
-
# Fails on Fedora 9/Ubuntu 10.04 64bit, PKCS11Exception: CKR_DEVICE_ERROR
sun/security/pkcs11/KeyAgreement/TestDH.java generic-all
@@ -517,9 +520,6 @@ sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java generic-all
# 7079203 sun/security/tools/keytool/printssl.sh fails on solaris with timeout
sun/security/tools/keytool/printssl.sh solaris-all
-# 7054637
-sun/security/tools/jarsigner/ec.sh solaris-all
-
# 7081817
sun/security/provider/certpath/X509CertPath/IllegalCertiticates.java generic-all
diff --git a/jdk/test/java/lang/ref/ReferenceEnqueue.java b/jdk/test/java/lang/ref/ReferenceEnqueue.java
new file mode 100644
index 00000000000..25907a034cc
--- /dev/null
+++ b/jdk/test/java/lang/ref/ReferenceEnqueue.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, 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 4268317
+ * @summary Test if Reference.enqueue() works properly with GC
+ */
+
+import java.lang.ref.*;
+
+public class ReferenceEnqueue {
+
+ public static void main(String args[]) throws Exception {
+ for (int i=0; i < 5; i++)
+ new WeakRef().run();
+ System.out.println("Test passed.");
+ }
+
+ static class WeakRef {
+ final ReferenceQueue queue = new ReferenceQueue();
+ final Reference ref;
+ final int iterations = 1000;
+
+ WeakRef() {
+ this.ref = new WeakReference(new Object(), queue);
+ }
+
+ void run() throws InterruptedException {
+ System.gc();
+ for (int i = 0; i < iterations; i++) {
+ System.gc();
+ if (ref.isEnqueued()) {
+ break;
+ }
+
+ Thread.sleep(100);
+ }
+
+ if (ref.isEnqueued() == false) {
+ // GC have not enqueued refWeak for the timeout period
+ System.out.println("Reference not enqueued yet");
+ return;
+ }
+
+ if (ref.enqueue() == true) {
+ // enqueue() should return false since
+ // ref is already enqueued by the GC
+ throw new RuntimeException("Error: enqueue() returned true;"
+ + " expected false");
+ }
+
+ if (queue.poll() == null) {
+ // poll() should return ref enqueued by the GC
+ throw new RuntimeException("Error: poll() returned null;"
+ + " expected ref object");
+ }
+ }
+ }
+}
diff --git a/jdk/test/java/lang/ref/ReferenceEnqueuePending.java b/jdk/test/java/lang/ref/ReferenceEnqueuePending.java
new file mode 100644
index 00000000000..0e8868fa9fd
--- /dev/null
+++ b/jdk/test/java/lang/ref/ReferenceEnqueuePending.java
@@ -0,0 +1,201 @@
+/* Copyright (c) 2011, 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 4243978
+ * @summary Test if Reference.enqueue() works properly with pending references
+ */
+import java.lang.ref.*;
+
+public class ReferenceEnqueuePending {
+ static class NumberedWeakReference extends WeakReference {
+ // Add an integer to identify the weak reference object.
+ int number;
+
+ NumberedWeakReference(Integer referent, ReferenceQueue q, int i) {
+ super(referent, q);
+ number = i;
+ }
+ }
+
+ final static boolean debug = System.getProperty("test.debug") != null;
+ final static int iterations = 1000;
+ final static int gc_trigger = 99;
+ static int[] a = new int[2 * iterations];
+ // Keep all weak references alive with the following array.
+ static NumberedWeakReference[] b = new NumberedWeakReference[iterations];
+
+ public static void main(String[] argv) throws Exception {
+ if (debug) {
+ System.out.println("Starting the test.");
+ }
+ // Raise thread priority to match the referenceHandler
+ // priority, so that they can race also on a uniprocessor.
+ raisePriority();
+
+ ReferenceQueue refQueue = new ReferenceQueue<>();
+
+ // Our objective is to let the mutator enqueue
+ // a Reference object that may already be in the
+ // pending state because of having been identified
+ // as weakly reachable at a previous garbage collection.
+ // To this end, we create many Reference objects, each with a
+ // a unique integer object as its referant.
+ // We let the referents become eligible for collection,
+ // while racing with the garbage collector which may
+ // have pended some of these Reference objects.
+ // Finally we check that all of the Reference objects
+ // end up on the their queue. The test was originally
+ // submitted to show that such races could break the
+ // pending list and/or the reference queue, because of sharing
+ // the same link ("next") for maintaining both lists, thus
+ // losing some of the Reference objects on either queue.
+
+ Integer obj = new Integer(0);
+ NumberedWeakReference weaky = new NumberedWeakReference(obj, refQueue, 0);
+ for (int i = 1; i < iterations; i++) {
+ // Create a new object, dropping the onlY strong reference to
+ // the previous Integer object.
+ obj = new Integer(i);
+ // Trigger gc each gc_trigger iterations.
+ if ((i % gc_trigger) == 0) {
+ forceGc(0);
+ }
+ // Enqueue every other weaky.
+ if ((i % 2) == 0) {
+ weaky.enqueue();
+ }
+ // Remember the Reference objects, for testing later.
+ b[i - 1] = weaky;
+ // Get a new weaky for the Integer object just
+ // created, which may be explicitly enqueued in
+ // our next trip around the loop.
+ weaky = new NumberedWeakReference(obj, refQueue, i);
+ }
+
+ // Do a final collection to discover and process all
+ // Reference objects created above, allowing enough time
+ // for the ReferenceHandler thread to queue the References.
+ forceGc(100);
+ forceGc(100);
+
+ // Verify that all WeakReference objects ended up queued.
+ checkResult(refQueue, obj, iterations-1);
+ System.out.println("Test passed.");
+ }
+
+ private static void checkResult(ReferenceQueue queue,
+ Integer obj,
+ int expected) {
+ if (debug) {
+ System.out.println("Reading the queue");
+ }
+
+ // Empty the queue and record numbers into a[];
+ NumberedWeakReference weakRead = (NumberedWeakReference) queue.poll();
+ int length = 0;
+ while (weakRead != null) {
+ a[length++] = weakRead.number;
+ weakRead = (NumberedWeakReference) queue.poll();
+ }
+ if (debug) {
+ System.out.println("Reference Queue had " + length + " elements");
+ }
+ // Use the last Reference object of those created above, so as to keep it "alive".
+ System.out.println("I must write " + obj + " to prevent compiler optimizations.");
+
+
+ // verify the queued references: all but the last Reference object
+ // should have been in the queue.
+ if (debug) {
+ System.out.println("Start of final check");
+ }
+
+ // Sort the first "length" elements in array "a[]".
+ sort(length);
+
+ boolean fail = (length != expected);
+ for (int i = 0; i < length; i++) {
+ if (a[i] != i) {
+ if (debug) {
+ System.out.println("a[" + i + "] is not " + i + " but " + a[i]);
+ }
+ fail = true;
+ }
+ }
+ if (fail) {
+ printMissingElements(length, expected);
+ throw new RuntimeException("TEST FAILED: only " + length
+ + " reference objects have been queued out of "
+ + expected);
+ }
+ }
+
+ private static void printMissingElements(int length, int expected) {
+ System.out.println("The following numbers were not found in the reference queue: ");
+ int missing = 0;
+ int element = 0;
+ for (int i = 0; i < length; i++) {
+ while ((a[i] != element) & (element < expected)) {
+ System.out.print(element + " ");
+ if (missing % 20 == 19) {
+ System.out.println(" ");
+ }
+ missing++;
+ element++;
+ }
+ element++;
+ }
+ System.out.print("\n");
+ }
+
+ private static void forceGc(long millis) throws InterruptedException {
+ Runtime.getRuntime().gc();
+ Thread.sleep(millis);
+ }
+
+ // Bubble sort the first "length" elements in array "a".
+ private static void sort(int length) {
+ int hold;
+ if (debug) {
+ System.out.println("Sorting. Length=" + length);
+ }
+ for (int pass = 1; pass < length; pass++) { // passes over the array
+ for (int i = 0; i < length - pass; i++) { // a single pass
+ if (a[i] > a[i + 1]) { // then swap
+ hold = a[i];
+ a[i] = a[i + 1];
+ a[i + 1] = hold;
+ }
+ } // End of i loop
+ } // End of pass loop
+ }
+
+ // Raise thread priority so as to increase the
+ // probability of the mutator succeeding in enqueueing
+ // an object that is still in the pending state.
+ // This is (probably) only required for a uniprocessor.
+ static void raisePriority() {
+ Thread tr = Thread.currentThread();
+ tr.setPriority(Thread.MAX_PRIORITY);
+ }
+} // End of class ReferenceEnqueuePending
diff --git a/jdk/test/java/nio/charset/coders/Errors.java b/jdk/test/java/nio/charset/coders/Errors.java
index be19c0b403d..0b74001dd6e 100644
--- a/jdk/test/java/nio/charset/coders/Errors.java
+++ b/jdk/test/java/nio/charset/coders/Errors.java
@@ -23,7 +23,7 @@
/* @test
* @summary Check that error cases are replaced correctly in String/ISR/OSW
- * @bug 4457851
+ * @bug 4457851 7096080
*
* @build Errors Util
* @run main Errors
@@ -193,11 +193,9 @@ public class Errors {
t.test("\uFFFF", new byte[] { (byte)0xEF, (byte)0xBF, (byte)0xBF });
t.test(new byte[] { X, (byte)0x7f, Y }, "x\u007Fy");
t.test(new byte[] { X, (byte)0x80, Y }, "x\uFFFDy");
- t.test(new byte[] { (byte)0xf0, (byte)0xf0 }, "\uFFFD");
}
public static void main(String[] args) throws Exception {
-
test_US_ASCII(new TestString("US-ASCII"));
test_US_ASCII(new TestStream("US-ASCII"));
diff --git a/jdk/test/java/util/Collections/CheckedQueue.java b/jdk/test/java/util/Collections/CheckedQueue.java
new file mode 100644
index 00000000000..6f28e12e9ef
--- /dev/null
+++ b/jdk/test/java/util/Collections/CheckedQueue.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2011, 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 5020931
+ * @summary Unit test for Collections.checkedQueue
+ */
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Queue;
+import java.util.concurrent.ArrayBlockingQueue;
+
+public class CheckedQueue {
+ static int status = 0;
+
+ public static void main(String[] args) throws Exception {
+ new CheckedQueue();
+ }
+
+ public CheckedQueue() throws Exception {
+ run();
+ }
+
+ private void run() throws Exception {
+ Method[] methods = this.getClass().getDeclaredMethods();
+
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ String methodName = method.getName();
+
+ if (methodName.startsWith("test")) {
+ try {
+ Object obj = method.invoke(this, new Object[0]);
+ } catch(Exception e) {
+ throw new Exception(this.getClass().getName() + "." +
+ methodName + " test failed, test exception "
+ + "follows\n" + e.getCause());
+ }
+ }
+ }
+ }
+
+ /**
+ * This test adds items to a queue.
+ */
+ private void test00() {
+ int arrayLength = 10;
+ ArrayBlockingQueue abq = new ArrayBlockingQueue(arrayLength);
+
+ for (int i = 0; i < arrayLength; i++) {
+ abq.add(new String(Integer.toString(i)));
+ }
+ }
+
+ /**
+ * This test tests the CheckedQueue.add method. It creates a queue of
+ * {@code String}s gets the checked queue, and attempt to add an Integer to
+ * the checked queue.
+ */
+ private void test01() throws Exception {
+ int arrayLength = 10;
+ ArrayBlockingQueue abq = new ArrayBlockingQueue(arrayLength + 1);
+
+ for (int i = 0; i < arrayLength; i++) {
+ abq.add(new String(Integer.toString(i)));
+ }
+
+ Queue q = Collections.checkedQueue(abq, String.class);
+
+ try {
+ q.add(new Integer(0));
+ throw new Exception(this.getClass().getName() + "." + "test01 test"
+ + " failed, should throw ClassCastException.");
+ } catch(ClassCastException cce) {
+ // Do nothing.
+ }
+ }
+
+ /**
+ * This test tests the CheckedQueue.add method. It creates a queue of one
+ * {@code String}, gets the checked queue, and attempt to add an Integer to
+ * the checked queue.
+ */
+ private void test02() throws Exception {
+ ArrayBlockingQueue abq = new ArrayBlockingQueue(1);
+ Queue q = Collections.checkedQueue(abq, String.class);
+
+ try {
+ q.add(new Integer(0));
+ throw new Exception(this.getClass().getName() + "." + "test02 test"
+ + " failed, should throw ClassCastException.");
+ } catch(ClassCastException e) {
+ // Do nothing.
+ }
+ }
+
+ /**
+ * This test tests the Collections.checkedQueue method call for nulls in
+ * each and both of the parameters.
+ */
+ private void test03() throws Exception {
+ ArrayBlockingQueue abq = new ArrayBlockingQueue(1);
+ Queue q;
+
+ try {
+ q = Collections.checkedQueue(null, String.class);
+ throw new Exception(this.getClass().getName() + "." + "test03 test"
+ + " failed, should throw NullPointerException.");
+ } catch(NullPointerException npe) {
+ // Do nothing
+ }
+
+ try {
+ q = Collections.checkedQueue(abq, null);
+ throw new Exception(this.getClass().getName() + "." + "test03 test"
+ + " failed, should throw NullPointerException.");
+ } catch(Exception e) {
+ // Do nothing
+ }
+
+ try {
+ q = Collections.checkedQueue(null, null);
+ throw new Exception(this.getClass().getName() + "." + "test03 test"
+ + " failed, should throw NullPointerException.");
+ } catch(Exception e) {
+ // Do nothing
+ }
+ }
+
+ /**
+ * This test tests the CheckedQueue.offer method.
+ */
+ private void test04() throws Exception {
+ ArrayBlockingQueue abq = new ArrayBlockingQueue(1);
+ Queue q = Collections.checkedQueue(abq, String.class);
+
+ try {
+ q.offer(null);
+ throw new Exception(this.getClass().getName() + "." + "test04 test"
+ + " failed, should throw NullPointerException.");
+ } catch (NullPointerException npe) {
+ // Do nothing
+ }
+
+ try {
+ q.offer(new Integer(0));
+ throw new Exception(this.getClass().getName() + "." + "test04 test"
+ + " failed, should throw ClassCastException.");
+ } catch (ClassCastException cce) {
+ // Do nothing
+ }
+
+ q.offer(new String("0"));
+
+ try {
+ q.offer(new String("1"));
+ throw new Exception(this.getClass().getName() + "." + "test04 test"
+ + " failed, should throw IllegalStateException.");
+ } catch(IllegalStateException ise) {
+ // Do nothing
+ }
+ }
+
+ private void test05() {
+
+ }
+}
diff --git a/jdk/test/java/util/Collections/EmptySortedSet.java b/jdk/test/java/util/Collections/EmptySortedSet.java
new file mode 100644
index 00000000000..224400ec7a8
--- /dev/null
+++ b/jdk/test/java/util/Collections/EmptySortedSet.java
@@ -0,0 +1,351 @@
+/*
+ * Copyright (c) 2011, 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 4533691
+ * @summary Unit test for Collections.emptySortedSet
+ */
+
+import java.lang.reflect.Method;
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+public class EmptySortedSet {
+ static int status = 0;
+ private static final String FAILED = " failed. ";
+ private static final String PERIOD = ".";
+ private final String thisClassName = this.getClass().getName();
+
+ public static void main(String[] args) throws Exception {
+ new EmptySortedSet();
+ }
+
+ public EmptySortedSet() throws Exception {
+ run();
+ }
+
+ /**
+ * Returns {@code true} if the {@link Object} passed in is an empty
+ * {@link SortedSet}.
+ *
+ * @param obj the object to test
+ * @return {@code true} if the {@link Object} is an empty {@link SortedSet}
+ * otherwise {@code false}.
+ */
+ private boolean isEmptySortedSet(Object obj) {
+ boolean isEmptySortedSet = false;
+
+ // We determine if the object is an empty sorted set by testing if it's
+ // an instance of SortedSet, and if so, if it's empty. Currently the
+ // testing doesn't include checks of the other methods.
+ if (obj instanceof SortedSet) {
+ SortedSet ss = (SortedSet) obj;
+
+ if ((ss.isEmpty()) && (ss.size() == 0)) {
+ isEmptySortedSet = true;
+ }
+ }
+
+ return isEmptySortedSet;
+ }
+
+ private void run() throws Exception {
+ Method[] methods = this.getClass().getDeclaredMethods();
+
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ String methodName = method.getName();
+
+ if (methodName.startsWith("test")) {
+ try {
+ Object obj = method.invoke(this, new Object[0]);
+ } catch(Exception e) {
+ throw new Exception(this.getClass().getName() + "." +
+ methodName + " test failed, test exception "
+ + "follows\n" + e.getCause());
+ }
+ }
+ }
+ }
+
+ private void throwException(String methodName, String reason)
+ throws Exception
+ {
+ StringBuilder sb = new StringBuilder(thisClassName);
+ sb.append(PERIOD);
+ sb.append(methodName);
+ sb.append(FAILED);
+ sb.append(reason);
+ throw new Exception(sb.toString());
+ }
+
+ /**
+ *
+ */
+ private void test00() throws Exception {
+ //throwException("test00", "This test has not been implemented yet.");
+ }
+
+ /**
+ * Tests that the comparator is {@code null}.
+ */
+ private void testComparatorIsNull() throws Exception {
+ SortedSet sortedSet = Collections.emptySortedSet();
+ Comparator comparator = sortedSet.comparator();
+
+ if (comparator != null) {
+ throwException("testComparatorIsNull", "Comparator is not null.");
+ }
+ }
+
+ /**
+ * Tests that the contains method returns {@code false}.
+ */
+ private void testContains() throws Exception {
+ SortedSet sortedSet = Collections.emptySortedSet();
+
+ if (sortedSet.contains(new Object())) {
+ throwException("testContains", "Should not contain any elements.");
+ }
+ }
+
+ /**
+ * Tests that the containsAll method returns {@code false}.
+ */
+ private void testContainsAll() throws Exception {
+ SortedSet sortedSet = Collections.emptySortedSet();
+ TreeSet treeSet = new TreeSet();
+ treeSet.add("1");
+ treeSet.add("2");
+ treeSet.add("3");
+
+ if (sortedSet.containsAll(treeSet)) {
+ throwException("testContainsAll",
+ "Should not contain any elements.");
+ }
+ }
+
+ /**
+ * Tests that the iterator is empty.
+ */
+ private void testEmptyIterator() throws Exception {
+ SortedSet sortedSet = Collections.emptySortedSet();
+ Iterator emptyIterator = sortedSet.iterator();
+
+ if ((emptyIterator != null) && (emptyIterator.hasNext())) {
+ throwException("testEmptyIterator", "The iterator is not empty.");
+ }
+ }
+
+ /**
+ * Tests that the set is empty.
+ */
+ private void testIsEmpty() throws Exception {
+ SortedSet sortedSet = Collections.emptySortedSet();
+
+ if ((sortedSet != null) && (!sortedSet.isEmpty())) {
+ throwException("testSizeIsZero", "The set is not empty.");
+ }
+ }
+
+ /**
+ * Tests that the first() method throws NoSuchElementException
+ */
+ private void testFirst() throws Exception {
+ SortedSet sortedSet = Collections.emptySortedSet();
+
+ try {
+ sortedSet.first();
+ throwException("testFirst",
+ "NoSuchElemenException was not thrown.");
+ } catch(NoSuchElementException nsee) {
+ // Do nothing
+ }
+ }
+
+ /**
+ * Tests the headSet() method.
+ */
+ private void testHeadSet() throws Exception {
+ SortedSet sortedSet = Collections.emptySortedSet();
+ SortedSet ss;
+
+ try {
+ ss = sortedSet.headSet(null);
+ throwException("testHeadSet",
+ "Must throw NullPointerException for null element");
+ } catch(NullPointerException npe) {
+ // Do nothing
+ }
+
+ try {
+ ss = sortedSet.headSet(new Object());
+ throwException("testHeadSet",
+ "Must throw ClassCastException for non-Comparable element");
+ } catch(ClassCastException cce) {
+ // Do nothing.
+ }
+
+ ss = sortedSet.headSet("1");
+
+ if ((ss == null) || !isEmptySortedSet(ss)) {
+ throwException("testHeadSet",
+ "Returned value is null or not an EmptySortedSet.");
+ }
+ }
+
+ /**
+ * Tests that the last() method throws NoSuchElementException
+ */
+ private void testLast() throws Exception {
+ SortedSet sortedSet = Collections.emptySortedSet();
+
+ try {
+ sortedSet.last();
+ throwException("testLast",
+ "NoSuchElemenException was not thrown.");
+ } catch(NoSuchElementException nsee) {
+ // Do nothing
+ }
+ }
+
+ /**
+ * Tests that the size is 0.
+ */
+ private void testSizeIsZero() throws Exception {
+ SortedSet sortedSet = Collections.emptySortedSet();
+ int size = sortedSet.size();
+
+ if (size > 0) {
+ throwException("testSizeIsZero",
+ "The size of the set is greater then 0.");
+ }
+ }
+
+ /**
+ * Tests the subSet() method.
+ */
+ private void testSubSet() throws Exception {
+ SortedSet sortedSet = Collections.emptySortedSet();
+ SortedSet ss = sortedSet.headSet("1");
+
+ try {
+ ss = sortedSet.subSet(null, BigInteger.TEN);
+ ss = sortedSet.subSet(BigInteger.ZERO, null);
+ ss = sortedSet.subSet(null, null);
+ throwException("testSubSet",
+ "Must throw NullPointerException for null element");
+ } catch(NullPointerException npe) {
+ // Do nothing
+ }
+
+ try {
+ Object obj1 = new Object();
+ Object obj2 = new Object();
+ ss = sortedSet.subSet(obj1, BigInteger.TEN);
+ ss = sortedSet.subSet(BigInteger.ZERO, obj2);
+ ss = sortedSet.subSet(obj1, obj2);
+ throwException("testSubSet",
+ "Must throw ClassCastException for parameter which is "
+ + "not Comparable.");
+ } catch(ClassCastException cce) {
+ // Do nothing.
+ }
+
+ try {
+ ss = sortedSet.subSet(BigInteger.ZERO, BigInteger.ZERO);
+ ss = sortedSet.subSet(BigInteger.TEN, BigInteger.ZERO);
+ throwException("testSubSet",
+ "Must throw IllegalArgumentException when fromElement is "
+ + "not less then then toElement.");
+ } catch(IllegalArgumentException iae) {
+ // Do nothing.
+ }
+
+ ss = sortedSet.subSet(BigInteger.ZERO, BigInteger.TEN);
+
+ if (!isEmptySortedSet(ss)) {
+ throw new Exception("Returned value is not empty sorted set.");
+ }
+ }
+
+ /**
+ * Tests the tailSet() method.
+ */
+ private void testTailSet() throws Exception {
+ SortedSet sortedSet = Collections.emptySortedSet();
+ SortedSet ss;
+
+ try {
+ ss = sortedSet.tailSet(null);
+ throwException("testTailSet",
+ "Must throw NullPointerException for null element");
+ } catch(NullPointerException npe) {
+ // Do nothing
+ }
+
+ try {
+ SortedSet ss2 = sortedSet.tailSet(new Object());
+ throwException("testTailSet",
+ "Must throw ClassCastException for non-Comparable element");
+ } catch(ClassCastException cce) {
+ // Do nothing.
+ }
+
+ ss = sortedSet.tailSet("1");
+
+ if ((ss == null) || !isEmptySortedSet(ss)) {
+ throwException("testTailSet",
+ "Returned value is null or not an EmptySortedSet.");
+ }
+ }
+
+ /**
+ * Tests that the array has a size of 0.
+ */
+ private void testToArray() throws Exception {
+ SortedSet sortedSet = Collections.emptySortedSet();
+ Object[] emptySortedSetArray = sortedSet.toArray();
+
+ if ((emptySortedSetArray == null) || (emptySortedSetArray.length > 0)) {
+ throwException("testToArray",
+ "Returned null array or array with length > 0.");
+ }
+
+ String[] strings = new String[2];
+ strings[0] = "1";
+ strings[1] = "2";
+ emptySortedSetArray = sortedSet.toArray(strings);
+
+ if ((emptySortedSetArray == null) || (emptySortedSetArray[0] != null)) {
+ throwException("testToArray",
+ "Returned null array or array with length > 0.");
+ }
+ }
+}
diff --git a/jdk/test/java/util/Currency/CurrencyTest.java b/jdk/test/java/util/Currency/CurrencyTest.java
index e7ae4fd79fc..c22813845ce 100644
--- a/jdk/test/java/util/Currency/CurrencyTest.java
+++ b/jdk/test/java/util/Currency/CurrencyTest.java
@@ -128,18 +128,20 @@ public class CurrencyTest {
checkCountryCurrency(country1[i], currency1[i]);
}
- // check currency changes
- String[] switchOverCtry = {"DE", "FR", "ES", "IT", "NL", "BE", "TR", "RO", "AZ", "MZ", "GH", "VE"};
- String[] switchOverOld = {"DEM", "FRF", "ESP", "ITL", "NLG", "BEF", "TRL", "ROL", "AZM", "MZM", "GHC", "VEB"};
- String[] switchOverNew = {"EUR", "EUR", "EUR", "EUR", "EUR", "EUR", "TRY", "RON", "AZN", "MZN", "GHS", "VEF"};
- String[] switchOverTZ = {"Europe/Paris", "Europe/Paris", "Europe/Paris", "Europe/Paris",
- "Europe/Paris", "Europe/Paris", "Asia/Istanbul", "Europe/Bucharest",
- "Asia/Baku", "Africa/Maputo", "Africa/Accra", "America/Caracas"};
- int[] switchOverYear = {2002, 2002, 2002, 2002, 2002, 2002, 2005, 2005, 2006, 2006, 2007, 2008};
- int[] switchOverMonth = {Calendar.JANUARY, Calendar.JANUARY, Calendar.JANUARY, Calendar.JANUARY,
- Calendar.JANUARY, Calendar.JANUARY, Calendar.JANUARY, Calendar.JULY,
- Calendar.JANUARY, Calendar.JULY, Calendar.JULY, Calendar.JANUARY};
- int[] switchOverDay = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
+ /*
+ * check currency changes
+ * In current implementation, there is no data of old currency and transition date at jdk/src/share/classes/java/util/CurrencyData.properties.
+ * So, all the switch data arrays are empty. In the future, if data of old currency and transition date are necessary for any country, the
+ * arrays here can be updated so that the program can check the currency switch.
+ */
+ String[] switchOverCtry = {};
+ String[] switchOverOld = {};
+ String[] switchOverNew = {};
+ String[] switchOverTZ = {};
+ int[] switchOverYear = {};
+ int[] switchOverMonth = {};
+ int[] switchOverDay = {};
+
for (int i = 0; i < switchOverCtry.length; i++) {
TimeZone.setDefault(TimeZone.getTimeZone(switchOverTZ[i]));
Calendar date = new GregorianCalendar(switchOverYear[i], switchOverMonth[i], switchOverDay[i]);
diff --git a/jdk/test/java/util/Currency/ValidateISO4217.java b/jdk/test/java/util/Currency/ValidateISO4217.java
index 3f5078060d4..679acfa20a9 100644
--- a/jdk/test/java/util/Currency/ValidateISO4217.java
+++ b/jdk/test/java/util/Currency/ValidateISO4217.java
@@ -92,7 +92,7 @@ public class ValidateISO4217 {
/* Codes that are obsolete, do not have related country */
static final String otherCodes =
- "ADP-AFA-ATS-AYM-BEF-BGL-BOV-BYB-CLF-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-NLG-PTE-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-USN-USS-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZWD-ZWN-ZWR";
+ "ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-CLF-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-MZM-NLG-PTE-ROL-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-USN-USS-VEB-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZWD-ZWN-ZWR";
static boolean err = false;
diff --git a/jdk/test/java/util/Currency/tablea1.txt b/jdk/test/java/util/Currency/tablea1.txt
index 898af09b538..8b2e1b5871f 100644
--- a/jdk/test/java/util/Currency/tablea1.txt
+++ b/jdk/test/java/util/Currency/tablea1.txt
@@ -23,7 +23,7 @@ AW AWG 533 2
AU AUD 36 2
AT EUR 978 2
# MA 129
-AZ AZM 31 2 2005-12-31-20-00-00 AZN 944 2
+AZ AZN 944 2
BS BSD 44 2
BH BHD 48 3
BD BDT 50 2
@@ -96,7 +96,7 @@ GA XAF 950 0
GM GMD 270 2
GE GEL 981 2
DE EUR 978 2
-GH GHC 288 2 2007-07-01-00-00-00 GHS 936 2
+GH GHS 936 2
GI GIP 292 2
GR EUR 978 2
GL DKK 208 2
@@ -166,7 +166,7 @@ MN MNT 496 2
MS XCD 951 2
MA MAD 504 2
# MA 130
-MZ MZM 508 2 2006-06-30-22-00-00 MZN 943 2
+MZ MZN 943 2
MM MMK 104 2
# MA 134
ME EUR 978 2
@@ -200,7 +200,7 @@ PT EUR 978 2
PR USD 840 2
QA QAR 634 2
RE EUR 978 2
-RO ROL 946 2 2005-06-30-21-00-00 RON 946 2
+RO RON 946 2
RU RUB 643 2
RW RWF 646 0
SH SHP 654 2
@@ -266,7 +266,7 @@ UM USD 840 2
UY UYU 858 2
UZ UZS 860 2
VU VUV 548 0
-VE VEB 862 2 2008-01-01-04-00-00 VEF 937 2
+VE VEF 937 2
VN VND 704 2
VG USD 840 2
VI USD 840 2
diff --git a/jdk/test/javax/swing/JEditorPane/4492274/bug4492274.java b/jdk/test/javax/swing/JEditorPane/4492274/bug4492274.java
new file mode 100644
index 00000000000..cf732a9c5f2
--- /dev/null
+++ b/jdk/test/javax/swing/JEditorPane/4492274/bug4492274.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2007, 2011, 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 4492274
+ * @summary Tests if JEditorPane.getPage() correctly returns anchor reference.
+ * @author Denis Sharypov
+ */
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import javax.swing.text.html.HTMLEditorKit;
+import java.awt.*;
+import java.io.File;
+import java.net.URL;
+
+public class bug4492274 {
+
+ private static URL page;
+
+ private static JEditorPane jep;
+
+ public static void main(String args[]) throws Exception {
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ createAndShowGUI();
+ }
+ });
+
+ toolkit.realSync();
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ page = new URL(page, "#linkname");
+ jep.setPage(page);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+
+ toolkit.realSync();
+
+ if (getPageAnchor() == null) {
+ throw new RuntimeException("JEditorPane.getPage() returns null anchor reference");
+ }
+
+ }
+
+ private static String getPageAnchor() throws Exception {
+ final String[] result = new String[1];
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ result[0] = jep.getPage().getRef();
+ }
+ });
+
+ return result[0];
+ }
+
+ private static void createAndShowGUI() {
+ try {
+ File file = new File(System.getProperty("test.src", "."), "test.html");
+ page = file.toURI().toURL();
+
+ JFrame f = new JFrame();
+
+ jep = new JEditorPane();
+ jep.setEditorKit(new HTMLEditorKit());
+ jep.setEditable(false);
+ jep.setPage(page);
+
+ JScrollPane sp = new JScrollPane(jep);
+
+ f.getContentPane().add(sp);
+ f.setSize(500, 500);
+ f.setVisible(true);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/jdk/test/javax/swing/JEditorPane/4492274/test.html b/jdk/test/javax/swing/JEditorPane/4492274/test.html
new file mode 100644
index 00000000000..2186cc326c8
--- /dev/null
+++ b/jdk/test/javax/swing/JEditorPane/4492274/test.html
@@ -0,0 +1,7 @@
+
+
+top
+
+bottom
+
+
diff --git a/jdk/test/javax/swing/JSlider/6348946/bug6348946.java b/jdk/test/javax/swing/JSlider/6348946/bug6348946.java
new file mode 100644
index 00000000000..7183debcb5e
--- /dev/null
+++ b/jdk/test/javax/swing/JSlider/6348946/bug6348946.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2007, 2011, 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 6348946
+ * @summary Tests that JSlider's thumb moves in the right direction
+ * when it is used as a JTable cell editor.
+ * @author Mikhail Lapshin
+*/
+
+import sun.awt.SunToolkit;
+
+import java.awt.*;
+import java.awt.event.InputEvent;
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.table.*;
+
+public class bug6348946 {
+
+ private static JFrame frame;
+
+ private static JPanel panel;
+
+ private static volatile boolean passed = false;
+
+ public static void main(String[] args) throws Exception {
+ String lf = "javax.swing.plaf.metal.MetalLookAndFeel";
+ UIManager.setLookAndFeel(lf);
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ setupUI();
+ }
+ });
+ toolkit.realSync();
+ clickOnSlider();
+ toolkit.realSync();
+ checkResult();
+ } finally {
+ stopEDT();
+ }
+ }
+
+ private static void setupUI() {
+ frame = new JFrame();
+
+ panel = new JPanel();
+ panel.setLayout(new BorderLayout());
+ panel.add(new ParameterTable(), BorderLayout.CENTER);
+ frame.getContentPane().add(panel);
+
+ frame.pack();
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+
+ private static void clickOnSlider() throws Exception {
+ Robot robot = new Robot();
+ robot.setAutoDelay(10);
+
+ Rectangle rect = getPanelRectangle();
+
+ double clickX = rect.getX() + rect.getWidth() / 4;
+ double clickY = rect.getY() + rect.getHeight() / 2;
+ robot.mouseMove((int) clickX, (int) clickY);
+
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+
+ private static void checkResult(){
+ if (passed) {
+ System.out.println("Test passed");
+ } else {
+ throw new RuntimeException("The thumb moved " +
+ "to the right instead of the left!");
+ }
+ }
+
+ private static void stopEDT() {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ frame.dispose();
+ }
+ });
+ }
+
+ private static class ParameterTable extends JTable {
+ public ParameterTable() {
+ super(new Object[][]{{5}}, new String[]{"Value"});
+ getColumnModel().getColumn(0).setCellRenderer(new Renderer());
+ getColumnModel().getColumn(0).setCellEditor(new Editor());
+ }
+ }
+
+ private static class Renderer implements TableCellRenderer {
+ private JSlider slider = new JSlider(0, 10);
+
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row, int col) {
+ int val = (Integer) value;
+ slider.setValue(val);
+ return slider;
+ }
+ }
+
+ private static class Editor extends AbstractCellEditor implements TableCellEditor {
+ private JSlider slider = new JSlider(0, 10);
+
+ public Component getTableCellEditorComponent(JTable table, Object value,
+ boolean isSelected,
+ int row, int col) {
+ int val = (Integer) value;
+ slider.setValue(val);
+ return slider;
+ }
+
+ public Editor() {
+ slider.addChangeListener(new ChangeListener() {
+ public void stateChanged(ChangeEvent e) {
+ if (!slider.getValueIsAdjusting()) {
+ passed = slider.getValue() <= 5;
+ }
+ }
+ });
+ }
+
+ public Object getCellEditorValue() {
+ return slider.getValue();
+ }
+ }
+
+ private static Rectangle getPanelRectangle() throws Exception{
+ final Rectangle[] result = new Rectangle[1];
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ result[0] = new Rectangle(panel.getLocationOnScreen(), panel.getSize());
+ }
+ });
+
+ return result[0];
+ }
+}
diff --git a/jdk/test/javax/swing/JTextArea/7049024/bug7049024.java b/jdk/test/javax/swing/JTextArea/7049024/bug7049024.java
new file mode 100644
index 00000000000..e6398b2f07c
--- /dev/null
+++ b/jdk/test/javax/swing/JTextArea/7049024/bug7049024.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2011 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.
+ */
+
+/*
+ * Portions Copyright (c) 2011 IBM Corporation
+ */
+
+/* @test
+ * @bug 7049024
+ * @summary DnD fails with JTextArea and JTextField
+ * @author Sean Chou
+ */
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import javax.swing.text.DefaultCaret;
+import java.awt.*;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.DataFlavor;
+
+public class bug7049024 {
+ public static Clipboard clipboard = null;
+
+ public static JTextField textField = null;
+
+ // This button is used to move focus away from textField.
+ public static JButton button = null;
+
+ public static JFrame frame = null;
+
+ public static DefaultCaret caret = null;
+
+ public static void main(String[] args) throws Exception {
+
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ frame = new JFrame("Test");
+ textField = new JTextField("test selection for textfield");
+ button = new JButton("To compete the focus");
+
+ frame.setLayout(new FlowLayout());
+ frame.getContentPane().add(textField);
+ frame.getContentPane().add(button);
+
+ frame.pack();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setVisible(true);
+ }
+ });
+ toolkit.realSync();
+
+ clipboard = textField.getToolkit().getSystemSelection();
+ if (null == clipboard) {
+ return;
+ }
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ textField.requestFocusInWindow();
+ }
+ });
+ toolkit.realSync();
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ caret = (DefaultCaret) textField.getCaret();
+ caret.setDot(2);
+ caret.moveDot(4);
+ }
+ });
+ toolkit.realSync();
+
+ String oldSelection = (String) clipboard.getData(DataFlavor.stringFlavor);
+ System.out.println("oldSelection is " + oldSelection);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ button.requestFocusInWindow();
+ }
+ });
+ toolkit.realSync(); // So JTextField loses the focus.
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ caret.setDot(4);
+ caret.moveDot(6);
+ }
+ });
+ toolkit.realSync();
+
+ String newSelection = (String) clipboard.getData(DataFlavor.stringFlavor);
+ System.out.println("newSelection is " + newSelection);
+
+ boolean passed = newSelection.equals(oldSelection);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ frame.dispose();
+ }
+ });
+
+ if (!passed) {
+ throw new RuntimeException("The test for bug 7049024 failed");
+ }
+ }
+}
diff --git a/jdk/test/javax/swing/ToolTipManager/Test6256140.java b/jdk/test/javax/swing/ToolTipManager/Test6256140.java
new file mode 100644
index 00000000000..12d5df8be03
--- /dev/null
+++ b/jdk/test/javax/swing/ToolTipManager/Test6256140.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2007, 2011, 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 6256140
+ * @summary Esc key doesn't restore old value in JFormattedtextField when ToolTip is set
+ * @author Alexander Potochkin
+ * @run main Test6256140
+ */
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+
+public class Test6256140 {
+
+ private static volatile JFormattedTextField ft;
+
+ private final static String initialText = "value";
+ private final static JLabel toolTipLabel = new JLabel("tip");
+
+ public static void main(String[] args) throws Exception {
+
+ Robot robot = new Robot();
+ robot.setAutoDelay(10);
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ createAndShowGUI();
+ }
+ });
+ toolkit.realSync();
+
+ Point point = ft.getLocationOnScreen();
+ robot.mouseMove(point.x, point.y);
+ robot.mouseMove(point.x + 3, point.y + 3);
+
+ robot.keyPress(KeyEvent.VK_A);
+ robot.keyRelease(KeyEvent.VK_A);
+ toolkit.realSync();
+
+ if (!isTooltipShowning()) {
+ throw new RuntimeException("Tooltip is not shown");
+ }
+
+ robot.keyPress(KeyEvent.VK_ESCAPE);
+ robot.keyRelease(KeyEvent.VK_ESCAPE);
+ toolkit.realSync();
+
+ if (isTooltipShowning()) {
+ throw new RuntimeException("Tooltip must be hidden now");
+ }
+
+ if (isTextEqual()) {
+ throw new RuntimeException("FormattedTextField must *not* cancel the updated value this time");
+ }
+
+ robot.keyPress(KeyEvent.VK_ESCAPE);
+ robot.keyRelease(KeyEvent.VK_ESCAPE);
+ toolkit.realSync();
+
+ if (!isTextEqual()) {
+ throw new RuntimeException("FormattedTextField must cancel the updated value");
+ }
+ }
+
+ private static boolean isTooltipShowning() throws Exception {
+ final boolean[] result = new boolean[1];
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ result[0] = toolTipLabel.isShowing();
+ }
+ });
+
+ return result[0];
+ }
+
+ private static boolean isTextEqual() throws Exception {
+ final boolean[] result = new boolean[1];
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ result[0] = initialText.equals(ft.getText());
+ }
+ });
+
+ return result[0];
+ }
+
+ private static void createAndShowGUI() {
+ ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE);
+ ToolTipManager.sharedInstance().setInitialDelay(0);
+
+ final JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setLayout(new FlowLayout());
+
+ ft = new JFormattedTextField() {
+
+ public JToolTip createToolTip() {
+ JToolTip toolTip = super.createToolTip();
+ toolTip.setLayout(new BorderLayout());
+ toolTip.add(toolTipLabel);
+ return toolTip;
+ }
+ };
+ ft.setToolTipText(" ");
+ ft.setValue(initialText);
+ frame.add(ft);
+
+ frame.pack();
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ ft.requestFocus();
+ }
+}
diff --git a/jdk/test/javax/xml/crypto/dsig/GenerationTests.java b/jdk/test/javax/xml/crypto/dsig/GenerationTests.java
index e4a963847ec..60ce1c66de2 100644
--- a/jdk/test/javax/xml/crypto/dsig/GenerationTests.java
+++ b/jdk/test/javax/xml/crypto/dsig/GenerationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 4635230 6283345 6303830 6824440 6867348
+ * @bug 4635230 6283345 6303830 6824440 6867348 7094155
* @summary Basic unit tests for generating XML Signatures with JSR 105
* @compile -XDignore.symbol.file KeySelectors.java SignatureValidator.java
* X509KeySelector.java GenerationTests.java
@@ -134,6 +134,7 @@ public class GenerationTests {
test_create_signature_enveloping_sha512_rsa_sha384();
test_create_signature_enveloping_sha512_rsa_sha512();
test_create_signature_reference_dependency();
+ test_create_signature_with_attr_in_no_namespace();
}
private static void setup() throws Exception {
@@ -443,6 +444,52 @@ public class GenerationTests {
sig.sign(dsc);
+// dumpDocument(doc, new PrintWriter(System.out));
+
+ DOMValidateContext dvc = new DOMValidateContext
+ (kvks, doc.getDocumentElement());
+ XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
+
+ if (sig.equals(sig2) == false) {
+ throw new Exception
+ ("Unmarshalled signature is not equal to generated signature");
+ }
+ if (sig2.validate(dvc) == false) {
+ throw new Exception("Validation of generated signature failed");
+ }
+
+ System.out.println();
+ }
+
+ static void test_create_signature_with_attr_in_no_namespace()
+ throws Exception
+ {
+ System.out.println
+ ("* Generating signature-with-attr-in-no-namespace.xml");
+
+ // create references
+ List refs = Collections.singletonList
+ (fac.newReference("#unknown", sha1));
+
+ // create SignedInfo
+ SignedInfo si = fac.newSignedInfo(withoutComments, rsaSha1, refs);
+
+ // create object-1
+ Document doc = db.newDocument();
+ Element nc = doc.createElementNS(null, "NonCommentandus");
+ // add attribute with no namespace
+ nc.setAttribute("Id", "unknown");
+ XMLObject obj = fac.newXMLObject(Collections.singletonList
+ (new DOMStructure(nc)), "object-1", null, null);
+
+ // create XMLSignature
+ XMLSignature sig = fac.newXMLSignature(si, rsa,
+ Collections.singletonList(obj),
+ "signature", null);
+ DOMSignContext dsc = new DOMSignContext(getPrivateKey("RSA"), doc);
+
+ sig.sign(dsc);
+
// dumpDocument(doc, new PrintWriter(System.out));
DOMValidateContext dvc = new DOMValidateContext
diff --git a/jdk/test/sun/java2d/DirectX/DrawBitmaskToSurfaceTest.java b/jdk/test/sun/java2d/DirectX/DrawBitmaskToSurfaceTest.java
new file mode 100644
index 00000000000..3f37e5c215e
--- /dev/null
+++ b/jdk/test/sun/java2d/DirectX/DrawBitmaskToSurfaceTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2011, 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 6997116
+ * @summary Test verifies that rendering of images with bitmap transparency
+ * to a D3D surface does not cause an ClassCastException.
+ *
+ * @run main/othervm -Dsun.java2d.d3d=True DrawBitmaskToSurfaceTest
+ */
+
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.awt.image.IndexColorModel;
+import java.util.concurrent.CountDownLatch;
+import javax.swing.JFrame;
+
+public class DrawBitmaskToSurfaceTest extends JFrame {
+
+ private final Image src;
+ private static java.util.concurrent.CountDownLatch latch = null;
+ private static Throwable theError = null;
+
+ public DrawBitmaskToSurfaceTest() {
+ src = createTestImage();
+ }
+
+ private static Image createTestImage() {
+ byte[] r = new byte[]{(byte)0x00, (byte)0x80, (byte)0xff, (byte)0xff};
+ byte[] g = new byte[]{(byte)0x00, (byte)0x80, (byte)0xff, (byte)0x00};
+ byte[] b = new byte[]{(byte)0x00, (byte)0x80, (byte)0xff, (byte)0x00};
+
+ IndexColorModel icm = new IndexColorModel(2, 4, r, g, b, 3);
+
+ BufferedImage img = new BufferedImage(100, 100,
+ BufferedImage.TYPE_BYTE_INDEXED,
+ icm);
+ return img;
+ }
+
+ @Override
+ public void paint(final Graphics g) {
+ try {
+ System.err.println("paint frame....");
+ g.drawImage(src, 30, 30, this);
+ } catch (Throwable e) {
+ theError = e;
+ } finally {
+ if (latch != null) {
+ latch.countDown();
+ }
+ }
+ }
+
+ public static void main(final String[] args) throws Exception {
+ final JFrame frame = new DrawBitmaskToSurfaceTest();
+ frame.setBounds(10, 350, 200, 200);
+ frame.setVisible(true);
+
+ Thread.sleep(2000);
+
+ System.err.println("Change frame bounds...");
+ latch = new CountDownLatch(1);
+ frame.setBounds(10, 350, 90, 90);
+ frame.repaint();
+
+ try {
+ if (latch.getCount() > 0) {
+ latch.await();
+ }
+ } catch (InterruptedException e) {
+ }
+
+ frame.dispose();
+
+ if (theError != null) {
+ throw new RuntimeException("Test failed.", theError);
+ }
+
+ System.err.println("Test passed");
+ }
+}
diff --git a/jdk/test/sun/nio/cs/TestStringCoding.java b/jdk/test/sun/nio/cs/TestStringCoding.java
index c4837e956ae..09e61444889 100644
--- a/jdk/test/sun/nio/cs/TestStringCoding.java
+++ b/jdk/test/sun/nio/cs/TestStringCoding.java
@@ -24,7 +24,7 @@
*/
/* @test
- @bug 6636323 6636319 7040220
+ @bug 6636323 6636319 7040220 7096080
@summary Test if StringCoding and NIO result have the same de/encoding result
* @run main/othervm/timeout=2000 TestStringCoding
*/
@@ -111,7 +111,8 @@ public class TestStringCoding {
//encode unmappable surrogates
if (enc instanceof sun.nio.cs.ArrayEncoder &&
cs.contains(Charset.forName("ASCII"))) {
- if (cs.name().equals("UTF-8")) // utf8 handles surrogates
+ if (cs.name().equals("UTF-8") || // utf8 handles surrogates
+ cs.name().equals("CESU-8")) // utf8 handles surrogates
return;
enc.replaceWith(new byte[] { (byte)'A'});
sun.nio.cs.ArrayEncoder cae = (sun.nio.cs.ArrayEncoder)enc;
@@ -136,7 +137,6 @@ public class TestStringCoding {
cs.name())))
throw new RuntimeException("encode3(surrogates) failed -> "
+ cs.name());
-
ba = new byte[str.length() - 1];
n = cae.encode(str.toCharArray(), 0, str.length(), ba);
if (n != 7 || !"abABABc".equals(new String(ba, 0, n,
diff --git a/jdk/test/sun/nio/cs/TestStringCodingUTF8.java b/jdk/test/sun/nio/cs/TestStringCodingUTF8.java
index fdc204849b7..d1f69950684 100644
--- a/jdk/test/sun/nio/cs/TestStringCodingUTF8.java
+++ b/jdk/test/sun/nio/cs/TestStringCodingUTF8.java
@@ -33,14 +33,16 @@ import java.nio.charset.*;
public class TestStringCodingUTF8 {
public static void main(String[] args) throws Throwable {
- test();
+ test("UTF-8");
+ test("CESU-8");
// security manager on
System.setSecurityManager(new PermissiveSecurityManger());
- test();
+ test("UTF-8");
+ test("CESU-8");
}
- static void test() throws Throwable {
- Charset cs = Charset.forName("UTF-8");
+ static void test(String csn) throws Throwable {
+ Charset cs = Charset.forName(csn);
char[] bmp = new char[0x10000];
for (int i = 0; i < 0x10000; i++) {
bmp[i] = (char)i;
diff --git a/jdk/test/sun/nio/cs/TestUTF8.java b/jdk/test/sun/nio/cs/TestUTF8.java
index f339eae046b..e83f8fbb51a 100644
--- a/jdk/test/sun/nio/cs/TestUTF8.java
+++ b/jdk/test/sun/nio/cs/TestUTF8.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 4486841 7040220
+ * @bug 4486841 7040220 7096080
* @summary Test UTF-8 charset
*/
@@ -156,15 +156,22 @@ public class TestUTF8 {
return 3;
}
+ static int to4ByteUTF8(int uc, byte[] bb, int pos) {
+ bb[pos++] = (byte)(0xf0 | ((uc >> 18)));
+ bb[pos++] = (byte)(0x80 | ((uc >> 12) & 0x3f));
+ bb[pos++] = (byte)(0x80 | ((uc >> 6) & 0x3f));
+ bb[pos++] = (byte)(0x80 | (uc & 0x3f));
+ return 4;
+ }
+
static void checkRoundtrip(String csn) throws Exception {
System.out.printf(" Check roundtrip <%s>...", csn);
char[] cc = getUTFChars();
byte[] bb = encode(cc, csn, false);
char[] ccO = decode(bb, csn, false);
- if (!Arrays.equals(cc, ccO)) {
+ if (!Arrays.equals(cc, ccO))
System.out.printf(" non-direct failed");
- }
bb = encode(cc, csn, true);
ccO = decode(bb, csn, true);
if (!Arrays.equals(cc, ccO)) {
@@ -180,6 +187,40 @@ public class TestUTF8 {
System.out.println();
}
+ static void check4ByteSurrs(String csn) throws Exception {
+ System.out.printf(" Check 4-byte Surrogates <%s>...%n", csn);
+ byte[] bb = new byte[(0x110000 - 0x10000) * 4];
+ char[] cc = new char[(0x110000 - 0x10000) * 2];
+ int bpos = 0;
+ int cpos = 0;
+ for (int i = 0x10000; i < 0x110000; i++) {
+ Character.toChars(i, cc, cpos);
+ bpos += to4ByteUTF8(i, bb, bpos);
+ cpos += 2;
+ }
+ checkSurrs(csn, bb, cc);
+ }
+
+
+ static void checkSurrs(String csn, byte[] bb, char[] cc)
+ throws Exception
+ {
+ char[] ccO = decode(bb, csn, false);
+ if (!Arrays.equals(cc, ccO)) {
+ System.out.printf(" decoding failed%n");
+ }
+ ccO = decode(bb, csn, true);
+ if (!Arrays.equals(cc, ccO)) {
+ System.out.printf(" decoding(direct) failed%n");
+ }
+ if (!Arrays.equals(cc, new String(bb, csn).toCharArray())) {
+ System.out.printf(" String.toCharArray() failed");
+ }
+ if (!Arrays.equals(bb, new String(cc).getBytes(csn))) {
+ System.out.printf(" String.getBytes() failed");
+ }
+ }
+
static void check6ByteSurrs(String csn) throws Exception {
System.out.printf(" Check 6-byte Surrogates <%s>...%n", csn);
byte[] bb = new byte[(0x110000 - 0x10000) * 6];
@@ -192,23 +233,10 @@ public class TestUTF8 {
bpos += to3ByteUTF8(cc[cpos + 1], bb, bpos);
cpos += 2;
}
-
- char[] ccO = decode(bb, csn, false);
- if (!Arrays.equals(cc, ccO)) {
- System.out.printf(" decoding failed%n");
- }
- ccO = decode(bb, csn, true);
- if (!Arrays.equals(cc, ccO)) {
- System.out.printf(" decoding(direct) failed%n");
- }
- // new String(bb, csn).getBytes(csn) will not return
- // the 6 bytes surrogates as in bb, so only test
- // toCharArray() here.
- if (!Arrays.equals(cc, new String(bb, csn).toCharArray())) {
- System.out.printf(" String.toCharArray() failed");
- }
+ checkSurrs(csn, bb, cc);
}
+
static void compare(String csn1, String csn2) throws Exception {
System.out.printf(" Diff <%s> <%s>...%n", csn1, csn2);
char[] cc = getUTFChars();
@@ -266,6 +294,10 @@ public class TestUTF8 {
{1, (byte)0xFF, (byte)0xFF, (byte)0xFF }, // all ones
{1, (byte)0xE0, (byte)0xC0, (byte)0x80 }, // invalid second byte
{1, (byte)0xE0, (byte)0x80, (byte)0xC0 }, // invalid first byte
+ {1, (byte)0xE0, (byte)0x41,}, // invalid second byte & 2 bytes
+ {3, (byte)0xED, (byte)0xAE, (byte)0x80 }, // 3 bytes surrogate
+ {3, (byte)0xED, (byte)0xB0, (byte)0x80 }, // 3 bytes surrogate
+
// Four-byte sequences
{1, (byte)0xF0, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
@@ -276,8 +308,13 @@ public class TestUTF8 {
{1, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF }, // all ones
{1, (byte)0xF0, (byte)0x80, (byte)0x80, (byte)0x80}, // invalid second byte
{1, (byte)0xF0, (byte)0xC0, (byte)0x80, (byte)0x80 }, // invalid second byte
+ {1, (byte)0xF0, (byte)41 }, // invalid second byte
+ // & only 2 bytes
+
{2, (byte)0xF0, (byte)0x90, (byte)0xC0, (byte)0x80 }, // invalid third byte
- {3, (byte)0xF0, (byte)0x90, (byte)0x80, (byte)0xC0 }, // invalid third byte
+ {3, (byte)0xF0, (byte)0x90, (byte)0x80, (byte)0xC0 }, // invalid forth byte
+ {2, (byte)0xF0, (byte)0x90, (byte)0x41 }, // invalid third byte
+ // & 3 bytes input
{1, (byte)0xF1, (byte)0xC0, (byte)0x80, (byte)0x80 }, // invalid second byte
{2, (byte)0xF1, (byte)0x80, (byte)0xC0, (byte)0x80 }, // invalid third byte
@@ -287,30 +324,113 @@ public class TestUTF8 {
{1, (byte)0xF5, (byte)0x80, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
// Five-byte sequences
- {5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80}, // invalid first byte
- {5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
- {5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
- {5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
- {5, (byte)0xF8, (byte)0x80, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+FFFF zero-padded
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80}, // invalid first byte
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
+ {1, (byte)0xF8, (byte)0x80, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+FFFF zero-padded
{1, (byte)0xF8, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80},
- {2, (byte)0xF8, (byte)0x80, (byte)0xC0, (byte)0x80, (byte)0x80 },
- {3, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xC1, (byte)0xBF },
- {4, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xC0 },
+ {1, (byte)0xF8, (byte)0x80, (byte)0xC0, (byte)0x80, (byte)0x80 },
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xC1, (byte)0xBF },
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xC0 },
// Six-byte sequences
- {6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
- {6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
- {6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
- {6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+FFFF zero-padded
+ {1, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
+ {1, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
+ {1, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
+ {1, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+FFFF zero-padded
{1, (byte)0xF8, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 },
- {2, (byte)0xF8, (byte)0x80, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80 },
- {3, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xC1, (byte)0xBF, (byte)0x80 },
- {4, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xC0, (byte)0x80 },
- {5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0x80, (byte)0xC0 },
+ {1, (byte)0xF8, (byte)0x80, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80 },
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xC1, (byte)0xBF, (byte)0x80 },
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xC0, (byte)0x80 },
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0x80, (byte)0xC0 },
};
- static void checkMalformed(String csn) throws Exception {
+ // The first byte is the length of malformed bytes
+ static byte[][] malformed_cesu8 = {
+ // One-byte sequences:
+ {1, (byte)0xFF },
+ {1, (byte)0xC0 },
+ {1, (byte)0x80 },
+
+ {1, (byte)0xFF, (byte)0xFF}, // all ones
+ {1, (byte)0xA0, (byte)0x80}, // 101x first byte first nibble
+
+ // Two-byte sequences:
+ {1, (byte)0xC0, (byte)0x80}, // invalid first byte
+ {1, (byte)0xC1, (byte)0xBF}, // invalid first byte
+ {1, (byte)0xC2, (byte)0x00}, // invalid second byte
+ {1, (byte)0xC2, (byte)0xC0}, // invalid second byte
+ {1, (byte)0xD0, (byte)0x00}, // invalid second byte
+ {1, (byte)0xD0, (byte)0xC0}, // invalid second byte
+ {1, (byte)0xDF, (byte)0x00}, // invalid second byte
+ {1, (byte)0xDF, (byte)0xC0}, // invalid second byte
+
+ // Three-byte sequences
+ {1, (byte)0xE0, (byte)0x80, (byte)0x80}, // 111x first byte first nibble
+ {1, (byte)0xE0, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
+ {1, (byte)0xE0, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
+ {1, (byte)0xE0, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
+
+ {1, (byte)0xE0, (byte)0xC0, (byte)0xBF }, // invalid second byte
+ {2, (byte)0xE0, (byte)0xA0, (byte)0x7F }, // invalid third byte
+ {2, (byte)0xE0, (byte)0xA0, (byte)0xC0 }, // invalid third byte
+ {1, (byte)0xFF, (byte)0xFF, (byte)0xFF }, // all ones
+ {1, (byte)0xE0, (byte)0xC0, (byte)0x80 }, // invalid second byte
+ {1, (byte)0xE0, (byte)0x80, (byte)0xC0 }, // invalid first byte
+ {1, (byte)0xE0, (byte)0x41,}, // invalid second byte & 2 bytes
+
+ // CESU-8 does not have 4, 5, 6 bytes sequenc
+ // Four-byte sequences
+ {1, (byte)0xF0, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
+ {1, (byte)0xF0, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
+ {1, (byte)0xF0, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+007F zero-padded
+ {1, (byte)0xF0, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+07FF zero-padded
+
+ {1, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF }, // all ones
+ {1, (byte)0xF0, (byte)0x80, (byte)0x80, (byte)0x80}, // invalid second byte
+ {1, (byte)0xF0, (byte)0xC0, (byte)0x80, (byte)0x80 }, // invalid second byte
+ {1, (byte)0xF0, (byte)41 }, // invalid second byte
+ // & only 2 bytes
+ {1, (byte)0xF0, (byte)0x90, (byte)0xC0, (byte)0x80 }, // invalid third byte
+ {1, (byte)0xF0, (byte)0x90, (byte)0x80, (byte)0xC0 }, // invalid forth byte
+ {1, (byte)0xF0, (byte)0x90, (byte)0x41 }, // invalid third byte
+ // & 3 bytes input
+
+ {1, (byte)0xF1, (byte)0xC0, (byte)0x80, (byte)0x80 }, // invalid second byte
+ {1, (byte)0xF1, (byte)0x80, (byte)0xC0, (byte)0x80 }, // invalid third byte
+ {1, (byte)0xF1, (byte)0x80, (byte)0x80, (byte)0xC0 }, // invalid forth byte
+ {1, (byte)0xF4, (byte)0x90, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
+ {1, (byte)0xF4, (byte)0xC0, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
+ {1, (byte)0xF5, (byte)0x80, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
+
+ // Five-byte sequences
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80}, // invalid first byte
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
+ {1, (byte)0xF8, (byte)0x80, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+FFFF zero-padded
+
+ {1, (byte)0xF8, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80},
+ {1, (byte)0xF8, (byte)0x80, (byte)0xC0, (byte)0x80, (byte)0x80 },
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xC1, (byte)0xBF },
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xC0 },
+
+ // Six-byte sequences
+ {1, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
+ {1, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
+ {1, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
+ {1, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+FFFF zero-padded
+ {1, (byte)0xF8, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 },
+ {1, (byte)0xF8, (byte)0x80, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80 },
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xC1, (byte)0xBF, (byte)0x80 },
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xC0, (byte)0x80 },
+ {1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0x80, (byte)0xC0 },
+ };
+
+
+ static void checkMalformed(String csn, byte[][] malformed) throws Exception {
boolean failed = false;
System.out.printf(" Check malformed <%s>...%n", csn);
Charset cs = Charset.forName(csn);
@@ -430,9 +550,12 @@ public class TestUTF8 {
public static void main(String[] args) throws Exception {
checkRoundtrip("UTF-8");
- check6ByteSurrs("UTF-8");
- //compare("UTF-8", "UTF-8-OLD");
- checkMalformed("UTF-8");
+ check4ByteSurrs("UTF-8");
+ checkMalformed("UTF-8", malformed);
checkUnderOverflow("UTF-8");
+
+ checkRoundtrip("CESU-8");
+ check6ByteSurrs("CESU-8");
+ checkMalformed("CESU-8", malformed_cesu8);
}
}
diff --git a/jdk/test/sun/security/pkcs11/Provider/Absolute.java b/jdk/test/sun/security/pkcs11/Provider/Absolute.java
index e35f9c60c58..fc035dc7c73 100644
--- a/jdk/test/sun/security/pkcs11/Provider/Absolute.java
+++ b/jdk/test/sun/security/pkcs11/Provider/Absolute.java
@@ -27,7 +27,6 @@
*/
import java.security.*;
import java.lang.reflect.*;
-import sun.security.pkcs11.*;
public class Absolute {
diff --git a/jdk/test/sun/security/pkcs11/fips/CipherTest.java b/jdk/test/sun/security/pkcs11/fips/CipherTest.java
index 0d9f8b363e0..32bc6df4e16 100644
--- a/jdk/test/sun/security/pkcs11/fips/CipherTest.java
+++ b/jdk/test/sun/security/pkcs11/fips/CipherTest.java
@@ -394,52 +394,47 @@ public class CipherTest {
public static void main(PeerFactory peerFactory, KeyStore keyStore,
String[] args) throws Exception {
- SSLContext reservedSSLContext = SSLContext.getDefault();
- try {
- long time = System.currentTimeMillis();
- String relPath;
- if ((args != null) && (args.length > 0) && args[0].equals("sh")) {
- relPath = pathToStoresSH;
- } else {
- relPath = pathToStores;
- }
- PATH = new File(System.getProperty("test.src", "."), relPath);
- CipherTest.peerFactory = peerFactory;
- System.out.print(
- "Initializing test '" + peerFactory.getName() + "'...");
-// secureRandom = new SecureRandom();
-// secureRandom.nextInt();
-// trustStore = readKeyStore(trustStoreFile);
- CipherTest.keyStore = keyStore;
-// keyStore = readKeyStore(keyStoreFile);
- KeyManagerFactory keyFactory =
- KeyManagerFactory.getInstance(
- KeyManagerFactory.getDefaultAlgorithm());
- keyFactory.init(keyStore, "test12".toCharArray());
- keyManager = (X509ExtendedKeyManager)keyFactory.getKeyManagers()[0];
-
- TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
- tmf.init(keyStore);
- trustManager = (X509TrustManager)tmf.getTrustManagers()[0];
-
-// trustManager = new AlwaysTrustManager();
- SSLContext context = SSLContext.getInstance("TLS");
- context.init(new KeyManager[] {keyManager},
- new TrustManager[] {trustManager}, null);
- SSLContext.setDefault(context);
-
- CipherTest cipherTest = new CipherTest(peerFactory);
- Thread serverThread = new Thread(peerFactory.newServer(cipherTest),
- "Server");
- serverThread.setDaemon(true);
- serverThread.start();
- System.out.println("Done");
- cipherTest.run();
- time = System.currentTimeMillis() - time;
- System.out.println("Done. (" + time + " ms)");
- } finally {
- SSLContext.setDefault(reservedSSLContext);
+ long time = System.currentTimeMillis();
+ String relPath;
+ if ((args != null) && (args.length > 0) && args[0].equals("sh")) {
+ relPath = pathToStoresSH;
+ } else {
+ relPath = pathToStores;
}
+ PATH = new File(System.getProperty("test.src", "."), relPath);
+ CipherTest.peerFactory = peerFactory;
+ System.out.print(
+ "Initializing test '" + peerFactory.getName() + "'...");
+// secureRandom = new SecureRandom();
+// secureRandom.nextInt();
+// trustStore = readKeyStore(trustStoreFile);
+ CipherTest.keyStore = keyStore;
+// keyStore = readKeyStore(keyStoreFile);
+ KeyManagerFactory keyFactory =
+ KeyManagerFactory.getInstance(
+ KeyManagerFactory.getDefaultAlgorithm());
+ keyFactory.init(keyStore, "test12".toCharArray());
+ keyManager = (X509ExtendedKeyManager)keyFactory.getKeyManagers()[0];
+
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ tmf.init(keyStore);
+ trustManager = (X509TrustManager)tmf.getTrustManagers()[0];
+
+// trustManager = new AlwaysTrustManager();
+ SSLContext context = SSLContext.getInstance("TLS");
+ context.init(new KeyManager[] {keyManager},
+ new TrustManager[] {trustManager}, null);
+ SSLContext.setDefault(context);
+
+ CipherTest cipherTest = new CipherTest(peerFactory);
+ Thread serverThread = new Thread(peerFactory.newServer(cipherTest),
+ "Server");
+ serverThread.setDaemon(true);
+ serverThread.start();
+ System.out.println("Done");
+ cipherTest.run();
+ time = System.currentTimeMillis() - time;
+ System.out.println("Done. (" + time + " ms)");
}
static abstract class PeerFactory {
diff --git a/jdk/test/sun/security/pkcs11/fips/ClientJSSEServerJSSE.java b/jdk/test/sun/security/pkcs11/fips/ClientJSSEServerJSSE.java
index 4cf931d969e..98dbdeea5e4 100644
--- a/jdk/test/sun/security/pkcs11/fips/ClientJSSEServerJSSE.java
+++ b/jdk/test/sun/security/pkcs11/fips/ClientJSSEServerJSSE.java
@@ -26,9 +26,9 @@
* @bug 6313675 6323647
* @summary Verify that all ciphersuites work in FIPS mode
* @library ..
- * @run main/othervm ClientJSSEServerJSSE
* @ignore JSSE supported cipher suites are changed with CR 6916074,
* need to update this test case in JDK 7 soon
+ * @run main/othervm ClientJSSEServerJSSE
* @author Andreas Sterbenz
*/
diff --git a/jdk/test/sun/security/provider/X509Factory/BigCRL.java b/jdk/test/sun/security/provider/X509Factory/BigCRL.java
new file mode 100644
index 00000000000..acee51a1434
--- /dev/null
+++ b/jdk/test/sun/security/provider/X509Factory/BigCRL.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2011, 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 7099399
+ * @summary cannot deal with CRL file larger than 16MB
+ * @run main/othervm -Xmx1024m BigCRL
+ */
+
+import java.io.FileInputStream;
+import java.math.BigInteger;
+import java.security.KeyStore;
+import java.security.cert.Certificate;
+import java.security.PrivateKey;
+import java.security.cert.X509CRLEntry;
+import java.util.Arrays;
+import java.util.Date;
+import sun.security.x509.*;
+import java.security.cert.CertificateFactory;
+import java.io.ByteArrayInputStream;
+
+public class BigCRL {
+
+ public static void main(String[] args) throws Exception {
+ int n = 500000;
+ String ks = System.getProperty("test.src", ".")
+ + "/../../ssl/etc/keystore";
+ String pass = "passphrase";
+ String alias = "dummy";
+
+ KeyStore keyStore = KeyStore.getInstance("JKS");
+ keyStore.load(new FileInputStream(ks), pass.toCharArray());
+ Certificate signerCert = keyStore.getCertificate(alias);
+ byte[] encoded = signerCert.getEncoded();
+ X509CertImpl signerCertImpl = new X509CertImpl(encoded);
+ X509CertInfo signerCertInfo = (X509CertInfo)signerCertImpl.get(
+ X509CertImpl.NAME + "." + X509CertImpl.INFO);
+ X500Name owner = (X500Name)signerCertInfo.get(X509CertInfo.SUBJECT + "."
+ + CertificateSubjectName.DN_NAME);
+
+ Date date = new Date();
+ PrivateKey privateKey = (PrivateKey)
+ keyStore.getKey(alias, pass.toCharArray());
+ String sigAlgName = signerCertImpl.getSigAlgOID();
+
+ X509CRLEntry[] badCerts = new X509CRLEntry[n];
+ CRLExtensions ext = new CRLExtensions();
+ ext.set("Reason", new CRLReasonCodeExtension(1));
+ for (int i = 0; i < n; i++) {
+ badCerts[i] = new X509CRLEntryImpl(
+ BigInteger.valueOf(i), date, ext);
+ }
+ X509CRLImpl crl = new X509CRLImpl(owner, date, date, badCerts);
+ crl.sign(privateKey, sigAlgName);
+ byte[] data = crl.getEncodedInternal();
+
+ // Make sure the CRL is big enough
+ if ((data[1]&0xff) != 0x84) {
+ throw new Exception("The file should be big enough?");
+ }
+
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ cf.generateCRL(new ByteArrayInputStream(data));
+ }
+}
+
diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/main.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/main.java
index 9a18be3240f..432aed4ffe3 100644
--- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/main.java
+++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/main.java
@@ -1,10 +1,7 @@
/*
* @test
* @build TestThread Traffic Handler ServerHandler ServerThread ClientThread
- * @run main/othervm/timeout=140 main
- *
- * SunJSSE does not support dynamic system properties, no way to re-use
- * system properties in samevm/agentvm mode.
+ * @run main/othervm/timeout=140 -Djsse.enableCBCProtection=false main
* @summary Make sure that different configurations of SSL sockets work
*/
diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java
new file mode 100644
index 00000000000..f9cd5185b33
--- /dev/null
+++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java
@@ -0,0 +1,479 @@
+/*
+ * Copyright (c) 2011, 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 7031830
+ * @summary bad_record_mac failure on TLSv1.2 enabled connection with SSLEngine
+ * @run main/othervm SSLEngineBadBufferArrayAccess
+ *
+ * SunJSSE does not support dynamic system properties, no way to re-use
+ * system properties in samevm/agentvm mode.
+ */
+
+/**
+ * A SSLSocket/SSLEngine interop test case. This is not the way to
+ * code SSLEngine-based servers, but works for what we need to do here,
+ * which is to make sure that SSLEngine/SSLSockets can talk to each other.
+ * SSLEngines can use direct or indirect buffers, and different code
+ * is used to get at the buffer contents internally, so we test that here.
+ *
+ * The test creates one SSLSocket (client) and one SSLEngine (server).
+ * The SSLSocket talks to a raw ServerSocket, and the server code
+ * does the translation between byte [] and ByteBuffers that the SSLEngine
+ * can use. The "transport" layer consists of a Socket Input/OutputStream
+ * and two byte buffers for the SSLEngines: think of them
+ * as directly connected pipes.
+ *
+ * Again, this is a *very* simple example: real code will be much more
+ * involved. For example, different threading and I/O models could be
+ * used, transport mechanisms could close unexpectedly, and so on.
+ *
+ * When this application runs, notice that several messages
+ * (wrap/unwrap) pass before any application data is consumed or
+ * produced. (For more information, please see the SSL/TLS
+ * specifications.) There may several steps for a successful handshake,
+ * so it's typical to see the following series of operations:
+ *
+ * client server message
+ * ====== ====== =======
+ * write() ... ClientHello
+ * ... unwrap() ClientHello
+ * ... wrap() ServerHello/Certificate
+ * read() ... ServerHello/Certificate
+ * write() ... ClientKeyExchange
+ * write() ... ChangeCipherSpec
+ * write() ... Finished
+ * ... unwrap() ClientKeyExchange
+ * ... unwrap() ChangeCipherSpec
+ * ... unwrap() Finished
+ * ... wrap() ChangeCipherSpec
+ * ... wrap() Finished
+ * read() ... ChangeCipherSpec
+ * read() ... Finished
+ *
+ * This particular bug had a problem where byte buffers backed by an
+ * array didn't offset correctly, and we got bad MAC errors.
+ */
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import java.io.*;
+import java.net.*;
+import java.security.*;
+import java.nio.*;
+
+public class SSLEngineBadBufferArrayAccess {
+
+ /*
+ * Enables logging of the SSL/TLS operations.
+ */
+ private static boolean logging = true;
+
+ /*
+ * Enables the JSSE system debugging system property:
+ *
+ * -Djavax.net.debug=all
+ *
+ * This gives a lot of low-level information about operations underway,
+ * including specific handshake messages, and might be best examined
+ * after gaining some familiarity with this application.
+ */
+ private static boolean debug = false;
+ private SSLContext sslc;
+ private SSLEngine serverEngine; // server-side SSLEngine
+ private SSLSocket sslSocket; // client-side socket
+ private ServerSocket serverSocket; // server-side Socket, generates the...
+ private Socket socket; // server-side socket that will read
+
+ private final byte[] serverMsg = "Hi there Client, I'm a Server".getBytes();
+ private final byte[] clientMsg = "Hello Server, I'm a Client".getBytes();
+
+ private ByteBuffer serverOut; // write side of serverEngine
+ private ByteBuffer serverIn; // read side of serverEngine
+
+ private volatile Exception clientException;
+ private volatile Exception serverException;
+
+ /*
+ * For data transport, this example uses local ByteBuffers.
+ */
+ private ByteBuffer cTOs; // "reliable" transport client->server
+ private ByteBuffer sTOc; // "reliable" transport server->client
+
+ /*
+ * The following is to set up the keystores/trust material.
+ */
+ private static final String pathToStores = "../../../../../../../etc/";
+ private static final String keyStoreFile = "keystore";
+ private static final String trustStoreFile = "truststore";
+ private static final String passwd = "passphrase";
+ private static String keyFilename =
+ System.getProperty("test.src", ".") + "/" + pathToStores
+ + "/" + keyStoreFile;
+ private static String trustFilename =
+ System.getProperty("test.src", ".") + "/" + pathToStores
+ + "/" + trustStoreFile;
+
+ /*
+ * Main entry point for this test.
+ */
+ public static void main(String args[]) throws Exception {
+ if (debug) {
+ System.setProperty("javax.net.debug", "all");
+ }
+
+ String [] protocols = new String [] {
+ "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2" };
+
+ for (String protocol : protocols) {
+ log("Testing " + protocol);
+ /*
+ * Run the tests with direct and indirect buffers.
+ */
+ SSLEngineBadBufferArrayAccess test =
+ new SSLEngineBadBufferArrayAccess(protocol);
+ test.runTest(true);
+ test.runTest(false);
+ }
+
+ System.out.println("Test Passed.");
+ }
+
+ /*
+ * Create an initialized SSLContext to use for these tests.
+ */
+ public SSLEngineBadBufferArrayAccess(String protocol) throws Exception {
+
+ KeyStore ks = KeyStore.getInstance("JKS");
+ KeyStore ts = KeyStore.getInstance("JKS");
+
+ char[] passphrase = "passphrase".toCharArray();
+
+ ks.load(new FileInputStream(keyFilename), passphrase);
+ ts.load(new FileInputStream(trustFilename), passphrase);
+
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+ kmf.init(ks, passphrase);
+
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+ tmf.init(ts);
+
+ SSLContext sslCtx = SSLContext.getInstance(protocol);
+
+ sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+ sslc = sslCtx;
+ }
+
+ /*
+ * Run the test.
+ *
+ * Sit in a tight loop, with the server engine calling wrap/unwrap
+ * regardless of whether data is available or not. We do this until
+ * we get the application data. Then we shutdown and go to the next one.
+ *
+ * The main loop handles all of the I/O phases of the SSLEngine's
+ * lifetime:
+ *
+ * initial handshaking
+ * application data transfer
+ * engine closing
+ *
+ * One could easily separate these phases into separate
+ * sections of code.
+ */
+ private void runTest(boolean direct) throws Exception {
+ boolean serverClose = direct;
+
+ serverSocket = new ServerSocket(0);
+ int port = serverSocket.getLocalPort();
+ Thread thread = createClientThread(port, serverClose);
+
+ socket = serverSocket.accept();
+ socket.setSoTimeout(500);
+ serverSocket.close();
+
+ createSSLEngine();
+ createBuffers(direct);
+
+ try {
+ boolean closed = false;
+
+ InputStream is = socket.getInputStream();
+ OutputStream os = socket.getOutputStream();
+
+ SSLEngineResult serverResult; // results from last operation
+
+ /*
+ * Examining the SSLEngineResults could be much more involved,
+ * and may alter the overall flow of the application.
+ *
+ * For example, if we received a BUFFER_OVERFLOW when trying
+ * to write to the output pipe, we could reallocate a larger
+ * pipe, but instead we wait for the peer to drain it.
+ */
+ byte[] inbound = new byte[8192];
+ byte[] outbound = new byte[8192];
+
+ while (!isEngineClosed(serverEngine)) {
+ int len = 0;
+
+ // Inbound data
+ log("================");
+
+ // Read from the Client side.
+ try {
+ len = is.read(inbound);
+ if (len == -1) {
+ throw new Exception("Unexpected EOF");
+ }
+ cTOs.put(inbound, 0, len);
+ } catch (SocketTimeoutException ste) {
+ // swallow. Nothing yet, probably waiting on us.
+ }
+
+ cTOs.flip();
+
+ serverResult = serverEngine.unwrap(cTOs, serverIn);
+ log("server unwrap: ", serverResult);
+ runDelegatedTasks(serverResult, serverEngine);
+ cTOs.compact();
+
+ // Outbound data
+ log("----");
+
+ serverResult = serverEngine.wrap(serverOut, sTOc);
+ log("server wrap: ", serverResult);
+ runDelegatedTasks(serverResult, serverEngine);
+
+ sTOc.flip();
+
+ if ((len = sTOc.remaining()) != 0) {
+ sTOc.get(outbound, 0, len);
+ os.write(outbound, 0, len);
+ // Give the other side a chance to process
+ }
+
+ sTOc.compact();
+
+ if (!closed && (serverOut.remaining() == 0)) {
+ closed = true;
+
+ /*
+ * We'll alternate initiatating the shutdown.
+ * When the server initiates, it will take one more
+ * loop, but tests the orderly shutdown.
+ */
+ if (serverClose) {
+ serverEngine.closeOutbound();
+ }
+ serverIn.flip();
+
+ /*
+ * A sanity check to ensure we got what was sent.
+ */
+ if (serverIn.remaining() != clientMsg.length) {
+ throw new Exception("Client: Data length error");
+ }
+
+ for (int i = 0; i < clientMsg.length; i++) {
+ if (clientMsg[i] != serverIn.get()) {
+ throw new Exception("Client: Data content error");
+ }
+ }
+ serverIn.compact();
+ }
+ }
+ return;
+ } catch (Exception e) {
+ serverException = e;
+ } finally {
+ socket.close();
+
+ // Wait for the client to join up with us.
+ thread.join();
+ if (serverException != null) {
+ throw serverException;
+ }
+ if (clientException != null) {
+ throw clientException;
+ }
+ }
+ }
+
+ /*
+ * Create a client thread which does simple SSLSocket operations.
+ * We'll write and read one data packet.
+ */
+ private Thread createClientThread(final int port,
+ final boolean serverClose) throws Exception {
+
+ Thread t = new Thread("ClientThread") {
+
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(1000); // Give server time to finish setup.
+
+ sslSocket = (SSLSocket) sslc.getSocketFactory().
+ createSocket("localhost", port);
+ OutputStream os = sslSocket.getOutputStream();
+ InputStream is = sslSocket.getInputStream();
+
+ // write(byte[]) goes in one shot.
+ os.write(clientMsg);
+
+ byte[] inbound = new byte[2048];
+ int pos = 0;
+
+ int len;
+done:
+ while ((len = is.read(inbound, pos, 2048 - pos)) != -1) {
+ pos += len;
+ // Let the client do the closing.
+ if ((pos == serverMsg.length) && !serverClose) {
+ sslSocket.close();
+ break done;
+ }
+ }
+
+ if (pos != serverMsg.length) {
+ throw new Exception("Client: Data length error");
+ }
+
+ for (int i = 0; i < serverMsg.length; i++) {
+ if (inbound[i] != serverMsg[i]) {
+ throw new Exception("Client: Data content error");
+ }
+ }
+ } catch (Exception e) {
+ clientException = e;
+ }
+ }
+ };
+ t.start();
+ return t;
+ }
+
+ /*
+ * Using the SSLContext created during object creation,
+ * create/configure the SSLEngines we'll use for this test.
+ */
+ private void createSSLEngine() throws Exception {
+ /*
+ * Configure the serverEngine to act as a server in the SSL/TLS
+ * handshake.
+ */
+ serverEngine = sslc.createSSLEngine();
+ serverEngine.setUseClientMode(false);
+ serverEngine.getNeedClientAuth();
+ }
+
+ /*
+ * Create and size the buffers appropriately.
+ */
+ private void createBuffers(boolean direct) {
+
+ SSLSession session = serverEngine.getSession();
+ int appBufferMax = session.getApplicationBufferSize();
+ int netBufferMax = session.getPacketBufferSize();
+
+ /*
+ * We'll make the input buffers a bit bigger than the max needed
+ * size, so that unwrap()s following a successful data transfer
+ * won't generate BUFFER_OVERFLOWS.
+ *
+ * We'll use a mix of direct and indirect ByteBuffers for
+ * tutorial purposes only. In reality, only use direct
+ * ByteBuffers when they give a clear performance enhancement.
+ */
+ if (direct) {
+ serverIn = ByteBuffer.allocateDirect(appBufferMax + 50);
+ cTOs = ByteBuffer.allocateDirect(netBufferMax);
+ sTOc = ByteBuffer.allocateDirect(netBufferMax);
+ } else {
+ serverIn = ByteBuffer.allocate(appBufferMax + 50);
+ cTOs = ByteBuffer.allocate(netBufferMax);
+ sTOc = ByteBuffer.allocate(netBufferMax);
+ }
+
+ serverOut = ByteBuffer.wrap(serverMsg);
+ }
+
+ /*
+ * If the result indicates that we have outstanding tasks to do,
+ * go ahead and run them in this thread.
+ */
+ private static void runDelegatedTasks(SSLEngineResult result,
+ SSLEngine engine) throws Exception {
+
+ if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+ Runnable runnable;
+ while ((runnable = engine.getDelegatedTask()) != null) {
+ log("\trunning delegated task...");
+ runnable.run();
+ }
+ HandshakeStatus hsStatus = engine.getHandshakeStatus();
+ if (hsStatus == HandshakeStatus.NEED_TASK) {
+ throw new Exception(
+ "handshake shouldn't need additional tasks");
+ }
+ log("\tnew HandshakeStatus: " + hsStatus);
+ }
+ }
+
+ private static boolean isEngineClosed(SSLEngine engine) {
+ return (engine.isOutboundDone() && engine.isInboundDone());
+ }
+
+ /*
+ * Logging code
+ */
+ private static boolean resultOnce = true;
+
+ private static void log(String str, SSLEngineResult result) {
+ if (!logging) {
+ return;
+ }
+ if (resultOnce) {
+ resultOnce = false;
+ System.out.println("The format of the SSLEngineResult is: \n"
+ + "\t\"getStatus() / getHandshakeStatus()\" +\n"
+ + "\t\"bytesConsumed() / bytesProduced()\"\n");
+ }
+ HandshakeStatus hsStatus = result.getHandshakeStatus();
+ log(str
+ + result.getStatus() + "/" + hsStatus + ", "
+ + result.bytesConsumed() + "/" + result.bytesProduced()
+ + " bytes");
+ if (hsStatus == HandshakeStatus.FINISHED) {
+ log("\t...ready for application data");
+ }
+ }
+
+ private static void log(String str) {
+ if (logging) {
+ System.out.println(str);
+ }
+ }
+}
diff --git a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/CheckStatus.java b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/CheckStatus.java
index c29f55a04b9..dfdefa9f1f7 100644
--- a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/CheckStatus.java
+++ b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/CheckStatus.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -29,6 +29,8 @@
* This is a simple hack to test a bunch of conditions and check
* their return codes.
*
+ * @run main/othervm -Djsse.enableCBCProtection=false CheckStatus
+ *
* @author Brad Wetmore
*/
diff --git a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargeBufs.java b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargeBufs.java
index 849e739c823..5960ea63992 100644
--- a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargeBufs.java
+++ b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargeBufs.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, 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
@@ -30,6 +30,8 @@
* This is to test larger buffer arrays, and make sure the maximum
* is being passed.
*
+ * @run main/othervm -Djsse.enableCBCProtection=false LargeBufs
+ *
* @author Brad R. Wetmore
*/
diff --git a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargePacket.java b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargePacket.java
index 9740b67021e..498df71463a 100644
--- a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargePacket.java
+++ b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargePacket.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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
@@ -27,10 +27,7 @@
* @bug 6388456
* @summary Need adjustable TLS max record size for interoperability
* with non-compliant
- * @run main/othervm LargePacket
- *
- * SunJSSE does not support dynamic system properties, no way to re-use
- * system properties in samevm/agentvm mode.
+ * @run main/othervm -Djsse.enableCBCProtection=false LargePacket
*
* @author Xuelei Fan
*/
diff --git a/jdk/test/sun/security/ssl/templates/SSLSocketSSLEngineTemplate.java b/jdk/test/sun/security/ssl/templates/SSLSocketSSLEngineTemplate.java
new file mode 100644
index 00000000000..e31409a0f74
--- /dev/null
+++ b/jdk/test/sun/security/ssl/templates/SSLSocketSSLEngineTemplate.java
@@ -0,0 +1,479 @@
+/*
+ * Copyright (c) 2011, 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 7105780
+ * @summary Add SSLSocket client/SSLEngine server to templates directory.
+ *
+ * SunJSSE does not support dynamic system properties, no way to re-use
+ * system properties in samevm/agentvm mode.
+ *
+ * @run main/othervm SSLSocketSSLEngineTemplate
+ */
+
+/**
+ * A SSLSocket/SSLEngine interop test case. This is not the way to
+ * code SSLEngine-based servers, but works for what we need to do here,
+ * which is to make sure that SSLEngine/SSLSockets can talk to each other.
+ * SSLEngines can use direct or indirect buffers, and different code
+ * is used to get at the buffer contents internally, so we test that here.
+ *
+ * The test creates one SSLSocket (client) and one SSLEngine (server).
+ * The SSLSocket talks to a raw ServerSocket, and the server code
+ * does the translation between byte [] and ByteBuffers that the SSLEngine
+ * can use. The "transport" layer consists of a Socket Input/OutputStream
+ * and two byte buffers for the SSLEngines: think of them
+ * as directly connected pipes.
+ *
+ * Again, this is a *very* simple example: real code will be much more
+ * involved. For example, different threading and I/O models could be
+ * used, transport mechanisms could close unexpectedly, and so on.
+ *
+ * When this application runs, notice that several messages
+ * (wrap/unwrap) pass before any application data is consumed or
+ * produced. (For more information, please see the SSL/TLS
+ * specifications.) There may several steps for a successful handshake,
+ * so it's typical to see the following series of operations:
+ *
+ * client server message
+ * ====== ====== =======
+ * write() ... ClientHello
+ * ... unwrap() ClientHello
+ * ... wrap() ServerHello/Certificate
+ * read() ... ServerHello/Certificate
+ * write() ... ClientKeyExchange
+ * write() ... ChangeCipherSpec
+ * write() ... Finished
+ * ... unwrap() ClientKeyExchange
+ * ... unwrap() ChangeCipherSpec
+ * ... unwrap() Finished
+ * ... wrap() ChangeCipherSpec
+ * ... wrap() Finished
+ * read() ... ChangeCipherSpec
+ * read() ... Finished
+ */
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import java.io.*;
+import java.net.*;
+import java.security.*;
+import java.nio.*;
+
+public class SSLSocketSSLEngineTemplate {
+
+ /*
+ * Enables logging of the SSL/TLS operations.
+ */
+ private static boolean logging = true;
+
+ /*
+ * Enables the JSSE system debugging system property:
+ *
+ * -Djavax.net.debug=all
+ *
+ * This gives a lot of low-level information about operations underway,
+ * including specific handshake messages, and might be best examined
+ * after gaining some familiarity with this application.
+ */
+ private static boolean debug = false;
+ private SSLContext sslc;
+ private SSLEngine serverEngine; // server-side SSLEngine
+ private SSLSocket sslSocket; // client-side socket
+ private ServerSocket serverSocket; // server-side Socket, generates the...
+ private Socket socket; // server-side socket that will read
+
+ private final byte[] serverMsg =
+ "Hi there Client, I'm a Server.".getBytes();
+ private final byte[] clientMsg =
+ "Hello Server, I'm a Client! Pleased to meet you!".getBytes();
+
+ private ByteBuffer serverOut; // write side of serverEngine
+ private ByteBuffer serverIn; // read side of serverEngine
+
+ private volatile Exception clientException;
+ private volatile Exception serverException;
+
+ /*
+ * For data transport, this example uses local ByteBuffers.
+ */
+ private ByteBuffer cTOs; // "reliable" transport client->server
+ private ByteBuffer sTOc; // "reliable" transport server->client
+
+ /*
+ * The following is to set up the keystores/trust material.
+ */
+ private static final String pathToStores = "../etc/";
+ private static final String keyStoreFile = "keystore";
+ private static final String trustStoreFile = "truststore";
+ private static final String passwd = "passphrase";
+ private static String keyFilename =
+ System.getProperty("test.src", ".") + "/" + pathToStores
+ + "/" + keyStoreFile;
+ private static String trustFilename =
+ System.getProperty("test.src", ".") + "/" + pathToStores
+ + "/" + trustStoreFile;
+
+ /*
+ * Main entry point for this test.
+ */
+ public static void main(String args[]) throws Exception {
+ if (debug) {
+ System.setProperty("javax.net.debug", "all");
+ }
+
+ String [] protocols = new String [] {
+ "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2" };
+
+ for (String protocol : protocols) {
+ log("Testing " + protocol);
+ /*
+ * Run the tests with direct and indirect buffers.
+ */
+ SSLSocketSSLEngineTemplate test =
+ new SSLSocketSSLEngineTemplate(protocol);
+ test.runTest(true);
+ test.runTest(false);
+ }
+
+ System.out.println("Test Passed.");
+ }
+
+ /*
+ * Create an initialized SSLContext to use for these tests.
+ */
+ public SSLSocketSSLEngineTemplate(String protocol) throws Exception {
+
+ KeyStore ks = KeyStore.getInstance("JKS");
+ KeyStore ts = KeyStore.getInstance("JKS");
+
+ char[] passphrase = "passphrase".toCharArray();
+
+ ks.load(new FileInputStream(keyFilename), passphrase);
+ ts.load(new FileInputStream(trustFilename), passphrase);
+
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+ kmf.init(ks, passphrase);
+
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+ tmf.init(ts);
+
+ SSLContext sslCtx = SSLContext.getInstance(protocol);
+
+ sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+ sslc = sslCtx;
+ }
+
+ /*
+ * Run the test.
+ *
+ * Sit in a tight loop, with the server engine calling wrap/unwrap
+ * regardless of whether data is available or not. We do this until
+ * we get the application data. Then we shutdown and go to the next one.
+ *
+ * The main loop handles all of the I/O phases of the SSLEngine's
+ * lifetime:
+ *
+ * initial handshaking
+ * application data transfer
+ * engine closing
+ *
+ * One could easily separate these phases into separate
+ * sections of code.
+ */
+ private void runTest(boolean direct) throws Exception {
+ boolean serverClose = direct;
+
+ serverSocket = new ServerSocket(0);
+ int port = serverSocket.getLocalPort();
+ Thread thread = createClientThread(port, serverClose);
+
+ socket = serverSocket.accept();
+ socket.setSoTimeout(500);
+ serverSocket.close();
+
+ createSSLEngine();
+ createBuffers(direct);
+
+ try {
+ boolean closed = false;
+
+ InputStream is = socket.getInputStream();
+ OutputStream os = socket.getOutputStream();
+
+ SSLEngineResult serverResult; // results from last operation
+
+ /*
+ * Examining the SSLEngineResults could be much more involved,
+ * and may alter the overall flow of the application.
+ *
+ * For example, if we received a BUFFER_OVERFLOW when trying
+ * to write to the output pipe, we could reallocate a larger
+ * pipe, but instead we wait for the peer to drain it.
+ */
+ byte[] inbound = new byte[8192];
+ byte[] outbound = new byte[8192];
+
+ while (!isEngineClosed(serverEngine)) {
+ int len = 0;
+
+ // Inbound data
+ log("================");
+
+ // Read from the Client side.
+ try {
+ len = is.read(inbound);
+ if (len == -1) {
+ throw new Exception("Unexpected EOF");
+ }
+ cTOs.put(inbound, 0, len);
+ } catch (SocketTimeoutException ste) {
+ // swallow. Nothing yet, probably waiting on us.
+ }
+
+ cTOs.flip();
+
+ serverResult = serverEngine.unwrap(cTOs, serverIn);
+ log("server unwrap: ", serverResult);
+ runDelegatedTasks(serverResult, serverEngine);
+ cTOs.compact();
+
+ // Outbound data
+ log("----");
+
+ serverResult = serverEngine.wrap(serverOut, sTOc);
+ log("server wrap: ", serverResult);
+ runDelegatedTasks(serverResult, serverEngine);
+
+ sTOc.flip();
+
+ if ((len = sTOc.remaining()) != 0) {
+ sTOc.get(outbound, 0, len);
+ os.write(outbound, 0, len);
+ // Give the other side a chance to process
+ }
+
+ sTOc.compact();
+
+ if (!closed && (serverOut.remaining() == 0)) {
+ closed = true;
+
+ /*
+ * We'll alternate initiatating the shutdown.
+ * When the server initiates, it will take one more
+ * loop, but tests the orderly shutdown.
+ */
+ if (serverClose) {
+ serverEngine.closeOutbound();
+ }
+ serverIn.flip();
+
+ /*
+ * A sanity check to ensure we got what was sent.
+ */
+ if (serverIn.remaining() != clientMsg.length) {
+ throw new Exception("Client: Data length error");
+ }
+
+ for (int i = 0; i < clientMsg.length; i++) {
+ if (clientMsg[i] != serverIn.get()) {
+ throw new Exception("Client: Data content error");
+ }
+ }
+ serverIn.compact();
+ }
+ }
+ return;
+ } catch (Exception e) {
+ serverException = e;
+ } finally {
+ socket.close();
+
+ // Wait for the client to join up with us.
+ thread.join();
+ if (serverException != null) {
+ throw serverException;
+ }
+ if (clientException != null) {
+ throw clientException;
+ }
+ }
+ }
+
+ /*
+ * Create a client thread which does simple SSLSocket operations.
+ * We'll write and read one data packet.
+ */
+ private Thread createClientThread(final int port,
+ final boolean serverClose) throws Exception {
+
+ Thread t = new Thread("ClientThread") {
+
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(1000); // Give server time to finish setup.
+
+ sslSocket = (SSLSocket) sslc.getSocketFactory().
+ createSocket("localhost", port);
+ OutputStream os = sslSocket.getOutputStream();
+ InputStream is = sslSocket.getInputStream();
+
+ // write(byte[]) goes in one shot.
+ os.write(clientMsg);
+
+ byte[] inbound = new byte[2048];
+ int pos = 0;
+
+ int len;
+done:
+ while ((len = is.read(inbound, pos, 2048 - pos)) != -1) {
+ pos += len;
+ // Let the client do the closing.
+ if ((pos == serverMsg.length) && !serverClose) {
+ sslSocket.close();
+ break done;
+ }
+ }
+
+ if (pos != serverMsg.length) {
+ throw new Exception("Client: Data length error");
+ }
+
+ for (int i = 0; i < serverMsg.length; i++) {
+ if (inbound[i] != serverMsg[i]) {
+ throw new Exception("Client: Data content error");
+ }
+ }
+ } catch (Exception e) {
+ clientException = e;
+ }
+ }
+ };
+ t.start();
+ return t;
+ }
+
+ /*
+ * Using the SSLContext created during object creation,
+ * create/configure the SSLEngines we'll use for this test.
+ */
+ private void createSSLEngine() throws Exception {
+ /*
+ * Configure the serverEngine to act as a server in the SSL/TLS
+ * handshake.
+ */
+ serverEngine = sslc.createSSLEngine();
+ serverEngine.setUseClientMode(false);
+ serverEngine.getNeedClientAuth();
+ }
+
+ /*
+ * Create and size the buffers appropriately.
+ */
+ private void createBuffers(boolean direct) {
+
+ SSLSession session = serverEngine.getSession();
+ int appBufferMax = session.getApplicationBufferSize();
+ int netBufferMax = session.getPacketBufferSize();
+
+ /*
+ * We'll make the input buffers a bit bigger than the max needed
+ * size, so that unwrap()s following a successful data transfer
+ * won't generate BUFFER_OVERFLOWS.
+ *
+ * We'll use a mix of direct and indirect ByteBuffers for
+ * tutorial purposes only. In reality, only use direct
+ * ByteBuffers when they give a clear performance enhancement.
+ */
+ if (direct) {
+ serverIn = ByteBuffer.allocateDirect(appBufferMax + 50);
+ cTOs = ByteBuffer.allocateDirect(netBufferMax);
+ sTOc = ByteBuffer.allocateDirect(netBufferMax);
+ } else {
+ serverIn = ByteBuffer.allocate(appBufferMax + 50);
+ cTOs = ByteBuffer.allocate(netBufferMax);
+ sTOc = ByteBuffer.allocate(netBufferMax);
+ }
+
+ serverOut = ByteBuffer.wrap(serverMsg);
+ }
+
+ /*
+ * If the result indicates that we have outstanding tasks to do,
+ * go ahead and run them in this thread.
+ */
+ private static void runDelegatedTasks(SSLEngineResult result,
+ SSLEngine engine) throws Exception {
+
+ if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+ Runnable runnable;
+ while ((runnable = engine.getDelegatedTask()) != null) {
+ log("\trunning delegated task...");
+ runnable.run();
+ }
+ HandshakeStatus hsStatus = engine.getHandshakeStatus();
+ if (hsStatus == HandshakeStatus.NEED_TASK) {
+ throw new Exception(
+ "handshake shouldn't need additional tasks");
+ }
+ log("\tnew HandshakeStatus: " + hsStatus);
+ }
+ }
+
+ private static boolean isEngineClosed(SSLEngine engine) {
+ return (engine.isOutboundDone() && engine.isInboundDone());
+ }
+
+ /*
+ * Logging code
+ */
+ private static boolean resultOnce = true;
+
+ private static void log(String str, SSLEngineResult result) {
+ if (!logging) {
+ return;
+ }
+ if (resultOnce) {
+ resultOnce = false;
+ System.out.println("The format of the SSLEngineResult is: \n"
+ + "\t\"getStatus() / getHandshakeStatus()\" +\n"
+ + "\t\"bytesConsumed() / bytesProduced()\"\n");
+ }
+ HandshakeStatus hsStatus = result.getHandshakeStatus();
+ log(str
+ + result.getStatus() + "/" + hsStatus + ", "
+ + result.bytesConsumed() + "/" + result.bytesProduced()
+ + " bytes");
+ if (hsStatus == HandshakeStatus.FINISHED) {
+ log("\t...ready for application data");
+ }
+ }
+
+ private static void log(String str) {
+ if (logging) {
+ System.out.println(str);
+ }
+ }
+}
diff --git a/jdk/test/sun/text/resources/Collator/Bug6755060.java b/jdk/test/sun/text/resources/Collator/Bug6755060.java
new file mode 100644
index 00000000000..ee23487d44b
--- /dev/null
+++ b/jdk/test/sun/text/resources/Collator/Bug6755060.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2011, 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 6755060
+ * @summary updating collation tables for thai to make it consistent with CLDR 1.9
+ */
+
+import java.text.*;
+import java.util.*;
+
+public class Bug6755060 {
+
+ /********************************************************
+ *********************************************************/
+ public static void main (String[] args) {
+
+ Locale reservedLocale = Locale.getDefault();
+
+ try{
+
+ int errors=0;
+
+ Locale loc = new Locale ("th", "TH"); // Thai
+
+ Locale.setDefault (loc);
+ Collator col = Collator.getInstance ();
+
+ /*
+ * The original data "data" are the data to be sorted provided by the submitter of the CR.
+ * It's in correct order in accord with thai collation in CLDR 1.9. If we use old Java without this fix,
+ * the output order will be incorrect. Correct order will be turned into incorrect order.
+
+ * If fix is there, "data" after sorting will be unchanged, same as "sortedData". If fix is lost (regression),
+ * "data" after sorting will be changed, not as "sortedData".(not correct anymore)
+
+ * The submitter of the CR also gives a expected "sortedData" in the CR, but it's in accord with collation in CLDR 1.4.
+ * His data to be sorted are actually well sorted in accord with CLDR 1.9.
+ */
+
+ String[] data = {"\u0e01", "\u0e01\u0e2f", "\u0e01\u0e46", "\u0e01\u0e4f", "\u0e01\u0e5a", "\u0e01\u0e5b", "\u0e01\u0e4e", "\u0e01\u0e4c", "\u0e01\u0e48", "\u0e01\u0e01", "\u0e01\u0e4b\u0e01", "\u0e01\u0e4d", "\u0e01\u0e30", "\u0e01\u0e31\u0e01", "\u0e01\u0e32", "\u0e01\u0e33", "\u0e01\u0e34", "\u0e01\u0e35", "\u0e01\u0e36", "\u0e01\u0e37", "\u0e01\u0e38", "\u0e01\u0e39", "\u0e40\u0e01", "\u0e40\u0e01\u0e48", "\u0e40\u0e01\u0e49", "\u0e40\u0e01\u0e4b", "\u0e41\u0e01", "\u0e42\u0e01", "\u0e43\u0e01", "\u0e44\u0e01", "\u0e01\u0e3a", "\u0e24\u0e32", "\u0e24\u0e45", "\u0e40\u0e25", "\u0e44\u0e26"};
+
+ String[] sortedData = {"\u0e01", "\u0e01\u0e2f", "\u0e01\u0e46", "\u0e01\u0e4f", "\u0e01\u0e5a", "\u0e01\u0e5b", "\u0e01\u0e4e", "\u0e01\u0e4c", "\u0e01\u0e48", "\u0e01\u0e01", "\u0e01\u0e4b\u0e01", "\u0e01\u0e4d", "\u0e01\u0e30", "\u0e01\u0e31\u0e01", "\u0e01\u0e32", "\u0e01\u0e33", "\u0e01\u0e34", "\u0e01\u0e35", "\u0e01\u0e36", "\u0e01\u0e37", "\u0e01\u0e38", "\u0e01\u0e39", "\u0e40\u0e01", "\u0e40\u0e01\u0e48", "\u0e40\u0e01\u0e49", "\u0e40\u0e01\u0e4b", "\u0e41\u0e01", "\u0e42\u0e01", "\u0e43\u0e01", "\u0e44\u0e01", "\u0e01\u0e3a", "\u0e24\u0e32", "\u0e24\u0e45", "\u0e40\u0e25", "\u0e44\u0e26"};
+
+ Arrays.sort (data, col);
+
+ System.out.println ("Using " + loc.getDisplayName());
+ for (int i = 0; i < data.length; i++) {
+ System.out.println(data[i] + " : " + sortedData[i]);
+ if (sortedData[i].compareTo(data[i]) != 0) {
+ errors++;
+ }
+ }//end for
+
+ if (errors > 0){
+ StringBuffer expected = new StringBuffer(), actual = new StringBuffer();
+ expected.append(sortedData[0]);
+ actual.append(data[0]);
+
+ for (int i=1; i&' with an external RMI registry
diff --git a/langtools/.hgtags b/langtools/.hgtags
index 9c596017a4a..ffd905c4f03 100644
--- a/langtools/.hgtags
+++ b/langtools/.hgtags
@@ -132,3 +132,6 @@ d2422276f9dabc848b7a079025719826d2f9a30f jdk8-b06
e8acc2d6c32f0c8321e642e1a86672a2e196a056 jdk8-b08
b7a7e47c8d3daf7822abf7c37e5179ccbbf53008 jdk8-b09
f6c783e18bdf4d46a0ab273868afebbf32600ff7 jdk8-b10
+4bf01f1c4e3464f378959d10f3983a0469181d94 jdk8-b11
+f2d6ed25857dfa7f269ac66e13666d648cb988c6 jdk8-b12
+ae25163501bc7477cd907e26a006a6f1b05fdb6d jdk8-b13
diff --git a/langtools/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java b/langtools/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java
index 89658e2bfe3..32d10ab50c5 100644
--- a/langtools/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java
+++ b/langtools/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java
@@ -42,7 +42,6 @@ import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.apt.comp.*;
import com.sun.tools.apt.util.Bark;
import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.tools.javac.parser.DocCommentScanner;
/**
* This is NOT part of any supported API.
diff --git a/langtools/src/share/classes/com/sun/tools/apt/main/Main.java b/langtools/src/share/classes/com/sun/tools/apt/main/Main.java
index 5c2cfcc4b7d..80e7e1dbda5 100644
--- a/langtools/src/share/classes/com/sun/tools/apt/main/Main.java
+++ b/langtools/src/share/classes/com/sun/tools/apt/main/Main.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, 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
@@ -56,7 +56,7 @@ import com.sun.tools.apt.comp.UsageMessageNeededException;
import com.sun.tools.apt.util.Bark;
import com.sun.mirror.apt.AnnotationProcessorFactory;
-import static com.sun.tools.javac.file.Paths.pathToURLs;
+import static com.sun.tools.javac.file.Locations.pathToURLs;
/** This class provides a commandline interface to the apt build-time
* tool.
diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
index 1b1e331dae9..e1a82e6cc54 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
@@ -325,7 +325,7 @@ public class JavacTaskImpl extends JavacTask {
ListBuffer elements = new ListBuffer();
for (JCCompilationUnit unit : units) {
for (JCTree node : unit.defs) {
- if (node.getTag() == JCTree.CLASSDEF) {
+ if (node.hasTag(JCTree.Tag.CLASSDEF)) {
JCClassDecl cdef = (JCClassDecl) node;
if (cdef.sym != null) // maybe null if errors in anno processing
elements.append(cdef.sym);
@@ -383,12 +383,12 @@ public class JavacTaskImpl extends JavacTask {
private void handleFlowResults(Queue> queue, ListBuffer elems) {
for (Env env: queue) {
switch (env.tree.getTag()) {
- case JCTree.CLASSDEF:
+ case CLASSDEF:
JCClassDecl cdef = (JCClassDecl) env.tree;
if (cdef.sym != null)
elems.append(cdef.sym);
break;
- case JCTree.TOPLEVEL:
+ case TOPLEVEL:
JCCompilationUnit unit = (JCCompilationUnit) env.tree;
if (unit.packge != null)
elems.append(unit.packge);
diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java
index 7bd384bb5ac..1c6f7302751 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java
@@ -207,7 +207,7 @@ public class JavacTrees extends Trees {
if (sym == null && TreeInfo.isDeclaration(tree)) {
for (TreePath p = path; p != null; p = p.getParentPath()) {
JCTree t = (JCTree) p.getLeaf();
- if (t.getTag() == JCTree.CLASSDEF) {
+ if (t.hasTag(JCTree.Tag.CLASSDEF)) {
JCClassDecl ct = (JCClassDecl) t;
if (ct.sym != null) {
if ((ct.sym.flags_field & Flags.UNATTRIBUTED) != 0) {
diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java b/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java
index 59aa924385d..f639caeef45 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java
@@ -258,7 +258,7 @@ public abstract class Printer implements Type.Visitor