--- a/meth.patch Mon Apr 06 03:29:37 2009 -0700
+++ b/meth.patch Tue Apr 07 02:06:36 2009 -0700
@@ -1,3 +1,22 @@ diff --git a/make/docs/CORE_PKGS.gmk b/m
+diff --git a/make/Makefile b/make/Makefile
+--- a/make/Makefile
++++ b/make/Makefile
+@@ -1,5 +1,5 @@
+ #
+-# Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
++# Copyright 1995-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
+@@ -239,7 +239,7 @@
+
+ all build:: sanity-all post-sanity-all
+
+-SUBDIRS = tools java javax org sun sunw com jpda mkdemo mksample launchers
++SUBDIRS = tools java javax org impl sun sunw com jpda mkdemo mksample launchers
+ all build::
+ $(SUBDIRS-loop)
+
diff --git a/make/docs/CORE_PKGS.gmk b/make/docs/CORE_PKGS.gmk
--- a/make/docs/CORE_PKGS.gmk
+++ b/make/docs/CORE_PKGS.gmk
@@ -178,7 +197,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/src/share/classes/impl/java/dyn/AdapterMethodHandle.java
-@@ -0,0 +1,599 @@
+@@ -0,0 +1,596 @@
+/*
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -485,33 +504,30 @@ new file mode 100644
+ private static long makeConv(int convOp, int argnum, int src, int dest) {
+ assert(src == (src & 0xF));
+ assert(dest == (dest & 0xF));
-+ assert(convOp == (convOp & CONV_OP_MASK));
-+ assert(convOp >= CHECK_CAST && convOp <= PRIM_TO_REF);
++ assert(convOp >= OP_CHECK_CAST && convOp <= OP_PRIM_TO_REF);
+ long stackMove = type2size(dest) - type2size(src);
+ return ((long) argnum << 32 |
-+ (long) convOp |
++ (long) convOp << CONV_OP_SHIFT |
+ (int) src << CONV_SRC_TYPE_SHIFT |
+ (int) dest << CONV_DEST_TYPE_SHIFT |
+ stackMove << CONV_STACK_MOVE_SHIFT
+ );
+ }
+ private static long makeConv(int convOp, int argnum, int stackMove) {
-+ assert(convOp == (convOp & CONV_OP_MASK));
-+ assert(convOp >= SWAP_ARGS && convOp <= SPREAD_ARGS);
++ assert(convOp >= OP_SWAP_ARGS && convOp <= OP_SPREAD_ARGS);
+ byte src = 0, dest = 0;
-+ if (convOp >= COLLECT_ARGS && convOp <= SPREAD_ARGS)
++ if (convOp >= OP_COLLECT_ARGS && convOp <= OP_SPREAD_ARGS)
+ src = dest = T_OBJECT;
+ return ((long) argnum << 32 |
-+ (long) convOp |
++ (long) convOp << CONV_OP_SHIFT |
+ (int) src << CONV_SRC_TYPE_SHIFT |
+ (int) dest << CONV_DEST_TYPE_SHIFT |
+ stackMove << CONV_STACK_MOVE_SHIFT
+ );
+ }
+ private static long makeConv(int convOp) {
-+ assert(convOp == (convOp & CONV_OP_MASK));
-+ assert(convOp == RETYPE_ONLY);
-+ return (long) convOp; // stackMove, src, dst, argnum all zero
++ assert(convOp == OP_RETYPE_ONLY);
++ return (long) convOp << CONV_OP_SHIFT; // stackMove, src, dst, argnum all zero
+ }
+ private static int convCode(long conv) {
+ return (int)conv;
@@ -590,7 +606,7 @@ new file mode 100644
+ Access.check(token);
+ assert(canRetypeOnly(newType, target.type()));
+ // %%% TO DO: If adapter is already an adapter, fold in the retyping.
-+ return new AdapterMethodHandle(target, newType, makeConv(RETYPE_ONLY));
++ return new AdapterMethodHandle(target, newType, makeConv(OP_RETYPE_ONLY));
+ }
+
+ /** Can a checkcast adapter validly convert the target to newType?
@@ -620,7 +636,7 @@ new file mode 100644
+ int arg, Class<?> castType) {
+ Access.check(token);
+ assert(canCheckCast(newType, target.type(), arg, castType));
-+ long conv = makeConv(CHECK_CAST, arg, 0);
++ long conv = makeConv(OP_CHECK_CAST, arg, 0);
+ return new AdapterMethodHandle(target, newType, conv, castType);
+ }
+
@@ -665,7 +681,7 @@ new file mode 100644
+ Class<?> src = newType.parameterType(arg);
+ Class<?> dst = oldType.parameterType(arg);
+ assert(canPrimCast(newType, oldType, arg, convType));
-+ long conv = makeConv(PRIM_TO_PRIM, arg, basicType(src), basicType(convType));
++ long conv = makeConv(OP_PRIM_TO_PRIM, arg, basicType(src), basicType(convType));
+ return new AdapterMethodHandle(target, newType, conv);
+ }
+
@@ -704,7 +720,7 @@ new file mode 100644
+ MethodType castDone = newType;
+ if (!VerifyType.isNullConversion(src, boxType))
+ castDone = newType.changeParameterType(arg, boxType);
-+ long conv = makeConv(REF_TO_PRIM, arg, T_OBJECT, basicType(primType));
++ long conv = makeConv(OP_REF_TO_PRIM, arg, T_OBJECT, basicType(primType));
+ MethodHandle adapter = new AdapterMethodHandle(target, castDone, conv, boxType);
+ if (castDone == newType)
+ return adapter;
@@ -772,7 +788,7 @@ new file mode 100644
+ dropSlotCount = lastKeptSlot - dropSlotPos;
+ assert(dropSlotCount >= dropArgCount);
+ }
-+ long conv = makeConv(DROP_ARGS, dropArgPos, +dropSlotCount);
++ long conv = makeConv(OP_DROP_ARGS, dropArgPos, +dropSlotCount);
+ return new AdapterMethodHandle(target, newType, dropSlotCount, conv);
+ }
+
@@ -2320,7 +2336,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/src/share/classes/impl/java/dyn/MethodHandleNatives.java
-@@ -0,0 +1,240 @@
+@@ -0,0 +1,245 @@
+/*
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -2492,28 +2508,33 @@ new file mode 100644
+
+ // AdapterMethodHandle
+ /** Conversions recognized by the JVM.
-+ * They must align with enum AdapterKind in vm/prims/methodHandles.hpp.
++ * They must align with the constants in impl_java_dyn_AdapterMethodHandle,
++ * in the JVM file hotspot/src/share/vm/classfile/javaClasses.hpp.
+ */
+ static final int
-+ RETYPE_ONLY = 0x000, // no argument changes; straight retype
-+ CHECK_CAST = 0x100, // ref-to-ref conversion; requires a Class argument
-+ PRIM_TO_PRIM = 0x200, // converts from one primitive to another
-+ REF_TO_PRIM = 0x300, // unboxes a wrapper to produce a primitive
-+ PRIM_TO_REF = 0x400, // boxes a primitive into a wrapper (NYI)
-+ SWAP_ARGS = 0x500, // swap arguments (vminfo is 2nd arg)
-+ ROT_ARGS = 0x600, // rotate arguments (vminfo is displaced arg)
-+ DUP_ARGS = 0x700, // duplicates one or more arguments (at TOS)
-+ DROP_ARGS = 0x800, // remove one or more argument slots
-+ COLLECT_ARGS = 0x900, // combine one or more arguments into a varargs (NYI)
-+ SPREAD_ARGS = 0xA00, // expand in place a varargs array (of known size)
-+ FLYBY = 0xB00, // operate first on reified argument list (NYI)
-+ RICOCHET = 0xC00; // run an adapter chain on the return value (NYI)
++ OP_RETYPE_ONLY = 0x0, // no argument changes; straight retype
++ OP_CHECK_CAST = 0x1, // ref-to-ref conversion; requires a Class argument
++ OP_PRIM_TO_PRIM = 0x2, // converts from one primitive to another
++ OP_REF_TO_PRIM = 0x3, // unboxes a wrapper to produce a primitive
++ OP_PRIM_TO_REF = 0x4, // boxes a primitive into a wrapper (NYI)
++ OP_SWAP_ARGS = 0x5, // swap arguments (vminfo is 2nd arg)
++ OP_ROT_ARGS = 0x6, // rotate arguments (vminfo is displaced arg)
++ OP_DUP_ARGS = 0x7, // duplicates one or more arguments (at TOS)
++ OP_DROP_ARGS = 0x8, // remove one or more argument slots
++ OP_COLLECT_ARGS = 0x9, // combine one or more arguments into a varargs (NYI)
++ OP_SPREAD_ARGS = 0xA, // expand in place a varargs array (of known size)
++ OP_FLYBY = 0xB, // operate first on reified argument list (NYI)
++ OP_RICOCHET = 0xC, // run an adapter chain on the return value (NYI)
++ CONV_OP_LIMIT = 0xD; // limit of CONV_OP enumeration
++ /** Shift and mask values for decoding the AMH.conversion field.
++ * These numbers are shared with the JVM for creating AMHs.
++ */
+ static final int
-+ CONV_OP_MASK = 0xF00, // byte 3 contains the conversion op field
++ CONV_OP_MASK = 0xF00, // this nybble contains the conversion op field
+ CONV_VMINFO_MASK = 0x0FF, // LSB is reserved for JVM use
+ CONV_VMINFO_SHIFT = 0, // position of bits in CONV_VMINFO_MASK
+ CONV_OP_SHIFT = 8, // position of bits in CONV_OP_MASK
-+ CONV_DEST_TYPE_SHIFT = 12, // byte 3 has the adapter BasicType (if needed)
++ CONV_DEST_TYPE_SHIFT = 12, // byte 2 has the adapter BasicType (if needed)
+ CONV_SRC_TYPE_SHIFT = 16, // byte 2 has the source BasicType (if needed)
+ CONV_STACK_MOVE_SHIFT = 20, // high 12 bits give signed SP change
+ CONV_STACK_MOVE_MASK = (1 << (32 - CONV_STACK_MOVE_SHIFT)) - 1;