< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java

Print this page
@@ -365,11 +365,11 @@
          }
  
          //create the method declaration hoisting the lambda body
          JCMethodDecl lambdaDecl = make.MethodDef(make.Modifiers(sym.flags_field),
                  sym.name,
-                 make.QualIdent(lambdaType.getReturnType().tsym),
+                 make.QualIdent(lambdaType.getReturnType().tsym).setType(lambdaType.getReturnType()),
                  List.nil(),
                  localContext.syntheticParams,
                  lambdaType.getThrownTypes() == null ?
                      List.nil() :
                      make.Types(lambdaType.getThrownTypes()),

@@ -1848,11 +1848,11 @@
              /** does this functional expression require serialization support? */
              boolean isSerializable() {
                  if (forceSerializable) {
                      return true;
                  }
-                 return types.asSuper(tree.target, syms.serializableType.tsym) != null;
+                 return types.asSuper(tree.target.referenceProjectionOrSelf(), syms.serializableType.tsym) != null;
              }
  
              /**
               * @return Name of the enclosing method to be folded into synthetic
               * method name

@@ -2271,10 +2271,18 @@
                  //when 292 issue is fixed we should remove this and change the backend
                  //code to always generate a method handle to an accessible method
                  return tree.ownerAccessible;
              }
  
+             /* Workaround to BootstrapMethodError. This workaround should not be required in the unified
+                class generation model, but seems to be required ...
+                Todo: Investigate to see if a defect should be reported against runtime lambda machinery
+             */
+             boolean receiverIsReferenceProjection() {
+                 return tree.getQualifierExpression().type.isPrimitiveReferenceType();
+             }
+ 
              /**
               * This method should be called only when target release <= 14
               * where LambdaMetaFactory does not spin nestmate classes.
               *
               * This method should be removed when --release 14 is not supported.

@@ -2323,13 +2331,14 @@
                          needsVarArgsConversion() ||
                          isArrayOp() ||
                          (!nestmateLambdas && isPrivateInOtherClass()) ||
                          isProtectedInSuperClassOfEnclosingClassInOtherPackage(tree.sym, owner) ||
                          !receiverAccessible() ||
+                         receiverIsReferenceProjection() ||
                          (tree.getMode() == ReferenceMode.NEW &&
                            tree.kind != ReferenceKind.ARRAY_CTOR &&
-                           (tree.sym.owner.isDirectlyOrIndirectlyLocal() || tree.sym.owner.isInner()));
+                           (tree.sym.owner.isDirectlyOrIndirectlyLocal() || tree.sym.owner.isInner() || tree.sym.owner.isPrimitiveClass()));
              }
  
              Type generatedRefSig() {
                  return types.erasure(tree.sym.type);
              }
< prev index next >