changeset 24:f5ed38073bc3

meth: name changes: invoke_[0-9] => invoke; invoke(mh,...) => invokeVarargs(my,...)
author jrose
date Tue, 21 Jul 2009 02:04:35 -0700
parents 4a09278b5c95
children 5745e8f6c36b
files netbeans/indy-demo/nbproject/project.properties netbeans/meth/test/jdk/java/dyn/MethodHandleBytecodeTest.java netbeans/meth/test/jdk/java/dyn/MethodHandlesTest.java netbeans/meth/test/sun/dyn/util/ValueConversionsTest.java
diffstat 4 files changed, 30 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/netbeans/indy-demo/nbproject/project.properties	Thu Jul 02 03:34:27 2009 -0700
+++ b/netbeans/indy-demo/nbproject/project.properties	Tue Jul 21 02:04:35 2009 -0700
@@ -5,6 +5,7 @@
 # This directory is removed when the project is cleaned:
 build.dir=build
 build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
 # Only compile against the classpath explicitly listed here:
 build.sysclasspath=ignore
 build.test.classes.dir=${build.dir}/test/classes
--- a/netbeans/meth/test/jdk/java/dyn/MethodHandleBytecodeTest.java	Thu Jul 02 03:34:27 2009 -0700
+++ b/netbeans/meth/test/jdk/java/dyn/MethodHandleBytecodeTest.java	Tue Jul 21 02:04:35 2009 -0700
@@ -69,7 +69,7 @@
 
     private String invokeToString(MethodHandle mh, Object obj) throws Throwable {
         System.out.println("invoke mh="+mh);
-        return (String) MethodHandles.invoke_1(mh, obj);
+        return (String) MethodHandles.invoke(mh, obj);
     }
 
     // Extra entry point for standalone use.  Use as follows:
--- a/netbeans/meth/test/jdk/java/dyn/MethodHandlesTest.java	Thu Jul 02 03:34:27 2009 -0700
+++ b/netbeans/meth/test/jdk/java/dyn/MethodHandlesTest.java	Tue Jul 21 02:04:35 2009 -0700
@@ -347,7 +347,7 @@
         if (!DO_MORE_CALLS && lookup != PRIVATE)  return;
         Object[] args = randomArgs(params);
         printCalled(target, name, args);
-        MethodHandles.invoke(target, args);
+        MethodHandles.invokeVarargs(target, args);
         assertCalled(name, args);
         System.out.print(':');
     }
@@ -414,7 +414,7 @@
         Object[] argsWithSelf = randomArgs(paramsWithSelf);
         if (rcvc != defc)  argsWithSelf[0] = randomArg(rcvc);
         printCalled(target, name, argsWithSelf);
-        MethodHandles.invoke(target, argsWithSelf);
+        MethodHandles.invokeVarargs(target, argsWithSelf);
         assertCalled(name, argsWithSelf);
         System.out.print(':');
     }
@@ -459,7 +459,7 @@
         if (!DO_MORE_CALLS && lookup != PRIVATE)  return;
         Object[] args = randomArgs(paramsWithSelf);
         printCalled(target, name, args);
-        MethodHandles.invoke(target, args);
+        MethodHandles.invokeVarargs(target, args);
         assertCalled(name, args);
         System.out.print(':');
     }
@@ -509,7 +509,7 @@
         assertEquals(type, target.type());
         Object[] args = randomArgs(params);
         printCalled(target, name, args);
-        MethodHandles.invoke(target, args);
+        MethodHandles.invokeVarargs(target, args);
         Object[] argsWithReceiver = cat(array(Object[].class, receiver), args);
         assertCalled(name, argsWithReceiver);
         System.out.print(':');
@@ -580,7 +580,7 @@
         assertEquals(typeMaybeWithSelf, ttype);
         Object[] argsMaybeWithSelf = randomArgs(paramsMaybeWithSelf);
         printCalled(target, name, argsMaybeWithSelf);
-        MethodHandles.invoke(target, argsMaybeWithSelf);
+        MethodHandles.invokeVarargs(target, argsMaybeWithSelf);
         assertCalled(name, argsMaybeWithSelf);
         System.out.print(':');
     }
@@ -696,7 +696,7 @@
             if (src != dst)
                 convArgs[i] = Wrapper.forPrimitiveType(dst).cast(convArgs[i], dst);
         }
