FileManagerGetServiceLoaderTest.java revision 3653:dd56c243c199
1200590Sluigi/* 2200673Sru * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3272840Smelifaro * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4272840Smelifaro * 5200590Sluigi * This code is free software; you can redistribute it and/or modify it 6200590Sluigi * under the terms of the GNU General Public License version 2 only, as 7200590Sluigi * published by the Free Software Foundation. 8200590Sluigi * 9200590Sluigi * This code is distributed in the hope that it will be useful, but WITHOUT 10200590Sluigi * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11200590Sluigi * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12200590Sluigi * version 2 for more details (a copy is included in the LICENSE file that 13200590Sluigi * accompanied this code). 14200590Sluigi * 15200590Sluigi * You should have received a copy of the GNU General Public License version 16200590Sluigi * 2 along with this work; if not, write to the Free Software Foundation, 17200590Sluigi * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18200590Sluigi * 19200590Sluigi * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20200590Sluigi * or visit www.oracle.com if you need additional information or have any 21200590Sluigi * questions. 22200590Sluigi */ 23200590Sluigi 24200590Sluigi/* 25200590Sluigi * @test 26200590Sluigi * @bug 8164742 27200590Sluigi * @summary Test that jdk.compiler can materialize a service loader for arbitrary services 28200590Sluigi * @run main FileManagerGetServiceLoaderTest 29200590Sluigi */ 30200590Sluigi 31200590Sluigiimport javax.tools.*; 32272840Smelifaro 33200601Sluigipublic class FileManagerGetServiceLoaderTest { 34272840Smelifaro 35272840Smelifaro public static void main(String... args) throws Exception { 36200838Sluigi 37272840Smelifaro JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 38272840Smelifaro StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null); 39272840Smelifaro 40272840Smelifaro /* FileManagerGetServiceLoaderTest.class is not really a service, but that is 41200590Sluigi immaterial to the test which just verifies addUses would have been called 42200590Sluigi so module boundary is not an issue for a class outside of jdk.compiler 43225518Sjhb */ 44200590Sluigi java.util.ServiceLoader<?> loader = fm.getServiceLoader(StandardLocation.CLASS_PATH, 45200590Sluigi FileManagerGetServiceLoaderTest.class); 46200590Sluigi if (loader == null) { 47200590Sluigi throw new AssertionError("Could not obtain service loader"); 48200590Sluigi } 49200590Sluigi } 50200590Sluigi} 51272840Smelifaro