< prev index next >

langtools/test/tools/javac/modules/DuplicateClassTest.java

Print this page




  43 
  44     public static void main(String... args) throws Exception {
  45         DuplicateClassTest t = new DuplicateClassTest();
  46         t.runTests();
  47     }
  48 
  49     @Test
  50     public void testSimple(Path base) throws Exception {
  51         Path m1 = base.resolve("m1");
  52         Path m2 = base.resolve("m2");
  53         tb.writeJavaFiles(m1,
  54                           "module m1 { }",
  55                           "package impl; public class Impl { }");
  56         tb.writeJavaFiles(m2,
  57                           "module m2 { }",
  58                           "package impl; public class Impl { }");
  59         Path classes = base.resolve("classes");
  60         Files.createDirectories(classes);
  61 
  62         String log = new JavacTask(tb)
  63                 .options("-modulesourcepath", base.toString())
  64                 .outdir(classes)
  65                 .files(findJavaFiles(base))
  66                 .run()
  67                 .writeAll()
  68                 .getOutput(Task.OutputKind.DIRECT);
  69 
  70         if (!log.isEmpty())
  71             throw new Exception("expected output not found; output: " + log);
  72     }
  73 
  74 }


  43 
  44     public static void main(String... args) throws Exception {
  45         DuplicateClassTest t = new DuplicateClassTest();
  46         t.runTests();
  47     }
  48 
  49     @Test
  50     public void testSimple(Path base) throws Exception {
  51         Path m1 = base.resolve("m1");
  52         Path m2 = base.resolve("m2");
  53         tb.writeJavaFiles(m1,
  54                           "module m1 { }",
  55                           "package impl; public class Impl { }");
  56         tb.writeJavaFiles(m2,
  57                           "module m2 { }",
  58                           "package impl; public class Impl { }");
  59         Path classes = base.resolve("classes");
  60         Files.createDirectories(classes);
  61 
  62         String log = new JavacTask(tb)
  63                 .options("--module-source-path", base.toString())
  64                 .outdir(classes)
  65                 .files(findJavaFiles(base))
  66                 .run()
  67                 .writeAll()
  68                 .getOutput(Task.OutputKind.DIRECT);
  69 
  70         if (!log.isEmpty())
  71             throw new Exception("expected output not found; output: " + log);
  72     }
  73 
  74 }
< prev index next >