Reflective Operation Exceptions

Applying previously published advice on designing exception types, as of JDK 7 build 68, exceptions thrown by core reflection operations have been retrofitted to have a common superclass, ReflectiveOperationException (6857789).

Inserting a new level into the superclass hierarchy in this fashion is a binary compatible change (JLSv3 § 13.4.4 Superclasses and Superinterfaces) since the exceptions remain subclasses of original superclass java.lang.Exception. The change in direct supercass should be transparent other than to reflective operations that specifically query the superclass.

All the exception classes in question already had explicit serialVersionUID fields so changing their superclass is compatible from a serialization perspective too. If explicit serialVersionUID fields were not already present, they would need to be added since the direct superclass figures into the default serial version computation.

Comments:

ReflectiveOperationException has strange serialVersionUID = 123456789L. Is it what intended?

Posted by Stepan Koltsov on August 11, 2009 at 11:16 AM PDT #

@Stepan,

All the serialVersionUIDs are strange; following good programming practice for a Serializable class (all exceptions are Serializable) I set the field explicitly to an arbitrary long value.

Posted by Joseph Darcy on August 11, 2009 at 11:27 AM PDT #

I personally use just 1 for serialVersionUID and increase it each time truly incompatible version is released. Gives a nice overview of how many compatibility breaking changes were done.

Posted by Artur Biesiadowski on August 11, 2009 at 11:41 PM PDT #

Post a Comment:
Comments are closed for this entry.
About

darcy

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
News

No bookmarks in folder

Blogroll