Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8026758

Inefficient code in LambdaToMethod

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8
    • 8
    • tools
    • b115
    • Not verified

    Description

      This code in visitIdent is horribly inefficient since every call to getSymbolMap creates a fresh new instance of a translationMap. There should be a single method which returns a pair of LambdaSymbolKind and the translated symbol



                  if (lambdaContext.getSymbolMap(PARAM).containsKey(tree.sym)) {
                      Symbol translatedSym = lambdaContext.getSymbolMap(PARAM).get(tree.sym);
                      result = make.Ident(translatedSym).setType(tree.type);
                      translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes());
                  } else if (lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) {
                      Symbol translatedSym = lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym);
                      result = make.Ident(translatedSym).setType(tree.type);
                      translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes());
                  } else if (lambdaContext.getSymbolMap(TYPE_VAR).containsKey(tree.sym)) {
                      Symbol translatedSym = lambdaContext.getSymbolMap(TYPE_VAR).get(tree.sym);
                      result = make.Ident(translatedSym).setType(translatedSym.type);
                      translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes());
                  } else if (lambdaContext.getSymbolMap(CAPTURED_VAR).containsKey(tree.sym)) {
                      Symbol translatedSym = lambdaContext.getSymbolMap(CAPTURED_VAR).get(tree.sym);
                      result = make.Ident(translatedSym).setType(tree.type);
                  } else {
                      //access to untranslated symbols (i.e. compile-time constants,
                      //members defined inside the lambda body, etc.) )
                      super.visitIdent(tree);
                  }

      Attachments

        Activity

          People

            ksrini Kumar Srinivasan
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: