Top Description Fields Constructors Methods
org.glassfish.jaxb.core.v2.runtime

public Class IllegalAnnotationException

extends JAXBException
Class Inheritance
Imports
java.lang.annotation.Annotation, java.util.ArrayList, .Collections, .List, jakarta.xml.bind.JAXBContext, .JAXBException, org.glassfish.jaxb.core.v2.model.annotation.Locatable

Signals an incorrect use of JAXB annotations.
Author
Kohsuke Kawaguchi ([email protected])
Since
JAXB 2.0 EA1

Field Summary

Modifier and TypeField and Description
private final transient List<List<Location>>
pos

Read-only list of Locations.

private static final long

Constructor Summary

AccessConstructor and Description
public
public
public
public
public
public

Method Summary

Modifier and TypeMethod and Description
private List<List<Location>>
build(Locatable... srcs)

private static Locatable
private List<Location>
convert(Locatable src)

Builds a list of Locations out of a Locatable.

public List<List<Location>>

Returns:

can be empty when no source position is available, but never null. The returned list will never contain null nor length-0 List.
getSourcePos
()

Returns a read-only list of Location that indicates where in the source code the problem has happened.

public String
toString()

Overrides jakarta.xml.bind.JAXBException.toString.

Returns the exception name, message, and related information together in one string.

Inherited from jakarta.xml.bind.JAXBException:
getCausegetErrorCodegetLinkedExceptionprintStackTraceprintStackTraceprintStackTracesetLinkedException

Field Detail

posback to summary
private final transient List<List<Location>> pos

Read-only list of Locations.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides jakarta.xml.bind.JAXBException.serialVersionUID.

Constructor Detail

IllegalAnnotationExceptionback to summary
public IllegalAnnotationException(String message, Locatable src)
IllegalAnnotationExceptionback to summary
public IllegalAnnotationException(String message, Annotation src)
IllegalAnnotationExceptionback to summary
public IllegalAnnotationException(String message, Locatable src1, Locatable src2)
IllegalAnnotationExceptionback to summary
public IllegalAnnotationException(String message, Annotation src1, Annotation src2)
IllegalAnnotationExceptionback to summary
public IllegalAnnotationException(String message, Annotation src1, Locatable src2)
IllegalAnnotationExceptionback to summary
public IllegalAnnotationException(String message, Throwable cause, Locatable src)

Method Detail

buildback to summary
private List<List<Location>> build(Locatable... srcs)
castback to summary
private static Locatable cast(Annotation a)
convertback to summary
private List<Location> convert(Locatable src)

Builds a list of Locations out of a Locatable.

getSourcePosback to summary
public List<List<Location>> getSourcePos()

Returns a read-only list of Location that 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 Location

Each error location is identified not just by one Location object, but by a sequence of Locations that shows why the runtime is led to the place of the error. This list is sorted such that the most specific Location comes to the first in the list, sort of like a stack trace.

For example, suppose you specify class Foo to JAXBContext, Foo derives from Bar, Bar has a field pea that points to Zot, Zot contains a gum property, and this property has an errornous annotation. Then when this exception is thrown, the list of Locations will look something like [ "gum property", "Zot class", "pea property", "Bar class", "Foo class" ]

Returns:List<List<Location>>

can be empty when no source position is available, but never null. The returned list will never contain null nor length-0 List.

toStringback to summary
public String toString()

Overrides jakarta.xml.bind.JAXBException.toString.

Returns the exception name, message, and related information together in one string.

Overriding this method (instead of printStackTrace() allows this crucial detail to show up even when this exception is nested inside other exceptions.

Annotations
@Override