changeset 1707:920d3226b48b

Serialized lambda: test all incoming parameters. Fixes SerializedLambdaTest.
author rfield
date Fri, 28 Dec 2012 11:18:30 -0800
parents 1faa2226c00e
children 767ba50fb4b2
files src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
diffstat 1 files changed, 23 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Wed Dec 19 16:39:47 2012 -0800
+++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Fri Dec 28 11:18:30 2012 -0800
@@ -548,19 +548,14 @@
 
     private void addDeserializationCase(int implMethodKind, Symbol refSym, Type targetType, MethodSymbol samSym,
             DiagnosticPosition pos, List<Object> staticArgs, MethodType indyType) {
-        String capturingClass = "??????";
-        int functionalInterfaceMethodKind = -1;
-        String implMethodName = refSym.getQualifiedName().toString();
         String functionalInterfaceClass = classSig(targetType);
         String functionalInterfaceMethodName = samSym.getSimpleName().toString();
         String functionalInterfaceMethodSignature = methodSig(types.erasure(samSym.type));
-        String implClass = refSym.owner.toString();
+        String implClass = classSig(refSym.owner.type);
+        String implMethodName = refSym.getQualifiedName().toString();
         String implMethodSignature = methodSig(types.erasure(refSym.type));
-        String instantiatedMethodType = "??????";
          
-        JCBinary kindTest = make.Binary(JCTree.Tag.EQ, deserGetter("getImplMethodKind", syms.intType), make.Literal(implMethodKind));
-        kindTest.operator = rs.resolveBinaryOperator(null, JCTree.Tag.EQ, attrEnv, syms.intType, syms.intType);
-        kindTest.setType(syms.booleanType);
+        JCExpression kindTest = eqTest(syms.intType, deserGetter("getImplMethodKind", syms.intType), make.Literal(implMethodKind));
         ListBuffer<JCExpression> serArgs = ListBuffer.lb();
         int i = 0;
         for (Type t : indyType.getParameterTypes()) {
@@ -568,10 +563,13 @@
             ++i;
         }
         JCStatement stmt = make.If(
-                deserTest(deserTest( //deserTest(deserTest(deserTest(
+                deserTest(deserTest(deserTest(deserTest(deserTest(
                     kindTest, 
                     "getFunctionalInterfaceClass", functionalInterfaceClass),
                     "getFunctionalInterfaceMethodName", functionalInterfaceMethodName),
+                    "getFunctionalInterfaceMethodSignature", functionalInterfaceMethodSignature),
+                    "getImplClass", implClass),
+                    "getImplMethodSignature", implMethodSignature),
                 make.Return(makeIndyCall(
                     pos, 
                     syms.lambdaMetafactory, 
@@ -583,23 +581,26 @@
             stmts = ListBuffer.lb();
             kInfo.deserializeCases.put(implMethodName, stmts);
         }
-        /***
+        /****
         System.err.printf("+++++++++++++++++\n");
-        System.err.printf("capturingClass: '%s'\n", capturingClass);
-        System.err.printf("functionalInterfaceMethodKind: %d\n", functionalInterfaceMethodKind);
-        System.err.printf("functionalInterfaceClass: '%s' -- %s\n", functionalInterfaceClass, 
-                functionalInterfaceClass.equals("java/util/function/Predicate")? "EQUALS" : "NOT-EQUALS");
-        System.err.printf("functionalInterfaceMethodName: '%s'\n", functionalInterfaceMethodName);
-        System.err.printf("functionalInterfaceMethodSignature: '%s'\n", functionalInterfaceMethodSignature);
-        System.err.printf("implMethodKind: %d\n", implMethodKind);
-        System.err.printf("implClass: '%s'\n", implClass);
-        System.err.printf("implMethodName: '%s'\n", implMethodName);
-        System.err.printf("implMethodSignature: '%s'\n", implMethodSignature);
-        System.err.printf("instantiatedMethodType: '%s'\n", instantiatedMethodType);
-        ***/
+        System.err.printf("*functionalInterfaceClass: '%s'\n", functionalInterfaceClass);
+        System.err.printf("*functionalInterfaceMethodName: '%s'\n", functionalInterfaceMethodName);
+        System.err.printf("*functionalInterfaceMethodSignature: '%s'\n", functionalInterfaceMethodSignature);
+        System.err.printf("*implMethodKind: %d\n", implMethodKind);
+        System.err.printf("*implClass: '%s'\n", implClass);
+        System.err.printf("*implMethodName: '%s'\n", implMethodName);
+        System.err.printf("*implMethodSignature: '%s'\n", implMethodSignature);
+        ****/
         stmts.append(stmt);
     }
     
+    private JCExpression eqTest(Type argType, JCExpression arg1, JCExpression arg2) {
+        JCBinary testExpr = make.Binary(JCTree.Tag.EQ, arg1, arg2);
+        testExpr.operator = rs.resolveBinaryOperator(null, JCTree.Tag.EQ, attrEnv, argType, argType);
+        testExpr.setType(syms.booleanType);
+        return testExpr;
+    }
+    
     private JCExpression deserTest(JCExpression prev, String func, String lit) {
         MethodType eqmt = new MethodType(List.of(syms.objectType), syms.booleanType, List.<Type>nil(), syms.methodClass);
         Symbol eqsym = rs.resolveQualifiedMethod(null, attrEnv, syms.objectType, names.equals, List.of(syms.objectType), List.<Type>nil());