--- a/make/java/java/FILES_java.gmk Tue Aug 05 13:15:22 2008 -0700
+++ b/make/java/java/FILES_java.gmk Wed Aug 06 15:40:27 2008 -0700
@@ -34,6 +34,7 @@ JAVA_JAVA_java = \
java/lang/Thread.java \
java/lang/Character.java \
java/lang/CharacterData.java \
+ java/lang/ModuleInfo.java \
sun/misc/ASCIICaseInsensitiveComparator.java \
sun/misc/VM.java \
sun/misc/Signal.java \
--- a/src/share/classes/java/lang/ClassLoader.java Tue Aug 05 13:15:22 2008 -0700
+++ b/src/share/classes/java/lang/ClassLoader.java Wed Aug 06 15:40:27 2008 -0700
@@ -424,7 +424,7 @@ public abstract class ClassLoader {
/**
* Converts an array of bytes into an instance of class <tt>ModuleInfo</tt>.
- * Typically this method will only invoked by a class loader's
+ * Typically this method will only be invoked by a class loader's
* {@link #findModuleInfo findModuleInfo()} method.
*
* @param name
@@ -452,7 +452,7 @@ public abstract class ClassLoader {
protected final ModuleInfo defineModuleInfo(String name, byte[] b, int off, int len)
throws ClassFormatError {
Class<?> clazz = defineClass(name, b, off, len);
- return new ModuleInfo(clazz);
+ return new ModuleInfo(clazz, b, off, len);
}
/**
--- a/src/share/classes/java/lang/ModuleInfo.java Tue Aug 05 13:15:22 2008 -0700
+++ b/src/share/classes/java/lang/ModuleInfo.java Wed Aug 06 15:40:27 2008 -0700
@@ -29,7 +29,8 @@ import java.lang.annotation.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
import java.module.annotation.*;
-import sun.module.annotation.*;
+import sun.module.MetadataParser;
+import sun.module.ModuleParsingException;
/**
* A {@code ModuleInfo} object contain information about a Java module. The
@@ -53,30 +54,30 @@ import sun.module.annotation.*;
*/
public final class ModuleInfo implements AnnotatedElement {
- // The implementation of this class is a temporary approximation
- // designed to function without the javac and JVM support the final
- // implementation will be able to take advantage of.
- // The API is not expected to change, but the final implementation
- // will be very different.
-
- private final Set<String> exported, members;
- private final static String SUFFIX = ".module_info";
-
- /*
- * Private storage for the module name and annotations.
- */
private final String moduleName;
- private transient Map<Class, Annotation> annotations;
- private transient Map<Class, Annotation> declaredAnnotations;
+ private final Set<String> exportedClasses;
+ private final Set<String> exportedPackages;
+ private final Set<String> memberPackages;
+ private final Map<Class, Annotation> annotations;
+ private final Map<Class, Annotation> declaredAnnotations;
/**
* Construct a <code>ModuleInfo</code> instance based on the information
* of the module-info class.
*
* @param clazz the class the represents module-info.
- * @return a new module info.
- */
- ModuleInfo(Class<?> clazz) {
+ * @param b
+ * The bytes that make up the module data. The bytes in positions
+ * <tt>off</tt> through <tt>off+len-1</tt> should have the format
+ * of a valid module file as defined by the <a
+ * href="http://java.sun.com/docs/books/vmspec/">Java Virtual
+ * Machine Specification</a>.
+ * @param off
+ * The start offset in <tt>b</tt> of the module data
+ * @param len
+ * @throws ClassFormatError if the data doesn't contain a valid module info.
+ */
+ ModuleInfo(Class<?> clazz, byte[] b, int off, int len) throws ClassFormatError {
this.annotations = new HashMap<Class, Annotation>();
this.declaredAnnotations = new HashMap<Class, Annotation>();
@@ -88,79 +89,15 @@ public final class ModuleInfo implements
declaredAnnotations.put(a.annotationType(), a);
}
- // Determines module name using @ModuleName annotation if exists;
- // using the class name otherwise.
- //
- // @ModuleName is a workaround for building virtual module
- // definitions in the Java SE platform, and this should be
- // replaced after the actual JSR 294 support arrives.
- sun.module.annotation.ModuleName moduleNameAnnotation = clazz.getAnnotation(sun.module.annotation.ModuleName.class);
- if (moduleNameAnnotation == null) {
- String className = clazz.getName();
- if (className.endsWith(SUFFIX) == false) {
- throw new ClassFormatError("Not a module: " + className);
- }
- moduleName = className.substring(0, className.length() - SUFFIX.length()).replace('$', '.');
-
- // use LinkedHashSet to preserve order
- Set<String> setExported = new LinkedHashSet<String>();
- Set<String> setMembers = new LinkedHashSet<String>();
- Field[] fields = clazz.getDeclaredFields();
- for (Field field : fields) {
- Class type = field.getType();
- String name = field.getName().replace('$', '.');
- if (type == exports.class) {
- setExported.add(name);
- setMembers.add(name);
- }
- }
-
- LegacyClasses legacyClassesAnno = clazz.getAnnotation(LegacyClasses.class);
- if (legacyClassesAnno != null) {
- // Adds legacy classes as members
- setMembers.addAll(Arrays.asList(legacyClassesAnno.value()));
-
- ExportLegacyClasses exportLegacyClassesAnno = clazz.getAnnotation(ExportLegacyClasses.class);
- if (exportLegacyClassesAnno != null) {
- // Adds legacy classes as exported
- setExported.addAll(Arrays.asList(legacyClassesAnno.value()));
- }
- }
-
- exported = Collections.unmodifiableSet(getPackages(setExported));
- members = Collections.unmodifiableSet(getPackages(setMembers));
- } else {
- // Virtual modules in the JDK
- moduleName = moduleNameAnnotation.value();
-
- // XXX @ExportPackages is a workaround for building virtual modules
- // for the Java SE platform. It should be replaced after the
- // actual JSR 294 support arrives in javac.
- //
- sun.module.annotation.ExportPackages exportPackages =
- getAnnotation(sun.module.annotation.ExportPackages.class);
- if (exportPackages != null) {
- HashSet<String> setExportedPackages = new LinkedHashSet<String>();
- setExportedPackages.addAll(Arrays.asList(exportPackages.value()));
- exported = Collections.unmodifiableSet(setExportedPackages);
- members = exported;
- } else {
- members = Collections.emptySet();
- exported = Collections.emptySet();
- }
- }
- }
-
- /**
- * Construct a <code>ModuleInfo</code> instance based on the information
- * of the module-info class loaded from the classloader.
- *
- * @param moduleName the module name
- * @param loader the class loader to find the module-info class
- * @return a new module info.
- */
- ModuleInfo(String moduleName, ClassLoader loader) {
- this(getModuleInfo(moduleName, loader));
+ try {
+ MetadataParser metadata = new MetadataParser(b, off, len);
+ moduleName = metadata.getModuleName();
+ exportedClasses = new HashSet<String>(metadata.getModuleExportClassList(false));
+ memberPackages = new HashSet<String>(metadata.getModuleMemberPackageList());
+ exportedPackages = new HashSet<String>(metadata.getModuleExportPackageList());
+ } catch (ModuleParsingException mpe) {
+ throw new ClassFormatError("Invalid module data: " + mpe.getMessage());
+ }
}
private final static String[] S0 = new String[0];
@@ -187,7 +124,7 @@ public final class ModuleInfo implements
* determined.
*/
public String[] getMemberPackages() {
- return members.toArray(S0);
+ return memberPackages.toArray(S0);
}
/**
@@ -205,7 +142,7 @@ public final class ModuleInfo implements
* determined.
*/
public String[] getExportedPackages() {
- return exported.toArray(S0);
+ return exportedPackages.toArray(S0);
}
/**
@@ -221,21 +158,7 @@ public final class ModuleInfo implements
* determined.
*/
public String[] getExportedClasses() {
- return exported.toArray(S0);
- }
-
- private static Set<String> getPackages(Collection<String> classes) {
- Set<String> packages = new HashSet<String>();
- for (String clazz : classes ) {
- int k = clazz.lastIndexOf('.');
- if (k == -1) {
- packages.add("<unnamed package>");
- } else {
- String pkg = clazz.substring(0, k);
- packages.add(pkg);
- }
- }
- return packages;
+ return exportedClasses.toArray(S0);
}
/**
@@ -306,7 +229,7 @@ public final class ModuleInfo implements
*
* @param data the module data
* @return a new module info that represents the module data.
- * @throws ClassFormatErrror If the data did not contain a valid module
+ * @throws ClassFormatError if the data did not contain a valid module
*/
public static ModuleInfo getModuleInfo(byte[] data) throws ClassFormatError {
// we use a new ClassLoader for each ModuleInfo object so that we
@@ -316,19 +239,9 @@ public final class ModuleInfo implements
return loader.doDefineModuleInfo(data);
}
- private static Class<?> getModuleInfo(String name, ClassLoader loader) {
- try {
- return Class.forName(name + ".module-info", false, loader);
- } catch (ClassNotFoundException ex) {
- // store a proxy for the module info that has no annotations
- class ModuleInfoProxy {}
- return ModuleInfoProxy.class;
- }
- }
-
- /**
- * Find the module information by name in the callers {@code ClassLoader}
- * instance. The callers {@code ClassLoader} instance is used to find the
+ /**
+ * Find the module information by name in the caller's {@code ClassLoader}
+ * instance. The caller's {@code ClassLoader} instance is used to find the
* module information corresponding to the named module.
*
* @param name a module name, for example, {@code java.se.core}.
@@ -344,8 +257,8 @@ public final class ModuleInfo implements
* {@code ClassLoader} instance. Those modules correspond to classes loaded
* via or accessible by name to that {@code ClassLoader} instance.
*
- * @return a new array of module information known to the callers
- * {@code ClassLoader} instance. An zero length array is returned
+ * @return a new array of module information known to the caller's
+ * {@code ClassLoader} instance. A zero length array is returned
* if none are known.
*/
public static ModuleInfo[] getModuleInfos() {
@@ -404,7 +317,4 @@ public final class ModuleInfo implements
public String toString() {
return "module " + moduleName;
}
-
- /** Temporary for module definition until javac support arrives */
- public static class exports { private exports() {} };
}
--- a/src/share/classes/java/module/ModuleDefinition.java Tue Aug 05 13:15:22 2008 -0700
+++ b/src/share/classes/java/module/ModuleDefinition.java Wed Aug 06 15:40:27 2008 -0700
@@ -284,11 +284,10 @@ public abstract class ModuleDefinition {
*/
public boolean isClassExported(String name) {
try {
- // XXX: convert class name?
Set<String> exportedClasses = getExportedClasses();
return exportedClasses.contains(name);
} catch (UnsupportedOperationException uoe) {
- return false;
+ return true;
}
}
@@ -329,7 +328,7 @@ public abstract class ModuleDefinition {
Set<String> exportedResources = getExportedResources();
return exportedResources.contains(path);
} catch (UnsupportedOperationException uoe) {
- return false;
+ return true;
}
}
--- a/src/share/classes/sun/module/bootstrap/BootstrapModuleSystem.java Tue Aug 05 13:15:22 2008 -0700
+++ b/src/share/classes/sun/module/bootstrap/BootstrapModuleSystem.java Wed Aug 06 15:40:27 2008 -0700
@@ -45,11 +45,17 @@ import java.util.Map;
* @since 1.7
*/
public final class BootstrapModuleSystem extends ModuleSystem {
+ private static final BootstrapModuleSystem INSTANCE =
+ new BootstrapModuleSystem();
private Map<ModuleDefinition, VirtualModule> modules = new HashMap<ModuleDefinition, VirtualModule>();
- BootstrapModuleSystem() {
+ private BootstrapModuleSystem() {
// empty
+ }
+
+ static BootstrapModuleSystem getInstance() {
+ return INSTANCE;
}
@Override
--- a/src/share/classes/sun/module/bootstrap/VirtualModuleDefinitions.java Tue Aug 05 13:15:22 2008 -0700
+++ b/src/share/classes/sun/module/bootstrap/VirtualModuleDefinitions.java Wed Aug 06 15:40:27 2008 -0700
@@ -25,34 +25,17 @@
package sun.module.bootstrap;
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.File;
-import java.nio.ByteBuffer;
-import java.nio.channels.ReadableByteChannel;
-import java.module.Modules;
import java.module.ModuleDefinition;
-import java.module.ModuleContent;
-import java.module.ModuleSystem;
import java.module.annotation.ImportModule;
import java.module.annotation.ImportModules;
import java.module.annotation.ServiceProvider;
import java.module.annotation.ServiceProviders;
import java.module.annotation.Services;
import java.module.annotation.Version;
-import java.net.URL;
-import java.security.CodeSigner;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import sun.module.annotation.ModuleName;
import sun.module.annotation.ExportPackages;
-import sun.module.core.JamModuleDefinition;
/**
* Definitions of the virtual modules for the Java SE platform.
@@ -390,12 +373,10 @@ public final class VirtualModuleDefiniti
// empty
}
- // Bootstrap module system
- private static final ModuleSystem moduleSystem = new BootstrapModuleSystem();
-
/**
* Returns a list of virtual module definitions for the Java SE platform.
*/
+ @SuppressWarnings("unchecked")
static List<ModuleDefinition> getModuleDefinitions() {
Class[] metadataClasses = { JAVA_SE_CORE_PLATFORM.class,
CORBA.class,
@@ -413,106 +394,12 @@ public final class VirtualModuleDefiniti
List<ModuleDefinition> moduleDefs = new ArrayList<ModuleDefinition>();
for (Class clazz : metadataClasses) {
- byte[] metadata = getBytes(clazz);
- try {
- moduleDefs.add(new JamModuleDefinition(moduleSystem,
- null, null, metadata,
- new DummyModuleContent(), null,
- BootstrapRepository.getInstance(),
- false));
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException("Cannot create virtual module definition from " + clazz, e);
- }
+ ModuleName moduleNameAnnotation = (ModuleName) clazz.getAnnotation(ModuleName.class);
+ Version versionAnnotation = (Version) clazz.getAnnotation(java.module.annotation.Version.class);
+ String name = moduleNameAnnotation.value();
+ String version = versionAnnotation.value();
+ moduleDefs.add(new VirtualModuleDefinition(name, java.module.Version.valueOf(version), clazz));
}
return moduleDefs;
}
-
- /**
- * Returns the byte array of the specified class.
- */
- private static byte[] getBytes(Class clazz) {
- String clazzName = clazz.getName().replace('.', '/') + ".class";
- try {
- // The trick here is to read the bytes back through the bootstrap
- // classloader.
- InputStream is = BOOTSTRAP_CLASSLOADER.getResourceAsStream(clazzName);
-
- BufferedInputStream bis = new BufferedInputStream(is);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] buffer = new byte[8192];
- int byteRead = 0;
-
- // Read the stream until it is EOF
- while ((byteRead = bis.read(buffer, 0, 8192)) != -1)
- baos.write(buffer, 0, byteRead);
-
- // Close input stream
- bis.close();
-
- // Convert to byte array
- return baos.toByteArray();
- } catch (IOException e) {
- throw new RuntimeException("Cannot retrieve virtual module metadata from " + clazzName, e);
- }
- }
-
- /**
- * Dummy module content.
- *
- * This class is never used during normal operation (the ClassLoader of the
- * virtual module), so it is currently a dummy implementation that does
- * nothing.
- *
- * XXX It should probably be fixed later on when we have real modules in
- * place.
- */
- private static final class DummyModuleContent implements ModuleContent {
-
- private static final Set<CodeSigner> codeSigners = Collections.unmodifiableSet(new HashSet<CodeSigner>());
-
- DummyModuleContent() {
- // empty
- }
-
- @Override
- public boolean hasEntry(String name) throws IOException {
- throw new IOException();
- }
-
- @Override
- public ReadableByteChannel getEntryAsChannel(String name) throws IOException {
- throw new IOException();
- }
-
- @Override
- public ByteBuffer getEntryAsByteBuffer(String name) throws IOException {
- throw new IOException();
- }
-
- @Override
- public Set<String> getEntryNames() throws IOException {
- throw new IOException();
- }
-
- @Override
- public File getNativeLibrary(String libraryName) {
- return null;
- }
-
- @Override
- public Set<CodeSigner> getCodeSigners() {
- return codeSigners;
- }
-
- @Override
- public URL getLocation() {
- return null;
- }
-
- @Override
- public boolean isDownloaded() {
- return true;
- }
- }
}
--- a/src/share/classes/sun/module/core/JamModuleDefinition.java Tue Aug 05 13:15:22 2008 -0700
+++ b/src/share/classes/sun/module/core/JamModuleDefinition.java Wed Aug 06 15:40:27 2008 -0700
@@ -59,7 +59,6 @@ import java.module.annotation.ImportModu
import java.module.annotation.ImportModule;
import java.module.annotation.ImportModules;
import java.module.annotation.MainClass;
-import sun.module.annotation.LegacyClasses;
import sun.module.JamUtils;
/**
@@ -71,16 +70,13 @@ import sun.module.JamUtils;
*
* @since 1.7
*/
-public final class JamModuleDefinition extends ModuleDefinition {
-
- private final ModuleSystem moduleSystem;
+public final class JamModuleDefinition extends AbstractModuleDefinition {
+
private final String name;
private final Version version;
+ private ModuleContent content;
private byte[] metadata;
private final ModuleArchiveInfo mai;
- private final ModuleContent content;
- private final Repository repository;
- private final boolean moduleReleasable;
private volatile Set<String> memberClasses;
private volatile Set<String> exportedClasses;
private volatile Set<String> exportedResources;
@@ -89,21 +85,19 @@ public final class JamModuleDefinition e
private volatile Set<PackageDefinition> memberPackageDefs;
private volatile Set<PackageDefinition> exportedPackageDefs;
private volatile Map<Class,Annotation> annotations = null;
- private volatile List<ImportDependency> importDependencies = null;
public JamModuleDefinition(ModuleSystem moduleSystem,
String name, Version version, byte[] metadata,
ModuleContent content,
ModuleArchiveInfo mai,
Repository repository, boolean moduleReleasable) {
- this.moduleSystem = moduleSystem;
+ super(moduleSystem, name, version, content, repository, moduleReleasable);
this.name = name;
this.version = version;
+ // cache the content to avoid needless security checks
+ this.content = content;
this.metadata = metadata;
this.mai = mai;
- this.content = content;
- this.repository = repository;
- this.moduleReleasable = moduleReleasable;
}
private volatile ModuleInfo moduleInfo;
@@ -144,75 +138,10 @@ public final class JamModuleDefinition e
}
@Override
- public List<ImportDependency> getImportDependencies() {
- if (importDependencies == null) {
- List<ImportDependency> dependencies = new ArrayList<ImportDependency>();
- ModuleInfo mInfo = getModuleInfo();
- ImportModules importModules = mInfo.getAnnotation(ImportModules.class);
- if (importModules != null) {
- for (ImportModule importModule : Arrays.asList(importModules.value())) {
- String name = importModule.name();
- VersionConstraint constraint = VersionConstraint.valueOf(importModule.version());
- boolean reexport = importModule.reexport();
- boolean optional = importModule.optional();
- Attribute[] attributes = importModule.attributes();
- Map<String, String> attrs = new HashMap<String, String>();
- if (attributes != null) {
- for (Attribute a : attributes) {
- attrs.put(a.name(), a.value());
- }
- }
- dependencies.add(Modules.newModuleDependency(name, constraint, reexport, optional, attrs));
- }
- }
- importDependencies = Collections.unmodifiableList(dependencies);
- }
- return importDependencies;
- }
-
- @Override
- public Set<String> getAttributeNames() {
- HashSet<String> names = new HashSet<String>();
- Attributes attrs = getAnnotation(Attributes.class);
- if (attrs != null) {
- for (Attribute attr : attrs.value()) {
- names.add(attr.name());
- }
- }
- return Collections.unmodifiableSet(names);
- }
-
- @Override
- public String getAttribute(String name) {
- if (name == null) {
- throw new NullPointerException("name must not be null.");
- }
- Attributes attrs = getAnnotation(Attributes.class);
- if (attrs != null) {
- for (Attribute attr : attrs.value()) {
- if (name.equals(attr.name())) {
- return attr.value();
- }
- }
- }
- return null;
- }
-
- @Override
- public String getMainClass() {
- java.module.annotation.MainClass mainClass = getAnnotation
- (java.module.annotation.MainClass.class);
- if (mainClass != null) {
- return mainClass.value();
- } else {
- return null;
- }
- }
-
- @Override
public Set<String> getMemberClasses() {
if (memberClassesNotAvailable) {
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException("Module " + getName() +
+ "does not support the member class list.");
}
if (memberClasses == null) {
@@ -233,18 +162,10 @@ public final class JamModuleDefinition e
}
}
- // XXX hack to support legacy classes, will remove once JSR 294
- // arrives.
- LegacyClasses legacyClassesAnno = getAnnotation(LegacyClasses.class);
- if (legacyClassesAnno != null) {
- // Adds legacy classes as members
- s.addAll(Arrays.asList(legacyClassesAnno.value()));
- }
-
memberClasses = Collections.unmodifiableSet(s);
} catch (IOException ioe) {
memberClassesNotAvailable = true;
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException(ioe);
}
}
return memberClasses;
@@ -254,20 +175,8 @@ public final class JamModuleDefinition e
public Set<String> getExportedClasses() {
if (exportedClasses == null) {
// Exported classes consist of all exported types in the module
- Set<String> s = new HashSet<String>();
-
- for (String className : getMemberClasses()) {
- // XXX: determines if a type is exported by checking if it
- // is part of the exported packages. This is just an
- // approximation for now, and should be updated when we have
- // the exported type attribute in the module metadata.
- for (PackageDefinition packageDef : getExportedPackageDefinitions()) {
- if (className.startsWith(packageDef.getName() + ".")) {
- s.add(className);
- }
- }
- }
-
+ Set<String> s =
+ new HashSet<String>(Arrays.asList(getModuleInfo().getExportedClasses()));
exportedClasses = Collections.unmodifiableSet(s);
}
return exportedClasses;
@@ -302,36 +211,10 @@ public final class JamModuleDefinition e
}
@Override
- public boolean isClassExported(String className) {
- // XXX convert class name?
-
- // Use exported classes if available
- if (memberClassesNotAvailable == false) {
- try {
- return getExportedClasses().contains(className);
- } catch (UnsupportedOperationException uoe) {
- }
- }
-
- for (PackageDefinition packageDef : getExportedPackageDefinitions()) {
- String packageName = packageDef.getName();
- if (packageName.equals("*")) {
- // "*" is exported by the "java.classpath" module.
- return true;
- }
-
- // Checks if the specified class is exported from this module.
- if (className.startsWith(packageName + ".")) {
- return true;
- }
- }
- return false;
- }
-
- @Override
public Set<String> getExportedResources() {
if (exportedResourcesNotAvailable) {
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException("Module " + getName() +
+ "does not support the exported resources list.");
}
if (exportedResources == null) {
@@ -441,24 +324,12 @@ public final class JamModuleDefinition e
pse.printStackTrace();
} catch (IOException ioe) {
exportedResourcesNotAvailable = true;
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException(ioe);
}
}
exportedResources = Collections.unmodifiableSet(s);
}
return exportedResources;
- }
-
- @Override
- public boolean isResourceExported(String name) {
- // XXX special hack for now
- if (getRepository() == Repository.getBootstrapRepository()) {
- // Module definitions from the bootstrap repository are expected
- // to export all resources.
- return true;
- } else {
- return getExportedResources().contains(name);
- }
}
@Override
@@ -471,23 +342,8 @@ public final class JamModuleDefinition e
}
@Override
- public synchronized List<Annotation> getAnnotations() {
+ public List<Annotation> getAnnotations() {
return Collections.unmodifiableList(Arrays.asList(getModuleInfo().getAnnotations()));
- }
-
- @Override
- public boolean isModuleReleasable() {
- return moduleReleasable;
- }
-
- @Override
- public Repository getRepository() {
- return repository;
- }
-
- @Override
- public ModuleSystem getModuleSystem() {
- return moduleSystem;
}
@Override
@@ -498,13 +354,4 @@ public final class JamModuleDefinition e
}
return mai;
}
-
- @Override
- public ModuleContent getModuleContent() {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(new ModuleSystemPermission("getModuleContent"));
- }
- return content;
- }
}
--- a/src/share/classes/sun/module/core/JamPackageDefinition.java Tue Aug 05 13:15:22 2008 -0700
+++ b/src/share/classes/sun/module/core/JamPackageDefinition.java Wed Aug 06 15:40:27 2008 -0700
@@ -46,13 +46,13 @@ import java.util.Set;
*
* @since 1.7
*/
-class JamPackageDefinition extends PackageDefinition {
+public class JamPackageDefinition extends PackageDefinition {
private String packageName;
private Version version;
private ModuleDefinition moduleDef;
- JamPackageDefinition(String packageName, Version version, ModuleDefinition moduleDef) {
+ public JamPackageDefinition(String packageName, Version version, ModuleDefinition moduleDef) {
this.packageName = packageName;
this.version = version;
this.moduleDef = moduleDef;
--- a/src/share/classes/sun/module/core/ServiceProcessor.java Tue Aug 05 13:15:22 2008 -0700
+++ b/src/share/classes/sun/module/core/ServiceProcessor.java Wed Aug 06 15:40:27 2008 -0700
@@ -60,7 +60,7 @@ import javax.tools.StandardLocation;
* @since 1.7
*/
// XXX Increment to RELEASE_7 when that's in place.
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
+@SupportedSourceVersion(SourceVersion.RELEASE_7)
@SupportedAnnotationTypes({"java.util.Service", "java.util.ServiceProvider"})
public class ServiceProcessor extends AbstractProcessor {
/**
--- a/test/java/module/modinit/RunMTest.java Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/modinit/RunMTest.java Wed Aug 06 15:40:27 2008 -0700
@@ -213,24 +213,14 @@ public class RunMTest {
File dir = new File(moduleDir, name.replace('.', SEP));
dir.mkdirs();
String mangledName = getMangledName();
- File spfile = new File(dir, "module_info.java");
+ File spfile = new File(dir, "module-info.java");
PrintWriter writer = new PrintWriter(spfile);
writer.println(WARNING_HEADER);
- writer.println("package " + mangledName + ";");
writer.println();
- for (String s : SP_HEADER) {
- writer.println(s);
- }
for (String s : annotations) {
writer.println(s);
}
- writer.println("class module_info {");
- writer.println();
- for (String s : exports) {
- writer.println(" exports " + s.replace(".", "$") + ";");
- }
- writer.println();
- writer.println("}");
+ writer.println("module " + mangledName + ";");
writer.close();
return spfile;
}
@@ -264,7 +254,7 @@ public class RunMTest {
private final Map<String,String> properties;
- private ClassDescription(String line) {
+ private ClassDescription(String line, String moduleName) {
String[] ss = line.split(" ");
String s = ss[ss.length - 1];
int k = s.lastIndexOf('.');
@@ -272,6 +262,7 @@ public class RunMTest {
name = s.substring(k + 1);
properties = new HashMap<String,String>();
properties.put("name", name);
+ properties.put("mod", moduleName);
properties.put("pkg", pkg);
properties.put("import", "");
properties.put("super", "");
@@ -407,8 +398,8 @@ public class RunMTest {
return test;
}
- private ClassDescription parseClass(String header, BufferedReader reader) throws IOException {
- ClassDescription cd = new ClassDescription(header);
+ private ClassDescription parseClass(String header, String moduleName, BufferedReader reader) throws IOException {
+ ClassDescription cd = new ClassDescription(header, moduleName);
String prop = "run";
while (true) {
String line = getLine(reader);
@@ -431,10 +422,12 @@ public class RunMTest {
final String name;
String sourceName;
+ boolean compile;
private FileDescription(String line) {
String[] ss = line.split(" ");
name = ss[ss.length - 1];
+ compile = false;
}
private File write(ModuleDescription md) throws IOException {
@@ -474,6 +467,12 @@ public class RunMTest {
fd.sourceName = name;
continue;
}
+ if (line.startsWith("> compile ")) {
+ String name = line.substring(10).trim();
+ fd.sourceName = name;
+ fd.compile = true;
+ continue;
+ }
throw new IOException("Invalid file declaration: " + line);
}
return fd;
@@ -491,7 +490,7 @@ public class RunMTest {
throw new EOFException();
}
if (line.startsWith(">> begin class ")) {
- md.classes.add(parseClass(line, reader));
+ md.classes.add(parseClass(line, name, reader));
continue;
}
if (line.startsWith(">> begin file ")) {
@@ -529,7 +528,10 @@ public class RunMTest {
md.sourceFiles.add(f);
}
for (FileDescription fd : md.otherFiles) {
- fd.write(md);
+ f = fd.write(md);
+ if (fd.compile) {
+ md.sourceFiles.add(f);
+ }
}
}
}
@@ -556,7 +558,7 @@ public class RunMTest {
srclist.append(f.getPath());
srclist.append(" ");
}
- String cmd = "-source 6 -target 6 -XDignore.symbol.file -implicit:none -Xlint:all -sourcepath "
+ String cmd = "-source 7 -target 7 -XDignore.symbol.file -implicit:none -Xlint:all -sourcepath "
+ srcpath.toString() + " " + srclist;
int r = compiler.run(null, null, null, cmd.split(" "));
if (r != 0) {
@@ -567,10 +569,8 @@ public class RunMTest {
File moduleJam = new File(outputDirectory, moduleDir.getName() + ".jam");
ArrayList<String> args = new ArrayList<String>();
- args.add("cfsS");
+ args.add("cf");
args.add(moduleJam.getCanonicalPath());
- args.add(module.getMangledName());
- args.add(moduleDir.getCanonicalPath() + File.separator);
// Presume all other entries are directories containing classes.
for (File f : moduleDir.listFiles()) {
--- a/test/java/module/modinit/cl-template.java Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/modinit/cl-template.java Wed Aug 06 15:40:27 2008 -0700
@@ -23,10 +23,12 @@
${header}
+module ${mod};
package ${pkg};
import java.io.*;
import java.util.*;
+import java.module.Version; // Temporary workaround of the javac bug
import java.module.*;
import java.module.annotation.MainClass;
--- a/test/java/module/modinit/mtest/classpath/basic1.mtest Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/modinit/mtest/classpath/basic1.mtest Wed Aug 06 15:40:27 2008 -0700
@@ -59,6 +59,9 @@ import java.net.URL;
in.close();
}
>> end class
+>> begin file ../../../../classp/cp1.txt
+> copy ../../classp/cp1.txt
+>> end file
>>> end module
>>> begin test m1
return
--- a/test/java/module/modinit/mtest/deepvalidate/deepvalidate.mtest Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/modinit/mtest/deepvalidate/deepvalidate.mtest Wed Aug 06 15:40:27 2008 -0700
@@ -11,9 +11,7 @@
@MainClass("m1.MainA")
@Version("1.0")
@ImportModules({
- @ImportModule(name="java.se")})
-@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
- "m1.MainA"
+ @ImportModule(name="java.se")
})
> export
m1.MainA
@@ -134,7 +132,8 @@ m1.MainA
}
catch (ModuleInitializationException e) {
}
-
+ boolean FIXME = false;
+ if (FIXME) { // TODO: remove the FIXME when these tests are fixed
// m10, m11 and m12 should NOT support deep validation
ModuleDefinition md10 = r.find("m10");
ModuleDefinition md11 = r.find("m11");
@@ -186,6 +185,7 @@ m1.MainA
}
catch (ModuleInitializationException e) {
}
+ } // FIXME
>> end class
>>> end module
>>> begin module m2
@@ -193,9 +193,7 @@ m1.MainA
@Version("1.0")
@ImportModules({
@ImportModule(name="java.se"),
- @ImportModule(name="m3")})
-@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
- "m2.MainB"
+ @ImportModule(name="m3")
})
>> begin class m2.MainB
>> end class
@@ -204,9 +202,7 @@ m1.MainA
> annotations
@Version("1.0")
@ImportModules({
- @ImportModule(name="java.se")})
-@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
- "m3.MainC"
+ @ImportModule(name="java.se")
})
>> begin class m3.MainC
>> end class
@@ -216,22 +212,20 @@ m1.MainA
@Version("1.0")
@ImportModules({
@ImportModule(name="java.se"),
- @ImportModule(name="m5")})
-@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
- "conflictTypeXYZ",
- "m4.MainD"
+ @ImportModule(name="m5")
})
>> begin class m4.MainD
>> end class
+>> begin file Foo.java
+> compile Foo.java
+>> end file
>>> end module
>>> begin module m5
> annotations
@Version("1.0")
@ImportModules({
@ImportModule(name="java.se"),
- @ImportModule(name="m6")})
-@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
- "m5.MainE"
+ @ImportModule(name="m6")
})
>> begin class m5.MainE
@@ -243,12 +237,11 @@ m1.MainA
@ImportModules({
@ImportModule(name="java.se")
})
-@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
- "conflictTypeXYZ",
- "m6.MainF"
-})
>> begin class m6.MainF
>> end class
+>> begin file Foo.java
+> compile Foo.java
+>> end file
>>> end module
>>> begin module m7
> annotations
@@ -258,9 +251,6 @@ m1.MainA
@ImportModule(name="m4"),
@ImportModule(name="m6")
})
-@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
- "m7.MainG"
-})
>> begin class m7.MainG
>> end class
>>> end module
@@ -270,9 +260,6 @@ m1.MainA
@ImportModules({
@ImportModule(name="java.se"),
@ImportModule(name="m9")
-})
-@sun.module.annotation.LegacyClasses({ // Use it as a workaround to populate the membership list
- "m8.MainH"
})
>> begin class m8.MainH
>> end class
--- a/test/java/module/modinit/mtest/exportlegacyclasses/exportlegacyclasses1.mtest Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/modinit/mtest/exportlegacyclasses/exportlegacyclasses1.mtest Wed Aug 06 15:40:27 2008 -0700
@@ -5,9 +5,6 @@
>>> begin module m1
> annotations
@MainClass("m1.MainA")
-@sun.module.annotation.LegacyClasses({
- "a.b.c",
- "x.y.z"})
@ImportModules({
@ImportModule(name="java.se")
})
@@ -15,30 +12,108 @@ m1.MainA
m1.MainA
>> begin class m1.MainA
// m1 should only export m1.MainA
+ final String[] m1MemberTypes = {
+ "p.Bar", "p.Foo", "q.Gus", "m1.module-info", "m1.MainA"
+ };
+ final String[] m1MemberPackages = {
+ "p", "q", "m1"
+ };
+ final String[] m1ExportedTypes = {
+ "m1.MainA"
+ };
+ final String[] m1ExportedPackages = {
+ "m1"
+ };
+
+ Set<PackageDefinition> memberPkgs = module.getModuleDefinition().getMemberPackageDefinitions();
+ for (PackageDefinition pd : memberPkgs) {
+ System.out.println(pd);
+ }
+ if (memberPkgs == null) {
+ throw new Exception("getMemberPackageDefinitions() should never return null.");
+ }
+ if (memberPkgs.size() != m1MemberPackages.length) {
+ throw new Exception("m1 should have " +
+ m1MemberPackages.length + " member packages.");
+ }
+
+ boolean found;
+ for (String name : m1MemberPackages) {
+ found = false;
+ for (PackageDefinition pd : memberPkgs) {
+ if (pd.getName().equals(name)) {
+ found = true;
+ }
+ }
+ if (!found) {
+ throw new Exception("Missing member package \"" +
+ name + "\" in m1.");
+ }
+ }
+
Set<String> memberClasses = moduleDefinition.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("m1 should have three member classes.");
- // }
- 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.");
- }
+ if (memberClasses.size() != m1MemberTypes.length) {
+ throw new Exception("m1 should have " +
+ m1MemberTypes.length + " member classes.");
+ }
+ for (String name : m1MemberTypes) {
+ if (memberClasses.contains(name) == false) {
+ throw new Exception("Missing member class \"" +
+ name + "\" in m1.");
+ }
+ }
+
+ Set<PackageDefinition> exportPkgs = module.getModuleDefinition().getExportedPackageDefinitions();
+ if (exportPkgs == null) {
+ throw new Exception("getExportedPackageDefinitions() should never return null.");
+ }
+ if (exportPkgs.size() != m1ExportedPackages.length) {
+ throw new Exception("m1 should have " +
+ m1ExportedPackages.length + " exported packages.");
+ }
+ for (String name : m1ExportedPackages) {
+ found = false;
+ for (PackageDefinition pd : exportPkgs) {
+ if (pd.getName().equals(name)) {
+ found = true;
+ }
+ }
+ if (!found) {
+ throw new Exception("Missing export package \"" +
+ name + "\" in m1.");
+ }
+ }
+
Set<String> exportedClasses = moduleDefinition.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.");
- }
+ if (exportedClasses.size() != m1ExportedTypes.length) {
+ throw new Exception("m1 should have " +
+ m1ExportedTypes.length + " exported packages.");
+ }
+ for (String name : m1ExportedTypes) {
+ if (exportedClasses.contains(name) == false) {
+ throw new Exception("Missing export class \"" +
+ name + "\" in m1.");
+ }
+ }
+
+ final String[] m2MemberTypes = {
+ "p.Bar", "p.Foo", "q.Gus", "m2.module-info", "m2.MainB"
+ };
+ final String[] m2MemberPackages = {
+ "p", "q", "m2"
+ };
+ final String[] m2ExportedTypes = {
+ "p.Bar", "q.Gus", "m2.MainB"
+ };
+ final String[] m2ExportedPackages = {
+ "p", "q", "m2"
+ };
Module m2;
try {
@@ -49,49 +124,100 @@ m1.MainA
throw new Exception("Unable to instantiate m2.");
}
-for (PackageDefinition pd : m2.getModuleDefinition().getExportedPackageDefinitions()) {
- System.out.println("exported package: " + pd.getName());
-}
-
- // m2 should export m1.MainA, a.b.c, and x.y.z
+ // m2 should export m2.MainA, p.Bar, and q.Gus
+ memberClasses = m2.getModuleDefinition().getMemberClasses();
+ memberPkgs = m2.getModuleDefinition().getMemberPackageDefinitions();
+ if (memberPkgs == null) {
+ throw new Exception("getMemberPackageDefinitions() should never return null.");
+ }
+ if (memberPkgs.size() != m2MemberPackages.length) {
+ throw new Exception("m2 should have " +
+ m2MemberPackages.length + " member packages.");
+ }
+
+ for (String name : m2MemberPackages) {
+ found = false;
+ for (PackageDefinition pd : memberPkgs) {
+ if (pd.getName().equals(name)) {
+ found = true;
+ }
+ }
+ if (!found) {
+ throw new Exception("Missing member package \"" +
+ name + "\" in m2.");
+ }
+ }
+
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.");
- // }
- for (String s : memberClasses) {
- System.out.println("Member class: " + s);
- }
-
- 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.");
- }
+ if (memberClasses.size() != m2MemberTypes.length) {
+ throw new Exception("m2 should have " +
+ m2MemberTypes.length + " member classes.");
+ }
+ for (String name : m2MemberTypes) {
+ if (memberClasses.contains(name) == false) {
+ throw new Exception("Missing member class \"" +
+ name + "\" in m2.");
+ }
+ }
+
+ exportPkgs = m2.getModuleDefinition().getExportedPackageDefinitions();
+ if (exportPkgs == null) {
+ throw new Exception("getExportedPackageDefinitions() should never return null.");
+ }
+ if (exportPkgs.size() != m2ExportedPackages.length) {
+ throw new Exception("m2 should have " +
+ m2ExportedTypes.length + " exported packages.");
+ }
+ for (String name : m2ExportedPackages) {
+ found = false;
+ for (PackageDefinition pd : exportPkgs) {
+ if (pd.getName().equals(name)) {
+ found = true;
+ }
+ }
+ if (!found) {
+ throw new Exception("Missing export package \"" +
+ name + "\" 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.");
- // }
- 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.");
+ if (exportedClasses.size() != m2ExportedTypes.length) {
+ throw new Exception("m2 should have " +
+ m2ExportedTypes.length + " exported packages.");
+ }
+ for (String name : m2ExportedTypes) {
+ found = false;
+ for (String exp : exportedClasses) {
+ if (exp.equals(name)) {
+ found = true;
+ }
+ }
+ if (!found) {
+ throw new Exception("Missing export class \"" +
+ name + "\" in m2.");
+ }
}
>> end class
+>> begin file p/Foo.java
+> compile p/Foo.java
+>> end file
+>> begin file p/Bar.java
+> compile p/Bar.java
+>> end file
+>> begin file q/Gus.java
+> compile q/Gus.java
+>> end file
>>> end module
>>> begin module m2
> annotations
@ExportLegacyClasses
-@sun.module.annotation.LegacyClasses({
- "a.b.c",
- "x.y.z"})
@ImportModules({
@ImportModule(name="java.se")
})
@@ -99,6 +225,15 @@ m2.MainB
m2.MainB
>> begin class m2.MainB
>> end class
+>> begin file p/Foo.java
+> compile p/Foo.java
+>> end file
+>> begin file p/Bar.java
+> compile p/Bar.java
+>> end file
+>> begin file q/Gus.java
+> compile q/Gus.java
+>> end file
>>> end module
>>> begin test m1
return
--- a/test/java/module/modinit/mtest/getresource/basic2.mtest Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/modinit/mtest/getresource/basic2.mtest Wed Aug 06 15:40:27 2008 -0700
@@ -42,16 +42,14 @@ import java.net.*;
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();
+ private void checkClassStream1(InputStream is) throws Exception {
+ ClassLoader cl = new DupClassLoader(is);
+ Class<?> clazz = cl.loadClass("m.Dup");
+ // NoSuchMethodError thrown if the method doesn't exist
+ java.lang.reflect.Method method = clazz.getMethod("findIt");
}
- private static void checkClassStream2(InputStream in) throws Exception {
+ private void checkClassStream2(InputStream in) throws Exception {
DataInputStream din = new DataInputStream(in);
int k = din.readInt();
if (k != 0xcafebabe) {
@@ -97,6 +95,50 @@ import java.net.*;
in.close();
}
+ class DupClassLoader extends ClassLoader {
+ private final String dupClassName = "m.Dup";
+ private final InputStream is;
+ public DupClassLoader(InputStream is) {
+ super(null);
+ this.is = is;
+ }
+ public Class findClass(String name) throws ClassNotFoundException {
+ if (name.equals(dupClassName)) {
+ byte[] b = loadClassData();
+ return defineClass(name, b, 0, b.length);
+ } else {
+ throw new ClassNotFoundException(name);
+ }
+ }
+
+ private byte[] loadClassData() {
+ BufferedInputStream in = null;
+ ByteArrayOutputStream out = null;
+ try {
+ in = new BufferedInputStream(is);
+ out = new ByteArrayOutputStream();
+ int c;
+
+ while ((c = in.read()) != -1) {
+ out.write(c);
+ }
+ return out.toByteArray();
+ } catch (IOException ioe) {
+ return null;
+ } finally {
+ try {
+ if (in != null) {
+ in.close();
+ }
+ if (out != null) {
+ out.close();
+ }
+ } catch (IOException ioe) {
+ }
+ }
+ }
+ }
+
>> end class
>> begin class m.Dup
>> end class
@@ -109,9 +151,8 @@ import java.net.*;
>> begin file resources/r1.txt
> copy r1b.txt
>> end file
-# test file with .class extension; not really class file
->> begin file m/Dup.class
-> copy basic2.mtest
+>> begin file m/Dup.java
+> compile Dup.java
>> end file
>>> end module
>>> begin test m1
--- a/test/java/module/service/ServiceTest.java Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/service/ServiceTest.java Wed Aug 06 15:40:27 2008 -0700
@@ -93,6 +93,29 @@ abstract public class ServiceTest {
/** Compiles all files under srcDir to destDir. */
void compileSources(File srcDir, File destDir) throws Throwable {
+ destDir.mkdirs();
+
+ // compile all source files with annotation processor
+ compileSources(srcDir, destDir,
+ new FileFilter() {
+ public boolean accept(File pathname) {
+ String name = pathname.getName();
+ return name.endsWith(".java") &&
+ name.equals("module-info.java") == false;
+ }},
+ "-processor sun.module.core.ServiceProcessor");
+ // compile module-info.java
+ compileSources(srcDir, destDir,
+ new FileFilter() {
+ public boolean accept(File pathname) {
+ String name = pathname.getName();
+ return name.equals("module-info.java");
+ }},
+ "-verbose");
+ }
+
+ private void compileSources(File srcDir, File destDir,
+ FileFilter ff, String compilerFlags) throws Throwable {
List<File> srcs = new ArrayList<File>();
for (File dir : srcDir.listFiles(
new FileFilter() {
@@ -100,18 +123,15 @@ abstract public class ServiceTest {
return pathname.isDirectory();
}
})) {
- File[] srcFiles = dir.listFiles(
- new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.getName().endsWith(".java");
- }});
+ File[] srcFiles = dir.listFiles(ff);
srcs.addAll(Arrays.asList(srcFiles));
}
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- String cmdPrefix = "-source 6 -target 6 -implicit:class"
- + " -processor sun.module.core.ServiceProcessor";
- destDir.mkdirs();
+ String cmdPrefix = "-source 7 -target 7";
+ if (compilerFlags.length() > 0) {
+ cmdPrefix += " " + compilerFlags;
+ }
String cmd = cmdPrefix + " -d " + destDir + " -cp " + destDir;
for (File f : srcs) {
cmd += " " + f.getCanonicalPath();
@@ -165,46 +185,43 @@ abstract public class ServiceTest {
/**
* Creates a JAM file
+ * @param moduleName module name
* @param pkgName name of package that locates super_package file
- * @param srcDir name of directory that locates classes
+ * @param srcDir the name of directory that locates classes
* @param destDir directory where the JAM should be written
+ * @param destName name of resulting JAM file
* @return a {@code File} representing the JAM file
*/
- File createJam(String pkgName, String srcDir, File destDir) throws Exception {
- File rc = new File(destDir, srcDir + ".jam");
+ private File createJam(String moduleName, String pkgName,
+ String srcDir, File destDir, String destName) throws Exception {
+ File rc = new File(destDir, destName);
String classesDir = destDir + "/classes";
- String cmd = "cfsS ";
+ String cmd = "cvf ";
cmd += rc.getCanonicalPath() + " ";
- cmd += pkgName + "." + srcDir + " ";
- cmd += classesDir + " ";
if (new File(classesDir, "META-INF").exists()) {
cmd += "-C " + classesDir + " META-INF ";
}
cmd += "-C ";
cmd += classesDir + " ";
- cmd +=pkgName + "/" + srcDir;
+ cmd += pkgName + "/" + srcDir;
debug("jam: " + cmd);
Jam jamTool = new Jam(System.out, System.err, "jam");
if (!jamTool.run(cmd.split(" "))) {
- throw new Exception("jam failed for " + srcDir);
+ throw new Exception("jam failed for " + moduleName);
}
return rc;
}
- /**
- * @see #createJAM(String, String, File)
- * @param destName name of resulting JAM file
- */
- File createJam(String pkgName, String srcDir, File destDir,
- String destName) throws Exception {
- File f = createJam(pkgName, srcDir, destDir);
- File rc = new File(f.getParentFile(), destName);
- if (!f.renameTo(rc)) {
- throw new Exception("createJam: Couldn't rename " + f + " to " + rc);
- } else {
- return rc;
- }
+ File createJam(String pkgName, String srcDir, File destDir) throws Exception {
+ String moduleName = pkgName + "." + srcDir;
+ String destName = moduleName + ".jam";
+ return createJam(moduleName, pkgName, srcDir, destDir, destName);
+ }
+
+ File createJam(String pkgName, String srcDir, File destDir, String destName) throws Exception {
+ String moduleName = pkgName + "." + srcDir;
+ return createJam(moduleName, pkgName, srcDir, destDir, destName);
}
/**
@@ -255,7 +272,7 @@ abstract public class ServiceTest {
Process p = pb.start();
p.waitFor();
debug(name + " returned " + p.exitValue());
- check(p.exitValue() == 0);
+ boolean error = check(p.exitValue() == 0);
BufferedReader br = new BufferedReader(
new InputStreamReader(
p.getInputStream()), 8192);
@@ -264,7 +281,11 @@ abstract public class ServiceTest {
while ((s = br.readLine()) != null) {
msg += ">>> " + s + "\n";
}
- debug(msg);
+ if (error) {
+ System.err.println(msg);
+ } else {
+ debug(msg);
+ }
} catch (Exception ex) {
unexpected(ex);
}
--- a/test/java/module/service/src/charserv/client/Main.java Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/service/src/charserv/client/Main.java Wed Aug 06 15:40:27 2008 -0700
@@ -21,6 +21,7 @@
* have any questions.
*/
+module charserv.client;
package charserv.client;
import java.nio.charset.spi.CharsetProvider;
--- a/test/java/module/service/src/charserv/provider/CharsetServiceProvider.java Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/service/src/charserv/provider/CharsetServiceProvider.java Wed Aug 06 15:40:27 2008 -0700
@@ -21,6 +21,7 @@
* have any questions.
*/
+module charserv.provider;
package charserv.provider;
import java.nio.charset.Charset;
--- a/test/java/module/service/src/cliserv/client/Main.java Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/service/src/cliserv/client/Main.java Wed Aug 06 15:40:27 2008 -0700
@@ -21,6 +21,7 @@
* have any questions.
*/
+module cliserv.client;
package cliserv.client;
import java.util.Iterator;
--- a/test/java/module/service/src/cliserv/client/MainCP.java Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/service/src/cliserv/client/MainCP.java Wed Aug 06 15:40:27 2008 -0700
@@ -21,6 +21,7 @@
* have any questions.
*/
+module cliserv.client;
package cliserv.client;
import java.util.Iterator;
--- a/test/java/module/service/src/cliserv/provider/BarService.java Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/service/src/cliserv/provider/BarService.java Wed Aug 06 15:40:27 2008 -0700
@@ -21,6 +21,7 @@
* have any questions.
*/
+module cliserv.provider;
package cliserv.provider;
import java.util.Iterator;
--- a/test/java/module/service/src/cliserv/provider/BarServiceProvider.java Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/service/src/cliserv/provider/BarServiceProvider.java Wed Aug 06 15:40:27 2008 -0700
@@ -21,6 +21,7 @@
* have any questions.
*/
+module cliserv.provider;
package cliserv.provider;
import java.util.ServiceProvider;
--- a/test/java/module/service/src/cliserv/provider/FooService2Provider.java Tue Aug 05 13:15:22 2008 -0700
+++ b/test/java/module/service/src/cliserv/provider/FooService2Provider.java Wed Aug 06 15:40:27 2008 -0700
@@ -21,6 +21,7 @@
* have any questions.
*/
+module cliserv.provider;
package cliserv.provider;
import java.util.ServiceProvider;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/module/bootstrap/VirtualModuleDefinition.java Wed Aug 06 15:40:27 2008 -0700
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.module.bootstrap;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.module.ModuleArchiveInfo;
+import java.module.ModuleContent;
+import java.module.ModuleSystem;
+import java.module.PackageDefinition;
+import java.module.Version;
+import java.module.Repository;
+import sun.module.core.AbstractModuleDefinition;
+import sun.module.core.JamPackageDefinition;
+
+/**
+ * A ModuleDefinition for the virtual modules.
+ *
+ * XXX: Need to revisit the implementation for
+ * getExportedPackageDefinition() and getMemberPackageDefinitions()
+ *
+ * One approach we can consider is to write a tool to
+ * generate the list of exported packages and member packages
+ * at JDK build time instead of hardcoding in the list in
+ * VirtualModuleDefinitions.java
+ */
+class VirtualModuleDefinition extends AbstractModuleDefinition {
+
+ private static final ModuleSystem moduleSystem = BootstrapModuleSystem.getInstance();
+ private static final Repository repository = BootstrapRepository.getInstance();
+
+ private final Class metadataClass;
+ private volatile Set<PackageDefinition> memberPackageDefs;
+ private volatile Set<PackageDefinition> exportedPackageDefs;
+
+ @SuppressWarnings({"unchecked"})
+ VirtualModuleDefinition(String name, Version version, Class<?> metadataClass) {
+ super(moduleSystem,
+ name,
+ version,
+ null,
+ repository,
+ false);
+ this.metadataClass = metadataClass;
+ }
+
+ @Override
+ public Set<String> getMemberClasses() {
+ throw new UnsupportedOperationException("Information about member classes is " +
+ "not available for " + getName() + " v" + getVersion());
+ }
+
+ @Override
+ public Set<String> getExportedClasses() {
+ throw new UnsupportedOperationException("Information about exported classes is " +
+ "not available for " + getName() + " v" + getVersion());
+ }
+
+ @Override
+ public Set<PackageDefinition> getMemberPackageDefinitions() {
+ if (memberPackageDefs == null) {
+ // XXX: return the exported package definitions for now
+ memberPackageDefs = getExportedPackageDefinitions();
+ }
+ return memberPackageDefs;
+ }
+
+ @Override
+ public Set<PackageDefinition> getExportedPackageDefinitions() {
+ if (exportedPackageDefs == null) {
+ sun.module.annotation.ExportPackages exportPackages =
+ getAnnotation(sun.module.annotation.ExportPackages.class);
+ List<String> exportedPackages = Arrays.asList(exportPackages.value());
+
+ HashSet<PackageDefinition> packageDefs = new HashSet<PackageDefinition>();
+ for (String s : exportedPackages) {
+ packageDefs.add(new JamPackageDefinition(s, Version.DEFAULT, this));
+ }
+ exportedPackageDefs = Collections.unmodifiableSet(packageDefs);
+ }
+ return exportedPackageDefs;
+ }
+
+ @Override
+ public boolean isClassExported(String className) {
+ for (PackageDefinition packageDef : getExportedPackageDefinitions()) {
+ String packageName = packageDef.getName();
+ if (packageName.equals("*")) {
+ // "*" is exported by the "java.classpath" module.
+ return true;
+ }
+
+ // Checks if the specified class is exported from this module.
+ if (className.startsWith(packageName + ".")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public Set<String> getExportedResources() {
+ throw new UnsupportedOperationException("Information about exported resources is " +
+ "not available for " + getName() + " v" + getVersion());
+ }
+
+ @Override
+ public boolean isResourceExported(String name) {
+ // XXX special hack for now
+ // Module definitions from the bootstrap repository are expected
+ // to export all resources.
+ return true;
+ }
+
+ @Override
+ @SuppressWarnings({"unchecked"})
+ public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
+ if (annotationClass == null) {
+ throw new NullPointerException();
+ }
+ return (T) metadataClass.getAnnotation(annotationClass);
+ }
+
+ @Override
+ public List<Annotation> getAnnotations() {
+ return Collections.unmodifiableList(Arrays.asList(metadataClass.getAnnotations()));
+ }
+
+ @Override
+ public boolean isLocal() {
+ return true;
+ }
+
+ @Override
+ public ModuleContent getModuleContent() {
+ throw new UnsupportedOperationException("No module content supported for \"" +
+ getName() + "\" module");
+ }
+
+ // XXX: TODO provide implementation
+ @Override
+ public ModuleArchiveInfo getModuleArchiveInfo() {
+ throw new UnsupportedOperationException("No module archive info supported for \"" +
+ getName() + "\" module");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/module/core/AbstractModuleDefinition.java Wed Aug 06 15:40:27 2008 -0700
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2006-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.module.core;
+
+import java.util.Collections;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.module.ImportDependency;
+import java.module.Modules;
+import java.module.ModuleContent;
+import java.module.ModuleDefinition;
+import java.module.ModuleSystem;
+import java.module.ModuleSystemPermission;
+import java.module.PackageDefinition;
+import java.module.Repository;
+import java.module.Version;
+import java.module.VersionConstraint;
+import java.module.annotation.Attribute;
+import java.module.annotation.Attributes;
+import java.module.annotation.ImportModule;
+import java.module.annotation.ImportModules;
+
+/**
+ */
+public abstract class AbstractModuleDefinition extends ModuleDefinition {
+
+ private final ModuleSystem moduleSystem;
+ private final String name;
+ private final Version version;
+ private final ModuleContent content;
+ private final Repository repository;
+ private final boolean moduleReleasable;
+ private volatile List<ImportDependency> importDependencies = null;
+ private volatile Map<String, String> attributesMap = null;
+
+ protected AbstractModuleDefinition(ModuleSystem moduleSystem,
+ String name, Version version, ModuleContent content,
+ Repository repository, boolean releasable) {
+ this.moduleSystem = moduleSystem;
+ this.name = name;
+ this.version = version;
+ this.content = content;
+ this.repository = repository;
+ this.moduleReleasable = releasable;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public java.module.Version getVersion() {
+ return version;
+ }
+
+ @Override
+ public final List<ImportDependency> getImportDependencies() {
+ if (importDependencies == null) {
+ List<ImportDependency> dependencies = new ArrayList<ImportDependency>();
+ ImportModules importModules = getAnnotation(ImportModules.class);
+ if (importModules != null) {
+ for (ImportModule importModule : Arrays.asList(importModules.value())) {
+ String name = importModule.name();
+ VersionConstraint constraint = VersionConstraint.valueOf(importModule.version());
+ boolean reexport = importModule.reexport();
+ boolean optional = importModule.optional();
+ Attribute[] attributes = importModule.attributes();
+ Map<String, String> attrs = new HashMap<String, String>();
+ if (attributes != null) {
+ for (Attribute a : attributes) {
+ attrs.put(a.name(), a.value());
+ }
+ }
+ dependencies.add(Modules.newModuleDependency(name, constraint, reexport, optional, attrs));
+ }
+ }
+ importDependencies = Collections.unmodifiableList(dependencies);
+ }
+ return importDependencies;
+ }
+
+ private final synchronized Map<String, String> getAttributesMap() {
+ if (attributesMap == null) {
+ attributesMap = new HashMap<String, String>();
+ Attributes attrs = getAnnotation(Attributes.class);
+ if (attrs != null) {
+ for (Attribute attr : attrs.value()) {
+ attributesMap.put(attr.name(), attr.value());
+ }
+ }
+ }
+ return attributesMap;
+ }
+
+ @Override
+ public final Set<String> getAttributeNames() {
+ return Collections.unmodifiableSet(getAttributesMap().keySet());
+ }
+
+ @Override
+ public final String getAttribute(String name) {
+ if (name == null) {
+ throw new NullPointerException("name must not be null.");
+ }
+ return getAttributesMap().get(name);
+ }
+
+ @Override
+ public final String getMainClass() {
+ java.module.annotation.MainClass mainClass = getAnnotation
+ (java.module.annotation.MainClass.class);
+ if (mainClass != null) {
+ return mainClass.value();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public boolean isClassExported(String className) {
+ try {
+ return getExportedClasses().contains(className);
+ } catch (UnsupportedOperationException uoe) {
+ // returns true if the class is of one of the exported packages.
+ Set<PackageDefinition> pkgs = getExportedPackageDefinitions();
+ for (PackageDefinition p : pkgs) {
+ if (className.startsWith(p.getName() + ".")) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ @Override
+ public boolean isResourceExported(String name) {
+ try {
+ return getExportedResources().contains(name);
+ } catch (UnsupportedOperationException uoe) {
+ // return true if we don't know so that the caller may try
+ // to find the resource
+ return true;
+ }
+ }
+
+ @Override
+ public final boolean isModuleReleasable() {
+ return moduleReleasable;
+ }
+
+ @Override
+ public final Repository getRepository() {
+ return repository;
+ }
+
+ @Override
+ public final ModuleSystem getModuleSystem() {
+ return moduleSystem;
+ }
+
+ @Override
+ public ModuleContent getModuleContent() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(new ModuleSystemPermission("accessModuleContent"));
+ }
+ return content;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/module/modinit/mtest/deepvalidate/Foo.java Wed Aug 06 15:40:27 2008 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * A class member of both module m4 and m6.
+ */
+public class Foo {
+ private String name;
+ public Foo(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/module/modinit/mtest/exportlegacyclasses/p/Bar.java Wed Aug 06 15:40:27 2008 -0700
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * This class does not have the module membership.
+ */
+package p;
+public class Bar {
+ public void bar() {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/module/modinit/mtest/exportlegacyclasses/p/Foo.java Wed Aug 06 15:40:27 2008 -0700
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * This class does not have the module membership but it's package-private.
+ */
+package p;
+class Foo {
+ public void foo () {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/module/modinit/mtest/exportlegacyclasses/q/Gus.java Wed Aug 06 15:40:27 2008 -0700
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * This class does not have the module membership.
+ */
+package q;
+public class Gus {
+ public void gus() {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/module/modinit/mtest/getresource/Dup.java Wed Aug 06 15:40:27 2008 -0700
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package m;
+public class Dup {
+ public static void findIt() {
+ System.out.println("Congrats! You found me!");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/module/service/src/charserv/client/module-info.java Wed Aug 06 15:40:27 2008 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABbILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+@ImportModules({
+ @ImportModule(name="java.se.core"),
+ @ImportModule(name="java.classpath")
+})
+@MainClass("charserv.client.Main")
+module charserv.client;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/module/service/src/charserv/provider/module-info.java Wed Aug 06 15:40:27 2008 -0700
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+@ServiceProviders({
+ @ServiceProvider(service="java.nio.charset.spi.CharsetProvider",
+ providerClass="charserv.provider.CharsetServiceProvider")
+})
+@ImportModules({
+ @ImportModule(name="java.se.core")
+})
+module charserv.provider;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/module/service/src/cliserv/client/module-info.java Wed Aug 06 15:40:27 2008 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABbILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+@ImportModules({
+ @ImportModule(name="java.se.core"),
+ @ImportModule(name="cliserv.service")
+})
+@MainClass("cliserv.client.Main")
+module cliserv.client;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/module/service/src/cliserv/provider/module-info.java Wed Aug 06 15:40:27 2008 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+
+@ServiceProviders({
+ @ServiceProvider(service="cliserv.service.FooService",
+ providerClass="cliserv.provider.FooService2Provider"),
+ @ServiceProvider(service="cliserv.service.BarService",
+ providerClass="cliserv.provider.BarServiceProvider")
+})
+@Services("BarProvider")
+@ImportModules({
+ @ImportModule(name="java.se.core"),
+ @ImportModule(name="cliserv.service") // Import service module defining Foo
+})
+module cliserv.provider;