JDK support for VM to read classes from modules in a module library
Jesse Glick
jesse.glick at oracle.com
Wed May 16 12:07:57 PDT 2012
On 05/16/2012 01:42 PM, Alan Bateman wrote:
> [...In Properties] the workaround is to use the loader for the base module to load
> XMLUtils. Given that XMLUtil is currently in the jaxp module (and I know this isn't quite right either as JAXP is a standalone technology etc.) then I would think that
> the Properties code will need to do a Class.forName on an exported javax.xml type and use that loader (or alternative use jdk.jaxp).
You have a module system now, why not clean this up and get rid of the reflection (and cyclic dependency)?
module jdk.base {
...
view sun.jaxp.bridge {
permits jdk.jaxp;
export sun.misc;
}
requires optional service sun.misc.XMLUtils;
}
package sun.misc;
public interface XMLUtils {
void load(Properties props, InputStream in) throws IOException, InvalidPropertiesFormatException;
void save(Properties props, OutputStream os, String comment, String encoding) throws IOException;
}
package java.util;
public class Properties {
...
@RequireOptionalModule("jdk.jaxp")
public synchronized void loadFromXML(InputStream in) throws IOException, InvalidPropertiesFormatException {
try {
ServiceLoader.loadInstalled(XMLUtils.class).iterator().next().load(this, in);
} catch (NoSuchElementException x) {
throw new ModuleNotPresentException("jdk.jaxp missing", x);
}
}
@RequireOptionalModule("jdk.jaxp")
public void storeToXML(OutputStream os, String comment, String encoding) throws IOException {
try {
ServiceLoader.loadInstalled(XMLUtils.class).iterator().next().save(this, os, comment, encoding);
} catch (NoSuchElementException x) {
throw new ModuleNotPresentException("jdk.jaxp missing", x);
}
}
}
module jdk.jaxp {
...
requires sun.jaxp.bridge;
provides service sun.misc.XMLUtils with ...;
}
More information about the jigsaw-dev
mailing list