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

Segmentation violation during compilation

XMLWordPrintable



      Name: ngC57085 Date: 05/19/98



      The test lang/CONV/conv047/conv04703 is not compiled by jdk1.2beta4F with JIT
      under win32. Segmentation violation occurs.


      -----------------conv04703.java------------------
      // Ident: @(#)conv04703.java 1.7 97/03/26
      // Copyright 03/26/97 Sun Microsystems, Inc. All Rights Reserved
      package javasoft.sqe.tests.lang.conv047.conv04703;



      import java.io.PrintStream;


      class SomeClass {

      public int i;

      public void printFields(PrintStream out) {
      out.print("i = ");
      out.println(i);
      }
       

      SomeClass(int i) {
      this.i = i;
      }

      }


      class ImmediateSubclass extends SomeClass {

      public float f;

      public void printFields(PrintStream out) {
      out.print("i = ");
      out.println(i);
      out.print("f = ");
      out.println(f);
      }
       
      ImmediateSubclass(int i, float f) {
      super(i);
      this.f = f;
      }

      }


      final class FinalSubclass extends ImmediateSubclass {

      public double d;

      public void printFields(PrintStream out) {
      out.print("i = ");
      out.println(i);
      out.print("f = ");
      out.println(f);
      out.print("d = ");
      out.println(d);
      }
       
      FinalSubclass(int i, float f, double d) {
      super(i, f);
      this.d = d;
      }

      }


      public class conv04703 {

      static void printObject1(SomeClass c, PrintStream out) {
      c.printFields(out);
      }

      static void printObject2(ImmediateSubclass c, PrintStream out) {
      c.printFields(out);
      }

      public static void main(String args[]) {
      System.exit(run(args, System.out) + 95/*STATUS_TEMP*/);
      }
       
      static int errorStatus = 0/*STATUS_PASSED*/;

      static void errorAlert(PrintStream out, int errorLevel) {
      out.println("conv04703: failure #" + errorLevel);
      errorStatus = 2/*STATUS_FAILED*/;
      }

      public static int run(String args[],PrintStream out) {
      SomeClass x;
      ImmediateSubclass y;
      FinalSubclass z;

      // assignment conversion to the immediate superclass

      z = new FinalSubclass(-33, 3.14f, 56.11d);
      y = z;
      if (! (y instanceof FinalSubclass))
      errorAlert(out, 2);
      else if (y != (ImmediateSubclass) z)
      errorAlert(out, 3);
      else if (((FinalSubclass) y).i != -33)
      errorAlert(out, 4);
      else if (((FinalSubclass) y).f != 3.14f)
      errorAlert(out, 5);
      else if (((FinalSubclass) y).d != 56.11d)
      errorAlert(out, 6);

      // assignment conversion to the non-immediate superclass

      z = new FinalSubclass(0, -2.71f, 123.456e-78d);
      x = z;
      if (! (x instanceof FinalSubclass))
      errorAlert(out, 7);
      else if (x != (SomeClass) z)
      errorAlert(out, 8);
      else if (((FinalSubclass) x).i != 0)
      errorAlert(out, 9);
      else if (((FinalSubclass) x).f != -2.71f)
      errorAlert(out, 10);
      else if (((FinalSubclass) x).d != 123.456e-78d)
      errorAlert(out, 11);

      return errorStatus;
      }

      }
      ---------------------------------------------


      ======================================================================

      Name: ngC57085 Date: 05/20/98


      Unfortunately this bug is unstable. To resieve segmentation violation
      test compilation may be repeated sevaral times.

      ======================================================================

            dviswanasunw Deepa Viswanathan (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: