Details

    • Verified

    Description

      Bytecode generation has been improved for enhanced for loops, providing an improvement in the translation approach for them. For example:
      ```
      List<String> data = new ArrayList<>();
      for (String b : data);
      ```
      The following is the code generated after the enhancement:
      ```
      {
          /*synthetic*/ Iterator i$ = data.iterator();
          for (; i$.hasNext(); ) {
              String b = (String)i$.next();
          }
          b = null;
          i$ = null;
      }
      ```
      Declaring the iterator variable outside of the for loop allows a null to be assigned to it as soon as it is no longer used. This makes it accessible to the GC, which can then get rid of the unused memory. Something similar is done for the case when the expression in the enhanced for loop is an array.

      Attachments

        Activity

          People

            vromero Vicente Arturo Romero Zaldivar
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: