--- old/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/SchemaCache.java 2015-05-19 11:21:51.000000000 +0200 +++ new/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/SchemaCache.java 2015-05-19 11:21:50.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, 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 @@ -25,14 +25,15 @@ package com.sun.tools.internal.xjc; -import java.net.URL; - +import javax.xml.transform.Source; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.ValidatorHandler; import com.sun.xml.internal.bind.v2.util.XmlFactory; import javax.xml.XMLConstants; + +import org.w3c.dom.ls.LSResourceResolver; import org.xml.sax.SAXException; import static com.sun.xml.internal.bind.v2.util.XmlFactory.allowExternalAccess; @@ -48,23 +49,32 @@ public final class SchemaCache { private Schema schema; + private Source source; + private LSResourceResolver resourceResolver; - private final URL source; + public SchemaCache(Source source) { + this(source, null); + } - public SchemaCache(URL source) { + public SchemaCache(Source source, LSResourceResolver resourceResolver) { this.source = source; + this.resourceResolver = resourceResolver; } public ValidatorHandler newValidator() { - synchronized(this) { - if(schema==null) { - try { - // do not disable secure processing - these are well-known schemas - SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false); - schema = allowExternalAccess(sf, "file", false).newSchema(source); - } catch (SAXException e) { - // we make sure that the schema is correct before we ship. - throw new AssertionError(e); + if(schema==null) { + synchronized (this) { + if (schema == null) { + try { + // do not disable secure processing - these are well-known schemas + SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false); + SchemaFactory schemaFactory = allowExternalAccess(sf, "file", false); + schemaFactory.setResourceResolver(resourceResolver); + schema = schemaFactory.newSchema(source); + } catch (SAXException e) { + // we make sure that the schema is correct before we ship. + throw new AssertionError(e); + } } } }