6691150: Updates APIs to support generic import dependency.
Summary: Updated JSR 277 + 294 API.
Reviewed-by: bristor
--- a/src/share/classes/java/lang/Class.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/java/lang/Class.java Sat Apr 19 03:38:14 2008 -0700
@@ -655,6 +655,7 @@ public final
if (cl != null) {
return cl;
} else {
+ // XXX: to be implemented
throw new UnsupportedOperationException("Not implemented yet");
}
}
--- a/src/share/classes/java/lang/ClassLoader.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/java/lang/ClassLoader.java Sat Apr 19 03:38:14 2008 -0700
@@ -445,7 +445,7 @@ public abstract class ClassLoader {
* @since 1.7
*/
protected final ModuleInfo defineModuleInfo(String name, byte[] b, int off, int len)
- throws ClassFormatError {
+ throws ClassFormatError {
Class<?> clazz = defineClass(name, b, off, len);
return new ModuleInfo(clazz);
}
--- a/src/share/classes/java/module/ImportOverridePolicy.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/java/module/ImportOverridePolicy.java Sat Apr 19 03:38:14 2008 -0700
@@ -36,6 +36,7 @@ import java.util.Map;
* The import override policy is invoked before the default or custom
* import policy of the module instance is executed during initialization.
* <p>
+ * @see java.module.ImportDependency;
* @see java.module.ImportPolicy
* @see java.module.ModuleDefinition
* @see java.module.VersionConstraint
@@ -45,9 +46,9 @@ 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 import dependencies and overridden version constraints
+ * for the module definition. The returned map contains the same set of
+ * import dependencies as in the given map.
* <p>
* For each import dependency, the overridden version constraint must be
* within the boundary of the original version constraint that was
@@ -55,11 +56,12 @@ public interface ImportOverridePolicy {
* initialization will fail.
*
* @param importer the importing module definition.
- * @param constraints an unmodifiable map of imported module names and
+ * @param constraints an unmodifiable map of import dependencies and
* overridden version constraints.
- * @return the map of imported module names and overridden version
- * constraints. It contains the same set of module names as the
- * given map.
+ * @return the map of import dependencies and overridden version
+ * constraints. It contains the same set of import dependencies as
+ * in the given map.
*/
- public abstract Map<String,VersionConstraint> narrow(ModuleDefinition importer, Map<String,VersionConstraint> constraints);
+ public abstract Map<ImportDependency, VersionConstraint> narrow(ModuleDefinition importer,
+ Map<ImportDependency, VersionConstraint> constraints);
}
--- a/src/share/classes/java/module/ImportPolicy.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/java/module/ImportPolicy.java Sat Apr 19 03:38:14 2008 -0700
@@ -30,9 +30,10 @@ import java.util.Map;
/**
* This interface represents the import policy of a module definition. The
- * import policy is used to determine the list of imported module definitions
- * in the resolving process to prepare the module instance.
+ * import policy is used to determine the version constraints that should be
+ * used to resolve the import dependencies in a module during initialization.
* <p>
+ * @see java.module.ImportDependency
* @see java.module.ImportOverridePolicy
* @see java.module.Module
* @see java.module.ModuleDefinition
@@ -44,49 +45,48 @@ public interface ImportPolicy {
public interface ImportPolicy {
/**
- * Returns a list of imported module definitions for preparing this module
- * instance.
+ * Returns a map of import dependencies and the associated version
+ * constraints that should used when initializing this module instance.
* <p>
- * The list of import module dependencies that is returned from the
+ * The list of import dependencies that is returned from the
* {@code getImportDependencies()} method of the
- * {@code ModuleDefinition} object only reflects the import module
- * dependencies with the original version constraints that were specified
+ * {@code ModuleDefinition} object only reflects the import 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>
- * Some implementations may use the map of imported module names and
+ * Some implementations may use the map of import dependencies 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
+ * an import has been overridden. The map is passed in one of the
* parameters of this method.
* <p>
* 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.
+ * determining the map of import dependencies and default version
+ * constraints for resolving, and it is passed in one of the parameters of
+ * this method.
* <p>
- * 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),
+ * All implementations should return a map of import dependencies and
+ * version constraints after resolving the 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.
+ * must be used to represent the version constraint of the missing import
+ * in the map.
*
* @param moduleDef the module definition of this module instance.
- * @param constraints an unmodifiable map of imported module names and
+ * @param constraints an unmodifiable map of import dependencies and
* overridden version constraints.
* @param defaultImportPolicy the default import policy for this module
* instance.
- * @throws UnsatisfiedDependencyException if an import module dependency
- * cannot be satisfied.
+ * @throws UnsatisfiedDependencyException if an import dependency cannot
+ * be satisfied.
* @throws ModuleInitializationException if there is other error.
- * @return a list of imported module definitions for preparing this module
- * instance in the resolving process.
+ * @return a map of import dependencies and overridden version constraints
+ * for preparing this module instance in the resolving process.
*/
- public abstract List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ public abstract Map<ImportDependency, VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
throws ModuleInitializationException;
}
--- a/src/share/classes/java/module/JamModuleDefinition.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/java/module/JamModuleDefinition.java Sat Apr 19 03:38:14 2008 -0700
@@ -282,7 +282,7 @@ final class JamModuleDefinition extends
for (String s : memberPackages) {
packageDefs.add(new JamPackageDefinition(s, Version.DEFAULT, this));
}
- memberPackageDefs = packageDefs;
+ memberPackageDefs = Collections.unmodifiableSet(packageDefs);
}
return memberPackageDefs;
}
@@ -296,7 +296,7 @@ final class JamModuleDefinition extends
for (String s : exportedPackages) {
packageDefs.add(new JamPackageDefinition(s, Version.DEFAULT, this));
}
- exportedPackageDefs = packageDefs;
+ exportedPackageDefs = Collections.unmodifiableSet(packageDefs);
}
return exportedPackageDefs;
}
--- a/src/share/classes/java/module/Module.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/java/module/Module.java Sat Apr 19 03:38:14 2008 -0700
@@ -47,10 +47,10 @@ public abstract class Module
}
/**
- * Returns the {@code ModuleDefinition} of this {@code Module}.
- *
- * @return the {@code ModuleDefinition} object.
- */
+ * Returns the {@code ModuleDefinition} of this {@code Module}.
+ *
+ * @return the {@code ModuleDefinition} object.
+ */
public abstract ModuleDefinition getModuleDefinition();
/**
--- a/src/share/classes/java/module/ModuleDefinition.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/java/module/ModuleDefinition.java Sat Apr 19 03:38:14 2008 -0700
@@ -86,11 +86,11 @@ public abstract class ModuleDefinition {
public abstract String getAttribute(String name);
/**
- * 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.
+ * Returns an unmodifiable list of all import dependencies. The order of
+ * the import dependencies in the list follows the declared import order in
+ * the {@code ModuleDefinition}.
+ *
+ * @return an unmodifiable list of all import dependencies.
*/
public abstract List<ImportDependency> getImportDependencies();
@@ -161,7 +161,7 @@ public abstract class ModuleDefinition {
*/
public boolean isClassExported(String name) {
try {
- // TODO: convert class name?
+ // XXX: convert class name?
Set<String> exportedClasses = getExportedClasses();
return exportedClasses.contains(name);
} catch (UnsupportedOperationException uoe) {
@@ -264,8 +264,8 @@ public abstract class ModuleDefinition {
public abstract boolean isModuleReleasable();
/**
- * Returns a {@code ModuleContent} instance which represents the content
- * of this {@code ModuleDefinition}.
+ * Returns a {@code ModuleContent} which represents the content of this
+ * {@code ModuleDefinition}.
* <p>
* If a security manager is present, this method calls the security
* manager's {@code checkPermission} method with a
@@ -273,7 +273,7 @@ public abstract class ModuleDefinition {
* permission to ensure it's ok to access the content of this
* {@code ModuleDefinition}.
*
- * @return the {@code ModuleContent} instance.
+ * @return the {@code ModuleContent}.
* @throws SecurityException if a security manager exists and
* its {@code checkPermission} method denies access
* to the content of this {@code ModuleDefinition}.
@@ -292,7 +292,7 @@ public abstract class ModuleDefinition {
* {@code ModuleDefinition}; otherwise, returns false.
*/
@Override
- public final boolean equals(Object obj) {
+ public final boolean equals(Object obj) {
return (this == obj);
}
@@ -302,7 +302,7 @@ public abstract class ModuleDefinition {
* @return a hash code value for this {@code ModuleDefinition}.
*/
@Override
- public final int hashCode() {
+ public final int hashCode() {
return super.hashCode();
}
--- a/src/share/classes/java/module/ModuleInitializer.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/java/module/ModuleInitializer.java Sat Apr 19 03:38:14 2008 -0700
@@ -26,7 +26,7 @@ package java.module;
package java.module;
/**
- * This interface represents a module initializer of a module definition. The
+ * This interface represents a module initializer of a module instance. The
* initializer is invoked when the module system initializes a module instance,
* and when that module instance is released from the module system.
* <p>
@@ -61,12 +61,11 @@ public interface ModuleInitializer {
* <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
+ * implementation 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 {@code ModuleInitializer}
- * belongs.
+ * @param module the {@code Module} instance to be initialized.
* @throws ModuleInitializationException if this {@code ModuleInitializer}
* fails to initialize.
*/
@@ -85,13 +84,13 @@ public interface ModuleInitializer {
* <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
+ * the implementation 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
- * implementations of this method attempt to reset some states or
+ * implementation 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.
@@ -101,8 +100,7 @@ public interface ModuleInitializer {
* {@link #initialize(Module) initialize(Module)} method has been invoked
* successfully.
*
- * @param module the module instance that this {@code ModuleInitializer}
- * belongs.
+ * @param module the {@code Module} instance to be released.
*/
public void release(Module module);
}
--- a/src/share/classes/java/module/ModuleSystem.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/java/module/ModuleSystem.java Sat Apr 19 03:38:14 2008 -0700
@@ -31,8 +31,8 @@ import java.util.concurrent.ThreadFactor
/**
* This class represents a module system. A module system is responsible for
- * instantiating a module instance from a module definition, and managing its
- * lifetime.
+ * instantiating module instances from module definitions, and managing their
+ * lifetimes.
* <p>
* @see java.module.Module
* @see java.module.ModuleDefinition
@@ -58,12 +58,15 @@ public abstract class ModuleSystem {
* {@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}.
+ * If there is an existing, unreleased {@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 the {@code ModuleDefinition} which designates the
+ * {@code Module} to be returned
+ * @return a {@code Module} instance corresponding to
+ * {@code ModuleDefinition}.
* @throws ModuleInitializationException if the {@code Module} instance
* cannot be initialized.
* @throws IllegalStateException if the specified {@code ModuleDefinition}
@@ -75,8 +78,8 @@ public abstract class ModuleSystem {
* Releases an existing {@code Module} instance corresponding to the
* 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
+ * If this {@code ModuleSystem} has a {@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
@@ -87,9 +90,9 @@ public abstract class ModuleSystem {
* <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} method
- * returns false also cannot be released.
+ * cannot be released. {@code Module} instances corresponding to
+ * {@code ModuleDefinition} that their {@code isModuleReleasable} method
+ * returns {@code false} also cannot be released.
* <p>
* If a security manager is present, this method calls the security
* manager's {@code checkPermission} method with a
@@ -114,10 +117,10 @@ public abstract class ModuleSystem {
* 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.
+ * {@code ModuleDefinition} throw an {@code IllegalStateException}.
+ * <p>
+ * {@code ModuleDefinition} instances 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
@@ -125,7 +128,8 @@ public abstract class ModuleSystem {
* ensure it's ok to disable the specified {@code ModuleDefinition} in this
* {@code ModuleSystem}.
*
- * @param moduleDef a {@code ModuleDefinition} object.
+ * @param moduleDef the {@code ModuleDefinition} which specifies the module
+ * to be disabled.
* @throws SecurityException if a security manager exists and its
* {@code checkPermission} method denies access to disable the
* specified {@code ModuleDefinition} in this {@code ModuleSystem}.
@@ -145,7 +149,6 @@ public abstract class ModuleSystem {
if (defaultImpl == null) {
defaultImpl = sun.module.core.ModuleSystemImpl.INSTANCE;
}
- // TODO: check system property
return defaultImpl;
}
--- a/src/share/classes/java/module/ModuleSystemListener.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/java/module/ModuleSystemListener.java Sat Apr 19 03:38:14 2008 -0700
@@ -31,13 +31,12 @@ import java.util.EventListener;
* The listener interface for receiving module system events.
* <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}
- * method.
+ * this interface. Instances of that class register with a module system,
+ * using the module system's {@code addModuleSystemListener} static 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} method.
+ * Listeners that are no longer interested in processing any module system
+ * events can be unregistered with the module system, using the module system's
+ * {@code removedModuleSystemListener} static method.
*
* @see java.module.ModuleSystem
* @see java.module.ModuleSystemEvent
--- a/src/share/classes/java/module/ModuleSystemPermission.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/java/module/ModuleSystemPermission.java Sat Apr 19 03:38:14 2008 -0700
@@ -117,25 +117,25 @@ at the permission allows, and associated
* </tr>
* <tr>
* <td>addModuleSystemListener</td>
- * <td>Adds a module system listener to the module systems.</td>
+ * <td>Adds a module system listener that listens to all module systems.</td>
* <td>This allows an attacker to monitor the module system events in the
* module systems.</td>
* </tr>
* <tr>
* <td>removeModuleSystemListener</td>
- * <td>Removes a module system listener to the module systems.</td>
+ * <td>Removes a module system listener from listening to any module systems.</td>
* <td>This allows an attacker to remove a system-provided module system
* listener from the module systems.</td>
* </tr>
* <tr>
* <td>addRepositoryListener</td>
- * <td>Adds a repository listener to the repositories.</td>
+ * <td>Adds a repository listener that listens to all repositories.</td>
* <td>This allows an attacker to monitor the repository events in the
* repositories.</td>
* </tr>
* <tr>
* <td>removeRepositoryListener</td>
- * <td>Removes a repository listener to the repositories.</td>
+ * <td>Removes a repository listener from listening to any repositories.</td>
* <td>This allows an attacker to remove a system-provided repository
* listener from the repositories.</td>
* </tr>
--- a/src/share/classes/java/module/Modules.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/java/module/Modules.java Sat Apr 19 03:38:14 2008 -0700
@@ -39,9 +39,9 @@ import sun.module.repository.URLReposito
/**
* This class consists exclusively of static methods that are specifically for
- * 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
+ * the default module system. It contains methods which construct module
+ * definitions that are defined by the default module system. It also contains
+ * methods that construct the local repository and URL repository. In
* addition, it contains methods for setting or getting the system's visibility
* policy and import override policy.
*
@@ -99,7 +99,7 @@ public class Modules {
* to create a new {@code Repository} instance.
* @throws IOException if the repository cannot be constructed and
* initialized.
- * @throws IllegalArgumentException if circularity is detected.
+ * @throws IllegalArgumentException if a circularity is detected.
*/
public static Repository newLocalRepository(Repository parent, String name, File source)
throws IOException {
@@ -152,7 +152,7 @@ public class Modules {
* to create a new repository instance.
* @throws IOException if the repository cannot be constructed and
* initialized.
- * @throws IllegalArgumentException if circularity is detected.
+ * @throws IllegalArgumentException if a circularity is detected.
*/
public static Repository newLocalRepository(Repository parent, String name,
File source, Map<String, String> config)
@@ -258,7 +258,7 @@ public class Modules {
* to create a new repository instance.
* @throws IOException if the repository cannot be constructed and
* initialized.
- * @throws IllegalArgumentException if circularity is detected.
+ * @throws IllegalArgumentException if a circularity is detected.
*/
public static Repository newURLRepository(Repository parent, String name, URL codebase)
throws IOException {
@@ -405,7 +405,7 @@ public class Modules {
* 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..
+ * override policy.
*
* @param policy the import override policy for module definitions.
* @throws SecurityException if a security manager exists and its
@@ -425,7 +425,7 @@ public class Modules {
/**
* Returns the system's default visibility policy for module definitions
- * in the repositories..
+ * in the repositories.
* <p>
* The default class of the visibility policy can be overridden using the
* {@code java.module.visibility.policy.classname} system property.
@@ -484,16 +484,17 @@ public class Modules {
* <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 metadata an array of bytes which is the content of the
+ * {@code MODULE-INF/METADATA.MODULE} file
* @param content the {@code ModuleContent} to be used to access the
* contents of the module archive
* @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
+ * @param moduleReleasable true if the module instance instantiated from
+ * this {@code ModuleDefinition} is releasable from its module
+ * system
* @throws ModuleFormatException if the contents of {@code metadata}
- * are not recognized or well formed.
+ * are not recognized or are not well formed.
* @return a new {@code ModuleDefinition}.
*/
public static ModuleDefinition newJamModuleDefinition(byte[] metadata,
@@ -525,12 +526,14 @@ public class Modules {
* @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
+ * as an array of bytes
* @param content the {@code ModuleContent} to be used to access the
* contents of the module archive
* @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
+ * @param moduleReleasable true if 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,
--- a/src/share/classes/sun/module/config/DefaultImportOverridePolicy.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/sun/module/config/DefaultImportOverridePolicy.java Sat Apr 19 03:38:14 2008 -0700
@@ -28,6 +28,7 @@ import java.io.File;
import java.io.File;
import java.io.IOException;
import java.module.ModuleDefinition;
+import java.module.ImportDependency;
import java.module.ImportOverridePolicy;
import java.module.Version;
import java.module.VersionConstraint;
@@ -163,24 +164,24 @@ public class DefaultImportOverridePolicy
}
/**
- * Returns a map of imported module names and overridden version constraints
+ * Returns a map of import dependencies and overridden version constraints
* for the module definition. The returned map contains the same set of
- * module names as the given map.
+ * import dependencies as the given map.
*
* @param importer the importing module definition.
- * @param originalConstraints an unmodifiable map of imported module names and
- * overridden version constraints.
- * @return the map of imported module names and overridden version
- * constraints. It contains the same set of module names as the
- * given map.
- */
- public Map<String,VersionConstraint> narrow(ModuleDefinition importer,
- Map<String,VersionConstraint> originalConstraints) {
-
- Set<Map<String,VersionConstraint> > newConstraintsSet = new HashSet<Map<String,VersionConstraint> >();
+ * @param originalConstraints an unmodifiable map of import dependencies
+ * and overridden version constraints.
+ * @return the map of import dependencies and overridden version
+ * constraints. It contains the same set of import dependencies as
+ * in the given map.
+ */
+ public Map<ImportDependency,VersionConstraint> narrow(ModuleDefinition importer,
+ Map<ImportDependency,VersionConstraint> originalConstraints) {
+
+ Set<Map<ImportDependency,VersionConstraint> > newConstraintsSet = new HashSet<Map<ImportDependency,VersionConstraint> >();
for (ImportOverridePolicy policy : policies) {
- Map<String,VersionConstraint> newConstraints = policy.narrow(importer, originalConstraints);
+ Map<ImportDependency,VersionConstraint> newConstraints = policy.narrow(importer, originalConstraints);
if (newConstraints != originalConstraints) {
// Added constraints only if they are different than the original ones.
newConstraintsSet.add(newConstraints);
@@ -193,31 +194,31 @@ public class DefaultImportOverridePolicy
return originalConstraints;
// Otherwise, determine the intersected constraint from all policies
- Map<String,VersionConstraint> result = null;
-
- for (Map.Entry<String,VersionConstraint> entry: originalConstraints.entrySet()) {
+ Map<ImportDependency,VersionConstraint> result = null;
+
+ for (Map.Entry<ImportDependency,VersionConstraint> entry: originalConstraints.entrySet()) {
// Determines intersecting version constraint between
// import override policies
- String name = entry.getKey();
+ ImportDependency dep = entry.getKey();
VersionConstraint originalvcs = entry.getValue();
VersionConstraint vcs = originalvcs;
- for (Map<String,VersionConstraint> constraints : newConstraintsSet) {
-
- vcs = vcs.intersection(constraints.get(name));
+ for (Map<ImportDependency,VersionConstraint> constraints : newConstraintsSet) {
+
+ vcs = vcs.intersection(constraints.get(dep));
if (vcs == null)
throw new IllegalArgumentException("The overridden version constraint "
+ " is outside the known range of the original version constraint "
- + originalConstraints.get(name));
+ + originalConstraints.get(dep));
}
if (originalvcs.equals(vcs) == false) {
if (result == null) {
- result = new HashMap<String,VersionConstraint>(originalConstraints);
+ result = new HashMap<ImportDependency,VersionConstraint>(originalConstraints);
}
- result.put(name, vcs);
+ result.put(dep, vcs);
}
}
--- a/src/share/classes/sun/module/config/ImportOverridePolicyFile.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/sun/module/config/ImportOverridePolicyFile.java Sat Apr 19 03:38:14 2008 -0700
@@ -33,6 +33,7 @@ import java.module.ModuleDefinition;
import java.module.ModuleDefinition;
import java.module.Version;
import java.module.VersionConstraint;
+import java.module.ImportDependency;
import java.module.ImportOverridePolicy;
import java.net.URL;
import java.util.ArrayList;
@@ -45,24 +46,24 @@ import sun.module.Debug;
* This class represents an import override policy file. It consists of zero
* or more entries in the following format:
*
- * importer <importer-module-name> [@ <version-constraint>] {
- * <imported-module-name> @ <overridden-version-constraint>;
+ * module <importer-module-name> [@ <version-constraint>] {
+ * import <type> <imported-name> @ <overridden-version-constraint>;
* ...
* };
*
* For example,
- * importer x.y.z @ [1.0, 1.1) {
- * a.b.c @ 1.7.1;
- * p.q.r @ 2.3.4;
+ * module x.y.z @ [1.0, 1.1) {
+ * import module a.b.c @ 1.7.1;
+ * import module p.q.r @ 2.3.4;
* };
* ....
*
- * Each entry must begin with "importer", followed by the module name and the
- * version constraint for the importer. If the version constraint is not present,
- * the default version constraint is assumed.
+ * Each entry must begin with "module", followed by the module name and the
+ * version constraint for the importer. If the version constraint is not
+ * present, the default version constraint is assumed.
*
* Inside each entry, it contains zero or more sub-entry. Each sub-entry begins
- * with the imported module name, followed by the overridden version constraint.
+ * with the import type, name, followed by the overridden version constraint.
*
* The importer module name may be set to the wildcard value, "*", which allows
* it to match any importer module. In addition, the module name may be suffixed
@@ -70,18 +71,18 @@ import sun.module.Debug;
* has the module name's prefix.
*
* For example,
- * importer * {
- * a.b.c @ [1.7, 1.8);
- * p.q.r @ [2.3, 2.4);
+ * module * {
+ * import module a.b.c @ [1.7, 1.8);
+ * import module p.q.r @ [2.3, 2.4);
* };
*
- * importer x.y.* @ [1.0, 1.1) {
- * a.b.c @ [1.7, 1.8);
- * p.q.r @ [2.3, 2.4);
+ * module x.y.* @ [1.0, 1.1) {
+ * import module a.b.c @ [1.7, 1.8);
+ * import module p.q.r @ [2.3, 2.4);
* };
*
- * When setting the <importer-module-name>, <version-constraint>,
- * <imported-module-name>, or <overridden-version-constraint>, do not surround
+ * When setting the <importer-module-name>, <version-constraint>, <type>,
+ * <imported-name>, or <overridden-version-constraint>, do not surround
* it with quotes.
*
* When determining the import overridden constraints for a module, each entry
@@ -169,18 +170,18 @@ public final class ImportOverridePolicyF
}
/**
- * Returns a map of imported module names and overridden version constraints
+ * Returns a map of import dependencies and overridden version constraints
* for the module definition. The returned map contains the same set of
- * module names as the given map.
+ * import dependencies as in the given map.
*
* @param importer the importing module definition.
- * @param constraints an unmodifiable map of imported module names and
+ * @param constraints an unmodifiable map of import dependencies and
* overridden version constraints.
- * @return the map of imported module names and overridden version
- * constraints. It contains the same set of module names as the
- * given map.
+ * @return the map of import dependencies and overridden version
+ * constraints. It contains the same set of import dependencies as
+ * in the given map.
*/
- public Map<String,VersionConstraint> narrow(ModuleDefinition importer, Map<String,VersionConstraint> originalConstraints) {
+ public Map<ImportDependency,VersionConstraint> narrow(ModuleDefinition importer, Map<ImportDependency,VersionConstraint> originalConstraints) {
String name = importer.getName();
Version version = importer.getVersion();
@@ -192,18 +193,18 @@ public final class ImportOverridePolicyF
if (entry.contains(name, version) == false)
continue;
- Map<String,VersionConstraint> result = null;
- Map<String,VersionConstraint> newConstraints = entry.getOverriddenVersionConstraint();
-
- for (Map.Entry<String,VersionConstraint> originalEntry : originalConstraints.entrySet()) {
-
- String key = originalEntry.getKey();
+ Map<ImportDependency,VersionConstraint> result = null;
+ Map<String,VersionConstraint> newConstraintsInPolicyFile = entry.getOverriddenVersionConstraint();
+
+ for (Map.Entry<ImportDependency,VersionConstraint> originalEntry : originalConstraints.entrySet()) {
+ ImportDependency dep = originalEntry.getKey();
+ String key = dep.getType() + ":" + dep.getName();
// Original version constraint
VersionConstraint originalvcs = originalEntry.getValue();
// Overridden version constraint
- VersionConstraint overriddenvcs = newConstraints.get(key);
+ VersionConstraint overriddenvcs = newConstraintsInPolicyFile.get(key);
// The overridden version constraint must be within the known range of the
// original version constraint.
@@ -214,10 +215,10 @@ public final class ImportOverridePolicyF
+ " is outside the known range of the original version constraint " + originalvcs);
if (result == null) {
- result = new HashMap<String,VersionConstraint>(originalConstraints);
+ result = new HashMap<ImportDependency,VersionConstraint>(originalConstraints);
}
- result.put(key, overriddenvcs);
+ result.put(dep, overriddenvcs);
}
}
@@ -424,15 +425,15 @@ public final class ImportOverridePolicyF
/**
* Parses an importer entry. Each entry is in the following format:
*
- * importer <importer-name> [@ <importer-version-constraint>] {
- * <imported-name> @ <overridden-version-constraint>;
+ * module <importer-name> [@ <importer-version-constraint>] {
+ * import <type> <imported-name> @ <overridden-version-constraint>;
* ...
* };
*/
private void parseImporterEntry() throws IOException {
- // "importer"
- match("importer");
+ // "module"
+ match("module");
// <importer-name>
String name = match(STRING_TOKEN);
@@ -482,12 +483,18 @@ public final class ImportOverridePolicyF
Map<String, VersionConstraint> overriddenConstraints = new HashMap<String, VersionConstraint>();
while(peek("}") == false) {
- // <imported-module-name>
- String importedModule = match(STRING_TOKEN);
+ // "import"
+ match("import");
+
+ // <type>
+ String importedType = match(STRING_TOKEN);
+
+ // <imported-name>
+ String importedName = match(STRING_TOKEN);
// No wildcard in <imported-module-name>
- if (importedModule.indexOf("*") != -1)
- throw new ParsingException(st.lineno(), "no wildcard in <imported-module-name>", importedModule);
+ if (importedName.indexOf("*") != -1)
+ throw new ParsingException(st.lineno(), "no wildcard in <imported-name>", importedName);
match("@");
@@ -504,10 +511,12 @@ public final class ImportOverridePolicyF
throw new ParsingException(st.lineno(), "missing <overridden-version-constraint>");
VersionConstraint overriddenVersionConstraint = VersionConstraint.valueOf(vcsBuffer.toString());
- overriddenConstraints.put(importedModule, overriddenVersionConstraint);
+
+ String key = importedType + ":" + importedName;
+ overriddenConstraints.put(key, overriddenVersionConstraint);
if (mdebug != null)
- mdebug.println(" imported-module-name=" + importedModule
+ mdebug.println(" type=" + importedType + ", imported-name=" + importedName
+ ", overridden-version-constraint=" + overriddenVersionConstraint);
match(";");
--- a/src/share/classes/sun/module/core/ModuleImpl.java Fri Apr 18 01:02:32 2008 -0700
+++ b/src/share/classes/sun/module/core/ModuleImpl.java Sat Apr 19 03:38:14 2008 -0700
@@ -473,10 +473,10 @@ final class ModuleImpl extends Module {
}
// Build version constraint map from the ImportDependencies
- Map<String,VersionConstraint> versionConstraints = new HashMap<String,VersionConstraint>();
+ Map<ImportDependency,VersionConstraint> versionConstraints = new HashMap<ImportDependency,VersionConstraint>();
for (ImportDependency dep : importDependencies) {
- if (versionConstraints.put(dep.getName(), dep.getVersionConstraint()) != null) {
- fail(null, "Module " + moduleString + " imports module "
+ if (versionConstraints.put(dep, dep.getVersionConstraint()) != null) {
+ fail(null, "Module " + moduleString + " imports " + dep.getType() + " "
+ dep.getName() + " more than once.");
}
}
@@ -486,14 +486,28 @@ final class ModuleImpl extends Module {
versionConstraints = callOverridePolicy(versionConstraints);
// Invoke default or custom import policy
- List<ModuleDefinition> importedMDs = callImportPolicy(versionConstraints);
+ Map<ImportDependency,VersionConstraint> result = callImportPolicy(versionConstraints);
// Get a Module instance for each imported ModuleDefinition
- for (ModuleDefinition importedMD : importedMDs) {
- if (importedMD == null) {
+ Repository repository = moduleDef.getRepository();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ if (dep.getType().equals("module") == false) {
+ // XXX: supports module dependency only at this point
+ fail(null, "Unrecognized import dependency type in module " + moduleString
+ + ": import " + dep.getType() + " " + dep.getName()
+ + " " + dep.getVersionConstraint());
+ }
+
+ // Retreives overriden version constraint for the dependency
+ VersionConstraint vc = result.get(dep);
+
+ // Checks if this dependency is optional
+ if (dep.isOptional() && vc == null) {
continue;
}
- ModuleSystem importedModuleSystem = importedMD.getRepository().getModuleSystem();
+
+ ModuleDefinition importedMD = repository.find(dep.getName(), vc);
+ ModuleSystem importedModuleSystem = importedMD.getModuleSystem();
if (importedModuleSystem == moduleSystem) {
// Get the raw module instance from the module system.
// If it has not been initialized yet, it is automatically
@@ -509,39 +523,40 @@ final class ModuleImpl extends Module {
}
// Invoke ImportOverridePolicy
- private Map<String,VersionConstraint> callOverridePolicy
- (Map<String,VersionConstraint> versionConstraints)
+ private Map<ImportDependency,VersionConstraint> callOverridePolicy
+ (Map<ImportDependency,VersionConstraint> versionConstraints)
throws ModuleInitializationException {
ImportOverridePolicy overridePolicy = Modules.getImportOverridePolicy();
if (overridePolicy == null) {
return versionConstraints;
}
- Map<String,VersionConstraint> newConstraints
+ Map<ImportDependency,VersionConstraint> newConstraints
= overridePolicy.narrow(moduleDef, versionConstraints);
// check constraints, unless the override policy just returned
// the original constraints Map
if (newConstraints != versionConstraints) {
// make a copy before checking
- newConstraints = new HashMap<String,VersionConstraint>(newConstraints);
+ newConstraints = new HashMap<ImportDependency,VersionConstraint>(newConstraints);
if (versionConstraints.size() != newConstraints.size()) {
fail(null, "Import override policy error in module " + moduleString
- + ": size mismatch in the returned map of imported "
- + "module names and overridden version constraints: "
+ + ": size mismatch in the returned map of import "
+ + "dependencies and overridden version constraints: "
+ versionConstraints.size() + " != " + newConstraints.size());
}
- for (Map.Entry<String,VersionConstraint> entry : versionConstraints.entrySet()) {
- String moduleName = entry.getKey();
+ for (Map.Entry<ImportDependency,VersionConstraint> entry : versionConstraints.entrySet()) {
+ ImportDependency dep = entry.getKey();
VersionConstraint constraint = entry.getValue();
- VersionConstraint newConstraint = newConstraints.get(moduleName);
+ VersionConstraint newConstraint = newConstraints.get(dep);
if (newConstraint == null) {
fail(null, "Import override policy error in module " + moduleString
+ ": overridden version constraint missing in the "
- + "returned map for module " + moduleName);
+ + "returned map for import " + dep.getType()
+ + " dependency " + dep.getName());
}
if (constraint.contains(newConstraint) == false) {
fail(null, "Import override policy error in module " + moduleString
+ ": overridden version constraint " + newConstraint
- + " for imported module " + moduleName
+ + " for import " + dep.getType() + " dependency " + dep.getName()
+ " is outside the boundary of the original "
+ "version constraint "+ constraint);
}
@@ -551,8 +566,8 @@ final class ModuleImpl extends Module {
}
// Invoke default or custom import policy
- private List<ModuleDefinition> callImportPolicy
- (Map<String,VersionConstraint> versionConstraints)
+ private Map<ImportDependency,VersionConstraint> callImportPolicy
+ (Map<ImportDependency,VersionConstraint> versionConstraints)
throws ModuleInitializationException {
ImportPolicyClass importClass = moduleDef.getAnnotation(ImportPolicyClass.class);
String importPolicyName = (importClass != null) ? importClass.value() : null;
@@ -575,46 +590,46 @@ final class ModuleImpl extends Module {
// not reached
}
ImportPolicy importPolicy = (ImportPolicy)obj;
- List<ModuleDefinition> importedMDs = importPolicy.getImports(moduleDef,
+ Map<ImportDependency,VersionConstraint> result = importPolicy.getImports(moduleDef,
versionConstraints, DefaultImportPolicy.INSTANCE);
// make copy before checking
- importedMDs = new ArrayList<ModuleDefinition>(importedMDs);
- // Verify that all the returned ModuleDefinitions match the
+ result = new HashMap<ImportDependency, VersionConstraint>(result);
+
+ // Verify that all the returned ImportDependency match the
// import dependencies in order, name, and version constraints
// and that no non-optional imports are missing
- int n = importedMDs.size();
- List<ImportDependency> importDependencies = moduleDef.getImportDependencies();
+ int n = result.size();
+ Set<ImportDependency> importDependencies = new HashSet<ImportDependency>(moduleDef.getImportDependencies());
if (n != importDependencies.size()) {
fail(null, "Import policy error in module " + moduleString
- + ": mismatch in number of imported module definition in the returned list: "
+ + ": mismatch in number of imports in the returned map: "
+ n + " != " + importDependencies.size());
}
- for (int i = 0; i < n; i++) {
- ImportDependency dep = importDependencies.get(i);
- ModuleDefinition md = importedMDs.get(i);
- if (md == null) {
+
+ if (!(importDependencies.containsAll(result.keySet())
+ && result.keySet().containsAll(importDependencies))) {
+ fail(null, "Import policy error in module " + moduleString
+ + ": the returned map does not contain all the import dependencies");
+ }
+
+ for (ImportDependency dep : importDependencies) {
+ VersionConstraint vc = result.get(dep);
+ if (vc == null) {
if (dep.isOptional() == false) {
fail(null, "Import policy error in module " + moduleString
- + ": non-optional imported module definition is missing in the returned list: "
+ + ": non-optional import dependency is missing in the returned map: "
+ dep.getName() + " " + dep.getVersionConstraint());
}
continue;
}
- String name = dep.getName();
- if (name.equals(md.getName()) == false) {
+ if (dep.getVersionConstraint().contains(vc) == false) {
fail(null, "Import policy error in module " + moduleString
- + ": mismatch in the name of imported module definition in the returned list: "
- + name + " != " + md.getName());
- }
- Version version = md.getVersion();
- VersionConstraint constraint = versionConstraints.get(name);
- if (constraint.contains(version) == false) {
- fail(null, "Import policy error in module " + moduleString
- + ": " + toString(md)
- + " in the returned list does not satisfy version constraint " + constraint);
- }
- }
- return importedMDs;
+ + ": import " + dep.getType() + " " + dep.getName()
+ + " in the returned map does not satisfy version constraint " + dep.getVersionConstraint());
+ }
+ }
+
+ return result;
}
// Default import policy implementation
@@ -626,21 +641,25 @@ final class ModuleImpl extends Module {
// empty
}
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
throws ModuleInitializationException {
String moduleString = moduleDef.getName() + " v" + moduleDef.getVersion();
- List<ModuleDefinition> importedMDs = new ArrayList<ModuleDefinition>();
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
Repository rep = moduleDef.getRepository();
List<ImportDependency> importDependencies = moduleDef.getImportDependencies();
for (ImportDependency dep : importDependencies) {
-
+ // XXX handle only module dependency at this point
+ //
+ if (dep.getType().equals("module") == false) {
+ continue;
+ }
String name = dep.getName();
- VersionConstraint constraint = constraints.get(name);
+ VersionConstraint constraint = constraints.get(dep);
if (constraint == null) {
throw new ModuleInitializationException
("Default import policy error in module " + moduleString
- + ": overridden version constraint is missing for imported module " + name);
+ + ": overridden version constraint is missing for import " + dep.getType() + " " + name);
}
ModuleDefinition importedMD = rep.find(name, constraint);
if (DEBUG) System.out.println("Imported module definition: " + importedMD);
@@ -657,9 +676,9 @@ final class ModuleImpl extends Module {
}
continue;
}
- importedMDs.add(importedMD);
- }
- return Collections.unmodifiableList(importedMDs);
+ result.put(dep, importedMD.getVersion().toVersionConstraint());
+ }
+ return Collections.unmodifiableMap(result);
}
}
--- a/test/java/module/config/DefaultImportOverridePolicy/Another.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/DefaultImportOverridePolicy/Another.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -2,8 +2,8 @@
*
*/
-importer a.b.c @ 1.0 {
- p.q.r @ [1.7.0, 1.7.1);
- x.y.z @ [2.3.4, 2.3.5);
+module a.b.c @ 1.0 {
+ import module p.q.r @ [1.7.0, 1.7.1);
+ import module x.y.z @ [2.3.4, 2.3.5);
};
--- a/test/java/module/config/DefaultImportOverridePolicy/BadNarrowing.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/DefaultImportOverridePolicy/BadNarrowing.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,8 +1,8 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
// original constraint is 1+. Error!
- x.y.z @ [0.2, 4.0);
+ import module x.y.z @ [0.2, 4.0);
};
--- a/test/java/module/config/DefaultImportOverridePolicy/DefaultImportOverridePolicyTest.java Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/DefaultImportOverridePolicy/DefaultImportOverridePolicyTest.java Sat Apr 19 03:38:14 2008 -0700
@@ -150,40 +150,47 @@ public class DefaultImportOverridePolicy
testBadNarrowing01();
}
+ static ImportDependency newImportDependency(String name) {
+ return new ImportDependency("module", name, VersionConstraint.DEFAULT, false, false, null);
+ }
+
static public void testConstructor01() throws Exception {
try {
MockModuleDefinition moduleDef = new MockModuleDefinition("a.b.c", Version.valueOf(1, 0, 0));
- Map<String, VersionConstraint> originalConstraints = new HashMap<String, VersionConstraint>();
- originalConstraints.put("e.f.g", VersionConstraint.valueOf("1.0+"));
- originalConstraints.put("p.q.r", VersionConstraint.valueOf("1.0+"));
- originalConstraints.put("x.y.z", VersionConstraint.valueOf("1.0+"));
+ Map<ImportDependency, VersionConstraint> originalConstraints = new HashMap<ImportDependency, VersionConstraint>();
+ ImportDependency importDep1 = newImportDependency("e.f.g");
+ ImportDependency importDep2 = newImportDependency("p.q.r");
+ ImportDependency importDep3 = newImportDependency("x.y.z");
+ originalConstraints.put(importDep1, VersionConstraint.valueOf("1.0+"));
+ originalConstraints.put(importDep2, VersionConstraint.valueOf("1.0+"));
+ originalConstraints.put(importDep3, VersionConstraint.valueOf("1.0+"));
File f = new File(System.getProperty("test.src", "."), "WellFormed.import.override.policy");
ModuleSystemConfig.setProperty(ModuleSystemConfig.IMPORT_OVERRIDE_POLICY_URL_PREFIX+2, f.toURI().toURL().toString());
ImportOverridePolicy iop = new DefaultImportOverridePolicy();
- Map<String, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
-
- check(overriddenConstraints.size() == originalConstraints.size());
- check(overriddenConstraints.get("e.f.g").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1.7.0")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("2.3.4")));
+ Map<ImportDependency, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
+
+ check(overriddenConstraints.size() == originalConstraints.size());
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("1.7.0")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("2.3.4")));
moduleDef = new MockModuleDefinition("a.b.z", Version.valueOf(1, 7, 0));
overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
check(overriddenConstraints.size() == originalConstraints.size());
- check(overriddenConstraints.get("e.f.g").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1.8.0")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("2.*")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("1.8.0")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("2.*")));
moduleDef = new MockModuleDefinition("a.b.c", Version.valueOf(2, 0, 0));
overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
check(overriddenConstraints.size() == originalConstraints.size());
- check(overriddenConstraints.get("e.f.g").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("[1.0, 2.0)")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("[2.0, 3.0)")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("[1.0, 2.0)")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("[2.0, 3.0)")));
}
catch (Throwable ex) {
unexpected(ex);
@@ -193,10 +200,13 @@ public class DefaultImportOverridePolicy
static public void testGetDefaultImportOverridePolicy01() throws Exception {
try {
MockModuleDefinition moduleDef = new MockModuleDefinition("a.b.c", Version.valueOf(1, 0, 0));
- Map<String, VersionConstraint> originalConstraints = new HashMap<String, VersionConstraint>();
- originalConstraints.put("e.f.g", VersionConstraint.valueOf("1.0+"));
- originalConstraints.put("p.q.r", VersionConstraint.valueOf("1.0+"));
- originalConstraints.put("x.y.z", VersionConstraint.valueOf("1.0+"));
+ Map<ImportDependency, VersionConstraint> originalConstraints = new HashMap<ImportDependency, VersionConstraint>();
+ ImportDependency importDep1 = newImportDependency("e.f.g");
+ ImportDependency importDep2 = newImportDependency("p.q.r");
+ ImportDependency importDep3 = newImportDependency("x.y.z");
+ originalConstraints.put(importDep1, VersionConstraint.valueOf("1.0+"));
+ originalConstraints.put(importDep2, VersionConstraint.valueOf("1.0+"));
+ originalConstraints.put(importDep3, VersionConstraint.valueOf("1.0+"));
ModuleSystemConfig.setProperty(ModuleSystemConfig.IMPORT_OVERRIDE_POLICY_URL_PREFIX+2, "");
ImportOverridePolicy iop = Modules.getImportOverridePolicy();
@@ -206,8 +216,8 @@ public class DefaultImportOverridePolicy
else
fail();
- Map<String, VersionConstraint> readOnlyOriginalConstraints = Collections.unmodifiableMap(originalConstraints);
- Map<String, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef, readOnlyOriginalConstraints);
+ Map<ImportDependency, VersionConstraint> readOnlyOriginalConstraints = Collections.unmodifiableMap(originalConstraints);
+ Map<ImportDependency, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef, readOnlyOriginalConstraints);
check(overriddenConstraints == readOnlyOriginalConstraints);
}
@@ -217,10 +227,13 @@ public class DefaultImportOverridePolicy
try {
MockModuleDefinition moduleDef = new MockModuleDefinition("a.b.c", Version.valueOf(1, 0, 0));
- Map<String, VersionConstraint> originalConstraints = new HashMap<String, VersionConstraint>();
- originalConstraints.put("e.f.g", VersionConstraint.valueOf("1.0+"));
- originalConstraints.put("p.q.r", VersionConstraint.valueOf("1.0+"));
- originalConstraints.put("x.y.z", VersionConstraint.valueOf("1.0+"));
+ Map<ImportDependency, VersionConstraint> originalConstraints = new HashMap<ImportDependency, VersionConstraint>();
+ ImportDependency importDep1 = newImportDependency("e.f.g");
+ ImportDependency importDep2 = newImportDependency("p.q.r");
+ ImportDependency importDep3 = newImportDependency("x.y.z");
+ originalConstraints.put(importDep1, VersionConstraint.valueOf("1.0+"));
+ originalConstraints.put(importDep2, VersionConstraint.valueOf("1.0+"));
+ originalConstraints.put(importDep3, VersionConstraint.valueOf("1.0+"));
File f = new File(System.getProperty("test.src", "."), "WellFormed.import.override.policy");
ModuleSystemConfig.setProperty(ModuleSystemConfig.IMPORT_OVERRIDE_POLICY_URL_PREFIX+2, f.toURI().toURL().toString());
@@ -235,28 +248,28 @@ public class DefaultImportOverridePolicy
DefaultImportOverridePolicy diop = (DefaultImportOverridePolicy) iop;
diop.refresh();
- Map<String, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
-
- check(overriddenConstraints.size() == originalConstraints.size());
- check(overriddenConstraints.get("e.f.g").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1.7.0")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("2.3.4")));
+ Map<ImportDependency, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
+
+ check(overriddenConstraints.size() == originalConstraints.size());
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("1.7.0")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("2.3.4")));
moduleDef = new MockModuleDefinition("a.b.z", Version.valueOf(1, 7, 0));
overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
check(overriddenConstraints.size() == originalConstraints.size());
- check(overriddenConstraints.get("e.f.g").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1.8.0")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("2.*")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("1.8.0")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("2.*")));
moduleDef = new MockModuleDefinition("a.b.c", Version.valueOf(2, 0, 0));
overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
check(overriddenConstraints.size() == originalConstraints.size());
- check(overriddenConstraints.get("e.f.g").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("[1.0, 2.0)")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("[2.0, 3.0)")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("[1.0, 2.0)")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("[2.0, 3.0)")));
}
catch (Throwable ex) {
unexpected(ex);
@@ -266,10 +279,13 @@ public class DefaultImportOverridePolicy
static public void testSystemPropertyOverride01() throws Exception {
try {
MockModuleDefinition moduleDef = new MockModuleDefinition("a.b.c", Version.valueOf(1, 0, 0));
- Map<String, VersionConstraint> originalConstraints = new HashMap<String, VersionConstraint>();
- originalConstraints.put("e.f.g", VersionConstraint.valueOf("1.0+"));
- originalConstraints.put("p.q.r", VersionConstraint.valueOf("1.0+"));
- originalConstraints.put("x.y.z", VersionConstraint.valueOf("1.0+"));
+ Map<ImportDependency, VersionConstraint> originalConstraints = new HashMap<ImportDependency, VersionConstraint>();
+ ImportDependency importDep1 = newImportDependency("e.f.g");
+ ImportDependency importDep2 = newImportDependency("p.q.r");
+ ImportDependency importDep3 = newImportDependency("x.y.z");
+ originalConstraints.put(importDep1, VersionConstraint.valueOf("1.0+"));
+ originalConstraints.put(importDep2, VersionConstraint.valueOf("1.0+"));
+ originalConstraints.put(importDep3, VersionConstraint.valueOf("1.0+"));
// Pretend like -Djava.module.visibility.policy.file=<url to WellFormed.visibility.policy>
//
@@ -287,39 +303,42 @@ public class DefaultImportOverridePolicy
DefaultImportOverridePolicy diop = (DefaultImportOverridePolicy) iop;
diop.refresh();
- Map<String, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
-
- check(overriddenConstraints.size() == originalConstraints.size());
- check(overriddenConstraints.get("e.f.g").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1.7.0")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("2.3.4")));
+ Map<ImportDependency, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
+
+ check(overriddenConstraints.size() == originalConstraints.size());
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("1.7.0")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("2.3.4")));
moduleDef = new MockModuleDefinition("a.b.z", Version.valueOf(1, 7, 0));
overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
check(overriddenConstraints.size() == originalConstraints.size());
- check(overriddenConstraints.get("e.f.g").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1.8.0")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("2.*")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("1.8.0")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("2.*")));
moduleDef = new MockModuleDefinition("a.b.c", Version.valueOf(2, 0, 0));
overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
check(overriddenConstraints.size() == originalConstraints.size());
- check(overriddenConstraints.get("e.f.g").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("[1.0, 2.0)")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("[2.0, 3.0)")));
- }
- catch (Throwable ex) {
- unexpected(ex);
- }
-
- try {
- MockModuleDefinition moduleDef = new MockModuleDefinition("a.b.c", Version.valueOf(1, 0, 0));
- Map<String, VersionConstraint> originalConstraints = new HashMap<String, VersionConstraint>();
- originalConstraints.put("e.f.g", VersionConstraint.valueOf("1.0+"));
- originalConstraints.put("p.q.r", VersionConstraint.valueOf("1.0+"));
- originalConstraints.put("x.y.z", VersionConstraint.valueOf("1.0+"));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("[1.0, 2.0)")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("[2.0, 3.0)")));
+ }
+ catch (Throwable ex) {
+ unexpected(ex);
+ }
+
+ try {
+ MockModuleDefinition moduleDef = new MockModuleDefinition("a.b.c", Version.valueOf(1, 0, 0));
+ Map<ImportDependency, VersionConstraint> originalConstraints = new HashMap<ImportDependency, VersionConstraint>();
+ ImportDependency importDep1 = newImportDependency("e.f.g");
+ ImportDependency importDep2 = newImportDependency("p.q.r");
+ ImportDependency importDep3 = newImportDependency("x.y.z");
+ originalConstraints.put(importDep1, VersionConstraint.valueOf("1.0+"));
+ originalConstraints.put(importDep2, VersionConstraint.valueOf("1.0+"));
+ originalConstraints.put(importDep3, VersionConstraint.valueOf("1.0+"));
// Pretend "import.override.policy.url.2" is set in the module system properties file
//
@@ -341,28 +360,28 @@ public class DefaultImportOverridePolicy
DefaultImportOverridePolicy diop = (DefaultImportOverridePolicy) iop;
diop.refresh();
- Map<String, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
-
- check(overriddenConstraints.size() == originalConstraints.size());
- check(overriddenConstraints.get("e.f.g").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("[1.7.0, 1.7.1)")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("[2.3.4, 2.3.5)")));
+ Map<ImportDependency, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
+
+ check(overriddenConstraints.size() == originalConstraints.size());
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("[1.7.0, 1.7.1)")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("[2.3.4, 2.3.5)")));
moduleDef = new MockModuleDefinition("a.b.z", Version.valueOf(1, 7, 0));
overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
check(overriddenConstraints.size() == originalConstraints.size());
- check(overriddenConstraints.get("e.f.g").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("1.0+")));
moduleDef = new MockModuleDefinition("a.b.c", Version.valueOf(2, 0, 0));
overriddenConstraints = iop.narrow(moduleDef, Collections.unmodifiableMap(originalConstraints));
check(overriddenConstraints.size() == originalConstraints.size());
- check(overriddenConstraints.get("e.f.g").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1.0+")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("1.0+")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("1.0+")));
}
catch (Throwable ex) {
unexpected(ex);
@@ -389,12 +408,15 @@ public class DefaultImportOverridePolicy
MockModuleDefinition moduleDef1 = new MockModuleDefinition("a.b.c", Version.valueOf(1, 0, 0));
- Map<String, VersionConstraint> constraints = new HashMap<String, VersionConstraint>();
- constraints.put("p.q.r", VersionConstraint.valueOf("1+"));
- constraints.put("x.y.z", VersionConstraint.valueOf("1+"));
- constraints.put("i.j.k", VersionConstraint.valueOf("1+"));
-
- Map<String, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef1, Collections.unmodifiableMap(constraints));
+ Map<ImportDependency, VersionConstraint> constraints = new HashMap<ImportDependency, VersionConstraint>();
+ ImportDependency importDep1 = newImportDependency("e.f.g");
+ ImportDependency importDep2 = newImportDependency("p.q.r");
+ ImportDependency importDep3 = newImportDependency("x.y.z");
+ constraints.put(importDep1, VersionConstraint.valueOf("1+"));
+ constraints.put(importDep2, VersionConstraint.valueOf("1+"));
+ constraints.put(importDep3, VersionConstraint.valueOf("1+"));
+
+ Map<ImportDependency, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef1, Collections.unmodifiableMap(constraints));
fail();
}
catch (Throwable ex) {
--- a/test/java/module/config/DefaultImportOverridePolicy/WellFormed.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/DefaultImportOverridePolicy/WellFormed.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -3,19 +3,19 @@
*/
// Test basics
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
// Test wildcards
-importer a.b.* @ 1.* {
- p.q.r @ 1.8.0;
- x.y.z @ 2.*;
- s.t.u @ 7.8.9;
+module a.b.* @ 1.* {
+ import module p.q.r @ 1.8.0;
+ import module x.y.z @ 2.*;
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/BadComment0.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/BadComment0.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -3,19 +3,19 @@
// Test basic
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
// Test wildcards
-importer a.b.* @ 1.* {
- p.q.r @ 1.8.0;
- x.y.z @ 2.*;
- s.t.u @ 7.8.9;
+module a.b.* @ 1.* {
+ import module p.q.r @ 1.8.0;
+ import module x.y.z @ 2.*;
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/BadComment1.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/BadComment1.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,20 +1,20 @@
// Test basics
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
// Test wildcards
-importer a.b.* @ 1.* {
- p.q.r @ 1.8.0;
- x.y.z @ 2.*;
- s.t.u @ 7.8.9;
+module a.b.* @ 1.* {
+ import module p.q.r @ 1.8.0;
+ import module x.y.z @ 2.*;
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
// Comment without opening "/**"
--- a/test/java/module/config/ImportOverridePolicyFile/BadComment2.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/BadComment2.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,20 +1,20 @@
// Test basics
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
// Test wildcards
-importer a.b.* @ 1.* {
- p.q.r @ 1.8.0;
- x.y.z @ 2.*;
- s.t.u @ 7.8.9;
+module a.b.* @ 1.* {
+ import module p.q.r @ 1.8.0;
+ import module x.y.z @ 2.*;
+ import module s.t.u @ 7.8.9;
};
# This is not a valid comment
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/BadNarrowing.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/BadNarrowing.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,8 +1,8 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
// original constraint is 1+. Error!
- x.y.z @ [0.2, 4.0);
+ import module x.y.z @ [0.2, 4.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/ExcessSemicolon0.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/ExcessSemicolon0.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,18 +1,18 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
-importer a.b.* @ 1.* {
- p.q.r @ 1.8.0;
+module a.b.* @ 1.* {
+ import module p.q.r @ 1.8.0;
// The next entry has more than one semicolon.
- x.y.z @ 2.*;;
- s.t.u @ 7.8.9;
+ import module x.y.z @ 2.*;;
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/ExcessSemicolon1.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/ExcessSemicolon1.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,17 +1,17 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
// The next entry has more than one semicolon.
-importer a.b.* @ 1.* {
- p.q.r @ 1.8.0;
- x.y.z @ 2.*;
- s.t.u @ 7.8.9;
+module a.b.* @ 1.* {
+ import module p.q.r @ 1.8.0;
+ import module x.y.z @ 2.*;
+ import module s.t.u @ 7.8.9;
};;
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/ImportOverridePolicyFileTest.java Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/ImportOverridePolicyFileTest.java Sat Apr 19 03:38:14 2008 -0700
@@ -146,6 +146,10 @@ public class ImportOverridePolicyFileTes
testBadImportOverridePolicyFile();
}
+ static ImportDependency newImportDependency(String name) {
+ return new ImportDependency("module", name, VersionConstraint.DEFAULT, false, false, null);
+ }
+
static public void testGoodImportOverridePolicyFile() throws Exception {
try {
File f = new File(System.getProperty("test.src", "."), "WellFormed.import.override.policy");
@@ -159,46 +163,49 @@ public class ImportOverridePolicyFileTes
MockModuleDefinition moduleDef5 = new MockModuleDefinition("*", Version.valueOf(1, 2, 3));
MockModuleDefinition moduleDef6 = new MockModuleDefinition("x.y.*", Version.valueOf(3, 4, 5));
- Map<String, VersionConstraint> constraints = new HashMap<String, VersionConstraint>();
- constraints.put("p.q.r", VersionConstraint.valueOf("1+"));
- constraints.put("x.y.z", VersionConstraint.valueOf("1+"));
- constraints.put("i.j.k", VersionConstraint.valueOf("1+"));
-
- Map<String, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef1, Collections.unmodifiableMap(constraints));
- check(overriddenConstraints.size() == 3);
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1.7.0")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("2.3.4")));
- check(overriddenConstraints.get("i.j.k").equals(VersionConstraint.valueOf("1+")));
+ Map<ImportDependency, VersionConstraint> constraints = new HashMap<ImportDependency, VersionConstraint>();
+ ImportDependency importDep1 = newImportDependency("p.q.r");
+ ImportDependency importDep2 = newImportDependency("x.y.z");
+ ImportDependency importDep3 = newImportDependency("i.j.k");
+ constraints.put(importDep1, VersionConstraint.valueOf("1+"));
+ constraints.put(importDep2, VersionConstraint.valueOf("1+"));
+ constraints.put(importDep3, VersionConstraint.valueOf("1+"));
+
+ Map<ImportDependency, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef1, Collections.unmodifiableMap(constraints));
+ check(overriddenConstraints.size() == 3);
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.7.0")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("2.3.4")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("1+")));
overriddenConstraints = iop.narrow(moduleDef2, Collections.unmodifiableMap(constraints));
check(overriddenConstraints.size() == 3);
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1.8.0")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("2.*")));
- check(overriddenConstraints.get("i.j.k").equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1.8.0")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("2.*")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("1+")));
overriddenConstraints = iop.narrow(moduleDef3, Collections.unmodifiableMap(constraints));
check(overriddenConstraints.size() == 3);
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("[1, 2)")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("[2, 3)")));
- check(overriddenConstraints.get("i.j.k").equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("[1, 2)")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("[2, 3)")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("1+")));
overriddenConstraints = iop.narrow(moduleDef4, Collections.unmodifiableMap(constraints));
check(overriddenConstraints.size() == 3);
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("[1, 2)")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("[2, 3)")));
- check(overriddenConstraints.get("i.j.k").equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("[1, 2)")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("[2, 3)")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("1+")));
overriddenConstraints = iop.narrow(moduleDef5, Collections.unmodifiableMap(constraints));
check(overriddenConstraints.size() == 3);
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("[1, 2)")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("[2, 3)")));
- check(overriddenConstraints.get("i.j.k").equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("[1, 2)")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("[2, 3)")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("1+")));
overriddenConstraints = iop.narrow(moduleDef6, Collections.unmodifiableMap(constraints));
check(overriddenConstraints.size() == 3);
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("[1, 2)")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("[2, 3)")));
- check(overriddenConstraints.get("i.j.k").equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("[1, 2)")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("[2, 3)")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("1+")));
}
catch (Throwable ex) {
unexpected(ex);
@@ -214,34 +221,37 @@ public class ImportOverridePolicyFileTes
MockModuleDefinition moduleDef3 = new MockModuleDefinition("*", Version.valueOf(1, 2, 3));
MockModuleDefinition moduleDef4 = new MockModuleDefinition("x.y.*", Version.valueOf(3, 4, 5));
- Map<String, VersionConstraint> constraints = new HashMap<String, VersionConstraint>();
- constraints.put("p.q.r", VersionConstraint.valueOf("1+"));
- constraints.put("x.y.z", VersionConstraint.valueOf("1+"));
- constraints.put("i.j.k", VersionConstraint.valueOf("1+"));
-
- Map<String, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef1, Collections.unmodifiableMap(constraints));
- check(overriddenConstraints.size() == 3);
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1+")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("1+")));
- check(overriddenConstraints.get("i.j.k").equals(VersionConstraint.valueOf("1+")));
+ Map<ImportDependency, VersionConstraint> constraints = new HashMap<ImportDependency, VersionConstraint>();
+ ImportDependency importDep1 = newImportDependency("p.q.r");
+ ImportDependency importDep2 = newImportDependency("x.y.z");
+ ImportDependency importDep3 = newImportDependency("i.j.k");
+ constraints.put(importDep1, VersionConstraint.valueOf("1+"));
+ constraints.put(importDep2, VersionConstraint.valueOf("1+"));
+ constraints.put(importDep3, VersionConstraint.valueOf("1+"));
+
+ Map<ImportDependency, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef1, Collections.unmodifiableMap(constraints));
+ check(overriddenConstraints.size() == 3);
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("1+")));
overriddenConstraints = iop.narrow(moduleDef2, Collections.unmodifiableMap(constraints));
check(overriddenConstraints.size() == 3);
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1+")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("1+")));
- check(overriddenConstraints.get("i.j.k").equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("1+")));
overriddenConstraints = iop.narrow(moduleDef3, Collections.unmodifiableMap(constraints));
check(overriddenConstraints.size() == 3);
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1+")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("1+")));
- check(overriddenConstraints.get("i.j.k").equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("1+")));
overriddenConstraints = iop.narrow(moduleDef4, Collections.unmodifiableMap(constraints));
check(overriddenConstraints.size() == 3);
- check(overriddenConstraints.get("p.q.r").equals(VersionConstraint.valueOf("1+")));
- check(overriddenConstraints.get("x.y.z").equals(VersionConstraint.valueOf("1+")));
- check(overriddenConstraints.get("i.j.k").equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep1).equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep2).equals(VersionConstraint.valueOf("1+")));
+ check(overriddenConstraints.get(importDep3).equals(VersionConstraint.valueOf("1+")));
}
catch (Throwable ex) {
unexpected(ex);
@@ -436,12 +446,15 @@ public class ImportOverridePolicyFileTes
MockModuleDefinition moduleDef1 = new MockModuleDefinition("a.b.c", Version.valueOf(1, 0, 0));
- Map<String, VersionConstraint> constraints = new HashMap<String, VersionConstraint>();
- constraints.put("p.q.r", VersionConstraint.valueOf("1+"));
- constraints.put("x.y.z", VersionConstraint.valueOf("1+"));
- constraints.put("i.j.k", VersionConstraint.valueOf("1+"));
-
- Map<String, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef1, Collections.unmodifiableMap(constraints));
+ Map<ImportDependency, VersionConstraint> constraints = new HashMap<ImportDependency, VersionConstraint>();
+ ImportDependency importDep1 = newImportDependency("p.q.r");
+ ImportDependency importDep2 = newImportDependency("x.y.z");
+ ImportDependency importDep3 = newImportDependency("i.j.k");
+ constraints.put(importDep1, VersionConstraint.valueOf("1+"));
+ constraints.put(importDep2, VersionConstraint.valueOf("1+"));
+ constraints.put(importDep3, VersionConstraint.valueOf("1+"));
+
+ Map<ImportDependency, VersionConstraint> overriddenConstraints = iop.narrow(moduleDef1, Collections.unmodifiableMap(constraints));
}
catch (FileNotFoundException fe) {
unexpected(fe);
--- a/test/java/module/config/ImportOverridePolicyFile/InvalidImporterToken.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/InvalidImporterToken.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,17 +1,17 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
-// Should be importer with no 's'
-IMPORTERS a.b.* @ 1.* {
- p.q.r @ 1.8.0;
- x.y.z @ 2.*;
- s.t.u @ 7.8.9;
+// Should be module with no 's'
+MODULES a.b.* @ 1.* {
+ import module p.q.r @ 1.8.0;
+ import module x.y.z @ 2.*;
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/InvalidModuleWildcard0.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/InvalidModuleWildcard0.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,17 +1,17 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
// The next entry use the wildcard incorrectly.
-importer a.*.c @ 1.* {
- p.q.r @ 1.8.0;
- x.y.z @ 2.*;
- s.t.u @ 7.8.9;
+module a.*.c @ 1.* {
+ import module p.q.r @ 1.8.0;
+ import module x.y.z @ 2.*;
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/InvalidModuleWildcard1.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/InvalidModuleWildcard1.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,17 +1,17 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
// The next entry use the wildcard incorrectly.
-importer *.b.c @ 1.* {
- p.q.r @ 1.8.0;
- x.y.z @ 2.*;
- s.t.u @ 7.8.9;
+module *.b.c @ 1.* {
+ import module p.q.r @ 1.8.0;
+ import module x.y.z @ 2.*;
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/InvalidModuleWildcard2.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/InvalidModuleWildcard2.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,17 +1,17 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
-importer a.b.* @ 1.* {
+module a.b.* @ 1.* {
// Wildcard is not allowed in the imported module name.
- p.q.* @ 1.8.0;
- x.y.z @ 2.*;
- s.t.u @ 7.8.9;
+ import module p.q.* @ 1.8.0;
+ import module x.y.z @ 2.*;
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/InvalidVersionConstraint0.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/InvalidVersionConstraint0.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,17 +1,17 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
// The next entry has invalid version constraint
-importer a.b.* @ 1* {
- p.q.r @ 1.8.0;
- x.y.z @ 2.*;
- s.t.u @ 7.8.9;
+module a.b.* @ 1* {
+ import module p.q.r @ 1.8.0;
+ import module x.y.z @ 2.*;
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/InvalidVersionConstraint1.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/InvalidVersionConstraint1.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,18 +1,18 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
-importer a.b.* @ 1.* {
- p.q.r @ 1.8.0;
+module a.b.* @ 1.* {
+ import module p.q.r @ 1.8.0;
// The next entry has invalid version constraint
- x.y.z @ 2*;
- s.t.u @ 7.8.9;
+ import module x.y.z @ 2*;
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/InvalidVersionConstraint2.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/InvalidVersionConstraint2.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,18 +1,18 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
-importer a.b.* @ 1.* {
- p.q.r @ 1.8.0;
+module a.b.* @ 1.* {
+ import module p.q.r @ 1.8.0;
// The next entry has missing version constraint
- x.y.z @ ;
- s.t.u @ 7.8.9;
+ import module x.y.z @ ;
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/InvalidVersionConstraint3.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/InvalidVersionConstraint3.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,17 +1,17 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
// The next entry has invalid version constraint
-importer a.b.* @ {
- p.q.r @ 1.8.0;
- x.y.z @ 2.*;
- s.t.u @ 7.8.9;
+module a.b.* @ {
+ import module p.q.r @ 1.8.0;
+ import module x.y.z @ 2.*;
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/MissingSemicolon0.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/MissingSemicolon0.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,17 +1,17 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
// The next entry has a missing semicolon.
-importer a.b.* @ 1.* {
- p.q.r @ 1.8.0;
- x.y.z @ 2.*;
- s.t.u @ 7.8.9;
+module a.b.* @ 1.* {
+ import module p.q.r @ 1.8.0;
+ import module x.y.z @ 2.*;
+ import module s.t.u @ 7.8.9;
}
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/MissingSemicolon1.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/MissingSemicolon1.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,18 +1,18 @@
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
-importer a.b.* @ 1.* {
- p.q.r @ 1.8.0;
+module a.b.* @ 1.* {
+ import module p.q.r @ 1.8.0;
// The next entry has a missing semicolon.
- x.y.z @ 2.*
- s.t.u @ 7.8.9;
+ import module x.y.z @ 2.*
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/config/ImportOverridePolicyFile/NoOp.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/NoOp.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -1,11 +1,11 @@
// no-op
-importer a.b.c.* {
+module a.b.c.* {
};
-importer a.b.* {
+module a.b.* {
};
-importer * {
+module * {
};
--- a/test/java/module/config/ImportOverridePolicyFile/WellFormed.import.override.policy Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/config/ImportOverridePolicyFile/WellFormed.import.override.policy Sat Apr 19 03:38:14 2008 -0700
@@ -3,19 +3,19 @@
*/
// Test basics
-importer a.b.c @ 1.0 {
- p.q.r @ 1.7.0;
- x.y.z @ 2.3.4;
+module a.b.c @ 1.0 {
+ import module p.q.r @ 1.7.0;
+ import module x.y.z @ 2.3.4;
};
// Test wildcards
-importer a.b.* @ 1.* {
- p.q.r @ 1.8.0;
- x.y.z @ 2.*;
- s.t.u @ 7.8.9;
+module a.b.* @ 1.* {
+ import module p.q.r @ 1.8.0;
+ import module x.y.z @ 2.*;
+ import module s.t.u @ 7.8.9;
};
-importer * {
- p.q.r @ [1.0, 2.0);
- x.y.z @ [2.0, 3.0);
+module * {
+ import module p.q.r @ [1.0, 2.0);
+ import module x.y.z @ [2.0, 3.0);
};
--- a/test/java/module/modinit/RunMTest.java Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/RunMTest.java Sat Apr 19 03:38:14 2008 -0700
@@ -523,7 +523,7 @@ public class RunMTest {
srclist.append(f.getPath());
srclist.append(" ");
}
- String cmd = "-source 6 -target 6 -implicit:none -Xlint:all -sourcepath "
+ String cmd = "-source 6 -target 6 -XDignore.symbol.file -implicit:none -Xlint:all -sourcepath "
+ srcpath.toString() + " " + srclist;
int r = compiler.run(null, null, null, cmd.split(" "));
if (r != 0) {
--- a/test/java/module/modinit/mtest/basic/initagain.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/basic/initagain.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -13,36 +13,38 @@
> export
m0.Main
>> begin class m0.Main
- ImportOverridePolicy oldPolicy = Modules.getImportOverridePolicy();
- ModuleDefinition md;
- try {
- Modules.setImportOverridePolicy(new OverridePolicyImpl());
- md = repository.find("m1");
- try {
- Module m = md.getModuleInstance();
- throw new Exception("Module not in error state: m1");
- } catch (ModuleInitializationException e) {
- System.out.println("OK: " + e);
- }
- } finally {
- Modules.setImportOverridePolicy(oldPolicy);
- }
- // give the module initialization thread a chance to run
- Thread.sleep(250);
- Module m = md.getModuleInstance();
- runOtherModule(m);
+ ImportOverridePolicy oldPolicy = Modules.getImportOverridePolicy();
+ ModuleDefinition md;
+ try {
+ Modules.setImportOverridePolicy(new OverridePolicyImpl());
+ md = repository.find("m1");
+ try {
+ Module m = md.getModuleInstance();
+ throw new Exception("Module not in error state: m1");
+ } catch (ModuleInitializationException e) {
+ System.out.println("OK: " + e);
+ }
+ } finally {
+ Modules.setImportOverridePolicy(oldPolicy);
+ }
+ // give the module initialization thread a chance to run
+ Thread.sleep(250);
+ Module m = md.getModuleInstance();
+ runOtherModule(m);
> body
static class OverridePolicyImpl implements ImportOverridePolicy {
- public Map<String,VersionConstraint> narrow(ModuleDefinition importer,
- Map<String,VersionConstraint> constraints) {
- if (constraints.get("m2") == null) {
- return constraints;
- }
- // use ImportOverridePolicy to make sure no match version of m2 is available
- Map<String,VersionConstraint> newConstraints = new HashMap<String,VersionConstraint>(constraints);
- newConstraints.put("m2", VersionConstraint.valueOf("2.0+"));
- return newConstraints;
- }
+ public Map<ImportDependency,VersionConstraint> narrow(ModuleDefinition importer,
+ Map<ImportDependency,VersionConstraint> constraints) {
+ for (ImportDependency dep : constraints.keySet()) {
+ if (dep.getName().equals("m2")) {
+ // use ImportOverridePolicy to make sure no match version of m2 is available
+ Map<ImportDependency,VersionConstraint> newConstraints = new HashMap<ImportDependency,VersionConstraint>(constraints);
+ newConstraints.put(dep, VersionConstraint.valueOf("2.0+"));
+ return newConstraints;
+ }
+ }
+ return constraints;
+ }
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/circular/circular_invalid2.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/circular/circular_invalid2.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -15,16 +15,16 @@
> export
m0.Main
>> begin class m0.Main
- String[] moduleNames = new String[] { "m1", "m2", "m3" };
- for (String moduleName : moduleNames) {
- ModuleDefinition md = repository.find(moduleName);
- try {
- Module m = md.getModuleInstance();
- throw new Exception("Module not in error state: " + moduleName);
- } catch (ModuleInitializationException e) {
- System.out.println("OK: " + e);
- }
- }
+ String[] moduleNames = new String[] { "m1", "m2", "m3" };
+ for (String moduleName : moduleNames) {
+ ModuleDefinition md = repository.find(moduleName);
+ try {
+ Module m = md.getModuleInstance();
+ throw new Exception("Module not in error state: " + moduleName);
+ } catch (ModuleInitializationException e) {
+ System.out.println("OK: " + e);
+ }
+ }
>> end class
>>> end module
>>> begin module m1
@@ -62,7 +62,7 @@ m2.MainB
> export
m3.MainC
>> begin class m3.MainC
- new m2.MainB().run(args);
+ new m2.MainB().run(args);
>> end class
>>> end module
>>> begin test m1
--- a/test/java/module/modinit/mtest/circular/circular_optional.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/circular/circular_optional.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -13,16 +13,16 @@
> export
m0.Main
>> begin class m0.Main
- String[] moduleNames = new String[] { "m1", "m2" };
- for (String moduleName : moduleNames) {
- ModuleDefinition md = repository.find(moduleName);
- try {
- Module m = md.getModuleInstance();
- throw new Exception("Module not in error state: " + moduleName);
- } catch (ModuleInitializationException e) {
- System.out.println("OK: " + e);
- }
- }
+ String[] moduleNames = new String[] { "m1", "m2" };
+ for (String moduleName : moduleNames) {
+ ModuleDefinition md = repository.find(moduleName);
+ try {
+ Module m = md.getModuleInstance();
+ throw new Exception("Module not in error state: " + moduleName);
+ } catch (ModuleInitializationException e) {
+ System.out.println("OK: " + e);
+ }
+ }
>> end class
>>> end module
>>> begin module m1
--- a/test/java/module/modinit/mtest/classesdirectorypath/classesdirectorypath.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/classesdirectorypath/classesdirectorypath.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -15,18 +15,18 @@ m1.MainA
try {
ModuleDefinition md2 = r.find("m2");
Module m2 = md2.getModuleInstance();
-
+
String name = "m2/MainA.class";
ClassLoader clazzLoader = m2.getClassLoader();
try {
Class clazz = clazzLoader.loadClass(name);
throw new Exception("Unexpected class found in WEB-INF/lib/m2/MainA.class.");
}
- catch(ClassNotFoundException e) {
+ catch(ClassNotFoundException e) {
}
name = "r1.txt";
-
+
// Checks ClassLoader.getResourceAsStream()
InputStream in = clazzLoader.getResourceAsStream(name);
@@ -35,8 +35,8 @@ m1.MainA
if (line.equals("resource 1") == false) {
throw new Exception("Wrong content: " + line);
}
- in.close();
-
+ in.close();
+
// Checks ClassLoader.getResource()
in = clazzLoader.getResource(name).openConnection().getInputStream();
reader = new BufferedReader(new InputStreamReader(in));
@@ -44,7 +44,7 @@ m1.MainA
if (line.equals("resource 1") == false) {
throw new Exception("Wrong content: " + line);
}
- in.close();
+ in.close();
}
catch (ModuleInitializationException e) {
throw new Exception("Unable to instantiate m2");
--- a/test/java/module/modinit/mtest/classpath/basic1.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/classpath/basic1.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -16,47 +16,47 @@ m1.MainA
> import
import java.net.URL;
> run
- // on the classpath
- new classp.MainX().run("from m1");
- ClassLoader loader = module.getClassLoader();
- InputStream in = loader.getResourceAsStream("classp/cp1.txt");
- checkFileStream(in);
- URL url = loader.getResource("classp/cp1.txt");
- checkFileStream(url.openStream());
- // in the extension class loader
- Class clazz = Class.forName("com.sun.crypto.provider.SunJCE");
- Object o = clazz.newInstance();
- System.out.println("Object: " + o);
- List<URL> urls = Collections.list(loader.getResources("META-INF/MANIFEST.MF"));
- System.out.println("urls: " + urls);
- // Problem with manifest as resource due to jre/lib/ext/meta-index ?!
-// url = null;
-// for (URL u : urls) {
-// if (u.getPath().contains("sunjce")) {
-// url = u;
-// break;
-// }
-// }
- url = loader.getResource("com/sun/crypto/provider/SunJCE.class");
- System.out.println("resource: " + url);
- if (url == null) {
- throw new Exception("Could not find sunjce resource");
- }
- in = url.openStream();
- in.read();
- in.close();
+ // on the classpath
+ new classp.MainX().run("from m1");
+ ClassLoader loader = module.getClassLoader();
+ InputStream in = loader.getResourceAsStream("classp/cp1.txt");
+ checkFileStream(in);
+ URL url = loader.getResource("classp/cp1.txt");
+ checkFileStream(url.openStream());
+ // in the extension class loader
+ Class clazz = Class.forName("com.sun.crypto.provider.SunJCE");
+ Object o = clazz.newInstance();
+ System.out.println("Object: " + o);
+ List<URL> urls = Collections.list(loader.getResources("META-INF/MANIFEST.MF"));
+ System.out.println("urls: " + urls);
+ // Problem with manifest as resource due to jre/lib/ext/meta-index ?!
+// url = null;
+// for (URL u : urls) {
+// if (u.getPath().contains("sunjce")) {
+// url = u;
+// break;
+// }
+// }
+ url = loader.getResource("com/sun/crypto/provider/SunJCE.class");
+ System.out.println("resource: " + url);
+ if (url == null) {
+ throw new Exception("Could not find sunjce resource");
+ }
+ in = url.openStream();
+ in.read();
+ in.close();
> body
private static void checkFileStream(InputStream in) throws Exception {
- System.out.println("Stream: " + in);
- if (in == null) {
- throw new Exception("Stream is null");
- }
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- String line = reader.readLine();
- if (line.equals("resource cp1") == false) {
- throw new Exception("Wrong content: " + line);
- }
- in.close();
+ System.out.println("Stream: " + in);
+ if (in == null) {
+ throw new Exception("Stream is null");
+ }
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ String line = reader.readLine();
+ if (line.equals("resource cp1") == false) {
+ throw new Exception("Wrong content: " + line);
+ }
+ in.close();
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/classpath/noclasspath.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/classpath/noclasspath.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -15,44 +15,44 @@ m1.MainA
> import
import java.net.URL;
> run
- // on the classpath
- ClassLoader loader = module.getClassLoader();
- try {
- System.out.println("class: " + Class.forName("classp.MainX"));
- throw new Exception("Loaded unexpected class");
- } catch (ClassNotFoundException e) {
- System.out.println("OK: " + e);
- }
- try {
- System.out.println("class: " + Class.forName("com.sun.crypto.provider.SunJCE"));
- throw new Exception("Loaded unexpected class");
- } catch (ClassNotFoundException e) {
- System.out.println("OK: " + e);
- }
+ // on the classpath
+ ClassLoader loader = module.getClassLoader();
+ try {
+ System.out.println("class: " + Class.forName("classp.MainX"));
+ throw new Exception("Loaded unexpected class");
+ } catch (ClassNotFoundException e) {
+ System.out.println("OK: " + e);
+ }
+ try {
+ System.out.println("class: " + Class.forName("com.sun.crypto.provider.SunJCE"));
+ throw new Exception("Loaded unexpected class");
+ } catch (ClassNotFoundException e) {
+ System.out.println("OK: " + e);
+ }
- InputStream in = loader.getResourceAsStream("classp/cp1.txt");
- if (in != null) {
- throw new Exception("Found unexpected resource: " + in);
- }
-
- URL url = loader.getResource("classp/cp1.txt");
- if (url != null) {
- throw new Exception("Found unexpected resource: " + url);
- }
+ InputStream in = loader.getResourceAsStream("classp/cp1.txt");
+ if (in != null) {
+ throw new Exception("Found unexpected resource: " + in);
+ }
- List<URL> urls = Collections.list(loader.getResources("META-INF/MANIFEST.MF"));
- System.out.println("urls: " + urls);
-// url = null;
-// for (URL u : urls) {
-// if (u.getPath().contains("sunjce")) {
-// url = u;
-// break;
-// }
-// }
- url = loader.getResource("com/sun/crypto/provider/SunJCE.class");
- if (url != null) {
- throw new Exception("Found unexpected sunjce resource");
- }
+ URL url = loader.getResource("classp/cp1.txt");
+ if (url != null) {
+ throw new Exception("Found unexpected resource: " + url);
+ }
+
+ List<URL> urls = Collections.list(loader.getResources("META-INF/MANIFEST.MF"));
+ System.out.println("urls: " + urls);
+// url = null;
+// for (URL u : urls) {
+// if (u.getPath().contains("sunjce")) {
+// url = u;
+// break;
+// }
+// }
+ url = loader.getResource("com/sun/crypto/provider/SunJCE.class");
+ if (url != null) {
+ throw new Exception("Found unexpected sunjce resource");
+ }
>> end class
>>> end module
>>> begin test m1
--- a/test/java/module/modinit/mtest/deepvalidate/deepvalidate.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/deepvalidate/deepvalidate.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -13,7 +13,7 @@
@ImportModule(name="java.se")})
@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
"m1.MainA"
-})
+})
> export
m1.MainA
>> begin class m1.MainA
@@ -24,7 +24,7 @@ m1.MainA
// m1 should support deep validation
if (m1.supportsDeepValidation() == false) {
throw new Exception("m1 does not support deep validation as expected.");
- }
+ }
// deep validation should succeed
m1.deepValidate();
@@ -33,7 +33,7 @@ m1.MainA
ModuleDefinition md3 = r.find("m3");
Module m2 = md2.getModuleInstance();
Module m3 = md3.getModuleInstance();
-
+
// m2 should support deep validation
if (m2.supportsDeepValidation() == false) {
throw new Exception("m2 does not support deep validation as expected.");
@@ -92,7 +92,7 @@ m1.MainA
catch (ModuleInitializationException e) {
}
-
+
ModuleDefinition md8 = r.find("m8");
Module m8 = md8.getModuleInstance();
@@ -121,7 +121,7 @@ m1.MainA
@ImportModule(name="m3")})
@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
"m2.MainB"
-})
+})
>> begin class m2.MainB
>> end class
>>> end module
@@ -132,7 +132,7 @@ m1.MainA
@ImportModule(name="java.se")})
@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
"m3.MainC"
-})
+})
>> begin class m3.MainC
>> end class
>>> end module
@@ -145,7 +145,7 @@ m1.MainA
@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
"conflictTypeXYZ",
"m4.MainD"
-})
+})
>> begin class m4.MainD
>> end class
>>> end module
@@ -157,8 +157,8 @@ m1.MainA
@ImportModule(name="m6")})
@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
"m5.MainE"
-})
-
+})
+
>> begin class m5.MainE
>> end class
>>> end module
@@ -171,7 +171,7 @@ m1.MainA
@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
"conflictTypeXYZ",
"m6.MainF"
-})
+})
>> begin class m6.MainF
>> end class
>>> end module
@@ -185,7 +185,7 @@ m1.MainA
})
@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
"m7.MainG"
-})
+})
>> begin class m7.MainG
>> end class
>>> end module
@@ -199,7 +199,7 @@ m1.MainA
@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
"conflictTypeXYZ",
"m8.MainH"
-})
+})
>> begin class m8.MainH
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/disablemodule/disablemodule.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/disablemodule/disablemodule.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -1,7 +1,7 @@
-# Defines m1, m2
+# Defines m1, m2
# m1 imports m2 with default versionconstraint
-# Test disables m2, and makes sure no more module instance of m2 can be
-# instantiated.
+# Test disables m2, and makes sure no more module instance of m2 can be
+# instantiated.
>>> begin module m1
> annotations
@MainClass("m1.MainA")
@@ -32,7 +32,7 @@ m2.MainB
Module m = md.getModuleInstance();
}
catch(Throwable e) {
- throw new Exception("Module definition cannot be instantiated.");
+ throw new Exception("Module definition cannot be instantiated.");
}
try {
@@ -46,7 +46,7 @@ m2.MainB
catch(UnsupportedOperationException ise) {
}
catch(Throwable e) {
- throw new Exception("Incorrect exception is thrown when disabling standard module definition.");
+ throw new Exception("Incorrect exception is thrown when disabling standard module definition.");
}
try {
@@ -61,7 +61,7 @@ m2.MainB
catch(IllegalStateException ise) {
}
catch(Throwable e) {
- throw new Exception("Incorrect exception is thrown when instantiating disabled module definition.");
+ throw new Exception("Incorrect exception is thrown when instantiating disabled module definition.");
}
try {
@@ -74,7 +74,7 @@ m2.MainB
catch(IllegalStateException ise) {
}
catch(Throwable e) {
- throw new Exception("Incorrect exception is thrown when instantiating disabled module definition.");
+ throw new Exception("Incorrect exception is thrown when instantiating disabled module definition.");
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/exportlegacyclasses/exportlegacyclasses1.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/exportlegacyclasses/exportlegacyclasses1.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -1,5 +1,5 @@
#
-# Verify that getMemberClasses() and getExportedClasses return the
+# Verify that getMemberClasses() and getExportedClasses return the
# correct information for the module when legacy classes are involved.
#
>>> begin module m1
@@ -17,28 +17,28 @@ m1.MainA
// m1 should only export m1.MainA
Set<String> memberClasses = module.getModuleDefinition().getMemberClasses();
if (memberClasses == null) {
- throw new Exception("getMemberClasses() should never return null.");
- }
+ throw new Exception("getMemberClasses() should never return null.");
+ }
// Workaround until JSR 294 support arrives
// if (memberClasses.size() != 3) {
- // throw new Exception("m1 should have three member classes.");
+ // throw new Exception("m1 should have three member classes.");
// }
- if (memberClasses.contains("m1.MainA") == false
+ if (memberClasses.contains("m1.MainA") == false
|| memberClasses.contains("a.b.c") == false
|| memberClasses.contains("x.y.z") == false) {
- throw new Exception("Missing member classes in m1.");
- }
+ throw new Exception("Missing member classes in m1.");
+ }
Set<String> exportedClasses = module.getModuleDefinition().getExportedClasses();
if (exportedClasses == null) {
throw new Exception("getExportedClasses() should never return null.");
- }
+ }
// Workaround until JSR 294 support arrives
// if (exportedClasses.size() != 1) {
// throw new Exception("m1 should have one exported class.");
// }
if (exportedClasses.contains("m1.MainA") == false) {
- throw new Exception("Missing exported classes in m1.");
- }
+ throw new Exception("Missing exported classes in m1.");
+ }
Module m2;
try {
@@ -47,7 +47,7 @@ m1.MainA
}
catch (ModuleInitializationException mie) {
throw new Exception("Unable to instantiate m2.");
- }
+ }
for (PackageDefinition pd : m2.getModuleDefinition().getExportedPackageDefinitions()) {
System.out.println("exported package: " + pd.getName());
@@ -57,7 +57,7 @@ for (PackageDefinition pd : m2.getModule
memberClasses = m2.getModuleDefinition().getMemberClasses();
if (memberClasses == null) {
throw new Exception("getMemberClasses() should never return null.");
- }
+ }
// Workaround until JSR 294 support arrives
// if (memberClasses.size() != 3) {
// throw new Exception("m2 should have three member classes.");
@@ -65,16 +65,16 @@ for (PackageDefinition pd : m2.getModule
for (String s : memberClasses) {
System.out.println("Member class: " + s);
}
-
- if (memberClasses.contains("m2.MainB") == false
+
+ if (memberClasses.contains("m2.MainB") == false
|| memberClasses.contains("a.b.c") == false
|| memberClasses.contains("x.y.z") == false) {
- throw new Exception("Missing member classes in m2.");
- }
+ throw new Exception("Missing member classes in m2.");
+ }
exportedClasses = m2.getModuleDefinition().getExportedClasses();
if (exportedClasses == null) {
throw new Exception("getExportedClasses() should never return null.");
- }
+ }
// Workaround until JSR 294 support arrives
// if (exportedClasses.size() != 3) {
// throw new Exception("m2 should have three exported classes.");
@@ -82,8 +82,8 @@ for (PackageDefinition pd : m2.getModule
if (exportedClasses.contains("m2.MainB") == false
|| exportedClasses.contains("a.b.c") == false
|| exportedClasses.contains("x.y.z") == false) {
- throw new Exception("Missing exported classes in m2.");
- }
+ throw new Exception("Missing exported classes in m2.");
+ }
>> end class
>>> end module
>>> begin module m2
--- a/test/java/module/modinit/mtest/exportresources/exportresources1.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/exportresources/exportresources1.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -1,5 +1,5 @@
#
-# Verify that getExportedResources() return the correct information for
+# Verify that getExportedResources() return the correct information for
# the exported resources within the module
#
>>> begin module m1
@@ -15,52 +15,52 @@ m1.MainA
checkExportedResources();
> body
private void checkExportedResources() throws Exception {
- ModuleDefinition moduleDef = module.getModuleDefinition();
- Repository r = moduleDef.getRepository();
-
- // m1 should have no exported resources
- Set<String> exportedResources = moduleDef.getExportedResources();
- if (exportedResources == null) {
- throw new Exception("getExportedResources() should never return null.");
- }
- if (exportedResources.size() != 0) {
- throw new Exception("m1 should have no exported resources.");
- }
-
- // m2 should export only r1.txt and r2.txt
- moduleDef = r.find("m2");
- exportedResources = moduleDef.getExportedResources();
- if (exportedResources == null) {
- throw new Exception("getExportedResources() should never return null.");
- }
- if (exportedResources.size() != 2) {
- throw new Exception("m2 should export only two resources.");
- }
- if (exportedResources.contains("r1.txt") == false
- || exportedResources.contains("r2.txt") == false) {
- throw new Exception("Missing exported resources in m2.");
- }
-
- // m3 should export only r1.txt, r2.txt, r3.txt, r4.txt, r5.txt, r6.txt. r7.txt, r8.txt, etc.
- moduleDef = r.find("m3");
- exportedResources = moduleDef.getExportedResources();
- if (exportedResources == null) {
- throw new Exception("getExportedResources() should never return null.");
- }
- if (exportedResources.size() < 8) {
- throw new Exception("m3 should export at least eight resources.");
- }
- if (exportedResources.contains("r1.txt") == false
- || exportedResources.contains("r2.txt") == false
- || exportedResources.contains("a/r3.txt") == false
- || exportedResources.contains("b/r4.txt") == false
- || exportedResources.contains("a/c/r5.txt") == false
- || exportedResources.contains("b/d/r6.txt") == false
- || exportedResources.contains("aa/r7.txt") == false
- || exportedResources.contains("bb/r8.txt") == false) {
- throw new Exception("Missing exported resources in m3.");
- }
-
+ ModuleDefinition moduleDef = module.getModuleDefinition();
+ Repository r = moduleDef.getRepository();
+
+ // m1 should have no exported resources
+ Set<String> exportedResources = moduleDef.getExportedResources();
+ if (exportedResources == null) {
+ throw new Exception("getExportedResources() should never return null.");
+ }
+ if (exportedResources.size() != 0) {
+ throw new Exception("m1 should have no exported resources.");
+ }
+
+ // m2 should export only r1.txt and r2.txt
+ moduleDef = r.find("m2");
+ exportedResources = moduleDef.getExportedResources();
+ if (exportedResources == null) {
+ throw new Exception("getExportedResources() should never return null.");
+ }
+ if (exportedResources.size() != 2) {
+ throw new Exception("m2 should export only two resources.");
+ }
+ if (exportedResources.contains("r1.txt") == false
+ || exportedResources.contains("r2.txt") == false) {
+ throw new Exception("Missing exported resources in m2.");
+ }
+
+ // m3 should export only r1.txt, r2.txt, r3.txt, r4.txt, r5.txt, r6.txt. r7.txt, r8.txt, etc.
+ moduleDef = r.find("m3");
+ exportedResources = moduleDef.getExportedResources();
+ if (exportedResources == null) {
+ throw new Exception("getExportedResources() should never return null.");
+ }
+ if (exportedResources.size() < 8) {
+ throw new Exception("m3 should export at least eight resources.");
+ }
+ if (exportedResources.contains("r1.txt") == false
+ || exportedResources.contains("r2.txt") == false
+ || exportedResources.contains("a/r3.txt") == false
+ || exportedResources.contains("b/r4.txt") == false
+ || exportedResources.contains("a/c/r5.txt") == false
+ || exportedResources.contains("b/d/r6.txt") == false
+ || exportedResources.contains("aa/r7.txt") == false
+ || exportedResources.contains("bb/r8.txt") == false) {
+ throw new Exception("Missing exported resources in m3.");
+ }
+
// m4 should export only r3.txt and r6.txt
moduleDef = r.find("m4");
exportedResources = moduleDef.getExportedResources();
@@ -72,8 +72,8 @@ m1.MainA
}
if (exportedResources.contains("a/r3.txt") == false
|| exportedResources.contains("b/d/r6.txt") == false) {
- throw new Exception("Missing exported resources in m4.");
- }
+ throw new Exception("Missing exported resources in m4.");
+ }
// m5 should export only r3.txt, r4.txt, r5.txt, r6.txt
moduleDef = r.find("m5");
@@ -84,28 +84,28 @@ m1.MainA
if (exportedResources.size() != 4) {
throw new Exception("m5 should export only four resources.");
}
- if (exportedResources.contains("a/r3.txt") == false
- || exportedResources.contains("b/r4.txt") == false
- || exportedResources.contains("a/c/r5.txt") == false
- || exportedResources.contains("b/d/r6.txt") == false) {
- throw new Exception("Missing exported resources in m5.");
- }
-
- // m6 should export only r3.txt, r5.txt, r8.txt
- moduleDef = r.find("m6");
- exportedResources = moduleDef.getExportedResources();
- if (exportedResources == null) {
- throw new Exception("getExportedResources() should never return null.");
- }
- if (exportedResources.size() != 3) {
- throw new Exception("m6 should export only three resources.");
- }
- if (exportedResources.contains("a/r3.txt") == false
- || exportedResources.contains("a/c/r5.txt") == false
- || exportedResources.contains("bb/r8.txt") == false) {
- throw new Exception("Missing exported resources in m6.");
- }
- }
+ if (exportedResources.contains("a/r3.txt") == false
+ || exportedResources.contains("b/r4.txt") == false
+ || exportedResources.contains("a/c/r5.txt") == false
+ || exportedResources.contains("b/d/r6.txt") == false) {
+ throw new Exception("Missing exported resources in m5.");
+ }
+
+ // m6 should export only r3.txt, r5.txt, r8.txt
+ moduleDef = r.find("m6");
+ exportedResources = moduleDef.getExportedResources();
+ if (exportedResources == null) {
+ throw new Exception("getExportedResources() should never return null.");
+ }
+ if (exportedResources.size() != 3) {
+ throw new Exception("m6 should export only three resources.");
+ }
+ if (exportedResources.contains("a/r3.txt") == false
+ || exportedResources.contains("a/c/r5.txt") == false
+ || exportedResources.contains("bb/r8.txt") == false) {
+ throw new Exception("Missing exported resources in m6.");
+ }
+ }
>> end class
>>> end module
>>> begin module m2
@@ -245,7 +245,7 @@ java.se
> annotations
@ExportResources({
"a/**",
- "bb/r8.txt"
+ "bb/r8.txt"
})
@ImportModules({
@ImportModule(name="java.se")
--- a/test/java/module/modinit/mtest/exportresources/exportresources2.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/exportresources/exportresources2.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -10,11 +10,11 @@
>>> begin module m1
> annotations
@MainClass("m1.MainA")
-@ImportModules({
- @ImportModule(name="java.se"),
- @ImportModule(name="m2"),
- @ImportModule(name="m3")
-})
+@ImportModules({
+ @ImportModule(name="java.se"),
+ @ImportModule(name="m2"),
+ @ImportModule(name="m3")
+})
> export
m1.MainA
>> begin file r1.txt
@@ -31,7 +31,7 @@ import java.net.URL;
InputStream is;
URL url;
Enumeration<URL> urls;
-
+
// r1.txt should be accessible from m1
//
is = cl.getResourceAsStream("r1.txt");
@@ -61,7 +61,7 @@ import java.net.URL;
if (urls != null && urls.hasMoreElements()) {
throw new Exception("m1 should have no access to r2.txt through getResources().");
}
-
+
// a/r3.txt should be accessible from m1 through m2
//
is = cl.getResourceAsStream("a/r3.txt");
@@ -76,7 +76,7 @@ import java.net.URL;
if (urls == null || urls.hasMoreElements() == false) {
throw new Exception("m1 should have access to a/r3.txt through getResources().");
}
-
+
// b/r4.txt should NOT be accessible from m1
//
is = cl.getResourceAsStream("b/r4.txt");
@@ -158,9 +158,9 @@ import java.net.URL;
@ExportResources({
"a/r3.txt"
})
-@ImportModules({
- @ImportModule(name="java.se")
-})
+@ImportModules({
+ @ImportModule(name="java.se")
+})
>> begin file r1.txt
> copy r1.txt
>> end file
@@ -191,9 +191,9 @@ import java.net.URL;
@ExportResources({
"a/c/r5.txt"
})
-@ImportModules({
- @ImportModule(name="java.se")
-})
+@ImportModules({
+ @ImportModule(name="java.se")
+})
>> begin file r1.txt
> copy r1.txt
>> end file
--- a/test/java/module/modinit/mtest/extclassloader/extclassloader.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/extclassloader/extclassloader.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -18,19 +18,19 @@
> export
m1.MainA
>> begin class m1.MainA
-> import
+> import
import java.io.*;
import java.module.*;
> run
- testExtensionModuleLoader();
+ testExtensionModuleLoader();
> body
private void testExtensionModuleLoader() throws Exception {
Repository r = module.getModuleDefinition().getRepository();
String testScratch = System.getProperty("test.scratch", ".");
// Create source location for a URLRepository
- File repositorySourceDir = new File(testScratch,
- "tmp_mtest" + File.separator
+ File repositorySourceDir = new File(testScratch,
+ "tmp_mtest" + File.separator
+ "extclassloader" + File.separator
+ "extrepo-" + System.currentTimeMillis());
repositorySourceDir.mkdirs();
@@ -42,19 +42,19 @@ m1.MainA
if (mai.getName().equals("m1") == false)
extensionRepo.install(new File(mai.getFileName()).toURI().toURL());
}
-
- // Create custom repository.properties file
+
+ // Create custom repository.properties file
File repositoryPropFile = new File(repositorySourceDir, "extclassloader.repository.properties");
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(repositoryPropFile)));
pw.println("extension.parent=bootstrap");
pw.println("extension.source=" + repositorySourceDir.getCanonicalFile().toURI().toURL());
pw.println("extension.classname=sun.module.repository.URLRepository");
pw.close();
-
- runWithCustomExtensionRepository(repositoryPropFile);
+
+ runWithCustomExtensionRepository(repositoryPropFile);
}
-
- private void runWithCustomExtensionRepository(File repositoryPropFile) throws Exception {
+
+ private void runWithCustomExtensionRepository(File repositoryPropFile) throws Exception {
String javaCmd = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
if (!new File(javaCmd).exists()) {
javaCmd = javaCmd + ".exe";
@@ -129,7 +129,7 @@ m3.MainC
} catch(ClassNotFoundException cnfe) {
// exception expected
}
-
+
try {
clazz = Class.forName("m2.MainB");
Module m = clazz.getClassLoader().getModule();
--- a/test/java/module/modinit/mtest/getpackage/basic1.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/getpackage/basic1.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -14,24 +14,24 @@ m1.MainA
> import
import java.net.*;
> run
- checkPackage();
+ checkPackage();
> body
private void checkPackage() throws Exception {
- String name = "m1";
- System.out.println("Checking package " + name + "...");
- ClassLoader cl = module.getClassLoader();
- Class clazz = cl.loadClass("m1.MainA");
- Package p = clazz.getPackage();
- if (p == null) {
- throw new Exception("Cannot find package " + name);
- }
- if (p.getName().equals(name) == false) {
- throw new Exception("Unexpected package: " + p.getName() + " instead of " + name);
- }
- if (p.isSealed() == false) {
- throw new Exception("Package is not sealed");
- }
- }
+ String name = "m1";
+ System.out.println("Checking package " + name + "...");
+ ClassLoader cl = module.getClassLoader();
+ Class clazz = cl.loadClass("m1.MainA");
+ Package p = clazz.getPackage();
+ if (p == null) {
+ throw new Exception("Cannot find package " + name);
+ }
+ if (p.getName().equals(name) == false) {
+ throw new Exception("Unexpected package: " + p.getName() + " instead of " + name);
+ }
+ if (p.isSealed() == false) {
+ throw new Exception("Package is not sealed");
+ }
+ }
>> end class
>>> end module
>>> begin test m1
--- a/test/java/module/modinit/mtest/getresource/basic1.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/getresource/basic1.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -17,93 +17,93 @@ m1.MainA
> import
import java.net.*;
> run
- checkClassResource();
- checkFileResource();
- checkMissingResource();
+ checkClassResource();
+ checkFileResource();
+ checkMissingResource();
> body
private void checkMissingResource() throws Exception {
- String name = "m1/Bar.class";
- System.out.println("Checking " + name + "...");
- ClassLoader cl = module.getClassLoader();
- InputStream in;
- in = cl.getResourceAsStream(name);
- if (in != null) {
- throw new Exception("Found non-existant resource");
- }
- URL url = cl.getResource(name);
- if (url != null) {
- throw new Exception("Found non-existant resource");
- }
- List<URL> urls = Collections.list(cl.getResources(name));
- if (urls.isEmpty() == false) {
- throw new Exception("Found non-existant resource");
- }
+ String name = "m1/Bar.class";
+ System.out.println("Checking " + name + "...");
+ ClassLoader cl = module.getClassLoader();
+ InputStream in;
+ in = cl.getResourceAsStream(name);
+ if (in != null) {
+ throw new Exception("Found non-existant resource");
+ }
+ URL url = cl.getResource(name);
+ if (url != null) {
+ throw new Exception("Found non-existant resource");
+ }
+ List<URL> urls = Collections.list(cl.getResources(name));
+ if (urls.isEmpty() == false) {
+ throw new Exception("Found non-existant resource");
+ }
}
private void checkClassResource() throws Exception {
- String name = "m1/MainA.class";
- System.out.println("Checking " + name + "...");
- ClassLoader cl = module.getClassLoader();
- InputStream in;
- in = cl.getResourceAsStream(name);
- checkClassStream(in);
- URL url = cl.getResource(name);
- System.out.println("URL: " + url);
- checkClassStream(url.openStream());
- checkClassStream(url.openStream());
- List<URL> urls = Collections.list(cl.getResources(name));
- if (urls.size() != 1) {
- throw new Exception("Expected one URL");
- }
- checkClassStream(urls.get(0).openStream());
- URLConnection conn = url.openConnection();
- System.out.println("headers: " + conn.getHeaderFields());
- if ("application/octet-stream".equals(conn.getHeaderField("Content-type")) == false) {
- throw new Exception("Wrong content type");
- }
+ String name = "m1/MainA.class";
+ System.out.println("Checking " + name + "...");
+ ClassLoader cl = module.getClassLoader();
+ InputStream in;
+ in = cl.getResourceAsStream(name);
+ checkClassStream(in);
+ URL url = cl.getResource(name);
+ System.out.println("URL: " + url);
+ checkClassStream(url.openStream());
+ checkClassStream(url.openStream());
+ List<URL> urls = Collections.list(cl.getResources(name));
+ if (urls.size() != 1) {
+ throw new Exception("Expected one URL");
+ }
+ checkClassStream(urls.get(0).openStream());
+ URLConnection conn = url.openConnection();
+ System.out.println("headers: " + conn.getHeaderFields());
+ if ("application/octet-stream".equals(conn.getHeaderField("Content-type")) == false) {
+ throw new Exception("Wrong content type");
+ }
}
private static void checkClassStream(InputStream in) throws Exception {
- DataInputStream din = new DataInputStream(in);
- int k = din.readInt();
- if (k != 0xcafebabe) {
- throw new Exception("Wrong data: " + k);
- }
- in.close();
+ DataInputStream din = new DataInputStream(in);
+ int k = din.readInt();
+ if (k != 0xcafebabe) {
+ throw new Exception("Wrong data: " + k);
+ }
+ in.close();
}
private void checkFileResource() throws Exception {
- String name = "resources/r1.txt";
- System.out.println("Checking " + name + "...");
- ClassLoader cl = module.getClassLoader();
- InputStream in;
- in = cl.getResourceAsStream(name);
- checkFileStream(in);
- URL url = cl.getResource(name);
- System.out.println("URL: " + url);
- checkFileStream(url.openStream());
- checkFileStream(url.openStream());
- List<URL> urls = Collections.list(cl.getResources(name));
- if (urls.size() != 1) {
- throw new Exception("Expected one URL");
- }
- checkFileStream(urls.get(0).openStream());
- URLConnection conn = url.openConnection();
- System.out.println("headers: " + conn.getHeaderFields());
- if ("text/plain".equals(conn.getHeaderField("Content-type")) == false) {
- throw new Exception("Wrong content type");
- }
+ String name = "resources/r1.txt";
+ System.out.println("Checking " + name + "...");
+ ClassLoader cl = module.getClassLoader();
+ InputStream in;
+ in = cl.getResourceAsStream(name);
+ checkFileStream(in);
+ URL url = cl.getResource(name);
+ System.out.println("URL: " + url);
+ checkFileStream(url.openStream());
+ checkFileStream(url.openStream());
+ List<URL> urls = Collections.list(cl.getResources(name));
+ if (urls.size() != 1) {
+ throw new Exception("Expected one URL");
+ }
+ checkFileStream(urls.get(0).openStream());
+ URLConnection conn = url.openConnection();
+ System.out.println("headers: " + conn.getHeaderFields());
+ if ("text/plain".equals(conn.getHeaderField("Content-type")) == false) {
+ throw new Exception("Wrong content type");
+ }
}
private static void checkFileStream(InputStream in) throws Exception {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- String line = reader.readLine();
- if (line.equals("resource 1") == false) {
- throw new Exception("Wrong content: " + line);
- }
- in.close();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ String line = reader.readLine();
+ if (line.equals("resource 1") == false) {
+ throw new Exception("Wrong content: " + line);
+ }
+ in.close();
}
-
+
>> end class
>>> end module
>>> begin test m1
--- a/test/java/module/modinit/mtest/getresource/basic2.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/getresource/basic2.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -20,83 +20,83 @@ m1.MainA
> import
import java.net.*;
> run
- checkClassResource();
- checkFileResource();
+ checkClassResource();
+ checkFileResource();
> body
private void checkClassResource() throws Exception {
- String name = "m/Dup.class";
- System.out.println("Checking " + name + "...");
- ClassLoader cl = module.getClassLoader();
- InputStream in;
- in = cl.getResourceAsStream(name);
- checkClassStream1(in);
- URL url = cl.getResource(name);
- checkClassStream1(url.openStream());
- checkClassStream1(url.openStream());
- List<URL> urls = Collections.list(cl.getResources(name));
- System.out.println("URLs: " + urls);
- if (urls.size() != 2) {
- throw new Exception("Expected two URLs");
- }
- checkClassStream1(urls.get(0).openStream());
- checkClassStream2(urls.get(1).openStream());
+ String name = "m/Dup.class";
+ System.out.println("Checking " + name + "...");
+ ClassLoader cl = module.getClassLoader();
+ InputStream in;
+ in = cl.getResourceAsStream(name);
+ checkClassStream1(in);
+ URL url = cl.getResource(name);
+ checkClassStream1(url.openStream());
+ checkClassStream1(url.openStream());
+ List<URL> urls = Collections.list(cl.getResources(name));
+ System.out.println("URLs: " + urls);
+ if (urls.size() != 2) {
+ throw new Exception("Expected two URLs");
+ }
+ checkClassStream1(urls.get(0).openStream());
+ checkClassStream2(urls.get(1).openStream());
}
private static void checkClassStream1(InputStream in) throws Exception {
- int k = in.read();
- if (k != '#') {
- throw new Exception("Wrong data: " + k);
-
- }
- in.close();
+ int k = in.read();
+ if (k != '#') {
+ throw new Exception("Wrong data: " + k);
+
+ }
+ in.close();
}
private static void checkClassStream2(InputStream in) throws Exception {
- DataInputStream din = new DataInputStream(in);
- int k = din.readInt();
- if (k != 0xcafebabe) {
- throw new Exception("Wrong data: " + k);
- }
- in.close();
+ DataInputStream din = new DataInputStream(in);
+ int k = din.readInt();
+ if (k != 0xcafebabe) {
+ throw new Exception("Wrong data: " + k);
+ }
+ in.close();
}
private void checkFileResource() throws Exception {
- String name = "resources/r1.txt";
- System.out.println("Checking " + name + "...");
- ClassLoader cl = module.getClassLoader();
- InputStream in;
- in = cl.getResourceAsStream(name);
- checkFileStream1(in);
- URL url = cl.getResource(name);
- checkFileStream1(url.openStream());
- checkFileStream1(url.openStream());
- List<URL> urls = Collections.list(cl.getResources(name));
- System.out.println("URLs: " + urls);
- if (urls.size() != 2) {
- throw new Exception("Expected two URLs");
- }
- checkFileStream1(urls.get(0).openStream());
- checkFileStream2(urls.get(1).openStream());
+ String name = "resources/r1.txt";
+ System.out.println("Checking " + name + "...");
+ ClassLoader cl = module.getClassLoader();
+ InputStream in;
+ in = cl.getResourceAsStream(name);
+ checkFileStream1(in);
+ URL url = cl.getResource(name);
+ checkFileStream1(url.openStream());
+ checkFileStream1(url.openStream());
+ List<URL> urls = Collections.list(cl.getResources(name));
+ System.out.println("URLs: " + urls);
+ if (urls.size() != 2) {
+ throw new Exception("Expected two URLs");
+ }
+ checkFileStream1(urls.get(0).openStream());
+ checkFileStream2(urls.get(1).openStream());
}
private static void checkFileStream1(InputStream in) throws Exception {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- String line = reader.readLine();
- if (line.equals("resource b1b") == false) {
- throw new Exception("Wrong content: " + line);
- }
- in.close();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ String line = reader.readLine();
+ if (line.equals("resource b1b") == false) {
+ throw new Exception("Wrong content: " + line);
+ }
+ in.close();
}
-
+
private static void checkFileStream2(InputStream in) throws Exception {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- String line = reader.readLine();
- if (line.equals("resource 1") == false) {
- throw new Exception("Wrong content: " + line);
- }
- in.close();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ String line = reader.readLine();
+ if (line.equals("resource 1") == false) {
+ throw new Exception("Wrong content: " + line);
+ }
+ in.close();
}
-
+
>> end class
>> begin class m.Dup
>> end class
--- a/test/java/module/modinit/mtest/importpolicy/access1.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/access1.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -13,10 +13,10 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -24,20 +24,22 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws ModuleInitializationException {
- CALLED = true;
- try {
- new m1.MainA().info("from import policy");
- } catch (Exception e) {
- throw new ModuleInitializationException("failed", e);
- }
- Repository rep = moduleDef.getRepository();
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m2"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ CALLED = true;
+ try {
+ new m1.MainA().info("from import policy");
+ } catch (Exception e) {
+ throw new ModuleInitializationException("failed", e);
+ }
+ Repository rep = moduleDef.getRepository();
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ ModuleDefinition md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/access2.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/access2.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -13,10 +13,10 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -24,23 +24,25 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws ModuleInitializationException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m2"));
- try {
- new m2.MainB().info("from import policy");
- throw new RuntimeException("failed");
- } catch (Exception e) {
- throw new ModuleInitializationException("failed", e);
- } catch (NoClassDefFoundError e) {
- System.out.println("OK: " + e);
- }
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ ModuleDefinition md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ try {
+ new m2.MainB().info("from import policy");
+ throw new RuntimeException("failed");
+ } catch (Exception e) {
+ throw new ModuleInitializationException("failed", e);
+ } catch (NoClassDefFoundError e) {
+ System.out.println("OK: " + e);
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/basic1.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/basic1.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -11,9 +11,9 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -21,12 +21,17 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws UnsatisfiedDependencyException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- return Collections.singletonList(rep.find("java.se"));
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws UnsatisfiedDependencyException {
+ CALLED = true;
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ Repository rep = moduleDef.getRepository();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ ModuleDefinition md = rep.find(dep.getName());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/default1.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/default1.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -13,10 +13,10 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -24,11 +24,11 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws ModuleInitializationException {
- CALLED = true;
- return defaultImportPolicy.getImports(moduleDef, constraints, null);
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ CALLED = true;
+ return defaultImportPolicy.getImports(moduleDef, constraints, null);
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/error1.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/error1.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -13,10 +13,10 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -24,11 +24,11 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws ModuleInitializationException {
- CALLED = true;
- throw new RuntimeException("aborted");
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ CALLED = true;
+ throw new RuntimeException("aborted");
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/error2.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/error2.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -13,10 +13,10 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -24,11 +24,11 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws ModuleInitializationException {
- CALLED = true;
- throw new ModuleInitializationException("aborted");
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ CALLED = true;
+ throw new ModuleInitializationException("aborted");
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/import1.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/import1.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -12,10 +12,10 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -23,15 +23,17 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws UnsatisfiedDependencyException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m2"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws UnsatisfiedDependencyException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ ModuleDefinition md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/import2.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/import2.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -1,5 +1,5 @@
#
-# Verify that module initialization fails
+# Verify that module initialization fails
# because the custom import policy returns the imports in the wrong order
#
>>> begin module m1
@@ -12,10 +12,10 @@ m2
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -23,15 +23,16 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws UnsatisfiedDependencyException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("m2"));
- mds.add(rep.find("java.se"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+// for (ImportDependency dep : moduleDef.getImportDependencies()) {
+// ModuleDefinition md = rep.find(dep.getName(), dep.getVersionConstraint());
+// result.put(dep, md.getVersion().toVersionConstraint());
+// }
+ throw new ModuleInitializationException("this test is no longer relevant");
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/import3.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/import3.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -1,5 +1,5 @@
#
-# Verify that module initialization fails
+# Verify that module initialization fails
# because the custom import policy failed to return a non-optional import
#
>>> begin module m1
@@ -13,10 +13,10 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -24,14 +24,17 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws UnsatisfiedDependencyException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("m2"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws UnsatisfiedDependencyException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ ModuleDefinition md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, null);
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/import4.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/import4.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -1,5 +1,5 @@
#
-# Verify that module initialization fails
+# Verify that module initialization fails
# because the custom import policy return a ModuleDefinition with the wrong name
#
>>> begin module m1
@@ -13,10 +13,10 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -24,15 +24,20 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws UnsatisfiedDependencyException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m3"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws UnsatisfiedDependencyException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ ModuleDefinition md = rep.find(dep.getName(), dep.getVersionConstraint());
+ if (md.getName().equals("m2") == false)
+ result.put(dep, md.getVersion().toVersionConstraint());
+ else
+ result.put(new ImportDependency("module", "m3", VersionConstraint.DEFAULT, false, false, null), md.getVersion().toVersionConstraint());
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/import5.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/import5.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -1,5 +1,5 @@
#
-# Verify that module initialization fails
+# Verify that module initialization fails
# because the custom import policy returned an additional ModuleDefinition
#
>>> begin module m1
@@ -13,10 +13,10 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -24,16 +24,18 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws UnsatisfiedDependencyException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m2"));
- mds.add(rep.find("m3"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws UnsatisfiedDependencyException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ ModuleDefinition md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ result.put(new ImportDependency("module", "m3", VersionConstraint.DEFAULT, false, false, null), VersionConstraint.DEFAULT);
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/import6.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/import6.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -1,5 +1,5 @@
#
-# Verify that module initialization fails
+# Verify that module initialization fails
# because the custom import policy failed to return a non-optional import
#
>>> begin module m1
@@ -13,10 +13,10 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -24,15 +24,20 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws UnsatisfiedDependencyException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(null);
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws UnsatisfiedDependencyException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ ModuleDefinition md = rep.find(dep.getName(), dep.getVersionConstraint());
+ if (md.getName().equals("m2") == false)
+ result.put(dep, md.getVersion().toVersionConstraint());
+ else
+ result.put(dep, null);
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/optional1.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/optional1.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -1,5 +1,5 @@
#
-# Verify that the custom import policy is invoked
+# Verify that the custom import policy is invoked
# and correctly imports optional import m2 and m3.
#
>>> begin module m1
@@ -14,11 +14,11 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
- new m3.MainC().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
+ new m3.MainC().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -26,16 +26,17 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws UnsatisfiedDependencyException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m2"));
- mds.add(rep.find("m3"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws UnsatisfiedDependencyException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ ModuleDefinition md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/optional2.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/optional2.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -1,5 +1,5 @@
#
-# Verify that the custom import policy is invoked
+# Verify that the custom import policy is invoked
# and that it can omit optional import m2.
#
>>> begin module m1
@@ -14,16 +14,16 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- try {
- new m2.MainB().run("from m1");
- throw new Exception("m2 visible");
- } catch (NoClassDefFoundError e) {
- System.out.println("OK: " + e);
- }
- new m3.MainC().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ try {
+ new m2.MainB().run("from m1");
+ throw new Exception("m2 visible");
+ } catch (NoClassDefFoundError e) {
+ System.out.println("OK: " + e);
+ }
+ new m3.MainC().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -31,16 +31,20 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws UnsatisfiedDependencyException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(null);
- mds.add(rep.find("m3"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws UnsatisfiedDependencyException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ ModuleDefinition md = rep.find(dep.getName(), dep.getVersionConstraint());
+ if (md.getName().equals("m2") == false)
+ result.put(dep, md.getVersion().toVersionConstraint());
+ else
+ result.put(dep, null);
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/optional3.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/optional3.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -1,5 +1,5 @@
#
-# Verify that the custom import policy is invoked
+# Verify that the custom import policy is invoked
# and that cannot ignore the optional import but must replace it will null.
#
>>> begin module m1
@@ -14,16 +14,16 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- try {
- new m2.MainB().run("from m1");
- throw new Exception("m2 visible");
- } catch (NoClassDefFoundError e) {
- System.out.println("OK: " + e);
- }
- new m3.MainC().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ try {
+ new m2.MainB().run("from m1");
+ throw new Exception("m2 visible");
+ } catch (NoClassDefFoundError e) {
+ System.out.println("OK: " + e);
+ }
+ new m3.MainC().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -31,15 +31,20 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws UnsatisfiedDependencyException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m3"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws UnsatisfiedDependencyException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ ModuleDefinition md = rep.find(dep.getName(), dep.getVersionConstraint());
+ if (md.getName().equals("m2") == false)
+ result.put(dep, md.getVersion().toVersionConstraint());
+ else
+ result.remove(dep);
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/optional4.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/optional4.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -1,5 +1,5 @@
#
-# Verify that the custom import policy is invoked
+# Verify that the custom import policy is invoked
# and that cannot ignore the optional import but must replace it will null.
#
>>> begin module m1
@@ -14,16 +14,16 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- try {
- new m2.MainB().run("from m1");
- throw new Exception("m2 visible");
- } catch (NoClassDefFoundError e) {
- System.out.println("OK: " + e);
- }
- new m3.MainC().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ try {
+ new m2.MainB().run("from m1");
+ throw new Exception("m2 visible");
+ } catch (NoClassDefFoundError e) {
+ System.out.println("OK: " + e);
+ }
+ new m3.MainC().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -31,16 +31,21 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws UnsatisfiedDependencyException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m4"));
- mds.add(rep.find("m3"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws UnsatisfiedDependencyException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ ModuleDefinition md = rep.find(dep.getName(), dep.getVersionConstraint());
+ if (md.getName().equals("m2") == false)
+ result.put(dep, md.getVersion().toVersionConstraint());
+ else {
+ result.put(new ImportDependency("module", "m4", VersionConstraint.DEFAULT, false, false, null), VersionConstraint.DEFAULT);
+ }
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/recurse1.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/recurse1.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -13,10 +13,10 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED != 1) {
- throw new Exception("Import policy not called once: " + ImportPolicyImpl.CALLED);
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED != 1) {
+ throw new Exception("Import policy not called once: " + ImportPolicyImpl.CALLED);
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -24,29 +24,31 @@ implements ImportPolicy
> body
static volatile int CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws ModuleInitializationException {
- if (CALLED != 0) {
- throw new ModuleInitializationException("Import policy called more than once");
- }
- CALLED++;
- Repository rep = moduleDef.getRepository();
- ModuleDefinition md = rep.find("m3");
- Module m = md.getModuleInstance();
- ClassLoader cl = m.getClassLoader();
- try {
- Class clazz = cl.loadClass("m3.MainC");
- Object o = clazz.newInstance();
- System.out.println("m3: " + o);
-// new Exception().printStackTrace();
- } catch (Exception e) {
- throw new ModuleInitializationException("could not get m3", e);
- }
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m2"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ if (CALLED != 0) {
+ throw new ModuleInitializationException("Import policy called more than once");
+ }
+ CALLED++;
+ Repository rep = moduleDef.getRepository();
+ ModuleDefinition md = rep.find("m3");
+ Module m = md.getModuleInstance();
+ ClassLoader cl = m.getClassLoader();
+ try {
+ Class clazz = cl.loadClass("m3.MainC");
+ Object o = clazz.newInstance();
+ System.out.println("m3: " + o);
+// new Exception().printStackTrace();
+ } catch (Exception e) {
+ throw new ModuleInitializationException("could not get m3", e);
+ }
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/recurse2.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/recurse2.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -13,10 +13,10 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -24,17 +24,19 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws ModuleInitializationException {
- CALLED = true;
- // recursive call
- Module m = moduleDef.getModuleInstance();
- Repository rep = moduleDef.getRepository();
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m2"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ CALLED = true;
+ // recursive call
+ Module m = moduleDef.getModuleInstance();
+ Repository rep = moduleDef.getRepository();
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ ModuleDefinition md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/recurse3.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/recurse3.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -13,10 +13,10 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -24,25 +24,27 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws ModuleInitializationException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- ModuleDefinition md = rep.find("m3");
- Module m = md.getModuleInstance();
- ClassLoader cl = m.getClassLoader();
- try {
- Class clazz = cl.loadClass("m3.MainC");
- Object o = clazz.newInstance();
- System.out.println("m3: " + o);
- } catch (Exception e) {
- throw new ModuleInitializationException("could not get m3", e);
- }
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m2"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ ModuleDefinition md = rep.find("m3");
+ Module m = md.getModuleInstance();
+ ClassLoader cl = m.getClassLoader();
+ try {
+ Class clazz = cl.loadClass("m3.MainC");
+ Object o = clazz.newInstance();
+ System.out.println("m3: " + o);
+ } catch (Exception e) {
+ throw new ModuleInitializationException("could not get m3", e);
+ }
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/recurse4.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/recurse4.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -12,7 +12,7 @@
> export
m0.Main
>> begin class m0.Main
- new m1.MainA().run("from m0");
+ new m1.MainA().run("from m0");
>> end class
>>> end module
>>> begin module m1
@@ -26,10 +26,10 @@ m0.Main
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -37,25 +37,27 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws ModuleInitializationException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- ModuleDefinition md = rep.find("m3");
- Module m = md.getModuleInstance();
- ClassLoader cl = m.getClassLoader();
- try {
- Class clazz = cl.loadClass("m3.MainC");
- Object o = clazz.newInstance();
- System.out.println("m3: " + o);
- } catch (Exception e) {
- throw new ModuleInitializationException("could not get m3", e);
- }
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m2"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ ModuleDefinition md = rep.find("m3");
+ Module m = md.getModuleInstance();
+ ClassLoader cl = m.getClassLoader();
+ try {
+ Class clazz = cl.loadClass("m3.MainC");
+ Object o = clazz.newInstance();
+ System.out.println("m3: " + o);
+ } catch (Exception e) {
+ throw new ModuleInitializationException("could not get m3", e);
+ }
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/recurse5.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/recurse5.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -13,26 +13,29 @@
> export
m0.Main
>> begin class m0.Main
- System.out.println("OK");
+ System.out.println("OK");
>> end class
>> begin class m0.ImportPolicyImpl
> super
implements ImportPolicy
> body
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws ModuleInitializationException {
- Repository rep = moduleDef.getRepository();
- ModuleDefinition md = rep.find("m1");
- try {
- Module m = md.getModuleInstance();
- throw new RuntimeException("Unexpectedly got m1: " + m);
- } catch (ModuleInitializationException e) {
- System.out.println("OK: " + e);
- }
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ Repository rep = moduleDef.getRepository();
+ ModuleDefinition md = rep.find("m1");
+ try {
+ Module m = md.getModuleInstance();
+ throw new RuntimeException("Unexpectedly got m1: " + m);
+ } catch (ModuleInitializationException e) {
+ System.out.println("OK: " + e);
+ }
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ return result;
}
>> end class
>>> end module
@@ -47,10 +50,10 @@ implements ImportPolicy
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -58,25 +61,27 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws ModuleInitializationException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- ModuleDefinition md = rep.find("m3");
- Module m = md.getModuleInstance();
- ClassLoader cl = m.getClassLoader();
- try {
- Class clazz = cl.loadClass("m3.MainC");
- Object o = clazz.newInstance();
- System.out.println("m3: " + o);
- } catch (Exception e) {
- throw new ModuleInitializationException("could not get m3", e);
- }
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m2"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ ModuleDefinition md = rep.find("m3");
+ Module m = md.getModuleInstance();
+ ClassLoader cl = m.getClassLoader();
+ try {
+ Class clazz = cl.loadClass("m3.MainC");
+ Object o = clazz.newInstance();
+ System.out.println("m3: " + o);
+ } catch (Exception e) {
+ throw new ModuleInitializationException("could not get m3", e);
+ }
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ return result;
}
>> end class
>>> end module
--- a/test/java/module/modinit/mtest/importpolicy/recurse6.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/recurse6.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -14,28 +14,30 @@
> export
m0.Main
>> begin class m0.Main
- new m4.MainD().run("from m0");
- System.out.println("OK");
+ new m4.MainD().run("from m0");
+ System.out.println("OK");
>> end class
>> begin class m0.ImportPolicyImpl
> super
implements ImportPolicy
> body
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws ModuleInitializationException {
- Repository rep = moduleDef.getRepository();
- ModuleDefinition md = rep.find("m1");
- try {
- Module m = md.getModuleInstance();
- throw new RuntimeException("Unexpectedly got m1: " + m);
- } catch (ModuleInitializationException e) {
- System.out.println("OK: " + e);
- }
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m4"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ Repository rep = moduleDef.getRepository();
+ ModuleDefinition md = rep.find("m1");
+ try {
+ Module m = md.getModuleInstance();
+ throw new RuntimeException("Unexpectedly got m1: " + m);
+ } catch (ModuleInitializationException e) {
+ System.out.println("OK: " + e);
+ }
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ return result;
}
>> end class
>>> end module
@@ -50,10 +52,10 @@ implements ImportPolicy
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
+ if (ImportPolicyImpl.CALLED == false) {
+ throw new Exception("Import policy not called");
+ }
+ new m2.MainB().run("from m1");
>> end class
>> begin class m1.ImportPolicyImpl
> super
@@ -61,25 +63,27 @@ implements ImportPolicy
> body
static volatile boolean CALLED;
- public List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
- Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
- throws ModuleInitializationException {
- CALLED = true;
- Repository rep = moduleDef.getRepository();
- ModuleDefinition md = rep.find("m3");
- Module m = md.getModuleInstance();
- ClassLoader cl = m.getClassLoader();
- try {
- Class clazz = cl.loadClass("m3.MainC");
- Object o = clazz.newInstance();
- System.out.println("m3: " + o);
- } catch (Exception e) {
- throw new ModuleInitializationException("could not get m3", e);
- }
- List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>();
- mds.add(rep.find("java.se"));
- mds.add(rep.find("m2"));
- return mds;
+ public Map<ImportDependency,VersionConstraint> getImports(ModuleDefinition moduleDef,
+ Map<ImportDependency,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
+ throws ModuleInitializationException {
+ CALLED = true;
+ Repository rep = moduleDef.getRepository();
+ ModuleDefinition md = rep.find("m3");
+ Module m = md.getModuleInstance();
+ ClassLoader cl = m.getClassLoader();
+ try {
+ Class clazz = cl.loadClass("m3.MainC");
+ Object o = clazz.newInstance();
+ System.out.println("m3: " + o);
+ } catch (Exception e) {
+ throw new ModuleInitializationException("could not get m3", e);
+ }
+ Map<ImportDependency,VersionConstraint> result = new HashMap<ImportDependency,VersionConstraint>();
+ for (ImportDependency dep : moduleDef.getImportDependencies()) {
+ md = rep.find(dep.getName(), dep.getVersionConstraint());
+ result.put(dep, md.getVersion().toVersionConstraint());
+ }
+ return result;
}
>> end class
>>> end module
@@ -114,7 +118,7 @@ m3.MainC
> export
m4.MainD
>> begin class m4.MainD
- new m5.MainE().run("from m4");
+ new m5.MainE().run("from m4");
>> end class
>>> end module
>>> begin module m5
--- a/test/java/module/modinit/mtest/importpolicy/version1.mtest Fri Apr 18 01:02:32 2008 -0700
+++ b/test/java/module/modinit/mtest/importpolicy/version1.mtest Sat Apr 19 03:38:14 2008 -0700
@@ -1,5 +1,5 @@
#
-# Verify that the custom import policy is invoked
+# Verify that the custom import policy is invoked
# and that it can pick a version of m2 other than the highest
# if no version constraint is specified in the import
#
@@ -14,13 +14,13 @@
> export
m1.Main
>> begin class m1.MainA
- if (ImportPolicyImpl.CALLED == false) {
- throw new Exception("Import policy not called");
- }
- new m2.MainB().run("from m1");
- if (m2.MainB.V != 1) {
- throw new Exception("Wrong version of m2");
- }