# HG changeset patch # User Doug Simon # Date 1451494507 -3600 # Node ID f2206f5bb62ed876e9fd031f4a5a148a0cc7b57b # Parent 4cf1946f59fc4438eecdbe9ff25ed5388531d7b6 removed @ServiceProvider mechanism (GRAAL-1380) diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.hotspot.aarch64/src/META-INF/jvmci.services/jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.vm.ci.hotspot.aarch64/src/META-INF/jvmci.services/jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory Wed Dec 30 17:55:07 2015 +0100 @@ -0,0 +1,1 @@ +jdk.vm.ci.hotspot.aarch64.AArch64HotSpotJVMCIBackendFactory diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java --- a/jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java Sat Dec 26 15:00:55 2015 +0100 +++ b/jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java Wed Dec 30 17:55:07 2015 +0100 @@ -41,9 +41,7 @@ import jdk.vm.ci.inittimer.InitTimer; import jdk.vm.ci.meta.ConstantReflectionProvider; import jdk.vm.ci.runtime.JVMCIBackend; -import jdk.vm.ci.service.ServiceProvider; -@ServiceProvider(HotSpotJVMCIBackendFactory.class) public class AArch64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { protected EnumSet computeFeatures(@SuppressWarnings("unused") HotSpotVMConfig config) { diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.hotspot.amd64/src/META-INF/jvmci.services/jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.vm.ci.hotspot.amd64/src/META-INF/jvmci.services/jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory Wed Dec 30 17:55:07 2015 +0100 @@ -0,0 +1,1 @@ +jdk.vm.ci.hotspot.amd64.AMD64HotSpotJVMCIBackendFactory diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java --- a/jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java Sat Dec 26 15:00:55 2015 +0100 +++ b/jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java Wed Dec 30 17:55:07 2015 +0100 @@ -41,9 +41,7 @@ import jdk.vm.ci.inittimer.InitTimer; import jdk.vm.ci.meta.ConstantReflectionProvider; import jdk.vm.ci.runtime.JVMCIBackend; -import jdk.vm.ci.service.ServiceProvider; -@ServiceProvider(HotSpotJVMCIBackendFactory.class) public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { protected EnumSet computeFeatures(HotSpotVMConfig config) { diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.hotspot.jfr/src/META-INF/jvmci.services/jdk.vm.ci.hotspot.events.EventProvider --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.vm.ci.hotspot.jfr/src/META-INF/jvmci.services/jdk.vm.ci.hotspot.events.EventProvider Wed Dec 30 17:55:07 2015 +0100 @@ -0,0 +1,1 @@ +jdk.vm.ci.hotspot.jfr.events.JFREventProvider diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.hotspot.jfr/src/jdk/vm/ci/hotspot/jfr/events/JFREventProvider.java --- a/jvmci/jdk.vm.ci.hotspot.jfr/src/jdk/vm/ci/hotspot/jfr/events/JFREventProvider.java Sat Dec 26 15:00:55 2015 +0100 +++ b/jvmci/jdk.vm.ci.hotspot.jfr/src/jdk/vm/ci/hotspot/jfr/events/JFREventProvider.java Wed Dec 30 17:55:07 2015 +0100 @@ -29,7 +29,6 @@ import jdk.vm.ci.hotspot.events.EmptyEventProvider.EmptyCompilationEvent; import jdk.vm.ci.hotspot.events.EmptyEventProvider.EmptyCompilerFailureEvent; import jdk.vm.ci.hotspot.events.EventProvider; -import jdk.vm.ci.service.ServiceProvider; /** * A JFR implementation for {@link EventProvider}. This implementation is used when Flight Recorder @@ -38,7 +37,6 @@ * Note: The use of fully qualified names for deprecated types is a workaround for JDK-8032211. */ -@ServiceProvider(EventProvider.class) @SuppressWarnings("deprecation") public final class JFREventProvider implements EventProvider { diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.hotspot.sparc/src/META-INF/jvmci.services/jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.vm.ci.hotspot.sparc/src/META-INF/jvmci.services/jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory Wed Dec 30 17:55:07 2015 +0100 @@ -0,0 +1,1 @@ +jdk.vm.ci.hotspot.sparc.SPARCHotSpotJVMCIBackendFactory diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java --- a/jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java Sat Dec 26 15:00:55 2015 +0100 +++ b/jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java Wed Dec 30 17:55:07 2015 +0100 @@ -39,11 +39,9 @@ import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.inittimer.InitTimer; import jdk.vm.ci.runtime.JVMCIBackend; -import jdk.vm.ci.service.ServiceProvider; import jdk.vm.ci.sparc.SPARC; import jdk.vm.ci.sparc.SPARC.CPUFeature; -@ServiceProvider(HotSpotJVMCIBackendFactory.class) public class SPARCHotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { protected TargetDescription createTarget(HotSpotVMConfig config) { diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Sat Dec 26 15:00:55 2015 +0100 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Wed Dec 30 17:55:07 2015 +0100 @@ -27,7 +27,7 @@ import jdk.vm.ci.runtime.JVMCICompiler; import jdk.vm.ci.runtime.JVMCICompilerFactory; import jdk.vm.ci.runtime.JVMCIRuntime; -import jdk.vm.ci.service.Services; +import jdk.vm.ci.services.Services; final class HotSpotJVMCICompilerConfig { diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Sat Dec 26 15:00:55 2015 +0100 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Wed Dec 30 17:55:07 2015 +0100 @@ -49,7 +49,7 @@ import jdk.vm.ci.runtime.JVMCI; import jdk.vm.ci.runtime.JVMCIBackend; import jdk.vm.ci.runtime.JVMCICompiler; -import jdk.vm.ci.service.Services; +import jdk.vm.ci.services.Services; //JaCoCo Exclude diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.service.processor/src/META-INF/services/javax.annotation.processing.Processor --- a/jvmci/jdk.vm.ci.service.processor/src/META-INF/services/javax.annotation.processing.Processor Sat Dec 26 15:00:55 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -jdk.vm.ci.service.processor.ServiceProviderProcessor diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.service.processor/src/jdk/vm/ci/service/processor/ServiceProviderProcessor.java --- a/jvmci/jdk.vm.ci.service.processor/src/jdk/vm/ci/service/processor/ServiceProviderProcessor.java Sat Dec 26 15:00:55 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.service.processor; - -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.HashSet; -import java.util.Set; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.FilerException; -import javax.annotation.processing.RoundEnvironment; -import javax.annotation.processing.SupportedAnnotationTypes; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import javax.lang.model.type.MirroredTypeException; -import javax.lang.model.type.TypeMirror; -import javax.tools.Diagnostic.Kind; -import javax.tools.FileObject; -import javax.tools.StandardLocation; - -import jdk.vm.ci.service.ServiceProvider; - -@SupportedAnnotationTypes("jdk.vm.ci.service.ServiceProvider") -public class ServiceProviderProcessor extends AbstractProcessor { - - private final Set processed = new HashSet<>(); - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - private boolean verifyAnnotation(TypeMirror serviceInterface, TypeElement serviceProvider) { - if (!processingEnv.getTypeUtils().isSubtype(serviceProvider.asType(), serviceInterface)) { - String msg = String.format("Service provider class %s must implement service interface %s", serviceProvider.getSimpleName(), serviceInterface); - processingEnv.getMessager().printMessage(Kind.ERROR, msg, serviceProvider); - return false; - } - - return true; - } - - private void processElement(TypeElement serviceProvider) { - if (processed.contains(serviceProvider)) { - return; - } - - processed.add(serviceProvider); - ServiceProvider annotation = serviceProvider.getAnnotation(ServiceProvider.class); - if (annotation != null) { - try { - annotation.value(); - } catch (MirroredTypeException ex) { - TypeMirror serviceInterface = ex.getTypeMirror(); - if (verifyAnnotation(serviceInterface, serviceProvider)) { - String interfaceName = ex.getTypeMirror().toString(); - createProviderFile(serviceProvider, interfaceName); - } - } - } - } - - private void createProviderFile(TypeElement serviceProvider, String interfaceName) { - if (serviceProvider.getNestingKind().isNested()) { - // This is a simplifying constraint that means we don't have to - // processed the qualified name to insert '$' characters at - // the relevant positions. - String msg = String.format("Service provider class %s must be a top level class", serviceProvider.getSimpleName()); - processingEnv.getMessager().printMessage(Kind.ERROR, msg, serviceProvider); - return; - } - - String filename = "META-INF/jvmci.providers/" + serviceProvider.getQualifiedName(); - try { - FileObject file = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", filename, serviceProvider); - PrintWriter writer = new PrintWriter(new OutputStreamWriter(file.openOutputStream(), "UTF-8")); - writer.println(interfaceName); - writer.close(); - } catch (IOException e) { - processingEnv.getMessager().printMessage(isBug367599(e) ? Kind.NOTE : Kind.ERROR, e.getMessage(), serviceProvider); - } - } - - /** - * Determines if a given exception is (most likely) caused by Bug 367599. - */ - public static boolean isBug367599(Throwable t) { - if (t instanceof FilerException) { - for (StackTraceElement ste : t.getStackTrace()) { - if (ste.toString().contains("org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeFilerImpl.create")) { - // See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=367599 - return true; - } - } - } - if (t.getCause() != null) { - return isBug367599(t.getCause()); - } - return false; - } - - @Override - public boolean process(Set annotations, RoundEnvironment roundEnv) { - if (roundEnv.processingOver()) { - return true; - } - - for (Element element : roundEnv.getElementsAnnotatedWith(ServiceProvider.class)) { - assert element.getKind().isClass(); - processElement((TypeElement) element); - } - - return true; - } -} diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.service/.checkstyle_checks.xml --- a/jvmci/jdk.vm.ci.service/.checkstyle_checks.xml Sat Dec 26 15:00:55 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,213 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.service/src/jdk/vm/ci/service/JVMCIClassLoaderFactory.java --- a/jvmci/jdk.vm.ci.service/src/jdk/vm/ci/service/JVMCIClassLoaderFactory.java Sat Dec 26 15:00:55 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.service; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.List; - -/** - * Utility called from the VM to create and register a separate class loader for loading JVMCI - * classes (i.e., those in found in lib/jvmci/*.jar). - */ -class JVMCIClassLoaderFactory { - - /** - * Copy of the {@code UseJVMCIClassLoader} VM option. Set by the VM before the static - * initializer is called. - */ - private static boolean useJVMCIClassLoader; - - /** - * Registers the JVMCI class loader in the VM. - */ - private static native void init(ClassLoader loader); - - static { - init(useJVMCIClassLoader ? newClassLoader() : null); - } - - /** - * Creates a new class loader for loading JVMCI classes. - */ - private static ClassLoader newClassLoader() { - URL[] urls = getJVMCIJarsUrls(); - ClassLoader parent = null; - return URLClassLoader.newInstance(urls, parent); - } - - /** - * Gets the URLs for lib/jvmci/*.jar. - */ - private static URL[] getJVMCIJarsUrls() { - File javaHome = new File(System.getProperty("java.home")); - File lib = new File(javaHome, "lib"); - File jvmci = new File(lib, "jvmci"); - if (!jvmci.exists()) { - throw new InternalError(jvmci + " does not exist"); - } - - List urls = new ArrayList<>(); - for (String fileName : jvmci.list()) { - if (fileName.endsWith(".jar")) { - File file = new File(jvmci, fileName); - if (file.isDirectory()) { - continue; - } - try { - urls.add(file.toURI().toURL()); - } catch (MalformedURLException e) { - throw new InternalError(e); - } - } - } - - return urls.toArray(new URL[urls.size()]); - } -} diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.service/src/jdk/vm/ci/service/ServiceProvider.java --- a/jvmci/jdk.vm.ci.service/src/jdk/vm/ci/service/ServiceProvider.java Sat Dec 26 15:00:55 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.service; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotates a service provider than can be loaded via {@linkplain Services#load(Class)} or - * {@link Services#loadSingle(Class, boolean)}. - */ -@Retention(RetentionPolicy.CLASS) -@Target(ElementType.TYPE) -public @interface ServiceProvider { - - Class value(); -} diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.service/src/jdk/vm/ci/service/Services.java --- a/jvmci/jdk.vm.ci.service/src/jdk/vm/ci/service/Services.java Sat Dec 26 15:00:55 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.service; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Formatter; -import java.util.List; - -import sun.reflect.Reflection; - -/** - * An mechanism for accessing service providers via JVMCI. These providers are loaded via a JVMCI - * class loader that is hidden from application code. Hence the {@link SecurityManager} checks in - * {@link #load(Class)} and {@link #loadSingle(Class, boolean)}. - */ -public final class Services { - - private Services() { - } - - private static final String SUPPRESS_PROPERTY_NAME = "jvmci.service.suppressNoClassDefFoundError"; - - /** - * Determines whether to suppress the {@link NoClassDefFoundError} raised if a service provider - * class specified in a {@code /jvmci/services/*} file is missing. - */ - private static final boolean SuppressNoClassDefFoundError = Boolean.getBoolean(SUPPRESS_PROPERTY_NAME); - - private static final ClassValue> cache = new ClassValue>() { - @Override - protected List computeValue(Class type) { - try { - return Arrays.asList(getServiceImpls(type)); - } catch (NoClassDefFoundError e) { - if (SuppressNoClassDefFoundError) { - return Collections.emptyList(); - } else { - NoClassDefFoundError newEx = new NoClassDefFoundError(e.getMessage() + " (suppress with -D" + SUPPRESS_PROPERTY_NAME + "=true)"); - if (e.getCause() != null) { - newEx.initCause(e.getCause()); - } - throw newEx; - } - } - } - }; - - /** - * Gets an {@link Iterable} of the JVMCI providers available for a given service. - * - * @throws SecurityException if a security manager is present and it denies - * {@link RuntimePermission}("jvmciServices") - */ - @SuppressWarnings("unchecked") - public static Iterable load(Class service) { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(new RuntimePermission("jvmciServices")); - } - try { - return (Iterable) cache.get(service); - } catch (UnsatisfiedLinkError e) { - return Collections.emptyList(); - } - } - - /** - * Gets the JVMCI provider for a given service for which at most one provider must be available. - * - * @param service the service whose provider is being requested - * @param required specifies if an {@link InternalError} should be thrown if no provider of - * {@code service} is available - * @throws SecurityException if a security manager is present and it denies - * {@link RuntimePermission}("jvmciServices") - */ - @SuppressWarnings({"unchecked"}) - public static S loadSingle(Class service, boolean required) { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(new RuntimePermission("jvmciServices")); - } - Iterable providers; - try { - providers = (Iterable) cache.get(service); - } catch (UnsatisfiedLinkError e) { - providers = Collections.emptyList(); - } - - S singleProvider = null; - for (S provider : providers) { - if (singleProvider != null) { - throw new InternalError(String.format("Multiple %s providers found: %s, %s", service.getName(), singleProvider.getClass().getName(), provider.getClass().getName())); - } - singleProvider = provider; - } - if (singleProvider == null && required) { - String javaHome = System.getProperty("java.home"); - String vmName = System.getProperty("java.vm.name"); - Formatter errorMessage = new Formatter(); - errorMessage.format("The VM does not expose required service %s.%n", service.getName()); - errorMessage.format("Currently used Java home directory is %s.%n", javaHome); - errorMessage.format("Currently used VM configuration is: %s", vmName); - throw new UnsupportedOperationException(errorMessage.toString()); - } - return singleProvider; - } - - static { - Reflection.registerMethodsToFilter(Services.class, "getServiceImpls"); - Reflection.registerFieldsToFilter(Services.class, "cache"); - } - - private static native S[] getServiceImpls(Class service); -} diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.services/.checkstyle_checks.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.vm.ci.services/.checkstyle_checks.xml Wed Dec 30 17:55:07 2015 +0100 @@ -0,0 +1,213 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.services/src/jdk/vm/ci/services/JVMCIClassLoaderFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.vm.ci.services/src/jdk/vm/ci/services/JVMCIClassLoaderFactory.java Wed Dec 30 17:55:07 2015 +0100 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.services; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.List; + +/** + * Utility called from the VM to create and register a separate class loader for loading JVMCI + * classes (i.e., those in found in lib/jvmci/*.jar). + */ +class JVMCIClassLoaderFactory { + + /** + * Copy of the {@code UseJVMCIClassLoader} VM option. Set by the VM before the static + * initializer is called. + */ + private static boolean useJVMCIClassLoader; + + /** + * Registers the JVMCI class loader in the VM. + */ + private static native void init(ClassLoader loader); + + static { + init(useJVMCIClassLoader ? newClassLoader() : null); + } + + /** + * Creates a new class loader for loading JVMCI classes. + */ + private static ClassLoader newClassLoader() { + URL[] urls = getJVMCIJarsUrls(); + ClassLoader parent = null; + return URLClassLoader.newInstance(urls, parent); + } + + /** + * Gets the URLs for lib/jvmci/*.jar. + */ + private static URL[] getJVMCIJarsUrls() { + File javaHome = new File(System.getProperty("java.home")); + File lib = new File(javaHome, "lib"); + File jvmci = new File(lib, "jvmci"); + if (!jvmci.exists()) { + throw new InternalError(jvmci + " does not exist"); + } + + List urls = new ArrayList<>(); + for (String fileName : jvmci.list()) { + if (fileName.endsWith(".jar")) { + File file = new File(jvmci, fileName); + if (file.isDirectory()) { + continue; + } + try { + urls.add(file.toURI().toURL()); + } catch (MalformedURLException e) { + throw new InternalError(e); + } + } + } + + return urls.toArray(new URL[urls.size()]); + } +} diff -r 4cf1946f59fc -r f2206f5bb62e jvmci/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java Wed Dec 30 17:55:07 2015 +0100 @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.services; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Formatter; +import java.util.List; + +import sun.reflect.Reflection; + +/** + * An mechanism for accessing service providers via JVMCI. These providers are loaded via a JVMCI + * class loader that is hidden from application code. Hence the {@link SecurityManager} checks in + * {@link #load(Class)} and {@link #loadSingle(Class, boolean)}. + */ +public final class Services { + + private Services() { + } + + private static final String SUPPRESS_PROPERTY_NAME = "jvmci.service.suppressNoClassDefFoundError"; + + /** + * Determines whether to suppress the {@link NoClassDefFoundError} raised if a service provider + * class specified in a {@code /jvmci/services/*} file is missing. + */ + private static final boolean SuppressNoClassDefFoundError = Boolean.getBoolean(SUPPRESS_PROPERTY_NAME); + + private static final ClassValue> cache = new ClassValue>() { + @Override + protected List computeValue(Class type) { + try { + return Arrays.asList(getServiceImpls(type)); + } catch (NoClassDefFoundError e) { + if (SuppressNoClassDefFoundError) { + return Collections.emptyList(); + } else { + NoClassDefFoundError newEx = new NoClassDefFoundError(e.getMessage() + " (suppress with -D" + SUPPRESS_PROPERTY_NAME + "=true)"); + if (e.getCause() != null) { + newEx.initCause(e.getCause()); + } + throw newEx; + } + } + } + }; + + /** + * Gets an {@link Iterable} of the JVMCI providers available for a given service. + * + * @throws SecurityException if a security manager is present and it denies + * {@link RuntimePermission}("jvmciServices") + */ + @SuppressWarnings("unchecked") + public static Iterable load(Class service) { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new RuntimePermission("jvmciServices")); + } + try { + return (Iterable) cache.get(service); + } catch (UnsatisfiedLinkError e) { + return Collections.emptyList(); + } + } + + /** + * Gets the JVMCI provider for a given service for which at most one provider must be available. + * + * @param service the service whose provider is being requested + * @param required specifies if an {@link InternalError} should be thrown if no provider of + * {@code service} is available + * @throws SecurityException if a security manager is present and it denies + * {@link RuntimePermission}("jvmciServices") + */ + @SuppressWarnings({"unchecked"}) + public static S loadSingle(Class service, boolean required) { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new RuntimePermission("jvmciServices")); + } + Iterable providers; + try { + providers = (Iterable) cache.get(service); + } catch (UnsatisfiedLinkError e) { + providers = Collections.emptyList(); + } + + S singleProvider = null; + for (S provider : providers) { + if (singleProvider != null) { + throw new InternalError(String.format("Multiple %s providers found: %s, %s", service.getName(), singleProvider.getClass().getName(), provider.getClass().getName())); + } + singleProvider = provider; + } + if (singleProvider == null && required) { + String javaHome = System.getProperty("java.home"); + String vmName = System.getProperty("java.vm.name"); + Formatter errorMessage = new Formatter(); + errorMessage.format("The VM does not expose required service %s.%n", service.getName()); + errorMessage.format("Currently used Java home directory is %s.%n", javaHome); + errorMessage.format("Currently used VM configuration is: %s", vmName); + throw new UnsupportedOperationException(errorMessage.toString()); + } + return singleProvider; + } + + static { + Reflection.registerMethodsToFilter(Services.class, "getServiceImpls"); + Reflection.registerFieldsToFilter(Services.class, "cache"); + } + + private static native S[] getServiceImpls(Class service); +} diff -r 4cf1946f59fc -r f2206f5bb62e make/defs.make --- a/make/defs.make Sat Dec 26 15:00:55 2015 +0100 +++ b/make/defs.make Wed Dec 30 17:55:07 2015 +0100 @@ -363,7 +363,7 @@ EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jni.h EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jmm.h -EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/jvmci-service.jar +EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/jvmci-services.jar EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_DIR)/jvmci-api.jar EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_DIR)/jvmci-hotspot.jar diff -r 4cf1946f59fc -r f2206f5bb62e make/jvmci.make --- a/make/jvmci.make Sat Dec 26 15:00:55 2015 +0100 +++ b/make/jvmci.make Wed Dec 30 17:55:07 2015 +0100 @@ -10,9 +10,7 @@ HS_COMMON_SRC=. # Directories, where the generated property-files reside within the JAR files -PROVIDERS_INF=/META-INF/jvmci.providers SERVICES_INF=/META-INF/jvmci.services -OPTIONS_INF=/META-INF/jvmci.options JARS = $(foreach dist,$(DISTRIBUTIONS),$($(dist)_JAR)) @@ -27,23 +25,6 @@ space := space += -# Takes the provider files created by ServiceProviderProcessor (the processor -# for the @ServiceProvider annotation) and merges them into a single file. -# Arguments: -# 1: directory with contents of the JAR file -define process_providers - $(eval providers := $(1)/$(PROVIDERS_INF)) - $(eval services := $(1)/$(SERVICES_INF)) - $(QUIETLY) test -d $(services) || mkdir -p $(services) - $(QUIETLY) test ! -d $(providers) || (cd $(providers) && for i in $$(ls); do c=$$(cat $$i); echo $$i >> $(abspath $(services))/$$c; rm $$i; done) - - @# Since all projects are built together with one javac call we cannot determine - @# which project contains HotSpotVMConfig.inline.hpp so we hardcode it. - $(eval vmconfig := $(1)/hotspot/HotSpotVMConfig.inline.hpp) - $(eval vmconfigDest := $(HS_COMMON_SRC)/../mxbuild/jvmci/jdk.vm.ci.hotspot/src_gen/hotspot) - $(QUIETLY) test ! -f $(vmconfig) || (mkdir -p $(vmconfigDest) && cp $(vmconfig) $(vmconfigDest)) -endef - # Extracts META-INF/jvmci.services from a JAR file into a given directory # Arguments: # 1: JAR file to extract @@ -67,7 +48,13 @@ $(eval TMP := $(shell mkdir -p $(TARGET) && mktemp -d $(TARGET)/tmp_XXXXX)) $(QUIETLY) $(JAVAC) -d $(TMP) -processorpath :$(1) -bootclasspath $(JDK_BOOTCLASSPATH) -cp :$(2) $(filter %.java,$^) $(QUIETLY) test "$(3)" = "" || cp -r $(3) $(TMP) - $(QUIETLY) $(call process_providers,$(TMP)) + + @# Since all projects are built together with one javac call we cannot determine + @# which project contains HotSpotVMConfig.inline.hpp so we hardcode it. + $(eval vmconfig := $(TMP)/hotspot/HotSpotVMConfig.inline.hpp) + $(eval vmconfigDest := $(HS_COMMON_SRC)/../mxbuild/jvmci/jdk.vm.ci.hotspot/src_gen/hotspot) + $(QUIETLY) test ! -f $(vmconfig) || (mkdir -p $(vmconfigDest) && cp $(vmconfig) $(vmconfigDest)) + $(QUIETLY) mkdir -p $(shell dirname $(4)) $(QUIETLY) $(JAR) -0cf $(4) -C $(TMP) . $(QUIETLY) rm -r $(TMP) @@ -107,11 +94,11 @@ JDK_BOOTCLASSPATH = $(ABS_BOOTDIR)/jre/lib/resources.jar:$(ABS_BOOTDIR)/jre/lib/rt.jar:$(ABS_BOOTDIR)/jre/lib/sunrsasign.jar:$(ABS_BOOTDIR)/jre/lib/jsse.jar:$(ABS_BOOTDIR)/jre/lib/jce.jar:$(ABS_BOOTDIR)/jre/lib/charsets.jar:$(ABS_BOOTDIR)/jre/lib/jfr.jar:$(ABS_BOOTDIR)/jre/classes -JVMCI_SERVICE_SRC += $(shell find jvmci/jdk.vm.ci.service/src -type f 2> /dev/null) +JVMCI_SERVICES_SRC += $(shell find jvmci/jdk.vm.ci.services/src -type f 2> /dev/null) -JVMCI_SERVICE_JAR = $(TARGET)/jvmci-service.jar +JVMCI_SERVICES_JAR = $(TARGET)/jvmci-services.jar -EXPORTED_FILES += $(JVMCI_SERVICE_JAR) +EXPORTED_FILES += $(JVMCI_SERVICES_JAR) JVMCI_API_SRC += $(shell find jvmci/jdk.vm.ci.inittimer/src -type f 2> /dev/null) JVMCI_API_SRC += $(shell find jvmci/jdk.vm.ci.meta/src -type f 2> /dev/null) @@ -124,16 +111,10 @@ JVMCI_API_JAR = $(TARGET)/jvmci-api.jar -JVMCI_API_DEP_JARS = $(TARGET)/jvmci-service.jar +JVMCI_API_DEP_JARS = $(TARGET)/jvmci-services.jar EXPORTED_FILES += $(JVMCI_API_JAR) -JVMCI_SERVICE_PROCESSOR_SRC += $(shell find jvmci/jdk.vm.ci.service.processor/src -type f 2> /dev/null) - -JVMCI_SERVICE_PROCESSOR_JAR = $(TARGET)/jvmci-service-processor.jar - -JVMCI_SERVICE_PROCESSOR_DEP_JARS = $(TARGET)/jvmci-service.jar - JVMCI_HOTSPOTVMCONFIG_SRC += $(shell find jvmci/jdk.vm.ci.hotspotvmconfig/src -type f 2> /dev/null) JVMCI_HOTSPOTVMCONFIG_JAR = $(TARGET)/jvmci-hotspotvmconfig.jar @@ -144,7 +125,7 @@ JVMCI_HOTSPOTVMCONFIG_PROCESSOR_JAR = $(TARGET)/jvmci-hotspotvmconfig-processor.jar -JVMCI_HOTSPOTVMCONFIG_PROCESSOR_DEP_JARS = $(TARGET)/jvmci-service.jar $(TARGET)/jvmci-api.jar $(TARGET)/jvmci-hotspotvmconfig.jar +JVMCI_HOTSPOTVMCONFIG_PROCESSOR_DEP_JARS = $(TARGET)/jvmci-services.jar $(TARGET)/jvmci-api.jar $(TARGET)/jvmci-hotspotvmconfig.jar JVMCI_HOTSPOT_SRC += $(shell find jvmci/jdk.vm.ci.hotspot/src -type f 2> /dev/null) JVMCI_HOTSPOT_SRC += $(shell find jvmci/jdk.vm.ci.hotspot.aarch64/src -type f 2> /dev/null) @@ -156,24 +137,20 @@ JVMCI_HOTSPOT_JAR = $(TARGET)/jvmci-hotspot.jar -JVMCI_HOTSPOT_DEP_JARS = $(TARGET)/jvmci-hotspotvmconfig.jar $(TARGET)/jvmci-service.jar $(TARGET)/jvmci-api.jar +JVMCI_HOTSPOT_DEP_JARS = $(TARGET)/jvmci-hotspotvmconfig.jar $(TARGET)/jvmci-services.jar $(TARGET)/jvmci-api.jar EXPORTED_FILES += $(JVMCI_HOTSPOT_JAR) -DISTRIBUTIONS = JVMCI_SERVICE JVMCI_API JVMCI_SERVICE_PROCESSOR JVMCI_HOTSPOTVMCONFIG JVMCI_HOTSPOTVMCONFIG_PROCESSOR JVMCI_HOTSPOT +DISTRIBUTIONS = JVMCI_SERVICES JVMCI_API JVMCI_HOTSPOTVMCONFIG JVMCI_HOTSPOTVMCONFIG_PROCESSOR JVMCI_HOTSPOT -$(JVMCI_SERVICE_JAR): $(JVMCI_SERVICE_SRC) - $(call build_and_jar,,$(subst $(space),:,),,$(JVMCI_SERVICE_JAR)) +$(JVMCI_SERVICES_JAR): $(JVMCI_SERVICES_SRC) + $(call build_and_jar,,$(subst $(space),:,),,$(JVMCI_SERVICES_JAR)) $(JVMCI_API_JAR): $(JVMCI_API_SRC) $(JVMCI_API_DEP_JARS) $(call build_and_jar,,$(subst $(space),:,$(JVMCI_API_DEP_JARS)),,$(JVMCI_API_JAR)) -$(JVMCI_SERVICE_PROCESSOR_JAR): $(JVMCI_SERVICE_PROCESSOR_SRC) $(JVMCI_SERVICE_PROCESSOR_DEP_JARS) - $(call build_and_jar,,$(subst $(space),:,$(JVMCI_SERVICE_PROCESSOR_DEP_JARS)),jvmci/jdk.vm.ci.service.processor/src/META-INF,$(JVMCI_SERVICE_PROCESSOR_JAR)) - - $(JVMCI_HOTSPOTVMCONFIG_JAR): $(JVMCI_HOTSPOTVMCONFIG_SRC) $(call build_and_jar,,$(subst $(space),:,),,$(JVMCI_HOTSPOTVMCONFIG_JAR)) @@ -182,9 +159,9 @@ $(call build_and_jar,,$(subst $(space),:,$(JVMCI_HOTSPOTVMCONFIG_PROCESSOR_DEP_JARS)),jvmci/jdk.vm.ci.hotspotvmconfig.processor/src/META-INF,$(JVMCI_HOTSPOTVMCONFIG_PROCESSOR_JAR)) -$(JVMCI_HOTSPOT_JAR): $(JVMCI_HOTSPOT_SRC) $(JVMCI_HOTSPOTVMCONFIG_PROCESSOR_JAR) $(JVMCI_SERVICE_PROCESSOR_JAR) $(JVMCI_HOTSPOT_DEP_JARS) - $(call build_and_jar,$(JVMCI_HOTSPOTVMCONFIG_PROCESSOR_JAR):$(JVMCI_SERVICE_PROCESSOR_JAR):$(subst $(space),:,$(JVMCI_HOTSPOTVMCONFIG_PROCESSOR_DEP_JARS)):$(subst $(space),:,$(JVMCI_SERVICE_PROCESSOR_DEP_JARS)),$(subst $(space),:,$(JVMCI_HOTSPOT_DEP_JARS)),,$(JVMCI_HOTSPOT_JAR)) +$(JVMCI_HOTSPOT_JAR): $(JVMCI_HOTSPOT_SRC) $(JVMCI_HOTSPOTVMCONFIG_PROCESSOR_JAR) $(JVMCI_HOTSPOT_DEP_JARS) + $(call build_and_jar,$(JVMCI_HOTSPOTVMCONFIG_PROCESSOR_JAR):$(subst $(space),:,$(JVMCI_HOTSPOTVMCONFIG_PROCESSOR_DEP_JARS)),$(subst $(space),:,$(JVMCI_HOTSPOT_DEP_JARS)),jvmci/jdk.vm.ci.hotspot.aarch64/src/META-INF jvmci/jdk.vm.ci.hotspot.amd64/src/META-INF jvmci/jdk.vm.ci.hotspot.sparc/src/META-INF jvmci/jdk.vm.ci.hotspot.jfr/src/META-INF,$(JVMCI_HOTSPOT_JAR)) -default: $(JVMCI_SERVICE_JAR) $(JVMCI_API_JAR) $(JVMCI_HOTSPOT_JAR) $(JVMCI_HOTSPOTVMCONFIG_JAR) +default: $(JVMCI_SERVICES_JAR) $(JVMCI_API_JAR) $(JVMCI_HOTSPOT_JAR) $(JVMCI_HOTSPOTVMCONFIG_JAR) .PHONY: default diff -r 4cf1946f59fc -r f2206f5bb62e mx.jvmci/mx_jvmci.py --- a/mx.jvmci/mx_jvmci.py Sat Dec 26 15:00:55 2015 +0100 +++ b/mx.jvmci/mx_jvmci.py Wed Dec 30 17:55:07 2015 +0100 @@ -99,6 +99,11 @@ def deploy(self, jdkDir): mx.nyi('deploy', self) + def post_parse_cmd_line(self): + def _install(d): + _installDistInJdks(self) + self.dist().add_update_listener(_install) + class JarJDKDeployedDist(JDKDeployedDist): def __init__(self, name, partOfHotSpot=False): JDKDeployedDist.__init__(self, name) @@ -144,6 +149,14 @@ if self._compilers: _updateJVMCIProperties(jdkDir, self._compilers) + def post_parse_cmd_line(self): + super(JvmciJDKDeployedDist, self).post_parse_cmd_line() + self.set_archiveparticipant() + + def set_archiveparticipant(self): + dist = self.dist() + dist.set_archiveparticipant(JVMCIArchiveParticipant(dist)) + def _exe(l): return mx.exe_suffix(l) @@ -185,7 +198,7 @@ List of distributions that are deployed into a JDK by mx. """ jdkDeployedDists = [ - LibJDKDeployedDist('JVMCI_SERVICE', partOfHotSpot=True), + LibJDKDeployedDist('JVMCI_SERVICES', partOfHotSpot=True), JvmciJDKDeployedDist('JVMCI_API', partOfHotSpot=True), JvmciJDKDeployedDist('JVMCI_HOTSPOT', partOfHotSpot=True), JvmciJDKDeployedDist('JVMCI_HOTSPOTVMCONFIG', partOfHotSpot=True), @@ -1708,15 +1721,6 @@ service = arcname[len('META-INF/jvmci.services/'):] self.jvmciServices.setdefault(service, []).extend([provider for provider in contents.split('\n')]) return True - if arcname.startswith('META-INF/jvmci.providers/'): - provider = arcname[len('META-INF/jvmci.providers/'):] - for service in contents.strip().split(os.linesep): - assert service - self.jvmciServices.setdefault(service, []).append(provider) - # Make provider available as a normal service as well to - # allow for deployment on JDK9 without having to recompile. - self.services.setdefault(service, []).append(provider) - return True return False def __addsrc__(self, arcname, contents): @@ -1859,11 +1863,4 @@ mx.instantiateDistribution('JVM__', dict(vmbuild=_vmbuild, vm=get_vm())) for jdkDist in jdkDeployedDists: - def _close(jdkDeployable): - def _install(dist): - _installDistInJdks(jdkDeployable) - return _install - dist = jdkDist.dist() - dist.add_update_listener(_close(jdkDist)) - if isinstance(jdkDist, JvmciJDKDeployedDist): - dist.set_archiveparticipant(JVMCIArchiveParticipant(dist)) + jdkDist.post_parse_cmd_line() diff -r 4cf1946f59fc -r f2206f5bb62e mx.jvmci/mx_jvmci_makefile.py --- a/mx.jvmci/mx_jvmci_makefile.py Sat Dec 26 15:00:55 2015 +0100 +++ b/mx.jvmci/mx_jvmci_makefile.py Wed Dec 30 17:55:07 2015 +0100 @@ -159,9 +159,7 @@ HS_COMMON_SRC=. # Directories, where the generated property-files reside within the JAR files -PROVIDERS_INF=/META-INF/jvmci.providers SERVICES_INF=/META-INF/jvmci.services -OPTIONS_INF=/META-INF/jvmci.options JARS = $(foreach dist,$(DISTRIBUTIONS),$($(dist)_JAR)) @@ -176,23 +174,6 @@ space := space += -# Takes the provider files created by ServiceProviderProcessor (the processor -# for the @ServiceProvider annotation) and merges them into a single file. -# Arguments: -# 1: directory with contents of the JAR file -define process_providers - $(eval providers := $(1)/$(PROVIDERS_INF)) - $(eval services := $(1)/$(SERVICES_INF)) - $(QUIETLY) test -d $(services) || mkdir -p $(services) - $(QUIETLY) test ! -d $(providers) || (cd $(providers) && for i in $$(ls); do c=$$(cat $$i); echo $$i >> $(abspath $(services))/$$c; rm $$i; done) - - @# Since all projects are built together with one javac call we cannot determine - @# which project contains HotSpotVMConfig.inline.hpp so we hardcode it. - $(eval vmconfig := $(1)/hotspot/HotSpotVMConfig.inline.hpp) - $(eval vmconfigDest := $(HS_COMMON_SRC)/../mxbuild/jvmci/jdk.vm.ci.hotspot/src_gen/hotspot) - $(QUIETLY) test ! -f $(vmconfig) || (mkdir -p $(vmconfigDest) && cp $(vmconfig) $(vmconfigDest)) -endef - # Extracts META-INF/jvmci.services from a JAR file into a given directory # Arguments: # 1: JAR file to extract @@ -216,7 +197,13 @@ $(eval TMP := $(shell mkdir -p $(TARGET) && mktemp -d $(TARGET)/tmp_XXXXX)) $(QUIETLY) $(JAVAC) -d $(TMP) -processorpath :$(1) -bootclasspath $(JDK_BOOTCLASSPATH) -cp :$(2) $(filter %.java,$^) $(QUIETLY) test "$(3)" = "" || cp -r $(3) $(TMP) - $(QUIETLY) $(call process_providers,$(TMP)) + + @# Since all projects are built together with one javac call we cannot determine + @# which project contains HotSpotVMConfig.inline.hpp so we hardcode it. + $(eval vmconfig := $(TMP)/hotspot/HotSpotVMConfig.inline.hpp) + $(eval vmconfigDest := $(HS_COMMON_SRC)/../mxbuild/jvmci/jdk.vm.ci.hotspot/src_gen/hotspot) + $(QUIETLY) test ! -f $(vmconfig) || (mkdir -p $(vmconfigDest) && cp $(vmconfig) $(vmconfigDest)) + $(QUIETLY) mkdir -p $(shell dirname $(4)) $(QUIETLY) $(JAR) -0cf $(4) -C $(TMP) . $(QUIETLY) rm -r $(TMP) diff -r 4cf1946f59fc -r f2206f5bb62e mx.jvmci/suite.py --- a/mx.jvmci/suite.py Sat Dec 26 15:00:55 2015 +0100 +++ b/mx.jvmci/suite.py Wed Dec 30 17:55:07 2015 +0100 @@ -61,28 +61,19 @@ # ------------- JVMCI:Service ------------- - "jdk.vm.ci.service" : { + "jdk.vm.ci.services" : { "subDir" : "jvmci", "sourceDirs" : ["src"], "javaCompliance" : "1.8", "workingSets" : "API,JVMCI", }, - "jdk.vm.ci.service.processor" : { - "subDir" : "jvmci", - "sourceDirs" : ["src"], - "dependencies" : ["jdk.vm.ci.service"], - "checkstyle" : "jdk.vm.ci.service", - "javaCompliance" : "1.8", - "workingSets" : "JVMCI,Codegen,HotSpot", - }, - # ------------- JVMCI:API ------------- "jdk.vm.ci.common" : { "subDir" : "jvmci", "sourceDirs" : ["src"], - "checkstyle" : "jdk.vm.ci.service", + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "API,JVMCI", }, @@ -90,7 +81,7 @@ "jdk.vm.ci.meta" : { "subDir" : "jvmci", "sourceDirs" : ["src"], - "checkstyle" : "jdk.vm.ci.service", + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "API,JVMCI", }, @@ -99,7 +90,7 @@ "subDir" : "jvmci", "sourceDirs" : ["src"], "dependencies" : ["jdk.vm.ci.meta"], - "checkstyle" : "jdk.vm.ci.service", + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "API,JVMCI", }, @@ -110,7 +101,7 @@ "dependencies" : [ "jdk.vm.ci.code", ], - "checkstyle" : "jdk.vm.ci.service", + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "API,JVMCI", }, @@ -123,7 +114,7 @@ "jdk.vm.ci.common", "jdk.vm.ci.runtime", ], - "checkstyle" : "jdk.vm.ci.service", + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "API,JVMCI", }, @@ -131,7 +122,7 @@ "jdk.vm.ci.inittimer" : { "subDir" : "jvmci", "sourceDirs" : ["src"], - "checkstyle" : "jdk.vm.ci.service", + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "JVMCI", }, @@ -142,7 +133,7 @@ "subDir" : "jvmci", "sourceDirs" : ["src"], "dependencies" : ["jdk.vm.ci.code"], - "checkstyle" : "jdk.vm.ci.service", + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "JVMCI,AArch64", }, @@ -151,7 +142,7 @@ "subDir" : "jvmci", "sourceDirs" : ["src"], "dependencies" : ["jdk.vm.ci.code"], - "checkstyle" : "jdk.vm.ci.service", + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "JVMCI,AMD64", }, @@ -160,7 +151,7 @@ "subDir" : "jvmci", "sourceDirs" : ["src"], "dependencies" : ["jdk.vm.ci.code"], - "checkstyle" : "jdk.vm.ci.service", + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "JVMCI,SPARC", }, @@ -173,12 +164,12 @@ "jdk.vm.ci.common", "jdk.vm.ci.inittimer", "jdk.vm.ci.runtime", - "jdk.vm.ci.service", + "jdk.vm.ci.services", ], "annotationProcessors" : [ "JVMCI_HOTSPOTVMCONFIG_PROCESSOR", ], - "checkstyle" : "jdk.vm.ci.service", + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "JVMCI", }, @@ -186,7 +177,7 @@ "jdk.vm.ci.hotspotvmconfig" : { "subDir" : "jvmci", "sourceDirs" : ["src"], - "checkstyle" : "jdk.vm.ci.service", + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "JVMCI,HotSpot", }, @@ -195,7 +186,7 @@ "subDir" : "jvmci", "sourceDirs" : ["src"], "dependencies" : ["jdk.vm.ci.hotspotvmconfig", "jdk.vm.ci.common"], - "checkstyle" : "jdk.vm.ci.service", + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "JVMCI,HotSpot,Codegen", }, @@ -207,10 +198,7 @@ "jdk.vm.ci.aarch64", "jdk.vm.ci.hotspot", ], - "checkstyle" : "jdk.vm.ci.service", - "annotationProcessors" : [ - "JVMCI_SERVICE_PROCESSOR", - ], + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "JVMCI,HotSpot,AArch64", }, @@ -222,10 +210,7 @@ "jdk.vm.ci.amd64", "jdk.vm.ci.hotspot", ], - "checkstyle" : "jdk.vm.ci.service", - "annotationProcessors" : [ - "JVMCI_SERVICE_PROCESSOR", - ], + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "JVMCI,HotSpot,AMD64", }, @@ -237,10 +222,7 @@ "jdk.vm.ci.sparc", "jdk.vm.ci.hotspot", ], - "checkstyle" : "jdk.vm.ci.service", - "annotationProcessors" : [ - "JVMCI_SERVICE_PROCESSOR", - ], + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "JVMCI,HotSpot,SPARC", }, @@ -252,8 +234,7 @@ "jdk.vm.ci.hotspot", "JFR", ], - "checkstyle" : "jdk.vm.ci.service", - "annotationProcessors" : ["JVMCI_SERVICE_PROCESSOR"], + "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "profile" : "", "workingSets" : "JVMCI,HotSpot", @@ -328,9 +309,9 @@ } }, - "JVMCI_SERVICE" : { + "JVMCI_SERVICES" : { "subDir" : "jvmci", - "dependencies" : ["jdk.vm.ci.service"], + "dependencies" : ["jdk.vm.ci.services"], }, "JVMCI_API" : { @@ -344,7 +325,7 @@ "jdk.vm.ci.sparc", ], "distDependencies" : [ - "JVMCI_SERVICE", + "JVMCI_SERVICES", ], }, @@ -365,7 +346,7 @@ ], "distDependencies" : [ "JVMCI_HOTSPOTVMCONFIG", - "JVMCI_SERVICE", + "JVMCI_SERVICES", "JVMCI_API", ], }, @@ -389,13 +370,5 @@ "JVMCI_HOTSPOTVMCONFIG", ], }, - - "JVMCI_SERVICE_PROCESSOR" : { - "subDir" : "jvmci", - "dependencies" : ["jdk.vm.ci.service.processor"], - "distDependencies" : [ - "JVMCI_SERVICE", - ], - }, }, } diff -r 4cf1946f59fc -r f2206f5bb62e src/share/vm/jvmci/jvmciRuntime.cpp --- a/src/share/vm/jvmci/jvmciRuntime.cpp Sat Dec 26 15:00:55 2015 +0100 +++ b/src/share/vm/jvmci/jvmciRuntime.cpp Wed Dec 30 17:55:07 2015 +0100 @@ -605,7 +605,7 @@ return JVMCIRuntime::get_HotSpotJVMCIRuntime_jobject(CHECK_NULL); JVM_END -// private static Service[] Services.getServiceImpls(String serviceClass) +// private static Object[] Services.getServiceImpls(String serviceClass) JVM_ENTRY(jobject, JVM_GetJVMCIServiceImpls(JNIEnv *env, jclass c, jclass serviceClass)) HandleMark hm; ResourceMark rm; @@ -790,7 +790,7 @@ static Klass* _FactoryKlass = NULL; if (_FactoryKlass == NULL) { Thread* THREAD = Thread::current(); - TempNewSymbol name = SymbolTable::new_symbol("jdk/vm/ci/service/JVMCIClassLoaderFactory", CHECK_ABORT); + TempNewSymbol name = SymbolTable::new_symbol("jdk/vm/ci/services/JVMCIClassLoaderFactory", CHECK_ABORT); KlassHandle klass = SystemDictionary::resolve_or_fail(name, true, THREAD); if (HAS_PENDING_EXCEPTION) { static volatile int seen_error = 0; diff -r 4cf1946f59fc -r f2206f5bb62e src/share/vm/jvmci/jvmciRuntime.hpp --- a/src/share/vm/jvmci/jvmciRuntime.hpp Sat Dec 26 15:00:55 2015 +0100 +++ b/src/share/vm/jvmci/jvmciRuntime.hpp Wed Dec 30 17:55:07 2015 +0100 @@ -81,7 +81,7 @@ /** * Instantiates a service object, calls its default constructor and returns it. * - * @param name the name of a class implementing jdk.vm.ci.service.Service + * @param name the name of a service provider class */ static Handle create_Service(const char* name, TRAPS); @@ -142,8 +142,7 @@ static bool treat_as_trivial(Method* method); /** - * Given an interface representing a JVMCI service (i.e. sub-interface of - * jdk.vm.ci.api.service.Service), gets an array of objects, one per + * Given an interface representing a JVMCI service, gets an array of objects, one per * known implementation of the service. */ static objArrayHandle get_service_impls(KlassHandle serviceKlass, TRAPS); diff -r 4cf1946f59fc -r f2206f5bb62e src/share/vm/prims/nativeLookup.cpp --- a/src/share/vm/prims/nativeLookup.cpp Sat Dec 26 15:00:55 2015 +0100 +++ b/src/share/vm/prims/nativeLookup.cpp Wed Dec 30 17:55:07 2015 +0100 @@ -143,10 +143,10 @@ { CC"Java_sun_misc_Perf_registerNatives", NULL, FN_PTR(JVM_RegisterPerfMethods) }, { CC"Java_sun_hotspot_WhiteBox_registerNatives", NULL, FN_PTR(JVM_RegisterWhiteBoxMethods) }, #if INCLUDE_JVMCI - { CC"Java_jdk_vm_ci_service_JVMCIClassLoaderFactory_init", NULL, FN_PTR(JVM_InitJVMCIClassLoader) }, - { CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime", NULL, FN_PTR(JVM_GetJVMCIRuntime) }, - { CC"Java_jdk_vm_ci_service_Services_getServiceImpls", NULL, FN_PTR(JVM_GetJVMCIServiceImpls) }, - { CC"Java_jdk_vm_ci_hotspot_CompilerToVM_registerNatives", NULL, FN_PTR(JVM_RegisterJVMCINatives) }, + { CC"Java_jdk_vm_ci_services_JVMCIClassLoaderFactory_init", NULL, FN_PTR(JVM_InitJVMCIClassLoader) }, + { CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime", NULL, FN_PTR(JVM_GetJVMCIRuntime) }, + { CC"Java_jdk_vm_ci_services_Services_getServiceImpls", NULL, FN_PTR(JVM_GetJVMCIServiceImpls) }, + { CC"Java_jdk_vm_ci_hotspot_CompilerToVM_registerNatives", NULL, FN_PTR(JVM_RegisterJVMCINatives) }, #endif }; diff -r 4cf1946f59fc -r f2206f5bb62e src/share/vm/runtime/os.cpp --- a/src/share/vm/runtime/os.cpp Sat Dec 26 15:00:55 2015 +0100 +++ b/src/share/vm/runtime/os.cpp Wed Dec 30 17:55:07 2015 +0100 @@ -1190,7 +1190,7 @@ "%/lib/charsets.jar:" "%/lib/jfr.jar:" #if INCLUDE_JVMCI - "%/lib/jvmci-service.jar:" + "%/lib/jvmci-services.jar:" #endif "%/classes"; char* sysclasspath = format_boot_path(classpath_format, home, home_len, fileSep, pathSep);