[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to handle throws declarations with duplicate exceptions
On Fri, 24 Jan 2003, Stephen Cheng wrote:
> >The only objection I can imagine to option 4 would be if there is
> >some significance to multiple copies of a single exception in an
> >Exceptions attribute. So does anybody know of any such
> >significance?
>
> 1. I suspect option 4 could interfere with the operation of class reflection.
> Refering to JavaDocs for JDK 1.4.0,
>
> Class.getInterfaces()
> If this object represents a class, the return value is an array containing objects
> representing all interfaces implemented by the class. The order of the interface
> objects in the array corresponds to the **order** of the interface names in
> the implements clause of the declaration of the class represented by this object
> Although the JavaDoc did not explicitly describes the behaviour in the
> circumstance of having duplicate interfaces declared, I would suspect
> the above function will happily return all the duplicate copies in order
I don't think it will, because we're changing thrown exceptions of a
method, not interfaces of a class.
> 2. What is the effect on serialisation? Would the optimised class be incompatible
> with the original class incompatible w.r.t. serialisation?
>
> >From memory, serialisation UID is calculated based on class name, declared interfaces,
> fields and methods. I suspect the UID calculation algorithm would give a different
> answer.
http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/class.doc6.html#4100
# For each non-private method sorted by method name and signature:
1. The name of the method in UTF encoding.
2. The modifiers of the method written as a 32-bit integer.
3. The descriptor of the method in UTF encoding.
The descriptor doesn't cover thrown exceptions. So it doesn't seem to me
that changing the throws clause of a method should change the
serialization UID. But on that page it warns, anyway, that different
compilers may produce different SUIDs because of synthetic members. Soot
is a compiler.
pat