changeset 5862:356ff53c9b6d

Merge
author lana
date Fri, 14 Sep 2012 10:14:02 -0700
parents 22d7a9f73a59 472145010fcc
children 92f3cda88d8e
files test/java/lang/invoke/MaxTest.java
diffstat 108 files changed, 3377 insertions(+), 891 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Fri Sep 14 09:47:14 2012 -0700
+++ b/.hgtags	Fri Sep 14 10:14:02 2012 -0700
@@ -176,3 +176,5 @@
 e8569a473cee7f4955bd9e76a9bdf6c6a07ced27 jdk8-b52
 2c6933c5106b81a8578b70996fe5b735fb3adb60 jdk8-b53
 70ad0ed1d6cef0e7712690d1bab21e4769708aad jdk8-b54
+1f3f4b333341873f00da3dee85e4879f0e89c9bb jdk8-b55
+2e9eeef2909b33c9224a024afddb61ccb0b77f14 jdk8-b56
--- a/make/common/Defs.gmk	Fri Sep 14 09:47:14 2012 -0700
+++ b/make/common/Defs.gmk	Fri Sep 14 10:14:02 2012 -0700
@@ -542,6 +542,21 @@
 CXXFLAGS_$(VARIANT)/BYFILE  = $(CXXFLAGS_$(VARIANT)/$(@F)) \
                               $(CXXFLAGS_$(VARIANT)$(CXXFLAGS_$(VARIANT)/$(@F)))
 
+# Command line define to provide basename of file being compiled to source.
+#   The C macro THIS_FILE can replace the use of __FILE__ in the source
+#   files for the current filename being compiled.
+#   The value of the __FILE__ macro is unpredictable and can be anything
+#   from a relative path to a full path, THIS_FILE will be more consistent..
+#   The THIS_FILE macro will always be just the basename of the file being
+#   compiled.
+#   Different string literals in the the object files makes it difficult to
+#   compare shared libraries from different builds.
+#
+#   NOTE: If the THIS_FILE macro is actually expanded while in an included
+#         source file, it will not return the name of the included file.
+#
+CPP_THIS_FILE = -DTHIS_FILE='"$(<F)"'
+
 #
 # Tool flags
 #
@@ -551,7 +566,7 @@
 CFLAGS          = $(CFLAGS_$(VARIANT)/BYFILE)   $(CFLAGS_COMMON) $(OTHER_CFLAGS) $(EXTRA_CFLAGS)
 CXXFLAGS        = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS) $(EXTRA_CFLAGS)
 CPPFLAGS        = $(CPPFLAGS_$(VARIANT)) $(CPPFLAGS_COMMON) $(OTHER_CPPFLAGS) \
-		  $(DEFINES) $(OPTIONS:%=-D%)
+		  $(DEFINES) $(OPTIONS:%=-D%) $(CPP_THIS_FILE)
 LDFLAGS         = $(LDFLAGS_$(VARIANT)) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS)
 LDLIBS          = $(OTHER_LDLIBS) $(LDLIBS_$(VARIANT)) $(LDLIBS_COMMON)
 LINTFLAGS       = $(LINTFLAGS_$(VARIANT)) $(LINTFLAGS_COMMON) \
--- a/make/common/Demo.gmk	Fri Sep 14 09:47:14 2012 -0700
+++ b/make/common/Demo.gmk	Fri Sep 14 10:14:02 2012 -0700
@@ -320,10 +320,10 @@
   ifeq ($(PLATFORM),windows)
 	$(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(DEMO_VERSION_INFO) $(VERSIONINFO_RESOURCE)
 	$(LINK.demo) $(SHARED_LIBRARY_FLAG) -Fe$@ \
-	    $(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
+	    $(sort $(DEMO_FULL_OBJECTS)) $(LDLIBS.demo)
   else
 	$(LINK.demo) $(SHARED_LIBRARY_FLAG) -o $@ \
-	    $(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
+	    $(sort $(DEMO_FULL_OBJECTS)) $(LDLIBS.demo)
   endif
 	@$(call binary_file_verification,$@)
 
--- a/make/common/Library.gmk	Fri Sep 14 09:47:14 2012 -0700
+++ b/make/common/Library.gmk	Fri Sep 14 10:14:02 2012 -0700
@@ -199,7 +199,7 @@
 $(OBJDIR)/$(LIBRARY).lcf: $(OBJDIR)/$(LIBRARY).res $(COMPILE_FILES_o) $(FILES_m)
 	@$(prep-target)
 	@$(MKDIR) -p $(TEMPDIR)
-	@$(ECHO) $(FILES_o) > $@ 
+	@$(ECHO) $(sort $(FILES_o)) > $@ 
 ifndef LOCAL_RESOURCE_FILE
 	@$(ECHO) $(OBJDIR)/$(LIBRARY).res >> $@
 endif
@@ -256,9 +256,9 @@
 	@$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), OPTIMIZATION_LEVEL=$(OPTIMIZATION_LEVEL)"
 	@$(ECHO) "Rebuilding $@ because of $?"
 ifeq ($(LIBRARY), fdlibm)
-	$(AR) $(ARFLAGS) $@ $(FILES_o)
+	$(AR) $(ARFLAGS) $@ $(sort $(FILES_o))
 else # LIBRARY
-	$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS)
+	$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(sort $(FILES_o)) $(LDLIBS)
 	@$(call binary_file_verification,$@)
 ifeq ($(WRITE_LIBVERSION),true)
 	$(MCS) -d -a "$(FULL_VERSION)" $@
--- a/make/common/Program.gmk	Fri Sep 14 09:47:14 2012 -0700
+++ b/make/common/Program.gmk	Fri Sep 14 10:14:02 2012 -0700
@@ -262,7 +262,7 @@
 	$(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
 	@$(MKDIR) -p $(TEMPDIR)
 	$(LINK_PRE_CMD) $(CC) $(CC_OBJECT_OUTPUT_FLAG)$@ $(LDFLAGS) \
-	$(FILES_o) $(THREADLIBS) $(LDLIBS)
+	$(sort $(FILES_o)) $(THREADLIBS) $(LDLIBS)
   ifeq ($(findstring privileged, $(INFO_PLIST_FILE)), privileged)
 	-codesign -s openjdk_codesign $@
   endif
@@ -392,8 +392,6 @@
 VERSION_DEFINES += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
                    -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"'
 
-
-
 $(OBJDIR)/main.$(OBJECT_SUFFIX): $(LAUNCHER_SHARE_SRC)/bin/main.c
 	@$(prep-target)
 	$(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$(OBJDIR)/main.$(OBJECT_SUFFIX) \
--- a/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Fri Sep 14 10:14:02 2012 -0700
@@ -40,6 +40,7 @@
 import java.awt.peer.ComponentPeer;
 import java.awt.peer.ContainerPeer;
 
+import java.awt.peer.KeyboardFocusManagerPeer;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.lang.reflect.Field;
 import java.security.AccessController;
@@ -894,15 +895,15 @@
                             ", focusedWindowChangeAllowed=" + focusedWindowChangeAllowed +
                             ", time= " + time + ", cause=" + cause);
         }
-        if (LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
-                processSynchronousLightweightTransfer(getTarget(), lightweightChild, temporary,
-                        focusedWindowChangeAllowed, time)) {
+        if (LWKeyboardFocusManagerPeer.processSynchronousLightweightTransfer(
+                getTarget(), lightweightChild, temporary,
+                focusedWindowChangeAllowed, time)) {
             return true;
         }
 
-        int result = LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
-                shouldNativelyFocusHeavyweight(getTarget(), lightweightChild, temporary,
-                        focusedWindowChangeAllowed, time, cause);
+        int result = LWKeyboardFocusManagerPeer.shouldNativelyFocusHeavyweight(
+                getTarget(), lightweightChild, temporary,
+                focusedWindowChangeAllowed, time, cause);
         switch (result) {
             case LWKeyboardFocusManagerPeer.SNFH_FAILURE:
                 return false;
@@ -951,14 +952,13 @@
                     return false;
                 }
 
-                LWComponentPeer focusOwnerPeer =
-                    LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
-                        getFocusOwner();
-                Component focusOwner = (focusOwnerPeer != null) ? focusOwnerPeer.getTarget() : null;
+                KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
+                Component focusOwner = kfmPeer.getCurrentFocusOwner();
                 return LWKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                         getTarget(), temporary,
                         focusedWindowChangeAllowed,
                         time, cause, focusOwner);
+
             case LWKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
                 return true;
         }
@@ -1251,9 +1251,6 @@
 
         if (!target.isFocusOwner() && LWKeyboardFocusManagerPeer.shouldFocusOnClick(target)) {
             LWKeyboardFocusManagerPeer.requestFocusFor(target, CausedFocusEvent.Cause.MOUSE_EVENT);
-        } else {
-            // Anyway request focus to the toplevel.
-            getWindowPeerOrSelf().requestWindowFocus(CausedFocusEvent.Cause.MOUSE_EVENT);
         }
     }
 
@@ -1263,8 +1260,8 @@
     protected void handleJavaFocusEvent(FocusEvent e) {
         // Note that the peer receives all the FocusEvents from
         // its lightweight children as well
-        LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
-                setFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? this : null);
+        KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
+        kfmPeer.setCurrentFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? getTarget() : null);
     }
 
     /**
--- a/src/macosx/classes/sun/lwawt/LWKeyboardFocusManagerPeer.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/classes/sun/lwawt/LWKeyboardFocusManagerPeer.java	Fri Sep 14 10:14:02 2012 -0700
@@ -26,85 +26,47 @@
 package sun.lwawt;
 
 import java.awt.Component;
-import java.awt.KeyboardFocusManager;
 import java.awt.Window;
-
-import java.util.Map;
-import java.util.HashMap;
-
-import sun.awt.AWTAccessor;
-import sun.awt.AppContext;
 import sun.awt.KeyboardFocusManagerPeerImpl;
 
 public class LWKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
+    private static final LWKeyboardFocusManagerPeer inst = new LWKeyboardFocusManagerPeer();
 
-    private Object lock = new Object();
-    private LWWindowPeer focusedWindow;
-    private LWComponentPeer focusOwner;
+    private Window focusedWindow;
+    private Component focusOwner;
 
-    private static Map<KeyboardFocusManager, LWKeyboardFocusManagerPeer> instances =
-        new HashMap<KeyboardFocusManager, LWKeyboardFocusManagerPeer>();
-
-    public static synchronized LWKeyboardFocusManagerPeer getInstance(AppContext ctx) {
-        return getInstance(AWTAccessor.getKeyboardFocusManagerAccessor().
-                           getCurrentKeyboardFocusManager(ctx));
+    public static LWKeyboardFocusManagerPeer getInstance() {
+        return inst;
     }
 
-    public static synchronized LWKeyboardFocusManagerPeer getInstance(KeyboardFocusManager manager) {
-        LWKeyboardFocusManagerPeer instance = instances.get(manager);
-        if (instance == null) {
-            instance = new LWKeyboardFocusManagerPeer(manager);
-            instances.put(manager, instance);
-        }
-        return instance;
+    private LWKeyboardFocusManagerPeer() {
     }
 
-    public LWKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
-        super(manager);
+    @Override
+    public void setCurrentFocusedWindow(Window win) {
+        synchronized (this) {
+            focusedWindow = win;
+        }
     }
 
     @Override
     public Window getCurrentFocusedWindow() {
-        synchronized (lock) {
-            return (focusedWindow != null) ? (Window)focusedWindow.getTarget() : null;
+        synchronized (this) {
+            return focusedWindow;
         }
     }
 
     @Override
     public Component getCurrentFocusOwner() {
-        synchronized (lock) {
-            return (focusOwner != null) ? focusOwner.getTarget() : null;
+        synchronized (this) {
+            return focusOwner;
         }
     }
 
     @Override
     public void setCurrentFocusOwner(Component comp) {
-        synchronized (lock) {
-            focusOwner = (comp != null) ? (LWComponentPeer)comp.getPeer() : null;
-        }
-    }
-
-    void setFocusedWindow(LWWindowPeer peer) {
-        synchronized (lock) {
-            focusedWindow = peer;
-        }
-    }
-
-    LWWindowPeer getFocusedWindow() {
-        synchronized (lock) {
-            return focusedWindow;
-        }
-    }
-
-    void setFocusOwner(LWComponentPeer peer) {
-        synchronized (lock) {
-            focusOwner = peer;
-        }
-    }
-
-    LWComponentPeer getFocusOwner() {
-        synchronized (lock) {
-            return focusOwner;
+        synchronized (this) {
+            focusOwner = comp;
         }
     }
 }
--- a/src/macosx/classes/sun/lwawt/LWToolkit.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/classes/sun/lwawt/LWToolkit.java	Fri Sep 14 10:14:02 2012 -0700
@@ -415,8 +415,8 @@
     }
 
     @Override
-    public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
-        return LWKeyboardFocusManagerPeer.getInstance(manager);
+    public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
+        return LWKeyboardFocusManagerPeer.getInstance();
     }
 
     @Override
--- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Fri Sep 14 10:14:02 2012 -0700
@@ -88,10 +88,16 @@
 
     private volatile int windowState = Frame.NORMAL;
 
+    // check that the mouse is over the window
+    private volatile boolean isMouseOver = false;
+
+    // A peer where the last mouse event came to. Used by cursor manager to
+    // find the component under cursor
+    private static volatile LWComponentPeer lastCommonMouseEventPeer = null;
+
     // A peer where the last mouse event came to. Used to generate
-    // MOUSE_ENTERED/EXITED notifications and by cursor manager to
-    // find the component under cursor
-    private static volatile LWComponentPeer lastMouseEventPeer = null;
+    // MOUSE_ENTERED/EXITED notifications
+    private volatile LWComponentPeer lastMouseEventPeer;
 
     // Peers where all dragged/released events should come to,
     // depending on what mouse button is being dragged according to Cocoa
@@ -232,8 +238,7 @@
         // TODO: update graphicsConfig, see 4868278
         platformWindow.setVisible(visible);
         if (isSimpleWindow()) {
-            LWKeyboardFocusManagerPeer manager = LWKeyboardFocusManagerPeer.
-                getInstance(getAppContext());
+            KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
 
             if (visible) {
                 if (!getTarget().isAutoRequestFocus()) {
@@ -242,7 +247,7 @@
                     requestWindowFocus(CausedFocusEvent.Cause.ACTIVATION);
                 }
             // Focus the owner in case this window is focused.
-            } else if (manager.getCurrentFocusedWindow() == getTarget()) {
+            } else if (kfmPeer.getCurrentFocusedWindow() == getTarget()) {
                 // Transfer focus to the owner.
                 LWWindowPeer owner = getOwnerFrameDialog(LWWindowPeer.this);
                 if (owner != null) {
@@ -707,66 +712,65 @@
         Rectangle r = getBounds();
         // findPeerAt() expects parent coordinates
         LWComponentPeer targetPeer = findPeerAt(r.x + x, r.y + y);
-        LWWindowPeer lastWindowPeer =
-            (lastMouseEventPeer != null) ? lastMouseEventPeer.getWindowPeerOrSelf() : null;
-        LWWindowPeer curWindowPeer =
-            (targetPeer != null) ? targetPeer.getWindowPeerOrSelf() : null;
 
         if (id == MouseEvent.MOUSE_EXITED) {
-            // Sometimes we may get MOUSE_EXITED after lastMouseEventPeer is switched
-            // to a peer from another window. So we must first check if this peer is
-            // the same as lastWindowPeer
-            if (lastWindowPeer == this) {
-                if (isEnabled()) {
+            isMouseOver = false;
+            if (lastMouseEventPeer != null) {
+                if (lastMouseEventPeer.isEnabled()) {
                     Point lp = lastMouseEventPeer.windowToLocal(x, y,
-                                                                lastWindowPeer);
+                            this);
                     postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
-                                             MouseEvent.MOUSE_EXITED, when,
-                                             modifiers, lp.x, lp.y, screenX,
-                                             screenY, clickCount, popupTrigger,
-                                             button));
+                            MouseEvent.MOUSE_EXITED, when,
+                            modifiers, lp.x, lp.y, screenX,
+                            screenY, clickCount, popupTrigger,
+                            button));
+                }
+
+                // Sometimes we may get MOUSE_EXITED after lastCommonMouseEventPeer is switched
+                // to a peer from another window. So we must first check if this peer is
+                // the same as lastWindowPeer
+                if (lastCommonMouseEventPeer != null && lastCommonMouseEventPeer.getWindowPeerOrSelf() == this) {
+                    lastCommonMouseEventPeer = null;
                 }
                 lastMouseEventPeer = null;
             }
-        } else {
-            if (targetPeer != lastMouseEventPeer) {
-
-                if (id != MouseEvent.MOUSE_DRAGGED || lastMouseEventPeer == null) {
-                    // lastMouseEventPeer may be null if mouse was out of Java windows
-                    if (lastMouseEventPeer != null && lastMouseEventPeer.isEnabled()) {
-                        // Sometimes, MOUSE_EXITED is not sent by delegate (or is sent a bit
-                        // later), in which case lastWindowPeer is another window
-                        if (lastWindowPeer != this) {
-                            Point oldp = lastMouseEventPeer.windowToLocal(x, y, lastWindowPeer);
-                            // Additionally translate from this to lastWindowPeer coordinates
-                            Rectangle lr = lastWindowPeer.getBounds();
-                            oldp.x += r.x - lr.x;
-                            oldp.y += r.y - lr.y;
-                            postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
-                                                     MouseEvent.MOUSE_EXITED,
-                                                     when, modifiers,
-                                                     oldp.x, oldp.y, screenX, screenY,
-                                                     clickCount, popupTrigger, button));
-                        } else {
-                            Point oldp = lastMouseEventPeer.windowToLocal(x, y, this);
-                            postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
-                                                     MouseEvent.MOUSE_EXITED,
-                                                     when, modifiers,
-                                                     oldp.x, oldp.y, screenX, screenY,
-                                                     clickCount, popupTrigger, button));
-                        }
-                    }
-                    if (targetPeer != null && targetPeer.isEnabled() && id != MouseEvent.MOUSE_ENTERED) {
-                        Point newp = targetPeer.windowToLocal(x, y, curWindowPeer);
+        } else if(id == MouseEvent.MOUSE_ENTERED) {
+            isMouseOver = true;
+            if (targetPeer != null) {
+                if (targetPeer.isEnabled()) {
+                    Point lp = targetPeer.windowToLocal(x, y, this);
                         postEvent(new MouseEvent(targetPeer.getTarget(),
-                                                 MouseEvent.MOUSE_ENTERED,
-                                                 when, modifiers,
-                                                 newp.x, newp.y, screenX, screenY,
-                                                 clickCount, popupTrigger, button));
-                    }
+                            MouseEvent.MOUSE_ENTERED, when,
+                            modifiers, lp.x, lp.y, screenX,
+                            screenY, clickCount, popupTrigger,
+                            button));
                 }
+                lastCommonMouseEventPeer = targetPeer;
                 lastMouseEventPeer = targetPeer;
             }
+        } else {
+            PlatformWindow topmostPlatforWindow =
+                    platformWindow.getTopmostPlatformWindowUnderMouse();
+
+            LWWindowPeer topmostWindowPeer =
+                    topmostPlatforWindow != null ? topmostPlatforWindow.getPeer() : null;
+
+            // topmostWindowPeer == null condition is added for the backward
+            // compatibility with applets. It can be removed when the
+            // getTopmostPlatformWindowUnderMouse() method will be properly
+            // implemented in CPlatformEmbeddedFrame class
+            if (topmostWindowPeer == this || topmostWindowPeer == null) {
+                generateMouseEnterExitEventsForComponents(when, button, x, y,
+                        screenX, screenY, modifiers, clickCount, popupTrigger,
+                        targetPeer);
+            } else {
+                LWComponentPeer topmostTargetPeer =
+                        topmostWindowPeer != null ? topmostWindowPeer.findPeerAt(r.x + x, r.y + y) : null;
+                topmostWindowPeer.generateMouseEnterExitEventsForComponents(when, button, x, y,
+                        screenX, screenY, modifiers, clickCount, popupTrigger,
+                        topmostTargetPeer);
+            }
+
             // TODO: fill "bdata" member of AWTEvent
 
             int eventButtonMask = (button > 0)? MouseEvent.getMaskForButton(button) : 0;
@@ -794,6 +798,14 @@
                     mouseClickButtons |= eventButtonMask;
                 }
 
+                // The window should be focused on mouse click. If it gets activated by the native platform,
+                // this request will be no op. It will take effect when:
+                // 1. A simple not focused window is clicked.
+                // 2. An active but not focused owner frame/dialog is clicked.
+                // The mouse event then will trigger a focus request "in window" to the component, so the window
+                // should gain focus before.
+                requestWindowFocus(CausedFocusEvent.Cause.MOUSE_EVENT);
+
                 mouseDownTarget[targetIdx] = targetPeer;
             } else if (id == MouseEvent.MOUSE_DRAGGED) {
                 // Cocoa dragged event has the information about which mouse
@@ -816,19 +828,13 @@
                 // mouseClickButtons is updated below, after MOUSE_CLICK is sent
             }
 
-            // check if we receive mouseEvent from outside the window's bounds
-            // it can be either mouseDragged or mouseReleased
-            if (curWindowPeer == null) {
-                //TODO This can happen if this window is invisible. this is correct behavior in this case?
-                curWindowPeer = this;
-            }
             if (targetPeer == null) {
                 //TODO This can happen if this window is invisible. this is correct behavior in this case?
                 targetPeer = this;
             }
 
 
-            Point lp = targetPeer.windowToLocal(x, y, curWindowPeer);
+            Point lp = targetPeer.windowToLocal(x, y, this);
             if (targetPeer.isEnabled()) {
                 MouseEvent event = new MouseEvent(targetPeer.getTarget(), id,
                                                   when, modifiers, lp.x, lp.y,
@@ -852,6 +858,38 @@
         notifyUpdateCursor();
     }
 
+    private void generateMouseEnterExitEventsForComponents(long when,
+            int button, int x, int y, int screenX, int screenY,
+            int modifiers, int clickCount, boolean popupTrigger,
+            LWComponentPeer targetPeer) {
+
+        if (!isMouseOver || targetPeer == lastMouseEventPeer) {
+            return;
+        }
+
+        // Generate Mouse Exit for components
+        if (lastMouseEventPeer != null && lastMouseEventPeer.isEnabled()) {
+            Point oldp = lastMouseEventPeer.windowToLocal(x, y, this);
+            postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
+                    MouseEvent.MOUSE_EXITED,
+                    when, modifiers,
+                    oldp.x, oldp.y, screenX, screenY,
+                    clickCount, popupTrigger, button));
+        }
+        lastCommonMouseEventPeer = targetPeer;
+        lastMouseEventPeer = targetPeer;
+
+        // Generate Mouse Enter for components
+        if (targetPeer != null && targetPeer.isEnabled()) {
+            Point newp = targetPeer.windowToLocal(x, y, this);
+            postEvent(new MouseEvent(targetPeer.getTarget(),
+                    MouseEvent.MOUSE_ENTERED,
+                    when, modifiers,
+                    newp.x, newp.y, screenX, screenY,
+                    clickCount, popupTrigger, button));
+        }
+    }
+
     public void dispatchMouseWheelEvent(long when, int x, int y, int modifiers,
                                         int scrollType, int scrollAmount,
                                         int wheelRotation, double preciseWheelRotation,
@@ -884,20 +922,16 @@
     public void dispatchKeyEvent(int id, long when, int modifiers,
                                  int keyCode, char keyChar, int keyLocation)
     {
-        LWComponentPeer focusOwner =
-            LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
-                getFocusOwner();
+        LWKeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
+        Component focusOwner = kfmPeer.getCurrentFocusOwner();
 
-        // Null focus owner may receive key event when
-        // application hides the focused window upon ESC press
-        // (AWT transfers/clears the focus owner) and pending ESC release
-        // may come to already hidden window. This check eliminates NPE.
-        if (focusOwner != null) {
-            KeyEvent event =
-                new KeyEvent(focusOwner.getTarget(), id, when, modifiers,
-                             keyCode, keyChar, keyLocation);
-            focusOwner.postEvent(event);
+        if (focusOwner == null) {
+            focusOwner = kfmPeer.getCurrentFocusedWindow();
+            if (focusOwner == null) {
+                focusOwner = this.getTarget();
+            }
         }
+        postEvent(new KeyEvent(focusOwner, id, when, modifiers, keyCode, keyChar, keyLocation));
     }
 
 
@@ -1096,11 +1130,11 @@
     }
 
     public static LWWindowPeer getWindowUnderCursor() {
-        return lastMouseEventPeer != null ? lastMouseEventPeer.getWindowPeerOrSelf() : null;
+        return lastCommonMouseEventPeer != null ? lastCommonMouseEventPeer.getWindowPeerOrSelf() : null;
     }
 
     public static LWComponentPeer<?, ?> getPeerUnderCursor() {
-        return lastMouseEventPeer;
+        return lastCommonMouseEventPeer;
     }
 
     /*
@@ -1213,10 +1247,8 @@
             }
         }
 
-        LWKeyboardFocusManagerPeer manager = LWKeyboardFocusManagerPeer.
-            getInstance(getAppContext());
-
-        Window oppositeWindow = becomesFocused ? manager.getCurrentFocusedWindow() : null;
+        KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
+        Window oppositeWindow = becomesFocused ? kfmPeer.getCurrentFocusedWindow() : null;
 
         // Note, the method is not called:
         // - when the opposite (gaining focus) window is an owned/owner window.
@@ -1229,10 +1261,10 @@
             grabbingWindow.ungrab();
         }
 
-        manager.setFocusedWindow(becomesFocused ? LWWindowPeer.this : null);
+        kfmPeer.setCurrentFocusedWindow(becomesFocused ? getTarget() : null);
 
         int eventID = becomesFocused ? WindowEvent.WINDOW_GAINED_FOCUS : WindowEvent.WINDOW_LOST_FOCUS;
-        WindowEvent windowEvent = new WindowEvent(getTarget(), eventID, oppositeWindow);
+        WindowEvent windowEvent = new TimedWindowEvent(getTarget(), eventID, oppositeWindow, System.currentTimeMillis());
 
         // TODO: wrap in SequencedEvent
         postEvent(windowEvent);
--- a/src/macosx/classes/sun/lwawt/PlatformWindow.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/classes/sun/lwawt/PlatformWindow.java	Fri Sep 14 10:14:02 2012 -0700
@@ -118,6 +118,8 @@
 
     public void setAlwaysOnTop(boolean value);
 
+    public PlatformWindow getTopmostPlatformWindowUnderMouse();
+
     public void updateFocusableWindowState();
 
     public boolean rejectFocusRequest(CausedFocusEvent.Cause cause);
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java	Fri Sep 14 10:14:02 2012 -0700
@@ -151,6 +151,10 @@
     @Override
     public void setAlwaysOnTop(boolean value) {}
 
+    // This method should be properly implemented for applets.
+    // It returns null just as a stub.
+    public PlatformWindow getTopmostPlatformWindowUnderMouse() { return null; }
+
     @Override
     public void updateFocusableWindowState() {}
 
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Fri Sep 14 10:14:02 2012 -0700
@@ -61,8 +61,9 @@
     private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename);
     private static native void nativeSetNSWindowSecurityWarningPositioning(long nsWindowPtr, double x, double y, float biasX, float biasY);
     private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
-    private static native void nativeSynthesizeMouseEnteredExitedEvents(long nsWindowPtr);
+    private static native void nativeSynthesizeMouseEnteredExitedEvents();
     private static native void nativeDispose(long nsWindowPtr);
+    private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
 
     private static native int nativeGetNSWindowDisplayID_AppKitThread(long nsWindowPtr);
 
@@ -588,7 +589,7 @@
             }
         }
 
-        nativeSynthesizeMouseEnteredExitedEvents(nsWindowPtr);
+        nativeSynthesizeMouseEnteredExitedEvents();
 
         // Configure stuff #2
         updateFocusabilityForAutoRequestFocus(true);
@@ -729,6 +730,10 @@
         setStyleBits(ALWAYS_ON_TOP, isAlwaysOnTop);
     }
 
+    public PlatformWindow getTopmostPlatformWindowUnderMouse(){
+        return CPlatformWindow.nativeGetTopmostPlatformWindowUnderMouse();
+    }
+
     @Override
     public void setOpacity(float opacity) {
         CWrapper.NSWindow.setAlphaValue(getNSWindowPtr(), opacity);
@@ -803,7 +808,7 @@
                 throw new RuntimeException("Unknown window state: " + windowState);
         }
 
-        nativeSynthesizeMouseEnteredExitedEvents(nsWindowPtr);
+        nativeSynthesizeMouseEnteredExitedEvents();
 
         // NOTE: the SWP.windowState field gets updated to the newWindowState
         //       value when the native notification comes to us
--- a/src/macosx/native/com/apple/laf/ScreenMenu.m	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/native/com/apple/laf/ScreenMenu.m	Fri Sep 14 10:14:02 2012 -0700
@@ -37,7 +37,11 @@
 #import "ThreadUtilities.h"
 #import "CMenuBar.h"
 
-
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__     
+#endif 
+ 
 static JNF_CLASS_CACHE(sjc_ScreenMenu, "com/apple/laf/ScreenMenu");
 
 static jint ns2awtModifiers(NSUInteger keyMods) {
@@ -97,7 +101,7 @@
 {
     if (self.javaObjectWrapper == nil) {
 #ifdef DEBUG
-        NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
+        NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
 #endif
         return;
     }
@@ -115,7 +119,7 @@
 {
     if (self.javaObjectWrapper == nil) {
 #ifdef DEBUG
-        NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
+        NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
 #endif
         return;
     }
@@ -133,7 +137,7 @@
 {
     if (self.javaObjectWrapper == nil) {
 #ifdef DEBUG
-        NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
+        NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
 #endif
         return;
     }
--- a/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiOut.c	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiOut.c	Fri Sep 14 10:14:02 2012 -0700
@@ -26,6 +26,11 @@
 //#define USE_ERROR
 //#define USE_TRACE
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #if USE_PLATFORM_MIDI_OUT == TRUE
 
 #include "PLATFORM_API_MacOSX_MidiUtils.h"
@@ -128,7 +133,7 @@
                 case 0xF7:
                     // System exclusive
                     fprintf(stderr, "%s: %d->internal error: sysex message status=0x%X while sending short message\n",
-                            __FILE__, __LINE__, data[0]);
+                            THIS_FILE, __LINE__, data[0]);
                     byteIsInvalid = TRUE;
                     break;
 
@@ -154,7 +159,7 @@
                 default:
                     // Invalid message
                     fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n",
-                            __FILE__, __LINE__, data[0]);
+                            THIS_FILE, __LINE__, data[0]);
                     byteIsInvalid = TRUE;
                     break;
             }
@@ -164,7 +169,7 @@
         default:
             // This can't happen, but handle it anyway.
             fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n",
-                    __FILE__, __LINE__, data[0]);
+                    THIS_FILE, __LINE__, data[0]);
             byteIsInvalid = TRUE;
             break;
     }
--- a/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiUtils.c	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiUtils.c	Fri Sep 14 10:14:02 2012 -0700
@@ -42,6 +42,11 @@
 //#define USE_ERROR
 //#define USE_TRACE
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #if (USE_PLATFORM_MIDI_IN == TRUE) || (USE_PLATFORM_MIDI_OUT == TRUE)
 
 #include "PLATFORM_API_MacOSX_MidiUtils.h"
@@ -317,7 +322,7 @@
                             packedMsg = pendingMessageStatus | pendingData[0] << 8;
                         } else {
                             fprintf(stderr, "%s: %d->internal error: pendingMessageStatus=0x%X, pendingDataLength=%d\n",
-                                    __FILE__, __LINE__, pendingMessageStatus, pendingDataLength);
+                                    THIS_FILE, __LINE__, pendingMessageStatus, pendingDataLength);
                             byteIsInvalid = TRUE;
                         }
                         pendingDataLength = 0;
--- a/src/macosx/native/sun/awt/AWTView.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/native/sun/awt/AWTView.h	Fri Sep 14 10:14:02 2012 -0700
@@ -33,8 +33,8 @@
 @private
     jobject m_cPlatformView;
 
-    // Handler for the tracking rect needed for Enter/Exit events management.
-    NSTrackingRectTag rolloverTrackingRectTag;
+    // Handler for the tracking area needed for Enter/Exit events management.
+    NSTrackingArea* rolloverTrackingArea;
 
     // TODO: NSMenu *contextualMenu;
 
@@ -61,7 +61,7 @@
 
 - (id) initWithRect:(NSRect) rect platformView:(jobject)cPlatformView windowLayer:(CALayer*)windowLayer;
 - (void) deliverJavaMouseEvent: (NSEvent *) event;
-- (void) resetTrackingRect;
+- (void) resetTrackingArea;
 - (void) deliverJavaKeyEventHelper: (NSEvent *) event;
 - (jobject) awtComponent:(JNIEnv *)env;
 
--- a/src/macosx/native/sun/awt/AWTView.m	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/native/sun/awt/AWTView.m	Fri Sep 14 10:14:02 2012 -0700
@@ -82,6 +82,7 @@
     fPAHNeedsToSelect = NO;
 
     mouseIsOver = NO;
+    [self resetTrackingArea];
 
     if (windowLayer != nil) {
         self.cglLayer = windowLayer;
@@ -146,7 +147,7 @@
         [[self window] makeFirstResponder: self];
     }];
     if ([self window] != NULL) {
-        [self resetTrackingRect];
+        [self resetTrackingArea];
     }
 }
 
@@ -368,30 +369,31 @@
     JNFCallVoidMethod(env, m_cPlatformView, jm_deliverMouseEvent, jEvent);
 }
 
+- (void) resetTrackingArea {
+    if (rolloverTrackingArea != nil) {
+        [self removeTrackingArea:rolloverTrackingArea];
+        [rolloverTrackingArea release];
+    }
 
-- (void) clearTrackingRect {
-    if (rolloverTrackingRectTag > 0) {
-        [self removeTrackingRect:rolloverTrackingRectTag];
-        rolloverTrackingRectTag = 0;
-    }
-}
+    int options = (NSTrackingActiveInActiveApp | NSTrackingMouseEnteredAndExited |
+                   NSTrackingMouseMoved | NSTrackingEnabledDuringMouseDrag);
 
-- (void) resetTrackingRect {
-    [self clearTrackingRect];
-    rolloverTrackingRectTag = [self addTrackingRect:[self visibleRect]
-                                              owner:self
-                                           userData:NULL
-                                       assumeInside:NO];
+    rolloverTrackingArea = [[NSTrackingArea alloc] initWithRect:[self visibleRect]
+                                                        options: options
+                                                          owner:self
+                                                       userInfo:nil
+                            ];
+    [self addTrackingArea:rolloverTrackingArea];
 }
 
 - (void)updateTrackingAreas {
     [super updateTrackingAreas];
-    [self resetTrackingRect];
+    [self resetTrackingArea];
 }
 
 - (void) resetCursorRects {
     [super resetCursorRects];
-    [self resetTrackingRect];
+    [self resetTrackingArea];
 }
 
 -(void) deliverJavaKeyEventHelper: (NSEvent *) event {
@@ -402,7 +404,7 @@
     }
     [sLastKeyEvent release];
     sLastKeyEvent = [event retain];
-	
+
     [AWTToolkit eventCountPlusPlus];
     JNIEnv *env = [ThreadUtilities getJNIEnv];
 
--- a/src/macosx/native/sun/awt/AWTWindow.m	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/native/sun/awt/AWTWindow.m	Fri Sep 14 10:14:02 2012 -0700
@@ -238,10 +238,12 @@
     return self;
 }
 
-// checks that this window is under the mouse cursor and this point is not overlapped by others windows
-- (BOOL) isTopmostWindowUnderMouse {
++ (BOOL) isAWTWindow:(NSWindow *)window {
+    return [window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]];
+}
 
-    int currentWinID = [self.nsWindow windowNumber];
+// returns id for the topmost window under mouse
++ (NSInteger) getTopmostWindowUnderMouseID {
 
     NSRect screenRect = [[NSScreen mainScreen] frame];
     NSPoint nsMouseLocation = [NSEvent mouseLocation];
@@ -249,53 +251,77 @@
 
     NSMutableArray *windows = (NSMutableArray *)CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID);
 
-
     for (NSDictionary *window in windows) {
-        int layer = [[window objectForKey:(id)kCGWindowLayer] intValue];
+        NSInteger layer = [[window objectForKey:(id)kCGWindowLayer] integerValue];
         if (layer == 0) {
-            int winID = [[window objectForKey:(id)kCGWindowNumber] intValue];
             CGRect rect;
             CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:(id)kCGWindowBounds], &rect);
             if (CGRectContainsPoint(rect, cgMouseLocation)) {
-                return currentWinID == winID;
-            } else if (currentWinID == winID) {
-                return NO;
+                return [[window objectForKey:(id)kCGWindowNumber] integerValue];
             }
         }
     }
-    return NO;
+    return -1;
 }
 
-- (void) synthesizeMouseEnteredExitedEvents {
+// checks that this window is under the mouse cursor and this point is not overlapped by others windows
+- (BOOL) isTopmostWindowUnderMouse {
+    return [self.nsWindow windowNumber] == [AWTWindow getTopmostWindowUnderMouseID];
+}
 
-    int eventType = 0;
-    BOOL isUnderMouse = [self isTopmostWindowUnderMouse];
-    BOOL mouseIsOver = [[self.nsWindow contentView] mouseIsOver];
++ (AWTWindow *) getTopmostWindowUnderMouse {
+    NSEnumerator *windowEnumerator = [[NSApp windows] objectEnumerator];
+    NSWindow *window;
 
-    if (isUnderMouse && !mouseIsOver) {
-        eventType = NSMouseEntered;
-    } else if (!isUnderMouse && mouseIsOver) {
-        eventType = NSMouseExited;
-    } else {
-        return;
+    NSInteger topmostWindowUnderMouseID = [AWTWindow getTopmostWindowUnderMouseID];
+
+    while ((window = [windowEnumerator nextObject]) != nil) {
+        if ([window windowNumber] == topmostWindowUnderMouseID) {
+            BOOL isAWTWindow = [AWTWindow isAWTWindow: window];
+            return isAWTWindow ? (AWTWindow *) [window delegate] : nil;
+        }
     }
+    return nil;
+}
+
++ (void) synthesizeMouseEnteredExitedEvents:(NSWindow*)window withType:(NSEventType)eventType {
 
     NSPoint screenLocation = [NSEvent mouseLocation];
-    NSPoint windowLocation = [self.nsWindow convertScreenToBase: screenLocation];
+    NSPoint windowLocation = [window convertScreenToBase: screenLocation];
     int modifierFlags = (eventType == NSMouseEntered) ? NSMouseEnteredMask : NSMouseExitedMask;
 
     NSEvent *mouseEvent = [NSEvent enterExitEventWithType: eventType
-                                                  location: windowLocation
-                                             modifierFlags: modifierFlags
-                                                 timestamp: 0
-                                              windowNumber: [self.nsWindow windowNumber]
-                                                   context: nil
-                                               eventNumber: 0
-                                            trackingNumber: 0
-                                                  userData: nil
-                            ];
+                                                 location: windowLocation
+                                            modifierFlags: modifierFlags
+                                                timestamp: 0
+                                             windowNumber: [window windowNumber]
+                                                  context: nil
+                                              eventNumber: 0
+                                           trackingNumber: 0
+                                                 userData: nil
+                           ];
 
-    [[self.nsWindow contentView] deliverJavaMouseEvent: mouseEvent];
+    [[window contentView] deliverJavaMouseEvent: mouseEvent];
+}
+
++ (void) synthesizeMouseEnteredExitedEventsForAllWindows {
+
+    NSInteger topmostWindowUnderMouseID = [AWTWindow getTopmostWindowUnderMouseID];
+    NSArray *windows = [NSApp windows];
+    NSWindow *window;
+
+    NSEnumerator *windowEnumerator = [windows objectEnumerator];
+    while ((window = [windowEnumerator nextObject]) != nil) {
+        if ([AWTWindow isAWTWindow: window]) {
+            BOOL isUnderMouse = ([window windowNumber] == topmostWindowUnderMouseID);
+            BOOL mouseIsOver = [[window contentView] mouseIsOver];
+            if (isUnderMouse && !mouseIsOver) {
+                [AWTWindow synthesizeMouseEnteredExitedEvents:window withType:NSMouseEntered];
+            } else if (!isUnderMouse && mouseIsOver) {
+                [AWTWindow synthesizeMouseEnteredExitedEvents:window withType:NSMouseExited];
+            }
+        }
+    }
 }
 
 - (void) dealloc {
@@ -825,7 +851,7 @@
         // (this will also re-enable screen updates, which were disabled above)
         // TODO: send PaintEvent
 
-        [window synthesizeMouseEnteredExitedEvents];
+        [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows];
     }];
 
 JNF_COCOA_EXIT(env);
@@ -1040,22 +1066,42 @@
 
 /*
  * Class:     sun_lwawt_macosx_CPlatformWindow
+ * Method:    nativeGetTopmostPlatformWindowUnderMouse
+ * Signature: (J)V
+ */
+JNIEXPORT jobject
+JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetTopmostPlatformWindowUnderMouse
+(JNIEnv *env, jclass clazz)
+{
+    jobject topmostWindowUnderMouse = nil;
+
+    JNF_COCOA_ENTER(env);
+    AWT_ASSERT_APPKIT_THREAD;
+
+    AWTWindow *awtWindow = [AWTWindow getTopmostWindowUnderMouse];
+    if (awtWindow != nil) {
+        topmostWindowUnderMouse = [awtWindow.javaPlatformWindow jObject];
+    }
+
+    JNF_COCOA_EXIT(env);
+
+    return topmostWindowUnderMouse;
+}
+
+/*
+ * Class:     sun_lwawt_macosx_CPlatformWindow
  * Method:    nativeSynthesizeMouseEnteredExitedEvents
  * Signature: (J)V
  */
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents
-(JNIEnv *env, jclass clazz, jlong windowPtr)
+(JNIEnv *env, jclass clazz)
 {
     JNF_COCOA_ENTER(env);
     AWT_ASSERT_NOT_APPKIT_THREAD;
 
-    NSWindow *nsWindow = OBJC(windowPtr);
     [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
         AWT_ASSERT_APPKIT_THREAD;
-
-        AWTWindow *window = (AWTWindow*)[nsWindow delegate];
-
-        [window synthesizeMouseEnteredExitedEvents];
+        [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows];
     }];
 
     JNF_COCOA_EXIT(env);
--- a/src/macosx/native/sun/awt/CSystemColors.m	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/native/sun/awt/CSystemColors.m	Fri Sep 14 10:14:02 2012 -0700
@@ -33,6 +33,11 @@
 
 #import "ThreadUtilities.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 NSColor **sColors = nil;
 NSColor **appleColors = nil;
 
@@ -130,7 +135,7 @@
         result = (useAppleColor ? appleColors : sColors)[colorIndex];
     }
     else {
-        NSLog(@"%s: %s %sColor: %ld not found, returning black.", __FILE__, __FUNCTION__, (useAppleColor) ? "Apple" : "System", colorIndex);
+        NSLog(@"%s: %s %sColor: %ld not found, returning black.", THIS_FILE, __FUNCTION__, (useAppleColor) ? "Apple" : "System", colorIndex);
         result = [NSColor blackColor];
     }
 
--- a/src/macosx/native/sun/awt/CTextPipe.m	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/native/sun/awt/CTextPipe.m	Fri Sep 14 10:14:02 2012 -0700
@@ -36,6 +36,10 @@
 #import "QuartzSurfaceData.h"
 #include "AWTStrike.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
 
 static const CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
 
@@ -488,7 +492,7 @@
         if (glyphs == NULL || advances == NULL)
         {
             (*env)->DeleteLocalRef(env, glyphsArray);
-            [NSException raise:NSMallocException format:@"%s-%s:%d", __FILE__, __FUNCTION__, __LINE__];
+            [NSException raise:NSMallocException format:@"%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__];
             return;
         }
 
--- a/src/macosx/native/sun/awt/ImageSurfaceData.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/native/sun/awt/ImageSurfaceData.h	Fri Sep 14 10:14:02 2012 -0700
@@ -41,7 +41,7 @@
 // If there is an image present, this is a no-op
 void makeSureImageIsCreated(ImageSDOps* isdo);
 
-struct _ContextInfo
+typedef struct _ContextInfo
 {
     BOOL                useWindowContextReference;
     BOOL                canUseJavaPixelsAsContext;
@@ -50,10 +50,9 @@
     size_t                bytesPerRow;
     CGImageAlphaInfo    alphaInfo;
     CGColorSpaceRef        colorSpace;
-}
-typedef ContextInfo;
+} ContextInfo;
 
-struct _ImageInfo
+typedef struct _ImageInfo
 {
     size_t                bitsPerComponent;
     size_t                bitsPerPixel;
@@ -61,8 +60,7 @@
     size_t                bytesPerRow;
     CGImageAlphaInfo    alphaInfo;
     CGColorSpaceRef        colorSpace;
-}
-typedef ImageInfo;
+} ImageInfo;
 
 struct _ImageSDOps
 {
--- a/src/macosx/native/sun/awt/ImageSurfaceData.m	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/native/sun/awt/ImageSurfaceData.m	Fri Sep 14 10:14:02 2012 -0700
@@ -53,10 +53,6 @@
 // for vImage framework headers
 #include <Accelerate/Accelerate.h>
 
-
-// private Quartz routines needed here
-CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx);
-
 static ContextInfo sDefaultContextInfo[sun_java2d_OSXOffScreenSurfaceData_TYPE_3BYTE_RGB+1] =
 {
     {YES,    YES,    8,        4,        0,        kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,    NULL},    // TYPE_CUSTOM            // special case
@@ -942,7 +938,6 @@
     // intitalize the context to match the Java coordinate system
 
     // BG, since the context is created above, we can just concat
-    //CGContextSetCTM(qsdo->cgRef, CGAffineTransformMake(1, 0, 0, -1, 0, isdo->height));
     CGContextConcatCTM(qsdo->cgRef, CGAffineTransformMake(1, 0, 0, -1, 0, isdo->height));
 
     CGContextSaveGState(qsdo->cgRef); // this will make sure we don't go pass device context settings
@@ -1114,7 +1109,10 @@
                 if (qsdo->cgRef != NULL)
                 {
                     CGContextSaveGState(qsdo->cgRef);
-                    CGContextSetCTM(qsdo->cgRef, CGAffineTransformMake(1, 0, 0, 1, 0, 0));
+                    CGAffineTransform currCTM = CGContextGetCTM(qsdo->cgRef);
+                    CGAffineTransform inverse = CGAffineTransformInvert(currCTM);
+                    CGContextConcatCTM(qsdo->cgRef, inverse);
+                    CGContextConcatCTM(qsdo->cgRef, CGAffineTransformMake(1, 0, 0, 1, 0, 0));
                     CGContextSetBlendMode(qsdo->cgRef, kCGBlendModeCopy);
                     CGContextSetAlpha(qsdo->cgRef, 1.0f);
                     CGContextDrawImage(qsdo->cgRef, CGRectMake(0, 0, width, height), javaImg);
--- a/src/macosx/native/sun/awt/QuartzRenderer.m	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/native/sun/awt/QuartzRenderer.m	Fri Sep 14 10:14:02 2012 -0700
@@ -50,9 +50,6 @@
 // same value as defined in Sun's own code
 #define XOR_ALPHA_CUTOFF 128
 
-// private Quartz routines needed here
-CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx);
-
 
 static CGFloat gRoundRectCtrlpts[10][12] =
 {
@@ -536,7 +533,7 @@
 
     makeSureImageIsCreated(isdo);
 
-    CGAffineTransform ctm = CGContextGetCTM(cgRef);
+    CGContextSaveGState(cgRef);
     CGContextConcatCTM(cgRef, CGAffineTransformMake(a, b, c, d, tx, ty));
     jint alphaInfo = isdo->contextInfo.alphaInfo & kCGBitmapAlphaInfoMask;
 
@@ -551,7 +548,7 @@
         CGImageRelease(subImg);
     }
 
-    CGContextSetCTM(cgRef, ctm);
+    CGContextRestoreGState(cgRef);
     UnlockImage(env, isdo);
 }
 
--- a/src/macosx/native/sun/awt/QuartzSurfaceData.m	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/native/sun/awt/QuartzSurfaceData.m	Fri Sep 14 10:14:02 2012 -0700
@@ -40,9 +40,6 @@
 #import <AppKit/AppKit.h>
 #import "ThreadUtilities.h"
 
-// private Quartz routines needed here
-CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx);
-
 //#define DEBUG
 #if defined DEBUG
     #define PRINT(msg) {fprintf(stderr, "%s\n", msg);}
@@ -50,9 +47,6 @@
     #define PRINT(msg) {}
 #endif
 
-// from CGAffineTransformPrivate.h
-extern CGPoint CGPointApplyInverseAffineTransform(CGPoint point, CGAffineTransform t);
-
 #define kOffset (0.5f)
 
 BOOL gAdjustForJavaDrawing;
@@ -608,7 +602,8 @@
                 // We need to flip both y coefficeints to flip the offset point into the java coordinate system.
                 ctm.b = -ctm.b; ctm.d = -ctm.d; ctm.tx = 0.0f; ctm.ty = 0.0f;
                 CGPoint offsets = {kOffset, kOffset};
-                offsets = CGPointApplyInverseAffineTransform(offsets, ctm);
+                CGAffineTransform inverse = CGAffineTransformInvert(ctm);
+                offsets = CGPointApplyAffineTransform(offsets, inverse);
                 qsdo->graphicsStateInfo.offsetX = offsets.x;
                 qsdo->graphicsStateInfo.offsetY = offsets.y;
             }
--- a/src/macosx/native/sun/font/AWTStrike.m	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/macosx/native/sun/font/AWTStrike.m	Fri Sep 14 10:14:02 2012 -0700
@@ -33,6 +33,11 @@
 #import "CoreTextSupport.h"
 //#import "jni_util.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 @implementation AWTStrike
 
 static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
@@ -102,7 +107,7 @@
 #define AWT_FONT_CLEANUP_FINISH                                         \
     if (_fontThrowJavaException == YES) {                               \
         char s[512];                                                    \
-        sprintf(s, "%s-%s:%d", __FILE__, __FUNCTION__, __LINE__);       \
+        sprintf(s, "%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__);       \
         [JNFException raise:env as:kRuntimeException reason:s];         \
     }
 
--- a/src/share/back/error_messages.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/back/error_messages.h	Fri Sep 14 10:14:02 2012 -0700
@@ -42,31 +42,36 @@
 const char * eventText(int);
 const char * jdwpErrorText(jdwpError);
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define EXIT_ERROR(error,msg) \
         { \
                 print_message(stderr, "JDWP exit error ", "\n", \
                         "%s(%d): %s [%s:%d]", \
                         jvmtiErrorText((jvmtiError)error), error, (msg==NULL?"":msg), \
-                        __FILE__, __LINE__); \
+                        THIS_FILE, __LINE__); \
                 debugInit_exit((jvmtiError)error, msg); \
         }
 
 #define JDI_ASSERT(expression)  \
 do {                            \
     if (gdata && gdata->assertOn && !(expression)) {            \
-        jdiAssertionFailed(__FILE__, __LINE__, #expression); \
+        jdiAssertionFailed(THIS_FILE, __LINE__, #expression); \
     }                                           \
 } while (0)
 
 #define JDI_ASSERT_MSG(expression, msg)  \
 do {                            \
     if (gdata && gdata->assertOn && !(expression)) {            \
-        jdiAssertionFailed(__FILE__, __LINE__, msg); \
+        jdiAssertionFailed(THIS_FILE, __LINE__, msg); \
     }                                           \
 } while (0)
 
 #define JDI_ASSERT_FAILED(msg)  \
-   jdiAssertionFailed(__FILE__, __LINE__, msg)
+   jdiAssertionFailed(THIS_FILE, __LINE__, msg)
 
 void do_pause(void);
 
--- a/src/share/back/log_messages.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/back/log_messages.h	Fri Sep 14 10:14:02 2012 -0700
@@ -33,11 +33,15 @@
 
 #define LOG_NULL ((void)0)
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #ifdef JDWP_LOGGING
 
-
     #define _LOG(flavor,args) \
-                (log_message_begin(flavor,__FILE__,__LINE__), \
+                (log_message_begin(flavor,THIS_FILE,__LINE__), \
                  log_message_end args)
 
     #define LOG_TEST(flag)  (gdata->log_flags & (flag))
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java	Fri Sep 14 10:14:02 2012 -0700
@@ -30,6 +30,8 @@
 import java.awt.Event;
 import java.awt.KeyEventPostProcessor;
 import java.awt.Window;
+import java.awt.Toolkit;
+import sun.awt.SunToolkit;
 
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
@@ -125,7 +127,19 @@
                 }
                 JMenu menu = mbar != null ? mbar.getMenu(0) : null;
 
-                if (menu != null) {
+                // It might happen that the altRelease event is processed
+                // with a reasonable delay since it has been generated.
+                // Here we check the last deactivation time of the containing
+                // window. If this time appears to be greater than the altRelease
+                // event time the event is skipped to avoid unexpected menu
+                // activation. See 7121442.
+                boolean skip = false;
+                Toolkit tk = Toolkit.getDefaultToolkit();
+                if (tk instanceof SunToolkit) {
+                    skip = ev.getWhen() <= ((SunToolkit)tk).getWindowDeactivationTime(winAncestor);
+                }
+
+                if (menu != null && !skip) {
                     MenuElement[] path = new MenuElement[2];
                     path[0] = mbar;
                     path[1] = menu;
--- a/src/share/classes/java/awt/Component.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/awt/Component.java	Fri Sep 14 10:14:02 2012 -0700
@@ -4710,7 +4710,10 @@
         /*
          * 0. Set timestamp and modifiers of current event.
          */
-        EventQueue.setCurrentEventAndMostRecentTime(e);
+        if (!(e instanceof KeyEvent)) {
+            // Timestamp of a key event is set later in DKFM.preDispatchKeyEvent(KeyEvent).
+            EventQueue.setCurrentEventAndMostRecentTime(e);
+        }
 
         /*
          * 1. Pre-dispatchers. Do any necessary retargeting/reordering here
@@ -7606,13 +7609,33 @@
                                      boolean focusedWindowChangeAllowed,
                                      CausedFocusEvent.Cause cause)
     {
+        // 1) Check if the event being dispatched is a system-generated mouse event.
+        AWTEvent currentEvent = EventQueue.getCurrentEvent();
+        if (currentEvent instanceof MouseEvent &&
+            SunToolkit.isSystemGenerated(currentEvent))
+        {
+            // 2) Sanity check: if the mouse event component source belongs to the same containing window.
+            Component source = ((MouseEvent)currentEvent).getComponent();
+            if (source == null || source.getContainingWindow() == getContainingWindow()) {
+                focusLog.finest("requesting focus by mouse event \"in window\"");
+
+                // If both the conditions are fulfilled the focus request should be strictly
+                // bounded by the toplevel window. It's assumed that the mouse event activates
+                // the window (if it wasn't active) and this makes it possible for a focus
+                // request with a strong in-window requirement to change focus in the bounds
+                // of the toplevel. If, by any means, due to asynchronous nature of the event
+                // dispatching mechanism, the window happens to be natively inactive by the time
+                // this focus request is eventually handled, it should not re-activate the
+                // toplevel. Otherwise the result may not meet user expectations. See 6981400.
+                focusedWindowChangeAllowed = false;
+            }
+        }
         if (!isRequestFocusAccepted(temporary, focusedWindowChangeAllowed, cause)) {
             if (focusLog.isLoggable(PlatformLogger.FINEST)) {
                 focusLog.finest("requestFocus is not accepted");
             }
             return false;
         }
-
         // Update most-recent map
         KeyboardFocusManager.setMostRecentFocusOwner(this);
 
@@ -7645,7 +7668,15 @@
         }
 
         // Focus this Component
-        long time = EventQueue.getMostRecentEventTime();
+        long time = 0;
+        if (EventQueue.isDispatchThread()) {
+            time = Toolkit.getEventQueue().getMostRecentKeyEventTime();
+        } else {
+            // A focus request made from outside EDT should not be associated with any event
+            // and so its time stamp is simply set to the current time.
+            time = System.currentTimeMillis();
+        }
+
         boolean success = peer.requestFocus
             (this, temporary, focusedWindowChangeAllowed, time, cause);
         if (!success) {
--- a/src/share/classes/java/awt/Container.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/awt/Container.java	Fri Sep 14 10:14:02 2012 -0700
@@ -2863,7 +2863,7 @@
 
         // keep the KeyEvents from being dispatched
         // until the focus has been transfered
-        long time = Toolkit.getEventQueue().getMostRecentEventTime();
+        long time = Toolkit.getEventQueue().getMostRecentKeyEventTime();
         Component predictedFocusOwner = (Component.isInstanceOf(this, "javax.swing.JInternalFrame")) ? ((javax.swing.JInternalFrame)(this)).getMostRecentFocusOwner() : null;
         if (predictedFocusOwner != null) {
             KeyboardFocusManager.getCurrentKeyboardFocusManager().
--- a/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Fri Sep 14 10:14:02 2012 -0700
@@ -41,6 +41,7 @@
 import sun.awt.SunToolkit;
 import sun.awt.AWTAccessor;
 import sun.awt.CausedFocusEvent;
+import sun.awt.TimedWindowEvent;
 
 /**
  * The default KeyboardFocusManager for AWT applications. Focus traversal is
@@ -72,8 +73,8 @@
     private WeakReference<Window> realOppositeWindowWR = NULL_WINDOW_WR;
     private WeakReference<Component> realOppositeComponentWR = NULL_COMPONENT_WR;
     private int inSendMessage;
-    private LinkedList enqueuedKeyEvents = new LinkedList(),
-        typeAheadMarkers = new LinkedList();
+    private LinkedList<KeyEvent> enqueuedKeyEvents = new LinkedList<KeyEvent>();
+    private LinkedList<TypeAheadMarker> typeAheadMarkers = new LinkedList<TypeAheadMarker>();
     private boolean consumeNextKeyTyped;
 
     static {
@@ -269,6 +270,31 @@
         return se.dispatched;
     }
 
+    /*
+     * Checks if the focus window event follows key events waiting in the type-ahead
+     * queue (if any). This may happen when a user types ahead in the window, the client
+     * listeners hang EDT for a while, and the user switches b/w toplevels. In that
+     * case the focus window events may be dispatched before the type-ahead events
+     * get handled. This may lead to wrong focus behavior and in order to avoid it,
+     * the focus window events are reposted to the end of the event queue. See 6981400.
+     */
+    private boolean repostIfFollowsKeyEvents(WindowEvent e) {
+        if (!(e instanceof TimedWindowEvent)) {
+            return false;
+        }
+        TimedWindowEvent we = (TimedWindowEvent)e;
+        long time = we.getWhen();
+        synchronized (this) {
+            for (KeyEvent ke: enqueuedKeyEvents) {
+                if (time >= ke.getWhen()) {
+                    SunToolkit.postEvent(AppContext.getAppContext(), new SequencedEvent(e));
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
     /**
      * This method is called by the AWT event dispatcher requesting that the
      * current KeyboardFocusManager dispatch the specified event on its behalf.
@@ -287,6 +313,10 @@
         if (focusLog.isLoggable(PlatformLogger.FINE) && (e instanceof WindowEvent || e instanceof FocusEvent)) focusLog.fine("" + e);
         switch (e.getID()) {
             case WindowEvent.WINDOW_GAINED_FOCUS: {
+                if (repostIfFollowsKeyEvents((WindowEvent)e)) {
+                    break;
+                }
+
                 WindowEvent we = (WindowEvent)e;
                 Window oldFocusedWindow = getGlobalFocusedWindow();
                 Window newFocusedWindow = we.getWindow();
@@ -646,6 +676,10 @@
             }
 
             case WindowEvent.WINDOW_LOST_FOCUS: {
+                if (repostIfFollowsKeyEvents((WindowEvent)e)) {
+                    break;
+                }
+
                 WindowEvent we = (WindowEvent)e;
                 Window currentFocusedWindow = getGlobalFocusedWindow();
                 Window losingFocusWindow = we.getWindow();
@@ -825,10 +859,9 @@
             ke = null;
             synchronized (this) {
                 if (enqueuedKeyEvents.size() != 0) {
-                    ke = (KeyEvent)enqueuedKeyEvents.getFirst();
+                    ke = enqueuedKeyEvents.getFirst();
                     if (typeAheadMarkers.size() != 0) {
-                        TypeAheadMarker marker = (TypeAheadMarker)
-                            typeAheadMarkers.getFirst();
+                        TypeAheadMarker marker = typeAheadMarkers.getFirst();
                         // Fixed 5064013: may appears that the events have the same time
                         // if (ke.getWhen() >= marker.after) {
                         // The fix is rolled out.
@@ -857,9 +890,9 @@
             focusLog.finest(">>> Markers dump, time: {0}", System.currentTimeMillis());
             synchronized (this) {
                 if (typeAheadMarkers.size() != 0) {
-                    Iterator iter = typeAheadMarkers.iterator();
+                    Iterator<TypeAheadMarker> iter = typeAheadMarkers.iterator();
                     while (iter.hasNext()) {
-                        TypeAheadMarker marker = (TypeAheadMarker)iter.next();
+                        TypeAheadMarker marker = iter.next();
                         focusLog.finest("    {0}", marker);
                     }
                 }
@@ -881,8 +914,7 @@
                 KeyEvent ke = (KeyEvent)e;
                 synchronized (this) {
                     if (e.isPosted && typeAheadMarkers.size() != 0) {
-                        TypeAheadMarker marker = (TypeAheadMarker)
-                            typeAheadMarkers.getFirst();
+                        TypeAheadMarker marker = typeAheadMarkers.getFirst();
                         // Fixed 5064013: may appears that the events have the same time
                         // if (ke.getWhen() >= marker.after) {
                         // The fix is rolled out.
@@ -915,12 +947,10 @@
                 synchronized (this) {
                     boolean found = false;
                     if (hasMarker(target)) {
-                        for (Iterator iter = typeAheadMarkers.iterator();
+                        for (Iterator<TypeAheadMarker> iter = typeAheadMarkers.iterator();
                              iter.hasNext(); )
                         {
-                            if (((TypeAheadMarker)iter.next()).untilFocused ==
-                                target)
-                            {
+                            if (iter.next().untilFocused == target) {
                                 found = true;
                             } else if (found) {
                                 break;
@@ -955,8 +985,8 @@
      * @since 1.5
      */
     private boolean hasMarker(Component comp) {
-        for (Iterator iter = typeAheadMarkers.iterator(); iter.hasNext(); ) {
-            if (((TypeAheadMarker)iter.next()).untilFocused == comp) {
+        for (Iterator<TypeAheadMarker> iter = typeAheadMarkers.iterator(); iter.hasNext(); ) {
+            if (iter.next().untilFocused == comp) {
                 return true;
             }
         }
@@ -982,11 +1012,10 @@
             return true;
         }
 
-        // Explicitly set the current event and most recent timestamp here in
-        // addition to the call in Component.dispatchEventImpl. Because
-        // KeyEvents can be delivered in response to a FOCUS_GAINED event, the
-        // current timestamp may be incorrect. We need to set it here so that
-        // KeyEventDispatchers will use the correct time.
+        // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
+        // - A key event is anyway passed to this method which starts its actual dispatching.
+        // - If a key event is put to the type ahead queue, its time stamp should not be registered
+        //   until its dispatching actually starts (by this method).
         EventQueue.setCurrentEventAndMostRecentTime(ke);
 
         /**
@@ -1174,10 +1203,10 @@
 
         int insertionIndex = 0,
             i = typeAheadMarkers.size();
-        ListIterator iter = typeAheadMarkers.listIterator(i);
+        ListIterator<TypeAheadMarker> iter = typeAheadMarkers.listIterator(i);
 
         for (; i > 0; i--) {
-            TypeAheadMarker marker = (TypeAheadMarker)iter.previous();
+            TypeAheadMarker marker = iter.previous();
             if (marker.after <= after) {
                 insertionIndex = i;
                 break;
@@ -1213,12 +1242,12 @@
                        after, untilFocused);
 
         TypeAheadMarker marker;
-        ListIterator iter = typeAheadMarkers.listIterator
+        ListIterator<TypeAheadMarker> iter = typeAheadMarkers.listIterator
             ((after >= 0) ? typeAheadMarkers.size() : 0);
 
         if (after < 0) {
             while (iter.hasNext()) {
-                marker = (TypeAheadMarker)iter.next();
+                marker = iter.next();
                 if (marker.untilFocused == untilFocused)
                 {
                     iter.remove();
@@ -1227,7 +1256,7 @@
             }
         } else {
             while (iter.hasPrevious()) {
-                marker = (TypeAheadMarker)iter.previous();
+                marker = iter.previous();
                 if (marker.untilFocused == untilFocused &&
                     marker.after == after)
                 {
@@ -1255,8 +1284,8 @@
 
         long start = -1;
 
-        for (Iterator iter = typeAheadMarkers.iterator(); iter.hasNext(); ) {
-            TypeAheadMarker marker = (TypeAheadMarker)iter.next();
+        for (Iterator<TypeAheadMarker> iter = typeAheadMarkers.iterator(); iter.hasNext(); ) {
+            TypeAheadMarker marker = iter.next();
             Component toTest = marker.untilFocused;
             boolean match = (toTest == comp);
             while (!match && toTest != null && !(toTest instanceof Window)) {
@@ -1287,8 +1316,8 @@
             return;
         }
 
-        for (Iterator iter = enqueuedKeyEvents.iterator(); iter.hasNext(); ) {
-            KeyEvent ke = (KeyEvent)iter.next();
+        for (Iterator<KeyEvent> iter = enqueuedKeyEvents.iterator(); iter.hasNext(); ) {
+            KeyEvent ke = iter.next();
             long time = ke.getWhen();
 
             if (start < time && (end < 0 || time <= end)) {
--- a/src/share/classes/java/awt/Dialog.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/awt/Dialog.java	Fri Sep 14 10:14:02 2012 -0700
@@ -924,7 +924,7 @@
                     isEnabled() && !isModalBlocked()) {
                     // keep the KeyEvents from being dispatched
                     // until the focus has been transfered
-                    time.set(Toolkit.getEventQueue().getMostRecentEventTimeEx());
+                    time.set(Toolkit.getEventQueue().getMostRecentKeyEventTime());
                     KeyboardFocusManager.getCurrentKeyboardFocusManager().
                         enqueueKeyEvents(time.get(), toFocus);
                 }
--- a/src/share/classes/java/awt/EventQueue.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/awt/EventQueue.java	Fri Sep 14 10:14:02 2012 -0700
@@ -162,6 +162,11 @@
      */
     private long mostRecentEventTime = System.currentTimeMillis();
 
+    /*
+     * The time stamp of the last KeyEvent .
+     */
+    private long mostRecentKeyEventTime = System.currentTimeMillis();
+
     /**
      * The modifiers field of the current event, if the current event is an
      * InputEvent or ActionEvent.
@@ -1142,6 +1147,15 @@
         }
     }
 
+    synchronized long getMostRecentKeyEventTime() {
+        pushPopLock.lock();
+        try {
+            return mostRecentKeyEventTime;
+        } finally {
+            pushPopLock.unlock();
+        }
+    }
+
     static void setCurrentEventAndMostRecentTime(AWTEvent e) {
         Toolkit.getEventQueue().setCurrentEventAndMostRecentTimeImpl(e);
     }
@@ -1166,6 +1180,9 @@
             if (e instanceof InputEvent) {
                 InputEvent ie = (InputEvent)e;
                 mostRecentEventTime2 = ie.getWhen();
+                if (e instanceof KeyEvent) {
+                    mostRecentKeyEventTime = ie.getWhen();
+                }
             } else if (e instanceof InputMethodEvent) {
                 InputMethodEvent ime = (InputMethodEvent)e;
                 mostRecentEventTime2 = ime.getWhen();
--- a/src/share/classes/java/awt/KeyboardFocusManager.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/awt/KeyboardFocusManager.java	Fri Sep 14 10:14:02 2012 -0700
@@ -445,7 +445,7 @@
     private void initPeer() {
         Toolkit tk = Toolkit.getDefaultToolkit();
         KeyboardFocusManagerPeerProvider peerProvider = (KeyboardFocusManagerPeerProvider)tk;
-        peer = peerProvider.createKeyboardFocusManagerPeer(this);
+        peer = peerProvider.getKeyboardFocusManagerPeer();
     }
 
     /**
--- a/src/share/classes/java/awt/SequencedEvent.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/awt/SequencedEvent.java	Fri Sep 14 10:14:02 2012 -0700
@@ -26,6 +26,7 @@
 package java.awt;
 
 import java.util.LinkedList;
+import sun.awt.AWTAccessor;
 import sun.awt.AppContext;
 import sun.awt.SunToolkit;
 
@@ -54,6 +55,17 @@
     private AppContext appContext;
     private boolean disposed;
 
+    static {
+        AWTAccessor.setSequencedEventAccessor(new AWTAccessor.SequencedEventAccessor() {
+            public AWTEvent getNested(AWTEvent sequencedEvent) {
+                return ((SequencedEvent)sequencedEvent).nested;
+            }
+            public boolean isSequencedEvent(AWTEvent event) {
+                return event instanceof SequencedEvent;
+            }
+        });
+    }
+
     /**
      * Constructs a new SequencedEvent which will dispatch the specified
      * nested event.
--- a/src/share/classes/java/awt/peer/KeyboardFocusManagerPeer.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/awt/peer/KeyboardFocusManagerPeer.java	Fri Sep 14 10:14:02 2012 -0700
@@ -34,6 +34,14 @@
 public interface KeyboardFocusManagerPeer {
 
     /**
+     * Sets the window that should become the focused window.
+     *
+     * @param win the window that should become the focused window
+     *
+     */
+    void setCurrentFocusedWindow(Window win);
+
+    /**
      * Returns the currently focused window.
      *
      * @return the currently focused window
--- a/src/share/classes/java/beans/Introspector.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/beans/Introspector.java	Fri Sep 14 10:14:02 2012 -0700
@@ -1460,7 +1460,7 @@
     private PropertyDescriptor[] properties;
     private int defaultProperty;
     private MethodDescriptor[] methods;
-    private final Reference<BeanInfo> targetBeanInfoRef;
+    private Reference<BeanInfo> targetBeanInfoRef;
 
     public GenericBeanInfo(BeanDescriptor beanDescriptor,
                 EventSetDescriptor[] events, int defaultEvent,
@@ -1472,7 +1472,9 @@
         this.properties = properties;
         this.defaultProperty = defaultProperty;
         this.methods = methods;
-        this.targetBeanInfoRef = new SoftReference<>(targetBeanInfo);
+        this.targetBeanInfoRef = (targetBeanInfo != null)
+                ? new SoftReference<>(targetBeanInfo)
+                : null;
     }
 
     /**
@@ -1539,10 +1541,25 @@
     }
 
     public java.awt.Image getIcon(int iconKind) {
-        BeanInfo targetBeanInfo = this.targetBeanInfoRef.get();
+        BeanInfo targetBeanInfo = getTargetBeanInfo();
         if (targetBeanInfo != null) {
             return targetBeanInfo.getIcon(iconKind);
         }
         return super.getIcon(iconKind);
     }
+
+    private BeanInfo getTargetBeanInfo() {
+        if (this.targetBeanInfoRef == null) {
+            return null;
+        }
+        BeanInfo targetBeanInfo = this.targetBeanInfoRef.get();
+        if (targetBeanInfo == null) {
+            targetBeanInfo = ThreadGroupContext.getContext().getBeanInfoFinder()
+                    .find(this.beanDescriptor.getBeanClass());
+            if (targetBeanInfo != null) {
+                this.targetBeanInfoRef = new SoftReference<>(targetBeanInfo);
+            }
+        }
+        return targetBeanInfo;
+    }
 }
--- a/src/share/classes/java/beans/PropertyDescriptor.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/beans/PropertyDescriptor.java	Fri Sep 14 10:14:02 2012 -0700
@@ -109,6 +109,10 @@
         if (writeMethodName != null && getWriteMethod() == null) {
             throw new IntrospectionException("Method not found: " + writeMethodName);
         }
+        boundInitialization(beanClass);
+    }
+
+    private void boundInitialization(Class<?> beanClass) {
         // If this class or one of its base classes allow PropertyChangeListener,
         // then we assume that any properties we discover are "bound".
         // See Introspector.getTargetPropertyInfo() method.
@@ -159,6 +163,7 @@
         setReadMethod(read);
         setWriteMethod(write);
         this.baseName = base;
+        boundInitialization(bean);
     }
 
     /**
@@ -588,7 +593,7 @@
         Method yw = y.getWriteMethod();
 
         try {
-            if (yw != null && yw.getDeclaringClass() == getClass0()) {
+            if (yw != null) {
                 setWriteMethod(yw);
             } else {
                 setWriteMethod(xw);
--- a/src/share/classes/java/beans/XMLEncoder.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/beans/XMLEncoder.java	Fri Sep 14 10:14:02 2012 -0700
@@ -631,7 +631,12 @@
         }
 
         if (d.name != null) {
-            outputXML(isArgument ? "object" : "void", " idref=" + quote(d.name), value);
+            if (isArgument) {
+                writeln("<object idref=" + quote(d.name) + "/>");
+            }
+            else {
+                outputXML("void", " idref=" + quote(d.name), value);
+            }
         }
         else if (d.exp != null) {
             outputStatement(d.exp, outer, isArgument);
@@ -710,12 +715,14 @@
         }
         else {
             d.refs = 2;
-            getValueData(target).refs++;
-            List<Statement> statements = statementList(target);
-            if (!statements.contains(exp)) {
-                statements.add(exp);
+            if (d.name == null) {
+                getValueData(target).refs++;
+                List<Statement> statements = statementList(target);
+                if (!statements.contains(exp)) {
+                    statements.add(exp);
+                }
+                outputValue(target, outer, false);
             }
-            outputValue(target, outer, false);
             if (expression) {
                 outputValue(value, outer, isArgument);
             }
--- a/src/share/classes/java/lang/invoke/BoundMethodHandle.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/lang/invoke/BoundMethodHandle.java	Fri Sep 14 10:14:02 2012 -0700
@@ -143,6 +143,11 @@
     protected abstract SpeciesData speciesData();
 
     @Override
+    final Object internalProperties() {
+        return "/BMH="+internalValues();
+    }
+
+    @Override
     final Object internalValues() {
         Object[] boundValues = new Object[speciesData().fieldCount()];
         for (int i = 0; i < boundValues.length; ++i) {
--- a/src/share/classes/java/lang/invoke/DirectMethodHandle.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/lang/invoke/DirectMethodHandle.java	Fri Sep 14 10:14:02 2012 -0700
@@ -108,8 +108,8 @@
     }
 
     @Override
-    String debugString() {
-        return "DMH["+member.toString()+"]="+super.debugString();
+    String internalProperties() {
+        return "/DMH="+member.toString();
     }
 
     //// Implementation methods.
--- a/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Fri Sep 14 10:14:02 2012 -0700
@@ -185,12 +185,17 @@
     }
 
     class CpPatch {
-        int index;
-        Object value;
-        CpPatch(int index, Object value) {
+        final int index;
+        final String placeholder;
+        final Object value;
+        CpPatch(int index, String placeholder, Object value) {
             this.index = index;
+            this.placeholder = placeholder;
             this.value = value;
         }
+        public String toString() {
+            return "CpPatch/index="+index+",placeholder="+placeholder+",value="+value;
+        }
     }
 
     Map<Object, CpPatch> cpPatches = new HashMap<>();
@@ -205,7 +210,7 @@
         }
         // insert placeholder in CP and remember the patch
         int index = cw.newConst((Object) cpPlaceholder);  // TODO check if aready in the constant pool
-        cpPatches.put(cpPlaceholder, new CpPatch(index, arg));
+        cpPatches.put(cpPlaceholder, new CpPatch(index, cpPlaceholder, arg));
         return cpPlaceholder;
     }
 
@@ -213,7 +218,9 @@
         int size = getConstantPoolSize(classFile);
         Object[] res = new Object[size];
         for (CpPatch p : cpPatches.values()) {
-                res[p.index] = p.value;
+            if (p.index >= size)
+                throw new InternalError("in cpool["+size+"]: "+p+"\n"+Arrays.toString(Arrays.copyOf(classFile, 20)));
+            res[p.index] = p.value;
         }
         return res;
     }
--- a/src/share/classes/java/lang/invoke/Invokers.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/lang/invoke/Invokers.java	Fri Sep 14 10:14:02 2012 -0700
@@ -74,8 +74,18 @@
         MethodHandle invoker = exactInvoker;
         if (invoker != null)  return invoker;
         MethodType mtype = targetType;
-        LambdaForm lform = invokeForm(mtype, MethodTypeForm.LF_EX_INVOKER);
-        invoker = BoundMethodHandle.bindSingle(mtype.invokerType(), lform, mtype);
+        MethodType invokerType = mtype.invokerType();
+        LambdaForm lform;
+        final int MTYPE_ARG_APPENDED = 1;  // argument count for appended mtype value
+        if (mtype.parameterSlotCount() <= MethodType.MAX_MH_INVOKER_ARITY - MTYPE_ARG_APPENDED) {
+            lform = invokeForm(mtype, false, MethodTypeForm.LF_EX_INVOKER);
+            invoker = BoundMethodHandle.bindSingle(invokerType, lform, mtype);
+        } else {
+            // At maximum arity, we cannot afford an extra mtype argument,
+            // so build a fully customized (non-cached) invoker form.
+            lform = invokeForm(mtype, true, MethodTypeForm.LF_EX_INVOKER);
+            invoker = SimpleMethodHandle.make(invokerType, lform);
+        }
         assert(checkInvoker(invoker));
         exactInvoker = invoker;
         return invoker;
@@ -85,9 +95,20 @@
         MethodHandle invoker = generalInvoker;
         if (invoker != null)  return invoker;
         MethodType mtype = targetType;
-        prepareForGenericCall(mtype);
-        LambdaForm lform = invokeForm(mtype, MethodTypeForm.LF_GEN_INVOKER);
-        invoker = BoundMethodHandle.bindSingle(mtype.invokerType(), lform, mtype);
+        MethodType invokerType = mtype.invokerType();
+        LambdaForm lform;
+        final int MTYPE_ARG_APPENDED = 1;  // argument count for appended mtype value
+        assert(GENERIC_INVOKER_SLOP >= MTYPE_ARG_APPENDED);
+        if (mtype.parameterSlotCount() <= MethodType.MAX_MH_INVOKER_ARITY - GENERIC_INVOKER_SLOP) {
+            prepareForGenericCall(mtype);
+            lform = invokeForm(mtype, false, MethodTypeForm.LF_GEN_INVOKER);
+            invoker = BoundMethodHandle.bindSingle(invokerType, lform, mtype);
+        } else {
+            // At maximum arity, we cannot afford an extra mtype argument,
+            // so build a fully customized (non-cached) invoker form.
+            lform = invokeForm(mtype, true, MethodTypeForm.LF_GEN_INVOKER);
+            invoker = SimpleMethodHandle.make(invokerType, lform);
+        }
         assert(checkInvoker(invoker));
         generalInvoker = invoker;
         return invoker;
@@ -102,6 +123,7 @@
     }
 
     static MemberName invokeBasicMethod(MethodType type) {
+        type = type.basicType();
         String name = "invokeBasic";
         try {
             //Lookup.findVirtual(MethodHandle.class, name, type);
@@ -135,9 +157,31 @@
     /*non-public*/ MethodHandle spreadInvoker(int leadingArgCount) {
         MethodHandle vaInvoker = spreadInvokers[leadingArgCount];
         if (vaInvoker != null)  return vaInvoker;
-        MethodHandle gInvoker = generalInvoker();
         int spreadArgCount = targetType.parameterCount() - leadingArgCount;
-        vaInvoker = gInvoker.asSpreader(Object[].class, spreadArgCount);
+        MethodType spreadInvokerType = targetType
+            .replaceParameterTypes(leadingArgCount, targetType.parameterCount(), Object[].class);
+        if (targetType.parameterSlotCount() <= MethodType.MAX_MH_INVOKER_ARITY) {
+            // Factor sinvoker.invoke(mh, a) into ginvoker.asSpreader().invoke(mh, a)
+            // where ginvoker.invoke(mh, a*) => mh.invoke(a*).
+            MethodHandle genInvoker = generalInvoker();
+            vaInvoker = genInvoker.asSpreader(Object[].class, spreadArgCount);
+        } else {
+            // Cannot build a general invoker here of type ginvoker.invoke(mh, a*[254]).
+            // Instead, factor sinvoker.invoke(mh, a) into ainvoker.invoke(filter(mh), a)
+            // where filter(mh) == mh.asSpreader(Object[], spreadArgCount)
+            MethodHandle arrayInvoker = MethodHandles.exactInvoker(spreadInvokerType);
+            MethodHandle makeSpreader;
+            try {
+                makeSpreader = IMPL_LOOKUP
+                    .findVirtual(MethodHandle.class, "asSpreader",
+                        MethodType.methodType(MethodHandle.class, Class.class, int.class));
+            } catch (ReflectiveOperationException ex) {
+                throw new InternalError(ex);
+            }
+            makeSpreader = MethodHandles.insertArguments(makeSpreader, 1, Object[].class, spreadArgCount);
+            vaInvoker = MethodHandles.filterArgument(arrayInvoker, 0, makeSpreader);
+        }
+        assert(vaInvoker.type().equals(spreadInvokerType.invokerType()));
         spreadInvokers[leadingArgCount] = vaInvoker;
         return vaInvoker;
     }
@@ -171,7 +215,7 @@
                     .findStatic(CallSite.class, "uninitializedCallSite",
                                 MethodType.methodType(Empty.class));
             } catch (ReflectiveOperationException ex) {
-                throw new RuntimeException(ex);
+                throw new InternalError(ex);
             }
         }
         invoker = MethodHandles.explicitCastArguments(invoker, MethodType.methodType(targetType.returnType()));
@@ -185,30 +229,39 @@
         return "Invokers"+targetType;
     }
 
-    private static MethodType fixMethodType(Class<?> callerClass, Object type) {
-        if (type instanceof MethodType)
-            return (MethodType) type;
-        else
-            return MethodType.fromMethodDescriptorString((String)type, callerClass.getClassLoader());
-    }
-
-    static MemberName exactInvokerMethod(Class<?> callerClass, Object type, Object[] appendixResult) {
-        MethodType mtype = fixMethodType(callerClass, type);
-        LambdaForm lform = invokeForm(mtype, MethodTypeForm.LF_EX_LINKER);
-        appendixResult[0] = mtype;
+    static MemberName exactInvokerMethod(MethodType mtype, Object[] appendixResult) {
+        LambdaForm lform;
+        final int MTYPE_ARG_APPENDED = 1;  // argument count for appended mtype value
+        if (mtype.parameterSlotCount() <= MethodType.MAX_MH_ARITY - MTYPE_ARG_APPENDED) {
+            lform = invokeForm(mtype, false, MethodTypeForm.LF_EX_LINKER);
+            appendixResult[0] = mtype;
+        } else {
+            lform = invokeForm(mtype, true, MethodTypeForm.LF_EX_LINKER);
+        }
         return lform.vmentry;
     }
 
-    static MemberName genericInvokerMethod(Class<?> callerClass, Object type, Object[] appendixResult) {
-        MethodType mtype = fixMethodType(callerClass, type);
-        LambdaForm lform = invokeForm(mtype, MethodTypeForm.LF_GEN_LINKER);
-        prepareForGenericCall(mtype);
-        appendixResult[0] = mtype;
+    static MemberName genericInvokerMethod(MethodType mtype, Object[] appendixResult) {
+        LambdaForm lform;
+        final int MTYPE_ARG_APPENDED = 1;  // argument count for appended mtype value
+        if (mtype.parameterSlotCount() <= MethodType.MAX_MH_ARITY - (MTYPE_ARG_APPENDED + GENERIC_INVOKER_SLOP)) {
+            lform = invokeForm(mtype, false, MethodTypeForm.LF_GEN_LINKER);
+            appendixResult[0] = mtype;
+            prepareForGenericCall(mtype);
+        } else {
+            lform = invokeForm(mtype, true, MethodTypeForm.LF_GEN_LINKER);
+        }
         return lform.vmentry;
     }
 
-    private static LambdaForm invokeForm(MethodType mtype, int which) {
-        mtype = mtype.basicType();  // normalize Z to I, String to Object, etc.
+    private static LambdaForm invokeForm(MethodType mtype, boolean customized, int which) {
+        boolean isCached;
+        if (!customized) {
+            mtype = mtype.basicType();  // normalize Z to I, String to Object, etc.
+            isCached = true;
+        } else {
+            isCached = false;  // maybe cache if mtype == mtype.basicType()
+        }
         boolean isLinker, isGeneric;
         String debugName;
         switch (which) {
@@ -218,27 +271,32 @@
         case MethodTypeForm.LF_GEN_INVOKER: isLinker = false; isGeneric = true;  debugName = "invoker"; break;
         default: throw new InternalError();
         }
-        LambdaForm lform = mtype.form().cachedLambdaForm(which);
-        if (lform != null)  return lform;
+        LambdaForm lform;
+        if (isCached) {
+            lform = mtype.form().cachedLambdaForm(which);
+            if (lform != null)  return lform;
+        }
         // exactInvokerForm (Object,Object)Object
         //   link with java.lang.invoke.MethodHandle.invokeBasic(MethodHandle,Object,Object)Object/invokeSpecial
         final int THIS_MH      = 0;
         final int CALL_MH      = THIS_MH + (isLinker ? 0 : 1);
         final int ARG_BASE     = CALL_MH + 1;
         final int OUTARG_LIMIT = ARG_BASE + mtype.parameterCount();
-        final int INARG_LIMIT  = OUTARG_LIMIT + (isLinker ? 1 : 0);
+        final int INARG_LIMIT  = OUTARG_LIMIT + (isLinker && !customized ? 1 : 0);
         int nameCursor = OUTARG_LIMIT;
-        final int MTYPE_ARG    = nameCursor++;  // might be last in-argument
+        final int MTYPE_ARG    = customized ? -1 : nameCursor++;  // might be last in-argument
         final int CHECK_TYPE   = nameCursor++;
         final int LINKER_CALL  = nameCursor++;
         MethodType invokerFormType = mtype.invokerType();
         if (isLinker) {
-            invokerFormType = invokerFormType.appendParameterTypes(MemberName.class);
+            if (!customized)
+                invokerFormType = invokerFormType.appendParameterTypes(MemberName.class);
         } else {
             invokerFormType = invokerFormType.invokerType();
         }
         Name[] names = arguments(nameCursor - INARG_LIMIT, invokerFormType);
-        assert(names.length == nameCursor);
+        assert(names.length == nameCursor)
+                : Arrays.asList(mtype, customized, which, nameCursor, names.length);
         if (MTYPE_ARG >= INARG_LIMIT) {
             assert(names[MTYPE_ARG] == null);
             names[MTYPE_ARG] = BoundMethodHandle.getSpeciesData("L").getterName(names[THIS_MH], 0);
@@ -248,31 +306,42 @@
         // Make the final call.  If isGeneric, then prepend the result of type checking.
         MethodType outCallType;
         Object[] outArgs;
+        Object mtypeArg = (customized ? mtype : names[MTYPE_ARG]);
         if (!isGeneric) {
-            names[CHECK_TYPE] = new Name(NF_checkExactType, names[CALL_MH], names[MTYPE_ARG]);
+            names[CHECK_TYPE] = new Name(NF_checkExactType, names[CALL_MH], mtypeArg);
             // mh.invokeExact(a*):R => checkExactType(mh, TYPEOF(a*:R)); mh.invokeBasic(a*)
             outArgs = Arrays.copyOfRange(names, CALL_MH, OUTARG_LIMIT, Object[].class);
             outCallType = mtype;
+        } else if (customized) {
+            names[CHECK_TYPE] = new Name(NF_asType, names[CALL_MH], mtypeArg);
+            // mh.invokeGeneric(a*):R =>
+            //  let mt=TYPEOF(a*:R), tmh=asType(mh, mt);
+            //    tmh.invokeBasic(a*)
+            outArgs = Arrays.copyOfRange(names, CALL_MH, OUTARG_LIMIT, Object[].class);
+            outCallType = mtype;
         } else {
-            names[CHECK_TYPE] = new Name(NF_checkGenericType, names[CALL_MH], names[MTYPE_ARG]);
+            names[CHECK_TYPE] = new Name(NF_checkGenericType, names[CALL_MH], mtypeArg);
             // mh.invokeGeneric(a*):R =>
             //  let mt=TYPEOF(a*:R), gamh=checkGenericType(mh, mt);
             //    gamh.invokeBasic(mt, mh, a*)
             final int PREPEND_GAMH = 0, PREPEND_MT = 1, PREPEND_COUNT = 2;
+            assert(GENERIC_INVOKER_SLOP == PREPEND_COUNT);
             outArgs = Arrays.copyOfRange(names, CALL_MH, OUTARG_LIMIT + PREPEND_COUNT, Object[].class);
             // prepend arguments:
             System.arraycopy(outArgs, 0, outArgs, PREPEND_COUNT, outArgs.length - PREPEND_COUNT);
             outArgs[PREPEND_GAMH] = names[CHECK_TYPE];
-            outArgs[PREPEND_MT] = names[MTYPE_ARG];
+            outArgs[PREPEND_MT] = mtypeArg;
             outCallType = mtype.insertParameterTypes(0, MethodType.class, MethodHandle.class);
         }
         names[LINKER_CALL] = new Name(invokeBasicMethod(outCallType), outArgs);
         lform = new LambdaForm(debugName, INARG_LIMIT, names);
         if (isLinker)
             lform.compileToBytecode();  // JVM needs a real methodOop
-        lform = mtype.form().setCachedLambdaForm(which, lform);
+        if (isCached)
+            lform = mtype.form().setCachedLambdaForm(which, lform);
         return lform;
     }
+    private static final int GENERIC_INVOKER_SLOP = 2;  // used elsewhere to avoid arity problems
 
     /*non-public*/ static
     WrongMethodTypeException newWrongMethodTypeException(MethodType actual, MethodType expected) {
@@ -370,6 +439,7 @@
     // Local constant functions:
     private static final NamedFunction NF_checkExactType;
     private static final NamedFunction NF_checkGenericType;
+    private static final NamedFunction NF_asType;
     private static final NamedFunction NF_getCallSiteTarget;
     static {
         try {
@@ -377,6 +447,8 @@
                     .getDeclaredMethod("checkExactType", Object.class, Object.class));
             NF_checkGenericType = new NamedFunction(Invokers.class
                     .getDeclaredMethod("checkGenericType", Object.class, Object.class));
+            NF_asType = new NamedFunction(MethodHandle.class
+                    .getDeclaredMethod("asType", MethodType.class));
             NF_getCallSiteTarget = new NamedFunction(Invokers.class
                     .getDeclaredMethod("getCallSiteTarget", Object.class));
             NF_checkExactType.resolve();
--- a/src/share/classes/java/lang/invoke/LambdaForm.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/lang/invoke/LambdaForm.java	Fri Sep 14 10:14:02 2012 -0700
@@ -596,14 +596,7 @@
     Object interpretWithArguments(Object... argumentValues) throws Throwable {
         if (TRACE_INTERPRETER)
             return interpretWithArgumentsTracing(argumentValues);
-        if (COMPILE_THRESHOLD != 0 &&
-            invocationCounter < COMPILE_THRESHOLD) {
-            invocationCounter++;  // benign race
-            if (invocationCounter >= COMPILE_THRESHOLD) {
-                // Replace vmentry with a bytecode version of this LF.
-                compileToBytecode();
-            }
-        }
+        checkInvocationCounter();
         assert(arityCheck(argumentValues));
         Object[] values = Arrays.copyOf(argumentValues, names.length);
         for (int i = argumentValues.length; i < values.length; i++) {
@@ -630,6 +623,16 @@
         return name.function.invokeWithArguments(arguments);
     }
 
+    private void checkInvocationCounter() {
+        if (COMPILE_THRESHOLD != 0 &&
+            invocationCounter < COMPILE_THRESHOLD) {
+            invocationCounter++;  // benign race
+            if (invocationCounter >= COMPILE_THRESHOLD) {
+                // Replace vmentry with a bytecode version of this LF.
+                compileToBytecode();
+            }
+        }
+    }
     Object interpretWithArgumentsTracing(Object... argumentValues) throws Throwable {
         traceInterpreter("[ interpretWithArguments", this, argumentValues);
         if (invocationCounter < COMPILE_THRESHOLD) {
@@ -703,7 +706,7 @@
     }
 
     public String toString() {
-        StringBuilder buf = new StringBuilder("Lambda(");
+        StringBuilder buf = new StringBuilder(debugName+"=Lambda(");
         for (int i = 0; i < names.length; i++) {
             if (i == arity)  buf.append(")=>{");
             Name n = names[i];
--- a/src/share/classes/java/lang/invoke/MemberName.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/lang/invoke/MemberName.java	Fri Sep 14 10:14:02 2012 -0700
@@ -306,12 +306,6 @@
         return this;
     }
 
-    private void setFlags(int flags) {
-        this.flags = flags;
-        assert(testAnyFlags(ALL_KINDS));
-        assert(referenceKindIsConsistent());
-    }
-
     private boolean testFlags(int mask, int value) {
         return (flags & mask) == value;
     }
@@ -452,8 +446,10 @@
         this.clazz = defClass;
         this.name = name;
         this.type = type;
-        setFlags(flags);
+        this.flags = flags;
+        assert(testAnyFlags(ALL_KINDS));
         assert(this.resolution == null);  // nobody should have touched this yet
+        //assert(referenceKindIsConsistent());  // do this after resolution
     }
 
     private void expandFromVM() {
--- a/src/share/classes/java/lang/invoke/MethodHandle.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/lang/invoke/MethodHandle.java	Fri Sep 14 10:14:02 2012 -0700
@@ -924,7 +924,7 @@
         if (arrayType != type().parameterType(collectArgPos))
             target = convertArguments(type().changeParameterType(collectArgPos, arrayType));
         MethodHandle collector = ValueConversions.varargsArray(arrayType, arrayLength);
-        return MethodHandleImpl.makeCollectArguments(target, collector, collectArgPos, false);
+        return MethodHandles.collectArguments(target, collectArgPos, collector);
     }
 
     // private API: return true if last param exactly matches arrayType
@@ -1226,7 +1226,7 @@
         return "MethodHandle"+type;
     }
     String debugString() {
-        return standardString()+"="+internalForm()+internalValues();
+        return standardString()+"/LF="+internalForm()+internalProperties();
     }
 
     //// Implementation methods.
@@ -1269,6 +1269,12 @@
 
     /*non-public*/
     Object internalValues() {
+        return null;
+    }
+
+    /*non-public*/
+    Object internalProperties() {
+        // Override to something like "/FOO=bar"
         return "";
     }
 
--- a/src/share/classes/java/lang/invoke/MethodHandleImpl.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/lang/invoke/MethodHandleImpl.java	Fri Sep 14 10:14:02 2012 -0700
@@ -59,7 +59,7 @@
         Name[] args  = Arrays.copyOfRange(names, 1, 1 + srcType.parameterCount());
         names[names.length - 1] = new Name(accessor.asType(srcType), (Object[]) args);
         LambdaForm form = new LambdaForm("getElement", lambdaType.parameterCount(), names);
-        MethodHandle mh = new SimpleMethodHandle(srcType, form);
+        MethodHandle mh = SimpleMethodHandle.make(srcType, form);
         if (ArrayAccessor.needCast(arrayClass)) {
             mh = mh.bindTo(arrayClass);
         }
@@ -171,38 +171,46 @@
 
         // Calculate extra arguments (temporaries) required in the names array.
         // FIXME: Use an ArrayList<Name>.  Some arguments require more than one conversion step.
-        int extra = 0;
-        for (int i = 0; i < srcType.parameterCount(); i++) {
+        final int INARG_COUNT = srcType.parameterCount();
+        int conversions = 0;
+        boolean[] needConv = new boolean[1+INARG_COUNT];
+        for (int i = 0; i <= INARG_COUNT; i++) {
+            Class<?> src = (i == INARG_COUNT) ? dstType.returnType() : srcType.parameterType(i);
+            Class<?> dst = (i == INARG_COUNT) ? srcType.returnType() : dstType.parameterType(i);
+            if (!VerifyType.isNullConversion(src, dst) ||
+                level <= 1 && dst.isInterface() && !dst.isAssignableFrom(src)) {
+                needConv[i] = true;
+                conversions++;
+            }
+        }
+        boolean retConv = needConv[INARG_COUNT];
+
+        final int IN_MH         = 0;
+        final int INARG_BASE    = 1;
+        final int INARG_LIMIT   = INARG_BASE + INARG_COUNT;
+        final int NAME_LIMIT    = INARG_LIMIT + conversions + 1;
+        final int RETURN_CONV   = (!retConv ? -1         : NAME_LIMIT - 1);
+        final int OUT_CALL      = (!retConv ? NAME_LIMIT : RETURN_CONV) - 1;
+
+        // Now build a LambdaForm.
+        MethodType lambdaType = srcType.basicType().invokerType();
+        Name[] names = arguments(NAME_LIMIT - INARG_LIMIT, lambdaType);
+
+        // Collect the arguments to the outgoing call, maybe with conversions:
+        final int OUTARG_BASE = 0;  // target MH is Name.function, name Name.arguments[0]
+        Object[] outArgs = new Object[OUTARG_BASE + INARG_COUNT];
+
+        int nameCursor = INARG_LIMIT;
+        for (int i = 0; i < INARG_COUNT; i++) {
             Class<?> src = srcType.parameterType(i);
             Class<?> dst = dstType.parameterType(i);
-            if (!VerifyType.isNullConversion(src, dst)) {
-                extra++;
-            }
-        }
 
-        Class<?> needReturn = srcType.returnType();
-        Class<?> haveReturn = dstType.returnType();
-        boolean retConv = !VerifyType.isNullConversion(haveReturn, needReturn);
-
-        // Now build a LambdaForm.
-        MethodType lambdaType = srcType.invokerType();
-        Name[] names = arguments(extra + 1, lambdaType);
-        int[] indexes = new int[lambdaType.parameterCount()];
-
-        MethodType midType = dstType;
-        for (int i = 0, argIndex = 1, tmpIndex = lambdaType.parameterCount(); i < srcType.parameterCount(); i++, argIndex++) {
-            Class<?> src = srcType.parameterType(i);
-            Class<?> dst = midType.parameterType(i);
-
-            if (VerifyType.isNullConversion(src, dst)) {
+            if (!needConv[i]) {
                 // do nothing: difference is trivial
-                indexes[i] = argIndex;
+                outArgs[OUTARG_BASE + i] = names[INARG_BASE + i];
                 continue;
             }
 
-            // Work the current type backward toward the desired caller type:
-            midType = midType.changeParameterType(i, src);
-
             // Tricky case analysis follows.
             MethodHandle fn = null;
             if (src.isPrimitive()) {
@@ -246,33 +254,41 @@
                     fn = ValueConversions.cast(dst);
                 }
             }
-            names[tmpIndex] = new Name(fn, names[argIndex]);
-            indexes[i] = tmpIndex;
-            tmpIndex++;
+            Name conv = new Name(fn, names[INARG_BASE + i]);
+            assert(names[nameCursor] == null);
+            names[nameCursor++] = conv;
+            assert(outArgs[OUTARG_BASE + i] == null);
+            outArgs[OUTARG_BASE + i] = conv;
         }
-        if (retConv) {
-            MethodHandle adjustReturn;
+
+        // Build argument array for the call.
+        assert(nameCursor == OUT_CALL);
+        names[OUT_CALL] = new Name(target, outArgs);
+
+        if (RETURN_CONV < 0) {
+            assert(OUT_CALL == names.length-1);
+        } else {
+            Class<?> needReturn = srcType.returnType();
+            Class<?> haveReturn = dstType.returnType();
+            MethodHandle fn;
+            Object[] arg = { names[OUT_CALL] };
             if (haveReturn == void.class) {
                 // synthesize a zero value for the given void
                 Object zero = Wrapper.forBasicType(needReturn).zero();
-                adjustReturn = MethodHandles.constant(needReturn, zero);
+                fn = MethodHandles.constant(needReturn, zero);
+                arg = new Object[0];  // don't pass names[OUT_CALL] to conversion
             } else {
                 MethodHandle identity = MethodHandles.identity(needReturn);
                 MethodType needConversion = identity.type().changeParameterType(0, haveReturn);
-                adjustReturn = makePairwiseConvert(identity, needConversion, level);
+                fn = makePairwiseConvert(identity, needConversion, level);
             }
-            target = makeCollectArguments(adjustReturn, target, 0, false);
+            assert(names[RETURN_CONV] == null);
+            names[RETURN_CONV] = new Name(fn, arg);
+            assert(RETURN_CONV == names.length-1);
         }
 
-        // Build argument array for the call.
-        Name[] targetArgs = new Name[dstType.parameterCount()];
-        for (int i = 0; i < dstType.parameterCount(); i++) {
-            int idx = indexes[i];
-            targetArgs[i] = names[idx];
-        }
-        names[names.length - 1] = new Name(target, (Object[]) targetArgs);
         LambdaForm form = new LambdaForm("convert", lambdaType.parameterCount(), names);
-        return new SimpleMethodHandle(srcType, form);
+        return SimpleMethodHandle.make(srcType, form);
     }
 
     static MethodHandle makeReferenceIdentity(Class<?> refType) {
@@ -280,7 +296,7 @@
         Name[] names = arguments(1, lambdaType);
         names[names.length - 1] = new Name(ValueConversions.identity(), names[1]);
         LambdaForm form = new LambdaForm("identity", lambdaType.parameterCount(), names);
-        return new SimpleMethodHandle(MethodType.methodType(refType, refType), form);
+        return SimpleMethodHandle.make(MethodType.methodType(refType, refType), form);
     }
 
     static MethodHandle makeVarargsCollector(MethodHandle target, Class<?> arrayType) {
@@ -334,8 +350,9 @@
             MethodHandle collector;
             try {
                 collector = asFixedArity().asCollector(arrayType, arrayLength);
+                assert(collector.type().parameterCount() == newArity) : "newArity="+newArity+" but collector="+collector;
             } catch (IllegalArgumentException ex) {
-                throw new WrongMethodTypeException("cannot build collector");
+                throw new WrongMethodTypeException("cannot build collector", ex);
             }
             cache = collector;
             return collector.asType(newType);
@@ -429,12 +446,18 @@
         names[names.length - 1] = new Name(target, (Object[]) targetArgs);
 
         LambdaForm form = new LambdaForm("spread", lambdaType.parameterCount(), names);
-        return new SimpleMethodHandle(srcType, form);
+        return SimpleMethodHandle.make(srcType, form);
     }
 
     static void checkSpreadArgument(Object av, int n) {
+        // FIXME: regression test for bug 7141637 erroneously expects an NPE, and other tests may expect IAE
+        // but the actual exception raised by an arity mismatch should be WMTE
+        final boolean RAISE_RANDOM_EXCEPTIONS = true;  // FIXME: delete in JSR 292 M1
         if (av == null) {
             if (n == 0)  return;
+            int len;
+            if (RAISE_RANDOM_EXCEPTIONS)
+                len = ((Object[])av).length;  // throw NPE; but delete this after tests are fixed
         } else if (av instanceof Object[]) {
             int len = ((Object[])av).length;
             if (len == n)  return;
@@ -443,7 +466,9 @@
             if (len == n)  return;
         }
         // fall through to error:
-        throw newIllegalArgumentException("Array is not of length "+n);
+        if (RAISE_RANDOM_EXCEPTIONS)
+            throw newIllegalArgumentException("Array is not of length "+n);
+        throw new WrongMethodTypeException("Array is not of length "+n);
     }
 
     private static final NamedFunction NF_checkSpreadArgument;
@@ -508,7 +533,7 @@
         names[targetNamePos] = new Name(target, (Object[]) targetArgs);
 
         LambdaForm form = new LambdaForm("collect", lambdaType.parameterCount(), names);
-        return new SimpleMethodHandle(srcType, form);
+        return SimpleMethodHandle.make(srcType, form);
     }
 
     static
@@ -555,7 +580,7 @@
         names[arity + 3] = new Name(new NamedFunction(invokeBasic), targetArgs);
 
         LambdaForm form = new LambdaForm("guard", lambdaType.parameterCount(), names);
-        return new SimpleMethodHandle(target.type(), form);
+        return SimpleMethodHandle.make(target.type(), form);
     }
 
     private static class GuardWithCatch {
--- a/src/share/classes/java/lang/invoke/MethodHandleNatives.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/lang/invoke/MethodHandleNatives.java	Fri Sep 14 10:14:02 2012 -0700
@@ -325,15 +325,28 @@
     static MemberName linkMethodImpl(Class<?> callerClass, int refKind,
                                      Class<?> defc, String name, Object type,
                                      Object[] appendixResult) {
-        if (defc != MethodHandle.class || refKind != REF_invokeVirtual)
-            throw new LinkageError("no such method "+defc.getName()+"."+name+type);
-        switch (name) {
-        case "invoke":
-            return Invokers.genericInvokerMethod(callerClass, type, appendixResult);
-        case "invokeExact":
-            return Invokers.exactInvokerMethod(callerClass, type, appendixResult);
+        try {
+            if (defc == MethodHandle.class && refKind == REF_invokeVirtual) {
+                switch (name) {
+                case "invoke":
+                    return Invokers.genericInvokerMethod(fixMethodType(callerClass, type), appendixResult);
+                case "invokeExact":
+                    return Invokers.exactInvokerMethod(fixMethodType(callerClass, type), appendixResult);
+                }
+            }
+        } catch (Throwable ex) {
+            if (ex instanceof LinkageError)
+                throw (LinkageError) ex;
+            else
+                throw new LinkageError(ex.getMessage(), ex);
         }
-        throw new UnsupportedOperationException("linkMethod "+name);
+        throw new LinkageError("no such method "+defc.getName()+"."+name+type);
+    }
+    private static MethodType fixMethodType(Class<?> callerClass, Object type) {
+        if (type instanceof MethodType)
+            return (MethodType) type;
+        else
+            return MethodType.fromMethodDescriptorString((String)type, callerClass.getClassLoader());
     }
     // Tracing logic:
     static MemberName linkMethodTracing(Class<?> callerClass, int refKind,
@@ -351,6 +364,7 @@
         }
     }
 
+
     /**
      * The JVM is resolving a CONSTANT_MethodHandle CP entry.  And it wants our help.
      * It will make an up-call to this method.  (Do not change the name or signature.)
--- a/src/share/classes/java/lang/invoke/MethodHandles.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/lang/invoke/MethodHandles.java	Fri Sep 14 10:14:02 2012 -0700
@@ -1876,6 +1876,17 @@
         return MethodHandleImpl.makeCollectArguments(target, filter, pos, false);
     }
 
+    // FIXME: Make this public in M1.
+    /*non-public*/ static
+    MethodHandle collectArguments(MethodHandle target, int pos, MethodHandle collector) {
+        MethodType targetType = target.type();
+        MethodType filterType = collector.type();
+        if (filterType.returnType() != void.class &&
+            filterType.returnType() != targetType.parameterType(pos))
+            throw newIllegalArgumentException("target and filter types do not match", targetType, filterType);
+        return MethodHandleImpl.makeCollectArguments(target, collector, pos, false);
+    }
+
     /**
      * Adapts a target method handle by post-processing
      * its return value (if any) with a filter (another method handle).
--- a/src/share/classes/java/lang/invoke/MethodType.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/lang/invoke/MethodType.java	Fri Sep 14 10:14:02 2012 -0700
@@ -111,6 +111,36 @@
 
     void setForm(MethodTypeForm f) { form = f; }
 
+    /** This number, mandated by the JVM spec as 255,
+     *  is the maximum number of <em>slots</em>
+     *  that any Java method can receive in its argument list.
+     *  It limits both JVM signatures and method type objects.
+     *  The longest possible invocation will look like
+     *  {@code staticMethod(arg1, arg2, ..., arg255)} or
+     *  {@code x.virtualMethod(arg1, arg2, ..., arg254)}.
+     */
+    /*non-public*/ static final int MAX_JVM_ARITY = 255;  // this is mandated by the JVM spec.
+
+    /** This number is the maximum arity of a method handle, 254.
+     *  It is derived from the absolute JVM-imposed arity by subtracting one,
+     *  which is the slot occupied by the method handle itself at the
+     *  beginning of the argument list used to invoke the method handle.
+     *  The longest possible invocation will look like
+     *  {@code mh.invoke(arg1, arg2, ..., arg254)}.
+     */
+    // Issue:  Should we allow MH.invokeWithArguments to go to the full 255?
+    /*non-public*/ static final int MAX_MH_ARITY = MAX_JVM_ARITY-1;  // deduct one for mh receiver
+
+    /** This number is the maximum arity of a method handle invoker, 253.
+     *  It is derived from the absolute JVM-imposed arity by subtracting two,
+     *  which are the slots occupied by invoke method handle, and the the
+     *  target method handle, which are both at the beginning of the argument
+     *  list used to invoke the target method handle.
+     *  The longest possible invocation will look like
+     *  {@code invokermh.invoke(targetmh, arg1, arg2, ..., arg253)}.
+     */
+    /*non-public*/ static final int MAX_MH_INVOKER_ARITY = MAX_MH_ARITY-1;  // deduct one more for invoker
+
     private static void checkRtype(Class<?> rtype) {
         rtype.equals(rtype);  // null check
     }
@@ -131,7 +161,9 @@
         return slots;
     }
     static void checkSlotCount(int count) {
-        if ((count & 0xFF) != count)
+        assert((MAX_JVM_ARITY & (MAX_JVM_ARITY+1)) == 0);
+        // MAX_JVM_ARITY must be power of 2 minus 1 for following code trick to work:
+        if ((count & MAX_JVM_ARITY) != count)
             throw newIllegalArgumentException("bad parameter count "+count);
     }
     private static IndexOutOfBoundsException newIndexOutOfBoundsException(Object num) {
--- a/src/share/classes/java/lang/invoke/SimpleMethodHandle.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/lang/invoke/SimpleMethodHandle.java	Fri Sep 14 10:14:02 2012 -0700
@@ -35,10 +35,14 @@
  * @author jrose
  */
 final class SimpleMethodHandle extends MethodHandle {
-    SimpleMethodHandle(MethodType type, LambdaForm form) {
+    private SimpleMethodHandle(MethodType type, LambdaForm form) {
         super(type, form);
     }
 
+    /*non-public*/ static SimpleMethodHandle make(MethodType type, LambdaForm form) {
+        return new SimpleMethodHandle(type, form);
+    }
+
     @Override
     MethodHandle bindArgument(int pos, char basicType, Object value) {
         MethodType type2 = type().dropParameterTypes(pos, pos+1);
--- a/src/share/classes/java/lang/invoke/WrongMethodTypeException.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/java/lang/invoke/WrongMethodTypeException.java	Fri Sep 14 10:14:02 2012 -0700
@@ -59,4 +59,27 @@
     public WrongMethodTypeException(String s) {
         super(s);
     }
+
+    /**
+     * Constructs a {@code WrongMethodTypeException} with the specified
+     * detail message and cause.
+     *
+     * @param s the detail message.
+     * @param cause the cause of the exception, or null.
+     */
+    //FIXME: make this public in MR1
+    /*non-public*/ WrongMethodTypeException(String s, Throwable cause) {
+        super(s, cause);
+    }
+
+    /**
+     * Constructs a {@code WrongMethodTypeException} with the specified
+     * cause.
+     *
+     * @param cause the cause of the exception, or null.
+     */
+    //FIXME: make this public in MR1
+    /*non-public*/ WrongMethodTypeException(Throwable cause) {
+        super(cause);
+    }
 }
--- a/src/share/classes/sun/awt/AWTAccessor.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/sun/awt/AWTAccessor.java	Fri Sep 14 10:14:02 2012 -0700
@@ -667,6 +667,21 @@
     }
 
     /*
+     * An accessor for the SequencedEventAccessor class
+     */
+    public interface SequencedEventAccessor {
+        /*
+         * Returns the nested event.
+         */
+        AWTEvent getNested(AWTEvent sequencedEvent);
+
+        /*
+         * Returns true if the event is an instances of SequencedEvent.
+         */
+        boolean isSequencedEvent(AWTEvent event);
+    }
+
+    /*
      * Accessor instances are initialized in the static initializers of
      * corresponding AWT classes by using setters defined below.
      */
@@ -692,6 +707,7 @@
     private static SystemTrayAccessor systemTrayAccessor;
     private static TrayIconAccessor trayIconAccessor;
     private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor;
+    private static SequencedEventAccessor sequencedEventAccessor;
 
     /*
      * Set an accessor object for the java.awt.Component class.
@@ -1069,4 +1085,20 @@
         }
         return defaultKeyboardFocusManagerAccessor;
     }
+    /*
+     * Set an accessor object for the java.awt.SequencedEvent class.
+     */
+    public static void setSequencedEventAccessor(SequencedEventAccessor sea) {
+        sequencedEventAccessor = sea;
+    }
+
+    /*
+     * Get the accessor object for the java.awt.SequencedEvent class.
+     */
+    public static SequencedEventAccessor getSequencedEventAccessor() {
+        // The class is not public. So we can't ensure it's initialized.
+        // Null returned value means it's not initialized
+        // (so not a single instance of the event has been created).
+        return sequencedEventAccessor;
+    }
 }
--- a/src/share/classes/sun/awt/HToolkit.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/sun/awt/HToolkit.java	Fri Sep 14 10:14:02 2012 -0700
@@ -44,6 +44,14 @@
 public class HToolkit extends SunToolkit
     implements ComponentFactory {
 
+    private static final KeyboardFocusManagerPeer kfmPeer = new KeyboardFocusManagerPeer() {
+        public void setCurrentFocusedWindow(Window win) {}
+        public Window getCurrentFocusedWindow() { return null; }
+        public void setCurrentFocusOwner(Component comp) {}
+        public Component getCurrentFocusOwner() { return null; }
+        public void clearGlobalFocusOwner(Window activeWindow) {}
+    };
+
     public HToolkit() {
     }
 
@@ -152,15 +160,9 @@
         throw new HeadlessException();
     }
 
-    public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
+    public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
         // See 6833019.
-        return
-            new KeyboardFocusManagerPeer() {
-                public Window getCurrentFocusedWindow() { return null; }
-                public void setCurrentFocusOwner(Component comp) {}
-                public Component getCurrentFocusOwner() { return null; }
-                public void clearGlobalFocusOwner(Window activeWindow) {}
-            };
+        return kfmPeer;
     }
 
     public TrayIconPeer createTrayIcon(TrayIcon target)
--- a/src/share/classes/sun/awt/HeadlessToolkit.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/sun/awt/HeadlessToolkit.java	Fri Sep 14 10:14:02 2012 -0700
@@ -30,22 +30,25 @@
 import java.awt.dnd.peer.DragSourceContextPeer;
 import java.awt.event.*;
 import java.awt.im.InputMethodHighlight;
-import java.awt.im.spi.InputMethodDescriptor;
 import java.awt.image.*;
 import java.awt.datatransfer.Clipboard;
 import java.awt.peer.*;
 import java.beans.PropertyChangeListener;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
 import java.util.Map;
 import java.util.Properties;
-import sun.awt.im.InputContext;
-import sun.awt.image.ImageRepresentation;
 
 public class HeadlessToolkit extends Toolkit
     implements ComponentFactory, KeyboardFocusManagerPeerProvider {
 
+    private static final KeyboardFocusManagerPeer kfmPeer = new KeyboardFocusManagerPeer() {
+        public void setCurrentFocusedWindow(Window win) {}
+        public Window getCurrentFocusedWindow() { return null; }
+        public void setCurrentFocusOwner(Component comp) {}
+        public Component getCurrentFocusOwner() { return null; }
+        public void clearGlobalFocusOwner(Window activeWindow) {}
+    };
+
     private Toolkit tk;
     private ComponentFactory componentFactory;
 
@@ -179,15 +182,9 @@
         throw new HeadlessException();
     }
 
-    public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
+    public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
         // See 6833019.
-        return
-            new KeyboardFocusManagerPeer() {
-                public Window getCurrentFocusedWindow() { return null; }
-                public void setCurrentFocusOwner(Component comp) {}
-                public Component getCurrentFocusOwner() { return null; }
-                public void clearGlobalFocusOwner(Window activeWindow) {}
-            };
+        return kfmPeer;
     }
 
     public TrayIconPeer createTrayIcon(TrayIcon target)
--- a/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java	Fri Sep 14 10:14:02 2012 -0700
@@ -53,12 +53,6 @@
     public static final int SNFH_SUCCESS_HANDLED = 1;
     public static final int SNFH_SUCCESS_PROCEED = 2;
 
-    protected KeyboardFocusManager manager;
-
-    public KeyboardFocusManagerPeerImpl(KeyboardFocusManager manager) {
-        this.manager = manager;
-    }
-
     @Override
     public void clearGlobalFocusOwner(Window activeWindow) {
         if (activeWindow != null) {
@@ -134,7 +128,7 @@
 
             if (focusLog.isLoggable(PlatformLogger.FINER))
                 focusLog.finer("Posting focus event: " + fl);
-            SunToolkit.postPriorityEvent(fl);
+            SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl);
         }
 
         FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED,
@@ -142,7 +136,7 @@
 
         if (focusLog.isLoggable(PlatformLogger.FINER))
             focusLog.finer("Posting focus event: " + fg);
-        SunToolkit.postPriorityEvent(fg);
+        SunToolkit.postEvent(SunToolkit.targetToAppContext(lightweightChild), fg);
         return true;
     }
 
--- a/src/share/classes/sun/awt/KeyboardFocusManagerPeerProvider.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/sun/awt/KeyboardFocusManagerPeerProvider.java	Fri Sep 14 10:14:02 2012 -0700
@@ -25,20 +25,19 @@
 
 package sun.awt;
 
-import java.awt.KeyboardFocusManager;
 import java.awt.peer.KeyboardFocusManagerPeer;
 
 /**
  * {@link KeyboardFocusManagerPeerProvider} is required to be implemented by
  * the currently used {@link java.awt.Toolkit} instance. In order to initialize
- * {@link java.awt.KeyboardFocusManager}, an instance of {@link KeyboardFocusManagerPeer}
- * is needed. To create that instance, the {@link #createKeyboardFocusManagerPeer}
+ * {@link java.awt.KeyboardFocusManager}, a singleton instance of {@link KeyboardFocusManagerPeer}
+ * is needed. To obtain that instance, the {@link #getKeyboardFocusManagerPeer}
  * method of the current toolkit is called.
  */
 public interface KeyboardFocusManagerPeerProvider {
 
     /**
-     * Creates a KeyboardFocusManagerPeer for the specified KeyboardFocusManager.
+     * Gets a singleton KeyboardFocusManagerPeer instance.
      */
-    KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager);
+    KeyboardFocusManagerPeer getKeyboardFocusManagerPeer();
 }
--- a/src/share/classes/sun/awt/SunToolkit.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/sun/awt/SunToolkit.java	Fri Sep 14 10:14:02 2012 -0700
@@ -197,7 +197,7 @@
     public abstract RobotPeer createRobot(Robot target, GraphicsDevice screen)
         throws AWTException;
 
-    public abstract KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager)
+    public abstract KeyboardFocusManagerPeer getKeyboardFocusManagerPeer()
         throws HeadlessException;
 
     /**
@@ -463,6 +463,19 @@
         if (event == null) {
             throw new NullPointerException();
         }
+
+        AWTAccessor.SequencedEventAccessor sea = AWTAccessor.getSequencedEventAccessor();
+        if (sea != null && sea.isSequencedEvent(event)) {
+            AWTEvent nested = sea.getNested(event);
+            if (nested.getID() == WindowEvent.WINDOW_LOST_FOCUS &&
+                nested instanceof TimedWindowEvent)
+            {
+                TimedWindowEvent twe = (TimedWindowEvent)nested;
+                ((SunToolkit)Toolkit.getDefaultToolkit()).
+                    setWindowDeactivationTime((Window)twe.getSource(), twe.getWhen());
+            }
+        }
+
         // All events posted via this method are system-generated.
         // Placing the following call here reduces considerably the
         // number of places throughout the toolkit that would
@@ -1863,6 +1876,28 @@
         return false;
     }
 
+    private static final Object DEACTIVATION_TIMES_MAP_KEY = new Object();
+
+    public synchronized void setWindowDeactivationTime(Window w, long time) {
+        AppContext ctx = getAppContext(w);
+        WeakHashMap<Window, Long> map = (WeakHashMap<Window, Long>)ctx.get(DEACTIVATION_TIMES_MAP_KEY);
+        if (map == null) {
+            map = new WeakHashMap<Window, Long>();
+            ctx.put(DEACTIVATION_TIMES_MAP_KEY, map);
+        }
+        map.put(w, time);
+    }
+
+    public synchronized long getWindowDeactivationTime(Window w) {
+        AppContext ctx = getAppContext(w);
+        WeakHashMap<Window, Long> map = (WeakHashMap<Window, Long>)ctx.get(DEACTIVATION_TIMES_MAP_KEY);
+        if (map == null) {
+            return -1;
+        }
+        Long time = map.get(w);
+        return time == null ? -1 : time;
+    }
+
     // Cosntant alpha
     public boolean isWindowOpacitySupported() {
         return false;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/awt/TimedWindowEvent.java	Fri Sep 14 10:14:02 2012 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.awt;
+
+import java.awt.event.WindowEvent;
+import java.awt.Window;
+
+public class TimedWindowEvent extends WindowEvent {
+
+    private long time;
+
+    public long getWhen() {
+        return time;
+    }
+
+    public TimedWindowEvent(Window source, int id, Window opposite, long time) {
+        super(source, id, opposite);
+        this.time = time;
+    }
+
+    public TimedWindowEvent(Window source, int id, Window opposite,
+                            int oldState, int newState, long time)
+    {
+        super(source, id, opposite, oldState, newState);
+        this.time = time;
+    }
+}
+
--- a/src/share/classes/sun/invoke/util/ValueConversions.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/classes/sun/invoke/util/ValueConversions.java	Fri Sep 14 10:14:02 2012 -0700
@@ -44,6 +44,7 @@
     static {
         final Object[] values = { 255 };
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                @Override
                 public Void run() {
                     values[0] = Integer.getInteger(THIS_CLASS.getName()+".MAX_ARITY", 255);
                     return null;
@@ -182,7 +183,7 @@
      */
     public static Number primitiveConversion(Wrapper wrap, Object x, boolean cast) {
         // Maybe merge this code with Wrapper.convert/cast.
-        Number res = null;
+        Number res;
         if (x == null) {
             if (!cast)  return null;
             return ZERO_INT;
@@ -322,11 +323,9 @@
 
     static void ignore(Object x) {
         // no value to return; this is an unbox of null
-        return;
     }
 
     static void empty() {
-        return;
     }
 
     static Object zeroObject() {
@@ -390,24 +389,6 @@
     /// Converting references to references.
 
     /**
-     * Value-killing function.
-     * @param x an arbitrary reference value
-     * @return a null
-     */
-    static Object alwaysNull(Object x) {
-        return null;
-    }
-
-    /**
-     * Value-killing function.
-     * @param x an arbitrary reference value
-     * @return a zero
-     */
-    static int alwaysZero(Object x) {
-        return 0;
-    }
-
-    /**
      * Identity function.
      * @param x an arbitrary reference value
      * @return the same value x
@@ -416,6 +397,10 @@
         return x;
     }
 
+    static <T> T[] identity(T[] x) {
+        return x;
+    }
+
     /**
      * Identity function on ints.
      * @param x an arbitrary int value
@@ -468,29 +453,33 @@
         return t.cast(x);
     }
 
-    private static final MethodHandle IDENTITY, CAST_REFERENCE, ALWAYS_NULL, ALWAYS_ZERO, ZERO_OBJECT, IGNORE, EMPTY, NEW_ARRAY;
+    private static final MethodHandle IDENTITY, CAST_REFERENCE, ZERO_OBJECT, IGNORE, EMPTY,
+            ARRAY_IDENTITY, FILL_NEW_TYPED_ARRAY, FILL_NEW_ARRAY;
     static {
         try {
             MethodType idType = MethodType.genericMethodType(1);
             MethodType castType = idType.insertParameterTypes(0, Class.class);
-            MethodType alwaysZeroType = idType.changeReturnType(int.class);
             MethodType ignoreType = idType.changeReturnType(void.class);
             MethodType zeroObjectType = MethodType.genericMethodType(0);
             IDENTITY = IMPL_LOOKUP.findStatic(THIS_CLASS, "identity", idType);
             //CAST_REFERENCE = IMPL_LOOKUP.findVirtual(Class.class, "cast", idType);
             CAST_REFERENCE = IMPL_LOOKUP.findStatic(THIS_CLASS, "castReference", castType);
-            ALWAYS_NULL = IMPL_LOOKUP.findStatic(THIS_CLASS, "alwaysNull", idType);
-            ALWAYS_ZERO = IMPL_LOOKUP.findStatic(THIS_CLASS, "alwaysZero", alwaysZeroType);
             ZERO_OBJECT = IMPL_LOOKUP.findStatic(THIS_CLASS, "zeroObject", zeroObjectType);
             IGNORE = IMPL_LOOKUP.findStatic(THIS_CLASS, "ignore", ignoreType);
             EMPTY = IMPL_LOOKUP.findStatic(THIS_CLASS, "empty", ignoreType.dropParameterTypes(0, 1));
-            NEW_ARRAY = IMPL_LOOKUP.findStatic(THIS_CLASS, "newArray", MethodType.methodType(Object[].class, int.class));
+            ARRAY_IDENTITY = IMPL_LOOKUP.findStatic(THIS_CLASS, "identity", MethodType.methodType(Object[].class, Object[].class));
+            FILL_NEW_ARRAY = IMPL_LOOKUP
+                    .findStatic(THIS_CLASS, "fillNewArray",
+                          MethodType.methodType(Object[].class, Integer.class, Object[].class));
+            FILL_NEW_TYPED_ARRAY = IMPL_LOOKUP
+                    .findStatic(THIS_CLASS, "fillNewTypedArray",
+                          MethodType.methodType(Object[].class, Object[].class, Integer.class, Object[].class));
         } catch (NoSuchMethodException | IllegalAccessException ex) {
             throw new InternalError("uncaught exception", ex);
         }
     }
 
-    // Varargs methods need to be in a separately initialized class, to bootstrapping problems.
+    // Varargs methods need to be in a separately initialized class, to avoid bootstrapping problems.
     static class LazyStatics {
         private static final MethodHandle COPY_AS_REFERENCE_ARRAY, COPY_AS_PRIMITIVE_ARRAY, MAKE_LIST;
         static {
@@ -505,34 +494,64 @@
         }
     }
 
+    static MethodHandle collectArguments(MethodHandle mh, int pos, MethodHandle collector) {
+        // FIXME: API needs public MHs.collectArguments.
+        // Should be:
+        //   return MethodHandles.collectArguments(mh, 0, collector);
+        // The rest of this code is a workaround for not having that API.
+        if (COLLECT_ARGUMENTS != null) {
+            try {
+                return (MethodHandle)
+                    COLLECT_ARGUMENTS.invokeExact(mh, pos, collector);
+            } catch (Throwable ex) {
+                if (ex instanceof RuntimeException)
+                    throw (RuntimeException) ex;
+                if (ex instanceof Error)
+                    throw (Error) ex;
+                throw new Error(ex.getMessage(), ex);
+            }
+        }
+        // Emulate MHs.collectArguments using fold + drop.
+        // This is slightly inefficient.
+        // More seriously, it can put a MH over the 255-argument limit.
+        mh = MethodHandles.dropArguments(mh, 1, collector.type().parameterList());
+        mh = MethodHandles.foldArguments(mh, collector);
+        return mh;
+    }
+    private static final MethodHandle COLLECT_ARGUMENTS;
+    static {
+        MethodHandle mh = null;
+        try {
+            java.lang.reflect.Method m = MethodHandles.class
+                .getDeclaredMethod("collectArguments",
+                    MethodHandle.class, int.class, MethodHandle.class);
+            m.setAccessible(true);
+            mh = IMPL_LOOKUP.unreflect(m);
+
+        } catch (ReflectiveOperationException | SecurityException ex) {
+            throw new InternalError(ex);
+        }
+        COLLECT_ARGUMENTS = mh;
+    }
+
     private static final EnumMap<Wrapper, MethodHandle>[] WRAPPER_CASTS
-            = newWrapperCaches(2);
+            = newWrapperCaches(1);
 
     /** Return a method that casts its sole argument (an Object) to the given type
-     *  and returns it as the given type (if exact is true), or as plain Object (if erase is true).
+     *  and returns it as the given type.
      */
     public static MethodHandle cast(Class<?> type) {
-        boolean exact = false;
         if (type.isPrimitive())  throw new IllegalArgumentException("cannot cast primitive type "+type);
-        MethodHandle mh = null;
+        MethodHandle mh;
         Wrapper wrap = null;
         EnumMap<Wrapper, MethodHandle> cache = null;
         if (Wrapper.isWrapperType(type)) {
             wrap = Wrapper.forWrapperType(type);
-            cache = WRAPPER_CASTS[exact?1:0];
+            cache = WRAPPER_CASTS[0];
             mh = cache.get(wrap);
             if (mh != null)  return mh;
         }
-        if (VerifyType.isNullReferenceConversion(Object.class, type))
-            mh = IDENTITY;
-        else if (VerifyType.isNullType(type))
-            mh = ALWAYS_NULL;
-        else
-            mh = MethodHandles.insertArguments(CAST_REFERENCE, 0, type);
-        if (exact) {
-            MethodType xmt = MethodType.methodType(type, Object.class);
-            mh = MethodHandles.explicitCastArguments(mh, xmt);
-        }
+        mh = MethodHandles.insertArguments(CAST_REFERENCE, 0, type);
         if (cache != null)
             cache.put(wrap, mh);
         return mh;
@@ -920,37 +939,47 @@
     }
     private static final MethodHandle[] ARRAYS = makeArrays();
 
-    // mh-fill versions of the above:
-    private static Object[] newArray(int len) { return new Object[len]; }
+    // filling versions of the above:
+    // using Integer len instead of int len and no varargs to avoid bootstrapping problems
+    private static Object[] fillNewArray(Integer len, Object[] /*not ...*/ args) {
+        Object[] a = new Object[len];
+        fillWithArguments(a, 0, args);
+        return a;
+    }
+    private static Object[] fillNewTypedArray(Object[] example, Integer len, Object[] /*not ...*/ args) {
+        Object[] a = Arrays.copyOf(example, len);
+        fillWithArguments(a, 0, args);
+        return a;
+    }
     private static void fillWithArguments(Object[] a, int pos, Object... args) {
         System.arraycopy(args, 0, a, pos, args.length);
     }
     // using Integer pos instead of int pos to avoid bootstrapping problems
-    private static Object[] fillArray(Object[] a, Integer pos, Object a0)
+    private static Object[] fillArray(Integer pos, Object[] a, Object a0)
                 { fillWithArguments(a, pos, a0); return a; }
-    private static Object[] fillArray(Object[] a, Integer pos, Object a0, Object a1)
+    private static Object[] fillArray(Integer pos, Object[] a, Object a0, Object a1)
                 { fillWithArguments(a, pos, a0, a1); return a; }
-    private static Object[] fillArray(Object[] a, Integer pos, Object a0, Object a1, Object a2)
+    private static Object[] fillArray(Integer pos, Object[] a, Object a0, Object a1, Object a2)
                 { fillWithArguments(a, pos, a0, a1, a2); return a; }
-    private static Object[] fillArray(Object[] a, Integer pos, Object a0, Object a1, Object a2, Object a3)
+    private static Object[] fillArray(Integer pos, Object[] a, Object a0, Object a1, Object a2, Object a3)
                 { fillWithArguments(a, pos, a0, a1, a2, a3); return a; }
-    private static Object[] fillArray(Object[] a, Integer pos, Object a0, Object a1, Object a2, Object a3,
+    private static Object[] fillArray(Integer pos, Object[] a, Object a0, Object a1, Object a2, Object a3,
                                   Object a4)
                 { fillWithArguments(a, pos, a0, a1, a2, a3, a4); return a; }
-    private static Object[] fillArray(Object[] a, Integer pos, Object a0, Object a1, Object a2, Object a3,
+    private static Object[] fillArray(Integer pos, Object[] a, Object a0, Object a1, Object a2, Object a3,
                                   Object a4, Object a5)
                 { fillWithArguments(a, pos, a0, a1, a2, a3, a4, a5); return a; }
-    private static Object[] fillArray(Object[] a, Integer pos, Object a0, Object a1, Object a2, Object a3,
+    private static Object[] fillArray(Integer pos, Object[] a, Object a0, Object a1, Object a2, Object a3,
                                   Object a4, Object a5, Object a6)
                 { fillWithArguments(a, pos, a0, a1, a2, a3, a4, a5, a6); return a; }
-    private static Object[] fillArray(Object[] a, Integer pos, Object a0, Object a1, Object a2, Object a3,
+    private static Object[] fillArray(Integer pos, Object[] a, Object a0, Object a1, Object a2, Object a3,
                                   Object a4, Object a5, Object a6, Object a7)
                 { fillWithArguments(a, pos, a0, a1, a2, a3, a4, a5, a6, a7); return a; }
-    private static Object[] fillArray(Object[] a, Integer pos, Object a0, Object a1, Object a2, Object a3,
+    private static Object[] fillArray(Integer pos, Object[] a, Object a0, Object a1, Object a2, Object a3,
                                   Object a4, Object a5, Object a6, Object a7,
                                   Object a8)
                 { fillWithArguments(a, pos, a0, a1, a2, a3, a4, a5, a6, a7, a8); return a; }
-    private static Object[] fillArray(Object[] a, Integer pos, Object a0, Object a1, Object a2, Object a3,
+    private static Object[] fillArray(Integer pos, Object[] a, Object a0, Object a1, Object a2, Object a3,
                                   Object a4, Object a5, Object a6, Object a7,
                                   Object a8, Object a9)
                 { fillWithArguments(a, pos, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); return a; }
@@ -958,7 +987,7 @@
         ArrayList<MethodHandle> mhs = new ArrayList<>();
         mhs.add(null);  // there is no empty fill; at least a0 is required
         for (;;) {
-            MethodHandle mh = findCollector("fillArray", mhs.size(), Object[].class, Object[].class, Integer.class);
+            MethodHandle mh = findCollector("fillArray", mhs.size(), Object[].class, Integer.class, Object[].class);
             if (mh == null)  break;
             mhs.add(mh);
         }
@@ -984,69 +1013,95 @@
         if (mh != null)  return mh;
         mh = findCollector("array", nargs, Object[].class);
         if (mh != null)  return ARRAYS[nargs] = mh;
-        MethodHandle producer = filler(0);  // identity function produces result
-        return ARRAYS[nargs] = buildVarargsArray(producer, nargs);
+        mh = buildVarargsArray(FILL_NEW_ARRAY, ARRAY_IDENTITY, nargs);
+        assert(assertCorrectArity(mh, nargs));
+        return ARRAYS[nargs] = mh;
     }
 
-    private static MethodHandle buildVarargsArray(MethodHandle producer, int nargs) {
+    private static boolean assertCorrectArity(MethodHandle mh, int arity) {
+        assert(mh.type().parameterCount() == arity) : "arity != "+arity+": "+mh;
+        return true;
+    }
+
+    private static MethodHandle buildVarargsArray(MethodHandle newArray, MethodHandle finisher, int nargs) {
         // Build up the result mh as a sequence of fills like this:
-        //   producer(fill(fill(fill(newArray(23),0,x1..x10),10,x11..x20),20,x21..x23))
+        //   finisher(fill(fill(newArrayWA(23,x1..x10),10,x11..x20),20,x21..x23))
         // The various fill(_,10*I,___*[J]) are reusable.
-        MethodHandle filler = filler(nargs);
-        MethodHandle mh = producer;
-        mh = MethodHandles.dropArguments(mh, 1, filler.type().parameterList());
-        mh = MethodHandles.foldArguments(mh, filler);
-        mh = MethodHandles.foldArguments(mh, buildNewArray(nargs));
+        int leftLen = Math.min(nargs, LEFT_ARGS);  // absorb some arguments immediately
+        int rightLen = nargs - leftLen;
+        MethodHandle leftCollector = newArray.bindTo(nargs);
+        leftCollector = leftCollector.asCollector(Object[].class, leftLen);
+        MethodHandle mh = finisher;
+        if (rightLen > 0) {
+            MethodHandle rightFiller = fillToRight(LEFT_ARGS + rightLen);
+            if (mh == ARRAY_IDENTITY)
+                mh = rightFiller;
+            else
+                mh = collectArguments(mh, 0, rightFiller);
+        }
+        if (mh == ARRAY_IDENTITY)
+            mh = leftCollector;
+        else
+            mh = collectArguments(mh, 0, leftCollector);
         return mh;
     }
 
-    private static MethodHandle buildNewArray(int nargs) {
-        return MethodHandles.insertArguments(NEW_ARRAY, 0, nargs);
-    }
-
-    private static final MethodHandle[] FILLERS = new MethodHandle[MAX_ARITY+1];
-    // filler(N).invoke(a, arg0..arg[N-1]) fills a[0]..a[N-1]
-    private static MethodHandle filler(int nargs) {
-        MethodHandle filler = FILLERS[nargs];
+    private static final int LEFT_ARGS = (FILL_ARRAYS.length - 1);
+    private static final MethodHandle[] FILL_ARRAY_TO_RIGHT = new MethodHandle[MAX_ARITY+1];
+    /** fill_array_to_right(N).invoke(a, argL..arg[N-1])
+     *  fills a[L]..a[N-1] with corresponding arguments,
+     *  and then returns a.  The value L is a global constant (LEFT_ARGS).
+     */
+    private static MethodHandle fillToRight(int nargs) {
+        MethodHandle filler = FILL_ARRAY_TO_RIGHT[nargs];
         if (filler != null)  return filler;
-        return FILLERS[nargs] = buildFiller(nargs);
+        filler = buildFiller(nargs);
+        assert(assertCorrectArity(filler, nargs - LEFT_ARGS + 1));
+        return FILL_ARRAY_TO_RIGHT[nargs] = filler;
     }
     private static MethodHandle buildFiller(int nargs) {
-        if (nargs == 0)
-            return MethodHandles.identity(Object[].class);
-        final int CHUNK = (FILL_ARRAYS.length - 1);
+        if (nargs <= LEFT_ARGS)
+            return ARRAY_IDENTITY;  // no args to fill; return the array unchanged
+        // we need room for both mh and a in mh.invoke(a, arg*[nargs])
+        final int CHUNK = LEFT_ARGS;
         int rightLen = nargs % CHUNK;
-        int leftLen = nargs - rightLen;
+        int midLen = nargs - rightLen;
         if (rightLen == 0) {
-            leftLen = nargs - (rightLen = CHUNK);
-            if (FILLERS[leftLen] == null) {
+            midLen = nargs - (rightLen = CHUNK);
+            if (FILL_ARRAY_TO_RIGHT[midLen] == null) {
                 // build some precursors from left to right
-                for (int j = 0; j < leftLen; j += CHUNK)  filler(j);
+                for (int j = LEFT_ARGS % CHUNK; j < midLen; j += CHUNK)
+                    if (j > LEFT_ARGS)  fillToRight(j);
             }
         }
-        MethodHandle leftFill = filler(leftLen);  // recursive fill
-        MethodHandle rightFill = FILL_ARRAYS[rightLen];
-        rightFill = MethodHandles.insertArguments(rightFill, 1, leftLen);  // [leftLen..nargs-1]
+        if (midLen < LEFT_ARGS) rightLen = nargs - (midLen = LEFT_ARGS);
+        assert(rightLen > 0);
+        MethodHandle midFill = fillToRight(midLen);  // recursive fill
+        MethodHandle rightFill = FILL_ARRAYS[rightLen].bindTo(midLen);  // [midLen..nargs-1]
+        assert(midFill.type().parameterCount()   == 1 + midLen - LEFT_ARGS);
+        assert(rightFill.type().parameterCount() == 1 + rightLen);
 
-        // Combine the two fills: right(left(newArray(nargs), x1..x20), x21..x23)
-        MethodHandle mh = filler(0);  // identity function produces result
-        mh = MethodHandles.dropArguments(mh, 1, rightFill.type().parameterList());
-        mh = MethodHandles.foldArguments(mh, rightFill);
-        if (leftLen > 0) {
-            mh = MethodHandles.dropArguments(mh, 1, leftFill.type().parameterList());
-            mh = MethodHandles.foldArguments(mh, leftFill);
-        }
-        return mh;
+        // Combine the two fills:
+        //   right(mid(a, x10..x19), x20..x23)
+        // The final product will look like this:
+        //   right(mid(newArrayLeft(24, x0..x9), x10..x19), x20..x23)
+        if (midLen == LEFT_ARGS)
+            return rightFill;
+        else
+            return collectArguments(rightFill, 0, midFill);
     }
 
     // Type-polymorphic version of varargs maker.
     private static final ClassValue<MethodHandle[]> TYPED_COLLECTORS
         = new ClassValue<MethodHandle[]>() {
+            @Override
             protected MethodHandle[] computeValue(Class<?> type) {
                 return new MethodHandle[256];
             }
     };
 
+    static final int MAX_JVM_ARITY = 255;  // limit imposed by the JVM
+
     /** Return a method handle that takes the indicated number of
      *  typed arguments and returns an array of them.
      *  The type argument is the array type.
@@ -1055,16 +1110,36 @@
         Class<?> elemType = arrayType.getComponentType();
         if (elemType == null)  throw new IllegalArgumentException("not an array: "+arrayType);
         // FIXME: Need more special casing and caching here.
+        if (nargs >= MAX_JVM_ARITY/2 - 1) {
+            int slots = nargs;
+            final int MAX_ARRAY_SLOTS = MAX_JVM_ARITY - 1;  // 1 for receiver MH
+            if (arrayType == double[].class || arrayType == long[].class)
+                slots *= 2;
+            if (slots > MAX_ARRAY_SLOTS)
+                throw new IllegalArgumentException("too many arguments: "+arrayType.getSimpleName()+", length "+nargs);
+        }
         if (elemType == Object.class)
             return varargsArray(nargs);
         // other cases:  primitive arrays, subtypes of Object[]
         MethodHandle cache[] = TYPED_COLLECTORS.get(elemType);
         MethodHandle mh = nargs < cache.length ? cache[nargs] : null;
         if (mh != null)  return mh;
-        MethodHandle producer = buildArrayProducer(arrayType);
-        mh = buildVarargsArray(producer, nargs);
+        if (elemType.isPrimitive()) {
+            MethodHandle builder = FILL_NEW_ARRAY;
+            MethodHandle producer = buildArrayProducer(arrayType);
+            mh = buildVarargsArray(builder, producer, nargs);
+        } else {
+            @SuppressWarnings("unchecked")
+            Class<? extends Object[]> objArrayType = (Class<? extends Object[]>) arrayType;
+            Object[] example = Arrays.copyOf(NO_ARGS_ARRAY, 0, objArrayType);
+            MethodHandle builder = FILL_NEW_TYPED_ARRAY.bindTo(example);
+            MethodHandle producer = ARRAY_IDENTITY;
+            mh = buildVarargsArray(builder, producer, nargs);
+        }
         mh = mh.asType(MethodType.methodType(arrayType, Collections.<Class<?>>nCopies(nargs, elemType)));
-        cache[nargs] = mh;
+        assert(assertCorrectArity(mh, nargs));
+        if (nargs < cache.length)
+            cache[nargs] = mh;
         return mh;
     }
 
--- a/src/share/demo/applets/CardTest/example1.html	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/demo/applets/CardTest/example1.html	Fri Sep 14 10:14:02 2012 -0700
@@ -5,7 +5,7 @@
   <body>
       <h1>Card Test (1.1)</h1>
       <hr>
-      <applet code=CardTest.class width=400 height=300>
+      <applet code=CardTest.class width=455 height=300>
 	alt="Your browser understands the &lt;APPLET&gt; tag but isn't running the applet, for some reason."
 	Your browser is completely ignoring the &lt;APPLET&gt; tag!
       </applet>
--- a/src/share/demo/applets/DitherTest/example1.html	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/demo/applets/DitherTest/example1.html	Fri Sep 14 10:14:02 2012 -0700
@@ -5,7 +5,7 @@
   <body>
       <h1>Dither Test (1.1)</h1>
       <hr>
-      <applet code=DitherTest.class width=425 height=400>
+      <applet code=DitherTest.class width=455 height=400>
 	alt="Your browser understands the &lt;APPLET&gt; tag but isn't running the applet, for some reason."
 	Your browser is completely ignoring the &lt;APPLET&gt; tag!
       </applet>
--- a/src/share/demo/jvmti/hprof/debug_malloc.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/demo/jvmti/hprof/debug_malloc.h	Fri Sep 14 10:14:02 2012 -0700
@@ -59,6 +59,11 @@
 #include <stdlib.h>
 #include <string.h>
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* The real functions behind the macro curtains. */
 
 void           *debug_malloc(size_t, const char *, int);
@@ -71,10 +76,10 @@
 
 void            debug_malloc_verify(const char*, int);
 #undef malloc_verify
-#define malloc_verify()     debug_malloc_verify(__FILE__, __LINE__)
+#define malloc_verify()     debug_malloc_verify(THIS_FILE, __LINE__)
 
 void            debug_malloc_police(const char*, int);
 #undef malloc_police
-#define malloc_police()     debug_malloc_police(__FILE__, __LINE__)
+#define malloc_police()     debug_malloc_police(THIS_FILE, __LINE__)
 
 #endif
--- a/src/share/demo/jvmti/hprof/hprof_error.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/demo/jvmti/hprof/hprof_error.h	Fri Sep 14 10:14:02 2012 -0700
@@ -41,20 +41,25 @@
 #ifndef HPROF_ERROR_H
 #define HPROF_ERROR_H
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* Macros over assert and error functions so we can capture the source loc. */
 
 #define HPROF_BOOL(x) ((jboolean)((x)==0?JNI_FALSE:JNI_TRUE))
 
 #define HPROF_ERROR(fatal,msg) \
-    error_handler(HPROF_BOOL(fatal), JVMTI_ERROR_NONE, msg, __FILE__, __LINE__)
+    error_handler(HPROF_BOOL(fatal), JVMTI_ERROR_NONE, msg, THIS_FILE, __LINE__)
 
 #define HPROF_JVMTI_ERROR(error,msg) \
     error_handler(HPROF_BOOL(error!=JVMTI_ERROR_NONE), \
-            error, msg, __FILE__, __LINE__)
+            error, msg, THIS_FILE, __LINE__)
 
 #if defined(DEBUG) || !defined(NDEBUG)
     #define HPROF_ASSERT(cond) \
-        (((int)(cond))?(void)0:error_assert(#cond, __FILE__, __LINE__))
+        (((int)(cond))?(void)0:error_assert(#cond, THIS_FILE, __LINE__))
 #else
     #define HPROF_ASSERT(cond)
 #endif
@@ -77,11 +82,11 @@
 #define LOG_FORMAT(format)      "HPROF LOG: " format " [%s:%d]\n"
 
 #define LOG1(str1)              LOG_STDERR((stderr, LOG_FORMAT("%s"), \
-                                    str1, __FILE__, __LINE__ ))
+                                    str1, THIS_FILE, __LINE__ ))
 #define LOG2(str1,str2)         LOG_STDERR((stderr, LOG_FORMAT("%s %s"), \
-                                    str1, str2, __FILE__, __LINE__ ))
+                                    str1, str2, THIS_FILE, __LINE__ ))
 #define LOG3(str1,str2,num)     LOG_STDERR((stderr, LOG_FORMAT("%s %s 0x%x"), \
-                                    str1, str2, num, __FILE__, __LINE__ ))
+                                    str1, str2, num, THIS_FILE, __LINE__ ))
 
 #define LOG(str) LOG1(str)
 
--- a/src/share/demo/jvmti/hprof/hprof_util.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/demo/jvmti/hprof/hprof_util.h	Fri Sep 14 10:14:02 2012 -0700
@@ -41,6 +41,11 @@
 #ifndef HPROF_UTIL_H
 #define HPROF_UTIL_H
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* Macros that protect code from accidently using a local ref improperly */
 #define WITH_LOCAL_REFS(env, number)            \
     {                                           \
@@ -184,8 +189,8 @@
 #ifdef DEBUG
     void *        hprof_debug_malloc(int size, char *file, int line);
     void          hprof_debug_free(void *ptr, char *file, int line);
-    #define HPROF_MALLOC(size)  hprof_debug_malloc(size, __FILE__, __LINE__)
-    #define HPROF_FREE(ptr)     hprof_debug_free(ptr, __FILE__, __LINE__)
+    #define HPROF_MALLOC(size)  hprof_debug_malloc(size, THIS_FILE, __LINE__)
+    #define HPROF_FREE(ptr)     hprof_debug_free(ptr, THIS_FILE, __LINE__)
 #else
     #define HPROF_MALLOC(size)  hprof_malloc(size)
     #define HPROF_FREE(ptr)     hprof_free(ptr)
--- a/src/share/demo/jvmti/java_crw_demo/java_crw_demo.c	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/demo/jvmti/java_crw_demo/java_crw_demo.c	Fri Sep 14 10:14:02 2012 -0700
@@ -70,12 +70,20 @@
 
 /* Macros over error functions to capture line numbers */
 
-#define CRW_FATAL(ci, message) fatal_error(ci, message, __FILE__, __LINE__)
+/* Fatal error used in all builds. */
+
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE "java_crw.demo.c" /* Never use __FILE__ */
+#endif
+
+#define CRW_FATAL(ci, message) fatal_error(ci, message, THIS_FILE, __LINE__)
 
 #if defined(DEBUG) || !defined(NDEBUG)
 
+  /* This assert macro is only used in the debug builds. */
   #define CRW_ASSERT(ci, cond) \
-        ((cond)?(void)0:assert_error(ci, #cond, __FILE__, __LINE__))
+        ((cond)?(void)0:assert_error(ci, #cond, THIS_FILE, __LINE__))
 
 #else
 
--- a/src/share/instrument/JPLISAssert.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/instrument/JPLISAssert.h	Fri Sep 14 10:14:02 2012 -0700
@@ -49,10 +49,14 @@
 #define JPLISASSERT_ENABLEASSERTIONS    (0)
 #endif
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
 
 #if JPLISASSERT_ENABLEASSERTIONS
-#define jplis_assert(x)             JPLISAssertCondition((jboolean)(x), #x, __FILE__, __LINE__)
-#define jplis_assert_msg(x, msg)    JPLISAssertConditionWithMessage((jboolean)(x), #x, msg, __FILE__, __LINE__)
+#define jplis_assert(x)             JPLISAssertCondition((jboolean)(x), #x, THIS_FILE, __LINE__)
+#define jplis_assert_msg(x, msg)    JPLISAssertConditionWithMessage((jboolean)(x), #x, msg, THIS_FILE, __LINE__)
 #else
 #define jplis_assert(x)
 #define jplis_assert_msg(x, msg)
--- a/src/share/native/sun/awt/debug/debug_assert.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/native/sun/awt/debug/debug_assert.h	Fri Sep 14 10:14:02 2012 -0700
@@ -32,17 +32,22 @@
 
 #include "debug_util.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #if defined(DEBUG)
 
 #define DASSERT(_expr) \
         if ( !(_expr) ) { \
-            DAssert_Impl( #_expr, __FILE__, __LINE__); \
+            DAssert_Impl( #_expr, THIS_FILE, __LINE__); \
         } else { \
         }
 
 #define DASSERTMSG(_expr, _msg) \
         if ( !(_expr) ) { \
-            DAssert_Impl( (_msg), __FILE__, __LINE__); \
+            DAssert_Impl( (_msg), THIS_FILE, __LINE__); \
         } else { \
         }
 
--- a/src/share/native/sun/awt/debug/debug_mem.c	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/native/sun/awt/debug/debug_mem.c	Fri Sep 14 10:14:02 2012 -0700
@@ -27,6 +27,11 @@
 
 #include "debug_util.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define DMEM_MIN(a,b)   (a) < (b) ? (a) : (b)
 #define DMEM_MAX(a,b)   (a) > (b) ? (a) : (b)
 
@@ -291,7 +296,7 @@
     DMutex_Enter(DMemMutex);
 
     /* Force memory leaks to be output regardless of trace settings */
-    DTrace_EnableFile(__FILE__, TRUE);
+    DTrace_EnableFile(THIS_FILE, TRUE);
     DTRACE_PRINTLN("--------------------------");
     DTRACE_PRINTLN("Debug Memory Manager Leaks");
     DTRACE_PRINTLN("--------------------------");
--- a/src/share/native/sun/awt/debug/debug_trace.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/native/sun/awt/debug/debug_trace.h	Fri Sep 14 10:14:02 2012 -0700
@@ -34,6 +34,11 @@
 
 #include "debug_util.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 typedef int     dtrace_id;
 enum {
     UNDEFINED_TRACE_ID = -1 /* indicates trace point has not been registered yet */
@@ -69,7 +74,7 @@
 #define _DTrace_Template(_func, _ac, _f, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) \
 { \
     static dtrace_id _dt_lineid_ = UNDEFINED_TRACE_ID; \
-    DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, __FILE__, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \
+    DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, THIS_FILE, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \
 }
 
 /* printf style trace macros */
--- a/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h	Fri Sep 14 10:14:02 2012 -0700
@@ -452,7 +452,12 @@
 void *p11malloc(size_t c, char *file, int line);
 void p11free(void *p, char *file, int line);
 
-#define malloc(c)       (p11malloc((c), __FILE__, __LINE__))
-#define free(c)         (p11free((c), __FILE__, __LINE__))
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
+#define malloc(c)       (p11malloc((c), THIS_FILE, __LINE__))
+#define free(c)         (p11free((c), THIS_FILE, __LINE__))
 
 #endif
--- a/src/share/npt/utf.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/npt/utf.h	Fri Sep 14 10:14:02 2012 -0700
@@ -33,8 +33,13 @@
 #include "jni.h"
 #include "utf_md.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* Error and assert macros */
-#define UTF_ERROR(m) utfError(__FILE__, __LINE__,  m)
+#define UTF_ERROR(m) utfError(THIS_FILE, __LINE__,  m)
 #define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR("ASSERT ERROR " #x) : (void)0 )
 
 void utfError(char *file, int line, char *message);
--- a/src/share/transport/shmem/shmemBase.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/share/transport/shmem/shmemBase.h	Fri Sep 14 10:14:02 2012 -0700
@@ -49,11 +49,16 @@
 jint shmemBase_name(SharedMemoryTransport *, char **name);
 jint shmemBase_getlasterror(char *msg, jint size);
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #ifdef DEBUG
 #define SHMEM_ASSERT(expression)  \
 do {                            \
     if (!(expression)) {                \
-        exitTransportWithError("assertion failed", __FILE__, __DATE__, __LINE__); \
+        exitTransportWithError("assertion failed", THIS_FILE, __DATE__, __LINE__); \
     } \
 } while (0)
 #else
@@ -63,7 +68,7 @@
 #define SHMEM_GUARANTEE(expression) \
 do {                            \
     if (!(expression)) {                \
-        exitTransportWithError("assertion failed", __FILE__, __DATE__, __LINE__); \
+        exitTransportWithError("assertion failed", THIS_FILE, __DATE__, __LINE__); \
     } \
 } while (0)
 
--- a/src/solaris/classes/sun/awt/X11/XBaseWindow.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/solaris/classes/sun/awt/X11/XBaseWindow.java	Fri Sep 14 10:14:02 2012 -0700
@@ -1001,6 +1001,13 @@
         switch (xev.get_type()) {
         case XConstants.ButtonPress:
             if (buttonState == 0) {
+                XWindowPeer parent = getToplevelXWindow();
+                // See 6385277, 6981400.
+                if (parent != null && parent.isFocusableWindow()) {
+                    // A click in a client area drops the actual focused window retaining.
+                    parent.setActualFocusedWindow(null);
+                    parent.requestWindowFocus(xbe.get_time(), true);
+                }
                 XAwtState.setAutoGrabWindow(this);
             }
             break;
--- a/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Fri Sep 14 10:14:02 2012 -0700
@@ -588,33 +588,6 @@
 
     }
 
-    public void handleButtonPressRelease(XEvent xev) {
-        /*
-         * Fix for 6385277.
-         * We request focus on simple Window by click in order
-         * to make it behave like Frame/Dialog in this case and also to unify
-         * the behaviour with what we have on MS Windows.
-         * handleJavaMouseEvent() would be more suitable place to do this
-         * but we want Swing to have this functionality also.
-         */
-        if (xev.get_type() == XConstants.ButtonPress) {
-            final XWindowPeer parentXWindow = getParentTopLevel();
-            Window parentWindow = (Window)parentXWindow.getTarget();
-            if (parentXWindow.isFocusableWindow() && parentXWindow.isSimpleWindow() &&
-                XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow() != parentWindow)
-            {
-                postEvent(new InvocationEvent(parentWindow, new  Runnable() {
-                        public void run() {
-                            // Request focus on the EDT of 'parentWindow' because
-                            // XDecoratedPeer.requestWindowFocus() calls client code.
-                            parentXWindow.requestXFocus();
-                        }
-                    }));
-            }
-        }
-        super.handleButtonPressRelease(xev);
-    }
-
     public Dimension getMinimumSize() {
         return target.getSize();
     }
--- a/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Fri Sep 14 10:14:02 2012 -0700
@@ -1108,7 +1108,7 @@
         focusLog.fine("Request for decorated window focus");
         // If this is Frame or Dialog we can't assure focus request success - but we still can try
         // If this is Window and its owner Frame is active we can be sure request succedded.
-        Window focusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow();
+        Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();
         Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow);
 
         focusLog.finer("Current window is: active={0}, focused={1}",
@@ -1201,7 +1201,7 @@
     }
 
     public void handleWindowFocusOut(Window oppositeWindow, long serial) {
-        Window actualFocusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow();
+        Window actualFocusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();
 
         // If the actual focused window is not this decorated window then retain it.
         if (actualFocusedWindow != null && actualFocusedWindow != target) {
--- a/src/solaris/classes/sun/awt/X11/XDialogPeer.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/solaris/classes/sun/awt/X11/XDialogPeer.java	Fri Sep 14 10:14:02 2012 -0700
@@ -135,7 +135,7 @@
      * Thus we don't have to perform any transitive (a blocker of a blocker) checks.
      */
     boolean isFocusedWindowModalBlocker() {
-        Window focusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow();
+        Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();
         XWindowPeer focusedWindowPeer = null;
 
         if (focusedWindow != null) {
--- a/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java	Fri Sep 14 10:14:02 2012 -0700
@@ -96,11 +96,11 @@
     public void handleEvent(AWTEvent e) {
         switch (e.getID()) {
           case FocusEvent.FOCUS_GAINED:
-              XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(proxy);
+              XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(proxy);
               container.focusGained(handle);
               break;
           case FocusEvent.FOCUS_LOST:
-              XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(null);
+              XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
               container.focusLost(handle);
               break;
           case KeyEvent.KEY_PRESSED:
@@ -172,7 +172,7 @@
         if (lightweightChild == null) {
             lightweightChild = (Component)proxy;
         }
-        Component currentOwner = XKeyboardFocusManagerPeer.getCurrentNativeFocusOwner();
+        Component currentOwner = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusOwner();
         if (currentOwner != null && currentOwner.getPeer() == null) {
             currentOwner = null;
         }
@@ -224,7 +224,8 @@
               if (parent != null) {
                   Window parentWindow = (Window)parent;
                   // and check that it is focused
-                  if (!parentWindow.isFocused() && XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow() == parentWindow) {
+                  if (!parentWindow.isFocused() &&
+                      XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() == parentWindow) {
                       // if it is not - skip requesting focus on Solaris
                       // but return true for compatibility.
                       return true;
--- a/src/solaris/classes/sun/awt/X11/XEmbedClientHelper.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/solaris/classes/sun/awt/X11/XEmbedClientHelper.java	Fri Sep 14 10:14:02 2012 -0700
@@ -204,7 +204,7 @@
         // XEMBED_FOCUS_OUT client messages), so we first need to check if
         // embedded is an active window before sending WINDOW_LOST_FOCUS
         // to shared code
-        if (XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow() == embedded.target) {
+        if (XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() == embedded.target) {
             embedded.handleWindowFocusOut(null, 0);
         }
     }
--- a/src/solaris/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/solaris/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java	Fri Sep 14 10:14:02 2012 -0700
@@ -25,66 +25,48 @@
 package sun.awt.X11;
 
 import java.awt.Component;
-import java.awt.KeyboardFocusManager;
 import java.awt.Window;
-
-import java.awt.event.FocusEvent;
-
-import java.awt.peer.KeyboardFocusManagerPeer;
-import java.awt.peer.ComponentPeer;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
 import sun.util.logging.PlatformLogger;
-
 import sun.awt.CausedFocusEvent;
-import sun.awt.SunToolkit;
 import sun.awt.KeyboardFocusManagerPeerImpl;
 
 public class XKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
     private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XKeyboardFocusManagerPeer");
+    private static final XKeyboardFocusManagerPeer inst = new XKeyboardFocusManagerPeer();
 
-    private static Object lock = new Object() {};
-    private static Component currentFocusOwner;
-    private static Window currentFocusedWindow;
+    private Component currentFocusOwner;
+    private Window currentFocusedWindow;
 
-    XKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
-        super(manager);
+    public static XKeyboardFocusManagerPeer getInstance() {
+        return inst;
+    }
+
+    private XKeyboardFocusManagerPeer() {
     }
 
     @Override
     public void setCurrentFocusOwner(Component comp) {
-        setCurrentNativeFocusOwner(comp);
+        synchronized (this) {
+            currentFocusOwner = comp;
+        }
     }
 
     @Override
     public Component getCurrentFocusOwner() {
-        return getCurrentNativeFocusOwner();
-    }
-
-    @Override
-    public Window getCurrentFocusedWindow() {
-        return getCurrentNativeFocusedWindow();
-    }
-
-    public static void setCurrentNativeFocusOwner(Component comp) {
-        synchronized (lock) {
-            currentFocusOwner = comp;
-        }
-    }
-
-    public static Component getCurrentNativeFocusOwner() {
-        synchronized(lock) {
+        synchronized(this) {
             return currentFocusOwner;
         }
     }
 
-    public static void setCurrentNativeFocusedWindow(Window win) {
-        if (focusLog.isLoggable(PlatformLogger.FINER)) focusLog.finer("Setting current native focused window " + win);
+    @Override
+    public void setCurrentFocusedWindow(Window win) {
+        if (focusLog.isLoggable(PlatformLogger.FINER)) {
+            focusLog.finer("Setting current focused window " + win);
+        }
+
         XWindowPeer from = null, to = null;
 
-        synchronized(lock) {
+        synchronized(this) {
             if (currentFocusedWindow != null) {
                 from = (XWindowPeer)currentFocusedWindow.getPeer();
             }
@@ -104,8 +86,9 @@
         }
     }
 
-    public static Window getCurrentNativeFocusedWindow() {
-        synchronized(lock) {
+    @Override
+    public Window getCurrentFocusedWindow() {
+        synchronized(this) {
             return currentFocusedWindow;
         }
     }
@@ -124,6 +107,6 @@
                                                          focusedWindowChangeAllowed,
                                                          time,
                                                          cause,
-                                                         getCurrentNativeFocusOwner());
+                                                         getInstance().getCurrentFocusOwner());
     }
 }
--- a/src/solaris/classes/sun/awt/X11/XToolkit.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/solaris/classes/sun/awt/X11/XToolkit.java	Fri Sep 14 10:14:02 2012 -0700
@@ -663,7 +663,7 @@
                 long w = 0;
                 if (windowToXWindow(ev.get_xany().get_window()) != null) {
                     Component owner =
-                        XKeyboardFocusManagerPeer.getCurrentNativeFocusOwner();
+                        XKeyboardFocusManagerPeer.getInstance().getCurrentFocusOwner();
                     if (owner != null) {
                         XWindow ownerWindow = (XWindow) AWTAccessor.getComponentAccessor().getPeer(owner);
                         if (ownerWindow != null) {
@@ -1155,9 +1155,8 @@
         return peer;
     }
 
-    public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) throws HeadlessException {
-        XKeyboardFocusManagerPeer peer = new XKeyboardFocusManagerPeer(manager);
-        return peer;
+    public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() throws HeadlessException {
+        return XKeyboardFocusManagerPeer.getInstance();
     }
 
     /**
--- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Fri Sep 14 10:14:02 2012 -0700
@@ -617,7 +617,7 @@
 
     public void handleWindowFocusIn_Dispatch() {
         if (EventQueue.isDispatchThread()) {
-            XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target);
+            XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow((Window) target);
             WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
             SunToolkit.setSystemGenerated(we);
             target.dispatchEvent(we);
@@ -626,7 +626,7 @@
 
     public void handleWindowFocusInSync(long serial) {
         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
-        XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target);
+        XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow((Window) target);
         sendEvent(we);
     }
     // NOTE: This method may be called by privileged threads.
@@ -634,7 +634,7 @@
     public void handleWindowFocusIn(long serial) {
         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
         /* wrap in Sequenced, then post*/
-        XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target);
+        XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow((Window) target);
         postEvent(wrapInSequenced((AWTEvent) we));
     }
 
@@ -642,15 +642,15 @@
     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
     public void handleWindowFocusOut(Window oppositeWindow, long serial) {
         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
-        XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow(null);
-        XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(null);
+        XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow(null);
+        XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
         /* wrap in Sequenced, then post*/
         postEvent(wrapInSequenced((AWTEvent) we));
     }
     public void handleWindowFocusOutSync(Window oppositeWindow, long serial) {
         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
-        XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow(null);
-        XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(null);
+        XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow(null);
+        XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
         sendEvent(we);
     }
 
@@ -1138,7 +1138,7 @@
             // getWMState() always returns 0 (Withdrawn) for simple windows. Hence
             // we ignore the state for such windows.
             if (isVisible() && (state == XUtilConstants.NormalState || isSimpleWindow())) {
-                if (XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow() ==
+                if (XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() ==
                         getTarget())
                 {
                     show = true;
@@ -1165,15 +1165,25 @@
     }
 
     public void dispose() {
+        if (isGrabbed()) {
+            if (grabLog.isLoggable(PlatformLogger.FINE)) {
+                grabLog.fine("Generating UngrabEvent on {0} because of the window disposal", this);
+            }
+            postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource()));
+        }
+
         SunToolkit.awtLock();
+
         try {
             windows.remove(this);
         } finally {
             SunToolkit.awtUnlock();
         }
+
         if (warningWindow != null) {
             warningWindow.destroy();
         }
+
         removeRootPropertyEventDispatcher();
         mustControlStackPosition = false;
         super.dispose();
@@ -1185,12 +1195,13 @@
          * receive WM_TAKE_FOCUS.
          */
         if (isSimpleWindow()) {
-            if (target == XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow()) {
+            if (target == XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow()) {
                 Window owner = getDecoratedOwner((Window)target);
                 ((XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(owner)).requestWindowFocus();
             }
         }
     }
+
     boolean isResizable() {
         return winAttr.isResizable;
     }
@@ -1825,7 +1836,7 @@
         // If this is Frame or Dialog we can't assure focus request success - but we still can try
         // If this is Window and its owner Frame is active we can be sure request succedded.
         Window ownerWindow  = XWindowPeer.getDecoratedOwner((Window)target);
-        Window focusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow();
+        Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();
         Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow);
 
         if (isWMStateNetHidden()) {
--- a/src/solaris/instrument/EncodingSupport_md.c	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/solaris/instrument/EncodingSupport_md.c	Fri Sep 14 10:14:02 2012 -0700
@@ -33,8 +33,13 @@
 
 /* Routines to convert back and forth between Platform Encoding and UTF-8 */
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* Error and assert macros */
-#define UTF_ERROR(m) utfError(__FILE__, __LINE__,  m)
+#define UTF_ERROR(m) utfError(THIS_FILE, __LINE__,  m)
 #define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR("ASSERT ERROR " #x) : (void)0 )
 #define UTF_DEBUG(x)
 
--- a/src/windows/classes/sun/awt/windows/WKeyboardFocusManagerPeer.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/windows/classes/sun/awt/windows/WKeyboardFocusManagerPeer.java	Fri Sep 14 10:14:02 2012 -0700
@@ -25,7 +25,6 @@
 
 package sun.awt.windows;
 
-import java.awt.KeyboardFocusManager;
 import java.awt.Window;
 import java.awt.Component;
 import java.awt.peer.ComponentPeer;
@@ -37,8 +36,13 @@
     static native Component getNativeFocusOwner();
     static native Window getNativeFocusedWindow();
 
-    WKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
-        super(manager);
+    private static final WKeyboardFocusManagerPeer inst = new WKeyboardFocusManagerPeer();
+
+    public static WKeyboardFocusManagerPeer getInstance() {
+        return inst;
+    }
+
+    private WKeyboardFocusManagerPeer() {
     }
 
     @Override
@@ -52,6 +56,12 @@
     }
 
     @Override
+    public void setCurrentFocusedWindow(Window win) {
+        // Not used on Windows
+        throw new RuntimeException("not implemented");
+    }
+
+    @Override
     public Window getCurrentFocusedWindow() {
         return getNativeFocusedWindow();
     }
--- a/src/windows/classes/sun/awt/windows/WToolkit.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/windows/classes/sun/awt/windows/WToolkit.java	Fri Sep 14 10:14:02 2012 -0700
@@ -506,10 +506,10 @@
         return true;
     }
 
-    public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager)
+    public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer()
       throws HeadlessException
     {
-        return new WKeyboardFocusManagerPeer(manager);
+        return WKeyboardFocusManagerPeer.getInstance();
     }
 
     protected native void setDynamicLayoutNative(boolean b);
--- a/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiIn.cpp	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiIn.cpp	Fri Sep 14 10:14:02 2012 -0700
@@ -35,9 +35,15 @@
 
 #ifdef USE_ERROR
 #include <stdio.h>
+
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define MIDIIN_CHECK_ERROR { \
         if (err != MMSYSERR_NOERROR) \
-            ERROR3("MIDI IN Error in %s:%d : %s\n", __FILE__, __LINE__, MIDI_IN_GetErrorStr((INT32) err)); \
+            ERROR3("MIDI IN Error in %s:%d : %s\n", THIS_FILE, __LINE__, MIDI_IN_GetErrorStr((INT32) err)); \
     }
 #else
 #define MIDIIN_CHECK_ERROR
--- a/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiOut.c	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiOut.c	Fri Sep 14 10:14:02 2012 -0700
@@ -33,9 +33,15 @@
 
 #ifdef USE_ERROR
 #include <stdio.h>
+
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define MIDIOUT_CHECK_ERROR  { \
         if (err != MMSYSERR_NOERROR) \
-            ERROR3("MIDI OUT Error in %s:%d : %s\n", __FILE__, __LINE__, MIDI_OUT_GetErrorStr((INT32) err)); \
+            ERROR3("MIDI OUT Error in %s:%d : %s\n", THIS_FILE, __LINE__, MIDI_OUT_GetErrorStr((INT32) err)); \
         }
 #else
 #define MIDIOUT_CHECK_ERROR
--- a/src/windows/native/sun/java2d/d3d/D3DPipeline.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/windows/native/sun/java2d/d3d/D3DPipeline.h	Fri Sep 14 10:14:02 2012 -0700
@@ -28,6 +28,11 @@
 #define D3D_DEBUG_INFO
 #endif // DEBUG
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE THIS_FILE
+#endif
+
 #ifdef D3D_PPL_DLL
 
 
@@ -104,7 +109,7 @@
 #define ACT_IF_NULL(ACTION, value)         \
     if ((value) == NULL) {                 \
         J2dTraceLn3(J2D_TRACE_ERROR,       \
-                    "%s is null in %s:%d", #value, __FILE__, __LINE__); \
+                    "%s is null in %s:%d", #value, THIS_FILE, __LINE__); \
         ACTION;                            \
     } else do { } while (0)
 #define RETURN_IF_NULL(value)   ACT_IF_NULL(return, value)
@@ -114,12 +119,12 @@
 
 #define RETURN_STATUS_IF_EXP_FAILED(EXPR) \
     if (FAILED(res = (EXPR))) {                    \
-        DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## __FILE__); \
+        DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## THIS_FILE); \
         return res;                   \
     } else do { } while (0)
 
 #define RETURN_STATUS_IF_FAILED(status) \
     if (FAILED((status))) {                    \
-        DebugPrintD3DError((status), " failed in " ## __FILE__ ## ", return;");\
+        DebugPrintD3DError((status), " failed in " ## THIS_FILE ## ", return;");\
         return (status);                   \
     } else do { } while (0)
--- a/src/windows/native/sun/windows/alloc.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/windows/native/sun/windows/alloc.h	Fri Sep 14 10:14:02 2012 -0700
@@ -26,6 +26,11 @@
 #ifndef _ALLOC_H_
 #define _ALLOC_H_
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #include "stdhdrs.h"
 
 // By defining std::bad_alloc in a local header file instead of including
@@ -127,12 +132,12 @@
         throw (std::bad_alloc);
 
     #define safe_Malloc(size) \
-        safe_Malloc_outofmem(size, __FILE__, __LINE__)
+        safe_Malloc_outofmem(size, THIS_FILE, __LINE__)
     #define safe_Calloc(num, size) \
-        safe_Calloc_outofmem(num, size, __FILE__, __LINE__)
+        safe_Calloc_outofmem(num, size, THIS_FILE, __LINE__)
     #define safe_Realloc(memblock, size) \
-        safe_Realloc_outofmem(memblock, size, __FILE__, __LINE__)
-    #define new new(__FILE__, __LINE__)
+        safe_Realloc_outofmem(memblock, size, THIS_FILE, __LINE__)
+    #define new new(THIS_FILE, __LINE__)
 #endif /* OUTOFMEM_TEST */
 
 #define TRY \
--- a/src/windows/native/sun/windows/awt_Debug.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/windows/native/sun/windows/awt_Debug.h	Fri Sep 14 10:14:02 2012 -0700
@@ -65,7 +65,12 @@
     #define AWT_DUMP_CLIP_RECTANGLE(_msg, _hwnd) \
         _DTrace_Template(DumpClipRectangle, 2, "", (_msg), (_hwnd), 0, 0, 0, 0, 0, 0)
 
-    #define new         new(__FILE__, __LINE__)
+    /* Use THIS_FILE when it is available. */
+    #ifndef THIS_FILE
+        #define THIS_FILE __FILE__
+    #endif
+
+    #define new         new(THIS_FILE, __LINE__)
 
     #define VERIFY(exp)         DASSERT(exp)
     #define UNIMPLEMENTED()     DASSERT(FALSE)
--- a/src/windows/native/sun/windows/awt_Toolkit.h	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/windows/native/sun/windows/awt_Toolkit.h	Fri Sep 14 10:14:02 2012 -0700
@@ -132,24 +132,30 @@
 
 // Macros for using CriticalSection objects that help trace
 // lock/unlock actions
+
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define CRITICAL_SECTION_ENTER(cs) { \
     J2dTraceLn4(J2D_TRACE_VERBOSE2, \
                 "CS.Wait:  tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
-                GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
+                GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
     (cs).Enter(); \
     J2dTraceLn4(J2D_TRACE_VERBOSE2, \
                 "CS.Enter: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
-                GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
+                GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
 }
 
 #define CRITICAL_SECTION_LEAVE(cs) { \
     J2dTraceLn4(J2D_TRACE_VERBOSE2, \
                 "CS.Leave: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
-                GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
+                GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
     (cs).Leave(); \
     J2dTraceLn4(J2D_TRACE_VERBOSE2, \
                 "CS.Left:  tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
-                GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
+                GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
 }
 
 /************************************************************************
--- a/src/windows/native/sun/windows/awt_Window.cpp	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/windows/native/sun/windows/awt_Window.cpp	Fri Sep 14 10:14:02 2012 -0700
@@ -1477,7 +1477,7 @@
     if (wClassEvent == NULL) {
         if (env->PushLocalFrame(1) < 0)
             return;
-        wClassEvent = env->FindClass("java/awt/event/WindowEvent");
+        wClassEvent = env->FindClass("sun/awt/TimedWindowEvent");
         if (wClassEvent != NULL) {
             wClassEvent = (jclass)env->NewGlobalRef(wClassEvent);
         }
@@ -1491,7 +1491,7 @@
     if (wEventInitMID == NULL) {
         wEventInitMID =
             env->GetMethodID(wClassEvent, "<init>",
-                             "(Ljava/awt/Window;ILjava/awt/Window;II)V");
+                             "(Ljava/awt/Window;ILjava/awt/Window;IIJ)V");
         DASSERT(wEventInitMID);
         if (wEventInitMID == NULL) {
             return;
@@ -1532,7 +1532,7 @@
         }
     }
     jobject event = env->NewObject(wClassEvent, wEventInitMID, target, id,
-                                   jOpposite, oldState, newState);
+                                   jOpposite, oldState, newState, TimeHelper::getMessageTimeUTC());
     DASSERT(!safe_ExceptionOccurred(env));
     DASSERT(event != NULL);
     if (jOpposite != NULL) {
--- a/src/windows/transport/shmem/shmem_md.c	Fri Sep 14 09:47:14 2012 -0700
+++ b/src/windows/transport/shmem/shmem_md.c	Fri Sep 14 10:14:02 2012 -0700
@@ -30,6 +30,11 @@
 #include "sysShmem.h"
 #include "shmemBase.h"  /* for exitTransportWithError */
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /*
  * These functions are not completely universal. For now, they are used
  * exclusively for Jbug's shared memory transport mechanism. They have
@@ -44,7 +49,7 @@
     if (!(expression)) {                \
             exitTransportWithError \
             ("\"%s\", line %d: assertion failure\n", \
-             __FILE__, __DATE__, __LINE__); \
+             THIS_FILE, __DATE__, __LINE__); \
     }                                   \
 }
 #else
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Focus/6981400/Test1.java	Fri Sep 14 10:14:02 2012 -0700
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug     6981400
+ * @summary Tabbing between textfiled do not work properly when ALT+TAB
+ * @author  anton.tarasov
+ * @library ../../regtesthelpers
+ * @build   Util
+ * @run     main Test1
+ */
+
+// This test shows a frame with four focusable components: b0, b1, b2, b3.
+// Then it presses Tab three times. EDT is freezed for a while on the first FOCUS_LOST event.
+// Meantime, the test clicks in a component of another frame and then clicks in the title
+// of the original frame. When EDT awakes and all the queued events get processed,
+// the other frame should ones gain focus and then pass it to the original frame.
+// The b3 component of the orinial frame should finally become a focus owner.
+// The FOCUS_LOST/FOCUS_GAINED events order in the original frame is tracked and should be:
+// b0 -> b1 -> b2 -> b3.
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.swing.*;
+import test.java.awt.regtesthelpers.Util;
+
+public class Test1 {
+    static JFrame f0 = new JFrame("base_frame") { public String getName() {return "base_frame";} };
+    static JButton f0b0 = new JB("b0");
+    static JButton f0b1 = new JB("b1");
+    static JButton f0b2 = new JB("b2");
+    static JButton f0b3 = new JB("b3");
+
+    static JFrame f1 = new JFrame("swing_frame") { public String getName() {return "swing_frame";} };
+    static JButton f1b0 = new JButton("button");
+
+    static Frame f2 = new Frame("awt_frame") { public String getName() {return "awt_frame";} };
+    static Button f2b0 = new Button("button");
+
+    static Robot robot;
+
+    static List<Component> gainedList = new ArrayList<Component>();
+    static List<Component> lostList = new ArrayList<Component>();
+
+    static Component[] refGainedList = new Component[] {f0b1, f0b2, f0b3, f0b3};
+    static Component[] refLostList = new Component[] {f0b0, f0b1, f0b2, f0b3};
+
+    static boolean tracking;
+
+    public static void main(String[] args) {
+        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+            public void eventDispatched(AWTEvent e) {
+                System.out.println(e);
+            }
+        }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_EVENT_MASK);
+
+        try {
+            robot = new Robot();
+        } catch (AWTException ex) {
+            throw new RuntimeException("Error: can't create Robot");
+        }
+
+        f0.add(f0b0);
+        f0.add(f0b1);
+        f0.add(f0b2);
+        f0.add(f0b3);
+        f0.setLayout(new FlowLayout());
+        f0.setBounds(0, 100, 400, 200);
+
+        f1.add(f1b0);
+        f1.setBounds(0, 400, 400, 200);
+
+        f2.add(f2b0);
+        f2.setBounds(0, 400, 400, 200);
+
+        f0b0.addFocusListener(new FocusAdapter() {
+            @Override
+            public void focusLost(FocusEvent e) {
+                try {
+                    Thread.sleep(1000);
+                } catch (Exception ex) {}
+            }
+        });
+
+        //
+        // Case 1. Test against swing JFrame.
+        //
+
+        f1.setVisible(true);
+        f0.setVisible(true);
+
+        Util.waitForIdle(robot);
+
+        if (!f0b0.isFocusOwner()) {
+            Util.clickOnComp(f0b0, robot);
+            Util.waitForIdle(robot);
+            if (!f0b0.isFocusOwner()) {
+                throw new RuntimeException("Error: can't focus the component " + f0b0);
+            }
+        }
+
+        System.out.println("\nTest case 1: swing frame\n");
+        test(f1b0);
+
+        //
+        // Case 2. Test against awt Frame.
+        //
+
+        tracking = false;
+        gainedList.clear();
+        lostList.clear();
+
+        f1.dispose();
+        f2.setAutoRequestFocus(false);
+        f2.setVisible(true);
+        Util.waitForIdle(robot);
+
+        Util.clickOnComp(f0b0, robot);
+        Util.waitForIdle(robot);
+        if (!f0b0.isFocusOwner()) {
+            throw new RuntimeException("Error: can't focus the component " + f0b0);
+        }
+
+        System.out.println("\nTest case 2: awt frame\n");
+        test(f2b0);
+
+        System.out.println("\nTest passed.");
+    }
+
+    public static void test(Component compToClick) {
+        tracking = true;
+
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_TAB);
+        robot.delay(50);
+
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_TAB);
+        robot.delay(50);
+
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_TAB);
+
+        robot.delay(50);
+        Util.clickOnComp(compToClick, robot);
+
+        robot.delay(50);
+        Util.clickOnTitle(f0, robot);
+
+        Util.waitForIdle(robot);
+
+        if (!f0b3.isFocusOwner()) {
+            throw new RuntimeException("Test failed: f0b3 is not a focus owner");
+        }
+
+        if (!"sun.awt.X11.XToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
+
+            if (!Arrays.asList(refGainedList).equals(gainedList)) {
+                System.out.println("gained list: " + gainedList);
+                throw new RuntimeException("Test failed: wrong FOCUS_GAINED events order");
+            }
+            if (!Arrays.asList(refLostList).equals(lostList)) {
+                System.out.println("lost list: " + lostList);
+                throw new RuntimeException("Test failed: wrong FOCUS_LOST events order");
+            }
+        }
+    }
+}
+
+class JB extends JButton {
+    String name;
+
+    public JB(String name) {
+        super(name);
+        this.name = name;
+
+        addFocusListener(new FocusListener() {
+            public void focusGained(FocusEvent e) {
+                if (Test1.tracking)
+                    Test1.gainedList.add(e.getComponent());
+            }
+
+            public void focusLost(FocusEvent e) {
+                if (Test1.tracking)
+                    Test1.lostList.add(e.getComponent());
+            }
+        });
+    }
+
+    public String toString() {
+        return "[" + name + "]";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Focus/6981400/Test2.java	Fri Sep 14 10:14:02 2012 -0700
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug     6981400
+ * @summary Tabbing between textfiled do not work properly when ALT+TAB
+ * @author  anton.tarasov
+ * @library ../../regtesthelpers
+ * @build   Util
+ * @run     main Test2
+ */
+
+// A focus request made after a char is typed ahead shouldn't affect the char's target component.
+
+import java.awt.*;
+import java.awt.event.*;
+import test.java.awt.regtesthelpers.Util;
+
+public class Test2 {
+    static Frame f = new Frame("frame");
+    static TextArea t0 = new TextArea(1, 10) { public String toString() { return "[TA-0]";} };
+    static TextArea t1 = new TextArea(1, 10) { public String toString() { return "[TA-1]";} };
+    static TextArea t2 = new TextArea(1, 10) { public String toString() { return "[TA-2]";} };
+
+    static volatile boolean passed = true;
+
+    static Robot robot;
+
+    public static void main(String[] args) {
+        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+            public void eventDispatched(AWTEvent e) {
+                System.out.println(e);
+                if (e.getID() == KeyEvent.KEY_TYPED) {
+                    if (e.getSource() != t1) {
+                        passed = false;
+                        throw new RuntimeException("Test failed: the key event has wrong source: " + e);
+                    }
+                }
+            }
+        }, FocusEvent.FOCUS_EVENT_MASK | KeyEvent.KEY_EVENT_MASK);
+
+        try {
+            robot = new Robot();
+        } catch (AWTException ex) {
+            throw new RuntimeException("Error: can't create Robot");
+        }
+
+        f.add(t0);
+        f.add(t1);
+        f.add(t2);
+
+        f.setLayout(new FlowLayout());
+        f.pack();
+
+        t0.addFocusListener(new FocusAdapter() {
+            public void focusLost(FocusEvent e) {
+                try {
+                    Thread.sleep(3000);
+                } catch (Exception ex) {}
+            }
+        });
+
+        // The request shouldn't affect the key event delivery.
+        new Thread(new Runnable() {
+            public void run() {
+                try {
+                    Thread.sleep(2000);
+                } catch (Exception ex) {}
+                System.out.println("requesting focus to " + t2);
+                t2.requestFocus();
+            }
+        }).start();
+
+
+        f.setVisible(true);
+        Util.waitForIdle(robot);
+
+        test();
+
+        if (passed) System.out.println("\nTest passed.");
+    }
+
+    static void test() {
+        Util.clickOnComp(t1, robot);
+
+        // The key event should be eventually delivered to t1.
+        robot.delay(50);
+        robot.keyPress(KeyEvent.VK_A);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_A);
+
+        Util.waitForIdle(robot);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Focus/6981400/Test3.java	Fri Sep 14 10:14:02 2012 -0700
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug     6981400
+ * @summary Tabbing between textfiled do not work properly when ALT+TAB
+ * @author  anton.tarasov
+ * @library ../../regtesthelpers
+ * @build   Util
+ * @run     main Test3
+ */
+
+// A menu item in a frame should not be auto-selected when switching by Alt+TAB back and forth.
+
+import java.awt.*;
+import javax.swing.*;
+import java.awt.event.*;
+import test.java.awt.regtesthelpers.Util;
+
+public class Test3 {
+    static JFrame f = new JFrame("Frame");
+    static JMenuBar bar = new JMenuBar();
+    static JMenu menu = new JMenu("File");
+    static JMenuItem item = new JMenuItem("Save");
+
+    static JButton b0 = new JButton("b0");
+    static JButton b1 = new JButton("b1");
+
+    static Robot robot;
+
+    public static void main(String[] args) {
+        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+            public void eventDispatched(AWTEvent e) {
+                System.err.println(e);
+            }
+        }, KeyEvent.KEY_EVENT_MASK);
+
+        try {
+            robot = new Robot();
+        } catch (AWTException ex) {
+            throw new RuntimeException("Error: can't create Robot");
+        }
+
+        try {
+            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+        } catch (Exception e) {}
+
+        b0.addFocusListener(new FocusAdapter() {
+            public void focusLost(FocusEvent f) {
+                try {
+                    Thread.sleep(2000);
+                } catch (Exception e) {}
+            }
+        });
+
+        menu.add(item);
+        bar.add(menu);
+        f.setJMenuBar(bar);
+
+        f.add(b0);
+        f.add(b1);
+
+        f.setLayout(new FlowLayout());
+        f.setSize(400, 100);
+        f.setVisible(true);
+        Util.waitForIdle(robot);
+
+        if (!b0.hasFocus()) {
+            Util.clickOnComp(b0, robot);
+            Util.waitForIdle(robot);
+            if (!b0.hasFocus()) {
+                throw new RuntimeException("Error: can't focus " + b0);
+            }
+        }
+
+        test();
+
+        System.out.println("Test passed.");
+    }
+
+    public static void test() {
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_TAB);
+        robot.delay(50);
+
+        robot.keyPress(KeyEvent.VK_ALT);
+        robot.delay(50);
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_ALT);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_TAB);
+
+        robot.delay(500);
+
+        robot.keyPress(KeyEvent.VK_ALT);
+        robot.delay(50);
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_ALT);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_TAB);
+
+        // Control shot.
+        Util.clickOnTitle(f, robot);
+        Util.waitForIdle(robot);
+
+        if (menu.isSelected()) {
+            throw new RuntimeException("Test failed: the menu gets selected");
+        }
+        if (!b1.hasFocus()) {
+            throw new RuntimeException("Test failed: the button is not a focus owner " + b1);
+        }
+    }
+}
+
+
--- a/test/java/beans/Introspector/6380849/TestBeanInfo.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/test/java/beans/Introspector/6380849/TestBeanInfo.java	Fri Sep 14 10:14:02 2012 -0700
@@ -38,8 +38,7 @@
 
 import java.beans.BeanInfo;
 import java.beans.Introspector;
-import java.lang.ref.Reference;
-import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 
 public class TestBeanInfo implements Runnable {
 
@@ -60,10 +59,9 @@
         try {
             actual = Introspector.getBeanInfo(type);
             type = actual.getClass();
-            Field field = type.getDeclaredField("targetBeanInfoRef"); // NON-NLS: field name
-            field.setAccessible(true);
-            Reference ref = (Reference) field.get(actual);
-            actual = (BeanInfo) ref.get();
+            Method method = type.getDeclaredMethod("getTargetBeanInfo"); // NON-NLS: method name
+            method.setAccessible(true);
+            actual = (BeanInfo) method.invoke(actual);
         }
         catch (Exception exception) {
             throw new Error("unexpected error", exception);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/Introspector/Test7186794.java	Fri Sep 14 10:14:02 2012 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2012, 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 7186794
+ * @summary Tests setter in the super class
+ * @author Sergey Malenkov
+ */
+
+import java.util.List;
+
+public class Test7186794 {
+
+    public static void main(String[] args) {
+        if (null == BeanUtils.findPropertyDescriptor(MyBean.class, "value").getWriteMethod()) {
+            throw new Error("The property setter is not found");
+        }
+    }
+
+    public static class BaseBean {
+
+        protected List<String> value;
+
+        public void setValue(List<String> value) {
+            this.value = value;
+        }
+    }
+
+    public static class MyBean extends BaseBean {
+        public List<String> getValue() {
+            return super.value;
+        }
+    }
+}
--- a/test/java/beans/Introspector/Test7189112.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/test/java/beans/Introspector/Test7189112.java	Fri Sep 14 10:14:02 2012 -0700
@@ -28,17 +28,11 @@
  * @author Sergey Malenkov
  */
 
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-
 public class Test7189112 {
 
-    public static void main(String[] args) throws IntrospectionException {
-        for (PropertyDescriptor pd : Introspector.getBeanInfo(MyBean.class).getPropertyDescriptors()) {
-            if (pd.getName().equals("value") && (null == pd.getWriteMethod())) {
-                throw new Error("The property setter is not found");
-            }
+    public static void main(String[] args) {
+        if (null == BeanUtils.findPropertyDescriptor(MyBean.class, "value").getWriteMethod()) {
+            throw new Error("The property setter is not found");
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/Introspector/Test7192955.java	Fri Sep 14 10:14:02 2012 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2012, 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 7192955
+ * @summary Tests that all properties are bound
+ * @author Sergey Malenkov
+ */
+
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+public class Test7192955 {
+
+    public static void main(String[] args) {
+        if (!BeanUtils.findPropertyDescriptor(MyBean.class, "test").isBound()) {
+            throw new Error("a simple property is not bound");
+        }
+        if (!BeanUtils.findPropertyDescriptor(MyBean.class, "list").isBound()) {
+            throw new Error("a generic property is not bound");
+        }
+        if (!BeanUtils.findPropertyDescriptor(MyBean.class, "readOnly").isBound()) {
+            throw new Error("a read-only property is not bound");
+        }
+    }
+
+    public static class BaseBean {
+
+        private List<String> list;
+
+        public List<String> getList() {
+            return this.list;
+        }
+
+        public void setList(List<String> list) {
+            this.list = list;
+        }
+
+        public void addPropertyChangeListener(PropertyChangeListener listener) {
+        }
+
+        public void removePropertyChangeListener(PropertyChangeListener listener) {
+        }
+
+        public List<String> getReadOnly() {
+            return this.list;
+        }
+    }
+
+    public static class MyBean extends BaseBean {
+
+        private String test;
+
+        public String getTest() {
+            return this.test;
+        }
+
+        public void setTest(String test) {
+            this.test = test;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/Introspector/Test7195106.java	Fri Sep 14 10:14:02 2012 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, 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 7195106
+ * @summary Tests that explicit BeanInfo is not collected
+ * @author Sergey Malenkov
+ */
+
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.SimpleBeanInfo;
+
+public class Test7195106 {
+
+    public static void main(String[] arg) throws Exception {
+        BeanInfo info = Introspector.getBeanInfo(My.class);
+        if (null == info.getIcon(BeanInfo.ICON_COLOR_16x16)) {
+            throw new Error("Unexpected behavior");
+        }
+        try {
+            int[] array = new int[1024];
+            while (true) {
+                array = new int[array.length << 1];
+            }
+        }
+        catch (OutOfMemoryError error) {
+            System.gc();
+        }
+        if (null == info.getIcon(BeanInfo.ICON_COLOR_16x16)) {
+            throw new Error("Explicit BeanInfo is collected");
+        }
+    }
+
+    public static class My {
+    }
+
+    public static class MyBeanInfo extends SimpleBeanInfo {
+        @Override
+        public Image getIcon(int type) {
+            return new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/XMLEncoder/Test7169395.java	Fri Sep 14 10:14:02 2012 -0700
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2012, 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 7169395
+ * @summary Tests that array list initialized correctly
+ * @author Sergey Malenkov
+ */
+
+import java.beans.ConstructorProperties;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class Test7169395 extends AbstractTest {
+
+    public static void main(String[] args) {
+        new Test7169395().test(true);
+    }
+
+    protected Object getObject() {
+        Container container = new Container();
+        container.add("test-null", null);
+        container.add("test-value", "value");
+        container.add("test-other", "other");
+        return container;
+    }
+
+    public static class Component {
+
+        private final Container container;
+        private final String name;
+        private String value;
+
+        @ConstructorProperties({ "container", "name" })
+        public Component(Container container, String name) {
+            this.container = container;
+            this.name = name;
+        }
+
+        public Container getContainer() {
+            return this.container;
+        }
+
+        public String getName() {
+            return this.name;
+        }
+
+        public String getValue() {
+            return this.value;
+        }
+
+        public void setValue(String value) {
+            this.value = value;
+        }
+    }
+
+    public static class Container {
+
+        private final Map<String, Component> map = new TreeMap<String, Component>();
+
+        public Collection<Component> getComponents() {
+            return new ArrayList<Component>(this.map.values());
+        }
+
+        public void setComponents(Collection<Component> components) {
+            this.map.clear();
+            for (Component component : components){
+                this.map.put(component.getName(), component);
+            }
+        }
+
+        public void add(String name, String value) {
+            Component list = new Component(this, name);
+            list.setValue(value);
+            this.map.put(name, list);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/invoke/BigArityTest.java	Fri Sep 14 10:14:02 2012 -0700
@@ -0,0 +1,1044 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @summary High arity invocations, up to the maximum of 255 arguments
+ * @compile BigArityTest.java
+ * @run junit/othervm -DBigArityTest.ITERATION_COUNT=1 test.java.lang.invoke.BigArityTest
+ */
+
+package test.java.lang.invoke;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.lang.invoke.WrongMethodTypeException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Objects;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class BigArityTest {
+
+    static MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
+
+    static final int MAX_JVM_ARITY = 255;
+    static final int ITERATION_COUNT = getProperty("ITERATION_COUNT", 40000);
+    static final int MIN_ARITY = getProperty("MIN_ARITY", 250);
+    static final int SLOW_ARITY = getProperty("SLOW_ARITY", MAX_JVM_ARITY-3);
+    static final int MAX_ARITY = getProperty("MAX_ARITY", MAX_JVM_ARITY-1);  // always -1 for the MH reciever itself
+    private static int getProperty(String name, int dflt) {
+        return Integer.parseInt(getProperty(name, ""+dflt));
+    }
+    private static String getProperty(String name, String dflt) {
+        String x = System.getProperty(BigArityTest.class.getSimpleName() + "." + name);
+        if (x == null)  x = System.getProperty(BigArityTest.class.getName() + "." + name);
+        return x == null ? dflt : x;
+    }
+
+    static Object hashArguments(Object... args) {
+        return Objects.hash(args);
+    }
+    static final MethodHandle MH_hashArguments_VA;
+    static {
+        try {
+            MH_hashArguments_VA =
+                MethodHandles.lookup().unreflect(
+                    BigArityTest.class.getDeclaredMethod("hashArguments", Object[].class));
+        } catch (ReflectiveOperationException ex) {
+            throw new InternalError(ex);
+        }
+    }
+    static MethodHandle MH_hashArguments(int arity) {
+        MethodType mt = MethodType.genericMethodType(arity);
+        return MH_hashArguments_VA.asType(mt);
+    }
+    static MethodHandle MH_hashArguments(Class<? extends Object[]> arrayClass, int arity) {
+        if (arrayClass == Object[].class)
+            return MH_hashArguments(arity);
+        ArrayList<Class<?>> ptypes = new ArrayList<>(Collections.<Class<?>>nCopies(arity, arrayClass.getComponentType()));
+        MethodType mt = MethodType.methodType(Object.class, ptypes);
+        return MH_hashArguments_VA.asType(mt);
+    }
+
+    static Object[] testArgs(int arity) {
+        Object args[] = new Object[arity];
+        for (int i = 0; i < arity; i++)
+            args[i] = i * (i + 1) / 2;
+        return args;
+    }
+
+    @Test
+    public void testBoundaryValues() throws Throwable {
+        for (int badArity : new int[]{ -1, MAX_JVM_ARITY+1, MAX_JVM_ARITY }) {
+            try {
+                MethodHandle badmh = MH_hashArguments(badArity);
+                throw new AssertionError("should not be able to build a 255-arity MH: "+badmh);
+            } catch (IllegalArgumentException | WrongMethodTypeException ex) {
+                System.out.println("OK: "+ex);
+            }
+        }
+    }
+
+    // Make sure the basic argument spreading and varargs mechanisms are working.
+    // Exercise arity 3 thoroughly.
+    @Test
+    public void testSpreads() throws Throwable {
+        System.out.println("testing asSpreader on arity=3");
+        Object[] args = testArgs(3);
+        int r0 = Objects.hash(args);
+        MethodHandle mh = MH_hashArguments(3);
+        Object r;
+        r = mh.invokeExact(args[0], args[1], args[2]);
+        assertEquals(r0, r);
+        r = mh.invoke(args[0], args[1], args[2]);
+        assertEquals(r0, r);
+        r = mh.invoke((Comparable) args[0], (Integer) args[1], (Number) args[2]);
+        assertEquals(r0, r);
+        r = mh.invokeWithArguments(args);
+        assertEquals(r0, r);
+        for (Class<?> cls0 : new Class<?>[] {
+            Object[].class, Number[].class, Integer[].class, Comparable[].class
+        }) {
+            @SuppressWarnings("unchecked")
+            Class<? extends Object[]> cls = (Class<? extends Object[]>) cls0;
+            //Class<? extends Object[]> cls = Object[].class.asSubclass(cls0);
+            int nargs = args.length, skip;
+            MethodHandle smh = mh.asSpreader(cls, nargs - (skip = 0));
+            Object[] tail = Arrays.copyOfRange(args, skip, nargs, cls);
+            if (cls == Object[].class)
+                r = smh.invokeExact(tail);
+            else if (cls == Integer[].class)
+                r = smh.invokeExact((Integer[]) tail);
+            else
+                r = smh.invoke(tail);
+            assertEquals(r0, r);
+            smh = mh.asSpreader(cls, nargs - (skip = 1));
+            tail = Arrays.copyOfRange(args, skip, nargs, cls);
+            if (cls == Object[].class)
+                r = smh.invokeExact(args[0], tail);
+            else if (cls == Integer[].class)
+                r = smh.invokeExact(args[0], (Integer[]) tail);
+            else
+                r = smh.invoke(args[0], tail);
+            assertEquals(r0, r);
+            smh = mh.asSpreader(cls, nargs - (skip = 2));
+            tail = Arrays.copyOfRange(args, skip, nargs, cls);
+            if (cls == Object[].class)
+                r = smh.invokeExact(args[0], args[1], tail);
+            else if (cls == Integer[].class)
+                r = smh.invokeExact(args[0], args[1], (Integer[]) tail);
+            else
+                r = smh.invoke(args[0], args[1], tail);
+            assertEquals(r0, r);
+            smh = mh.asSpreader(cls, nargs - (skip = 3));
+            tail = Arrays.copyOfRange(args, skip, nargs, cls);
+            if (cls == Object[].class)
+                r = smh.invokeExact(args[0], args[1], args[2], tail);
+            else if (cls == Integer[].class)
+                r = smh.invokeExact(args[0], args[1], args[2], (Integer[]) tail);
+            else
+                r = smh.invoke(args[0], args[1], args[2], tail);
+            assertEquals(r0, r);
+            // Try null array in addition to zero-length array:
+            tail = null;
+            if (cls == Object[].class)
+                r = smh.invokeExact(args[0], args[1], args[2], tail);
+            else if (cls == Integer[].class)
+                r = smh.invokeExact(args[0], args[1], args[2], (Integer[]) tail);
+            else
+                r = smh.invoke(args[0], args[1], args[2], tail);
+            assertEquals(r0, r);
+        }
+    }
+
+    @Test
+    public void testInvokeWithArguments() throws Throwable {
+        System.out.println("testing invokeWithArguments on all arities");
+        for (int arity = 0; arity < MAX_ARITY; arity++) {
+            Object[] args = testArgs(arity);
+            Object r0 = Objects.hash(args);
+            Object r = MH_hashArguments(arity).invokeWithArguments(args);
+            assertEquals("arity="+arity, r0, r);
+        }
+        // The next one is the most likely to fail:
+        int arity = MAX_ARITY;
+        Object[] args = testArgs(arity);
+        Object r0 = Objects.hash(args);
+        Object r = MH_hashArguments(arity).invokeWithArguments(args);
+        assertEquals("arity=MAX_ARITY", r0, r);
+    }
+
+    static Object[] cat(Object a, Object[] b) {
+        int alen = 1, blen = b.length;
+        Object[] c = new Object[alen + blen];
+        c[0] = a;
+        System.arraycopy(b, 0, c, alen, blen);
+        return c;
+    }
+
+    @Test
+    public void testArities() throws Throwable {
+        System.out.println("testing spreaders and collectors on high arities...");
+            int iterations = ITERATION_COUNT;
+        testArities(Object[].class, MIN_ARITY-10, MIN_ARITY-1, iterations / 1000);
+        testArities(Object[].class, MIN_ARITY, SLOW_ARITY-1, iterations);
+        testArities(Object[].class, SLOW_ARITY, MAX_ARITY, iterations / 1000);
+    }
+
+    @Test
+    public void testAritiesOnTypedArrays() throws Throwable {
+        for (Class<?> cls0 : new Class<?>[] {
+            Number[].class, Integer[].class, Comparable[].class
+        }) {
+            @SuppressWarnings("unchecked")
+            Class<? extends Object[]> cls = (Class<? extends Object[]>) cls0;
+            System.out.println("array class: "+cls.getSimpleName());
+            int iterations = ITERATION_COUNT / 1000;
+            testArities(cls, MIN_ARITY, SLOW_ARITY-1, iterations);
+            testArities(cls, SLOW_ARITY, MAX_ARITY, iterations / 100);
+        }
+    }
+
+    private void testArities(Class<? extends Object[]> cls,
+                             int minArity,
+                             int maxArity,
+                             int iterations) throws Throwable {
+        boolean verbose = (cls == Object[].class);
+        for (int arity = minArity; arity <= maxArity; arity++) {
+            if (verbose)  System.out.println("arity="+arity);
+            MethodHandle mh = MH_hashArguments(cls, arity);
+            MethodHandle mh_VA = mh.asSpreader(cls, arity);
+            assert(mh_VA.type().parameterType(0) == cls);
+            testArities(cls, arity, iterations, verbose, mh, mh_VA);
+            if (cls != Object[].class) {
+                // mh_CA will collect arguments of a particular type and pass them to mh_VA
+                MethodHandle mh_CA = mh_VA.asCollector(cls, arity);
+                MethodHandle mh_VA2 = mh_CA.asSpreader(cls, arity);
+                try {
+                    mh_VA2.invokeWithArguments(new Object[arity]);
+                    throw new AssertionError("should not reach");
+                } catch (ClassCastException | WrongMethodTypeException ex) {
+                }
+                assert(mh_CA.type().equals(mh.type()));
+                assert(mh_VA2.type().equals(mh_VA.type()));
+                testArities(cls, arity, iterations, false, mh_CA, mh_VA2);
+            }
+        }
+    }
+    private void testArities(Class<? extends Object[]> cls,
+                             int arity,
+                             int iterations,
+                             boolean verbose,
+                             MethodHandle mh,
+                             MethodHandle mh_VA
+                             ) throws Throwable {
+        if (iterations < 4)  iterations = 4;
+        final int MAX_MH_ARITY      = MAX_JVM_ARITY - 1;  // mh.invoke(arg*[N])
+        final int MAX_INVOKER_ARITY = MAX_MH_ARITY - 1;   // inv.invoke(mh, arg*[N])
+        Object[] args = testArgs(arity);
+        if (cls != Object[].class)
+            args = Arrays.copyOf(args, arity, cls);
+        Object r0 = Objects.hash(args);
+        Object r;
+        MethodHandle ximh = null;
+        MethodHandle gimh = null;
+        if (arity <= MAX_INVOKER_ARITY) {
+            ximh = MethodHandles.exactInvoker(mh.type());
+            gimh = MethodHandles.invoker(mh.type());
+        } else {
+            try {
+                ximh = MethodHandles.exactInvoker(mh.type());
+                throw new AssertionError("should fail to create ximh of arity "+arity);
+            } catch (IllegalArgumentException ex) {
+                if (verbose)
+                    System.out.println("OK: xmih["+arity+"] => "+ex);
+            }
+            try {
+                gimh = MethodHandles.invoker(mh.type());
+                throw new AssertionError("should fail to create gimh of arity "+arity);
+            } catch (IllegalArgumentException ex) {
+                if (verbose)
+                    System.out.println("OK: gmih["+arity+"] => "+ex);
+            }
+        }
+        Object[] mh_args = cat(mh, args);
+        assert(arity <= MAX_MH_ARITY);
+        for (int i = 0; i < iterations; ++i) {
+            if (cls == Object[].class)
+                r = mh_VA.invokeExact(args);
+            else if (cls == Integer[].class)
+                r = mh_VA.invokeExact((Integer[])args);
+            else
+                r = mh_VA.invoke(args);
+            assertEquals(r0, r);
+            r = mh.invokeWithArguments(args);
+            assertEquals(r0, r);
+            if (ximh != null) {
+                r = ximh.invokeWithArguments(mh_args);
+                assertEquals(r0, r);
+            }
+            if (gimh != null) {
+                r = gimh.invokeWithArguments(mh_args);
+                assertEquals(r0, r);
+            }
+        }
+    }
+
+    static Object hashArguments_252(
+    // <editor-fold defaultstate="collapsed" desc="Object x00, Object x01, Object x02, Object x03, Object x04, ...">
+    Object x00, Object x01, Object x02, Object x03, Object x04, Object x05, Object x06, Object x07,
+    Object x08, Object x09, Object x0A, Object x0B, Object x0C, Object x0D, Object x0E, Object x0F,
+    Object x10, Object x11, Object x12, Object x13, Object x14, Object x15, Object x16, Object x17,
+    Object x18, Object x19, Object x1A, Object x1B, Object x1C, Object x1D, Object x1E, Object x1F,
+    Object x20, Object x21, Object x22, Object x23, Object x24, Object x25, Object x26, Object x27,
+    Object x28, Object x29, Object x2A, Object x2B, Object x2C, Object x2D, Object x2E, Object x2F,
+    Object x30, Object x31, Object x32, Object x33, Object x34, Object x35, Object x36, Object x37,
+    Object x38, Object x39, Object x3A, Object x3B, Object x3C, Object x3D, Object x3E, Object x3F,
+    Object x40, Object x41, Object x42, Object x43, Object x44, Object x45, Object x46, Object x47,
+    Object x48, Object x49, Object x4A, Object x4B, Object x4C, Object x4D, Object x4E, Object x4F,
+    Object x50, Object x51, Object x52, Object x53, Object x54, Object x55, Object x56, Object x57,
+    Object x58, Object x59, Object x5A, Object x5B, Object x5C, Object x5D, Object x5E, Object x5F,
+    Object x60, Object x61, Object x62, Object x63, Object x64, Object x65, Object x66, Object x67,
+    Object x68, Object x69, Object x6A, Object x6B, Object x6C, Object x6D, Object x6E, Object x6F,
+    Object x70, Object x71, Object x72, Object x73, Object x74, Object x75, Object x76, Object x77,
+    Object x78, Object x79, Object x7A, Object x7B, Object x7C, Object x7D, Object x7E, Object x7F,
+    Object x80, Object x81, Object x82, Object x83, Object x84, Object x85, Object x86, Object x87,
+    Object x88, Object x89, Object x8A, Object x8B, Object x8C, Object x8D, Object x8E, Object x8F,
+    Object x90, Object x91, Object x92, Object x93, Object x94, Object x95, Object x96, Object x97,
+    Object x98, Object x99, Object x9A, Object x9B, Object x9C, Object x9D, Object x9E, Object x9F,
+    Object xA0, Object xA1, Object xA2, Object xA3, Object xA4, Object xA5, Object xA6, Object xA7,
+    Object xA8, Object xA9, Object xAA, Object xAB, Object xAC, Object xAD, Object xAE, Object xAF,
+    Object xB0, Object xB1, Object xB2, Object xB3, Object xB4, Object xB5, Object xB6, Object xB7,
+    Object xB8, Object xB9, Object xBA, Object xBB, Object xBC, Object xBD, Object xBE, Object xBF,
+    Object xC0, Object xC1, Object xC2, Object xC3, Object xC4, Object xC5, Object xC6, Object xC7,
+    Object xC8, Object xC9, Object xCA, Object xCB, Object xCC, Object xCD, Object xCE, Object xCF,
+    Object xD0, Object xD1, Object xD2, Object xD3, Object xD4, Object xD5, Object xD6, Object xD7,
+    Object xD8, Object xD9, Object xDA, Object xDB, Object xDC, Object xDD, Object xDE, Object xDF,
+    Object xE0, Object xE1, Object xE2, Object xE3, Object xE4, Object xE5, Object xE6, Object xE7,
+    Object xE8, Object xE9, Object xEA, Object xEB, Object xEC, Object xED, Object xEE, Object xEF,
+    Object xF0, Object xF1, Object xF2, Object xF3, Object xF4, Object xF5, Object xF6, Object xF7,
+    // </editor-fold>
+    Object xF8, Object xF9, Object xFA, Object xFB) {
+        return Objects.hash(
+    // <editor-fold defaultstate="collapsed" desc="x00, x01, x02, x03, x04, ...">
+    x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x0A, x0B, x0C, x0D, x0E, x0F,
+    x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x1A, x1B, x1C, x1D, x1E, x1F,
+    x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x2A, x2B, x2C, x2D, x2E, x2F,
+    x30, x31, x32, x33, x34, x35, x36, x37, x38, x39, x3A, x3B, x3C, x3D, x3E, x3F,
+    x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x4A, x4B, x4C, x4D, x4E, x4F,
+    x50, x51, x52, x53, x54, x55, x56, x57, x58, x59, x5A, x5B, x5C, x5D, x5E, x5F,
+    x60, x61, x62, x63, x64, x65, x66, x67, x68, x69, x6A, x6B, x6C, x6D, x6E, x6F,
+    x70, x71, x72, x73, x74, x75, x76, x77, x78, x79, x7A, x7B, x7C, x7D, x7E, x7F,
+    x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x8A, x8B, x8C, x8D, x8E, x8F,
+    x90, x91, x92, x93, x94, x95, x96, x97, x98, x99, x9A, x9B, x9C, x9D, x9E, x9F,
+    xA0, xA1, xA2, xA3, xA4, xA5, xA6, xA7, xA8, xA9, xAA, xAB, xAC, xAD, xAE, xAF,
+    xB0, xB1, xB2, xB3, xB4, xB5, xB6, xB7, xB8, xB9, xBA, xBB, xBC, xBD, xBE, xBF,
+    xC0, xC1, xC2, xC3, xC4, xC5, xC6, xC7, xC8, xC9, xCA, xCB, xCC, xCD, xCE, xCF,
+    xD0, xD1, xD2, xD3, xD4, xD5, xD6, xD7, xD8, xD9, xDA, xDB, xDC, xDD, xDE, xDF,
+    xE0, xE1, xE2, xE3, xE4, xE5, xE6, xE7, xE8, xE9, xEA, xEB, xEC, xED, xEE, xEF,
+    xF0, xF1, xF2, xF3, xF4, xF5, xF6, xF7,
+    // </editor-fold>
+    xF8, xF9, xFA, xFB);
+    }
+
+    @Test
+    public void test252() throws Throwable {
+        final int ARITY = 252;
+        System.out.println("test"+ARITY);
+        Object[] a = testArgs(ARITY);
+        Object r0 = hashArguments(a);
+        Object r;
+        r = hashArguments_252(
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB]);
+        assertEquals(r0, r);
+        MethodType mt = MethodType.genericMethodType(ARITY);
+        MethodHandle mh = MethodHandles.lookup().findStatic(BigArityTest.class, "hashArguments_"+ARITY, mt);
+        r = mh.invokeExact(
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB]);
+        assertEquals(r0, r);
+        r = mh.invokeWithArguments(a);
+        assertEquals(r0, r);
+        MethodHandle ximh = MethodHandles.exactInvoker(mh.type());
+        r = ximh.invokeExact(mh,
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB]);
+        assertEquals(r0, r);
+        r = ximh.invokeWithArguments(cat(mh,a));
+        assertEquals(r0, r);
+        MethodHandle gimh = MethodHandles.invoker(mh.type());
+        r = gimh.invoke(mh,
+    // <editor-fold defaultstate="collapsed" desc="(Number) a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    (Number)
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB]);
+        assertEquals(r0, r);
+        r = gimh.invokeWithArguments(cat(mh,a));
+        assertEquals(r0, r);
+        mh = mh.asType(mh.type().changeParameterType(0x10, Integer.class));
+        //System.out.println("type="+mh.type().toString().replaceAll("Object", ""));
+        r = mh.invokeExact(
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ... (Integer) a[0x10], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    (Integer)
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB]);
+        assertEquals(r0, r);
+        r = mh.invoke(
+    // <editor-fold defaultstate="collapsed" desc="(Comparable) a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    (Comparable<?>)
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB]);
+        assertEquals(r0, r);
+    }
+
+    static Object hashArguments_253(
+    // <editor-fold defaultstate="collapsed" desc="Object x00, Object x01, Object x02, Object x03, Object x04, ...">
+    Object x00, Object x01, Object x02, Object x03, Object x04, Object x05, Object x06, Object x07,
+    Object x08, Object x09, Object x0A, Object x0B, Object x0C, Object x0D, Object x0E, Object x0F,
+    Object x10, Object x11, Object x12, Object x13, Object x14, Object x15, Object x16, Object x17,
+    Object x18, Object x19, Object x1A, Object x1B, Object x1C, Object x1D, Object x1E, Object x1F,
+    Object x20, Object x21, Object x22, Object x23, Object x24, Object x25, Object x26, Object x27,
+    Object x28, Object x29, Object x2A, Object x2B, Object x2C, Object x2D, Object x2E, Object x2F,
+    Object x30, Object x31, Object x32, Object x33, Object x34, Object x35, Object x36, Object x37,
+    Object x38, Object x39, Object x3A, Object x3B, Object x3C, Object x3D, Object x3E, Object x3F,
+    Object x40, Object x41, Object x42, Object x43, Object x44, Object x45, Object x46, Object x47,
+    Object x48, Object x49, Object x4A, Object x4B, Object x4C, Object x4D, Object x4E, Object x4F,
+    Object x50, Object x51, Object x52, Object x53, Object x54, Object x55, Object x56, Object x57,
+    Object x58, Object x59, Object x5A, Object x5B, Object x5C, Object x5D, Object x5E, Object x5F,
+    Object x60, Object x61, Object x62, Object x63, Object x64, Object x65, Object x66, Object x67,
+    Object x68, Object x69, Object x6A, Object x6B, Object x6C, Object x6D, Object x6E, Object x6F,
+    Object x70, Object x71, Object x72, Object x73, Object x74, Object x75, Object x76, Object x77,
+    Object x78, Object x79, Object x7A, Object x7B, Object x7C, Object x7D, Object x7E, Object x7F,
+    Object x80, Object x81, Object x82, Object x83, Object x84, Object x85, Object x86, Object x87,
+    Object x88, Object x89, Object x8A, Object x8B, Object x8C, Object x8D, Object x8E, Object x8F,
+    Object x90, Object x91, Object x92, Object x93, Object x94, Object x95, Object x96, Object x97,
+    Object x98, Object x99, Object x9A, Object x9B, Object x9C, Object x9D, Object x9E, Object x9F,
+    Object xA0, Object xA1, Object xA2, Object xA3, Object xA4, Object xA5, Object xA6, Object xA7,
+    Object xA8, Object xA9, Object xAA, Object xAB, Object xAC, Object xAD, Object xAE, Object xAF,
+    Object xB0, Object xB1, Object xB2, Object xB3, Object xB4, Object xB5, Object xB6, Object xB7,
+    Object xB8, Object xB9, Object xBA, Object xBB, Object xBC, Object xBD, Object xBE, Object xBF,
+    Object xC0, Object xC1, Object xC2, Object xC3, Object xC4, Object xC5, Object xC6, Object xC7,
+    Object xC8, Object xC9, Object xCA, Object xCB, Object xCC, Object xCD, Object xCE, Object xCF,
+    Object xD0, Object xD1, Object xD2, Object xD3, Object xD4, Object xD5, Object xD6, Object xD7,
+    Object xD8, Object xD9, Object xDA, Object xDB, Object xDC, Object xDD, Object xDE, Object xDF,
+    Object xE0, Object xE1, Object xE2, Object xE3, Object xE4, Object xE5, Object xE6, Object xE7,
+    Object xE8, Object xE9, Object xEA, Object xEB, Object xEC, Object xED, Object xEE, Object xEF,
+    Object xF0, Object xF1, Object xF2, Object xF3, Object xF4, Object xF5, Object xF6, Object xF7,
+    // </editor-fold>
+    Object xF8, Object xF9, Object xFA, Object xFB, Object xFC) {
+        return Objects.hash(
+    // <editor-fold defaultstate="collapsed" desc="x00, x01, x02, x03, x04, ...">
+    x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x0A, x0B, x0C, x0D, x0E, x0F,
+    x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x1A, x1B, x1C, x1D, x1E, x1F,
+    x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x2A, x2B, x2C, x2D, x2E, x2F,
+    x30, x31, x32, x33, x34, x35, x36, x37, x38, x39, x3A, x3B, x3C, x3D, x3E, x3F,
+    x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x4A, x4B, x4C, x4D, x4E, x4F,
+    x50, x51, x52, x53, x54, x55, x56, x57, x58, x59, x5A, x5B, x5C, x5D, x5E, x5F,
+    x60, x61, x62, x63, x64, x65, x66, x67, x68, x69, x6A, x6B, x6C, x6D, x6E, x6F,
+    x70, x71, x72, x73, x74, x75, x76, x77, x78, x79, x7A, x7B, x7C, x7D, x7E, x7F,
+    x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x8A, x8B, x8C, x8D, x8E, x8F,
+    x90, x91, x92, x93, x94, x95, x96, x97, x98, x99, x9A, x9B, x9C, x9D, x9E, x9F,
+    xA0, xA1, xA2, xA3, xA4, xA5, xA6, xA7, xA8, xA9, xAA, xAB, xAC, xAD, xAE, xAF,
+    xB0, xB1, xB2, xB3, xB4, xB5, xB6, xB7, xB8, xB9, xBA, xBB, xBC, xBD, xBE, xBF,
+    xC0, xC1, xC2, xC3, xC4, xC5, xC6, xC7, xC8, xC9, xCA, xCB, xCC, xCD, xCE, xCF,
+    xD0, xD1, xD2, xD3, xD4, xD5, xD6, xD7, xD8, xD9, xDA, xDB, xDC, xDD, xDE, xDF,
+    xE0, xE1, xE2, xE3, xE4, xE5, xE6, xE7, xE8, xE9, xEA, xEB, xEC, xED, xEE, xEF,
+    xF0, xF1, xF2, xF3, xF4, xF5, xF6, xF7,
+    // </editor-fold>
+    xF8, xF9, xFA, xFB, xFC);
+    }
+
+    @Test
+    public void test253() throws Throwable {
+        final int ARITY = 253;
+        System.out.println("test"+ARITY);
+        Object[] a = testArgs(ARITY);
+        Object r0 = hashArguments(a);
+        Object r;
+        r = hashArguments_253(
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB], a[0xFC]);
+        assertEquals(r0, r);
+        MethodType mt = MethodType.genericMethodType(ARITY);
+        MethodHandle mh = MethodHandles.lookup().findStatic(BigArityTest.class, "hashArguments_"+ARITY, mt);
+        r = mh.invokeExact(
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB], a[0xFC]);
+        assertEquals(r0, r);
+        r = mh.invokeWithArguments(a);
+        assertEquals(r0, r);
+        MethodHandle ximh = MethodHandles.exactInvoker(mh.type());
+        r = ximh.invokeExact(mh,
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB], a[0xFC]);
+        assertEquals(r0, r);
+        // FIXME: This next one fails, because it uses an internal invoker of arity 255.
+        r = ximh.invokeWithArguments(cat(mh,a));
+        assertEquals(r0, r);
+        MethodHandle gimh = MethodHandles.invoker(mh.type());
+        r = gimh.invoke(mh,
+    // <editor-fold defaultstate="collapsed" desc="(Number) a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    (Number)
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB], a[0xFC]);
+        assertEquals(r0, r);
+        // FIXME: This next one fails, because it uses an internal invoker of arity 255.
+        r = gimh.invokeWithArguments(cat(mh,a));
+        assertEquals(r0, r);
+        mh = mh.asType(mh.type().changeParameterType(0x10, Integer.class));
+        //System.out.println("type="+mh.type().toString().replaceAll("Object", ""));
+        r = mh.invokeExact(
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ... (Integer) a[0x10], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    (Integer)
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB], a[0xFC]);
+        assertEquals(r0, r);
+        r = mh.invoke(
+    // <editor-fold defaultstate="collapsed" desc="(Comparable) a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    (Comparable<?>)
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB], a[0xFC]);
+        assertEquals(r0, r);
+    }
+
+    static Object hashArguments_254(
+    // <editor-fold defaultstate="collapsed" desc="Object x00, Object x01, Object x02, Object x03, Object x04, ...">
+    Object x00, Object x01, Object x02, Object x03, Object x04, Object x05, Object x06, Object x07,
+    Object x08, Object x09, Object x0A, Object x0B, Object x0C, Object x0D, Object x0E, Object x0F,
+    Object x10, Object x11, Object x12, Object x13, Object x14, Object x15, Object x16, Object x17,
+    Object x18, Object x19, Object x1A, Object x1B, Object x1C, Object x1D, Object x1E, Object x1F,
+    Object x20, Object x21, Object x22, Object x23, Object x24, Object x25, Object x26, Object x27,
+    Object x28, Object x29, Object x2A, Object x2B, Object x2C, Object x2D, Object x2E, Object x2F,
+    Object x30, Object x31, Object x32, Object x33, Object x34, Object x35, Object x36, Object x37,
+    Object x38, Object x39, Object x3A, Object x3B, Object x3C, Object x3D, Object x3E, Object x3F,
+    Object x40, Object x41, Object x42, Object x43, Object x44, Object x45, Object x46, Object x47,
+    Object x48, Object x49, Object x4A, Object x4B, Object x4C, Object x4D, Object x4E, Object x4F,
+    Object x50, Object x51, Object x52, Object x53, Object x54, Object x55, Object x56, Object x57,
+    Object x58, Object x59, Object x5A, Object x5B, Object x5C, Object x5D, Object x5E, Object x5F,
+    Object x60, Object x61, Object x62, Object x63, Object x64, Object x65, Object x66, Object x67,
+    Object x68, Object x69, Object x6A, Object x6B, Object x6C, Object x6D, Object x6E, Object x6F,
+    Object x70, Object x71, Object x72, Object x73, Object x74, Object x75, Object x76, Object x77,
+    Object x78, Object x79, Object x7A, Object x7B, Object x7C, Object x7D, Object x7E, Object x7F,
+    Object x80, Object x81, Object x82, Object x83, Object x84, Object x85, Object x86, Object x87,
+    Object x88, Object x89, Object x8A, Object x8B, Object x8C, Object x8D, Object x8E, Object x8F,
+    Object x90, Object x91, Object x92, Object x93, Object x94, Object x95, Object x96, Object x97,
+    Object x98, Object x99, Object x9A, Object x9B, Object x9C, Object x9D, Object x9E, Object x9F,
+    Object xA0, Object xA1, Object xA2, Object xA3, Object xA4, Object xA5, Object xA6, Object xA7,
+    Object xA8, Object xA9, Object xAA, Object xAB, Object xAC, Object xAD, Object xAE, Object xAF,
+    Object xB0, Object xB1, Object xB2, Object xB3, Object xB4, Object xB5, Object xB6, Object xB7,
+    Object xB8, Object xB9, Object xBA, Object xBB, Object xBC, Object xBD, Object xBE, Object xBF,
+    Object xC0, Object xC1, Object xC2, Object xC3, Object xC4, Object xC5, Object xC6, Object xC7,
+    Object xC8, Object xC9, Object xCA, Object xCB, Object xCC, Object xCD, Object xCE, Object xCF,
+    Object xD0, Object xD1, Object xD2, Object xD3, Object xD4, Object xD5, Object xD6, Object xD7,
+    Object xD8, Object xD9, Object xDA, Object xDB, Object xDC, Object xDD, Object xDE, Object xDF,
+    Object xE0, Object xE1, Object xE2, Object xE3, Object xE4, Object xE5, Object xE6, Object xE7,
+    Object xE8, Object xE9, Object xEA, Object xEB, Object xEC, Object xED, Object xEE, Object xEF,
+    Object xF0, Object xF1, Object xF2, Object xF3, Object xF4, Object xF5, Object xF6, Object xF7,
+    // </editor-fold>
+    Object xF8, Object xF9, Object xFA, Object xFB, Object xFC, Object xFD) {
+        return Objects.hash(
+    // <editor-fold defaultstate="collapsed" desc="x00, x01, x02, x03, x04, ...">
+    x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x0A, x0B, x0C, x0D, x0E, x0F,
+    x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x1A, x1B, x1C, x1D, x1E, x1F,
+    x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x2A, x2B, x2C, x2D, x2E, x2F,
+    x30, x31, x32, x33, x34, x35, x36, x37, x38, x39, x3A, x3B, x3C, x3D, x3E, x3F,
+    x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x4A, x4B, x4C, x4D, x4E, x4F,
+    x50, x51, x52, x53, x54, x55, x56, x57, x58, x59, x5A, x5B, x5C, x5D, x5E, x5F,
+    x60, x61, x62, x63, x64, x65, x66, x67, x68, x69, x6A, x6B, x6C, x6D, x6E, x6F,
+    x70, x71, x72, x73, x74, x75, x76, x77, x78, x79, x7A, x7B, x7C, x7D, x7E, x7F,
+    x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x8A, x8B, x8C, x8D, x8E, x8F,
+    x90, x91, x92, x93, x94, x95, x96, x97, x98, x99, x9A, x9B, x9C, x9D, x9E, x9F,
+    xA0, xA1, xA2, xA3, xA4, xA5, xA6, xA7, xA8, xA9, xAA, xAB, xAC, xAD, xAE, xAF,
+    xB0, xB1, xB2, xB3, xB4, xB5, xB6, xB7, xB8, xB9, xBA, xBB, xBC, xBD, xBE, xBF,
+    xC0, xC1, xC2, xC3, xC4, xC5, xC6, xC7, xC8, xC9, xCA, xCB, xCC, xCD, xCE, xCF,
+    xD0, xD1, xD2, xD3, xD4, xD5, xD6, xD7, xD8, xD9, xDA, xDB, xDC, xDD, xDE, xDF,
+    xE0, xE1, xE2, xE3, xE4, xE5, xE6, xE7, xE8, xE9, xEA, xEB, xEC, xED, xEE, xEF,
+    xF0, xF1, xF2, xF3, xF4, xF5, xF6, xF7,
+    // </editor-fold>
+    xF8, xF9, xFA, xFB, xFC, xFD);
+    }
+
+    @Test
+    public void test254() throws Throwable {
+        final int ARITY = 254;
+        System.out.println("test"+ARITY);
+        Object[] a = testArgs(ARITY);
+        Object r0 = hashArguments(a);
+        Object r;
+        r = hashArguments_254(
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB], a[0xFC], a[0xFD]);
+        assertEquals(r0, r);
+        MethodType mt = MethodType.genericMethodType(ARITY);
+        MethodHandle mh = MethodHandles.lookup().findStatic(BigArityTest.class, "hashArguments_"+ARITY, mt);
+        r = mh.invokeExact(
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB], a[0xFC], a[0xFD]);
+        assertEquals(r0, r);
+        // FIXME: This next one fails, because it uses an internal invoker of arity 255.
+        r = mh.invokeWithArguments(a);
+        assertEquals(r0, r);
+        try {
+            MethodHandle ximh = MethodHandles.exactInvoker(mh.type());
+            throw new AssertionError("should have thrown IAE; cannot have 1+1+254 arguments");
+        } catch (IllegalArgumentException ex) {
+            System.out.println("OK: "+ex);
+        }
+        mh = mh.asType(mh.type().changeParameterType(0x10, Integer.class));
+        //System.out.println("type="+mh.type().toString().replaceAll("Object", ""));
+        r = mh.invokeExact(
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ... (Integer) a[0x10], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    (Integer)
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB], a[0xFC], a[0xFD]);
+        assertEquals(r0, r);
+        mh = mh.asType(mh.type().changeParameterType(0xE0, Number.class));
+        //System.out.println("type="+mh.type().toString().replaceAll("Object", ""));
+        r = mh.invokeExact(
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ... (Integer) a[0x10], ... (Number) a[0xE0], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    (Integer)
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    (Number)
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB], a[0xFC], a[0xFD]);
+        assertEquals(r0, r);
+        r = mh.invoke(
+    // <editor-fold defaultstate="collapsed" desc="(Comparable) a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    (Comparable<?>)
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB], a[0xFC], a[0xFD]);
+        assertEquals(r0, r);
+    }
+
+    static Object hashArguments_255(
+    // <editor-fold defaultstate="collapsed" desc="Object x00, Object x01, Object x02, Object x03, Object x04, ...">
+    Object x00, Object x01, Object x02, Object x03, Object x04, Object x05, Object x06, Object x07,
+    Object x08, Object x09, Object x0A, Object x0B, Object x0C, Object x0D, Object x0E, Object x0F,
+    Object x10, Object x11, Object x12, Object x13, Object x14, Object x15, Object x16, Object x17,
+    Object x18, Object x19, Object x1A, Object x1B, Object x1C, Object x1D, Object x1E, Object x1F,
+    Object x20, Object x21, Object x22, Object x23, Object x24, Object x25, Object x26, Object x27,
+    Object x28, Object x29, Object x2A, Object x2B, Object x2C, Object x2D, Object x2E, Object x2F,
+    Object x30, Object x31, Object x32, Object x33, Object x34, Object x35, Object x36, Object x37,
+    Object x38, Object x39, Object x3A, Object x3B, Object x3C, Object x3D, Object x3E, Object x3F,
+    Object x40, Object x41, Object x42, Object x43, Object x44, Object x45, Object x46, Object x47,
+    Object x48, Object x49, Object x4A, Object x4B, Object x4C, Object x4D, Object x4E, Object x4F,
+    Object x50, Object x51, Object x52, Object x53, Object x54, Object x55, Object x56, Object x57,
+    Object x58, Object x59, Object x5A, Object x5B, Object x5C, Object x5D, Object x5E, Object x5F,
+    Object x60, Object x61, Object x62, Object x63, Object x64, Object x65, Object x66, Object x67,
+    Object x68, Object x69, Object x6A, Object x6B, Object x6C, Object x6D, Object x6E, Object x6F,
+    Object x70, Object x71, Object x72, Object x73, Object x74, Object x75, Object x76, Object x77,
+    Object x78, Object x79, Object x7A, Object x7B, Object x7C, Object x7D, Object x7E, Object x7F,
+    Object x80, Object x81, Object x82, Object x83, Object x84, Object x85, Object x86, Object x87,
+    Object x88, Object x89, Object x8A, Object x8B, Object x8C, Object x8D, Object x8E, Object x8F,
+    Object x90, Object x91, Object x92, Object x93, Object x94, Object x95, Object x96, Object x97,
+    Object x98, Object x99, Object x9A, Object x9B, Object x9C, Object x9D, Object x9E, Object x9F,
+    Object xA0, Object xA1, Object xA2, Object xA3, Object xA4, Object xA5, Object xA6, Object xA7,
+    Object xA8, Object xA9, Object xAA, Object xAB, Object xAC, Object xAD, Object xAE, Object xAF,
+    Object xB0, Object xB1, Object xB2, Object xB3, Object xB4, Object xB5, Object xB6, Object xB7,
+    Object xB8, Object xB9, Object xBA, Object xBB, Object xBC, Object xBD, Object xBE, Object xBF,
+    Object xC0, Object xC1, Object xC2, Object xC3, Object xC4, Object xC5, Object xC6, Object xC7,
+    Object xC8, Object xC9, Object xCA, Object xCB, Object xCC, Object xCD, Object xCE, Object xCF,
+    Object xD0, Object xD1, Object xD2, Object xD3, Object xD4, Object xD5, Object xD6, Object xD7,
+    Object xD8, Object xD9, Object xDA, Object xDB, Object xDC, Object xDD, Object xDE, Object xDF,
+    Object xE0, Object xE1, Object xE2, Object xE3, Object xE4, Object xE5, Object xE6, Object xE7,
+    Object xE8, Object xE9, Object xEA, Object xEB, Object xEC, Object xED, Object xEE, Object xEF,
+    Object xF0, Object xF1, Object xF2, Object xF3, Object xF4, Object xF5, Object xF6, Object xF7,
+    // </editor-fold>
+    Object xF8, Object xF9, Object xFA, Object xFB, Object xFC, Object xFD, Object xFE) {
+        return Objects.hash(
+    // <editor-fold defaultstate="collapsed" desc="x00, x01, x02, x03, x04, ...">
+    x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x0A, x0B, x0C, x0D, x0E, x0F,
+    x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x1A, x1B, x1C, x1D, x1E, x1F,
+    x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x2A, x2B, x2C, x2D, x2E, x2F,
+    x30, x31, x32, x33, x34, x35, x36, x37, x38, x39, x3A, x3B, x3C, x3D, x3E, x3F,
+    x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x4A, x4B, x4C, x4D, x4E, x4F,
+    x50, x51, x52, x53, x54, x55, x56, x57, x58, x59, x5A, x5B, x5C, x5D, x5E, x5F,
+    x60, x61, x62, x63, x64, x65, x66, x67, x68, x69, x6A, x6B, x6C, x6D, x6E, x6F,
+    x70, x71, x72, x73, x74, x75, x76, x77, x78, x79, x7A, x7B, x7C, x7D, x7E, x7F,
+    x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x8A, x8B, x8C, x8D, x8E, x8F,
+    x90, x91, x92, x93, x94, x95, x96, x97, x98, x99, x9A, x9B, x9C, x9D, x9E, x9F,
+    xA0, xA1, xA2, xA3, xA4, xA5, xA6, xA7, xA8, xA9, xAA, xAB, xAC, xAD, xAE, xAF,
+    xB0, xB1, xB2, xB3, xB4, xB5, xB6, xB7, xB8, xB9, xBA, xBB, xBC, xBD, xBE, xBF,
+    xC0, xC1, xC2, xC3, xC4, xC5, xC6, xC7, xC8, xC9, xCA, xCB, xCC, xCD, xCE, xCF,
+    xD0, xD1, xD2, xD3, xD4, xD5, xD6, xD7, xD8, xD9, xDA, xDB, xDC, xDD, xDE, xDF,
+    xE0, xE1, xE2, xE3, xE4, xE5, xE6, xE7, xE8, xE9, xEA, xEB, xEC, xED, xEE, xEF,
+    xF0, xF1, xF2, xF3, xF4, xF5, xF6, xF7,
+    // </editor-fold>
+    xF8, xF9, xFA, xFB, xFC, xFD, xFE);
+    }
+
+    @Test
+    public void test255() throws Throwable {
+        final int ARITY = 255;
+        System.out.println("test"+ARITY);
+        Object[] a = testArgs(ARITY);
+        Object r0 = hashArguments(a);
+        Object r;
+        r = hashArguments_255(
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB], a[0xFC], a[0xFD], a[0xFE]);
+        assertEquals(r0, r);
+        MethodType mt = MethodType.genericMethodType(ARITY);
+        MethodHandle mh;
+        try {
+            mh = MethodHandles.lookup().findStatic(BigArityTest.class, "hashArguments_"+ARITY, mt);
+            throw new AssertionError("should not create an arity 255 method handle");
+        } catch (IllegalArgumentException ex) {
+            System.out.println("OK: "+ex);
+            mh = MethodHandles.lookup().findStatic(BigArityTest.class, "hashArguments_"+(ARITY-1), mt.dropParameterTypes(ARITY-1, ARITY));
+        }
+        try {
+            r = mh.invokeExact(
+    // <editor-fold defaultstate="collapsed" desc="a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], ...">
+    a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0A], a[0x0B], a[0x0C], a[0x0D], a[0x0E], a[0x0F],
+    a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], a[0x18], a[0x19], a[0x1A], a[0x1B], a[0x1C], a[0x1D], a[0x1E], a[0x1F],
+    a[0x20], a[0x21], a[0x22], a[0x23], a[0x24], a[0x25], a[0x26], a[0x27], a[0x28], a[0x29], a[0x2A], a[0x2B], a[0x2C], a[0x2D], a[0x2E], a[0x2F],
+    a[0x30], a[0x31], a[0x32], a[0x33], a[0x34], a[0x35], a[0x36], a[0x37], a[0x38], a[0x39], a[0x3A], a[0x3B], a[0x3C], a[0x3D], a[0x3E], a[0x3F],
+    a[0x40], a[0x41], a[0x42], a[0x43], a[0x44], a[0x45], a[0x46], a[0x47], a[0x48], a[0x49], a[0x4A], a[0x4B], a[0x4C], a[0x4D], a[0x4E], a[0x4F],
+    a[0x50], a[0x51], a[0x52], a[0x53], a[0x54], a[0x55], a[0x56], a[0x57], a[0x58], a[0x59], a[0x5A], a[0x5B], a[0x5C], a[0x5D], a[0x5E], a[0x5F],
+    a[0x60], a[0x61], a[0x62], a[0x63], a[0x64], a[0x65], a[0x66], a[0x67], a[0x68], a[0x69], a[0x6A], a[0x6B], a[0x6C], a[0x6D], a[0x6E], a[0x6F],
+    a[0x70], a[0x71], a[0x72], a[0x73], a[0x74], a[0x75], a[0x76], a[0x77], a[0x78], a[0x79], a[0x7A], a[0x7B], a[0x7C], a[0x7D], a[0x7E], a[0x7F],
+    a[0x80], a[0x81], a[0x82], a[0x83], a[0x84], a[0x85], a[0x86], a[0x87], a[0x88], a[0x89], a[0x8A], a[0x8B], a[0x8C], a[0x8D], a[0x8E], a[0x8F],
+    a[0x90], a[0x91], a[0x92], a[0x93], a[0x94], a[0x95], a[0x96], a[0x97], a[0x98], a[0x99], a[0x9A], a[0x9B], a[0x9C], a[0x9D], a[0x9E], a[0x9F],
+    a[0xA0], a[0xA1], a[0xA2], a[0xA3], a[0xA4], a[0xA5], a[0xA6], a[0xA7], a[0xA8], a[0xA9], a[0xAA], a[0xAB], a[0xAC], a[0xAD], a[0xAE], a[0xAF],
+    a[0xB0], a[0xB1], a[0xB2], a[0xB3], a[0xB4], a[0xB5], a[0xB6], a[0xB7], a[0xB8], a[0xB9], a[0xBA], a[0xBB], a[0xBC], a[0xBD], a[0xBE], a[0xBF],
+    a[0xC0], a[0xC1], a[0xC2], a[0xC3], a[0xC4], a[0xC5], a[0xC6], a[0xC7], a[0xC8], a[0xC9], a[0xCA], a[0xCB], a[0xCC], a[0xCD], a[0xCE], a[0xCF],
+    a[0xD0], a[0xD1], a[0xD2], a[0xD3], a[0xD4], a[0xD5], a[0xD6], a[0xD7], a[0xD8], a[0xD9], a[0xDA], a[0xDB], a[0xDC], a[0xDD], a[0xDE], a[0xDF],
+    a[0xE0], a[0xE1], a[0xE2], a[0xE3], a[0xE4], a[0xE5], a[0xE6], a[0xE7], a[0xE8], a[0xE9], a[0xEA], a[0xEB], a[0xEC], a[0xED], a[0xEE], a[0xEF],
+    a[0xF0], a[0xF1], a[0xF2], a[0xF3], a[0xF4], a[0xF5], a[0xF6], a[0xF7],
+    // </editor-fold>
+    a[0xF8], a[0xF9], a[0xFA], a[0xFB], a[0xFC], a[0xFD], a[0xFE]);
+            throw new AssertionError("should not call an arity 255 method handle");
+        } catch (LinkageError ex) {
+            System.out.println("OK: "+ex);
+        }
+        try {
+            MethodHandle ximh = MethodHandles.exactInvoker(mt);
+            throw new AssertionError("should have thrown IAE; cannot have 1+1+255 arguments");
+        } catch (IllegalArgumentException ex) {
+            System.out.println("OK: "+ex);
+        }
+    }
+}
--- a/test/java/lang/invoke/MaxTest.java	Fri Sep 14 09:47:14 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* @test
- * @summary BoundMethodHandle tests with primitive types
- * @compile MaxTest.java
- * @run junit/othervm test.java.lang.invoke.MaxTest
- */
-
-package test.java.lang.invoke;
-
-import static org.junit.Assert.assertEquals;
-
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodType;
-
-import org.junit.Test;
-
-public class MaxTest {
-
-    static MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
-
-    private MethodHandle getMax(Class<?> t) throws Throwable {
-        return LOOKUP.findStatic(Math.class, "max", MethodType.methodType(t, t, t));
-    }
-
-    static int ITERATION_COUNT = 40000;
-    static {
-        String iterations = System.getProperty(MaxTest.class.getSimpleName() + ".ITERATION_COUNT");
-        if (iterations == null) {
-            iterations = System.getProperty(MaxTest.class.getName() + ".ITERATION_COUNT");
-        }
-        if (iterations != null) {
-            ITERATION_COUNT = Integer.parseInt(iterations);
-        }
-    }
-
-    @Test
-    public void testMaxLong() throws Throwable {
-        final Class<?> C = long.class;
-        final long P = 23L;
-        final long Q = 42L;
-        final long R = Math.max(P, Q);
-        for (int i = 0; i < ITERATION_COUNT; ++i) {
-            MethodHandle h = getMax(C);
-            assertEquals((long) h.invokeExact(P, Q), R);
-            MethodHandle bh = MethodHandles.insertArguments(h, 0, P);
-            assertEquals((long) bh.invokeExact(Q), R);
-            MethodHandle bbh = MethodHandles.insertArguments(bh, 0, Q);
-            assertEquals((long) bbh.invokeExact(), R);
-            MethodHandle b2h = MethodHandles.insertArguments(h, 1, Q);
-            assertEquals((long) b2h.invokeExact(P), R);
-            MethodHandle bb2h = MethodHandles.insertArguments(b2h, 0, P);
-            assertEquals((long) bb2h.invokeExact(), R);
-        }
-    }
-
-    @Test
-    public void testMaxInt() throws Throwable {
-        final Class<?> C = int.class;
-        final int P = 23;
-        final int Q = 42;
-        final int R = Math.max(P, Q);
-        for (int i = 0; i < ITERATION_COUNT; ++i) {
-            MethodHandle h = getMax(C);
-            assertEquals((int) h.invokeExact(P, Q), R);
-            MethodHandle bh = MethodHandles.insertArguments(h, 0, P);
-            assertEquals((int) bh.invokeExact(Q), R);
-            MethodHandle bbh = MethodHandles.insertArguments(bh, 0, Q);
-            assertEquals((int) bbh.invokeExact(), R);
-            MethodHandle b2h = MethodHandles.insertArguments(h, 1, Q);
-            assertEquals((int) b2h.invokeExact(P), R);
-            MethodHandle bb2h = MethodHandles.insertArguments(b2h, 0, P);
-            assertEquals((int) bb2h.invokeExact(), R);
-        }
-    }
-
-    @Test
-    public void testMaxFloat() throws Throwable {
-        final Class<?> C = float.class;
-        final float P = 23F;
-        final float Q = 42F;
-        final float R = Math.max(P, Q);
-        final float D = 0.1F;
-        for (int i = 0; i < ITERATION_COUNT; ++i) {
-            MethodHandle h = getMax(C);
-            assertEquals((float) h.invokeExact(P, Q), R, D);
-            MethodHandle bh = MethodHandles.insertArguments(h, 0, P);
-            assertEquals((float) bh.invokeExact(Q), R, D);
-            MethodHandle bbh = MethodHandles.insertArguments(bh, 0, Q);
-            assertEquals((float) bbh.invokeExact(), R, D);
-            MethodHandle b2h = MethodHandles.insertArguments(h, 1, Q);
-            assertEquals((float) b2h.invokeExact(P), R, D);
-            MethodHandle bb2h = MethodHandles.insertArguments(b2h, 0, P);
-            assertEquals((float) bb2h.invokeExact(), R, D);
-        }
-    }
-
-    @Test
-    public void testMaxDouble() throws Throwable {
-        final Class<?> C = double.class;
-        final double P = 23F;
-        final double Q = 42F;
-        final double R = Math.max(P, Q);
-        final double D = 0.1;
-        for (int i = 0; i < ITERATION_COUNT; ++i) {
-            MethodHandle h = getMax(C);
-            assertEquals((double) h.invokeExact(P, Q), R, D);
-            MethodHandle bh = MethodHandles.insertArguments(h, 0, P);
-            assertEquals((double) bh.invokeExact(Q), R, D);
-            MethodHandle bbh = MethodHandles.insertArguments(bh, 0, Q);
-            assertEquals((double) bbh.invokeExact(), R, D);
-            MethodHandle b2h = MethodHandles.insertArguments(h, 1, Q);
-            assertEquals((double) b2h.invokeExact(P), R, D);
-            MethodHandle bb2h = MethodHandles.insertArguments(b2h, 0, P);
-            assertEquals((double) bb2h.invokeExact(), R, D);
-        }
-    }
-
-}
--- a/test/java/lang/invoke/MethodHandlesTest.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/test/java/lang/invoke/MethodHandlesTest.java	Fri Sep 14 10:14:02 2012 -0700
@@ -1485,7 +1485,7 @@
         RuntimeException error = null;
         try {
             target = id.asType(newType);
-        } catch (RuntimeException ex) {
+        } catch (WrongMethodTypeException ex) {
             error = ex;
         }
         if (verbosity >= 3)
@@ -2381,47 +2381,100 @@
         assertSame(thrown, caught);
     }
 
-    //@Test
+    @Test
     public void testInterfaceCast() throws Throwable {
         //if (CAN_SKIP_WORKING)  return;
         startTest("interfaceCast");
-        for (Class<?> ctype : new Class<?>[]{ Object.class, String.class, CharSequence.class, Number.class, Iterable.class}) {
-            testInterfaceCast(ctype, false, false);
-            testInterfaceCast(ctype, true,  false);
-            testInterfaceCast(ctype, false, true);
-            testInterfaceCast(ctype, true,  true);
+        assert( (((Object)"foo") instanceof CharSequence));
+        assert(!(((Object)"foo") instanceof Iterable));
+        for (MethodHandle mh : new MethodHandle[]{
+            MethodHandles.identity(String.class),
+            MethodHandles.identity(CharSequence.class),
+            MethodHandles.identity(Iterable.class)
+        }) {
+            if (verbosity > 0)  System.out.println("-- mh = "+mh);
+            for (Class<?> ctype : new Class<?>[]{
+                Object.class, String.class, CharSequence.class,
+                Number.class, Iterable.class
+            }) {
+                if (verbosity > 0)  System.out.println("---- ctype = "+ctype.getName());
+                //                           doret  docast
+                testInterfaceCast(mh, ctype, false, false);
+                testInterfaceCast(mh, ctype, true,  false);
+                testInterfaceCast(mh, ctype, false, true);
+                testInterfaceCast(mh, ctype, true,  true);
+            }
         }
     }
-    public void testInterfaceCast(Class<?> ctype, boolean doret, boolean docast) throws Throwable {
-        String str = "normal return value";
-        MethodHandle mh = MethodHandles.identity(String.class);
+    private static Class<?> i2o(Class<?> c) {
+        return (c.isInterface() ? Object.class : c);
+    }
+    public void testInterfaceCast(MethodHandle mh, Class<?> ctype,
+                                                   boolean doret, boolean docast) throws Throwable {
+        MethodHandle mh0 = mh;
+        if (verbosity > 1)
+            System.out.println("mh="+mh+", ctype="+ctype.getName()+", doret="+doret+", docast="+docast);
+        String normalRetVal = "normal return value";
         MethodType mt = mh.type();
+        MethodType mt0 = mt;
         if (doret)  mt = mt.changeReturnType(ctype);
         else        mt = mt.changeParameterType(0, ctype);
         if (docast) mh = MethodHandles.explicitCastArguments(mh, mt);
         else        mh = mh.asType(mt);
+        assertEquals(mt, mh.type());
+        MethodType mt1 = mt;
         // this bit is needed to make the interface types disappear for invokeWithArguments:
         mh = MethodHandles.explicitCastArguments(mh, mt.generic());
-        boolean expectFail = !ctype.isInstance(str);
-        if (ctype.isInterface()) {
-            // special rules:  interfaces slide by more frequently
-            if (docast || !doret)  expectFail = false;
+        Class<?>[] step = {
+            mt1.parameterType(0),  // param as passed to mh at first
+            mt0.parameterType(0),  // param after incoming cast
+            mt0.returnType(),      // return value before cast
+            mt1.returnType(),      // return value after outgoing cast
+        };
+        // where might a checkCast occur?
+        boolean[] checkCast = new boolean[step.length];
+        // the string value must pass each step without causing an exception
+        if (!docast) {
+            if (!doret) {
+                if (step[0] != step[1])
+                    checkCast[1] = true;  // incoming value is cast
+            } else {
+                if (step[2] != step[3])
+                    checkCast[3] = true;  // outgoing value is cast
+            }
         }
+        boolean expectFail = false;
+        for (int i = 0; i < step.length; i++) {
+            Class<?> c = step[i];
+            if (!checkCast[i])  c = i2o(c);
+            if (!c.isInstance(normalRetVal)) {
+                if (verbosity > 3)
+                    System.out.println("expect failure at step "+i+" in "+Arrays.toString(step)+Arrays.toString(checkCast));
+                expectFail = true;
+                break;
+            }
+        }
+        countTest(!expectFail);
+        if (verbosity > 2)
+            System.out.println("expectFail="+expectFail+", mt="+mt);
         Object res;
         try {
-            res = mh.invokeWithArguments(str);
+            res = mh.invokeWithArguments(normalRetVal);
         } catch (Exception ex) {
             res = ex;
         }
         boolean sawFail = !(res instanceof String);
         if (sawFail != expectFail) {
-            System.out.println("*** testInterfaceCast: "+mh+" was "+mt+" => "+res+(docast ? " (explicitCastArguments)" : ""));
+            System.out.println("*** testInterfaceCast: mh0 = "+mh0);
+            System.out.println("  retype using "+(docast ? "explicitCastArguments" : "asType")+" to "+mt+" => "+mh);
+            System.out.println("  call returned "+res);
+            System.out.println("  expected "+(expectFail ? "an exception" : normalRetVal));
         }
-        if (!sawFail) {
-            assertFalse(res.toString(), expectFail);
-            assertEquals(str, res);
+        if (!expectFail) {
+            assertFalse(res.toString(), sawFail);
+            assertEquals(normalRetVal, res);
         } else {
-            assertTrue(res.toString(), expectFail);
+            assertTrue(res.toString(), sawFail);
         }
     }
 
--- a/test/java/lang/invoke/PermuteArgsTest.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/test/java/lang/invoke/PermuteArgsTest.java	Fri Sep 14 10:14:02 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, 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
@@ -25,7 +25,7 @@
 
 /* @test
  * @summary unit tests for method handles which permute their arguments
- * @run junit/othervm -ea -esa -DPermuteArgsTest.MAX_ARITY=8 test.java.lang.invoke.PermuteArgsTest
+ * @run junit/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -ea -esa -DPermuteArgsTest.MAX_ARITY=8 test.java.lang.invoke.PermuteArgsTest
  */
 /* Examples of manual runs:
  * java -DPermuteArgsTest.{DRY_RUN=true,MAX_ARITY=253} test.java.lang.invoke.PermuteArgsTest
@@ -191,7 +191,11 @@
                 pt = mt1.parameterType(mt1.parameterCount() - posArgs);
             mt1 = mt1.appendParameterTypes(pt);
         }
-        return mh.asType(mt1);
+        try {
+            return mh.asType(mt1);
+        } catch (WrongMethodTypeException | IllegalArgumentException ex) {
+            throw new IllegalArgumentException("cannot convert to type "+mt1+" from "+mh, ex);
+        }
     }
     static MethodHandle findTestMH(String name, int[] perm) throws ReflectiveOperationException {
         int arity = perm.length;
--- a/test/java/lang/invoke/RicochetTest.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/test/java/lang/invoke/RicochetTest.java	Fri Sep 14 10:14:02 2012 -0700
@@ -256,7 +256,7 @@
                     //System.out.println("  expect="+expect);
 
                     // now use the combined MH, and test the output:
-                    MethodHandle mh = collectArguments(lister, pos, INT_COLLECTORS[collects]);
+                    MethodHandle mh = collectArguments(lister, pos, int[].class, INT_COLLECTORS[collects]);
                     if (mh == null)  continue;  // no infix collection, yet
                     assert(mh.type().parameterCount() == inputs);
                     Object observe = mh.asSpreader(int[].class, args.length).invokeExact(args);
@@ -266,13 +266,53 @@
         }
     }
 
-    private static MethodHandle collectArguments(MethodHandle lister, int pos, MethodHandle collector) {
+    @Test
+    public void testByteCollects() throws Throwable {
+        if (!startTest("testByteCollects"))  return;
+        for (MethodHandle lister : BYTE_LISTERS) {
+            int outputs = lister.type().parameterCount();
+            for (int collects = 0; collects <= Math.min(outputs, BYTE_COLLECTORS.length-1); collects++) {
+                int inputs = outputs - 1 + collects;
+                if (inputs < 0)  continue;
+                for (int pos = 0; pos + collects <= inputs; pos++) {
+                    MethodHandle collector = BYTE_COLLECTORS[collects];
+                    byte[] args = new byte[inputs];
+                    int ap = 0, arg = 31;
+                    for (int i = 0; i < pos; i++)
+                        args[ap++] = (byte)(arg++ + 0);
+                    for (int i = 0; i < collects; i++)
+                        args[ap++] = (byte)(arg++ + 10);
+                    while (ap < args.length)
+                        args[ap++] = (byte)(arg++ + 20);
+                    // calculate piecemeal:
+                    //System.out.println("testIntCollects "+Arrays.asList(lister, pos, collector)+" on "+Arrays.toString(args));
+                    byte[] collargs = Arrays.copyOfRange(args, pos, pos+collects);
+                    byte coll = (byte) collector.asSpreader(byte[].class, collargs.length).invokeExact(collargs);
+                    byte[] listargs = Arrays.copyOfRange(args, 0, outputs);
+                    System.arraycopy(args, pos+collects, listargs, pos+1, outputs - (pos+1));
+                    listargs[pos] = coll;
+                    //System.out.println("  coll="+coll+" listargs="+Arrays.toString(listargs));
+                    Object expect = lister.asSpreader(byte[].class, listargs.length).invokeExact(listargs);
+                    //System.out.println("  expect="+expect);
+
+                    // now use the combined MH, and test the output:
+                    MethodHandle mh = collectArguments(lister, pos, byte[].class, BYTE_COLLECTORS[collects]);
+                    if (mh == null)  continue;  // no infix collection, yet
+                    assert(mh.type().parameterCount() == inputs);
+                    Object observe = mh.asSpreader(byte[].class, args.length).invokeExact(args);
+                    assertEquals(expect, observe);
+                }
+            }
+        }
+    }
+
+    private static MethodHandle collectArguments(MethodHandle lister, int pos, Class<?> array, MethodHandle collector) {
         int collects = collector.type().parameterCount();
         int outputs = lister.type().parameterCount();
         if (pos == outputs - 1)
             return MethodHandles.filterArguments(lister, pos,
-                        collector.asSpreader(int[].class, collects))
-                            .asCollector(int[].class, collects);
+                        collector.asSpreader(array, collects))
+                            .asCollector(array, collects);
         //return MethodHandles.collectArguments(lister, pos, collector); //no such animal
         return null;
     }
@@ -537,6 +577,9 @@
     private static final MethodHandle[] INT_COLLECTORS = {
         constant(int.class, 42), opI, opI2, opI3, opI4
     };
+    private static final MethodHandle[] BYTE_COLLECTORS = {
+        constant(byte.class, (byte)42), i2b(opI), i2b(opI2), i2b(opI3), i2b(opI4)
+    };
     private static final MethodHandle[] LONG_COLLECTORS = {
         constant(long.class, 42), opJ, opJ2, opJ3
     };
@@ -559,21 +602,36 @@
                                                              Collections.nCopies(8, int.class));
     private static final MethodHandle list8longs = findStatic("list8longs", Object.class,
                                                               Collections.nCopies(8, long.class));
-    private static final MethodHandle[] INT_LISTERS, LONG_LISTERS;
+    private static final MethodHandle[] INT_LISTERS, LONG_LISTERS, BYTE_LISTERS;
     static {
         int listerCount = list8ints.type().parameterCount() + 1;
         INT_LISTERS  = new MethodHandle[listerCount];
         LONG_LISTERS = new MethodHandle[listerCount];
+        BYTE_LISTERS = new MethodHandle[listerCount];
         MethodHandle lister = list8ints;
         MethodHandle llister = list8longs;
         for (int i = listerCount - 1; ; i--) {
             INT_LISTERS[i] = lister;
             LONG_LISTERS[i] = llister;
+            BYTE_LISTERS[i] = i2b(lister);
             if (i == 0)  break;
             lister  = insertArguments(lister,  i-1, 0);
             llister = insertArguments(llister, i-1, 0L);
         }
     }
+    private static MethodHandle i2b(MethodHandle mh) {
+        return MethodHandles.explicitCastArguments(mh, subst(mh.type(), int.class, byte.class));
+    }
+    private static MethodType subst(MethodType mt, Class<?> from, Class<?> to) {
+        for (int i = 0; i < mt.parameterCount(); i++) {
+            if (mt.parameterType(i) == from)
+                mt = mt.changeParameterType(i, to);
+        }
+        if (mt.returnType() == from)
+            mt = mt.changeReturnType(to);
+        return mt;
+    }
+
 
     private static Object  convI_L(int     x) { stress(); return (Object)  x; }
     private static int     convL_I(Object  x) { stress(); return (int)     x; }
--- a/test/sun/invoke/util/ValueConversionsTest.java	Fri Sep 14 09:47:14 2012 -0700
+++ b/test/sun/invoke/util/ValueConversionsTest.java	Fri Sep 14 10:14:02 2012 -0700
@@ -159,14 +159,8 @@
             assertEquals(caster.type(), ValueConversions.identity().type());
             for (Object obj : objects) {
                 Class<?> src = obj.getClass();
-                boolean canCast;
-                if (dst.isInterface()) {
-                    canCast = true;
-                } else {
-                    canCast = dst.isAssignableFrom(src);
-                    assertEquals(canCast, dst.isInstance(obj));
-                }
-                //System.out.println("obj="+obj+" <: dst="+dst);
+                boolean canCast = dst.isAssignableFrom(src);
+                //System.out.println("obj="+obj+" <: dst="+dst+(canCast ? " (OK)" : " (will fail)"));
                 try {
                     Object result = caster.invokeExact(obj);
                     if (canCast)