diff options
author | Andrew Haley <aph@redhat.com> | 2005-04-06 22:30:01 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2005-04-06 22:30:01 +0000 |
commit | 58bf803e6c5f7e16989cf8b50b07e9c27264e92a (patch) | |
tree | 28d3dbccadbb283006a3f5170554d3ca021fd926 /libjava | |
parent | 3425638af52c359b893547b9dcde5cccd1bb67ac (diff) | |
download | gcc-58bf803e6c5f7e16989cf8b50b07e9c27264e92a.zip gcc-58bf803e6c5f7e16989cf8b50b07e9c27264e92a.tar.gz gcc-58bf803e6c5f7e16989cf8b50b07e9c27264e92a.tar.bz2 |
bytearray.java: New file.
2005-04-06 Andrew Haley <aph@redhat.com>
* testsuite/libjava.lang/bytearray.java: New file.
* testsuite/libjava.lang/bytearray.out: New file.
* java/lang/ClassLoader.java (loadClassFromSig): Declare
(loadClass): Use it.
* java/lang/natClassLoader.cc (loadClassFromSig): New method.
From-SVN: r97756
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 8 | ||||
-rw-r--r-- | libjava/java/lang/ClassLoader.java | 42 | ||||
-rw-r--r-- | libjava/java/lang/natClassLoader.cc | 11 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/bytearray.java | 10 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/bytearray.out | 2 |
5 files changed, 57 insertions, 16 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index a0d7cc1..298bfec 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,11 @@ +2005-04-06 Andrew Haley <aph@redhat.com> + + * testsuite/libjava.lang/bytearray.java: New file. + * testsuite/libjava.lang/bytearray.out: New file. + * java/lang/ClassLoader.java (loadClassFromSig): Declare + (loadClass): Use it. + * java/lang/natClassLoader.cc (loadClassFromSig): New method. + 2005-04-06 Mohan Embar <gnustuff@thisiscool.com> * Makefile.am ($(db_name)): Add $(EXEEXT) suffix to diff --git a/libjava/java/lang/ClassLoader.java b/libjava/java/lang/ClassLoader.java index db68e60..5737dda 100644 --- a/libjava/java/lang/ClassLoader.java +++ b/libjava/java/lang/ClassLoader.java @@ -260,6 +260,9 @@ public abstract class ClassLoader return loadClass(name, false); } + private native Class loadClassFromSig(String name) + throws ClassNotFoundException; + /** * Load a class using this ClassLoader or its parent, possibly resolving * it as well using <code>resolveClass()</code>. It first tries to find @@ -283,29 +286,36 @@ public abstract class ClassLoader protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { - // Have we already loaded this class? - Class c = findLoadedClass(name); - if (c == null) + // Arrays are handled specially. + Class c; + if (name.charAt(0) == '[') + c = loadClassFromSig(name); + else { - // Can the class be loaded by a parent? - try + // Have we already loaded this class? + c = findLoadedClass(name); + if (c == null) { - if (parent == null) + // Can the class be loaded by a parent? + try { - c = VMClassLoader.loadClass(name, resolve); - if (c != null) - return c; + if (parent == null) + { + c = VMClassLoader.loadClass(name, resolve); + if (c != null) + return c; + } + else + { + return parent.loadClass(name, resolve); + } } - else + catch (ClassNotFoundException e) { - return parent.loadClass(name, resolve); } + // Still not found, we have to do it ourself. + c = findClass(name); } - catch (ClassNotFoundException e) - { - } - // Still not found, we have to do it ourself. - c = findClass(name); } if (resolve) resolveClass(c); diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc index b8d87c6..ed43b7a 100644 --- a/libjava/java/lang/natClassLoader.cc +++ b/libjava/java/lang/natClassLoader.cc @@ -65,6 +65,17 @@ static int bootstrap_index; +jclass +java::lang::ClassLoader::loadClassFromSig(jstring name) +{ + int len = _Jv_GetStringUTFLength (name); + char sig[len + 1]; + _Jv_GetStringUTFRegion (name, 0, name->length(), sig); + return _Jv_FindClassFromSignature(sig, this); +} + + + // This tries to find a class in our built-in cache. This cache is // used only for classes which are linked in to the executable or // loaded via dlopen(). diff --git a/libjava/testsuite/libjava.lang/bytearray.java b/libjava/testsuite/libjava.lang/bytearray.java new file mode 100644 index 0000000..88fdc9af --- /dev/null +++ b/libjava/testsuite/libjava.lang/bytearray.java @@ -0,0 +1,10 @@ +public class bytearray +{ + public static void main (String[] argv) throws Throwable { + Class c = Class.forName ("[Ljava.lang.String;"); + c = Class.forName ("[B"); + System.out.println (c); + c = ClassLoader.getSystemClassLoader().loadClass ("[[Ljava.lang.String;"); + System.out.println (c); + } +} diff --git a/libjava/testsuite/libjava.lang/bytearray.out b/libjava/testsuite/libjava.lang/bytearray.out new file mode 100644 index 0000000..520d568 --- /dev/null +++ b/libjava/testsuite/libjava.lang/bytearray.out @@ -0,0 +1,2 @@ +class [B +class [[Ljava.lang.String; |