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

Fatal: Rewriting exceeded local variable limit

XMLWordPrintable

    • fcs
    • x86
    • windows_nt
    • Not verified

      ####################

          void expectObject(ObjectInputStream s) {
      try {
      Object obj = s.readObject();
      } catch (OptionalDataException data) {
      out.println("Unexpected OptionalDataException, length = " + data.length +
      ", eof = " + data.eof);
      data.printStackTrace(out);
      } catch (Exception e) {
      e.printStackTrace(out);
      }
          }
          
          void expectData(ObjectInputStream s, int n)
      throws IOException, ClassNotFoundException
          {
      try {
      Object obj = s.readObject();
      out.println("Incorrect value, expected data, found an object.");
      } catch (OptionalDataException data) {
      for (int i = n-1; i >= 0; i--) {
      int value = s.readByte();
      if (value != i) {
      out.println("Incorrect byte, expected " + i +
      " found " + value);
      }
      }
      }
          }
          
          void writeSeq(ObjectOutputStream p, int n) throws IOException {
      for (int i = n-1; i >= 0; i--) {
      p.writeByte(i);
      }
          }
          
          int integer = 7;
          
          public boolean equals(Object obj) {
      if (obj == null || !(obj instanceof PrimitivesTest))
      return false;
      PrimitivesTest other = (PrimitivesTest)obj;
      return true;
          }
          public String toString() {
      return "integer = " + integer;
          }
          
          
          public static void main (String args[]) {
      Status s;
      PrimitivesTest test = new PrimitivesTest();
      s = test.run(args, System.err, System.out);
      s.exit();
          }
          
          
      }
      //--------------------- Status.java:
      package javasoft.sqe.harness;

      import java.io.DataInputStream;
      import java.io.IOException;
      import java.io.PrintStream;

      public class Status
      {
          public static Status passed(String reason) {
      return new Status(PASSED, reason);
          }

          public static Status failed(String reason) {
      return new Status(FAILED, reason);
          }

          public static Status checkFile(String reason) {
      return new Status(CHECK_FILE, reason);
          }

          public static Status notApplicable(String reason) {
      return new Status(NOT_APPLICABLE, reason);
          }

          public static Status notRun(String reason) {
      return new Status(NOT_RUN, reason);
          }

          public static final int PASSED = 0;

          public static final int FAILED = 1;

          public static final int CHECK_FILE = 2;

          public static final int NOT_APPLICABLE = 3;

          public static final int NOT_RUN = 4;

          public int getType() {
      return type;
          }

          public String getReason() {
      return reason;
          }

          public Status augment(Status aux) {
      if (aux.reason == null || aux.reason.length() == 0)
      return this;
      else
      return new Status(type, (reason + " [" + aux.reason + "]"));
          }


          public void write(PrintStream out) {
      out.println(toString());
          }

          public static Status read(DataInputStream in) throws IOException {
      String s = in.readLine();
      for (int i = 0; i < texts.length; i++)
      if (s.startsWith(texts[i]))
      return new Status(i, s.substring(texts[i].length()).trim());
      return null;
          }

          public String toString() {
      if (reason == null || reason.length() == 0)
      return texts[type];
      else
      return texts[type] + " " + reason;
          }

          public void exit() {
      PrintStream strm = System.err;
      strm.print(marker);
      write(strm);
      strm.flush();
      System.exit(exitCodes[type]);
          }


          public Status(int type, String reason) {
      this.type = type;
      this.reason = reason;
          }

          private int type;
          private String reason;

          private static final String marker = "STATUS:";

          private static String[] texts = {
      "Passed.",
              "Failed.",
      "Completed--check results.",
      "Not applicable.",
      "Not run."
          };

          public static final int[] exitCodes = { 95, 97, 96, 98, 99 };
      }

      //--------------------- Test.java:
      package javasoft.sqe.harness;

      import java.io.PrintStream;

      public interface Test
      {
          public Status run(String[] args, PrintStream log, PrintStream ref);

      }

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

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


      Name: szC45993 Date: 01/15/99



      The Tonga/src/nsk/relocator/reloc00101 (reloc00102) test discovers the HotSpot VM (1.0beta1, core version, release build Jan 13 1999 12:43:10) error:

      export CLASSPATH=".;c:\\zss\\classes_my"
      cd C:/zss/TONGA_WSs/testbase_js/src/nsk/relocator/reloc00101
      h:/ld25/java/dest/jdk1.1.6/win32/bin/javac.exe -d c:/zss/classes_my Status.java Test.java
      rm Status.java Test.java
      h:/ld25/java/dest/jdk1.1.6/win32/bin/javac.exe -d c:/zss/classes_my reloc00101.java
      c:/jdk1.2/bin/java -Xmixed -verify reloc00101
      #
      # HotSpot Virtual Machine Error, Fatal Error
      #
      # Fatal: Rewriting exceeded local variable limit
      # C:\hotspot1_0beta1_hp-n-src-win\src\share\vm\oops\generateOopMap.cpp, 1981#
      [1] + Done(134) c:/jdk1.2/bin/java -Xmixed -verify reloc00101
        170 Abort c:/jdk1.2/bin/java

      Before the test invokation, you should create .../reloc00101 dir.
      Then to include in this dir all of below sources with the corresponding
      names.



      SOURCES:

      //--------------------- reloc00101.java:

      import java.io.*;
      import javasoft.sqe.harness.*;

      class PrimitivesTest implements Test, java.io.Serializable {

          public java.lang.String verify() {
      return "verified";
         }
          public Status run(String[] args, PrintStream log, PrintStream out) {
      ByteArrayInputStream istream = null;
      try {
      int i = 0x01234567;
      byte b = 12;
      short s = 0x4545;
      char c = 'A';
      long l = 0x1234567890000L;
      float f = 3.14159f;
      double d = f*2;
      boolean z = true;
      String string = "The String";

      ByteArrayOutputStream ostream = new ByteArrayOutputStream(2048);
      ObjectOutputStream p = new ObjectOutputStream(ostream);

      p.writeInt(i);
      p.writeByte(b);
      p.writeShort(s);
      p.writeChar(c);
      p.writeLong(l);
      p.writeFloat(f);
      p.writeDouble(d);
      p.writeBoolean(z);
      p.writeUTF(string);

      p.writeObject(this);
      p.flush();

      /* Print a hexdump to the file for comparison */
      DumpOutputStream dump = new DumpOutputStream(out);
      ostream.writeTo(dump);
      dump.flush();
      {
      istream = new ByteArrayInputStream(ostream.toByteArray());
      ObjectInputStream q = new ObjectInputStream(istream);

      int i_u = q.readInt();
      if (i != i_u)
      return Status.failed("int: expected " + i + " actual " +i_u);

      byte b_u = q.readByte();
      if (b != b_u)
      return Status.failed("byte: expected " + b + " actual " +b_u);

      short s_u = q.readShort();
      if (s != s_u)
      return Status.failed("short: expected " + s + " actual " +s_u);

      char c_u = q.readChar();
      if (c != c_u)
      return Status.failed("char: expected " + c + " actual " +c_u);

      long l_u = q.readLong();
      if (l != l_u)
      return Status.failed("long: expected " + l + " actual " +l_u);

      float f_u = q.readFloat();
      if (f != f_u)
      return Status.failed("float: expected " + f + " actual " +f_u);

      double d_u = q.readDouble();
      if (d != d_u)
      return Status.failed("double: expected " + d + " actual " + d_u);

      boolean z_u = q.readBoolean();
      if (z != z_u)
        return Status.failed("boolean: expected " + z + " actual " + z_u);

      String string_utf = q.readUTF();
      if (!string.equals(string_utf))
      return Status.failed("String: expected " + string + " actual " + string_utf);

      PrimitivesTest prim_u = (PrimitivesTest)q.readObject();
      if (!this.equals(prim_u)) {
      log.println(this.toString());
      log.println(prim_u.toString());

      return Status.failed("PrimitivesTest object read is not equal to the one written.");
      }

      }

      {
      istream = new ByteArrayInputStream(ostream.toByteArray());
      ObjectInputStream q = new ObjectInputStream(istream);
      boolean exceptionOccurred = false;
      try {
      Object notreally = q.readObject();
      } catch (OptionalDataException ignore) {
      exceptionOccurred = true;
      }
      if (!exceptionOccurred) {
      log.println("With only data in the stream readObject should fail.");
      return Status.failed("StreamCorruptedException not thrown when expected");
      }
      }

      {
      istream = new ByteArrayInputStream(ostream.toByteArray());
      ObjectInputStream q = new ObjectInputStream(istream);

      q.readInt();
      q.readByte();
      q.readShort();
      q.readChar();
      q.readLong();
      q.readFloat();
      q.readDouble();
      q.readBoolean();
      q.readUTF();

      /*
      * Now try to read another byte. It should fail since
      * what is really in the stream is an object.
      */
      boolean exceptionOccured = false;
      try {
      q.readByte();
      } catch (EOFException ignore) {
      exceptionOccured = true;
      }
      if (!exceptionOccured) {
      log.println("\t With and object in the stream reads of primitives should fail.");
      return Status.failed("EOFException not thrown when expected.");
      }
      }

      }
      catch (Exception e) {
      e.printStackTrace();
      out.println("Input remaining");

      DumpOutputStream rest = new DumpOutputStream(out);
      int ch;
      try {

      while ((ch = istream.read()) != -1)
      rest.write(ch);
      rest.flush();
      } catch (Exception f) {
      }
      return Status.failed("An Exception occurred: " + e.getMessage());
      }
      return(Status.passed("Success"));
          }
          
          public static void main (String args[]) {
      Status s;
      PrimitivesTest test = new PrimitivesTest();
      s = test.run(args, System.err, System.out);
      s.exit();
          }
          
          byte b = 4;
          short s = 5;
          int integer = 6;
          long l = 7;
          float f = 3.14159f;
          double d = (double)f * 2.0;
          char c = 'A';
          boolean z = true;
          
          public boolean equals(Object obj) {
      if (obj == null || !(obj instanceof PrimitivesTest))
      return false;
      PrimitivesTest other = (PrimitivesTest)obj;
      return (b == other.b &&
      s == other.s &&
      integer == other.integer &&
      l == other.l &&
      f == other.f &&
      d == other.d &&
      c == other.c &&
      z == other.z);
          }
          public String toString() {
      return "b = " + b + ", s = " + s + ", integer = " + integer +
      ", l = " + l + ", f = " + f + ", d = " + d +
      ", c = " + c + ", z = " + z;
          }
      }


      class DumpOutputStream extends OutputStream {
      private int radix = 16; // radix to print bytes in
      private int offset = 0; // offset in stream
      private int nextprint = 0; // next offset to print
      private byte[] buf; // buffer for the data
      private PrintStream pos; // stream for formatting data

        public DumpOutputStream(OutputStream out) {
        this.radix = 16;
      buf = new byte[16]; // buffer 1 line's worth of bytes
        pos = new PrintStream(out);
        }
       
         public DumpOutputStream(OutputStream out, int radix) {
        this.radix = radix;
      buf = new byte[16]; // buffer 1 line's worth of bytes
        pos = new PrintStream(out);
        }
       
      public void flush() throws IOException {
      pos.print(numToString(nextprint));
      pos.print(": ");
      for (int i = 0; i < 16; i++) {
      if (i < (offset - nextprint)) {
      pos.print(numToString(buf[i]));
      pos.print(" ");
      } else {
      pos.print(" ");
      }
      }
      pos.print(" >");
      for (int i = 0; i < (offset - nextprint); i++) {
      char c = (char)buf[i];
      if (c >= 32 && c < 127)
      pos.print(c);
      else
      pos.print(".");
      }
      pos.println("<");
      nextprint = offset;
      }

      private String numToString(byte value) {
      return numToString((int) (value & 0xff), (radix <= 10) ? 3 : 2);
      }

      private String numToString(int value) {
      return numToString(value, 8);
      }
      private String numToString(int value, int length) {
      String s = Integer.toString(value, radix);
      while (s.length() < length) {
      s = ((radix == 10) ? " " : "0") + s;
      }
      return s;
      }

      public void write(int value) throws IOException {
      buf[offset++ & 0x0f] = (byte)value;
      if ((offset & 0x0f) == 0) {
      flush();
      }
      }
      }

      public class reloc00101 {

          /* Local context of the text harness. */
          private transient PrintStream out;
          private transient PrintStream log;
          
      //############################################################
      //############################################################
      //############################################################
          public Status run(String[] args, PrintStream log, PrintStream out) {

      this.log = log;
      this.out = out;

      ByteArrayInputStream istream = null;


      try {
      ByteArrayOutputStream ostream = new ByteArrayOutputStream(2048);
      ObjectOutputStream p = new ObjectOutputStream(ostream);

      writeSeq(p, 4); /* Write bytes 3, 2, 1, 0 */
      p.writeObject(this);
      writeSeq(p, 8);
      writeSeq(p, 4);
      p.writeObject(this);
      writeSeq(p, 12);
      p.writeObject(this);
      p.flush();

      /* Print a hexdump to the file for comparison */
      DumpOutputStream dump = new DumpOutputStream(out);
      ostream.writeTo(dump);

      {
      istream = new ByteArrayInputStream(ostream.toByteArray());
      ObjectInputStream q = new ObjectInputStream(istream);

      expectData(q, 4);
      expectObject(q);
      expectData(q, 8);
      expectData(q, 4);
      expectObject(q);
      expectData(q,12);
      expectObject(q);

      /* verify the stream is at end=of-file */
      try {
      int d = q.read();
      double d0 = 0.0d;
      double d1 = 0.1d;
      double d2 = 0.2d;
      double d3 = 0.3d;
      double d4 = 0.4d;
      double d5 = 0.5d;
      double d6 = 0.6d;
      double d7 = 0.7d;
      double d8 = 0.8d;
      double d9 = 0.9d;
      double d10 = 0.10d;
      double d11 = 0.11d;
      double d12 = 0.12d;
      double d13 = 0.13d;
      double d14 = 0.14d;
      double d15 = 0.15d;
      double d16 = 0.16d;
      double d17 = 0.17d;
      double d18 = 0.18d;
      double d19 = 0.19d;
      double d20 = 0.20d;
      double d21 = 0.21d;
      double d22 = 0.22d;
      double d23 = 0.23d;
      double d24 = 0.24d;
      double d25 = 0.25d;
      double d26 = 0.26d;
      double d27 = 0.27d;
      double d28 = 0.28d;
      double d29 = 0.29d;
      double d30 = 0.30d;
      double d31 = 0.31d;
      double d32 = 0.32d;
      double d33 = 0.33d;
      double d34 = 0.34d;
      double d35 = 0.35d;
      double d36 = 0.36d;
      double d37 = 0.37d;
      double d38 = 0.38d;
      double d39 = 0.39d;
      double d40 = 0.40d;
      double d41 = 0.41d;
      double d42 = 0.42d;
      double d43 = 0.43d;
      double d44 = 0.44d;
      double d45 = 0.45d;
      double d46 = 0.46d;
      double d47 = 0.47d;
      double d48 = 0.48d;
      double d49 = 0.49d;
      double d50 = 0.50d;
      double d51 = 0.51d;
      double d52 = 0.52d;
      double d53 = 0.53d;
      double d54 = 0.54d;
      double d55 = 0.55d;
      double d56 = 0.56d;
      double d57 = 0.57d;
      double d58 = 0.58d;
      double d59 = 0.59d;
      double d60 = 0.60d;
      double d61 = 0.61d;
      double d62 = 0.62d;
      double d63 = 0.63d;
      double d64 = 0.64d;
      double d65 = 0.65d;
      double d66 = 0.66d;
      double d67 = 0.67d;
      double d68 = 0.68d;
      double d69 = 0.69d;
      double d70 = 0.70d;
      double d71 = 0.71d;
      double d72 = 0.72d;
      double d73 = 0.73d;
      double d74 = 0.74d;
      double d75 = 0.75d;
      double d76 = 0.76d;
      double d77 = 0.77d;
      double d78 = 0.78d;
      double d79 = 0.79d;
      double d80 = 0.80d;
      double d81 = 0.81d;
      double d82 = 0.82d;
      double d83 = 0.83d;
      double d84 = 0.84d;
      double d85 = 0.85d;
      double d86 = 0.86d;
      double d87 = 0.87d;
      double d88 = 0.88d;
      double d89 = 0.89d;
      double d90 = 0.90d;
      double d91 = 0.91d;
      double d92 = 0.92d;
      double d93 = 0.93d;
      double d94 = 0.94d;
      double d95 = 0.95d;
      double d96 = 0.96d;
      double d97 = 0.97d;
      double d98 = 0.98d;
      double d99 = 0.99d;
      double d100 = 0.100d;
      double d101 = 0.101d;
      double d102 = 0.102d;
      double d103 = 0.103d;
      double d104 = 0.104d;
      double d105 = 0.105d;
      double d106 = 0.106d;
      double d107 = 0.107d;
      double d108 = 0.108d;
      double d109 = 0.109d;
      double d110 = 0.110d;
      double d111 = 0.111d;
      double d112 = 0.112d;
      double d113 = 0.113d;
      double d114 = 0.114d;
      double d115 = 0.115d;
      double d116 = 0.116d;
      double d117 = 0.117d;
      double d118 = 0.118d;
      double d119 = 0.119d;
      double d120 = 0.120d;
      double d121 = 0.121d;
      double d122 = 0.122d;
      double d123 = 0.123d;
      double d124 = 0.124d;
      double d125 = 0.125d;
      double d126 = 0.126d;
      double d127 = 0.127d;
      double d128 = 0.128d;
      double d129 = 0.129d;

      log.println("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"+d1 +d0
      +d1
      +d2
      +d3
      +d4
      +d5
      +d6
      +d7
      +d8
      +d9
      +d10
      +d11
      +d12
      +d13
      +d14
      +d15
      +d16
      +d17
      +d18
      +d19
      +d20
      +d21
      +d22
      +d23
      +d24
      +d25
      +d26
      +d27
      +d28
      +d29
      +d30
      +d31
      +d32
      +d33
      +d34
      +d35
      +d36
      +d37
      +d38
      +d39
      +d40
      +d41
      +d42
      +d43
      +d44
      +d45
      +d46
      +d47
      +d48
      +d49
      +d50
      +d51
      +d52
      +d53
      +d54
      +d55
      +d56
      +d57
      +d58
      +d59
      +d60
      +d61
      +d62
      +d63
      +d64
      +d65
      +d66
      +d67
      +d68
      +d69
      +d70
      +d71
      +d72
      +d73
      +d74
      +d75
      +d76
      +d77
      +d78
      +d79
      +d80
      +d81
      +d82
      +d83
      +d84
      +d85
      +d86
      +d87
      +d88
      +d89
      +d90
      +d91
      +d92
      +d93
      +d94
      +d95
      +d96
      +d97
      +d98
      +d99
      +d100
      +d101
      +d102
      +d103
      +d104
      +d105
      +d106
      +d107
      +d108
      +d109
      +d110
      +d111
      +d112
      +d113
      +d114
      +d115
      +d116
      +d117
      +d118
      +d119
      +d120
      +d121
      +d122
      +d123
      +d124
      +d125
      +d126
      +d127
      +d128
      +d129
      );
      if (d != -1)
      log.println("read at EOF did not return -1 as expected.");
      } catch (EOFException expected) {
      }

      try {
      q.readObject(); // Try to read past eof
      log.println("EOF did not occur when expected.");
      } catch (EOFException expected) {
      }
      }
      }
      catch (Exception e) {
      e.printStackTrace();
      out.println("Input remaining");

      DumpOutputStream rest = new DumpOutputStream(out);
      int ch;
      boolean some = false;
      try {

      while ((ch = istream.read()) != -1) {
      rest.write(ch);
      some = true;
      }
      } catch (Exception f) {
      } finally {
      try {
      rest.flush();
      } catch (IOException ignore) {
      }
      }
      return Status.failed("An Exception occurred: " + e.getMessage());
      }
      return(Status.passed("Success"));

          }
      //############################################################
      //############################################################
      //########################################

            rschmidtsunw Rene Schmidt (Inactive)
            zsssunw Zss Zss (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: