Java Code Examples for java.util.List.of()

The following are Jave code examples for showing how to use of() of the java.util.List class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: IncludeLocalesPlugin.java   View Source Code Vote up 6 votes
private List<String> includeLocaleFilePatterns(String tag) {
    // Ignore extension variations
    if (tag.matches(".+-[a-z]-.+")) {
        return List.of();
    }

    List<String> files = new ArrayList<>(includeLocaleFiles(tag.replaceAll("-", "_")));

    // Add Thai BreakIterator related data files
    if (tag.equals("th")) {
        files.add(".+sun/text/resources/ext/thai_dict");
        files.add(".+sun/text/resources/ext/[^_]+BreakIteratorData_th");
    }

    // Add Taiwan resource bundles for Hong Kong
    if (tag.equals("zh-HK")) {
        files.addAll(includeLocaleFiles("zh_TW"));
    }

    return files;
}
 
Example 2
Project: openjdk-jdk10   File: CheckSealedTest.java   View Source Code Vote up 5 votes
public static void main(String[] args)
        throws Throwable {

    String baseDir = System.getProperty("user.dir") + File.separator;
    String javac = JDKToolFinder.getTestJDKTool("javac");
    String java = JDKToolFinder.getTestJDKTool("java");

    setup(baseDir);
    String srcDir = System.getProperty("test.src");
    String cp = srcDir + File.separator + "a" + File.pathSeparator
            + srcDir + File.separator + "b.jar" + File.pathSeparator
            + ".";
    List<String[]> allCMDs = List.of(
            // Compile command
            new String[]{
                    javac, "-cp", cp, "-d", ".",
                    srcDir + File.separator + TEST_NAME + ".java"
            },
            // Run test the first time
            new String[]{
                    java, "-cp", cp, TEST_NAME, "1"
            },
            // Run test the second time
            new String[]{
                    java, "-cp", cp, TEST_NAME, "2"
            }
    );

    for (String[] cmd : allCMDs) {
        ProcessTools.executeCommand(cmd)
                    .outputTo(System.out)
                    .errorTo(System.out)
                    .shouldHaveExitValue(0);
    }
}
 
Example 3
Project: openjdk-jdk10   File: ByteBufferViews.java   View Source Code Vote up 5 votes
@DataProvider
public static Object[][] intViewProvider() {
    List<Map.Entry<String, Function<ByteBuffer, IntBuffer>>> bfs = List.of(
            Map.entry("bb.asIntBuffer()",
                      bb -> bb.asIntBuffer()),
            Map.entry("bb.asIntBuffer().slice()",
                      bb -> bb.asIntBuffer().slice()),
            Map.entry("bb.asIntBuffer().slice().duplicate()",
                      bb -> bb.asIntBuffer().slice().duplicate())
    );

    return product(BYTE_BUFFER_FUNCTIONS, bfs);
}
 
Example 4
Project: Reactive4JavaFlow   File: CompositeAutoDisposableTest.java   View Source Code Vote up 5 votes
@Test
public void normal4() {
    BooleanAutoDisposable b1 = new BooleanAutoDisposable();
    BooleanAutoDisposable b2 = new BooleanAutoDisposable();

    CompositeAutoDisposable cd = new CompositeAutoDisposable(List.of(b1, b2));

    assertEquals(2, cd.size());

    cd.close();

    assertTrue(b1.isClosed());
    assertTrue(b2.isClosed());
}
 
Example 5
Project: bach   File: BuildDemo02Testing.java   View Source Code Vote up 5 votes
void compileMain() {
  Bach.JdkTool.Javac javac = new Bach.JdkTool.Javac();
  javac.destination = MAIN;
  javac.modulePath = List.of(DEPS);
  javac.moduleSourcePath = List.of(Paths.get("src", "main", "java"));
  javac.run();
}
 
Example 6
Project: openjdk-jdk10   File: ContinuousCallSiteTargetChange.java   View Source Code Vote up 5 votes
static void testServer(Class<?> test, String... args) throws Exception {
    List<String> extraArgsList = new ArrayList<>(
            List.of("-server", "-XX:-TieredCompilation"));
    extraArgsList.addAll(Arrays.asList(args));

    runTest(test, extraArgsList.toArray(new String[extraArgsList.size()]));
}
 
Example 7
Project: openjdk-jdk10   File: LoggingTest.java   View Source Code Vote up 5 votes
public void run(TestStream ts) {

        // start recording traces and trigger creation of the platform
        // MBeanServer to produce some. This won't work if the platform
        // MBeanServer was already initialized - so it's important to
        // run this test in its own JVM.
        ts.startRecording();
        MBeanServer platform = ManagementFactory.getPlatformMBeanServer();
        ts.stopRecording();
        String printed = ts.bos.toString();
        ts.bos.reset();

        // Check that the Platform MBeanServer is emitting the expected
        // log traces. This can be a bit fragile because debug traces
        // could be changed without notice - in which case this test will
        // need to be updated.
        // For each registered MBean we expect to see three traces.
        // If the messages logged by the MBeanServer change then these checks
        // may need to be revisited.
        List<String> checkTraces =
                List.of("ObjectName = %s", "name = %s", "JMX.mbean.registered %s");

        for (ObjectName o : platform.queryNames(ObjectName.WILDCARD, null)) {
            String n = o.toString();
            System.out.println("Checking log for: " + n);
            for (String check : checkTraces) {
                String s = String.format(check, n);
                if (!printed.contains(s)) {
                    throw new RuntimeException("Trace not found: " + s);
                }
            }
        }
    }
 
Example 8
Project: openjdk-jdk10   File: BasicVMTest.java   View Source Code Vote up 5 votes
public static void main(String[] args) throws Exception {
    List<String> flags = List.of(
            "-version",
            "-Xinternalversion",
            "-X",
            "-help");
    for (String flag : flags) {
        ProcessTools.executeTestJvm(flag)
                    .shouldHaveExitValue(0);
    }
}
 
Example 9
Project: openjdk-jdk10   File: AnnotationsOnModules.java   View Source Code Vote up 5 votes
@Test
public void testDeprecatedModuleRequiresDeprecatedForRemovalModule(Path base) throws Exception {
    Path moduleSrc = base.resolve("module-src");
    Path m1 = moduleSrc.resolve("src1/A");

    tb.writeJavaFiles(m1,
            "@Deprecated(forRemoval=true) module A { }");

    Path modulePath = base.resolve("module-path");

    Files.createDirectories(modulePath);

    new JavacTask(tb)
            .options("--module-source-path", m1.getParent().toString())
            .outdir(modulePath)
            .files(findJavaFiles(m1))
            .run()
            .writeAll();

    Path m2 = base.resolve("src2/B");

    tb.writeJavaFiles(m2,
            "@Deprecated(forRemoval=false) module B { requires A; }");
    List<String> log = new JavacTask(tb)
            .options("--module-source-path", m2.getParent().toString(),
                    "--module-path", modulePath.toString(),
                    "-XDrawDiagnostics")
            .outdir(modulePath)
            .files(findJavaFiles(m2))
            .run()
            .writeAll()
            .getOutputLines(OutputKind.DIRECT);

    List<String> expected = List.of("module-info.java:1:51: compiler.warn.has.been.deprecated.for.removal.module: A",
            "1 warning");
    if (!log.containsAll(expected)) {
        throw new AssertionError("Expected output not found. Expected: " + expected);
    }
}
 
Example 10
Project: openjdk-jdk10   File: ImageModules.java   View Source Code Vote up 5 votes
@DataProvider(name = "singleModule")
public Object[][] singleModuleValues() throws IOException {
    Object[][] values = new Object[][]{
     // { Extra args to the build the message.converter jmod
     //   Tokens to pass to the run time --add-modules option
     //   SUCCESS or FAILURE expected
     //   Messages expected in the run time output
     //   Messages that must not appear in the run time output },
        { "",
          List.of("ALL-DEFAULT", "ALL-SYSTEM"),
          ToolResult.ASSERT_SUCCESS,
          List.of("hello world", "message.converter", "java.base"),
          List.of("WARNING") },
        { "--do-not-resolve-by-default",
          List.of("ALL-DEFAULT"),
          ToolResult.ASSERT_FAILURE,
          List.of("java.base", "java.lang.ClassNotFoundException: converter.MessageConverter"),
          List.of("WARNING", "message.converter") },
        { "--warn-if-resolved=incubating",
          List.of("ALL-DEFAULT", "ALL-SYSTEM"),
          ToolResult.ASSERT_SUCCESS,
          List.of("hello world", "message.converter", "java.base",
                  "WARNING: Using incubator modules: message.converter"),
          List.of() },
        { "--do-not-resolve-by-default --warn-if-resolved=incubating",
          List.of("ALL-DEFAULT"),
          ToolResult.ASSERT_FAILURE,
          List.of("java.base", "java.lang.ClassNotFoundException: converter.MessageConverter"),
          List.of("WARNING", "message.converter") },
        { "--do-not-resolve-by-default --warn-if-resolved=incubating",
          List.of("message.converter"),
          ToolResult.ASSERT_SUCCESS,
          List.of("hello world", "message.converter", "java.base", "WARNING"),
          List.of() }
    };
    return values;
}
 
Example 11
Project: openjdk-jdk10   File: Lookup.java   View Source Code Vote up 5 votes
static String lookupWithIPv4Prefer() throws IOException {
    String java = JDKToolFinder.getTestJDKTool("java");
    String testClz = Lookup.class.getName();
    List<String> cmd = List.of(java, "-Djava.net.preferIPv4Stack=true",
            "-cp", CLASS_PATH, testClz);
    System.out.println("Executing: " + cmd);
    return new OutputAnalyzer(new ProcessBuilder(cmd).start()).getOutput();
}
 
Example 12
Project: bach   File: JdkToolTests.java   View Source Code Vote up 5 votes
@Test
void dumpJavadocOptions() {
  List<String> expectedLines = List.of("javadoc", "-quiet");
  Bach.JdkTool.Javadoc javadoc = new Bach.JdkTool.Javadoc();
  javadoc.quiet = true;
  assertLinesMatch(expectedLines, dump(javadoc.toCommand()));
}
 
Example 13
Project: Java-9-Cookbook   File: CollectionUtil.java   View Source Code Vote up 4 votes
public static List<String> list(String ... args){
	System.out.println("Using factory methods");
	return List.of(args);
}
 
Example 14
Project: openjdk-jdk10   File: ImageModules.java   View Source Code Vote up 4 votes
@DataProvider(name = "twoModules")
public Object[][] twoModulesValues() throws IOException {
    Object[][] values = new Object[][]{
     // { Extra args to the build the message.writer jmod
     //   Extra args to the build the message.converter jmod
     //   Tokens to pass to the run time --add-modules option
     //   SUCCESS or FAILURE expected
     //   Messages expected in the run time output
     //   Messages that must not appear in the run time output },
        { "",
          "",
          List.of("ALL-DEFAULT", "ALL-SYSTEM"),
          ToolResult.ASSERT_SUCCESS,
          List.of("HELLO CHEGAR !!!", "message.writer", "message.converter", "java.base"),
          List.of() },
        { "",
          "--do-not-resolve-by-default",
          List.of("ALL-DEFAULT", "ALL-SYSTEM"),
          ToolResult.ASSERT_SUCCESS,
          List.of("HELLO CHEGAR !!!", "message.writer", "message.converter", "java.base"),
          List.of() },
        { "--do-not-resolve-by-default",
          "",
          List.of("ALL-DEFAULT"),
          ToolResult.ASSERT_FAILURE,
          List.of("java.lang.ClassNotFoundException: writer.MessageWriter", "java.base"),
          List.of("message.writer") },
        { "--do-not-resolve-by-default",
          "--do-not-resolve-by-default",
          List.of("ALL-DEFAULT"),
          ToolResult.ASSERT_FAILURE,
          List.of("java.lang.ClassNotFoundException: writer.MessageWriter", "java.base"),
          List.of("message.converter", "message.writer") },
    // now add in warnings
        { "--do-not-resolve-by-default --warn-if-resolved=incubating",
          "",
          List.of("message.writer"),
          ToolResult.ASSERT_SUCCESS,
          List.of("HELLO CHEGAR !!!", "message.writer", "message.converter", "java.base",
                  "WARNING: Using incubator modules: message.writer"),
          List.of() },
        { "",
          "--do-not-resolve-by-default --warn-if-resolved=incubating",
          List.of("message.writer"),
          ToolResult.ASSERT_SUCCESS,
          List.of("HELLO CHEGAR !!!", "message.writer", "message.converter", "java.base",
                  "WARNING: Using incubator modules: message.converter"),
          List.of() }
        };
    return values;
}
 
Example 15
Project: openjdk-jdk10   File: MethodHandles.java   View Source Code Vote up 4 votes
private static List<Class<?>> longestParameterList(List<List<Class<?>>> lists) {
    final List<Class<?>> empty = List.of();
    return lists.stream().reduce((p, q) -> p.size() >= q.size() ? p : q).orElse(empty);
}
 
Example 16
Project: openjdk-jdk10   File: BootstrapMethodErrorTest.java   View Source Code Vote up 4 votes
@Override
List<Class<? extends Throwable>> expectedThrowableClasses() {
    return List.of(BootstrapMethodError.class, ClassCastException.class);
}
 
Example 17
Project: openjdk-jdk10   File: AnnotationProcessing.java   View Source Code Vote up 4 votes
@Test
public void testQualifiedClassForProcessing(Path base) throws Exception {
    Path moduleSrc = base.resolve("module-src");
    Path m1 = moduleSrc.resolve("m1x");
    Path m2 = moduleSrc.resolve("m2x");

    Path classes = base.resolve("classes");

    Files.createDirectories(classes);

    tb.writeJavaFiles(m1,
                      "module m1x { }",
                      "package impl; public class Impl { int m1x; }");

    tb.writeJavaFiles(m2,
                      "module m2x { }",
                      "package impl; public class Impl { int m2x; }");

    new JavacTask(tb)
        .options("--module-source-path", moduleSrc.toString())
        .outdir(classes)
        .files(findJavaFiles(moduleSrc))
        .run()
        .writeAll()
        .getOutput(Task.OutputKind.DIRECT);

    List<String> expected = List.of("Note: field: m1x");

    for (Mode mode : new Mode[] {Mode.API, Mode.CMDLINE}) {
        List<String> log = new JavacTask(tb, mode)
                .options("-processor", QualifiedClassForProcessing.class.getName(),
                         "--module-path", classes.toString())
                .classes("m1x/impl.Impl")
                .outdir(classes)
                .run()
                .writeAll()
                .getOutputLines(Task.OutputKind.DIRECT);

        if (!expected.equals(log))
            throw new AssertionError("Unexpected output: " + log);
    }
}
 
Example 18
Project: openjdk-jdk10   File: ListFactories.java   View Source Code Vote up 4 votes
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed10() {
    List.of("a", "b", "c", "d", "e", "f", "g", "h", "i", null);
}
 
Example 19
Project: openjdk-jdk10   File: IsoChronology.java   View Source Code Vote up 4 votes
@Override
public List<Era> eras() {
    return List.of(IsoEra.values());
}
 
Example 20
Project: openjdk-jdk10   File: JapaneseChronology.java   View Source Code Vote up 4 votes
@Override
public List<Era> eras() {
    return List.of(JapaneseEra.values());
}