langtools/test/tools/javac/modules/EdgeCases.java
changeset 43269 12f989542165
parent 43138 680d378b9d64
child 43271 ce89609dde7c
equal deleted inserted replaced
43268:12436ebea906 43269:12f989542165
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 8154283 8167320
    26  * @bug 8154283 8167320 8171098
    27  * @summary tests for multi-module mode compilation
    27  * @summary tests for multi-module mode compilation
    28  * @library /tools/lib
    28  * @library /tools/lib
    29  * @modules
    29  * @modules
    30  *      jdk.compiler/com.sun.tools.javac.api
    30  *      jdk.compiler/com.sun.tools.javac.api
    31  *      jdk.compiler/com.sun.tools.javac.code
    31  *      jdk.compiler/com.sun.tools.javac.code
   482 
   482 
   483         if (!expected.equals(log)) {
   483         if (!expected.equals(log)) {
   484             throw new AssertionError("Unexpected output: " + log);
   484             throw new AssertionError("Unexpected output: " + log);
   485         }
   485         }
   486     }
   486     }
       
   487 
       
   488     @Test
       
   489     public void testOnDemandCompletionModuleInfoJava(Path base) throws Exception {
       
   490         Path src = base.resolve("src");
       
   491         Path src_m1 = src.resolve("m1x");
       
   492         tb.writeJavaFiles(src_m1,
       
   493                           "@Deprecated module m1x { }");
       
   494         Path src_m2 = src.resolve("m2x");
       
   495         tb.writeJavaFiles(src_m2,
       
   496                           "module m2x { requires m1x; }");
       
   497         Path src_m3 = src.resolve("m3x");
       
   498         tb.writeJavaFiles(src_m3,
       
   499                           "module m3x { requires m2x; requires m1x; }");
       
   500         Path classes = base.resolve("classes");
       
   501         tb.createDirectories(classes);
       
   502 
       
   503         List<String> log;
       
   504         List<String> expected;
       
   505 
       
   506         log = new JavacTask(tb)
       
   507                 .options("--module-source-path", src.toString())
       
   508                 .outdir(classes)
       
   509                 .files(findJavaFiles(src_m1))
       
   510                 .run()
       
   511                 .writeAll()
       
   512                 .getOutputLines(Task.OutputKind.DIRECT);
       
   513 
       
   514         expected = Arrays.asList("");
       
   515 
       
   516         if (!expected.equals(log)) {
       
   517             throw new IllegalStateException(log.toString());
       
   518         }
       
   519 
       
   520         log = new JavacTask(tb)
       
   521                 .options("--module-source-path", src.toString(),
       
   522                          "-XDrawDiagnostics",
       
   523                          "-Xlint:deprecation")
       
   524                 .outdir(classes)
       
   525                 .files(findJavaFiles(src_m3))
       
   526                 .run()
       
   527                 .writeAll()
       
   528                 .getOutputLines(Task.OutputKind.DIRECT);
       
   529 
       
   530         expected = Arrays.asList(
       
   531                 "module-info.java:1:23: compiler.warn.has.been.deprecated.module: m1x",
       
   532                 "module-info.java:1:37: compiler.warn.has.been.deprecated.module: m1x",
       
   533                 "2 warnings"
       
   534         );
       
   535 
       
   536         if (!expected.equals(log)) {
       
   537             throw new IllegalStateException(log.toString());
       
   538         }
       
   539     }
       
   540 
   487 }
   541 }