Bug 514810 - Use empty array constant for empty object descriptors

Change-Id: I71c7177fce75a39310f86245efe7ed333dcd1e00
Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
Signed-off-by: Brian de Alwis <bsd@mt.ca>
diff --git a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ConstructorRequestor.java b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ConstructorRequestor.java
index 8ff6be1..5a35040 100644
--- a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ConstructorRequestor.java
+++ b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ConstructorRequestor.java
@@ -71,7 +71,9 @@
 			System.arraycopy(logicalParams, 0, tmp, compilerParams.length - logicalParams.length, logicalParams.length);
 			logicalParams = tmp;
 		}
-
+		if (logicalParams.length == 0) {
+			return EMPTY_DESCRIPTORS;
+		}
 		IObjectDescriptor[] descriptors = new IObjectDescriptor[logicalParams.length];
 		for (int i = 0; i < logicalParams.length; i++) {
 			descriptors[i] = new ObjectDescriptor(logicalParams[i], annotations[i]);
diff --git a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/MethodRequestor.java b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/MethodRequestor.java
index 496fdac..dbd10f8 100644
--- a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/MethodRequestor.java
+++ b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/MethodRequestor.java
@@ -75,6 +75,9 @@
 	protected IObjectDescriptor[] calcDependentObjects() {
 		Type[] parameterTypes = location.getGenericParameterTypes();
 		Annotation[][] annotations = getParameterAnnotations();
+		if (parameterTypes.length == 0) {
+			return EMPTY_DESCRIPTORS;
+		}
 		IObjectDescriptor[] descriptors = new IObjectDescriptor[parameterTypes.length];
 		for (int i = 0; i < parameterTypes.length; i++) {
 			descriptors[i] = new ObjectDescriptor(parameterTypes[i], annotations[i]);
diff --git a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/Requestor.java b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/Requestor.java
index 519e3e3..96fce16 100644
--- a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/Requestor.java
+++ b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/Requestor.java
@@ -30,6 +30,7 @@
 
 	private static final Map<AnnotatedElement, IObjectDescriptor[]> descriptorCache = Collections
 			.synchronizedMap(new WeakHashMap<>());
+	protected static final IObjectDescriptor[] EMPTY_DESCRIPTORS = new IObjectDescriptor[0];
 
 	/** The request location; may be null */
 	final protected L location;
@@ -48,6 +49,7 @@
 
 	private IObjectDescriptor[] objectDescriptors;
 
+	/* @NonNull */
 	protected abstract IObjectDescriptor[] calcDependentObjects();
 
 	public Requestor(L location, IInjector injector, PrimaryObjectSupplier primarySupplier, PrimaryObjectSupplier tempSupplier, Object requestingObject, boolean track) {