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

(refs) java.lang.Runtime.runFinalizersOnExit only has effect when exit code is 0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P5 P5
    • None
    • 1.1, 1.2.0
    • hotspot
    • x86, sparc
    • solaris_2.5, windows_nt



      Name: mc57594 Date: 02/12/97


      The following program produces different results depending
      on what exit code is passed in:

      public
      class tt {
        static foo Foo = null;

        static public void main(String argv[]) {
          System.runFinalizersOnExit(true);
          new foo(1);
          Foo = new foo(2);
          System.exit(Integer.parseInt(argv[0]));
        }

      }

      class foo {
        int ii;
        foo(int i) {
          ii = i;
          System.out.println("foo(" + i + ") called");
        }
        protected void finalize() {
          System.out.println("finalize called on " + ii);
        }
      }

      D:\temp>java tt 0
      foo(1) called
      foo(2) called
      finalize called on 1
      finalize called on 2

      D:\temp>java tt 1
      foo(1) called
      foo(2) called

      If this is intentional, then it should be documented. It would
      be nice if the finalization code was run, no matter what the
      exit value is.

      company - Object Design, Inc. , email - ###@###.###
      ======================================================================

            mr Mark Reinhold
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: