--- /dev/null	2009-01-20 02:47:17.000000000 -0800
+++ new/src/share/projects/meth/src/impl/java/dyn/BoundMethodHandle.java	2009-01-20 02:47:17.000000000 -0800
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2008-2009 Sun Microsystems, Inc.  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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package impl.java.dyn;
+
+import java.dyn.*;
+
+/**
+ * The flavor of method handle which emulates an invoke instruction
+ * on a predetermined argument.  The JVM dispatches to the correct method
+ * when the handle is created, not when it is invoked.
+ * @author jrose
+ */
+public class BoundMethodHandle extends MethodHandle  {
+    //MethodHandle vmtarget;           // next BMH or final DMH or methodOop
+    private final Object argument;     // argument to insert
+    private final int    vmargslot;    // position at which it is inserted
+
+    // Constructors in this class *must* be package scoped or private.
+
+    /** Bind a direct MH to its receiver (or first ref. argument).
+     *  The JVM will pre-dispatch the MH if it is not already static.
+     */
+    BoundMethodHandle(DirectMethodHandle mh, Object argument) {
+        super(Access.TOKEN, mh.type().deleteParameterType(0));
+        // check the type now, once for all:
+        this.argument = mh.type().parameterType(0).cast(argument);
+        this.vmargslot = this.type().parameterSlotCount();
+        if (MethodHandleNatives.JVM_SUPPORT) {
+            this.vmtarget = null;  // maybe updated by JVM
+            MethodHandleNatives.init(this, mh, 0);
+        } else {
+            this.vmtarget = mh;
+        }
+     }
+
+    /** Insert an argument into an arbitrary method handle.
+     *  If argnum is zero, inserts the first argument, etc.
+     */
+    BoundMethodHandle(MethodHandle mh, Object argument, int argnum) {
+        super(Access.TOKEN, mh.type().deleteParameterType(argnum));
+        this.argument = mh.type().parameterType(argnum).cast(argument);
+        this.vmargslot = this.type().parameterSlot(argnum-1);
+        System.out.println("init BMH type="+type()+" argnum="+argnum+" vmargslot="+vmargslot);
+        if (MethodHandleNatives.JVM_SUPPORT) {
+            this.vmtarget = null;  // maybe updated by JVM
+            MethodHandleNatives.init(this, mh, argnum);
+        } else {
+            this.vmtarget = mh;
+        }
+    }
+
+    /** For subclasses only.
+     */
+    BoundMethodHandle(MethodType type, Object argument, int vmargslot) {
+        super(Access.TOKEN, type);
+        this.argument = argument;
+        this.vmargslot = vmargslot;
+        assert(this.getClass() != BoundMethodHandle.class);
+    }
+
+    @Override
+    public String toString() {
+        return "Bound[" + super.toString() + "]";
+    }
+}
