<Beans Dev> <AWT Dev> JDK 12 RFR of JDK-8203263: Remove unnecessary throws clauses from serialization-related methods
Phil Race
philip.race at oracle.com
Wed Jul 18 22:17:39 UTC 2018
Looks fine to me. I checked Font and MenuBar in JDK 1.x sources and they
were
like that way back then, so why they declare the additional exception is
lost in time ..
-phil.
On 07/17/2018 05:01 PM, Joseph D. Darcy wrote:
> Hello,
>
> A few classes in awt and beans have writeObject methods declared to
> throw extra exception types. The serialization spec requires the
> following declaration for a writeObject method:
>
> private void writeObject(ObjectOutputStream stream)
> throws IOException;
> https://docs.oracle.com/javase/10/docs/specs/serialization/output.html#the-writeobject-method
>
>
> Declaring writeObject to throw additional exceptions is improper.
>
> Please review the change below to remove the extraneous throws clauses:
>
> http://cr.openjdk.java.net/~darcy/8203263.0/
>
> Patch below.
>
> Thanks,
>
> -Joe
>
> --- old/src/java.desktop/share/classes/java/awt/Font.java 2018-07-17
> 16:45:12.772011569 -0700
> +++ new/src/java.desktop/share/classes/java/awt/Font.java 2018-07-17
> 16:45:11.415333527 -0700
> @@ -1895,8 +1895,7 @@
> * @see #readObject(java.io.ObjectInputStream)
> */
> private void writeObject(java.io.ObjectOutputStream s)
> - throws java.lang.ClassNotFoundException,
> - java.io.IOException
> + throws java.io.IOException
> {
> if (values != null) {
> synchronized(values) {
> --- old/src/java.desktop/share/classes/java/awt/MenuBar.java
> 2018-07-17 16:45:15.997623670 -0700
> +++ new/src/java.desktop/share/classes/java/awt/MenuBar.java
> 2018-07-17 16:45:14.576913625 -0700
> @@ -432,8 +432,7 @@
> * @see #readObject(java.io.ObjectInputStream)
> */
> private void writeObject(java.io.ObjectOutputStream s)
> - throws java.lang.ClassNotFoundException,
> - java.io.IOException
> + throws java.io.IOException
> {
> s.defaultWriteObject();
> }
> ---
> old/src/java.desktop/share/classes/java/awt/font/TransformAttribute.java
> 2018-07-17 16:45:19.063155766 -0700
> +++
> new/src/java.desktop/share/classes/java/awt/font/TransformAttribute.java
> 2018-07-17 16:45:17.686467723 -0700
> @@ -100,8 +100,7 @@
> public static final TransformAttribute IDENTITY = new
> TransformAttribute(null);
>
> private void writeObject(java.io.ObjectOutputStream s)
> - throws java.lang.ClassNotFoundException,
> - java.io.IOException
> + throws java.io.IOException
> {
> // sigh -- 1.3 expects transform is never null, so we need to
> always write one out
> if (this.transform == null) {
> ---
> old/src/java.desktop/share/classes/java/awt/geom/AffineTransform.java
> 2018-07-17 16:45:22.040643859 -0700
> +++
> new/src/java.desktop/share/classes/java/awt/geom/AffineTransform.java
> 2018-07-17 16:45:20.635941814 -0700
> @@ -3943,7 +3943,7 @@
> private static final long serialVersionUID = 1330973210523860834L;
>
> private void writeObject(java.io.ObjectOutputStream s)
> - throws java.lang.ClassNotFoundException, java.io.IOException
> + throws java.io.IOException
> {
> s.defaultWriteObject();
> }
> ---
> old/src/java.desktop/share/classes/java/beans/beancontext/BeanContextSupport.java
> 2018-07-17 16:45:25.334289961 -0700
> +++
> new/src/java.desktop/share/classes/java/beans/beancontext/BeanContextSupport.java
> 2018-07-17 16:45:23.973609919 -0700
> @@ -998,7 +998,7 @@
> * @param oos the ObjectOutputStream
> */
>
> - private synchronized void writeObject(ObjectOutputStream oos)
> throws IOException, ClassNotFoundException {
> + private synchronized void writeObject(ObjectOutputStream oos)
> throws IOException {
> serializing = true;
>
> synchronized (BeanContext.globalHierarchyLock) {
>
More information about the beans-dev
mailing list