below is a program that has a bug - it doesn't create an array
before assigning into it (happens in a constructor).

Under 116v4a/glibc, the program says "Can't find class" rather
than printing a nice stacktrace.  Under 115v5,7 it sometimes
prints the stacktrace; sometimes the constructor returns
null and no (correct) error is printed.

-----

// 1.1.6v4a calles the parent constructor(shape), then
//      says "Can't find class bblobBUG"
// 1.1.5v5  runs, but theShape is printed as null
// search for BUG. 

import java.awt.*;
import java.applet.*;

class avector {
  avector() { arr = new float[3]; }
  float[] arr;
}

abstract class shape 
{
  static avector p[][];

  shape()
  {
    System.out.println("shape constructor, initializing");
    // BUG is here: need p = new avector[2][2]
    for( int ir=0; ir < 2; ir++ ) {
      for( int it=0; it < 2; it++ ) {
        p[ir][it] = new avector();
      }
    }
  }
} //shape

//----------------------------------------------------------------

public class bblobBUG extends java.applet.Applet
{
  static class sphere extends shape
  {
    sphere() {
      super();
      System.out.println("sphere constructor");

    } 
  } //sphere

  //----------------------------------------------------------------

  final static int      XRES    = 300;
  final static int      YRES    = 300;

  static shape theShape         = new sphere();

  //----------------------------------------------------------------

  public static void main(String[] args)
  {
    bblobBUG bb = new bblobBUG();
    System.out.println(theShape);       // BUG: says "null"


    Frame mainFrame = new Frame("bblob");
    mainFrame.setSize(XRES, YRES);
    mainFrame.add(bb);
    mainFrame.show();

  } //main

} //bblob

-----------------------------------------------------------------------
j.p.lewis                                               [EMAIL PROTECTED]
012 345 6789                                     //www.idiom.com/~zilla

Reply via email to