diff options
author | Thomas Watson | 2020-05-18 18:47:24 +0000 |
---|---|---|
committer | Thomas Watson | 2020-05-18 18:47:24 +0000 |
commit | 6f37585b0f192c49df9c3ccba5c1704a5d62bf8a (patch) | |
tree | 1096c0c50ba307a1bfefc78aa6989bdbac507dd9 | |
parent | 19ea8b7ed79db5437135cda641dd1908b9b7f939 (diff) | |
parent | 3bc986c22e78806d076a6830a590c2b6f9d23d26 (diff) | |
download | rt.equinox.framework-6f37585b0f192c49df9c3ccba5c1704a5d62bf8a.tar.gz rt.equinox.framework-6f37585b0f192c49df9c3ccba5c1704a5d62bf8a.tar.xz rt.equinox.framework-6f37585b0f192c49df9c3ccba5c1704a5d62bf8a.zip |
Merge branch 'master' into osgiR8
10 files changed, 122 insertions, 11 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java index 2f509b25d..f279c8c3c 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2018 IBM Corporation and others. + * Copyright (c) 2006, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -2283,7 +2283,7 @@ public class ClassLoadingBundleTests extends AbstractBundleTests { reg.unregister(); } - assertEquals("Unexpected number of woven classes.", 3, called.size()); + assertEquals("Unexpected number of woven classes.", 2, called.size()); for (WovenClass wovenClass : called) { if (weavingHookClasses.contains(wovenClass.getClassName())) { assertNull("Did not expect to find class: " + wovenClass.getDefinedClass(), wovenClass.getDefinedClass()); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java index 8df1049fa..fcbae3ee6 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2017 IBM Corporation and others. + * Copyright (c) 2012, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -46,7 +46,8 @@ import org.osgi.framework.hooks.bundle.EventHook; public class EquinoxEventPublisher { static final String eventHookName = EventHook.class.getName(); static final String collisionHookName = CollisionHook.class.getName(); - static final int FRAMEWORK_STOPPED_MASK = (FrameworkEvent.STOPPED | FrameworkEvent.STOPPED_BOOTCLASSPATH_MODIFIED | FrameworkEvent.STOPPED_UPDATE); + static final int FRAMEWORK_STOPPED_MASK = (FrameworkEvent.STOPPED | FrameworkEvent.STOPPED_BOOTCLASSPATH_MODIFIED + | FrameworkEvent.STOPPED_UPDATE | FrameworkEvent.STOPPED_SYSTEM_REFRESHED); static final int BUNDLEEVENT = 1; static final int BUNDLEEVENTSYNC = 2; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java index 5f642f5f6..a0dc562b4 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java @@ -234,6 +234,7 @@ public class ServiceRegistrationImpl<S> implements ServiceRegistration<S>, Compa } } + ungetHookInstance(); /* must not hold the registrationLock when this event is published */ registry.publishServiceEvent(new ServiceEvent(ServiceEvent.UNREGISTERING, ref)); @@ -291,6 +292,18 @@ public class ServiceRegistrationImpl<S> implements ServiceRegistration<S>, Compa return getReferenceImpl(); } + S getHookInstance() { + return null; + } + + void initHookInstance() { + // nothing by default + } + + void ungetHookInstance() { + // nothing by default + } + ServiceReferenceImpl<S> getReferenceImpl() { /* use reference instead of unregistered so that ServiceFactorys, called * by releaseService after the registration is unregistered, can @@ -760,4 +773,46 @@ public class ServiceRegistrationImpl<S> implements ServiceRegistration<S>, Compa } return 1; } + + static class FrameworkHookRegistration<S> extends ServiceRegistrationImpl<S> { + private volatile boolean hookInitialized = false; + private volatile S hookInstance; + private final BundleContextImpl systemContext; + private final Object hookLock = new Object(); + + FrameworkHookRegistration(ServiceRegistry registry, BundleContextImpl context, String[] clazzes, S service, + BundleContextImpl systemContext) { + super(registry, context, clazzes, service); + this.systemContext = systemContext; + } + + @Override + S getHookInstance() { + if (hookInstance != null || !hookInitialized) { + return hookInstance; + } + synchronized (hookLock) { + if (hookInstance == null) { + hookInstance = getSafeService(systemContext, ServiceConsumer.singletonConsumer); + } + } + return hookInstance; + } + + @Override + void initHookInstance() { + ServiceReference<S> ref = getReference(); + if (ref != null) { + hookInstance = getSafeService(systemContext, ServiceConsumer.singletonConsumer); + hookInitialized = true; + } + } + + @Override + void ungetHookInstance() { + if (hookInstance != null) { + systemContext.ungetService(getReferenceImpl()); + } + } + } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java index 4b9092167..4cdcd976d 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2017 IBM Corporation and others. + * Copyright (c) 2004, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -74,6 +74,7 @@ public class ServiceRegistry { static final String eventListenerHookName = EventListenerHook.class.getName(); static final String listenerHookName = ListenerHook.class.getName(); + /** Published services by class name. * The {@literal List<ServiceRegistrationImpl<?>>}s are both sorted * in the natural order of ServiceRegistrationImpl and also are sets in that @@ -229,12 +230,16 @@ public class ServiceRegistry { throw new IllegalArgumentException(Msg.SERVICE_EMPTY_CLASS_LIST_EXCEPTION); } + boolean isListenerHook = false; + boolean isFrameworkHook = false; /* copy the array so that changes to the original will not affect us. */ List<String> copy = new ArrayList<>(size); // intern the strings and remove duplicates for (int i = 0; i < size; i++) { String clazz = clazzes[i].intern(); if (!copy.contains(clazz)) { + isListenerHook = isListenerHook || listenerHookName.equals(clazz); + isFrameworkHook = isFrameworkHook || isFrameworkHook(clazz); copy.add(clazz); } } @@ -254,14 +259,44 @@ public class ServiceRegistry { } } - ServiceRegistrationImpl<?> registration = new ServiceRegistrationImpl<>(this, context, clazzes, service); + ServiceRegistrationImpl<?> registration = isFrameworkHook + ? new ServiceRegistrationImpl.FrameworkHookRegistration<>(this, context, clazzes, service, + systemBundleContext) + : new ServiceRegistrationImpl<>(this, context, clazzes, service); registration.register(properties); - if (copy.contains(listenerHookName)) { + registration.initHookInstance(); + + if (isListenerHook) { notifyNewListenerHook(registration); } return registration; } + private boolean isFrameworkHook(String className) { + switch (className) { + case "org.osgi.framework.hooks.bundle.CollisionHook": //$NON-NLS-1$ + return true; + case "org.osgi.framework.hooks.bundle.EventHook": //$NON-NLS-1$ + return true; + case "org.osgi.framework.hooks.bundle.FindHook": //$NON-NLS-1$ + return true; + case "org.osgi.framework.hooks.service.EventHook": //$NON-NLS-1$ + return true; + case "org.osgi.framework.hooks.service.EventListenerHook": //$NON-NLS-1$ + return true; + case "org.osgi.framework.hooks.service.FindHook": //$NON-NLS-1$ + return true; + case "org.osgi.framework.hooks.service.ListenerHook": //$NON-NLS-1$ + return true; + case "org.osgi.framework.hooks.weaving.WeavingHook": //$NON-NLS-1$ + return true; + case "org.osgi.framework.hooks.weaving.WovenClassListener": //$NON-NLS-1$ + return true; + default: + return false; + } + } + /** * Returns an array of <code>ServiceReferenceImpl</code> objects. The returned * array of <code>ServiceReferenceImpl</code> objects contains services that @@ -1335,8 +1370,11 @@ public class ServiceRegistry { if (hookContext.skipRegistration(registration)) { return; } - Object hook = registration.getSafeService(context, ServiceConsumer.singletonConsumer); - if (hook == null) { // if the hook is null + Object hook = registration.getHookInstance(); + if (hook == null) { + // The hook may not be initialized yet + // We do not call the hook until after it has been registered + // This means we could miss calls to a hook during the registered event. return; } try { @@ -1350,8 +1388,6 @@ public class ServiceRegistry { container.handleRuntimeError(t); ServiceException se = new ServiceException(NLS.bind(Msg.SERVICE_FACTORY_EXCEPTION, hook.getClass().getName(), hookContext.getHookMethodName()), t); container.getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, registration.getBundle(), se); - } finally { - registration.ungetService(context, ServiceConsumer.singletonConsumer, null); } } diff --git a/features/org.eclipse.equinox.executable.feature/build.properties b/features/org.eclipse.equinox.executable.feature/build.properties index 2b22bd40b..44e0ad77f 100644 --- a/features/org.eclipse.equinox.executable.feature/build.properties +++ b/features/org.eclipse.equinox.executable.feature/build.properties @@ -24,6 +24,9 @@ bin.includes = bin/,\ root.win32.win32.x86_64=bin/win32/win32/x86_64 root.win32.win32.x86_64.permissions.755=launcher.exe +root.linux.gtk.ppc64le=bin/gtk/linux/ppc64le,gtk_root +root.linux.gtk.ppc64le.permissions.755=launcher + root.macosx.cocoa.x86_64=bin/cocoa/macosx/x86_64 root.macosx.cocoa.x86_64.permissions.755=Eclipse.app/Contents/MacOS/launcher diff --git a/features/org.eclipse.equinox.executable.feature/feature.xml b/features/org.eclipse.equinox.executable.feature/feature.xml index 7ff8622c1..aaa8a63f7 100755 --- a/features/org.eclipse.equinox.executable.feature/feature.xml +++ b/features/org.eclipse.equinox.executable.feature/feature.xml @@ -33,6 +33,16 @@ fragment="true"/> <plugin + id="org.eclipse.equinox.launcher.gtk.linux.ppc64le" + os="linux" + ws="gtk" + arch="ppc64le" + download-size="0" + install-size="0" + version="0.0.0" + fragment="true"/> + + <plugin id="org.eclipse.equinox.launcher.gtk.linux.x86_64" os="linux" ws="gtk" diff --git a/features/org.eclipse.equinox.executable.feature/pom.xml b/features/org.eclipse.equinox.executable.feature/pom.xml index 0b56c8527..569b29f19 100644 --- a/features/org.eclipse.equinox.executable.feature/pom.xml +++ b/features/org.eclipse.equinox.executable.feature/pom.xml @@ -123,6 +123,7 @@ <copy todir="bin" verbose="true" includeEmptyDirs="false" failonerror="true"> <fileset dir="${rt.equinox.binaries.loc}/org.eclipse.equinox.executable/bin/"> <include name="cocoa/macosx/x86_64/**/*"/> + <include name="gtk/linux/ppc64le/**/*"/> <include name="gtk/linux/x86_64/**/*"/> <include name="win32/win32/x86_64/**/*"/> </fileset> diff --git a/features/org.eclipse.equinox.executable.feature/resources/build.properties b/features/org.eclipse.equinox.executable.feature/resources/build.properties index 606c1b88f..741e9b30f 100644 --- a/features/org.eclipse.equinox.executable.feature/resources/build.properties +++ b/features/org.eclipse.equinox.executable.feature/resources/build.properties @@ -20,6 +20,9 @@ root.permissions.755=${launcherName} root.win32.win32.x86_64=file:bin/win32/win32/x86_64/launcher.exe root.win32.win32.x86_64.permissions.755=launcher.exe +root.linux.gtk.ppc64le=bin/gtk/linux/ppc64le,gtk_root +root.linux.gtk.ppc64le.permissions.755=launcher + root.macosx.cocoa.x86_64=bin/cocoa/macosx/x86_64 root.macosx.cocoa.x86_64.permissions.755=Contents/MacOS/${launcherName} diff --git a/features/org.eclipse.equinox.executable.feature/resources/build.xml b/features/org.eclipse.equinox.executable.feature/resources/build.xml index 5811ae426..297ae849f 100644 --- a/features/org.eclipse.equinox.executable.feature/resources/build.xml +++ b/features/org.eclipse.equinox.executable.feature/resources/build.xml @@ -138,6 +138,7 @@ <target name="rootFilesgroup_group_group"> <antcall target="rootFileswin32_win32_x86_64"/> <antcall target="rootFilesmacosx_cocoa_x86_64"/> + <antcall target="rootFileslinux_gtk_ppc64le"/> <antcall target="rootFileslinux_gtk_x86_64"/> </target> @@ -88,6 +88,7 @@ <module>bundles/org.eclipse.equinox.launcher</module> <module>bundles/org.eclipse.equinox.launcher.cocoa.macosx.x86_64</module> + <module>bundles/org.eclipse.equinox.launcher.gtk.linux.ppc64le</module> <module>bundles/org.eclipse.equinox.launcher.gtk.linux.x86_64</module> <module>bundles/org.eclipse.equinox.launcher.win32.win32.x86_64</module> |