Class IllegalAnnotationException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- jakarta.xml.bind.JAXBException
-
- org.glassfish.jaxb.core.v2.runtime.IllegalAnnotationException
-
- All Implemented Interfaces:
Serializable
public class IllegalAnnotationException extends jakarta.xml.bind.JAXBExceptionSignals an incorrect use of JAXB annotations.- Since:
- JAXB 2.0 EA1
- Author:
- Kohsuke Kawaguchi (kk@kohsuke.org)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description IllegalAnnotationException(String message, Annotation src)IllegalAnnotationException(String message, Annotation src1, Annotation src2)IllegalAnnotationException(String message, Annotation src1, Locatable src2)IllegalAnnotationException(String message, Throwable cause, Locatable src)IllegalAnnotationException(String message, Locatable src)IllegalAnnotationException(String message, Locatable src1, Locatable src2)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<List<Location>>getSourcePos()Returns a read-only list ofLocationthat indicates where in the source code the problem has happened.StringtoString()Returns the exception name, message, and related information together in one string.-
Methods inherited from class jakarta.xml.bind.JAXBException
getCause, getErrorCode, getLinkedException, printStackTrace, printStackTrace, printStackTrace, setLinkedException
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, setStackTrace
-
-
-
-
Constructor Detail
-
IllegalAnnotationException
public IllegalAnnotationException(String message, Annotation src)
-
IllegalAnnotationException
public IllegalAnnotationException(String message, Locatable src1, Locatable src2)
-
IllegalAnnotationException
public IllegalAnnotationException(String message, Annotation src1, Annotation src2)
-
IllegalAnnotationException
public IllegalAnnotationException(String message, Annotation src1, Locatable src2)
-
-
Method Detail
-
getSourcePos
public List<List<Location>> getSourcePos()
Returns a read-only list ofLocationthat indicates where in the source code the problem has happened.Normally, an annotation error happens on one particular annotation, in which case this method returns a list that contains another list, which in turn contains the location information that leads to the error location (IOW,
[ [pos1,pos2,...,posN] ])Sometimes, an error could occur because of two or more conflicting annotations, in which case this method returns a list that contains many lists, where each list contains the location information that leads to each of the conflicting annotations (IOW,
[ [pos11,pos12,...,pos1N],[pos21,pos22,...,pos2M], ... ])Yet some other time, the runtime can fail to provide any error location, in which case this method returns an empty list. (IOW,
[]). We do try hard to make sure this won't happen, so please let us know if you see this behavior.List of
LocationEach error location is identified not just by one
Locationobject, but by a sequence ofLocations that shows why the runtime is led to the place of the error. This list is sorted such that the most specificLocationcomes to the first in the list, sort of like a stack trace.For example, suppose you specify class
FootoJAXBContext,Fooderives fromBar,Barhas a fieldpeathat points toZot,Zotcontains agumproperty, and this property has an errornous annotation. Then when this exception is thrown, the list ofLocations will look something like[ "gum property", "Zot class", "pea property", "Bar class", "Foo class" ]- Returns:
- can be empty when no source position is available,
but never null. The returned list will never contain
null nor length-0
List.
-
toString
public String toString()
Returns the exception name, message, and related information together in one string.Overriding this method (instead of
JAXBException.printStackTrace(java.io.PrintStream)allows this crucial detail to show up even when this exception is nested inside other exceptions.- Overrides:
toStringin classjakarta.xml.bind.JAXBException
-
-