* src/classes/gnu: Renamed to src/classes/gnuclasspath.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Wed, 14 May 2008 14:24:55 +0000 (16:24 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Wed, 14 May 2008 14:24:55 +0000 (16:24 +0200)
--HG--
rename : src/classes/gnu/gnu/classpath/VMStackWalker.java => src/classes/gnuclasspath/gnu/classpath/VMStackWalker.java
rename : src/classes/gnu/gnu/classpath/VMSystemProperties.java => src/classes/gnuclasspath/gnu/classpath/VMSystemProperties.java
rename : src/classes/gnu/gnu/java/lang/CPStringBuilder.java => src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java
rename : src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java => src/classes/gnuclasspath/gnu/java/lang/VMCPStringBuilder.java
rename : src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java => src/classes/gnuclasspath/gnu/java/lang/management/VMMemoryMXBeanImpl.java
rename : src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java => src/classes/gnuclasspath/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
rename : src/classes/gnu/java/lang/VMClassLoader.java => src/classes/gnuclasspath/java/lang/VMClassLoader.java
rename : src/classes/gnu/java/lang/VMString.java => src/classes/gnuclasspath/java/lang/VMString.java
rename : src/classes/gnu/java/lang/VMThread.java => src/classes/gnuclasspath/java/lang/VMThread.java
rename : src/classes/gnu/java/lang/reflect/Constructor.java => src/classes/gnuclasspath/java/lang/reflect/Constructor.java
rename : src/classes/gnu/java/lang/reflect/Field.java => src/classes/gnuclasspath/java/lang/reflect/Field.java
rename : src/classes/gnu/java/lang/reflect/Method.java => src/classes/gnuclasspath/java/lang/reflect/Method.java
rename : src/classes/gnu/java/lang/reflect/Modifier.java => src/classes/gnuclasspath/java/lang/reflect/Modifier.java
rename : src/classes/gnu/java/lang/reflect/VMConstructor.java => src/classes/gnuclasspath/java/lang/reflect/VMConstructor.java
rename : src/classes/gnu/java/lang/reflect/VMField.java => src/classes/gnuclasspath/java/lang/reflect/VMField.java
rename : src/classes/gnu/java/lang/reflect/VMMethod.java => src/classes/gnuclasspath/java/lang/reflect/VMMethod.java
rename : src/classes/gnu/java/security/VMAccessController.java => src/classes/gnuclasspath/java/security/VMAccessController.java
rename : src/classes/gnu/sun/misc/Unsafe.java => src/classes/gnuclasspath/sun/misc/Unsafe.java
rename : src/classes/gnu/sun/reflect/ConstantPool.java => src/classes/gnuclasspath/sun/reflect/ConstantPool.java
rename : src/classes/gnu/sun/reflect/annotation/AnnotationParser.java => src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java
rename : src/classes/gnu/sun/reflect/annotation/AnnotationType.java => src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java
rename : src/classes/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java => src/classes/gnuclasspath/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java
rename : src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java => src/classes/gnuclasspath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java
rename : src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java => src/classes/gnuclasspath/sun/reflect/annotation/ExceptionProxy.java
rename : src/classes/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java => src/classes/gnuclasspath/sun/reflect/annotation/TypeNotPresentExceptionProxy.java

51 files changed:
src/classes/Makefile.am
src/classes/gnu/gnu/classpath/VMStackWalker.java [deleted file]
src/classes/gnu/gnu/classpath/VMSystemProperties.java [deleted file]
src/classes/gnu/gnu/java/lang/CPStringBuilder.java [deleted file]
src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java [deleted file]
src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java [deleted file]
src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java [deleted file]
src/classes/gnu/java/lang/VMClassLoader.java [deleted file]
src/classes/gnu/java/lang/VMString.java [deleted file]
src/classes/gnu/java/lang/VMThread.java [deleted file]
src/classes/gnu/java/lang/reflect/Constructor.java [deleted file]
src/classes/gnu/java/lang/reflect/Field.java [deleted file]
src/classes/gnu/java/lang/reflect/Method.java [deleted file]
src/classes/gnu/java/lang/reflect/Modifier.java [deleted file]
src/classes/gnu/java/lang/reflect/VMConstructor.java [deleted file]
src/classes/gnu/java/lang/reflect/VMField.java [deleted file]
src/classes/gnu/java/lang/reflect/VMMethod.java [deleted file]
src/classes/gnu/java/security/VMAccessController.java [deleted file]
src/classes/gnu/sun/misc/Unsafe.java [deleted file]
src/classes/gnu/sun/reflect/ConstantPool.java [deleted file]
src/classes/gnu/sun/reflect/annotation/AnnotationParser.java [deleted file]
src/classes/gnu/sun/reflect/annotation/AnnotationType.java [deleted file]
src/classes/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java [deleted file]
src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java [deleted file]
src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java [deleted file]
src/classes/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java [deleted file]
src/classes/gnuclasspath/gnu/classpath/VMStackWalker.java [new file with mode: 0644]
src/classes/gnuclasspath/gnu/classpath/VMSystemProperties.java [new file with mode: 0644]
src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java [new file with mode: 0644]
src/classes/gnuclasspath/gnu/java/lang/VMCPStringBuilder.java [new file with mode: 0644]
src/classes/gnuclasspath/gnu/java/lang/management/VMMemoryMXBeanImpl.java [new file with mode: 0644]
src/classes/gnuclasspath/gnu/java/lang/management/VMRuntimeMXBeanImpl.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/VMClassLoader.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/VMString.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/VMThread.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/Constructor.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/Field.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/Method.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/Modifier.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/VMConstructor.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/VMField.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/VMMethod.java [new file with mode: 0644]
src/classes/gnuclasspath/java/security/VMAccessController.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/misc/Unsafe.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/ConstantPool.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/annotation/ExceptionProxy.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/annotation/TypeNotPresentExceptionProxy.java [new file with mode: 0644]

index 526ccb4fb51c5fe831c33d2796ec512649bf1146..9ddec49705cbcf2cbc404f6813ea5087afdc1507 100644 (file)
@@ -1,4 +1,4 @@
-## src/lib/Makefile.am
+## src/classes/Makefile.am
 ##
 ## Copyright (C) 1996-2005, 2006, 2007, 2008
 ## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
@@ -29,38 +29,38 @@ EXTRA_DIST = \
 CLEANFILES = vm.zip
 
 VM_JAVA_FILES_GNU_CLASSPATH = \
-       $(top_srcdir)/src/classes/gnu/gnu/classpath/VMStackWalker.java \
-       $(top_srcdir)/src/classes/gnu/gnu/classpath/VMSystemProperties.java \
-       $(top_srcdir)/src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java \
-       $(top_srcdir)/src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java \
-       $(top_srcdir)/src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/VMClassLoader.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/VMString.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/VMThread.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/VMConstructor.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/VMField.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/VMMethod.java \
-       $(top_srcdir)/src/classes/gnu/java/security/VMAccessController.java \
-       $(top_srcdir)/src/classes/gnu/sun/misc/Unsafe.java
+       $(top_srcdir)/src/classes/gnuclasspath/gnu/classpath/VMStackWalker.java \
+       $(top_srcdir)/src/classes/gnuclasspath/gnu/classpath/VMSystemProperties.java \
+       $(top_srcdir)/src/classes/gnuclasspath/gnu/java/lang/VMCPStringBuilder.java \
+       $(top_srcdir)/src/classes/gnuclasspath/gnu/java/lang/management/VMMemoryMXBeanImpl.java \
+       $(top_srcdir)/src/classes/gnuclasspath/gnu/java/lang/management/VMRuntimeMXBeanImpl.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/VMClassLoader.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/VMString.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/VMThread.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/VMConstructor.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/VMField.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/VMMethod.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/security/VMAccessController.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/misc/Unsafe.java
 
 # Remove these files when a new GNU Classpath release (> 0.97.1) is
 # available.
 
 VM_JAVA_FILES_GNU_CLASSPATH += \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/Constructor.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/Field.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/Method.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/Modifier.java \
-       $(top_srcdir)/src/classes/gnu/gnu/java/lang/CPStringBuilder.java
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/Constructor.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/Field.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/Method.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/Modifier.java \
+       $(top_srcdir)/src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java
 
 VM_JAVA_FILES_GNU_CLASSPATH_ANNOTATIONS = \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/ConstantPool.java \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/annotation/AnnotationType.java \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/annotation/AnnotationParser.java
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/ConstantPool.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/annotation/ExceptionProxy.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/annotation/TypeNotPresentExceptionProxy.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java
 
 VM_JAVA_FILES_CLDC1_1 = \
        $(top_srcdir)/src/classes/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java
diff --git a/src/classes/gnu/gnu/classpath/VMStackWalker.java b/src/classes/gnu/gnu/classpath/VMStackWalker.java
deleted file mode 100644 (file)
index 434edd2..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/* VMStackWalker.java -- Reference implementation of VM hooks for stack access
-   Copyright (C) 2005 Free Software Foundation
-
-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 gnu.classpath;
-
-/**
- * This class provides access to the classes on the Java stack
- * for reflection and security purposes.
- *
- * <p>
- * This class is only available to privileged code (i.e., code loaded
- * by the bootstrap loader).
- *
- * @author John Keiser
- * @author Eric Blake <ebb9@email.byu.edu>
- * @author Archie Cobbs
- */
-public final class VMStackWalker
-{
-  /**
-   * Get a list of all the classes currently executing methods on the
-   * Java stack. <code>getClassContext()[0]</code> is the class associated
-   * with the currently executing method, i.e., the method that called
-   * <code>VMStackWalker.getClassContext()</code> (possibly through
-   * reflection). So you may need to pop off these stack frames from
-   * the top of the stack:
-   * <ul>
-   * <li><code>VMStackWalker.getClassContext()</code>
-   * <li><code>Method.invoke()</code>
-   * </ul>
-   *
-   * @return an array of the declaring classes of each stack frame
-   */
-  public static native Class[] getClassContext();
-
-  /**
-   * Get the class associated with the method invoking the method
-   * invoking this method, or <code>null</code> if the stack is not
-   * that deep (e.g., invoked via JNI invocation API). This method
-   * is an optimization for the expression <code>getClassContext()[1]</code>
-   * and should return the same result.
-   *
-   * <p>
-   * VM implementers are encouraged to provide a more efficient
-   * version of this method.
-   */
-//    public static Class getCallingClass()
-//    {
-//      Class[] ctx = getClassContext();
-//      if (ctx.length < 3)
-//        return null;
-//      return ctx[2];
-//    }
-  public static native Class getCallingClass();
-
-  /**
-   * Get the class loader associated with the Class returned by
-   * <code>getCallingClass()</code>, or <code>null</code> if no such class
-   * exists or it is the boot loader. This method is an optimization for the
-   * expression <code>VMStackWalker.getClassLoader(getClassContext()[1])</code>
-   * and should return the same result.
-   *
-   * <p>
-   * VM implementers are encouraged to provide a more efficient
-   * version of this method.
-   */
-//    public static ClassLoader getCallingClassLoader()
-//    {
-//      Class[] ctx = getClassContext();
-//      if (ctx.length < 3)
-//        return null;
-//      return getClassLoader(ctx[2]);
-//    }
-  public static native ClassLoader getCallingClassLoader();
-
-
-  /**
-   * Retrieve the class's ClassLoader, or <code>null</code> if loaded
-   * by the bootstrap loader. I.e., this should return the same thing
-   * as {@link java.lang.VMClass#getClassLoader}. This duplicate version
-   * is here to work around access permissions.
-   */
-//    public static native ClassLoader getClassLoader(Class cl);
-
-  /**
-   * Walk up the stack and return the first non-null class loader.
-   * If there aren't any non-null class loaders on the stack, return null.
-   */
-//   public static ClassLoader firstNonNullClassLoader()
-//   {
-//     Class[] stack = getClassContext();
-//     for (int i = 0; i < stack.length; i++)
-//       {
-//         ClassLoader loader = getClassLoader(stack[i]);
-//         if (loader != null)
-//           return loader;
-//       }
-//     return null;
-//   }
-    public static native ClassLoader firstNonNullClassLoader();
-}
diff --git a/src/classes/gnu/gnu/classpath/VMSystemProperties.java b/src/classes/gnu/gnu/classpath/VMSystemProperties.java
deleted file mode 100644 (file)
index 287a933..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/* VMSystemProperties.java -- Allow the VM to set System properties.
-   Copyright (C) 2004 Free Software Foundation
-
-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 gnu.classpath;
-
-import java.util.Properties;
-
-class VMSystemProperties
-{
-    /**
-     * Get the system properties. This is done here, instead of in System,
-     * because of the bootstrap sequence. Note that the native code should
-     * not try to use the Java I/O classes yet, as they rely on the properties
-     * already existing. The only safe method to use to insert these default
-     * system properties is {@link Properties#setProperty(String, String)}.
-     *
-     * <p>These properties MUST include:
-     * <dl>
-     * <dt>java.version         <dd>Java version number
-     * <dt>java.vendor          <dd>Java vendor specific string
-     * <dt>java.vendor.url      <dd>Java vendor URL
-     * <dt>java.home            <dd>Java installation directory
-     * <dt>java.vm.specification.version <dd>VM Spec version
-     * <dt>java.vm.specification.vendor  <dd>VM Spec vendor
-     * <dt>java.vm.specification.name    <dd>VM Spec name
-     * <dt>java.vm.version      <dd>VM implementation version
-     * <dt>java.vm.vendor       <dd>VM implementation vendor
-     * <dt>java.vm.name         <dd>VM implementation name
-     * <dt>java.specification.version    <dd>Java Runtime Environment version
-     * <dt>java.specification.vendor     <dd>Java Runtime Environment vendor
-     * <dt>java.specification.name       <dd>Java Runtime Environment name
-     * <dt>java.class.version   <dd>Java class version number
-     * <dt>java.class.path      <dd>Java classpath
-     * <dt>java.library.path    <dd>Path for finding Java libraries
-     * <dt>java.io.tmpdir       <dd>Default temp file path
-     * <dt>java.compiler        <dd>Name of JIT to use
-     * <dt>java.ext.dirs        <dd>Java extension path
-     * <dt>os.name              <dd>Operating System Name
-     * <dt>os.arch              <dd>Operating System Architecture
-     * <dt>os.version           <dd>Operating System Version
-     * <dt>file.separator       <dd>File separator ("/" on Unix)
-     * <dt>path.separator       <dd>Path separator (":" on Unix)
-     * <dt>line.separator       <dd>Line separator ("\n" on Unix)
-     * <dt>user.name            <dd>User account name
-     * <dt>user.home            <dd>User home directory
-     * <dt>user.dir             <dd>User's current working directory
-     * <dt>gnu.cpu.endian       <dd>"big" or "little"
-     * </dl>
-     *
-     * @param properties the Properties object to insert the system properties into
-     */
-    static native void preInit(Properties properties);
-
-    /**
-     * Here you get a chance to overwrite some of the properties set by
-     * the common SystemProperties code. For example, it might be
-     * a good idea to process the properties specified on the command
-     * line here.
-     */
-//     static void postInit(Properties properties)
-//     {
-//     }
-    static native void postInit(Properties properties);
-}
diff --git a/src/classes/gnu/gnu/java/lang/CPStringBuilder.java b/src/classes/gnu/gnu/java/lang/CPStringBuilder.java
deleted file mode 100644 (file)
index 978a204..0000000
+++ /dev/null
@@ -1,1084 +0,0 @@
-/* ClasspathStringBuffer.java -- Growable strings without locking or copying
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
-   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 gnu.java.lang;
-
-import java.io.Serializable;
-
-/**
- * This class is based on java.lang.AbstractStringBuffer but
- * without the copying of the string by toString.
- * If you modify this, please consider also modifying that code.
- * This code is not thread-safe; limit its use to internal use within
- * methods.
- */
-public final class CPStringBuilder
-  implements Serializable, CharSequence, Appendable
-{
-
-  /**
-   * Index of next available character (and thus the size of the current
-   * string contents).  Note that this has permissions set this way so that
-   * String can get the value.
-   *
-   * @serial the number of characters in the buffer
-   */
-  int count;
-
-  /**
-   * The buffer.  Note that this has permissions set this way so that String
-   * can get the value.
-   *
-   * @serial the buffer
-   */
-  char[] value;
-
-  /**
-   * The default capacity of a buffer.
-   */
-  private static final int DEFAULT_CAPACITY = 16;
-
-  /**
-   * Create a new CPStringBuilder with default capacity 16.
-   */
-  public CPStringBuilder()
-  {
-    this(DEFAULT_CAPACITY);
-  }
-
-  /**
-   * Create an empty <code>StringBuffer</code> with the specified initial
-   * capacity.
-   *
-   * @param capacity the initial capacity
-   * @throws NegativeArraySizeException if capacity is negative
-   */
-  public CPStringBuilder(int capacity)
-  {
-    value = new char[capacity];
-  }
-
-  /**
-   * Create a new <code>StringBuffer</code> with the characters in the
-   * specified <code>String</code>. Initial capacity will be the size of the
-   * String plus 16.
-   *
-   * @param str the <code>String</code> to convert
-   * @throws NullPointerException if str is null
-   */
-  public CPStringBuilder(String str)
-  {
-    count = str.length();
-    value = new char[count + DEFAULT_CAPACITY];
-    str.getChars(0, count, value, 0);
-  }
-
-  /**
-   * Create a new <code>StringBuffer</code> with the characters in the
-   * specified <code>CharSequence</code>. Initial capacity will be the
-   * length of the sequence plus 16; if the sequence reports a length
-   * less than or equal to 0, then the initial capacity will be 16.
-   *
-   * @param seq the initializing <code>CharSequence</code>
-   * @throws NullPointerException if str is null
-   * @since 1.5
-   */
-  public CPStringBuilder(CharSequence seq)
-  {
-    int len = seq.length();
-    count = len <= 0 ? 0 : len;
-    value = new char[count + DEFAULT_CAPACITY];
-    for (int i = 0; i < len; ++i)
-      value[i] = seq.charAt(i);
-  }
-
-  /**
-   * Increase the capacity of this <code>StringBuffer</code>. This will
-   * ensure that an expensive growing operation will not occur until
-   * <code>minimumCapacity</code> is reached. The buffer is grown to the
-   * larger of <code>minimumCapacity</code> and
-   * <code>capacity() * 2 + 2</code>, if it is not already large enough.
-   *
-   * @param minimumCapacity the new capacity
-   * @see #capacity()
-   */
-  public void ensureCapacity(int minimumCapacity)
-  {
-    ensureCapacity_unsynchronized(minimumCapacity);
-  }
-
-  /**
-   * Set the length of this StringBuffer. If the new length is greater than
-   * the current length, all the new characters are set to '\0'. If the new
-   * length is less than the current length, the first <code>newLength</code>
-   * characters of the old array will be preserved, and the remaining
-   * characters are truncated.
-   *
-   * @param newLength the new length
-   * @throws IndexOutOfBoundsException if the new length is negative
-   *         (while unspecified, this is a StringIndexOutOfBoundsException)
-   * @see #length()
-   */
-  public void setLength(int newLength)
-  {
-    if (newLength < 0)
-      throw new StringIndexOutOfBoundsException(newLength);
-
-    int valueLength = value.length;
-
-    /* Always call ensureCapacity_unsynchronized in order to preserve
-       copy-on-write semantics.  */
-    ensureCapacity_unsynchronized(newLength);
-
-    if (newLength < valueLength)
-      {
-        /* If the StringBuffer's value just grew, then we know that
-           value is newly allocated and the region between count and
-           newLength is filled with '\0'.  */
-       count = newLength;
-      }
-    else
-      {
-       /* The StringBuffer's value doesn't need to grow.  However,
-          we should clear out any cruft that may exist.  */
-       while (count < newLength)
-          value[count++] = '\0';
-      }
-  }
-
-  /**
-   * Get the character at the specified index.
-   *
-   * @param index the index of the character to get, starting at 0
-   * @return the character at the specified index
-   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
-   *         (while unspecified, this is a StringIndexOutOfBoundsException)
-   */
-  public char charAt(int index)
-  {
-    if (index < 0 || index >= count)
-      throw new StringIndexOutOfBoundsException(index);
-    return value[index];
-  }
-
-  /**
-   * Get the code point at the specified index.  This is like #charAt(int),
-   * but if the character is the start of a surrogate pair, and the
-   * following character completes the pair, then the corresponding
-   * supplementary code point is returned.
-   * @param index the index of the codepoint to get, starting at 0
-   * @return the codepoint at the specified index
-   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
-   * @since 1.5
-   */
-  public int codePointAt(int index)
-  {
-    return Character.codePointAt(value, index, count);
-  }
-
-  /**
-   * Get the code point before the specified index.  This is like
-   * #codePointAt(int), but checks the characters at <code>index-1</code> and
-   * <code>index-2</code> to see if they form a supplementary code point.
-   * @param index the index just past the codepoint to get, starting at 0
-   * @return the codepoint at the specified index
-   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
-   * @since 1.5
-   */
-  public int codePointBefore(int index)
-  {
-    // Character.codePointBefore() doesn't perform this check.  We
-    // could use the CharSequence overload, but this is just as easy.
-    if (index >= count)
-      throw new IndexOutOfBoundsException();
-    return Character.codePointBefore(value, index, 1);
-  }
-
-  /**
-   * Get the specified array of characters. <code>srcOffset - srcEnd</code>
-   * characters will be copied into the array you pass in.
-   *
-   * @param srcOffset the index to start copying from (inclusive)
-   * @param srcEnd the index to stop copying from (exclusive)
-   * @param dst the array to copy into
-   * @param dstOffset the index to start copying into
-   * @throws NullPointerException if dst is null
-   * @throws IndexOutOfBoundsException if any source or target indices are
-   *         out of range (while unspecified, source problems cause a
-   *         StringIndexOutOfBoundsException, and dest problems cause an
-   *         ArrayIndexOutOfBoundsException)
-   * @see System#arraycopy(Object, int, Object, int, int)
-   */
-  public void getChars(int srcOffset, int srcEnd,
-                      char[] dst, int dstOffset)
-  {
-    if (srcOffset < 0 || srcEnd > count || srcEnd < srcOffset)
-      throw new StringIndexOutOfBoundsException();
-    System.arraycopy(value, srcOffset, dst, dstOffset, srcEnd - srcOffset);
-  }
-
-  /**
-   * Set the character at the specified index.
-   *
-   * @param index the index of the character to set starting at 0
-   * @param ch the value to set that character to
-   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
-   *         (while unspecified, this is a StringIndexOutOfBoundsException)
-   */
-  public void setCharAt(int index, char ch)
-  {
-    if (index < 0 || index >= count)
-      throw new StringIndexOutOfBoundsException(index);
-    // Call ensureCapacity to enforce copy-on-write.
-    ensureCapacity_unsynchronized(count);
-    value[index] = ch;
-  }
-
-  /**
-   * Append the <code>String</code> value of the argument to this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param obj the <code>Object</code> to convert and append
-   * @return this <code>StringBuffer</code>
-   * @see String#valueOf(Object)
-   * @see #append(String)
-   */
-  public CPStringBuilder append(Object obj)
-  {
-    return append(String.valueOf(obj));
-  }
-
-  /**
-   * Append the <code>String</code> to this <code>StringBuffer</code>. If
-   * str is null, the String "null" is appended.
-   *
-   * @param str the <code>String</code> to append
-   * @return this <code>StringBuffer</code>
-   */
-  public CPStringBuilder append(String str)
-  {
-    if (str == null)
-      str = "null";
-    int len = str.length();
-    ensureCapacity_unsynchronized(count + len);
-    str.getChars(0, len, value, count);
-    count += len;
-    return this;
-  }
-
-  /**
-   * Append the <code>StringBuilder</code> value of the argument to this
-   * <code>StringBuilder</code>. This behaves the same as
-   * <code>append((Object) stringBuffer)</code>, except it is more efficient.
-   *
-   * @param stringBuffer the <code>StringBuilder</code> to convert and append
-   * @return this <code>StringBuilder</code>
-   * @see #append(Object)
-   */
-  public CPStringBuilder append(StringBuffer stringBuffer)
-  {
-    if (stringBuffer == null)
-      return append("null");
-    synchronized (stringBuffer)
-      {
-       int len = stringBuffer.length();
-       ensureCapacity(count + len);
-       stringBuffer.getChars(0, len, value, count);
-       count += len;
-      }
-    return this;
-  }
-
-  /**
-   * Append the <code>char</code> array to this <code>StringBuffer</code>.
-   * This is similar (but more efficient) than
-   * <code>append(new String(data))</code>, except in the case of null.
-   *
-   * @param data the <code>char[]</code> to append
-   * @return this <code>StringBuffer</code>
-   * @throws NullPointerException if <code>str</code> is <code>null</code>
-   * @see #append(char[], int, int)
-   */
-  public CPStringBuilder append(char[] data)
-  {
-    return append(data, 0, data.length);
-  }
-
-  /**
-   * Append part of the <code>char</code> array to this
-   * <code>StringBuffer</code>. This is similar (but more efficient) than
-   * <code>append(new String(data, offset, count))</code>, except in the case
-   * of null.
-   *
-   * @param data the <code>char[]</code> to append
-   * @param offset the start location in <code>str</code>
-   * @param count the number of characters to get from <code>str</code>
-   * @return this <code>StringBuffer</code>
-   * @throws NullPointerException if <code>str</code> is <code>null</code>
-   * @throws IndexOutOfBoundsException if offset or count is out of range
-   *         (while unspecified, this is a StringIndexOutOfBoundsException)
-   */
-  public CPStringBuilder append(char[] data, int offset, int count)
-  {
-    if (offset < 0 || count < 0 || offset > data.length - count)
-      throw new StringIndexOutOfBoundsException();
-    ensureCapacity_unsynchronized(this.count + count);
-    System.arraycopy(data, offset, value, this.count, count);
-    this.count += count;
-    return this;
-  }
-
-  /**
-   * Append the <code>String</code> value of the argument to this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param bool the <code>boolean</code> to convert and append
-   * @return this <code>StringBuffer</code>
-   * @see String#valueOf(boolean)
-   */
-  public CPStringBuilder append(boolean bool)
-  {
-    return append(bool ? "true" : "false");
-  }
-
-  /**
-   * Append the <code>char</code> to this <code>StringBuffer</code>.
-   *
-   * @param ch the <code>char</code> to append
-   * @return this <code>StringBuffer</code>
-   */
-  public CPStringBuilder append(char ch)
-  {
-    ensureCapacity_unsynchronized(count + 1);
-    value[count++] = ch;
-    return this;
-  }
-
-  /**
-   * Append the characters in the <code>CharSequence</code> to this
-   * buffer.
-   *
-   * @param seq the <code>CharSequence</code> providing the characters
-   * @return this <code>StringBuffer</code>
-   * @since 1.5
-   */
-  public CPStringBuilder append(CharSequence seq)
-  {
-    return append(seq, 0, seq.length());
-  }
-
-  /**
-   * Append some characters from the <code>CharSequence</code> to this
-   * buffer.  If the argument is null, the four characters "null" are
-   * appended.
-   *
-   * @param seq the <code>CharSequence</code> providing the characters
-   * @param start the starting index
-   * @param end one past the final index
-   * @return this <code>StringBuffer</code>
-   * @since 1.5
-   */
-  public CPStringBuilder append(CharSequence seq, int start, int end)
-  {
-    if (seq == null)
-      return append("null");
-    if (end - start > 0)
-      {
-       ensureCapacity_unsynchronized(count + end - start);
-       for (; start < end; ++start)
-         value[count++] = seq.charAt(start);
-      }
-    return this;
-  }
-
-  /**
-   * Append the <code>String</code> value of the argument to this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param inum the <code>int</code> to convert and append
-   * @return this <code>StringBuffer</code>
-   * @see String#valueOf(int)
-   */
-  // This is native in libgcj, for efficiency.
-  public CPStringBuilder append(int inum)
-  {
-    return append(String.valueOf(inum));
-  }
-
-  /**
-   * Append the <code>String</code> value of the argument to this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param lnum the <code>long</code> to convert and append
-   * @return this <code>StringBuffer</code>
-   * @see String#valueOf(long)
-   */
-  public CPStringBuilder append(long lnum)
-  {
-    return append(Long.toString(lnum, 10));
-  }
-
-  /**
-   * Append the <code>String</code> value of the argument to this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param fnum the <code>float</code> to convert and append
-   * @return this <code>StringBuffer</code>
-   * @see String#valueOf(float)
-   */
-  public CPStringBuilder append(float fnum)
-  {
-    return append(Float.toString(fnum));
-  }
-
-  /**
-   * Append the <code>String</code> value of the argument to this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param dnum the <code>double</code> to convert and append
-   * @return this <code>StringBuffer</code>
-   * @see String#valueOf(double)
-   */
-  public CPStringBuilder append(double dnum)
-  {
-    return append(Double.toString(dnum));
-  }
-
-  /**
-   * Append the code point to this <code>StringBuffer</code>.
-   * This is like #append(char), but will append two characters
-   * if a supplementary code point is given.
-   *
-   * @param code the code point to append
-   * @return this <code>StringBuffer</code>
-   * @see Character#toChars(int, char[], int)
-   * @since 1.5
-   */
-  public CPStringBuilder appendCodePoint(int code)
-  {
-    int len = Character.charCount(code);
-    ensureCapacity_unsynchronized(count + len);
-    Character.toChars(code, value, count);
-    count += len;
-    return this;
-  }
-
-  /**
-   * Delete characters from this <code>StringBuffer</code>.
-   * <code>delete(10, 12)</code> will delete 10 and 11, but not 12. It is
-   * harmless for end to be larger than length().
-   *
-   * @param start the first character to delete
-   * @param end the index after the last character to delete
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if start or end are out of bounds
-   * @since 1.2
-   */
-  public CPStringBuilder delete(int start, int end)
-  {
-    if (start < 0 || start > count || start > end)
-      throw new StringIndexOutOfBoundsException(start);
-    if (end > count)
-      end = count;
-    ensureCapacity_unsynchronized(count);
-    if (count - end != 0)
-      System.arraycopy(value, end, value, start, count - end);
-    count -= end - start;
-    return this;
-  }
-
-  /**
-   * Delete a character from this <code>StringBuffer</code>.
-   *
-   * @param index the index of the character to delete
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if index is out of bounds
-   * @since 1.2
-   */
-  public CPStringBuilder deleteCharAt(int index)
-  {
-    return delete(index, index + 1);
-  }
-
-  /**
-   * Replace characters between index <code>start</code> (inclusive) and
-   * <code>end</code> (exclusive) with <code>str</code>. If <code>end</code>
-   * is larger than the size of this StringBuffer, all characters after
-   * <code>start</code> are replaced.
-   *
-   * @param start the beginning index of characters to delete (inclusive)
-   * @param end the ending index of characters to delete (exclusive)
-   * @param str the new <code>String</code> to insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if start or end are out of bounds
-   * @throws NullPointerException if str is null
-   * @since 1.2
-   */
-  public CPStringBuilder replace(int start, int end, String str)
-  {
-    if (start < 0 || start > count || start > end)
-      throw new StringIndexOutOfBoundsException(start);
-
-    int len = str.length();
-    // Calculate the difference in 'count' after the replace.
-    int delta = len - (end > count ? count : end) + start;
-    ensureCapacity_unsynchronized(count + delta);
-
-    if (delta != 0 && end < count)
-      System.arraycopy(value, end, value, end + delta, count - end);
-
-    str.getChars(0, len, value, start);
-    count += delta;
-    return this;
-  }
-
-  /**
-   * Insert a subarray of the <code>char[]</code> argument into this
-   * <code>StringBuffer</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param str the <code>char[]</code> to insert
-   * @param str_offset the index in <code>str</code> to start inserting from
-   * @param len the number of characters to insert
-   * @return this <code>StringBuffer</code>
-   * @throws NullPointerException if <code>str</code> is <code>null</code>
-   * @throws StringIndexOutOfBoundsException if any index is out of bounds
-   * @since 1.2
-   */
-  public CPStringBuilder insert(int offset, char[] str, int str_offset, int len)
-  {
-    if (offset < 0 || offset > count || len < 0
-        || str_offset < 0 || str_offset > str.length - len)
-      throw new StringIndexOutOfBoundsException();
-    ensureCapacity_unsynchronized(count + len);
-    System.arraycopy(value, offset, value, offset + len, count - offset);
-    System.arraycopy(str, str_offset, value, offset, len);
-    count += len;
-    return this;
-  }
-
-  /**
-   * Insert the <code>String</code> value of the argument into this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param obj the <code>Object</code> to convert and insert
-   * @return this <code>StringBuffer</code>
-   * @exception StringIndexOutOfBoundsException if offset is out of bounds
-   * @see String#valueOf(Object)
-   */
-  public CPStringBuilder insert(int offset, Object obj)
-  {
-    return insert(offset, obj == null ? "null" : obj.toString());
-  }
-
-  /**
-   * Insert the <code>String</code> argument into this
-   * <code>StringBuffer</code>. If str is null, the String "null" is used
-   * instead.
-   *
-   * @param offset the place to insert in this buffer
-   * @param str the <code>String</code> to insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   */
-  public CPStringBuilder insert(int offset, String str)
-  {
-    if (offset < 0 || offset > count)
-      throw new StringIndexOutOfBoundsException(offset);
-    if (str == null)
-      str = "null";
-    int len = str.length();
-    ensureCapacity_unsynchronized(count + len);
-    System.arraycopy(value, offset, value, offset + len, count - offset);
-    str.getChars(0, len, value, offset);
-    count += len;
-    return this;
-  }
-
-  /**
-   * Insert the <code>CharSequence</code> argument into this
-   * <code>StringBuffer</code>.  If the sequence is null, the String
-   * "null" is used instead.
-   *
-   * @param offset the place to insert in this buffer
-   * @param sequence the <code>CharSequence</code> to insert
-   * @return this <code>StringBuffer</code>
-   * @throws IndexOutOfBoundsException if offset is out of bounds
-   * @since 1.5
-   */
-  public CPStringBuilder insert(int offset, CharSequence sequence)
-  {
-    if (sequence == null)
-      sequence = "null";
-    return insert(offset, sequence, 0, sequence.length());
-  }
-
-  /**
-   * Insert a subsequence of the <code>CharSequence</code> argument into this
-   * <code>StringBuffer</code>.  If the sequence is null, the String
-   * "null" is used instead.
-   *
-   * @param offset the place to insert in this buffer
-   * @param sequence the <code>CharSequence</code> to insert
-   * @param start the starting index of the subsequence
-   * @param end one past the ending index of the subsequence
-   * @return this <code>StringBuffer</code>
-   * @throws IndexOutOfBoundsException if offset, start,
-   * or end are out of bounds
-   * @since 1.5
-   */
-  public CPStringBuilder insert(int offset, CharSequence sequence, int start, int end)
-  {
-    if (sequence == null)
-      sequence = "null";
-    if (start < 0 || end < 0 || start > end || end > sequence.length())
-      throw new IndexOutOfBoundsException();
-    int len = end - start;
-    ensureCapacity_unsynchronized(count + len);
-    System.arraycopy(value, offset, value, offset + len, count - offset);
-    for (int i = start; i < end; ++i)
-      value[offset++] = sequence.charAt(i);
-    count += len;
-    return this;
-  }
-
-  /**
-   * Insert the <code>char[]</code> argument into this
-   * <code>StringBuffer</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param data the <code>char[]</code> to insert
-   * @return this <code>StringBuffer</code>
-   * @throws NullPointerException if <code>data</code> is <code>null</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   * @see #insert(int, char[], int, int)
-   */
-  public CPStringBuilder insert(int offset, char[] data)
-  {
-    return insert(offset, data, 0, data.length);
-  }
-
-  /**
-   * Insert the <code>String</code> value of the argument into this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param bool the <code>boolean</code> to convert and insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   * @see String#valueOf(boolean)
-   */
-  public CPStringBuilder insert(int offset, boolean bool)
-  {
-    return insert(offset, bool ? "true" : "false");
-  }
-
-  /**
-   * Insert the <code>char</code> argument into this <code>StringBuffer</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param ch the <code>char</code> to insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   */
-  public CPStringBuilder insert(int offset, char ch)
-  {
-    if (offset < 0 || offset > count)
-      throw new StringIndexOutOfBoundsException(offset);
-    ensureCapacity_unsynchronized(count + 1);
-    System.arraycopy(value, offset, value, offset + 1, count - offset);
-    value[offset] = ch;
-    count++;
-    return this;
-  }
-
-  /**
-   * Insert the <code>String</code> value of the argument into this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param inum the <code>int</code> to convert and insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   * @see String#valueOf(int)
-   */
-  public CPStringBuilder insert(int offset, int inum)
-  {
-    return insert(offset, String.valueOf(inum));
-  }
-
-  /**
-   * Insert the <code>String</code> value of the argument into this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param lnum the <code>long</code> to convert and insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   * @see String#valueOf(long)
-   */
-  public CPStringBuilder insert(int offset, long lnum)
-  {
-    return insert(offset, Long.toString(lnum, 10));
-  }
-
-  /**
-   * Insert the <code>String</code> value of the argument into this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param fnum the <code>float</code> to convert and insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   * @see String#valueOf(float)
-   */
-  public CPStringBuilder insert(int offset, float fnum)
-  {
-    return insert(offset, Float.toString(fnum));
-  }
-
-  /**
-   * Insert the <code>String</code> value of the argument into this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param dnum the <code>double</code> to convert and insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   * @see String#valueOf(double)
-   */
-  public CPStringBuilder insert(int offset, double dnum)
-  {
-    return insert(offset, Double.toString(dnum));
-  }
-
-  /**
-   * Finds the first instance of a substring in this StringBuilder.
-   *
-   * @param str String to find
-   * @return location (base 0) of the String, or -1 if not found
-   * @throws NullPointerException if str is null
-   * @see #indexOf(String, int)
-   */
-  public int indexOf(String str)
-  {
-    return indexOf(str, 0);
-  }
-
-  /**
-   * Finds the first instance of a String in this StringBuffer, starting at
-   * a given index.  If starting index is less than 0, the search starts at
-   * the beginning of this String.  If the starting index is greater than the
-   * length of this String, or the substring is not found, -1 is returned.
-   *
-   * @param str String to find
-   * @param fromIndex index to start the search
-   * @return location (base 0) of the String, or -1 if not found
-   * @throws NullPointerException if str is null
-   * @since 1.4
-   */
-  public int indexOf(String str, int fromIndex)
-  {
-    if (fromIndex < 0)
-      fromIndex = 0;
-    int olength = str.length();
-    int limit = count - olength;
-    String s = VMCPStringBuilder.toString(value, 0, count);
-    for (; fromIndex <= limit; ++fromIndex)
-      if (s.regionMatches(fromIndex, str, 0, olength))
-        return fromIndex;
-    return -1;
-  }
-
-  /**
-   * Finds the last instance of a substring in this StringBuffer.
-   *
-   * @param str String to find
-   * @return location (base 0) of the String, or -1 if not found
-   * @throws NullPointerException if str is null
-   * @see #lastIndexOf(String, int)
-   * @since 1.4
-   */
-  public int lastIndexOf(String str)
-  {
-    return lastIndexOf(str, count - str.length());
-  }
-
-  /**
-   * Finds the last instance of a String in this StringBuffer, starting at a
-   * given index.  If starting index is greater than the maximum valid index,
-   * then the search begins at the end of this String.  If the starting index
-   * is less than zero, or the substring is not found, -1 is returned.
-   *
-   * @param str String to find
-   * @param fromIndex index to start the search
-   * @return location (base 0) of the String, or -1 if not found
-   * @throws NullPointerException if str is null
-   * @since 1.4
-   */
-  public int lastIndexOf(String str, int fromIndex)
-  {
-    fromIndex = Math.min(fromIndex, count - str.length());
-    String s = VMCPStringBuilder.toString(value, 0, count);
-    int olength = str.length();
-    for ( ; fromIndex >= 0; fromIndex--)
-      if (s.regionMatches(fromIndex, str, 0, olength))
-        return fromIndex;
-    return -1;
-  }
-
-  /**
-   * Reverse the characters in this StringBuffer. The same sequence of
-   * characters exists, but in the reverse index ordering.
-   *
-   * @return this <code>StringBuffer</code>
-   */
-  public CPStringBuilder reverse()
-  {
-    // Call ensureCapacity to enforce copy-on-write.
-    ensureCapacity_unsynchronized(count);
-    for (int i = count >> 1, j = count - i; --i >= 0; ++j)
-      {
-        char c = value[i];
-        value[i] = value[j];
-        value[j] = c;
-      }
-    return this;
-  }
-
-  /**
-   * This may reduce the amount of memory used by the StringBuffer,
-   * by resizing the internal array to remove unused space.  However,
-   * this method is not required to resize, so this behavior cannot
-   * be relied upon.
-   * @since 1.5
-   */
-  public void trimToSize()
-  {
-    int wouldSave = value.length - count;
-    // Some random heuristics: if we save less than 20 characters, who
-    // cares.
-    if (wouldSave < 20)
-      return;
-    // If we save more than 200 characters, shrink.
-    // If we save more than 1/4 of the buffer, shrink.
-    if (wouldSave > 200 || wouldSave * 4 > value.length)
-      {
-       char[] newValue = new char[count];
-       System.arraycopy(value, 0, newValue, 0, count);
-       value = newValue;
-      }
-  }
-
-  /**
-   * Return the number of code points between two indices in the
-   * <code>StringBuffer</code>.  An unpaired surrogate counts as a
-   * code point for this purpose.  Characters outside the indicated
-   * range are not examined, even if the range ends in the middle of a
-   * surrogate pair.
-   *
-   * @param start the starting index
-   * @param end one past the ending index
-   * @return the number of code points
-   * @since 1.5
-   */
-  public int codePointCount(int start, int end)
-  {
-    if (start < 0 || end >= count || start > end)
-      throw new StringIndexOutOfBoundsException();
-
-    int count = 0;
-    while (start < end)
-      {
-       char base = value[start];
-       if (base < Character.MIN_HIGH_SURROGATE
-           || base > Character.MAX_HIGH_SURROGATE
-           || start == end
-           || start == count
-           || value[start + 1] < Character.MIN_LOW_SURROGATE
-           || value[start + 1] > Character.MAX_LOW_SURROGATE)
-         {
-           // Nothing.
-         }
-       else
-         {
-           // Surrogate pair.
-           ++start;
-         }
-       ++start;
-       ++count;
-      }
-    return count;
-  }
-
-  /**
-   * Starting at the given index, this counts forward by the indicated
-   * number of code points, and then returns the resulting index.  An
-   * unpaired surrogate counts as a single code point for this
-   * purpose.
-   *
-   * @param start the starting index
-   * @param codePoints the number of code points
-   * @return the resulting index
-   * @since 1.5
-   */
-  public int offsetByCodePoints(int start, int codePoints)
-  {
-    while (codePoints > 0)
-      {
-       char base = value[start];
-       if (base < Character.MIN_HIGH_SURROGATE
-           || base > Character.MAX_HIGH_SURROGATE
-           || start == count
-           || value[start + 1] < Character.MIN_LOW_SURROGATE
-           || value[start + 1] > Character.MAX_LOW_SURROGATE)
-         {
-           // Nothing.
-         }
-       else
-         {
-           // Surrogate pair.
-           ++start;
-         }
-       ++start;
-       --codePoints;
-      }
-    return start;
-  }
-
-  /**
-   * Increase the capacity of this <code>StringBuilder</code>. This will
-   * ensure that an expensive growing operation will not occur until
-   * <code>minimumCapacity</code> is reached. The buffer is grown to the
-   * larger of <code>minimumCapacity</code> and
-   * <code>capacity() * 2 + 2</code>, if it is not already large enough.
-   *
-   * @param minimumCapacity the new capacity
-   * @see #capacity()
-   */
-  protected void ensureCapacity_unsynchronized(int minimumCapacity)
-  {
-    if (minimumCapacity > value.length)
-      {
-        int max = value.length * 2 + 2;
-        minimumCapacity = (minimumCapacity < max ? max : minimumCapacity);
-        char[] nb = new char[minimumCapacity];
-        System.arraycopy(value, 0, nb, 0, count);
-        value = nb;
-      }
-  }
-
-  /**
-   * Get the length of the <code>String</code> this <code>StringBuilder</code>
-   * would create. Not to be confused with the <em>capacity</em> of the
-   * <code>StringBuilder</code>.
-   *
-   * @return the length of this <code>StringBuilder</code>
-   * @see #capacity()
-   * @see #setLength(int)
-   */
-  public int length()
-  {
-    return count;
-  }
-
-  /**
-   * Creates a substring of this StringBuilder, starting at a specified index
-   * and ending at one character before a specified index. This is implemented
-   * the same as <code>substring(beginIndex, endIndex)</code>, to satisfy
-   * the CharSequence interface.
-   *
-   * @param beginIndex index to start at (inclusive, base 0)
-   * @param endIndex index to end at (exclusive)
-   * @return new String which is a substring of this StringBuilder
-   * @throws IndexOutOfBoundsException if beginIndex or endIndex is out of
-   *         bounds
-   * @see #substring(int, int)
-   */
-  public CharSequence subSequence(int beginIndex, int endIndex)
-  {
-    return substring(beginIndex, endIndex);
-  }
-
-  /**
-   * Creates a substring of this StringBuilder, starting at a specified index
-   * and ending at one character before a specified index.
-   *
-   * @param beginIndex index to start at (inclusive, base 0)
-   * @param endIndex index to end at (exclusive)
-   * @return new String which is a substring of this StringBuilder
-   * @throws StringIndexOutOfBoundsException if beginIndex or endIndex is out
-   *         of bounds
-   */
-  public String substring(int beginIndex, int endIndex)
-  {
-    if (beginIndex < 0 || endIndex > count || endIndex < beginIndex)
-      throw new StringIndexOutOfBoundsException();
-    int len = endIndex - beginIndex;
-    if (len == 0)
-      return "";
-    return VMCPStringBuilder.toString(value, beginIndex, len);
-  }
-
-  /**
-   * Convert this <code>StringBuilder</code> to a <code>String</code>. The
-   * String is composed of the characters currently in this StringBuilder. Note
-   * that the result is not a copy, so future modifications to this buffer
-   * do affect the String.
-   *
-   * @return the characters in this StringBuilder
-   */
-  public String toString()
-  {
-    return VMCPStringBuilder.toString(value, 0, count);
-  }
-
-}
diff --git a/src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java b/src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java
deleted file mode 100644 (file)
index ca1c39d..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/* VMCPStringBuilder.java -- Growable strings without locking or copying
-   Copyright (C) 2008 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 gnu.java.lang;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * This class provides VM support for CPStringBuilder
- * by allowing the package-private constructor
- * of java.lang.String to be invoked.  The default
- * implementation uses reflection.  VMs may replace
- * this class with a more efficient version.
- */
-final class VMCPStringBuilder
-{
-
-  /**
-   * The package-private constructor for String objects without copying.
-   */
-//   private static final Constructor<String> cons;
-
-//   static
-//   {
-//     try
-//       {
-//     cons = String.class.getDeclaredConstructor(char[].class, Integer.TYPE,
-//                                                Integer.TYPE, Boolean.TYPE);
-//     cons.setAccessible(true);
-//       }
-//     catch (NoSuchMethodException e)
-//       {
-//     throw (Error) 
-//       new InternalError("Could not get no-copy String constructor").initCause(e);
-//       }
-//   }
-
-  /**
-   * Convert this <code>StringBuilder</code> to a <code>String</code>. The
-   * String is composed of the characters currently in this StringBuilder. Note
-   * that the result is not a copy, so future modifications to this buffer
-   * do affect the String.
-   *
-   * @param value the buffered characters.
-   * @param startIndex the index at which to start taking characters from the buffer.
-   * @param count the number of characters used in the buffer.
-   * @return the characters in this StringBuilder
-   */
-//   public static String toString(char[] value, int startIndex, int count)
-//   {
-//     try
-//       {
-//     return cons.newInstance(value, startIndex, count, true);
-//       }
-//     catch (InstantiationException e)
-//       {
-//     throw (Error) 
-//       new InternalError("Could not instantiate no-copy String constructor").initCause(e);
-//       }
-//     catch (IllegalAccessException e)
-//       {
-//     throw (Error) 
-//       new InternalError("Could not access no-copy String constructor").initCause(e);
-//       }
-//     catch (InvocationTargetException e)
-//       {
-//     throw (Error) 
-//       new InternalError("Error calling no-copy String constructor").initCause(e);
-//       }
-//   }
-  public static native String toString(char[] value, int startIndex, int count);
-
-}
diff --git a/src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java b/src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java
deleted file mode 100644 (file)
index d71a06d..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/* VMMemoryMXBeanImpl.java - VM impl. of a memory bean
-   Copyright (C) 2006 Free Software Foundation
-
-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 gnu.java.lang.management;
-
-import java.lang.management.MemoryUsage;
-
-/**
- * Provides access to information about the memory
- * management of the current invocation of the virtual
- * machine.  Instances of this bean are obtained by calling
- * {@link ManagementFactory#getMemoryMXBean()}.
- *
- * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
- * @since 1.5
- */
-final class VMMemoryMXBeanImpl
-{
-
-  /**
-   * Returns an instance of {@link java.lang.management.MemoryUsage}
-   * with appropriate initial, used, committed and maximum values
-   * for the heap.  By default, this uses the methods of
-   * {@link java.lang.Runtime} to provide some of the values.
-   *
-   * @return an {@link java.lang.management.MemoryUsage} instance
-   *         for the heap.
-   */
-//   static MemoryUsage getHeapMemoryUsage()
-//   {
-//     Runtime runtime = Runtime.getRuntime();
-//     long totalMem = runtime.totalMemory();
-//     return new MemoryUsage(-1, totalMem - runtime.freeMemory(),
-//                        totalMem, runtime.maxMemory());
-//   }
-  static native MemoryUsage getHeapMemoryUsage();
-
-  /**
-   * Returns an instance of {@link java.lang.management.MemoryUsage}
-   * with appropriate initial, used, committed and maximum values
-   * for non-heap memory.
-   *
-   * @return an {@link java.lang.management.MemoryUsage} instance
-   *         for non-heap memory.
-   */
-  static native MemoryUsage getNonHeapMemoryUsage();
-
-  /**
-   * Returns the number of objects ready to be garbage collected.
-   *
-   * @return the number of finalizable objects.
-   */
-  static native int getObjectPendingFinalizationCount();
-
-  /**
-   * Returns true if the virtual machine will emit additional
-   * information when memory is allocated and deallocated.  The
-   * format of the output is left up to the virtual machine.
-   *
-   * @return true if verbose class loading output is on.
-   */
-  static native boolean isVerbose();
-
-  /**
-   * Turns on or off the emission of additional information
-   * when memory is allocated and deallocated.  The format of the
-   * output is left up to the virtual machine.  This method
-   * may be called by multiple threads concurrently, but there
-   * is only one global setting of verbosity that is affected.
-   *
-   * @param verbose the new setting for verbose class loading
-   *                output.
-   */
-  static native void setVerbose(boolean verbose);
-
-}
diff --git a/src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java b/src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
deleted file mode 100644 (file)
index 32a8660..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* VMRuntimeMXBeanImpl.java - VM implementation of an runtime bean
-   Copyright (C) 2006 Free Software Foundation
-
-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 gnu.java.lang.management;
-
-import gnu.classpath.SystemProperties;
-
-/**
- * Provides access to information about the virtual machine.
- *
- * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
- * @since 1.5
- */
-final class VMRuntimeMXBeanImpl
-{
-
-  /**
-   * Returns the command-line arguments supplied
-   * to the virtual machine, excluding those supplied
-   * to <code>main()</code>.
-   *
-   * @return the command-line arguments.
-   */
-  static native String[] getInputArguments();
-
-  /**
-   * Returns a developer-chosen name for the virtual
-   * machine, which may differ over different running
-   * instances of the same virtual machine binary.
-   * For example, this may include the particular
-   * process identifier used by this instance or
-   * the host name of the machine on which it is
-   * running.  The intention is that this name refers
-   * to the precise entity that the other data supplied
-   * by the bean refers to, rather than the VM in general.
-   *
-   * @return the custom name of the VM.
-   */
-  static String getName()
-  {
-    return SystemProperties.getProperty("java.vm.name") + " " +
-      SystemProperties.getProperty("java.vm.version");
-  }
-
-  /**
-   * The time in milliseconds at which the virtual
-   * machine was started.  This method is only executed
-   * once (for efficency), as the value is not expected
-   * to change.
-   *
-   * @return the VM start time.
-   */
-  static native long getStartTime();
-
-}
diff --git a/src/classes/gnu/java/lang/VMClassLoader.java b/src/classes/gnu/java/lang/VMClassLoader.java
deleted file mode 100644 (file)
index f09838b..0000000
+++ /dev/null
@@ -1,457 +0,0 @@
-/* VMClassLoader.java -- Reference implementation of native interface
-   required by ClassLoader
-   Copyright (C) 1998, 2001, 2002, 2004, 2005, 2006 Free Software Foundation
-
-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;
-
-import gnu.classpath.Configuration;
-import gnu.classpath.SystemProperties;
-import gnu.java.lang.InstrumentationImpl;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.instrument.Instrumentation;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.ProtectionDomain;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.Vector;
-import java.util.zip.ZipFile;
-import java.util.Collections;
-import java.lang.Boolean;
-
-/**
- * java.lang.VMClassLoader is a package-private helper for VMs to implement
- * on behalf of java.lang.ClassLoader.
- *
- * @author John Keiser
- * @author Mark Wielaard (mark@klomp.org)
- * @author Eric Blake (ebb9@email.byu.edu)
- */
-final class VMClassLoader
-{
-
-
-  /** packages loaded by the bootstrap class loader */
-  static final HashMap definedPackages = new HashMap();
-
-  /** jars from property java.boot.class.path */
-  static final HashMap bootjars = new HashMap();
-  
-
-  /**
-   * Converts the array string of native package names to
-   * Packages. The packages are then put into the
-   * definedPackages hashMap
-   */
-  static
-  {
-    String[] packages = getBootPackages();
-    
-    if( packages != null)
-      {
-        String specName = 
-              SystemProperties.getProperty("java.specification.name");
-        String vendor =
-              SystemProperties.getProperty("java.specification.vendor");
-        String version =
-              SystemProperties.getProperty("java.specification.version");
-        
-        Package p;
-              
-        for(int i = 0; i < packages.length; i++)
-          {
-            p = new Package(packages[i],
-                  specName,
-                  vendor,
-                  version,
-                  "GNU Classpath",
-                  "GNU",
-                  Configuration.CLASSPATH_VERSION,
-                  null,
-                  null);
-
-            definedPackages.put(packages[i], p);
-          }
-      }
-  }
-
-  
-  /**
-   * Helper to define a class using a string of bytes. This assumes that
-   * the security checks have already been performed, if necessary.
-   *
-   * Implementations of this method are advised to consider the
-   * situation where user code modifies the byte array after it has
-   * been passed to defineClass.  This can be handled by making a
-   * private copy of the array, or arranging to only read any given
-   * byte a single time.
-   *
-   * @param name the name to give the class, or null if unknown
-   * @param data the data representing the classfile, in classfile format
-   * @param offset the offset into the data where the classfile starts
-   * @param len the length of the classfile data in the array
-   * @param pd the protection domain
-   * @return the class that was defined
-   * @throws ClassFormatError if data is not in proper classfile format
-   */
-  static final native Class defineClass(ClassLoader cl, String name,
-                                 byte[] data, int offset, int len,
-                                 ProtectionDomain pd)
-    throws ClassFormatError;
-
-  /**
-   * Helper to resolve all references to other classes from this class.
-   *
-   * @param c the class to resolve
-   */
-  static final native void resolveClass(Class c);
-
-  /**
-   * Helper to load a class from the bootstrap class loader.
-   *
-   * @param name the class name to load
-   * @param resolve whether to resolve it
-   * @return the class, loaded by the bootstrap classloader or null
-   * if the class wasn't found. Returning null is equivalent to throwing
-   * a ClassNotFoundException (but a possible performance optimization).
-   */
-  static final native Class loadClass(String name, boolean resolve)
-    throws ClassNotFoundException;
-
-  /**
-   * Helper to load a resource from the bootstrap class loader.
-   *
-   * @param name the resource to find
-   * @return the URL to the resource
-   */
-  static URL getResource(String name)
-  {
-    Enumeration e = getResources(name);
-    if (e.hasMoreElements())
-      return (URL)e.nextElement();
-    return null;
-  }
-  /**
-   * Helper to get a list of resources from the bootstrap class loader.
-   *
-   * @param name the resource to find
-   * @return an enumeration of resources
-   */
-  static Enumeration getResources(String name)
-  {
-//     StringTokenizer st = new StringTokenizer(
-//       SystemProperties.getProperty("java.boot.class.path", "."),
-//       File.pathSeparator);
-//     Vector v = new Vector();
-//     while (st.hasMoreTokens())
-//       {
-//     File file = new File(st.nextToken());
-//     if (file.isDirectory())
-//       {
-//         try
-//           {
-//                 File f = new File(file, name);
-//                 if (!f.exists()) continue;
-//                 v.add(new URL("file://" + f.getAbsolutePath()));
-//           }
-//         catch (MalformedURLException e)
-//           {
-//             throw new Error(e);
-//           }
-//       }
-//     else if (file.isFile())
-//       {
-//         ZipFile zip;
-//             synchronized(bootjars)
-//               {
-//                 zip = (ZipFile) bootjars.get(file.getName());
-//               }
-//             if(zip == null)
-//               {
-//                 try
-//               {
-//                     zip = new ZipFile(file);
-//                     synchronized(bootjars)
-//                       {
-//                         bootjars.put(file.getName(), zip);
-//                       }
-//               }
-//             catch (IOException e)
-//               {
-//                 continue;
-//               }
-//               }
-//         String zname = name.startsWith("/") ? name.substring(1) : name;
-//         if (zip.getEntry(zname) == null)
-//           continue;
-//         try
-//           {
-//             v.add(new URL("jar:file://"
-//               + file.getAbsolutePath() + "!/" + zname));
-//           }
-//         catch (MalformedURLException e)
-//           {
-//             throw new Error(e);
-//           }
-//       }
-//       }
-//     return v.elements();
-//   }
-    Vector urls = nativeGetResources(name);
-    Vector v = new Vector();
-    for (Enumeration en = urls.elements(); en.hasMoreElements();)
-      {
-       try
-         {
-           v.add(new URL((String) en.nextElement()));
-         }
-       catch (MalformedURLException e)
-         {
-           throw new Error(e);
-         }
-      }
-    return v.elements();
-  }
-
-  private native static final Vector nativeGetResources(String name);
-
-
-  /**
-   * Returns a String[] of native package names. The default
-   * implementation tries to load a list of package from
-   * the META-INF/INDEX.LIST file in the boot jar file.
-   * If not found or if any exception is raised, it returns
-   * an empty array. You may decide this needs native help.
-   */
-  private static String[] getBootPackages()
-  {
-    try
-      {
-        Enumeration indexListEnumeration = getResources("META-INF/INDEX.LIST");
-        Set packageSet = new HashSet();
-
-        while (indexListEnumeration.hasMoreElements())
-          {
-            try
-              {
-                String line;
-                int lineToSkip = 3;
-                BufferedReader reader = new BufferedReader(
-                                                           new InputStreamReader(
-                                                                                 ((URL) indexListEnumeration.nextElement()).openStream()));
-                while ((line = reader.readLine()) != null)
-                  {
-                    if (lineToSkip == 0)
-                      {
-                        if (line.length() == 0)
-                          lineToSkip = 1;
-                        else
-                          packageSet.add(line.replace('/', '.'));
-                      }
-                    else
-                      lineToSkip--;
-                  }
-                reader.close();
-              }
-            catch (IOException e)
-              {
-                // Empty catch block on purpose
-              }
-          }
-        return (String[]) packageSet.toArray(new String[packageSet.size()]);
-      }
-    catch (Exception e)
-      {
-        return new String[0];
-      }
-  }
-
-
-  /**
-   * Helper to get a package from the bootstrap class loader.
-   *
-   * @param name the name to find
-   * @return the named package, if it exists
-   */
-  static Package getPackage(String name)
-  {
-    return (Package)definedPackages.get(name);
-  }
-
-
-  
-  /**
-   * Helper to get all packages from the bootstrap class loader.  
-   *
-   * @return all named packages, if any exist
-   */
-  static Package[] getPackages()
-  {
-    Package[] packages = new Package[definedPackages.size()];
-    definedPackages.values().toArray(packages);
-    return packages;
-  }
-
-  /**
-   * Helper for java.lang.Integer, Byte, etc to get the TYPE class
-   * at initialization time. The type code is one of the chars that
-   * represents the primitive type as in JNI.
-   *
-   * <ul>
-   * <li>'Z' - boolean</li>
-   * <li>'B' - byte</li>
-   * <li>'C' - char</li>
-   * <li>'D' - double</li>
-   * <li>'F' - float</li>
-   * <li>'I' - int</li>
-   * <li>'J' - long</li>
-   * <li>'S' - short</li>
-   * <li>'V' - void</li>
-   * </ul>
-   *
-   * @param type the primitive type
-   * @return a "bogus" class representing the primitive type
-   */
-  static final native Class getPrimitiveClass(char type);
-
-  /**
-   * The system default for assertion status. This is used for all system
-   * classes (those with a null ClassLoader), as well as the initial value for
-   * every ClassLoader's default assertion status.
-   *
-   * @return the system-wide default assertion status
-   */
-  static native final boolean defaultAssertionStatus();
-
-  static native final boolean defaultUserAssertionStatus();
-
-
-  static final Map packageAssertionMap = 
-    Collections.unmodifiableMap(packageAssertionStatus0(Boolean.TRUE, Boolean.FALSE));
-  
-  static native final Map packageAssertionStatus0(Boolean jtrue, Boolean jfalse);
-  /**
-   * The system default for package assertion status. This is used for all
-   * ClassLoader's packageAssertionStatus defaults. It must be a map of
-   * package names to Boolean.TRUE or Boolean.FALSE, with the unnamed package
-   * represented as a null key.
-   *
-   * @return a (read-only) map for the default packageAssertionStatus
-   */
-   
-  static final Map packageAssertionStatus() {
-    return packageAssertionMap;
-  }
-
-  static final Map classAssertionMap = 
-    Collections.unmodifiableMap(classAssertionStatus0(Boolean.TRUE, Boolean.FALSE));
-  
-  static native final Map classAssertionStatus0(Boolean jtrue, Boolean jfalse);
-
-  /**
-   * The system default for class assertion status. This is used for all
-   * ClassLoader's classAssertionStatus defaults. It must be a map of
-   * class names to Boolean.TRUE or Boolean.FALSE
-   *
-   * @return a (read-only) map for the default classAssertionStatus
-   */
-  static final Map classAssertionStatus() {
-    return classAssertionMap;
-  }
-  
-  static ClassLoader getSystemClassLoader()
-  {
-    return ClassLoader.defaultGetSystemClassLoader();
-  }
-
-  /**
-   * Find the class if this class loader previously defined this class
-   * or if this class loader has been recorded as the initiating class loader
-   * for this class.
-   */
-  static native Class findLoadedClass(ClassLoader cl, String name);
-
-  /**
-   * The Instrumentation object created by the vm when agents are defined.
-   */
-  static final Instrumentation instrumenter = null;
-
-  /**
-   * Call the transformers of the possible Instrumentation object. This
-   * implementation assumes the instrumenter is a
-   * <code>InstrumentationImpl</code> object. VM implementors would
-   * have to redefine this method if they provide their own implementation
-   * of the <code>Instrumentation</code> interface.
-   *
-   * @param loader the initiating loader
-   * @param name the name of the class
-   * @param data the data representing the classfile, in classfile format
-   * @param offset the offset into the data where the classfile starts
-   * @param len the length of the classfile data in the array
-   * @param pd the protection domain
-   * @return the new data representing the classfile
-   */
-  static final Class defineClassWithTransformers(ClassLoader loader,
-      String name, byte[] data, int offset, int len, ProtectionDomain pd)
-  {
-    
-    if (instrumenter != null)
-      {
-        byte[] modifiedData = new byte[len];
-        System.arraycopy(data, offset, modifiedData, 0, len);
-        modifiedData =
-          ((InstrumentationImpl)instrumenter).callTransformers(loader, name,
-            null, pd, modifiedData);
-        
-        return defineClass(loader, name, modifiedData, 0, modifiedData.length,
-            pd);
-      }
-    else
-      {
-        return defineClass(loader, name, data, offset, len, pd);
-      }
-  }
-}
diff --git a/src/classes/gnu/java/lang/VMString.java b/src/classes/gnu/java/lang/VMString.java
deleted file mode 100644 (file)
index 57e4423..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/* VMString.java -- VM Specific String methods
-   Copyright (C) 2003 Free Software Foundation
-
-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;
-
-import java.lang.ref.WeakReference;
-import java.util.WeakHashMap;
-
-/*
- * This class is a reference version, mainly for compiling a class library
- * jar.  It is likely that VM implementers replace this with their own
- * version that can communicate effectively with the VM.
- */
-
-/**
- * Code relocated from java.lang.String by 
- * @author Dave Grove <groved@us.ibm.com>
- */
-final class VMString
-{
-
-  /**
-   * Holds the references for each intern()'d String. If all references to
-   * the string disappear, and the VM properly supports weak references,
-   * the String will be GC'd.
-   */
-//    private static final WeakHashMap internTable = new WeakHashMap();
-
-  /**
-   * Fetches this String from the intern hashtable. If two Strings are
-   * considered equal, by the equals() method, then intern() will return the
-   * same String instance. ie. if (s1.equals(s2)) then
-   * (s1.intern() == s2.intern()). All string literals and string-valued
-   * constant expressions are already interned.
-   *
-   * @param str the String to intern
-   * @return the interned String
-   */
-//    static String intern(String str)
-//    {
-//      synchronized (internTable)
-//        {
-//          WeakReference ref = (WeakReference) internTable.get(str);
-//          if (ref != null)
-//            {
-//              String s = (String) ref.get();
-//              // If s is null, then no strong references exist to the String;
-//              // the weak hash map will soon delete the key.
-//              if (s != null)
-//                return s;
-//            }
-//          internTable.put(str, new WeakReference(str));
-//        }
-//      return str;
-//    }
-
-  /**
-   * this one is native in CACAO
-   */
-  static native String intern(String str);
-
-} // class VMString
diff --git a/src/classes/gnu/java/lang/VMThread.java b/src/classes/gnu/java/lang/VMThread.java
deleted file mode 100644 (file)
index a511f3c..0000000
+++ /dev/null
@@ -1,462 +0,0 @@
-/* VMThread -- VM interface for Thread of executable code
-   Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation
-
-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;
-
-/**
- * VM interface for Thread of executable code. Holds VM dependent state.
- * It is deliberately package local and final and should only be accessed
- * by the Thread class.
- * <p>
- * This is the GNU Classpath reference implementation, it should be adapted
- * for a specific VM.
- * <p>
- * The following methods must be implemented:
- * <ul>
- * <li>native void start(long stacksize);
- * <li>native void interrupt();
- * <li>native boolean isInterrupted();
- * <li>native void suspend();
- * <li>native void resume();
- * <li>native void nativeSetPriority(int priority);
- * <li>native void nativeStop(Throwable t);
- * <li>native static Thread currentThread();
- * <li>static native void yield();
- * <li>static native boolean interrupted();
- * </ul>
- * All other methods may be implemented to make Thread handling more efficient
- * or to implement some optional (and sometimes deprecated) behaviour. Default
- * implementations are provided but it is highly recommended to optimize them
- * for a specific VM.
- * 
- * @author Jeroen Frijters (jeroen@frijters.net)
- * @author Dalibor Topic (robilad@kaffe.org)
- */
-final class VMThread
-{
-    /**
-     * The Thread object that this VM state belongs to.
-     * Used in currentThread() and start().
-     * Note: when this thread dies, this reference is *not* cleared
-     */
-    volatile Thread thread;
-
-    /**
-     * Flag that is set when the thread runs, used by stop() to protect against
-     * stop's getting lost.
-     */
-    private volatile boolean running;
-
-    /**
-     * VM private data.
-     */
-    private transient Object vmdata;
-
-    /**
-     * Private constructor, create VMThreads with the static create method.
-     *
-     * @param thread The Thread object that was just created.
-     */
-    private VMThread(Thread thread)
-    {
-       this.thread = thread;
-    }
-
-    /**
-     * This method is the initial Java code that gets executed when a native
-     * thread starts. It's job is to coordinate with the rest of the VMThread
-     * logic and to start executing user code and afterwards handle clean up.
-     */
-    private void run()
-    {
-       try
-       {
-           try
-           {
-               running = true;
-               synchronized(thread)
-               {
-                   Throwable t = thread.stillborn;
-                   if(t != null)
-                   {
-                       thread.stillborn = null;
-                       throw t;
-                   }
-               }
-               thread.run();
-           }
-           catch(Throwable t)
-           {
-               try
-               {
-                 Thread.UncaughtExceptionHandler handler;
-                 handler = thread.getUncaughtExceptionHandler();
-                 handler.uncaughtException(thread, t);
-               }
-               catch(Throwable ignore)
-               {
-               }
-           }
-       }
-       finally
-       {
-           // Setting runnable to false is partial protection against stop
-           // being called while we're cleaning up. To be safe all code in
-           // VMThread be unstoppable.
-           running = false;
-           thread.die();
-           synchronized(this)
-           {
-               // release the threads waiting to join us
-               notifyAll();
-           }
-       }
-    }
-
-    /**
-     * Creates a native Thread. This is called from the start method of Thread.
-     * The Thread is started.
-     *
-     * @param thread The newly created Thread object
-     * @param stacksize Indicates the requested stacksize. Normally zero,
-     * non-zero values indicate requested stack size in bytes but it is up
-     * to the specific VM implementation to interpret them and may be ignored.
-     */
-    static void create(Thread thread, long stacksize)
-    {
-       VMThread vmThread = new VMThread(thread);
-       thread.vmThread = vmThread;
-       vmThread.start(stacksize);
-    }
-
-    /**
-     * Gets the name of the thread. Usually this is the name field of the
-     * associated Thread object, but some implementation might choose to
-     * return the name of the underlying platform thread.
-     */
-    String getName()
-    {
-       return thread.name;
-    }
-
-    /**
-     * Set the name of the thread. Usually this sets the name field of the
-     * associated Thread object, but some implementations might choose to
-     * set the name of the underlying platform thread.
-     * @param name The new name
-     */
-    void setName(String name)
-    {
-       thread.name = name;
-    }
-
-    /**
-     * Set the thread priority field in the associated Thread object and
-     * calls the native method to set the priority of the underlying
-     * platform thread.
-     * @param priority The new priority
-     */
-    void setPriority(int priority)
-    {
-       thread.priority = priority;
-       nativeSetPriority(priority);
-    }
-
-    /**
-     * Returns the priority. Usually this is the priority field from the
-     * associated Thread object, but some implementation might choose to
-     * return the priority of the underlying platform thread.
-     * @return this Thread's priority
-     */
-    int getPriority()
-    {
-        return thread.priority;
-    }
-
-    /**
-     * Returns true if the thread is a daemon thread. Usually this is the
-     * daemon field from the associated Thread object, but some
-     * implementation might choose to return the daemon state of the underlying
-     * platform thread.
-     * @return whether this is a daemon Thread or not
-     */
-    boolean isDaemon()
-    {
-        return thread.daemon;
-    }
-
-    /**
-     * Returns the number of stack frames in this Thread.
-     * Will only be called when when a previous call to suspend() returned true.
-     *
-     * @deprecated unsafe operation
-     */
-    native int countStackFrames();
-
-    /**
-     * Wait the specified amount of time for the Thread in question to die.
-     *
-     * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
-     * not offer that fine a grain of timing resolution. Besides, there is
-     * no guarantee that this thread can start up immediately when time expires,
-     * because some other thread may be active.  So don't expect real-time
-     * performance.
-     *
-     * @param ms the number of milliseconds to wait, or 0 for forever
-     * @param ns the number of extra nanoseconds to sleep (0-999999)
-     * @throws InterruptedException if the Thread is interrupted; it's
-     *         <i>interrupted status</i> will be cleared
-     */
-    synchronized void join(long ms, int ns) throws InterruptedException
-    {
-       // Round up
-       ms += (ns != 0) ? 1 : 0;
-
-       // Compute end time, but don't overflow
-       long now = System.currentTimeMillis();
-       long end = now + ms;
-       if (end < now)
-           end = Long.MAX_VALUE;
-
-       // A VM is allowed to return from wait() without notify() having been
-       // called, so we loop to handle possible spurious wakeups.
-       while(thread.vmThread != null)
-       {
-           // We use the VMThread object to wait on, because this is a private
-           // object, so client code cannot call notify on us.
-           wait(ms);
-           if(ms != 0)
-           {
-               now = System.currentTimeMillis();
-               ms = end - now;
-               if(ms <= 0)
-               {
-                   break;
-               }
-           }
-       }
-    }
-
-    /**
-     * Cause this Thread to stop abnormally and throw the specified exception.
-     * If you stop a Thread that has not yet started, the stop is ignored
-     * (contrary to what the JDK documentation says).
-     * <b>WARNING</b>This bypasses Java security, and can throw a checked
-     * exception which the call stack is unprepared to handle. Do not abuse 
-     * this power.
-     *
-     * <p>This is inherently unsafe, as it can interrupt synchronized blocks and
-     * leave data in bad states.
-     *
-     * <p><b>NOTE</b> stop() should take care not to stop a thread if it is
-     * executing code in this class.
-     *
-     * @param t the Throwable to throw when the Thread dies
-     * @deprecated unsafe operation, try not to use
-     */
-    void stop(Throwable t)
-    {
-       // Note: we assume that we own the lock on thread
-       // (i.e. that Thread.stop() is synchronized)
-       if(running)
-           nativeStop(t);
-       else
-           thread.stillborn = t;
-    }
-
-    /**
-     * Create a native thread on the underlying platform and start it executing
-     * on the run method of this object.
-     * @param stacksize the requested size of the native thread stack
-     */
-    native void start(long stacksize);
-
-    /**
-     * Interrupt this thread.
-     */
-    native void interrupt();
-
-    /**
-     * Determine whether this Thread has been interrupted, but leave
-     * the <i>interrupted status</i> alone in the process.
-     *
-     * @return whether the Thread has been interrupted
-     */
-    native boolean isInterrupted();
-
-    /**
-     * Suspend this Thread.  It will not come back, ever, unless it is resumed.
-     */
-    native void suspend();
-
-    /**
-     * Resume this Thread.  If the thread is not suspended, this method does
-     * nothing.
-     */
-    native void resume();
-
-    /**
-     * Set the priority of the underlying platform thread.
-     *
-     * @param priority the new priority
-     */
-    native void nativeSetPriority(int priority);
-
-    /**
-     * Asynchronously throw the specified throwable in this Thread.
-     *
-     * @param t the exception to throw
-     */
-    native void nativeStop(Throwable t);
-
-    /**
-     * Return the Thread object associated with the currently executing
-     * thread.
-     *
-     * @return the currently executing Thread
-     */
-    static native Thread currentThread();
-
-    /**
-     * Yield to another thread. The Thread will not lose any locks it holds
-     * during this time. There are no guarantees which thread will be
-     * next to run, and it could even be this one, but most VMs will choose
-     * the highest priority thread that has been waiting longest.
-     */
-    static native void yield();
-
-    /**
-     * Suspend the current Thread's execution for the specified amount of
-     * time. The Thread will not lose any locks it has during this time. There
-     * are no guarantees which thread will be next to run, but most VMs will
-     * choose the highest priority thread that has been waiting longest.
-     *
-     * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
-     * not offer that fine a grain of timing resolution. Besides, there is
-     * no guarantee that this thread can start up immediately when time expires,
-     * because some other thread may be active.  So don't expect real-time
-     * performance.
-     *
-     * @param ms the number of milliseconds to sleep.
-     * @param ns the number of extra nanoseconds to sleep (0-999999)
-     * @throws InterruptedException if the Thread is (or was) interrupted;
-     *         it's <i>interrupted status</i> will be cleared
-     */
-    static void sleep(long ms, int ns) throws InterruptedException
-    {
-      // Note: JDK treats a zero length sleep is like Thread.yield(),
-      // without checking the interrupted status of the thread.
-      // It's unclear if this is a bug in the implementation or the spec.
-      // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213203
-      if (ms == 0 && ns == 0)
-       {
-         if (Thread.interrupted())
-           throw new InterruptedException();
-         return;
-       }
-
-      // Compute end time, but don't overflow
-      long now = System.currentTimeMillis();
-      long end = now + ms;
-      if (end < now)
-         end = Long.MAX_VALUE;
-
-      // A VM is allowed to return from wait() without notify() having been
-      // called, so we loop to handle possible spurious wakeups.
-      VMThread vt = Thread.currentThread().vmThread;
-      synchronized (vt)
-       {
-         while (true)
-           {
-             vt.wait(ms, ns);
-             now = System.currentTimeMillis();
-             if (now >= end)
-               break;
-             ms = end - now;
-             ns = 0;
-           }
-       }
-    }
-
-    /**
-     * Determine whether the current Thread has been interrupted, and clear
-     * the <i>interrupted status</i> in the process.
-     *
-     * @return whether the current Thread has been interrupted
-     */
-    static native boolean interrupted();
-
-    /**
-     * Checks whether the current thread holds the monitor on a given object.
-     * This allows you to do <code>assert Thread.holdsLock(obj)</code>.
-     *
-     * @param obj the object to check
-     * @return true if the current thread is currently synchronized on obj
-     * @throws NullPointerException if obj is null
-     */
-//     static boolean holdsLock(Object obj) 
-//     {
-//       /* Use obj.notify to check if the current thread holds
-//        * the monitor of the object.
-//        * If it doesn't, notify will throw an exception.
-//        */
-//       try 
-//     {
-//       obj.notify();
-//       // okay, current thread holds lock
-//       return true;
-//     }
-//       catch (IllegalMonitorStateException e)
-//     {
-//       // it doesn't hold the lock
-//       return false;
-//     }
-//     }
-    static native boolean holdsLock(Object obj);
-
-  /**
-   * Returns the current state of the thread.
-   * The value must be one of "BLOCKED", "NEW",
-   * "RUNNABLE", "TERMINATED", "TIMED_WAITING" or
-   * "WAITING".
-   *
-   * @return a string corresponding to one of the 
-   *         thread enumeration states specified above.
-   */
-  native String getState();
-
-}
diff --git a/src/classes/gnu/java/lang/reflect/Constructor.java b/src/classes/gnu/java/lang/reflect/Constructor.java
deleted file mode 100644 (file)
index 55b82e8..0000000
+++ /dev/null
@@ -1,449 +0,0 @@
-/* java.lang.reflect.Constructor - reflection of Java constructors
-   Copyright (C) 1998, 2001, 2004, 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.java.lang.ClassHelper;
-import gnu.java.lang.CPStringBuilder;
-
-import gnu.java.lang.reflect.MethodSignatureParser;
-
-import java.lang.annotation.Annotation;
-
-/**
- * The Constructor class represents a constructor of a class. It also allows
- * dynamic creation of an object, via reflection. Invocation on Constructor
- * objects knows how to do widening conversions, but throws
- * {@link IllegalArgumentException} if a narrowing conversion would be
- * necessary. You can query for information on this Constructor regardless
- * of location, but construction access may be limited by Java language
- * access controls. If you can't do it in the compiler, you can't normally
- * do it here either.<p>
- *
- * <B>Note:</B> This class returns and accepts types as Classes, even
- * primitive types; there are Class types defined that represent each
- * different primitive type.  They are <code>java.lang.Boolean.TYPE,
- * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class,
- * byte.class</code>, etc.  These are not to be confused with the
- * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are
- * real classes.<p>
- *
- * Also note that this is not a serializable class.  It is entirely feasible
- * to make it serializable using the Externalizable interface, but this is
- * on Sun, not me.
- *
- * @author John Keiser
- * @author Eric Blake <ebb9@email.byu.edu>
- * @see Member
- * @see Class
- * @see java.lang.Class#getConstructor(Class[])
- * @see java.lang.Class#getDeclaredConstructor(Class[])
- * @see java.lang.Class#getConstructors()
- * @see java.lang.Class#getDeclaredConstructors()
- * @since 1.1
- * @status updated to 1.4
- */
-public final class Constructor<T>
-  extends AccessibleObject
-  implements GenericDeclaration, Member
-{  
-  private static final int CONSTRUCTOR_MODIFIERS
-    = Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC;
-
-  private MethodSignatureParser p;
-
-  VMConstructor cons;
-
-  /**
-   * This class is uninstantiable outside this package.
-   */
-  Constructor(VMConstructor cons)
-  {
-    this.cons = cons;
-    cons.cons = this;
-  }
-
-  private Constructor()
-  {
-  }
-
-  /**
-   * Gets the class that declared this constructor.
-   * @return the class that declared this member
-   */
-  @SuppressWarnings("unchecked")
-  public Class<T> getDeclaringClass()
-  {
-    return (Class<T>) cons.getDeclaringClass();
-  }
-
-  /**
-   * Gets the name of this constructor (the non-qualified name of the class
-   * it was declared in).
-   * @return the name of this constructor
-   */
-  public String getName()
-  {
-    return cons.getDeclaringClass().getName();
-  }
-
-  /**
-   * Gets the modifiers this constructor uses.  Use the <code>Modifier</code>
-   * class to interpret the values. A constructor can only have a subset of the
-   * following modifiers: public, private, protected.
-   *
-   * @return an integer representing the modifiers to this Member
-   * @see Modifier
-   */
-  public int getModifiers()
-  {
-    return cons.getModifiersInternal() & CONSTRUCTOR_MODIFIERS;
-  }
-
-  /**
-   * Return true if this constructor is synthetic, false otherwise.
-   * A synthetic member is one which is created by the compiler,
-   * and which does not appear in the user's source code.
-   * @since 1.5
-   */
-  public boolean isSynthetic()
-  {
-    return (cons.getModifiersInternal() & Modifier.SYNTHETIC) != 0;
-  }
-
-  /**
-   * Return true if this is a varargs constructor, that is if
-   * the constructor takes a variable number of arguments.
-   * @since 1.5
-   */
-  public boolean isVarArgs()
-  {
-    return (cons.getModifiersInternal() & Modifier.VARARGS) != 0;
-  }
-
-  /**
-   * Get the parameter list for this constructor, in declaration order. If the
-   * constructor takes no parameters, returns a 0-length array (not null).
-   *
-   * @return a list of the types of the constructor's parameters
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?>[] getParameterTypes()
-  {
-    return (Class<?>[]) cons.getParameterTypes();
-  }
-
-  /**
-   * Get the exception types this constructor says it throws, in no particular
-   * order. If the constructor has no throws clause, returns a 0-length array
-   * (not null).
-   *
-   * @return a list of the types in the constructor's throws clause
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?>[] getExceptionTypes()
-  {
-    return (Class<?>[]) cons.getExceptionTypes();
-  }
-
-  /**
-   * Compare two objects to see if they are semantically equivalent.
-   * Two Constructors are semantically equivalent if they have the same
-   * declaring class and the same parameter list.  This ignores different
-   * exception clauses, but since you can't create a Method except through the
-   * VM, this is just the == relation.
-   *
-   * @param o the object to compare to
-   * @return <code>true</code> if they are equal; <code>false</code> if not.
-   */
-  public boolean equals(Object o)
-  {
-    return cons.equals(o);
-  }
-
-  /**
-   * Get the hash code for the Constructor. The Constructor hash code is the
-   * hash code of the declaring class's name.
-   *
-   * @return the hash code for the object
-   */
-  public int hashCode()
-  {
-    return getName().hashCode();
-  }
-
-  /**
-   * Get a String representation of the Constructor. A Constructor's String
-   * representation is "&lt;modifier&gt; &lt;classname&gt;(&lt;paramtypes&gt;)
-   * throws &lt;exceptions&gt;", where everything after ')' is omitted if
-   * there are no exceptions.<br> Example:
-   * <code>public java.io.FileInputStream(java.lang.Runnable)
-   * throws java.io.FileNotFoundException</code>
-   *
-   * @return the String representation of the Constructor
-   */
-  public String toString()
-  {
-    // 128 is a reasonable buffer initial size for constructor
-    CPStringBuilder sb = new CPStringBuilder(128);
-    Modifier.toString(getModifiers(), sb).append(' ');
-    sb.append(getDeclaringClass().getName()).append('(');
-    Class[] c = getParameterTypes();
-    if (c.length > 0)
-      {
-        sb.append(ClassHelper.getUserName(c[0]));
-        for (int i = 1; i < c.length; i++)
-          sb.append(',').append(ClassHelper.getUserName(c[i]));
-      }
-    sb.append(')');
-    c = getExceptionTypes();
-    if (c.length > 0)
-      {
-        sb.append(" throws ").append(c[0].getName());
-        for (int i = 1; i < c.length; i++)
-          sb.append(',').append(c[i].getName());
-      }
-    return sb.toString();
-  }
-
-  static <X extends GenericDeclaration>
-  void addTypeParameters(CPStringBuilder sb, TypeVariable<X>[] typeArgs)
-  {
-    if (typeArgs.length == 0)
-      return;
-    sb.append('<');
-    for (int i = 0; i < typeArgs.length; ++i)
-      {
-        if (i > 0)
-          sb.append(',');
-        sb.append(typeArgs[i]);
-      }
-    sb.append("> ");
-  }
-
-  public String toGenericString()
-  {
-    CPStringBuilder sb = new CPStringBuilder(128);
-    Modifier.toString(getModifiers(), sb).append(' ');
-    addTypeParameters(sb, getTypeParameters());
-    sb.append(getDeclaringClass().getName()).append('(');
-    Type[] types = getGenericParameterTypes();
-    if (types.length > 0)
-      {
-        sb.append(types[0]);
-        for (int i = 1; i < types.length; ++i)
-          sb.append(',').append(types[i]);
-      }
-    sb.append(')');
-    types = getGenericExceptionTypes();
-    if (types.length > 0)
-      {
-        sb.append(" throws ").append(types[0]);
-        for (int i = 1; i < types.length; i++)
-          sb.append(',').append(types[i]);
-      }
-    return sb.toString();
-  }
-
-  /**
-   * Create a new instance by invoking the constructor. Arguments are
-   * automatically unwrapped and widened, if needed.<p>
-   *
-   * If this class is abstract, you will get an
-   * <code>InstantiationException</code>. If the constructor takes 0
-   * arguments, you may use null or a 0-length array for <code>args</code>.<p>
-   *
-   * If this Constructor enforces access control, your runtime context is
-   * evaluated, and you may have an <code>IllegalAccessException</code> if
-   * you could not create this object in similar compiled code. If the class
-   * is uninitialized, you trigger class initialization, which may end in a
-   * <code>ExceptionInInitializerError</code>.<p>
-   *
-   * Then, the constructor is invoked. If it completes normally, the return
-   * value will be the new object. If it completes abruptly, the exception is
-   * wrapped in an <code>InvocationTargetException</code>.
-   *
-   * @param args the arguments to the constructor
-   * @return the newly created object
-   * @throws IllegalAccessException if the constructor could not normally be
-   *         called by the Java code (i.e. it is not public)
-   * @throws IllegalArgumentException if the number of arguments is incorrect;
-   *         or if the arguments types are wrong even with a widening
-   *         conversion
-   * @throws InstantiationException if the class is abstract
-   * @throws InvocationTargetException if the constructor throws an exception
-   * @throws ExceptionInInitializerError if construction triggered class
-   *         initialization, which then failed
-   */
-  @SuppressWarnings("unchecked")
-  public T newInstance(Object... args)
-    throws InstantiationException, IllegalAccessException,
-           InvocationTargetException
-  {
-    return (T) cons.construct(args);
-  }
-
-  /**
-   * Returns an array of <code>TypeVariable</code> objects that represents
-   * the type variables declared by this constructor, in declaration order.
-   * An array of size zero is returned if this constructor has no type
-   * variables.
-   *
-   * @return the type variables associated with this constructor.
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public TypeVariable<Constructor<T>>[] getTypeParameters()
-  {
-    if (p == null)
-      {
-       String sig = cons.getSignature();
-       if (sig == null)
-         return new TypeVariable[0];
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getTypeParameters();
-  }
-
-  /**
-   * Returns an array of <code>Type</code> objects that represents
-   * the exception types declared by this constructor, in declaration order.
-   * An array of size zero is returned if this constructor declares no
-   * exceptions.
-   *
-   * @return the exception types declared by this constructor. 
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public Type[] getGenericExceptionTypes()
-  {
-    if (p == null)
-      {
-       String sig = cons.getSignature();
-       if (sig == null)
-         return getExceptionTypes();
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getGenericExceptionTypes();
-  }
-
-  /**
-   * Returns an array of <code>Type</code> objects that represents
-   * the parameter list for this constructor, in declaration order.
-   * An array of size zero is returned if this constructor takes no
-   * parameters.
-   *
-   * @return a list of the types of the constructor's parameters
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public Type[] getGenericParameterTypes()
-  {
-    if (p == null)
-      {
-       String sig = cons.getSignature();
-       if (sig == null)
-         return getParameterTypes();
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getGenericParameterTypes();
-  }
-
-  /**
-   * <p>
-   * Return an array of arrays representing the annotations on each
-   * of the constructor's parameters.  The outer array is aligned against
-   * the parameters of the constructors and is thus equal in length to
-   * the number of parameters (thus having a length zero if there are none).
-   * Each array element in the outer array contains an inner array which
-   * holds the annotations.  This array has a length of zero if the parameter
-   * has no annotations.
-   * </p>
-   * <p>
-   * The returned annotations are serialized.  Changing the annotations has
-   * no affect on the return value of future calls to this method.
-   * </p>
-   * 
-   * @return an array of arrays which represents the annotations used on the
-   *         parameters of this constructor.  The order of the array elements
-   *         matches the declaration order of the parameters.
-   * @since 1.5
-   */
-  public Annotation[][] getParameterAnnotations()
-  {
-    return cons.getParameterAnnotations();
-  }
-
-  /**
-   * Returns the element's annotation for the specified annotation type,
-   * or <code>null</code> if no such annotation exists.
-   *
-   * @param annotationClass the type of annotation to look for.
-   * @return this element's annotation for the specified type, or
-   *         <code>null</code> if no such annotation exists.
-   * @throws NullPointerException if the annotation class is <code>null</code>.
-   */
-  @SuppressWarnings("unchecked")
-  public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
-  {
-    return (T) cons.getAnnotation(annotationClass);
-  }
-
-  /**
-   * Returns all annotations directly defined by the element.  If there are
-   * no annotations directly associated with the element, then a zero-length
-   * array will be returned.  The returned array may be modified by the client
-   * code, but this will have no effect on the annotation content of this
-   * class, and hence no effect on the return value of this method for
-   * future callers.
-   *
-   * @return the annotations directly defined by the element.
-   * @since 1.5
-   */
-  public Annotation[] getDeclaredAnnotations()
-  {
-    return cons.getDeclaredAnnotations();
-  }
-
-}
diff --git a/src/classes/gnu/java/lang/reflect/Field.java b/src/classes/gnu/java/lang/reflect/Field.java
deleted file mode 100644 (file)
index 4c2c183..0000000
+++ /dev/null
@@ -1,735 +0,0 @@
-/* java.lang.reflect.Field - reflection of Java fields
-   Copyright (C) 1998, 2001, 2005, 2008 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.java.lang.ClassHelper;
-import gnu.java.lang.CPStringBuilder;
-
-import gnu.java.lang.reflect.FieldSignatureParser;
-
-import java.lang.annotation.Annotation;
-
-/**
- * The Field class represents a member variable of a class. It also allows
- * dynamic access to a member, via reflection. This works for both
- * static and instance fields. Operations on Field objects know how to
- * do widening conversions, but throw {@link IllegalArgumentException} if
- * a narrowing conversion would be necessary. You can query for information
- * on this Field regardless of location, but get and set access may be limited
- * by Java language access controls. If you can't do it in the compiler, you
- * can't normally do it here either.<p>
- *
- * <B>Note:</B> This class returns and accepts types as Classes, even
- * primitive types; there are Class types defined that represent each
- * different primitive type.  They are <code>java.lang.Boolean.TYPE,
- * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class,
- * byte.class</code>, etc.  These are not to be confused with the
- * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are
- * real classes.<p>
- *
- * Also note that this is not a serializable class.  It is entirely feasible
- * to make it serializable using the Externalizable interface, but this is
- * on Sun, not me.
- *
- * @author John Keiser
- * @author Eric Blake <ebb9@email.byu.edu>
- * @see Member
- * @see Class
- * @see Class#getField(String)
- * @see Class#getDeclaredField(String)
- * @see Class#getFields()
- * @see Class#getDeclaredFields()
- * @since 1.1
- * @status updated to 1.4
- */
-public final class Field
-extends AccessibleObject implements Member
-{
-  static final int FIELD_MODIFIERS
-    = Modifier.FINAL | Modifier.PRIVATE | Modifier.PROTECTED
-      | Modifier.PUBLIC | Modifier.STATIC | Modifier.TRANSIENT
-      | Modifier.VOLATILE;
-
-  private FieldSignatureParser p;
-
-  VMField f;
-
-  /**
-   * This class is uninstantiable outside the package.
-   */
-  Field(VMField f)
-  {
-    this.f = f;
-    f.f = this;
-  }
-
-  /**
-   * Gets the class that declared this field, or the class where this field
-   * is a non-inherited member.
-   * @return the class that declared this member
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?> getDeclaringClass()
-  {
-    return (Class<?>) f.getDeclaringClass();
-  }
-
-  /**
-   * Gets the name of this field.
-   * @return the name of this field
-   */
-  public String getName()
-  {
-    return f.getName();
-  }
-
-  /**
-   * Gets the modifiers this field uses.  Use the <code>Modifier</code>
-   * class to interpret the values.  A field can only have a subset of the
-   * following modifiers: public, private, protected, static, final,
-   * transient, and volatile.
-   *
-   * @return an integer representing the modifiers to this Member
-   * @see Modifier
-   */
-  public int getModifiers()
-  {
-    return f.getModifiersInternal() & FIELD_MODIFIERS;
-  }
-
-  /**
-   * Return true if this field is synthetic, false otherwise.
-   * @since 1.5
-   */
-  public boolean isSynthetic()
-  {
-    return (f.getModifiersInternal() & Modifier.SYNTHETIC) != 0;
-  }
-
-  /**
-   * Return true if this field represents an enum constant,
-   * false otherwise.
-   * @since 1.5
-   */
-  public boolean isEnumConstant()
-  {
-    return (f.getModifiersInternal() & Modifier.ENUM) != 0;
-  }
-
-  /**
-   * Gets the type of this field.
-   * @return the type of this field
-   */
-  public Class<?> getType()
-  {
-    return f.getType();
-  }
-
-  /**
-   * Compare two objects to see if they are semantically equivalent.
-   * Two Fields are semantically equivalent if they have the same declaring
-   * class, name, and type. Since you can't creat a Field except through
-   * the VM, this is just the == relation.
-   *
-   * @param o the object to compare to
-   * @return <code>true</code> if they are equal; <code>false</code> if not
-   */
-  public boolean equals(Object o)
-  {
-    return f.equals(o);
-  }
-
-  /**
-   * Get the hash code for the Field. The Field hash code is the hash code
-   * of its name XOR'd with the hash code of its class name.
-   *
-   * @return the hash code for the object.
-   */
-  public int hashCode()
-  {
-    return f.getDeclaringClass().getName().hashCode() ^ f.getName().hashCode();
-  }
-
-  /**
-   * Get a String representation of the Field. A Field's String
-   * representation is "&lt;modifiers&gt; &lt;type&gt;
-   * &lt;class&gt;.&lt;fieldname&gt;".<br> Example:
-   * <code>public transient boolean gnu.parse.Parser.parseComplete</code>
-   *
-   * @return the String representation of the Field
-   */
-  public String toString()
-  {
-    // 64 is a reasonable buffer initial size for field
-    CPStringBuilder sb = new CPStringBuilder(64);
-    Modifier.toString(getModifiers(), sb).append(' ');
-    sb.append(ClassHelper.getUserName(getType())).append(' ');
-    sb.append(getDeclaringClass().getName()).append('.');
-    sb.append(getName());
-    return sb.toString();
-  }
-
-  public String toGenericString()
-  {
-    CPStringBuilder sb = new CPStringBuilder(64);
-    Modifier.toString(getModifiers(), sb).append(' ');
-    sb.append(getGenericType()).append(' ');
-    sb.append(getDeclaringClass().getName()).append('.');
-    sb.append(getName());
-    return sb.toString();
-  }
-
-  /**
-   * Get the value of this Field.  If it is primitive, it will be wrapped
-   * in the appropriate wrapper type (boolean = java.lang.Boolean).<p>
-   *
-   * If the field is static, <code>o</code> will be ignored. Otherwise, if
-   * <code>o</code> is null, you get a <code>NullPointerException</code>,
-   * and if it is incompatible with the declaring class of the field, you
-   * get an <code>IllegalArgumentException</code>.<p>
-   *
-   * Next, if this Field enforces access control, your runtime context is
-   * evaluated, and you may have an <code>IllegalAccessException</code> if
-   * you could not access this field in similar compiled code. If the field
-   * is static, and its class is uninitialized, you trigger class
-   * initialization, which may end in a
-   * <code>ExceptionInInitializerError</code>.<p>
-   *
-   * Finally, the field is accessed, and primitives are wrapped (but not
-   * necessarily in new objects). This method accesses the field of the
-   * declaring class, even if the instance passed in belongs to a subclass
-   * which declares another field to hide this one.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if <code>o</code> is not an instance of
-   *         the class or interface declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #getBoolean(Object)
-   * @see #getByte(Object)
-   * @see #getChar(Object)
-   * @see #getShort(Object)
-   * @see #getInt(Object)
-   * @see #getLong(Object)
-   * @see #getFloat(Object)
-   * @see #getDouble(Object)
-   */
-  public Object get(Object o)
-    throws IllegalAccessException
-  {
-    return f.get(o);
-  }
-
-  /**
-   * Get the value of this boolean Field. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a boolean field of
-   *         <code>o</code>, or if <code>o</code> is not an instance of the
-   *         declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public boolean getBoolean(Object o)
-    throws IllegalAccessException
-  {
-    return f.getBoolean(o);
-  }
-
-  /**
-   * Get the value of this byte Field. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte field of
-   *         <code>o</code>, or if <code>o</code> is not an instance of the
-   *         declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public byte getByte(Object o)
-    throws IllegalAccessException
-  {
-    return f.getByte(o);
-  }
-
-  /**
-   * Get the value of this Field as a char. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a char field of
-   *         <code>o</code>, or if <code>o</code> is not an instance
-   *         of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public char getChar(Object o)
-    throws IllegalAccessException
-  {
-    return f.getChar(o);
-  }
-
-  /**
-   * Get the value of this Field as a short. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte or short
-   *         field of <code>o</code>, or if <code>o</code> is not an instance
-   *         of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public short getShort(Object o)
-    throws IllegalAccessException
-  {
-    return f.getShort(o);
-  }
-
-  /**
-   * Get the value of this Field as an int. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, or
-   *         int field of <code>o</code>, or if <code>o</code> is not an
-   *         instance of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public int getInt(Object o)
-    throws IllegalAccessException
-  {
-    return f.getInt(o);
-  }
-
-  /**
-   * Get the value of this Field as a long. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, int,
-   *         or long field of <code>o</code>, or if <code>o</code> is not an
-   *         instance of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public long getLong(Object o)
-    throws IllegalAccessException
-  {
-    return f.getLong(o);
-  }
-
-  /**
-   * Get the value of this Field as a float. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, int,
-   *         long, or float field of <code>o</code>, or if <code>o</code> is
-   *         not an instance of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public float getFloat(Object o)
-    throws IllegalAccessException
-  {
-    return f.getFloat(o);
-  }
-
-  /**
-   * Get the value of this Field as a double. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, int,
-   *         long, float, or double field of <code>o</code>, or if
-   *         <code>o</code> is not an instance of the declaring class of this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public double getDouble(Object o)
-    throws IllegalAccessException
-  {
-    return f.getDouble(o);
-  }
-
-  /**
-   * Set the value of this Field.  If it is a primitive field, the value
-   * will be unwrapped from the passed object (boolean = java.lang.Boolean).<p>
-   *
-   * If the field is static, <code>o</code> will be ignored. Otherwise, if
-   * <code>o</code> is null, you get a <code>NullPointerException</code>,
-   * and if it is incompatible with the declaring class of the field, you
-   * get an <code>IllegalArgumentException</code>.<p>
-   *
-   * Next, if this Field enforces access control, your runtime context is
-   * evaluated, and you may have an <code>IllegalAccessException</code> if
-   * you could not access this field in similar compiled code. This also
-   * occurs whether or not there is access control if the field is final.
-   * If the field is primitive, and unwrapping your argument fails, you will
-   * get an <code>IllegalArgumentException</code>; likewise, this error
-   * happens if <code>value</code> cannot be cast to the correct object type.
-   * If the field is static, and its class is uninitialized, you trigger class
-   * initialization, which may end in a
-   * <code>ExceptionInInitializerError</code>.<p>
-   *
-   * Finally, the field is set with the widened value. This method accesses
-   * the field of the declaring class, even if the instance passed in belongs
-   * to a subclass which declares another field to hide this one.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if <code>value</code> cannot be
-   *         converted by a widening conversion to the underlying type of
-   *         the Field, or if <code>o</code> is not an instance of the class
-   *         declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #setBoolean(Object, boolean)
-   * @see #setByte(Object, byte)
-   * @see #setChar(Object, char)
-   * @see #setShort(Object, short)
-   * @see #setInt(Object, int)
-   * @see #setLong(Object, long)
-   * @see #setFloat(Object, float)
-   * @see #setDouble(Object, double)
-   */
-  public void set(Object o, Object value)
-    throws IllegalAccessException
-  {
-    f.set(o, value);
-  }
-
-  /**
-   * Set this boolean Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a boolean field, or if
-   *         <code>o</code> is not an instance of the class declaring this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setBoolean(Object o, boolean value)
-    throws IllegalAccessException
-  {
-    f.setBoolean(o, value);
-  }
-
-  /**
-   * Set this byte Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, int, long,
-   *         float, or double field, or if <code>o</code> is not an instance
-   *         of the class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setByte(Object o, byte value)
-    throws IllegalAccessException
-  {
-    f.setByte(o, value);
-  }
-
-  /**
-   * Set this char Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a char, int, long,
-   *         float, or double field, or if <code>o</code> is not an instance
-   *         of the class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setChar(Object o, char value)
-    throws IllegalAccessException
-  {
-    f.setChar(o, value);
-  }
-
-  /**
-   * Set this short Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a short, int, long,
-   *         float, or double field, or if <code>o</code> is not an instance
-   *         of the class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setShort(Object o, short value)
-    throws IllegalAccessException
-  {
-    f.setShort(o, value);
-  }
-
-  /**
-   * Set this int Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not an int, long, float, or
-   *         double field, or if <code>o</code> is not an instance of the
-   *         class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setInt(Object o, int value)
-    throws IllegalAccessException
-  {
-    f.setInt(o, value);
-  }
-
-  /**
-   * Set this long Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a long, float, or double
-   *         field, or if <code>o</code> is not an instance of the class
-   *         declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setLong(Object o, long value)
-    throws IllegalAccessException
-  {
-    f.setLong(o, value);
-  }
-
-  /**
-   * Set this float Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a float or long field, or
-   *         if <code>o</code> is not an instance of the class declaring this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setFloat(Object o, float value)
-    throws IllegalAccessException
-  {
-    f.setFloat(o, value);
-  }
-
-  /**
-   * Set this double Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a double field, or if
-   *         <code>o</code> is not an instance of the class declaring this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setDouble(Object o, double value)
-    throws IllegalAccessException
-  {
-    f.setDouble(o, value);
-  }
-
-  /**
-   * Return the generic type of the field. If the field type is not a generic
-   * type, the method returns the same as <code>getType()</code>.
-   *
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public Type getGenericType()
-  {
-    if (p == null)
-      {
-       String signature = f.getSignature();
-       if (signature == null)
-         return getType();
-       p = new FieldSignatureParser(getDeclaringClass(),
-                                    signature);
-      }
-    return p.getFieldType();
-  }
-
-  /**
-   * Returns the element's annotation for the specified annotation type,
-   * or <code>null</code> if no such annotation exists.
-   *
-   * @param annotationClass the type of annotation to look for.
-   * @return this element's annotation for the specified type, or
-   *         <code>null</code> if no such annotation exists.
-   * @throws NullPointerException if the annotation class is <code>null</code>.
-   */
-  @SuppressWarnings("unchecked")
-  public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
-  {
-    return (T) f.getAnnotation(annotationClass);
-  }
-
-  /**
-   * Returns all annotations directly defined by the element.  If there are
-   * no annotations directly associated with the element, then a zero-length
-   * array will be returned.  The returned array may be modified by the client
-   * code, but this will have no effect on the annotation content of this
-   * class, and hence no effect on the return value of this method for
-   * future callers.
-   *
-   * @return the annotations directly defined by the element.
-   * @since 1.5
-   */
-  public Annotation[] getDeclaredAnnotations()
-  {
-    return f.getDeclaredAnnotations();
-  }
-
-}
diff --git a/src/classes/gnu/java/lang/reflect/Method.java b/src/classes/gnu/java/lang/reflect/Method.java
deleted file mode 100644 (file)
index e787fb3..0000000
+++ /dev/null
@@ -1,499 +0,0 @@
-/* java.lang.reflect.Method - reflection of Java methods
-   Copyright (C) 1998, 2001, 2002, 2005, 2007, 2008 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.java.lang.ClassHelper;
-import gnu.java.lang.CPStringBuilder;
-
-import gnu.java.lang.reflect.MethodSignatureParser;
-
-import java.lang.annotation.Annotation;
-
-/**
- * The Method class represents a member method of a class. It also allows
- * dynamic invocation, via reflection. This works for both static and
- * instance methods. Invocation on Method objects knows how to do
- * widening conversions, but throws {@link IllegalArgumentException} if
- * a narrowing conversion would be necessary. You can query for information
- * on this Method regardless of location, but invocation access may be limited
- * by Java language access controls. If you can't do it in the compiler, you
- * can't normally do it here either.<p>
- *
- * <B>Note:</B> This class returns and accepts types as Classes, even
- * primitive types; there are Class types defined that represent each
- * different primitive type.  They are <code>java.lang.Boolean.TYPE,
- * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class,
- * byte.class</code>, etc.  These are not to be confused with the
- * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are
- * real classes.<p>
- *
- * Also note that this is not a serializable class.  It is entirely feasible
- * to make it serializable using the Externalizable interface, but this is
- * on Sun, not me.
- *
- * @author John Keiser
- * @author Eric Blake <ebb9@email.byu.edu>
- * @see Member
- * @see Class
- * @see java.lang.Class#getMethod(String,Class[])
- * @see java.lang.Class#getDeclaredMethod(String,Class[])
- * @see java.lang.Class#getMethods()
- * @see java.lang.Class#getDeclaredMethods()
- * @since 1.1
- * @status updated to 1.4
- */
-public final class Method
-extends AccessibleObject implements Member, GenericDeclaration
-{
-  private static final int METHOD_MODIFIERS
-    = Modifier.ABSTRACT | Modifier.FINAL | Modifier.NATIVE
-      | Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC
-      | Modifier.STATIC | Modifier.STRICT | Modifier.SYNCHRONIZED;
-
-  private MethodSignatureParser p;
-
-  VMMethod m;
-
-  /**
-   * This class is uninstantiable outside this package.
-   */
-  Method(VMMethod m)
-  {
-    this.m = m;
-    m.m = this;
-  }
-
-  /**
-   * Gets the class that declared this method, or the class where this method
-   * is a non-inherited member.
-   * @return the class that declared this member
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?> getDeclaringClass()
-  {
-    return (Class<?>) m.getDeclaringClass();
-  }
-
-  /**
-   * Gets the name of this method.
-   * @return the name of this method
-   */
-  public String getName()
-  {
-    return m.getName();
-  }
-
-  /**
-   * Gets the modifiers this method uses.  Use the <code>Modifier</code>
-   * class to interpret the values.  A method can only have a subset of the
-   * following modifiers: public, private, protected, abstract, static,
-   * final, synchronized, native, and strictfp.
-   *
-   * @return an integer representing the modifiers to this Member
-   * @see Modifier
-   */
-  public int getModifiers()
-  {
-    return m.getModifiersInternal() & METHOD_MODIFIERS;
-  }
-
-  /**
-   * Return true if this method is a bridge method.  A bridge method
-   * is generated by the compiler in some situations involving
-   * generics and inheritance.
-   * @since 1.5
-   */
-  public boolean isBridge()
-  {
-    return (m.getModifiersInternal() & Modifier.BRIDGE) != 0;
-  }
-
-  /**
-   * Return true if this method is synthetic, false otherwise.
-   * @since 1.5
-   */
-  public boolean isSynthetic()
-  {
-    return (m.getModifiersInternal() & Modifier.SYNTHETIC) != 0;
-  }
-
-  /**
-   * Return true if this is a varargs method, that is if
-   * the method takes a variable number of arguments.
-   * @since 1.5
-   */
-  public boolean isVarArgs()
-  {
-    return (m.getModifiersInternal() & Modifier.VARARGS) != 0;
-  }
-
-  /**
-   * Gets the return type of this method.
-   * @return the type of this method
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?> getReturnType()
-  {
-    return (Class<?>) m.getReturnType();
-  }
-
-  /**
-   * Get the parameter list for this method, in declaration order. If the
-   * method takes no parameters, returns a 0-length array (not null).
-   *
-   * @return a list of the types of the method's parameters
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?>[] getParameterTypes()
-  {
-    return (Class<?>[]) m.getParameterTypes();
-  }
-
-  /**
-   * Get the exception types this method says it throws, in no particular
-   * order. If the method has no throws clause, returns a 0-length array
-   * (not null).
-   *
-   * @return a list of the types in the method's throws clause
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?>[] getExceptionTypes()
-  {
-    return (Class<?>[]) m.getExceptionTypes();
-  }
-
-  /**
-   * Compare two objects to see if they are semantically equivalent.
-   * Two Methods are semantically equivalent if they have the same declaring
-   * class, name, parameter list, and return type.
-   *
-   * @param o the object to compare to
-   * @return <code>true</code> if they are equal; <code>false</code> if not
-   */
-  public boolean equals(Object o)
-  {
-    return m.equals(o);
-  }
-
-  /**
-   * Get the hash code for the Method. The Method hash code is the hash code
-   * of its name XOR'd with the hash code of its class name.
-   *
-   * @return the hash code for the object
-   */
-  public int hashCode()
-  {
-    return m.getDeclaringClass().getName().hashCode() ^ m.getName().hashCode();
-  }
-
-  /**
-   * Get a String representation of the Method. A Method's String
-   * representation is "&lt;modifiers&gt; &lt;returntype&gt;
-   * &lt;methodname&gt;(&lt;paramtypes&gt;) throws &lt;exceptions&gt;", where
-   * everything after ')' is omitted if there are no exceptions.<br> Example:
-   * <code>public static int run(java.lang.Runnable,int)</code>
-   *
-   * @return the String representation of the Method
-   */
-  public String toString()
-  {
-    // 128 is a reasonable buffer initial size for constructor
-    CPStringBuilder sb = new CPStringBuilder(128);
-    Modifier.toString(getModifiers(), sb).append(' ');
-    sb.append(ClassHelper.getUserName(getReturnType())).append(' ');
-    sb.append(getDeclaringClass().getName()).append('.');
-    sb.append(getName()).append('(');
-    Class[] c = getParameterTypes();
-    if (c.length > 0)
-      {
-        sb.append(ClassHelper.getUserName(c[0]));
-        for (int i = 1; i < c.length; i++)
-          sb.append(',').append(ClassHelper.getUserName(c[i]));
-      }
-    sb.append(')');
-    c = getExceptionTypes();
-    if (c.length > 0)
-      {
-        sb.append(" throws ").append(c[0].getName());
-        for (int i = 1; i < c.length; i++)
-          sb.append(',').append(c[i].getName());
-      }
-    return sb.toString();
-  }
-
-  public String toGenericString()
-  {
-    // 128 is a reasonable buffer initial size for constructor
-    CPStringBuilder sb = new CPStringBuilder(128);
-    Modifier.toString(getModifiers(), sb).append(' ');
-    Constructor.addTypeParameters(sb, getTypeParameters());
-    sb.append(getGenericReturnType()).append(' ');
-    sb.append(getDeclaringClass().getName()).append('.');
-    sb.append(getName()).append('(');
-    Type[] types = getGenericParameterTypes();
-    if (types.length > 0)
-      {
-        sb.append(types[0]);
-        for (int i = 1; i < types.length; i++)
-          sb.append(',').append(types[i]);
-      }
-    sb.append(')');
-    types = getGenericExceptionTypes();
-    if (types.length > 0)
-      {
-        sb.append(" throws ").append(types[0]);
-        for (int i = 1; i < types.length; i++)
-          sb.append(',').append(types[i]);
-      }
-    return sb.toString();
-  }
-
-  /**
-   * Invoke the method. Arguments are automatically unwrapped and widened,
-   * and the result is automatically wrapped, if needed.<p>
-   *
-   * If the method is static, <code>o</code> will be ignored. Otherwise,
-   * the method uses dynamic lookup as described in JLS 15.12.4.4. You cannot
-   * mimic the behavior of nonvirtual lookup (as in super.foo()). This means
-   * you will get a <code>NullPointerException</code> if <code>o</code> is
-   * null, and an <code>IllegalArgumentException</code> if it is incompatible
-   * with the declaring class of the method. If the method takes 0 arguments,
-   * you may use null or a 0-length array for <code>args</code>.<p>
-   *
-   * Next, if this Method enforces access control, your runtime context is
-   * evaluated, and you may have an <code>IllegalAccessException</code> if
-   * you could not acces this method in similar compiled code. If the method
-   * is static, and its class is uninitialized, you trigger class
-   * initialization, which may end in a
-   * <code>ExceptionInInitializerError</code>.<p>
-   *
-   * Finally, the method is invoked. If it completes normally, the return value
-   * will be null for a void method, a wrapped object for a primitive return
-   * method, or the actual return of an Object method. If it completes
-   * abruptly, the exception is wrapped in an
-   * <code>InvocationTargetException</code>.
-   *
-   * @param o the object to invoke the method on
-   * @param args the arguments to the method
-   * @return the return value of the method, wrapped in the appropriate
-   *         wrapper if it is primitive
-   * @throws IllegalAccessException if the method could not normally be called
-   *         by the Java code (i.e. it is not public)
-   * @throws IllegalArgumentException if the number of arguments is incorrect;
-   *         if the arguments types are wrong even with a widening conversion;
-   *         or if <code>o</code> is not an instance of the class or interface
-   *         declaring this method
-   * @throws InvocationTargetException if the method throws an exception
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static method triggered
-   *         class initialization, which then failed
-   */
-  public Object invoke(Object o, Object... args)
-    throws IllegalAccessException, InvocationTargetException
-  {
-    return m.invoke(o, args);
-  }
-
-  /**
-   * Returns an array of <code>TypeVariable</code> objects that represents
-   * the type variables declared by this constructor, in declaration order.
-   * An array of size zero is returned if this class has no type
-   * variables.
-   *
-   * @return the type variables associated with this class. 
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public TypeVariable<Method>[] getTypeParameters()
-  {
-    if (p == null)
-      {
-       String sig = m.getSignature();
-       if (sig == null)
-         return (TypeVariable<Method>[]) new TypeVariable[0];
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getTypeParameters();
-  }
-
-  /**
-   * Returns an array of <code>Type</code> objects that represents
-   * the exception types declared by this method, in declaration order.
-   * An array of size zero is returned if this method declares no
-   * exceptions.
-   *
-   * @return the exception types declared by this method. 
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public Type[] getGenericExceptionTypes()
-  {
-    if (p == null)
-      {
-       String sig = m.getSignature();
-       if (sig == null)
-         return getExceptionTypes();
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getGenericExceptionTypes();
-  }
-
-  /**
-   * Returns an array of <code>Type</code> objects that represents
-   * the parameter list for this method, in declaration order.
-   * An array of size zero is returned if this method takes no
-   * parameters.
-   *
-   * @return a list of the types of the method's parameters
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public Type[] getGenericParameterTypes()
-  {
-    if (p == null)
-      {
-       String sig = m.getSignature();
-       if (sig == null)
-         return getParameterTypes();
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getGenericParameterTypes();
-  }
-
-  /**
-   * Returns the return type of this method.
-   *
-   * @return the return type of this method
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public Type getGenericReturnType()
-  {
-    if (p == null)
-      {
-       String sig = m.getSignature();
-       if (sig == null)
-         return getReturnType();
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getGenericReturnType();
-  }
-
-  /**
-   * If this method is an annotation method, returns the default
-   * value for the method.  If there is no default value, or if the
-   * method is not a member of an annotation type, returns null.
-   * Primitive types are wrapped.
-   *
-   * @throws TypeNotPresentException if the method returns a Class,
-   * and the class cannot be found
-   *
-   * @since 1.5
-   */
-  public Object getDefaultValue()
-  {
-    return m.getDefaultValue();
-  }
-
-  /**
-   * <p>
-   * Return an array of arrays representing the annotations on each
-   * of the method's parameters.  The outer array is aligned against
-   * the parameters of the method and is thus equal in length to
-   * the number of parameters (thus having a length zero if there are none).
-   * Each array element in the outer array contains an inner array which
-   * holds the annotations.  This array has a length of zero if the parameter
-   * has no annotations.
-   * </p>
-   * <p>
-   * The returned annotations are serialized.  Changing the annotations has
-   * no affect on the return value of future calls to this method.
-   * </p>
-   * 
-   * @return an array of arrays which represents the annotations used on the
-   *         parameters of this method.  The order of the array elements
-   *         matches the declaration order of the parameters.
-   * @since 1.5
-   */
-  public Annotation[][] getParameterAnnotations()
-  {
-    return m.getParameterAnnotations();
-  }
-
-  /**
-   * Returns the element's annotation for the specified annotation type,
-   * or <code>null</code> if no such annotation exists.
-   *
-   * @param annotationClass the type of annotation to look for.
-   * @return this element's annotation for the specified type, or
-   *         <code>null</code> if no such annotation exists.
-   * @throws NullPointerException if the annotation class is <code>null</code>.
-   */
-  @SuppressWarnings("unchecked")
-  public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
-  {
-    return (T) m.getAnnotation(annotationClass);
-  }
-
-  /**
-   * Returns all annotations directly defined by the element.  If there are
-   * no annotations directly associated with the element, then a zero-length
-   * array will be returned.  The returned array may be modified by the client
-   * code, but this will have no effect on the annotation content of this
-   * class, and hence no effect on the return value of this method for
-   * future callers.
-   *
-   * @return the annotations directly defined by the element.
-   * @since 1.5
-   */
-  public Annotation[] getDeclaredAnnotations()
-  {
-    return m.getDeclaredAnnotations();
-  }
-
-}
diff --git a/src/classes/gnu/java/lang/reflect/Modifier.java b/src/classes/gnu/java/lang/reflect/Modifier.java
deleted file mode 100644 (file)
index 45d9b51..0000000
+++ /dev/null
@@ -1,354 +0,0 @@
-/* java.lang.reflect.Modifier
-   Copyright (C) 1998, 1999, 2001, 2002, 2005, 2008  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.java.lang.CPStringBuilder;
-
-/**
- * Modifier is a helper class with static methods to determine whether an
- * int returned from getModifiers() represents static, public, protected,
- * native, final, etc... and provides an additional method to print
- * out all of the modifiers in an int in order.
- * <p>
- * The methods in this class use the bitmask values in the VM spec to
- * determine the modifiers of an int. This means that a VM must return a
- * standard mask, conformant with the VM spec.  I don't know if this is how
- * Sun does it, but I'm willing to bet money that it is.
- *
- * @author John Keiser
- * @author Tom Tromey (tromey@cygnus.com)
- * @author Eric Blake (ebb9@email.byu.edu)
- * @see Member#getModifiers()
- * @see Method#getModifiers()
- * @see Field#getModifiers()
- * @see Constructor#getModifiers()
- * @see Class#getModifiers()
- * @since 1.1
- */
-public class Modifier
-{
-  /** <STRONG>This constructor really shouldn't be here ... there are no
-   * instance methods or variables of this class, so instantiation is
-   * worthless.  However, this function is in the 1.1 spec, so it is added
-   * for completeness.</STRONG>
-   */
-  public Modifier()
-  {
-  }
-
-  /**
-   * Public: accessible from any other class.
-   */
-  public static final int PUBLIC = 0x0001;
-
-  /**
-   * Private: accessible only from the same enclosing class.
-   */
-  public static final int PRIVATE = 0x0002;
-
-  /**
-   * Protected: accessible only to subclasses, or within the package.
-   */
-  public static final int PROTECTED = 0x0004;
-
-  /**
-   * Static:<br><ul>
-   * <li>Class: no enclosing instance for nested class.</li>
-   * <li>Field or Method: can be accessed or invoked without an
-   *     instance of the declaring class.</li>
-   * </ul>
-   */
-  public static final int STATIC = 0x0008;
-
-  /**
-   * Final:<br><ul>
-   * <li>Class: no subclasses allowed.</li>
-   * <li>Field: cannot be changed.</li>
-   * <li>Method: cannot be overriden.</li>
-   * </ul>
-   */
-  public static final int FINAL = 0x0010;
-
-  /**
-   * Synchronized: Method: lock the class while calling this method.
-   */
-  public static final int SYNCHRONIZED = 0x0020;
-
-  /**
-   * Volatile: Field: cannot be cached.
-   */
-  public static final int VOLATILE = 0x0040;
-
-  /**
-   * Transient: Field: not serialized or deserialized.
-   */
-  public static final int TRANSIENT = 0x0080;
-
-  /**
-   * Native: Method: use JNI to call this method.
-   */
-  public static final int NATIVE = 0x0100;
-
-  /**
-   * Interface: Class: is an interface.
-   */
-  public static final int INTERFACE = 0x0200;
-
-  /**
-   * Abstract:<br><ul>
-   * <li>Class: may not be instantiated.</li>
-   * <li>Method: may not be called.</li>
-   * </ul>
-   */
-  public static final int ABSTRACT = 0x0400;
-
-  /**
-   * Strictfp: Method: expressions are FP-strict.<p>
-   * Also used as a modifier for classes, to mean that all initializers
-   * and constructors are FP-strict, but does not show up in
-   * Class.getModifiers.
-   */
-  public static final int STRICT = 0x0800;
-
-
-  /**
-   * Super - treat invokespecial as polymorphic so that super.foo() works
-   * according to the JLS. This is a reuse of the synchronized constant
-   * to patch a hole in JDK 1.0. *shudder*.
-   */
-  static final int SUPER = 0x0020;
-
-  /**
-   * All the flags, only used by code in this package.
-   */
-  static final int ALL_FLAGS = 0xfff;
-
-  /**
-   * Flag indicating a bridge method.
-   */
-  static final int BRIDGE = 0x40;
-
-  /**
-   * Flag indicating a varargs method.
-   */
-  static final int VARARGS = 0x80;
-
-  /**
-   * Flag indicating a synthetic member.
-   */
-  static final int SYNTHETIC = 0x1000;
-
-  /**
-   * Flag indicating an enum constant or an enum class.
-   */
-  static final int ENUM = 0x4000;
-
-  /**
-   * Check whether the given modifier is abstract.
-   * @param mod the modifier.
-   * @return <code>true</code> if abstract, <code>false</code> otherwise.
-   */
-  public static boolean isAbstract(int mod)
-  {
-    return (mod & ABSTRACT) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is final.
-   * @param mod the modifier.
-   * @return <code>true</code> if final, <code>false</code> otherwise.
-   */
-  public static boolean isFinal(int mod)
-  {
-    return (mod & FINAL) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is an interface.
-   * @param mod the modifier.
-   * @return <code>true</code> if an interface, <code>false</code> otherwise.
-   */
-  public static boolean isInterface(int mod)
-  {
-    return (mod & INTERFACE) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is native.
-   * @param mod the modifier.
-   * @return <code>true</code> if native, <code>false</code> otherwise.
-   */
-  public static boolean isNative(int mod)
-  {
-    return (mod & NATIVE) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is private.
-   * @param mod the modifier.
-   * @return <code>true</code> if private, <code>false</code> otherwise.
-   */
-  public static boolean isPrivate(int mod)
-  {
-    return (mod & PRIVATE) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is protected.
-   * @param mod the modifier.
-   * @return <code>true</code> if protected, <code>false</code> otherwise.
-   */
-  public static boolean isProtected(int mod)
-  {
-    return (mod & PROTECTED) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is public.
-   * @param mod the modifier.
-   * @return <code>true</code> if public, <code>false</code> otherwise.
-   */
-  public static boolean isPublic(int mod)
-  {
-    return (mod & PUBLIC) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is static.
-   * @param mod the modifier.
-   * @return <code>true</code> if static, <code>false</code> otherwise.
-   */
-  public static boolean isStatic(int mod)
-  {
-    return (mod & STATIC) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is strictfp.
-   * @param mod the modifier.
-   * @return <code>true</code> if strictfp, <code>false</code> otherwise.
-   */
-  public static boolean isStrict(int mod)
-  {
-    return (mod & STRICT) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is synchronized.
-   * @param mod the modifier.
-   * @return <code>true</code> if synchronized, <code>false</code> otherwise.
-   */
-  public static boolean isSynchronized(int mod)
-  {
-    return (mod & SYNCHRONIZED) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is transient.
-   * @param mod the modifier.
-   * @return <code>true</code> if transient, <code>false</code> otherwise.
-   */
-  public static boolean isTransient(int mod)
-  {
-    return (mod & TRANSIENT) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is volatile.
-   * @param mod the modifier.
-   * @return <code>true</code> if volatile, <code>false</code> otherwise.
-   */
-  public static boolean isVolatile(int mod)
-  {
-    return (mod & VOLATILE) != 0;
-  }
-
-  /**
-   * Get a string representation of all the modifiers represented by the
-   * given int. The keywords are printed in this order:
-   * <code>&lt;public|protected|private&gt; abstract static final transient
-   * volatile synchronized native strictfp interface</code>.
-   *
-   * @param mod the modifier.
-   * @return the String representing the modifiers.
-   */
-  public static String toString(int mod)
-  {
-    return toString(mod, new CPStringBuilder()).toString();
-  }
-
-  /**
-   * Package helper method that can take a CPStringBuilder.
-   * @param mod the modifier
-   * @param r the CPStringBuilder to which the String representation is appended
-   * @return r, with information appended
-   */
-  static CPStringBuilder toString(int mod, CPStringBuilder r)
-  {
-    if (isPublic(mod))
-      r.append("public ");
-    if (isProtected(mod))
-      r.append("protected ");
-    if (isPrivate(mod))
-      r.append("private ");
-    if (isAbstract(mod))
-      r.append("abstract ");
-    if (isStatic(mod))
-      r.append("static ");
-    if (isFinal(mod))
-      r.append("final ");
-    if (isTransient(mod))
-      r.append("transient ");
-    if (isVolatile(mod))
-      r.append("volatile ");
-    if (isSynchronized(mod))
-      r.append("synchronized ");
-    if (isNative(mod))
-      r.append("native ");
-    if (isStrict(mod))
-      r.append("strictfp ");
-    if (isInterface(mod))
-      r.append("interface ");
-    
-    // Trim trailing space.
-    if ((mod & ALL_FLAGS) != 0)
-      r.setLength(r.length() - 1);
-    return r;
-  }
-}
diff --git a/src/classes/gnu/java/lang/reflect/VMConstructor.java b/src/classes/gnu/java/lang/reflect/VMConstructor.java
deleted file mode 100644 (file)
index 6a94711..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/* java.lang.reflect.VMConstructor - VM interface for reflection of Java constructors
-   Copyright (C) 1998, 2001, 2004, 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 java.lang.annotation.Annotation;
-
-import java.util.Arrays;
-import java.util.Map;
-
-final class VMConstructor
-{
-  Class clazz;
-  int slot;
-
-  /**
-   * Unparsed annotations.
-   */
-  private byte[] annotations = null;
-
-  /**
-   * Unparsed parameter annotations.
-   */
-  private byte[] parameterAnnotations = null;
-
-  /**
-   * Annotations get parsed the first time they are
-   * accessed and are then cached it this map.
-   */
-  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
-
-  /**
-   * Helper array for creating a new array from a java.util.Container.
-   */
-  private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
-    new Annotation[0];
-
-  /** 
-   * This field allows us to refer back to the main constructor instance.
-   *  It is set by the constructor of Constructor.
-   */
-  Constructor cons;
-
-  VMConstructor(Class clazz, int slot)
-  {
-    this.clazz = clazz;
-    this.slot = slot;
-  }
-
-  public Class getDeclaringClass()
-  {
-    return clazz;
-  }
-
-  /**
-   * Return the raw modifiers for this constructor.  In particular
-   * this will include the synthetic and varargs bits.
-   * @return the constructor's modifiers
-   */
-  native int getModifiersInternal();
-
-  /**
-   * Get the parameter list for this constructor, in declaration order. If the
-   * constructor takes no parameters, returns a 0-length array (not null).
-   *
-   * @return a list of the types of the constructor's parameters
-   */
-  native Class[] getParameterTypes();
-
-  /**
-   * Get the exception types this constructor says it throws, in no particular
-   * order. If the constructor has no throws clause, returns a 0-length array
-   * (not null).
-   *
-   * @return a list of the types in the constructor's throws clause
-   */
-  native Class[] getExceptionTypes();
-
-  native Object construct(Object[] args)
-    throws InstantiationException, IllegalAccessException,
-    InvocationTargetException;
-
-  /**
-   * Return the String in the Signature attribute for this constructor. If there
-   * is no Signature attribute, return null.
-   */
-  native String getSignature();
-  
-  /**
-   * <p>
-   * Return an array of arrays representing the annotations on each
-   * of the constructor's parameters.  The outer array is aligned against
-   * the parameters of the constructors and is thus equal in length to
-   * the number of parameters (thus having a length zero if there are none).
-   * Each array element in the outer array contains an inner array which
-   * holds the annotations.  This array has a length of zero if the parameter
-   * has no annotations.
-   * </p>
-   * <p>
-   * The returned annotations are serialized.  Changing the annotations has
-   * no affect on the return value of future calls to this method.
-   * </p>
-   * 
-   * @return an array of arrays which represents the annotations used on the
-   *         parameters of this constructor.  The order of the array elements
-   *         matches the declaration order of the parameters.
-   * @since 1.5
-   */
-  native Annotation[][] getParameterAnnotations();
-
-  /**
-   * Compare two objects to see if they are semantically equivalent.
-   * Two Constructors are semantically equivalent if they have the same
-   * declaring class and the same parameter list.  This ignores different
-   * exception clauses, but since you can't create a Method except through the
-   * VM, this is just the == relation.
-   *
-   * @param o the object to compare to
-   * @return <code>true</code> if they are equal; <code>false</code> if not.
-   */
-  public boolean equals(Object o)
-  {
-    if (!(o instanceof Constructor))
-      return false;
-    Constructor that = (Constructor)o; 
-    if (clazz != that.getDeclaringClass())
-      return false;
-    if (!Arrays.equals(getParameterTypes(), that.getParameterTypes()))
-      return false;
-    return true;
-  }
-
-  /**
-   * Returns the element's annotation for the specified annotation type,
-   * or <code>null</code> if no such annotation exists.
-   *
-   * @param annotationClass the type of annotation to look for.
-   * @return this element's annotation for the specified type, or
-   *         <code>null</code> if no such annotation exists.
-   * @throws NullPointerException if the annotation class is <code>null</code>.
-   */
-//   native Annotation getAnnotation(Class annotationClass);
-  Annotation getAnnotation(Class annotationClass) {
-    if (annotationClass == null)
-      throw new NullPointerException();
-
-    return declaredAnnotations().get(annotationClass);
-  }
-
-  /**
-   * Returns all annotations directly defined by the element.  If there are
-   * no annotations directly associated with the element, then a zero-length
-   * array will be returned.  The returned array may be modified by the client
-   * code, but this will have no effect on the annotation content of this
-   * class, and hence no effect on the return value of this method for
-   * future callers.
-   *
-   * @return the annotations directly defined by the element.
-   * @since 1.5
-   */
-//   native Annotation[] getDeclaredAnnotations();
-  Annotation[] getDeclaredAnnotations() {
-    return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
-  }
-
-  /**
-   * Parses the annotations if they aren't parsed yet and stores them into
-   * the declaredAnnotations map and return this map.
-   */
-  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
-
-}
diff --git a/src/classes/gnu/java/lang/reflect/VMField.java b/src/classes/gnu/java/lang/reflect/VMField.java
deleted file mode 100644 (file)
index eeb30a8..0000000
+++ /dev/null
@@ -1,583 +0,0 @@
-/* java.lang.reflect.Field - VM interface for reflection of Java fields
-   Copyright (C) 1998, 2001, 2005, 2008 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 java.lang.annotation.Annotation;
-
-import java.util.Map;
-
-final class VMField
-{
-  Class clazz;
-  String name;
-  int slot;
-  
-  /**
-   * Unparsed annotations.
-   */
-  private byte[] annotations = null;
-
-  /**
-   * Annotations get parsed the first time they are
-   * accessed and are then cached it this map.
-   */
-  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
-
-  /**
-   * Helper array for creating a new array from a java.util.Container.
-   */
-  private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
-    new Annotation[0];
-
-  /** 
-   * This field allows us to refer back to the main constructor instance.
-   *  It is set by the constructor of Field.
-   */
-  Field f;
-
-  VMField(Class clazz, String name, int slot)
-  {
-    this.clazz = clazz;
-    this.name = name;
-    this.slot = slot;
-  }
-
-  public Class getDeclaringClass()
-  {
-    return clazz;
-  }
-
-  public String getName()
-  {
-    return name;
-  }
-
-  /**
-   * Return the raw modifiers for this field.
-   * @return the field's modifiers
-   */
-  native int getModifiersInternal();
-
-  /**
-   * Gets the type of this field.
-   * @return the type of this field
-   */
-  native Class getType();
-
-  /**
-   * Get the value of this Field.  If it is primitive, it will be wrapped
-   * in the appropriate wrapper type (boolean = java.lang.Boolean).<p>
-   *
-   * If the field is static, <code>o</code> will be ignored. Otherwise, if
-   * <code>o</code> is null, you get a <code>NullPointerException</code>,
-   * and if it is incompatible with the declaring class of the field, you
-   * get an <code>IllegalArgumentException</code>.<p>
-   *
-   * Next, if this Field enforces access control, your runtime context is
-   * evaluated, and you may have an <code>IllegalAccessException</code> if
-   * you could not access this field in similar compiled code. If the field
-   * is static, and its class is uninitialized, you trigger class
-   * initialization, which may end in a
-   * <code>ExceptionInInitializerError</code>.<p>
-   *
-   * Finally, the field is accessed, and primitives are wrapped (but not
-   * necessarily in new objects). This method accesses the field of the
-   * declaring class, even if the instance passed in belongs to a subclass
-   * which declares another field to hide this one.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if <code>o</code> is not an instance of
-   *         the class or interface declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #getBoolean(Object)
-   * @see #getByte(Object)
-   * @see #getChar(Object)
-   * @see #getShort(Object)
-   * @see #getInt(Object)
-   * @see #getLong(Object)
-   * @see #getFloat(Object)
-   * @see #getDouble(Object)
-   */
-  native Object get(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this boolean Field. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a boolean field of
-   *         <code>o</code>, or if <code>o</code> is not an instance of the
-   *         declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native boolean getBoolean(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this byte Field. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte field of
-   *         <code>o</code>, or if <code>o</code> is not an instance of the
-   *         declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native byte getByte(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this Field as a char. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a char field of
-   *         <code>o</code>, or if <code>o</code> is not an instance
-   *         of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native char getChar(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this Field as a short. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte or short
-   *         field of <code>o</code>, or if <code>o</code> is not an instance
-   *         of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native short getShort(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this Field as an int. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, or
-   *         int field of <code>o</code>, or if <code>o</code> is not an
-   *         instance of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native int getInt(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this Field as a long. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, int,
-   *         or long field of <code>o</code>, or if <code>o</code> is not an
-   *         instance of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native long getLong(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this Field as a float. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, int,
-   *         long, or float field of <code>o</code>, or if <code>o</code> is
-   *         not an instance of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native float getFloat(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this Field as a double. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, int,
-   *         long, float, or double field of <code>o</code>, or if
-   *         <code>o</code> is not an instance of the declaring class of this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native double getDouble(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Set the value of this Field.  If it is a primitive field, the value
-   * will be unwrapped from the passed object (boolean = java.lang.Boolean).<p>
-   *
-   * If the field is static, <code>o</code> will be ignored. Otherwise, if
-   * <code>o</code> is null, you get a <code>NullPointerException</code>,
-   * and if it is incompatible with the declaring class of the field, you
-   * get an <code>IllegalArgumentException</code>.<p>
-   *
-   * Next, if this Field enforces access control, your runtime context is
-   * evaluated, and you may have an <code>IllegalAccessException</code> if
-   * you could not access this field in similar compiled code. This also
-   * occurs whether or not there is access control if the field is final.
-   * If the field is primitive, and unwrapping your argument fails, you will
-   * get an <code>IllegalArgumentException</code>; likewise, this error
-   * happens if <code>value</code> cannot be cast to the correct object type.
-   * If the field is static, and its class is uninitialized, you trigger class
-   * initialization, which may end in a
-   * <code>ExceptionInInitializerError</code>.<p>
-   *
-   * Finally, the field is set with the widened value. This method accesses
-   * the field of the declaring class, even if the instance passed in belongs
-   * to a subclass which declares another field to hide this one.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if <code>value</code> cannot be
-   *         converted by a widening conversion to the underlying type of
-   *         the Field, or if <code>o</code> is not an instance of the class
-   *         declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #setBoolean(Object, boolean)
-   * @see #setByte(Object, byte)
-   * @see #setChar(Object, char)
-   * @see #setShort(Object, short)
-   * @see #setInt(Object, int)
-   * @see #setLong(Object, long)
-   * @see #setFloat(Object, float)
-   * @see #setDouble(Object, double)
-   */
-  native void set(Object o, Object value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this boolean Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a boolean field, or if
-   *         <code>o</code> is not an instance of the class declaring this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setBoolean(Object o, boolean value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this byte Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, int, long,
-   *         float, or double field, or if <code>o</code> is not an instance
-   *         of the class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setByte(Object o, byte value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this char Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a char, int, long,
-   *         float, or double field, or if <code>o</code> is not an instance
-   *         of the class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setChar(Object o, char value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this short Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a short, int, long,
-   *         float, or double field, or if <code>o</code> is not an instance
-   *         of the class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setShort(Object o, short value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this int Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not an int, long, float, or
-   *         double field, or if <code>o</code> is not an instance of the
-   *         class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setInt(Object o, int value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this long Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a long, float, or double
-   *         field, or if <code>o</code> is not an instance of the class
-   *         declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setLong(Object o, long value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this float Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a float or long field, or
-   *         if <code>o</code> is not an instance of the class declaring this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setFloat(Object o, float value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this double Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a double field, or if
-   *         <code>o</code> is not an instance of the class declaring this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setDouble(Object o, double value)
-    throws IllegalAccessException;
-
-  /**
-   * Return the String in the Signature attribute for this field. If there
-   * is no Signature attribute, return null.
-   *
-   */
-  native String getSignature();
-
-  /**
-   * Compare two objects to see if they are semantically equivalent.
-   * Two Fields are semantically equivalent if they have the same declaring
-   * class, name, and type. Since you can't create a Field except through
-   * the VM, this is just the == relation.
-   *
-   * @param o the object to compare to
-   * @return <code>true</code> if they are equal; <code>false</code> if not
-   */
-  public boolean equals(Object o)
-  {
-    if (!(o instanceof Field))
-      return false;
-    Field that = (Field)o; 
-    if (clazz != that.getDeclaringClass())
-      return false;
-    if (!name.equals(that.getName()))
-      return false;
-    if (getType() != that.getType())
-      return false;
-    return true;
-  }
-
-  /**
-   * Returns the element's annotation for the specified annotation type,
-   * or <code>null</code> if no such annotation exists.
-   *
-   * @param annotationClass the type of annotation to look for.
-   * @return this element's annotation for the specified type, or
-   *         <code>null</code> if no such annotation exists.
-   * @throws NullPointerException if the annotation class is <code>null</code>.
-   */
-//   native Annotation getAnnotation(Class annotationClass);
-  Annotation getAnnotation(Class annotationClass){
-    if (annotationClass == null)
-      throw new NullPointerException();
-
-    return declaredAnnotations().get(annotationClass);
-  }
-
-  /**
-   * Returns all annotations directly defined by the element.  If there are
-   * no annotations directly associated with the element, then a zero-length
-   * array will be returned.  The returned array may be modified by the client
-   * code, but this will have no effect on the annotation content of this
-   * class, and hence no effect on the return value of this method for
-   * future callers.
-   *
-   * @return the annotations directly defined by the element.
-   * @since 1.5
-   */
-//   native Annotation[] getDeclaredAnnotations();
-  Annotation[] getDeclaredAnnotations() {
-    return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
-  }
-
-  /**
-   * Parses the annotations if they aren't parsed yet and stores them into
-   * the declaredAnnotations map and return this map.
-   */
-  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
-
-}
diff --git a/src/classes/gnu/java/lang/reflect/VMMethod.java b/src/classes/gnu/java/lang/reflect/VMMethod.java
deleted file mode 100644 (file)
index ad556f2..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-/* java.lang.reflect.VMMethod - VM interface for reflection of Java methods
-   Copyright (C) 1998, 2001, 2002, 2005, 2007, 2008 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 java.lang.annotation.Annotation;
-
-import java.util.Arrays;
-import java.util.Map;
-
-final class VMMethod
-{
-  Class clazz;
-  String name;
-  int slot;
-
-  /**
-   * Unparsed annotations.
-   */
-  private byte[] annotations          = null;
-
-  /**
-   * Unparsed parameter annotations.
-   */
-  private byte[] parameterAnnotations = null;
-  
-  /**
-   * Unparsed annotation default value.
-   */
-  private byte[] annotationDefault    = null;
-
-  /**
-   * Annotations get parsed the first time they are
-   * accessed and are then cached it this map.
-   */
-  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
-
-  /**
-   * Helper array for creating a new array from a java.util.Container.
-   */
-  private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
-    new Annotation[0];
-
-  /** 
-   * This field allows us to refer back to the main constructor instance.
-   *  It is set by the constructor of Field.
-   */
-  Method m;
-
-  public Class getDeclaringClass()
-  {
-    return clazz;
-  }
-
-  public String getName()
-  {
-    return name;
-  }
-
-  /**
-   * Return the raw modifiers for this method.
-   * @return the method's modifiers
-   */
-  native int getModifiersInternal();
-
-  /**
-   * Gets the return type of this method.
-   * @return the type of this method
-   */
-  native Class getReturnType();
-
-  /**
-   * Get the parameter list for this method, in declaration order. If the
-   * method takes no parameters, returns a 0-length array (not null).
-   *
-   * @return a list of the types of the method's parameters
-   */
-  native Class[] getParameterTypes();
-
-  /**
-   * Get the exception types this method says it throws, in no particular
-   * order. If the method has no throws clause, returns a 0-length array
-   * (not null).
-   *
-   * @return a list of the types in the method's throws clause
-   */
-  native Class[] getExceptionTypes();
-
-  native Object invoke(Object o, Object[] args)
-    throws IllegalAccessException, InvocationTargetException;
-
-  /**
-   * Return the String in the Signature attribute for this method. If there
-   * is no Signature attribute, return null.
-   */
-  native String getSignature();
-
-  /**
-   * If this method is an annotation method, returns the default
-   * value for the method.  If there is no default value, or if the
-   * method is not a member of an annotation type, returns null.
-   * Primitive types are wrapped.
-   *
-   * @throws TypeNotPresentException if the method returns a Class,
-   * and the class cannot be found
-   *
-   * @since 1.5
-   */
-  native Object getDefaultValue();
-
-  /**
-   * <p>
-   * Return an array of arrays representing the annotations on each
-   * of the method's parameters.  The outer array is aligned against
-   * the parameters of the method and is thus equal in length to
-   * the number of parameters (thus having a length zero if there are none).
-   * Each array element in the outer array contains an inner array which
-   * holds the annotations.  This array has a length of zero if the parameter
-   * has no annotations.
-   * </p>
-   * <p>
-   * The returned annotations are serialized.  Changing the annotations has
-   * no affect on the return value of future calls to this method.
-   * </p>
-   * 
-   * @return an array of arrays which represents the annotations used on the
-   *         parameters of this method.  The order of the array elements
-   *         matches the declaration order of the parameters.
-   * @since 1.5
-   */
-  native Annotation[][] getParameterAnnotations();
-
-  /**
-   * Compare two objects to see if they are semantically equivalent.
-   * Two Methods are semantically equivalent if they have the same declaring
-   * class, name, parameter list, and return type.
-   *
-   * @param o the object to compare to
-   * @return <code>true</code> if they are equal; <code>false</code> if not
-   */
-  public boolean equals(Object o)
-  {
-      // Implementation note:
-      // The following is a correct but possibly slow implementation.
-      //
-      // This class has a private field 'slot' that could be used by
-      // the VM implementation to "link" a particular method to a Class.
-      // In that case equals could be simply implemented as:
-      //
-      // if (o instanceof Method)
-      // {
-      //    Method m = (Method)o;
-      //    return m.declaringClass == this.declaringClass
-      //           && m.slot == this.slot;
-      // }
-      // return false;
-      //
-      // If a VM uses the Method class as their native/internal representation
-      // then just using the following would be optimal:
-      //
-      // return this == o;
-      //
-    if (!(o instanceof Method))
-      return false;
-    Method that = (Method)o;
-    if (clazz != that.getDeclaringClass())
-      return false;
-    if (!name.equals(that.getName()))
-      return false;
-    if (getReturnType() != that.getReturnType())
-      return false;
-    if (!Arrays.equals(getParameterTypes(), that.getParameterTypes()))
-      return false;
-    return true;
-  }
-
-  /**
-   * Returns the element's annotation for the specified annotation type,
-   * or <code>null</code> if no such annotation exists.
-   *
-   * @param annotationClass the type of annotation to look for.
-   * @return this element's annotation for the specified type, or
-   *         <code>null</code> if no such annotation exists.
-   * @throws NullPointerException if the annotation class is <code>null</code>.
-   */
-//   native Annotation getAnnotation(Class annotationClass);
-  Annotation getAnnotation(Class annotationClass) {
-    if (annotationClass == null)
-      throw new NullPointerException();
-
-    return declaredAnnotations().get(annotationClass);
-  }
-
-  /**
-   * Returns all annotations directly defined by the element.  If there are
-   * no annotations directly associated with the element, then a zero-length
-   * array will be returned.  The returned array may be modified by the client
-   * code, but this will have no effect on the annotation content of this
-   * class, and hence no effect on the return value of this method for
-   * future callers.
-   *
-   * @return the annotations directly defined by the element.
-   * @since 1.5
-   */
-//   native Annotation[] getDeclaredAnnotations();
-  Annotation[] getDeclaredAnnotations() {
-    return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
-  }
-
-  /**
-   * Parses the annotations if they aren't parsed yet and stores them into
-   * the declaredAnnotations map and return this map.
-   */
-  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
-
-}
-
diff --git a/src/classes/gnu/java/security/VMAccessController.java b/src/classes/gnu/java/security/VMAccessController.java
deleted file mode 100644 (file)
index 160df10..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-/* VMAccessController.java -- VM-specific access controller methods.
-   Copyright (C) 2004, 2005  Free Software Foundation, Inc.
-
-This program 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.
-
-This program 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 this program; 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.security;
-
-import java.util.HashSet;
-import java.util.LinkedList;
-
-final class VMAccessController
-{
-
-  // Fields.
-  // -------------------------------------------------------------------------
-
-  /**
-   * This is a per-thread stack of AccessControlContext objects (which can
-   * be null) for each call to AccessController.doPrivileged in each thread's
-   * call stack. We use this to remember which context object corresponds to
-   * which call.
-   */
-  private static final ThreadLocal contexts = new ThreadLocal();
-
-  /**
-   * This is a Boolean that, if set, tells getContext that it has already
-   * been called once, allowing us to handle recursive permission checks
-   * caused by methods getContext calls.
-   */
-  private static final ThreadLocal inGetContext = new ThreadLocal();
-
-  /**
-   * And we return this all-permissive context to ensure that privileged
-   * methods called from getContext succeed.
-   */
-  private static final AccessControlContext DEFAULT_CONTEXT;
-  static
-  {
-    CodeSource source = new CodeSource(null, null);
-    Permissions permissions = new Permissions();
-    permissions.add(new AllPermission());
-    ProtectionDomain[] domain = new ProtectionDomain[] {
-      new ProtectionDomain(source, permissions)
-    };
-    DEFAULT_CONTEXT = new AccessControlContext(domain);
-  }
-
-  private static final boolean DEBUG = gnu.classpath.Configuration.DEBUG;
-  private static void debug(String msg)
-  {
-    System.err.print(">>> VMAccessController: ");
-    System.err.println(msg);
-  }
-
-  // Constructors.
-  // -------------------------------------------------------------------------
-
-  private VMAccessController() { }
-
-  // Class methods.
-  // -------------------------------------------------------------------------
-
-  /**
-   * Relate a class (which should be an instance of {@link PrivilegedAction}
-   * with an access control context. This method is used by {@link
-   * AccessController#doPrivileged(java.security.PrivilegedAction,java.security.AccessControlContext)}
-   * to set up the context that will be returned by {@link #getContext()}.
-   * This method relates the class to the current thread, so contexts
-   * pushed from one thread will not be available to another.
-   *
-   * @param acc The access control context.
-   */
-  static void pushContext (AccessControlContext acc)
-  {
-    if (DEBUG)
-      debug("pushing " + acc);
-    LinkedList stack = (LinkedList) contexts.get();
-    if (stack == null)
-      {
-         if (DEBUG)
-           debug("no stack... creating ");
-        stack = new LinkedList();
-        contexts.set(stack);
-      }
-    stack.addFirst(acc);
-  }
-
-  /**
-   * Removes the relation of a class to an {@link AccessControlContext}.
-   * This method is used by {@link AccessController} when exiting from a
-   * call to {@link
-   * AccessController#doPrivileged(java.security.PrivilegedAction,java.security.AccessControlContext)}.
-   */
-  static void popContext()
-  {
-    if (DEBUG)
-      debug("popping context");
-
-    // Stack should never be null, nor should it be empty, if this method
-    // and its counterpart has been called properly.
-    LinkedList stack = (LinkedList) contexts.get();
-    if (stack != null)
-      {
-        stack.removeFirst();
-        if (stack.isEmpty())
-          contexts.set(null);
-      }
-    else if (DEBUG)
-      {
-        debug("no stack during pop?????");
-      }
-  }
-
-  /**
-   * Examine the method stack of the currently running thread, and create
-   * an {@link AccessControlContext} filled in with the appropriate {@link
-   * ProtectionDomain} objects given this stack.
-   *
-   * @return The context.
-   */
-  static AccessControlContext getContext()
-  {
-    // If we are already in getContext, but called a method that needs
-    // a permission check, return the all-permissive context so methods
-    // called from here succeed.
-    //
-    // XXX is this necessary? We should verify if there are any calls in
-    // the stack below this method that require permission checks.
-    Boolean inCall = (Boolean) inGetContext.get();
-    if (inCall != null && inCall.booleanValue())
-      {
-        if (DEBUG)
-          debug("already in getContext");
-        return DEFAULT_CONTEXT;
-      }
-
-    inGetContext.set(Boolean.TRUE);
-
-    Object[][] stack = getStack();
-    Class[] classes = (Class[]) stack[0];
-    String[] methods = (String[]) stack[1];
-
-    if (DEBUG)
-      debug("got trace of length " + classes.length);
-
-    HashSet domains = new HashSet();
-    HashSet seenDomains = new HashSet();
-    AccessControlContext context = null;
-    int privileged = 0;
-
-    // We walk down the stack, adding each ProtectionDomain for each
-    // class in the call stack. If we reach a call to doPrivileged,
-    // we don't add any more stack frames. We skip the first three stack
-    // frames, since they comprise the calls to getStack, getContext,
-    // and AccessController.getContext.
-    for (int i = 3; i < classes.length && privileged < 2; i++)
-      {
-        Class clazz = classes[i];
-        String method = methods[i];
-
-        if (DEBUG)
-          {
-            debug("checking " + clazz + "." + method);
-            // subject to getClassLoader RuntimePermission
-            debug("loader = " + clazz.getClassLoader());
-          }
-
-        // If the previous frame was a call to doPrivileged, then this is
-        // the last frame we look at.
-        if (privileged == 1)
-          privileged = 2;
-
-        if (clazz.equals (AccessController.class)
-            && method.equals ("doPrivileged"))
-          {
-            // If there was a call to doPrivileged with a supplied context,
-            // return that context. If using JAAS doAs*, it should be 
-           // a context with a SubjectDomainCombiner
-            LinkedList l = (LinkedList) contexts.get();
-            if (l != null)
-              context = (AccessControlContext) l.getFirst();
-            privileged = 1;
-          }
-
-        // subject to getProtectionDomain RuntimePermission
-       ProtectionDomain domain = clazz.getProtectionDomain();
-
-        if (domain == null)
-          continue;
-        if (seenDomains.contains(domain))
-          continue;
-        seenDomains.add(domain);
-
-        // Create a static snapshot of this domain, which may change over time
-        // if the current policy changes.
-        domains.add(new ProtectionDomain(domain.getCodeSource(),
-                                         domain.getPermissions()));
-      }
-
-    if (DEBUG)
-      debug("created domains: " + domains);
-
-    ProtectionDomain[] result = (ProtectionDomain[])
-      domains.toArray(new ProtectionDomain[domains.size()]);
-
-    if (context != null)
-      {
-        DomainCombiner dc = context.getDomainCombiner ();
-        // If the supplied context had no explicit DomainCombiner, use
-        // our private version, which computes the intersection of the
-        // context's domains with the derived set.
-        if (dc == null)
-          context = new AccessControlContext
-            (IntersectingDomainCombiner.SINGLETON.combine
-             (result, context.getProtectionDomains ()));
-        // Use the supplied DomainCombiner. This should be secure,
-        // because only trusted code may create an
-        // AccessControlContext with a custom DomainCombiner.
-        else
-          context = new AccessControlContext (result, context, dc);
-      }
-    // No context was supplied. Return the derived one.
-    else
-      context = new AccessControlContext (result);
-
-    inGetContext.set(Boolean.FALSE);
-    return context;
-  }
-
-  /**
-   * Returns a snapshot of the current call stack as a pair of arrays:
-   * the first an array of classes in the call stack, the second an array
-   * of strings containing the method names in the call stack. The two
-   * arrays match up, meaning that method <i>i</i> is declared in class
-   * <i>i</i>. The arrays are clean; it will only contain Java methods,
-   * and no element of the list should be null.
-   *
-   * <p>The default implementation returns an empty stack, which will be
-   * interpreted as having no permissions whatsoever.
-   *
-   * @return A pair of arrays describing the current call stack. The first
-   *    element is an array of Class objects, and the second is an array
-   *    of Strings comprising the method names.
-   */
-//    private static Object[][] getStack()
-//    {
-//      return new Object[][] { new Class[0], new String[0] };
-//    }
-  private native static Object[][] getStack();
-}
diff --git a/src/classes/gnu/sun/misc/Unsafe.java b/src/classes/gnu/sun/misc/Unsafe.java
deleted file mode 100644 (file)
index 2577488..0000000
+++ /dev/null
@@ -1,861 +0,0 @@
-/*
- * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.misc;
-
-import java.security.*;
-import java.lang.reflect.*;
-
-
-/**
- * A collection of methods for performing low-level, unsafe operations.
- * Although the class and all methods are public, use of this class is
- * limited because only trusted code can obtain instances of it.
- *
- * @author John R. Rose
- * @see #getUnsafe
- */
-
-public final class Unsafe {
-
-    private static native void registerNatives();
-    static {
-        registerNatives();
-//        sun.reflect.Reflection.registerMethodsToFilter(Unsafe.class, "getUnsafe");
-    }
-
-    private Unsafe() {}
-
-    private static final Unsafe theUnsafe = new Unsafe();
-
-    /**
-     * Provides the caller with the capability of performing unsafe
-     * operations.
-     *
-     * <p> The returned <code>Unsafe</code> object should be carefully guarded
-     * by the caller, since it can be used to read and write data at arbitrary
-     * memory addresses.  It must never be passed to untrusted code.
-     *
-     * <p> Most methods in this class are very low-level, and correspond to a
-     * small number of hardware instructions (on typical machines).  Compilers
-     * are encouraged to optimize these methods accordingly.
-     *
-     * <p> Here is a suggested idiom for using unsafe operations:
-     *
-     * <blockquote><pre>
-     * class MyTrustedClass {
-     *   private static final Unsafe unsafe = Unsafe.getUnsafe();
-     *   ...
-     *   private long myCountAddress = ...;
-     *   public int getCount() { return unsafe.getByte(myCountAddress); }
-     * }
-     * </pre></blockquote>
-     *
-     * (It may assist compilers to make the local variable be
-     * <code>final</code>.)
-     *
-     * @exception  SecurityException  if a security manager exists and its
-     *             <code>checkPropertiesAccess</code> method doesn't allow
-     *             access to the system properties.
-     */
-    public static Unsafe getUnsafe() {
-        Class cc = sun.reflect.Reflection.getCallerClass(2);
-        if (cc.getClassLoader() != null)
-            throw new SecurityException("Unsafe");
-        return theUnsafe;
-    }
-
-    /// peek and poke operations
-    /// (compilers should optimize these to memory ops)
-
-    // These work on object fields in the Java heap.
-    // They will not work on elements of packed arrays.
-
-    /**
-     * Fetches a value from a given Java variable.
-     * More specifically, fetches a field or array element within the given
-     * object <code>o</code> at the given offset, or (if <code>o</code> is
-     * null) from the memory address whose numerical value is the given
-     * offset.
-     * <p>
-     * The results are undefined unless one of the following cases is true:
-     * <ul>
-     * <li>The offset was obtained from {@link #objectFieldOffset} on
-     * the {@link java.lang.reflect.Field} of some Java field and the object
-     * referred to by <code>o</code> is of a class compatible with that
-     * field's class.
-     *
-     * <li>The offset and object reference <code>o</code> (either null or
-     * non-null) were both obtained via {@link #staticFieldOffset}
-     * and {@link #staticFieldBase} (respectively) from the
-     * reflective {@link Field} representation of some Java field.
-     *
-     * <li>The object referred to by <code>o</code> is an array, and the offset
-     * is an integer of the form <code>B+N*S</code>, where <code>N</code> is
-     * a valid index into the array, and <code>B</code> and <code>S</code> are
-     * the values obtained by {@link #arrayBaseOffset} and {@link
-     * #arrayIndexScale} (respectively) from the array's class.  The value
-     * referred to is the <code>N</code><em>th</em> element of the array.
-     *
-     * </ul>
-     * <p>
-     * If one of the above cases is true, the call references a specific Java
-     * variable (field or array element).  However, the results are undefined
-     * if that variable is not in fact of the type returned by this method.
-     * <p>
-     * This method refers to a variable by means of two parameters, and so
-     * it provides (in effect) a <em>double-register</em> addressing mode
-     * for Java variables.  When the object reference is null, this method
-     * uses its offset as an absolute address.  This is similar in operation
-     * to methods such as {@link #getInt(long)}, which provide (in effect) a
-     * <em>single-register</em> addressing mode for non-Java variables.
-     * However, because Java variables may have a different layout in memory
-     * from non-Java variables, programmers should not assume that these
-     * two addressing modes are ever equivalent.  Also, programmers should
-     * remember that offsets from the double-register addressing mode cannot
-     * be portably confused with longs used in the single-register addressing
-     * mode.
-     *
-     * @param o Java heap object in which the variable resides, if any, else
-     *        null
-     * @param offset indication of where the variable resides in a Java heap
-     *        object, if any, else a memory address locating the variable
-     *        statically
-     * @return the value fetched from the indicated Java variable
-     * @throws RuntimeException No defined exceptions are thrown, not even
-     *         {@link NullPointerException}
-     */
-    public native int getInt(Object o, long offset);
-
-    /**
-     * Stores a value into a given Java variable.
-     * <p>
-     * The first two parameters are interpreted exactly as with
-     * {@link #getInt(Object, long)} to refer to a specific
-     * Java variable (field or array element).  The given value
-     * is stored into that variable.
-     * <p>
-     * The variable must be of the same type as the method
-     * parameter <code>x</code>.
-     *
-     * @param o Java heap object in which the variable resides, if any, else
-     *        null
-     * @param offset indication of where the variable resides in a Java heap
-     *        object, if any, else a memory address locating the variable
-     *        statically
-     * @param x the value to store into the indicated Java variable
-     * @throws RuntimeException No defined exceptions are thrown, not even
-     *         {@link NullPointerException}
-     */
-    public native void putInt(Object o, long offset, int x);
-
-    /**
-     * Fetches a reference value from a given Java variable.
-     * @see #getInt(Object, long)
-     */
-    public native Object getObject(Object o, long offset);
-
-    /**
-     * Stores a reference value into a given Java variable.
-     * <p>
-     * Unless the reference <code>x</code> being stored is either null
-     * or matches the field type, the results are undefined.
-     * If the reference <code>o</code> is non-null, car marks or
-     * other store barriers for that object (if the VM requires them)
-     * are updated.
-     * @see #putInt(Object, int, int)
-     */
-    public native void putObject(Object o, long offset, Object x);
-
-    /** @see #getInt(Object, long) */
-    public native boolean getBoolean(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putBoolean(Object o, long offset, boolean x);
-    /** @see #getInt(Object, long) */
-    public native byte    getByte(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putByte(Object o, long offset, byte x);
-    /** @see #getInt(Object, long) */
-    public native short   getShort(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putShort(Object o, long offset, short x);
-    /** @see #getInt(Object, long) */
-    public native char    getChar(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putChar(Object o, long offset, char x);
-    /** @see #getInt(Object, long) */
-    public native long    getLong(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putLong(Object o, long offset, long x);
-    /** @see #getInt(Object, long) */
-    public native float   getFloat(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putFloat(Object o, long offset, float x);
-    /** @see #getInt(Object, long) */
-    public native double  getDouble(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putDouble(Object o, long offset, double x);
-
-    /**
-     * This method, like all others with 32-bit offsets, was native
-     * in a previous release but is now a wrapper which simply casts
-     * the offset to a long value.  It provides backward compatibility
-     * with bytecodes compiled against 1.4.
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public int getInt(Object o, int offset) {
-        return getInt(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putInt(Object o, int offset, int x) {
-        putInt(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public Object getObject(Object o, int offset) {
-        return getObject(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putObject(Object o, int offset, Object x) {
-        putObject(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public boolean getBoolean(Object o, int offset) {
-        return getBoolean(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putBoolean(Object o, int offset, boolean x) {
-        putBoolean(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public byte getByte(Object o, int offset) {
-        return getByte(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putByte(Object o, int offset, byte x) {
-        putByte(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public short getShort(Object o, int offset) {
-        return getShort(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putShort(Object o, int offset, short x) {
-        putShort(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public char getChar(Object o, int offset) {
-        return getChar(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putChar(Object o, int offset, char x) {
-        putChar(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public long getLong(Object o, int offset) {
-        return getLong(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putLong(Object o, int offset, long x) {
-        putLong(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public float getFloat(Object o, int offset) {
-        return getFloat(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putFloat(Object o, int offset, float x) {
-        putFloat(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public double getDouble(Object o, int offset) {
-        return getDouble(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putDouble(Object o, int offset, double x) {
-        putDouble(o, (long)offset, x);
-    }
-
-    // These work on values in the C heap.
-
-    /**
-     * Fetches a value from a given memory address.  If the address is zero, or
-     * does not point into a block obtained from {@link #allocateMemory}, the
-     * results are undefined.
-     *
-     * @see #allocateMemory
-     */
-    public native byte    getByte(long address);
-
-    /**
-     * Stores a value into a given memory address.  If the address is zero, or
-     * does not point into a block obtained from {@link #allocateMemory}, the
-     * results are undefined.
-     *
-     * @see #getByte(long)
-     */
-    public native void    putByte(long address, byte x);
-
-    /** @see #getByte(long) */
-    public native short   getShort(long address);
-    /** @see #putByte(long, byte) */
-    public native void    putShort(long address, short x);
-    /** @see #getByte(long) */
-    public native char    getChar(long address);
-    /** @see #putByte(long, byte) */
-    public native void    putChar(long address, char x);
-    /** @see #getByte(long) */
-    public native int     getInt(long address);
-    /** @see #putByte(long, byte) */
-    public native void    putInt(long address, int x);
-    /** @see #getByte(long) */
-    public native long    getLong(long address);
-    /** @see #putByte(long, byte) */
-    public native void    putLong(long address, long x);
-    /** @see #getByte(long) */
-    public native float   getFloat(long address);
-    /** @see #putByte(long, byte) */
-    public native void    putFloat(long address, float x);
-    /** @see #getByte(long) */
-    public native double  getDouble(long address);
-    /** @see #putByte(long, byte) */
-    public native void    putDouble(long address, double x);
-
-    /**
-     * Fetches a native pointer from a given memory address.  If the address is
-     * zero, or does not point into a block obtained from {@link
-     * #allocateMemory}, the results are undefined.
-     *
-     * <p> If the native pointer is less than 64 bits wide, it is extended as
-     * an unsigned number to a Java long.  The pointer may be indexed by any
-     * given byte offset, simply by adding that offset (as a simple integer) to
-     * the long representing the pointer.  The number of bytes actually read
-     * from the target address maybe determined by consulting {@link
-     * #addressSize}.
-     *
-     * @see #allocateMemory
-     */
-    public native long getAddress(long address);
-
-    /**
-     * Stores a native pointer into a given memory address.  If the address is
-     * zero, or does not point into a block obtained from {@link
-     * #allocateMemory}, the results are undefined.
-     *
-     * <p> The number of bytes actually written at the target address maybe
-     * determined by consulting {@link #addressSize}.
-     *
-     * @see #getAddress(long)
-     */
-    public native void putAddress(long address, long x);
-
-    /// wrappers for malloc, realloc, free:
-
-    /**
-     * Allocates a new block of native memory, of the given size in bytes.  The
-     * contents of the memory are uninitialized; they will generally be
-     * garbage.  The resulting native pointer will never be zero, and will be
-     * aligned for all value types.  Dispose of this memory by calling {@link
-     * #freeMemory}, or resize it with {@link #reallocateMemory}.
-     *
-     * @throws IllegalArgumentException if the size is negative or too large
-     *         for the native size_t type
-     *
-     * @throws OutOfMemoryError if the allocation is refused by the system
-     *
-     * @see #getByte(long)
-     * @see #putByte(long, byte)
-     */
-    public native long allocateMemory(long bytes);
-
-    /**
-     * Resizes a new block of native memory, to the given size in bytes.  The
-     * contents of the new block past the size of the old block are
-     * uninitialized; they will generally be garbage.  The resulting native
-     * pointer will be zero if and only if the requested size is zero.  The
-     * resulting native pointer will be aligned for all value types.  Dispose
-     * of this memory by calling {@link #freeMemory}, or resize it with {@link
-     * #reallocateMemory}.  The address passed to this method may be null, in
-     * which case an allocation will be performed.
-     *
-     * @throws IllegalArgumentException if the size is negative or too large
-     *         for the native size_t type
-     *
-     * @throws OutOfMemoryError if the allocation is refused by the system
-     *
-     * @see #allocateMemory
-     */
-    public native long reallocateMemory(long address, long bytes);
-
-    /**
-     * Sets all bytes in a given block of memory to a fixed value
-     * (usually zero).
-     */
-    public native void setMemory(long address, long bytes, byte value);
-
-    /**
-     * Sets all bytes in a given block of memory to a copy of another
-     * block.
-     */
-    public native void copyMemory(long srcAddress, long destAddress,
-                                  long bytes);
-
-    /**
-     * Disposes of a block of native memory, as obtained from {@link
-     * #allocateMemory} or {@link #reallocateMemory}.  The address passed to
-     * this method may be null, in which case no action is taken.
-     *
-     * @see #allocateMemory
-     */
-    public native void freeMemory(long address);
-
-    /// random queries
-
-    /**
-     * This constant differs from all results that will ever be returned from
-     * {@link #staticFieldOffset}, {@link #objectFieldOffset},
-     * or {@link #arrayBaseOffset}.
-     */
-    public static final int INVALID_FIELD_OFFSET   = -1;
-
-    /**
-     * Returns the offset of a field, truncated to 32 bits.
-     * This method is implemented as follows:
-     * <blockquote><pre>
-     * public int fieldOffset(Field f) {
-     *     if (Modifier.isStatic(f.getModifiers()))
-     *         return (int) staticFieldOffset(f);
-     *     else
-     *         return (int) objectFieldOffset(f);
-     * }
-     * </pre></blockquote>
-     * @deprecated As of 1.4.1, use {@link #staticFieldOffset} for static
-     * fields and {@link #objectFieldOffset} for non-static fields.
-     */
-    @Deprecated
-    public int fieldOffset(Field f) {
-        if (Modifier.isStatic(f.getModifiers()))
-            return (int) staticFieldOffset(f);
-        else
-            return (int) objectFieldOffset(f);
-    }
-
-    /**
-     * Returns the base address for accessing some static field
-     * in the given class.  This method is implemented as follows:
-     * <blockquote><pre>
-     * public Object staticFieldBase(Class c) {
-     *     Field[] fields = c.getDeclaredFields();
-     *     for (int i = 0; i < fields.length; i++) {
-     *         if (Modifier.isStatic(fields[i].getModifiers())) {
-     *             return staticFieldBase(fields[i]);
-     *         }
-     *     }
-     *     return null;
-     * }
-     * </pre></blockquote>
-     * @deprecated As of 1.4.1, use {@link #staticFieldBase(Field)}
-     * to obtain the base pertaining to a specific {@link Field}.
-     * This method works only for JVMs which store all statics
-     * for a given class in one place.
-     */
-    @Deprecated
-    public Object staticFieldBase(Class c) {
-        Field[] fields = c.getDeclaredFields();
-        for (int i = 0; i < fields.length; i++) {
-            if (Modifier.isStatic(fields[i].getModifiers())) {
-                return staticFieldBase(fields[i]);
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Report the location of a given field in the storage allocation of its
-     * class.  Do not expect to perform any sort of arithmetic on this offset;
-     * it is just a cookie which is passed to the unsafe heap memory accessors.
-     *
-     * <p>Any given field will always have the same offset and base, and no
-     * two distinct fields of the same class will ever have the same offset
-     * and base.
-     *
-     * <p>As of 1.4.1, offsets for fields are represented as long values,
-     * although the Sun JVM does not use the most significant 32 bits.
-     * However, JVM implementations which store static fields at absolute
-     * addresses can use long offsets and null base pointers to express
-     * the field locations in a form usable by {@link #getInt(Object,long)}.
-     * Therefore, code which will be ported to such JVMs on 64-bit platforms
-     * must preserve all bits of static field offsets.
-     * @see #getInt(Object, long)
-     */
-    public native long staticFieldOffset(Field f);
-
-    /**
-     * Report the location of a given static field, in conjunction with {@link
-     * #staticFieldBase}.
-     * <p>Do not expect to perform any sort of arithmetic on this offset;
-     * it is just a cookie which is passed to the unsafe heap memory accessors.
-     *
-     * <p>Any given field will always have the same offset, and no two distinct
-     * fields of the same class will ever have the same offset.
-     *
-     * <p>As of 1.4.1, offsets for fields are represented as long values,
-     * although the Sun JVM does not use the most significant 32 bits.
-     * It is hard to imagine a JVM technology which needs more than
-     * a few bits to encode an offset within a non-array object,
-     * However, for consistency with other methods in this class,
-     * this method reports its result as a long value.
-     * @see #getInt(Object, long)
-     */
-    public native long objectFieldOffset(Field f);
-
-    /**
-     * Report the location of a given static field, in conjunction with {@link
-     * #staticFieldOffset}.
-     * <p>Fetch the base "Object", if any, with which static fields of the
-     * given class can be accessed via methods like {@link #getInt(Object,
-     * long)}.  This value may be null.  This value may refer to an object
-     * which is a "cookie", not guaranteed to be a real Object, and it should
-     * not be used in any way except as argument to the get and put routines in
-     * this class.
-     */
-    public native Object staticFieldBase(Field f);
-
-    /**
-     * Ensure the given class has been initialized. This is often
-     * needed in conjunction with obtaining the static field base of a
-     * class.
-     */
-    public native void ensureClassInitialized(Class c);
-
-    /**
-     * Report the offset of the first element in the storage allocation of a
-     * given array class.  If {@link #arrayIndexScale} returns a non-zero value
-     * for the same class, you may use that scale factor, together with this
-     * base offset, to form new offsets to access elements of arrays of the
-     * given class.
-     *
-     * @see #getInt(Object, long)
-     * @see #putInt(Object, long, int)
-     */
-    public native int arrayBaseOffset(Class arrayClass);
-
-    /**
-     * Report the scale factor for addressing elements in the storage
-     * allocation of a given array class.  However, arrays of "narrow" types
-     * will generally not work properly with accessors like {@link
-     * #getByte(Object, int)}, so the scale factor for such classes is reported
-     * as zero.
-     *
-     * @see #arrayBaseOffset
-     * @see #getInt(Object, long)
-     * @see #putInt(Object, long, int)
-     */
-    public native int arrayIndexScale(Class arrayClass);
-
-    /**
-     * Report the size in bytes of a native pointer, as stored via {@link
-     * #putAddress}.  This value will be either 4 or 8.  Note that the sizes of
-     * other primitive types (as stored in native memory blocks) is determined
-     * fully by their information content.
-     */
-    public native int addressSize();
-
-    /**
-     * Report the size in bytes of a native memory page (whatever that is).
-     * This value will always be a power of two.
-     */
-    public native int pageSize();
-
-
-    /// random trusted operations from JNI:
-
-    /**
-     * Tell the VM to define a class, without security checks.  By default, the
-     * class loader and protection domain come from the caller's class.
-     */
-    public native Class defineClass(String name, byte[] b, int off, int len,
-                                    ClassLoader loader,
-                                    ProtectionDomain protectionDomain);
-
-    public native Class defineClass(String name, byte[] b, int off, int len);
-
-    /** Allocate an instance but do not run any constructor.
-        Initializes the class if it has not yet been. */
-    public native Object allocateInstance(Class cls)
-        throws InstantiationException;
-
-    /** Lock the object.  It must get unlocked via {@link #monitorExit}. */
-    public native void monitorEnter(Object o);
-
-    /**
-     * Unlock the object.  It must have been locked via {@link
-     * #monitorEnter}.
-     */
-    public native void monitorExit(Object o);
-
-    /**
-     * Tries to lock the object.  Returns true or false to indicate
-     * whether the lock succeeded.  If it did, the object must be
-     * unlocked via {@link #monitorExit}.
-     */
-    public native boolean tryMonitorEnter(Object o);
-
-    /** Throw the exception without telling the verifier. */
-    public native void throwException(Throwable ee);
-
-
-    /**
-     * Atomically update Java variable to <tt>x</tt> if it is currently
-     * holding <tt>expected</tt>.
-     * @return <tt>true</tt> if successful
-     */
-    public final native boolean compareAndSwapObject(Object o, long offset,
-                                                     Object expected,
-                                                     Object x);
-
-    /**
-     * Atomically update Java variable to <tt>x</tt> if it is currently
-     * holding <tt>expected</tt>.
-     * @return <tt>true</tt> if successful
-     */
-    public final native boolean compareAndSwapInt(Object o, long offset,
-                                                  int expected,
-                                                  int x);
-
-    /**
-     * Atomically update Java variable to <tt>x</tt> if it is currently
-     * holding <tt>expected</tt>.
-     * @return <tt>true</tt> if successful
-     */
-    public final native boolean compareAndSwapLong(Object o, long offset,
-                                                   long expected,
-                                                   long x);
-
-    /**
-     * Fetches a reference value from a given Java variable, with volatile
-     * load semantics. Otherwise identical to {@link #getObject(Object, long)}
-     */
-    public native Object getObjectVolatile(Object o, long offset);
-
-    /**
-     * Stores a reference value into a given Java variable, with
-     * volatile store semantics. Otherwise identical to {@link #putObject(Object, long, Object)}
-     */
-    public native void    putObjectVolatile(Object o, long offset, Object x);
-
-    /** Volatile version of {@link #getInt(Object, long)}  */
-    public native int     getIntVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putInt(Object, long, int)}  */
-    public native void    putIntVolatile(Object o, long offset, int x);
-
-    /** Volatile version of {@link #getBoolean(Object, long)}  */
-    public native boolean getBooleanVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putBoolean(Object, long, boolean)}  */
-    public native void    putBooleanVolatile(Object o, long offset, boolean x);
-
-    /** Volatile version of {@link #getByte(Object, long)}  */
-    public native byte    getByteVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putByte(Object, long, byte)}  */
-    public native void    putByteVolatile(Object o, long offset, byte x);
-
-    /** Volatile version of {@link #getShort(Object, long)}  */
-    public native short   getShortVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putShort(Object, long, short)}  */
-    public native void    putShortVolatile(Object o, long offset, short x);
-
-    /** Volatile version of {@link #getChar(Object, long)}  */
-    public native char    getCharVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putChar(Object, long, char)}  */
-    public native void    putCharVolatile(Object o, long offset, char x);
-
-    /** Volatile version of {@link #getLong(Object, long)}  */
-    public native long    getLongVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putLong(Object, long, long)}  */
-    public native void    putLongVolatile(Object o, long offset, long x);
-
-    /** Volatile version of {@link #getFloat(Object, long)}  */
-    public native float   getFloatVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putFloat(Object, long, float)}  */
-    public native void    putFloatVolatile(Object o, long offset, float x);
-
-    /** Volatile version of {@link #getDouble(Object, long)}  */
-    public native double  getDoubleVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putDouble(Object, long, double)}  */
-    public native void    putDoubleVolatile(Object o, long offset, double x);
-
-    /**
-     * Version of {@link #putObjectVolatile(Object, long, Object)}
-     * that does not guarantee immediate visibility of the store to
-     * other threads. This method is generally only useful if the
-     * underlying field is a Java volatile (or if an array cell, one
-     * that is otherwise only accessed using volatile accesses).
-     */
-    public native void    putOrderedObject(Object o, long offset, Object x);
-
-    /** Ordered/Lazy version of {@link #putIntVolatile(Object, long, int)}  */
-    public native void    putOrderedInt(Object o, long offset, int x);
-
-    /** Ordered/Lazy version of {@link #putLongVolatile(Object, long, long)} */
-    public native void    putOrderedLong(Object o, long offset, long x);
-
-    /**
-     * Unblock the given thread blocked on <tt>park</tt>, or, if it is
-     * not blocked, cause the subsequent call to <tt>park</tt> not to
-     * block.  Note: this operation is "unsafe" solely because the
-     * caller must somehow ensure that the thread has not been
-     * destroyed. Nothing special is usually required to ensure this
-     * when called from Java (in which there will ordinarily be a live
-     * reference to the thread) but this is not nearly-automatically
-     * so when calling from native code.
-     * @param thread the thread to unpark.
-     *
-     */
-    public native void unpark(Object thread);
-
-    /**
-     * Block current thread, returning when a balancing
-     * <tt>unpark</tt> occurs, or a balancing <tt>unpark</tt> has
-     * already occurred, or the thread is interrupted, or, if not
-     * absolute and time is not zero, the given time nanoseconds have
-     * elapsed, or if absolute, the given deadline in milliseconds
-     * since Epoch has passed, or spuriously (i.e., returning for no
-     * "reason"). Note: This operation is in the Unsafe class only
-     * because <tt>unpark</tt> is, so it would be strange to place it
-     * elsewhere.
-     */
-    public native void park(boolean isAbsolute, long time);
-
-    /**
-     * Gets the load average in the system run queue assigned
-     * to the available processors averaged over various periods of time.
-     * This method retrieves the given <tt>nelem</tt> samples and
-     * assigns to the elements of the given <tt>loadavg</tt> array.
-     * The system imposes a maximum of 3 samples, representing
-     * averages over the last 1,  5,  and  15 minutes, respectively.
-     *
-     * @params loadavg an array of double of size nelems
-     * @params nelems the number of samples to be retrieved and
-     *         must be 1 to 3.
-     *
-     * @return the number of samples actually retrieved; or -1
-     *         if the load average is unobtainable.
-     */
-    public native int getLoadAverage(double[] loadavg, int nelems);
-}
diff --git a/src/classes/gnu/sun/reflect/ConstantPool.java b/src/classes/gnu/sun/reflect/ConstantPool.java
deleted file mode 100644 (file)
index b24d28e..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.*;
-
-/** Provides reflective access to the constant pools of classes.
-    Currently this is needed to provide reflective access to annotations
-    but may be used by other internal subsystems in the future. */
-
-public class ConstantPool {
-  // Number of entries in this constant pool (= maximum valid constant pool index)
-  public int      getSize()                      { return getSize0            (constantPoolOop);        }
-  public Class    getClassAt         (int index) { return getClassAt0         (constantPoolOop, index); }
-  public Class    getClassAtIfLoaded (int index) { return getClassAtIfLoaded0 (constantPoolOop, index); }
-  // Returns either a Method or Constructor.
-  // Static initializers are returned as Method objects.
-  public Member   getMethodAt        (int index) { return getMethodAt0        (constantPoolOop, index); }
-  public Member   getMethodAtIfLoaded(int index) { return getMethodAtIfLoaded0(constantPoolOop, index); }
-  public Field    getFieldAt         (int index) { return getFieldAt0         (constantPoolOop, index); }
-  public Field    getFieldAtIfLoaded (int index) { return getFieldAtIfLoaded0 (constantPoolOop, index); }
-  // Fetches the class name, member (field, method or interface
-  // method) name, and type descriptor as an array of three Strings
-  public String[] getMemberRefInfoAt (int index) { return getMemberRefInfoAt0 (constantPoolOop, index); }
-  public int      getIntAt           (int index) { return getIntAt0           (constantPoolOop, index); }
-  public long     getLongAt          (int index) { return getLongAt0          (constantPoolOop, index); }
-  public float    getFloatAt         (int index) { return getFloatAt0         (constantPoolOop, index); }
-  public double   getDoubleAt        (int index) { return getDoubleAt0        (constantPoolOop, index); }
-  public String   getStringAt        (int index) { return getStringAt0        (constantPoolOop, index); }
-  public String   getUTF8At          (int index) { return getUTF8At0          (constantPoolOop, index); }
-
-  //---------------------------------------------------------------------------
-  // Internals only below this point
-  //
-/* This hides this member from being visible through the reflection API in OpenJDK
- * TODO: find out how to do this with GNU Classpath (if it's realy neccesary).
-
-  static {
-      Reflection.registerFieldsToFilter(ConstantPool.class, new String[] { "constantPoolOop" });
-  }
-*/
-  // HotSpot-internal constant pool object (set by the VM, name known to the VM)
-  private Object constantPoolOop;
-
-  private native int      getSize0            (Object constantPoolOop);
-  private native Class    getClassAt0         (Object constantPoolOop, int index);
-  private native Class    getClassAtIfLoaded0 (Object constantPoolOop, int index);
-  private native Member   getMethodAt0        (Object constantPoolOop, int index);
-  private native Member   getMethodAtIfLoaded0(Object constantPoolOop, int index);
-  private native Field    getFieldAt0         (Object constantPoolOop, int index);
-  private native Field    getFieldAtIfLoaded0 (Object constantPoolOop, int index);
-  private native String[] getMemberRefInfoAt0 (Object constantPoolOop, int index);
-  private native int      getIntAt0           (Object constantPoolOop, int index);
-  private native long     getLongAt0          (Object constantPoolOop, int index);
-  private native float    getFloatAt0         (Object constantPoolOop, int index);
-  private native double   getDoubleAt0        (Object constantPoolOop, int index);
-  private native String   getStringAt0        (Object constantPoolOop, int index);
-  private native String   getUTF8At0          (Object constantPoolOop, int index);
-}
diff --git a/src/classes/gnu/sun/reflect/annotation/AnnotationParser.java b/src/classes/gnu/sun/reflect/annotation/AnnotationParser.java
deleted file mode 100644 (file)
index 8c5aca3..0000000
+++ /dev/null
@@ -1,873 +0,0 @@
-/*
- * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect.annotation;
-
-import java.lang.annotation.*;
-import java.util.*;
-import java.nio.ByteBuffer;
-import java.nio.BufferUnderflowException;
-import java.lang.reflect.*;
-import sun.reflect.ConstantPool;
-
-import gnu.java.lang.reflect.FieldSignatureParser;
-
-
-/**
- * Parser for Java programming language annotations.  Translates
- * annotation byte streams emitted by compiler into annotation objects.
- *
- * @author  Josh Bloch
- * @since   1.5
- */
-public class AnnotationParser {
-    /**
-     * Parses the annotations described by the passed byte array,
-     * but returns Annotation[] so I don't have to do this in C.
-     *
-     * @author Mathias Panzenböck
-     * 
-     * @param rawAnnotations are the unparsed annotations
-     * @param constPool is the constant pool of the declaring class
-     * @param container is the containing class
-     * @return the parsed annotations in an array
-     * @throws AnnotationFormatError if an annotation is found to be
-     *         malformed.
-     */
-    public static Annotation[] parseAnnotationsIntoArray(
-                byte[] rawAnnotations,
-                ConstantPool constPool,
-                Class container) {
-        Map<Class, Annotation> annotations = parseAnnotations(rawAnnotations, constPool, container);
-        return annotations.values().toArray(EMPTY_ANNOTATIONS_ARRAY);
-    }
-
-    /**
-     * Parses parameter annotations.
-     * 
-     * @author Mathias Panzenböck
-     * 
-     * @param parameterAnnotations are the unparsed parameter annotations
-     * @param constPool is the constant pool of the declaring class
-     * @param container is the containing class
-     * @return the parsed parameter annotations in an array 2 dimensional array
-     * @throws AnnotationFormatError if an annotation is found to be
-     *         malformed.
-     */
-    public static Annotation[][] parseParameterAnnotations(
-                    byte[] parameterAnnotations,
-                    ConstantPool constPool,
-                    Class container,
-                    int numParameters) {
-        if (parameterAnnotations == null)
-            return new Annotation[numParameters][0];
-
-        Annotation[][] result = parseParameterAnnotations(
-            parameterAnnotations, constPool, container); 
-
-        if (result.length != numParameters)
-            throw new AnnotationFormatError(
-                "Parameter annotations don't match number of parameters (count was " +
-               result.length + " but should be " + numParameters + ").");
-        return result;
-    }
-
-    /**
-     * Parses the annotation default value of the supplied method.
-     * This method is basically copied from OpenJDKs
-     * java.lang.reflect.Method.getAnnotationDefault()
-     * 
-     * @author Mathias Panzenböck
-     *
-     * @param method represents the method for which the annotation default value has to be parsed
-     * @param annotationDefault is the unparsed annotation default value
-     * @param constPool is the constant pool of the declaring class
-     * @return the parsed annotation default value (boxed, if it's a primitive type)
-     * @throws AnnotationFormatError if an annotation is found to be
-     *         malformed.
-     */
-    public static Object parseAnnotationDefault(Method method,
-                                                byte[] annotationDefault,
-                                                ConstantPool constPool) {
-        if  (annotationDefault == null)
-            return null;
-        
-       Class memberType = AnnotationType.invocationHandlerReturnType(
-            method.getReturnType());
-        
-       Object result = AnnotationParser.parseMemberValue(
-            memberType, ByteBuffer.wrap(annotationDefault),
-            constPool, method.getDeclaringClass());
-
-        if (result instanceof sun.reflect.annotation.ExceptionProxy)
-            throw new AnnotationFormatError("Invalid default: " + method);
-        
-       return result;
-    }
-
-    /**
-     * Parses the annotations described by the specified byte array.
-     * resolving constant references in the specified constant pool.
-     * The array must contain an array of annotations as described
-     * in the RuntimeVisibleAnnotations_attribute:
-     *
-     *   u2 num_annotations;
-     *   annotation annotations[num_annotations];
-     *
-     * @throws AnnotationFormatError if an annotation is found to be
-     *         malformed.
-     */
-    public static Map<Class, Annotation> parseAnnotations(
-                byte[] rawAnnotations,
-                ConstantPool constPool,
-                Class container) {
-        if (rawAnnotations == null)
-            return Collections.emptyMap();
-
-        try {
-            return parseAnnotations2(rawAnnotations, constPool, container);
-        } catch(BufferUnderflowException e) {
-            throw new AnnotationFormatError("Unexpected end of annotations.");
-        } catch(IllegalArgumentException e) {
-            // Type mismatch in constant pool
-            throw new AnnotationFormatError(e);
-        }
-    }
-
-    private static Map<Class, Annotation> parseAnnotations2(
-                byte[] rawAnnotations,
-                ConstantPool constPool,
-                Class container) {
-        Map<Class, Annotation> result = new LinkedHashMap<Class, Annotation>();
-        ByteBuffer buf = ByteBuffer.wrap(rawAnnotations);
-        int numAnnotations = buf.getShort() & 0xFFFF;
-        for (int i = 0; i < numAnnotations; i++) {
-           Annotation a = parseAnnotation(buf, constPool, container, false);
-            if (a != null) {
-                Class klass = a.annotationType();
-                AnnotationType type = AnnotationType.getInstance(klass);
-                if (type.retention() == RetentionPolicy.RUNTIME)
-                    if (result.put(klass, a) != null)
-                        throw new AnnotationFormatError(
-                            "Duplicate annotation for class: "+klass+": " + a);
-            }
-        }
-        return result;
-    }
-
-    /**
-     * Parses the parameter annotations described by the specified byte array.
-     * resolving constant references in the specified constant pool.
-     * The array must contain an array of annotations as described
-     * in the RuntimeVisibleParameterAnnotations_attribute:
-     *
-     *    u1 num_parameters;
-     *    {
-     *        u2 num_annotations;
-     *        annotation annotations[num_annotations];
-     *    } parameter_annotations[num_parameters];
-     *
-     * Unlike parseAnnotations, rawAnnotations must not be null!
-     * A null value must be handled by the caller.  This is so because
-     * we cannot determine the number of parameters if rawAnnotations
-     * is null.  Also, the caller should check that the number
-     * of parameters indicated by the return value of this method
-     * matches the actual number of method parameters.  A mismatch
-     * indicates that an AnnotationFormatError should be thrown.
-     *
-     * @throws AnnotationFormatError if an annotation is found to be
-     *         malformed.
-     */
-    public static Annotation[][] parseParameterAnnotations(
-                    byte[] rawAnnotations,
-                    ConstantPool constPool,
-                    Class container) {
-        try {
-            return parseParameterAnnotations2(rawAnnotations, constPool, container);
-        } catch(BufferUnderflowException e) {
-            throw new AnnotationFormatError(
-                "Unexpected end of parameter annotations.");
-        } catch(IllegalArgumentException e) {
-            // Type mismatch in constant pool
-            throw new AnnotationFormatError(e);
-        }
-    }
-
-    private static Annotation[][] parseParameterAnnotations2(
-                    byte[] rawAnnotations,
-                    ConstantPool constPool,
-                    Class container) {
-        ByteBuffer buf = ByteBuffer.wrap(rawAnnotations);
-        int numParameters = buf.get() & 0xFF;
-        Annotation[][] result = new Annotation[numParameters][];
-
-        for (int i = 0; i < numParameters; i++) {
-            int numAnnotations = buf.getShort() & 0xFFFF;
-            List<Annotation> annotations =
-                new ArrayList<Annotation>(numAnnotations);
-            for (int j = 0; j < numAnnotations; j++) {
-                Annotation a = parseAnnotation(buf, constPool, container, false);
-                if (a != null) {
-                    AnnotationType type = AnnotationType.getInstance(
-                                              a.annotationType());
-                    if (type.retention() == RetentionPolicy.RUNTIME)
-                        annotations.add(a);
-                }
-            }
-            result[i] = annotations.toArray(EMPTY_ANNOTATIONS_ARRAY);
-        }
-        return result;
-    }
-
-    private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
-                    new Annotation[0];
-
-    /**
-     * Parses the annotation at the current position in the specified
-     * byte buffer, resolving constant references in the specified constant
-     * pool.  The cursor of the byte buffer must point to an "annotation
-     * structure" as described in the RuntimeVisibleAnnotations_attribute:
-     *
-     * annotation {
-     *    u2    type_index;
-     *       u2    num_member_value_pairs;
-     *       {    u2    member_name_index;
-     *             member_value value;
-     *       }    member_value_pairs[num_member_value_pairs];
-     *    }
-     * }
-     *
-     * Returns the annotation, or null if the annotation's type cannot
-     * be found by the VM, or is not a valid annotation type.
-     *
-     * @param exceptionOnMissingAnnotationClass if true, throw
-     * TypeNotPresentException if a referenced annotation type is not
-     * available at runtime
-     */
-    private static Annotation parseAnnotation(ByteBuffer buf,
-                                              ConstantPool constPool,
-                                              Class container,
-                                             boolean exceptionOnMissingAnnotationClass) {
-        int typeIndex = buf.getShort() & 0xFFFF;
-        Class annotationClass = null;
-       String sig = "[unknown]";
-        try {
-            try {
-                sig = constPool.getUTF8At(typeIndex);
-                annotationClass = parseSig(sig, container);
-            } catch (IllegalArgumentException ex) {
-                // support obsolete early jsr175 format class files
-                annotationClass = constPool.getClassAt(typeIndex);
-            }
-        } catch (NoClassDefFoundError e) {
-           if (exceptionOnMissingAnnotationClass)
-               // note: at this point sig is "[unknown]" or VM-style
-               // name instead of a binary name
-               throw new TypeNotPresentException(sig, e);
-            skipAnnotation(buf, false);
-            return null;
-        }
-       catch (TypeNotPresentException e) {
-           if (exceptionOnMissingAnnotationClass)
-               throw e;
-            skipAnnotation(buf, false);
-            return null;
-        }
-        AnnotationType type = null;
-        try {
-            type = AnnotationType.getInstance(annotationClass);
-        } catch (IllegalArgumentException e) {
-            skipAnnotation(buf, false);
-            return null;
-        }
-
-        Map<String, Class> memberTypes = type.memberTypes();
-        Map<String, Object> memberValues =
-            new LinkedHashMap<String, Object>(type.memberDefaults());
-
-        int numMembers = buf.getShort() & 0xFFFF;
-        for (int i = 0; i < numMembers; i++) {
-            int memberNameIndex = buf.getShort() & 0xFFFF;
-            String memberName = constPool.getUTF8At(memberNameIndex);
-            Class memberType = memberTypes.get(memberName);
-
-            if (memberType == null) {
-                // Member is no longer present in annotation type; ignore it
-                skipMemberValue(buf);
-            } else {
-                Object value = parseMemberValue(memberType, buf, constPool, container);
-                if (value instanceof AnnotationTypeMismatchExceptionProxy)
-                    ((AnnotationTypeMismatchExceptionProxy) value).
-                        setMember(type.members().get(memberName));
-                memberValues.put(memberName, value);
-            }
-        }
-        return annotationForMap(annotationClass, memberValues);
-    }
-
-    /**
-     * Returns an annotation of the given type backed by the given
-     * member -> value map.
-     */
-    public static Annotation annotationForMap(
-        Class type, Map<String, Object> memberValues)
-    {
-        return (Annotation) Proxy.newProxyInstance(
-            type.getClassLoader(), new Class[] { type },
-            new AnnotationInvocationHandler(type, memberValues));
-    }
-
-    /**
-     * Parses the annotation member value at the current position in the
-     * specified byte buffer, resolving constant references in the specified
-     * constant pool.  The cursor of the byte buffer must point to a
-     * "member_value structure" as described in the
-     * RuntimeVisibleAnnotations_attribute:
-     *
-     *  member_value {
-     *    u1 tag;
-     *    union {
-     *       u2   const_value_index;
-     *       {
-     *           u2   type_name_index;
-     *           u2   const_name_index;
-     *       } enum_const_value;
-     *       u2   class_info_index;
-     *       annotation annotation_value; 
-     *       {
-     *           u2    num_values;
-     *           member_value values[num_values];
-     *       } array_value;
-     *    } value;
-     * }
-     *
-     * The member must be of the indicated type. If it is not, this
-     * method returns an AnnotationTypeMismatchExceptionProxy.
-     */
-    public static Object parseMemberValue(Class memberType, ByteBuffer buf,
-                                          ConstantPool constPool,
-                                          Class container) {
-        Object result = null;
-        int tag = buf.get();
-        switch(tag) {
-          case 'e':
-              return parseEnumValue(memberType, buf, constPool, container);
-          case 'c':
-              result = parseClassValue(buf, constPool, container);
-              break;
-          case '@':
-              result = parseAnnotation(buf, constPool, container, true);
-              break;
-          case '[':
-              return parseArray(memberType, buf, constPool, container);
-          default:
-              result = parseConst(tag, buf, constPool);
-        }
-
-        if (!(result instanceof ExceptionProxy) &&
-            !memberType.isInstance(result))
-            result = new AnnotationTypeMismatchExceptionProxy(
-                result.getClass() + "[" + result + "]");
-        return result;
-    }
-
-    /**
-     * Parses the primitive or String annotation member value indicated by 
-     * the specified tag byte at the current position in the specified byte
-     * buffer, resolving constant reference in the specified constant pool.
-     * The cursor of the byte buffer must point to an annotation member value
-     * of the type indicated by the specified tag, as described in the
-     * RuntimeVisibleAnnotations_attribute:
-     *
-     *       u2   const_value_index;
-     */
-    private static Object parseConst(int tag,
-                                     ByteBuffer buf, ConstantPool constPool) {
-        int constIndex = buf.getShort() & 0xFFFF;
-        switch(tag) {
-          case 'B':
-            return Byte.valueOf((byte) constPool.getIntAt(constIndex));
-          case 'C':
-            return Character.valueOf((char) constPool.getIntAt(constIndex));
-          case 'D':
-            return Double.valueOf(constPool.getDoubleAt(constIndex));
-          case 'F':
-            return Float.valueOf(constPool.getFloatAt(constIndex));
-          case 'I':
-            return Integer.valueOf(constPool.getIntAt(constIndex));
-          case 'J':
-            return Long.valueOf(constPool.getLongAt(constIndex));
-          case 'S':
-            return Short.valueOf((short) constPool.getIntAt(constIndex));
-          case 'Z':
-            return Boolean.valueOf(constPool.getIntAt(constIndex) != 0);
-          case 's':
-            return constPool.getUTF8At(constIndex);
-          default:
-            throw new AnnotationFormatError(
-                "Invalid member-value tag in annotation: " + tag);
-        }
-    }
-
-    /**
-     * Parses the Class member value at the current position in the
-     * specified byte buffer, resolving constant references in the specified
-     * constant pool.  The cursor of the byte buffer must point to a "class
-     * info index" as described in the RuntimeVisibleAnnotations_attribute:
-     *
-     *       u2   class_info_index;
-     */
-    private static Object parseClassValue(ByteBuffer buf,
-                                          ConstantPool constPool,
-                                          Class container) {
-        int classIndex = buf.getShort() & 0xFFFF;
-        try {
-            try {
-                String sig = constPool.getUTF8At(classIndex);
-                return parseSig(sig, container);
-            } catch (IllegalArgumentException ex) {
-                // support obsolete early jsr175 format class files
-                return constPool.getClassAt(classIndex);
-            }
-        } catch (NoClassDefFoundError e) {
-            return new TypeNotPresentExceptionProxy("[unknown]", e);
-        }
-        catch (TypeNotPresentException e) {
-            return new TypeNotPresentExceptionProxy(e.typeName(), e.getCause());
-        }
-    }
-
-    /**
-     * Parses a return type signature and returns the according Class object.
-     */
-    private static Class<?> parseSig(String sig, Class container) {
-        if (sig.equals("V")) {
-            return void.class;
-        }
-        else {
-            return toClass(new FieldSignatureParser(container, sig).getFieldType());
-        }
-    }
-
-    static Class<?> toClass(Type o) {
-        if (o instanceof GenericArrayType)
-            return Array.newInstance(toClass(((GenericArrayType)o).getGenericComponentType()),
-                                     0)
-                .getClass();
-        return (Class<?>)o;
-    }
-
-    /**
-     * Parses the enum constant member value at the current position in the
-     * specified byte buffer, resolving constant references in the specified
-     * constant pool.  The cursor of the byte buffer must point to a
-     * "enum_const_value structure" as described in the
-     * RuntimeVisibleAnnotations_attribute:
-     *
-     *       {
-     *           u2   type_name_index;
-     *           u2   const_name_index;
-     *       } enum_const_value;
-     */
-    private static Object parseEnumValue(Class enumType, ByteBuffer buf,
-                                         ConstantPool constPool,
-                                         Class container) {
-        int typeNameIndex = buf.getShort() & 0xFFFF;
-        String typeName  = constPool.getUTF8At(typeNameIndex);
-        int constNameIndex = buf.getShort() & 0xFFFF;
-        String constName = constPool.getUTF8At(constNameIndex);
-
-        if (!typeName.endsWith(";")) {
-            // support now-obsolete early jsr175-format class files.
-            if (!enumType.getName().equals(typeName))
-            return new AnnotationTypeMismatchExceptionProxy(
-                typeName + "." + constName);
-        } else if (enumType != parseSig(typeName, container)) {
-            return new AnnotationTypeMismatchExceptionProxy(
-                typeName + "." + constName);
-        }
-
-        try {
-            return  Enum.valueOf(enumType, constName);
-        } catch(IllegalArgumentException e) {
-            return new EnumConstantNotPresentExceptionProxy(
-                (Class<? extends Enum>)enumType, constName);
-        }
-    }
-
-    /**
-     * Parses the array value at the current position in the specified byte
-     * buffer, resolving constant references in the specified constant pool.
-     * The cursor of the byte buffer must point to an array value struct
-     * as specified in the RuntimeVisibleAnnotations_attribute:
-     *
-     *       {
-     *           u2    num_values;
-     *           member_value values[num_values];
-     *       } array_value;
-     *
-     * If the array values do not match arrayType, an
-     * AnnotationTypeMismatchExceptionProxy will be returned.
-     */
-    private static Object parseArray(Class arrayType,
-                                     ByteBuffer buf,
-                                     ConstantPool constPool,
-                                     Class container) {
-        int length = buf.getShort() & 0xFFFF;  // Number of array components
-        Class componentType = arrayType.getComponentType();
-
-        if (componentType == byte.class) {
-            return parseByteArray(length, buf, constPool); 
-        } else if (componentType == char.class) {
-            return parseCharArray(length, buf, constPool);
-        } else if (componentType == double.class) {
-            return parseDoubleArray(length, buf, constPool);
-        } else if (componentType == float.class) {
-            return parseFloatArray(length, buf, constPool);
-        } else if (componentType == int.class) {
-            return parseIntArray(length, buf, constPool);
-        } else if (componentType == long.class) {
-            return parseLongArray(length, buf, constPool);
-        } else if (componentType == short.class) {
-            return parseShortArray(length, buf, constPool);
-        } else if (componentType == boolean.class) {
-            return parseBooleanArray(length, buf, constPool);
-        } else if (componentType == String.class) {
-            return parseStringArray(length, buf, constPool);
-        } else if (componentType == Class.class) {
-            return parseClassArray(length, buf, constPool, container);
-        } else if (componentType.isEnum()) {
-            return parseEnumArray(length, componentType, buf,
-                                  constPool, container);
-        } else {
-            assert componentType.isAnnotation();
-            return parseAnnotationArray(length, componentType, buf,
-                                        constPool, container);
-        }
-    }
-
-    private static Object parseByteArray(int length,
-                                  ByteBuffer buf, ConstantPool constPool) {
-        byte[] result = new byte[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'B') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = (byte) constPool.getIntAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseCharArray(int length,
-                                  ByteBuffer buf, ConstantPool constPool) {
-        char[] result = new char[length];
-        boolean typeMismatch = false;
-        byte tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'C') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = (char) constPool.getIntAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseDoubleArray(int length,
-                                    ByteBuffer buf, ConstantPool constPool) {
-        double[] result = new  double[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'D') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = constPool.getDoubleAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseFloatArray(int length,
-                                   ByteBuffer buf, ConstantPool constPool) {
-        float[] result = new float[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'F') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = constPool.getFloatAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseIntArray(int length,
-                                 ByteBuffer buf, ConstantPool constPool) {
-        int[] result = new  int[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'I') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = constPool.getIntAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-    
-    private static Object parseLongArray(int length,
-                                  ByteBuffer buf, ConstantPool constPool) {
-        long[] result = new long[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'J') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = constPool.getLongAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseShortArray(int length,
-                                   ByteBuffer buf, ConstantPool constPool) {
-        short[] result = new short[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'S') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = (short) constPool.getIntAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseBooleanArray(int length,
-                                     ByteBuffer buf, ConstantPool constPool) {
-        boolean[] result = new boolean[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'Z') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = (constPool.getIntAt(index) != 0);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseStringArray(int length,
-                                    ByteBuffer buf,  ConstantPool constPool) {
-        String[] result = new String[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 's') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = constPool.getUTF8At(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseClassArray(int length,
-                                          ByteBuffer buf,
-                                          ConstantPool constPool,
-                                          Class container) {
-        Object[] result = new Class[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'c') {
-                result[i] = parseClassValue(buf, constPool, container);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseEnumArray(int length, Class enumType,
-                                         ByteBuffer buf,
-                                         ConstantPool constPool,
-                                         Class container) {
-        Object[] result = (Object[]) Array.newInstance(enumType, length);
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'e') {
-                result[i] = parseEnumValue(enumType, buf, constPool, container);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseAnnotationArray(int length,
-                                               Class annotationType,
-                                               ByteBuffer buf,
-                                               ConstantPool constPool,
-                                               Class container) {
-        Object[] result = (Object[]) Array.newInstance(annotationType, length);
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == '@') {
-                result[i] = parseAnnotation(buf, constPool, container, true);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    /**
-     * Return an appropriate exception proxy for a mismatching array
-     * annotation where the erroneous array has the specified tag.
-     */
-    private static ExceptionProxy exceptionProxy(int tag) {
-        return new AnnotationTypeMismatchExceptionProxy(
-            "Array with component tag: " + tag);
-    }
-
-    /**
-     * Skips the annotation at the current position in the specified
-     * byte buffer.  The cursor of the byte buffer must point to 
-     * an "annotation structure" OR two bytes into an annotation
-     * structure (i.e., after the type index).
-     * 
-     * @parameter complete true if the byte buffer points to the beginning
-     *     of an annotation structure (rather than two bytes in).
-     */
-    private static void skipAnnotation(ByteBuffer buf, boolean complete) {
-        if (complete)
-            buf.getShort();   // Skip type index
-        int numMembers = buf.getShort() & 0xFFFF;
-        for (int i = 0; i < numMembers; i++) {
-            buf.getShort();   // Skip memberNameIndex
-            skipMemberValue(buf);
-        }
-    }
-
-    /**
-     * Skips the annotation member value at the current position in the
-     * specified byte buffer.  The cursor of the byte buffer must point to a
-     * "member_value structure."
-     */
-    private static void skipMemberValue(ByteBuffer buf) {
-        int tag = buf.get();
-        skipMemberValue(tag, buf);
-    }
-
-    /**
-     * Skips the annotation member value at the current position in the
-     * specified byte buffer.  The cursor of the byte buffer must point
-     * immediately after the tag in a "member_value structure."
-     */
-    private static void skipMemberValue(int tag, ByteBuffer buf) {
-        switch(tag) {
-          case 'e': // Enum value
-            buf.getInt();  // (Two shorts, actually.)
-            break;
-          case '@':
-            skipAnnotation(buf, true);
-            break;
-          case '[':
-            skipArray(buf);
-            break;
-          default:
-            // Class, primitive, or String
-            buf.getShort();
-        }
-    }
-
-    /**
-     * Skips the array value at the current position in the specified byte
-     * buffer.  The cursor of the byte buffer must point to an array value
-     * struct.
-     */
-    private static void skipArray(ByteBuffer buf) {
-        int length = buf.getShort() & 0xFFFF;
-        for (int i = 0; i < length; i++)
-            skipMemberValue(buf);
-    }
-}
diff --git a/src/classes/gnu/sun/reflect/annotation/AnnotationType.java b/src/classes/gnu/sun/reflect/annotation/AnnotationType.java
deleted file mode 100644 (file)
index ea559bb..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect.annotation;
-
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-import java.util.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * Represents an annotation type at run time.  Used to type-check annotations
- * and apply member defaults.
- *
- * @author  Josh Bloch
- * @since   1.5
- */
-public class AnnotationType {
-    /**
-     * Annotation class -> AnnotationType mapping. This emulates
-     * sun.misc.SharedSecrets.getJavaLangAccess().getAnnotationType() and
-     * sun.misc.SharedSecrets.getJavaLangAccess().setAnnotationType() so
-     * this class can be used with gnu classpath.
-     *
-     * @author Mathias Panzenböck
-     */
-    private static Map<Class, AnnotationType> annotationTypes =
-        new HashMap<Class, AnnotationType>();
-
-    /**
-     * Member name -> type mapping. Note that primitive types
-     * are represented by the class objects for the corresponding wrapper
-     * types.  This matches the return value that must be used for a
-     * dynamic proxy, allowing for a simple isInstance test.
-     */
-    private final Map<String, Class> memberTypes = new HashMap<String,Class>();
-
-    /**
-     * Member name -> default value mapping.
-     */
-    private final Map<String, Object> memberDefaults =
-        new HashMap<String, Object>();
-
-    /**
-     * Member name -> Method object mapping. This (and its assoicated
-     * accessor) are used only to generate AnnotationTypeMismatchExceptions.
-     */
-    private final Map<String, Method> members = new HashMap<String, Method>();
-
-    /**
-     * The retention policy for this annotation type.
-     */
-    private RetentionPolicy retention = RetentionPolicy.RUNTIME;;
-
-    /**
-     * Whether this annotation type is inherited.
-     */
-    private boolean inherited = false;
-
-    /**
-     * Returns an AnnotationType instance for the specified annotation type.
-     *
-     * @throw IllegalArgumentException if the specified class object for
-     *     does not represent a valid annotation type
-     */
-    public static synchronized AnnotationType getInstance(
-        Class annotationClass)
-    {
-        /*
-       AnnotationType result = sun.misc.SharedSecrets.getJavaLangAccess(). 
-            getAnnotationType(annotationClass); 
-        */
-       // emulating OpenJDKs SharedSecrets in GNU Classpath:
-       AnnotationType result = annotationTypes.get(annotationClass); 
-       if (result == null)
-            result = new AnnotationType((Class<?>) annotationClass);
-
-        return result;
-    }
-
-    /**
-     * Sole constructor.
-     *
-     * @param annotationClass the class object for the annotation type
-     * @throw IllegalArgumentException if the specified class object for
-     *     does not represent a valid annotation type
-     */
-    private AnnotationType(final Class<?> annotationClass) {
-        if (!annotationClass.isAnnotation())
-            throw new IllegalArgumentException("Not an annotation type");
-
-       Method[] methods =      
-           AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
-               public Method[] run() {
-                   // Initialize memberTypes and defaultValues
-                   return annotationClass.getDeclaredMethods();
-               }
-           });
-
-
-       for (Method method :  methods) {
-           if (method.getParameterTypes().length != 0)
-               throw new IllegalArgumentException(method + " has params");
-           String name = method.getName();
-           Class type = method.getReturnType();
-           memberTypes.put(name, invocationHandlerReturnType(type));
-           members.put(name, method);
-                   
-           Object defaultValue = method.getDefaultValue();
-           if (defaultValue != null)
-               memberDefaults.put(name, defaultValue);
-
-           members.put(name, method);
-       }
-
-       /*
-        sun.misc.SharedSecrets.getJavaLangAccess(). 
-            setAnnotationType(annotationClass, this); 
-        */
-       // emulating OpenJDKs SharedSecrets in GNU Classpath:
-       annotationTypes.put(annotationClass, this);
-
-        // Initialize retention, & inherited fields.  Special treatment
-        // of the corresponding annotation types breaks infinite recursion.
-        if (annotationClass != Retention.class &&
-            annotationClass != Inherited.class) {
-            Retention ret = annotationClass.getAnnotation(Retention.class);
-            retention = (ret == null ? RetentionPolicy.CLASS : ret.value());
-            inherited = annotationClass.isAnnotationPresent(Inherited.class);
-        }
-    }
-
-    /**
-     * Returns the type that must be returned by the invocation handler
-     * of a dynamic proxy in order to have the dynamic proxy return
-     * the specified type (which is assumed to be a legal member type
-     * for an annotation).
-     */
-    public static Class invocationHandlerReturnType(Class type) {
-        // Translate primitives to wrappers
-        if (type == byte.class)
-            return Byte.class;
-        if (type == char.class)
-            return Character.class;
-        if (type == double.class)
-            return Double.class;
-        if (type == float.class)
-            return Float.class;
-        if (type == int.class)
-            return Integer.class;
-        if (type == long.class)
-            return Long.class;
-        if (type == short.class)
-            return Short.class;
-        if (type == boolean.class)
-            return Boolean.class;
-
-        // Otherwise, just return declared type
-        return type;
-    }
-
-    /**
-     * Returns member types for this annotation type
-     * (member name -> type mapping).
-     */
-    public Map<String, Class> memberTypes() {
-        return memberTypes;
-    }
-
-    /**
-     * Returns members of this annotation type
-     * (member name -> associated Method object mapping).
-     */
-    public Map<String, Method> members() {
-        return members;
-    }
-
-    /**
-     * Returns the default values for this annotation type
-     * (Member name -> default value mapping).
-     */
-    public Map<String, Object> memberDefaults() {
-        return memberDefaults;
-    }
-
-    /**
-     * Returns the retention policy for this annotation type.
-     */
-    public RetentionPolicy retention() {
-        return retention;
-    }
-
-    /**
-     * Returns true if this this annotation type is inherited.
-     */
-    public boolean isInherited() {
-        return inherited;
-    }
-
-    /**
-     * For debugging.
-     */
-    public String toString() {
-        StringBuffer s = new StringBuffer("Annotation Type:" + "\n");
-        s.append("   Member types: " + memberTypes + "\n");
-        s.append("   Member defaults: " + memberDefaults + "\n");
-        s.append("   Retention policy: " + retention + "\n");
-        s.append("   Inherited: " + inherited);
-        return s.toString();
-    }
-}
diff --git a/src/classes/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java b/src/classes/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java
deleted file mode 100644 (file)
index a7f434f..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect.annotation;
-import java.lang.annotation.*;
-import java.lang.reflect.Method;
-
-/**
- * ExceptionProxy for AnnotationTypeMismatchException.
- *
- * @author  Josh Bloch
- * @since   1.5
- */
-class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy {
-    private Method member;
-    private String foundType;
-
-    /**
-     * It turns out to be convenient to construct these proxies in
-     * two stages.  Since this is a private implementation class, we
-     * permit ourselves this liberty even though it's normally a very
-     * bad idea.
-     */
-    AnnotationTypeMismatchExceptionProxy(String foundType) {
-        this.foundType = foundType;
-    }
-
-    AnnotationTypeMismatchExceptionProxy setMember(Method member) {
-        this.member = member;
-        return this;
-    }
-
-    protected RuntimeException generateException() {
-        return new AnnotationTypeMismatchException(member, foundType);
-    }
-}
diff --git a/src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java b/src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java
deleted file mode 100644 (file)
index 6049a3f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect.annotation;
-import java.lang.annotation.*;
-
-/**
- * ExceptionProxy for EnumConstantNotPresentException.
- *
- * @author  Josh Bloch
- * @since   1.5
- */
-public class EnumConstantNotPresentExceptionProxy extends ExceptionProxy {
-    Class<? extends Enum> enumType;
-    String constName;
-
-    public EnumConstantNotPresentExceptionProxy(Class<? extends Enum> enumType,
-                                                String constName) {
-        this.enumType = enumType;
-        this.constName = constName;
-    }
-
-    protected RuntimeException generateException() {
-        return new EnumConstantNotPresentException(enumType, constName);
-    }
-}
diff --git a/src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java b/src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java
deleted file mode 100644 (file)
index e9cda0b..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect.annotation;
-
-/**
- * An instance of this class is stored in an AnnotationInvocationHandler's
- * "memberValues" map in lieu of a value for an annotation member that
- * cannot be returned due to some exceptional condition (typically some
- * form of illegal evolution of the annotation class).  The ExceptionProxy
- * instance describes the exception that the dynamic proxy should throw if
- * it is queried for this member.
- *
- * @author  Josh Bloch
- * @since   1.5
- */
-public abstract class ExceptionProxy implements java.io.Serializable {
-    protected abstract RuntimeException generateException();
-}
diff --git a/src/classes/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java b/src/classes/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
deleted file mode 100644 (file)
index 22cab5d..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect.annotation;
-import java.lang.annotation.*;
-
-/**
- * ExceptionProxy for TypeNotPresentException.
- *
- * @author  Josh Bloch
- * @since   1.5
- */
-public class TypeNotPresentExceptionProxy extends ExceptionProxy {
-    String typeName;
-    Throwable cause;
-
-    public TypeNotPresentExceptionProxy(String typeName, Throwable cause) {
-        this.typeName = typeName;
-        this.cause = cause;
-    }
-
-    protected RuntimeException generateException() {
-        return new TypeNotPresentException(typeName, cause);
-    }
-}
diff --git a/src/classes/gnuclasspath/gnu/classpath/VMStackWalker.java b/src/classes/gnuclasspath/gnu/classpath/VMStackWalker.java
new file mode 100644 (file)
index 0000000..434edd2
--- /dev/null
@@ -0,0 +1,135 @@
+/* VMStackWalker.java -- Reference implementation of VM hooks for stack access
+   Copyright (C) 2005 Free Software Foundation
+
+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 gnu.classpath;
+
+/**
+ * This class provides access to the classes on the Java stack
+ * for reflection and security purposes.
+ *
+ * <p>
+ * This class is only available to privileged code (i.e., code loaded
+ * by the bootstrap loader).
+ *
+ * @author John Keiser
+ * @author Eric Blake <ebb9@email.byu.edu>
+ * @author Archie Cobbs
+ */
+public final class VMStackWalker
+{
+  /**
+   * Get a list of all the classes currently executing methods on the
+   * Java stack. <code>getClassContext()[0]</code> is the class associated
+   * with the currently executing method, i.e., the method that called
+   * <code>VMStackWalker.getClassContext()</code> (possibly through
+   * reflection). So you may need to pop off these stack frames from
+   * the top of the stack:
+   * <ul>
+   * <li><code>VMStackWalker.getClassContext()</code>
+   * <li><code>Method.invoke()</code>
+   * </ul>
+   *
+   * @return an array of the declaring classes of each stack frame
+   */
+  public static native Class[] getClassContext();
+
+  /**
+   * Get the class associated with the method invoking the method
+   * invoking this method, or <code>null</code> if the stack is not
+   * that deep (e.g., invoked via JNI invocation API). This method
+   * is an optimization for the expression <code>getClassContext()[1]</code>
+   * and should return the same result.
+   *
+   * <p>
+   * VM implementers are encouraged to provide a more efficient
+   * version of this method.
+   */
+//    public static Class getCallingClass()
+//    {
+//      Class[] ctx = getClassContext();
+//      if (ctx.length < 3)
+//        return null;
+//      return ctx[2];
+//    }
+  public static native Class getCallingClass();
+
+  /**
+   * Get the class loader associated with the Class returned by
+   * <code>getCallingClass()</code>, or <code>null</code> if no such class
+   * exists or it is the boot loader. This method is an optimization for the
+   * expression <code>VMStackWalker.getClassLoader(getClassContext()[1])</code>
+   * and should return the same result.
+   *
+   * <p>
+   * VM implementers are encouraged to provide a more efficient
+   * version of this method.
+   */
+//    public static ClassLoader getCallingClassLoader()
+//    {
+//      Class[] ctx = getClassContext();
+//      if (ctx.length < 3)
+//        return null;
+//      return getClassLoader(ctx[2]);
+//    }
+  public static native ClassLoader getCallingClassLoader();
+
+
+  /**
+   * Retrieve the class's ClassLoader, or <code>null</code> if loaded
+   * by the bootstrap loader. I.e., this should return the same thing
+   * as {@link java.lang.VMClass#getClassLoader}. This duplicate version
+   * is here to work around access permissions.
+   */
+//    public static native ClassLoader getClassLoader(Class cl);
+
+  /**
+   * Walk up the stack and return the first non-null class loader.
+   * If there aren't any non-null class loaders on the stack, return null.
+   */
+//   public static ClassLoader firstNonNullClassLoader()
+//   {
+//     Class[] stack = getClassContext();
+//     for (int i = 0; i < stack.length; i++)
+//       {
+//         ClassLoader loader = getClassLoader(stack[i]);
+//         if (loader != null)
+//           return loader;
+//       }
+//     return null;
+//   }
+    public static native ClassLoader firstNonNullClassLoader();
+}
diff --git a/src/classes/gnuclasspath/gnu/classpath/VMSystemProperties.java b/src/classes/gnuclasspath/gnu/classpath/VMSystemProperties.java
new file mode 100644 (file)
index 0000000..287a933
--- /dev/null
@@ -0,0 +1,98 @@
+/* VMSystemProperties.java -- Allow the VM to set System properties.
+   Copyright (C) 2004 Free Software Foundation
+
+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 gnu.classpath;
+
+import java.util.Properties;
+
+class VMSystemProperties
+{
+    /**
+     * Get the system properties. This is done here, instead of in System,
+     * because of the bootstrap sequence. Note that the native code should
+     * not try to use the Java I/O classes yet, as they rely on the properties
+     * already existing. The only safe method to use to insert these default
+     * system properties is {@link Properties#setProperty(String, String)}.
+     *
+     * <p>These properties MUST include:
+     * <dl>
+     * <dt>java.version         <dd>Java version number
+     * <dt>java.vendor          <dd>Java vendor specific string
+     * <dt>java.vendor.url      <dd>Java vendor URL
+     * <dt>java.home            <dd>Java installation directory
+     * <dt>java.vm.specification.version <dd>VM Spec version
+     * <dt>java.vm.specification.vendor  <dd>VM Spec vendor
+     * <dt>java.vm.specification.name    <dd>VM Spec name
+     * <dt>java.vm.version      <dd>VM implementation version
+     * <dt>java.vm.vendor       <dd>VM implementation vendor
+     * <dt>java.vm.name         <dd>VM implementation name
+     * <dt>java.specification.version    <dd>Java Runtime Environment version
+     * <dt>java.specification.vendor     <dd>Java Runtime Environment vendor
+     * <dt>java.specification.name       <dd>Java Runtime Environment name
+     * <dt>java.class.version   <dd>Java class version number
+     * <dt>java.class.path      <dd>Java classpath
+     * <dt>java.library.path    <dd>Path for finding Java libraries
+     * <dt>java.io.tmpdir       <dd>Default temp file path
+     * <dt>java.compiler        <dd>Name of JIT to use
+     * <dt>java.ext.dirs        <dd>Java extension path
+     * <dt>os.name              <dd>Operating System Name
+     * <dt>os.arch              <dd>Operating System Architecture
+     * <dt>os.version           <dd>Operating System Version
+     * <dt>file.separator       <dd>File separator ("/" on Unix)
+     * <dt>path.separator       <dd>Path separator (":" on Unix)
+     * <dt>line.separator       <dd>Line separator ("\n" on Unix)
+     * <dt>user.name            <dd>User account name
+     * <dt>user.home            <dd>User home directory
+     * <dt>user.dir             <dd>User's current working directory
+     * <dt>gnu.cpu.endian       <dd>"big" or "little"
+     * </dl>
+     *
+     * @param properties the Properties object to insert the system properties into
+     */
+    static native void preInit(Properties properties);
+
+    /**
+     * Here you get a chance to overwrite some of the properties set by
+     * the common SystemProperties code. For example, it might be
+     * a good idea to process the properties specified on the command
+     * line here.
+     */
+//     static void postInit(Properties properties)
+//     {
+//     }
+    static native void postInit(Properties properties);
+}
diff --git a/src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java b/src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java
new file mode 100644 (file)
index 0000000..978a204
--- /dev/null
@@ -0,0 +1,1084 @@
+/* ClasspathStringBuffer.java -- Growable strings without locking or copying
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
+   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 gnu.java.lang;
+
+import java.io.Serializable;
+
+/**
+ * This class is based on java.lang.AbstractStringBuffer but
+ * without the copying of the string by toString.
+ * If you modify this, please consider also modifying that code.
+ * This code is not thread-safe; limit its use to internal use within
+ * methods.
+ */
+public final class CPStringBuilder
+  implements Serializable, CharSequence, Appendable
+{
+
+  /**
+   * Index of next available character (and thus the size of the current
+   * string contents).  Note that this has permissions set this way so that
+   * String can get the value.
+   *
+   * @serial the number of characters in the buffer
+   */
+  int count;
+
+  /**
+   * The buffer.  Note that this has permissions set this way so that String
+   * can get the value.
+   *
+   * @serial the buffer
+   */
+  char[] value;
+
+  /**
+   * The default capacity of a buffer.
+   */
+  private static final int DEFAULT_CAPACITY = 16;
+
+  /**
+   * Create a new CPStringBuilder with default capacity 16.
+   */
+  public CPStringBuilder()
+  {
+    this(DEFAULT_CAPACITY);
+  }
+
+  /**
+   * Create an empty <code>StringBuffer</code> with the specified initial
+   * capacity.
+   *
+   * @param capacity the initial capacity
+   * @throws NegativeArraySizeException if capacity is negative
+   */
+  public CPStringBuilder(int capacity)
+  {
+    value = new char[capacity];
+  }
+
+  /**
+   * Create a new <code>StringBuffer</code> with the characters in the
+   * specified <code>String</code>. Initial capacity will be the size of the
+   * String plus 16.
+   *
+   * @param str the <code>String</code> to convert
+   * @throws NullPointerException if str is null
+   */
+  public CPStringBuilder(String str)
+  {
+    count = str.length();
+    value = new char[count + DEFAULT_CAPACITY];
+    str.getChars(0, count, value, 0);
+  }
+
+  /**
+   * Create a new <code>StringBuffer</code> with the characters in the
+   * specified <code>CharSequence</code>. Initial capacity will be the
+   * length of the sequence plus 16; if the sequence reports a length
+   * less than or equal to 0, then the initial capacity will be 16.
+   *
+   * @param seq the initializing <code>CharSequence</code>
+   * @throws NullPointerException if str is null
+   * @since 1.5
+   */
+  public CPStringBuilder(CharSequence seq)
+  {
+    int len = seq.length();
+    count = len <= 0 ? 0 : len;
+    value = new char[count + DEFAULT_CAPACITY];
+    for (int i = 0; i < len; ++i)
+      value[i] = seq.charAt(i);
+  }
+
+  /**
+   * Increase the capacity of this <code>StringBuffer</code>. This will
+   * ensure that an expensive growing operation will not occur until
+   * <code>minimumCapacity</code> is reached. The buffer is grown to the
+   * larger of <code>minimumCapacity</code> and
+   * <code>capacity() * 2 + 2</code>, if it is not already large enough.
+   *
+   * @param minimumCapacity the new capacity
+   * @see #capacity()
+   */
+  public void ensureCapacity(int minimumCapacity)
+  {
+    ensureCapacity_unsynchronized(minimumCapacity);
+  }
+
+  /**
+   * Set the length of this StringBuffer. If the new length is greater than
+   * the current length, all the new characters are set to '\0'. If the new
+   * length is less than the current length, the first <code>newLength</code>
+   * characters of the old array will be preserved, and the remaining
+   * characters are truncated.
+   *
+   * @param newLength the new length
+   * @throws IndexOutOfBoundsException if the new length is negative
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   * @see #length()
+   */
+  public void setLength(int newLength)
+  {
+    if (newLength < 0)
+      throw new StringIndexOutOfBoundsException(newLength);
+
+    int valueLength = value.length;
+
+    /* Always call ensureCapacity_unsynchronized in order to preserve
+       copy-on-write semantics.  */
+    ensureCapacity_unsynchronized(newLength);
+
+    if (newLength < valueLength)
+      {
+        /* If the StringBuffer's value just grew, then we know that
+           value is newly allocated and the region between count and
+           newLength is filled with '\0'.  */
+       count = newLength;
+      }
+    else
+      {
+       /* The StringBuffer's value doesn't need to grow.  However,
+          we should clear out any cruft that may exist.  */
+       while (count < newLength)
+          value[count++] = '\0';
+      }
+  }
+
+  /**
+   * Get the character at the specified index.
+   *
+   * @param index the index of the character to get, starting at 0
+   * @return the character at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public char charAt(int index)
+  {
+    if (index < 0 || index >= count)
+      throw new StringIndexOutOfBoundsException(index);
+    return value[index];
+  }
+
+  /**
+   * Get the code point at the specified index.  This is like #charAt(int),
+   * but if the character is the start of a surrogate pair, and the
+   * following character completes the pair, then the corresponding
+   * supplementary code point is returned.
+   * @param index the index of the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+   * @since 1.5
+   */
+  public int codePointAt(int index)
+  {
+    return Character.codePointAt(value, index, count);
+  }
+
+  /**
+   * Get the code point before the specified index.  This is like
+   * #codePointAt(int), but checks the characters at <code>index-1</code> and
+   * <code>index-2</code> to see if they form a supplementary code point.
+   * @param index the index just past the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+   * @since 1.5
+   */
+  public int codePointBefore(int index)
+  {
+    // Character.codePointBefore() doesn't perform this check.  We
+    // could use the CharSequence overload, but this is just as easy.
+    if (index >= count)
+      throw new IndexOutOfBoundsException();
+    return Character.codePointBefore(value, index, 1);
+  }
+
+  /**
+   * Get the specified array of characters. <code>srcOffset - srcEnd</code>
+   * characters will be copied into the array you pass in.
+   *
+   * @param srcOffset the index to start copying from (inclusive)
+   * @param srcEnd the index to stop copying from (exclusive)
+   * @param dst the array to copy into
+   * @param dstOffset the index to start copying into
+   * @throws NullPointerException if dst is null
+   * @throws IndexOutOfBoundsException if any source or target indices are
+   *         out of range (while unspecified, source problems cause a
+   *         StringIndexOutOfBoundsException, and dest problems cause an
+   *         ArrayIndexOutOfBoundsException)
+   * @see System#arraycopy(Object, int, Object, int, int)
+   */
+  public void getChars(int srcOffset, int srcEnd,
+                      char[] dst, int dstOffset)
+  {
+    if (srcOffset < 0 || srcEnd > count || srcEnd < srcOffset)
+      throw new StringIndexOutOfBoundsException();
+    System.arraycopy(value, srcOffset, dst, dstOffset, srcEnd - srcOffset);
+  }
+
+  /**
+   * Set the character at the specified index.
+   *
+   * @param index the index of the character to set starting at 0
+   * @param ch the value to set that character to
+   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public void setCharAt(int index, char ch)
+  {
+    if (index < 0 || index >= count)
+      throw new StringIndexOutOfBoundsException(index);
+    // Call ensureCapacity to enforce copy-on-write.
+    ensureCapacity_unsynchronized(count);
+    value[index] = ch;
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param obj the <code>Object</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(Object)
+   * @see #append(String)
+   */
+  public CPStringBuilder append(Object obj)
+  {
+    return append(String.valueOf(obj));
+  }
+
+  /**
+   * Append the <code>String</code> to this <code>StringBuffer</code>. If
+   * str is null, the String "null" is appended.
+   *
+   * @param str the <code>String</code> to append
+   * @return this <code>StringBuffer</code>
+   */
+  public CPStringBuilder append(String str)
+  {
+    if (str == null)
+      str = "null";
+    int len = str.length();
+    ensureCapacity_unsynchronized(count + len);
+    str.getChars(0, len, value, count);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Append the <code>StringBuilder</code> value of the argument to this
+   * <code>StringBuilder</code>. This behaves the same as
+   * <code>append((Object) stringBuffer)</code>, except it is more efficient.
+   *
+   * @param stringBuffer the <code>StringBuilder</code> to convert and append
+   * @return this <code>StringBuilder</code>
+   * @see #append(Object)
+   */
+  public CPStringBuilder append(StringBuffer stringBuffer)
+  {
+    if (stringBuffer == null)
+      return append("null");
+    synchronized (stringBuffer)
+      {
+       int len = stringBuffer.length();
+       ensureCapacity(count + len);
+       stringBuffer.getChars(0, len, value, count);
+       count += len;
+      }
+    return this;
+  }
+
+  /**
+   * Append the <code>char</code> array to this <code>StringBuffer</code>.
+   * This is similar (but more efficient) than
+   * <code>append(new String(data))</code>, except in the case of null.
+   *
+   * @param data the <code>char[]</code> to append
+   * @return this <code>StringBuffer</code>
+   * @throws NullPointerException if <code>str</code> is <code>null</code>
+   * @see #append(char[], int, int)
+   */
+  public CPStringBuilder append(char[] data)
+  {
+    return append(data, 0, data.length);
+  }
+
+  /**
+   * Append part of the <code>char</code> array to this
+   * <code>StringBuffer</code>. This is similar (but more efficient) than
+   * <code>append(new String(data, offset, count))</code>, except in the case
+   * of null.
+   *
+   * @param data the <code>char[]</code> to append
+   * @param offset the start location in <code>str</code>
+   * @param count the number of characters to get from <code>str</code>
+   * @return this <code>StringBuffer</code>
+   * @throws NullPointerException if <code>str</code> is <code>null</code>
+   * @throws IndexOutOfBoundsException if offset or count is out of range
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public CPStringBuilder append(char[] data, int offset, int count)
+  {
+    if (offset < 0 || count < 0 || offset > data.length - count)
+      throw new StringIndexOutOfBoundsException();
+    ensureCapacity_unsynchronized(this.count + count);
+    System.arraycopy(data, offset, value, this.count, count);
+    this.count += count;
+    return this;
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param bool the <code>boolean</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(boolean)
+   */
+  public CPStringBuilder append(boolean bool)
+  {
+    return append(bool ? "true" : "false");
+  }
+
+  /**
+   * Append the <code>char</code> to this <code>StringBuffer</code>.
+   *
+   * @param ch the <code>char</code> to append
+   * @return this <code>StringBuffer</code>
+   */
+  public CPStringBuilder append(char ch)
+  {
+    ensureCapacity_unsynchronized(count + 1);
+    value[count++] = ch;
+    return this;
+  }
+
+  /**
+   * Append the characters in the <code>CharSequence</code> to this
+   * buffer.
+   *
+   * @param seq the <code>CharSequence</code> providing the characters
+   * @return this <code>StringBuffer</code>
+   * @since 1.5
+   */
+  public CPStringBuilder append(CharSequence seq)
+  {
+    return append(seq, 0, seq.length());
+  }
+
+  /**
+   * Append some characters from the <code>CharSequence</code> to this
+   * buffer.  If the argument is null, the four characters "null" are
+   * appended.
+   *
+   * @param seq the <code>CharSequence</code> providing the characters
+   * @param start the starting index
+   * @param end one past the final index
+   * @return this <code>StringBuffer</code>
+   * @since 1.5
+   */
+  public CPStringBuilder append(CharSequence seq, int start, int end)
+  {
+    if (seq == null)
+      return append("null");
+    if (end - start > 0)
+      {
+       ensureCapacity_unsynchronized(count + end - start);
+       for (; start < end; ++start)
+         value[count++] = seq.charAt(start);
+      }
+    return this;
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param inum the <code>int</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(int)
+   */
+  // This is native in libgcj, for efficiency.
+  public CPStringBuilder append(int inum)
+  {
+    return append(String.valueOf(inum));
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param lnum the <code>long</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(long)
+   */
+  public CPStringBuilder append(long lnum)
+  {
+    return append(Long.toString(lnum, 10));
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param fnum the <code>float</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(float)
+   */
+  public CPStringBuilder append(float fnum)
+  {
+    return append(Float.toString(fnum));
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param dnum the <code>double</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(double)
+   */
+  public CPStringBuilder append(double dnum)
+  {
+    return append(Double.toString(dnum));
+  }
+
+  /**
+   * Append the code point to this <code>StringBuffer</code>.
+   * This is like #append(char), but will append two characters
+   * if a supplementary code point is given.
+   *
+   * @param code the code point to append
+   * @return this <code>StringBuffer</code>
+   * @see Character#toChars(int, char[], int)
+   * @since 1.5
+   */
+  public CPStringBuilder appendCodePoint(int code)
+  {
+    int len = Character.charCount(code);
+    ensureCapacity_unsynchronized(count + len);
+    Character.toChars(code, value, count);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Delete characters from this <code>StringBuffer</code>.
+   * <code>delete(10, 12)</code> will delete 10 and 11, but not 12. It is
+   * harmless for end to be larger than length().
+   *
+   * @param start the first character to delete
+   * @param end the index after the last character to delete
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if start or end are out of bounds
+   * @since 1.2
+   */
+  public CPStringBuilder delete(int start, int end)
+  {
+    if (start < 0 || start > count || start > end)
+      throw new StringIndexOutOfBoundsException(start);
+    if (end > count)
+      end = count;
+    ensureCapacity_unsynchronized(count);
+    if (count - end != 0)
+      System.arraycopy(value, end, value, start, count - end);
+    count -= end - start;
+    return this;
+  }
+
+  /**
+   * Delete a character from this <code>StringBuffer</code>.
+   *
+   * @param index the index of the character to delete
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if index is out of bounds
+   * @since 1.2
+   */
+  public CPStringBuilder deleteCharAt(int index)
+  {
+    return delete(index, index + 1);
+  }
+
+  /**
+   * Replace characters between index <code>start</code> (inclusive) and
+   * <code>end</code> (exclusive) with <code>str</code>. If <code>end</code>
+   * is larger than the size of this StringBuffer, all characters after
+   * <code>start</code> are replaced.
+   *
+   * @param start the beginning index of characters to delete (inclusive)
+   * @param end the ending index of characters to delete (exclusive)
+   * @param str the new <code>String</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if start or end are out of bounds
+   * @throws NullPointerException if str is null
+   * @since 1.2
+   */
+  public CPStringBuilder replace(int start, int end, String str)
+  {
+    if (start < 0 || start > count || start > end)
+      throw new StringIndexOutOfBoundsException(start);
+
+    int len = str.length();
+    // Calculate the difference in 'count' after the replace.
+    int delta = len - (end > count ? count : end) + start;
+    ensureCapacity_unsynchronized(count + delta);
+
+    if (delta != 0 && end < count)
+      System.arraycopy(value, end, value, end + delta, count - end);
+
+    str.getChars(0, len, value, start);
+    count += delta;
+    return this;
+  }
+
+  /**
+   * Insert a subarray of the <code>char[]</code> argument into this
+   * <code>StringBuffer</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param str the <code>char[]</code> to insert
+   * @param str_offset the index in <code>str</code> to start inserting from
+   * @param len the number of characters to insert
+   * @return this <code>StringBuffer</code>
+   * @throws NullPointerException if <code>str</code> is <code>null</code>
+   * @throws StringIndexOutOfBoundsException if any index is out of bounds
+   * @since 1.2
+   */
+  public CPStringBuilder insert(int offset, char[] str, int str_offset, int len)
+  {
+    if (offset < 0 || offset > count || len < 0
+        || str_offset < 0 || str_offset > str.length - len)
+      throw new StringIndexOutOfBoundsException();
+    ensureCapacity_unsynchronized(count + len);
+    System.arraycopy(value, offset, value, offset + len, count - offset);
+    System.arraycopy(str, str_offset, value, offset, len);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param obj the <code>Object</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @exception StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(Object)
+   */
+  public CPStringBuilder insert(int offset, Object obj)
+  {
+    return insert(offset, obj == null ? "null" : obj.toString());
+  }
+
+  /**
+   * Insert the <code>String</code> argument into this
+   * <code>StringBuffer</code>. If str is null, the String "null" is used
+   * instead.
+   *
+   * @param offset the place to insert in this buffer
+   * @param str the <code>String</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   */
+  public CPStringBuilder insert(int offset, String str)
+  {
+    if (offset < 0 || offset > count)
+      throw new StringIndexOutOfBoundsException(offset);
+    if (str == null)
+      str = "null";
+    int len = str.length();
+    ensureCapacity_unsynchronized(count + len);
+    System.arraycopy(value, offset, value, offset + len, count - offset);
+    str.getChars(0, len, value, offset);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Insert the <code>CharSequence</code> argument into this
+   * <code>StringBuffer</code>.  If the sequence is null, the String
+   * "null" is used instead.
+   *
+   * @param offset the place to insert in this buffer
+   * @param sequence the <code>CharSequence</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws IndexOutOfBoundsException if offset is out of bounds
+   * @since 1.5
+   */
+  public CPStringBuilder insert(int offset, CharSequence sequence)
+  {
+    if (sequence == null)
+      sequence = "null";
+    return insert(offset, sequence, 0, sequence.length());
+  }
+
+  /**
+   * Insert a subsequence of the <code>CharSequence</code> argument into this
+   * <code>StringBuffer</code>.  If the sequence is null, the String
+   * "null" is used instead.
+   *
+   * @param offset the place to insert in this buffer
+   * @param sequence the <code>CharSequence</code> to insert
+   * @param start the starting index of the subsequence
+   * @param end one past the ending index of the subsequence
+   * @return this <code>StringBuffer</code>
+   * @throws IndexOutOfBoundsException if offset, start,
+   * or end are out of bounds
+   * @since 1.5
+   */
+  public CPStringBuilder insert(int offset, CharSequence sequence, int start, int end)
+  {
+    if (sequence == null)
+      sequence = "null";
+    if (start < 0 || end < 0 || start > end || end > sequence.length())
+      throw new IndexOutOfBoundsException();
+    int len = end - start;
+    ensureCapacity_unsynchronized(count + len);
+    System.arraycopy(value, offset, value, offset + len, count - offset);
+    for (int i = start; i < end; ++i)
+      value[offset++] = sequence.charAt(i);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Insert the <code>char[]</code> argument into this
+   * <code>StringBuffer</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param data the <code>char[]</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws NullPointerException if <code>data</code> is <code>null</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see #insert(int, char[], int, int)
+   */
+  public CPStringBuilder insert(int offset, char[] data)
+  {
+    return insert(offset, data, 0, data.length);
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param bool the <code>boolean</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(boolean)
+   */
+  public CPStringBuilder insert(int offset, boolean bool)
+  {
+    return insert(offset, bool ? "true" : "false");
+  }
+
+  /**
+   * Insert the <code>char</code> argument into this <code>StringBuffer</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param ch the <code>char</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   */
+  public CPStringBuilder insert(int offset, char ch)
+  {
+    if (offset < 0 || offset > count)
+      throw new StringIndexOutOfBoundsException(offset);
+    ensureCapacity_unsynchronized(count + 1);
+    System.arraycopy(value, offset, value, offset + 1, count - offset);
+    value[offset] = ch;
+    count++;
+    return this;
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param inum the <code>int</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(int)
+   */
+  public CPStringBuilder insert(int offset, int inum)
+  {
+    return insert(offset, String.valueOf(inum));
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param lnum the <code>long</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(long)
+   */
+  public CPStringBuilder insert(int offset, long lnum)
+  {
+    return insert(offset, Long.toString(lnum, 10));
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param fnum the <code>float</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(float)
+   */
+  public CPStringBuilder insert(int offset, float fnum)
+  {
+    return insert(offset, Float.toString(fnum));
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param dnum the <code>double</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(double)
+   */
+  public CPStringBuilder insert(int offset, double dnum)
+  {
+    return insert(offset, Double.toString(dnum));
+  }
+
+  /**
+   * Finds the first instance of a substring in this StringBuilder.
+   *
+   * @param str String to find
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @see #indexOf(String, int)
+   */
+  public int indexOf(String str)
+  {
+    return indexOf(str, 0);
+  }
+
+  /**
+   * Finds the first instance of a String in this StringBuffer, starting at
+   * a given index.  If starting index is less than 0, the search starts at
+   * the beginning of this String.  If the starting index is greater than the
+   * length of this String, or the substring is not found, -1 is returned.
+   *
+   * @param str String to find
+   * @param fromIndex index to start the search
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @since 1.4
+   */
+  public int indexOf(String str, int fromIndex)
+  {
+    if (fromIndex < 0)
+      fromIndex = 0;
+    int olength = str.length();
+    int limit = count - olength;
+    String s = VMCPStringBuilder.toString(value, 0, count);
+    for (; fromIndex <= limit; ++fromIndex)
+      if (s.regionMatches(fromIndex, str, 0, olength))
+        return fromIndex;
+    return -1;
+  }
+
+  /**
+   * Finds the last instance of a substring in this StringBuffer.
+   *
+   * @param str String to find
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @see #lastIndexOf(String, int)
+   * @since 1.4
+   */
+  public int lastIndexOf(String str)
+  {
+    return lastIndexOf(str, count - str.length());
+  }
+
+  /**
+   * Finds the last instance of a String in this StringBuffer, starting at a
+   * given index.  If starting index is greater than the maximum valid index,
+   * then the search begins at the end of this String.  If the starting index
+   * is less than zero, or the substring is not found, -1 is returned.
+   *
+   * @param str String to find
+   * @param fromIndex index to start the search
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @since 1.4
+   */
+  public int lastIndexOf(String str, int fromIndex)
+  {
+    fromIndex = Math.min(fromIndex, count - str.length());
+    String s = VMCPStringBuilder.toString(value, 0, count);
+    int olength = str.length();
+    for ( ; fromIndex >= 0; fromIndex--)
+      if (s.regionMatches(fromIndex, str, 0, olength))
+        return fromIndex;
+    return -1;
+  }
+
+  /**
+   * Reverse the characters in this StringBuffer. The same sequence of
+   * characters exists, but in the reverse index ordering.
+   *
+   * @return this <code>StringBuffer</code>
+   */
+  public CPStringBuilder reverse()
+  {
+    // Call ensureCapacity to enforce copy-on-write.
+    ensureCapacity_unsynchronized(count);
+    for (int i = count >> 1, j = count - i; --i >= 0; ++j)
+      {
+        char c = value[i];
+        value[i] = value[j];
+        value[j] = c;
+      }
+    return this;
+  }
+
+  /**
+   * This may reduce the amount of memory used by the StringBuffer,
+   * by resizing the internal array to remove unused space.  However,
+   * this method is not required to resize, so this behavior cannot
+   * be relied upon.
+   * @since 1.5
+   */
+  public void trimToSize()
+  {
+    int wouldSave = value.length - count;
+    // Some random heuristics: if we save less than 20 characters, who
+    // cares.
+    if (wouldSave < 20)
+      return;
+    // If we save more than 200 characters, shrink.
+    // If we save more than 1/4 of the buffer, shrink.
+    if (wouldSave > 200 || wouldSave * 4 > value.length)
+      {
+       char[] newValue = new char[count];
+       System.arraycopy(value, 0, newValue, 0, count);
+       value = newValue;
+      }
+  }
+
+  /**
+   * Return the number of code points between two indices in the
+   * <code>StringBuffer</code>.  An unpaired surrogate counts as a
+   * code point for this purpose.  Characters outside the indicated
+   * range are not examined, even if the range ends in the middle of a
+   * surrogate pair.
+   *
+   * @param start the starting index
+   * @param end one past the ending index
+   * @return the number of code points
+   * @since 1.5
+   */
+  public int codePointCount(int start, int end)
+  {
+    if (start < 0 || end >= count || start > end)
+      throw new StringIndexOutOfBoundsException();
+
+    int count = 0;
+    while (start < end)
+      {
+       char base = value[start];
+       if (base < Character.MIN_HIGH_SURROGATE
+           || base > Character.MAX_HIGH_SURROGATE
+           || start == end
+           || start == count
+           || value[start + 1] < Character.MIN_LOW_SURROGATE
+           || value[start + 1] > Character.MAX_LOW_SURROGATE)
+         {
+           // Nothing.
+         }
+       else
+         {
+           // Surrogate pair.
+           ++start;
+         }
+       ++start;
+       ++count;
+      }
+    return count;
+  }
+
+  /**
+   * Starting at the given index, this counts forward by the indicated
+   * number of code points, and then returns the resulting index.  An
+   * unpaired surrogate counts as a single code point for this
+   * purpose.
+   *
+   * @param start the starting index
+   * @param codePoints the number of code points
+   * @return the resulting index
+   * @since 1.5
+   */
+  public int offsetByCodePoints(int start, int codePoints)
+  {
+    while (codePoints > 0)
+      {
+       char base = value[start];
+       if (base < Character.MIN_HIGH_SURROGATE
+           || base > Character.MAX_HIGH_SURROGATE
+           || start == count
+           || value[start + 1] < Character.MIN_LOW_SURROGATE
+           || value[start + 1] > Character.MAX_LOW_SURROGATE)
+         {
+           // Nothing.
+         }
+       else
+         {
+           // Surrogate pair.
+           ++start;
+         }
+       ++start;
+       --codePoints;
+      }
+    return start;
+  }
+
+  /**
+   * Increase the capacity of this <code>StringBuilder</code>. This will
+   * ensure that an expensive growing operation will not occur until
+   * <code>minimumCapacity</code> is reached. The buffer is grown to the
+   * larger of <code>minimumCapacity</code> and
+   * <code>capacity() * 2 + 2</code>, if it is not already large enough.
+   *
+   * @param minimumCapacity the new capacity
+   * @see #capacity()
+   */
+  protected void ensureCapacity_unsynchronized(int minimumCapacity)
+  {
+    if (minimumCapacity > value.length)
+      {
+        int max = value.length * 2 + 2;
+        minimumCapacity = (minimumCapacity < max ? max : minimumCapacity);
+        char[] nb = new char[minimumCapacity];
+        System.arraycopy(value, 0, nb, 0, count);
+        value = nb;
+      }
+  }
+
+  /**
+   * Get the length of the <code>String</code> this <code>StringBuilder</code>
+   * would create. Not to be confused with the <em>capacity</em> of the
+   * <code>StringBuilder</code>.
+   *
+   * @return the length of this <code>StringBuilder</code>
+   * @see #capacity()
+   * @see #setLength(int)
+   */
+  public int length()
+  {
+    return count;
+  }
+
+  /**
+   * Creates a substring of this StringBuilder, starting at a specified index
+   * and ending at one character before a specified index. This is implemented
+   * the same as <code>substring(beginIndex, endIndex)</code>, to satisfy
+   * the CharSequence interface.
+   *
+   * @param beginIndex index to start at (inclusive, base 0)
+   * @param endIndex index to end at (exclusive)
+   * @return new String which is a substring of this StringBuilder
+   * @throws IndexOutOfBoundsException if beginIndex or endIndex is out of
+   *         bounds
+   * @see #substring(int, int)
+   */
+  public CharSequence subSequence(int beginIndex, int endIndex)
+  {
+    return substring(beginIndex, endIndex);
+  }
+
+  /**
+   * Creates a substring of this StringBuilder, starting at a specified index
+   * and ending at one character before a specified index.
+   *
+   * @param beginIndex index to start at (inclusive, base 0)
+   * @param endIndex index to end at (exclusive)
+   * @return new String which is a substring of this StringBuilder
+   * @throws StringIndexOutOfBoundsException if beginIndex or endIndex is out
+   *         of bounds
+   */
+  public String substring(int beginIndex, int endIndex)
+  {
+    if (beginIndex < 0 || endIndex > count || endIndex < beginIndex)
+      throw new StringIndexOutOfBoundsException();
+    int len = endIndex - beginIndex;
+    if (len == 0)
+      return "";
+    return VMCPStringBuilder.toString(value, beginIndex, len);
+  }
+
+  /**
+   * Convert this <code>StringBuilder</code> to a <code>String</code>. The
+   * String is composed of the characters currently in this StringBuilder. Note
+   * that the result is not a copy, so future modifications to this buffer
+   * do affect the String.
+   *
+   * @return the characters in this StringBuilder
+   */
+  public String toString()
+  {
+    return VMCPStringBuilder.toString(value, 0, count);
+  }
+
+}
diff --git a/src/classes/gnuclasspath/gnu/java/lang/VMCPStringBuilder.java b/src/classes/gnuclasspath/gnu/java/lang/VMCPStringBuilder.java
new file mode 100644 (file)
index 0000000..ca1c39d
--- /dev/null
@@ -0,0 +1,108 @@
+/* VMCPStringBuilder.java -- Growable strings without locking or copying
+   Copyright (C) 2008 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 gnu.java.lang;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * This class provides VM support for CPStringBuilder
+ * by allowing the package-private constructor
+ * of java.lang.String to be invoked.  The default
+ * implementation uses reflection.  VMs may replace
+ * this class with a more efficient version.
+ */
+final class VMCPStringBuilder
+{
+
+  /**
+   * The package-private constructor for String objects without copying.
+   */
+//   private static final Constructor<String> cons;
+
+//   static
+//   {
+//     try
+//       {
+//     cons = String.class.getDeclaredConstructor(char[].class, Integer.TYPE,
+//                                                Integer.TYPE, Boolean.TYPE);
+//     cons.setAccessible(true);
+//       }
+//     catch (NoSuchMethodException e)
+//       {
+//     throw (Error) 
+//       new InternalError("Could not get no-copy String constructor").initCause(e);
+//       }
+//   }
+
+  /**
+   * Convert this <code>StringBuilder</code> to a <code>String</code>. The
+   * String is composed of the characters currently in this StringBuilder. Note
+   * that the result is not a copy, so future modifications to this buffer
+   * do affect the String.
+   *
+   * @param value the buffered characters.
+   * @param startIndex the index at which to start taking characters from the buffer.
+   * @param count the number of characters used in the buffer.
+   * @return the characters in this StringBuilder
+   */
+//   public static String toString(char[] value, int startIndex, int count)
+//   {
+//     try
+//       {
+//     return cons.newInstance(value, startIndex, count, true);
+//       }
+//     catch (InstantiationException e)
+//       {
+//     throw (Error) 
+//       new InternalError("Could not instantiate no-copy String constructor").initCause(e);
+//       }
+//     catch (IllegalAccessException e)
+//       {
+//     throw (Error) 
+//       new InternalError("Could not access no-copy String constructor").initCause(e);
+//       }
+//     catch (InvocationTargetException e)
+//       {
+//     throw (Error) 
+//       new InternalError("Error calling no-copy String constructor").initCause(e);
+//       }
+//   }
+  public static native String toString(char[] value, int startIndex, int count);
+
+}
diff --git a/src/classes/gnuclasspath/gnu/java/lang/management/VMMemoryMXBeanImpl.java b/src/classes/gnuclasspath/gnu/java/lang/management/VMMemoryMXBeanImpl.java
new file mode 100644 (file)
index 0000000..d71a06d
--- /dev/null
@@ -0,0 +1,110 @@
+/* VMMemoryMXBeanImpl.java - VM impl. of a memory bean
+   Copyright (C) 2006 Free Software Foundation
+
+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 gnu.java.lang.management;
+
+import java.lang.management.MemoryUsage;
+
+/**
+ * Provides access to information about the memory
+ * management of the current invocation of the virtual
+ * machine.  Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getMemoryMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMMemoryMXBeanImpl
+{
+
+  /**
+   * Returns an instance of {@link java.lang.management.MemoryUsage}
+   * with appropriate initial, used, committed and maximum values
+   * for the heap.  By default, this uses the methods of
+   * {@link java.lang.Runtime} to provide some of the values.
+   *
+   * @return an {@link java.lang.management.MemoryUsage} instance
+   *         for the heap.
+   */
+//   static MemoryUsage getHeapMemoryUsage()
+//   {
+//     Runtime runtime = Runtime.getRuntime();
+//     long totalMem = runtime.totalMemory();
+//     return new MemoryUsage(-1, totalMem - runtime.freeMemory(),
+//                        totalMem, runtime.maxMemory());
+//   }
+  static native MemoryUsage getHeapMemoryUsage();
+
+  /**
+   * Returns an instance of {@link java.lang.management.MemoryUsage}
+   * with appropriate initial, used, committed and maximum values
+   * for non-heap memory.
+   *
+   * @return an {@link java.lang.management.MemoryUsage} instance
+   *         for non-heap memory.
+   */
+  static native MemoryUsage getNonHeapMemoryUsage();
+
+  /**
+   * Returns the number of objects ready to be garbage collected.
+   *
+   * @return the number of finalizable objects.
+   */
+  static native int getObjectPendingFinalizationCount();
+
+  /**
+   * Returns true if the virtual machine will emit additional
+   * information when memory is allocated and deallocated.  The
+   * format of the output is left up to the virtual machine.
+   *
+   * @return true if verbose class loading output is on.
+   */
+  static native boolean isVerbose();
+
+  /**
+   * Turns on or off the emission of additional information
+   * when memory is allocated and deallocated.  The format of the
+   * output is left up to the virtual machine.  This method
+   * may be called by multiple threads concurrently, but there
+   * is only one global setting of verbosity that is affected.
+   *
+   * @param verbose the new setting for verbose class loading
+   *                output.
+   */
+  static native void setVerbose(boolean verbose);
+
+}
diff --git a/src/classes/gnuclasspath/gnu/java/lang/management/VMRuntimeMXBeanImpl.java b/src/classes/gnuclasspath/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
new file mode 100644 (file)
index 0000000..32a8660
--- /dev/null
@@ -0,0 +1,89 @@
+/* VMRuntimeMXBeanImpl.java - VM implementation of an runtime bean
+   Copyright (C) 2006 Free Software Foundation
+
+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 gnu.java.lang.management;
+
+import gnu.classpath.SystemProperties;
+
+/**
+ * Provides access to information about the virtual machine.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMRuntimeMXBeanImpl
+{
+
+  /**
+   * Returns the command-line arguments supplied
+   * to the virtual machine, excluding those supplied
+   * to <code>main()</code>.
+   *
+   * @return the command-line arguments.
+   */
+  static native String[] getInputArguments();
+
+  /**
+   * Returns a developer-chosen name for the virtual
+   * machine, which may differ over different running
+   * instances of the same virtual machine binary.
+   * For example, this may include the particular
+   * process identifier used by this instance or
+   * the host name of the machine on which it is
+   * running.  The intention is that this name refers
+   * to the precise entity that the other data supplied
+   * by the bean refers to, rather than the VM in general.
+   *
+   * @return the custom name of the VM.
+   */
+  static String getName()
+  {
+    return SystemProperties.getProperty("java.vm.name") + " " +
+      SystemProperties.getProperty("java.vm.version");
+  }
+
+  /**
+   * The time in milliseconds at which the virtual
+   * machine was started.  This method is only executed
+   * once (for efficency), as the value is not expected
+   * to change.
+   *
+   * @return the VM start time.
+   */
+  static native long getStartTime();
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/VMClassLoader.java b/src/classes/gnuclasspath/java/lang/VMClassLoader.java
new file mode 100644 (file)
index 0000000..f09838b
--- /dev/null
@@ -0,0 +1,457 @@
+/* VMClassLoader.java -- Reference implementation of native interface
+   required by ClassLoader
+   Copyright (C) 1998, 2001, 2002, 2004, 2005, 2006 Free Software Foundation
+
+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;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.SystemProperties;
+import gnu.java.lang.InstrumentationImpl;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.lang.instrument.Instrumentation;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.ProtectionDomain;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.util.zip.ZipFile;
+import java.util.Collections;
+import java.lang.Boolean;
+
+/**
+ * java.lang.VMClassLoader is a package-private helper for VMs to implement
+ * on behalf of java.lang.ClassLoader.
+ *
+ * @author John Keiser
+ * @author Mark Wielaard (mark@klomp.org)
+ * @author Eric Blake (ebb9@email.byu.edu)
+ */
+final class VMClassLoader
+{
+
+
+  /** packages loaded by the bootstrap class loader */
+  static final HashMap definedPackages = new HashMap();
+
+  /** jars from property java.boot.class.path */
+  static final HashMap bootjars = new HashMap();
+  
+
+  /**
+   * Converts the array string of native package names to
+   * Packages. The packages are then put into the
+   * definedPackages hashMap
+   */
+  static
+  {
+    String[] packages = getBootPackages();
+    
+    if( packages != null)
+      {
+        String specName = 
+              SystemProperties.getProperty("java.specification.name");
+        String vendor =
+              SystemProperties.getProperty("java.specification.vendor");
+        String version =
+              SystemProperties.getProperty("java.specification.version");
+        
+        Package p;
+              
+        for(int i = 0; i < packages.length; i++)
+          {
+            p = new Package(packages[i],
+                  specName,
+                  vendor,
+                  version,
+                  "GNU Classpath",
+                  "GNU",
+                  Configuration.CLASSPATH_VERSION,
+                  null,
+                  null);
+
+            definedPackages.put(packages[i], p);
+          }
+      }
+  }
+
+  
+  /**
+   * Helper to define a class using a string of bytes. This assumes that
+   * the security checks have already been performed, if necessary.
+   *
+   * Implementations of this method are advised to consider the
+   * situation where user code modifies the byte array after it has
+   * been passed to defineClass.  This can be handled by making a
+   * private copy of the array, or arranging to only read any given
+   * byte a single time.
+   *
+   * @param name the name to give the class, or null if unknown
+   * @param data the data representing the classfile, in classfile format
+   * @param offset the offset into the data where the classfile starts
+   * @param len the length of the classfile data in the array
+   * @param pd the protection domain
+   * @return the class that was defined
+   * @throws ClassFormatError if data is not in proper classfile format
+   */
+  static final native Class defineClass(ClassLoader cl, String name,
+                                 byte[] data, int offset, int len,
+                                 ProtectionDomain pd)
+    throws ClassFormatError;
+
+  /**
+   * Helper to resolve all references to other classes from this class.
+   *
+   * @param c the class to resolve
+   */
+  static final native void resolveClass(Class c);
+
+  /**
+   * Helper to load a class from the bootstrap class loader.
+   *
+   * @param name the class name to load
+   * @param resolve whether to resolve it
+   * @return the class, loaded by the bootstrap classloader or null
+   * if the class wasn't found. Returning null is equivalent to throwing
+   * a ClassNotFoundException (but a possible performance optimization).
+   */
+  static final native Class loadClass(String name, boolean resolve)
+    throws ClassNotFoundException;
+
+  /**
+   * Helper to load a resource from the bootstrap class loader.
+   *
+   * @param name the resource to find
+   * @return the URL to the resource
+   */
+  static URL getResource(String name)
+  {
+    Enumeration e = getResources(name);
+    if (e.hasMoreElements())
+      return (URL)e.nextElement();
+    return null;
+  }
+  /**
+   * Helper to get a list of resources from the bootstrap class loader.
+   *
+   * @param name the resource to find
+   * @return an enumeration of resources
+   */
+  static Enumeration getResources(String name)
+  {
+//     StringTokenizer st = new StringTokenizer(
+//       SystemProperties.getProperty("java.boot.class.path", "."),
+//       File.pathSeparator);
+//     Vector v = new Vector();
+//     while (st.hasMoreTokens())
+//       {
+//     File file = new File(st.nextToken());
+//     if (file.isDirectory())
+//       {
+//         try
+//           {
+//                 File f = new File(file, name);
+//                 if (!f.exists()) continue;
+//                 v.add(new URL("file://" + f.getAbsolutePath()));
+//           }
+//         catch (MalformedURLException e)
+//           {
+//             throw new Error(e);
+//           }
+//       }
+//     else if (file.isFile())
+//       {
+//         ZipFile zip;
+//             synchronized(bootjars)
+//               {
+//                 zip = (ZipFile) bootjars.get(file.getName());
+//               }
+//             if(zip == null)
+//               {
+//                 try
+//               {
+//                     zip = new ZipFile(file);
+//                     synchronized(bootjars)
+//                       {
+//                         bootjars.put(file.getName(), zip);
+//                       }
+//               }
+//             catch (IOException e)
+//               {
+//                 continue;
+//               }
+//               }
+//         String zname = name.startsWith("/") ? name.substring(1) : name;
+//         if (zip.getEntry(zname) == null)
+//           continue;
+//         try
+//           {
+//             v.add(new URL("jar:file://"
+//               + file.getAbsolutePath() + "!/" + zname));
+//           }
+//         catch (MalformedURLException e)
+//           {
+//             throw new Error(e);
+//           }
+//       }
+//       }
+//     return v.elements();
+//   }
+    Vector urls = nativeGetResources(name);
+    Vector v = new Vector();
+    for (Enumeration en = urls.elements(); en.hasMoreElements();)
+      {
+       try
+         {
+           v.add(new URL((String) en.nextElement()));
+         }
+       catch (MalformedURLException e)
+         {
+           throw new Error(e);
+         }
+      }
+    return v.elements();
+  }
+
+  private native static final Vector nativeGetResources(String name);
+
+
+  /**
+   * Returns a String[] of native package names. The default
+   * implementation tries to load a list of package from
+   * the META-INF/INDEX.LIST file in the boot jar file.
+   * If not found or if any exception is raised, it returns
+   * an empty array. You may decide this needs native help.
+   */
+  private static String[] getBootPackages()
+  {
+    try
+      {
+        Enumeration indexListEnumeration = getResources("META-INF/INDEX.LIST");
+        Set packageSet = new HashSet();
+
+        while (indexListEnumeration.hasMoreElements())
+          {
+            try
+              {
+                String line;
+                int lineToSkip = 3;
+                BufferedReader reader = new BufferedReader(
+                                                           new InputStreamReader(
+                                                                                 ((URL) indexListEnumeration.nextElement()).openStream()));
+                while ((line = reader.readLine()) != null)
+                  {
+                    if (lineToSkip == 0)
+                      {
+                        if (line.length() == 0)
+                          lineToSkip = 1;
+                        else
+                          packageSet.add(line.replace('/', '.'));
+                      }
+                    else
+                      lineToSkip--;
+                  }
+                reader.close();
+              }
+            catch (IOException e)
+              {
+                // Empty catch block on purpose
+              }
+          }
+        return (String[]) packageSet.toArray(new String[packageSet.size()]);
+      }
+    catch (Exception e)
+      {
+        return new String[0];
+      }
+  }
+
+
+  /**
+   * Helper to get a package from the bootstrap class loader.
+   *
+   * @param name the name to find
+   * @return the named package, if it exists
+   */
+  static Package getPackage(String name)
+  {
+    return (Package)definedPackages.get(name);
+  }
+
+
+  
+  /**
+   * Helper to get all packages from the bootstrap class loader.  
+   *
+   * @return all named packages, if any exist
+   */
+  static Package[] getPackages()
+  {
+    Package[] packages = new Package[definedPackages.size()];
+    definedPackages.values().toArray(packages);
+    return packages;
+  }
+
+  /**
+   * Helper for java.lang.Integer, Byte, etc to get the TYPE class
+   * at initialization time. The type code is one of the chars that
+   * represents the primitive type as in JNI.
+   *
+   * <ul>
+   * <li>'Z' - boolean</li>
+   * <li>'B' - byte</li>
+   * <li>'C' - char</li>
+   * <li>'D' - double</li>
+   * <li>'F' - float</li>
+   * <li>'I' - int</li>
+   * <li>'J' - long</li>
+   * <li>'S' - short</li>
+   * <li>'V' - void</li>
+   * </ul>
+   *
+   * @param type the primitive type
+   * @return a "bogus" class representing the primitive type
+   */
+  static final native Class getPrimitiveClass(char type);
+
+  /**
+   * The system default for assertion status. This is used for all system
+   * classes (those with a null ClassLoader), as well as the initial value for
+   * every ClassLoader's default assertion status.
+   *
+   * @return the system-wide default assertion status
+   */
+  static native final boolean defaultAssertionStatus();
+
+  static native final boolean defaultUserAssertionStatus();
+
+
+  static final Map packageAssertionMap = 
+    Collections.unmodifiableMap(packageAssertionStatus0(Boolean.TRUE, Boolean.FALSE));
+  
+  static native final Map packageAssertionStatus0(Boolean jtrue, Boolean jfalse);
+  /**
+   * The system default for package assertion status. This is used for all
+   * ClassLoader's packageAssertionStatus defaults. It must be a map of
+   * package names to Boolean.TRUE or Boolean.FALSE, with the unnamed package
+   * represented as a null key.
+   *
+   * @return a (read-only) map for the default packageAssertionStatus
+   */
+   
+  static final Map packageAssertionStatus() {
+    return packageAssertionMap;
+  }
+
+  static final Map classAssertionMap = 
+    Collections.unmodifiableMap(classAssertionStatus0(Boolean.TRUE, Boolean.FALSE));
+  
+  static native final Map classAssertionStatus0(Boolean jtrue, Boolean jfalse);
+
+  /**
+   * The system default for class assertion status. This is used for all
+   * ClassLoader's classAssertionStatus defaults. It must be a map of
+   * class names to Boolean.TRUE or Boolean.FALSE
+   *
+   * @return a (read-only) map for the default classAssertionStatus
+   */
+  static final Map classAssertionStatus() {
+    return classAssertionMap;
+  }
+  
+  static ClassLoader getSystemClassLoader()
+  {
+    return ClassLoader.defaultGetSystemClassLoader();
+  }
+
+  /**
+   * Find the class if this class loader previously defined this class
+   * or if this class loader has been recorded as the initiating class loader
+   * for this class.
+   */
+  static native Class findLoadedClass(ClassLoader cl, String name);
+
+  /**
+   * The Instrumentation object created by the vm when agents are defined.
+   */
+  static final Instrumentation instrumenter = null;
+
+  /**
+   * Call the transformers of the possible Instrumentation object. This
+   * implementation assumes the instrumenter is a
+   * <code>InstrumentationImpl</code> object. VM implementors would
+   * have to redefine this method if they provide their own implementation
+   * of the <code>Instrumentation</code> interface.
+   *
+   * @param loader the initiating loader
+   * @param name the name of the class
+   * @param data the data representing the classfile, in classfile format
+   * @param offset the offset into the data where the classfile starts
+   * @param len the length of the classfile data in the array
+   * @param pd the protection domain
+   * @return the new data representing the classfile
+   */
+  static final Class defineClassWithTransformers(ClassLoader loader,
+      String name, byte[] data, int offset, int len, ProtectionDomain pd)
+  {
+    
+    if (instrumenter != null)
+      {
+        byte[] modifiedData = new byte[len];
+        System.arraycopy(data, offset, modifiedData, 0, len);
+        modifiedData =
+          ((InstrumentationImpl)instrumenter).callTransformers(loader, name,
+            null, pd, modifiedData);
+        
+        return defineClass(loader, name, modifiedData, 0, modifiedData.length,
+            pd);
+      }
+    else
+      {
+        return defineClass(loader, name, data, offset, len, pd);
+      }
+  }
+}
diff --git a/src/classes/gnuclasspath/java/lang/VMString.java b/src/classes/gnuclasspath/java/lang/VMString.java
new file mode 100644 (file)
index 0000000..57e4423
--- /dev/null
@@ -0,0 +1,96 @@
+/* VMString.java -- VM Specific String methods
+   Copyright (C) 2003 Free Software Foundation
+
+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;
+
+import java.lang.ref.WeakReference;
+import java.util.WeakHashMap;
+
+/*
+ * This class is a reference version, mainly for compiling a class library
+ * jar.  It is likely that VM implementers replace this with their own
+ * version that can communicate effectively with the VM.
+ */
+
+/**
+ * Code relocated from java.lang.String by 
+ * @author Dave Grove <groved@us.ibm.com>
+ */
+final class VMString
+{
+
+  /**
+   * Holds the references for each intern()'d String. If all references to
+   * the string disappear, and the VM properly supports weak references,
+   * the String will be GC'd.
+   */
+//    private static final WeakHashMap internTable = new WeakHashMap();
+
+  /**
+   * Fetches this String from the intern hashtable. If two Strings are
+   * considered equal, by the equals() method, then intern() will return the
+   * same String instance. ie. if (s1.equals(s2)) then
+   * (s1.intern() == s2.intern()). All string literals and string-valued
+   * constant expressions are already interned.
+   *
+   * @param str the String to intern
+   * @return the interned String
+   */
+//    static String intern(String str)
+//    {
+//      synchronized (internTable)
+//        {
+//          WeakReference ref = (WeakReference) internTable.get(str);
+//          if (ref != null)
+//            {
+//              String s = (String) ref.get();
+//              // If s is null, then no strong references exist to the String;
+//              // the weak hash map will soon delete the key.
+//              if (s != null)
+//                return s;
+//            }
+//          internTable.put(str, new WeakReference(str));
+//        }
+//      return str;
+//    }
+
+  /**
+   * this one is native in CACAO
+   */
+  static native String intern(String str);
+
+} // class VMString
diff --git a/src/classes/gnuclasspath/java/lang/VMThread.java b/src/classes/gnuclasspath/java/lang/VMThread.java
new file mode 100644 (file)
index 0000000..a511f3c
--- /dev/null
@@ -0,0 +1,462 @@
+/* VMThread -- VM interface for Thread of executable code
+   Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation
+
+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;
+
+/**
+ * VM interface for Thread of executable code. Holds VM dependent state.
+ * It is deliberately package local and final and should only be accessed
+ * by the Thread class.
+ * <p>
+ * This is the GNU Classpath reference implementation, it should be adapted
+ * for a specific VM.
+ * <p>
+ * The following methods must be implemented:
+ * <ul>
+ * <li>native void start(long stacksize);
+ * <li>native void interrupt();
+ * <li>native boolean isInterrupted();
+ * <li>native void suspend();
+ * <li>native void resume();
+ * <li>native void nativeSetPriority(int priority);
+ * <li>native void nativeStop(Throwable t);
+ * <li>native static Thread currentThread();
+ * <li>static native void yield();
+ * <li>static native boolean interrupted();
+ * </ul>
+ * All other methods may be implemented to make Thread handling more efficient
+ * or to implement some optional (and sometimes deprecated) behaviour. Default
+ * implementations are provided but it is highly recommended to optimize them
+ * for a specific VM.
+ * 
+ * @author Jeroen Frijters (jeroen@frijters.net)
+ * @author Dalibor Topic (robilad@kaffe.org)
+ */
+final class VMThread
+{
+    /**
+     * The Thread object that this VM state belongs to.
+     * Used in currentThread() and start().
+     * Note: when this thread dies, this reference is *not* cleared
+     */
+    volatile Thread thread;
+
+    /**
+     * Flag that is set when the thread runs, used by stop() to protect against
+     * stop's getting lost.
+     */
+    private volatile boolean running;
+
+    /**
+     * VM private data.
+     */
+    private transient Object vmdata;
+
+    /**
+     * Private constructor, create VMThreads with the static create method.
+     *
+     * @param thread The Thread object that was just created.
+     */
+    private VMThread(Thread thread)
+    {
+       this.thread = thread;
+    }
+
+    /**
+     * This method is the initial Java code that gets executed when a native
+     * thread starts. It's job is to coordinate with the rest of the VMThread
+     * logic and to start executing user code and afterwards handle clean up.
+     */
+    private void run()
+    {
+       try
+       {
+           try
+           {
+               running = true;
+               synchronized(thread)
+               {
+                   Throwable t = thread.stillborn;
+                   if(t != null)
+                   {
+                       thread.stillborn = null;
+                       throw t;
+                   }
+               }
+               thread.run();
+           }
+           catch(Throwable t)
+           {
+               try
+               {
+                 Thread.UncaughtExceptionHandler handler;
+                 handler = thread.getUncaughtExceptionHandler();
+                 handler.uncaughtException(thread, t);
+               }
+               catch(Throwable ignore)
+               {
+               }
+           }
+       }
+       finally
+       {
+           // Setting runnable to false is partial protection against stop
+           // being called while we're cleaning up. To be safe all code in
+           // VMThread be unstoppable.
+           running = false;
+           thread.die();
+           synchronized(this)
+           {
+               // release the threads waiting to join us
+               notifyAll();
+           }
+       }
+    }
+
+    /**
+     * Creates a native Thread. This is called from the start method of Thread.
+     * The Thread is started.
+     *
+     * @param thread The newly created Thread object
+     * @param stacksize Indicates the requested stacksize. Normally zero,
+     * non-zero values indicate requested stack size in bytes but it is up
+     * to the specific VM implementation to interpret them and may be ignored.
+     */
+    static void create(Thread thread, long stacksize)
+    {
+       VMThread vmThread = new VMThread(thread);
+       thread.vmThread = vmThread;
+       vmThread.start(stacksize);
+    }
+
+    /**
+     * Gets the name of the thread. Usually this is the name field of the
+     * associated Thread object, but some implementation might choose to
+     * return the name of the underlying platform thread.
+     */
+    String getName()
+    {
+       return thread.name;
+    }
+
+    /**
+     * Set the name of the thread. Usually this sets the name field of the
+     * associated Thread object, but some implementations might choose to
+     * set the name of the underlying platform thread.
+     * @param name The new name
+     */
+    void setName(String name)
+    {
+       thread.name = name;
+    }
+
+    /**
+     * Set the thread priority field in the associated Thread object and
+     * calls the native method to set the priority of the underlying
+     * platform thread.
+     * @param priority The new priority
+     */
+    void setPriority(int priority)
+    {
+       thread.priority = priority;
+       nativeSetPriority(priority);
+    }
+
+    /**
+     * Returns the priority. Usually this is the priority field from the
+     * associated Thread object, but some implementation might choose to
+     * return the priority of the underlying platform thread.
+     * @return this Thread's priority
+     */
+    int getPriority()
+    {
+        return thread.priority;
+    }
+
+    /**
+     * Returns true if the thread is a daemon thread. Usually this is the
+     * daemon field from the associated Thread object, but some
+     * implementation might choose to return the daemon state of the underlying
+     * platform thread.
+     * @return whether this is a daemon Thread or not
+     */
+    boolean isDaemon()
+    {
+        return thread.daemon;
+    }
+
+    /**
+     * Returns the number of stack frames in this Thread.
+     * Will only be called when when a previous call to suspend() returned true.
+     *
+     * @deprecated unsafe operation
+     */
+    native int countStackFrames();
+
+    /**
+     * Wait the specified amount of time for the Thread in question to die.
+     *
+     * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
+     * not offer that fine a grain of timing resolution. Besides, there is
+     * no guarantee that this thread can start up immediately when time expires,
+     * because some other thread may be active.  So don't expect real-time
+     * performance.
+     *
+     * @param ms the number of milliseconds to wait, or 0 for forever
+     * @param ns the number of extra nanoseconds to sleep (0-999999)
+     * @throws InterruptedException if the Thread is interrupted; it's
+     *         <i>interrupted status</i> will be cleared
+     */
+    synchronized void join(long ms, int ns) throws InterruptedException
+    {
+       // Round up
+       ms += (ns != 0) ? 1 : 0;
+
+       // Compute end time, but don't overflow
+       long now = System.currentTimeMillis();
+       long end = now + ms;
+       if (end < now)
+           end = Long.MAX_VALUE;
+
+       // A VM is allowed to return from wait() without notify() having been
+       // called, so we loop to handle possible spurious wakeups.
+       while(thread.vmThread != null)
+       {
+           // We use the VMThread object to wait on, because this is a private
+           // object, so client code cannot call notify on us.
+           wait(ms);
+           if(ms != 0)
+           {
+               now = System.currentTimeMillis();
+               ms = end - now;
+               if(ms <= 0)
+               {
+                   break;
+               }
+           }
+       }
+    }
+
+    /**
+     * Cause this Thread to stop abnormally and throw the specified exception.
+     * If you stop a Thread that has not yet started, the stop is ignored
+     * (contrary to what the JDK documentation says).
+     * <b>WARNING</b>This bypasses Java security, and can throw a checked
+     * exception which the call stack is unprepared to handle. Do not abuse 
+     * this power.
+     *
+     * <p>This is inherently unsafe, as it can interrupt synchronized blocks and
+     * leave data in bad states.
+     *
+     * <p><b>NOTE</b> stop() should take care not to stop a thread if it is
+     * executing code in this class.
+     *
+     * @param t the Throwable to throw when the Thread dies
+     * @deprecated unsafe operation, try not to use
+     */
+    void stop(Throwable t)
+    {
+       // Note: we assume that we own the lock on thread
+       // (i.e. that Thread.stop() is synchronized)
+       if(running)
+           nativeStop(t);
+       else
+           thread.stillborn = t;
+    }
+
+    /**
+     * Create a native thread on the underlying platform and start it executing
+     * on the run method of this object.
+     * @param stacksize the requested size of the native thread stack
+     */
+    native void start(long stacksize);
+
+    /**
+     * Interrupt this thread.
+     */
+    native void interrupt();
+
+    /**
+     * Determine whether this Thread has been interrupted, but leave
+     * the <i>interrupted status</i> alone in the process.
+     *
+     * @return whether the Thread has been interrupted
+     */
+    native boolean isInterrupted();
+
+    /**
+     * Suspend this Thread.  It will not come back, ever, unless it is resumed.
+     */
+    native void suspend();
+
+    /**
+     * Resume this Thread.  If the thread is not suspended, this method does
+     * nothing.
+     */
+    native void resume();
+
+    /**
+     * Set the priority of the underlying platform thread.
+     *
+     * @param priority the new priority
+     */
+    native void nativeSetPriority(int priority);
+
+    /**
+     * Asynchronously throw the specified throwable in this Thread.
+     *
+     * @param t the exception to throw
+     */
+    native void nativeStop(Throwable t);
+
+    /**
+     * Return the Thread object associated with the currently executing
+     * thread.
+     *
+     * @return the currently executing Thread
+     */
+    static native Thread currentThread();
+
+    /**
+     * Yield to another thread. The Thread will not lose any locks it holds
+     * during this time. There are no guarantees which thread will be
+     * next to run, and it could even be this one, but most VMs will choose
+     * the highest priority thread that has been waiting longest.
+     */
+    static native void yield();
+
+    /**
+     * Suspend the current Thread's execution for the specified amount of
+     * time. The Thread will not lose any locks it has during this time. There
+     * are no guarantees which thread will be next to run, but most VMs will
+     * choose the highest priority thread that has been waiting longest.
+     *
+     * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
+     * not offer that fine a grain of timing resolution. Besides, there is
+     * no guarantee that this thread can start up immediately when time expires,
+     * because some other thread may be active.  So don't expect real-time
+     * performance.
+     *
+     * @param ms the number of milliseconds to sleep.
+     * @param ns the number of extra nanoseconds to sleep (0-999999)
+     * @throws InterruptedException if the Thread is (or was) interrupted;
+     *         it's <i>interrupted status</i> will be cleared
+     */
+    static void sleep(long ms, int ns) throws InterruptedException
+    {
+      // Note: JDK treats a zero length sleep is like Thread.yield(),
+      // without checking the interrupted status of the thread.
+      // It's unclear if this is a bug in the implementation or the spec.
+      // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213203
+      if (ms == 0 && ns == 0)
+       {
+         if (Thread.interrupted())
+           throw new InterruptedException();
+         return;
+       }
+
+      // Compute end time, but don't overflow
+      long now = System.currentTimeMillis();
+      long end = now + ms;
+      if (end < now)
+         end = Long.MAX_VALUE;
+
+      // A VM is allowed to return from wait() without notify() having been
+      // called, so we loop to handle possible spurious wakeups.
+      VMThread vt = Thread.currentThread().vmThread;
+      synchronized (vt)
+       {
+         while (true)
+           {
+             vt.wait(ms, ns);
+             now = System.currentTimeMillis();
+             if (now >= end)
+               break;
+             ms = end - now;
+             ns = 0;
+           }
+       }
+    }
+
+    /**
+     * Determine whether the current Thread has been interrupted, and clear
+     * the <i>interrupted status</i> in the process.
+     *
+     * @return whether the current Thread has been interrupted
+     */
+    static native boolean interrupted();
+
+    /**
+     * Checks whether the current thread holds the monitor on a given object.
+     * This allows you to do <code>assert Thread.holdsLock(obj)</code>.
+     *
+     * @param obj the object to check
+     * @return true if the current thread is currently synchronized on obj
+     * @throws NullPointerException if obj is null
+     */
+//     static boolean holdsLock(Object obj) 
+//     {
+//       /* Use obj.notify to check if the current thread holds
+//        * the monitor of the object.
+//        * If it doesn't, notify will throw an exception.
+//        */
+//       try 
+//     {
+//       obj.notify();
+//       // okay, current thread holds lock
+//       return true;
+//     }
+//       catch (IllegalMonitorStateException e)
+//     {
+//       // it doesn't hold the lock
+//       return false;
+//     }
+//     }
+    static native boolean holdsLock(Object obj);
+
+  /**
+   * Returns the current state of the thread.
+   * The value must be one of "BLOCKED", "NEW",
+   * "RUNNABLE", "TERMINATED", "TIMED_WAITING" or
+   * "WAITING".
+   *
+   * @return a string corresponding to one of the 
+   *         thread enumeration states specified above.
+   */
+  native String getState();
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/Constructor.java b/src/classes/gnuclasspath/java/lang/reflect/Constructor.java
new file mode 100644 (file)
index 0000000..55b82e8
--- /dev/null
@@ -0,0 +1,449 @@
+/* java.lang.reflect.Constructor - reflection of Java constructors
+   Copyright (C) 1998, 2001, 2004, 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.java.lang.ClassHelper;
+import gnu.java.lang.CPStringBuilder;
+
+import gnu.java.lang.reflect.MethodSignatureParser;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * The Constructor class represents a constructor of a class. It also allows
+ * dynamic creation of an object, via reflection. Invocation on Constructor
+ * objects knows how to do widening conversions, but throws
+ * {@link IllegalArgumentException} if a narrowing conversion would be
+ * necessary. You can query for information on this Constructor regardless
+ * of location, but construction access may be limited by Java language
+ * access controls. If you can't do it in the compiler, you can't normally
+ * do it here either.<p>
+ *
+ * <B>Note:</B> This class returns and accepts types as Classes, even
+ * primitive types; there are Class types defined that represent each
+ * different primitive type.  They are <code>java.lang.Boolean.TYPE,
+ * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class,
+ * byte.class</code>, etc.  These are not to be confused with the
+ * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are
+ * real classes.<p>
+ *
+ * Also note that this is not a serializable class.  It is entirely feasible
+ * to make it serializable using the Externalizable interface, but this is
+ * on Sun, not me.
+ *
+ * @author John Keiser
+ * @author Eric Blake <ebb9@email.byu.edu>
+ * @see Member
+ * @see Class
+ * @see java.lang.Class#getConstructor(Class[])
+ * @see java.lang.Class#getDeclaredConstructor(Class[])
+ * @see java.lang.Class#getConstructors()
+ * @see java.lang.Class#getDeclaredConstructors()
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public final class Constructor<T>
+  extends AccessibleObject
+  implements GenericDeclaration, Member
+{  
+  private static final int CONSTRUCTOR_MODIFIERS
+    = Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC;
+
+  private MethodSignatureParser p;
+
+  VMConstructor cons;
+
+  /**
+   * This class is uninstantiable outside this package.
+   */
+  Constructor(VMConstructor cons)
+  {
+    this.cons = cons;
+    cons.cons = this;
+  }
+
+  private Constructor()
+  {
+  }
+
+  /**
+   * Gets the class that declared this constructor.
+   * @return the class that declared this member
+   */
+  @SuppressWarnings("unchecked")
+  public Class<T> getDeclaringClass()
+  {
+    return (Class<T>) cons.getDeclaringClass();
+  }
+
+  /**
+   * Gets the name of this constructor (the non-qualified name of the class
+   * it was declared in).
+   * @return the name of this constructor
+   */
+  public String getName()
+  {
+    return cons.getDeclaringClass().getName();
+  }
+
+  /**
+   * Gets the modifiers this constructor uses.  Use the <code>Modifier</code>
+   * class to interpret the values. A constructor can only have a subset of the
+   * following modifiers: public, private, protected.
+   *
+   * @return an integer representing the modifiers to this Member
+   * @see Modifier
+   */
+  public int getModifiers()
+  {
+    return cons.getModifiersInternal() & CONSTRUCTOR_MODIFIERS;
+  }
+
+  /**
+   * Return true if this constructor is synthetic, false otherwise.
+   * A synthetic member is one which is created by the compiler,
+   * and which does not appear in the user's source code.
+   * @since 1.5
+   */
+  public boolean isSynthetic()
+  {
+    return (cons.getModifiersInternal() & Modifier.SYNTHETIC) != 0;
+  }
+
+  /**
+   * Return true if this is a varargs constructor, that is if
+   * the constructor takes a variable number of arguments.
+   * @since 1.5
+   */
+  public boolean isVarArgs()
+  {
+    return (cons.getModifiersInternal() & Modifier.VARARGS) != 0;
+  }
+
+  /**
+   * Get the parameter list for this constructor, in declaration order. If the
+   * constructor takes no parameters, returns a 0-length array (not null).
+   *
+   * @return a list of the types of the constructor's parameters
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?>[] getParameterTypes()
+  {
+    return (Class<?>[]) cons.getParameterTypes();
+  }
+
+  /**
+   * Get the exception types this constructor says it throws, in no particular
+   * order. If the constructor has no throws clause, returns a 0-length array
+   * (not null).
+   *
+   * @return a list of the types in the constructor's throws clause
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?>[] getExceptionTypes()
+  {
+    return (Class<?>[]) cons.getExceptionTypes();
+  }
+
+  /**
+   * Compare two objects to see if they are semantically equivalent.
+   * Two Constructors are semantically equivalent if they have the same
+   * declaring class and the same parameter list.  This ignores different
+   * exception clauses, but since you can't create a Method except through the
+   * VM, this is just the == relation.
+   *
+   * @param o the object to compare to
+   * @return <code>true</code> if they are equal; <code>false</code> if not.
+   */
+  public boolean equals(Object o)
+  {
+    return cons.equals(o);
+  }
+
+  /**
+   * Get the hash code for the Constructor. The Constructor hash code is the
+   * hash code of the declaring class's name.
+   *
+   * @return the hash code for the object
+   */
+  public int hashCode()
+  {
+    return getName().hashCode();
+  }
+
+  /**
+   * Get a String representation of the Constructor. A Constructor's String
+   * representation is "&lt;modifier&gt; &lt;classname&gt;(&lt;paramtypes&gt;)
+   * throws &lt;exceptions&gt;", where everything after ')' is omitted if
+   * there are no exceptions.<br> Example:
+   * <code>public java.io.FileInputStream(java.lang.Runnable)
+   * throws java.io.FileNotFoundException</code>
+   *
+   * @return the String representation of the Constructor
+   */
+  public String toString()
+  {
+    // 128 is a reasonable buffer initial size for constructor
+    CPStringBuilder sb = new CPStringBuilder(128);
+    Modifier.toString(getModifiers(), sb).append(' ');
+    sb.append(getDeclaringClass().getName()).append('(');
+    Class[] c = getParameterTypes();
+    if (c.length > 0)
+      {
+        sb.append(ClassHelper.getUserName(c[0]));
+        for (int i = 1; i < c.length; i++)
+          sb.append(',').append(ClassHelper.getUserName(c[i]));
+      }
+    sb.append(')');
+    c = getExceptionTypes();
+    if (c.length > 0)
+      {
+        sb.append(" throws ").append(c[0].getName());
+        for (int i = 1; i < c.length; i++)
+          sb.append(',').append(c[i].getName());
+      }
+    return sb.toString();
+  }
+
+  static <X extends GenericDeclaration>
+  void addTypeParameters(CPStringBuilder sb, TypeVariable<X>[] typeArgs)
+  {
+    if (typeArgs.length == 0)
+      return;
+    sb.append('<');
+    for (int i = 0; i < typeArgs.length; ++i)
+      {
+        if (i > 0)
+          sb.append(',');
+        sb.append(typeArgs[i]);
+      }
+    sb.append("> ");
+  }
+
+  public String toGenericString()
+  {
+    CPStringBuilder sb = new CPStringBuilder(128);
+    Modifier.toString(getModifiers(), sb).append(' ');
+    addTypeParameters(sb, getTypeParameters());
+    sb.append(getDeclaringClass().getName()).append('(');
+    Type[] types = getGenericParameterTypes();
+    if (types.length > 0)
+      {
+        sb.append(types[0]);
+        for (int i = 1; i < types.length; ++i)
+          sb.append(',').append(types[i]);
+      }
+    sb.append(')');
+    types = getGenericExceptionTypes();
+    if (types.length > 0)
+      {
+        sb.append(" throws ").append(types[0]);
+        for (int i = 1; i < types.length; i++)
+          sb.append(',').append(types[i]);
+      }
+    return sb.toString();
+  }
+
+  /**
+   * Create a new instance by invoking the constructor. Arguments are
+   * automatically unwrapped and widened, if needed.<p>
+   *
+   * If this class is abstract, you will get an
+   * <code>InstantiationException</code>. If the constructor takes 0
+   * arguments, you may use null or a 0-length array for <code>args</code>.<p>
+   *
+   * If this Constructor enforces access control, your runtime context is
+   * evaluated, and you may have an <code>IllegalAccessException</code> if
+   * you could not create this object in similar compiled code. If the class
+   * is uninitialized, you trigger class initialization, which may end in a
+   * <code>ExceptionInInitializerError</code>.<p>
+   *
+   * Then, the constructor is invoked. If it completes normally, the return
+   * value will be the new object. If it completes abruptly, the exception is
+   * wrapped in an <code>InvocationTargetException</code>.
+   *
+   * @param args the arguments to the constructor
+   * @return the newly created object
+   * @throws IllegalAccessException if the constructor could not normally be
+   *         called by the Java code (i.e. it is not public)
+   * @throws IllegalArgumentException if the number of arguments is incorrect;
+   *         or if the arguments types are wrong even with a widening
+   *         conversion
+   * @throws InstantiationException if the class is abstract
+   * @throws InvocationTargetException if the constructor throws an exception
+   * @throws ExceptionInInitializerError if construction triggered class
+   *         initialization, which then failed
+   */
+  @SuppressWarnings("unchecked")
+  public T newInstance(Object... args)
+    throws InstantiationException, IllegalAccessException,
+           InvocationTargetException
+  {
+    return (T) cons.construct(args);
+  }
+
+  /**
+   * Returns an array of <code>TypeVariable</code> objects that represents
+   * the type variables declared by this constructor, in declaration order.
+   * An array of size zero is returned if this constructor has no type
+   * variables.
+   *
+   * @return the type variables associated with this constructor.
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public TypeVariable<Constructor<T>>[] getTypeParameters()
+  {
+    if (p == null)
+      {
+       String sig = cons.getSignature();
+       if (sig == null)
+         return new TypeVariable[0];
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getTypeParameters();
+  }
+
+  /**
+   * Returns an array of <code>Type</code> objects that represents
+   * the exception types declared by this constructor, in declaration order.
+   * An array of size zero is returned if this constructor declares no
+   * exceptions.
+   *
+   * @return the exception types declared by this constructor. 
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type[] getGenericExceptionTypes()
+  {
+    if (p == null)
+      {
+       String sig = cons.getSignature();
+       if (sig == null)
+         return getExceptionTypes();
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getGenericExceptionTypes();
+  }
+
+  /**
+   * Returns an array of <code>Type</code> objects that represents
+   * the parameter list for this constructor, in declaration order.
+   * An array of size zero is returned if this constructor takes no
+   * parameters.
+   *
+   * @return a list of the types of the constructor's parameters
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type[] getGenericParameterTypes()
+  {
+    if (p == null)
+      {
+       String sig = cons.getSignature();
+       if (sig == null)
+         return getParameterTypes();
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getGenericParameterTypes();
+  }
+
+  /**
+   * <p>
+   * Return an array of arrays representing the annotations on each
+   * of the constructor's parameters.  The outer array is aligned against
+   * the parameters of the constructors and is thus equal in length to
+   * the number of parameters (thus having a length zero if there are none).
+   * Each array element in the outer array contains an inner array which
+   * holds the annotations.  This array has a length of zero if the parameter
+   * has no annotations.
+   * </p>
+   * <p>
+   * The returned annotations are serialized.  Changing the annotations has
+   * no affect on the return value of future calls to this method.
+   * </p>
+   * 
+   * @return an array of arrays which represents the annotations used on the
+   *         parameters of this constructor.  The order of the array elements
+   *         matches the declaration order of the parameters.
+   * @since 1.5
+   */
+  public Annotation[][] getParameterAnnotations()
+  {
+    return cons.getParameterAnnotations();
+  }
+
+  /**
+   * Returns the element's annotation for the specified annotation type,
+   * or <code>null</code> if no such annotation exists.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return this element's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @throws NullPointerException if the annotation class is <code>null</code>.
+   */
+  @SuppressWarnings("unchecked")
+  public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
+  {
+    return (T) cons.getAnnotation(annotationClass);
+  }
+
+  /**
+   * Returns all annotations directly defined by the element.  If there are
+   * no annotations directly associated with the element, then a zero-length
+   * array will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of this
+   * class, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by the element.
+   * @since 1.5
+   */
+  public Annotation[] getDeclaredAnnotations()
+  {
+    return cons.getDeclaredAnnotations();
+  }
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/Field.java b/src/classes/gnuclasspath/java/lang/reflect/Field.java
new file mode 100644 (file)
index 0000000..4c2c183
--- /dev/null
@@ -0,0 +1,735 @@
+/* java.lang.reflect.Field - reflection of Java fields
+   Copyright (C) 1998, 2001, 2005, 2008 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.java.lang.ClassHelper;
+import gnu.java.lang.CPStringBuilder;
+
+import gnu.java.lang.reflect.FieldSignatureParser;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * The Field class represents a member variable of a class. It also allows
+ * dynamic access to a member, via reflection. This works for both
+ * static and instance fields. Operations on Field objects know how to
+ * do widening conversions, but throw {@link IllegalArgumentException} if
+ * a narrowing conversion would be necessary. You can query for information
+ * on this Field regardless of location, but get and set access may be limited
+ * by Java language access controls. If you can't do it in the compiler, you
+ * can't normally do it here either.<p>
+ *
+ * <B>Note:</B> This class returns and accepts types as Classes, even
+ * primitive types; there are Class types defined that represent each
+ * different primitive type.  They are <code>java.lang.Boolean.TYPE,
+ * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class,
+ * byte.class</code>, etc.  These are not to be confused with the
+ * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are
+ * real classes.<p>
+ *
+ * Also note that this is not a serializable class.  It is entirely feasible
+ * to make it serializable using the Externalizable interface, but this is
+ * on Sun, not me.
+ *
+ * @author John Keiser
+ * @author Eric Blake <ebb9@email.byu.edu>
+ * @see Member
+ * @see Class
+ * @see Class#getField(String)
+ * @see Class#getDeclaredField(String)
+ * @see Class#getFields()
+ * @see Class#getDeclaredFields()
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public final class Field
+extends AccessibleObject implements Member
+{
+  static final int FIELD_MODIFIERS
+    = Modifier.FINAL | Modifier.PRIVATE | Modifier.PROTECTED
+      | Modifier.PUBLIC | Modifier.STATIC | Modifier.TRANSIENT
+      | Modifier.VOLATILE;
+
+  private FieldSignatureParser p;
+
+  VMField f;
+
+  /**
+   * This class is uninstantiable outside the package.
+   */
+  Field(VMField f)
+  {
+    this.f = f;
+    f.f = this;
+  }
+
+  /**
+   * Gets the class that declared this field, or the class where this field
+   * is a non-inherited member.
+   * @return the class that declared this member
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?> getDeclaringClass()
+  {
+    return (Class<?>) f.getDeclaringClass();
+  }
+
+  /**
+   * Gets the name of this field.
+   * @return the name of this field
+   */
+  public String getName()
+  {
+    return f.getName();
+  }
+
+  /**
+   * Gets the modifiers this field uses.  Use the <code>Modifier</code>
+   * class to interpret the values.  A field can only have a subset of the
+   * following modifiers: public, private, protected, static, final,
+   * transient, and volatile.
+   *
+   * @return an integer representing the modifiers to this Member
+   * @see Modifier
+   */
+  public int getModifiers()
+  {
+    return f.getModifiersInternal() & FIELD_MODIFIERS;
+  }
+
+  /**
+   * Return true if this field is synthetic, false otherwise.
+   * @since 1.5
+   */
+  public boolean isSynthetic()
+  {
+    return (f.getModifiersInternal() & Modifier.SYNTHETIC) != 0;
+  }
+
+  /**
+   * Return true if this field represents an enum constant,
+   * false otherwise.
+   * @since 1.5
+   */
+  public boolean isEnumConstant()
+  {
+    return (f.getModifiersInternal() & Modifier.ENUM) != 0;
+  }
+
+  /**
+   * Gets the type of this field.
+   * @return the type of this field
+   */
+  public Class<?> getType()
+  {
+    return f.getType();
+  }
+
+  /**
+   * Compare two objects to see if they are semantically equivalent.
+   * Two Fields are semantically equivalent if they have the same declaring
+   * class, name, and type. Since you can't creat a Field except through
+   * the VM, this is just the == relation.
+   *
+   * @param o the object to compare to
+   * @return <code>true</code> if they are equal; <code>false</code> if not
+   */
+  public boolean equals(Object o)
+  {
+    return f.equals(o);
+  }
+
+  /**
+   * Get the hash code for the Field. The Field hash code is the hash code
+   * of its name XOR'd with the hash code of its class name.
+   *
+   * @return the hash code for the object.
+   */
+  public int hashCode()
+  {
+    return f.getDeclaringClass().getName().hashCode() ^ f.getName().hashCode();
+  }
+
+  /**
+   * Get a String representation of the Field. A Field's String
+   * representation is "&lt;modifiers&gt; &lt;type&gt;
+   * &lt;class&gt;.&lt;fieldname&gt;".<br> Example:
+   * <code>public transient boolean gnu.parse.Parser.parseComplete</code>
+   *
+   * @return the String representation of the Field
+   */
+  public String toString()
+  {
+    // 64 is a reasonable buffer initial size for field
+    CPStringBuilder sb = new CPStringBuilder(64);
+    Modifier.toString(getModifiers(), sb).append(' ');
+    sb.append(ClassHelper.getUserName(getType())).append(' ');
+    sb.append(getDeclaringClass().getName()).append('.');
+    sb.append(getName());
+    return sb.toString();
+  }
+
+  public String toGenericString()
+  {
+    CPStringBuilder sb = new CPStringBuilder(64);
+    Modifier.toString(getModifiers(), sb).append(' ');
+    sb.append(getGenericType()).append(' ');
+    sb.append(getDeclaringClass().getName()).append('.');
+    sb.append(getName());
+    return sb.toString();
+  }
+
+  /**
+   * Get the value of this Field.  If it is primitive, it will be wrapped
+   * in the appropriate wrapper type (boolean = java.lang.Boolean).<p>
+   *
+   * If the field is static, <code>o</code> will be ignored. Otherwise, if
+   * <code>o</code> is null, you get a <code>NullPointerException</code>,
+   * and if it is incompatible with the declaring class of the field, you
+   * get an <code>IllegalArgumentException</code>.<p>
+   *
+   * Next, if this Field enforces access control, your runtime context is
+   * evaluated, and you may have an <code>IllegalAccessException</code> if
+   * you could not access this field in similar compiled code. If the field
+   * is static, and its class is uninitialized, you trigger class
+   * initialization, which may end in a
+   * <code>ExceptionInInitializerError</code>.<p>
+   *
+   * Finally, the field is accessed, and primitives are wrapped (but not
+   * necessarily in new objects). This method accesses the field of the
+   * declaring class, even if the instance passed in belongs to a subclass
+   * which declares another field to hide this one.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if <code>o</code> is not an instance of
+   *         the class or interface declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #getBoolean(Object)
+   * @see #getByte(Object)
+   * @see #getChar(Object)
+   * @see #getShort(Object)
+   * @see #getInt(Object)
+   * @see #getLong(Object)
+   * @see #getFloat(Object)
+   * @see #getDouble(Object)
+   */
+  public Object get(Object o)
+    throws IllegalAccessException
+  {
+    return f.get(o);
+  }
+
+  /**
+   * Get the value of this boolean Field. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a boolean field of
+   *         <code>o</code>, or if <code>o</code> is not an instance of the
+   *         declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public boolean getBoolean(Object o)
+    throws IllegalAccessException
+  {
+    return f.getBoolean(o);
+  }
+
+  /**
+   * Get the value of this byte Field. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte field of
+   *         <code>o</code>, or if <code>o</code> is not an instance of the
+   *         declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public byte getByte(Object o)
+    throws IllegalAccessException
+  {
+    return f.getByte(o);
+  }
+
+  /**
+   * Get the value of this Field as a char. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a char field of
+   *         <code>o</code>, or if <code>o</code> is not an instance
+   *         of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public char getChar(Object o)
+    throws IllegalAccessException
+  {
+    return f.getChar(o);
+  }
+
+  /**
+   * Get the value of this Field as a short. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte or short
+   *         field of <code>o</code>, or if <code>o</code> is not an instance
+   *         of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public short getShort(Object o)
+    throws IllegalAccessException
+  {
+    return f.getShort(o);
+  }
+
+  /**
+   * Get the value of this Field as an int. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, or
+   *         int field of <code>o</code>, or if <code>o</code> is not an
+   *         instance of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public int getInt(Object o)
+    throws IllegalAccessException
+  {
+    return f.getInt(o);
+  }
+
+  /**
+   * Get the value of this Field as a long. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, int,
+   *         or long field of <code>o</code>, or if <code>o</code> is not an
+   *         instance of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public long getLong(Object o)
+    throws IllegalAccessException
+  {
+    return f.getLong(o);
+  }
+
+  /**
+   * Get the value of this Field as a float. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, int,
+   *         long, or float field of <code>o</code>, or if <code>o</code> is
+   *         not an instance of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public float getFloat(Object o)
+    throws IllegalAccessException
+  {
+    return f.getFloat(o);
+  }
+
+  /**
+   * Get the value of this Field as a double. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, int,
+   *         long, float, or double field of <code>o</code>, or if
+   *         <code>o</code> is not an instance of the declaring class of this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public double getDouble(Object o)
+    throws IllegalAccessException
+  {
+    return f.getDouble(o);
+  }
+
+  /**
+   * Set the value of this Field.  If it is a primitive field, the value
+   * will be unwrapped from the passed object (boolean = java.lang.Boolean).<p>
+   *
+   * If the field is static, <code>o</code> will be ignored. Otherwise, if
+   * <code>o</code> is null, you get a <code>NullPointerException</code>,
+   * and if it is incompatible with the declaring class of the field, you
+   * get an <code>IllegalArgumentException</code>.<p>
+   *
+   * Next, if this Field enforces access control, your runtime context is
+   * evaluated, and you may have an <code>IllegalAccessException</code> if
+   * you could not access this field in similar compiled code. This also
+   * occurs whether or not there is access control if the field is final.
+   * If the field is primitive, and unwrapping your argument fails, you will
+   * get an <code>IllegalArgumentException</code>; likewise, this error
+   * happens if <code>value</code> cannot be cast to the correct object type.
+   * If the field is static, and its class is uninitialized, you trigger class
+   * initialization, which may end in a
+   * <code>ExceptionInInitializerError</code>.<p>
+   *
+   * Finally, the field is set with the widened value. This method accesses
+   * the field of the declaring class, even if the instance passed in belongs
+   * to a subclass which declares another field to hide this one.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if <code>value</code> cannot be
+   *         converted by a widening conversion to the underlying type of
+   *         the Field, or if <code>o</code> is not an instance of the class
+   *         declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #setBoolean(Object, boolean)
+   * @see #setByte(Object, byte)
+   * @see #setChar(Object, char)
+   * @see #setShort(Object, short)
+   * @see #setInt(Object, int)
+   * @see #setLong(Object, long)
+   * @see #setFloat(Object, float)
+   * @see #setDouble(Object, double)
+   */
+  public void set(Object o, Object value)
+    throws IllegalAccessException
+  {
+    f.set(o, value);
+  }
+
+  /**
+   * Set this boolean Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a boolean field, or if
+   *         <code>o</code> is not an instance of the class declaring this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setBoolean(Object o, boolean value)
+    throws IllegalAccessException
+  {
+    f.setBoolean(o, value);
+  }
+
+  /**
+   * Set this byte Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, int, long,
+   *         float, or double field, or if <code>o</code> is not an instance
+   *         of the class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setByte(Object o, byte value)
+    throws IllegalAccessException
+  {
+    f.setByte(o, value);
+  }
+
+  /**
+   * Set this char Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a char, int, long,
+   *         float, or double field, or if <code>o</code> is not an instance
+   *         of the class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setChar(Object o, char value)
+    throws IllegalAccessException
+  {
+    f.setChar(o, value);
+  }
+
+  /**
+   * Set this short Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a short, int, long,
+   *         float, or double field, or if <code>o</code> is not an instance
+   *         of the class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setShort(Object o, short value)
+    throws IllegalAccessException
+  {
+    f.setShort(o, value);
+  }
+
+  /**
+   * Set this int Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not an int, long, float, or
+   *         double field, or if <code>o</code> is not an instance of the
+   *         class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setInt(Object o, int value)
+    throws IllegalAccessException
+  {
+    f.setInt(o, value);
+  }
+
+  /**
+   * Set this long Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a long, float, or double
+   *         field, or if <code>o</code> is not an instance of the class
+   *         declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setLong(Object o, long value)
+    throws IllegalAccessException
+  {
+    f.setLong(o, value);
+  }
+
+  /**
+   * Set this float Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a float or long field, or
+   *         if <code>o</code> is not an instance of the class declaring this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setFloat(Object o, float value)
+    throws IllegalAccessException
+  {
+    f.setFloat(o, value);
+  }
+
+  /**
+   * Set this double Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a double field, or if
+   *         <code>o</code> is not an instance of the class declaring this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setDouble(Object o, double value)
+    throws IllegalAccessException
+  {
+    f.setDouble(o, value);
+  }
+
+  /**
+   * Return the generic type of the field. If the field type is not a generic
+   * type, the method returns the same as <code>getType()</code>.
+   *
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type getGenericType()
+  {
+    if (p == null)
+      {
+       String signature = f.getSignature();
+       if (signature == null)
+         return getType();
+       p = new FieldSignatureParser(getDeclaringClass(),
+                                    signature);
+      }
+    return p.getFieldType();
+  }
+
+  /**
+   * Returns the element's annotation for the specified annotation type,
+   * or <code>null</code> if no such annotation exists.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return this element's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @throws NullPointerException if the annotation class is <code>null</code>.
+   */
+  @SuppressWarnings("unchecked")
+  public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
+  {
+    return (T) f.getAnnotation(annotationClass);
+  }
+
+  /**
+   * Returns all annotations directly defined by the element.  If there are
+   * no annotations directly associated with the element, then a zero-length
+   * array will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of this
+   * class, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by the element.
+   * @since 1.5
+   */
+  public Annotation[] getDeclaredAnnotations()
+  {
+    return f.getDeclaredAnnotations();
+  }
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/Method.java b/src/classes/gnuclasspath/java/lang/reflect/Method.java
new file mode 100644 (file)
index 0000000..e787fb3
--- /dev/null
@@ -0,0 +1,499 @@
+/* java.lang.reflect.Method - reflection of Java methods
+   Copyright (C) 1998, 2001, 2002, 2005, 2007, 2008 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.java.lang.ClassHelper;
+import gnu.java.lang.CPStringBuilder;
+
+import gnu.java.lang.reflect.MethodSignatureParser;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * The Method class represents a member method of a class. It also allows
+ * dynamic invocation, via reflection. This works for both static and
+ * instance methods. Invocation on Method objects knows how to do
+ * widening conversions, but throws {@link IllegalArgumentException} if
+ * a narrowing conversion would be necessary. You can query for information
+ * on this Method regardless of location, but invocation access may be limited
+ * by Java language access controls. If you can't do it in the compiler, you
+ * can't normally do it here either.<p>
+ *
+ * <B>Note:</B> This class returns and accepts types as Classes, even
+ * primitive types; there are Class types defined that represent each
+ * different primitive type.  They are <code>java.lang.Boolean.TYPE,
+ * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class,
+ * byte.class</code>, etc.  These are not to be confused with the
+ * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are
+ * real classes.<p>
+ *
+ * Also note that this is not a serializable class.  It is entirely feasible
+ * to make it serializable using the Externalizable interface, but this is
+ * on Sun, not me.
+ *
+ * @author John Keiser
+ * @author Eric Blake <ebb9@email.byu.edu>
+ * @see Member
+ * @see Class
+ * @see java.lang.Class#getMethod(String,Class[])
+ * @see java.lang.Class#getDeclaredMethod(String,Class[])
+ * @see java.lang.Class#getMethods()
+ * @see java.lang.Class#getDeclaredMethods()
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public final class Method
+extends AccessibleObject implements Member, GenericDeclaration
+{
+  private static final int METHOD_MODIFIERS
+    = Modifier.ABSTRACT | Modifier.FINAL | Modifier.NATIVE
+      | Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC
+      | Modifier.STATIC | Modifier.STRICT | Modifier.SYNCHRONIZED;
+
+  private MethodSignatureParser p;
+
+  VMMethod m;
+
+  /**
+   * This class is uninstantiable outside this package.
+   */
+  Method(VMMethod m)
+  {
+    this.m = m;
+    m.m = this;
+  }
+
+  /**
+   * Gets the class that declared this method, or the class where this method
+   * is a non-inherited member.
+   * @return the class that declared this member
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?> getDeclaringClass()
+  {
+    return (Class<?>) m.getDeclaringClass();
+  }
+
+  /**
+   * Gets the name of this method.
+   * @return the name of this method
+   */
+  public String getName()
+  {
+    return m.getName();
+  }
+
+  /**
+   * Gets the modifiers this method uses.  Use the <code>Modifier</code>
+   * class to interpret the values.  A method can only have a subset of the
+   * following modifiers: public, private, protected, abstract, static,
+   * final, synchronized, native, and strictfp.
+   *
+   * @return an integer representing the modifiers to this Member
+   * @see Modifier
+   */
+  public int getModifiers()
+  {
+    return m.getModifiersInternal() & METHOD_MODIFIERS;
+  }
+
+  /**
+   * Return true if this method is a bridge method.  A bridge method
+   * is generated by the compiler in some situations involving
+   * generics and inheritance.
+   * @since 1.5
+   */
+  public boolean isBridge()
+  {
+    return (m.getModifiersInternal() & Modifier.BRIDGE) != 0;
+  }
+
+  /**
+   * Return true if this method is synthetic, false otherwise.
+   * @since 1.5
+   */
+  public boolean isSynthetic()
+  {
+    return (m.getModifiersInternal() & Modifier.SYNTHETIC) != 0;
+  }
+
+  /**
+   * Return true if this is a varargs method, that is if
+   * the method takes a variable number of arguments.
+   * @since 1.5
+   */
+  public boolean isVarArgs()
+  {
+    return (m.getModifiersInternal() & Modifier.VARARGS) != 0;
+  }
+
+  /**
+   * Gets the return type of this method.
+   * @return the type of this method
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?> getReturnType()
+  {
+    return (Class<?>) m.getReturnType();
+  }
+
+  /**
+   * Get the parameter list for this method, in declaration order. If the
+   * method takes no parameters, returns a 0-length array (not null).
+   *
+   * @return a list of the types of the method's parameters
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?>[] getParameterTypes()
+  {
+    return (Class<?>[]) m.getParameterTypes();
+  }
+
+  /**
+   * Get the exception types this method says it throws, in no particular
+   * order. If the method has no throws clause, returns a 0-length array
+   * (not null).
+   *
+   * @return a list of the types in the method's throws clause
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?>[] getExceptionTypes()
+  {
+    return (Class<?>[]) m.getExceptionTypes();
+  }
+
+  /**
+   * Compare two objects to see if they are semantically equivalent.
+   * Two Methods are semantically equivalent if they have the same declaring
+   * class, name, parameter list, and return type.
+   *
+   * @param o the object to compare to
+   * @return <code>true</code> if they are equal; <code>false</code> if not
+   */
+  public boolean equals(Object o)
+  {
+    return m.equals(o);
+  }
+
+  /**
+   * Get the hash code for the Method. The Method hash code is the hash code
+   * of its name XOR'd with the hash code of its class name.
+   *
+   * @return the hash code for the object
+   */
+  public int hashCode()
+  {
+    return m.getDeclaringClass().getName().hashCode() ^ m.getName().hashCode();
+  }
+
+  /**
+   * Get a String representation of the Method. A Method's String
+   * representation is "&lt;modifiers&gt; &lt;returntype&gt;
+   * &lt;methodname&gt;(&lt;paramtypes&gt;) throws &lt;exceptions&gt;", where
+   * everything after ')' is omitted if there are no exceptions.<br> Example:
+   * <code>public static int run(java.lang.Runnable,int)</code>
+   *
+   * @return the String representation of the Method
+   */
+  public String toString()
+  {
+    // 128 is a reasonable buffer initial size for constructor
+    CPStringBuilder sb = new CPStringBuilder(128);
+    Modifier.toString(getModifiers(), sb).append(' ');
+    sb.append(ClassHelper.getUserName(getReturnType())).append(' ');
+    sb.append(getDeclaringClass().getName()).append('.');
+    sb.append(getName()).append('(');
+    Class[] c = getParameterTypes();
+    if (c.length > 0)
+      {
+        sb.append(ClassHelper.getUserName(c[0]));
+        for (int i = 1; i < c.length; i++)
+          sb.append(',').append(ClassHelper.getUserName(c[i]));
+      }
+    sb.append(')');
+    c = getExceptionTypes();
+    if (c.length > 0)
+      {
+        sb.append(" throws ").append(c[0].getName());
+        for (int i = 1; i < c.length; i++)
+          sb.append(',').append(c[i].getName());
+      }
+    return sb.toString();
+  }
+
+  public String toGenericString()
+  {
+    // 128 is a reasonable buffer initial size for constructor
+    CPStringBuilder sb = new CPStringBuilder(128);
+    Modifier.toString(getModifiers(), sb).append(' ');
+    Constructor.addTypeParameters(sb, getTypeParameters());
+    sb.append(getGenericReturnType()).append(' ');
+    sb.append(getDeclaringClass().getName()).append('.');
+    sb.append(getName()).append('(');
+    Type[] types = getGenericParameterTypes();
+    if (types.length > 0)
+      {
+        sb.append(types[0]);
+        for (int i = 1; i < types.length; i++)
+          sb.append(',').append(types[i]);
+      }
+    sb.append(')');
+    types = getGenericExceptionTypes();
+    if (types.length > 0)
+      {
+        sb.append(" throws ").append(types[0]);
+        for (int i = 1; i < types.length; i++)
+          sb.append(',').append(types[i]);
+      }
+    return sb.toString();
+  }
+
+  /**
+   * Invoke the method. Arguments are automatically unwrapped and widened,
+   * and the result is automatically wrapped, if needed.<p>
+   *
+   * If the method is static, <code>o</code> will be ignored. Otherwise,
+   * the method uses dynamic lookup as described in JLS 15.12.4.4. You cannot
+   * mimic the behavior of nonvirtual lookup (as in super.foo()). This means
+   * you will get a <code>NullPointerException</code> if <code>o</code> is
+   * null, and an <code>IllegalArgumentException</code> if it is incompatible
+   * with the declaring class of the method. If the method takes 0 arguments,
+   * you may use null or a 0-length array for <code>args</code>.<p>
+   *
+   * Next, if this Method enforces access control, your runtime context is
+   * evaluated, and you may have an <code>IllegalAccessException</code> if
+   * you could not acces this method in similar compiled code. If the method
+   * is static, and its class is uninitialized, you trigger class
+   * initialization, which may end in a
+   * <code>ExceptionInInitializerError</code>.<p>
+   *
+   * Finally, the method is invoked. If it completes normally, the return value
+   * will be null for a void method, a wrapped object for a primitive return
+   * method, or the actual return of an Object method. If it completes
+   * abruptly, the exception is wrapped in an
+   * <code>InvocationTargetException</code>.
+   *
+   * @param o the object to invoke the method on
+   * @param args the arguments to the method
+   * @return the return value of the method, wrapped in the appropriate
+   *         wrapper if it is primitive
+   * @throws IllegalAccessException if the method could not normally be called
+   *         by the Java code (i.e. it is not public)
+   * @throws IllegalArgumentException if the number of arguments is incorrect;
+   *         if the arguments types are wrong even with a widening conversion;
+   *         or if <code>o</code> is not an instance of the class or interface
+   *         declaring this method
+   * @throws InvocationTargetException if the method throws an exception
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static method triggered
+   *         class initialization, which then failed
+   */
+  public Object invoke(Object o, Object... args)
+    throws IllegalAccessException, InvocationTargetException
+  {
+    return m.invoke(o, args);
+  }
+
+  /**
+   * Returns an array of <code>TypeVariable</code> objects that represents
+   * the type variables declared by this constructor, in declaration order.
+   * An array of size zero is returned if this class has no type
+   * variables.
+   *
+   * @return the type variables associated with this class. 
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public TypeVariable<Method>[] getTypeParameters()
+  {
+    if (p == null)
+      {
+       String sig = m.getSignature();
+       if (sig == null)
+         return (TypeVariable<Method>[]) new TypeVariable[0];
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getTypeParameters();
+  }
+
+  /**
+   * Returns an array of <code>Type</code> objects that represents
+   * the exception types declared by this method, in declaration order.
+   * An array of size zero is returned if this method declares no
+   * exceptions.
+   *
+   * @return the exception types declared by this method. 
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type[] getGenericExceptionTypes()
+  {
+    if (p == null)
+      {
+       String sig = m.getSignature();
+       if (sig == null)
+         return getExceptionTypes();
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getGenericExceptionTypes();
+  }
+
+  /**
+   * Returns an array of <code>Type</code> objects that represents
+   * the parameter list for this method, in declaration order.
+   * An array of size zero is returned if this method takes no
+   * parameters.
+   *
+   * @return a list of the types of the method's parameters
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type[] getGenericParameterTypes()
+  {
+    if (p == null)
+      {
+       String sig = m.getSignature();
+       if (sig == null)
+         return getParameterTypes();
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getGenericParameterTypes();
+  }
+
+  /**
+   * Returns the return type of this method.
+   *
+   * @return the return type of this method
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type getGenericReturnType()
+  {
+    if (p == null)
+      {
+       String sig = m.getSignature();
+       if (sig == null)
+         return getReturnType();
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getGenericReturnType();
+  }
+
+  /**
+   * If this method is an annotation method, returns the default
+   * value for the method.  If there is no default value, or if the
+   * method is not a member of an annotation type, returns null.
+   * Primitive types are wrapped.
+   *
+   * @throws TypeNotPresentException if the method returns a Class,
+   * and the class cannot be found
+   *
+   * @since 1.5
+   */
+  public Object getDefaultValue()
+  {
+    return m.getDefaultValue();
+  }
+
+  /**
+   * <p>
+   * Return an array of arrays representing the annotations on each
+   * of the method's parameters.  The outer array is aligned against
+   * the parameters of the method and is thus equal in length to
+   * the number of parameters (thus having a length zero if there are none).
+   * Each array element in the outer array contains an inner array which
+   * holds the annotations.  This array has a length of zero if the parameter
+   * has no annotations.
+   * </p>
+   * <p>
+   * The returned annotations are serialized.  Changing the annotations has
+   * no affect on the return value of future calls to this method.
+   * </p>
+   * 
+   * @return an array of arrays which represents the annotations used on the
+   *         parameters of this method.  The order of the array elements
+   *         matches the declaration order of the parameters.
+   * @since 1.5
+   */
+  public Annotation[][] getParameterAnnotations()
+  {
+    return m.getParameterAnnotations();
+  }
+
+  /**
+   * Returns the element's annotation for the specified annotation type,
+   * or <code>null</code> if no such annotation exists.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return this element's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @throws NullPointerException if the annotation class is <code>null</code>.
+   */
+  @SuppressWarnings("unchecked")
+  public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
+  {
+    return (T) m.getAnnotation(annotationClass);
+  }
+
+  /**
+   * Returns all annotations directly defined by the element.  If there are
+   * no annotations directly associated with the element, then a zero-length
+   * array will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of this
+   * class, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by the element.
+   * @since 1.5
+   */
+  public Annotation[] getDeclaredAnnotations()
+  {
+    return m.getDeclaredAnnotations();
+  }
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/Modifier.java b/src/classes/gnuclasspath/java/lang/reflect/Modifier.java
new file mode 100644 (file)
index 0000000..45d9b51
--- /dev/null
@@ -0,0 +1,354 @@
+/* java.lang.reflect.Modifier
+   Copyright (C) 1998, 1999, 2001, 2002, 2005, 2008  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.java.lang.CPStringBuilder;
+
+/**
+ * Modifier is a helper class with static methods to determine whether an
+ * int returned from getModifiers() represents static, public, protected,
+ * native, final, etc... and provides an additional method to print
+ * out all of the modifiers in an int in order.
+ * <p>
+ * The methods in this class use the bitmask values in the VM spec to
+ * determine the modifiers of an int. This means that a VM must return a
+ * standard mask, conformant with the VM spec.  I don't know if this is how
+ * Sun does it, but I'm willing to bet money that it is.
+ *
+ * @author John Keiser
+ * @author Tom Tromey (tromey@cygnus.com)
+ * @author Eric Blake (ebb9@email.byu.edu)
+ * @see Member#getModifiers()
+ * @see Method#getModifiers()
+ * @see Field#getModifiers()
+ * @see Constructor#getModifiers()
+ * @see Class#getModifiers()
+ * @since 1.1
+ */
+public class Modifier
+{
+  /** <STRONG>This constructor really shouldn't be here ... there are no
+   * instance methods or variables of this class, so instantiation is
+   * worthless.  However, this function is in the 1.1 spec, so it is added
+   * for completeness.</STRONG>
+   */
+  public Modifier()
+  {
+  }
+
+  /**
+   * Public: accessible from any other class.
+   */
+  public static final int PUBLIC = 0x0001;
+
+  /**
+   * Private: accessible only from the same enclosing class.
+   */
+  public static final int PRIVATE = 0x0002;
+
+  /**
+   * Protected: accessible only to subclasses, or within the package.
+   */
+  public static final int PROTECTED = 0x0004;
+
+  /**
+   * Static:<br><ul>
+   * <li>Class: no enclosing instance for nested class.</li>
+   * <li>Field or Method: can be accessed or invoked without an
+   *     instance of the declaring class.</li>
+   * </ul>
+   */
+  public static final int STATIC = 0x0008;
+
+  /**
+   * Final:<br><ul>
+   * <li>Class: no subclasses allowed.</li>
+   * <li>Field: cannot be changed.</li>
+   * <li>Method: cannot be overriden.</li>
+   * </ul>
+   */
+  public static final int FINAL = 0x0010;
+
+  /**
+   * Synchronized: Method: lock the class while calling this method.
+   */
+  public static final int SYNCHRONIZED = 0x0020;
+
+  /**
+   * Volatile: Field: cannot be cached.
+   */
+  public static final int VOLATILE = 0x0040;
+
+  /**
+   * Transient: Field: not serialized or deserialized.
+   */
+  public static final int TRANSIENT = 0x0080;
+
+  /**
+   * Native: Method: use JNI to call this method.
+   */
+  public static final int NATIVE = 0x0100;
+
+  /**
+   * Interface: Class: is an interface.
+   */
+  public static final int INTERFACE = 0x0200;
+
+  /**
+   * Abstract:<br><ul>
+   * <li>Class: may not be instantiated.</li>
+   * <li>Method: may not be called.</li>
+   * </ul>
+   */
+  public static final int ABSTRACT = 0x0400;
+
+  /**
+   * Strictfp: Method: expressions are FP-strict.<p>
+   * Also used as a modifier for classes, to mean that all initializers
+   * and constructors are FP-strict, but does not show up in
+   * Class.getModifiers.
+   */
+  public static final int STRICT = 0x0800;
+
+
+  /**
+   * Super - treat invokespecial as polymorphic so that super.foo() works
+   * according to the JLS. This is a reuse of the synchronized constant
+   * to patch a hole in JDK 1.0. *shudder*.
+   */
+  static final int SUPER = 0x0020;
+
+  /**
+   * All the flags, only used by code in this package.
+   */
+  static final int ALL_FLAGS = 0xfff;
+
+  /**
+   * Flag indicating a bridge method.
+   */
+  static final int BRIDGE = 0x40;
+
+  /**
+   * Flag indicating a varargs method.
+   */
+  static final int VARARGS = 0x80;
+
+  /**
+   * Flag indicating a synthetic member.
+   */
+  static final int SYNTHETIC = 0x1000;
+
+  /**
+   * Flag indicating an enum constant or an enum class.
+   */
+  static final int ENUM = 0x4000;
+
+  /**
+   * Check whether the given modifier is abstract.
+   * @param mod the modifier.
+   * @return <code>true</code> if abstract, <code>false</code> otherwise.
+   */
+  public static boolean isAbstract(int mod)
+  {
+    return (mod & ABSTRACT) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is final.
+   * @param mod the modifier.
+   * @return <code>true</code> if final, <code>false</code> otherwise.
+   */
+  public static boolean isFinal(int mod)
+  {
+    return (mod & FINAL) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is an interface.
+   * @param mod the modifier.
+   * @return <code>true</code> if an interface, <code>false</code> otherwise.
+   */
+  public static boolean isInterface(int mod)
+  {
+    return (mod & INTERFACE) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is native.
+   * @param mod the modifier.
+   * @return <code>true</code> if native, <code>false</code> otherwise.
+   */
+  public static boolean isNative(int mod)
+  {
+    return (mod & NATIVE) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is private.
+   * @param mod the modifier.
+   * @return <code>true</code> if private, <code>false</code> otherwise.
+   */
+  public static boolean isPrivate(int mod)
+  {
+    return (mod & PRIVATE) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is protected.
+   * @param mod the modifier.
+   * @return <code>true</code> if protected, <code>false</code> otherwise.
+   */
+  public static boolean isProtected(int mod)
+  {
+    return (mod & PROTECTED) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is public.
+   * @param mod the modifier.
+   * @return <code>true</code> if public, <code>false</code> otherwise.
+   */
+  public static boolean isPublic(int mod)
+  {
+    return (mod & PUBLIC) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is static.
+   * @param mod the modifier.
+   * @return <code>true</code> if static, <code>false</code> otherwise.
+   */
+  public static boolean isStatic(int mod)
+  {
+    return (mod & STATIC) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is strictfp.
+   * @param mod the modifier.
+   * @return <code>true</code> if strictfp, <code>false</code> otherwise.
+   */
+  public static boolean isStrict(int mod)
+  {
+    return (mod & STRICT) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is synchronized.
+   * @param mod the modifier.
+   * @return <code>true</code> if synchronized, <code>false</code> otherwise.
+   */
+  public static boolean isSynchronized(int mod)
+  {
+    return (mod & SYNCHRONIZED) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is transient.
+   * @param mod the modifier.
+   * @return <code>true</code> if transient, <code>false</code> otherwise.
+   */
+  public static boolean isTransient(int mod)
+  {
+    return (mod & TRANSIENT) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is volatile.
+   * @param mod the modifier.
+   * @return <code>true</code> if volatile, <code>false</code> otherwise.
+   */
+  public static boolean isVolatile(int mod)
+  {
+    return (mod & VOLATILE) != 0;
+  }
+
+  /**
+   * Get a string representation of all the modifiers represented by the
+   * given int. The keywords are printed in this order:
+   * <code>&lt;public|protected|private&gt; abstract static final transient
+   * volatile synchronized native strictfp interface</code>.
+   *
+   * @param mod the modifier.
+   * @return the String representing the modifiers.
+   */
+  public static String toString(int mod)
+  {
+    return toString(mod, new CPStringBuilder()).toString();
+  }
+
+  /**
+   * Package helper method that can take a CPStringBuilder.
+   * @param mod the modifier
+   * @param r the CPStringBuilder to which the String representation is appended
+   * @return r, with information appended
+   */
+  static CPStringBuilder toString(int mod, CPStringBuilder r)
+  {
+    if (isPublic(mod))
+      r.append("public ");
+    if (isProtected(mod))
+      r.append("protected ");
+    if (isPrivate(mod))
+      r.append("private ");
+    if (isAbstract(mod))
+      r.append("abstract ");
+    if (isStatic(mod))
+      r.append("static ");
+    if (isFinal(mod))
+      r.append("final ");
+    if (isTransient(mod))
+      r.append("transient ");
+    if (isVolatile(mod))
+      r.append("volatile ");
+    if (isSynchronized(mod))
+      r.append("synchronized ");
+    if (isNative(mod))
+      r.append("native ");
+    if (isStrict(mod))
+      r.append("strictfp ");
+    if (isInterface(mod))
+      r.append("interface ");
+    
+    // Trim trailing space.
+    if ((mod & ALL_FLAGS) != 0)
+      r.setLength(r.length() - 1);
+    return r;
+  }
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/VMConstructor.java b/src/classes/gnuclasspath/java/lang/reflect/VMConstructor.java
new file mode 100644 (file)
index 0000000..6a94711
--- /dev/null
@@ -0,0 +1,207 @@
+/* java.lang.reflect.VMConstructor - VM interface for reflection of Java constructors
+   Copyright (C) 1998, 2001, 2004, 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 java.lang.annotation.Annotation;
+
+import java.util.Arrays;
+import java.util.Map;
+
+final class VMConstructor
+{
+  Class clazz;
+  int slot;
+
+  /**
+   * Unparsed annotations.
+   */
+  private byte[] annotations = null;
+
+  /**
+   * Unparsed parameter annotations.
+   */
+  private byte[] parameterAnnotations = null;
+
+  /**
+   * Annotations get parsed the first time they are
+   * accessed and are then cached it this map.
+   */
+  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
+
+  /**
+   * Helper array for creating a new array from a java.util.Container.
+   */
+  private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
+    new Annotation[0];
+
+  /** 
+   * This field allows us to refer back to the main constructor instance.
+   *  It is set by the constructor of Constructor.
+   */
+  Constructor cons;
+
+  VMConstructor(Class clazz, int slot)
+  {
+    this.clazz = clazz;
+    this.slot = slot;
+  }
+
+  public Class getDeclaringClass()
+  {
+    return clazz;
+  }
+
+  /**
+   * Return the raw modifiers for this constructor.  In particular
+   * this will include the synthetic and varargs bits.
+   * @return the constructor's modifiers
+   */
+  native int getModifiersInternal();
+
+  /**
+   * Get the parameter list for this constructor, in declaration order. If the
+   * constructor takes no parameters, returns a 0-length array (not null).
+   *
+   * @return a list of the types of the constructor's parameters
+   */
+  native Class[] getParameterTypes();
+
+  /**
+   * Get the exception types this constructor says it throws, in no particular
+   * order. If the constructor has no throws clause, returns a 0-length array
+   * (not null).
+   *
+   * @return a list of the types in the constructor's throws clause
+   */
+  native Class[] getExceptionTypes();
+
+  native Object construct(Object[] args)
+    throws InstantiationException, IllegalAccessException,
+    InvocationTargetException;
+
+  /**
+   * Return the String in the Signature attribute for this constructor. If there
+   * is no Signature attribute, return null.
+   */
+  native String getSignature();
+  
+  /**
+   * <p>
+   * Return an array of arrays representing the annotations on each
+   * of the constructor's parameters.  The outer array is aligned against
+   * the parameters of the constructors and is thus equal in length to
+   * the number of parameters (thus having a length zero if there are none).
+   * Each array element in the outer array contains an inner array which
+   * holds the annotations.  This array has a length of zero if the parameter
+   * has no annotations.
+   * </p>
+   * <p>
+   * The returned annotations are serialized.  Changing the annotations has
+   * no affect on the return value of future calls to this method.
+   * </p>
+   * 
+   * @return an array of arrays which represents the annotations used on the
+   *         parameters of this constructor.  The order of the array elements
+   *         matches the declaration order of the parameters.
+   * @since 1.5
+   */
+  native Annotation[][] getParameterAnnotations();
+
+  /**
+   * Compare two objects to see if they are semantically equivalent.
+   * Two Constructors are semantically equivalent if they have the same
+   * declaring class and the same parameter list.  This ignores different
+   * exception clauses, but since you can't create a Method except through the
+   * VM, this is just the == relation.
+   *
+   * @param o the object to compare to
+   * @return <code>true</code> if they are equal; <code>false</code> if not.
+   */
+  public boolean equals(Object o)
+  {
+    if (!(o instanceof Constructor))
+      return false;
+    Constructor that = (Constructor)o; 
+    if (clazz != that.getDeclaringClass())
+      return false;
+    if (!Arrays.equals(getParameterTypes(), that.getParameterTypes()))
+      return false;
+    return true;
+  }
+
+  /**
+   * Returns the element's annotation for the specified annotation type,
+   * or <code>null</code> if no such annotation exists.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return this element's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @throws NullPointerException if the annotation class is <code>null</code>.
+   */
+//   native Annotation getAnnotation(Class annotationClass);
+  Annotation getAnnotation(Class annotationClass) {
+    if (annotationClass == null)
+      throw new NullPointerException();
+
+    return declaredAnnotations().get(annotationClass);
+  }
+
+  /**
+   * Returns all annotations directly defined by the element.  If there are
+   * no annotations directly associated with the element, then a zero-length
+   * array will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of this
+   * class, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by the element.
+   * @since 1.5
+   */
+//   native Annotation[] getDeclaredAnnotations();
+  Annotation[] getDeclaredAnnotations() {
+    return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
+  }
+
+  /**
+   * Parses the annotations if they aren't parsed yet and stores them into
+   * the declaredAnnotations map and return this map.
+   */
+  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/VMField.java b/src/classes/gnuclasspath/java/lang/reflect/VMField.java
new file mode 100644 (file)
index 0000000..eeb30a8
--- /dev/null
@@ -0,0 +1,583 @@
+/* java.lang.reflect.Field - VM interface for reflection of Java fields
+   Copyright (C) 1998, 2001, 2005, 2008 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 java.lang.annotation.Annotation;
+
+import java.util.Map;
+
+final class VMField
+{
+  Class clazz;
+  String name;
+  int slot;
+  
+  /**
+   * Unparsed annotations.
+   */
+  private byte[] annotations = null;
+
+  /**
+   * Annotations get parsed the first time they are
+   * accessed and are then cached it this map.
+   */
+  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
+
+  /**
+   * Helper array for creating a new array from a java.util.Container.
+   */
+  private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
+    new Annotation[0];
+
+  /** 
+   * This field allows us to refer back to the main constructor instance.
+   *  It is set by the constructor of Field.
+   */
+  Field f;
+
+  VMField(Class clazz, String name, int slot)
+  {
+    this.clazz = clazz;
+    this.name = name;
+    this.slot = slot;
+  }
+
+  public Class getDeclaringClass()
+  {
+    return clazz;
+  }
+
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Return the raw modifiers for this field.
+   * @return the field's modifiers
+   */
+  native int getModifiersInternal();
+
+  /**
+   * Gets the type of this field.
+   * @return the type of this field
+   */
+  native Class getType();
+
+  /**
+   * Get the value of this Field.  If it is primitive, it will be wrapped
+   * in the appropriate wrapper type (boolean = java.lang.Boolean).<p>
+   *
+   * If the field is static, <code>o</code> will be ignored. Otherwise, if
+   * <code>o</code> is null, you get a <code>NullPointerException</code>,
+   * and if it is incompatible with the declaring class of the field, you
+   * get an <code>IllegalArgumentException</code>.<p>
+   *
+   * Next, if this Field enforces access control, your runtime context is
+   * evaluated, and you may have an <code>IllegalAccessException</code> if
+   * you could not access this field in similar compiled code. If the field
+   * is static, and its class is uninitialized, you trigger class
+   * initialization, which may end in a
+   * <code>ExceptionInInitializerError</code>.<p>
+   *
+   * Finally, the field is accessed, and primitives are wrapped (but not
+   * necessarily in new objects). This method accesses the field of the
+   * declaring class, even if the instance passed in belongs to a subclass
+   * which declares another field to hide this one.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if <code>o</code> is not an instance of
+   *         the class or interface declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #getBoolean(Object)
+   * @see #getByte(Object)
+   * @see #getChar(Object)
+   * @see #getShort(Object)
+   * @see #getInt(Object)
+   * @see #getLong(Object)
+   * @see #getFloat(Object)
+   * @see #getDouble(Object)
+   */
+  native Object get(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this boolean Field. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a boolean field of
+   *         <code>o</code>, or if <code>o</code> is not an instance of the
+   *         declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native boolean getBoolean(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this byte Field. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte field of
+   *         <code>o</code>, or if <code>o</code> is not an instance of the
+   *         declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native byte getByte(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this Field as a char. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a char field of
+   *         <code>o</code>, or if <code>o</code> is not an instance
+   *         of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native char getChar(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this Field as a short. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte or short
+   *         field of <code>o</code>, or if <code>o</code> is not an instance
+   *         of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native short getShort(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this Field as an int. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, or
+   *         int field of <code>o</code>, or if <code>o</code> is not an
+   *         instance of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native int getInt(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this Field as a long. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, int,
+   *         or long field of <code>o</code>, or if <code>o</code> is not an
+   *         instance of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native long getLong(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this Field as a float. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, int,
+   *         long, or float field of <code>o</code>, or if <code>o</code> is
+   *         not an instance of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native float getFloat(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this Field as a double. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, int,
+   *         long, float, or double field of <code>o</code>, or if
+   *         <code>o</code> is not an instance of the declaring class of this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native double getDouble(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Set the value of this Field.  If it is a primitive field, the value
+   * will be unwrapped from the passed object (boolean = java.lang.Boolean).<p>
+   *
+   * If the field is static, <code>o</code> will be ignored. Otherwise, if
+   * <code>o</code> is null, you get a <code>NullPointerException</code>,
+   * and if it is incompatible with the declaring class of the field, you
+   * get an <code>IllegalArgumentException</code>.<p>
+   *
+   * Next, if this Field enforces access control, your runtime context is
+   * evaluated, and you may have an <code>IllegalAccessException</code> if
+   * you could not access this field in similar compiled code. This also
+   * occurs whether or not there is access control if the field is final.
+   * If the field is primitive, and unwrapping your argument fails, you will
+   * get an <code>IllegalArgumentException</code>; likewise, this error
+   * happens if <code>value</code> cannot be cast to the correct object type.
+   * If the field is static, and its class is uninitialized, you trigger class
+   * initialization, which may end in a
+   * <code>ExceptionInInitializerError</code>.<p>
+   *
+   * Finally, the field is set with the widened value. This method accesses
+   * the field of the declaring class, even if the instance passed in belongs
+   * to a subclass which declares another field to hide this one.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if <code>value</code> cannot be
+   *         converted by a widening conversion to the underlying type of
+   *         the Field, or if <code>o</code> is not an instance of the class
+   *         declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #setBoolean(Object, boolean)
+   * @see #setByte(Object, byte)
+   * @see #setChar(Object, char)
+   * @see #setShort(Object, short)
+   * @see #setInt(Object, int)
+   * @see #setLong(Object, long)
+   * @see #setFloat(Object, float)
+   * @see #setDouble(Object, double)
+   */
+  native void set(Object o, Object value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this boolean Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a boolean field, or if
+   *         <code>o</code> is not an instance of the class declaring this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setBoolean(Object o, boolean value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this byte Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, int, long,
+   *         float, or double field, or if <code>o</code> is not an instance
+   *         of the class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setByte(Object o, byte value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this char Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a char, int, long,
+   *         float, or double field, or if <code>o</code> is not an instance
+   *         of the class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setChar(Object o, char value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this short Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a short, int, long,
+   *         float, or double field, or if <code>o</code> is not an instance
+   *         of the class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setShort(Object o, short value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this int Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not an int, long, float, or
+   *         double field, or if <code>o</code> is not an instance of the
+   *         class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setInt(Object o, int value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this long Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a long, float, or double
+   *         field, or if <code>o</code> is not an instance of the class
+   *         declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setLong(Object o, long value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this float Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a float or long field, or
+   *         if <code>o</code> is not an instance of the class declaring this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setFloat(Object o, float value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this double Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a double field, or if
+   *         <code>o</code> is not an instance of the class declaring this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setDouble(Object o, double value)
+    throws IllegalAccessException;
+
+  /**
+   * Return the String in the Signature attribute for this field. If there
+   * is no Signature attribute, return null.
+   *
+   */
+  native String getSignature();
+
+  /**
+   * Compare two objects to see if they are semantically equivalent.
+   * Two Fields are semantically equivalent if they have the same declaring
+   * class, name, and type. Since you can't create a Field except through
+   * the VM, this is just the == relation.
+   *
+   * @param o the object to compare to
+   * @return <code>true</code> if they are equal; <code>false</code> if not
+   */
+  public boolean equals(Object o)
+  {
+    if (!(o instanceof Field))
+      return false;
+    Field that = (Field)o; 
+    if (clazz != that.getDeclaringClass())
+      return false;
+    if (!name.equals(that.getName()))
+      return false;
+    if (getType() != that.getType())
+      return false;
+    return true;
+  }
+
+  /**
+   * Returns the element's annotation for the specified annotation type,
+   * or <code>null</code> if no such annotation exists.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return this element's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @throws NullPointerException if the annotation class is <code>null</code>.
+   */
+//   native Annotation getAnnotation(Class annotationClass);
+  Annotation getAnnotation(Class annotationClass){
+    if (annotationClass == null)
+      throw new NullPointerException();
+
+    return declaredAnnotations().get(annotationClass);
+  }
+
+  /**
+   * Returns all annotations directly defined by the element.  If there are
+   * no annotations directly associated with the element, then a zero-length
+   * array will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of this
+   * class, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by the element.
+   * @since 1.5
+   */
+//   native Annotation[] getDeclaredAnnotations();
+  Annotation[] getDeclaredAnnotations() {
+    return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
+  }
+
+  /**
+   * Parses the annotations if they aren't parsed yet and stores them into
+   * the declaredAnnotations map and return this map.
+   */
+  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/VMMethod.java b/src/classes/gnuclasspath/java/lang/reflect/VMMethod.java
new file mode 100644 (file)
index 0000000..ad556f2
--- /dev/null
@@ -0,0 +1,252 @@
+/* java.lang.reflect.VMMethod - VM interface for reflection of Java methods
+   Copyright (C) 1998, 2001, 2002, 2005, 2007, 2008 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 java.lang.annotation.Annotation;
+
+import java.util.Arrays;
+import java.util.Map;
+
+final class VMMethod
+{
+  Class clazz;
+  String name;
+  int slot;
+
+  /**
+   * Unparsed annotations.
+   */
+  private byte[] annotations          = null;
+
+  /**
+   * Unparsed parameter annotations.
+   */
+  private byte[] parameterAnnotations = null;
+  
+  /**
+   * Unparsed annotation default value.
+   */
+  private byte[] annotationDefault    = null;
+
+  /**
+   * Annotations get parsed the first time they are
+   * accessed and are then cached it this map.
+   */
+  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
+
+  /**
+   * Helper array for creating a new array from a java.util.Container.
+   */
+  private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
+    new Annotation[0];
+
+  /** 
+   * This field allows us to refer back to the main constructor instance.
+   *  It is set by the constructor of Field.
+   */
+  Method m;
+
+  public Class getDeclaringClass()
+  {
+    return clazz;
+  }
+
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Return the raw modifiers for this method.
+   * @return the method's modifiers
+   */
+  native int getModifiersInternal();
+
+  /**
+   * Gets the return type of this method.
+   * @return the type of this method
+   */
+  native Class getReturnType();
+
+  /**
+   * Get the parameter list for this method, in declaration order. If the
+   * method takes no parameters, returns a 0-length array (not null).
+   *
+   * @return a list of the types of the method's parameters
+   */
+  native Class[] getParameterTypes();
+
+  /**
+   * Get the exception types this method says it throws, in no particular
+   * order. If the method has no throws clause, returns a 0-length array
+   * (not null).
+   *
+   * @return a list of the types in the method's throws clause
+   */
+  native Class[] getExceptionTypes();
+
+  native Object invoke(Object o, Object[] args)
+    throws IllegalAccessException, InvocationTargetException;
+
+  /**
+   * Return the String in the Signature attribute for this method. If there
+   * is no Signature attribute, return null.
+   */
+  native String getSignature();
+
+  /**
+   * If this method is an annotation method, returns the default
+   * value for the method.  If there is no default value, or if the
+   * method is not a member of an annotation type, returns null.
+   * Primitive types are wrapped.
+   *
+   * @throws TypeNotPresentException if the method returns a Class,
+   * and the class cannot be found
+   *
+   * @since 1.5
+   */
+  native Object getDefaultValue();
+
+  /**
+   * <p>
+   * Return an array of arrays representing the annotations on each
+   * of the method's parameters.  The outer array is aligned against
+   * the parameters of the method and is thus equal in length to
+   * the number of parameters (thus having a length zero if there are none).
+   * Each array element in the outer array contains an inner array which
+   * holds the annotations.  This array has a length of zero if the parameter
+   * has no annotations.
+   * </p>
+   * <p>
+   * The returned annotations are serialized.  Changing the annotations has
+   * no affect on the return value of future calls to this method.
+   * </p>
+   * 
+   * @return an array of arrays which represents the annotations used on the
+   *         parameters of this method.  The order of the array elements
+   *         matches the declaration order of the parameters.
+   * @since 1.5
+   */
+  native Annotation[][] getParameterAnnotations();
+
+  /**
+   * Compare two objects to see if they are semantically equivalent.
+   * Two Methods are semantically equivalent if they have the same declaring
+   * class, name, parameter list, and return type.
+   *
+   * @param o the object to compare to
+   * @return <code>true</code> if they are equal; <code>false</code> if not
+   */
+  public boolean equals(Object o)
+  {
+      // Implementation note:
+      // The following is a correct but possibly slow implementation.
+      //
+      // This class has a private field 'slot' that could be used by
+      // the VM implementation to "link" a particular method to a Class.
+      // In that case equals could be simply implemented as:
+      //
+      // if (o instanceof Method)
+      // {
+      //    Method m = (Method)o;
+      //    return m.declaringClass == this.declaringClass
+      //           && m.slot == this.slot;
+      // }
+      // return false;
+      //
+      // If a VM uses the Method class as their native/internal representation
+      // then just using the following would be optimal:
+      //
+      // return this == o;
+      //
+    if (!(o instanceof Method))
+      return false;
+    Method that = (Method)o;
+    if (clazz != that.getDeclaringClass())
+      return false;
+    if (!name.equals(that.getName()))
+      return false;
+    if (getReturnType() != that.getReturnType())
+      return false;
+    if (!Arrays.equals(getParameterTypes(), that.getParameterTypes()))
+      return false;
+    return true;
+  }
+
+  /**
+   * Returns the element's annotation for the specified annotation type,
+   * or <code>null</code> if no such annotation exists.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return this element's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @throws NullPointerException if the annotation class is <code>null</code>.
+   */
+//   native Annotation getAnnotation(Class annotationClass);
+  Annotation getAnnotation(Class annotationClass) {
+    if (annotationClass == null)
+      throw new NullPointerException();
+
+    return declaredAnnotations().get(annotationClass);
+  }
+
+  /**
+   * Returns all annotations directly defined by the element.  If there are
+   * no annotations directly associated with the element, then a zero-length
+   * array will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of this
+   * class, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by the element.
+   * @since 1.5
+   */
+//   native Annotation[] getDeclaredAnnotations();
+  Annotation[] getDeclaredAnnotations() {
+    return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
+  }
+
+  /**
+   * Parses the annotations if they aren't parsed yet and stores them into
+   * the declaredAnnotations map and return this map.
+   */
+  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
+
+}
+
diff --git a/src/classes/gnuclasspath/java/security/VMAccessController.java b/src/classes/gnuclasspath/java/security/VMAccessController.java
new file mode 100644 (file)
index 0000000..160df10
--- /dev/null
@@ -0,0 +1,281 @@
+/* VMAccessController.java -- VM-specific access controller methods.
+   Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+
+This program 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.
+
+This program 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 this program; 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.security;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+
+final class VMAccessController
+{
+
+  // Fields.
+  // -------------------------------------------------------------------------
+
+  /**
+   * This is a per-thread stack of AccessControlContext objects (which can
+   * be null) for each call to AccessController.doPrivileged in each thread's
+   * call stack. We use this to remember which context object corresponds to
+   * which call.
+   */
+  private static final ThreadLocal contexts = new ThreadLocal();
+
+  /**
+   * This is a Boolean that, if set, tells getContext that it has already
+   * been called once, allowing us to handle recursive permission checks
+   * caused by methods getContext calls.
+   */
+  private static final ThreadLocal inGetContext = new ThreadLocal();
+
+  /**
+   * And we return this all-permissive context to ensure that privileged
+   * methods called from getContext succeed.
+   */
+  private static final AccessControlContext DEFAULT_CONTEXT;
+  static
+  {
+    CodeSource source = new CodeSource(null, null);
+    Permissions permissions = new Permissions();
+    permissions.add(new AllPermission());
+    ProtectionDomain[] domain = new ProtectionDomain[] {
+      new ProtectionDomain(source, permissions)
+    };
+    DEFAULT_CONTEXT = new AccessControlContext(domain);
+  }
+
+  private static final boolean DEBUG = gnu.classpath.Configuration.DEBUG;
+  private static void debug(String msg)
+  {
+    System.err.print(">>> VMAccessController: ");
+    System.err.println(msg);
+  }
+
+  // Constructors.
+  // -------------------------------------------------------------------------
+
+  private VMAccessController() { }
+
+  // Class methods.
+  // -------------------------------------------------------------------------
+
+  /**
+   * Relate a class (which should be an instance of {@link PrivilegedAction}
+   * with an access control context. This method is used by {@link
+   * AccessController#doPrivileged(java.security.PrivilegedAction,java.security.AccessControlContext)}
+   * to set up the context that will be returned by {@link #getContext()}.
+   * This method relates the class to the current thread, so contexts
+   * pushed from one thread will not be available to another.
+   *
+   * @param acc The access control context.
+   */
+  static void pushContext (AccessControlContext acc)
+  {
+    if (DEBUG)
+      debug("pushing " + acc);
+    LinkedList stack = (LinkedList) contexts.get();
+    if (stack == null)
+      {
+         if (DEBUG)
+           debug("no stack... creating ");
+        stack = new LinkedList();
+        contexts.set(stack);
+      }
+    stack.addFirst(acc);
+  }
+
+  /**
+   * Removes the relation of a class to an {@link AccessControlContext}.
+   * This method is used by {@link AccessController} when exiting from a
+   * call to {@link
+   * AccessController#doPrivileged(java.security.PrivilegedAction,java.security.AccessControlContext)}.
+   */
+  static void popContext()
+  {
+    if (DEBUG)
+      debug("popping context");
+
+    // Stack should never be null, nor should it be empty, if this method
+    // and its counterpart has been called properly.
+    LinkedList stack = (LinkedList) contexts.get();
+    if (stack != null)
+      {
+        stack.removeFirst();
+        if (stack.isEmpty())
+          contexts.set(null);
+      }
+    else if (DEBUG)
+      {
+        debug("no stack during pop?????");
+      }
+  }
+
+  /**
+   * Examine the method stack of the currently running thread, and create
+   * an {@link AccessControlContext} filled in with the appropriate {@link
+   * ProtectionDomain} objects given this stack.
+   *
+   * @return The context.
+   */
+  static AccessControlContext getContext()
+  {
+    // If we are already in getContext, but called a method that needs
+    // a permission check, return the all-permissive context so methods
+    // called from here succeed.
+    //
+    // XXX is this necessary? We should verify if there are any calls in
+    // the stack below this method that require permission checks.
+    Boolean inCall = (Boolean) inGetContext.get();
+    if (inCall != null && inCall.booleanValue())
+      {
+        if (DEBUG)
+          debug("already in getContext");
+        return DEFAULT_CONTEXT;
+      }
+
+    inGetContext.set(Boolean.TRUE);
+
+    Object[][] stack = getStack();
+    Class[] classes = (Class[]) stack[0];
+    String[] methods = (String[]) stack[1];
+
+    if (DEBUG)
+      debug("got trace of length " + classes.length);
+
+    HashSet domains = new HashSet();
+    HashSet seenDomains = new HashSet();
+    AccessControlContext context = null;
+    int privileged = 0;
+
+    // We walk down the stack, adding each ProtectionDomain for each
+    // class in the call stack. If we reach a call to doPrivileged,
+    // we don't add any more stack frames. We skip the first three stack
+    // frames, since they comprise the calls to getStack, getContext,
+    // and AccessController.getContext.
+    for (int i = 3; i < classes.length && privileged < 2; i++)
+      {
+        Class clazz = classes[i];
+        String method = methods[i];
+
+        if (DEBUG)
+          {
+            debug("checking " + clazz + "." + method);
+            // subject to getClassLoader RuntimePermission
+            debug("loader = " + clazz.getClassLoader());
+          }
+
+        // If the previous frame was a call to doPrivileged, then this is
+        // the last frame we look at.
+        if (privileged == 1)
+          privileged = 2;
+
+        if (clazz.equals (AccessController.class)
+            && method.equals ("doPrivileged"))
+          {
+            // If there was a call to doPrivileged with a supplied context,
+            // return that context. If using JAAS doAs*, it should be 
+           // a context with a SubjectDomainCombiner
+            LinkedList l = (LinkedList) contexts.get();
+            if (l != null)
+              context = (AccessControlContext) l.getFirst();
+            privileged = 1;
+          }
+
+        // subject to getProtectionDomain RuntimePermission
+       ProtectionDomain domain = clazz.getProtectionDomain();
+
+        if (domain == null)
+          continue;
+        if (seenDomains.contains(domain))
+          continue;
+        seenDomains.add(domain);
+
+        // Create a static snapshot of this domain, which may change over time
+        // if the current policy changes.
+        domains.add(new ProtectionDomain(domain.getCodeSource(),
+                                         domain.getPermissions()));
+      }
+
+    if (DEBUG)
+      debug("created domains: " + domains);
+
+    ProtectionDomain[] result = (ProtectionDomain[])
+      domains.toArray(new ProtectionDomain[domains.size()]);
+
+    if (context != null)
+      {
+        DomainCombiner dc = context.getDomainCombiner ();
+        // If the supplied context had no explicit DomainCombiner, use
+        // our private version, which computes the intersection of the
+        // context's domains with the derived set.
+        if (dc == null)
+          context = new AccessControlContext
+            (IntersectingDomainCombiner.SINGLETON.combine
+             (result, context.getProtectionDomains ()));
+        // Use the supplied DomainCombiner. This should be secure,
+        // because only trusted code may create an
+        // AccessControlContext with a custom DomainCombiner.
+        else
+          context = new AccessControlContext (result, context, dc);
+      }
+    // No context was supplied. Return the derived one.
+    else
+      context = new AccessControlContext (result);
+
+    inGetContext.set(Boolean.FALSE);
+    return context;
+  }
+
+  /**
+   * Returns a snapshot of the current call stack as a pair of arrays:
+   * the first an array of classes in the call stack, the second an array
+   * of strings containing the method names in the call stack. The two
+   * arrays match up, meaning that method <i>i</i> is declared in class
+   * <i>i</i>. The arrays are clean; it will only contain Java methods,
+   * and no element of the list should be null.
+   *
+   * <p>The default implementation returns an empty stack, which will be
+   * interpreted as having no permissions whatsoever.
+   *
+   * @return A pair of arrays describing the current call stack. The first
+   *    element is an array of Class objects, and the second is an array
+   *    of Strings comprising the method names.
+   */
+//    private static Object[][] getStack()
+//    {
+//      return new Object[][] { new Class[0], new String[0] };
+//    }
+  private native static Object[][] getStack();
+}
diff --git a/src/classes/gnuclasspath/sun/misc/Unsafe.java b/src/classes/gnuclasspath/sun/misc/Unsafe.java
new file mode 100644 (file)
index 0000000..2577488
--- /dev/null
@@ -0,0 +1,861 @@
+/*
+ * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.misc;
+
+import java.security.*;
+import java.lang.reflect.*;
+
+
+/**
+ * A collection of methods for performing low-level, unsafe operations.
+ * Although the class and all methods are public, use of this class is
+ * limited because only trusted code can obtain instances of it.
+ *
+ * @author John R. Rose
+ * @see #getUnsafe
+ */
+
+public final class Unsafe {
+
+    private static native void registerNatives();
+    static {
+        registerNatives();
+//        sun.reflect.Reflection.registerMethodsToFilter(Unsafe.class, "getUnsafe");
+    }
+
+    private Unsafe() {}
+
+    private static final Unsafe theUnsafe = new Unsafe();
+
+    /**
+     * Provides the caller with the capability of performing unsafe
+     * operations.
+     *
+     * <p> The returned <code>Unsafe</code> object should be carefully guarded
+     * by the caller, since it can be used to read and write data at arbitrary
+     * memory addresses.  It must never be passed to untrusted code.
+     *
+     * <p> Most methods in this class are very low-level, and correspond to a
+     * small number of hardware instructions (on typical machines).  Compilers
+     * are encouraged to optimize these methods accordingly.
+     *
+     * <p> Here is a suggested idiom for using unsafe operations:
+     *
+     * <blockquote><pre>
+     * class MyTrustedClass {
+     *   private static final Unsafe unsafe = Unsafe.getUnsafe();
+     *   ...
+     *   private long myCountAddress = ...;
+     *   public int getCount() { return unsafe.getByte(myCountAddress); }
+     * }
+     * </pre></blockquote>
+     *
+     * (It may assist compilers to make the local variable be
+     * <code>final</code>.)
+     *
+     * @exception  SecurityException  if a security manager exists and its
+     *             <code>checkPropertiesAccess</code> method doesn't allow
+     *             access to the system properties.
+     */
+    public static Unsafe getUnsafe() {
+        Class cc = sun.reflect.Reflection.getCallerClass(2);
+        if (cc.getClassLoader() != null)
+            throw new SecurityException("Unsafe");
+        return theUnsafe;
+    }
+
+    /// peek and poke operations
+    /// (compilers should optimize these to memory ops)
+
+    // These work on object fields in the Java heap.
+    // They will not work on elements of packed arrays.
+
+    /**
+     * Fetches a value from a given Java variable.
+     * More specifically, fetches a field or array element within the given
+     * object <code>o</code> at the given offset, or (if <code>o</code> is
+     * null) from the memory address whose numerical value is the given
+     * offset.
+     * <p>
+     * The results are undefined unless one of the following cases is true:
+     * <ul>
+     * <li>The offset was obtained from {@link #objectFieldOffset} on
+     * the {@link java.lang.reflect.Field} of some Java field and the object
+     * referred to by <code>o</code> is of a class compatible with that
+     * field's class.
+     *
+     * <li>The offset and object reference <code>o</code> (either null or
+     * non-null) were both obtained via {@link #staticFieldOffset}
+     * and {@link #staticFieldBase} (respectively) from the
+     * reflective {@link Field} representation of some Java field.
+     *
+     * <li>The object referred to by <code>o</code> is an array, and the offset
+     * is an integer of the form <code>B+N*S</code>, where <code>N</code> is
+     * a valid index into the array, and <code>B</code> and <code>S</code> are
+     * the values obtained by {@link #arrayBaseOffset} and {@link
+     * #arrayIndexScale} (respectively) from the array's class.  The value
+     * referred to is the <code>N</code><em>th</em> element of the array.
+     *
+     * </ul>
+     * <p>
+     * If one of the above cases is true, the call references a specific Java
+     * variable (field or array element).  However, the results are undefined
+     * if that variable is not in fact of the type returned by this method.
+     * <p>
+     * This method refers to a variable by means of two parameters, and so
+     * it provides (in effect) a <em>double-register</em> addressing mode
+     * for Java variables.  When the object reference is null, this method
+     * uses its offset as an absolute address.  This is similar in operation
+     * to methods such as {@link #getInt(long)}, which provide (in effect) a
+     * <em>single-register</em> addressing mode for non-Java variables.
+     * However, because Java variables may have a different layout in memory
+     * from non-Java variables, programmers should not assume that these
+     * two addressing modes are ever equivalent.  Also, programmers should
+     * remember that offsets from the double-register addressing mode cannot
+     * be portably confused with longs used in the single-register addressing
+     * mode.
+     *
+     * @param o Java heap object in which the variable resides, if any, else
+     *        null
+     * @param offset indication of where the variable resides in a Java heap
+     *        object, if any, else a memory address locating the variable
+     *        statically
+     * @return the value fetched from the indicated Java variable
+     * @throws RuntimeException No defined exceptions are thrown, not even
+     *         {@link NullPointerException}
+     */
+    public native int getInt(Object o, long offset);
+
+    /**
+     * Stores a value into a given Java variable.
+     * <p>
+     * The first two parameters are interpreted exactly as with
+     * {@link #getInt(Object, long)} to refer to a specific
+     * Java variable (field or array element).  The given value
+     * is stored into that variable.
+     * <p>
+     * The variable must be of the same type as the method
+     * parameter <code>x</code>.
+     *
+     * @param o Java heap object in which the variable resides, if any, else
+     *        null
+     * @param offset indication of where the variable resides in a Java heap
+     *        object, if any, else a memory address locating the variable
+     *        statically
+     * @param x the value to store into the indicated Java variable
+     * @throws RuntimeException No defined exceptions are thrown, not even
+     *         {@link NullPointerException}
+     */
+    public native void putInt(Object o, long offset, int x);
+
+    /**
+     * Fetches a reference value from a given Java variable.
+     * @see #getInt(Object, long)
+     */
+    public native Object getObject(Object o, long offset);
+
+    /**
+     * Stores a reference value into a given Java variable.
+     * <p>
+     * Unless the reference <code>x</code> being stored is either null
+     * or matches the field type, the results are undefined.
+     * If the reference <code>o</code> is non-null, car marks or
+     * other store barriers for that object (if the VM requires them)
+     * are updated.
+     * @see #putInt(Object, int, int)
+     */
+    public native void putObject(Object o, long offset, Object x);
+
+    /** @see #getInt(Object, long) */
+    public native boolean getBoolean(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putBoolean(Object o, long offset, boolean x);
+    /** @see #getInt(Object, long) */
+    public native byte    getByte(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putByte(Object o, long offset, byte x);
+    /** @see #getInt(Object, long) */
+    public native short   getShort(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putShort(Object o, long offset, short x);
+    /** @see #getInt(Object, long) */
+    public native char    getChar(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putChar(Object o, long offset, char x);
+    /** @see #getInt(Object, long) */
+    public native long    getLong(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putLong(Object o, long offset, long x);
+    /** @see #getInt(Object, long) */
+    public native float   getFloat(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putFloat(Object o, long offset, float x);
+    /** @see #getInt(Object, long) */
+    public native double  getDouble(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putDouble(Object o, long offset, double x);
+
+    /**
+     * This method, like all others with 32-bit offsets, was native
+     * in a previous release but is now a wrapper which simply casts
+     * the offset to a long value.  It provides backward compatibility
+     * with bytecodes compiled against 1.4.
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public int getInt(Object o, int offset) {
+        return getInt(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putInt(Object o, int offset, int x) {
+        putInt(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public Object getObject(Object o, int offset) {
+        return getObject(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putObject(Object o, int offset, Object x) {
+        putObject(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public boolean getBoolean(Object o, int offset) {
+        return getBoolean(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putBoolean(Object o, int offset, boolean x) {
+        putBoolean(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public byte getByte(Object o, int offset) {
+        return getByte(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putByte(Object o, int offset, byte x) {
+        putByte(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public short getShort(Object o, int offset) {
+        return getShort(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putShort(Object o, int offset, short x) {
+        putShort(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public char getChar(Object o, int offset) {
+        return getChar(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putChar(Object o, int offset, char x) {
+        putChar(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public long getLong(Object o, int offset) {
+        return getLong(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putLong(Object o, int offset, long x) {
+        putLong(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public float getFloat(Object o, int offset) {
+        return getFloat(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putFloat(Object o, int offset, float x) {
+        putFloat(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public double getDouble(Object o, int offset) {
+        return getDouble(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putDouble(Object o, int offset, double x) {
+        putDouble(o, (long)offset, x);
+    }
+
+    // These work on values in the C heap.
+
+    /**
+     * Fetches a value from a given memory address.  If the address is zero, or
+     * does not point into a block obtained from {@link #allocateMemory}, the
+     * results are undefined.
+     *
+     * @see #allocateMemory
+     */
+    public native byte    getByte(long address);
+
+    /**
+     * Stores a value into a given memory address.  If the address is zero, or
+     * does not point into a block obtained from {@link #allocateMemory}, the
+     * results are undefined.
+     *
+     * @see #getByte(long)
+     */
+    public native void    putByte(long address, byte x);
+
+    /** @see #getByte(long) */
+    public native short   getShort(long address);
+    /** @see #putByte(long, byte) */
+    public native void    putShort(long address, short x);
+    /** @see #getByte(long) */
+    public native char    getChar(long address);
+    /** @see #putByte(long, byte) */
+    public native void    putChar(long address, char x);
+    /** @see #getByte(long) */
+    public native int     getInt(long address);
+    /** @see #putByte(long, byte) */
+    public native void    putInt(long address, int x);
+    /** @see #getByte(long) */
+    public native long    getLong(long address);
+    /** @see #putByte(long, byte) */
+    public native void    putLong(long address, long x);
+    /** @see #getByte(long) */
+    public native float   getFloat(long address);
+    /** @see #putByte(long, byte) */
+    public native void    putFloat(long address, float x);
+    /** @see #getByte(long) */
+    public native double  getDouble(long address);
+    /** @see #putByte(long, byte) */
+    public native void    putDouble(long address, double x);
+
+    /**
+     * Fetches a native pointer from a given memory address.  If the address is
+     * zero, or does not point into a block obtained from {@link
+     * #allocateMemory}, the results are undefined.
+     *
+     * <p> If the native pointer is less than 64 bits wide, it is extended as
+     * an unsigned number to a Java long.  The pointer may be indexed by any
+     * given byte offset, simply by adding that offset (as a simple integer) to
+     * the long representing the pointer.  The number of bytes actually read
+     * from the target address maybe determined by consulting {@link
+     * #addressSize}.
+     *
+     * @see #allocateMemory
+     */
+    public native long getAddress(long address);
+
+    /**
+     * Stores a native pointer into a given memory address.  If the address is
+     * zero, or does not point into a block obtained from {@link
+     * #allocateMemory}, the results are undefined.
+     *
+     * <p> The number of bytes actually written at the target address maybe
+     * determined by consulting {@link #addressSize}.
+     *
+     * @see #getAddress(long)
+     */
+    public native void putAddress(long address, long x);
+
+    /// wrappers for malloc, realloc, free:
+
+    /**
+     * Allocates a new block of native memory, of the given size in bytes.  The
+     * contents of the memory are uninitialized; they will generally be
+     * garbage.  The resulting native pointer will never be zero, and will be
+     * aligned for all value types.  Dispose of this memory by calling {@link
+     * #freeMemory}, or resize it with {@link #reallocateMemory}.
+     *
+     * @throws IllegalArgumentException if the size is negative or too large
+     *         for the native size_t type
+     *
+     * @throws OutOfMemoryError if the allocation is refused by the system
+     *
+     * @see #getByte(long)
+     * @see #putByte(long, byte)
+     */
+    public native long allocateMemory(long bytes);
+
+    /**
+     * Resizes a new block of native memory, to the given size in bytes.  The
+     * contents of the new block past the size of the old block are
+     * uninitialized; they will generally be garbage.  The resulting native
+     * pointer will be zero if and only if the requested size is zero.  The
+     * resulting native pointer will be aligned for all value types.  Dispose
+     * of this memory by calling {@link #freeMemory}, or resize it with {@link
+     * #reallocateMemory}.  The address passed to this method may be null, in
+     * which case an allocation will be performed.
+     *
+     * @throws IllegalArgumentException if the size is negative or too large
+     *         for the native size_t type
+     *
+     * @throws OutOfMemoryError if the allocation is refused by the system
+     *
+     * @see #allocateMemory
+     */
+    public native long reallocateMemory(long address, long bytes);
+
+    /**
+     * Sets all bytes in a given block of memory to a fixed value
+     * (usually zero).
+     */
+    public native void setMemory(long address, long bytes, byte value);
+
+    /**
+     * Sets all bytes in a given block of memory to a copy of another
+     * block.
+     */
+    public native void copyMemory(long srcAddress, long destAddress,
+                                  long bytes);
+
+    /**
+     * Disposes of a block of native memory, as obtained from {@link
+     * #allocateMemory} or {@link #reallocateMemory}.  The address passed to
+     * this method may be null, in which case no action is taken.
+     *
+     * @see #allocateMemory
+     */
+    public native void freeMemory(long address);
+
+    /// random queries
+
+    /**
+     * This constant differs from all results that will ever be returned from
+     * {@link #staticFieldOffset}, {@link #objectFieldOffset},
+     * or {@link #arrayBaseOffset}.
+     */
+    public static final int INVALID_FIELD_OFFSET   = -1;
+
+    /**
+     * Returns the offset of a field, truncated to 32 bits.
+     * This method is implemented as follows:
+     * <blockquote><pre>
+     * public int fieldOffset(Field f) {
+     *     if (Modifier.isStatic(f.getModifiers()))
+     *         return (int) staticFieldOffset(f);
+     *     else
+     *         return (int) objectFieldOffset(f);
+     * }
+     * </pre></blockquote>
+     * @deprecated As of 1.4.1, use {@link #staticFieldOffset} for static
+     * fields and {@link #objectFieldOffset} for non-static fields.
+     */
+    @Deprecated
+    public int fieldOffset(Field f) {
+        if (Modifier.isStatic(f.getModifiers()))
+            return (int) staticFieldOffset(f);
+        else
+            return (int) objectFieldOffset(f);
+    }
+
+    /**
+     * Returns the base address for accessing some static field
+     * in the given class.  This method is implemented as follows:
+     * <blockquote><pre>
+     * public Object staticFieldBase(Class c) {
+     *     Field[] fields = c.getDeclaredFields();
+     *     for (int i = 0; i < fields.length; i++) {
+     *         if (Modifier.isStatic(fields[i].getModifiers())) {
+     *             return staticFieldBase(fields[i]);
+     *         }
+     *     }
+     *     return null;
+     * }
+     * </pre></blockquote>
+     * @deprecated As of 1.4.1, use {@link #staticFieldBase(Field)}
+     * to obtain the base pertaining to a specific {@link Field}.
+     * This method works only for JVMs which store all statics
+     * for a given class in one place.
+     */
+    @Deprecated
+    public Object staticFieldBase(Class c) {
+        Field[] fields = c.getDeclaredFields();
+        for (int i = 0; i < fields.length; i++) {
+            if (Modifier.isStatic(fields[i].getModifiers())) {
+                return staticFieldBase(fields[i]);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Report the location of a given field in the storage allocation of its
+     * class.  Do not expect to perform any sort of arithmetic on this offset;
+     * it is just a cookie which is passed to the unsafe heap memory accessors.
+     *
+     * <p>Any given field will always have the same offset and base, and no
+     * two distinct fields of the same class will ever have the same offset
+     * and base.
+     *
+     * <p>As of 1.4.1, offsets for fields are represented as long values,
+     * although the Sun JVM does not use the most significant 32 bits.
+     * However, JVM implementations which store static fields at absolute
+     * addresses can use long offsets and null base pointers to express
+     * the field locations in a form usable by {@link #getInt(Object,long)}.
+     * Therefore, code which will be ported to such JVMs on 64-bit platforms
+     * must preserve all bits of static field offsets.
+     * @see #getInt(Object, long)
+     */
+    public native long staticFieldOffset(Field f);
+
+    /**
+     * Report the location of a given static field, in conjunction with {@link
+     * #staticFieldBase}.
+     * <p>Do not expect to perform any sort of arithmetic on this offset;
+     * it is just a cookie which is passed to the unsafe heap memory accessors.
+     *
+     * <p>Any given field will always have the same offset, and no two distinct
+     * fields of the same class will ever have the same offset.
+     *
+     * <p>As of 1.4.1, offsets for fields are represented as long values,
+     * although the Sun JVM does not use the most significant 32 bits.
+     * It is hard to imagine a JVM technology which needs more than
+     * a few bits to encode an offset within a non-array object,
+     * However, for consistency with other methods in this class,
+     * this method reports its result as a long value.
+     * @see #getInt(Object, long)
+     */
+    public native long objectFieldOffset(Field f);
+
+    /**
+     * Report the location of a given static field, in conjunction with {@link
+     * #staticFieldOffset}.
+     * <p>Fetch the base "Object", if any, with which static fields of the
+     * given class can be accessed via methods like {@link #getInt(Object,
+     * long)}.  This value may be null.  This value may refer to an object
+     * which is a "cookie", not guaranteed to be a real Object, and it should
+     * not be used in any way except as argument to the get and put routines in
+     * this class.
+     */
+    public native Object staticFieldBase(Field f);
+
+    /**
+     * Ensure the given class has been initialized. This is often
+     * needed in conjunction with obtaining the static field base of a
+     * class.
+     */
+    public native void ensureClassInitialized(Class c);
+
+    /**
+     * Report the offset of the first element in the storage allocation of a
+     * given array class.  If {@link #arrayIndexScale} returns a non-zero value
+     * for the same class, you may use that scale factor, together with this
+     * base offset, to form new offsets to access elements of arrays of the
+     * given class.
+     *
+     * @see #getInt(Object, long)
+     * @see #putInt(Object, long, int)
+     */
+    public native int arrayBaseOffset(Class arrayClass);
+
+    /**
+     * Report the scale factor for addressing elements in the storage
+     * allocation of a given array class.  However, arrays of "narrow" types
+     * will generally not work properly with accessors like {@link
+     * #getByte(Object, int)}, so the scale factor for such classes is reported
+     * as zero.
+     *
+     * @see #arrayBaseOffset
+     * @see #getInt(Object, long)
+     * @see #putInt(Object, long, int)
+     */
+    public native int arrayIndexScale(Class arrayClass);
+
+    /**
+     * Report the size in bytes of a native pointer, as stored via {@link
+     * #putAddress}.  This value will be either 4 or 8.  Note that the sizes of
+     * other primitive types (as stored in native memory blocks) is determined
+     * fully by their information content.
+     */
+    public native int addressSize();
+
+    /**
+     * Report the size in bytes of a native memory page (whatever that is).
+     * This value will always be a power of two.
+     */
+    public native int pageSize();
+
+
+    /// random trusted operations from JNI:
+
+    /**
+     * Tell the VM to define a class, without security checks.  By default, the
+     * class loader and protection domain come from the caller's class.
+     */
+    public native Class defineClass(String name, byte[] b, int off, int len,
+                                    ClassLoader loader,
+                                    ProtectionDomain protectionDomain);
+
+    public native Class defineClass(String name, byte[] b, int off, int len);
+
+    /** Allocate an instance but do not run any constructor.
+        Initializes the class if it has not yet been. */
+    public native Object allocateInstance(Class cls)
+        throws InstantiationException;
+
+    /** Lock the object.  It must get unlocked via {@link #monitorExit}. */
+    public native void monitorEnter(Object o);
+
+    /**
+     * Unlock the object.  It must have been locked via {@link
+     * #monitorEnter}.
+     */
+    public native void monitorExit(Object o);
+
+    /**
+     * Tries to lock the object.  Returns true or false to indicate
+     * whether the lock succeeded.  If it did, the object must be
+     * unlocked via {@link #monitorExit}.
+     */
+    public native boolean tryMonitorEnter(Object o);
+
+    /** Throw the exception without telling the verifier. */
+    public native void throwException(Throwable ee);
+
+
+    /**
+     * Atomically update Java variable to <tt>x</tt> if it is currently
+     * holding <tt>expected</tt>.
+     * @return <tt>true</tt> if successful
+     */
+    public final native boolean compareAndSwapObject(Object o, long offset,
+                                                     Object expected,
+                                                     Object x);
+
+    /**
+     * Atomically update Java variable to <tt>x</tt> if it is currently
+     * holding <tt>expected</tt>.
+     * @return <tt>true</tt> if successful
+     */
+    public final native boolean compareAndSwapInt(Object o, long offset,
+                                                  int expected,
+                                                  int x);
+
+    /**
+     * Atomically update Java variable to <tt>x</tt> if it is currently
+     * holding <tt>expected</tt>.
+     * @return <tt>true</tt> if successful
+     */
+    public final native boolean compareAndSwapLong(Object o, long offset,
+                                                   long expected,
+                                                   long x);
+
+    /**
+     * Fetches a reference value from a given Java variable, with volatile
+     * load semantics. Otherwise identical to {@link #getObject(Object, long)}
+     */
+    public native Object getObjectVolatile(Object o, long offset);
+
+    /**
+     * Stores a reference value into a given Java variable, with
+     * volatile store semantics. Otherwise identical to {@link #putObject(Object, long, Object)}
+     */
+    public native void    putObjectVolatile(Object o, long offset, Object x);
+
+    /** Volatile version of {@link #getInt(Object, long)}  */
+    public native int     getIntVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putInt(Object, long, int)}  */
+    public native void    putIntVolatile(Object o, long offset, int x);
+
+    /** Volatile version of {@link #getBoolean(Object, long)}  */
+    public native boolean getBooleanVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putBoolean(Object, long, boolean)}  */
+    public native void    putBooleanVolatile(Object o, long offset, boolean x);
+
+    /** Volatile version of {@link #getByte(Object, long)}  */
+    public native byte    getByteVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putByte(Object, long, byte)}  */
+    public native void    putByteVolatile(Object o, long offset, byte x);
+
+    /** Volatile version of {@link #getShort(Object, long)}  */
+    public native short   getShortVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putShort(Object, long, short)}  */
+    public native void    putShortVolatile(Object o, long offset, short x);
+
+    /** Volatile version of {@link #getChar(Object, long)}  */
+    public native char    getCharVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putChar(Object, long, char)}  */
+    public native void    putCharVolatile(Object o, long offset, char x);
+
+    /** Volatile version of {@link #getLong(Object, long)}  */
+    public native long    getLongVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putLong(Object, long, long)}  */
+    public native void    putLongVolatile(Object o, long offset, long x);
+
+    /** Volatile version of {@link #getFloat(Object, long)}  */
+    public native float   getFloatVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putFloat(Object, long, float)}  */
+    public native void    putFloatVolatile(Object o, long offset, float x);
+
+    /** Volatile version of {@link #getDouble(Object, long)}  */
+    public native double  getDoubleVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putDouble(Object, long, double)}  */
+    public native void    putDoubleVolatile(Object o, long offset, double x);
+
+    /**
+     * Version of {@link #putObjectVolatile(Object, long, Object)}
+     * that does not guarantee immediate visibility of the store to
+     * other threads. This method is generally only useful if the
+     * underlying field is a Java volatile (or if an array cell, one
+     * that is otherwise only accessed using volatile accesses).
+     */
+    public native void    putOrderedObject(Object o, long offset, Object x);
+
+    /** Ordered/Lazy version of {@link #putIntVolatile(Object, long, int)}  */
+    public native void    putOrderedInt(Object o, long offset, int x);
+
+    /** Ordered/Lazy version of {@link #putLongVolatile(Object, long, long)} */
+    public native void    putOrderedLong(Object o, long offset, long x);
+
+    /**
+     * Unblock the given thread blocked on <tt>park</tt>, or, if it is
+     * not blocked, cause the subsequent call to <tt>park</tt> not to
+     * block.  Note: this operation is "unsafe" solely because the
+     * caller must somehow ensure that the thread has not been
+     * destroyed. Nothing special is usually required to ensure this
+     * when called from Java (in which there will ordinarily be a live
+     * reference to the thread) but this is not nearly-automatically
+     * so when calling from native code.
+     * @param thread the thread to unpark.
+     *
+     */
+    public native void unpark(Object thread);
+
+    /**
+     * Block current thread, returning when a balancing
+     * <tt>unpark</tt> occurs, or a balancing <tt>unpark</tt> has
+     * already occurred, or the thread is interrupted, or, if not
+     * absolute and time is not zero, the given time nanoseconds have
+     * elapsed, or if absolute, the given deadline in milliseconds
+     * since Epoch has passed, or spuriously (i.e., returning for no
+     * "reason"). Note: This operation is in the Unsafe class only
+     * because <tt>unpark</tt> is, so it would be strange to place it
+     * elsewhere.
+     */
+    public native void park(boolean isAbsolute, long time);
+
+    /**
+     * Gets the load average in the system run queue assigned
+     * to the available processors averaged over various periods of time.
+     * This method retrieves the given <tt>nelem</tt> samples and
+     * assigns to the elements of the given <tt>loadavg</tt> array.
+     * The system imposes a maximum of 3 samples, representing
+     * averages over the last 1,  5,  and  15 minutes, respectively.
+     *
+     * @params loadavg an array of double of size nelems
+     * @params nelems the number of samples to be retrieved and
+     *         must be 1 to 3.
+     *
+     * @return the number of samples actually retrieved; or -1
+     *         if the load average is unobtainable.
+     */
+    public native int getLoadAverage(double[] loadavg, int nelems);
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/ConstantPool.java b/src/classes/gnuclasspath/sun/reflect/ConstantPool.java
new file mode 100644 (file)
index 0000000..b24d28e
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect;
+
+import java.lang.reflect.*;
+
+/** Provides reflective access to the constant pools of classes.
+    Currently this is needed to provide reflective access to annotations
+    but may be used by other internal subsystems in the future. */
+
+public class ConstantPool {
+  // Number of entries in this constant pool (= maximum valid constant pool index)
+  public int      getSize()                      { return getSize0            (constantPoolOop);        }
+  public Class    getClassAt         (int index) { return getClassAt0         (constantPoolOop, index); }
+  public Class    getClassAtIfLoaded (int index) { return getClassAtIfLoaded0 (constantPoolOop, index); }
+  // Returns either a Method or Constructor.
+  // Static initializers are returned as Method objects.
+  public Member   getMethodAt        (int index) { return getMethodAt0        (constantPoolOop, index); }
+  public Member   getMethodAtIfLoaded(int index) { return getMethodAtIfLoaded0(constantPoolOop, index); }
+  public Field    getFieldAt         (int index) { return getFieldAt0         (constantPoolOop, index); }
+  public Field    getFieldAtIfLoaded (int index) { return getFieldAtIfLoaded0 (constantPoolOop, index); }
+  // Fetches the class name, member (field, method or interface
+  // method) name, and type descriptor as an array of three Strings
+  public String[] getMemberRefInfoAt (int index) { return getMemberRefInfoAt0 (constantPoolOop, index); }
+  public int      getIntAt           (int index) { return getIntAt0           (constantPoolOop, index); }
+  public long     getLongAt          (int index) { return getLongAt0          (constantPoolOop, index); }
+  public float    getFloatAt         (int index) { return getFloatAt0         (constantPoolOop, index); }
+  public double   getDoubleAt        (int index) { return getDoubleAt0        (constantPoolOop, index); }
+  public String   getStringAt        (int index) { return getStringAt0        (constantPoolOop, index); }
+  public String   getUTF8At          (int index) { return getUTF8At0          (constantPoolOop, index); }
+
+  //---------------------------------------------------------------------------
+  // Internals only below this point
+  //
+/* This hides this member from being visible through the reflection API in OpenJDK
+ * TODO: find out how to do this with GNU Classpath (if it's realy neccesary).
+
+  static {
+      Reflection.registerFieldsToFilter(ConstantPool.class, new String[] { "constantPoolOop" });
+  }
+*/
+  // HotSpot-internal constant pool object (set by the VM, name known to the VM)
+  private Object constantPoolOop;
+
+  private native int      getSize0            (Object constantPoolOop);
+  private native Class    getClassAt0         (Object constantPoolOop, int index);
+  private native Class    getClassAtIfLoaded0 (Object constantPoolOop, int index);
+  private native Member   getMethodAt0        (Object constantPoolOop, int index);
+  private native Member   getMethodAtIfLoaded0(Object constantPoolOop, int index);
+  private native Field    getFieldAt0         (Object constantPoolOop, int index);
+  private native Field    getFieldAtIfLoaded0 (Object constantPoolOop, int index);
+  private native String[] getMemberRefInfoAt0 (Object constantPoolOop, int index);
+  private native int      getIntAt0           (Object constantPoolOop, int index);
+  private native long     getLongAt0          (Object constantPoolOop, int index);
+  private native float    getFloatAt0         (Object constantPoolOop, int index);
+  private native double   getDoubleAt0        (Object constantPoolOop, int index);
+  private native String   getStringAt0        (Object constantPoolOop, int index);
+  private native String   getUTF8At0          (Object constantPoolOop, int index);
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java b/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java
new file mode 100644 (file)
index 0000000..8c5aca3
--- /dev/null
@@ -0,0 +1,873 @@
+/*
+ * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect.annotation;
+
+import java.lang.annotation.*;
+import java.util.*;
+import java.nio.ByteBuffer;
+import java.nio.BufferUnderflowException;
+import java.lang.reflect.*;
+import sun.reflect.ConstantPool;
+
+import gnu.java.lang.reflect.FieldSignatureParser;
+
+
+/**
+ * Parser for Java programming language annotations.  Translates
+ * annotation byte streams emitted by compiler into annotation objects.
+ *
+ * @author  Josh Bloch
+ * @since   1.5
+ */
+public class AnnotationParser {
+    /**
+     * Parses the annotations described by the passed byte array,
+     * but returns Annotation[] so I don't have to do this in C.
+     *
+     * @author Mathias Panzenböck
+     * 
+     * @param rawAnnotations are the unparsed annotations
+     * @param constPool is the constant pool of the declaring class
+     * @param container is the containing class
+     * @return the parsed annotations in an array
+     * @throws AnnotationFormatError if an annotation is found to be
+     *         malformed.
+     */
+    public static Annotation[] parseAnnotationsIntoArray(
+                byte[] rawAnnotations,
+                ConstantPool constPool,
+                Class container) {
+        Map<Class, Annotation> annotations = parseAnnotations(rawAnnotations, constPool, container);
+        return annotations.values().toArray(EMPTY_ANNOTATIONS_ARRAY);
+    }
+
+    /**
+     * Parses parameter annotations.
+     * 
+     * @author Mathias Panzenböck
+     * 
+     * @param parameterAnnotations are the unparsed parameter annotations
+     * @param constPool is the constant pool of the declaring class
+     * @param container is the containing class
+     * @return the parsed parameter annotations in an array 2 dimensional array
+     * @throws AnnotationFormatError if an annotation is found to be
+     *         malformed.
+     */
+    public static Annotation[][] parseParameterAnnotations(
+                    byte[] parameterAnnotations,
+                    ConstantPool constPool,
+                    Class container,
+                    int numParameters) {
+        if (parameterAnnotations == null)
+            return new Annotation[numParameters][0];
+
+        Annotation[][] result = parseParameterAnnotations(
+            parameterAnnotations, constPool, container); 
+
+        if (result.length != numParameters)
+            throw new AnnotationFormatError(
+                "Parameter annotations don't match number of parameters (count was " +
+               result.length + " but should be " + numParameters + ").");
+        return result;
+    }
+
+    /**
+     * Parses the annotation default value of the supplied method.
+     * This method is basically copied from OpenJDKs
+     * java.lang.reflect.Method.getAnnotationDefault()
+     * 
+     * @author Mathias Panzenböck
+     *
+     * @param method represents the method for which the annotation default value has to be parsed
+     * @param annotationDefault is the unparsed annotation default value
+     * @param constPool is the constant pool of the declaring class
+     * @return the parsed annotation default value (boxed, if it's a primitive type)
+     * @throws AnnotationFormatError if an annotation is found to be
+     *         malformed.
+     */
+    public static Object parseAnnotationDefault(Method method,
+                                                byte[] annotationDefault,
+                                                ConstantPool constPool) {
+        if  (annotationDefault == null)
+            return null;
+        
+       Class memberType = AnnotationType.invocationHandlerReturnType(
+            method.getReturnType());
+        
+       Object result = AnnotationParser.parseMemberValue(
+            memberType, ByteBuffer.wrap(annotationDefault),
+            constPool, method.getDeclaringClass());
+
+        if (result instanceof sun.reflect.annotation.ExceptionProxy)
+            throw new AnnotationFormatError("Invalid default: " + method);
+        
+       return result;
+    }
+
+    /**
+     * Parses the annotations described by the specified byte array.
+     * resolving constant references in the specified constant pool.
+     * The array must contain an array of annotations as described
+     * in the RuntimeVisibleAnnotations_attribute:
+     *
+     *   u2 num_annotations;
+     *   annotation annotations[num_annotations];
+     *
+     * @throws AnnotationFormatError if an annotation is found to be
+     *         malformed.
+     */
+    public static Map<Class, Annotation> parseAnnotations(
+                byte[] rawAnnotations,
+                ConstantPool constPool,
+                Class container) {
+        if (rawAnnotations == null)
+            return Collections.emptyMap();
+
+        try {
+            return parseAnnotations2(rawAnnotations, constPool, container);
+        } catch(BufferUnderflowException e) {
+            throw new AnnotationFormatError("Unexpected end of annotations.");
+        } catch(IllegalArgumentException e) {
+            // Type mismatch in constant pool
+            throw new AnnotationFormatError(e);
+        }
+    }
+
+    private static Map<Class, Annotation> parseAnnotations2(
+                byte[] rawAnnotations,
+                ConstantPool constPool,
+                Class container) {
+        Map<Class, Annotation> result = new LinkedHashMap<Class, Annotation>();
+        ByteBuffer buf = ByteBuffer.wrap(rawAnnotations);
+        int numAnnotations = buf.getShort() & 0xFFFF;
+        for (int i = 0; i < numAnnotations; i++) {
+           Annotation a = parseAnnotation(buf, constPool, container, false);
+            if (a != null) {
+                Class klass = a.annotationType();
+                AnnotationType type = AnnotationType.getInstance(klass);
+                if (type.retention() == RetentionPolicy.RUNTIME)
+                    if (result.put(klass, a) != null)
+                        throw new AnnotationFormatError(
+                            "Duplicate annotation for class: "+klass+": " + a);
+            }
+        }
+        return result;
+    }
+
+    /**
+     * Parses the parameter annotations described by the specified byte array.
+     * resolving constant references in the specified constant pool.
+     * The array must contain an array of annotations as described
+     * in the RuntimeVisibleParameterAnnotations_attribute:
+     *
+     *    u1 num_parameters;
+     *    {
+     *        u2 num_annotations;
+     *        annotation annotations[num_annotations];
+     *    } parameter_annotations[num_parameters];
+     *
+     * Unlike parseAnnotations, rawAnnotations must not be null!
+     * A null value must be handled by the caller.  This is so because
+     * we cannot determine the number of parameters if rawAnnotations
+     * is null.  Also, the caller should check that the number
+     * of parameters indicated by the return value of this method
+     * matches the actual number of method parameters.  A mismatch
+     * indicates that an AnnotationFormatError should be thrown.
+     *
+     * @throws AnnotationFormatError if an annotation is found to be
+     *         malformed.
+     */
+    public static Annotation[][] parseParameterAnnotations(
+                    byte[] rawAnnotations,
+                    ConstantPool constPool,
+                    Class container) {
+        try {
+            return parseParameterAnnotations2(rawAnnotations, constPool, container);
+        } catch(BufferUnderflowException e) {
+            throw new AnnotationFormatError(
+                "Unexpected end of parameter annotations.");
+        } catch(IllegalArgumentException e) {
+            // Type mismatch in constant pool
+            throw new AnnotationFormatError(e);
+        }
+    }
+
+    private static Annotation[][] parseParameterAnnotations2(
+                    byte[] rawAnnotations,
+                    ConstantPool constPool,
+                    Class container) {
+        ByteBuffer buf = ByteBuffer.wrap(rawAnnotations);
+        int numParameters = buf.get() & 0xFF;
+        Annotation[][] result = new Annotation[numParameters][];
+
+        for (int i = 0; i < numParameters; i++) {
+            int numAnnotations = buf.getShort() & 0xFFFF;
+            List<Annotation> annotations =
+                new ArrayList<Annotation>(numAnnotations);
+            for (int j = 0; j < numAnnotations; j++) {
+                Annotation a = parseAnnotation(buf, constPool, container, false);
+                if (a != null) {
+                    AnnotationType type = AnnotationType.getInstance(
+                                              a.annotationType());
+                    if (type.retention() == RetentionPolicy.RUNTIME)
+                        annotations.add(a);
+                }
+            }
+            result[i] = annotations.toArray(EMPTY_ANNOTATIONS_ARRAY);
+        }
+        return result;
+    }
+
+    private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
+                    new Annotation[0];
+
+    /**
+     * Parses the annotation at the current position in the specified
+     * byte buffer, resolving constant references in the specified constant
+     * pool.  The cursor of the byte buffer must point to an "annotation
+     * structure" as described in the RuntimeVisibleAnnotations_attribute:
+     *
+     * annotation {
+     *    u2    type_index;
+     *       u2    num_member_value_pairs;
+     *       {    u2    member_name_index;
+     *             member_value value;
+     *       }    member_value_pairs[num_member_value_pairs];
+     *    }
+     * }
+     *
+     * Returns the annotation, or null if the annotation's type cannot
+     * be found by the VM, or is not a valid annotation type.
+     *
+     * @param exceptionOnMissingAnnotationClass if true, throw
+     * TypeNotPresentException if a referenced annotation type is not
+     * available at runtime
+     */
+    private static Annotation parseAnnotation(ByteBuffer buf,
+                                              ConstantPool constPool,
+                                              Class container,
+                                             boolean exceptionOnMissingAnnotationClass) {
+        int typeIndex = buf.getShort() & 0xFFFF;
+        Class annotationClass = null;
+       String sig = "[unknown]";
+        try {
+            try {
+                sig = constPool.getUTF8At(typeIndex);
+                annotationClass = parseSig(sig, container);
+            } catch (IllegalArgumentException ex) {
+                // support obsolete early jsr175 format class files
+                annotationClass = constPool.getClassAt(typeIndex);
+            }
+        } catch (NoClassDefFoundError e) {
+           if (exceptionOnMissingAnnotationClass)
+               // note: at this point sig is "[unknown]" or VM-style
+               // name instead of a binary name
+               throw new TypeNotPresentException(sig, e);
+            skipAnnotation(buf, false);
+            return null;
+        }
+       catch (TypeNotPresentException e) {
+           if (exceptionOnMissingAnnotationClass)
+               throw e;
+            skipAnnotation(buf, false);
+            return null;
+        }
+        AnnotationType type = null;
+        try {
+            type = AnnotationType.getInstance(annotationClass);
+        } catch (IllegalArgumentException e) {
+            skipAnnotation(buf, false);
+            return null;
+        }
+
+        Map<String, Class> memberTypes = type.memberTypes();
+        Map<String, Object> memberValues =
+            new LinkedHashMap<String, Object>(type.memberDefaults());
+
+        int numMembers = buf.getShort() & 0xFFFF;
+        for (int i = 0; i < numMembers; i++) {
+            int memberNameIndex = buf.getShort() & 0xFFFF;
+            String memberName = constPool.getUTF8At(memberNameIndex);
+            Class memberType = memberTypes.get(memberName);
+
+            if (memberType == null) {
+                // Member is no longer present in annotation type; ignore it
+                skipMemberValue(buf);
+            } else {
+                Object value = parseMemberValue(memberType, buf, constPool, container);
+                if (value instanceof AnnotationTypeMismatchExceptionProxy)
+                    ((AnnotationTypeMismatchExceptionProxy) value).
+                        setMember(type.members().get(memberName));
+                memberValues.put(memberName, value);
+            }
+        }
+        return annotationForMap(annotationClass, memberValues);
+    }
+
+    /**
+     * Returns an annotation of the given type backed by the given
+     * member -> value map.
+     */
+    public static Annotation annotationForMap(
+        Class type, Map<String, Object> memberValues)
+    {
+        return (Annotation) Proxy.newProxyInstance(
+            type.getClassLoader(), new Class[] { type },
+            new AnnotationInvocationHandler(type, memberValues));
+    }
+
+    /**
+     * Parses the annotation member value at the current position in the
+     * specified byte buffer, resolving constant references in the specified
+     * constant pool.  The cursor of the byte buffer must point to a
+     * "member_value structure" as described in the
+     * RuntimeVisibleAnnotations_attribute:
+     *
+     *  member_value {
+     *    u1 tag;
+     *    union {
+     *       u2   const_value_index;
+     *       {
+     *           u2   type_name_index;
+     *           u2   const_name_index;
+     *       } enum_const_value;
+     *       u2   class_info_index;
+     *       annotation annotation_value; 
+     *       {
+     *           u2    num_values;
+     *           member_value values[num_values];
+     *       } array_value;
+     *    } value;
+     * }
+     *
+     * The member must be of the indicated type. If it is not, this
+     * method returns an AnnotationTypeMismatchExceptionProxy.
+     */
+    public static Object parseMemberValue(Class memberType, ByteBuffer buf,
+                                          ConstantPool constPool,
+                                          Class container) {
+        Object result = null;
+        int tag = buf.get();
+        switch(tag) {
+          case 'e':
+              return parseEnumValue(memberType, buf, constPool, container);
+          case 'c':
+              result = parseClassValue(buf, constPool, container);
+              break;
+          case '@':
+              result = parseAnnotation(buf, constPool, container, true);
+              break;
+          case '[':
+              return parseArray(memberType, buf, constPool, container);
+          default:
+              result = parseConst(tag, buf, constPool);
+        }
+
+        if (!(result instanceof ExceptionProxy) &&
+            !memberType.isInstance(result))
+            result = new AnnotationTypeMismatchExceptionProxy(
+                result.getClass() + "[" + result + "]");
+        return result;
+    }
+
+    /**
+     * Parses the primitive or String annotation member value indicated by 
+     * the specified tag byte at the current position in the specified byte
+     * buffer, resolving constant reference in the specified constant pool.
+     * The cursor of the byte buffer must point to an annotation member value
+     * of the type indicated by the specified tag, as described in the
+     * RuntimeVisibleAnnotations_attribute:
+     *
+     *       u2   const_value_index;
+     */
+    private static Object parseConst(int tag,
+                                     ByteBuffer buf, ConstantPool constPool) {
+        int constIndex = buf.getShort() & 0xFFFF;
+        switch(tag) {
+          case 'B':
+            return Byte.valueOf((byte) constPool.getIntAt(constIndex));
+          case 'C':
+            return Character.valueOf((char) constPool.getIntAt(constIndex));
+          case 'D':
+            return Double.valueOf(constPool.getDoubleAt(constIndex));
+          case 'F':
+            return Float.valueOf(constPool.getFloatAt(constIndex));
+          case 'I':
+            return Integer.valueOf(constPool.getIntAt(constIndex));
+          case 'J':
+            return Long.valueOf(constPool.getLongAt(constIndex));
+          case 'S':
+            return Short.valueOf((short) constPool.getIntAt(constIndex));
+          case 'Z':
+            return Boolean.valueOf(constPool.getIntAt(constIndex) != 0);
+          case 's':
+            return constPool.getUTF8At(constIndex);
+          default:
+            throw new AnnotationFormatError(
+                "Invalid member-value tag in annotation: " + tag);
+        }
+    }
+
+    /**
+     * Parses the Class member value at the current position in the
+     * specified byte buffer, resolving constant references in the specified
+     * constant pool.  The cursor of the byte buffer must point to a "class
+     * info index" as described in the RuntimeVisibleAnnotations_attribute:
+     *
+     *       u2   class_info_index;
+     */
+    private static Object parseClassValue(ByteBuffer buf,
+                                          ConstantPool constPool,
+                                          Class container) {
+        int classIndex = buf.getShort() & 0xFFFF;
+        try {
+            try {
+                String sig = constPool.getUTF8At(classIndex);
+                return parseSig(sig, container);
+            } catch (IllegalArgumentException ex) {
+                // support obsolete early jsr175 format class files
+                return constPool.getClassAt(classIndex);
+            }
+        } catch (NoClassDefFoundError e) {
+            return new TypeNotPresentExceptionProxy("[unknown]", e);
+        }
+        catch (TypeNotPresentException e) {
+            return new TypeNotPresentExceptionProxy(e.typeName(), e.getCause());
+        }
+    }
+
+    /**
+     * Parses a return type signature and returns the according Class object.
+     */
+    private static Class<?> parseSig(String sig, Class container) {
+        if (sig.equals("V")) {
+            return void.class;
+        }
+        else {
+            return toClass(new FieldSignatureParser(container, sig).getFieldType());
+        }
+    }
+
+    static Class<?> toClass(Type o) {
+        if (o instanceof GenericArrayType)
+            return Array.newInstance(toClass(((GenericArrayType)o).getGenericComponentType()),
+                                     0)
+                .getClass();
+        return (Class<?>)o;
+    }
+
+    /**
+     * Parses the enum constant member value at the current position in the
+     * specified byte buffer, resolving constant references in the specified
+     * constant pool.  The cursor of the byte buffer must point to a
+     * "enum_const_value structure" as described in the
+     * RuntimeVisibleAnnotations_attribute:
+     *
+     *       {
+     *           u2   type_name_index;
+     *           u2   const_name_index;
+     *       } enum_const_value;
+     */
+    private static Object parseEnumValue(Class enumType, ByteBuffer buf,
+                                         ConstantPool constPool,
+                                         Class container) {
+        int typeNameIndex = buf.getShort() & 0xFFFF;
+        String typeName  = constPool.getUTF8At(typeNameIndex);
+        int constNameIndex = buf.getShort() & 0xFFFF;
+        String constName = constPool.getUTF8At(constNameIndex);
+
+        if (!typeName.endsWith(";")) {
+            // support now-obsolete early jsr175-format class files.
+            if (!enumType.getName().equals(typeName))
+            return new AnnotationTypeMismatchExceptionProxy(
+                typeName + "." + constName);
+        } else if (enumType != parseSig(typeName, container)) {
+            return new AnnotationTypeMismatchExceptionProxy(
+                typeName + "." + constName);
+        }
+
+        try {
+            return  Enum.valueOf(enumType, constName);
+        } catch(IllegalArgumentException e) {
+            return new EnumConstantNotPresentExceptionProxy(
+                (Class<? extends Enum>)enumType, constName);
+        }
+    }
+
+    /**
+     * Parses the array value at the current position in the specified byte
+     * buffer, resolving constant references in the specified constant pool.
+     * The cursor of the byte buffer must point to an array value struct
+     * as specified in the RuntimeVisibleAnnotations_attribute:
+     *
+     *       {
+     *           u2    num_values;
+     *           member_value values[num_values];
+     *       } array_value;
+     *
+     * If the array values do not match arrayType, an
+     * AnnotationTypeMismatchExceptionProxy will be returned.
+     */
+    private static Object parseArray(Class arrayType,
+                                     ByteBuffer buf,
+                                     ConstantPool constPool,
+                                     Class container) {
+        int length = buf.getShort() & 0xFFFF;  // Number of array components
+        Class componentType = arrayType.getComponentType();
+
+        if (componentType == byte.class) {
+            return parseByteArray(length, buf, constPool); 
+        } else if (componentType == char.class) {
+            return parseCharArray(length, buf, constPool);
+        } else if (componentType == double.class) {
+            return parseDoubleArray(length, buf, constPool);
+        } else if (componentType == float.class) {
+            return parseFloatArray(length, buf, constPool);
+        } else if (componentType == int.class) {
+            return parseIntArray(length, buf, constPool);
+        } else if (componentType == long.class) {
+            return parseLongArray(length, buf, constPool);
+        } else if (componentType == short.class) {
+            return parseShortArray(length, buf, constPool);
+        } else if (componentType == boolean.class) {
+            return parseBooleanArray(length, buf, constPool);
+        } else if (componentType == String.class) {
+            return parseStringArray(length, buf, constPool);
+        } else if (componentType == Class.class) {
+            return parseClassArray(length, buf, constPool, container);
+        } else if (componentType.isEnum()) {
+            return parseEnumArray(length, componentType, buf,
+                                  constPool, container);
+        } else {
+            assert componentType.isAnnotation();
+            return parseAnnotationArray(length, componentType, buf,
+                                        constPool, container);
+        }
+    }
+
+    private static Object parseByteArray(int length,
+                                  ByteBuffer buf, ConstantPool constPool) {
+        byte[] result = new byte[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'B') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = (byte) constPool.getIntAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseCharArray(int length,
+                                  ByteBuffer buf, ConstantPool constPool) {
+        char[] result = new char[length];
+        boolean typeMismatch = false;
+        byte tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'C') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = (char) constPool.getIntAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseDoubleArray(int length,
+                                    ByteBuffer buf, ConstantPool constPool) {
+        double[] result = new  double[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'D') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = constPool.getDoubleAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseFloatArray(int length,
+                                   ByteBuffer buf, ConstantPool constPool) {
+        float[] result = new float[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'F') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = constPool.getFloatAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseIntArray(int length,
+                                 ByteBuffer buf, ConstantPool constPool) {
+        int[] result = new  int[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'I') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = constPool.getIntAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+    
+    private static Object parseLongArray(int length,
+                                  ByteBuffer buf, ConstantPool constPool) {
+        long[] result = new long[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'J') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = constPool.getLongAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseShortArray(int length,
+                                   ByteBuffer buf, ConstantPool constPool) {
+        short[] result = new short[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'S') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = (short) constPool.getIntAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseBooleanArray(int length,
+                                     ByteBuffer buf, ConstantPool constPool) {
+        boolean[] result = new boolean[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'Z') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = (constPool.getIntAt(index) != 0);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseStringArray(int length,
+                                    ByteBuffer buf,  ConstantPool constPool) {
+        String[] result = new String[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 's') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = constPool.getUTF8At(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseClassArray(int length,
+                                          ByteBuffer buf,
+                                          ConstantPool constPool,
+                                          Class container) {
+        Object[] result = new Class[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'c') {
+                result[i] = parseClassValue(buf, constPool, container);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseEnumArray(int length, Class enumType,
+                                         ByteBuffer buf,
+                                         ConstantPool constPool,
+                                         Class container) {
+        Object[] result = (Object[]) Array.newInstance(enumType, length);
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'e') {
+                result[i] = parseEnumValue(enumType, buf, constPool, container);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseAnnotationArray(int length,
+                                               Class annotationType,
+                                               ByteBuffer buf,
+                                               ConstantPool constPool,
+                                               Class container) {
+        Object[] result = (Object[]) Array.newInstance(annotationType, length);
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == '@') {
+                result[i] = parseAnnotation(buf, constPool, container, true);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    /**
+     * Return an appropriate exception proxy for a mismatching array
+     * annotation where the erroneous array has the specified tag.
+     */
+    private static ExceptionProxy exceptionProxy(int tag) {
+        return new AnnotationTypeMismatchExceptionProxy(
+            "Array with component tag: " + tag);
+    }
+
+    /**
+     * Skips the annotation at the current position in the specified
+     * byte buffer.  The cursor of the byte buffer must point to 
+     * an "annotation structure" OR two bytes into an annotation
+     * structure (i.e., after the type index).
+     * 
+     * @parameter complete true if the byte buffer points to the beginning
+     *     of an annotation structure (rather than two bytes in).
+     */
+    private static void skipAnnotation(ByteBuffer buf, boolean complete) {
+        if (complete)
+            buf.getShort();   // Skip type index
+        int numMembers = buf.getShort() & 0xFFFF;
+        for (int i = 0; i < numMembers; i++) {
+            buf.getShort();   // Skip memberNameIndex
+            skipMemberValue(buf);
+        }
+    }
+
+    /**
+     * Skips the annotation member value at the current position in the
+     * specified byte buffer.  The cursor of the byte buffer must point to a
+     * "member_value structure."
+     */
+    private static void skipMemberValue(ByteBuffer buf) {
+        int tag = buf.get();
+        skipMemberValue(tag, buf);
+    }
+
+    /**
+     * Skips the annotation member value at the current position in the
+     * specified byte buffer.  The cursor of the byte buffer must point
+     * immediately after the tag in a "member_value structure."
+     */
+    private static void skipMemberValue(int tag, ByteBuffer buf) {
+        switch(tag) {
+          case 'e': // Enum value
+            buf.getInt();  // (Two shorts, actually.)
+            break;
+          case '@':
+            skipAnnotation(buf, true);
+            break;
+          case '[':
+            skipArray(buf);
+            break;
+          default:
+            // Class, primitive, or String
+            buf.getShort();
+        }
+    }
+
+    /**
+     * Skips the array value at the current position in the specified byte
+     * buffer.  The cursor of the byte buffer must point to an array value
+     * struct.
+     */
+    private static void skipArray(ByteBuffer buf) {
+        int length = buf.getShort() & 0xFFFF;
+        for (int i = 0; i < length; i++)
+            skipMemberValue(buf);
+    }
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java b/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java
new file mode 100644 (file)
index 0000000..ea559bb
--- /dev/null
@@ -0,0 +1,234 @@
+/*
+ * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect.annotation;
+
+import java.lang.annotation.*;
+import java.lang.reflect.*;
+import java.util.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Represents an annotation type at run time.  Used to type-check annotations
+ * and apply member defaults.
+ *
+ * @author  Josh Bloch
+ * @since   1.5
+ */
+public class AnnotationType {
+    /**
+     * Annotation class -> AnnotationType mapping. This emulates
+     * sun.misc.SharedSecrets.getJavaLangAccess().getAnnotationType() and
+     * sun.misc.SharedSecrets.getJavaLangAccess().setAnnotationType() so
+     * this class can be used with gnu classpath.
+     *
+     * @author Mathias Panzenböck
+     */
+    private static Map<Class, AnnotationType> annotationTypes =
+        new HashMap<Class, AnnotationType>();
+
+    /**
+     * Member name -> type mapping. Note that primitive types
+     * are represented by the class objects for the corresponding wrapper
+     * types.  This matches the return value that must be used for a
+     * dynamic proxy, allowing for a simple isInstance test.
+     */
+    private final Map<String, Class> memberTypes = new HashMap<String,Class>();
+
+    /**
+     * Member name -> default value mapping.
+     */
+    private final Map<String, Object> memberDefaults =
+        new HashMap<String, Object>();
+
+    /**
+     * Member name -> Method object mapping. This (and its assoicated
+     * accessor) are used only to generate AnnotationTypeMismatchExceptions.
+     */
+    private final Map<String, Method> members = new HashMap<String, Method>();
+
+    /**
+     * The retention policy for this annotation type.
+     */
+    private RetentionPolicy retention = RetentionPolicy.RUNTIME;;
+
+    /**
+     * Whether this annotation type is inherited.
+     */
+    private boolean inherited = false;
+
+    /**
+     * Returns an AnnotationType instance for the specified annotation type.
+     *
+     * @throw IllegalArgumentException if the specified class object for
+     *     does not represent a valid annotation type
+     */
+    public static synchronized AnnotationType getInstance(
+        Class annotationClass)
+    {
+        /*
+       AnnotationType result = sun.misc.SharedSecrets.getJavaLangAccess(). 
+            getAnnotationType(annotationClass); 
+        */
+       // emulating OpenJDKs SharedSecrets in GNU Classpath:
+       AnnotationType result = annotationTypes.get(annotationClass); 
+       if (result == null)
+            result = new AnnotationType((Class<?>) annotationClass);
+
+        return result;
+    }
+
+    /**
+     * Sole constructor.
+     *
+     * @param annotationClass the class object for the annotation type
+     * @throw IllegalArgumentException if the specified class object for
+     *     does not represent a valid annotation type
+     */
+    private AnnotationType(final Class<?> annotationClass) {
+        if (!annotationClass.isAnnotation())
+            throw new IllegalArgumentException("Not an annotation type");
+
+       Method[] methods =      
+           AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
+               public Method[] run() {
+                   // Initialize memberTypes and defaultValues
+                   return annotationClass.getDeclaredMethods();
+               }
+           });
+
+
+       for (Method method :  methods) {
+           if (method.getParameterTypes().length != 0)
+               throw new IllegalArgumentException(method + " has params");
+           String name = method.getName();
+           Class type = method.getReturnType();
+           memberTypes.put(name, invocationHandlerReturnType(type));
+           members.put(name, method);
+                   
+           Object defaultValue = method.getDefaultValue();
+           if (defaultValue != null)
+               memberDefaults.put(name, defaultValue);
+
+           members.put(name, method);
+       }
+
+       /*
+        sun.misc.SharedSecrets.getJavaLangAccess(). 
+            setAnnotationType(annotationClass, this); 
+        */
+       // emulating OpenJDKs SharedSecrets in GNU Classpath:
+       annotationTypes.put(annotationClass, this);
+
+        // Initialize retention, & inherited fields.  Special treatment
+        // of the corresponding annotation types breaks infinite recursion.
+        if (annotationClass != Retention.class &&
+            annotationClass != Inherited.class) {
+            Retention ret = annotationClass.getAnnotation(Retention.class);
+            retention = (ret == null ? RetentionPolicy.CLASS : ret.value());
+            inherited = annotationClass.isAnnotationPresent(Inherited.class);
+        }
+    }
+
+    /**
+     * Returns the type that must be returned by the invocation handler
+     * of a dynamic proxy in order to have the dynamic proxy return
+     * the specified type (which is assumed to be a legal member type
+     * for an annotation).
+     */
+    public static Class invocationHandlerReturnType(Class type) {
+        // Translate primitives to wrappers
+        if (type == byte.class)
+            return Byte.class;
+        if (type == char.class)
+            return Character.class;
+        if (type == double.class)
+            return Double.class;
+        if (type == float.class)
+            return Float.class;
+        if (type == int.class)
+            return Integer.class;
+        if (type == long.class)
+            return Long.class;
+        if (type == short.class)
+            return Short.class;
+        if (type == boolean.class)
+            return Boolean.class;
+
+        // Otherwise, just return declared type
+        return type;
+    }
+
+    /**
+     * Returns member types for this annotation type
+     * (member name -> type mapping).
+     */
+    public Map<String, Class> memberTypes() {
+        return memberTypes;
+    }
+
+    /**
+     * Returns members of this annotation type
+     * (member name -> associated Method object mapping).
+     */
+    public Map<String, Method> members() {
+        return members;
+    }
+
+    /**
+     * Returns the default values for this annotation type
+     * (Member name -> default value mapping).
+     */
+    public Map<String, Object> memberDefaults() {
+        return memberDefaults;
+    }
+
+    /**
+     * Returns the retention policy for this annotation type.
+     */
+    public RetentionPolicy retention() {
+        return retention;
+    }
+
+    /**
+     * Returns true if this this annotation type is inherited.
+     */
+    public boolean isInherited() {
+        return inherited;
+    }
+
+    /**
+     * For debugging.
+     */
+    public String toString() {
+        StringBuffer s = new StringBuffer("Annotation Type:" + "\n");
+        s.append("   Member types: " + memberTypes + "\n");
+        s.append("   Member defaults: " + memberDefaults + "\n");
+        s.append("   Retention policy: " + retention + "\n");
+        s.append("   Inherited: " + inherited);
+        return s.toString();
+    }
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java b/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java
new file mode 100644 (file)
index 0000000..a7f434f
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect.annotation;
+import java.lang.annotation.*;
+import java.lang.reflect.Method;
+
+/**
+ * ExceptionProxy for AnnotationTypeMismatchException.
+ *
+ * @author  Josh Bloch
+ * @since   1.5
+ */
+class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy {
+    private Method member;
+    private String foundType;
+
+    /**
+     * It turns out to be convenient to construct these proxies in
+     * two stages.  Since this is a private implementation class, we
+     * permit ourselves this liberty even though it's normally a very
+     * bad idea.
+     */
+    AnnotationTypeMismatchExceptionProxy(String foundType) {
+        this.foundType = foundType;
+    }
+
+    AnnotationTypeMismatchExceptionProxy setMember(Method member) {
+        this.member = member;
+        return this;
+    }
+
+    protected RuntimeException generateException() {
+        return new AnnotationTypeMismatchException(member, foundType);
+    }
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java b/src/classes/gnuclasspath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java
new file mode 100644 (file)
index 0000000..6049a3f
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect.annotation;
+import java.lang.annotation.*;
+
+/**
+ * ExceptionProxy for EnumConstantNotPresentException.
+ *
+ * @author  Josh Bloch
+ * @since   1.5
+ */
+public class EnumConstantNotPresentExceptionProxy extends ExceptionProxy {
+    Class<? extends Enum> enumType;
+    String constName;
+
+    public EnumConstantNotPresentExceptionProxy(Class<? extends Enum> enumType,
+                                                String constName) {
+        this.enumType = enumType;
+        this.constName = constName;
+    }
+
+    protected RuntimeException generateException() {
+        return new EnumConstantNotPresentException(enumType, constName);
+    }
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/ExceptionProxy.java b/src/classes/gnuclasspath/sun/reflect/annotation/ExceptionProxy.java
new file mode 100644 (file)
index 0000000..e9cda0b
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect.annotation;
+
+/**
+ * An instance of this class is stored in an AnnotationInvocationHandler's
+ * "memberValues" map in lieu of a value for an annotation member that
+ * cannot be returned due to some exceptional condition (typically some
+ * form of illegal evolution of the annotation class).  The ExceptionProxy
+ * instance describes the exception that the dynamic proxy should throw if
+ * it is queried for this member.
+ *
+ * @author  Josh Bloch
+ * @since   1.5
+ */
+public abstract class ExceptionProxy implements java.io.Serializable {
+    protected abstract RuntimeException generateException();
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/TypeNotPresentExceptionProxy.java b/src/classes/gnuclasspath/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
new file mode 100644 (file)
index 0000000..22cab5d
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect.annotation;
+import java.lang.annotation.*;
+
+/**
+ * ExceptionProxy for TypeNotPresentException.
+ *
+ * @author  Josh Bloch
+ * @since   1.5
+ */
+public class TypeNotPresentExceptionProxy extends ExceptionProxy {
+    String typeName;
+    Throwable cause;
+
+    public TypeNotPresentExceptionProxy(String typeName, Throwable cause) {
+        this.typeName = typeName;
+        this.cause = cause;
+    }
+
+    protected RuntimeException generateException() {
+        return new TypeNotPresentException(typeName, cause);
+    }
+}