next up previous
Next: An implementation note on Up: Appendix Previous: To be added:

Update to JDK 1.1

The main reason we deemed this necessary was the awkward dependency on java.awt incurred by the ants package due to the silly way in which AWT 1.0 worked. ANTS 1.2's ``base class'', Entity, was derived from java.awt.Frame, so that subclasses could override handleEvent. We eliminated this dependency, making the ants package independent of java.awt (except for the configuration manager). Applications have to create their own windows, if they want to use any.

Unfortunately, applications will have to be changed. A typical change would be to insert:

      Frame window = FrameCreator.createFrame(getName());

in the application's start method, and then to prefix all calls to AWT-related functions such as pack(), show(), etc. with ``window.'' The FrameCreator class is an utility class that creates windows that will exit the application when closed, just like ANTS 1.2 did.

Secondly, functions such as handleEvent will have to be replaced with the proper 1.1 methods. For instance,

      public boolean handleEvent(Event evt) {
        if (evt.id == Event.ACTION_EVENT && evt.target == pinger) {
          new Thread(this).start();
          return true;
        } else 
          return super.handleEvent(evt);
        }
must be replaced with
      public void actionPerformed(ActionEvent evt) {
        if (evt.getSource() == pinger) {
          new Thread(this).start();
        }
      }
The application must implement the ActionListener interface, and register itself:
      pinger = new Button("ping!");
      pinger.addActionListener(this);
Changing existing applications is really straightforward and took a few minutes. We believe that the added cleanliness is well worth that effort.

In addition, we eliminated all deprecated functions. These were mainly functions dealing with String to byte array conversion.

While stopping at JDK 1.0.2 might have had some advantages, we believe that all relevant JVMs already or in the near future support JDK 1.1.



Jay Lepreau
Tue Jun 2 05:48:49 MDT 1998