< prev index next >

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

Print this page
*** 351,11 ***
                      owner::setTypeAttributes,
                      sym::setTypeAttributes);
  
  
              boolean init;
!             if ((init = (owner.name == names.init)) || owner.name == names.clinit) {
                  owner = owner.owner;
                  apportionTypeAnnotations(tree,
                          init ? owner::getInitTypeAttributes : owner::getClassInitTypeAttributes,
                          init ? owner::setInitTypeAttributes : owner::setClassInitTypeAttributes,
                          sym::appendUniqueTypeAttributes);
--- 351,12 ---
                      owner::setTypeAttributes,
                      sym::setTypeAttributes);
  
  
              boolean init;
!             // TODO - can <vnew> exist in this context?
+             if ((init = names.isInitOrVNew(owner.name)) || owner.name == names.clinit) {
                  owner = owner.owner;
                  apportionTypeAnnotations(tree,
                          init ? owner::getInitTypeAttributes : owner::getClassInitTypeAttributes,
                          init ? owner::setInitTypeAttributes : owner::setClassInitTypeAttributes,
                          sym::appendUniqueTypeAttributes);

*** 370,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),
                  List.nil(),
                  localContext.syntheticParams,
                  lambdaType.getThrownTypes() == null ?
                      List.nil() :
                      make.Types(lambdaType.getThrownTypes()),
--- 371,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).setType(lambdaType.getReturnType()),
                  List.nil(),
                  localContext.syntheticParams,
                  lambdaType.getThrownTypes() == null ?
                      List.nil() :
                      make.Types(lambdaType.getThrownTypes()),

*** 1659,11 ***
                      clinits.put(csym, clinit);
                  }
                  return clinit;
              } else {
                  //get the first constructor and treat it as the instance init sym
!                 for (Symbol s : csym.members_field.getSymbolsByName(names.init)) {
                      return s;
                  }
              }
              Assert.error("init not found");
              return null;
--- 1660,12 ---
                      clinits.put(csym, clinit);
                  }
                  return clinit;
              } else {
                  //get the first constructor and treat it as the instance init sym
!                 Name constructorName = csym.isConcreteValueClass() ? names.vnew : names.init;
+                 for (Symbol s : csym.members_field.getSymbolsByName(constructorName)) {
                      return s;
                  }
              }
              Assert.error("init not found");
              return null;

*** 1763,11 ***
           *  when translating away lambda expressions
           */
          private boolean lambdaIdentSymbolFilter(Symbol sym) {
              return (sym.kind == VAR || sym.kind == MTH)
                      && !sym.isStatic()
!                     && sym.name != names.init;
          }
  
          /**
           *  This is used to filter out those select nodes that need to be adjusted
           *  when translating away lambda expressions - at the moment, this is the
--- 1765,11 ---
           *  when translating away lambda expressions
           */
          private boolean lambdaIdentSymbolFilter(Symbol sym) {
              return (sym.kind == VAR || sym.kind == MTH)
                      && !sym.isStatic()
!                     && !names.isInitOrVNew(sym.name);
          }
  
          /**
           *  This is used to filter out those select nodes that need to be adjusted
           *  when translating away lambda expressions - at the moment, this is the

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

*** 1885,10 ***
--- 1887,12 ---
                  String methodName = name.toString();
                  if (methodName.equals("<clinit>")) {
                      methodName = "static";
                  } else if (methodName.equals("<init>")) {
                      methodName = "new";
+                 } else if (methodName.equals("<vnew>")) {
+                     methodName = "vnew";
                  }
                  return methodName;
              }
          }
  

*** 2339,11 ***
                          (!nestmateLambdas && isPrivateInOtherClass()) ||
                          isProtectedInSuperClassOfEnclosingClassInOtherPackage(tree.sym, owner) ||
                          !receiverAccessible() ||
                          (tree.getMode() == ReferenceMode.NEW &&
                            tree.kind != ReferenceKind.ARRAY_CTOR &&
!                           (tree.sym.owner.isDirectlyOrIndirectlyLocal() || tree.sym.owner.isInner()));
              }
  
              Type generatedRefSig() {
                  return types.erasure(tree.sym.type);
              }
--- 2343,11 ---
                          (!nestmateLambdas && isPrivateInOtherClass()) ||
                          isProtectedInSuperClassOfEnclosingClassInOtherPackage(tree.sym, owner) ||
                          !receiverAccessible() ||
                          (tree.getMode() == ReferenceMode.NEW &&
                            tree.kind != ReferenceKind.ARRAY_CTOR &&
!                           (tree.sym.owner.isDirectlyOrIndirectlyLocal() || tree.sym.owner.isInner() || tree.sym.owner.isValueClass()));
              }
  
              Type generatedRefSig() {
                  return types.erasure(tree.sym.type);
              }
< prev index next >