Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-914

Generated WizardDescriptor.InstantiatingIterator contains suspicious code

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 9.0
    • None
    • apisupport - Project
    • None
    • Linux

    Description

      The InstantiatingIterator contains following code:

                  String[] steps = createSteps();
                  for (int i = 0; i < panels.size(); i++) {
                      Component c = panels.get.getComponent();
                      if (steps[i] == null)

      {                     // Default step name to component name of panel. Mainly                     // useful for getting the name of the target chooser to                     // appear in the list of steps.                     steps[i] = c.getName();                 }

      Here, "steps" is used as a zero-based array.

      It uses following method:

      private String[] createSteps() {
          String[] beforeSteps = (String[])wizard.getProperty("WizardPanel_contentData");
          assert beforeSteps != null : "This wizard may only be used embedded in the template wizard";
          String[] res = new String[(beforeSteps.length - 1) + panels.size()];
          for (int i = 0; i < res.length; i++) {
              if (i < (beforeSteps.length - 1))

      {             res[i] = beforeSteps[i];         }

      else

      {             res[i] = panels.get(i - beforeSteps.length + 1).getComponent().getName();         }

          }
          return res;
      }

      Here, "steps" has a bias-value (the size of beforeSteps - 1), which seems to be zero in most cases, but the different usage may cause errors if bias > 0.

      Probably it should be made clear, what this bias value exactly is, and then it should also be used in the code above, if needed.

      Attachments

        Activity

          People

            Unassigned Unassigned
            epdv Peter Nabbefeld
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: