Merge
diff --git a/src/aix/classes/sun/tools/attach/AixVirtualMachine.java b/src/aix/classes/sun/tools/attach/AixVirtualMachine.java
index 714f5c0..29ee013 100644
--- a/src/aix/classes/sun/tools/attach/AixVirtualMachine.java
+++ b/src/aix/classes/sun/tools/attach/AixVirtualMachine.java
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2013 SAP AG. All rights reserved.
+ * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2015 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,14 @@
*/
package sun.tools.attach;
-import com.sun.tools.attach.VirtualMachine;
+import com.sun.tools.attach.AttachOperationFailedException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.spi.AttachProvider;
+
import java.io.InputStream;
import java.io.IOException;
import java.io.File;
-import java.util.Properties;
// Based on 'LinuxVirtualMachine.java'. All occurrences of the string
// "Linux" have been textually replaced by "Aix" to avoid confusion.
@@ -192,6 +192,8 @@
}
if (completionStatus != 0) {
+ // read from the stream and use that as the error message
+ String message = readErrorMessage(sis);
sis.close();
// In the event of a protocol mismatch then the target VM
@@ -206,7 +208,11 @@
if (cmd.equals("load")) {
throw new AgentLoadException("Failed to load agent library");
} else {
- throw new IOException("Command failed in target VM");
+ if (message == null) {
+ throw new AttachOperationFailedException("Command failed in target VM");
+ } else {
+ throw new AttachOperationFailedException(message);
+ }
}
}
diff --git a/src/aix/native/sun/tools/attach/AixVirtualMachine.c b/src/aix/native/sun/tools/attach/AixVirtualMachine.c
index a5ba160..8ed522d 100644
--- a/src/aix/native/sun/tools/attach/AixVirtualMachine.c
+++ b/src/aix/native/sun/tools/attach/AixVirtualMachine.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2013 SAP AG. All rights reserved.
+ * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2015 SAP AG. 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
@@ -238,14 +238,14 @@
len = remaining;
}
- RESTARTABLE(read(fd, buf+off, len), n);
+ RESTARTABLE(read(fd, buf, len), n);
if (n == -1) {
JNU_ThrowIOExceptionWithLastError(env, "read");
} else {
if (n == 0) {
n = -1; // EOF
} else {
- (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf+off));
+ (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf));
}
}
return n;
diff --git a/src/macosx/classes/com/apple/laf/AquaMenuUI.java b/src/macosx/classes/com/apple/laf/AquaMenuUI.java
index 450bf54..f56a3c6 100644
--- a/src/macosx/classes/com/apple/laf/AquaMenuUI.java
+++ b/src/macosx/classes/com/apple/laf/AquaMenuUI.java
@@ -148,11 +148,15 @@
// In Aqua, we always have a menu delay, regardless of where the menu is.
if (!(selectedPath.length > 0 && selectedPath[selectedPath.length - 1] == menu.getPopupMenu())) {
- if (menu.getDelay() == 0) {
- appendPath(getPath(), menu.getPopupMenu());
- } else {
- manager.setSelectedPath(getPath());
- setupPostTimer(menu);
+ // the condition below prevents from activating menu in other frame
+ if (!menu.isTopLevelMenu() || (selectedPath.length > 0 &&
+ selectedPath[0] == menu.getParent())) {
+ if (menu.getDelay() == 0) {
+ appendPath(getPath(), menu.getPopupMenu());
+ } else {
+ manager.setSelectedPath(getPath());
+ setupPostTimer(menu);
+ }
}
}
}
diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
index 9cd88ee..e449227 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
@@ -488,6 +488,9 @@
} else {
deliverZoom(true);
+ // We need an up to date size of the peer, so we flush the native events
+ // to be sure that there are no setBounds requests in the queue.
+ LWCToolkit.flushNativeSelectors();
this.normalBounds = peer.getBounds();
GraphicsConfiguration config = getPeer().getGraphicsConfiguration();
diff --git a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
index f13a01c..5e0d78e 100644
--- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
+++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
@@ -833,7 +833,7 @@
/**
* Just spin a single empty block synchronously.
*/
- private static native void flushNativeSelectors();
+ static native void flushNativeSelectors();
@Override
public Clipboard createPlatformClipboard() {
diff --git a/src/macosx/native/sun/awt/AWTView.m b/src/macosx/native/sun/awt/AWTView.m
index d98d0d3..0cba2ed 100644
--- a/src/macosx/native/sun/awt/AWTView.m
+++ b/src/macosx/native/sun/awt/AWTView.m
@@ -310,7 +310,10 @@
}
- (BOOL) performKeyEquivalent: (NSEvent *) event {
- [self deliverJavaKeyEventHelper: event];
+ // if IM is active key events should be ignored
+ if (![self hasMarkedText] && !fInPressAndHold) {
+ [self deliverJavaKeyEventHelper: event];
+ }
// Workaround for 8020209: special case for "Cmd =" and "Cmd ."
// because Cocoa calls performKeyEquivalent twice for these keystrokes
diff --git a/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m b/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m
index 0eaf688..c71c636 100644
--- a/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m
+++ b/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m
@@ -131,11 +131,7 @@
NSAutoreleasePool *pool = [NSAutoreleasePool new];
*scaleFactor = 1;
char* scaledFile = nil;
- __block float screenScaleFactor = 1;
-
- [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
- screenScaleFactor = [SplashNSScreen() backingScaleFactor];
- }];
+ float screenScaleFactor = 1;
if (screenScaleFactor > 1) {
NSString *fileName = [NSString stringWithUTF8String: file];
diff --git a/src/share/classes/com/sun/crypto/provider/JceKeyStore.java b/src/share/classes/com/sun/crypto/provider/JceKeyStore.java
index 5d48553..cbbc54e 100644
--- a/src/share/classes/com/sun/crypto/provider/JceKeyStore.java
+++ b/src/share/classes/com/sun/crypto/provider/JceKeyStore.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -107,7 +107,7 @@
{
Key key = null;
- Object entry = entries.get(alias.toLowerCase());
+ Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
if (!((entry instanceof PrivateKeyEntry) ||
(entry instanceof SecretKeyEntry))) {
@@ -150,7 +150,7 @@
{
Certificate[] chain = null;
- Object entry = entries.get(alias.toLowerCase());
+ Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
if ((entry instanceof PrivateKeyEntry)
&& (((PrivateKeyEntry)entry).chain != null)) {
@@ -178,7 +178,7 @@
public Certificate engineGetCertificate(String alias) {
Certificate cert = null;
- Object entry = entries.get(alias.toLowerCase());
+ Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
if (entry != null) {
if (entry instanceof TrustedCertEntry) {
@@ -203,7 +203,7 @@
public Date engineGetCreationDate(String alias) {
Date date = null;
- Object entry = entries.get(alias.toLowerCase());
+ Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
if (entry != null) {
// We have to create a new instance of java.util.Date because
@@ -266,7 +266,7 @@
}
// store the entry
- entries.put(alias.toLowerCase(), entry);
+ entries.put(alias.toLowerCase(Locale.ENGLISH), entry);
} else {
SecretKeyEntry entry = new SecretKeyEntry();
@@ -274,7 +274,7 @@
// seal and store the key
entry.sealedKey = keyProtector.seal(key);
- entries.put(alias.toLowerCase(), entry);
+ entries.put(alias.toLowerCase(Locale.ENGLISH), entry);
}
} catch (Exception e) {
@@ -322,7 +322,7 @@
entry.chain = null;
}
- entries.put(alias.toLowerCase(), entry);
+ entries.put(alias.toLowerCase(Locale.ENGLISH), entry);
}
}
@@ -345,7 +345,7 @@
{
synchronized(entries) {
- Object entry = entries.get(alias.toLowerCase());
+ Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
if (entry != null) {
if (entry instanceof PrivateKeyEntry) {
throw new KeyStoreException("Cannot overwrite own "
@@ -358,7 +358,7 @@
TrustedCertEntry trustedCertEntry = new TrustedCertEntry();
trustedCertEntry.cert = cert;
trustedCertEntry.date = new Date();
- entries.put(alias.toLowerCase(), trustedCertEntry);
+ entries.put(alias.toLowerCase(Locale.ENGLISH), trustedCertEntry);
}
}
@@ -373,7 +373,7 @@
throws KeyStoreException
{
synchronized(entries) {
- entries.remove(alias.toLowerCase());
+ entries.remove(alias.toLowerCase(Locale.ENGLISH));
}
}
@@ -394,7 +394,7 @@
* @return true if the alias exists, false otherwise
*/
public boolean engineContainsAlias(String alias) {
- return entries.containsKey(alias.toLowerCase());
+ return entries.containsKey(alias.toLowerCase(Locale.ENGLISH));
}
/**
@@ -416,7 +416,7 @@
public boolean engineIsKeyEntry(String alias) {
boolean isKey = false;
- Object entry = entries.get(alias.toLowerCase());
+ Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
if ((entry instanceof PrivateKeyEntry)
|| (entry instanceof SecretKeyEntry)) {
isKey = true;
@@ -434,7 +434,7 @@
*/
public boolean engineIsCertificateEntry(String alias) {
boolean isCert = false;
- Object entry = entries.get(alias.toLowerCase());
+ Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
if (entry instanceof TrustedCertEntry) {
isCert = true;
}
diff --git a/src/share/classes/com/sun/crypto/provider/PBEKey.java b/src/share/classes/com/sun/crypto/provider/PBEKey.java
index d954d0f..10ba5cb 100644
--- a/src/share/classes/com/sun/crypto/provider/PBEKey.java
+++ b/src/share/classes/com/sun/crypto/provider/PBEKey.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
import java.security.KeyRep;
import java.security.spec.InvalidKeySpecException;
+import java.util.Locale;
import javax.crypto.SecretKey;
import javax.crypto.spec.PBEKeySpec;
@@ -91,7 +92,7 @@
for (int i = 1; i < this.key.length; i++) {
retval += this.key[i] * i;
}
- return(retval ^= getAlgorithm().toLowerCase().hashCode());
+ return(retval ^= getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode());
}
public boolean equals(Object obj) {
diff --git a/src/share/classes/com/sun/crypto/provider/PBEKeyFactory.java b/src/share/classes/com/sun/crypto/provider/PBEKeyFactory.java
index 26dd086..0c87971 100644
--- a/src/share/classes/com/sun/crypto/provider/PBEKeyFactory.java
+++ b/src/share/classes/com/sun/crypto/provider/PBEKeyFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
import javax.crypto.SecretKeyFactorySpi;
import javax.crypto.spec.PBEKeySpec;
import java.util.HashSet;
+import java.util.Locale;
/**
* This class implements a key factory for PBE keys according to PKCS#5,
@@ -56,24 +57,24 @@
static {
validTypes = new HashSet<String>(17);
- validTypes.add("PBEWithMD5AndDES".toUpperCase());
- validTypes.add("PBEWithSHA1AndDESede".toUpperCase());
- validTypes.add("PBEWithSHA1AndRC2_40".toUpperCase());
- validTypes.add("PBEWithSHA1AndRC2_128".toUpperCase());
- validTypes.add("PBEWithSHA1AndRC4_40".toUpperCase());
- validTypes.add("PBEWithSHA1AndRC4_128".toUpperCase());
+ validTypes.add("PBEWithMD5AndDES".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithSHA1AndDESede".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithSHA1AndRC2_40".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithSHA1AndRC2_128".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithSHA1AndRC4_40".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithSHA1AndRC4_128".toUpperCase(Locale.ENGLISH));
// Proprietary algorithm.
- validTypes.add("PBEWithMD5AndTripleDES".toUpperCase());
- validTypes.add("PBEWithHmacSHA1AndAES_128".toUpperCase());
- validTypes.add("PBEWithHmacSHA224AndAES_128".toUpperCase());
- validTypes.add("PBEWithHmacSHA256AndAES_128".toUpperCase());
- validTypes.add("PBEWithHmacSHA384AndAES_128".toUpperCase());
- validTypes.add("PBEWithHmacSHA512AndAES_128".toUpperCase());
- validTypes.add("PBEWithHmacSHA1AndAES_256".toUpperCase());
- validTypes.add("PBEWithHmacSHA224AndAES_256".toUpperCase());
- validTypes.add("PBEWithHmacSHA256AndAES_256".toUpperCase());
- validTypes.add("PBEWithHmacSHA384AndAES_256".toUpperCase());
- validTypes.add("PBEWithHmacSHA512AndAES_256".toUpperCase());
+ validTypes.add("PBEWithMD5AndTripleDES".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithHmacSHA1AndAES_128".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithHmacSHA224AndAES_128".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithHmacSHA256AndAES_128".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithHmacSHA384AndAES_128".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithHmacSHA512AndAES_128".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithHmacSHA1AndAES_256".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithHmacSHA224AndAES_256".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithHmacSHA256AndAES_256".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithHmacSHA384AndAES_256".toUpperCase(Locale.ENGLISH));
+ validTypes.add("PBEWithHmacSHA512AndAES_256".toUpperCase(Locale.ENGLISH));
}
public static final class PBEWithMD5AndDES
@@ -237,7 +238,7 @@
protected KeySpec engineGetKeySpec(SecretKey key, Class<?> keySpecCl)
throws InvalidKeySpecException {
if ((key instanceof SecretKey)
- && (validTypes.contains(key.getAlgorithm().toUpperCase()))
+ && (validTypes.contains(key.getAlgorithm().toUpperCase(Locale.ENGLISH)))
&& (key.getFormat().equalsIgnoreCase("RAW"))) {
// Check if requested key spec is amongst the valid ones
@@ -279,7 +280,7 @@
{
try {
if ((key != null) &&
- (validTypes.contains(key.getAlgorithm().toUpperCase())) &&
+ (validTypes.contains(key.getAlgorithm().toUpperCase(Locale.ENGLISH))) &&
(key.getFormat().equalsIgnoreCase("RAW"))) {
// Check if key originates from this factory
diff --git a/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java b/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java
index ec3bd3e..16756fb 100644
--- a/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java
+++ b/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.util.Arrays;
+import java.util.Locale;
import java.security.KeyRep;
import java.security.GeneralSecurityException;
import java.security.NoSuchAlgorithmException;
@@ -143,7 +144,7 @@
@Override
public int hashCode() {
return Arrays.hashCode(password) * 41 +
- prf.getAlgorithm().toLowerCase().hashCode();
+ prf.getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode();
}
@Override
public boolean equals(Object obj) {
@@ -221,7 +222,7 @@
for (int i = 1; i < this.key.length; i++) {
retval += this.key[i] * i;
}
- return(retval ^= getAlgorithm().toLowerCase().hashCode());
+ return(retval ^= getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode());
}
public boolean equals(Object obj) {
diff --git a/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java b/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java
index 68379a7..54c27e9 100644
--- a/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java
+++ b/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -538,6 +538,13 @@
currentFetchThread = null;
}
+ if (nr == null) {
+ if (logger.traceOn()) {
+ logger.trace("NotifFetcher-run",
+ "Recieved null object as notifs, stops fetching because the "
+ + "notification server is terminated.");
+ }
+ }
if (nr == null || shouldStop()) {
// tell that the thread is REALLY stopped
setState(STOPPED);
@@ -657,7 +664,7 @@
return null;
}
- if (shouldStop())
+ if (shouldStop() || nr == null)
return null;
startSequenceNumber = nr.getNextSequenceNumber();
diff --git a/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java
index 1d5a6c9..f457337 100644
--- a/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java
+++ b/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -311,7 +311,7 @@
/*
* For nonvirtual invokes, method must have a body
*/
- if ((options & INVOKE_NONVIRTUAL) != 0) {
+ if (isNonVirtual(options)) {
if (method.isAbstract()) {
throw new IllegalArgumentException("Abstract method");
}
@@ -323,7 +323,7 @@
* method argument types.
*/
ClassTypeImpl invokedClass;
- if ((options & INVOKE_NONVIRTUAL) != 0) {
+ if (isNonVirtual(options)) {
// No overrides in non-virtual invokes
invokedClass = clazz;
} else {
@@ -348,7 +348,7 @@
/*
* Only default methods allowed for nonvirtual invokes
*/
- if (!method.isDefault()) {
+ if (isNonVirtual(options) && !method.isDefault()) {
throw new IllegalArgumentException("Not a default method");
}
}
@@ -624,4 +624,8 @@
byte typeValueKey() {
return JDWP.Tag.OBJECT;
}
+
+ private static boolean isNonVirtual(int options) {
+ return (options & INVOKE_NONVIRTUAL) != 0;
+ }
}
diff --git a/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java b/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java
index 752c097..47357db 100644
--- a/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java
+++ b/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java
@@ -285,6 +285,7 @@
// Forward the SAM method
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, samMethodName,
samMethodType.toMethodDescriptorString(), null, null);
+ mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
new ForwardingMethodGenerator(mv).generate(samMethodType);
// Forward the bridges
@@ -292,6 +293,7 @@
for (MethodType mt : additionalBridges) {
mv = cw.visitMethod(ACC_PUBLIC|ACC_BRIDGE, samMethodName,
mt.toMethodDescriptorString(), null, null);
+ mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
new ForwardingMethodGenerator(mv).generate(mt);
}
}
diff --git a/src/share/classes/java/util/zip/ZipEntry.java b/src/share/classes/java/util/zip/ZipEntry.java
index 1e32e74..b61e334 100644
--- a/src/share/classes/java/util/zip/ZipEntry.java
+++ b/src/share/classes/java/util/zip/ZipEntry.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,9 @@
class ZipEntry implements ZipConstants, Cloneable {
String name; // entry name
- long time = -1; // last modification time
+ long xdostime = -1; // last modification time (in extended DOS time,
+ // where milliseconds lost in conversion might
+ // be encoded into the upper half)
FileTime mtime; // last modification time, from extra field data
FileTime atime; // last access time, from extra field data
FileTime ctime; // creation time, from extra field data
@@ -64,6 +66,28 @@
public static final int DEFLATED = 8;
/**
+ * DOS time constant for representing timestamps before 1980.
+ */
+ static final long DOSTIME_BEFORE_1980 = (1 << 21) | (1 << 16);
+
+ /**
+ * Approximately 128 years, in milliseconds (ignoring leap years etc).
+ *
+ * This establish an approximate high-bound value for DOS times in
+ * milliseconds since epoch, used to enable an efficient but
+ * sufficient bounds check to avoid generating extended last modified
+ * time entries.
+ *
+ * Calculating the exact number is locale dependent, would require loading
+ * TimeZone data eagerly, and would make little practical sense. Since DOS
+ * times theoretically go to 2107 - with compatibility not guaranteed
+ * after 2099 - setting this to a time that is before but near 2099
+ * should be sufficient.
+ */
+ private static final long UPPER_DOSTIME_BOUND =
+ 128L * 365 * 24 * 60 * 60 * 1000;
+
+ /**
* Creates a new zip entry with the specified name.
*
* @param name
@@ -93,7 +117,7 @@
public ZipEntry(ZipEntry e) {
Objects.requireNonNull(e, "entry");
name = e.name;
- time = e.time;
+ xdostime = e.xdostime;
mtime = e.mtime;
atime = e.atime;
ctime = e.ctime;
@@ -137,8 +161,14 @@
* @see #getLastModifiedTime()
*/
public void setTime(long time) {
- this.time = time;
- this.mtime = null;
+ this.xdostime = javaToExtendedDosTime(time);
+ // Avoid setting the mtime field if time is in the valid
+ // range for a DOS time
+ if (xdostime != DOSTIME_BEFORE_1980 && time <= UPPER_DOSTIME_BOUND) {
+ this.mtime = null;
+ } else {
+ this.mtime = FileTime.from(time, TimeUnit.MILLISECONDS);
+ }
}
/**
@@ -158,7 +188,10 @@
* @see #setLastModifiedTime(FileTime)
*/
public long getTime() {
- return time;
+ if (mtime != null) {
+ return mtime.toMillis();
+ }
+ return (xdostime != -1) ? extendedDosToJavaTime(xdostime) : -1;
}
/**
@@ -181,7 +214,7 @@
*/
public ZipEntry setLastModifiedTime(FileTime time) {
this.mtime = Objects.requireNonNull(time, "lastModifiedTime");
- this.time = time.to(TimeUnit.MILLISECONDS);
+ this.xdostime = javaToExtendedDosTime(time.to(TimeUnit.MILLISECONDS));
return this;
}
@@ -204,9 +237,9 @@
public FileTime getLastModifiedTime() {
if (mtime != null)
return mtime;
- if (time == -1)
+ if (xdostime == -1)
return null;
- return FileTime.from(time, TimeUnit.MILLISECONDS);
+ return FileTime.from(getTime(), TimeUnit.MILLISECONDS);
}
/**
diff --git a/src/share/classes/java/util/zip/ZipFile.java b/src/share/classes/java/util/zip/ZipFile.java
index b101c33..e6b9f01 100644
--- a/src/share/classes/java/util/zip/ZipFile.java
+++ b/src/share/classes/java/util/zip/ZipFile.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,6 @@
import java.util.stream.StreamSupport;
import static java.util.zip.ZipConstants64.*;
-import static java.util.zip.ZipUtils.*;
/**
* This class is used to read entries from a zip file.
@@ -567,7 +566,7 @@
e.name = zc.toString(bname, bname.length);
}
}
- e.time = dosToJavaTime(getEntryTime(jzentry));
+ e.xdostime = getEntryTime(jzentry);
e.crc = getEntryCrc(jzentry);
e.size = getEntrySize(jzentry);
e.csize = getEntryCSize(jzentry);
diff --git a/src/share/classes/java/util/zip/ZipInputStream.java b/src/share/classes/java/util/zip/ZipInputStream.java
index 7b4ccc8..98526ef 100644
--- a/src/share/classes/java/util/zip/ZipInputStream.java
+++ b/src/share/classes/java/util/zip/ZipInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -303,7 +303,7 @@
throw new ZipException("encrypted ZIP entry not supported");
}
e.method = get16(tmpbuf, LOCHOW);
- e.time = dosToJavaTime(get32(tmpbuf, LOCTIM));
+ e.xdostime = get32(tmpbuf, LOCTIM);
if ((flag & 8) == 8) {
/* "Data Descriptor" present */
if (e.method != DEFLATED) {
diff --git a/src/share/classes/java/util/zip/ZipOutputStream.java b/src/share/classes/java/util/zip/ZipOutputStream.java
index 0bd7580..6b480aa 100644
--- a/src/share/classes/java/util/zip/ZipOutputStream.java
+++ b/src/share/classes/java/util/zip/ZipOutputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,6 @@
private static class XEntry {
final ZipEntry entry;
final long offset;
- long dostime; // last modification time in msdos format
public XEntry(ZipEntry entry, long offset) {
this.entry = entry;
this.offset = offset;
@@ -192,7 +191,7 @@
if (current != null) {
closeEntry(); // close previous entry
}
- if (e.time == -1) {
+ if (e.xdostime == -1) {
// by default, do NOT use extended timestamps in extra
// data, for now.
e.setTime(System.currentTimeMillis());
@@ -389,18 +388,12 @@
boolean hasZip64 = false;
int elen = getExtraLen(e.extra);
- // keep a copy of dostime for writeCEN(), otherwise the tz
- // sensitive local time entries in loc and cen might be
- // different if the default tz get changed during writeLOC()
- // and writeCEN()
- xentry.dostime = javaToDosTime(e.time);
-
writeInt(LOCSIG); // LOC header signature
if ((flag & 8) == 8) {
writeShort(version(e)); // version needed to extract
writeShort(flag); // general purpose bit flag
writeShort(e.method); // compression method
- writeInt(xentry.dostime); // last modification time
+ writeInt(e.xdostime); // last modification time
// store size, uncompressed size, and crc-32 in data descriptor
// immediately following compressed entry data
writeInt(0);
@@ -415,7 +408,7 @@
}
writeShort(flag); // general purpose bit flag
writeShort(e.method); // compression method
- writeInt(xentry.dostime); // last modification time
+ writeInt(e.xdostime); // last modification time
writeInt(e.crc); // crc-32
if (hasZip64) {
writeInt(ZIP64_MAGICVAL);
@@ -522,9 +515,7 @@
}
writeShort(flag); // general purpose bit flag
writeShort(e.method); // compression method
- // use the copy in xentry, which has been converted
- // from e.time in writeLOC()
- writeInt(xentry.dostime); // last modification time
+ writeInt(e.xdostime); // last modification time
writeInt(e.crc); // crc-32
writeInt(csize); // compressed size
writeInt(size); // uncompressed size
diff --git a/src/share/classes/java/util/zip/ZipUtils.java b/src/share/classes/java/util/zip/ZipUtils.java
index 5a5e9a0..cd8b052 100644
--- a/src/share/classes/java/util/zip/ZipUtils.java
+++ b/src/share/classes/java/util/zip/ZipUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,9 +29,6 @@
import java.util.Date;
import java.util.concurrent.TimeUnit;
-import static java.util.zip.ZipConstants.*;
-import static java.util.zip.ZipConstants64.*;
-
class ZipUtils {
// used to adjust values between Windows and java epoch
@@ -69,7 +66,7 @@
/**
* Converts DOS time to Java time (number of milliseconds since epoch).
*/
- public static long dosToJavaTime(long dtime) {
+ private static long dosToJavaTime(long dtime) {
@SuppressWarnings("deprecation") // Use of date constructor.
Date d = new Date((int)(((dtime >> 25) & 0x7f) + 80),
(int)(((dtime >> 21) & 0x0f) - 1),
@@ -81,14 +78,26 @@
}
/**
+ * Converts extended DOS time to Java time, where up to 1999 milliseconds
+ * might be encoded into the upper half of the returned long.
+ *
+ * @param xdostime the extended DOS time value
+ * @return milliseconds since epoch
+ */
+ public static long extendedDosToJavaTime(long xdostime) {
+ long time = dosToJavaTime(xdostime);
+ return time + (xdostime >> 32);
+ }
+
+ /**
* Converts Java time to DOS time.
*/
@SuppressWarnings("deprecation") // Use of date methods
- public static long javaToDosTime(long time) {
+ private static long javaToDosTime(long time) {
Date d = new Date(time);
int year = d.getYear() + 1900;
if (year < 1980) {
- return (1 << 21) | (1 << 16);
+ return ZipEntry.DOSTIME_BEFORE_1980;
}
return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
@@ -96,6 +105,23 @@
}
/**
+ * Converts Java time to DOS time, encoding any milliseconds lost
+ * in the conversion into the upper half of the returned long.
+ *
+ * @param time milliseconds since epoch
+ * @return DOS time with 2s remainder encoded into upper half
+ */
+ public static long javaToExtendedDosTime(long time) {
+ if (time < 0) {
+ return ZipEntry.DOSTIME_BEFORE_1980;
+ }
+ long dostime = javaToDosTime(time);
+ return (dostime != ZipEntry.DOSTIME_BEFORE_1980)
+ ? dostime + ((time % 2000) << 32)
+ : ZipEntry.DOSTIME_BEFORE_1980;
+ }
+
+ /**
* Fetches unsigned 16-bit value from byte array at specified offset.
* The bytes are assumed to be in Intel (little-endian) byte order.
*/
diff --git a/src/share/classes/javax/crypto/spec/SecretKeySpec.java b/src/share/classes/javax/crypto/spec/SecretKeySpec.java
index aedd9ca..94c35e0 100644
--- a/src/share/classes/javax/crypto/spec/SecretKeySpec.java
+++ b/src/share/classes/javax/crypto/spec/SecretKeySpec.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
package javax.crypto.spec;
import java.security.spec.KeySpec;
+import java.util.Locale;
import javax.crypto.SecretKey;
/**
@@ -194,7 +195,8 @@
if (this.algorithm.equalsIgnoreCase("TripleDES"))
return (retval ^= "desede".hashCode());
else
- return (retval ^= this.algorithm.toLowerCase().hashCode());
+ return (retval ^=
+ this.algorithm.toLowerCase(Locale.ENGLISH).hashCode());
}
/**
diff --git a/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java b/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
index 6f60de7..702df9f 100644
--- a/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
+++ b/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
@@ -1254,10 +1254,11 @@
if (serverTerminated) {
// we must not call fetchNotifs() if the server is
// terminated (timeout elapsed).
- //
- return new NotificationResult(0L, 0L,
- new TargetedNotification[0]);
-
+ // returns null to force the client to stop fetching
+ if (logger.debugOn()) logger.debug("fetchNotifications",
+ "The notification server has been closed, "
+ + "returns null to force the client to stop fetching");
+ return null;
}
final long csn = clientSequenceNumber;
final int mn = maxNotifications;
diff --git a/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java b/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
index 3556449..9861bc8 100644
--- a/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
+++ b/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -900,7 +900,7 @@
private static ObjectIdentifier mapPBEAlgorithmToOID(String algorithm)
throws NoSuchAlgorithmException {
// Check for PBES2 algorithms
- if (algorithm.toLowerCase().startsWith("pbewithhmacsha")) {
+ if (algorithm.toLowerCase(Locale.ENGLISH).startsWith("pbewithhmacsha")) {
return pbes2_OID;
}
return AlgorithmId.get(algorithm).getOID();
diff --git a/src/share/classes/sun/security/provider/ConfigFile.java b/src/share/classes/sun/security/provider/ConfigFile.java
index f3c041a..6e243c4 100644
--- a/src/share/classes/sun/security/provider/ConfigFile.java
+++ b/src/share/classes/sun/security/provider/ConfigFile.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -451,7 +451,7 @@
// controlFlag (required, optional, etc)
LoginModuleControlFlag controlFlag;
- String sflag = match("controlFlag").toUpperCase();
+ String sflag = match("controlFlag").toUpperCase(Locale.ENGLISH);
switch (sflag) {
case "REQUIRED":
controlFlag = LoginModuleControlFlag.REQUIRED;
diff --git a/src/share/classes/sun/security/provider/PolicyParser.java b/src/share/classes/sun/security/provider/PolicyParser.java
index b13345f..8d037b4 100644
--- a/src/share/classes/sun/security/provider/PolicyParser.java
+++ b/src/share/classes/sun/security/provider/PolicyParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -707,7 +707,7 @@
} catch (PropertyExpander.ExpandException peee) {
throw new IOException(peee.getLocalizedMessage());
}
- properties.put(key.toLowerCase(), value);
+ properties.put(key.toLowerCase(Locale.ENGLISH), value);
}
return properties;
diff --git a/src/share/classes/sun/security/ssl/HandshakeMessage.java b/src/share/classes/sun/security/ssl/HandshakeMessage.java
index 4190830..c621adf 100644
--- a/src/share/classes/sun/security/ssl/HandshakeMessage.java
+++ b/src/share/classes/sun/security/ssl/HandshakeMessage.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -243,6 +243,7 @@
protocolVersion = ProtocolVersion.valueOf(s.getInt8(), s.getInt8());
clnt_random = new RandomCookie(s);
sessionId = new SessionId(s.getBytes8());
+ sessionId.checkLength(protocolVersion);
cipherSuites = new CipherSuiteList(s);
compression_methods = s.getBytes8();
if (messageLength() != messageLength) {
@@ -355,6 +356,7 @@
input.getInt8());
svr_random = new RandomCookie(input);
sessionId = new SessionId(input.getBytes8());
+ sessionId.checkLength(protocolVersion);
cipherSuite = CipherSuite.valueOf(input.getInt8(), input.getInt8());
compression_method = (byte)input.getInt8();
if (messageLength() != messageLength) {
diff --git a/src/share/classes/sun/security/ssl/SessionId.java b/src/share/classes/sun/security/ssl/SessionId.java
index 39bdd67..063e86d 100644
--- a/src/share/classes/sun/security/ssl/SessionId.java
+++ b/src/share/classes/sun/security/ssl/SessionId.java
@@ -27,6 +27,7 @@
package sun.security.ssl;
import java.security.SecureRandom;
+import javax.net.ssl.SSLProtocolException;
/**
* Encapsulates an SSL session ID. SSL Session IDs are not reused by
@@ -41,6 +42,7 @@
final
class SessionId
{
+ static int MAX_LENGTH = 32;
private byte sessionId []; // max 32 bytes
/** Constructs a new session ID ... perhaps for a rejoinable session */
@@ -114,4 +116,19 @@
}
return true;
}
+
+ /**
+ * Checks the length of the session ID to make sure it sits within
+ * the range called out in the specification
+ */
+ void checkLength(ProtocolVersion pv) throws SSLProtocolException {
+ // As of today all versions of TLS have a 32-byte maximum length.
+ // In the future we can do more here to support protocol versions
+ // that may have longer max lengths.
+ if (sessionId.length > MAX_LENGTH) {
+ throw new SSLProtocolException("Invalid session ID length (" +
+ sessionId.length + " bytes)");
+ }
+ }
+
}
diff --git a/src/share/classes/sun/security/tools/keytool/Main.java b/src/share/classes/sun/security/tools/keytool/Main.java
index 7cd92d6..efbbf5b 100644
--- a/src/share/classes/sun/security/tools/keytool/Main.java
+++ b/src/share/classes/sun/security/tools/keytool/Main.java
@@ -1494,7 +1494,7 @@
boolean useDefaultPBEAlgorithm = true;
SecretKey secKey = null;
- if (keyAlgName.toUpperCase().startsWith("PBE")) {
+ if (keyAlgName.toUpperCase(Locale.ENGLISH).startsWith("PBE")) {
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBE");
// User is prompted for PBE credential
diff --git a/src/share/classes/sun/text/resources/fi/FormatData_fi.java b/src/share/classes/sun/text/resources/fi/FormatData_fi.java
index f80df88..c9a520a 100644
--- a/src/share/classes/sun/text/resources/fi/FormatData_fi.java
+++ b/src/share/classes/sun/text/resources/fi/FormatData_fi.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -295,8 +295,8 @@
},
{ "DatePatterns",
new String[] {
- "d. MMMM'ta 'yyyy", // full date pattern
- "d. MMMM'ta 'yyyy", // long date pattern
+ "d. MMMM yyyy", // full date pattern
+ "d. MMMM yyyy", // long date pattern
"d.M.yyyy", // medium date pattern
"d.M.yyyy", // short date pattern
}
diff --git a/src/share/native/sun/tracing/dtrace/JVM.c b/src/share/native/sun/tracing/dtrace/JVM.c
index d17f8a8..ba54d8e 100644
--- a/src/share/native/sun/tracing/dtrace/JVM.c
+++ b/src/share/native/sun/tracing/dtrace/JVM.c
@@ -144,32 +144,34 @@
env, provider, &(jvm_provider->argsAttributes));
}
-static void readProviderData(
+static int readProviderData(
JNIEnv* env, jobject provider, JVM_DTraceProvider* jvm_provider) {
jmethodID mid;
jobjectArray probes;
jsize i;
- jclass clazz = (*env)->GetObjectClass(env, provider); CHECK
+ jclass clazz = (*env)->GetObjectClass(env, provider); CHECK_(0)
mid = (*env)->GetMethodID(
- env, clazz, "getProbes", "()[Lsun/tracing/dtrace/DTraceProbe;"); CHECK
+ env, clazz, "getProbes", "()[Lsun/tracing/dtrace/DTraceProbe;"); CHECK_(0)
probes = (jobjectArray)(*env)->CallObjectMethod(
- env, provider, mid); CHECK
+ env, provider, mid); CHECK_(0)
// Fill JVM structure, describing provider
- jvm_provider->probe_count = (*env)->GetArrayLength(env, probes); CHECK
+ jvm_provider->probe_count = (*env)->GetArrayLength(env, probes); CHECK_(0)
jvm_provider->probes = (JVM_DTraceProbe*)calloc(
jvm_provider->probe_count, sizeof(*jvm_provider->probes));
mid = (*env)->GetMethodID(
- env, clazz, "getProviderName", "()Ljava/lang/String;"); CHECK
+ env, clazz, "getProviderName", "()Ljava/lang/String;"); CHECK_(0)
jvm_provider->name = (jstring)(*env)->CallObjectMethod(
- env, provider, mid); CHECK
+ env, provider, mid); CHECK_(0)
- readInterfaceAttributes(env, provider, jvm_provider); CHECK
+ readInterfaceAttributes(env, provider, jvm_provider); CHECK_(0)
for (i = 0; i < jvm_provider->probe_count; ++i) {
- jobject probe = (*env)->GetObjectArrayElement(env, probes, i); CHECK
- readProbeData(env, probe, &jvm_provider->probes[i]); CHECK
+ jobject probe = (*env)->GetObjectArrayElement(env, probes, i); CHECK_(0)
+ readProbeData(env, probe, &jvm_provider->probes[i]); CHECK_(0)
}
+
+ return 1;
}
/*
@@ -182,6 +184,7 @@
jlong handle = 0;
jsize num_providers;
jsize i;
+ jsize count = 0;
JVM_DTraceProvider* jvm_providers;
initialize();
@@ -195,16 +198,23 @@
jvm_providers = (JVM_DTraceProvider*)calloc(
num_providers, sizeof(*jvm_providers));
- for (i = 0; i < num_providers; ++i) {
- JVM_DTraceProvider* p = &(jvm_providers[i]);
+ for (; count < num_providers; ++count) {
+ JVM_DTraceProvider* p = &(jvm_providers[count]);
jobject provider = (*env)->GetObjectArrayElement(
- env, providers, i);
- readProviderData(env, provider, p);
+ env, providers, count);
+ if ((*env)->ExceptionOccurred(env) ||
+ ! readProviderData(env, provider, p)) {
+ // got an error, bail out!
+ break;
+ }
}
- handle = jvm_symbols->Activate(
- env, JVM_TRACING_DTRACE_VERSION, moduleName,
- num_providers, jvm_providers);
+ if (count == num_providers) {
+ // all providers successfully loaded - get the handle
+ handle = jvm_symbols->Activate(
+ env, JVM_TRACING_DTRACE_VERSION, moduleName,
+ num_providers, jvm_providers);
+ }
for (i = 0; i < num_providers; ++i) {
JVM_DTraceProvider* p = &(jvm_providers[i]);
diff --git a/src/solaris/native/sun/awt/gtk2_interface.c b/src/solaris/native/sun/awt/gtk2_interface.c
index f61fee0..a9add84 100644
--- a/src/solaris/native/sun/awt/gtk2_interface.c
+++ b/src/solaris/native/sun/awt/gtk2_interface.c
@@ -433,7 +433,8 @@
result = TRUE;
}
- dlclose(lib);
+ // 8048289: workaround for https://bugzilla.gnome.org/show_bug.cgi?id=733065
+ // dlclose(lib);
return result;
}
diff --git a/test/Makefile b/test/Makefile
index 71053da..64b828b 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -262,8 +262,8 @@
EXTRA_JTREG_OPTIONS += -concurrency:$(CONCURRENCY)
endif
-# Default JTREG to run (win32 script works for everybody)
-JTREG = $(JT_HOME)/win32/bin/jtreg
+# Default JTREG to run
+JTREG = $(JT_HOME)/bin/jtreg
# run in agentvm mode
JTREG_BASIC_OPTIONS += -agentvm
# Only run automatic tests
diff --git a/test/com/sun/jdi/InterfaceMethodsTest.java b/test/com/sun/jdi/InterfaceMethodsTest.java
index e127fa5..b2fd758 100644
--- a/test/com/sun/jdi/InterfaceMethodsTest.java
+++ b/test/com/sun/jdi/InterfaceMethodsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/**
* @test
* @bug 8031195
+ * @bug 8071657
* @summary JDI: Add support for static and default methods in interfaces
*
* @run build TestScaffold VMConnection TargetListener TargetAdapter
@@ -38,6 +39,7 @@
private static final int RESULT_A = 1;
private static final int RESULT_B = 1;
private static final int RESULT_TARGET = 1;
+
static interface InterfaceA {
static int staticMethodA() {
System.out.println("-InterfaceA: static interface method A-");
@@ -202,6 +204,9 @@
// try to invoke static method B on the instance
testInvokePos(ifaceClass, ref, "staticMethodB", "()I", vm().mirrorOf(RESULT_A));
+
+ // try to invoke a virtual method
+ testInvokePos(ifaceClass, ref, "implementedMethod", "()I", vm().mirrorOf(RESULT_A), true);
}
private void testInterfaceB(ObjectReference ref) {
@@ -302,9 +307,14 @@
private void testInvokePos(ReferenceType targetClass, ObjectReference ref, String methodName,
String methodSig, Value value) {
+ testInvokePos(targetClass, ref, methodName, methodSig, value, false);
+ }
+
+ private void testInvokePos(ReferenceType targetClass, ObjectReference ref, String methodName,
+ String methodSig, Value value, boolean virtual) {
logInvocation(ref, methodName, methodSig, targetClass);
try {
- invoke(targetClass, ref, methodName, methodSig, value);
+ invoke(targetClass, ref, methodName, methodSig, value, virtual);
System.err.println("--- PASSED");
} catch (Exception e) {
System.err.println("--- FAILED");
@@ -314,9 +324,14 @@
private void testInvokeNeg(ReferenceType targetClass, ObjectReference ref, String methodName,
String methodSig, Value value, String msg) {
+ testInvokeNeg(targetClass, ref, methodName, methodSig, value, msg, false);
+ }
+
+ private void testInvokeNeg(ReferenceType targetClass, ObjectReference ref, String methodName,
+ String methodSig, Value value, String msg, boolean virtual) {
logInvocation(ref, methodName, methodSig, targetClass);
try {
- invoke(targetClass, ref, methodName, methodSig, value);
+ invoke(targetClass, ref, methodName, methodSig, value, virtual);
System.err.println("--- FAILED");
failure("FAILED: " + msg);
} catch (Exception e) {
@@ -326,7 +341,7 @@
}
private void invoke(ReferenceType targetClass, ObjectReference ref, String methodName,
- String methodSig, Value value)
+ String methodSig, Value value, boolean virtual)
throws Exception {
Method method = getMethod(targetClass, methodName, methodSig);
if (method == null) {
@@ -334,10 +349,15 @@
}
println("Invoking " + (method.isAbstract() ? "abstract " : " ") + "method: " + method);
+ println(method.declaringType().toString());
Value returnValue = null;
if (ref != null) {
- returnValue = invokeInstance(ref, method);
+ if (virtual) {
+ returnValue = invokeVirtual(ref, method);
+ } else {
+ returnValue = invokeInstance(ref, method);
+ }
} else {
returnValue = invokeStatic(targetClass, method);
}
@@ -362,6 +382,10 @@
return ref.invokeMethod(mainThread, method, Collections.emptyList(), ObjectReference.INVOKE_NONVIRTUAL);
}
+ private Value invokeVirtual(ObjectReference ref, Method method) throws Exception {
+ return ref.invokeMethod(mainThread, method, Collections.emptyList(), 0);
+ }
+
private Value invokeStatic(ReferenceType refType, Method method) throws Exception {
if (refType instanceof ClassType) {
return ((ClassType)refType).invokeMethod(mainThread, method, Collections.emptyList(), ObjectReference.INVOKE_NONVIRTUAL);
diff --git a/test/java/awt/Frame/MaximizedNormalBoundsUndecoratedTest/MaximizedNormalBoundsUndecoratedTest.java b/test/java/awt/Frame/MaximizedNormalBoundsUndecoratedTest/MaximizedNormalBoundsUndecoratedTest.java
new file mode 100644
index 0000000..119224a
--- /dev/null
+++ b/test/java/awt/Frame/MaximizedNormalBoundsUndecoratedTest/MaximizedNormalBoundsUndecoratedTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Frame;
+import java.awt.Toolkit;
+import java.awt.Dimension;
+/*
+ * @test
+ * @bug 8066436
+ * @summary Set the size of frame. Set extendedState Frame.MAXIMIZED_BOTH and Frame.NORMAL
+ * sequentially for undecorated Frame and .
+ * Check if resulted size is equal to original frame size.
+ * @run main MaximizedNormalBoundsUndecoratedTest
+ */
+
+
+public class MaximizedNormalBoundsUndecoratedTest {
+ private Frame frame;
+ public static void main(String args[]) {
+ if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)
+ && !Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.NORMAL)) {
+ return;
+ }
+ MaximizedNormalBoundsUndecoratedTest test = new MaximizedNormalBoundsUndecoratedTest();
+ boolean doPass = true;
+ if( !test.doTest() ) {
+ System.out.println("Maximizing frame not saving correct normal bounds");
+ doPass = false;
+ }
+
+ if(!doPass) {
+ throw new RuntimeException("Maximizing frame not saving correct normal bounds");
+ }
+ }
+
+ boolean doTest() {
+ Dimension beforeMaximizeCalled = new Dimension(300,300);
+
+ frame = new Frame("Test Frame");
+ frame.setUndecorated(true);
+ frame.setFocusable(true);
+ frame.setSize(beforeMaximizeCalled);
+ frame.setVisible(true);
+ frame.setExtendedState(Frame.MAXIMIZED_BOTH);
+ frame.setExtendedState(Frame.NORMAL);
+
+ Dimension afterMaximizedCalled= frame.getBounds().getSize();
+
+ frame.dispose();
+
+ if (beforeMaximizeCalled.equals(afterMaximizedCalled)) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/test/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java b/test/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java
index a13cd81..92de5f5 100644
--- a/test/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java
+++ b/test/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java
@@ -36,7 +36,7 @@
import sun.java2d.SunGraphics2D;
/**
- * @test
+ * test
* @bug 8043869
* @author Alexander Scherbatiy
* @summary [macosx] java -splash does not honor 2x hi dpi notation for retina
diff --git a/test/java/lang/invoke/lambda/LambdaStackTrace.java b/test/java/lang/invoke/lambda/LambdaStackTrace.java
new file mode 100644
index 0000000..e2cdb79
--- /dev/null
+++ b/test/java/lang/invoke/lambda/LambdaStackTrace.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8025636
+ * @summary Synthetic frames should be hidden in exceptions
+ * @compile -XDignore.symbol.file LUtils.java LambdaStackTrace.java
+ * @run main LambdaStackTrace
+ */
+
+import jdk.internal.org.objectweb.asm.ClassWriter;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+
+import static jdk.internal.org.objectweb.asm.Opcodes.ACC_ABSTRACT;
+import static jdk.internal.org.objectweb.asm.Opcodes.ACC_INTERFACE;
+import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
+import static jdk.internal.org.objectweb.asm.Opcodes.V1_7;
+
+public class LambdaStackTrace {
+
+ static File classes = new File(System.getProperty("test.classes"));
+
+ public static void main(String[] args) throws Exception {
+ testBasic();
+ testBridgeMethods();
+ }
+
+ /**
+ * Test the simple case
+ */
+ private static void testBasic() throws Exception {
+ try {
+ Runnable r = () -> {
+ throw new RuntimeException();
+ };
+ r.run();
+ } catch (Exception ex) {
+ // Before 8025636 the stacktrace would look like:
+ // at LambdaStackTrace.lambda$main$0(LambdaStackTrace.java:37)
+ // at LambdaStackTrace$$Lambda$1/1937396743.run(<Unknown>:1000000)
+ // at LambdaStackTrace.testBasic(LambdaStackTrace.java:40)
+ // at ...
+ //
+ // We are verifying that the middle frame above is gone.
+
+ verifyFrames(ex.getStackTrace(),
+ "LambdaStackTrace\\..*",
+ "LambdaStackTrace.testBasic");
+ }
+ }
+
+ /**
+ * Test the more complicated case with bridge methods.
+ *
+ * We set up the following interfaces:
+ *
+ * interface Maker {
+ * Object make();
+ * }
+ * interface StringMaker extends Maker {
+ * String make();
+ * }
+ *
+ * And we will use them like so:
+ *
+ * StringMaker sm = () -> { throw new RuntimeException(); };
+ * sm.make();
+ * ((Maker)m).make();
+ *
+ * The first call is a "normal" interface call, the second will use a
+ * bridge method. In both cases the generated lambda frame should
+ * be removed from the stack trace.
+ */
+ private static void testBridgeMethods() throws Exception {
+ // setup
+ generateInterfaces();
+ compileCaller();
+
+ // test
+ StackTraceElement[] frames = call("Caller", "callStringMaker");
+ verifyFrames(frames,
+ "Caller\\..*",
+ "Caller.callStringMaker");
+
+ frames = call("Caller", "callMaker");
+ verifyFrames(frames,
+ "Caller\\..*",
+ "Caller.callMaker");
+ }
+
+ private static void generateInterfaces() throws IOException {
+ // We can't let javac compile these interfaces because in > 1.8 it will insert
+ // bridge methods into the interfaces - we want code that looks like <= 1.7,
+ // so we generate it.
+ try (FileOutputStream fw = new FileOutputStream(new File(classes, "Maker.class"))) {
+ fw.write(generateMaker());
+ }
+ try (FileOutputStream fw = new FileOutputStream(new File(classes, "StringMaker.class"))) {
+ fw.write(generateStringMaker());
+ }
+ }
+
+ private static byte[] generateMaker() {
+ // interface Maker {
+ // Object make();
+ // }
+ ClassWriter cw = new ClassWriter(0);
+ cw.visit(V1_7, ACC_INTERFACE | ACC_ABSTRACT, "Maker", null, "java/lang/Object", null);
+ cw.visitMethod(ACC_PUBLIC | ACC_ABSTRACT, "make",
+ "()Ljava/lang/Object;", null, null);
+ cw.visitEnd();
+ return cw.toByteArray();
+ }
+
+ private static byte[] generateStringMaker() {
+ // interface StringMaker extends Maker {
+ // String make();
+ // }
+ ClassWriter cw = new ClassWriter(0);
+ cw.visit(V1_7, ACC_INTERFACE | ACC_ABSTRACT, "StringMaker", null, "java/lang/Object", new String[]{"Maker"});
+ cw.visitMethod(ACC_PUBLIC | ACC_ABSTRACT, "make",
+ "()Ljava/lang/String;", null, null);
+ cw.visitEnd();
+ return cw.toByteArray();
+ }
+
+
+ static void emitCode(File f) {
+ ArrayList<String> scratch = new ArrayList<>();
+ scratch.add("public class Caller {");
+ scratch.add(" public static void callStringMaker() {");
+ scratch.add(" StringMaker sm = () -> { throw new RuntimeException(); };");
+ scratch.add(" sm.make();");
+ scratch.add(" }");
+ scratch.add(" public static void callMaker() {");
+ scratch.add(" StringMaker sm = () -> { throw new RuntimeException(); };");
+ scratch.add(" ((Maker) sm).make();"); // <-- This will call the bridge method
+ scratch.add(" }");
+ scratch.add("}");
+ LUtils.createFile(f, scratch);
+ }
+
+ static void compileCaller() {
+ File caller = new File(classes, "Caller.java");
+ emitCode(caller);
+ LUtils.compile("-cp", classes.getAbsolutePath(), "-d", classes.getAbsolutePath(), caller.getAbsolutePath());
+ }
+
+ private static void verifyFrames(StackTraceElement[] stack, String... patterns) throws Exception {
+ for (int i = 0; i < patterns.length; i++) {
+ String cm = stack[i].getClassName() + "." + stack[i].getMethodName();
+ if (!cm.matches(patterns[i])) {
+ System.err.println("Actual trace did not match expected trace at frame " + i);
+ System.err.println("Expected frame patterns:");
+ for (int j = 0; j < patterns.length; j++) {
+ System.err.println(" " + j + ": " + patterns[j]);
+ }
+ System.err.println("Actual frames:");
+ for (int j = 0; j < patterns.length; j++) {
+ System.err.println(" " + j + ": " + stack[j]);
+ }
+ throw new Exception("Incorrect stack frames found");
+ }
+ }
+ }
+
+ private static StackTraceElement[] call(String clazz, String method) throws Exception {
+ Class<?> c = Class.forName(clazz);
+ try {
+ Method m = c.getDeclaredMethod(method);
+ m.invoke(null);
+ } catch(InvocationTargetException ex) {
+ return ex.getTargetException().getStackTrace();
+ }
+ throw new Exception("Expected exception to be thrown");
+ }
+}
diff --git a/test/java/util/zip/TestExtraTime.java b/test/java/util/zip/TestExtraTime.java
index fcf75a1..c6723b8 100644
--- a/test/java/util/zip/TestExtraTime.java
+++ b/test/java/util/zip/TestExtraTime.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 4759491 6303183 7012868 8015666 8023713 8068790
+ * @bug 4759491 6303183 7012868 8015666 8023713 8068790 8074694
* @summary Test ZOS and ZIS timestamp in extra field correctly
*/
@@ -71,6 +71,7 @@
}
testNullHandling();
+ testTimeConversions();
}
static void test(FileTime mtime, FileTime atime, FileTime ctime,
@@ -178,4 +179,33 @@
// pass
}
}
+
+ // verify that setting and getting any time is possible as per the intent
+ // of 4759491
+ static void testTimeConversions() {
+ // Sample across the entire range
+ long step = Long.MAX_VALUE / 100L;
+ testTimeConversions(Long.MIN_VALUE, Long.MAX_VALUE - step, step);
+
+ // Samples through the near future
+ long currentTime = System.currentTimeMillis();
+ testTimeConversions(currentTime, currentTime + 1_000_000, 10_000);
+ }
+
+ static void testTimeConversions(long from, long to, long step) {
+ ZipEntry ze = new ZipEntry("TestExtraTime.java");
+ for (long time = from; time <= to; time += step) {
+ ze.setTime(time);
+ FileTime lastModifiedTime = ze.getLastModifiedTime();
+ if (lastModifiedTime.toMillis() != time) {
+ throw new RuntimeException("setTime should make getLastModifiedTime " +
+ "return the specified instant: " + time +
+ " got: " + lastModifiedTime.toMillis());
+ }
+ if (ze.getTime() != time) {
+ throw new RuntimeException("getTime after setTime, expected: " +
+ time + " got: " + ze.getTime());
+ }
+ }
+ }
}
diff --git a/test/javax/swing/JMenu/8072900/WrongSelectionOnMouseOver.java b/test/javax/swing/JMenu/8072900/WrongSelectionOnMouseOver.java
new file mode 100644
index 0000000..cf02f6f
--- /dev/null
+++ b/test/javax/swing/JMenu/8072900/WrongSelectionOnMouseOver.java
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+@test
+@bug 8072900
+@summary Mouse events are captured by the wrong menu in OS X
+@author Anton Nashatyrev
+@run main WrongSelectionOnMouseOver
+*/
+
+import javax.swing.*;
+import javax.swing.event.MenuEvent;
+import javax.swing.event.MenuListener;
+import java.awt.*;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import static javax.swing.UIManager.getInstalledLookAndFeels;
+
+public class WrongSelectionOnMouseOver implements Runnable {
+
+ CountDownLatch firstMenuSelected = new CountDownLatch(1);
+ CountDownLatch secondMenuMouseEntered = new CountDownLatch(1);
+ CountDownLatch secondMenuSelected = new CountDownLatch(1);
+
+ JMenu m1, m2;
+
+ private UIManager.LookAndFeelInfo laf;
+ JFrame frame1;
+ JFrame frame2;
+
+ public WrongSelectionOnMouseOver(UIManager.LookAndFeelInfo laf) throws Exception {
+ this.laf = laf;
+ }
+
+ private void createUI() throws Exception {
+ System.out.println("Testing UI: " + laf);
+ UIManager.setLookAndFeel(laf.getClassName());
+
+ {
+ frame1 = new JFrame("Frame1");
+ JMenuBar mb = new JMenuBar();
+ m1 = new JMenu("File");
+ JMenuItem i1 = new JMenuItem("Save");
+ JMenuItem i2 = new JMenuItem("Load");
+
+ m1.addMenuListener(new MenuListener() {
+ @Override
+ public void menuSelected(MenuEvent e) {
+ firstMenuSelected.countDown();
+ System.out.println("Menu1: menuSelected");
+ }
+
+ @Override
+ public void menuDeselected(MenuEvent e) {
+ System.out.println("Menu1: menuDeselected");
+ }
+
+ @Override
+ public void menuCanceled(MenuEvent e) {
+ System.out.println("Menu1: menuCanceled");
+ }
+ });
+
+ frame1.setJMenuBar(mb);
+ mb.add(m1);
+ m1.add(i1);
+ m1.add(i2);
+
+ frame1.setLayout(new FlowLayout());
+ frame1.setBounds(200, 200, 200, 200);
+
+ frame1.setVisible(true);
+ }
+
+ {
+ frame2 = new JFrame("Frame2");
+ JMenuBar mb = new JMenuBar();
+ m2 = new JMenu("File");
+ JMenuItem i1 = new JMenuItem("Save");
+ JMenuItem i2 = new JMenuItem("Load");
+
+ m2.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ secondMenuMouseEntered.countDown();
+ System.out.println("WrongSelectionOnMouseOver.mouseEntered");
+ }
+ });
+
+ m2.addMenuListener(new MenuListener() {
+ @Override
+ public void menuSelected(MenuEvent e) {
+ secondMenuSelected.countDown();
+ System.out.println("Menu2: menuSelected");
+ }
+
+ @Override
+ public void menuDeselected(MenuEvent e) {
+ System.out.println("Menu2: menuDeselected");
+ }
+
+ @Override
+ public void menuCanceled(MenuEvent e) {
+ System.out.println("Menu2: menuCanceled");
+ }
+ });
+
+ frame2.setJMenuBar(mb);
+ mb.add(m2);
+ m2.add(i1);
+ m2.add(i2);
+
+ frame2.setLayout(new FlowLayout());
+ frame2.setBounds(400, 200, 200, 200);
+
+ frame2.setVisible(true);
+ }
+ }
+
+ public void disposeUI() {
+ frame1.dispose();
+ frame2.dispose();
+ }
+
+ @Override
+ public void run() {
+ try {
+ if (frame1 == null) {
+ createUI();
+ } else {
+ disposeUI();
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void test() throws Exception {
+ Robot robot = new Robot();
+ robot.setAutoDelay(100);
+
+ robot.waitForIdle();
+
+ robot.mouseMove((int) m1.getLocationOnScreen().getX() + 5,
+ (int) m1.getLocationOnScreen().getY() + 5);
+ robot.mousePress(MouseEvent.BUTTON1_MASK);
+ robot.mouseRelease(MouseEvent.BUTTON1_MASK);
+
+ if (!firstMenuSelected.await(5, TimeUnit.SECONDS)) {
+ throw new RuntimeException("Menu has not been selected.");
+ };
+
+ robot.mouseMove((int) m2.getLocationOnScreen().getX() + 5,
+ (int) m2.getLocationOnScreen().getY() + 5);
+
+ if (!secondMenuMouseEntered.await(5, TimeUnit.SECONDS)) {
+ throw new RuntimeException("MouseEntered event missed for the second menu");
+ };
+
+ if (secondMenuSelected.await(1, TimeUnit.SECONDS)) {
+ throw new RuntimeException("The second menu has been selected");
+ };
+ }
+
+ public static void main(final String[] args) throws Exception {
+ for (final UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) {
+ WrongSelectionOnMouseOver test = new WrongSelectionOnMouseOver(laf);
+ SwingUtilities.invokeAndWait(test);
+ test.test();
+ SwingUtilities.invokeAndWait(test);
+ }
+ System.out.println("Test passed");
+ }
+}
\ No newline at end of file
diff --git a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ClientHandshaker/LengthCheckTest.java b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ClientHandshaker/LengthCheckTest.java
new file mode 100644
index 0000000..38122d7
--- /dev/null
+++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ClientHandshaker/LengthCheckTest.java
@@ -0,0 +1,814 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8044860
+ * @summary Vectors and fixed length fields should be verified
+ * for allowed sizes.
+ * @run main/othervm LengthCheckTest
+ */
+
+/**
+ * A SSLEngine usage example which simplifies the presentation
+ * by removing the I/O and multi-threading concerns.
+ *
+ * The test creates two SSLEngines, simulating a client and server.
+ * The "transport" layer consists two byte buffers: think of them
+ * as directly connected pipes.
+ *
+ * Note, 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
+ * ====== ====== =======
+ * wrap() ... ClientHello
+ * ... unwrap() ClientHello
+ * ... wrap() ServerHello/Certificate
+ * unwrap() ... ServerHello/Certificate
+ * wrap() ... ClientKeyExchange
+ * wrap() ... ChangeCipherSpec
+ * wrap() ... Finished
+ * ... unwrap() ClientKeyExchange
+ * ... unwrap() ChangeCipherSpec
+ * ... unwrap() Finished
+ * ... wrap() ChangeCipherSpec
+ * ... wrap() Finished
+ * unwrap() ... ChangeCipherSpec
+ * unwrap() ... Finished
+ */
+
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import java.io.*;
+import java.security.*;
+import java.nio.*;
+import java.util.List;
+import java.util.ArrayList;
+import sun.security.ssl.ProtocolVersion;
+
+public class LengthCheckTest {
+
+ /*
+ * Enables logging of the SSLEngine operations.
+ */
+ private static final 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 final boolean debug = false;
+ private static final boolean dumpBufs = true;
+
+ private final SSLContext sslc;
+
+ private SSLEngine clientEngine; // client Engine
+ private ByteBuffer clientOut; // write side of clientEngine
+ private ByteBuffer clientIn; // read side of clientEngine
+
+ private SSLEngine serverEngine; // server Engine
+ private ByteBuffer serverOut; // write side of serverEngine
+ private ByteBuffer serverIn; // read side of serverEngine
+
+ private HandshakeTest handshakeTest;
+
+ /*
+ * For data transport, this example uses local ByteBuffers. This
+ * isn't really useful, but the purpose of this example is to show
+ * SSLEngine concepts, not how to do network transport.
+ */
+ private ByteBuffer cTOs; // "reliable" transport client->server
+ private ByteBuffer sTOc; // "reliable" transport server->client
+
+ /*
+ * The following is to set up the keystores.
+ */
+ 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 final String keyFilename =
+ System.getProperty("test.src", ".") + "/" + pathToStores +
+ "/" + keyStoreFile;
+ private static final String trustFilename =
+ System.getProperty("test.src", ".") + "/" + pathToStores +
+ "/" + trustStoreFile;
+
+ // Define a few basic TLS record and message types we might need
+ private static final int TLS_RECTYPE_CCS = 0x14;
+ private static final int TLS_RECTYPE_ALERT = 0x15;
+ private static final int TLS_RECTYPE_HANDSHAKE = 0x16;
+ private static final int TLS_RECTYPE_APPDATA = 0x17;
+
+ private static final int TLS_HS_HELLO_REQUEST = 0x00;
+ private static final int TLS_HS_CLIENT_HELLO = 0x01;
+ private static final int TLS_HS_SERVER_HELLO = 0x02;
+ private static final int TLS_HS_CERTIFICATE = 0x0B;
+ private static final int TLS_HS_SERVER_KEY_EXCHG = 0x0C;
+ private static final int TLS_HS_CERT_REQUEST = 0x0D;
+ private static final int TLS_HS_SERVER_HELLO_DONE = 0x0E;
+ private static final int TLS_HS_CERT_VERIFY = 0x0F;
+ private static final int TLS_HS_CLIENT_KEY_EXCHG = 0x10;
+ private static final int TLS_HS_FINISHED = 0x14;
+
+ // We're not going to define all the alert types in TLS, just
+ // the ones we think we'll need to reference by name.
+ private static final int TLS_ALERT_LVL_WARNING = 0x01;
+ private static final int TLS_ALERT_LVL_FATAL = 0x02;
+
+ private static final int TLS_ALERT_UNEXPECTED_MSG = 0x0A;
+ private static final int TLS_ALERT_HANDSHAKE_FAILURE = 0x28;
+ private static final int TLS_ALERT_INTERNAL_ERROR = 0x50;
+
+ public interface HandshakeTest {
+ void execTest() throws Exception;
+ }
+
+ public final HandshakeTest servSendLongID = new HandshakeTest() {
+ @Override
+ public void execTest() throws Exception {
+ boolean gotException = false;
+ SSLEngineResult clientResult; // results from client's last op
+ SSLEngineResult serverResult; // results from server's last op
+
+ log("\n==== Test: Client receives 64-byte session ID ====");
+
+ // Send Client Hello
+ clientResult = clientEngine.wrap(clientOut, cTOs);
+ log("client wrap: ", clientResult);
+ runDelegatedTasks(clientResult, clientEngine);
+ cTOs.flip();
+ dumpByteBuffer("CLIENT-TO-SERVER", cTOs);
+
+ // Server consumes Client Hello
+ serverResult = serverEngine.unwrap(cTOs, serverIn);
+ log("server unwrap: ", serverResult);
+ runDelegatedTasks(serverResult, serverEngine);
+ cTOs.compact();
+
+ // Server generates ServerHello/Cert/Done record
+ serverResult = serverEngine.wrap(serverOut, sTOc);
+ log("server wrap: ", serverResult);
+ runDelegatedTasks(serverResult, serverEngine);
+ sTOc.flip();
+
+ // Intercept the ServerHello messages and instead send
+ // one that has a 64-byte session ID.
+ if (isTlsMessage(sTOc, TLS_RECTYPE_HANDSHAKE,
+ TLS_HS_SERVER_HELLO)) {
+ ArrayList<ByteBuffer> recList = splitRecord(sTOc);
+
+ // Use the original ServerHello as a template to craft one
+ // with a longer-than-allowed session ID.
+ ByteBuffer servHelloBuf =
+ createEvilServerHello(recList.get(0), 64);
+
+ recList.set(0, servHelloBuf);
+
+ // Now send each ByteBuffer (each being a complete
+ // TLS record) into the client-side unwrap.
+ for (ByteBuffer bBuf : recList) {
+ dumpByteBuffer("SERVER-TO-CLIENT", bBuf);
+ try {
+ clientResult = clientEngine.unwrap(bBuf, clientIn);
+ } catch (SSLProtocolException e) {
+ log("Received expected SSLProtocolException: " + e);
+ gotException = true;
+ }
+ log("client unwrap: ", clientResult);
+ runDelegatedTasks(clientResult, clientEngine);
+ }
+ } else {
+ dumpByteBuffer("SERVER-TO-CLIENT", sTOc);
+ log("client unwrap: ", clientResult);
+ runDelegatedTasks(clientResult, clientEngine);
+ }
+ sTOc.compact();
+
+ // The Client should now send a TLS Alert
+ clientResult = clientEngine.wrap(clientOut, cTOs);
+ log("client wrap: ", clientResult);
+ runDelegatedTasks(clientResult, clientEngine);
+ cTOs.flip();
+ dumpByteBuffer("CLIENT-TO-SERVER", cTOs);
+
+ // At this point we can verify that both an exception
+ // was thrown and the proper action (a TLS alert) was
+ // sent back to the server.
+ if (gotException == false ||
+ !isTlsMessage(cTOs, TLS_RECTYPE_ALERT, TLS_ALERT_LVL_FATAL,
+ TLS_ALERT_INTERNAL_ERROR)) {
+ throw new SSLException(
+ "Client failed to throw Alert:fatal:internal_error");
+ }
+ }
+ };
+
+ public final HandshakeTest clientSendLongID = new HandshakeTest() {
+ @Override
+ public void execTest() throws Exception {
+ boolean gotException = false;
+ SSLEngineResult clientResult; // results from client's last op
+ SSLEngineResult serverResult; // results from server's last op
+
+ log("\n==== Test: Server receives 64-byte session ID ====");
+
+ // Send Client Hello
+ ByteBuffer evilClientHello = createEvilClientHello(64);
+ dumpByteBuffer("CLIENT-TO-SERVER", evilClientHello);
+
+ try {
+ // Server consumes Client Hello
+ serverResult = serverEngine.unwrap(evilClientHello, serverIn);
+ log("server unwrap: ", serverResult);
+ runDelegatedTasks(serverResult, serverEngine);
+ evilClientHello.compact();
+
+ // Under normal circumstances this should be a ServerHello
+ // But should throw an exception instead due to the invalid
+ // session ID.
+ serverResult = serverEngine.wrap(serverOut, sTOc);
+ log("server wrap: ", serverResult);
+ runDelegatedTasks(serverResult, serverEngine);
+ sTOc.flip();
+ dumpByteBuffer("SERVER-TO-CLIENT", sTOc);
+ } catch (SSLProtocolException ssle) {
+ log("Received expected SSLProtocolException: " + ssle);
+ gotException = true;
+ }
+
+ // We expect to see the server generate an alert here
+ serverResult = serverEngine.wrap(serverOut, sTOc);
+ log("server wrap: ", serverResult);
+ runDelegatedTasks(serverResult, serverEngine);
+ sTOc.flip();
+ dumpByteBuffer("SERVER-TO-CLIENT", sTOc);
+
+ // At this point we can verify that both an exception
+ // was thrown and the proper action (a TLS alert) was
+ // sent back to the client.
+ if (gotException == false ||
+ !isTlsMessage(sTOc, TLS_RECTYPE_ALERT, TLS_ALERT_LVL_FATAL,
+ TLS_ALERT_INTERNAL_ERROR)) {
+ throw new SSLException(
+ "Server failed to throw Alert:fatal:internal_error");
+ }
+ }
+ };
+
+
+ /*
+ * Main entry point for this test.
+ */
+ public static void main(String args[]) throws Exception {
+ List<LengthCheckTest> ccsTests = new ArrayList<>();
+
+ if (debug) {
+ System.setProperty("javax.net.debug", "ssl");
+ }
+
+ ccsTests.add(new LengthCheckTest("ServSendLongID"));
+ ccsTests.add(new LengthCheckTest("ClientSendLongID"));
+
+ for (LengthCheckTest test : ccsTests) {
+ test.runTest();
+ }
+
+ System.out.println("Test Passed.");
+ }
+
+ /*
+ * Create an initialized SSLContext to use for these tests.
+ */
+ public LengthCheckTest(String testName) 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("TLS");
+
+ sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+ sslc = sslCtx;
+
+ switch (testName) {
+ case "ServSendLongID":
+ handshakeTest = servSendLongID;
+ break;
+ case "ClientSendLongID":
+ handshakeTest = clientSendLongID;
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown test name: " +
+ testName);
+ }
+ }
+
+ /*
+ * Run the test.
+ *
+ * Sit in a tight loop, both engines calling wrap/unwrap regardless
+ * of whether data is available or not. We do this until both engines
+ * report back they are closed.
+ *
+ * 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() throws Exception {
+ boolean dataDone = false;
+
+ createSSLEngines();
+ createBuffers();
+
+ handshakeTest.execTest();
+ }
+
+ /*
+ * Using the SSLContext created during object creation,
+ * create/configure the SSLEngines we'll use for this test.
+ */
+ private void createSSLEngines() throws Exception {
+ /*
+ * Configure the serverEngine to act as a server in the SSL/TLS
+ * handshake. Also, require SSL client authentication.
+ */
+ serverEngine = sslc.createSSLEngine();
+ serverEngine.setUseClientMode(false);
+ serverEngine.setNeedClientAuth(false);
+
+ /*
+ * Similar to above, but using client mode instead.
+ */
+ clientEngine = sslc.createSSLEngine("client", 80);
+ clientEngine.setUseClientMode(true);
+
+ // In order to make a test that will be backwards compatible
+ // going back to JDK 5, force the handshake to be TLS 1.0 and
+ // use one of the older cipher suites.
+ clientEngine.setEnabledProtocols(new String[]{"TLSv1"});
+ clientEngine.setEnabledCipherSuites(
+ new String[]{"TLS_RSA_WITH_AES_128_CBC_SHA"});
+ }
+
+ /*
+ * Create and size the buffers appropriately.
+ */
+ private void createBuffers() {
+
+ /*
+ * We'll assume the buffer sizes are the same
+ * between client and server.
+ */
+ SSLSession session = clientEngine.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.
+ */
+ clientIn = ByteBuffer.allocate(appBufferMax + 50);
+ serverIn = ByteBuffer.allocate(appBufferMax + 50);
+
+ cTOs = ByteBuffer.allocateDirect(netBufferMax);
+ sTOc = ByteBuffer.allocateDirect(netBufferMax);
+
+ clientOut = ByteBuffer.wrap("Hi Server, I'm Client".getBytes());
+ serverOut = ByteBuffer.wrap("Hello Client, I'm Server".getBytes());
+ }
+
+ /*
+ * 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());
+ }
+
+ /*
+ * Simple check to make sure everything came across as expected.
+ */
+ private static void checkTransfer(ByteBuffer a, ByteBuffer b)
+ throws Exception {
+ a.flip();
+ b.flip();
+
+ if (!a.equals(b)) {
+ throw new Exception("Data didn't transfer cleanly");
+ } else {
+ log("\tData transferred cleanly");
+ }
+
+ a.position(a.limit());
+ b.position(b.limit());
+ a.limit(a.capacity());
+ b.limit(b.capacity());
+ }
+
+ /*
+ * 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);
+ }
+ }
+
+ /**
+ * Split a record consisting of multiple TLS handshake messages
+ * into individual TLS records, each one in a ByteBuffer of its own.
+ *
+ * @param tlsRecord A ByteBuffer containing the tls record data.
+ * The position of the buffer should be at the first byte
+ * in the TLS record data.
+ *
+ * @return An ArrayList consisting of one or more ByteBuffers. Each
+ * ByteBuffer will contain a single TLS record with one message.
+ * That message will be taken from the input record. The order
+ * of the messages in the ArrayList will be the same as they
+ * were in the input record.
+ */
+ private ArrayList<ByteBuffer> splitRecord(ByteBuffer tlsRecord) {
+ SSLSession session = clientEngine.getSession();
+ int netBufferMax = session.getPacketBufferSize();
+ ArrayList<ByteBuffer> recordList = new ArrayList<>();
+
+ if (tlsRecord.hasRemaining()) {
+ int type = Byte.toUnsignedInt(tlsRecord.get());
+ byte ver_major = tlsRecord.get();
+ byte ver_minor = tlsRecord.get();
+ int recLen = Short.toUnsignedInt(tlsRecord.getShort());
+ byte[] newMsgData = null;
+ while (tlsRecord.hasRemaining()) {
+ ByteBuffer newRecord = ByteBuffer.allocateDirect(netBufferMax);
+ switch (type) {
+ case TLS_RECTYPE_CCS:
+ case TLS_RECTYPE_ALERT:
+ case TLS_RECTYPE_APPDATA:
+ // None of our tests have multiple non-handshake
+ // messages coalesced into a single record.
+ break;
+ case TLS_RECTYPE_HANDSHAKE:
+ newMsgData = getHandshakeMessage(tlsRecord);
+ break;
+ }
+
+ // Put a new TLS record on the destination ByteBuffer
+ newRecord.put((byte)type);
+ newRecord.put(ver_major);
+ newRecord.put(ver_minor);
+ newRecord.putShort((short)newMsgData.length);
+
+ // Now add the message content itself and attach to the
+ // returned ArrayList
+ newRecord.put(newMsgData);
+ newRecord.flip();
+ recordList.add(newRecord);
+ }
+ }
+
+ return recordList;
+ }
+
+ private static ByteBuffer createEvilClientHello(int sessIdLen) {
+ ByteBuffer newRecord = ByteBuffer.allocateDirect(4096);
+
+ // Lengths will initially be place holders until we determine the
+ // finished length of the ByteBuffer. Then we'll go back and scribble
+ // in the correct lengths.
+
+ newRecord.put((byte)TLS_RECTYPE_HANDSHAKE); // Record type
+ newRecord.putShort((short)0x0301); // Protocol (TLS 1.0)
+ newRecord.putShort((short)0); // Length place holder
+
+ newRecord.putInt(TLS_HS_CLIENT_HELLO << 24); // HS type and length
+ newRecord.putShort((short)0x0301);
+ newRecord.putInt((int)(System.currentTimeMillis() / 1000));
+ SecureRandom sr = new SecureRandom();
+ byte[] randBuf = new byte[28];
+ sr.nextBytes(randBuf);
+ newRecord.put(randBuf); // Client Random
+ newRecord.put((byte)sessIdLen); // Session ID length
+ if (sessIdLen > 0) {
+ byte[] sessId = new byte[sessIdLen];
+ sr.nextBytes(sessId);
+ newRecord.put(sessId); // Session ID
+ }
+ newRecord.putShort((short)2); // 2 bytes of ciphers
+ newRecord.putShort((short)0x002F); // TLS_RSA_AES_CBC_SHA
+ newRecord.putShort((short)0x0100); // only null compression
+ newRecord.putShort((short)5); // 5 bytes of extensions
+ newRecord.putShort((short)0xFF01); // Renegotiation info
+ newRecord.putShort((short)1);
+ newRecord.put((byte)0); // No reneg info exts
+
+ // Go back and fill in the correct length values for the record
+ // and handshake message headers.
+ int recordLength = newRecord.position();
+ newRecord.putShort(3, (short)(recordLength - 5));
+ int newTypeAndLen = (newRecord.getInt(5) & 0xFF000000) |
+ ((recordLength - 9) & 0x00FFFFFF);
+ newRecord.putInt(5, newTypeAndLen);
+
+ newRecord.flip();
+ return newRecord;
+ }
+
+ private static ByteBuffer createEvilServerHello(ByteBuffer origHello,
+ int newSessIdLen) {
+ if (newSessIdLen < 0 || newSessIdLen > Byte.MAX_VALUE) {
+ throw new RuntimeException("Length must be 0 <= X <= 127");
+ }
+
+ ByteBuffer newRecord = ByteBuffer.allocateDirect(4096);
+ // Copy the bytes from the old hello to the new up to the session ID
+ // field. We will go back later and fill in a new length field in
+ // the record header. This includes the record header (5 bytes), the
+ // Handshake message header (4 bytes), protocol version (2 bytes),
+ // and the random (32 bytes).
+ ByteBuffer scratchBuffer = origHello.slice();
+ scratchBuffer.limit(43);
+ newRecord.put(scratchBuffer);
+
+ // Advance the position in the originial hello buffer past the
+ // session ID.
+ origHello.position(43);
+ int origIDLen = Byte.toUnsignedInt(origHello.get());
+ if (origIDLen > 0) {
+ // Skip over the session ID
+ origHello.position(origHello.position() + origIDLen);
+ }
+
+ // Now add our own sessionID to the new record
+ SecureRandom sr = new SecureRandom();
+ byte[] sessId = new byte[newSessIdLen];
+ sr.nextBytes(sessId);
+ newRecord.put((byte)newSessIdLen);
+ newRecord.put(sessId);
+
+ // Create another slice in the original buffer, based on the position
+ // past the session ID. Copy the remaining bytes into the new
+ // hello buffer. Then go back and fix up the length
+ newRecord.put(origHello.slice());
+
+ // Go back and fill in the correct length values for the record
+ // and handshake message headers.
+ int recordLength = newRecord.position();
+ newRecord.putShort(3, (short)(recordLength - 5));
+ int newTypeAndLen = (newRecord.getInt(5) & 0xFF000000) |
+ ((recordLength - 9) & 0x00FFFFFF);
+ newRecord.putInt(5, newTypeAndLen);
+
+ newRecord.flip();
+ return newRecord;
+ }
+
+ /**
+ * Look at an incoming TLS record and see if it is the desired
+ * record type, and where appropriate the correct subtype.
+ *
+ * @param srcRecord The input TLS record to be evaluated. This
+ * method will only look at the leading message if multiple
+ * TLS handshake messages are coalesced into a single record.
+ * @param reqRecType The requested TLS record type
+ * @param recParams Zero or more integer sub type fields. For CCS
+ * and ApplicationData, no params are used. For handshake records,
+ * one value corresponding to the HandshakeType is required.
+ * For Alerts, two values corresponding to AlertLevel and
+ * AlertDescription are necessary.
+ *
+ * @return true if the proper handshake message is the first one
+ * in the input record, false otherwise.
+ */
+ private boolean isTlsMessage(ByteBuffer srcRecord, int reqRecType,
+ int... recParams) {
+ boolean foundMsg = false;
+
+ if (srcRecord.hasRemaining()) {
+ srcRecord.mark();
+
+ // Grab the fields from the TLS Record
+ int recordType = Byte.toUnsignedInt(srcRecord.get());
+ byte ver_major = srcRecord.get();
+ byte ver_minor = srcRecord.get();
+ int recLen = Short.toUnsignedInt(srcRecord.getShort());
+
+ if (recordType == reqRecType) {
+ // For any zero-length recParams, making sure the requested
+ // type is sufficient.
+ if (recParams.length == 0) {
+ foundMsg = true;
+ } else {
+ switch (recordType) {
+ case TLS_RECTYPE_CCS:
+ case TLS_RECTYPE_APPDATA:
+ // We really shouldn't find ourselves here, but
+ // if someone asked for these types and had more
+ // recParams we can ignore them.
+ foundMsg = true;
+ break;
+ case TLS_RECTYPE_ALERT:
+ // Needs two params, AlertLevel and AlertDescription
+ if (recParams.length != 2) {
+ throw new RuntimeException(
+ "Test for Alert requires level and desc.");
+ } else {
+ int level = Byte.toUnsignedInt(srcRecord.get());
+ int desc = Byte.toUnsignedInt(srcRecord.get());
+ if (level == recParams[0] &&
+ desc == recParams[1]) {
+ foundMsg = true;
+ }
+ }
+ break;
+ case TLS_RECTYPE_HANDSHAKE:
+ // Needs one parameter, HandshakeType
+ if (recParams.length != 1) {
+ throw new RuntimeException(
+ "Test for Handshake requires only HS type");
+ } else {
+ // Go into the first handhshake message in the
+ // record and grab the handshake message header.
+ // All we need to do is parse out the leading
+ // byte.
+ int msgHdr = srcRecord.getInt();
+ int msgType = (msgHdr >> 24) & 0x000000FF;
+ if (msgType == recParams[0]) {
+ foundMsg = true;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ srcRecord.reset();
+ }
+
+ return foundMsg;
+ }
+
+ private byte[] getHandshakeMessage(ByteBuffer srcRecord) {
+ // At the start of this routine, the position should be lined up
+ // at the first byte of a handshake message. Mark this location
+ // so we can return to it after reading the type and length.
+ srcRecord.mark();
+ int msgHdr = srcRecord.getInt();
+ int type = (msgHdr >> 24) & 0x000000FF;
+ int length = msgHdr & 0x00FFFFFF;
+
+ // Create a byte array that has enough space for the handshake
+ // message header and body.
+ byte[] data = new byte[length + 4];
+ srcRecord.reset();
+ srcRecord.get(data, 0, length + 4);
+
+ return (data);
+ }
+
+ /**
+ * Hex-dumps a ByteBuffer to stdout.
+ */
+ private static void dumpByteBuffer(String header, ByteBuffer bBuf) {
+ if (dumpBufs == false) {
+ return;
+ }
+
+ int bufLen = bBuf.remaining();
+ if (bufLen > 0) {
+ bBuf.mark();
+
+ // We expect the position of the buffer to be at the
+ // beginning of a TLS record. Get the type, version and length.
+ int type = Byte.toUnsignedInt(bBuf.get());
+ int ver_major = Byte.toUnsignedInt(bBuf.get());
+ int ver_minor = Byte.toUnsignedInt(bBuf.get());
+ int recLen = Short.toUnsignedInt(bBuf.getShort());
+ ProtocolVersion pv = ProtocolVersion.valueOf(ver_major, ver_minor);
+
+ log("===== " + header + " (" + tlsRecType(type) + " / " +
+ pv + " / " + bufLen + " bytes) =====");
+ bBuf.reset();
+ for (int i = 0; i < bufLen; i++) {
+ if (i != 0 && i % 16 == 0) {
+ System.out.print("\n");
+ }
+ System.out.format("%02X ", bBuf.get(i));
+ }
+ log("\n===============================================");
+ bBuf.reset();
+ }
+ }
+
+ private static String tlsRecType(int type) {
+ switch (type) {
+ case 20:
+ return "Change Cipher Spec";
+ case 21:
+ return "Alert";
+ case 22:
+ return "Handshake";
+ case 23:
+ return "Application Data";
+ default:
+ return ("Unknown (" + type + ")");
+ }
+ }
+}
diff --git a/test/sun/text/resources/Format/Bug8074791.java b/test/sun/text/resources/Format/Bug8074791.java
new file mode 100644
index 0000000..138158c
--- /dev/null
+++ b/test/sun/text/resources/Format/Bug8074791.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8074791
+ * @summary Make sure that Finnish month names are correct in formatted text.
+ */
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import static java.text.DateFormat.*;
+import static java.util.Calendar.JANUARY;
+
+public class Bug8074791 {
+ private static Locale FINNISH = new Locale("fi");
+ private static String JAN_FORMAT = "tammikuuta";
+ private static String JAN_STANDALONE = "tammikuu";
+
+ public static void main(String[] arg) {
+ int errors = 0;
+
+ DateFormat df = DateFormat.getDateInstance(LONG, FINNISH);
+ Date jan20 = new GregorianCalendar(2015, JANUARY, 20).getTime();
+ String str = df.format(jan20).toString();
+ // Extract the month name (locale data dependent)
+ String month = str.replaceAll(".+\\s([a-z]+)\\s\\d+$", "$1");
+ if (!month.equals(JAN_FORMAT)) {
+ errors++;
+ System.err.println("wrong format month name: got '" + month
+ + "', expected '" + JAN_FORMAT + "'");
+ }
+
+ SimpleDateFormat sdf = new SimpleDateFormat("LLLL", FINNISH); // stand-alone month name
+ month = sdf.format(jan20);
+ if (!month.equals(JAN_STANDALONE)) {
+ errors++;
+ System.err.println("wrong stand-alone month name: got '" + month
+ + "', expected '" + JAN_STANDALONE + "'");
+ }
+
+ if (errors > 0) {
+ throw new RuntimeException();
+ }
+ }
+}
diff --git a/test/sun/text/resources/LocaleData b/test/sun/text/resources/LocaleData
index f6439c2..c20ae59 100644
--- a/test/sun/text/resources/LocaleData
+++ b/test/sun/text/resources/LocaleData
@@ -8276,3 +8276,9 @@
FormatData/zh/MonthNarrows/10=11
FormatData/zh/MonthNarrows/11=12
FormatData/zh/MonthNarrows/12=
+
+# bug #8074791
+FormatData/fi/DatePatterns/0=d. MMMM yyyy
+FormatData/fi/DatePatterns/1=d. MMMM yyyy
+FormatData/fi/DatePatterns/2=d.M.yyyy
+FormatData/fi/DatePatterns/3=d.M.yyyy
diff --git a/test/sun/text/resources/LocaleDataTest.java b/test/sun/text/resources/LocaleDataTest.java
index 6ac5dc5..27d7e3a 100644
--- a/test/sun/text/resources/LocaleDataTest.java
+++ b/test/sun/text/resources/LocaleDataTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
* 6919624 6998391 7019267 7020960 7025837 7020583 7036905 7066203 7101495
* 7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509
* 7114053 7074882 7040556 8013836 8021121 6192407 6931564 8027695 7090826
- * 8017142 8037343 8055222 8042126
+ * 8017142 8037343 8055222 8042126 8074791
* @summary Verify locale data
*
*/