Skip to content

Possible enhanced for loop failure #72

@JDLogic

Description

@JDLogic

MC 1.16-pre1 BackupList.func_230753_a_

...
      try {
         JsonElement jsonelement = jsonparser.parse(p_230753_0_).getAsJsonObject().get("backups");
         if (jsonelement.isJsonArray()) {
            Iterator<JsonElement> iterator = jsonelement.getAsJsonArray().iterator();

            while(iterator.hasNext()) {
               backuplist.field_230560_a_.add(Backup.func_230750_a_(iterator.next()));
            }
         }
      } catch (Exception exception) {
         field_230561_b_.error("Could not parse BackupList: " + exception.getMessage());
      }

      return backuplist;

There are a few cases like this. The enhanced for loop fails to generate as we expect the first statement in the loop to be iterator.next() being assigned to a variable. In this case, it has already been collapsed into the following statement.

I say this is a possible failure as the iterator variable definition has the correct generic type, which suggest the method was actually written this way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions