[5597] in java-interest

home help back first fref pref prev next nref lref last post

Finalize Broken?

daemon@ATHENA.MIT.EDU (Mike Afergan)
Mon Feb 19 02:06:58 1996

From: mikea@ai.mit.edu (Mike Afergan)
To: java-interest@java.sun.com
Date: Sun, 18 Feb 1996 17:04:08 GMT

	Is the finalize method in java.lang.Object operationable?  I haven't
seen too much discussion of it, but it is still a valuable tool.  
	For example, with the following code:

	public class tryer {
		public void testme() {
			System.out.println("Here we go...");
			}
		protected void finalize() {
			System.out.println("Good bye!!!");
			}
		}

	public class gb3  {
		public static void main(String argv[]) {
			System.out.println("1");
			testing();
			System.out.println("2");
			testing();
			System.out.println("3");
	                }
		static void testing() {
			tryer examp;
			examp = new tryer();
			examp.testme();
			}
		}

	Everytime the testing() method is run, a new tryer object is created.
Therefore, when the method is done, it should be collected - thereby
executing the finalize() method.

	Thus, I would expect to get the following output:

C:\dev>c:\jdk2\java\bin\java gb3
1
Here we go...
Good Bye!!!
2
Here we go...
Good Bye!!!
3

However, I get:
C:\dev>c:\jdk2\java\bin\java gb3
1
Here we go...
2
Here we go...
3

	This seems to indicate that the finalize() method is not working
properly.  Am I doing something wrong, or is something out of broken
along the way?

	Thanks,
	-- Mike

-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post