ObscureMessageForBadProvidesTest.java revision 3451:a8fefe4d1826
177701Sbrian/* 285964Sbrian * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 377701Sbrian * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 477701Sbrian * 577701Sbrian * This code is free software; you can redistribute it and/or modify it 677701Sbrian * under the terms of the GNU General Public License version 2 only, as 777701Sbrian * published by the Free Software Foundation. 877701Sbrian * 977701Sbrian * This code is distributed in the hope that it will be useful, but WITHOUT 1077701Sbrian * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1177701Sbrian * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1277701Sbrian * version 2 for more details (a copy is included in the LICENSE file that 1377701Sbrian * accompanied this code). 1477701Sbrian * 1577701Sbrian * You should have received a copy of the GNU General Public License version 1677701Sbrian * 2 along with this work; if not, write to the Free Software Foundation, 1777701Sbrian * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1877701Sbrian * 1977701Sbrian * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2077701Sbrian * or visit www.oracle.com if you need additional information or have any 2177701Sbrian * questions. 2277701Sbrian */ 2377701Sbrian 2477701Sbrian/* 2577701Sbrian * @test 2677701Sbrian * @bug 8152062 2784195Sdillon * @summary obscure error message for bad 'provides' 2884195Sdillon * @library /tools/lib 2984195Sdillon * @modules 3084195Sdillon * jdk.compiler/com.sun.tools.javac.api 3126026Sbrian * jdk.compiler/com.sun.tools.javac.main 3259031Sru * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase 3326026Sbrian * @run main ObscureMessageForBadProvidesTest 3426026Sbrian */ 3526026Sbrian 3626026Sbrianimport java.nio.file.Path; 3726026Sbrian 3826026Sbrianimport toolbox.JavacTask; 3926026Sbrianimport toolbox.Task; 4026026Sbrianimport toolbox.ToolBox; 4126026Sbrian 4226026Sbrianpublic class ObscureMessageForBadProvidesTest extends ModuleTestBase { 43131612Sdes public static void main(String... args) throws Exception { 4426026Sbrian new ObscureMessageForBadProvidesTest().runTests(); 4526026Sbrian } 46145921Sglebius 47145921Sglebius @Test 48162674Spiso public void theTest(Path base) throws Exception { 49145921Sglebius Path mod = base.resolve("mod"); 50145921Sglebius tb.writeJavaFiles(mod, "module mod { provides java.lang.String with java.io.File; }"); 51124621Sphk Path classes = base.resolve("classes"); 52145921Sglebius tb.createDirectories(classes); 53145921Sglebius String log = new JavacTask(tb) 5426026Sbrian .options("-XDrawDiagnostics") 5526026Sbrian .outdir(classes) 5626026Sbrian .files(findJavaFiles(mod)) 5726026Sbrian .run(Task.Expect.FAIL) 5826026Sbrian .writeAll() 59145921Sglebius .getOutput(Task.OutputKind.DIRECT); 60145921Sglebius 61145921Sglebius if (!log.startsWith("module-info.java:1:52: compiler.err.service.implementation.must.be.subtype.of.service.interface")) 62145921Sglebius throw new Exception("expected output not found"); 6327864Sbrian } 6426026Sbrian} 65145921Sglebius