-        Object convResult = MethodHandles.invoke(id, convArgs);
+        Object convResult = MethodHandles.invokeVarargs(id, convArgs);
         {
             Class<?> dst = newType.returnType();
             Class<?> src = idType.returnType();
@@ -718,7 +718,7 @@
         if (!positive)  return; // negative test failed as expected
         assertEquals(newType, target.type());
         printCalled(target, id.toString(), args);
-        Object result = MethodHandles.invoke(target, args);
+        Object result = MethodHandles.invokeVarargs(target, args);
         assertCalled(name, convArgs);
         assertEquals(convResult, result);
         System.out.print(':');
@@ -839,7 +839,7 @@
         MethodType outType = MethodType.make(Object.class, permTypes);
         MethodHandle target = MethodHandles.convertArguments(ValueConversions.varargsList(outargs), outType);
         MethodHandle newTarget = MethodHandles.permuteArguments(target, inType, reorder);
-        Object result = MethodHandles.invoke(newTarget, args);
+        Object result = MethodHandles.invokeVarargs(newTarget, args);
         Object expected = Arrays.asList(permArgs);
         assertEquals(expected, result);
     }
@@ -870,7 +870,7 @@
         Object[] args = randomArgs(target2.type().parameterArray());
         // make sure the target does what we think it does:
         if (pos == 0 && nargs < 5) {
-            Object[] check = (Object[]) MethodHandles.invoke(target, args);
+            Object[] check = (Object[]) MethodHandles.invokeVarargs(target, args);
             assertArrayEquals(args, check);
             switch (nargs) {
                 case 0:
@@ -900,7 +900,7 @@
         } else {
             Object[] args1 = Arrays.copyOfRange(args, 0, pos+1);
             args1[pos] = Arrays.copyOfRange(args, pos, args.length);
-            returnValue = (Object[]) MethodHandles.invoke(result, args1);
+            returnValue = (Object[]) MethodHandles.invokeVarargs(result, args1);
         }
         assertArrayEquals(args, returnValue);
     }
@@ -937,7 +937,7 @@
         if (verbosity >= 2)
             System.out.println("collect from "+Arrays.asList(args)+" ["+pos+".."+nargs+"]");
         MethodHandle result = MethodHandles.collectArguments(target, newType);
-        Object[] returnValue = (Object[]) MethodHandles.invoke(result, args);
+        Object[] returnValue = (Object[]) MethodHandles.invokeVarargs(result, args);
 //        assertTrue(returnValue.length == pos+1 && returnValue[pos] instanceof Object[]);
 //        returnValue[pos] = Arrays.asList((Object[]) returnValue[pos]);
 //        collectedArgs[pos] = Arrays.asList((Object[]) collectedArgs[pos]);
@@ -970,7 +970,7 @@
         MethodHandle target2 = MethodHandles.insertArguments(target, pos,
                 (Object[]) argsToInsert.toArray());
         argsToInsert.clear();  // remove from argsToInsert
-        Object res2 = MethodHandles.invoke(target2, argsToPass.toArray());
+        Object res2 = MethodHandles.invokeVarargs(target2, argsToPass.toArray());
         Object res2List = Arrays.asList((Object[])res2);
         if (verbosity >= 2)
             System.out.println("result: "+res2List);
@@ -1005,7 +1005,7 @@
         Object[] filteredArgs = argsToPass.clone();
         filteredArgs[pos] = filter.invoke(filteredArgs[pos]);
         List<Object> expected = Arrays.asList(filteredArgs);
-        Object result = MethodHandles.invoke(target2, argsToPass);
+        Object result = MethodHandles.invokeVarargs(target2, argsToPass);
         if (verbosity >= 2)
             System.out.println("result: "+result);
         if (!expected.equals(result))
@@ -1040,9 +1040,9 @@
         List<Object> argsToFold = expected.subList(pos, pos + fold);
         if (verbosity >= 2)
             System.out.println("fold: "+argsToFold+" into "+target2);
-        Object foldedArgs = MethodHandles.invoke(combine, argsToFold.toArray());
+        Object foldedArgs = MethodHandles.invokeVarargs(combine, argsToFold.toArray());
         argsToFold.add(0, foldedArgs);
-        Object result = MethodHandles.invoke(target2, argsToPass.toArray());
+        Object result = MethodHandles.invokeVarargs(target2, argsToPass.toArray());
         if (verbosity >= 2)
             System.out.println("result: "+result);
         if (!expected.equals(result))
@@ -1074,7 +1074,7 @@
         for (int i = drop; i > 0; i--) {
             argsToDrop.add(pos, "blort#"+i);
         }
-        Object res2 = MethodHandles.invoke(target2, argsToDrop.toArray());
+        Object res2 = MethodHandles.invokeVarargs(target2, argsToDrop.toArray());
         Object res2List = Arrays.asList((Object[])res2);
         //if (!resList.equals(res2List))
         //    System.out.println("*** fail at n/p/d = "+nargs+"/"+pos+"/"+drop+": "+argsToDrop+" => "+res2List);
@@ -1130,7 +1130,7 @@
         countTest();
         calledLog.clear();
         inv = MethodHandles.exactInvoker(type);
-        result = MethodHandles.invoke(inv, targetPlusArgs.toArray());
+        result = MethodHandles.invokeVarargs(inv, targetPlusArgs.toArray());
         if (testRetCode)  assertEquals(code, result);
         assertCalled("invokee", args);
         // generic invoker
@@ -1156,7 +1156,7 @@
             assertCalled("invokee", args);
         }
         calledLog.clear();
-        result = MethodHandles.invoke(inv, targetPlusArgs.toArray());
+        result = MethodHandles.invokeVarargs(inv, targetPlusArgs.toArray());
         if (testRetCode)  assertEquals(code, result);
         assertCalled("invokee", args);
         // varargs invoker #0
@@ -1198,7 +1198,7 @@
             List<Object> tailList = targetPlusVarArgs.subList(1+k, 1+nargs);
             Object[] tail = tailList.toArray();
             tailList.clear(); tailList.add(tail);
-            result = MethodHandles.invoke(inv, targetPlusVarArgs.toArray());
+            result = MethodHandles.invokeVarargs(inv, targetPlusVarArgs.toArray());
             if (testRetCode)  assertEquals(code, result);
             assertCalled("invokee", args);
         }
@@ -1208,7 +1208,7 @@
         inv = MethodHandles.dynamicInvoker(site);
         site.setTarget(target);
         calledLog.clear();
-        result = MethodHandles.invoke(inv, args);
+        result = MethodHandles.invokeVarargs(inv, args);
         if (testRetCode)  assertEquals(code, result);
         assertCalled("invokee", args);
     }
@@ -1292,7 +1292,7 @@
             String willCall = (equals ? "targetIfEquals" : "fallbackIfNotEquals");
             if (verbosity >= 2)
                 System.out.println(logEntry(willCall, argList));
-            Object result = MethodHandles.invoke(mh, argList);
+            Object result = MethodHandles.invokeVarargs(mh, argList);
             assertCalled(willCall, argList);
         }
     }
@@ -1319,6 +1319,8 @@
 
     void testCatchException(Class<?> returnType, Throwable thrown, boolean throwIt, int nargs) throws Throwable {
         countTest();
+        if (verbosity >= 2)
+            System.out.println("catchException rt="+returnType+" throw="+throwIt+" nargs="+nargs);
         Class<? extends Throwable> exType = thrown.getClass();
         MethodHandle throwOrReturn
                 = PRIVATE.findStatic(MethodHandlesTest.class, "throwOrReturn",
@@ -1332,7 +1334,7 @@
         //System.out.println("catching with "+target+" : "+throwOrReturn);
         Object[] args = randomArgs(nargs, Object.class);
         args[1] = (throwIt ? thrown : null);
-        Object returned = MethodHandles.invoke(target, args);
+        Object returned = MethodHandles.invokeVarargs(target, args);
         //System.out.println("return from "+target+" : "+returned);
         if (!throwIt) {
             assertSame(args[0], returned);
@@ -1361,7 +1363,7 @@
         assertEquals(expectedType, target.type());
         Throwable caught = null;
         try {
-            Object res = MethodHandles.invoke_1(target, thrown);
+            Object res = MethodHandles.invokeVarargs(target, thrown);
             fail("got "+res+" instead of throwing "+thrown);
         } catch (Throwable ex) {
             if (ex != thrown) {
@@ -1373,6 +1375,7 @@
         assertSame(thrown, caught);
     }
 
+
 }
 
 // This guy tests access from outside the same package member, but inside
--- a/netbeans/meth/test/sun/dyn/util/ValueConversionsTest.java	Thu Jul 02 03:34:27 2009 -0700
+++ b/netbeans/meth/test/sun/dyn/util/ValueConversionsTest.java	Tue Jul 21 02:04:35 2009 -0700
@@ -243,7 +243,7 @@
             Object[] args = new Object[nargs];
             for (int i = 0; i < nargs; i++)
                 args[i] = "#"+i;
-            Object res = MethodHandles.invoke(target, args);
+            Object res = MethodHandles.invokeVarargs(target, args);
             assertArrayEquals(args, (Object[])res);
         }
     }
@@ -256,7 +256,7 @@
             Object[] args = new Object[nargs];
             for (int i = 0; i < nargs; i++)
                 args[i] = "#"+i;
-            Object res = MethodHandles.invoke(target, args);
+            Object res = MethodHandles.invokeVarargs(target, args);
             assertEquals(Arrays.asList(args), res);
         }
     }