Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ArrayTest.java15
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java24
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java7
3 files changed, 45 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ArrayTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ArrayTest.java
new file mode 100644
index 000000000..e4ce55f12
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ArrayTest.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.tests.bundles;
+
+public class ArrayTest {
+
+}
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 afbb7b2df..acedfe46e 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
@@ -1346,6 +1346,30 @@ public class ClassLoadingBundleTests extends AbstractBundleTests {
}
}
+ public void testArrayTypeLoad() {
+ doTestArrayTypeLoad("[B"); //$NON-NLS-1$
+ doTestArrayTypeLoad("[C"); //$NON-NLS-1$
+ doTestArrayTypeLoad("[D"); //$NON-NLS-1$
+ doTestArrayTypeLoad("[F"); //$NON-NLS-1$
+ doTestArrayTypeLoad("[I"); //$NON-NLS-1$
+ doTestArrayTypeLoad("[J"); //$NON-NLS-1$
+ doTestArrayTypeLoad("[S"); //$NON-NLS-1$
+ doTestArrayTypeLoad("[Z"); //$NON-NLS-1$
+ doTestArrayTypeLoad("[Lorg.eclipse.osgi.tests.bundles.ArrayTest;"); //$NON-NLS-1$
+ doTestArrayTypeLoad("[[D"); //$NON-NLS-1$
+ doTestArrayTypeLoad("[[Lorg.eclipse.osgi.tests.bundles.ArrayTest;"); //$NON-NLS-1$
+ }
+
+ private void doTestArrayTypeLoad(String name) {
+ try {
+ Class arrayType = OSGiTestsActivator.getContext().getBundle().loadClass(name);
+ assertNotNull("Null class", arrayType); //$NON-NLS-1$
+ assertTrue("Class is not an array: " + arrayType, arrayType.isArray()); //$NON-NLS-1$
+ } catch (ClassNotFoundException e) {
+ fail("Unexpected exception", e); //$NON-NLS-1$
+ }
+ }
+
private String readURL(URL url) {
StringBuffer sb = new StringBuffer();
try {
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java
index c1f63f472..ae867f25f 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java
@@ -318,7 +318,12 @@ public class BundleLoader implements ClassLoaderDelegate {
* @exception java.lang.ClassNotFoundException if the class definition was not found.
*/
final public Class loadClass(String name) throws ClassNotFoundException {
- return createClassLoader().loadClass(name);
+ BundleClassLoader bcl = createClassLoader();
+ // The instanceof check here is just to be safe. The javadoc contract stated in BundleClassLoader
+ // mandate that BundleClassLoaders be an instance of ClassLoader.
+ if (name.length() > 0 && name.charAt(0) == '[' && bcl instanceof ClassLoader)
+ return Class.forName(name, false, (ClassLoader) bcl);
+ return bcl.loadClass(name);
}
/**

Back to the top