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

init and postinit blocks do not keep variable assignments

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • None
    • javafx
    • linux 1.2

      I am using JavaFX 1.2 on Linux. It seems that the init and postinit blocks do not keep their variable assignments.

      public class DataInputForm extends CustomNode {
          var countries: String[] =["South Africa","Namibia","Botswana","Zimbabwe","Lesotho","Swaziland","Mozambique"];
          var provinces: String[]=["Gauteng","Western Cape","Northern Cape","Limpopo","Eastern Cape","Free State","Mpumalanga","KwaZulu-Natal","North West"];

          
          //Sort the sequences alphabetically.
          postinit{
              sort();
              println("{countries}"); //shows sorted list
          }
          init{
                sort();
                println("{countries}"); //shows sorted list
          }

          function sort(){
                  countries = Sequences.sort(countries,Comparator{
                     override public function compare(obj1: Object, obj2: Object):Integer{
                           var string1:String = obj1 as String;
                           var string2:String = obj2 as String;
                           return string1.compareTo(string2);
                      }
                }) as String[];

                  provinces = Sequences.sort(provinces,Comparator{
                     override public function compare(obj1: Object, obj2: Object):Integer{
                           var string1:String = obj1 as String;
                           var string2:String = obj2 as String;
                           return string1.compareTo(string2);
                      }
                }) as String[];
          }

           override function create():Node {
                  println("{counties}"); //unsorted
                  ................
           }
      }

      Thanks

            kcr Kevin Rushforth
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: