Code found in JAXB
/** * Makes sure that we are running with 2.1 JAXB API, * and report an error if not. */ static { try { XmlSchema s = null; s.location(); } catch (NullPointerException e) { // as epxected } catch (NoSuchMethodError e) { // this is not a 2.1 API. Where is it being loaded from? Messages res; if(XmlSchema.class.getClassLoader()==null) res = Messages.INCOMPATIBLE_API_VERSION_MUSTANG; else res = Messages.INCOMPATIBLE_API_VERSION; throw new LinkageError( res.format( Which.which(XmlSchema.class), Which.which(ModelBuilder.class) )); } }