classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More finalize woes


From: Dalibor Topic
Subject: Re: More finalize woes
Date: Thu, 6 Mar 2003 00:40:08 -0800 (PST)

hi Tom,

--- Tom Tromey <address@hidden> wrote:
> >>>>> "Dalibor" == Dalibor Topic <address@hidden>
> writes:
> 
> >> java.util.zip.[De|In]flater both have an empty
> finalize method "for
> >> compatibility". Is this really necessary?
> 
> Dalibor> Yes, in order to have reflection on these
> methods
> Dalibor> working. A pretty good reason in my
> opinion.
> 
> I'm not so sure.  It seems to me that anybody using
> reflection has to
> be aware of, and understand, the Java binary
> compatibility rules.
> Implementing or not implementing finalize doesn't
> affect binary
> compatibility, so it should be a change we are free
> to make.

Here's a somewhat made up example:

you're writing an automated black box test generator.
In order to generate tests, your generator scans each
class for its declared public and protected methods.
Methods that take no parameters and don't start with
'get', 'is' or 'has' are assumed to change state of an
object in some way (like 'close', 'end', 'finalize'
do).

Your generator ends up with a different set of test
cases for Classpath and for JDK. This may not be what
you want but it's what you get when methods are left
out ;)

Even worse, if you're using reflection to invoke the
methods in tests, then your tests generated on JDK
will no longer work on classpath.

I've wrote some code that does similar things for
debugging kaffe's class library, and it can be really
interesting what sorts of bugs one can find in
reflection code using it ;)

beside, the 'least surprise' argument applies here as
well. If I extend Classpath's Deflater to implement my
own SuperfastNativeDeflater, then I'd like to rely on
finalize() calling end(), as the spec says. Otherwise
my extended class is going to leak memory all over
Classpath if I'm not familiar with contents of
Classpath's java.util.zip.Deflator sources ;)

cheers,
dalibor topic

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]