6559121: Updates implementations and tests for `module' support.
Summary: Updated JSR 277 + 294 API.
Reviewed-by: bristor, ksrini
--- a/src/share/classes/java/lang/Class.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/lang/Class.java Wed Apr 16 02:49:49 2008 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -36,7 +36,6 @@ import java.lang.reflect.Type;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Superpackage;
import java.lang.ref.SoftReference;
import java.io.InputStream;
import java.io.ObjectStreamField;
@@ -618,6 +617,47 @@ public final
// Package-private to allow ClassLoader access
native ClassLoader getClassLoader0();
+ /**
+ * Returns the actual class loader for the class. If the class appeared to
+ * be loaded by the boostrap classloader (i.e. {@link #getClassLoader()}
+ * returns {@code null}), some implementations may actually use module
+ * class loader internally to load the class. This method will return the
+ * actual module class loader in such implementations. If the class is
+ * loaded by non-bootstrap classloader, this method will simply return the
+ * same class loader that is returned by calling {@link #getClassLoader()}.
+ *
+ * <p> If a security manager is present, and the caller's class loader is
+ * not null and the caller's class loader is not the same as or an ancestor
+ * of the class loader for the class whose class loader is requested, then
+ * this method calls the security manager's {@code checkPermission} method
+ * with a {@code RuntimePermission("getClassLoader")} permission to ensure
+ * it's ok to access the actual class loader for the class.
+ *
+ * @return the actual class loader that loaded the class or interface
+ * represented by this object.
+ * @throws SecurityException if a security manager exists and its
+ * {@code checkPermission} method denies access to the actual class
+ * loader for the class.
+ * @see java.lang.ClassLoader
+ * @see SecurityManager#checkPermission
+ * @see java.lang.RuntimePermission
+ * @since 1.7
+ */
+ public ClassLoader getActualClassLoader() {
+ ClassLoader cl = getClassLoader0();
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ ClassLoader ccl = ClassLoader.getCallerClassLoader();
+ if (ccl != null && ccl != cl && (cl == null || !cl.isAncestor(ccl))) {
+ sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
+ }
+ }
+ if (cl != null) {
+ return cl;
+ } else {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+ }
/**
* Returns an array of {@code TypeVariable} objects that represent the
@@ -698,13 +738,14 @@ public final
}
/**
- * Returns the superpackage this class is a member of,
- * or null if it is not a member of a superpackage.
- *
- * @return the superpackage this class is a member of,
- * or null if it is not a member of a superpackage.
- */
- public Superpackage getSuperpackage() {
+ * Returns the information of the module that this class is a member of,
+ * or null if this class is not a member of any module.
+ *
+ * @return the information of the module this class is a member of,
+ * or null if this class is not a member of any module.
+ * @since 1.7
+ */
+ public ModuleInfo getModuleInfo() {
throw new UnsupportedOperationException("Not implemented yet");
}
--- a/src/share/classes/java/lang/ClassLoader.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/lang/ClassLoader.java Wed Apr 16 02:49:49 2008 -0700
@@ -30,7 +30,6 @@ import java.module.Module;
import java.module.Module;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Superpackage;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.AccessController;
@@ -197,6 +196,10 @@ public abstract class ClassLoader {
// to its corresponding Package object.
private HashMap<String, Package> packages = new HashMap<String, Package>();
+ // The modules defined in this class loader. Each module name is mapped
+ // to its corresponding ModuleInfo object.
+ private HashMap<String, ModuleInfo> moduleInfos = new HashMap<String, ModuleInfo>();
+
/**
* Creates a new class loader using the specified parent class loader for
* delegation.
@@ -250,13 +253,16 @@ public abstract class ClassLoader {
}
/**
- * Returns the Module this ClassLoader is associated with.
+ * Returns the {@code Module} instance this {@code ClassLoader} is
+ * associated with.
*
* <p>If this class loader is the module class loader of a
- * {@link Module}, this method returns that Module object. Otherwise
- * it returns null.
- *
- * @return the Module this ClassLoader is associated with or null.
+ * {@link Module}, this method returns that {@code Module} object.
+ * Otherwise, it returns null.
+ *
+ * @return the {@code Module} instance this {@code ClassLoader} is
+ * associated with or null.
+ * @since 1.7
*/
public Module getModule() {
return null;
@@ -393,83 +399,55 @@ public abstract class ClassLoader {
}
/**
- * Finds the superpackage with the specified fully qualified name.
- * This method is invoked by the Java virtual machine to resolve superpackage
+ * Finds the module information with the specified fully qualified name.
+ * This method is invoked by the Java virtual machine to resolve module
* references. Typically, it should not be called by application code.
*
* <p>The default implementation of this method calls
* {@link #findResource findResource()} to obtain the contents of the
- * superpackage file and {@link #defineSuperpackage defineSuperpackage()}
- * to construct the {@code Superpackage} object.
-
+ * module file and {@link #defineModuleInfo defineModuleInfo()}
+ * to construct the {@code ModuleInfo} object.
+
+ * @param name The fully qualified name of the module
+ * @return The resulting <tt>ModuleInfo</tt> object
+ * @throws ClassNotFoundException if the module could not be found.
+ * @since 1.7
+ */
+ protected ModuleInfo findModuleInfo(String name) throws ClassNotFoundException {
+ throw new ClassNotFoundException(name);
+ }
+
+ /**
+ * Converts an array of bytes into an instance of class <tt>ModuleInfo</tt>.
+ * Typically this method will only invoked by a class loader's
+ * {@link #findModuleInfo findModuleInfo()} method.
+ *
* @param name
- * The fully qualified name of the superpackage
- *
- * @return The resulting <tt>Superpackage</tt> object
- *
- * @throws ClassNotFoundException
- * If the superpackage could not be found
- */
- protected Superpackage findSuperpackage(String name) throws ClassNotFoundException {
- throw new ClassNotFoundException(name);
- }
-
- /**
- * Converts an array of bytes into an instance of class <tt>Superpackage</tt>.
- * Typically this method will only invoked by a class loader's
- * {@link #findSuperpackage findSuperpackage()} method.
- *
- * @param name
- * The expected fully qualified name of the superpackage, or
+ * The expected fully qualified name of the module, or
* <tt>null</tt> if not known
- *
* @param b
- * The bytes that make up the superpackage data. The bytes in positions
+ * The bytes that make up the module data. The bytes in positions
* <tt>off</tt> through <tt>off+len-1</tt> should have the format
- * of a valid superpackage file as defined by the <a
+ * of a valid module file as defined by the <a
* href="http://java.sun.com/docs/books/vmspec/">Java Virtual
* Machine Specification</a>.
- *
* @param off
- * The start offset in <tt>b</tt> of the superpackage data
- *
+ * The start offset in <tt>b</tt> of the module data
* @param len
- * The length of the superpackage data
- *
- * @return The <tt>Superpackage</tt> object that was created from the specified
- * superpackage data.
- *
+ * The length of the module data
+ * @return The <tt>ModuleInfo</tt> object that was created from the specified
+ * module data.
* @throws ClassFormatError
- * If the data did not contain a valid superpackage
- *
+ * If the data did not contain a valid module
* @throws IndexOutOfBoundsException
* If either <tt>off</tt> or <tt>len</tt> is negative, or if
* <tt>off+len</tt> is greater than <tt>b.length</tt>.
- *
- */
- protected final Superpackage defineSuperpackage(String name, byte[] b, int off, int len)
- throws ClassFormatError
- {
+ * @since 1.7
+ */
+ protected final ModuleInfo defineModuleInfo(String name, byte[] b, int off, int len)
+ throws ClassFormatError {
Class<?> clazz = defineClass(name, b, off, len);
- try {
- return getSuperpackageConstructor().newInstance(clazz);
- } catch (Exception e) {
- throw (ClassFormatError)new ClassFormatError
- ("Could not construct superpackage").initCause(e);
- }
- }
-
- private static volatile Constructor<Superpackage> superpackageConstructor;
-
- private static Constructor<Superpackage> getSuperpackageConstructor() throws NoSuchMethodException {
- Constructor<Superpackage> c = superpackageConstructor;
- // XXX add doPrivileged()
- if (c == null) {
- c = Superpackage.class.getDeclaredConstructor(Class.class);
- c.setAccessible(true);
- superpackageConstructor = c;
- }
- return c;
+ return new ModuleInfo(clazz);
}
/**
@@ -1598,6 +1576,32 @@ public abstract class ClassLoader {
}
}
return map.values().toArray(new Package[map.size()]);
+ }
+
+ /**
+ * Returns a <tt>ModuleInfo</tt> that has been defined by this class loader
+ * or any of its ancestors. </p>
+ *
+ * @param name
+ * The module name
+ * @return The <tt>ModuleInfo</tt> corresponding to the given name, or
+ * <tt>null</tt> if not found
+ * @since 1.7
+ */
+ protected ModuleInfo getModuleInfo(String name) {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ /**
+ * Returns all of the <tt>ModuleInfo</tt> defined by this class loader and
+ * its ancestors. </p>
+ *
+ * @return The array of <tt>ModuleInfo</tt> objects defined by this
+ * <tt>ClassLoader</tt>
+ * @since 1.7
+ */
+ protected ModuleInfo[] getModuleInfos() {
+ throw new UnsupportedOperationException("Not yet implemented");
}
--- a/src/share/classes/java/lang/annotation/ElementType.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/lang/annotation/ElementType.java Wed Apr 16 02:49:49 2008 -0700
@@ -61,6 +61,10 @@ public enum ElementType {
/** Package declaration */
PACKAGE,
- /** Superpackage declaration */
- SUPERPACKAGE
+ /**
+ * Module declaration
+ *
+ * @since 1.7
+ */
+ MODULE
}
--- a/src/share/classes/java/module/ImportDependency.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/ImportDependency.java Wed Apr 16 02:49:49 2008 -0700
@@ -26,166 +26,26 @@ package java.module;
package java.module;
/**
- * This class represents an import dependency of the module definition.
+ * A tagging interface that all import dependencies must extend.
* <p>
- * @see java.module.VersionConstraint
- * @see java.io.Serializable
+ * @see java.module.ModuleDependency
*
* @since 1.7
- * @serial include
*/
-public class ImportDependency implements java.io.Serializable {
-
- private static final long serialVersionUID = -4888614342905988975L;
-
- private final String name;
- private final VersionConstraint constraint;
- private final boolean reexport;
- private final boolean optional;
+public interface ImportDependency {
/**
- * Constructs a <code>ImportDependency</code>.
- * <p>
- * The imported module definition is assumed to be neither re-exported
- * nor optional.
+ * Returns true if the import dependency is optional. Otherwise, returns
+ * false.
*
- * @param name the name of the imported module definition.
- * @param constraint the version constraint of the import dependency.
- * @throws NullPointerException if name is null or constraint is null.
+ * @return true if the import dependency is optional; false otherwise.
*/
- public ImportDependency(String name, VersionConstraint constraint) {
- this(name, constraint, false, false);
- }
+ public boolean isOptional();
/**
- * Constructs a <code>ImportDependency</code>.
+ * Returns the granularity of the import dependency.
*
- * @param name the name of the imported module definition.
- * @param constraint the version constraint of the import dependency.
- * @param reexport true if the imported module definition is re-exported;
- * otherwise, false.
- * @param optional true if the imported module definition is optional;
- * otherwise, false.
- * @throws NullPointerException if name is null or constraint is null.
+ * @return the granularity of the import dependency.
*/
- public ImportDependency(String name, VersionConstraint constraint, boolean reexport, boolean optional) {
-
- if (name == null)
- throw new NullPointerException("name must not be null.");
-
- if (constraint == null)
- throw new NullPointerException("constraint must not be null.");
-
- this.name = name;
- this.constraint = constraint;
- this.reexport = reexport;
- this.optional = optional;
- }
-
- /**
- * Returns the name of the imported module definition in an import
- * dependency.
- *
- * @return the name of the imported module definition.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns the version constraint of the import dependency.
- *
- * @return the version constraint of the import dependency.
- */
- public VersionConstraint getVersionConstraint() {
- return constraint;
- }
-
- /**
- * Returns true if the imported module definition is re-exported. Otherwise,
- * returns false.
- *
- * @return true if the imported module definition is re-exported; false
- * otherwise.
- */
- public boolean isReexported() {
- return reexport;
- }
-
- /**
- * Returns true if the imported module definition is optional. Otherwise,
- * returns false.
- *
- * @return true if the imported module definition is optional; false
- * otherwise.
- */
- public boolean isOptional() {
- return optional;
- }
-
- /**
- * Compare two <code>ImportDependency</code> objects for equality. The
- * result is <code>true</code> if and only if the argument is not
- * <code>null</code> and is a <code>ImportDependency</code> object that
- * imported module name, version constraint, reexport, and optional the
- * same as those of this <code>ImportDependency</code>.
- *
- * @param obj the object to compare with.
- * @return whether or not the two objects are equal
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
-
- if (!(obj instanceof ImportDependency))
- return false;
-
- ImportDependency importDep = (ImportDependency) obj;
-
- return (name.equals(importDep.getName())
- && constraint.equals(importDep.getVersionConstraint())
- && reexport == importDep.isReexported()
- && optional == importDep.isOptional());
- }
-
- /**
- * Returns a hash code for this <code>ImportDependency</code>.
- *
- * @return a hash code value for this object.
- */
- @Override
- public int hashCode() {
- int result = 17;
- result = 37 * result + name.hashCode();
- result = 37 * result + constraint.hashCode();
- result = 37 * result + (reexport ? 0 : 1);
- result = 37 * result + (optional ? 0 : 1);
- return result;
- }
-
- /**
- * Returns a <code>String</code> object representing this
- * <code>ImportDependency</code>.
- *
- * @return a string representation of this object.
- */
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
-
- builder.append("ImportDependency[module ");
- builder.append(name);
- builder.append(" ");
- builder.append(constraint.toString());
- if (reexport) {
- builder.append(",re-export");
- }
- if (optional) {
- builder.append(",optional");
- }
- builder.append("]");
-
- return builder.toString();
- }
+ public String getGranularity();
}
--- a/src/share/classes/java/module/ImportOverridePolicy.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/ImportOverridePolicy.java Wed Apr 16 02:49:49 2008 -0700
@@ -45,14 +45,14 @@ public interface ImportOverridePolicy {
public interface ImportOverridePolicy {
/**
- * Returns a map of imported module names and overridden version constraints
- * for the module definition. The returned map contains the same set of
- * module names as the given map.
+ * Returns a map of imported module names and overridden version
+ * constraints for the module definition. The returned map contains the
+ * same set of module names as the given map.
* <p>
* For each import dependency, the overridden version constraint must be
* within the boundary of the original version constraint that was
- * specified in the module definition at build time. Otherwise
- * module initialization will fail.
+ * specified in the module definition at build time. Otherwise, module
+ * initialization will fail.
*
* @param importer the importing module definition.
* @param constraints an unmodifiable map of imported module names and
@@ -62,5 +62,4 @@ public interface ImportOverridePolicy {
* given map.
*/
public abstract Map<String,VersionConstraint> narrow(ModuleDefinition importer, Map<String,VersionConstraint> constraints);
-
}
--- a/src/share/classes/java/module/ImportPolicy.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/ImportPolicy.java Wed Apr 16 02:49:49 2008 -0700
@@ -48,41 +48,41 @@ public interface ImportPolicy {
* Returns a list of imported module definitions for preparing this module
* instance.
* <p>
- * The list of import dependencies that is returned from the
- * <code>getImportDependencies()</code> method of the
- * <code>ModuleDefinition</code> object only reflects the import
+ * The list of import module dependencies that is returned from the
+ * {@code getImportModuleDependencies()} method of the
+ * {@code ModuleDefinition} object only reflects the import module
* dependencies with the original version constraints that were specified
* in the module definition at build time. However, it is possible that
* deployers might have used the system's import override policy to narrow
* these version constraints at deployment time to control the actual
* resolution.
* <p>
- * Implementation of the import policy may use the map of imported
- * module names and overridden version constraints to determine if
- * the version constraint of an imported module has been overridden.
- * The map is passed in one of the parameters of this method.
+ * Some implementations may use the map of imported module names and
+ * overridden version constraints to determine if the version constraint of
+ * an imported module has been overridden. The map is passed in one of the
+ * parameters of this method.
* <p>
- * Implementation of the import policy may use the default import policy
- * instance for determining the list of default imported module definitions
- * for resolving, and it is passed in one of the parameters of this method.
+ * Some implementations may use the default import policy instance for
+ * determining the list of default imported module definitions for
+ * resolving, and it is passed in one of the parameters of this method.
* <p>
- * Implementation of the import policy should return a list of imported
- * module definitions after it resolves the imports. The order of the
- * imported module definitions in the list must follow the exact
- * declared order of the corresponding imports. If an import cannot
- * be resolved and the import dependency is mandatory (i.e. non-optional),
- * <code>UnsatisfiedDependencyException</code> must be thrown. If an
- * import cannot be resolved and the import dependency is optional,
- * <code>null</code> must be used to represent the missing imported module
- * definition in the list.
+ * All implementations should return a list of imported module
+ * definitions after it resolves the imports. The order of the imported
+ * module definitions in the list must follow the exact declared order of
+ * the corresponding imports. If an import cannot be resolved and the
+ * import dependency is mandatory (i.e. non-optional),
+ * {@code UnsatisfiedDependencyException} must be thrown. If an import
+ * cannot be resolved and the import dependency is optional, {@code null}
+ * must be used to represent the missing imported module definition in the
+ * list.
*
* @param moduleDef the module definition of this module instance.
* @param constraints an unmodifiable map of imported module names and
* overridden version constraints.
* @param defaultImportPolicy the default import policy for this module
* instance.
- * @throws UnsatisfiedDependencyException if an import dependency cannot
- * be satisfied.
+ * @throws UnsatisfiedDependencyException if an import module dependency
+ * cannot be satisfied.
* @return a list of imported module definitions for preparing this module
* instance in the resolving process.
*/
--- a/src/share/classes/java/module/JamModuleDefinition.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/JamModuleDefinition.java Wed Apr 16 02:49:49 2008 -0700
@@ -26,7 +26,6 @@ package java.module;
package java.module;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Superpackage;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
@@ -42,15 +41,13 @@ import java.util.regex.Matcher;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import java.module.annotation.ExportLegacyClasses;
import java.module.annotation.ExportResources;
import java.module.annotation.ImportModule;
import java.module.annotation.ImportModules;
import java.module.annotation.MainClass;
import java.module.annotation.ModuleAttribute;
import java.module.annotation.ModuleAttributes;
-import java.module.annotation.LegacyClasses;
-import sun.module.annotation.ExportPackages;
+import sun.module.annotation.LegacyClasses;
import sun.module.JamUtils;
/**
@@ -58,7 +55,7 @@ import sun.module.JamUtils;
* <code>MODULE-INF/MODULE.METADATA</code> file.
* <p>
* @see java.module.ModuleDefinition
- * @see java.module.ModuleDefinitionContent
+ * @see java.module.ModuleContent
*
* @since 1.7
*/
@@ -68,16 +65,22 @@ final class JamModuleDefinition extends
private final Version version;
private byte[] metadata;
private final Callable<byte[]> metadataHandle;
- private final ModuleDefinitionContent content;
+ private final ModuleContent content;
private final Repository repository;
private final boolean moduleReleasable;
private volatile Set<String> memberClasses;
private volatile Set<String> exportedClasses;
private volatile Set<String> exportedResources;
- private Map<Class,Annotation> annotations = null;
+ private volatile boolean memberClassesNotAvailable = false;
+ private volatile boolean exportedResourcesNotAvailable = false;
+ private volatile Set<PackageDefinition> memberPackageDefs;
+ private volatile Set<PackageDefinition> exportedPackageDefs;
+ private volatile Map<Class,Annotation> annotations = null;
+ private volatile List<ImportDependency> importDependencies = null;
+ private volatile List<ModuleDependency> importModuleDependencies = null;
JamModuleDefinition(String name, Version version, byte[] metadata,
- Callable<byte[]> metadataHandle, ModuleDefinitionContent content,
+ Callable<byte[]> metadataHandle, ModuleContent content,
Repository repository, boolean moduleReleasable) {
this.name = name;
this.version = version;
@@ -89,7 +92,7 @@ final class JamModuleDefinition extends
}
//
- // The metadata/superpackage arrangement below is temporary until the
+ // The module metadata arrangement below is temporary until the
// full JSR 294 reflective APIs are in place
//
@@ -115,23 +118,23 @@ final class JamModuleDefinition extends
}
}
- private volatile Superpackage superpackage;
-
- private Superpackage getSuperpackage() {
- if (superpackage == null) {
+ private volatile ModuleInfo moduleInfo;
+
+ private ModuleInfo getModuleInfo() {
+ if (moduleInfo == null) {
synchronized (this) {
- if (superpackage == null) {
+ if (moduleInfo == null) {
// XXX check name and version against metadata
- superpackage = JamUtils.getSuperpackage(getMetadata());
- }
- }
- }
- return superpackage;
+ moduleInfo = ModuleInfo.getModuleInfo(getMetadata());
+ }
+ }
+ }
+ return moduleInfo;
}
@Override
public String getName() {
- return (name != null) ? name : getSuperpackage().getName();
+ return (name != null) ? name : getModuleInfo().getName();
}
@Override
@@ -154,19 +157,32 @@ final class JamModuleDefinition extends
@Override
public List<ImportDependency> getImportDependencies() {
- List<ImportDependency> dependencies = new ArrayList<ImportDependency>();
- Superpackage sp = getSuperpackage();
- ImportModules importModules = sp.getAnnotation(ImportModules.class);
- if (importModules != null) {
- for (ImportModule importModule : Arrays.asList(importModules.value())) {
- String name = importModule.name();
- VersionConstraint constraint = VersionConstraint.valueOf(importModule.version());
- boolean reexport = importModule.reexport();
- boolean optional = importModule.optional();
- dependencies.add(new ImportDependency(name, constraint, reexport, optional));
- }
- }
- return Collections.unmodifiableList(dependencies);
+ if (importDependencies == null) {
+ List<ImportDependency> dependencies = new ArrayList<ImportDependency>();
+ dependencies.addAll(getImportModuleDependencies());
+ importDependencies = Collections.unmodifiableList(dependencies);
+ }
+ return importDependencies;
+ }
+
+ @Override
+ public List<ModuleDependency> getImportModuleDependencies() {
+ if (importModuleDependencies == null) {
+ List<ModuleDependency> dependencies = new ArrayList<ModuleDependency>();
+ ModuleInfo mInfo = getModuleInfo();
+ ImportModules importModules = mInfo.getAnnotation(ImportModules.class);
+ if (importModules != null) {
+ for (ImportModule importModule : Arrays.asList(importModules.value())) {
+ String name = importModule.name();
+ VersionConstraint constraint = VersionConstraint.valueOf(importModule.version());
+ boolean reexport = importModule.reexport();
+ boolean optional = importModule.optional();
+ dependencies.add(new ModuleDependency(name, constraint, reexport, optional));
+ }
+ }
+ importModuleDependencies = Collections.unmodifiableList(dependencies);
+ }
+ return importModuleDependencies;
}
@Override
@@ -199,16 +215,41 @@ final class JamModuleDefinition extends
@Override
public Set<String> getMemberClasses() {
+ if (memberClassesNotAvailable) {
+ throw new UnsupportedOperationException();
+ }
+
if (memberClasses == null) {
- // Member classes consist of classes in the superpackage
- Set<String> s = new HashSet<String>
- (Arrays.asList(getSuperpackage().getMemberTypes()));
- // As well as classes in the embedded legacy jars
- LegacyClasses legacyClassesAnnotation = getAnnotation(LegacyClasses.class);
- if (legacyClassesAnnotation != null) {
- s.addAll(Arrays.asList(legacyClassesAnnotation.value()));
- }
- memberClasses = Collections.unmodifiableSet(s);
+ try {
+ // Member classes consist of all types in the module
+ Set<String> s = new HashSet<String>();
+
+ for (String className : content.getEntryNames()) {
+ // Skip classes in META-INF/ or MODULE-INF/
+ if (className.startsWith("META-INF/")
+ || className.startsWith("MODULE-INF/")) {
+ continue;
+ }
+
+ if (className.endsWith(".class")) {
+ className = className.substring(0, className.length() - 6).replace('/', '.');
+ s.add(className);
+ }
+ }
+
+ // XXX hack to support legacy classes, will remove once JSR 294
+ // arrives.
+ LegacyClasses legacyClassesAnno = getAnnotation(LegacyClasses.class);
+ if (legacyClassesAnno != null) {
+ // Adds legacy classes as members
+ s.addAll(Arrays.asList(legacyClassesAnno.value()));
+ }
+
+ memberClasses = Collections.unmodifiableSet(s);
+ } catch (IOException ioe) {
+ memberClassesNotAvailable = true;
+ throw new UnsupportedOperationException();
+ }
}
return memberClasses;
}
@@ -216,52 +257,87 @@ final class JamModuleDefinition extends
@Override
public Set<String> getExportedClasses() {
if (exportedClasses == null) {
- // Exported classes consist of exported classes in the superpackage
- Set<String> s = new HashSet<String>
- (Arrays.asList(getSuperpackage().getExportedTypes()));
- // As well as exported legacy classes in the embedded jars
- ExportLegacyClasses exportLegacyClassesAnnotation = getAnnotation(ExportLegacyClasses.class);
- if (exportLegacyClassesAnnotation != null) {
- LegacyClasses legacyClassesAnnotation = getAnnotation(LegacyClasses.class);
- if (legacyClassesAnnotation != null) {
- s.addAll(Arrays.asList(legacyClassesAnnotation.value()));
- }
- }
+ // Exported classes consist of all exported types in the module
+ Set<String> s = new HashSet<String>();
+
+ for (String className : getMemberClasses()) {
+ // XXX: determines if a type is exported by checking if it
+ // is part of the exported packages. This is just an
+ // approximation for now, and should be updated when we have
+ // the exported type attribute in the module metadata.
+ for (PackageDefinition packageDef : getExportedPackageDefinitions()) {
+ if (className.startsWith(packageDef.getName() + ".")) {
+ s.add(className);
+ }
+ }
+ }
+
exportedClasses = Collections.unmodifiableSet(s);
}
return exportedClasses;
+ }
+
+ @Override
+ public Set<PackageDefinition> getMemberPackageDefinitions() {
+ if (memberPackageDefs == null) {
+ List<String> memberPackages = Arrays.asList(getModuleInfo().getMemberPackages());
+
+ HashSet<PackageDefinition> packageDefs = new HashSet<PackageDefinition>();
+ for (String s : memberPackages) {
+ packageDefs.add(new JamPackageDefinition(s, Version.DEFAULT, this));
+ }
+ memberPackageDefs = packageDefs;
+ }
+ return memberPackageDefs;
+ }
+
+ @Override
+ public Set<PackageDefinition> getExportedPackageDefinitions() {
+ if (exportedPackageDefs == null) {
+ List<String> exportedPackages = Arrays.asList(getModuleInfo().getExportedPackages());
+
+ HashSet<PackageDefinition> packageDefs = new HashSet<PackageDefinition>();
+ for (String s : exportedPackages) {
+ packageDefs.add(new JamPackageDefinition(s, Version.DEFAULT, this));
+ }
+ exportedPackageDefs = packageDefs;
+ }
+ return exportedPackageDefs;
}
@Override
public boolean isClassExported(String className) {
// XXX convert class name?
- // XXX @ExportPackages is a workaround for building virtual modules
- // for the Java SE platform. It should be replaced after the
- // actual JSR 294 support arrives in javac.
- //
- ExportPackages exportPackages = getAnnotation(ExportPackages.class);
- if (exportPackages != null) {
- String[] p = exportPackages.value();
- if (p.length == 1 && p[0].equals("*")) {
+ // Use exported classes if available
+ if (memberClassesNotAvailable == false) {
+ try {
+ return getExportedClasses().contains(className);
+ } catch (UnsupportedOperationException uoe) {
+ }
+ }
+
+ for (PackageDefinition packageDef : getExportedPackageDefinitions()) {
+ String packageName = packageDef.getName();
+ if (packageName.equals("*")) {
// "*" is exported by the "java.classpath" module.
return true;
}
- for (String s : p) {
- // Checks if the specified class is exported from this module.
- if (className.startsWith(s + ".")) {
- return true;
- }
- }
- return false;
- } else {
- return getExportedClasses().contains(className);
- }
+ // Checks if the specified class is exported from this module.
+ if (className.startsWith(packageName + ".")) {
+ return true;
+ }
+ }
+ return false;
}
@Override
public Set<String> getExportedResources() {
+ if (exportedResourcesNotAvailable) {
+ throw new UnsupportedOperationException();
+ }
+
if (exportedResources == null) {
Set<String> s = new HashSet<String>();
@@ -367,6 +443,9 @@ final class JamModuleDefinition extends
System.err.println("Warning: Unrecognized filter in @ExportResources: "
+ filters[i] + ", filter is ignored.");
pse.printStackTrace();
+ } catch (IOException ioe) {
+ exportedResourcesNotAvailable = true;
+ throw new UnsupportedOperationException();
}
}
exportedResources = Collections.unmodifiableSet(s);
@@ -392,95 +471,12 @@ final class JamModuleDefinition extends
if (annotationClass == null) {
throw new NullPointerException();
}
- return getSuperpackage().getAnnotation(annotationClass);
-
- /*
- // XXX: Loading side files to synthetize annotaions would have
- // the side effect of downloading the JAM file eagerly in some
- // cases. This is undesirable, and thus the code is commented out
- // for now.
-
- // Determines if requested annotation is a stock annotation.
- if (annotationClass.equals(LegacyClasses.class) == false) {
- return getSuperpackage().getAnnotation(annotationClass);
- }
-
- // Determines if requested annotation is a synthetic annotation.
- initAnnotationsIfNecessary();
- for (Class c : annotations.keySet()) {
- if (annotationClass.isAssignableFrom(c))
- return (T) annotations.get(c);
- }
- return null;
- */
- }
-
+ return getModuleInfo().getAnnotation(annotationClass);
+ }
@Override
public synchronized List<Annotation> getAnnotations() {
- return Collections.unmodifiableList(Arrays.asList(getSuperpackage().getAnnotations()));
- /*
- // XXX: See comments in getAnnotation(Class<T>)
-
- initAnnotationsIfNecessary();
- return Collections.unmodifiableList(new ArrayList<Annotation>(annotations.values()));
- */
- }
-
- private void initAnnotationsIfNecessary() {
- if (annotations == null) {
- Map<Class, Annotation> annotationMap = new HashMap<Class, Annotation>();
-
- for (Annotation a : Arrays.asList(getSuperpackage().getAnnotations())) {
- // Skips over LegacyClasses annotation if it exists in the superpackage
- if (a instanceof LegacyClasses) {
- continue;
- }
- else {
- annotationMap.put(a.getClass(), a);
- }
- }
-
- // Constructs a legacy classes annotation on the fly based on the
- // content of MODULE-INF/legacy-classes.list
- final String legacyClassesEntry = "MODULE-INF/legacy-classes.list";
- try {
- if (content.hasEntry(legacyClassesEntry)) {
- BufferedReader r = new BufferedReader(new InputStreamReader(content.getEntryAsStream(legacyClassesEntry)));
- Set<String> rc = new HashSet<String>();
- String s;
- while ((s = r.readLine()) != null) {
- s = s.trim();
- if (!s.equals("") && !s.startsWith("#")) {
- rc.add(s);
- }
- }
- r.close();
-
- final String[] legacyClasses = new String[rc.size()];
- int i = 0;
- for (String lc : rc) {
- legacyClasses[i++] = lc;
- }
-
- LegacyClasses legacyClassesAnnotation = new LegacyClasses() {
- public String[] value() {
- return legacyClasses;
- }
- public Class<? extends Annotation> annotationType() {
- return LegacyClasses.class;
- }
- };
- annotationMap.put(LegacyClasses.class, legacyClassesAnnotation);
- }
- } catch (IOException ioe) {
- // TODO: use logging
- System.err.println("Warning: Unrecognized file format in MODULE-INF/legacy-classes.list, "
- + "legacy classes list is ignored.");
- ioe.printStackTrace();
- }
- annotations = annotationMap;
- }
+ return Collections.unmodifiableList(Arrays.asList(getModuleInfo().getAnnotations()));
}
@Override
@@ -494,10 +490,15 @@ final class JamModuleDefinition extends
}
@Override
- public ModuleDefinitionContent getModuleDefinitionContent() {
+ public ModuleSystem getModuleSystem() {
+ return repository.getModuleSystem();
+ }
+
+ @Override
+ public ModuleContent getModuleContent() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
- sm.checkPermission(new ModuleSystemPermission("accessModuleDefinitionContent"));
+ sm.checkPermission(new ModuleSystemPermission("accessModuleContent"));
}
return content;
}
--- a/src/share/classes/java/module/Module.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/Module.java Wed Apr 16 02:49:49 2008 -0700
@@ -25,11 +25,10 @@
package java.module;
-import java.util.concurrent.atomic.AtomicLong;
import java.util.List;
/**
- * This class represents the reified module instance in the module system.
+ * This class represents a reified module instance in a module system.
* <p>
* @see java.lang.ClassLoader
* @see java.module.ModuleDefinition
@@ -40,56 +39,35 @@ public abstract class Module
{
private static ModuleSystem defaultImpl = null;
- /** Counter for generating Id for module instances. */
- private static final AtomicLong idCounter = new AtomicLong();
-
- /** Id for this module instance. */
- private final long id = idCounter.incrementAndGet();
-
/**
- * Creates a new <code>Module</code> instance.
+ * Creates a new {@code Module} instance.
*/
protected Module() {
// empty
}
/**
- * Returns a long value that represents the unique identifier assigned to
- * this module instance. The identifier is assigned by the JVM and is JVM
- * implementation dependent.
- *
- * @return a long value that represents the unique identifier assigned to
- * this module instance.
- */
- public final long getId() {
- return id;
- }
-
- /**
- * Returns the <code>ModuleDefinition</code> of the module instance.
+ * Returns the {@code ModuleDefinition} of this {@code Module}.
*
- * @return the <code>ModuleDefinition</code> object.
+ * @return the {@code ModuleDefinition} object.
*/
public abstract ModuleDefinition getModuleDefinition();
/**
- * Returns the classloader associated with the module instance.
+ * Returns the classloader associated with this {@code Module}.
* <p>
- * If a security manager is present, and the caller's
- * class loader is not null and the caller's class loader
- * is not the same as or an ancestor of the class loader
- * for the module instance whose class loader is
- * requested, then this method calls the security
- * manager's <code>checkPermission</code> method with a
- * <code>RuntimePermission("getClassLoader")</code>
- * permission to ensure it's ok to access the class
- * loader for the module instance.
+ * If a security manager is present, and the caller's class loader is not
+ * null and the caller's class loader is not the same as or an ancestor of
+ * the class loader for the module instance whose class loader is
+ * requested, then this method calls the security manager's
+ * {@code checkPermission} method with a
+ * {@code RuntimePermission("getClassLoader")} permission to ensure it's
+ * ok to access the class loader for this {@code Module}.
*
- * @return the classloader object of the module.
- * @throws SecurityException if a security manager
- * exists and its <code>checkPermission</code>
- * method denies access to the class loader for
- * the module instance.
+ * @return the {@code ClassLoader} object for this {@code Module}.
+ * @throws SecurityException if a security manager exists and its
+ * {@code checkPermission} method denies access to the class loader
+ * for this {@code Module}.
*/
public abstract ClassLoader getClassLoader();
@@ -101,14 +79,14 @@ public abstract class Module
public abstract List<Module> getImportedModules();
/**
- * Check if deep validation is supported.
+ * Check if deep validation is supported on this {@code Module}.
*
- * @return true if deep validation is supported.
+ * @return true if deep validation is supported; otherwise, returns false.
*/
public abstract boolean supportsDeepValidation();
/**
- * Perform deep validation on the module instance.
+ * Perform deep validation on this {@code Module}.
*
* @throws UnsupportedOperationException if deep validation is not supported.
* @throws ModuleInitializationException if deep validation fails.
@@ -118,10 +96,12 @@ public abstract class Module
/**
* Compares the specified object with this {@code Module} for equality.
* Returns {@code true} if and only if {@code obj} is the same object as
- * this object.
+ * this {@code Module}.
*
- * @param obj the object to be compared for equality with this module.
- * @return {@code true} if the specified object is equal to this module
+ * @param obj the object to be compared for equality with this
+ * {@code Module}.
+ * @return {@code true} if the specified object is equal to this
+ * {@code Module}.
*/
@Override
public final boolean equals(Object obj) {
@@ -131,7 +111,7 @@ public abstract class Module
/**
* Returns a hash code for this {@code Module}.
*
- * @return a hash code value for this object.
+ * @return a hash code value for this {@code Module}.
*/
@Override
public final int hashCode() {
@@ -139,15 +119,14 @@ public abstract class Module
}
/**
- * Returns a <code>String</code> object representing this
- * <code>Module</code>.
+ * Returns a {@code String} object representing this {@code Module}.
*
- * @return a string representation of the <code>Module</code> object.
+ * @return a string representation of the {@code Module} object.
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
- builder.append("module ");
+ builder.append("module instance ");
builder.append(getModuleDefinition().getName());
builder.append(" v");
builder.append(getModuleDefinition().getVersion());
--- a/src/share/classes/java/module/ModuleArchiveInfo.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/ModuleArchiveInfo.java Wed Apr 16 02:49:49 2008 -0700
@@ -27,7 +27,7 @@ package java.module;
/**
* This class represents the information of an installed module archive
- * in the repository.
+ * in a repository.
*
* @see java.module.Repository
* @see java.module.Version
@@ -46,10 +46,11 @@ public class ModuleArchiveInfo {
private long lastModified;
/**
- * Constructs a new <code>ModuleArchiveInfo</code> instance.
+ * Constructs a new {@code ModuleArchiveInfo} instance.
* <p>
* If the module definition in the module archive is platform and
- * architecture neutral, both platform and arch must be null.
+ * architecture neutral, both {@code platform} and {@code arch} must be
+ * null.
*
* @param repository the repository
* @param name the name of the module definition in the module archive.
@@ -128,7 +129,7 @@ public class ModuleArchiveInfo {
/**
* Returns the name of the platform of the module definition in the
* module archive. The value should be one of the possible values
- * of the system property "os.platform".
+ * of the system property {@code "os.platform"}.
*
* @return the name of the platform. If the module definition has no
* platform binding, returns null.
@@ -140,7 +141,7 @@ public class ModuleArchiveInfo {
/**
* Returns the name of the architecture of the module definition in the
* module archive. The value should be one of the possible values of
- * the system property "os.arch".
+ * the system property {@code "os.arch"}.
*
* @return the name of the architecture. If the module definition has no
* platform binding, returns null.
@@ -181,10 +182,10 @@ public class ModuleArchiveInfo {
}
/**
- * Returns a <code>String</code> object representing this
- * <code>ModuleArchiveInfo</code>.
- *
- * @return a string representation of the <code>ModuleArchiveInfo</code> object.
+ * Returns a {@code String} object representing this
+ * {@code ModuleArchiveInfo}.
+ *
+ * @return a string representation of the {@code ModuleArchiveInfo} object.
*/
@Override
public String toString() {
--- a/src/share/classes/java/module/ModuleDefinition.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/ModuleDefinition.java Wed Apr 16 02:49:49 2008 -0700
@@ -26,15 +26,17 @@ package java.module;
package java.module;
import java.lang.annotation.Annotation;
-import java.util.concurrent.atomic.AtomicLong;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
/**
-* This class represents the reified module definition in the
-* module system.
+* This class represents a reified module definition in a module system.
* <p>
* @see java.lang.ClassLoader
+* @see java.module.Module
+* @see java.module.ModuleSystem
* @see java.module.Repository
* @see java.module.Version
*
@@ -42,12 +44,6 @@ import java.util.Set;
*/
public abstract class ModuleDefinition {
- /** Counter for generating Id for module definitions. */
- private static final AtomicLong idCounter = new AtomicLong();
-
- /** Id for this module definition. */
- private final long id = idCounter.incrementAndGet();
-
/**
* Constructor used by subclasses.
*/
@@ -56,34 +52,22 @@ public abstract class ModuleDefinition {
}
/**
- * Returns a long value that represents the unique identifier assigned to
- * this module definition. The identifier is assigned by the JVM and is JVM
- * implementation dependent.
- *
- * @return a long value that represents the unique identifier assigned to
- * this module definition.
- */
- public final long getId() {
- return id;
- }
-
- /**
- * Returns the name of the module definition.
- *
- * @return the name of the module definition.
+ * Returns the name of this {@code ModuleDefinition}.
+ *
+ * @return the name of this {@code ModuleDefinition}.
*/
public abstract String getName();
/**
- * Returns the version of the module definition.
- *
- * @return the <code>Version</code> object.
+ * Returns the version of this {@code ModuleDefinition}.
+ *
+ * @return the {@code Version} object.
*/
public abstract Version getVersion();
/**
* Returns an unmodifiable set of the names of the attributes
- * associated with the module definition.
+ * associated with this {@code ModuleDefinition}.
*
* @return an unmodifiable set of the names of the attributes.
*/
@@ -91,9 +75,9 @@ public abstract class ModuleDefinition {
/**
* Returns the value corresponding to the specified attribute name that is
- * associated with the module definition. If the module definition has
- * attributes with duplicate names, the value of the attribute in the last
- * occurrence is returned.
+ * associated with this {@code ModuleDefinition}. If this
+ * {@code ModuleDefinition} has attributes with duplicate names, the value
+ * of the attribute in the last occurrence is returned.
*
* @param name the name of the attribute.
* @return the value of the attribute. Returns null if the specified
@@ -102,121 +86,185 @@ public abstract class ModuleDefinition {
public abstract String getAttribute(String name);
/**
- * Returns an unmodifiable list of import dependency. The order
- * of the import dependency in the list follows the declared
- * import order in the module definition.
- *
- * @return an unmodifiable list of import dependency.
+ * Returns an unmodifiable list of all kinds of import dependencies. The
+ * order of the import dependency in the list follows the declared import
+ * order in the {@code ModuleDefinition}.
+ *
+ * @return an unmodifiable list of all kinds of import dependencies.
*/
public abstract List<ImportDependency> getImportDependencies();
/**
- * Returns repository that is associated with the module
- * definition.
- *
- * @return the <code>Repository</code> object.
+ * Returns an unmodifiable list of import module dependencies. The order of
+ * the import dependency in the list follows the declared import order in
+ * the {@code ModuleDefinition}.
+ *
+ * @return an unmodifiable list of import module dependencies .
+ */
+ public List<ModuleDependency> getImportModuleDependencies() {
+ List<ModuleDependency> moduleDependencies = new ArrayList<ModuleDependency>();
+ for (ImportDependency impDep : getImportDependencies()) {
+ if (impDep instanceof ModuleDependency) {
+ moduleDependencies.add((ModuleDependency) impDep);
+ }
+ }
+ return Collections.unmodifiableList(moduleDependencies);
+ }
+
+ /**
+ * Returns the repository that is associated with this
+ * {@code ModuleDefinition}.
+ *
+ * @return the {@code Repository} object.
*/
public abstract Repository getRepository();
/**
- * Returns an unmodifiable set of the names of the classes
- * that a member of this module definition.
+ * Returns the module system that is associated with this
+ * {@code ModuleDefinition}. Equivalent to:
+ * <pre>
+ * getRepository().getModuleSystem();
+ * </pre>
+ * @return the {@code ModuleSystem} object.
+ */
+ public abstract ModuleSystem getModuleSystem();
+
+
+ /**
+ * Returns an unmodifiable set of the names of the classes that are members
+ * of this {@code ModuleDefinition}.
*
* @return The unmodifiable set of the names of the member classes.
+ * @throws UnsupportedOperationException if the set of member classes
+ * in this {@code ModuleDefinition} cannot be determined.
*/
public abstract Set<String> getMemberClasses();
/**
- * Returns an unmodifiable set of the names of the classes
- * that are exported by this module definition.
- * This is a subset of the classes returned by
- * {@link #getMemberClasses}.
+ * Returns an unmodifiable set of the package definitions that represents
+ * the member packages in this {@code ModuleDefinition}.
+ *
+ * @return The unmodifiable set of the member package definitions.
+ */
+ public abstract Set<PackageDefinition> getMemberPackageDefinitions();
+
+ /**
+ * Returns an unmodifiable set of the names of the classes that are
+ * exported by this {@code ModuleDefinition}. This is a subset of the
+ * classes returned by {@link #getMemberClasses() getMemberClasses()}.
*
* @return The unmodifiable set of the names of the exported classes.
+ * @throws UnsupportedOperationException if the set of exported classes
+ * in this {@code ModuleDefinition} cannot be determined.
*/
public abstract Set<String> getExportedClasses();
/**
- * Check if the specified class is exported by this module definition.
+ * Returns an unmodifiable set of the package definitions that represents
+ * the exported packages in this {@code ModuleDefinition}. This is a subset
+ * of the package definitions returned by
+ * {@link #getMemberPackageDefinitions() getMemberPackageDefinitions()}.
+ *
+ * @return The unmodifiable set of the exported package definitions.
+ */
+ public abstract Set<PackageDefinition> getExportedPackageDefinitions();
+
+ /**
+ * Check if the specified class is exported by this
+ * {@code ModuleDefinition}.
*
* @param name the name of the class.
- * @return true if the class is exported.
+ * @return true if the class is exported; otherwise, returns false.
*/
public boolean isClassExported(String name) {
- // TODO: convert class name?
- Set<String> exportedClasses = getExportedClasses();
- return exportedClasses.contains(name);
+ try {
+ // TODO: convert class name?
+ Set<String> exportedClasses = getExportedClasses();
+ return exportedClasses.contains(name);
+ } catch (UnsupportedOperationException uoe) {
+ return false;
+ }
}
/**
* Returns an unmodifiable set of the path of the resources exported by
- * this module definition.
+ * this {@code ModuleDefinition}.
* <p>
* Resources are specified as '/' separated paths, with no leading '/'.
*
* @return The unmodifiable set of the path of the exported resources.
+ * @throws UnsupportedOperationException if the set of exported resources
+ * in this {@code ModuleDefinition} cannot be determined.
*/
public abstract Set<String> getExportedResources();
/**
- * Check if the specified resource is exported by this module definition.
+ * Check if the specified resource is exported by this
+ * {@code ModuleDefinition}.
*
* @param path A '/' delimited path (e.g. x/y/Z.class")
* @return true if the resource in the path is exported.
*/
public boolean isResourceExported(String path) {
- Set<String> exportedResources = getExportedResources();
- return exportedResources.contains(path);
- }
-
- /**
- * Returns a {@code Module} instance for the specified {@code ModuleDefinition}
- * in the {@code ModuleSystem}. The module is initialized and ready to use.
- * Equivalent to:
+ try {
+ Set<String> exportedResources = getExportedResources();
+ return exportedResources.contains(path);
+ } catch (UnsupportedOperationException uoe) {
+ return false;
+ }
+ }
+
+ /**
+ * Returns a {@code Module} instance for the specified
+ * {@code ModuleDefinition} in the {@code ModuleSystem}. The {@code Module}
+ * is initialized and ready to use. Equivalent to:
* <pre>
- * getRepository().getModuleSystem().getModule(this);
+ * getModuleSystem().getModule(this);
* </pre>
*
* @return a {@code Module} instance of the {@code ModuleDefinition}.
* @throws ModuleInitializationException if the module instance cannot be initialized.
- * @throws IllegalStateException if the specified module definition
- * has already been disabled.
+ * @throws IllegalStateException if this {@code ModuleDefinition} has
+ * already been disabled.
*/
public final Module getModuleInstance() throws ModuleInitializationException {
- return getRepository().getModuleSystem().getModule(this);
- }
-
- /**
- * Returns this element's annotation for the specified type or
- * the value of the specified attribute as an annotation.
+ return getModuleSystem().getModule(this);
+ }
+
+ /**
+ * Returns this {@code ModuleDefinition}'s annotation for the specified
+ * type or the value of the specified attribute as an annotation.
*
* @param annotationClass the Class object corresponding to the
* annotation type
- * @return this element's annotation for the specified annotation type if
- * present on this element, else null
+ * @return this {@code ModuleDefinition}'s annotation for the specified
+ * annotation type if present, else null
* @throws NullPointerException if the given annotation class is null
*/
public abstract <T extends Annotation> T getAnnotation(Class<T> annotationClass);
/**
- * Returns an unmodifiable list of all annotations present on this element.
- * If no annotations are present, an empty list is returned.
- *
- * @return an unmodifiable list of all annotations present on this element
+ * Returns an unmodifiable list of all annotations present on this
+ * {@code ModuleDefinition}. If no annotations are present, an empty list
+ * is returned.
+ *
+ * @return an unmodifiable list of all annotations present on this
+ * {@code ModuleDefinition}
*/
public abstract List<Annotation> getAnnotations();
/**
- * Checks if the entire content of this module definition is stored locally.
- *
- * @return true if the entire content of this module definition is stored
- * locally. Otherwise, returns false.
+ * Checks if the entire content of this {@code ModuleDefinition} is stored
+ * locally.
+ *
+ * @return true if the entire content of this {@code ModuleDefinition} is
+ * stored locally; otherwise, returns false.
*/
public boolean isDownloaded() {
Boolean local = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Boolean>() {
public Boolean run() {
- return getModuleDefinitionContent().isDownloaded();
+ return getModuleContent().isDownloaded();
}
});
@@ -224,30 +272,30 @@ public abstract class ModuleDefinition {
}
/**
- * Check if the {@code Module} instance for this module definition can be
- * released from the {@code ModuleSystem}.
- *
- * @return true if {@code Module} instance of this {@code ModuleDefinition}
- * can be released. Otherwise, returns false.
+ * Check if the {@code Module} instances instantiated from this
+ * {@code ModuleDefinition} can be released from its {@code ModuleSystem}.
+ *
+ * @return true if {@code Module} instances can be released; otherwise,
+ * returns false.
*/
public abstract boolean isModuleReleasable();
/**
- * Returns a <code>ModuleDefinitionContent</code> instance which
- * represents the content of this module definition.
+ * Returns a {@code ModuleContent} instance which represents the content
+ * of this {@code ModuleDefinition}.
* <p>
* If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with a
- * <code>ModuleSystemPermission("accessModuleDefinitionContent")</code>
- * permission to ensure it's ok to access the content of this module
- * definition.
- *
- * @return the <code>ModuleDefinitionContent</code> instance.
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("accessModuleContent")}
+ * permission to ensure it's ok to access the content of this
+ * {@code ModuleDefinition}.
+ *
+ * @return the {@code ModuleContent} instance.
* @throws SecurityException if a security manager exists and
- * its <tt>checkPermission</tt> method denies access
- * to the content of this module definition.
- */
- public abstract ModuleDefinitionContent getModuleDefinitionContent();
+ * its {@code checkPermission} method denies access
+ * to the content of this {@code ModuleDefinition}.
+ */
+ public abstract ModuleContent getModuleContent();
/**
* Compares the specified object with this {@code ModuleDefinition} for
@@ -255,8 +303,10 @@ public abstract class ModuleDefinition {
* Returns {@code true} if and only if {@code obj} is the same object as
* this object.
*
- * @param obj the object to be compared for equality with this module definition.
- * @return {@code true} if the specified object is equal to this module definition
+ * @param obj the object to be compared for equality with this
+ * {@code ModuleDefinition}.
+ * @return {@code true} if the specified object is equal to this
+ * {@code ModuleDefinition}; otherwise, returns false.
*/
@Override
public final boolean equals(Object obj) {
@@ -266,7 +316,7 @@ public abstract class ModuleDefinition {
/**
* Returns a hash code for this {@code ModuleDefinition}.
*
- * @return a hash code value for this object.
+ * @return a hash code value for this {@code ModuleDefinition}.
*/
@Override
public final int hashCode() {
@@ -274,11 +324,10 @@ public abstract class ModuleDefinition {
}
/**
- * Returns a <code>String</code> object representing this
- * <code>ModuleDefinition</code>.
- *
- * @return a string representation of the
- * <code>ModuleDefinition</code> object.
+ * Returns a {@code String} object representing this
+ * {@code ModuleDefinition}.
+ *
+ * @return a string representation of the {@code ModuleDefinition} object.
*/
@Override
public String toString() {
--- a/src/share/classes/java/module/ModuleFormatException.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/ModuleFormatException.java Wed Apr 16 02:49:49 2008 -0700
@@ -28,8 +28,8 @@ import java.io.IOException;
import java.io.IOException;
/**
- * Thrown to indicate that the format of the module archive is not recognized
- * or supported.
+ * Thrown to indicate that the format of the module archive is neither
+ * recognized nor supported.
*
* @since 1.7
*/
@@ -38,8 +38,8 @@ public class ModuleFormatException exten
private static final long serialVersionUID = 3913242042315331551L;
/**
- * Constructs a <code>ModuleFormatException</code> the
- * specified detail message.
+ * Constructs a {@code ModuleFormatException} with the specified detail
+ * message.
*
* @param s the detail message.
*/
@@ -48,8 +48,8 @@ public class ModuleFormatException exten
}
/**
- * Constructs a <code>ModuleFormatException</code> the
- * specified detail message and cause.
+ * Constructs a {@code ModuleFormatException} with the specified detail
+ * message and cause.
*
* @param s the detail message.
* @param cause the cause.
--- a/src/share/classes/java/module/ModuleInitializationException.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/ModuleInitializationException.java Wed Apr 16 02:49:49 2008 -0700
@@ -26,7 +26,7 @@ package java.module;
package java.module;
/**
- * Thrown to indicate that the initialization of a Module failed.
+ * Thrown to indicate that the initialization of a module instance has failed.
*
* @since 1.7
*/
@@ -35,8 +35,8 @@ public class ModuleInitializationExcepti
private static final long serialVersionUID = 2254350161991536852L;
/**
- * Constructs a <code>ModuleInitializationException</code> with
- * the specified detail message.
+ * Constructs a {@code ModuleInitializationException} with the specified
+ * detail message.
*
*
* @param s the detail message.
@@ -46,8 +46,8 @@ public class ModuleInitializationExcepti
}
/**
- * Constructs a <code>ModuleInitializationException</code> with
- * the specified detail message and cause.
+ * Constructs a {@code ModuleInitializationException} with the specified
+ * detail message and cause.
*
*
* @param s the detail message.
--- a/src/share/classes/java/module/ModuleInitializer.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/ModuleInitializer.java Wed Apr 16 02:49:49 2008 -0700
@@ -26,10 +26,9 @@ package java.module;
package java.module;
/**
- * This interface represents the initializer of a module definition. The
- * initializer is invoked when the module system initializes a module
- * instance of the module definition, and when that module instance is
- * released from the module system.
+ * This interface represents a module initializer of a module definition. The
+ * initializer is invoked when the module system initializes a module instance,
+ * and when that module instance is released from the module system.
* <p>
* @see java.module.Module
* @see java.module.ModuleDefinition
@@ -40,9 +39,9 @@ public interface ModuleInitializer {
public interface ModuleInitializer {
/**
- * This method is invoked during module instance's initialization. It is
- * invoked after the module instance has been shallow validated
- * successfully, but before the module instance becomes ready.
+ * This method is invoked when a module instance is initializing in the
+ * module system. It is invoked after the module instance has been shallow
+ * validated successfully, but before the module instance becomes ready.
* <p>
* If this method throws any exception during execution, it will cause the
* module instance's initialization to fail.
@@ -52,38 +51,58 @@ public interface ModuleInitializer {
* there are two potential issues:
* <p>
* 1. The exported classes from these imported modules might not yet be
- * accessible from this method.
+ * accessible from this method.<p>
* 2. The initializer of these imported modules might not yet been invoked.
* <p>
- * Implementation of this method should avoid accessing classes from the
+ * Implementations of this method should avoid accessing classes from the
* imported modules, and should make no assumption that the imported
* modules have been fully intitalized. Otherwise, the result is
* undeterministic.
+ * <p>
+ * Note that the module instance passed as the argument of this method has
+ * not been fully initialized. The only methods in {@code Module} that the
+ * implementations of this method could invoke reliably are
+ * {@code Module}'s {@code getModuleDefinition()}, {@code hashCode()}, and
+ * {@code toString()}. Otherwise, the result is undeterministric.
*
- * @param module the module instance that this module initializer belongs.
- * @throws ModuleInitializationException if this module initializer
+ * @param module the module instance that this {@code ModuleInitializer}
+ * belongs.
+ * @throws ModuleInitializationException if this {@code ModuleInitializer}
* fails to initialize.
*/
public void initialize(Module module) throws ModuleInitializationException;
/**
* This method is invoked when a module instance is released from the
- * module system in the following situations:
+ * module system. It is invoked in the following situations:
* <p>
- * 1. The {@code initialize} method has been invoked successfully, but
- * this module instance still gets into error state because one or
- * more of its imported modules get into error state, or
- * 2. After the <code>releaseModuleDefinition</code> method of the
- * {@code ModuleSystem} is invoked.
+ * 1. The {@link #initialize(Module) initialize(Module)} method has been
+ * invoked successfully, but this module instance still gets into error
+ * state because one or more of its imported modules get into error
+ * state, or<p>
+ * 2. After the {@code releaseModule} method of the {@code ModuleSystem}
+ * is invoked.
+ * <p>
+ * In the first situation, the module instance passed as the argument of
+ * this method is in error state. The only methods in {@code Module} that
+ * the implementations of this method could invoke reliably are
+ * {@code Module}'s {@code getModuleDefinition()}, {@code hashCode()}, and
+ * {@code toString()}. Otherwise, the result is undeterministric.
* <p>
* Note that after this method is invoked, the module classloader of this
* module instance might still be accessible from other modules. If the
- * implementation of this method attempts to reset some states or
+ * implementations of this method attempt to reset some states or
* shutdown some functionalities in this module instance, this could be
* problematic for the importing modules if they continue to access this
* module instance after this module instance has been released.
+ * <p>
+ * Also, when the virtual machine exits, there is no guarantee that this
+ * method is ever invoked even if the
+ * {@link #initialize(Module) initialize(Module)} method has been invoked
+ * successfully.
*
- * @param module the module instance that this module initializer belongs.
+ * @param module the module instance that this {@code ModuleInitializer}
+ * belongs.
*/
public void release(Module module);
}
--- a/src/share/classes/java/module/ModuleSystem.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/ModuleSystem.java Wed Apr 16 02:49:49 2008 -0700
@@ -25,14 +25,14 @@
package java.module;
-import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadFactory;
/**
- * This class represents the module system which constructs a module
- * instance from a module definition.
+ * This class represents a module system. A module system is responsible for
+ * instantiating a module instance from a module definition, and managing its
+ * lifetime.
* <p>
* @see java.module.Module
* @see java.module.ModuleDefinition
@@ -46,12 +46,6 @@ public abstract class ModuleSystem {
private static ModuleSystem defaultImpl = null;
- /** Counter for generating Ids for module systems. */
- private static final AtomicLong idCounter = new AtomicLong();
-
- /** Id for this module system. */
- private final long id = idCounter.incrementAndGet();
-
/**
* Constructor used by subclasses.
*/
@@ -60,101 +54,90 @@ public abstract class ModuleSystem {
}
/**
- * Returns a long value that represents the unique identifier assigned to
- * this module system. The identifier is assigned by the JVM and is JVM
- * implementation dependent.
- *
- * @return a long value that represents the unique identifier assigned to
- * this module system.
- */
- public final long getId() {
- return id;
- }
-
- /**
- * Returns a {@code Module} instance for the specified {@code ModuleDefinition}
- * in the {@code ModuleSystem}. The module is initialized and ready to use.
- * <p>
- * If there is an existing module instance for the specified
- * {@code ModuleDefinition}, that instance is returned. Otherwise, a new module
- * instance is instantiated and returned.
- *
- * @param moduleDef a {@code ModuleDefinition}
+ * Returns a {@code Module} instance for the specified
+ * {@code ModuleDefinition} in this {@code ModuleSystem}. The returned
+ * {@code Module} is fully initialized and ready to use.
+ * <p>
+ * If there is an existing {@code Module} instance for the specified
+ * {@code ModuleDefinition}, that instance is returned. Otherwise, a new
+ * {@code Module} instance is instantiated, initialized, and returned.
+ *
+ * @param moduleDef a {@code ModuleDefinition} object
* @return a {@code Module} instance of the {@code ModuleDefinition}.
- * @throws ModuleInitializationException if the module instance cannot be initialized.
- * @throws IllegalStateException if the specified module definition
+ * @throws ModuleInitializationException if the {@code Module} instance
+ * cannot be initialized.
+ * @throws IllegalStateException if the specified {@code ModuleDefinition}
* has already been disabled.
*/
public abstract Module getModule(ModuleDefinition moduleDef) throws ModuleInitializationException;
/**
* Releases an existing {@code Module} instance corresponding to the
- * specified {@code ModuleDefinition} in the {@code ModuleSystem}.
- * <p>
- * If there is an existing module instance for the specified module
- * definition, it will never be returned by the {@code ModuleSystem}
- * after this method returns. Further, if that module instance is
- * imported by other module instances, each of these importing module
- * instance will also be released.
- * <p>
- * If there is no module instance corresponding to the module
- * definition, calling this method has no effect.
+ * specified {@code ModuleDefinition} in this {@code ModuleSystem}.
+ * <p>
+ * If there is an existing {@code Module} instance for the specified
+ * {@code ModuleDefinition}, it will never be returned by this
+ * {@code ModuleSystem} after this method returns. Further, if that
+ * {@code Module} instance is imported by other {@code Module}
+ * instances, each of these importing {@code Module} instance will
+ * also be released.
+ * <p>
+ * If there is no {@code Module} instance corresponding to the
+ * {@code ModuleDefinition}, calling this method has no effect.
* <p>
* {@code Module} instances corresponding to the {@code ModuleDefinition}
* with name that begins with "java.", or from the bootstrap repository
* cannot be released. {@code Module} instances corresponding to the
- * {@code ModuleDefinition} that its <code>isModuleReleasable</code>
- * method returns false also cannot be released.
- * <p>
- * If a security manager is present, this method calls the security
- * manager's checkPermission method with a <code>
- * ModuleSystemPermission("releaseModule")</code> permission to ensure
- * it's ok to release the existing module instance of the specified
- * module definition.
- *
- * @param moduleDef a {@code ModuleDefinition}.
- * @throws SecurityException if a security manager exists and its
- * checkPermission method denies access to release the
- * module instance of the specified module definition.
+ * {@code ModuleDefinition} that its {@code isModuleReleasable} method
+ * returns false also cannot be released.
+ * <p>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("releaseModule")} permission to ensure
+ * it's ok to release the existing {@code Module} instance of the
+ * specified {@code ModuleDefinition} in this {@code ModuleSystem}.
+ *
+ * @param moduleDef a {@code ModuleDefinition} object.
+ * @throws SecurityException if a security manager exists and its
+ * {@code checkPermission} method denies access to release the
+ * {@code Module} instance of the specified
+ * {@code ModuleDefinition}.
* @throws UnsupportedOperationException if the existing module
* instance cannot be released.
*/
public abstract void releaseModule(ModuleDefinition moduleDef);
/**
- * Disables the specified {@code ModuleDefinition} in the
+ * Disables the specified {@code ModuleDefinition} in this
* {@code ModuleSystem}.
* <p>
- * The ModuleDefinition is {@link #releaseModule released} and marked to
- * disallow creation of new {@code Module} instances. Subsequent calls
- * to {@link #getModule getModule} with this ModuleDefinition throw an
- * IllegalStateException.
- * <p>
- * {@code ModuleDefinition} with name that begins with "java.",
- * or from the bootstrap repository cannot be disabled.
- * <p>
- * If a security manager is present, this method calls the security
- * manager's checkPermission method with a <code>
- * ModuleSystemPermission("disableModuleDefinition")</code> permission to
- * ensure it's ok to disable the specified module definition in the
- * module system.
- *
- * @param moduleDef a {@code ModuleDefinition}.
- * @throws SecurityException if a security manager exists and its
- * checkPermission method denies access to disable the
- * specified module definition in the module system.
- * @throws UnsupportedOperationException if the specified module
- * definition cannot be disabled.
- * @throws IllegalStateException if the specified module definition
+ * The {@code ModuleDefinition} is {@link #releaseModule released} and
+ * marked to disallow creation of new {@code Module} instances. Subsequent
+ * calls to {@link #getModule getModule} with this
+ * {@code ModuleDefinition} throw an IllegalStateException.
+ * <p>
+ * {@code ModuleDefinition} with name that begins with "java.", or from
+ * the bootstrap repository cannot be disabled.
+ * <p>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("disableModuleDefinition")} permission to
+ * ensure it's ok to disable the specified {@code ModuleDefinition} in this
+ * {@code ModuleSystem}.
+ *
+ * @param moduleDef a {@code ModuleDefinition} object.
+ * @throws SecurityException if a security manager exists and its
+ * {@code checkPermission} method denies access to disable the
+ * specified {@code ModuleDefinition} in this {@code ModuleSystem}.
+ * @throws UnsupportedOperationException if the specified
+ * {@code ModuleDefinition} cannot be disabled.
+ * @throws IllegalStateException if the specified {@code ModuleDefinition}
* has already been disabled.
*/
public abstract void disableModuleDefinition(ModuleDefinition moduleDef);
/**
* Returns the system's default module system.
- * <p>
- * The default class of the module system can be overridden using the
- * <code>java.module.ModuleSystem</code> system property.
*
* @return the system's default module system.
*/
@@ -175,8 +158,8 @@ public abstract class ModuleSystem {
* events from the module systems.
* <p>
* If a security manager is present, this method calls the security
- * manager's checkPermission method with a <code>
- * ModuleSystemPermission("addModuleSystemListener")</code> permission to
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("addModuleSystemListener")} permission to
* ensure it's ok to add a module system listener to the module systems.
*
* @param listener the module system listener
@@ -205,8 +188,8 @@ public abstract class ModuleSystem {
* receives module system events from the module systems.
* <p>
* If a security manager is present, this method calls the security
- * manager's checkPermission method with a <code>
- * ModuleSystemPermission("removeModuleSystemListener")</code> permission
+ * manager's {@code checkPermission} method with a {@code
+ * ModuleSystemPermission("removeModuleSystemListener")} permission
* to ensure it's ok to remove a module system listener from the module
* systems.
*
@@ -267,8 +250,8 @@ public abstract class ModuleSystem {
private static ExecutorService executorService = null;
/**
- * Processes module system event occuring in this module system by
- * dispatching them to any registered ModuleSystemListener objects.
+ * Processes module system event occuring in this {@code ModuleSystem} by
+ * dispatching them to any registered {@code ModuleSystemListener} objects.
*
* @param event the module system event
*/
--- a/src/share/classes/java/module/ModuleSystemEvent.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/ModuleSystemEvent.java Wed Apr 16 02:49:49 2008 -0700
@@ -26,7 +26,7 @@ package java.module;
package java.module;
/**
- * This class represents a module system event that occurs in the module
+ * This class represents a module system event that occurs in a module
* system.
*
* @see java.module.Module
@@ -70,15 +70,16 @@ public class ModuleSystemEvent {
private ModuleInitializationException exception;
/**
- * Constructs a ModuleSystemEvent object with event type MODULE_INITIALIZED,
- * or MODULE_RELEASED, using the specified module system, event type, and
- * module instance.
+ * Constructs a {@code ModuleSystemEvent} object with event type
+ * {@code MODULE_INITIALIZED} or {@code MODULE_RELEASED}, using the
+ * specified module system, event type, and module instance.
*
* @param source the module system where the event occurs
* @param type the event type
* @param module the module instance that the event applies to
* @throws IllegalArgumentException if type is
- * MODULE_INITIALIZATION_EXCEPTION or MODULE_DEFINITION_DISABLED
+ * {@code MODULE_INITIALIZATION_EXCEPTION} or
+ * {@code MODULE_DEFINITION_DISABLED}
* @throws NullPointerException if source is null, type is null,
* or module is null.
*
@@ -104,8 +105,8 @@ public class ModuleSystemEvent {
}
/**
- * Constructs a ModuleSystemEvent object with event type
- * MODULE_DEFINITION_DISABLED, using the specified module system
+ * Constructs a {@code ModuleSystemEvent} object with event type
+ * {@code MODULE_DEFINITION_DISABLED}, using the specified module system
* and module definition.
*
* @param source the module system where the event occurs
@@ -128,9 +129,9 @@ public class ModuleSystemEvent {
}
/**
- * Constructs a ModuleSystemEvent object with event type
- * MODULE_INITIALIZATION_EXCEPTION, using the specified module system,
- * module definition, and module initialization exception.
+ * Constructs a {@code ModuleSystemEvent} object with event type
+ * {@code MODULE_INITIALIZATION_EXCEPTION}, using the specified module
+ * system, module definition, and module initialization exception.
*
* @param source the module system where the event occurs
* @param moduleDef the module definition that the event applies to
@@ -191,10 +192,10 @@ public class ModuleSystemEvent {
}
/**
- * Returns a <code>String</code> object representing this
- * <code>ModuleSystemEvent</code>.
- *
- * @return a string representation of the <code>ModuleSystemEvent</code> object.
+ * Returns a {@code String} object representing this
+ * {@code ModuleSystemEvent}.
+ *
+ * @return a string representation of the {@code ModuleSystemEvent} object.
*/
@Override
public String toString() {
--- a/src/share/classes/java/module/ModuleSystemListener.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/ModuleSystemListener.java Wed Apr 16 02:49:49 2008 -0700
@@ -32,12 +32,12 @@ import java.util.EventListener;
* <p>
* The class that is interested in processing module system events implements
* this interface, and the object created with that class is registered with a
- * module system, using the module system's <code>addModuleSystemListener</code>
+ * module system, using the module system's {@code addModuleSystemListener}
* method.
* <p>
* The object that is no longer interested in processing any module system event is
* unregistered with the module system, using the module system's
- * <code>removedModuleSystemListener</code> method.
+ * {@code removedModuleSystemListener} method.
*
* @see java.module.ModuleSystem
* @see java.module.ModuleSystemEvent
@@ -47,9 +47,10 @@ public interface ModuleSystemListener ex
public interface ModuleSystemListener extends EventListener {
/**
- * Invoked after a module instance has been initialized successfully,
- * after a module instance has been released successfully, or after a
- * module initialization exception occurs.
+ * Invoked after a module instance has been initialized successfully, after
+ * a module instance has been released successfully, after a module
+ * initialization exception occurs, or after a module definition has been
+ * disabled successfully.
*
* @param e module system event
*/
--- a/src/share/classes/java/module/ModuleSystemPermission.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/ModuleSystemPermission.java Wed Apr 16 02:49:49 2008 -0700
@@ -28,13 +28,12 @@ import java.security.BasicPermission;
import java.security.BasicPermission;
/**
- * The permission which the SecurityManager will check when code that
- * is running with a SecurityManager calls methods defined in the
+ * The permission which the {@code SecurityManager} will check when code that
+ * is running with a {@code SecurityManager} calls methods defined in the
* module system for the Java platform.
* <P>
- * The following table provides a summary description of what the
- * permission allows, and discusses the risks of granting code the
- * permission.
+ * The following table provides a summary description of what the permission
+ * allows, and discusses the risks of granting code the permission.
* <P>
*
* <table border=1 cellpadding=5 summary="Table shows permission target name, wh
@@ -47,74 +46,68 @@ at the permission allows, and associated
*
* <tr>
* <td>releaseModule</td>
- * <td>Releases an existing module instance from the module system via calls to
- * the ModuleSystem <code>releaseModule</code> method.</td>
- * <td>This is a dangerous permission to grant.
- * Malicious applications that allows an attacker to
- * release an existing module instance, so the
- * runtime characteristics of the Java virtual
- * machine is changed and it could cause the system to
- * misbehave.</td>
+ * <td>Releases an existing module instance from a module system via calls to
+ * the {@code ModuleSystem}'s {@code releaseModule} method.</td>
+ * <td>This is a dangerous permission to grant. Malicious applications could
+ * allow an attacker to release an existing module instance, so the
+ * runtime characteristics of the Java virtual machine is changed
+ * unexpectedly and it could cause the system to misbehave.</td>
* </tr>
* <tr>
* <td>disableModuleDefinition</td>
- * <td>Disables a module definition in the module system via calls to
- * the ModuleSystem <code>disableModuleDefinition</code> method.</td>
- * <td>This is an extremely dangerous permission to grant.
- * Malicious applications that allows an attacker to perform
- * denial-of-service attack by disabling a module definition,
- * so the existing module instance is released, and also disallows
- * the module system from creating a new module instance from
- * that disabled module definition.</td>
+ * <td>Disables a module definition in a module system via calls to
+ * the {@code ModuleSystem}'s {@code disableModuleDefinition} method.</td>
+ * <td>This is an extremely dangerous permission to grant. Malicious
+ * applications could allow an attacker to perform denial-of-service
+ * attack by disabling a module definition, and the module system will be
+ * disallowed from creating any new module instance from that disabled
+ * module definition.</td>
* </tr>
* <tr>
* <td>installModuleArchive</td>
- * <td>Installs a module archive in a repository via calls
- * to the Repository <code>install</code> method.</td>
- * <td>This allows an attacker to install malicious code
- * into the repository of the module system.</td>
+ * <td>Installs a module archive in a repository via calls to the
+ * {@code Repository}'s {@code install} method.</td>
+ * <td>This allows an attacker to install malicious code into a repository.</td>
* </tr>
* <tr>
* <td>uninstallModuleArchive</td>
- * <td>Uninstalls a module archive in a repository via calls
- * to the Repository <code>uninstall</code> method.</td>
- * <td>This allows an attacker to remove critical module
- * definitions from the repository of the module system.</td>
+ * <td>Uninstalls a module archive in a repository via calls to the
+ * {@code Repository}'s {@code uninstall} method.</td>
+ * <td>This allows an attacker to remove critical module definitions from a
+ * repository.</td>
* </tr>
* <tr>
* <td>listModuleArchive</td>
* <td>Discovers the installed module archives in a repository via calls
- * to the Repository <code>list</code> method.</td>
- * <td>This allows an attacker to discover the installed module archives
- * in the repository of the module system.</td>
+ * to the {@code Repository}'s {@code list} method.</td>
+ * <td>This allows an attacker to discover the installed module archives in a
+ * repository.</td>
* </tr>
* <tr>
* <td>createRepository</td>
* <td>Creation of a repository.</td>
- * <td>This is an extremely dangerous permission to grant.
- * Malicious applications that can instantiate their
- * own repositories could then load their rogue
- * modules and classes into the module system.</td>
+ * <td>This is an extremely dangerous permission to grant. Malicious
+ * applications that can instantiate their own repositories could then
+ * load their rogue modules and classes into the system.</td>
* </tr>
* <tr>
* <td>shutdownRepository</td>
* <td>Shutdown a repository.</td>
- * <td>This allows an attacker to shutdown a repository
- * so the repository can no longer serve any module
- * definition.</td>
+ * <td>This allows an attacker to shutdown a repository so the repository
+ * can no longer serve any module definition.</td>
* </tr>
* <tr>
* <td>reloadRepository</td>
* <td>Reloads module definitions in a repository.</td>
- * <td>This allows an attacker to invalidate the lifetime of
- * the outstanding module instances instantiated from
- * the module definitions in the repository.</td>
+ * <td>This allows an attacker to invalidate the lifetime of the outstanding
+ * module instances instantiated from the module definitions in the
+ * repository.</td>
* </tr>
* <tr>
- * <td>accessModuleDefinitionContent</td>
- * <td>Accesses the actual content of the module definition.</td>
- * <td>This allows an attacker to have access to the actual content
- * of the module definition in the repository.</td>
+ * <td>accessModuleContent</td>
+ * <td>Accesses the content of the module definition.</td>
+ * <td>This allows an attacker to have access to the actual content of the
+ * module definition, which may contain sensitive information internally.</td>
* </tr>
* <tr>
* <td>setImportOverridePolicy</td>
@@ -124,33 +117,33 @@ at the permission allows, and associated
* </tr>
* <tr>
* <td>addModuleSystemListener</td>
- * <td>Adds a module system listener to the module system.</td>
+ * <td>Adds a module system listener to the module systems.</td>
* <td>This allows an attacker to monitor the module system events in the
- * module system.</td>
+ * module systems.</td>
* </tr>
* <tr>
* <td>removeModuleSystemListener</td>
- * <td>Removes a module system listener to the module system.</td>
+ * <td>Removes a module system listener to the module systems.</td>
* <td>This allows an attacker to remove a system-provided module system
- * listener from the module system.</td>
+ * listener from the module systems.</td>
* </tr>
* <tr>
* <td>addRepositoryListener</td>
- * <td>Adds a repository listener to the repository.</td>
+ * <td>Adds a repository listener to the repositories.</td>
* <td>This allows an attacker to monitor the repository events in the
- * repository.</td>
+ * repositories.</td>
* </tr>
* <tr>
* <td>removeRepositoryListener</td>
- * <td>Removes a repository listener to the repository.</td>
+ * <td>Removes a repository listener to the repositories.</td>
* <td>This allows an attacker to remove a system-provided repository
- * listener from the repository.</td>
+ * listener from the repositories.</td>
* </tr>
* </table>
* <p>
- * Programmers do not normally create ModuleSystemPermission
- * objects directly. Instead they are created by the security
- * policy code based on reading the security policy file.
+ * Programmers do not normally create {@code ModuleSystemPermission} objects
+ * directly. Instead they are created by the security policy code based on
+ * reading the security policy file.
*
* @see java.security.BasicPermission
* @see java.security.Permission
@@ -166,7 +159,7 @@ public final class ModuleSystemPermissio
private static final long serialVersionUID = 1228383723285909334L;
/**
- * Constructs a new <code>ModuleSystemPermission</code> instance with the
+ * Constructs a new {@code ModuleSystemPermission} instance with the
* specified name.
*
* @param name Permission name.
@@ -177,7 +170,7 @@ public final class ModuleSystemPermissio
}
/**
- * Constructs a new <code>ModuleSystemPermission</code> instance.
+ * Constructs a new {@code ModuleSystemPermission} instance.
*
* @param name Permission name.
* @param actions Must be either null or the empty string.
--- a/src/share/classes/java/module/Modules.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/Modules.java Wed Apr 16 02:49:49 2008 -0700
@@ -39,8 +39,8 @@ import sun.module.repository.URLReposito
/**
* This class consists exclusively of static methods that are specifically for
- * the Java Module System. It contains methods which constructs module
- * definition that are defined by the system's module system. It also contains
+ * the default module system. It contains methods which constructs module
+ * definition that are defined by the default module system. It also contains
* methods that constructs the local repository and URL repository. In
* addition, it contains methods for setting or getting the system's visibility
* policy and import override policy.
@@ -82,24 +82,24 @@ public class Modules {
}
/**
- * Constructs and initializes a new repository instance that loads
+ * Constructs and initializes a new {@code Repository} instance that loads
* module definitions from a directory on the file system.
* <p>
* If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with
- * <code>ModuleSystemPermission("createRepository")</code> permission to
+ * manager's {@code checkPermission} method with
+ * {@code ModuleSystemPermission("createRepository")} permission to
* ensure it's ok to create a repository.
*
* @param parent the parent repository for delegation.
* @param name the repository name.
* @param source the directory on the file system.
- * @return a new repository instance.
- * @throws SecurityException if a security manager exists and
- * its <tt>checkPermission</tt> method denies access
- * to create a new instance of repository.
- * @throws IOException if the repository cannot be constructed and
- * initialized.
- * @throws IllegalArgumentException if a circularity is detected.
+ * @return a new {@coder Repository} instance.
+ * @throws SecurityException if a security manager exists and
+ * its {@code checkPermission} method denies access
+ * to create a new {@code Repository} instance.
+ * @throws IOException if the repository cannot be constructed and
+ * initialized.
+ * @throws IllegalArgumentException if circularity is detected.
*/
public static Repository newLocalRepository(Repository parent, String name, File source)
throws IOException {
@@ -107,49 +107,52 @@ public class Modules {
}
/**
- * Constructs and initializes a new repository instance that loads
- * module definitions from a directory on the file system.
- * <p>
- * If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with
- * <code>ModuleSystemPermission("createRepository")</code> permission to
+ * Constructs and initializes a new {@code Repository} instance that loads
+ * module definitions from a directory on the file system. Equivalent to:
+ * <pre>
+ * newLocalRepository(Repository.getSystemRepository(), name, source);
+ * </pre>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with
+ * {@code ModuleSystemPermission("createRepository")} permission to
* ensure it's ok to create a repository.
*
* @param name the repository name.
* @param source the directory on the file system.
- * @return a new repository instance.
- * @throws SecurityException if a security manager exists and
- * its <tt>checkPermission</tt> method denies access
- * to create a new instance of repository.
+ * @return a new {@code Repository} instance.
+ * @throws SecurityException if a security manager exists and
+ * its {@code checkPermission} method denies access
+ * to create a new repository instance.
* @throws IOException if the repository cannot be constructed and
* initialized.
*/
public static Repository newLocalRepository(String name, File source)
throws IOException {
- return new LocalRepository(name, source.toURI().toURL());
- }
-
- /**
- * Constructs a new repository instance that loads module definitions
- * from a directory on the file system, and initializes using information
- * from the given {@code config}.
- * <p>
- * If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with
- * <code>ModuleSystemPermission("createRepository")</code> permission to
+ return new LocalRepository(Repository.getSystemRepository(), name,
+ source.toURI().toURL());
+ }
+
+ /**
+ * Constructs a new {@code Repository} instance that loads module
+ * definitions from a directory on the file system, and initializes
+ * using information from the given {@code config}.
+ * <p>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with
+ * {@code ModuleSystemPermission("createRepository")} permission to
* ensure it's ok to create a repository.
*
* @param parent the parent repository for delegation.
* @param name the repository name.
* @param source the directory on the file system.
* @param config Map of configuration names to their values
- * @return a new repository instance.
- * @throws SecurityException if a security manager exists and
- * its <tt>checkPermission</tt> method denies access
- * to create a new instance of repository.
- * @throws IOException if the repository cannot be constructed and
- * initialized.
- * @throws IllegalArgumentException if a circularity is detected.
+ * @return a new {@code Repository} instance.
+ * @throws SecurityException if a security manager exists and
+ * its {@code checkPermission} method denies access
+ * to create a new repository instance.
+ * @throws IOException if the repository cannot be constructed and
+ * initialized.
+ * @throws IllegalArgumentException if circularity is detected.
*/
public static Repository newLocalRepository(Repository parent, String name,
File source, Map<String, String> config)
@@ -158,29 +161,32 @@ public class Modules {
}
/**
- * Constructs a new repository instance that loads module definitions
- * from a directory on the file system, and initializes using information
- * from the given {@code config}.
- * <p>
- * If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with
- * <code>ModuleSystemPermission("createRepository")</code> permission to
+ * Constructs a new {@code Repository} instance that loads module
+ * definitions from a directory on the file system, and initializes
+ * using information from the given {@code config}. Equivalent to:
+ * <pre>
+ * newLocalRepository(Repository.getSystemRepository(), name, source, config);
+ * </pre>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with
+ * {@code ModuleSystemPermission("createRepository")} permission to
* ensure it's ok to create a repository.
*
* @param name the repository name.
* @param source the directory on the file system.
* @param config Map of configuration names to their values
- * @return a new repository instance.
- * @throws SecurityException if a security manager exists and
- * its <tt>checkPermission</tt> method denies access
- * to create a new instance of repository.
+ * @return a new {@code Repository} instance.
+ * @throws SecurityException if a security manager exists and
+ * its {@code checkPermission} method denies access
+ * to create a new repository instance.
* @throws IOException if the repository cannot be constructed and
* initialized.
*/
public static Repository newLocalRepository(String name, File source,
Map<String, String> config)
throws IOException {
- return new LocalRepository(name, source.toURI().toURL(), config);
+ return new LocalRepository(Repository.getSystemRepository(), name,
+ source.toURI().toURL(), config);
}
/**
@@ -190,7 +196,7 @@ public class Modules {
* Information about the module definitions available from the
* codebase URL must be published in a repository metadata file. The
* contents of the file must follow the schema of the URL Repository
- * metadata for the Java Module System.
+ * metadata described in the Java Module System specification.
* <p><i>
* {codebase}/repository-metadata.xml
* <p></i>
@@ -206,8 +212,8 @@ public class Modules {
* path is not specified and the module definition has platform
* binding, the default path is "{name}/{version}/{platform}-{arch}".
* <p>
- * After the URL repository instance successfully downloads the
- * repository metadata file, the module file of each module definition
+ * After the repository instance successfully downloads the repository
+ * metadata file, the module file of each module definition
* (i.e. MODULE.METADATA file) in the repository is downloaded based on
* the information in the repository metadata file:
* <p><i>
@@ -218,10 +224,10 @@ public class Modules {
* repository metadata file matches the platform and the architecture
* of the system.
* <p>
- * Module definitions are available for searches after the URL
- * repository instance is initialized. If a module instance is
- * instantiated from a module definition that has no platform binding,
- * the module archive is downloaded by probing in the following order:
+ * Module definitions are available for searches after the repository
+ * instance is initialized. If a module instance is instantiated from a
+ * module definition that has no platform binding, the module archive is
+ * downloaded by probing in the following order:
* <p><i>
* {codebase}/{path}/{name}-{version}.jam.pack.gz<p>
* {codebase}/{path}/{name}-{version}.jam
@@ -238,21 +244,21 @@ public class Modules {
* they are compared bit-wise against each other after the module
* archive is downloaded.
* <p>
- * If a security manager is present, this method calls the
- * security manager's <code>checkPermission</code> method with
- * a <code>ModuleSystemPermission("createRepository")</code>
- * permission to ensure it's ok to create a repository.
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("createRepository")} permission to ensure
+ * it's ok to create a repository.
*
* @param parent the parent repository for delegation.
* @param name the repository name.
* @param codebase the source location.
- * @return a new repository instance.
- * @throws SecurityException if a security manager exists and
- * its <tt>checkPermission</tt> method denies access
- * to create a new instance of repository.
- * @throws IOException if the repository cannot be constructed and
- * initialized.
- * @throws IllegalArgumentException if a circularity is detected.
+ * @return a new {@code Repository} instance.
+ * @throws SecurityException if a security manager exists and
+ * its {@code checkPermission} method denies access
+ * to create a new repository instance.
+ * @throws IOException if the repository cannot be constructed and
+ * initialized.
+ * @throws IllegalArgumentException if circularity is detected.
*/
public static Repository newURLRepository(Repository parent, String name, URL codebase)
throws IOException {
@@ -260,26 +266,28 @@ public class Modules {
}
/**
- * Constructs and initializes a new repository instance that loads
- * module definitions from a codebase URL.
- * <p>
- * If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with
- * <code>ModuleSystemPermission("createRepository")</code> permission to
+ * Constructs and initializes a new {@code Repository} instance that loads
+ * module definitions from a codebase URL. Equivalent to:
+ * <pre>
+ * newURLRepository(Repository.getSystemRepository(), name, codebase);
+ * </pre>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with
+ * {@code ModuleSystemPermission("createRepository")} permission to
* ensure it's ok to create a repository.
*
* @param name the repository name.
* @param codebase the source location.
- * @return a new repository instance.
+ * @return a new {@code Repository} instance.
* @throws SecurityException if a security manager exists and its
- * <tt>checkPermission</tt> method denies access to create a new
- * instance of repository.
+ * {@code checkPermission} method denies access to create a new
+ * repository instance.
* @throws IOException if the repository cannot be constructed and
* initialized.
*/
public static Repository newURLRepository(String name, URL codebase)
throws IOException {
- return new URLRepository(name, codebase);
+ return new URLRepository(Repository.getSystemRepository(), name, codebase);
}
/**
@@ -288,8 +296,8 @@ public class Modules {
* given {@code config}.
* <p>
* If a security manager is present, this method calls the
- * security manager's <code>checkPermission</code> method with
- * a <code>ModuleSystemPermission("createRepository")</code>
+ * security manager's {@code checkPermission} method with
+ * a {@code ModuleSystemPermission("createRepository")}
* permission to ensure it's ok to create a repository.
*
* @param parent the parent repository for delegation.
@@ -298,7 +306,7 @@ public class Modules {
* @param config Map of configuration names to their values
* @return a new repository instance.
* @throws SecurityException if a security manager exists and
- * its <tt>checkPermission</tt> method denies access
+ * its {@code checkPermission} method denies access
* to create a new instance of repository.
* @throws IOException if the repository cannot be constructed and
* initialized.
@@ -313,11 +321,13 @@ public class Modules {
/**
* Constructs a new repository instance that loads module definitions
* from a codebase URL, and initializes using information from the
- * given {@code config}.
- * <p>
+ * given {@code config}. Equivalent to:
+ * <pre>
+ * newURLRepository(Repository.getSystemRepository(), name, codebase, config);
+ * </pre>
* If a security manager is present, this method calls the
- * security manager's <code>checkPermission</code> method with
- * a <code>ModuleSystemPermission("createRepository")</code>
+ * security manager's {@code checkPermission} method with
+ * a {@code ModuleSystemPermission("createRepository")}
* permission to ensure it's ok to create a repository.
*
* @param name the repository name.
@@ -325,7 +335,7 @@ public class Modules {
* @param config Map of configuration names to their values
* @return a new repository instance.
* @throws SecurityException if a security manager exists and
- * its <tt>checkPermission</tt> method denies access
+ * its {@code checkPermission} method denies access
* to create a new instance of repository.
* @throws IOException if the repository cannot be constructed and
* initialized.
@@ -333,14 +343,14 @@ public class Modules {
public static Repository newURLRepository(String name, URL codebase,
Map<String, String> config)
throws IOException {
- return new URLRepository(name, codebase, config);
+ return new URLRepository(Repository.getSystemRepository(), name, codebase, config);
}
/**
* Returns the system's import override policy for module definitions.
* <p>
* The default class of the override policy can be changed using the
- * <code>java.module.import.override.policy.classname</code> system property.
+ * {@code java.module.import.override.policy.classname} system property.
*
* @return the system's default import override policy for module definitions.
*/
@@ -391,15 +401,15 @@ public class Modules {
/**
* Set the system's import override policy for module definitions.
* <p>
- * If a security manager is present, this method calls the
- * security manager's <code>checkPermission</code> method with
- * a <code>ModuleSystemPermission("setImportOverridePolicy")</code>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("setImportOverridePolicy")}
* permission to ensure it's ok to set the system's default import
* override policy..
*
* @param policy the import override policy for module definitions.
* @throws SecurityException if a security manager exists and its
- * <tt>checkPermission</tt> method denies access to set the
+ * {@code checkPermission} method denies access to set the
* system's default import override policy.
*/
public synchronized static void setImportOverridePolicy(ImportOverridePolicy policy) {
@@ -415,10 +425,10 @@ public class Modules {
/**
* Returns the system's default visibility policy for module definitions
- * in the repository of the module system.
+ * in the repositories..
* <p>
* The default class of the visibility policy can be overridden using the
- * <code>java.module.visibility.policy.classname</code> system property.
+ * {@code java.module.visibility.policy.classname} system property.
*
* @return the system's default visibility policy for module definitions.
*/
@@ -468,24 +478,26 @@ public class Modules {
/**
* Returns a new {@code ModuleDefinition} for modules based on the Java
- * Module System format.
- *
- * <p>This method will typically called by repository implementations
+ * Module System's module metadata file format described in the Java
+ * Module System specification.
+ *
+ * <p>This method will typically be called by repository implementations
* and not by applications.
*
* @param metadata the contents of the {@code MODULE-INF/METADATA.MODULE}
* file
- * @param content the ModuleDefinitionContent to be used to access the
+ * @param content the {@code ModuleContent} to be used to access the
* contents of the module archive
- * @param repository the repository in which the module archive is stored
- * @param moduleReleasable the module instance instantiated from this module
- * definition is releasable from the module system
+ * @param repository the {@code Repository} in which the module archive is
+ * stored
+ * @param moduleReleasable the module instance instantiated from this
+ * {@code ModuleDefinition} is releasable from its module system
* @throws ModuleFormatException if the contents of {@code metadata}
- * are not well formed.
- * @return a new {@code ModuleDefinition}
+ * are not recognized or well formed.
+ * @return a new {@code ModuleDefinition}.
*/
public static ModuleDefinition newJamModuleDefinition(byte[] metadata,
- ModuleDefinitionContent content, Repository repository, boolean moduleReleasable)
+ ModuleContent content, Repository repository, boolean moduleReleasable)
throws ModuleFormatException {
if (metadata == null) {
throw new NullPointerException("metadata must not be null.");
@@ -501,26 +513,28 @@ public class Modules {
}
/**
- * Returns a new ModuleDefinition for modules based on the
- * Java Module System format.
- *
- * <p>This method will typically called by repository implementations
+ * Returns a new {@code ModuleDefinition} for modules based on the Java
+ * Module System's module metadata file format described in the Java
+ * Module System specification.
+ *
+ * <p>This method will typically be called by repository implementations
* and not by applications. It is useful in case the metadata has not
* yet been retrieved but the module name and version are available.
*
- * @param name the name of the module definition
- * @param version the version of the module definition
+ * @param name the name of the {@code ModuleDefinition}
+ * @param version the version of the {@code ModuleDefinition}
* @param metadataHandle a Callable from which the contents of the
* {@code MODULE-INF/METADATA.MODULE} file can be retrieved
- * @param content the ModuleDefinitionContent to be used to access the
+ * @param content the {@code ModuleContent} to be used to access the
* contents of the module archive
- * @param repository the repository in which the module archive is stored
- * @param moduleReleasable the module instance instantiated from this module
- * definition is releasable from the module system
- * @return a new ModuleDefinition
+ * @param repository the {@code Repository} in which the module archive is
+ * stored
+ * @param moduleReleasable the module instance instantiated from this
+ * {@code ModuleDefinition} is releasable from the module system
+ * @return a new {@code ModuleDefinition}.
*/
public static ModuleDefinition newJamModuleDefinition(String name, Version version,
- Callable<byte[]> metadataHandle, ModuleDefinitionContent content,
+ Callable<byte[]> metadataHandle, ModuleContent content,
Repository repository, boolean moduleReleasable) {
if (name == null) {
throw new NullPointerException("name must not be null.");
--- a/src/share/classes/java/module/Query.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/Query.java Wed Apr 16 02:49:49 2008 -0700
@@ -37,12 +37,12 @@ import java.util.Set;
/**
* This class represents a query that determines whether or not a particular
* module definition matches some criteria. The static methods provided return
- * query that may be used in matching <code>ModuleDefinition</code>.
+ * query that may be used in matching {@code ModuleDefinition}.
* Composition of calls can construct arbitrary nestings of constraints, as
* the following example illustrates:</p>
* <pre>
- * Query query = Query.and(Query.name("com.wombat.webservice"),
- * Query.versionRange("2.0.0+"));
+ * Query query = Query.and(Query.module("com.wombat.webservice", "2.0.0+"),
+ * Query.annotation(ServiceProviders.class));
* </pre>
*
* <p> Unless otherwise specified, passing a <tt>null</tt> argument to any
@@ -79,7 +79,10 @@ public abstract class Query implements S
public boolean match(ModuleDefinition moduleDef) {
return true;
}
- public Set<String> getIndexableNames() {
+ public Set<String> getIndexableModuleNames() {
+ return null;
+ }
+ public Set<String> getIndexablePackageNames() {
return null;
}
public boolean equals(Object obj) {
@@ -101,7 +104,10 @@ public abstract class Query implements S
public boolean match(ModuleDefinition moduleDef) {
return false;
}
- public Set<String> getIndexableNames() {
+ public Set<String> getIndexableModuleNames() {
+ return Collections.emptySet();
+ }
+ public Set<String> getIndexablePackageNames() {
return Collections.emptySet();
}
public boolean equals(Object obj) {
@@ -118,74 +124,118 @@ public abstract class Query implements S
/**
* @serial include
*/
- private static class NameQuery extends Query {
+ private static class ModuleQuery extends Query {
private static final long serialVersionUID = 6249315499292409988L;
- private String name;
- NameQuery(String name) {
+ private transient String name;
+ private transient VersionConstraint constraint;
+ ModuleQuery(String name, VersionConstraint constraint) {
this.name = name;
- }
- public Set<String> getIndexableNames() {
+ this.constraint = constraint;
+ }
+ private void writeObject(ObjectOutputStream s) throws IOException {
+ s.defaultWriteObject();
+ s.writeUTF(name);
+ s.writeUTF(constraint.toString());
+ }
+ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
+ s.defaultReadObject();
+ name = s.readUTF();
+ constraint = VersionConstraint.valueOf(s.readUTF());
+ }
+ public Set<String> getIndexableModuleNames() {
Set<String> indexableNames = new HashSet<String>();
indexableNames.add(name);
return Collections.unmodifiableSet(indexableNames);
}
+ public Set<String> getIndexablePackageNames() {
+ return null;
+ }
public boolean match(ModuleDefinition moduleDef) {
- return moduleDef.getName().equals(name);
+ return moduleDef.getName().equals(name)
+ && constraint.contains(moduleDef.getVersion());
}
public boolean equals(Object obj) {
- if (!(obj instanceof NameQuery))
- return false;
- NameQuery query = (NameQuery) obj;
- return this.name.equals(query.name);
- }
- public int hashCode() {
- return 37 * 17 + name.hashCode();
- }
- public String toString() {
- return "name=" + name;
+ if (!(obj instanceof ModuleQuery))
+ return false;
+ ModuleQuery query = (ModuleQuery) obj;
+ return this.name.equals(query.name)
+ && this.constraint.equals(query.constraint);
+ }
+ public int hashCode() {
+ int result = 17;
+ result = 37 * result + name.hashCode();
+ result = 37 * result + constraint.hashCode();
+ return result;
+ }
+ public String toString() {
+ return "module-name=" + name + ", version=" + constraint;
}
public String getName() {
return name;
}
- }
-
- /**
- * @serial include
- */
- private static class VersionConstraintQuery extends Query {
+ public VersionConstraint getVersionConstraint() {
+ return constraint;
+ }
+ }
+
+ /**
+ * @serial include
+ */
+ private static class ExportedPackageQuery extends Query {
private static final long serialVersionUID = -1700827011713291084L;
- private transient VersionConstraint versionConstraint;
- VersionConstraintQuery(VersionConstraint versionConstraint) {
- this.versionConstraint = versionConstraint;
- }
- public boolean match(ModuleDefinition moduleDef) {
- return versionConstraint.contains(moduleDef.getVersion());
- }
- public Set<String> getIndexableNames() {
- return null;
+ private transient String name;
+ private transient VersionConstraint constraint;
+ ExportedPackageQuery(String name, VersionConstraint constraint) {
+ this.name = name;
+ this.constraint = constraint;
}
private void writeObject(ObjectOutputStream s) throws IOException {
s.defaultWriteObject();
- s.writeUTF(versionConstraint.toString());
+ s.writeUTF(name);
+ s.writeUTF(constraint.toString());
}
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
s.defaultReadObject();
- versionConstraint = VersionConstraint.valueOf(s.readUTF());
+ name = s.readUTF();
+ constraint = VersionConstraint.valueOf(s.readUTF());
+ }
+ public Set<String> getIndexableModuleNames() {
+ return null;
+ }
+ public Set<String> getIndexablePackageNames() {
+ Set<String> indexableNames = new HashSet<String>();
+ indexableNames.add(name);
+ return Collections.unmodifiableSet(indexableNames);
+ }
+ public boolean match(ModuleDefinition moduleDef) {
+ for (PackageDefinition packageDef : moduleDef.getExportedPackageDefinitions()) {
+ if (packageDef.getName().equals(name)
+ && constraint.contains(packageDef.getVersion()))
+ return true;
+ }
+ return false;
}
public boolean equals(Object obj) {
- if (!(obj instanceof VersionConstraintQuery))
- return false;
- VersionConstraintQuery query = (VersionConstraintQuery) obj;
- return this.versionConstraint.equals(query.versionConstraint);
- }
- public int hashCode() {
- return 37 * 17 + versionConstraint.hashCode();
- }
- public String toString() {
- return "version-constraint=" + versionConstraint;
+ if (!(obj instanceof ExportedPackageQuery))
+ return false;
+ ExportedPackageQuery query = (ExportedPackageQuery) obj;
+ return this.name.equals(query.name)
+ && this.constraint.equals(query.constraint);
+ }
+ public int hashCode() {
+ int result = 17;
+ result = 37 * result + name.hashCode();
+ result = 37 * result + constraint.hashCode();
+ return result;
+ }
+ public String toString() {
+ return "exported-package-name=" + name + ", version=" + constraint;
+ }
+ public String getName() {
+ return name;
}
public VersionConstraint getVersionConstraint() {
- return versionConstraint;
+ return constraint;
}
}
@@ -216,7 +266,10 @@ public abstract class Query implements S
else
return (v.equals(value));
}
- public Set<String> getIndexableNames() {
+ public Set<String> getIndexableModuleNames() {
+ return null;
+ }
+ public Set<String> getIndexablePackageNames() {
return null;
}
public boolean equals(Object obj) {
@@ -259,7 +312,10 @@ public abstract class Query implements S
// No match if annotation is not present.
return (annotation != null);
}
- public Set<String> getIndexableNames() {
+ public Set<String> getIndexableModuleNames() {
+ return null;
+ }
+ public Set<String> getIndexablePackageNames() {
return null;
}
public boolean equals(Object obj) {
@@ -290,7 +346,10 @@ public abstract class Query implements S
public boolean match(ModuleDefinition moduleDef) {
return !query.match(moduleDef);
}
- public Set<String> getIndexableNames() {
+ public Set<String> getIndexableModuleNames() {
+ return null;
+ }
+ public Set<String> getIndexablePackageNames() {
return null;
}
public boolean equals(Object obj) {
@@ -324,9 +383,9 @@ public abstract class Query implements S
public boolean match(ModuleDefinition moduleDef) {
return query1.match(moduleDef) && query2.match(moduleDef);
}
- public Set<String> getIndexableNames() {
- Set<String> indexableNames1 = query1.getIndexableNames();
- Set<String> indexableNames2 = query2.getIndexableNames();
+ public Set<String> getIndexableModuleNames() {
+ Set<String> indexableNames1 = query1.getIndexableModuleNames();
+ Set<String> indexableNames2 = query2.getIndexableModuleNames();
if (indexableNames1 == null) {
return indexableNames2;
} else if (indexableNames2 == null) {
@@ -337,6 +396,19 @@ public abstract class Query implements S
return Collections.unmodifiableSet(result);
}
}
+ public Set<String> getIndexablePackageNames() {
+ Set<String> indexableNames1 = query1.getIndexablePackageNames();
+ Set<String> indexableNames2 = query2.getIndexablePackageNames();
+ if (indexableNames1 == null) {
+ return indexableNames2;
+ } else if (indexableNames2 == null) {
+ return indexableNames1;
+ } else {
+ Set<String> result = new HashSet<String>(indexableNames1);
+ result.retainAll(indexableNames2);
+ return Collections.unmodifiableSet(result);
+ }
+ }
public boolean equals(Object obj) {
if (!(obj instanceof AndQuery))
return false;
@@ -373,9 +445,9 @@ public abstract class Query implements S
public boolean match(ModuleDefinition moduleDef) {
return query1.match(moduleDef) || query2.match(moduleDef);
}
- public Set<String> getIndexableNames() {
- Set<String> indexableNames1 = query1.getIndexableNames();
- Set<String> indexableNames2 = query2.getIndexableNames();
+ public Set<String> getIndexableModuleNames() {
+ Set<String> indexableNames1 = query1.getIndexableModuleNames();
+ Set<String> indexableNames2 = query2.getIndexableModuleNames();
if (indexableNames1 == null) {
return indexableNames2;
} else if (indexableNames2 == null) {
@@ -386,6 +458,19 @@ public abstract class Query implements S
return Collections.unmodifiableSet(result);
}
}
+ public Set<String> getIndexablePackageNames() {
+ Set<String> indexableNames1 = query1.getIndexablePackageNames();
+ Set<String> indexableNames2 = query2.getIndexablePackageNames();
+ if (indexableNames1 == null) {
+ return indexableNames2;
+ } else if (indexableNames2 == null) {
+ return indexableNames1;
+ } else {
+ Set<String> result = new HashSet<String>(indexableNames1);
+ result.addAll(indexableNames2);
+ return Collections.unmodifiableSet(result);
+ }
+ }
public boolean equals(Object obj) {
if (!(obj instanceof OrQuery))
return false;
@@ -412,7 +497,7 @@ public abstract class Query implements S
* Returns a {@code Query} that inverts the specified query.
*
* @param query the specified query.
- * @return the <code>Query</code> object.
+ * @return the {@code Query} object.
*/
public static Query not(Query query) {
if (query == null)
@@ -429,7 +514,7 @@ public abstract class Query implements S
*
* @param query1 A query.
* @param query2 Another query.
- * @return the <code>Query</code> object.
+ * @return the {@code Query} object.
*/
public static Query and(Query query1, Query query2) {
if (query1 == null)
@@ -457,7 +542,7 @@ public abstract class Query implements S
*
* @param query1 A query.
* @param query2 Another query.
- * @return the <code>Query</code> object.
+ * @return the {@code Query} object.
*/
public static Query or(Query query1, Query query2) {
if (query1 == null)
@@ -481,53 +566,36 @@ public abstract class Query implements S
}
/**
- * Returns a {@code Query} that requires the version of a module definition
- * to be contained within any of the ranges known to the specified
- * version constraint. The string must not contain any leading or trailing
- * whitespace.
- *
- * @param source the string to be parsed.
- * @return the <code>Query</code> object.
- * @throws IllegalArgumentException if the string does not follow
- * the version constraint format.
- */
- public static Query version(String source) {
- if (source == null)
- throw new NullPointerException("source must not be null.");
-
- return version(VersionConstraint.valueOf(source));
- }
-
- /**
- * Returns a {@code Query} that requires the version of a module definition
- * to be contained within any of the ranges known to the specified
- * version constraint.
- *
- * @param versionConstraint the <code>VersionConstraint</code> object.
- * @return the <code>Query</code> object.
- */
- public static Query version(VersionConstraint versionConstraint) {
- if (versionConstraint == null)
- throw new NullPointerException("version constraint must not be null.");
-
- if (versionConstraint.equals(VersionConstraint.DEFAULT))
- return MATCH_ALL;
- else
- return new VersionConstraintQuery(versionConstraint);
- }
-
- /**
* Returns a {@code Query} that requires the name of a module definition equals
* to the specified name.
*
* @param name the name of the module definition.
- * @return the <code>Query</code> object.
- */
- public static Query name(String name) {
+ * @return the {@code Query} object.
+ */
+ public static Query module(String name) {
if (name == null)
throw new NullPointerException("name must not be null.");
- return new NameQuery(name);
+ return new ModuleQuery(name, VersionConstraint.DEFAULT);
+ }
+
+ /**
+ * Returns a {@code Query} that requires the name of a module definition
+ * equals to the specified name and that the version of a module definition
+ * to be contained within any of the ranges known to the specified version
+ * constraint.
+ *
+ * @param name the name of the module definition.
+ * @param constraint the {@code VersionConstraint} object.
+ * @return the {@code Query} object.
+ */
+ public static Query module(String name, VersionConstraint constraint) {
+ if (name == null)
+ throw new NullPointerException("name must not be null.");
+ if (constraint == null)
+ throw new NullPointerException("version constraint must not be null.");
+
+ return new ModuleQuery(name, constraint);
}
/**
@@ -535,7 +603,7 @@ public abstract class Query implements S
* exists.
*
* @param name the name of the module attribute.
- * @return the <code>Query</code> object.
+ * @return the {@code Query} object.
*/
public static Query attribute(String name) {
if (name == null)
@@ -550,7 +618,7 @@ public abstract class Query implements S
*
* @param name the name of the module attribute.
* @param value the value of the module attribute.
- * @return the <code>Query</code> object.
+ * @return the {@code Query} object.
*/
public static Query attribute(String name, String value) {
if (name == null)
@@ -566,7 +634,7 @@ public abstract class Query implements S
* for the specified type.
*
* @param annotationClass the Class object corresponding to the annotation type.
- * @return the <code>Query</code> object.
+ * @return the {@code Query} object.
*/
public static Query annotation(Class annotationClass) {
if (annotationClass == null)
@@ -576,11 +644,44 @@ public abstract class Query implements S
}
/**
+ * Returns a {@code Query} that requires a module definition to have an
+ * exported package definition of the specified name.
+ *
+ * @param name the name of the package definition.
+ * @return the {@code Query} object.
+ */
+ public static Query exportedPackage(String name) {
+ if (name == null)
+ throw new NullPointerException("name must not be null.");
+
+ return new ExportedPackageQuery(name, VersionConstraint.DEFAULT);
+ }
+
+ /**
+ * Returns a {@code Query} that requires a module definition to have an
+ * exported package definition of the specified name and that the version
+ * of the package definition to be contained within any of the ranges known
+ * to the specified version constraint.
+ *
+ * @param name the name of the package definition
+ * @param constraint the {@code VersionConstraint} object.
+ * @return the {@code Query} object.
+ */
+ public static Query exportedPackage(String name, VersionConstraint constraint) {
+ if (name == null)
+ throw new NullPointerException("name must not be null.");
+ if (constraint == null)
+ throw new NullPointerException("version constraint must not be null.");
+
+ return new ExportedPackageQuery(name, constraint);
+ }
+
+ /**
* Determine if the specified module definition matches this query.
*
- * @param target the <code>ModuleDefinition</code> to be matched.
- * @return true if the <code>ModuleDefinition</code> matches this
- * query.
+ * @param target the {@code ModuleDefinition} to be matched.
+ * @return true if the {@code ModuleDefinition} matches this
+ * query; otherwise returns false.
*/
public abstract boolean match(ModuleDefinition target);
@@ -590,11 +691,26 @@ public abstract class Query implements S
*
* This method is intended to be used by the repository implementation as
* an optimization to determine a set of module definitions that matches
- * this query solely based on the requirement on the module names.
+ * this query, solely based on the requirement on the module names.
*
* @return an unmodifiable set of indexable module names if it exists;
* returns null otherwise. If the set is empty, no module
* definition would match this query.
*/
- public abstract Set<String> getIndexableNames();
+ public abstract Set<String> getIndexableModuleNames();
+
+ /**
+ * Returns an unmodifiable set of the indexable names of the package
+ * definitions that is represented by this query.
+ *
+ * This method is intended to be used by the repository implementation as
+ * an optimization to determine a set of module definitions that have
+ * exported package definitions which match this query, solely based on
+ * the requirement on the package names.
+ *
+ * @return an unmodifiable set of indexable package names if it exists;
+ * returns null otherwise. If the set is empty, no module
+ * definition would match this query.
+ */
+ public abstract Set<String> getIndexablePackageNames();
}
--- a/src/share/classes/java/module/Repository.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/Repository.java Wed Apr 16 02:49:49 2008 -0700
@@ -34,12 +34,13 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicLong;
import sun.module.bootstrap.BootstrapRepository;
import sun.module.repository.RepositoryConfig;
/**
- * This class represents the repository in the module system.
+ * This class represents a repository. A repository is a mechanism for storing,
+ * discovering, and retrieving module definitions that can be used by a module
+ * system.
*
* <p> Unless otherwise specified, passing a <tt>null</tt> argument to any
* method in this class will cause a {@link NullPointerException} to be thrown.
@@ -78,26 +79,22 @@ public abstract class Repository {
/** Shuts down the repository upon JVM exit; see {@link #shutdownOnExit}. */
private Thread shutdownThread;
- /** Counter for generating Id for repository instances. */
- private static final AtomicLong idCounter = new AtomicLong();
-
- /** Id for this repository instance. */
- private final long id = idCounter.incrementAndGet();
-
- /**
- * Creates a repository instance.
- * <p>
- * If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with
- * <code>ModuleSystemPermission("createRepository")</code> permission to
- * ensure it's ok to create a repository.
+ /**
+ * Creates a {@code Repository} instance.
+ * <p>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with
+ * {@code ModuleSystemPermission("createRepository")} permission to ensure
+ * it's ok to create a repository.
*
* @param parent the parent repository for delegation.
* @param name the repository name.
* @param source the source location.
- * @throws SecurityException if a security manager exists and its
- * <tt>checkPermission</tt> method denies access to create a new
- * instance of repository.
+ * @param system the module system the module definitions in the repository
+ * associated with.
+ * @throws SecurityException if a security manager exists and its
+ * {@code checkPermission} method denies access to create a new
+ * repository instance.
* @throws IllegalArgumentException if a circularity is detected.
*/
protected Repository(Repository parent, String name, URL source, ModuleSystem system) {
@@ -137,17 +134,19 @@ public abstract class Repository {
}
/**
- * Creates a repository instance.
- * <p>
- * If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with
- * <code>ModuleSystemPermission("createRepository")</code> permission to
- * ensure it's ok to create a repository.
+ * Creates a {@code Repository} instance.
+ * <p>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with
+ * {@code ModuleSystemPermission("createRepository")} permission to ensure
+ * it's ok to create a repository.
*
* @param name the repository name.
* @param source the source location.
- * @throws SecurityException if a security manager exists and its
- * <tt>checkPermission</tt> method denies access to create a new
+ * @param system the module system the module definitions in the repository
+ * associated with.
+ * @throws SecurityException if a security manager exists and its
+ * {@code checkPermission} method denies access to create a new
* instance of repository.
* @throws IllegalArgumentException if a circularity is detected.
*/
@@ -156,19 +155,7 @@ public abstract class Repository {
}
/**
- * Returns a long value that represents the unique identifier assigned to
- * this repository instance. The identifier is assigned by the JVM and is
- * JVM implementation dependent.
- *
- * @return a long value that represents the unique identifier assigned to
- * this repository instance.
- */
- public final long getId() {
- return id;
- }
-
- /**
- * Returns the name of this repository.
+ * Returns the name of this {@code Repository}.
*
* @return the name.
*/
@@ -177,7 +164,7 @@ public abstract class Repository {
}
/**
- * Returns the source location of this repository.
+ * Returns the source location of this {@code Repository}.
*
* @return the source location.
*/
@@ -186,82 +173,83 @@ public abstract class Repository {
}
/**
- * Returns the parent repository for delegation. If this
- * is the bootstrap repository, its parent is null.
- *
- * @return the parent <code>Repository.</code>.
+ * Returns the parent repository for delegation. If this is the bootstrap
+ * repository, its parent is null.
+ *
+ * @return the parent {@code Repository}.
*/
public final Repository getParent() {
return parent;
}
/**
- * Returns this Repository's {@code ModuleSystem}.
- *
- * @return this repository's {@code ModuleSystem}
+ * Returns the {@code ModuleSystem} associated with the module definitions
+ * in this {@code Repository}.
+ *
+ * @return the {@code ModuleSystem} associated with the module definitions
+ * in this {@code Repository}.
*/
public final ModuleSystem getModuleSystem() {
return system;
}
/**
- * Returns the bootstrap repository for delegation. This
- * the repository provided by the Java Runtime.
+ * Returns the bootstrap repository. This is the repository provided by
+ * the Java Runtime.
*/
public static Repository getBootstrapRepository() {
return BootstrapRepository.getInstance();
}
/**
- * Returns the system repository for delegation. This is
- * the default delegation parent for new Repository
- * instances.
+ * Returns the system repository. This is the default delegation parent
+ * for new {@code Repository} instances.
*/
public static Repository getSystemRepository() {
return RepositoryConfig.getSystemRepository();
}
/**
- * Initializes the repository using the default configuration.
+ * Initializes this {@code Repository}.
*
* @throws IOException if an I/O error occurs.
- * @throws IllegalStateException if the repository instance has been
+ * @throws IllegalStateException if this {@code Repository} has been
* initialized or has been shutdown.
*/
public abstract void initialize() throws IOException;
/**
- * Shutdown the repository.
- *
- * If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with a
- * <code>ModuleSystemPermission("shutdownRepository")</code> permission
- * to ensure it's ok to shutdown a repository.
- *
- * @throws SecurityException if a security manager exists and its
- * <tt>checkPermission</tt> method denies access to shutdown the
- * repository.
+ * Shutdown this {@code Repository}.
+ * <p>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("shutdownRepository")} permission to
+ * ensure it's ok to shutdown this {@code Repository}.
+ *
+ * @throws SecurityException if a security manager exists and its
+ * {@code checkPermission} method denies access to shutdown this
+ * {@code Repository}.
* @throws IOException if an I/O error occurs.
- * @throws IllegalStateException if the repository instance has not been
+ * @throws IllegalStateException if this {@code Repository} has not been
* initialized or has been shutdown.
*/
public abstract void shutdown() throws IOException;
/**
- * Enable or disable that the repository is shutdown when the module
- * system terminates. Shutdown will be attempted only during the normal
- * termination of the virtual machine, as defined by the Java Language
- * Specification. By default, shutdown on exit is disabled.
- *
- * If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with a
- * <code>ModuleSystemPermission("shutdownRepository")</code> permission
- * to ensure it's ok to shutdown a repository.
+ * Enable or disable that this {@code Repository} is shutdown when the
+ * module system terminates. Shutdown will be attempted only during the
+ * normal termination of the virtual machine, as defined by the Java
+ * Language Specification. By default, shutdown on exit is disabled.
+ * <p>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("shutdownRepository")} permission
+ * to ensure it's ok to shutdown this {@code Repository}.
*
* @param value indicating enabling or disabling of shutdown.
* @throws SecurityException if a security manager exists and its
- * <tt>checkPermission</tt> method denies access to shutdown the
- * repository.
+ * {@code checkPermission} method denies access to shutdown this
+ * {@code Repository}.
*/
public final synchronized void shutdownOnExit(final boolean value) {
SecurityManager sm = System.getSecurityManager();
@@ -302,26 +290,28 @@ public abstract class Repository {
}
/**
- * Returns whether or not the repository instance is active.
- * <p>
- * A repository instance is active if it has been initialized but has not
- * been shutdown.
- *
- * @return true if this repository instance is active.
+ * Returns whether or not this {@code Repository} is active. A repository
+ * instance is active if it has been initialized but has not been shutdown.
+ *
+ * @return true if this repository instance is active; otherwise, returns
+ * false.
*/
public abstract boolean isActive();
/**
- * Returns whether or not this repository is read-only.
- *
- * @return true if this repository is read-only.
+ * Returns whether or not this {@code Repository} is read-only.
+ *
+ * @return true if this {@code Repository} is read-only; otherwise, returns
+ * false.
*/
public abstract boolean isReadOnly();
/**
- * Returns whether or not this repository supports reloading.
- *
- * @return true if this repository supports reloading.
+ * Returns whether or not this {@code Repository} supports reload
+ * of module definitions.
+ *
+ * @return true if this {@code Repository} supports reload; otherwise,
+ * returns false.
* @see #reload()
*/
public abstract boolean supportsReload();
@@ -331,17 +321,12 @@ public abstract class Repository {
* <pre>
* find(moduleName, VersionConstraint.DEFAULT);
* </pre>
- *
- * If this repository instance has not been initialized when this method
- * is called, it will be initialized automatically by calling the
- * {@link #initialize} method with no argument.
- *
* @param name the module definition's name.
* @return the module definition or null if not found. If more than one
* module definition matches the specified name, the highest
* version is returned.
- * @throws IllegalStateException if the repository instance has been
- * shutdown.
+ * @throws IllegalStateException if this {@code Repository} has not been
+ * initialized or if it has been shutdown.
*/
public final ModuleDefinition find(String name) {
assertActive();
@@ -350,22 +335,18 @@ public abstract class Repository {
/**
* Find a module definition.
- *
- * If this repository instance has not been initialized when this method
- * is called, it will be initialized automatically by calling the
- * {@link #initialize} method with no argument.
*
* @param name the module definition's name.
* @param versionConstraint the version constraint.
* @return the module definition or null if not found. If more than one
* module definition matches the specified name and version
* constraint, the highest version is returned.
- * @throws IllegalStateException if the repository instance has been
- * shutdown.
+ * @throws IllegalStateException if this {@code Repository} has not been
+ * initialized or if it has been shutdown.
*/
public final ModuleDefinition find(String name, VersionConstraint versionConstraint) {
assertActive();
- List<ModuleDefinition> moduleDefs = find(Query.and(Query.name(name), Query.version(versionConstraint)));
+ List<ModuleDefinition> moduleDefs = find(Query.module(name, versionConstraint));
if (moduleDefs.isEmpty()) {
return null;
@@ -390,14 +371,9 @@ public abstract class Repository {
* <pre>
* find(Query.ANY);
* </pre>
- *
- * If this repository instance has not been initialized when this
- * method is called, it will be initialized automatically by
- * calling the {@link #initialize} method with no argument.
- *
- * @return the result list.
- * @throws IllegalStateException if the repository instance has been
- * shutdown.
+ * @return the list of matching module definitions.
+ * @throws IllegalStateException if this {@code Repository} has not been
+ * initialized or if it has been shutdown.
*/
public final List<ModuleDefinition> findAll() {
assertActive();
@@ -407,14 +383,10 @@ public abstract class Repository {
/**
* Find all matching module definitions that match the specified constraint.
*
- * If this repository instance has not been initialized when this
- * method is called, it will be initialized automatically by
- * calling the {@link #initialize} method with no argument.
- *
* @param constraint the constraint.
- * @return the result list.
- * @throws IllegalStateException if the repository instance has been
- * shutdown.
+ * @return the list of matching module definitions.
+ * @throws IllegalStateException if this {@code Repository} has not been
+ * initialized or if it has been shutdown.
*/
public final List<ModuleDefinition> find(Query constraint) {
assertActive();
@@ -466,108 +438,111 @@ public abstract class Repository {
}
/**
- * Find all matching module definitions in the repository. This method
- * should be overridden by repository implementations for finding
+ * Find all matching module definitions in this {@code Repository}. This
+ * method should be overridden by repository implementations for finding
* matching module definitions, and will be invoked by the
* {@link #find} method after checking the parent repository for the
* requested module definitions.
- * <p>
- * If this repository instance has not been initialized when this method
- * is called, it will be initialized automatically by calling the
- * {@link #initialize} method with no argument.
*
* @param constraint the constraint.
- * @return the collection of matching module definitions.
- * @throws IllegalStateException if the repository instance has not been
+ * @return the list of matching module definitions.
+ * @throws IllegalStateException if this {@code Repository} has not been
* initialized or has been shutdown.
*/
protected abstract List<ModuleDefinition> findModuleDefinitions(Query constraint);
/**
* Returns an unmodifiable list of the installed module archives'
- * information in the repository. The list will contain a snapshot of the
- * installed module archives in the repository at the time of the given
- * invocation of this method.
- * <p>
- * If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with a
- * <code>ModuleSystemPermission("listModuleArchive")</code> permission to
+ * information in this {@code Repository}. The list will contain a snapshot
+ * of the installed module archives in this {@code Repository} at the time
+ * of the given invocation of this method.
+ * <p>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("listModuleArchive")} permission to
* ensure it's ok to return the information of the installed module
- * archives in a repository.
+ * archives in this {@code Repository}.
*
* @return an unmodifiable list of the installed module archives'
* information.
* @throws SecurityException if a security manager exists and its
* <tt>checkPermission</tt> method denies access to return the
* information of the installed module archives.
- * @throws IllegalStateException if the repository instance has not been
+ * @throws IllegalStateException if this {@code Repository} has not been
* initialized or it has been shutdown.
*/
public abstract List<ModuleArchiveInfo> list();
/**
- * Install a module archive with the module definition into the repository.
- * <p>
- * If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with a
- * <code>ModuleSystemPermission("installModuleArchive")</code> permission
- * to ensure it's ok to install a module archive into a repository.
+ * Install a module archive with the module definition into this
+ * {@code Repository}.
+ * <p>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("installModuleArchive")} permission
+ * to ensure it's ok to install a module archive into this
+ * {@code Repository}.
*
* @param url the URL to the module archive.
- * @return the <code>ModuleArchiveInfo</code> object that represents the
+ * @return the {@code ModuleArchiveInfo} object that represents the
* installed module archive.
* @throws SecurityException if a security manager exists and its
- * <tt>checkPermission</tt> method denies access to install a
- * module archive in the repository.
- * @throws UnsupportedOperationException if the repository is read-only.
- * @throws IOException if an error occurs while installing the module archive.
+ * {@code checkPermission} method denies access to install a
+ * module archive in this {@code Repository}.
+ * @throws UnsupportedOperationException if {@code Repository} is
+ * read-only.
+ * @throws IOException if an error occurs while installing the module
+ * archive.
* @throws ModuleFormatException if the module archive format is not
* supported by this implementation.
* @throws IllegalStateException if a module definition with the same name,
- * version and platform binding is already installed, or if the
- * repository instance has not been initialized or it has been
+ * version and platform binding is already installed, or if this
+ * {@code Repository} has not been initialized or it has been
* shutdown.
*/
public abstract ModuleArchiveInfo install(URL url) throws IOException;
/**
- * Uninstall a module archive from the repository.
- * <p>
- * If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with a
- * <code>ModuleSystemPermission("uninstallModuleArchive")</code>
- * permission to ensure it's ok to uninstall a module archive from a
- * repository.
+ * Uninstall a module archive from this {@code Repository}.
+ * <p>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("uninstallModuleArchive")}
+ * permission to ensure it's ok to uninstall a module archive from this
+ * {@code Repository}.
*
* @param m the module archive to be uninstalled.
* @return true if the module archive is found and uninstalled, returns
* false otherwise.
* @throws SecurityException if a security manager exists and its
- * <tt>checkPermission</tt> method denies access to uninstall the
- * module archive in the repository.
- * @throws UnsupportedOperationException if the repository is read-only.
+ * {@code checkPermission} method denies access to uninstall the
+ * module archive in this {@code Repository}.
+ * @throws UnsupportedOperationException if this {@code Repository} is
+ * read-only.
* @throws IllegalStateException if the module definition in the specified
- * specified module archive is in use, or if the repository
- * instance has not been initialized or it has been shutdown.
+ * specified module archive is in use, or if this
+ * {@code Repository} has not been initialized or it has been
+ * shutdown.
* @throws IOException If an error occurs while uninstalling the module
* archive.
*/
public abstract boolean uninstall(ModuleArchiveInfo m) throws IOException;
/**
- * Reload the repository. The behavior of this method depends on the
- * implementation.
- * <p>
- * If a security manager is present, this method calls the security
- * manager's <code>checkPermission</code> method with a
- * <code>ModuleSystemPermission("reloadRepository")</code> permission
- * to ensure it's ok to reload module definitions in a repository.
- *
- * @throws SecurityException if a security manager exists and its
- * <tt>checkPermission</tt> method denies access to reload module
- * definitions in the repository.
- * @throws UnsupportedOperationException if the repository does not
- * support reload.
+ * Reload this {@code Repository}. The behavior of this method depends on
+ * the implementation.
+ * <p>
+ * If a security manager is present, this method calls the security
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("reloadRepository")} permission
+ * to ensure it's ok to reload module definitions in this
+ * {@code Repository}.
+ *
+ * @throws SecurityException if a security manager exists and its
+ * {@code checkPermission} method denies access to reload module
+ * definitions in this {@code Repository}.
+ * @throws UnsupportedOperationException if this {@code Repository}
+ * does not support reload.
* @throws IllegalStateException if a module definition is in use thus
* cannot be reloaded.
* @throws IOException If an error occurs while reloading the module
@@ -580,13 +555,13 @@ public abstract class Repository {
* the repositories.
* <p>
* If a security manager is present, this method calls the security
- * manager's checkPermission method with a
- * <code>ModuleSystemPermission("addRepositoryListener")</code> permission
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("addRepositoryListener")} permission
* to ensure it's ok to add a repository listener to the repositories.
*
* @param listener the repository listener
* @throws SecurityException if a security manager exists and its
- * <tt>checkPermission</tt> method denies access to add a
+ * {@code checkPermission} method denies access to add a
* repository listener to the repositories.
*/
public static final void addRepositoryListener(RepositoryListener listener) {
@@ -609,14 +584,14 @@ public abstract class Repository {
* repository events from the repositories.
* <p>
* If a security manager is present, this method calls the security
- * manager's checkPermission method with a
- * <code>ModuleSystemPermission("removeModuleSystemListener")</code>
+ * manager's {@code checkPermission} method with a
+ * {@code ModuleSystemPermission("removeModuleSystemListener")}
* permission to ensure it's ok to remove a repository listener from the
* repositories.
*
* @param listener the repository listener
* @throws SecurityException if a security manager exists and its
- * <tt>checkPermission</tt> method denies access to remove a
+ * {@code checkPermission} method denies access to remove a
* repository listener from the repositories.
*/
public static final void removeRepositoryListener(RepositoryListener listener) {
@@ -661,8 +636,8 @@ public abstract class Repository {
}
/**
- * Processes repository event occuring in this repository by dispatching
- * them to any registered RepositoryListener objects.
+ * Processes repository event occuring in this {@code Repository} by
+ * dispatching them to any registered {@code RepositoryListener} objects.
*
* @param event the repository event
*/
@@ -697,10 +672,12 @@ public abstract class Repository {
/**
* Compares the specified object with this {@code Repository} for equality.
* Returns {@code true} if and only if {@code obj} is the same object as
- * this object.
- *
- * @param obj the object to be compared for equality with this repository.
- * @return {@code true} if the specified object is equal to this repository
+ * this {@code Repository}.
+ *
+ * @param obj the object to be compared for equality with this
+ * {@code Repository}.
+ * @return {@code true} if the specified object is equal to this
+ * {@code Repository}
*/
@Override
public final boolean equals(Object obj) {
@@ -710,7 +687,7 @@ public abstract class Repository {
/**
* Returns a hash code for this {@code Repository}.
*
- * @return a hash code value for this object.
+ * @return a hash code value for this {@code Repository}.
*/
@Override
public final int hashCode() {
@@ -718,10 +695,9 @@ public abstract class Repository {
}
/**
- * Returns a <code>String</code> object representing this
- * <code>Repository</code>.
- *
- * @return a string representation of the <code>Repository</code> object.
+ * Returns a {@code String} object representing this {@code Repository}.
+ *
+ * @return a string representation of the {@code Repository} object.
*/
@Override
public String toString() {
--- a/src/share/classes/java/module/RepositoryEvent.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/RepositoryEvent.java Wed Apr 16 02:49:49 2008 -0700
@@ -26,7 +26,7 @@ package java.module;
package java.module;
/**
- * This class represents a repository event that occurs in the repository.
+ * This class represents a repository event that occurs in a repository.
*
* @see java.module.ModuleDefinition
* @see java.module.ModuleArchiveInfo
@@ -53,12 +53,12 @@ public class RepositoryEvent {
REPOSITORY_SHUTDOWN,
/**
- * A module definition has been installed successfully in the repository.
+ * A module definition has been installed successfully in a repository.
*/
MODULE_INSTALLED,
/**
- * A module definition has been uninstalled successfully in the repository.
+ * A module definition has been uninstalled successfully in a repository.
*/
MODULE_UNINSTALLED
};
@@ -68,7 +68,7 @@ public class RepositoryEvent {
private ModuleArchiveInfo info;
/**
- * Constructs a RepositoryEvent object with the specified repository,
+ * Constructs a {@code RepositoryEvent} object with the specified repository,
* and event type.
*
* @param source the repository where the event occurs
@@ -88,7 +88,7 @@ public class RepositoryEvent {
}
/**
- * Constructs a RepositoryEvent object with the specified repository,
+ * Constructs a {@code RepositoryEvent} object with the specified repository,
* event type, and module archive information.
*
* @param source the repository where the event occurs
@@ -120,7 +120,7 @@ public class RepositoryEvent {
}
/**
- * Returns the repository associated with the event.
+ * Returns the repository where the event occurs.
*/
public Repository getSource() {
return source;
@@ -134,10 +134,9 @@ public class RepositoryEvent {
}
/**
- * Returns a <code>String</code> object representing this
- * <code>RepositoryEvent</code>.
+ * Returns a {@code String} object representing this {@code RepositoryEvent}.
*
- * @return a string representation of the <code>RepositoryEvent</code> object.
+ * @return a string representation of the {@code RepositoryEvent} object.
*/
@Override
public String toString() {
--- a/src/share/classes/java/module/RepositoryListener.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/RepositoryListener.java Wed Apr 16 02:49:49 2008 -0700
@@ -30,12 +30,12 @@ import java.util.EventListener;
/**
* The listener interface for receiving repository events. The class that
* is interested in processing repository events implements this interface,
- * and the object created with that class is registered with a repository,
- * using the repository's <code>addRepositoryListener</code> method.
+ * and the object created with that class is registered, using the
+ * repository's {@code addRepositoryListener} static method.
* <p>
* The object that is no longer interested in processing any repository event
- * is unregistered with the repository, using the repository's
- * <code>removedRepositoryListener</code> method.
+ * is unregistered, using the repository's {@code removedRepositoryListener}
+ * static method.
*
* @see java.module.Repository
* @see java.module.RepositoryEvent
@@ -47,8 +47,8 @@ public interface RepositoryListener exte
/**
* Invoked after a repository has been initialized successfully, after a
* repository has been shutdown successfully, after a module definition has
- * been installed successfully in the repository, or after a module
- * definition has been uninstalled successfully in the repository.
+ * been installed successfully in a repository, or after a module
+ * definition has been uninstalled successfully in a repository.
*
* @param e repository event
*/
--- a/src/share/classes/java/module/UnsatisfiedDependencyException.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/UnsatisfiedDependencyException.java Wed Apr 16 02:49:49 2008 -0700
@@ -26,11 +26,12 @@ package java.module;
package java.module;
/**
- * Thrown to indicate that there is an unsatisifed import dependency in a
- * module during resolution.
+ * Thrown to indicate that there is an unsatisifed module dependency during
+ * module initialization.
*
- * @see java.module.ImportDependency
* @see java.module.ModuleDefinition
+ * @see java.module.ModuleDependency
+ * @see java.module.ImportPolicy
*
* @since 1.7
*/
@@ -39,44 +40,46 @@ public class UnsatisfiedDependencyExcept
static final long serialVersionUID = -3333250440766142016L;
private final transient ModuleDefinition moduleDef;
- private final transient ImportDependency importDep;
+ private final transient ModuleDependency moduleDependency;
private final transient VersionConstraint versionConstraint;
/**
- * Constructs a <code>UnsatisfiedDependencyException</code> with the
- * detail message, the specified module definition, the import
- * dependency, and the override version constraint.
+ * Constructs a {@code UnsatisfiedDependencyException} with the detail
+ * message, the specified module definition, the module dependency, and
+ * the override version constraint.
*
* @param s the detail message.
* @param moduleDef the module definition.
- * @param importDep the unsatisifed import dependency.
+ * @param moduleDependency the unsatisifed module dependency.
* @param versionConstraint the override version constraint.
*/
public UnsatisfiedDependencyException(String s, ModuleDefinition moduleDef,
- ImportDependency importDep, VersionConstraint versionConstraint) {
+ ModuleDependency moduleDependency, VersionConstraint versionConstraint)
+ {
super(s);
this.moduleDef = moduleDef;
- this.importDep = importDep;
+ this.moduleDependency = moduleDependency;
this.versionConstraint = versionConstraint;
}
/**
- * Constructs a <code>UnsatisfiedDependencyException</code> with the
- * detail message, the cause, the specified module definition, and the
- * import dependency, and the override version constraint.
+ * Constructs a {@code UnsatisfiedDependencyException} with the detail
+ * message, the cause, the specified module definition, the module
+ * dependency, and the override version constraint.
*
* @param s the detail message.
* @param cause the cause.
* @param moduleDef the module definition.
- * @param importDep the unsatisifed import dependency.
+ * @param moduleDependency the unsatisifed module dependency.
* @param versionConstraint the override version constraint.
*/
public UnsatisfiedDependencyException(String s, Throwable cause,
- ModuleDefinition moduleDef, ImportDependency importDep,
+ ModuleDefinition moduleDef,
+ ModuleDependency moduleDependency,
VersionConstraint versionConstraint) {
super(s, cause);
this.moduleDef = moduleDef;
- this.importDep = importDep;
+ this.moduleDependency = moduleDependency;
this.versionConstraint = versionConstraint;
}
@@ -88,10 +91,10 @@ public class UnsatisfiedDependencyExcept
}
/**
- * Returns the import dependency of the module definition that is unsatisfied.
+ * Returns the module dependency that is unsatisfied.
*/
- public ImportDependency getImportDependency() {
- return importDep;
+ public ModuleDependency getModuleDependency() {
+ return moduleDependency;
}
/**
--- a/src/share/classes/java/module/Version.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/Version.java Wed Apr 16 02:49:49 2008 -0700
@@ -28,6 +28,9 @@ import java.io.IOException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -60,8 +63,8 @@ import java.util.regex.Pattern;
* update := digit+
* qualifier := (alpha | digit | '-' | '_')+
* </pre></blockquote>
- * where <code>alpha</code> is an alphabetic character, e.g. a-z, A-Z.
- * <code>digit</code> is a decimal digit, e.g. 0-9.
+ * where {@code alpha} is an alphabetic character, e.g. {@code a-z, A-Z}.
+ * {@code digit} is a decimal digit, e.g. {@code 0-9}.
*
* <p>Instances of this class are immutable and safe for concurrent use by
* multiple threads.
@@ -95,23 +98,19 @@ public final class Version implements Co
* A {@code Version} object that represents the default version
* "0.0.0.0-default".
*/
- public static final Version DEFAULT = new Version(0, 0, 0, 0, "default");
-
- private int major;
- private int minor;
- private int micro;
- private int update;
- private String qualifier;
-
- /**
- * Returns a {@code Version} object holding the value of the specified string.
- * The string must be in the version format and must not
- * contain any leading or trailing whitespace.
+ public static final Version DEFAULT = new Version(new int[4], "default");
+
+ private transient int[] components;
+ private transient String qualifier;
+
+ /**
+ * Returns a {@code Version} object holding the value of the specified
+ * string. The string must be in the version format and must not contain
+ * any leading or trailing whitespace.
*
* @param version the string to be parsed.
- * @return a <code>Version</code> parsed from the string.
- * @throws IllegalArgumentException if
- * the string cannot be parsed.
+ * @return a {@code Version} parsed from the string.
+ * @throws IllegalArgumentException if the string cannot be parsed.
*/
public static Version valueOf(String version) {
// we could add a basic caching scheme here to reuse Version objects
@@ -131,22 +130,21 @@ public final class Version implements Co
version = version.substring(0, qualifierIndex);
}
- // Parse major, minor, micro, update versions
+ // Parse major, minor, micro, update versions ...
StringTokenizer st = new StringTokenizer(version, ".");
- int major = convertVersionNumber(st.nextToken());
- int minor = 0;
- int micro = 0;
- int update = 0;
- if (st.hasMoreTokens())
- minor = convertVersionNumber(st.nextToken());
-
- if (st.hasMoreTokens())
- micro = convertVersionNumber(st.nextToken());
-
- if (st.hasMoreTokens())
- update = convertVersionNumber(st.nextToken());
-
- return Version.valueOf(major, minor, micro, update, qualifier);
+ List<Integer> numberList = new ArrayList<Integer>();
+ while (st.hasMoreTokens()) {
+ numberList.add(convertVersionNumber(st.nextToken()));
+ }
+
+ // Copy the version numbers into an array of int
+ Integer[] numbers = numberList.toArray(new Integer[0]);
+ int[] components = new int[numbers.length > 4 ? numbers.length : 4];
+ for (int i=0; i < numbers.length; i++) {
+ components[i] = numbers[i];
+ }
+
+ return new Version(components, qualifier);
}
/**
@@ -157,8 +155,8 @@ public final class Version implements Co
* @param major the major version number.
* @param minor the minor version number.
* @param micro the micro version number.
- * @throws IllegalArgumentException if major, minor, or micro
- * is negative.
+ * @throws IllegalArgumentException if major, minor, or micro is
+ * negative.
*/
public static Version valueOf(int major, int minor, int micro) {
return Version.valueOf(major, minor, micro, 0, null);
@@ -173,8 +171,8 @@ public final class Version implements Co
* @param minor the minor version number.
* @param micro the micro version number.
* @param qualifier the qualifier
- * @throws IllegalArgumentException if major or minor or micro
- * is negative, or qualifier contains illegal character.
+ * @throws IllegalArgumentException if major or minor or micro is
+ * negative, or qualifier contains illegal character.
*/
public static Version valueOf(int major, int minor, int micro, String qualifier) {
return Version.valueOf(major, minor, micro, 0, qualifier);
@@ -189,8 +187,8 @@ public final class Version implements Co
* @param minor the minor version number.
* @param micro the micro version number.
* @param update the update version number.
- * @throws IllegalArgumentException if major or minor or micro
- * or update is negative.
+ * @throws IllegalArgumentException if major or minor or micro or update is
+ * negative.
*/
public static Version valueOf(int major, int minor, int micro, int update) {
return Version.valueOf(major, minor, micro, update, null);
@@ -204,85 +202,84 @@ public final class Version implements Co
* @param micro the micro version number.
* @param update the update version number.
* @param qualifier the qualifier
- * @throws IllegalArgumentException if major, minor, micro,
- * or update is negative, or if qualifier contains illegal characters.
+ * @throws IllegalArgumentException if major, minor, micro, or update is
+ * negative, or if qualifier contains illegal characters.
*/
public static Version valueOf(int major, int minor, int micro, int update, String qualifier) {
// we could add a basic caching scheme here to reuse Version objects
- return new Version(major, minor, micro, update, qualifier);
- }
-
- /**
- * Constructs a new <code>Version</code> instance.
- * This constructor is for use by subclasses. Applications should use
- * one of the {@link #valueOf(int,int,int) valueOf()} factory methods to
- * obtain {@code Version} instances.
- *
- * @param major the major version number.
- * @param minor the minor version number.
- * @param micro the micro version number.
- * @param update the update version number.
+ int[] components = new int[4];
+ components[0] = major;
+ components[1] = minor;
+ components[2] = micro;
+ components[3] = update;
+
+ return new Version(components, qualifier);
+ }
+
+ /**
+ * Constructs a new {@code Version} instance.
+ *
+ * @param components an array of version number
* @param qualifier the qualifier
- * @throws IllegalArgumentException if major, minor, micro,
- * or update are negative, or if qualifier contains illegal character.
- */
- protected Version(int major, int minor, int micro, int update, String qualifier) {
- if (major < 0)
- throw new IllegalArgumentException("Major version number must not be negative: " + major);
-
- if (minor < 0)
- throw new IllegalArgumentException("Minor version number must not be negative: " + minor);
-
- if (micro < 0)
- throw new IllegalArgumentException("Micro version number must not be negative: " + micro);
-
- if (update < 0)
- throw new IllegalArgumentException("Update version number must not be negative: " + update);
+ * @throws IllegalArgumentException if any version number is negative, or
+ * if qualifier contains illegal character.
+ */
+ private Version(int[] components, String qualifier) {
+ if (components[0] < 0)
+ throw new IllegalArgumentException("Major version number must not be negative: " + components[0]);
+
+ if (components[1] < 0)
+ throw new IllegalArgumentException("Minor version number must not be negative: " + components[1]);
+
+ if (components[2] < 0)
+ throw new IllegalArgumentException("Micro version number must not be negative: " + components[2]);
+
+ if (components[3] < 0)
+ throw new IllegalArgumentException("Update version number must not be negative: " + components[3]);
if (qualifier != null && qualifierPattern.matcher(qualifier).matches() == false)
throw new IllegalArgumentException("qualifier must contain only legal character: " + qualifier);
- this.major = major;
- this.minor = minor;
- this.micro = micro;
- this.update = update;
+ // this constructor is private, and it claims the ownership of
+ // the components that was passed in.
+ this.components = components;
this.qualifier = qualifier;
}
/**
- * Returns the major number in the version.
- *
- * @return the major version.
+ * Returns the major version number.
+ *
+ * @return the major version number.
*/
public int getMajorNumber() {
- return major;
- }
-
- /**
- * Returns the minor number in the version.
- *
- * @return the minor version.
+ return components[0];
+ }
+
+ /**
+ * Returns the minor version number.
+ *
+ * @return the minor version number.
*/
public int getMinorNumber() {
- return minor;
- }
-
- /**
- * Returns the micro number in the version.
- *
- * @return the micro version.
+ return components[1];
+ }
+
+ /**
+ * Returns the micro version number.
+ *
+ * @return the micro version number.
*/
public int getMicroNumber() {
- return micro;
- }
-
- /**
- * Returns the update number in the version.
- *
- * @return the update version.
+ return components[2];
+ }
+
+ /**
+ * Returns the update version number.
+ *
+ * @return the update version number.
*/
public int getUpdateNumber() {
- return update;
+ return components[3];
}
/**
@@ -297,10 +294,11 @@ public final class Version implements Co
/**
* Returns true if the string is a version in valid format.
*
- * @return true if the string is a version in valid format.
- * Otherwise, returns false.
- */
- public static boolean isVersion(String source) {
+ * @return true if the string is a version in valid format. Otherwise,
+ * returns false.
+ */
+ /** package private */
+ static boolean isVersion(String source) {
return versionPattern.matcher(source).matches();
}
@@ -320,9 +318,9 @@ public final class Version implements Co
}
/**
- * Return a <code>VersionConstraint</code> object that represents this version.
- *
- * @return a <code>VersionConstraint</code> object.
+ * Return a {@code VersionConstraint} object that represents this version.
+ *
+ * @return a {@code VersionConstraint} object.
*/
public VersionConstraint toVersionConstraint() {
VersionConstraintBuilder builder = new VersionConstraintBuilder();
@@ -349,10 +347,7 @@ public final class Version implements Co
} catch (IllegalArgumentException e) {
throw new IOException("Serialized format of version is invalid for de-serialization.");
}
- this.major = version.major;
- this.minor = version.minor;
- this.micro = version.micro;
- this.update = version.update;
+ this.components = Arrays.copyOf(version.components, version.components.length);
this.qualifier = version.qualifier;
}
@@ -369,40 +364,41 @@ public final class Version implements Co
}
/**
- * Compare two <code>Version</code> objects.
- *
- * @param version the <code>Version</code> to be compared.
- * @return the value 0 if the argument <code>Version</code>
- * is equal to this <code>Version</code>; a value
- * less than 0 if this <code>Version</code> is less
- * than the <code>Version</code> argument; and a
- * value greater than 0 if this <code>Version</code>
- * is greater than the <code>Version</code> argument.
- */
- // @Override // javac 5.0 bug
+ * Compare two {@code Version} objects.
+ *
+ * @param version the {@code Version} to be compared.
+ * @return the value 0 if the this {@code Version} is equal to the
+ * {@code Version} argument; a value less than 0 if this
+ * {@code Version} is less than the {@code Version} argument; and a
+ * value greater than 0 if this {@code Version} is greater than the
+ * {@code Version} argument.
+ * @throws NullPointerException if the {@code Version} argument is null.
+ */
+ @Override
public int compareTo(Version version) {
+ if (version == null) {
+ throw new NullPointerException("version must not be null.");
+ }
+
if (this == version)
return 0;
- // Compare major version
- int result = major - version.getMajorNumber();
- if (result != 0)
- return result;
-
- // Compare minor version
- result = minor - version.getMinorNumber();
- if (result != 0)
- return result;
-
- // Compare micro version
- result = micro - version.getMicroNumber();
- if (result != 0)
- return result;
-
- // Compare update version
- result = update - version.getUpdateNumber();
- if (result != 0)
- return result;
+ // Resize components from both Version objects to be the
+ // same size before comparison
+ int[] components1 = this.components;
+ int[] components2 = version.components;
+ if (components1.length > components2.length) {
+ components2 = Arrays.copyOf(components2, components1.length);
+ } else if (components1.length < components2.length) {
+ components1 = Arrays.copyOf(components1, components2.length);
+ }
+
+ // Compare major, minor, micro, update version ...
+ for (int i = 0 ; i < components1.length; i++) {
+ int result = components1[i] - components2[i];
+ if (result != 0)
+ return result;
+ }
// Is there a qualifier?
String qualifier2 = version.getQualifier();
@@ -416,26 +412,24 @@ public final class Version implements Co
}
/**
- * Returns a <code>Version</code> instance, with the qualifier omitted.
- */
- public Version trimQualifier() {
+ * Returns a {@code Version} instance, with the qualifier omitted.
+ */
+ Version trimQualifier() {
if (getQualifier() == null)
return this;
else
return Version.valueOf(getMajorNumber(), getMinorNumber(),
- getMicroNumber(), getUpdateNumber());
- }
-
- /**
- * Compare two <code>Version</code> objects for equality.
- * The result is <code>true</code> if and only if the
- * argument is not <code>null</code> and is a
- * <code>Version</code> object that the major, minor,
- * micro, update, and qualifier the same as those of this
- * <code>Version</code>.
+ getMicroNumber(), getUpdateNumber());
+ }
+
+ /**
+ * Compare two {@code Version} objects for equality. The result is
+ * {@code true} if and only if the argument is not {@code null} and is a
+ * {@code Version} object that the major, minor, micro, update, and
+ * qualifier are the same as those of this {@code Version}.
*
* @param obj the object to compare with.
- * @return whether or not the two objects are equal
+ * @return whether or not two {@code Version} objects are equal
*/
@Override
public boolean equals(Object obj) {
@@ -449,17 +443,16 @@ public final class Version implements Co
}
/**
- * Returns a hash code for this <code>Version</code>.
- *
- * @return a hash code value for this object.
+ * Returns a hash code for this {@code Version}.
+ *
+ * @return a hash code value for this {@code Version}.
*/
@Override
public int hashCode() {
int result = 17;
- result = 37 * result + major;
- result = 37 * result + minor;
- result = 37 * result + micro;
- result = 37 * result + update;
+ for (int n : components) {
+ result = 37 * result + n;
+ }
result = 37 * result + (qualifier != null ? qualifier.hashCode() : 0);
return result;
}
@@ -469,20 +462,24 @@ public final class Version implements Co
// If shortForm is false, the minor number is always displayed.
private String toString(boolean shortForm) {
StringBuilder buffer = new StringBuilder();
- buffer.append(major);
-
- if ((shortForm == false) || (minor != 0) || (update != 0) || (micro != 0)) {
+ buffer.append(components[0]); // major number
+
+ // Finds the last component that is not zero
+ int lastIndex = 0;
+ for (int i=components.length-1; i > 0; i--) {
+ if (components[i] != 0) {
+ lastIndex = i;
+ break;
+ }
+ }
+
+ if (shortForm == false || lastIndex != 0) {
buffer.append('.');
- buffer.append(minor);
-
- if (micro != 0 || update != 0) {
+ buffer.append(components[1]);
+
+ for (int i=2; i <= lastIndex; i++) {
buffer.append('.');
- buffer.append(micro);
-
- if (update != 0) {
- buffer.append('.');
- buffer.append(update);
- }
+ buffer.append(components[i]);
}
}
@@ -500,12 +497,12 @@ public final class Version implements Co
}
/**
- * Returns a <code>String</code> object representing this
- * <code>Version</code>'s value. The value is converted to the version
- * format and returned as a string.
- *
- * @return a string representation of the value of this object in the
- * version format.
+ * Returns a {@code String} object representing this {@code Version}'s
+ * value. The value is converted to the version format and returned as a
+ * string.
+ *
+ * @return a string representation of the value of this {@code Version} in
+ * the version format.
*/
@Override
public String toString() {
--- a/src/share/classes/java/module/VersionConstraint.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/VersionConstraint.java Wed Apr 16 02:49:49 2008 -0700
@@ -92,8 +92,8 @@ import java.util.StringTokenizer;
* update := digit+
* qualifier := (alpha | digit | '-' | '_')+
* </pre></blockquote>
- * where <code>alpha</code> is an alphabetic character, e.g. a-z, A-Z.
- * <code>digit</code> is a decimal digit, e.g. 0-9.
+ * where {@code alpha} is an alphabetic character, e.g. {@code a-z, A-Z}.
+ * {@code digit} is a decimal digit, e.g. {@code 0-9}.
*
* <p>Applications can obtain {@code VersionConstraint} objects by calling the
* {@link #valueOf(String) valueOf()} factory method.
@@ -116,12 +116,14 @@ public final class VersionConstraint imp
*/
public static final VersionConstraint DEFAULT = VersionConstraint.valueOf("0.0.0.0+");
- // A list of versions and version ranges that are part of the version constraint.
- // Each versions and version ranges have neither been normalized nor combined.
+ // A list of versions and version ranges that are part of the version
+ // constraint. Each versions and version ranges have neither been
+ // normalized nor combined.
private transient List<Object> constraints;
- // A list of versions and version ranges that are part of the normalized version constraint.
- // These versions and version ranges have been normalized and combined if possible.
+ // A list of versions and version ranges that are part of the normalized
+ // version constraint. These versions and version ranges have been
+ // normalized and combined if possible.
private transient List<Object> normalizedConstraints;
/**
@@ -137,7 +139,7 @@ public final class VersionConstraint imp
* Returns true if the specified {@code Version} is contained within any of
* the ranges known to this {@code VersionConstraint}.
*
- * @param version the <code>Version</code> object.
+ * @param version the {@code Version} object.
* @return true if the specified version is contained within any of ranges
* known to this version constraint. Otherwise, returns false.
*/
@@ -159,12 +161,13 @@ public final class VersionConstraint imp
}
/**
- * Returns true if the specified {@code VersionRange} is contained
- * within any of the ranges known to this {@code VersionConstraint}.
- *
- * @param versionRange the <code>VersionRange</code> object.
+ * Returns true if the specified {@code VersionRange} is contained within
+ * any of the ranges known to this {@code VersionConstraint}.
+ *
+ * @param versionRange the {@code VersionRange} object.
* @return true if the specified version range is contained within any of
- * ranges known to this version constraint. Otherwise, returns false.
+ * ranges known to this version constraint. Otherwise, returns
+ * false.
*/
private boolean contains(VersionRange versionRange) {
for (Object cs : normalizedConstraints) {
@@ -182,7 +185,7 @@ public final class VersionConstraint imp
* Returns true if the specified {@code VersionConstraint} is contained
* within any of the ranges known to this {@code VersionConstraint}.
*
- * @param versionConstraint the <code>VersionConstraint</code> object.
+ * @param versionConstraint the {@code VersionConstraint} object.
* @return true if the specified version constraint is contained within
* any of ranges known to this version constraint. Otherwise,
* returns false.
@@ -206,14 +209,14 @@ public final class VersionConstraint imp
}
/**
- * Determines if the given {@code VersionConstraint} and {@code
- * VersionRange} intersect, and if so adds that intersection to {@code
- * VersionConstraintBuilder}.
- *
- * @param versionConstraint the <code>VersionConstraint</code> object.
- * @param versionRange the <code>VersionRange</code> object.
- * @return the true if the specified version range intersects with
- * this version constraint. Otherwise, returns false.
+ * Determines if the given {@code VersionConstraint} and
+ * {@code VersionRange} intersect, and if so adds that intersection to
+ * {@code VersionConstraintBuilder}.
+ *
+ * @param versionConstraint the {@code VersionConstraint} object.
+ * @param versionRange the {@code VersionRange} object.
+ * @return the true if the specified version range intersects with this
+ * version constraint. Otherwise, returns false.
*/
private static boolean intersection(VersionConstraint versionConstraint,
VersionRange versionRange,
@@ -243,12 +246,12 @@ public final class VersionConstraint imp
}
/**
- * Returns a VersionConstraint that represents the intersection between
- * the specified {@code VersionConstraint} and this {@code
- * VersionConstraint}.
- *
- * @param versionConstraint the <code>VersionConstraint</code> object.
- * @return the version constraint of intersection if the specified version
+ * Returns a {@code VersionConstraint} that represents the intersection
+ * between the specified {@code VersionConstraint} and this
+ * {@code VersionConstraint}.
+ *
+ * @param versionConstraint the {@code VersionConstraint} object.
+ * @return the version constraint of intersection if the specified version
* constraint and this version constraint intersect. Otherwise,
* returns null.
*/
@@ -285,12 +288,11 @@ public final class VersionConstraint imp
/**
* Returns a {@code VersionConstraint} object holding the value of the
- * specified string.
- * The string must be in the version constraint format and must not
- * contain any leading or trailing whitespace.
+ * specified string. The string must be in the version constraint format
+ * and must not contain any leading or trailing whitespace.
*
* @param versionConstraint the string to be parsed.
- * @return A <code>VersionConstraint</code> parsed from the string.
+ * @return A {@code VersionConstraint} parsed from the string.
* @throws IllegalArgumentException if the string cannot be parsed.
*/
public static VersionConstraint valueOf(String versionConstraint) {
@@ -366,11 +368,10 @@ public final class VersionConstraint imp
}
/**
- * Compare two <code>VersionConstraint</code> objects for equality. The result
- * is <code>true</code> if and only if the argument is not
- * <code>null</code> and is a <code>VersionConstraint</code> object that
- * it has the same normalized versions and version ranges as those of
- * this <code>VersionConstraint</code>.
+ * Compare two {@code VersionConstraint} objects for equality. The result
+ * is {@code true} if and only if the argument is not {@code null} and is
+ * a {@code VersionConstraint} object that it has the same normalized
+ * versions and version ranges as those of this {@code VersionConstraint}.
*
* @param obj the object to compare with.
* @return whether or not the two objects are equal
@@ -391,7 +392,7 @@ public final class VersionConstraint imp
}
/**
- * Returns a hash code for this <code>VersionConstraint</code>.
+ * Returns a hash code for this {@code VersionConstraint}.
*
* @return a hash code value for this object.
*/
@@ -403,9 +404,9 @@ public final class VersionConstraint imp
}
/**
- * Returns a <code>String</code> object representing this
- * <code>VersionConstraint</code>'s value. The value is converted to the
- * version constraint format and returned as a string.
+ * Returns a {@code String} object representing this
+ * {@code VersionConstraint}'s value. The value is converted to the version
+ * constraint format and returned as a string.
*
* @return a string representation of the value of this object in the
* version constraint format.
--- a/src/share/classes/java/module/VersionConstraintBuilder.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/VersionConstraintBuilder.java Wed Apr 16 02:49:49 2008 -0700
@@ -36,8 +36,8 @@ import java.util.StringTokenizer;
/**
* This class provides an API for building version constraint.
*
- * <p>The principal operation on a <code>VersionConstraintBuilder</code> is the
- * <code>add</code> method, which is overloaded so as to accept version and
+ * <p>The principal operation on a {@code VersionConstraintBuilder} is the
+ * {@code add} method, which is overloaded so as to accept version and
* version range. Each effectively converts a version or a version range
* and normalizes it in the version constraint builder.
* <p>
@@ -46,7 +46,7 @@ import java.util.StringTokenizer;
* while adding a new version range [3.0, 3.6) would alter the version
* constraint builder to contain "1.3;[2.0, 3.6)" as the version constraints.
* <p>
- * <p>Instances of <code>VersionConstraintBuilder</code> are not safe for
+ * <p>Instances of {@code VersionConstraintBuilder} are not safe for
* use by multiple threads.
*
* @see java.module.Version
--- a/src/share/classes/java/module/VersionRange.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/VersionRange.java Wed Apr 16 02:49:49 2008 -0700
@@ -67,7 +67,7 @@ class VersionRange implements Comparable
private final Version normalizedUpperBound;
/**
- * Constructs a new <code>VersionRange</code> instance.
+ * Constructs a new {@code VersionRange} instance.
* <p>
* The qualifiers in the lower bound and the upper bound are ignored.
* <pre>
@@ -82,7 +82,8 @@ class VersionRange implements Comparable
* @param upperBound the upper bound version in the version range.
* @param upperBoundInclusive the inclusiveness of the upper bound version.
* @throws NullPointerException if lowerBound is null or upperBound is null.
- * @throws IllegalArgumentException if the lowerBound is greater than the upperBound.
+ * @throws IllegalArgumentException if the lowerBound is greater than the
+ * upperBound.
*/
private VersionRange(Version lowerBound, boolean lowerBoundInclusive,
Version upperBound, boolean upperBoundInclusive) {
@@ -140,11 +141,11 @@ class VersionRange implements Comparable
}
/**
- * Constructs a new <code>VersionRange</code> instance.
+ * Constructs a new {@code VersionRange} instance.
* <p>
- * The lower bound is assumed to be inclusive, and the upper bound is assumed
- * to be infinity and exclusive. The qualifiers in the lower bound and the
- * upper bound are ignored.
+ * The lower bound is assumed to be inclusive, and the upper bound is
+ * assumed to be infinity and exclusive. The qualifiers in the lower
+ * bound and the upper bound are ignored.
* <pre>
* a.b.c.d+ ~ [a.b.c.d, infinity) ~ a.b.c.d <= x < infinity
* </pre>
@@ -170,19 +171,21 @@ class VersionRange implements Comparable
}
/**
- * Constructs a new <code>VersionRange</code> instance.
+ * Constructs a new {@code VersionRange} instance.
* <p>
- * The lower bound is assumed to be inclusive, and the upper bound is assumed
- * to be exclusive. The qualifiers in the lower bound and the upper bound
- * are ignored.
+ * The lower bound is assumed to be inclusive, and the upper bound is
+ * assumed to be exclusive. The qualifiers in the lower bound and the
+ * upper bound are ignored.
* <pre>
* [a.b.c.d, p.q.r.s) ~ a.b.c.d <= x < p.q.r.s
* </pre>
*
* @param lowerBound the lower bound version in the version range.
* @param upperBound the upper bound version in the version range.
- * @throws NullPointerException if lowerBound is null or upperBound is null.
- * @throws IllegalArgumentException if the lowerBound is greater than the upperBound.
+ * @throws NullPointerException if lowerBound is null or upperBound is
+ * null.
+ * @throws IllegalArgumentException if the lowerBound is greater than
+ * the upperBound.
*/
private VersionRange(Version lowerBound, Version upperBound) {
this(lowerBound, true, upperBound, false);
@@ -201,17 +204,16 @@ class VersionRange implements Comparable
* Returns true if the lower bound version in the version range is
* inclusive.
*
- * @return true if the lower bound version is inclusive. Otherwise, returns
- * false.
+ * @return true if the lower bound version is inclusive. Otherwise,
+ * returns false.
*/
boolean isLowerBoundInclusive() {
return lowerBoundInclusive;
}
/**
- * Returns the upper bound version in the version range.
- *
- * If upper bound version is <code>null</code>, the upper bound is infinity.
+ * Returns the upper bound version in the version range. If upper bound
+ * version is {@code null}, the upper bound is infinity.
*
* @return the upper bound version.
*/
@@ -268,13 +270,12 @@ class VersionRange implements Comparable
}
/**
- * Parses a string according to the version range format. The string
- * must not contain any leading or trailing whitespace.
+ * Parses a string according to the version range format. The string must
+ * not contain any leading or trailing whitespace.
*
* @param versionRange the string to be parsed.
- * @return A <code>Version</code> parsed from the string.
- * @throws IllegalArgumentException if the string cannot be
- * parsed.
+ * @return A {@code Version} parsed from the string.
+ * @throws IllegalArgumentException if the string cannot be parsed.
*/
static VersionRange parse(String versionRange) {
@@ -357,7 +358,7 @@ class VersionRange implements Comparable
/**
* Returns true if the specified version range is within this version range.
*
- * @param versionRange the <code>VersionRange</code> object.
+ * @param versionRange the {@code VersionRange} object.
* @return true if the specified version range is within this version
* range. Otherwise, returns false.
*/
@@ -385,7 +386,7 @@ class VersionRange implements Comparable
/**
* Returns true if the specified version is within this version range.
*
- * @param version the <code>Version</code> object.
+ * @param version the {@code Version} object.
* @return true if the specified version is within this version range.
* Otherwise, returns false.
*/
@@ -408,9 +409,10 @@ class VersionRange implements Comparable
}
/**
- * Returns true if the specified version range intersects with this version range.
- *
- * @param versionRange the <code>VersionRange</code> object.
+ * Returns true if the specified version range intersects with this version
+ * range.
+ *
+ * @param versionRange the {@code VersionRange} object.
* @return true if the specified version range intersects with this version
* range. Otherwise, returns false.
*/
@@ -430,8 +432,8 @@ class VersionRange implements Comparable
* Intersects two version ranges and returns the version range of
* intersection.
*
- * @param versionRange1 the <code>VersionRange</code> object.
- * @param versionRange2 another <code>VersionRange</code> object.
+ * @param versionRange1 the {@code VersionRange} object.
+ * @param versionRange2 another {@code VersionRange} object.
* @return the version range of intersection between two version ranges.
* Otherwise, returns null.
*/
@@ -451,7 +453,8 @@ class VersionRange implements Comparable
Version upperBound = null;
// The version ranges overlap, so the largest of the two lower bounds
- // of the version ranges is the lower bound of the intersecting version range.
+ // of the version ranges is the lower bound of the intersecting version
+ // range.
//
if (versionRange1.getNormalizedLowerBound().compareTo
(versionRange2.getNormalizedLowerBound()) <= 0) {
@@ -461,7 +464,8 @@ class VersionRange implements Comparable
}
// The version ranges overlap, so the smallest of the two upper bounds
- // of the version ranges is the upper bound of the intersecting version range.
+ // of the version ranges is the upper bound of the intersecting version
+ // range.
//
if (versionRange1.getNormalizedUpperBound() != null
&& versionRange2.getNormalizedUpperBound() != null) {
@@ -487,10 +491,11 @@ class VersionRange implements Comparable
}
/**
- * Merges two version ranges together and returns the combined version range.
- *
- * @param versionRange1 the <code>VersionRange</code> object.
- * @param versionRange2 another <code>VersionRange</code> object.
+ * Merges two version ranges together and returns the combined version
+ * range.
+ *
+ * @param versionRange1 the {@code VersionRange} object.
+ * @param versionRange2 another {@code VersionRange} object.
* @return the merged version range.
* @throws IllegalArgumentException if two version ranges have no
* intersection or are not contiguous.
@@ -581,7 +586,7 @@ class VersionRange implements Comparable
/**
* Returns a normalized version range.
*
- * This method is used by java.module.VersionConstraint.
+ * This method is used by {code java.module.VersionConstraint}.
*/
VersionRange normalize() {
@@ -599,9 +604,10 @@ class VersionRange implements Comparable
}
/**
- * Return a <code>VersionConstraint</code> object that represents this version range.
- *
- * @return a <code>VersionConstraint</code> object.
+ * Return a {@code VersionConstraint} object that represents this version
+ * range.
+ *
+ * @return a {@code VersionConstraint} object.
*/
VersionConstraint toVersionConstraint() {
VersionConstraintBuilder builder = new VersionConstraintBuilder();
@@ -610,17 +616,17 @@ class VersionRange implements Comparable
}
/**
- * Compare two <code>VersionRange</code> objects.
- *
- * @param versionRange the <code>VersionRange</code> to be compared.
- * @return the value 0 if the argument <code>Version</code> is equal to
- * this <code>VersionRange</code>; a value less than 0 if this
- * <code>VersionRange</code> is less than the
- * <code>VersionRange</code> argument; and a value greater than 0
- * if this <code>VersionRange</code> is greater than the
- * <code>VersionRange</code> argument.
- */
- // @Override // javac 5.0 bug
+ * Compare two {@code VersionRange} objects.
+ *
+ * @param versionRange the {@code VersionRange} to be compared.
+ * @return the value 0 if the argument {@code Version} is equal to this
+ * {@code VersionRange}; a value less than 0 if this
+ * {@code VersionRange} is less than the {@code VersionRange}
+ * argument; and a value greater than 0 if this
+ * {@code VersionRange} is greater than the
+ * {@code VersionRange} argument.
+ */
+ @Override
public int compareTo(VersionRange versionRange) {
if (this == versionRange)
return 0;
@@ -644,11 +650,11 @@ class VersionRange implements Comparable
}
/**
- * Compare two <code>VersionRange</code> objects for equality. The result
- * is <code>true</code> if and only if the argument is not
- * <code>null</code> and is a <code>VersionRange</code> object that
- * lowerBound, lowerBoundInclusive, upperBound, and upperBoundInclusive
- * the same as those of this <code>VersionRange</code>.
+ * Compare two {@code VersionRange} objects for equality. The result is
+ * {@code true} if and only if the argument is not {@code null} and is a
+ * {@code VersionRange} object that lowerBound, lowerBoundInclusive,
+ * upperBound, and upperBoundInclusive the same as those of this
+ * {@code VersionRange}.
*
* @param obj the object to compare with.
* @return whether or not the two objects are equal
@@ -677,7 +683,7 @@ class VersionRange implements Comparable
}
/**
- * Returns a hash code for this <code>VersionRange</code>.
+ * Returns a hash code for this {@code VersionRange}.
*
* @return a hash code value for this object.
*/
@@ -690,9 +696,9 @@ class VersionRange implements Comparable
}
/**
- * Returns a <code>String</code> object representing this
- * <code>VersionRange</code>'s value. The value is converted to
- * the version range format and returned as a string.
+ * Returns a {@code String} object representing this {@code VersionRange}'s
+ * value. The value is converted to the version range format and returned
+ * as a string.
*
* @return a string representation of the value of this object in the
* version range format.
--- a/src/share/classes/java/module/VisibilityPolicy.java Fri Apr 11 08:27:13 2008 -0700
+++ b/src/share/classes/java/module/VisibilityPolicy.java Wed Apr 16 02:49:49 2008 -0700
@@ -26,8 +26,8 @@ package java.module;
package java.module;
/**
- * This interface represents the visibility policy of the module definitions in
- * the repository of the module system.
+ * This interface represents the visibility policy for the module definitions in
+ * the repository.
* <p>
* @see java.module.ModuleDefinition
* @see java.module.Repository
@@ -38,12 +38,12 @@ public interface VisibilityPolicy {
/**
* Returns true if the module definition should be visible in the
- * repository of the module system. Otherwise, returns false.
+ * reposi