6226715: (ann) java.lang.annotation.AnnotationTypeMismatchException could not be serialized
Reviewed-by: rriggs
--- a/jdk/src/java.base/share/classes/java/lang/annotation/AnnotationTypeMismatchException.java Tue Jul 05 20:41:56 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/annotation/AnnotationTypeMismatchException.java Tue Jul 05 21:11:40 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@
/**
* The {@code Method} object for the annotation element.
*/
- private final Method element;
+ private final transient Method element;
/**
* The (erroneous) type of data found in the annotation. This string
@@ -57,10 +57,12 @@
* Constructs an AnnotationTypeMismatchException for the specified
* annotation type element and found data type.
*
- * @param element the {@code Method} object for the annotation element
+ * @param element the {@code Method} object for the annotation
+ * element, may be {@code null}
* @param foundType the (erroneous) type of data found in the annotation.
* This string may, but is not required to, contain the value
- * as well. The exact format of the string is unspecified.
+ * as well. The exact format of the string is unspecified,
+ * may be {@code null}.
*/
public AnnotationTypeMismatchException(Method element, String foundType) {
super("Incorrectly typed data found for annotation element " + element
@@ -71,8 +73,11 @@
/**
* Returns the {@code Method} object for the incorrectly typed element.
+ * The value may be unavailable if this exception has been
+ * serialized and then read back in.
*
- * @return the {@code Method} object for the incorrectly typed element
+ * @return the {@code Method} object for the incorrectly typed
+ * element, or {@code null} if unavailable
*/
public Method element() {
return this.element;
@@ -81,7 +86,8 @@
/**
* Returns the type of data found in the incorrectly typed element.
* The returned string may, but is not required to, contain the value
- * as well. The exact format of the string is unspecified.
+ * as well. The exact format of the string is unspecified and the string
+ * may be {@code null}.
*
* @return the type of data found in the incorrectly typed element
*/