Java Code Examples for java.lang.module.ModuleDescriptor#Modifier

The following examples show how to use java.lang.module.ModuleDescriptor#Modifier . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Builder.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Returns an immutable set of the module modifiers derived from the flags.
 */
private Set<ModuleDescriptor.Modifier> modifiers() {
    int n = 0;
    if (open) n++;
    if (synthetic) n++;
    if (mandated) n++;
    if (n == 0) {
        return Set.of();
    } else {
        ModuleDescriptor.Modifier[] mods = new ModuleDescriptor.Modifier[n];
        if (open) mods[--n] = ModuleDescriptor.Modifier.OPEN;
        if (synthetic) mods[--n] = ModuleDescriptor.Modifier.SYNTHETIC;
        if (mandated) mods[--n] = ModuleDescriptor.Modifier.MANDATED;
        return Set.of(mods);
    }
}
 
Example 2
Source File: Builder.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns an immutable set of the module modifiers derived from the flags.
 */
private Set<ModuleDescriptor.Modifier> modifiers() {
    int n = 0;
    if (open) n++;
    if (synthetic) n++;
    if (mandated) n++;
    if (n == 0) {
        return Collections.emptySet();
    } else {
        ModuleDescriptor.Modifier[] mods = new ModuleDescriptor.Modifier[n];
        if (open) mods[--n] = ModuleDescriptor.Modifier.OPEN;
        if (synthetic) mods[--n] = ModuleDescriptor.Modifier.SYNTHETIC;
        if (mandated) mods[--n] = ModuleDescriptor.Modifier.MANDATED;
        return Set.of(mods);
    }
}
 
Example 3
Source File: JavaLangModuleAccess.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new {@code ModuleDescriptor} instance.
 */
ModuleDescriptor newModuleDescriptor(String name,
                                     Version version,
                                     Set<ModuleDescriptor.Modifier> ms,
                                     Set<Requires> requires,
                                     Set<Exports> exports,
                                     Set<Opens> opens,
                                     Set<String> uses,
                                     Set<Provides> provides,
                                     Set<String> packages,
                                     String mainClass,
                                     int hashCode);
 
Example 4
Source File: JavaLangModuleAccess.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a new {@code ModuleDescriptor} instance.
 */
ModuleDescriptor newModuleDescriptor(String name,
                                     Version version,
                                     Set<ModuleDescriptor.Modifier> ms,
                                     Set<Requires> requires,
                                     Set<Exports> exports,
                                     Set<Opens> opens,
                                     Set<String> uses,
                                     Set<Provides> provides,
                                     Set<String> packages,
                                     String mainClass,
                                     int hashCode);
 
Example 5
Source File: ModuleDescriptorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void testNewModuleToBuildOpenModule() {
    Set<ModuleDescriptor.Modifier> ms = Set.of(ModuleDescriptor.Modifier.OPEN);
    ModuleDescriptor descriptor = ModuleDescriptor.newModule("foo", ms).build();
    assertTrue(descriptor.modifiers().equals(ms));
    assertTrue(descriptor.isOpen());

    ms = Set.of(ModuleDescriptor.Modifier.OPEN, ModuleDescriptor.Modifier.SYNTHETIC);
    descriptor = ModuleDescriptor.newModule("foo", ms).build();
    assertTrue(descriptor.modifiers().equals(ms));
    assertTrue(descriptor.isOpen());
}
 
Example 6
Source File: ModuleDescriptorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void testNewModuleToBuildAutomaticModule() {
    Set<ModuleDescriptor.Modifier> ms = Set.of(ModuleDescriptor.Modifier.AUTOMATIC);
    ModuleDescriptor descriptor = ModuleDescriptor.newModule("foo", ms).build();
    assertTrue(descriptor.modifiers().equals(ms));
    assertTrue(descriptor.isAutomatic());
}
 
Example 7
Source File: ModuleDescriptorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = IllegalArgumentException.class)
public void testNewModuleToBuildAutomaticAndOpenModule() {
    Set<ModuleDescriptor.Modifier> ms = Set.of(ModuleDescriptor.Modifier.AUTOMATIC,
                                               ModuleDescriptor.Modifier.OPEN);
    ModuleDescriptor.newModule("foo", ms);
}
 
Example 8
Source File: JavaLangModuleAccess.java    From Bytecoder with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a builder for building a module with the given module name.
 *
 * @param strict
 *        Indicates whether module names are checked or not
 */
ModuleDescriptor.Builder newModuleBuilder(String mn,
                                          boolean strict,
                                          Set<ModuleDescriptor.Modifier> ms);
 
Example 9
Source File: JavaLangModuleAccess.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a builder for building a module with the given module name.
 *
 * @param strict
 *        Indicates whether module names are checked or not
 */
ModuleDescriptor.Builder newModuleBuilder(String mn,
                                          boolean strict,
                                          Set<ModuleDescriptor.Modifier> ms);