I propose the attached patch which moves the native method in java.lang.reflect.Array to a new VMArray class, as per PR#22923.
Changelog:
2006-03-18 Andrew John Hughes <[EMAIL PROTECTED]>
* doc/vmintegration.texinfo:
Updated to include VMArray.
* include/Makefile.am:
Replace java_lang_reflect_Array.h with
java_lang_reflect_VMArray.h
* include/java_lang_reflect_VMArray.h:
New autogenerated header.
* include/java_lang_reflect_Array.h:
Removed.
* java/lang/reflect/Array.java:
(newInstance(Class,int)): Calls VMArray.
(createMultiArray(Class,int[],int)): Likewise.
(createObjectArray(Class,int)): Removed.
* native/jni/java-lang/Makefile.am:
Replaced java_lang_reflect_Array.c with
java_lang_reflect_VMArray.c
* native/jni/java-lang/java_lang_reflect_VMArray.c:
Renamed from java_lang_reflect_Array.c.
* vm/reference/java/lang/reflect/VMArray.java:
(createObjectArray(Class,int)): Native method moved
from java.lang.reflect.Array.
--
Andrew :-)
Please avoid sending me Microsoft Office (e.g. Word, PowerPoint)
attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
If you use Microsoft Office, support movement towards the end of vendor
lock-in:
http://opendocumentfellowship.org/petition/
"Value your freedom, or you will lose it, teaches history.
`Don't bother us with politics' respond those who don't want to learn."
-- Richard Stallman
Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
Index: doc/vmintegration.texinfo
===================================================================
RCS file: /cvsroot/classpath/classpath/doc/vmintegration.texinfo,v
retrieving revision 1.22
diff -u -3 -p -u -r1.22 vmintegration.texinfo
--- doc/vmintegration.texinfo 24 Feb 2006 12:49:44 -0000 1.22
+++ doc/vmintegration.texinfo 19 Mar 2006 00:49:46 -0000
@@ -200,6 +200,7 @@ implementation.
* java.nio::
* java.nio.channels::
* gnu.java.nio::
+* java.lang.reflect::
* Classpath Callbacks::
@end menu
@@ -1111,7 +1112,7 @@ in a @code{FileInputStream}.
in a @code{FileOutputStream}.
@end itemize
[EMAIL PROTECTED] gnu.java.nio, Classpath Callbacks, java.nio.channels, Classpath Hooks
[EMAIL PROTECTED] gnu.java.nio, java.lang.reflect, java.nio.channels, Classpath Hooks
@section gnu.java.nio
The @code{gnu.java.nio} class provides Classpath implementations of the
@@ -1142,7 +1143,25 @@ operation to be performed. This is repr
@code{native} method, @code{select(int[],int[],int[],long)}, and a default
implementation of this is provided.
[EMAIL PROTECTED] Classpath Callbacks, , gnu.java.nio, Classpath Hooks
[EMAIL PROTECTED] java.lang.reflect, Classpath Callbacks, gnu.java.nio, Classpath Hooks
[EMAIL PROTECTED] @code{java.lang.reflect}
[EMAIL PROTECTED] provides the interface to Java's reflection
+facilities. Via reflection, programmers can obtain type information about
+a particular instance at runtime or dynamically create new instances.
+
[EMAIL PROTECTED]
+* java.lang.reflect.VMArray::
[EMAIL PROTECTED] menu
+
[EMAIL PROTECTED] java.lang.reflect.VMArray,,,java.lang.reflect
[EMAIL PROTECTED] @code{java.lang.reflect.VMArray}
+
+The @code{VMArray} class provides a hook, @code{createObjectArray},
+which the VM uses to generate a new non-primitive array of a
+particular class and size. The default implementation simply passes
+the job down to the standard JNI function, @code{NewObjectArray}.
+
[EMAIL PROTECTED] Classpath Callbacks, , java.lang.reflect, Classpath Hooks
Some of the classes you implement for the VM will need to call back to
package-private methods in Classpath:
Index: include/Makefile.am
===================================================================
RCS file: /cvsroot/classpath/classpath/include/Makefile.am,v
retrieving revision 1.53
diff -u -3 -p -u -r1.53 Makefile.am
--- include/Makefile.am 13 Feb 2006 16:12:53 -0000 1.53
+++ include/Makefile.am 19 Mar 2006 00:49:48 -0000
@@ -132,7 +132,7 @@ $(top_srcdir)/include/java_lang_VMFloat.
$(top_srcdir)/include/java_lang_VMMath.h \
$(top_srcdir)/include/java_lang_VMProcess.h \
$(top_srcdir)/include/java_lang_VMSystem.h \
-$(top_srcdir)/include/java_lang_reflect_Array.h \
+$(top_srcdir)/include/java_lang_reflect_VMArray.h \
$(top_srcdir)/include/java_net_VMInetAddress.h \
$(top_srcdir)/include/java_net_VMNetworkInterface.h \
$(top_srcdir)/include/java_nio_VMDirectByteBuffer.h \
@@ -188,8 +188,8 @@ $(top_srcdir)/include/java_lang_VMProces
$(JAVAH) -o $@ java.lang.VMProcess
$(top_srcdir)/include/java_lang_VMSystem.h: $(top_srcdir)/vm/reference/java/lang/VMSystem.java
$(JAVAH) -o $@ java.lang.VMSystem
-$(top_srcdir)/include/java_lang_reflect_Array.h: $(top_srcdir)/java/lang/reflect/Array.java
- $(JAVAH) -o $@ java.lang.reflect.Array
+$(top_srcdir)/include/java_lang_reflect_VMArray.h: $(top_srcdir)/vm/reference/java/lang/reflect/VMArray.java
+ $(JAVAH) -o $@ java.lang.reflect.VMArray
$(top_srcdir)/include/java_net_VMInetAddress.h: $(top_srcdir)/vm/reference/java/net/VMInetAddress.java
$(JAVAH) -o $@ java.net.VMInetAddress
$(top_srcdir)/include/java_net_VMNetworkInterface.h: $(top_srcdir)/vm/reference/java/net/VMNetworkInterface.java
Index: include/java_lang_reflect_Array.h
===================================================================
RCS file: include/java_lang_reflect_Array.h
diff -N include/java_lang_reflect_Array.h
--- include/java_lang_reflect_Array.h 28 May 2004 17:27:55 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-
-#ifndef __java_lang_reflect_Array__
-#define __java_lang_reflect_Array__
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-JNIEXPORT jobject JNICALL Java_java_lang_reflect_Array_createObjectArray (JNIEnv *env, jclass, jclass, jint);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __java_lang_reflect_Array__ */
Index: include/java_lang_reflect_VMArray.h
===================================================================
RCS file: include/java_lang_reflect_VMArray.h
diff -N include/java_lang_reflect_VMArray.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/java_lang_reflect_VMArray.h 19 Mar 2006 00:49:50 -0000
@@ -0,0 +1,19 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __java_lang_reflect_VMArray__
+#define __java_lang_reflect_VMArray__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMArray_createObjectArray (JNIEnv *env, jclass, jclass, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __java_lang_reflect_VMArray__ */
Index: java/lang/reflect/Array.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/reflect/Array.java,v
retrieving revision 1.14
diff -u -3 -p -u -r1.14 Array.java
--- java/lang/reflect/Array.java 2 Jul 2005 20:32:39 -0000 1.14
+++ java/lang/reflect/Array.java 19 Mar 2006 00:49:51 -0000
@@ -38,8 +38,6 @@ exception statement from your version. *
package java.lang.reflect;
-import gnu.classpath.Configuration;
-
/**
* Array holds static helper functions that allow you to create and
* manipulate arrays by reflection. Operations know how to perform widening
@@ -78,13 +76,6 @@ import gnu.classpath.Configuration;
*/
public final class Array
{
- static
- {
- if (Configuration.INIT_LOAD_LIBRARY)
- {
- System.loadLibrary("javalangreflect");
- }
- }
/**
* This class is uninstantiable.
@@ -107,7 +98,7 @@ public final class Array
public static Object newInstance(Class componentType, int length)
{
if (! componentType.isPrimitive())
- return createObjectArray(componentType, length);
+ return VMArray.createObjectArray(componentType, length);
if (componentType == boolean.class)
return new boolean[length];
if (componentType == byte.class)
@@ -653,7 +644,7 @@ public final class Array
Object toAdd = createMultiArray(type, dimensions, index - 1);
Class thisType = toAdd.getClass();
Object[] retval
- = (Object[]) createObjectArray(thisType, dimensions[index]);
+ = (Object[]) VMArray.createObjectArray(thisType, dimensions[index]);
if (dimensions[index] > 0)
retval[0] = toAdd;
int i = dimensions[index];
@@ -662,14 +653,4 @@ public final class Array
return retval;
}
- /**
- * Dynamically create an array of objects.
- *
- * @param type guaranteed to be a valid object type
- * @param dim the length of the array
- * @return the new array
- * @throws NegativeArraySizeException if dim is negative
- * @throws OutOfMemoryError if memory allocation fails
- */
- private static native Object createObjectArray(Class type, int dim);
}
Index: native/jni/java-lang/Makefile.am
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-lang/Makefile.am,v
retrieving revision 1.16
diff -u -3 -p -u -r1.16 Makefile.am
--- native/jni/java-lang/Makefile.am 10 Mar 2006 01:36:10 -0000 1.16
+++ native/jni/java-lang/Makefile.am 19 Mar 2006 00:49:54 -0000
@@ -9,7 +9,7 @@ libjavalang_la_SOURCES = java_lang_VMSys
libjavalang_la_LIBADD = $(wildcard $(top_builddir)/native/fdlibm/*.lo) \
$(top_builddir)/native/jni/classpath/jcl.lo
-libjavalangreflect_la_SOURCES = java_lang_reflect_Array.c
+libjavalangreflect_la_SOURCES = java_lang_reflect_VMArray.c
AM_LDFLAGS = @CLASSPATH_MODULE@
AM_CPPFLAGS = @CLASSPATH_INCLUDES@ -I$(top_srcdir)/native/fdlibm
Index: native/jni/java-lang/java_lang_reflect_Array.c
===================================================================
RCS file: native/jni/java-lang/java_lang_reflect_Array.c
diff -N native/jni/java-lang/java_lang_reflect_Array.c
--- native/jni/java-lang/java_lang_reflect_Array.c 5 Oct 2005 19:19:00 -0000 1.11
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,62 +0,0 @@
-/* java.lang.reflect.Array native functions
- Copyright (C) 1998, 2004 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath 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 for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-/*
- * java.lang.reflect.Array native functions.
- * Author: John Keiser
- * Version: 1.1.0
- * Date: 2 Jun 1998
- */
-
-#include <config.h>
-#include <stddef.h>
-
-#include "java_lang_reflect_Array.h"
-
-/*
- * Class: java_lang_reflect_Array
- * Method: createObjectArray
- * Signature: (Ljava/lang/Class;I)Ljava/lang/Object;
- */
-JNIEXPORT jobject JNICALL
-Java_java_lang_reflect_Array_createObjectArray
- (JNIEnv * env,
- jclass thisClass __attribute__ ((__unused__)),
- jclass arrayType, jint arrayLength)
-{
- return (jobject) (*env)->NewObjectArray (env, arrayLength, arrayType, NULL);
-}
Index: native/jni/java-lang/java_lang_reflect_VMArray.c
===================================================================
RCS file: native/jni/java-lang/java_lang_reflect_VMArray.c
diff -N native/jni/java-lang/java_lang_reflect_VMArray.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ native/jni/java-lang/java_lang_reflect_VMArray.c 19 Mar 2006 00:49:54 -0000
@@ -0,0 +1,62 @@
+/* java.lang.reflect.Array native functions
+ Copyright (C) 1998, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+/*
+ * java.lang.reflect.Array native functions.
+ * Author: John Keiser
+ * Version: 1.1.0
+ * Date: 2 Jun 1998
+ */
+
+#include <config.h>
+#include <stddef.h>
+
+#include "java_lang_reflect_VMArray.h"
+
+/*
+ * Class: java_lang_reflect_Array
+ * Method: createObjectArray
+ * Signature: (Ljava/lang/Class;I)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL
+Java_java_lang_reflect_VMArray_createObjectArray
+ (JNIEnv * env,
+ jclass thisClass __attribute__ ((__unused__)),
+ jclass arrayType, jint arrayLength)
+{
+ return (jobject) (*env)->NewObjectArray (env, arrayLength, arrayType, NULL);
+}
Index: vm/reference/java/lang/reflect/VMArray.java
===================================================================
RCS file: vm/reference/java/lang/reflect/VMArray.java
diff -N vm/reference/java/lang/reflect/VMArray.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ vm/reference/java/lang/reflect/VMArray.java 19 Mar 2006 00:49:54 -0000
@@ -0,0 +1,65 @@
+/* java.lang.reflect.VMArray - VM class for array manipulation by reflection.
+ Copyright (C) 1998, 1999, 2001, 2003, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+import gnu.classpath.Configuration;
+
+class VMArray
+{
+
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ {
+ System.loadLibrary("javalangreflect");
+ }
+ }
+
+ /**
+ * Dynamically create an array of objects.
+ *
+ * @param type guaranteed to be a valid object type
+ * @param dim the length of the array
+ * @return the new array
+ * @throws NegativeArraySizeException if dim is negative
+ * @throws OutOfMemoryError if memory allocation fails
+ */
+ static native Object createObjectArray(Class type, int dim);
+
+}
signature.asc
Description: This is a digitally signed message part
