Mercurial > hg > openjdk > aarch64-port > jdk
changeset 10682:f31bbaa095ff
Merge
author | lana |
---|---|
date | Thu, 12 Mar 2015 13:46:10 -0700 |
parents | e48ca20d8943 (current diff) a810f93ace76 (diff) |
children | 293cb6865e64 |
files | |
diffstat | 18 files changed, 653 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/src/macosx/classes/com/apple/laf/AquaMenuUI.java Wed Mar 11 14:11:01 2015 -0700 +++ b/src/macosx/classes/com/apple/laf/AquaMenuUI.java Thu Mar 12 13:46:10 2015 -0700 @@ -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); + } } } }
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Wed Mar 11 14:11:01 2015 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Mar 12 13:46:10 2015 -0700 @@ -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();
--- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Mar 11 14:11:01 2015 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Thu Mar 12 13:46:10 2015 -0700 @@ -833,7 +833,7 @@ /** * Just spin a single empty block synchronously. */ - private static native void flushNativeSelectors(); + static native void flushNativeSelectors(); @Override public Clipboard createPlatformClipboard() {
--- a/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m Wed Mar 11 14:11:01 2015 -0700 +++ b/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m Thu Mar 12 13:46:10 2015 -0700 @@ -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];
--- a/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java Wed Mar 11 14:11:01 2015 -0700 +++ b/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java Thu Mar 12 13:46:10 2015 -0700 @@ -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();
--- a/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java Wed Mar 11 14:11:01 2015 -0700 +++ b/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java Thu Mar 12 13:46:10 2015 -0700 @@ -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; + } }
--- a/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java Wed Mar 11 14:11:01 2015 -0700 +++ b/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java Thu Mar 12 13:46:10 2015 -0700 @@ -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); } }
--- a/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java Wed Mar 11 14:11:01 2015 -0700 +++ b/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java Thu Mar 12 13:46:10 2015 -0700 @@ -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;
--- a/src/share/classes/sun/text/resources/fi/FormatData_fi.java Wed Mar 11 14:11:01 2015 -0700 +++ b/src/share/classes/sun/text/resources/fi/FormatData_fi.java Thu Mar 12 13:46:10 2015 -0700 @@ -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 }
--- a/src/share/native/sun/tracing/dtrace/JVM.c Wed Mar 11 14:11:01 2015 -0700 +++ b/src/share/native/sun/tracing/dtrace/JVM.c Thu Mar 12 13:46:10 2015 -0700 @@ -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]);
--- a/test/com/sun/jdi/InterfaceMethodsTest.java Wed Mar 11 14:11:01 2015 -0700 +++ b/test/com/sun/jdi/InterfaceMethodsTest.java Thu Mar 12 13:46:10 2015 -0700 @@ -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);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Frame/MaximizedNormalBoundsUndecoratedTest/MaximizedNormalBoundsUndecoratedTest.java Thu Mar 12 13:46:10 2015 -0700 @@ -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; + } +}
--- a/test/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java Wed Mar 11 14:11:01 2015 -0700 +++ b/test/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java Thu Mar 12 13:46:10 2015 -0700 @@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/invoke/lambda/LambdaStackTrace.java Thu Mar 12 13:46:10 2015 -0700 @@ -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"); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JMenu/8072900/WrongSelectionOnMouseOver.java Thu Mar 12 13:46:10 2015 -0700 @@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/text/resources/Format/Bug8074791.java Thu Mar 12 13:46:10 2015 -0700 @@ -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(); + } + } +}
--- a/test/sun/text/resources/LocaleData Wed Mar 11 14:11:01 2015 -0700 +++ b/test/sun/text/resources/LocaleData Thu Mar 12 13:46:10 2015 -0700 @@ -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
--- a/test/sun/text/resources/LocaleDataTest.java Wed Mar 11 14:11:01 2015 -0700 +++ b/test/sun/text/resources/LocaleDataTest.java Thu Mar 12 13:46:10 2015 -0700 @@ -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 * */