Class ImportDependency

  extended by
All Implemented Interfaces:

public class ImportDependency
extends java.lang.Object
implements java.lang.Cloneable

Import dependency of a module definition. Contrary to the Java Module System, this class does not capture the version constraints; the constraint still says what must be the name of the imported module definition, but now also specifies the sharing of its module instance.

For example, the default import clause import M; will cause the module instance mi of this module definition to import a shared instance of M --- this is the only option in the Java Module System.

If the imported module definition is marked with "replicating" and it is imported with the above (default) import clause, the effect is the same as specifying "own" on the import clause as shown in the next paragraph. The importer can override this switch by explicitly demanding a shared instance with import shared M;.

The user can also write import own M;, which means that mi will have its own module instance of M, which no other module instance can import.

The third option is for user to write import M as X;, which means that mi will have its own module instance of M, but that any other module definition, which also imports M as X, and can see the same module definition M, will import the same module instance as this module definition.

Furthermore, the user can specify the renaming of specific classes for a particular import. That is, each import statement can end with "with ( as )*". This performs renaming at the module boundaries, which is the key to supporting localized module patches.

The module instances are stored in a repository using a HashMap. ImportDependency objects are used as keys in that map, so the definition of its hashCode function is important. Basically, if the type of the import dependency is default (shared), the hashCode function returns a constant value (0); if it is own it calls the Object's hashCode (unique value based on its reference); and if it conditionally shared (as X) the function returns the String's hashCode value for X.

Nested Class Summary
static class ImportDependency.Type
Field Summary
private  java.lang.String id
(package private)  java.lang.String moduleName
(package private)  java.util.Map<java.lang.String,java.lang.String> renaming
(package private)  ImportDependency.Type type
Constructor Summary
ImportDependency(java.lang.String name)
ImportDependency(java.lang.String name, ImportDependency.Type type, java.lang.String id, java.util.Map<java.lang.String,java.lang.String> renaming)
Method Summary
 java.lang.Object clone()
 boolean equals(java.lang.Object obj)
 int hashCode()
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait

Field Detail


final java.lang.String moduleName


ImportDependency.Type type


private final java.lang.String id


java.util.Map<java.lang.String,java.lang.String> renaming
Constructor Detail


public ImportDependency(java.lang.String name)


public ImportDependency(java.lang.String name,
                        ImportDependency.Type type,
                        java.lang.String id,
                        java.util.Map<java.lang.String,java.lang.String> renaming)
Method Detail


public boolean equals(java.lang.Object obj)
equals in class java.lang.Object


public int hashCode()
hashCode in class java.lang.Object


public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
clone in class java.lang.Object