Xjc generated code links OverrideAnnotationOf annotation from sun internal package

I am trying to create Java classes from a set of XML schemas. The following linked file is used to process mixed content in schemas:

<?xml version="1.0" encoding="UTF-8"?> <jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.1" xmlns:xjc= "http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc"> <jaxb:globalBindings generateMixedExtensions="true"/> </jaxb:bindings> 

Code generation works fine, but one of the generated classes has @OverrideAnnotationOf from the com.sun.xml.internal.bind.annotation package. This package is included in rt.jar, but a regular java compiler cannot find it (and probably should not find it because it is internal).

Is there a way to handle mixed content and not have OverrideAnnotationOf from the internal sun package in my generated code?

+4
source share
1 answer

In Java 6 and above, the oracle has moved the JAXB implementation implemented in the JRE to another package to prevent potential collisions with the external JAXB reference implementation .

So, the OverrideAnnotationOf class has moved from the com.sun.xml.bind.annotation package to the com.sun.xml.internal.bind.annotation package.

However, embedded xjc still generates java files that are annotated with com.sun.xml.bind.annotation.OverrideAnnotationOf (!)

Therefore, the JAXB implementation shipped with Java 7 will not understand its own output generated with generateMixedExtensions="true" . Even if you use the -XDignore.symbol.file option.

+2
source

All Articles