[llvm-commits] [llvm-gcc-4.2] r43913 [65/80] - in /llvm-gcc-4.2/trunk: boehm-gc/ boehm-gc/Mac_files/ boehm-gc/cord/ boehm-gc/doc/ boehm-gc/include/ boehm-gc/include/private/ boehm-gc/tests/ libffi/ libffi/include/ libffi/src/ libffi/src/alpha/ libffi/src/arm/ libffi/src/cris/ libffi/src/frv/ libffi/src/ia64/ libffi/src/m32r/ libffi/src/m68k/ libffi/src/mips/ libffi/src/pa/ libffi/src/powerpc/ libffi/src/s390/ libffi/src/sh/ libffi/src/sh64/ libffi/src/sparc/ libffi/src/x86/ libffi/testsuite/ libffi/testsuite/config/ li...

Bill Wendling isanbard at gmail.com
Thu Nov 8 14:57:11 PST 2007


Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl_Stub.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl_Stub.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl_Stub.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl_Stub.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,556 @@
+/* ActivationSystemImpl.java -- implementation of the activation system.
+   Copyright (c) 2006 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.classpath.tools.rmi.rmid;
+
+import java.rmi.MarshalledObject;
+import java.rmi.RemoteException;
+import java.rmi.activation.ActivationDesc;
+import java.rmi.activation.ActivationException;
+import java.rmi.activation.ActivationGroupDesc;
+import java.rmi.activation.ActivationGroupID;
+import java.rmi.activation.ActivationID;
+import java.rmi.activation.ActivationInstantiator;
+import java.rmi.activation.ActivationMonitor;
+import java.rmi.activation.ActivationSystem;
+import java.rmi.activation.Activator;
+import java.rmi.activation.UnknownGroupException;
+import java.rmi.activation.UnknownObjectException;
+
+import java.lang.reflect.Method;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+import java.rmi.UnexpectedException;
+
+/**
+ * This class delegates its method calls to the remote RMI object, referenced
+ * by {@link RemoteRef}. 
+ *
+ * It is normally generated with rmic.
+ */
+public final class ActivationSystemImpl_Stub 
+    extends RemoteStub
+    implements ActivationMonitor, Activator, ActivationSystem
+{
+    /**
+     * Use serialVersionUID for interoperability 
+     */
+    private static final long serialVersionUID = 2;
+    
+    /**
+     * The explaining message for {@ling UnexpectedException}.
+     */
+    private static final String exception_message = 
+      "undeclared checked exception";
+
+     /* All remote methods, invoked by this stub: */
+    private static final Method met_setActivationGroupDesc;
+    private static final Method met_inactiveGroup;
+    private static final Method met_unregisterObject;
+    private static final Method met_getActivationDesc;
+    private static final Method met_setActivationDesc;
+    private static final Method met_shutdown;
+    private static final Method met_activate;
+    private static final Method met_activeGroup;
+    private static final Method met_registerGroup;
+    private static final Method met_getActivationGroupDesc;
+    private static final Method met_activeObject;
+    private static final Method met_registerObject;
+    private static final Method met_inactiveObject;
+    private static final Method met_unregisterGroup;
+    private static final Object[] NO_ARGS = new Object[0];
+    static
+      {
+        final Class[]  NO_ARGSc = new Class[0];      
+        try 
+          {
+             met_setActivationGroupDesc =
+               ActivationSystem.class.getMethod("setActivationGroupDesc", new Class[]
+                 {
+                   ActivationGroupID.class, ActivationGroupDesc.class
+                 });
+             met_inactiveGroup =
+               ActivationMonitor.class.getMethod("inactiveGroup", new Class[]
+                 {
+                   ActivationGroupID.class, long.class
+                 });
+             met_unregisterObject =
+               ActivationSystem.class.getMethod("unregisterObject", new Class[]
+                 {
+                   ActivationID.class
+                 });
+             met_getActivationDesc =
+               ActivationSystem.class.getMethod("getActivationDesc", new Class[]
+                 {
+                   ActivationID.class
+                 });
+             met_setActivationDesc =
+               ActivationSystem.class.getMethod("setActivationDesc", new Class[]
+                 {
+                   ActivationID.class, ActivationDesc.class
+                 });
+             met_shutdown =
+               ActivationSystem.class.getMethod("shutdown", NO_ARGSc);
+             met_activate =
+               Activator.class.getMethod("activate", new Class[]
+                 {
+                   ActivationID.class, boolean.class
+                 });
+             met_activeGroup =
+               ActivationSystem.class.getMethod("activeGroup", new Class[]
+                 {
+                   ActivationGroupID.class, ActivationInstantiator.class, long.class
+                 });
+             met_registerGroup =
+               ActivationSystem.class.getMethod("registerGroup", new Class[]
+                 {
+                   ActivationGroupDesc.class
+                 });
+             met_getActivationGroupDesc =
+               ActivationSystem.class.getMethod("getActivationGroupDesc", new Class[]
+                 {
+                   ActivationGroupID.class
+                 });
+             met_activeObject =
+               ActivationMonitor.class.getMethod("activeObject", new Class[]
+                 {
+                   ActivationID.class, MarshalledObject.class
+                 });
+             met_registerObject =
+               ActivationSystem.class.getMethod("registerObject", new Class[]
+                 {
+                   ActivationDesc.class
+                 });
+             met_inactiveObject =
+               ActivationMonitor.class.getMethod("inactiveObject", new Class[]
+                 {
+                   ActivationID.class
+                 });
+             met_unregisterGroup =
+               ActivationSystem.class.getMethod("unregisterGroup", new Class[]
+                 {
+                   ActivationGroupID.class
+                 });
+
+          }
+        catch (NoSuchMethodException nex)
+          {
+             NoSuchMethodError err = new NoSuchMethodError(
+               "ActivationSystemImpl_Stub class initialization failed");
+             err.initCause(nex);
+             throw err;
+          }  
+      }
+    
+    /**
+     * Create the instance for _ActivationSystemImpl_Stub that forwards method calls to the
+     * remote object.
+     *
+     * @para the reference to the remote object.
+     */
+    public ActivationSystemImpl_Stub(RemoteRef reference) 
+    {
+       super(reference);
+    }    
+    
+    /* Methods */
+  /** @inheritDoc */
+  public ActivationGroupDesc setActivationGroupDesc(ActivationGroupID p0,
+                                                    ActivationGroupDesc p1)
+      throws ActivationException, UnknownGroupException, RemoteException
+  {
+    try
+      {
+        Object result = ref.invoke(this, met_setActivationGroupDesc,
+                                   new Object[] { p0, p1 },
+                                   1213918527826541191L);
+        return (ActivationGroupDesc) result;
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+  /** @inheritDoc */
+  public void inactiveGroup(ActivationGroupID p0, long p1)
+      throws UnknownGroupException, RemoteException
+  {
+    try
+      {
+        ref.invoke(this, met_inactiveGroup, new Object[] { p0, new Long(p1) },
+                   -399287892768650944L);
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+  /** @inheritDoc */
+  public void unregisterObject(ActivationID p0) throws ActivationException,
+      UnknownObjectException, RemoteException
+  {
+    try
+      {
+        ref.invoke(this, met_unregisterObject, new Object[] { p0 },
+                   -6843850585331411084L);
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+  /** @inheritDoc */
+  public ActivationDesc getActivationDesc(ActivationID p0)
+      throws ActivationException, UnknownObjectException, RemoteException
+  {
+    try
+      {
+        Object result = ref.invoke(this, met_getActivationDesc,
+                                   new Object[] { p0 }, 4830055440982622087L);
+        return (ActivationDesc) result;
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+  /** @inheritDoc */
+  public ActivationDesc setActivationDesc(ActivationID p0, ActivationDesc p1)
+      throws ActivationException, UnknownObjectException,
+      UnknownGroupException, RemoteException
+  {
+    try
+      {
+        Object result = ref.invoke(this, met_setActivationDesc,
+                                   new Object[] { p0, p1 },
+                                   7128043237057180796L);
+        return (ActivationDesc) result;
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+  /** @inheritDoc */
+  public void shutdown() throws RemoteException
+  {
+    try
+      {
+        ref.invoke(this, met_shutdown, NO_ARGS, -7207851917985848402L);
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+  /** @inheritDoc */
+  public MarshalledObject activate(ActivationID p0, boolean p1)
+      throws ActivationException, UnknownObjectException, RemoteException
+  {
+    try
+      {
+        Object result = ref.invoke(this, met_activate,
+                                   new Object[] { p0, new Boolean(p1) },
+                                   -8767355154875805558L);
+        return (MarshalledObject) result;
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+  /** @inheritDoc */
+  public ActivationMonitor activeGroup(ActivationGroupID p0,
+                                       ActivationInstantiator p1, long p2)
+      throws UnknownGroupException, ActivationException, RemoteException
+  {
+    try
+      {
+        Object result = ref.invoke(this, met_activeGroup,
+                                   new Object[] { p0, p1, new Long(p2) },
+                                   -4575843150759415294L);
+        return (ActivationMonitor) result;
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+  /** @inheritDoc */
+  public ActivationGroupID registerGroup(ActivationGroupDesc p0)
+      throws ActivationException, RemoteException
+  {
+    try
+      {
+        Object result = ref.invoke(this, met_registerGroup,
+                                   new Object[] { p0 }, 6921515268192657754L);
+        return (ActivationGroupID) result;
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+  /** @inheritDoc */
+  public ActivationGroupDesc getActivationGroupDesc(ActivationGroupID p0)
+      throws ActivationException, UnknownGroupException, RemoteException
+  {
+    try
+      {
+        Object result = ref.invoke(this, met_getActivationGroupDesc,
+                                   new Object[] { p0 }, -8701843806548736528L);
+        return (ActivationGroupDesc) result;
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+  /** @inheritDoc */
+  public void activeObject(ActivationID p0, MarshalledObject p1)
+      throws UnknownObjectException, RemoteException
+  {
+    try
+      {
+        ref.invoke(this, met_activeObject, new Object[] { p0, p1 },
+                   2543984342209939736L);
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+  /** @inheritDoc */
+  public ActivationID registerObject(ActivationDesc p0)
+      throws ActivationException, UnknownGroupException, RemoteException
+  {
+    try
+      {
+        Object result = ref.invoke(this, met_registerObject,
+                                   new Object[] { p0 }, -3006759798994351347L);
+        return (ActivationID) result;
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+  /** @inheritDoc */
+  public void inactiveObject(ActivationID p0) throws UnknownObjectException,
+      RemoteException
+  {
+    try
+      {
+        ref.invoke(this, met_inactiveObject, new Object[] { p0 },
+                   -4165404120701281807L);
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+  /** @inheritDoc */
+  public void unregisterGroup(ActivationGroupID p0) throws ActivationException,
+      UnknownGroupException, RemoteException
+  {
+    try
+      {
+        ref.invoke(this, met_unregisterGroup, new Object[] { p0 },
+                   3768097077835970701L);
+      }
+    catch (RuntimeException e)
+      {
+        throw e;
+      }
+    catch (RemoteException e)
+      {
+        throw e;
+      }
+    catch (Exception e)
+      {
+        UnexpectedException uex = new UnexpectedException(exception_message);
+        uex.detail = e;
+        throw uex;
+      }
+  }
+   
+    
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/serialver/Messages.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/serialver/Messages.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/serialver/Messages.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/serialver/Messages.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,68 @@
+/* Messages.java -- translations for serialver tool
+ Copyright (C) 2006 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.classpath.tools.serialver;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+  private static final String BUNDLE_NAME
+    = "gnu.classpath.tools.serialver.messages"; //$NON-NLS-1$
+
+  private static final ResourceBundle RESOURCE_BUNDLE
+    = ResourceBundle.getBundle(BUNDLE_NAME);
+
+  private Messages()
+  {
+  }
+
+  public static String getString(String key)
+  {
+    // TODO Auto-generated method stub
+    try
+      {
+        return RESOURCE_BUNDLE.getString(key);
+      }
+    catch (MissingResourceException e)
+      {
+        return '!' + key + '!';
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,163 @@
+/* gnu.classpath.tools.SerialVer
+ Copyright (C) 1998, 1999, 2000, 2001 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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+package gnu.classpath.tools.serialver;
+
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.File;
+import java.io.ObjectStreamClass;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+/**
+ * This class is an implementation of the `serialver' program. Any number of
+ * class names can be passed as arguments, and the serial version unique
+ * identitfier for each class will be printed in a manner suitable for cuting
+ * and pasting into a Java source file.
+ */
+public class SerialVer
+{
+  // List of classes to load.
+  ArrayList classes = new ArrayList();
+  // The class path to use.
+  String classpath;
+
+  // FIXME: taken from ClassLoader, should share it.
+  private static void addFileURL(ArrayList list, String file)
+  {
+    try
+      {
+        list.add(new File(file).toURL());
+      }
+    catch(java.net.MalformedURLException x)
+      {
+      }
+  }
+
+  private ClassLoader getClassLoader()
+  {
+    // FIXME: this code is taken from ClassLoader.
+    // We should share it somewhere.
+    URL[] urls;
+    if (classpath == null)
+      urls = new URL[0];
+    else
+      {
+        StringTokenizer tok = new StringTokenizer(classpath,
+                                                  File.pathSeparator, true);
+        ArrayList list = new ArrayList();
+        while (tok.hasMoreTokens())
+          {
+            String s = tok.nextToken();
+            if (s.equals(File.pathSeparator))
+              addFileURL(list, "."); //$NON-NLS-1$
+            else
+              {
+                addFileURL(list, s);
+                if (tok.hasMoreTokens())
+                  {
+                    // Skip the separator.
+                    tok.nextToken();
+                    // If the classpath ended with a separator,
+                    // append the current directory.
+                    if (!tok.hasMoreTokens())
+                      addFileURL(list, "."); //$NON-NLS-1$
+                  }
+              }
+          }
+        urls = new URL[list.size()];
+        urls = (URL[]) list.toArray(urls);
+      }
+    return new URLClassLoader(urls);
+  }
+
+  private void printMessage(String format, String klass)
+  {
+    System.err.println(MessageFormat.format(format, new Object[] { klass }));
+  }
+
+  public void run(String[] args)
+  {
+    Parser p = new ClasspathToolParser("serialver", true) //$NON-NLS-1$
+    {
+      protected void validate() throws OptionException
+      {
+        if (classes.isEmpty())
+          throw new OptionException(Messages.getString("SerialVer.NoClassesSpecd")); //$NON-NLS-1$
+      }
+    };
+    p.setHeader(Messages.getString("SerialVer.HelpHeader")); //$NON-NLS-1$
+
+    p.add(new Option(Messages.getString("SerialVer.5"), Messages.getString("SerialVer.ClasspathHelp"), "PATH") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        if (classpath != null)
+          throw new OptionException(Messages.getString("SerialVer.DupClasspath")); //$NON-NLS-1$
+        classpath = argument;
+      }
+    });
+
+    p.parse(args, new FileArgumentCallback()
+    {
+      public void notifyFile(String fileArgument) throws OptionException
+      {
+        classes.add(fileArgument);
+      }
+    });
+
+    ClassLoader loader = getClassLoader();
+    Iterator it = classes.iterator();
+    while (it.hasNext())
+      {
+        String name = (String) it.next();
+        try
+          {
+            Class clazz = loader.loadClass(name);
+            ObjectStreamClass osc = ObjectStreamClass.lookup(clazz);
+            if (osc != null)
+              System.out.println(clazz.getName() + ": " //$NON-NLS-1$
+                                 + "static final long serialVersionUID = " //$NON-NLS-1$
+                                 + osc.getSerialVersionUID() + "L;"); //$NON-NLS-1$
+            else
+              printMessage(Messages.getString("SerialVer.ClassNotSerial"), name); //$NON-NLS-1$
+          }
+        catch (ClassNotFoundException e)
+          {
+            printMessage(Messages.getString("SerialVer.ClassNotFound"), name); //$NON-NLS-1$
+          }
+      }
+  }
+
+  public static void main(String[] args)
+  {
+    new SerialVer().run(args);
+  }
+}
\ No newline at end of file

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gserialver.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gserialver.in?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gserialver.in (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gserialver.in Thu Nov  8 16:56:19 2007
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a 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 of the License, 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; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, 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.
+##
+##
+## A simple shell script to launch the GNU Classpath serialver tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.serialver.Main "$@"

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/jarsigner.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/jarsigner.in?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/jarsigner.in (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/jarsigner.in Thu Nov  8 16:56:19 2007
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a 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 of the License, 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; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, 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.
+##
+##
+## A simple shell script to launch the GNU Classpath jarsigner tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.jarsigner.Main $@

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/keytool.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/keytool.in?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/keytool.in (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/keytool.in Thu Nov  8 16:56:19 2007
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a 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 of the License, 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; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, 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.
+##
+##
+## A simple shell script to launch the GNU Classpath keytool tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.keytool.Main $@

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/toolwrapper.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/toolwrapper.c?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/toolwrapper.c (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/toolwrapper.c Thu Nov  8 16:56:19 2007
@@ -0,0 +1,220 @@
+/* toolwrapper.c -- a native tool wrapper for VMs that support the JNI
+   invocation interface
+   Copyright (C) 2006  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. */
+
+#include <jni.h>
+#include <string.h>
+#include <stdlib.h>
+#include "config.h"
+
+#ifndef JNI_VERSION_1_2
+# error JNI version 1.2 or greater required
+#endif
+
+union env_union
+{
+  void *void_env;
+  JNIEnv *jni_env;
+};
+
+int
+main (int argc, const char** argv)
+{
+  union env_union tmp;
+  JNIEnv* env;
+  JavaVM* jvm;
+  JavaVMInitArgs vm_args;
+  jint result;
+  jclass class_id;
+  jmethodID method_id;
+  jstring str;
+  jclass string_class_id;
+  jobjectArray args_array;
+  char** non_vm_argv;
+  int non_vm_argc;
+  int i;
+  int classpath_found = 0;
+
+  env = NULL;
+  jvm = NULL;
+
+  vm_args.nOptions = 0;
+  vm_args.options = NULL;
+
+  non_vm_argc = 0;
+  non_vm_argv = NULL;
+
+  if (argc > 1)
+    {
+      for (i = 1; i < argc; i++)
+	{
+	  if (!strncmp (argv[i], "-J", 2))
+	    {
+	      if (!strncmp (argv[i], "-J-Djava.class.path=", 20))
+		classpath_found = 1;
+
+	      /* A virtual machine option. */
+	      vm_args.options = (JavaVMOption*) realloc (vm_args.options, (vm_args.nOptions + 1) * sizeof (JavaVMOption));
+
+	      if (vm_args.options == NULL)
+		{
+		  fprintf (stderr, TOOLNAME ": realloc failed.\n");
+		  goto destroy;
+		}
+
+	      if (strlen (argv[i]) == 2)
+		{
+		  fprintf (stderr, TOOLNAME ": the -J option must not be followed by a space.\n");
+		  goto destroy;
+		}
+	      else
+		vm_args.options[vm_args.nOptions++].optionString = strdup (argv[i] + 2);
+	    }
+	  else
+	    {
+	      non_vm_argv = (char**) realloc (non_vm_argv, (non_vm_argc + 1) * sizeof (char*));
+	      if (non_vm_argv == NULL)
+		{
+		  fprintf (stderr, TOOLNAME ": realloc failed.\n");
+		  goto destroy;
+		}
+	      non_vm_argv[non_vm_argc++] = strdup (argv[i]);
+	    }
+	}
+    }
+
+  if (!classpath_found)
+    {
+      /* Set the invocation classpath. */
+      vm_args.options = (JavaVMOption*) realloc (vm_args.options, (vm_args.nOptions + 1) * sizeof (JavaVMOption));
+
+      if (vm_args.options == NULL)
+	{
+	  fprintf (stderr, TOOLNAME ": realloc failed.\n");
+	  goto destroy;
+	}
+
+      vm_args.options[vm_args.nOptions++].optionString = "-Djava.class.path=" TOOLS_ZIP;
+    }
+
+  /* Terminate vm_args.options with a NULL element. */
+  vm_args.options = (JavaVMOption*) realloc (vm_args.options, (vm_args.nOptions + 1) * sizeof (JavaVMOption));
+  if (vm_args.options == NULL)
+    {
+      fprintf (stderr, TOOLNAME ": realloc failed.\n");
+      goto destroy;
+    }
+  vm_args.options[vm_args.nOptions].optionString = NULL;
+
+  /* Terminate non_vm_argv with a NULL element. */
+  non_vm_argv = (char**) realloc (non_vm_argv, (non_vm_argc + 1) * sizeof (char*));
+  if (non_vm_argv == NULL)
+    {
+      fprintf (stderr, TOOLNAME ": realloc failed.\n");
+      goto destroy;
+    }
+  non_vm_argv[non_vm_argc] = NULL;
+
+  vm_args.version = JNI_VERSION_1_2;
+  vm_args.ignoreUnrecognized = JNI_TRUE;
+
+  result = JNI_CreateJavaVM (&jvm, &tmp.void_env, &vm_args);
+
+  if (result < 0)
+    {
+      fprintf (stderr, TOOLNAME ": couldn't create virtual machine\n");
+      goto destroy;
+    }
+
+  env = tmp.jni_env;
+
+  string_class_id = (*env)->FindClass (env, "java/lang/String");
+  if (string_class_id == NULL)
+    {
+      fprintf (stderr, TOOLNAME ": FindClass failed.\n");
+      goto destroy;
+    }
+
+  args_array = (*env)->NewObjectArray (env, non_vm_argc, string_class_id, NULL);
+  if (args_array == NULL)
+    {
+      fprintf (stderr, TOOLNAME ": NewObjectArray failed.\n");
+      goto destroy;
+    }
+
+  for (i = 0; i < non_vm_argc; i++)
+    {
+      str = (*env)->NewStringUTF (env, non_vm_argv[i]);
+      if (str == NULL)
+	{
+	  fprintf (stderr, TOOLNAME ": NewStringUTF failed.\n");
+	  goto destroy;
+	}
+
+      (*env)->SetObjectArrayElement (env, args_array, i, str);
+    }
+
+  class_id = (*env)->FindClass (env, "gnu/classpath/tools/" TOOLPACKAGE "/Main");
+  if (class_id == NULL)
+    {
+      fprintf (stderr, TOOLNAME ": FindClass failed.\n");
+      goto destroy;
+    }
+
+  method_id = (*env)->GetStaticMethodID (env, class_id, "main", "([Ljava/lang/String;)V");
+
+  if (method_id == NULL)
+    {
+      fprintf (stderr, TOOLNAME ": GetStaticMethodID failed.\n");
+      goto destroy;
+    }
+
+  (*env)->CallStaticVoidMethod (env, class_id, method_id, args_array);
+
+ destroy:
+
+  if (env != NULL)
+    {
+      if ((*env)->ExceptionOccurred (env))
+	(*env)->ExceptionDescribe (env);
+
+      if (jvm != NULL)
+	(*jvm)->DestroyJavaVM (jvm);
+    }
+
+  return 1;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/Makefile.am?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/Makefile.am (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/Makefile.am Thu Nov  8 16:56:19 2007
@@ -0,0 +1,4 @@
+# used by automake to generate Makefile.in
+
+
+SUBDIRS = reference

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/Makefile.am?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/Makefile.am (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/Makefile.am Thu Nov  8 16:56:19 2007
@@ -0,0 +1,3 @@
+# used by automake to generate Makefile.in
+
+SUBDIRS = java gnu

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/VMStackWalker.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/VMStackWalker.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/VMStackWalker.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/VMStackWalker.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,116 @@
+/* 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 at 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];
+  }
+
+  /**
+   * 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]);
+  }
+
+  /**
+   * 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);
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/VMSystemProperties.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/VMSystemProperties.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/VMSystemProperties.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/VMSystemProperties.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,97 @@
+/* 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)
+    {
+    }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMFrame.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMFrame.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMFrame.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMFrame.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,106 @@
+/* VMFrame.java -- Reference implementation of VM hooks for JDWP Frame access.
+   Copyright (C) 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
+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.jdwp;
+
+import gnu.classpath.jdwp.util.Location;
+
+/**
+ * Reference implementation of VM hooks for JDWP Frame access.
+ * 
+ * @author aluchko 
+ */
+
+public class VMFrame
+{
+  /**
+   * Returns the size of a frame ID over JDWP
+   */
+  public static final int SIZE = 8;
+
+  // The object this frame resides in
+  private Object obj;
+  
+  // The current location of this frame
+  private Location loc;
+  
+  // id of this frame
+  private long id;
+  
+  /**
+   * Gets the current location of the frame.
+   */
+  public Location getLocation()
+  {
+    return loc;
+  }
+
+  /**
+   * Returns the value of the variable in the given slot.
+   * 
+   * @param slot the slot containing the variable
+   */
+  public native Object getValue(int slot);
+
+  /**
+   * Assigns the given variable to the given value. 
+   * @param slot The slot which contains the variable
+   * @param value The value to assign the variable to
+   */
+  public native void setValue(int slot, Object value);
+
+  /**
+   * Get the object which is represented by 'this' in the context of the frame,
+   * returns null if the method is native or static.
+   */
+  public Object getObject()
+  {
+    return obj;
+  }
+
+  /**
+   * Get the frameID
+   * @return an id which is unique within the scope of the VM
+   */
+  public long getId()
+  {
+    return id;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMIdManager.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMIdManager.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMIdManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMIdManager.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,427 @@
+/* VMIdManager.java -- A reference/example implementation of a manager for
+   JDWP object/reference type IDs
+
+   Copyright (C) 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
+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.jdwp;
+
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.id.*;
+
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.SoftReference;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Hashtable;
+
+/**
+ * This class manages objects and referencetypes that are reported
+ * to the debugger. All objects and referencetypes reported to the
+ * debugger should go through this manager.
+ *
+ * A brief summary of what an <code>IdManager</code> must provide:
+ *
+ * <code>
+ * public ObjectId getObjectId (Object theObject);
+ * public ObjectId get (long id);
+ * public ObjectId readObjectId (ByteBuffer bb);
+ * public ReferenceTypeId getReferenceTypeId (Class clazz);
+ * public ReferenceTypeId getReferenceType (long id);
+ * public ReferenceTypeId readReferenceTypeId (ByteBuffer bb);
+ * </code>
+ *
+ * See the javadoc on these methods later in this file for more
+ * information on these functions.
+ *
+ * <b>NOTE:</b> All IDs handled by the ID manager (all object and reference
+ * type IDs) are assumed to be of type <code>long</code>.
+ *
+ * <b>NOTE:</b> This class does not manage virtual machine-specific types,
+ * like methods, fields, and frames. These already have unique IDs within
+ * the virtual machine and do not need further abstraction here.
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class VMIdManager
+{
+  // This factory generates ids for objects and types that may
+  // be sent to a debugger.
+  private static class IdFactory
+  {
+    // ID of last object / referencetype
+    private static Object _idLock = new Object ();
+    private static Object _ridLock = new Object ();
+    private static long _lastId = 0;
+    private static long _lastRid = 0;
+
+    // A list of all ID types
+    private static HashMap _idList = new HashMap ();
+
+    // Initialize the id list with known types
+    static
+    {
+      // ObjectId and ArrayId are special cases. See newObjectId.
+      _idList.put (ClassLoaderId.typeClass, ClassLoaderId.class);
+      _idList.put (ClassObjectId.typeClass, ClassObjectId.class);
+      _idList.put (StringId.typeClass, StringId.class);
+      _idList.put (ThreadId.typeClass, ThreadId.class);
+      _idList.put (ThreadGroupId.typeClass, ThreadGroupId.class);
+    }
+
+    /**
+     * Returns a new id for the given object
+     *
+     * @param obj  SoftReference of the object for which an id is desired
+     * @returns a suitable object id
+     */
+    public static ObjectId newObjectId (SoftReference obj)
+    {
+      ObjectId id = null;
+      Object object = obj.get ();
+
+      // Special case: arrays
+      if (object.getClass ().isArray ())
+	id = new ArrayId ();
+      else
+	{
+	  // Loop through all classes until we hit baseclass
+	  Class myClass;
+	  for (myClass = object.getClass (); myClass != null;
+	       myClass = myClass.getSuperclass ())
+	    {
+	      Class clz = (Class) _idList.get (myClass);
+	      if (clz != null)
+		{
+		  try
+		    {
+		      id = (ObjectId) clz.newInstance ();
+		      synchronized (_idLock)
+			{
+			  id.setId (++_lastId);
+			}
+		      id.setReference (obj);
+		      return id;
+		    }
+		  catch (InstantiationException ie)
+		    {
+		      // This really should not happen
+		      throw new RuntimeException ("cannot create new ID", ie);
+		    }
+		  catch (IllegalAccessException iae)
+		    {
+		      // This really should not happen
+		      throw new RuntimeException ("illegal access of ID", iae);
+		    }
+		}
+	    }
+
+	  /* getSuperclass returned null and no matching ID type found.
+	     So it must derive from Object. */
+	  id = new ObjectId ();
+	}
+
+      synchronized (_idLock)
+	{
+	  id.setId (++_lastId);
+	}
+      id.setReference (obj);
+      return id;
+    }
+
+    /**
+     * Returns a new reference type id for the given class
+     *
+     * @param ref  SoftReference to the desired type
+     * @returns a suitable reference type id or null when the
+     * reference is cleared.
+     */
+    public static ReferenceTypeId newReferenceTypeId (SoftReference ref)
+    {
+      ReferenceTypeId id;
+      Class clazz = (Class) ref.get ();
+      if (clazz == null)
+	return null;
+
+      if (clazz.isArray ())
+	id = new ArrayReferenceTypeId ();
+      else if (clazz.isInterface ())
+	id = new InterfaceReferenceTypeId ();
+      else
+	id = new ClassReferenceTypeId ();
+      id.setReference (ref);
+      synchronized (_ridLock)
+	{
+	  id.setId (++_lastRid);
+	}
+      return id;
+    }
+  }
+
+  /**
+   * This class is a SoftReferenceIdentity type that is used by
+   * the ID manager.
+   */
+  class ReferenceKey extends SoftReference
+  {
+    // Hash code of referent
+    private int _hash;
+
+    /**
+     * Constructs a new <code>ReferenceKey</code> object
+     * with the given referent.
+     *
+     * <p>This constructor should only be used for object lookups
+     * by the backend.
+     *
+     * @param referent  the object to reference
+     */
+    public ReferenceKey (Object referent)
+    {
+      super (referent);
+      _hash = referent.hashCode ();
+    }
+    
+    /**
+     * Constructs a new <code>ReferenceKey</code> object
+     * with the given referent and reference queue.
+     *
+     * <p>The JDWP back-end stores a <code>ReferenceKey</code>
+     * with its corresponding <code>JdwpId</code>. This constructor
+     * is used by the back-end when adding new IDs to be managed.
+     *
+     * @param referent  the object to reference
+     * @param queue     the queue to which to report garbage collections
+     */
+    public ReferenceKey (Object referent, ReferenceQueue queue)
+    {
+      super (referent, queue);
+      _hash = referent.hashCode ();
+    }
+    
+    /**
+     * Returns the hash code of the referent.
+     * This seems hacky, but is required in order to use this class
+     * as a hash table key.
+     *
+     * @returns the hash code of the referent
+     */
+    public int hashCode ()
+    {
+      return _hash;
+    }
+
+    /**
+     * Comparator for keys
+     *
+     * This method can be used in two ways:
+     *
+     * <ol>
+     *    <li>For table lookups, where we want to compare referents</li>
+     *    <li>For clearing GCd objects, where we want to compare the actual
+     *        key object (not the referent)</li>
+     * </ol>
+     */
+    public boolean equals (Object obj)
+    {
+      if (obj instanceof ReferenceKey)
+	{
+	  ReferenceKey ref = (ReferenceKey) obj;
+	  
+	  /* First check if the two references are the same.
+	     If they are, that means we must be clearing GCd objects. */
+	  if (this == obj)
+	    return true;
+	  
+	  return (ref.get () == get ());
+	}
+      
+      return false;
+    }
+  }
+  
+  // instance of VMIdManager
+  private static VMIdManager _idm = new VMIdManager ();
+
+  // A reference queue for our objects
+  private ReferenceQueue _refQueue;
+
+  // Mapping of objects (ReferenceKey) to IDs (ObjectId)
+  private Hashtable _oidTable;
+
+  // Mapping of ID numbers (Long) to IDs (ObjectId)
+  private Hashtable _idTable;
+
+  /* Mapping of class (ReferenceKey) to IDs (ReferenceTypeId) for reference
+     types. Unlike other types, reference id types are NEVER released. */
+  private Hashtable _classTable;
+
+  // Mapping of ID numbers (Long) to reference type IDs (ReferenceTypeId)
+  private Hashtable _ridTable;
+
+  /**
+   * Gets the instance of VMIdManager, constructing a new one
+   * if none currently exists.
+   */
+  public static VMIdManager getDefault ()
+  {
+    return _idm;
+  }
+
+  // Constructs a new <code>IdManager</code>
+  private VMIdManager ()
+  {
+    _refQueue = new ReferenceQueue ();
+    _oidTable = new Hashtable (50);
+    _idTable = new Hashtable (50);
+    _classTable = new Hashtable (20);
+    _ridTable = new Hashtable (20);
+  }
+
+  // Updates the object ID table, removing IDs whose objects have
+  // been garbage collected.
+  private void _update ()
+  {
+    Reference ref;
+    while ((ref = _refQueue.poll ()) != null)
+      {
+	ObjectId id = (ObjectId) _oidTable.get (ref);
+	_oidTable.remove (ref);
+	_idTable.remove (new Long (id.getId ()));
+      }
+  }
+
+  /**
+   * Returns an id for the given object, adding it
+   * if it does not have an id.
+   *
+   * @param theObject  the object to get an ID/add
+   * @returns  the ID of the object
+   */
+  public ObjectId getObjectId (Object theObject)
+  {
+    ReferenceKey ref = new ReferenceKey (theObject, _refQueue);
+    ObjectId id = (ObjectId) _oidTable.get (ref);
+    if (id == null)
+      {
+	// update the tables -- this is an arbitrary place to put this
+	_update ();
+
+	// Object not found. Make new id for it
+	id = IdFactory.newObjectId (ref);
+	_oidTable.put (ref, id);
+	_idTable.put (new Long (id.getId ()), id);
+      }
+
+    return id;
+  }
+
+  /**
+   * Returns the <code>JdwpId</code> for a given ID. Unlike
+   * <code>getId</code>, it throws an exception if the ID is not
+   * known.
+   *
+   * @param id  the numerical ID of the desired <code>JdwpId</code>
+   * @throws InvalidObjectException if the ID is not found
+   */
+  public ObjectId get (long id)
+    throws InvalidObjectException
+  {
+    ObjectId oid = (ObjectId) _idTable.get (new Long (id));
+    if (oid == null)
+      throw new InvalidObjectException (id);
+ 
+    return oid;
+  }
+
+  public ObjectId readObjectId (ByteBuffer bb)
+    throws InvalidObjectException
+  {
+    long id = bb.getLong ();
+    return get (id);
+  }
+
+  /**
+   * Gets the reference type id for the given class, creating
+   * a new one if it does not already have an id
+   *
+   * @param clazz  the class for which to get an ID
+   * @returns  the ID of the class
+   */
+  public ReferenceTypeId getReferenceTypeId (Class clazz)
+  {
+    ReferenceKey ref = new ReferenceKey (clazz);
+    ReferenceTypeId id = (ReferenceTypeId)_classTable.get (ref);
+    if (id == null)
+      {
+	// Object not found. Make new id for it
+	id = IdFactory.newReferenceTypeId (ref);
+	_classTable.put (ref, id);
+	_ridTable.put (new Long (id.getId ()), id);
+      }
+
+    return id;
+  }
+
+  /**
+   * Returns the <code>ReferenceTypeId</code> for a given ID. Unlike
+   * <code>getReferenceTypeId</code>, it throws an exception if the ID is not
+   * known.
+   *
+   * @param id  the numerical ID of the desired reference type
+   * @throws InvalidClassException if the ID is not found
+   */
+  public ReferenceTypeId getReferenceType (long id)
+    throws InvalidClassException
+  {
+    ReferenceTypeId rid = (ReferenceTypeId) _ridTable.get (new Long (id));
+    if (rid == null)
+      throw new InvalidClassException (id);
+ 
+    return rid;
+  }
+
+  public ReferenceTypeId readReferenceTypeId (ByteBuffer bb)
+    throws InvalidClassException
+  {
+    long id = bb.getLong ();
+    return getReferenceType (id);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMMethod.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMMethod.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMMethod.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMMethod.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,178 @@
+/* VMMethod.java -- a method in a virtual machine
+   Copyright (C) 2006 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
+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.jdwp;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.util.LineTable;
+import gnu.classpath.jdwp.util.VariableTable;
+
+/**
+ * This class is really an amalgamation of two classes: one class
+ * represents a virtual machine method and the other represents
+ * the JDWP back-end's ID for the method.
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class VMMethod
+{
+  /**
+   * Returns the size of a JDWP method ID
+   * @see gnu.classpath.jdwp.id.JdwpId#SIZE
+   */
+   public static final int SIZE = 8;
+
+  // The class in which this method is declared
+  private Class _class;
+
+  // The method's ID
+  private long _methodId;
+
+  /**
+   * Constructs a new VMMethod object. This constructor is protected
+   * so that only the factory methods of VMVirtualMachine can be used
+   * to create VMMethods.
+   *
+   * @param klass the method's containing class
+   * @param id    method identifier, e.g., jmethodID
+   * @see gnu.classpath.jdwp.VMVirtualMachine#getAllClassMethods
+   * @see gnu.classpath.jdwp.VMVirtualMachine#getClassMethod
+   */
+  protected VMMethod(Class klass, long id)
+  {
+    _class = klass;
+    _methodId = id;
+  }
+
+  /**
+   * Returns the internal method ID for this method
+   */
+  public long getId()
+  {
+    return _methodId;
+  }
+
+  /**
+   * Returns the method's declaring class
+   */
+  public Class getDeclaringClass()
+  {
+    return _class;
+  }
+
+  /**
+   * Returns the name of this method
+   */
+  public native String getName();
+
+  /**
+   * Returns the signature of this method
+   */
+  public native String getSignature();
+
+  /**
+   * Returns the method's modifier flags
+   */
+  public native int getModifiers();
+
+  /**
+   * "Returns line number information for the method, if present. The line
+   * table maps source line numbers to the initial code index of the line.
+   * The line table is ordered by code index (from lowest to highest). The
+   * line number information is constant unless a new class definition is
+   * installed using RedefineClasses."
+   *
+   * @return the line table
+   * @throws JdwpException
+   */
+  public native LineTable getLineTable()
+    throws JdwpException;
+
+  /**
+   * "Returns variable information for the method. The variable table
+   * includes arguments and locals declared within the method. For instance
+   * methods, the "this" reference is included in the table. Also, synthetic
+   * variables may be present."
+   *
+   * @return the variable table
+   * @throws JdwpException
+   */
+  public native VariableTable getVariableTable()
+    throws JdwpException;
+
+  /**
+   * Returns a string representation of this method (not
+   * required but nice for debugging).
+   */
+  public String toString()
+  {
+    return getDeclaringClass().getName() + "." + getName();
+  }
+
+  /**
+   * Writes the method's ID to the output stream
+   *
+   * @param ostream the output stream to which to write
+   * @throws IOException for any errors writing to the stream
+   * @see gnu.classpath.jdwp.id.JdwpId#write
+   */
+  public void writeId(DataOutputStream ostream)
+    throws IOException
+  {
+    ostream.writeLong(getId());
+  }
+
+  /**
+   * Returns a VMMethod from the ID in the byte buffer
+   *
+   * @param klass the method's declaring class
+   * @param bb    a ByteBuffer containing the method's ID
+   * @throws JdwpException for any errors creating the method
+   * @throws IOException for any errors reading from the buffer
+   */
+  public static VMMethod readId(Class klass, ByteBuffer bb)
+    throws JdwpException, IOException
+  {
+    return VMVirtualMachine.getClassMethod(klass, bb.getLong());
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,329 @@
+/* VMVirtualMachine.java -- A reference implementation of a JDWP virtual
+   machine
+
+   Copyright (C) 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
+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.jdwp;
+
+import gnu.classpath.jdwp.event.EventRequest;
+import gnu.classpath.jdwp.exception.InvalidMethodException;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.util.MethodResult;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * A virtual machine according to JDWP.
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class VMVirtualMachine
+{
+  /**
+   * Suspend a thread
+   *
+   * @param  thread  the thread to suspend
+   */
+  public static native void suspendThread (Thread thread)
+    throws JdwpException;
+
+  /**
+   * Suspend all threads
+   */
+  public static void suspendAllThreads ()
+    throws JdwpException
+  {
+    // Our JDWP thread group -- don't suspend any of those threads
+    Thread current = Thread.currentThread ();
+    ThreadGroup jdwpGroup = Jdwp.getDefault().getJdwpThreadGroup();
+
+    // Find the root ThreadGroup
+    ThreadGroup group = jdwpGroup;
+    ThreadGroup parent = group.getParent ();
+    while (parent != null)
+      {
+	group = parent;
+	parent = group.getParent ();
+      }
+    
+    // Get all the threads in the system
+    int num = group.activeCount ();
+    Thread[] threads = new Thread[num];
+    group.enumerate (threads);
+
+    for (int i = 0; i < num; ++i)
+      {
+	Thread t = threads[i];
+	if (t != null)
+	  {
+	    if (t.getThreadGroup () == jdwpGroup || t == current)
+	      {
+		// Don't suspend the current thread or any JDWP thread
+		continue;
+	      }
+	    else
+	      suspendThread (t);
+	  }
+      }
+
+    // Now suspend the current thread
+    if (current.getThreadGroup() != jdwpGroup)
+      suspendThread (current);
+  }
+
+  /**
+   * Resume a thread. A thread must be resumed as many times
+   * as it has been suspended.
+   *
+   * @param  thread  the thread to resume
+   */
+  public static native void resumeThread (Thread thread)
+    throws JdwpException;
+
+  /**
+   * Resume all threads. This simply decrements the thread's
+   * suspend count. It can not be used to force the application
+   * to run.
+   */
+  public static void resumeAllThreads ()
+    throws JdwpException
+  {
+    // Our JDWP thread group -- don't resume
+    Thread current = Thread.currentThread ();
+    ThreadGroup jdwpGroup = current.getThreadGroup ();
+
+    // Find the root ThreadGroup
+    ThreadGroup group = jdwpGroup;
+    ThreadGroup parent = group.getParent ();
+    while (parent != null)
+      {
+	group = parent;
+	parent = group.getParent ();
+      }
+    
+    // Get all the threads in the system
+    int num = group.activeCount ();
+    Thread[] threads = new Thread[num];
+    group.enumerate (threads);
+
+    for (int i = 0; i < num; ++i)
+      {
+	Thread t = threads[i];
+	if (t != null)
+	  {
+	    if (t.getThreadGroup () == jdwpGroup || t == current)
+	      {
+		// Don't resume the current thread or any JDWP thread
+		continue;
+	      }
+	    else
+	      resumeThread (t);
+	  }
+      }
+  }
+
+  /**
+   * Get the suspend count for a give thread
+   *
+   * @param  thread  the thread whose suspend count is desired
+   * @return the number of times the thread has been suspended
+   */
+  public static native int getSuspendCount (Thread thread)
+    throws JdwpException;
+ 
+  /**
+   * Returns a count of the number of loaded classes in the VM
+   */
+  public static native int getAllLoadedClassesCount ()
+    throws JdwpException;
+
+  /**
+   * Returns an iterator over all the loaded classes in the VM
+   */
+  public static native Iterator getAllLoadedClasses ()
+    throws JdwpException;
+
+  /**
+   * Returns the status of the given class
+   *
+   * @param  clazz  the class whose status is desired
+   * @return a flag containing the class's status
+   * @see JdwpConstants.ClassStatus
+   */
+  public static native int getClassStatus (Class clazz)
+    throws JdwpException;
+
+  /**
+   * Returns all of the methods defined in the given class. This
+   * includes all methods, constructors, and class initializers.
+   *
+   * @param  klass  the class whose methods are desired
+   * @return an array of virtual machine methods
+   */
+  public static native VMMethod[] getAllClassMethods (Class klass)
+    throws JdwpException;
+
+  /**
+   * A factory method for getting valid virtual machine methods
+   * which may be passed to/from the debugger.
+   *
+   * @param klass the class in which the method is defined
+   * @param id    the ID of the desired method
+   * @return the desired internal representation of the method
+   * @throws InvalidMethodException if the method is not defined
+   *           in the class
+   * @throws JdwpException for any other error
+   */
+  public static native VMMethod getClassMethod(Class klass, long id)
+    throws JdwpException;
+
+  /**
+   * Returns the thread's call stack
+   *
+   * @param  thread  thread for which to get call stack
+   * @param  start   index of first frame to return
+   * @param  length  number of frames to return (-1 for all frames)
+   * @return a list of frames
+   */
+  public static native ArrayList getFrames (Thread thread, int start,
+					    int length)
+    throws JdwpException;
+
+  /**
+   * Returns the frame for a given thread with the frame ID in
+   * the buffer
+   *
+   * I don't like this.
+   *
+   * @param  thread  the frame's thread
+   * @param  bb      buffer containing the frame's ID
+   * @return the desired frame
+   */
+  public static native VMFrame getFrame (Thread thread, ByteBuffer bb)
+    throws JdwpException;
+
+  /**
+   * Returns the number of frames in the thread's stack
+   *
+   * @param  thread  the thread for which to get a frame count
+   * @return the number of frames in the thread's stack
+   */
+  public static native int getFrameCount (Thread thread)
+    throws JdwpException;
+
+
+  /**
+   * Returns the status of a thread
+   *
+   * @param  thread  the thread for which to get status
+   * @return integer status of the thread
+   * @see JdwpConstants.ThreadStatus
+   */
+  public static native int getThreadStatus (Thread thread)
+    throws JdwpException;
+
+  /**
+   * Returns a list of all classes which this class loader has been
+   * requested to load
+   *
+   * @param  cl  the class loader
+   * @return a list of all visible classes
+   */
+  public static native ArrayList getLoadRequests (ClassLoader cl)
+    throws JdwpException;
+
+  /**
+   * Executes a method in the virtual machine
+   *
+   * @param  obj         instance in which to invoke method (null for static)
+   * @param  thread      the thread in which to invoke the method
+   * @param  clazz       the class in which the method is defined
+   * @param  method      the method to invoke
+   * @param  values      arguments to pass to method
+   * @param  nonVirtual  "otherwise, normal virtual invoke
+   *                     (instance methods only) "
+   * @return a result object containing the results of the invocation
+   */
+  public static native MethodResult executeMethod (Object obj, Thread thread,
+					    Class clazz, Method method,
+					    Object[] values,
+					    boolean nonVirtual)
+    throws JdwpException;
+
+  /**
+   * "Returns the name of source file in which a reference type was declared"
+   *
+   * @param  clazz  the class for which to return a source file
+   * @return a string containing the source file name; "no path information
+   *         for the file is included"
+   */
+  public static native String getSourceFile (Class clazz)
+    throws JdwpException;
+
+  /**
+   * Register a request from the debugger
+   *
+   * Virtual machines have two options. Either do nothing and allow
+   * the event manager to take care of the request (useful for broadcast-type
+   * events like class prepare/load/unload, thread start/end, etc.)
+   * or do some internal work to set up the event notification (useful for
+   * execution-related events like breakpoints, single-stepping, etc.).
+   */
+  public static native void registerEvent (EventRequest request)
+    throws JdwpException;
+
+  /**
+   * Unregisters the given request
+   *
+   * @param  request  the request to unregister
+   */
+  public static native void unregisterEvent (EventRequest request)
+    throws JdwpException;
+
+
+  /**
+   * Clear all events of the given kind
+   *
+   * @param  kind  the type of events to clear
+   */
+  public static native void clearEvents (byte kind)
+    throws JdwpException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/VMInstrumentationImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/VMInstrumentationImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/VMInstrumentationImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/VMInstrumentationImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,108 @@
+/* VMInstrumentationImpl.java -- interface for the GNU implementation
+   of InstrumentationImpl
+   Copyright (C) 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 gnu.java.lang;
+
+import java.lang.instrument.ClassDefinition;
+import java.lang.instrument.Instrumentation;
+
+/**
+ * @author Nicolas Geoffray (nicolas.geoffray at menlina.com)
+ * @since 1.5
+ */
+final class VMInstrumentationImpl
+{
+ 
+  /**
+   * Returns if the current JVM supports class redefinition
+   * 
+   * @return true if the current JVM supports class redefinition
+   */
+  static native boolean isRedefineClassesSupported();
+    
+  /**
+   * Redefines classes given as parameters. The method has to call
+   * the callTransformers from InstrumentationImpl
+   *
+   * @param inst an instrumentation object
+   * @param definitions an array of bytecode<->class correspondance
+   *
+   * @throws ClassNotFoundException if a class cannot be found 
+   * @throws UnmodifiableClassException if a class cannot be modified 
+   * @throws UnsupportedOperationException if the JVM does not support
+   * redefinition or the redefinition made unsupported changes
+   * @throws ClassFormatError if a class file is not valid
+   * @throws NoClassDefFoundError if a class name is not equal to the name
+   * in the class file specified
+   * @throws UnsupportedClassVersionError if the class file version numbers
+   * are unsupported
+   * @throws ClassCircularityError if circularity occured with the new
+   * classes
+   * @throws LinkageError if a linkage error occurs 
+   */
+  static native void redefineClasses(Instrumentation inst,
+      ClassDefinition[] definitions);
+ 
+  /**
+   * Get all the classes loaded by the JVM.
+   * 
+   * @return an array containing all the classes loaded by the JVM. The array
+   * is empty if no class is loaded.
+   */
+  static native Class[] getAllLoadedClasses();
+
+  /**
+   * Get all the classes loaded by a given class loader
+   * 
+   * @param loader the loader
+   * 
+   * @return an array containing all the classes loaded by the given loader.
+   * The array is empty if no class was loaded by the loader.
+   */
+  static native Class[] getInitiatedClasses(ClassLoader loader);
+
+  /**
+   * Get the size of an object. The object is not null
+   * 
+   * @param objectToSize the object
+   * @return the size of the object
+   */
+  static native long getObjectSize(Object objectToSize);
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* VMClassLoadingMXBeanImpl.java - VM impl. of a class loading 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;
+
+/**
+ * Provides access to information about the class loading 
+ * behaviour of the current invocation of the virtual
+ * machine.  Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getClassLoadingMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+final class VMClassLoadingMXBeanImpl
+{
+
+  /**
+   * Returns the number of classes currently loaded by
+   * the virtual machine.
+   *
+   * @return the number of loaded classes.
+   */
+  static native int getLoadedClassCount();
+
+  /**
+   * Returns the number of classes that have been unloaded
+   * by the virtual machine since it was started.
+   *
+   * @return the number of unloaded classes.
+   */
+  static native long getUnloadedClassCount();
+
+  /**
+   * Returns true if the virtual machine will emit additional
+   * information when classes are loaded and unloaded.  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 classes are loaded and unloaded.  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);
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,66 @@
+/* VMCompilationMXBeanImpl.java - VM implementation of a compilation 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;
+
+/**
+ * Provides access to information about the JIT 
+ * compiler of the virtual machine, if one exists.
+ * Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getCompilationMXBean()},
+ * if this is the case.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+final class VMCompilationMXBeanImpl
+{
+
+  /**
+   * Returns the number of milliseconds the JIT
+   * compiler has spent compiling Java bytecode
+   * to native machine code.  This is only called
+   * if a JIT compiler exists and the
+   * gnu.java.lang.management.CompilationTimeSupport
+   * property has been set.
+   *
+   * @return the number of milliseconds spent
+   *         compiling.
+   */
+  static native long getTotalCompilationTime();
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,80 @@
+/* VMGarbageCollectorMXBeanImpl.java - VM interface for a GC 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;
+
+/**
+ * Provides access to information about the garbage collectors
+ * of the virtual machine.  Garbage collectors are responsible
+ * for removing unreferenced objects from memory.  A garbage
+ * collector is a type of memory manager, so this interface
+ * is combined with that of generic memory managers.  An instance
+ * of this bean for each garbage collector is obtained by calling
+ * {@link ManagementFactory#getGarbageCollectorMXBeans()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+final class VMGarbageCollectorMXBeanImpl
+{
+
+  /**
+   * Returns the number of collections the garbage collector
+   * represented by this bean has made.  -1 is returned if the
+   * collection count is undefined.
+   *
+   * @param name the name of the garbage collector.
+   * @return the number of collections made, or -1 if this is
+   *         undefined.
+   */
+  static native long getCollectionCount(String name);
+
+  /**
+   * Returns the accumulated number of milliseconds this garbage
+   * collector has spent freeing the memory used by unreferenced
+   * objects.  -1 is returned if the collection time is undefined.
+   * Note that the accumulated time may not change, even when the
+   * collection count increases, if the time taken is sufficiently
+   * short; this depends on the resolution of the timer used.
+   * 
+   * @param name the name of the garbage collector.
+   * @return the accumulated number of milliseconds spent collecting,
+   *         or -1 if this is undefined.
+   */
+  static native long getCollectionTime(String name);
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,109 @@
+/* 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 at 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());
+  }
+
+  /**
+   * 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);
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,95 @@
+/* VMMemoryManagerMXBeanImpl.java - VM interface for a memory manager 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.ManagementFactory;
+import java.lang.management.MemoryPoolMXBean;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Provides access to information about the memory managers
+ * of the virtual machine.  An instance of this bean for each
+ * memory manager is obtained by calling
+ * {@link ManagementFactory#getMemoryManagerMXBeans()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+final class VMMemoryManagerMXBeanImpl
+{
+
+  /** 
+   * Returns an array containing the names of the memory pools
+   * this memory manager manages.
+   * 
+   * @param name the name of the memory manager.
+   * @return an array containing the name of each memory pool
+   *         this manager is responsible for.
+   */
+  static String[] getMemoryPoolNames(String name)
+  {
+    List managedPools = new ArrayList();
+    Iterator beans = ManagementFactory.getMemoryPoolMXBeans().iterator();
+    while (beans.hasNext())
+      {
+	MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next();
+	String[] managers = bean.getMemoryManagerNames();
+	for (int a = 0; a < managers.length; ++a)
+	  if (managers[a].equals(name))
+	    {
+	      managedPools.add(bean.getName());
+	      break;
+	    }
+      }
+    return (String[]) managedPools.toArray(new String[managedPools.size()]);
+  }
+
+  /**
+   * Returns true if this memory manager is still valid.  A memory
+   * manager becomes invalid when it is removed by the virtual machine
+   * and no longer used.
+   *
+   * @param name the name of the memory manager.
+   * @return true if this memory manager is valid.
+   */
+  static native boolean isValid(String name);
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,195 @@
+/* MemoryPoolMXBeanImpl.java - VM interface for memory pool beans
+   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 on the memory resources or
+ * pools used by the current invocation of the virtual machine.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+final class VMMemoryPoolMXBeanImpl
+{
+
+  /**
+   * Returns memory usage statistics for the specified pool
+   * just after a best-effort attempt to free memory.  This
+   * is valid only for certain garbage collectors.
+   *
+   * @param name the name of the pool to obtain statistics on.
+   * @return a {@link java.lang.management.MemoryUsage} object
+   *         containing the statistics or <code>null</code>
+   *         if this pool does not support such statistics.
+   */
+  static native MemoryUsage getCollectionUsage(String name);
+
+  /**
+   * Returns the collection usage threshold for the specified pool.
+   * This is only called if this functionality is supported
+   * by the virtual machine (i.e. the appropriate property,
+   * <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
+   * is defined).  The value is initially zero.
+   *
+   * @param name the name of the pool to obtain statistics on.
+   * @return the collection usage threshold.
+   */
+  static native long getCollectionUsageThreshold(String name);
+
+  /**
+   * Returns the number of times the collection usage threshold
+   * has been met or exceeded by the specified pool.
+   * This is only called if this functionality is supported
+   * by the virtual machine (i.e. the appropriate property,
+   * <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
+   * is defined).
+   *
+   * @param name the name of the pool to obtain statistics on.
+   * @return the collection usage threshold count.
+   */
+  static native long getCollectionUsageThresholdCount(String name);
+
+  /**
+   * Returns an array of names of memory managers which manage
+   * the specified pool.
+   *
+   * @param name the name of the pool to obtain statistics on.
+   * @return a list of memory managers for the pool.
+   */
+  static native String[] getMemoryManagerNames(String name);
+
+  /**
+   * Returns the peak usage level of the specified pool.
+   * This is only called if the pool is valid.
+   *
+   * @param name the name of the pool to obtain statistics on.
+   * @return a {@link java.lang.management.MemoryUsage} object
+   *         containing the statistics.
+   */
+  static native MemoryUsage getPeakUsage(String name);
+
+  /**
+   * Returns the type of memory used by the specified pool. 
+   * The value must be either "HEAP" or "NON_HEAP".
+   *
+   * @param name the name of the pool to obtain statistics on.
+   * @return the type of the given pool.
+   */
+  static native String getType(String name);
+
+  /**
+   * Returns the current usage level of the specified pool.
+   * This is only called if the pool is valid.
+   *
+   * @param name the name of the pool to obtain statistics on.
+   * @return a {@link java.lang.management.MemoryUsage} object
+   *         containing the statistics.
+   */
+  static native MemoryUsage getUsage(String name);
+
+  /**
+   * Returns the usage threshold for the specified pool.
+   * This is only called if this functionality is supported
+   * by the virtual machine (i.e. the appropriate property,
+   * <code>gnu.java.lang.management.UsageThresholdSupport</code>,
+   * is defined).  The value is initially defined by the
+   * virtual machine.
+   *
+   * @param name the name of the pool to obtain statistics on.
+   * @return the usage threshold.
+   */
+  static native long getUsageThreshold(String name);
+
+  /**
+   * Returns the number of times the usage threshold
+   * has been met or exceeded by the specified pool.
+   * This is only called if this functionality is supported
+   * by the virtual machine (i.e. the appropriate property,
+   * <code>gnu.java.lang.management.UsageThresholdSupport</code>,
+   * is defined).
+   *
+   * @param name the name of the pool to obtain statistics on.
+   * @return the usage threshold count.
+   */
+  static native long getUsageThresholdCount(String name);
+  
+  /**
+   * Returns true if the specified pool is still valid i.e.
+   * it is still in use by the virtual machine.
+   *
+   * @param name the name of the pool to check the validity of.
+   * @return true if the pool is valid.
+   */
+  static native boolean isValid(String name);
+  
+  /**
+   * Resets the peak usage level to the current usage level for
+   * the specified pool.
+   *
+   * @param name the name of the pool to reset the peak usage of.
+   */
+  static native void resetPeakUsage(String name);
+
+  /**
+   * Sets the collection usage threshold for the specified
+   * pool to the supplied value.
+   * This is only called if this functionality is supported
+   * by the virtual machine (i.e. the appropriate property,
+   * <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
+   * is defined). 
+   *
+   * @param name the name of the pool to set the threshold of.
+   * @param threshold the new threshold level.
+   */
+  static native void setCollectionUsageThreshold(String name, long threshold);
+
+  /**
+   * Sets the usage threshold for the specified pool to the supplied value.
+   * This is only called if this functionality is supported
+   * by the virtual machine (i.e. the appropriate property,
+   * <code>gnu.java.lang.management.UsageThresholdSupport</code>,
+   * is defined). 
+   *
+   * @param name the name of the pool to set the threshold of.
+   * @param threshold the new threshold level.
+   */
+  static native void setUsageThreshold(String name, long threshold);
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java Thu Nov  8 16:56:19 2007
@@ -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 at 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();
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,207 @@
+/* VMThreadMXBeanImpl.java - VM impl. of a thread 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.ThreadInfo;
+
+/**
+ * Provides access to information about the threads 
+ * of the virtual machine.  An instance of this bean is
+ * obtained by calling
+ * {@link ManagementFactory#getThreadMXBean()}.
+ * See {@link java.lang.management.ThreadMXBean} for
+ * full documentation.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+final class VMThreadMXBeanImpl
+{
+
+  /**
+   * Cache of how many threads were found.
+   */
+  private static int filled;
+
+  /**
+   * Returns the ids of cycles of deadlocked threads, occurring
+   * due to monitor ownership.
+   *
+   * @return the ids of the deadlocked threads.
+   */
+  static native long[] findMonitorDeadlockedThreads();
+
+  /* This is the same as in Thread.getAllStackTraces() */
+  static Thread[] getAllThreads()
+  {
+    ThreadGroup group = Thread.currentThread().getThreadGroup();
+    while (group.getParent() != null)
+      group = group.getParent();
+    int arraySize = group.activeCount();
+    Thread[] threadList = new Thread[arraySize];
+    filled = group.enumerate(threadList);
+    while (filled == arraySize)
+      {
+	arraySize *= 2;
+	threadList = new Thread[arraySize];
+	filled = group.enumerate(threadList);
+      }
+    return threadList;
+  }
+  
+  /**
+   * Returns the id of all live threads at the time of execution.
+   *
+   * @return the live thread ids.
+   */
+  static long[] getAllThreadIds()
+  {
+    Thread[] threadList = getAllThreads();
+    long[] ids = new long[filled];
+    for (int a = 0; a < filled; ++a)
+      ids[a] = threadList[a].getId();
+    return ids;
+  }
+
+  /**
+   * Returns the number of nanoseconds of CPU time
+   * the current thread has used in total.   This is
+   * only called if this feature is enabled and
+   * supported.
+   *
+   * @return the nanoseconds of CPU time used by
+   *         the current thread.
+   */
+  static native long getCurrentThreadCpuTime();
+
+  /**
+   * Returns the number of nanoseconds of user time
+   * the current thread has used in total.   This is
+   * only called if this feature is enabled and
+   * supported.
+   *
+   * @return the nanoseconds of user time used by
+   *         the current thread.
+   */
+  static native long getCurrentThreadUserTime();
+
+  /**
+   * Returns the number of live daemon threads.
+   *
+   * @return the number of live daemon threads.
+   */
+  static int getDaemonThreadCount()
+  {
+    Thread[] threadList = getAllThreads();
+    int daemonCount = 0;
+    for (int a = 0; a < filled; ++a)
+      {
+	if (threadList[a].isDaemon())
+	  ++daemonCount;
+      }
+    return daemonCount;
+  }
+
+  /**
+   * Returns the current peak number of live threads.
+   *
+   * @return the peak number of live threads.
+   */
+  static native int getPeakThreadCount();
+
+  /**
+   * Returns the number of live threads.
+   *
+   * @return the number of live threads.
+   */
+  static int getThreadCount()
+  {
+    getAllThreads();
+    return filled;
+  }
+
+  /**
+   * Returns the number of nanoseconds of CPU time
+   * the specified thread has used in total.   This is
+   * only called if this feature is enabled and
+   * supported.
+   *
+   * @param id the thread to obtain statistics on.
+   * @return the nanoseconds of CPU time used by
+   *         the thread.
+   */
+  static native long getThreadCpuTime(long id);
+
+  /**
+   * Returns the {@link java.lang.management.ThreadInfo}
+   * which corresponds to the specified id.
+   *
+   * @param id the id of the thread.
+   * @param maxDepth the depth of the stack trace.
+   * @return the corresponding <code>ThreadInfo</code>.
+   */
+  static native ThreadInfo getThreadInfoForId(long id, int maxDepth);
+  
+  /**
+   * Returns the number of nanoseconds of user time
+   * the specified thread has used in total.   This is
+   * only called if this feature is enabled and
+   * supported.
+   *
+   * @param id the thread to obtain statistics on.
+   * @return the nanoseconds of user time used by
+   *         the thread.
+   */
+  static native long getThreadUserTime(long id);
+  
+  /**
+   * Returns the total number of threads that have
+   * been started over the lifetime of the virtual
+   * machine.
+   *
+   * @return the total number of threads started.
+   */
+  static native long getTotalStartedThreadCount();
+
+  /**
+   * Resets the peak thread count to the current
+   * number of live threads.
+   */
+  static native void resetPeakThreadCount();
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,260 @@
+/* PlainDatagramSocketImpl.java -- VM interface for DatagramSocket impl
+   Copyright (C) 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 gnu.java.net;
+
+import gnu.classpath.Configuration;
+
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketAddress;
+import java.net.SocketException;
+
+/**
+ * The VM interface for {@link gnu.java.net.PlainDatagramSocketImpl}.
+ *
+ * @author Ingo Proetel (proetel at aicas.com)
+ * @author Roman Kennke (kennke at aicas.com)
+ */
+public final class VMPlainDatagramSocketImpl
+{
+  /**
+   * Option id for the IP_TTL (time to live) value.
+   */
+  static final int IP_TTL = 0x1E61; // 7777
+
+
+  // Static initializer to load native library
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+        System.loadLibrary("javanet");
+      }
+  }
+  
+  /**
+   * Binds this socket to a particular port and interface
+   *
+   * @param socket the socket object
+   * @param port the port to bind to
+   * @param addr the address to bind to
+   *
+   * @throws SocketException If an error occurs
+   */  
+  static native void bind(PlainDatagramSocketImpl socket, int port,
+                          InetAddress addr) 
+    throws SocketException;
+
+  /**
+   * Creates a new datagram socket.
+   *
+   * @param socket the socket object
+   *
+   * @throws SocketException If an error occurs
+   */
+  static native void create(PlainDatagramSocketImpl socket)
+    throws SocketException;
+
+  /**
+   * Connects to the remote address and port specified as arguments.
+   *
+   * @param socket the socket object
+   * @param addr the remote address to connect to
+   * @param port the remote port to connect to
+   *
+   * @throws SocketException If an error occurs
+   */
+  static native void connect(PlainDatagramSocketImpl socket, InetAddress addr,
+                             int port)
+    throws SocketException;
+
+  /**
+   * Sends a packet of data to a remote host.
+   *
+   * @param socket the socket object
+   * @param packet the packet to send
+   *
+   * @throws IOException If an error occurs
+   */
+  static void send(PlainDatagramSocketImpl socket, DatagramPacket packet)
+    throws IOException
+  {
+    nativeSendTo(socket, packet.getAddress(), packet.getPort(),
+                 packet.getData(), packet.getOffset(), packet.getLength());
+  }
+
+
+  /**
+   * Sends a packet of data to a remote host.
+   *
+   * @param socket the socket object
+   * @param addr the address to send to
+   * @param port the port to send to 
+   * @param buf the buffer to send
+   * @param offset the offset of the data in the buffer to send
+   * @param len the length of the data to send
+   *
+   * @throws IOException If an error occurs
+   */
+  private static native void nativeSendTo(PlainDatagramSocketImpl socket,
+                                          InetAddress addr, int port,
+                                          byte[] buf, int offset, int len)
+    throws IOException;
+
+  /**
+   * Receives a UDP packet from the network
+   *
+   * @param socket the socket object
+   * @param packet the packet to fill in with the data received
+   *
+   * @throws IOException IOException If an error occurs
+   */
+  static void receive(PlainDatagramSocketImpl socket, DatagramPacket packet)
+    throws IOException
+  {
+    byte[] receiveFromAddress = new byte[4];
+    int[] receiveFromPort = new int[1];
+    int[] receivedLength = new int[1];
+
+    nativeReceive(socket, packet.getData(), packet.getOffset(),
+                  packet.getLength(),
+                  receiveFromAddress, receiveFromPort, receivedLength);
+
+    packet.setAddress(InetAddress.getByAddress(receiveFromAddress));
+    packet.setPort(receiveFromPort[0]);
+    packet.setLength(receivedLength[0]);
+  }
+
+  private static native void nativeReceive(PlainDatagramSocketImpl socket,
+                                           byte[] buf, int offset, int len,
+                                           byte[] receiveFromAddress,
+                                           int[] receiveFromPort,
+                                           int[] receivedLength)
+    throws IOException;
+
+  /**
+   * Sets the value of an option on the socket
+   *
+   * @param socket the socket object
+   * @param optionId the identifier of the option to set
+   * @param value the value of the option to set
+   *
+   * @exception SocketException If an error occurs
+   */
+  static native void setOption(PlainDatagramSocketImpl socket, int optionId,
+                               Object value)
+    throws SocketException;
+
+  /**
+   * Retrieves the value of an option on the socket.
+   *
+   * @param socket the socket object
+   * @param optionId the identifier of the option to retrieve
+   *
+   * @return the value of the option
+   *
+   * @throws SocketException if an error occurs
+   */
+  static native Object getOption(PlainDatagramSocketImpl socket, int optionId)
+    throws SocketException;
+
+  /**
+   * Closes the socket.
+   *
+   * @param socket the socket object
+   */
+  static native void close(PlainDatagramSocketImpl socket);
+
+  /**
+   * Joins a multicast group
+   *
+   * @param addr The group to join
+   *
+   * @exception IOException If an error occurs
+   */
+  static native void join(PlainDatagramSocketImpl socket, InetAddress addr)
+    throws IOException;
+
+  /**
+   * Leaves a multicast group
+   *
+   * @param addr The group to leave
+   *
+   * @exception IOException If an error occurs
+   */
+  static native void leave(PlainDatagramSocketImpl socket, InetAddress addr)
+    throws IOException;
+
+  /**
+   * Joins a multicast group.
+   *
+   * @param socket the socket object
+   * @param address the socket address
+   * @param netIf the network interface
+   *
+   * @throws IOException if I/O errors occur
+   */
+  static void joinGroup(PlainDatagramSocketImpl socket, SocketAddress address,
+                        NetworkInterface netIf)
+    throws IOException
+  {
+    throw new InternalError
+      ("PlainDatagramSocketImpl::joinGroup is not implemented");
+  }
+
+  /**
+   * Leaves a multicast group.
+   *
+   * @param socket the socket object
+   * @param address the socket address
+   * @param netIf the network interface
+   *
+   * @throws IOException if I/O errors occur
+   */
+  static void leaveGroup(PlainDatagramSocketImpl socket, SocketAddress address,
+                         NetworkInterface netIf)
+    throws IOException
+  {
+    throw new InternalError
+      ("PlainDatagramSocketImpl::leaveGroup is not implemented");
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/net/VMPlainSocketImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/net/VMPlainSocketImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/net/VMPlainSocketImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/net/VMPlainSocketImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,314 @@
+/* VMPlainSocketImpl.java -- VM interface for default socket implementation
+   Copyright (C) 2005, 2006 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.net;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.SocketImpl;
+import java.net.SocketOptions;
+import java.net.UnknownHostException;
+
+import gnu.classpath.Configuration;
+
+/**
+ * The VM interface for {@link gnu.java.net.PlainSocketImpl}.
+ *
+ * @author Ingo Proetel (proetel at aicas.com)
+ * @author Roman Kennke (kennke at aicas.com)
+ */
+public final class VMPlainSocketImpl
+{
+  /**
+   * Static initializer to load native library.
+   */
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+        System.loadLibrary("javanet");
+      }
+  }
+
+  /**
+   * Sets the specified option on a socket to the passed in object.
+   * The optionId parameter is one of the defined constants in
+   * the SocketImpl interface.
+   *
+   * @param socket the socket object
+   * @param optionId the identifier of the option
+   * @param value the value to set the option to
+   *
+   * @throws SocketException if an error occurs
+   */
+  static native void setOption(PlainSocketImpl socket, int optionId, Object value)
+    throws SocketException;
+
+  /**
+   * Returns the current setting of the specified option. The optionId
+   * is one of the defined constants in this interface.
+   *
+   * @param socket the socket object
+   * @param optionId the option identifier
+   *
+   * @return the current value of the option
+   *
+   * @throws SocketException ff an error occurs
+   */
+  static native Object getOption(PlainSocketImpl socket, int optionId)
+    throws SocketException;
+
+  /**
+   * Creates a new socket that is not bound to any local address/port and
+   * is not connected to any remote address/port.
+   *
+   * @param socket the socket object
+   *
+   * @throws IOException if something goes wrong while creating the socket
+   */
+  static native void create(PlainSocketImpl socket) throws IOException;
+
+  /**
+   * Connects to the remote address and port specified as arguments.
+   *
+   * @param socket the socket object
+   * @param addr the remote address to connect to
+   * @param port the remote port to connect to
+   *
+   * @throws IOException if an error occurs
+   */
+  static native void connect(PlainSocketImpl socket, InetAddress addr,
+                             int port) throws IOException;
+
+  /**
+   * Binds to the specified port on the specified addr.  Note that this addr
+   * must represent a local IP address.  **** How bind to INADDR_ANY? ****
+   *
+   * @param socket the socket object
+   * @param addr the address to bind to
+   * @param port the port number to bind to
+   *
+   * @exception IOException If an error occurs
+   */
+  static native void bind(PlainSocketImpl socket, InetAddress addr, int port)
+    throws IOException;
+
+  /**
+   * Starts listening for connections on a socket. The queueLen parameter
+   * is how many pending connections will queue up waiting to be serviced
+   * before being accepted.  If the queue of pending requests exceeds this
+   * number, additional connections will be refused.
+   *
+   * @param socket the socket object
+   * @param queueLen the length of the pending connection queue
+   * 
+   * @exception IOException if an error occurs
+   */
+  static native void listen(PlainSocketImpl socket, int queueLen)
+    throws IOException;
+
+  /**
+   * Accepts a new connection on this socket.
+   *
+   * @param socket the socket object
+   * @param impl the socket object to accept this connection.
+   */
+  static native void accept(PlainSocketImpl socket, SocketImpl impl)
+    throws IOException;
+
+  /**
+   * Returns the number of bytes that the caller can read from this socket
+   * without blocking. 
+   *
+   * @param socket the socket object
+   *
+   * @return the number of readable bytes before blocking
+   *
+   * @throws IOException If an error occurs
+   */
+  static native int available(PlainSocketImpl socket) throws IOException;
+
+  /**
+   * Closes the socket.  This will cause any InputStream or OutputStream
+   * objects for this Socket to be closed as well.
+   *
+   * <p>
+   * Note that if the SO_LINGER option is set on this socket, then the
+   * operation could block.
+   * </p>
+   *
+   * @param socket the socket object
+   *
+   * @throws IOException if an error occurs
+   */
+  static native void close(PlainSocketImpl socket) throws IOException;
+
+  /**
+   * Internal method used by SocketInputStream for reading data from
+   * the connection.  Reads up to len bytes of data into the buffer
+   * buf starting at offset bytes into the buffer.
+   *
+   * @param socket the socket object
+   *
+   * @return the actual number of bytes read or -1 if end of stream.
+   *
+   * @throws IOException if an error occurs
+   */
+  static native int read(PlainSocketImpl socket, byte[] buf, int offset,
+                         int len) throws IOException;
+
+  /**
+   * Internal method used by SocketInputStream for reading data from
+   * the connection.  Reads and returns one byte of data.
+   *
+   * @param socket the socket object
+   *
+   * @return read byte or -1 if end of stream.
+   *
+   * @throws IOException if an error occurs
+   */
+  static int read(PlainSocketImpl socket) throws IOException
+  {
+    byte[] buf = new byte[1];
+    if (read(socket, buf, 0, 1) > 0)
+      return buf[0] & 0xFF;
+    else
+      return -1;
+  }
+
+  /**
+   * Internal method used by SocketOuputStream for writing data to
+   * the connection. Writes up to len bytes of data from the buffer
+   * <code>buf</code> starting at <cod>offset</code> bytes into the buffer.
+   *
+   * @param socket the socket object
+   * @param buf the buffer to write to the stream
+   * @param offset the start offset in the buffer
+   * @param len the number of bytes to write
+   *
+   * @throws IOException if an error occurs
+   */
+  static native void write(PlainSocketImpl socket, byte[] buf, int offset,
+                           int len) throws IOException;
+
+  /**
+   * Internal method used by SocketOuputStream for writing data to
+   * the connection. Writes exactly one byte to the socket.
+   *
+   * @param socket the socket object
+   * @param data the byte to write to the socket
+   *
+   * @throws IOException if an error occurs
+   */
+  static void write(PlainSocketImpl socket, int data)
+    throws IOException
+  {
+    write(socket, new byte[]{ (byte) data }, 0, 1);
+  }
+
+  /**
+   * Sets the input stream for this socket to the end of the stream. Any
+   * attempts to read more bytes from the stream will return an EOF.
+   *
+   * @param socket the socket object
+   *
+   * @throws IOException if I/O errors occur
+   */
+  static native void shutdownInput(PlainSocketImpl socket) throws IOException;
+
+  /**
+   * Disables the output stream for this socket. Any attempt to write more
+   * data to the socket will throw an IOException.
+   *
+   * @param socket the socket object
+   *
+   * @throws IOException if I/O errors occur
+   */
+  static native void shutdownOutput(PlainSocketImpl socket) throws IOException;
+
+  /**
+   * Connects to the remote socket address with a specified timeout.
+   *
+   * @param socket the socket object
+   * @param address the remote address to connect to
+   * @param timeout the timeout to use for this connect, 0 means infinite.
+   *
+   * @throws IOException if an error occurs
+   */
+  static synchronized void connect(PlainSocketImpl socket,
+                                      SocketAddress address, int timeout)
+    throws IOException
+  {
+    InetSocketAddress sockAddr = (InetSocketAddress) address;
+    InetAddress addr = sockAddr.getAddress();
+
+    if (addr == null)
+      throw new UnknownHostException(sockAddr.getHostName());
+
+    int port = sockAddr.getPort();
+
+    if (timeout < 0)
+      throw new IllegalArgumentException("negative timeout");
+
+    Object oldTimeoutObj = null;
+    try
+      {
+        oldTimeoutObj = getOption(socket, SocketOptions.SO_TIMEOUT);
+        setOption(socket, SocketOptions.SO_TIMEOUT, new Integer(timeout));
+        connect(socket, addr, port);
+      }
+    finally
+      {
+        if (oldTimeoutObj != null)
+          setOption(socket, SocketOptions.SO_TIMEOUT, oldTimeoutObj);
+      }
+  }
+
+  /**
+   * Send one byte of urgent data over the socket.
+   *
+   * @param socket the socket object
+   * @param data the byte to send
+   */
+  static void sendUrgendData(PlainSocketImpl socket, int data)
+  {
+    throw new InternalError ("PlainSocketImpl::sendUrgentData not implemented");
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,197 @@
+/* VMChannel.java -- Native interface suppling channel operations.
+   Copyright (C) 2006 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.nio;
+
+import gnu.classpath.Configuration;
+import gnu.java.net.PlainSocketImpl;
+import gnu.java.nio.PipeImpl.SinkChannelImpl;
+import gnu.java.nio.PipeImpl.SourceChannelImpl;
+import gnu.java.nio.channels.FileChannelImpl;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * Native interface to support configuring of channel to run in a non-blocking
+ * manner and support scatter/gather io operations.
+ * 
+ * @author Michael Barker <mike at middlesoft.co.uk>
+ *
+ */
+public class VMChannel
+{
+  private final int fd;
+  
+  private VMChannel(int fd)
+  {
+    this.fd = fd;
+  }
+  
+  public static VMChannel getVMChannel(PlainSocketImpl socket)
+  {
+    return new VMChannel(socket.getNativeFD());
+  }
+  
+  public static VMChannel getVMChannel(SourceChannelImpl source)
+  {
+    return new VMChannel(source.getNativeFD());
+  }
+  
+  public static VMChannel getVMChannel(SinkChannelImpl sink)
+  {
+    return new VMChannel(sink.getNativeFD());
+  }
+  
+  public static VMChannel getVMChannel(FileChannelImpl file)
+  {
+    return new VMChannel(file.getNativeFD());
+  }
+
+  static
+  {
+    // load the shared library needed for native methods.
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+        System.loadLibrary ("javanio");
+      }
+    initIDs();
+  }
+  
+  /**
+   * Set the file descriptor to have the required blocking
+   * setting.
+   * 
+   * @param fd
+   * @param blocking
+   */
+  public native void setBlocking(int fd, boolean blocking);
+  
+  public void setBlocking(boolean blocking)
+  {
+    setBlocking(fd, blocking);
+  }
+  
+
+  /**
+   * Reads a byte buffer directly using the supplied file descriptor.
+   * Assumes that the buffer is a DirectBuffer.
+   * 
+   * @param fd Native file descriptor to read from.
+   * @param dst Direct Byte Buffer to read to.
+   * @return Number of bytes read.
+   * @throws IOException If an error occurs or dst is not a direct buffers. 
+   */
+  native int read(int fd, ByteBuffer dst)
+    throws IOException;
+  
+  public int read(ByteBuffer dst)
+    throws IOException
+  {
+    return read(fd, dst);
+  }
+  
+  /**
+   * Reads into byte buffers directly using the supplied file descriptor.
+   * Assumes that the buffer list contains DirectBuffers.  Will perform a
+   * scattering read.
+   * 
+   * @param fd Native file descriptor to read from.
+   * @param dsts An array direct byte buffers.
+   * @param offset Index of the first buffer to read to.
+   * @param length The number of buffers to read to.
+   * @return Number of bytes read.
+   * @throws IOException If an error occurs or the dsts are not direct buffers. 
+   */
+  native long readScattering(int fd, ByteBuffer[] dsts, int offset, int length)
+    throws IOException;
+
+  public long readScattering(ByteBuffer[] dsts, int offset, int length)
+    throws IOException
+  {
+    if (offset + length > dsts.length)
+      throw new IndexOutOfBoundsException("offset + length > dsts.length");
+    
+    return readScattering(fd, dsts, offset, length);
+  }
+  
+  /**
+   * Writes from a direct byte bufer using the supplied file descriptor.
+   * Assumes the buffer is a DirectBuffer.
+   * 
+   * @param fd
+   * @param src
+   * @return Number of bytes written.
+   * @throws IOException
+   */
+  native int write(int fd, ByteBuffer src)
+    throws IOException;
+
+  public int write(ByteBuffer src)
+    throws IOException
+  {
+    return write(fd, src);
+  }
+  
+  /**
+   * Writes from byte buffers directly using the supplied file descriptor.
+   * Assumes the that buffer list constains DirectBuffers.  Will perform
+   * as gathering write.
+   * 
+   * @param fd
+   * @param srcs
+   * @param offset
+   * @param length
+   * @return Number of bytes written.
+   * @throws IOException
+   */
+  native long writeGathering(int fd, ByteBuffer[] srcs, int offset, int length)
+    throws IOException;
+  
+  public long writeGathering(ByteBuffer[] srcs, int offset, int length)
+    throws IOException
+  {
+    if (offset + length > srcs.length)
+      throw new IndexOutOfBoundsException("offset + length > srcs.length");
+    
+    return writeGathering(fd, srcs, offset, length);
+  }
+  
+  private native static void initIDs();
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/nio/VMPipe.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/nio/VMPipe.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/nio/VMPipe.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/nio/VMPipe.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,64 @@
+/* VMPipe.java -- Reference implementation for VM hooks used by PipeImpl
+   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.java.nio;
+
+import java.io.IOException;
+import java.nio.channels.spi.SelectorProvider;
+import gnu.classpath.Configuration;
+
+/**
+ * This class contains the native methods for gnu.java.nio.PipeImpl
+ * As such, it needs help from the VM.
+ *
+ * @author Patrik Reali
+ */
+final class VMPipe
+{
+
+  static
+  {
+    // load the shared library needed for native methods.
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+        System.loadLibrary ("javanio");
+      }
+  }
+
+  static native void init(PipeImpl self, SelectorProvider provider)
+    throws IOException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/nio/VMSelector.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/nio/VMSelector.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/nio/VMSelector.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/gnu/java/nio/VMSelector.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* VMSelector.java -- 
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.nio;
+
+import gnu.classpath.Configuration;
+import java.io.IOException;
+
+public final class VMSelector
+{
+  static
+  {
+    // load the shared library needed for native methods.
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+        System.loadLibrary ("javanio");
+      }
+  }
+  
+  // A timeout value of 0 means block forever.
+  static native int select (int[] read, int[] write,
+                                        int[] except, long timeout)
+    throws IOException;
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/io/VMFile.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/io/VMFile.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/io/VMFile.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/io/VMFile.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,225 @@
+/* VMFile.java -- Class for methods natively accessing files
+   Copyright (C) 2004, 2006  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.io;
+
+import gnu.classpath.Configuration;
+import gnu.java.io.PlatformHelper;
+
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+final class VMFile
+{
+  // FIXME: We support only case sensitive filesystems currently.
+  static final boolean IS_CASE_SENSITIVE = true;
+  static final boolean IS_DOS_8_3 = false;
+
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+	System.loadLibrary("javaio");
+      }
+  }
+
+  /*
+   * This native method does the actual work of getting the last file
+   * modification time.  It also does the existence check to avoid the
+   * overhead of a call to exists()
+   */
+  static native long lastModified(String path);
+
+  /*
+   * This native method sets the permissions to make the file read only.
+   */
+  static native boolean setReadOnly(String path);
+
+  /**
+   * This method is used to create a temporary file
+   */
+  static native boolean create(String path) throws IOException;
+
+  /*
+   * This native function actually produces the list of file in this
+   * directory
+   */
+  static native String[] list(String dirpath);
+
+  /*
+   * This native method actually performs the rename.
+   */
+  static native boolean renameTo(String targetpath, String destpath);
+
+  /*
+   * This native method actually determines the length of the file and
+   * handles the existence check
+   */
+  static native long length(String path);
+
+  /*
+   * This native method does the actual checking of file existence.
+   */
+  static native boolean exists(String path);
+
+  /*
+   * This native method handles the actual deleting of the file
+   */
+  static native boolean delete(String path);
+
+  /*
+   * This method does the actual setting of the modification time.
+   */
+  static native boolean setLastModified(String path, long time);
+
+  /*
+   * This native method actually creates the directory
+   */
+  static native boolean mkdir(String dirpath);
+
+  /*
+   * This native method does the actual check of whether or not a file
+   * is a plain file or not.  It also handles the existence check to
+   * eliminate the overhead of a call to exists()
+   */
+  static native boolean isFile(String path);
+
+  /**
+   * This native method checks file permissions for writing
+   */
+  static synchronized native boolean canWrite(String path);
+
+  /**
+   * This methods checks if a directory can be written to.
+   */
+  static boolean canWriteDirectory(File dir)
+  {
+    try
+      {
+        String filename = IS_DOS_8_3 ? "tst" : "test-dir-write";
+        File test = File.createTempFile(filename, null, dir);
+        return (test != null && test.delete());
+      }
+    catch (IOException ioe)
+      {
+        return false;
+      }
+  }
+
+  /**
+   * This native method checks file permissions for reading
+   */
+  static synchronized native boolean canRead(String path);
+
+  /*
+   * This method does the actual check of whether or not a file is a
+   * directory or not.  It also handle the existence check to eliminate
+   * the overhead of a call to exists()
+   */
+  static native boolean isDirectory(String dirpath);
+
+  /**
+   * This method returns an array of filesystem roots.  Some operating systems
+   * have volume oriented filesystem.  This method provides a mechanism for
+   * determining which volumes exist.  GNU systems use a single hierarchical
+   * filesystem, so will have only one "/" filesystem root.
+   *
+   * @return An array of <code>File</code> objects for each filesystem root
+   * available.
+   *
+   * @since 1.2
+   */
+  static File[] listRoots()
+  {
+	File[] roots = new File[1];
+	roots[0] = new File("/");
+	return roots;
+  }
+
+  /**
+   * This method tests whether or not this file represents a "hidden" file.
+   * On GNU systems, a file is hidden if its name begins with a "."
+   * character.  Files with these names are traditionally not shown with
+   * directory listing tools.
+   *
+   * @return <code>true</code> if the file is hidden, <code>false</code>
+   * otherwise.
+   *
+   * @since 1.2
+   */
+  static boolean isHidden(String path)
+  {
+	// FIXME: this only works on UNIX
+	return getName(path).startsWith(".");
+  }
+
+  /**
+   * This method returns the name of the file.  This is everything in the
+   * complete path of the file after the last instance of the separator
+   * string.
+   *
+   * @return The file name
+   */
+  static String getName(String path)
+  {
+	int pos = PlatformHelper.lastIndexOfSeparator(path);
+	if (pos == -1)
+	  return path;
+	
+	if (PlatformHelper.endWithSeparator(path))
+	  return "";
+	
+	return path.substring(pos + File.separator.length());
+  }
+
+  /**
+   * This method returns a canonical representation of the pathname of
+   * this file.  The actual form of the canonical representation is
+   * system-dependent.  On the GNU system, conversion to canonical
+   * form involves the removal of redundant separators, references to
+   * "." and "..", and symbolic links.
+   * <p>
+   * Note that this method, unlike the other methods which return path
+   * names, can throw an IOException.  This is because native method 
+   * might be required in order to resolve the canonical path
+   *
+   * @exception IOException If an error occurs
+   */
+  public static native String toCanonicalForm(String path) throws IOException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/io/VMObjectInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/io/VMObjectInputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/io/VMObjectInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/io/VMObjectInputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,103 @@
+/* ObjectInputStream.java -- Class used to read serialized objects
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.VMStackWalker;
+import java.lang.reflect.Constructor;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+final class VMObjectInputStream
+{
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+	System.loadLibrary("javaio");
+      }
+  }
+
+  /**
+   * PrivilegedAction needed for Class.getClassLoader()
+   */ 
+  private static PrivilegedAction loaderAction = new PrivilegedAction()
+  {
+   /**
+     * Returns the first user defined class loader on the call stack, or the
+     * context class loader of the current thread, when no non-null class loader
+     * was found.
+     */
+    public Object run()
+    {
+      Class[] ctx = VMStackWalker.getClassContext();
+
+      for (int i = 0; i < ctx.length; i++)
+        {
+          ClassLoader cl = ctx[i].getClassLoader();
+          if (cl != null)
+            return cl;
+        }
+      return Thread.currentThread().getContextClassLoader();
+    }
+    };
+
+  /**
+   * Returns the first user defined class loader on the call stack, or the
+   * context class loader of the current thread, when no non-null class loader
+   * was found.
+   * 
+   * @return the class loader
+   */
+  static ClassLoader currentClassLoader()
+  {
+    return (ClassLoader) AccessController.doPrivileged(loaderAction);
+  }
+
+  /**
+   * Allocates a new Object of type clazz but without running the
+   * default constructor on it. It then calls the given constructor on
+   * it. The given constructor method comes from the constr_clazz
+   * which is a super class of the given clazz.
+   */
+  static native Object allocateObject(Class clazz, Class constr_clazz,
+				      Constructor constructor)
+    throws InstantiationException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/io/VMObjectStreamClass.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/io/VMObjectStreamClass.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/io/VMObjectStreamClass.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/io/VMObjectStreamClass.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,169 @@
+/* VMObjectStreamClass.java -- VM helper functions for ObjectStreamClass
+   Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import gnu.classpath.Configuration;
+import java.lang.reflect.Field;
+
+final class VMObjectStreamClass
+{
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+	System.loadLibrary("javaio");
+      }
+  }
+
+  /**
+    * Returns true if CLAZZ has a static class initializer
+    * (a.k.a. <clinit>).
+    */
+  static native boolean hasClassInitializer (Class clazz);
+
+  /**
+   * Sets the value of the specified field. This method handles "double".
+   * Warning ! The types are not truely checked here and final values may be
+   * assigned.
+   *
+   * @param field Field to set the value.
+   * @param obj Instance which will have its field set.
+   * @param val Value to put in the field.
+   */
+  static native void setDoubleNative(Field field, Object obj, double val)
+    throws InternalError;
+
+  /**
+   * Sets the value of the specified field. This method handles "float".
+   * Warning ! The types are not truely checked here and final values may be
+   * assigned.
+   *
+   * @param field Field to set the value.
+   * @param obj Instance which will have its field set.
+   * @param val Value to put in the field.
+   */
+  static native void setFloatNative(Field field, Object obj, float val)
+    throws InternalError;
+
+  /**
+   * Sets the value of the specified field. This method handles "long".
+   * Warning ! The types are not truely checked here and final values may be
+   * assigned.
+   *
+   * @param field Field to set the value.
+   * @param obj Instance which will have its field set.
+   * @param val Value to put in the field.
+   */
+  static native void setLongNative(Field field, Object obj, long val)
+    throws InternalError;
+  
+  /**
+   * Sets the value of the specified field. This method handles "int".
+   * Warning ! The types are not truely checked here and final values may be
+   * assigned.
+   *
+   * @param field Field to set the value.
+   * @param obj Instance which will have its field set.
+   * @param val Value to put in the field.
+   */
+  static native void setIntNative(Field field, Object obj, int val) 
+    throws InternalError;
+  
+  /**
+   * Sets the value of the specified field. This method handles "short".
+   * Warning ! The types are not truely checked here and final values may be
+   * assigned.
+   *
+   * @param field Field to set the value.
+   * @param obj Instance which will have its field set.
+   * @param val Value to put in the field.
+   */
+  static native void setShortNative(Field field, Object obj, short val) 
+    throws InternalError;
+
+  /**
+   * Sets the value of the specified field. This method handles "char".
+   * Warning ! The types are not truely checked here and final values may be
+   * assigned.
+   *
+   * @param field Field to set the value.
+   * @param obj Instance which will have its field set.
+   * @param val Value to put in the field.
+   */
+  static native void setCharNative(Field field, Object obj, char val) 
+    throws InternalError;
+
+  /**
+   * Sets the value of the specified field. This method handles "byte".
+   * Warning ! The types are not truely checked here and final values may be
+   * assigned.
+   *
+   * @param field Field to set the value.
+   * @param obj Instance which will have its field set.
+   * @param val Value to put in the field.
+   */
+  static native void setByteNative(Field field, Object obj, byte val) 
+    throws InternalError;
+
+  /**
+   * Sets the value of the specified field. This method handles "boolean".
+   * Warning ! The types are not truely checked here and final values may be
+   * assigned.
+   *
+   * @param field Field to set the value.
+   * @param obj Instance which will have its field set.
+   * @param val Value to put in the field.
+   */
+  static native void setBooleanNative(Field field, Object obj, boolean val) 
+    throws InternalError;
+
+  /**
+   * Sets the value of the specified field. This method handles "object".
+   * Warning ! The types are not truely checked here and final values may be
+   * assigned.
+   *
+   * @param field Field to set the value.
+   * @param obj Instance which will have its field set.
+   * @param val Value to put in the field.
+   */
+  static native void setObjectNative(Field field, Object obj, Object val) 
+    throws InternalError;
+  
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMClass.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMClass.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMClass.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMClass.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,454 @@
+/* VMClass.java -- VM Specific Class methods
+   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;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+
+/*
+ * 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.
+ */
+
+/**
+ *
+ * @author Etienne Gagnon (etienne.gagnon at uqam.ca)
+ * @author Archie Cobbs (archie at dellroad.org)
+ * @author C. Brian Jones (cbj at gnu.org)
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ */
+final class VMClass 
+{
+
+  // Only static methods. Cannot be instantiated.
+  private VMClass()
+  {
+  }
+
+  /**
+   * Discover whether an Object is an instance of this Class.  Think of it
+   * as almost like <code>o instanceof (this class)</code>.
+   *
+   * @param klass the Class object that's calling us
+   * @param o the Object to check
+   * @return whether o is an instance of this class
+   * @since 1.1
+   */
+  static native boolean isInstance(Class klass, Object o);
+
+  /**
+   * Discover whether an instance of the Class parameter would be an
+   * instance of this Class as well.  Think of doing
+   * <code>isInstance(c.newInstance())</code> or even
+   * <code>c.newInstance() instanceof (this class)</code>. While this
+   * checks widening conversions for objects, it must be exact for primitive
+   * types.
+   *
+   * @param klass the Class object that's calling us
+   * @param c the class to check
+   * @return whether an instance of c would be an instance of this class
+   *         as well
+   * @throws NullPointerException if c is null
+   * @since 1.1
+   */
+  static native boolean isAssignableFrom(Class klass, Class c);
+
+  /**
+   * Check whether this class is an interface or not.  Array types are not
+   * interfaces.
+   *
+   * @param klass the Class object that's calling us
+   * @return whether this class is an interface or not
+   */
+  static native boolean isInterface(Class klass);
+
+  /**
+   * Return whether this class is a primitive type.  A primitive type class
+   * is a class representing a kind of "placeholder" for the various
+   * primitive types, or void.  You can access the various primitive type
+   * classes through java.lang.Boolean.TYPE, java.lang.Integer.TYPE, etc.,
+   * or through boolean.class, int.class, etc.
+   *
+   * @param klass the Class object that's calling us
+   * @return whether this class is a primitive type
+   * @see Boolean#TYPE
+   * @see Byte#TYPE
+   * @see Character#TYPE
+   * @see Short#TYPE
+   * @see Integer#TYPE
+   * @see Long#TYPE
+   * @see Float#TYPE
+   * @see Double#TYPE
+   * @see Void#TYPE
+   * @since 1.1
+   */
+  static native boolean isPrimitive(Class klass);
+
+  /**
+   * Get the name of this class, separated by dots for package separators.
+   * Primitive types and arrays are encoded as:
+   * <pre>
+   * boolean             Z
+   * byte                B
+   * char                C
+   * short               S
+   * int                 I
+   * long                J
+   * float               F
+   * double              D
+   * void                V
+   * array type          [<em>element type</em>
+   * class or interface, alone: <dotted name>
+   * class or interface, as element type: L<dotted name>;
+   *
+   * @param klass the Class object that's calling us
+   * @return the name of this class
+   */
+  static native String getName(Class klass);
+
+  /**
+   * Get the direct superclass of this class.  If this is an interface,
+   * Object, a primitive type, or void, it will return null. If this is an
+   * array type, it will return Object.
+   *
+   * @param klass the Class object that's calling us
+   * @return the direct superclass of this class
+   */
+  static native Class getSuperclass(Class klass);
+
+  /**
+   * Get the interfaces this class <EM>directly</EM> implements, in the
+   * order that they were declared. This returns an empty array, not null,
+   * for Object, primitives, void, and classes or interfaces with no direct
+   * superinterface. Array types return Cloneable and Serializable.
+   *
+   * @param klass the Class object that's calling us
+   * @return the interfaces this class directly implements
+   */
+  static native Class[] getInterfaces(Class klass);
+
+  /**
+   * If this is an array, get the Class representing the type of array.
+   * Examples: "[[Ljava.lang.String;" would return "[Ljava.lang.String;", and
+   * calling getComponentType on that would give "java.lang.String".  If
+   * this is not an array, returns null.
+   *
+   * @param klass the Class object that's calling us
+   * @return the array type of this class, or null
+   * @see Array
+   * @since 1.1
+   */
+  static native Class getComponentType(Class klass);
+
+  /**
+   * Get the modifiers of this class.  These can be decoded using Modifier,
+   * and is limited to one of public, protected, or private, and any of
+   * final, static, abstract, or interface. An array class has the same
+   * public, protected, or private modifier as its component type, and is
+   * marked final but not an interface. Primitive types and void are marked
+   * public and final, but not an interface.
+   *
+   * @param klass the Class object that's calling us
+   * @param ignoreInnerClassesAttrib if set, return the real modifiers, not
+   * the ones specified in the InnerClasses attribute.
+   * @return the modifiers of this class
+   * @see Modifier
+   * @since 1.1
+   */
+  static native int getModifiers(Class klass, boolean ignoreInnerClassesAttrib);
+
+  /**
+   * If this is a nested or inner class, return the class that declared it.
+   * If not, return null.
+   *
+   * @param klass the Class object that's calling us
+   * @return the declaring class of this class
+   * @since 1.1
+   */
+  static native Class getDeclaringClass(Class klass);
+
+  /**
+   * Like <code>getDeclaredClasses()</code> but without the security checks.
+   *
+   * @param klass the Class object that's calling us
+   * @param publicOnly Only public classes should be returned
+   */
+  static native Class[] getDeclaredClasses(Class klass, boolean publicOnly);
+
+  /**
+   * Like <code>getDeclaredFields()</code> but without the security checks.
+   *
+   * @param klass the Class object that's calling us
+   * @param publicOnly Only public fields should be returned
+   */
+  static native Field[] getDeclaredFields(Class klass, boolean publicOnly);
+
+  /**
+   * Like <code>getDeclaredMethods()</code> but without the security checks.
+   *
+   * @param klass the Class object that's calling us
+   * @param publicOnly Only public methods should be returned
+   */
+  static native Method[] getDeclaredMethods(Class klass, boolean publicOnly);
+
+  /**
+   * Like <code>getDeclaredConstructors()</code> but without
+   * the security checks.
+   *
+   * @param klass the Class object that's calling us
+   * @param publicOnly Only public constructors should be returned
+   */
+  static native Constructor[] getDeclaredConstructors(Class klass, boolean publicOnly);
+
+  /**
+   * Return the class loader of this class.
+   *
+   * @param klass the Class object that's calling us
+   * @return the class loader
+   */
+  static native ClassLoader getClassLoader(Class klass);
+
+  /**
+   * Load the requested class and record the specified loader as the
+   * initiating class loader.
+   *
+   * @param name the name of the class to find
+   * @param initialize should the class initializer be run?
+   * @param loader the class loader to use (or null for the bootstrap loader)
+   * @return the Class object representing the class or null for noop
+   * @throws ClassNotFoundException if the class was not found by the
+   *         class loader
+   * @throws LinkageError if linking the class fails
+   * @throws ExceptionInInitializerError if the class loads, but an exception
+   *         occurs during initialization
+   */
+  static native Class forName(String name, boolean initialize,
+                              ClassLoader loader)
+    throws ClassNotFoundException;
+
+  /**
+   * Return whether this class is an array type.
+   *
+   * @param klass the Class object that's calling us
+   * @return true if this class is an array type
+   * operation
+   */
+  static native boolean isArray(Class klass);
+
+  /**
+   * Throw a checked exception without declaring it.
+   */
+  static native void throwException(Throwable t);
+
+  /**
+   * Returns the simple name for the specified class, as used in the source
+   * code.  For normal classes, this is the content returned by
+   * <code>getName()</code> which follows the last ".".  Anonymous
+   * classes have no name, and so the result of calling this method is
+   * "".  The simple name of an array consists of the simple name of
+   * its component type, followed by "[]".  Thus, an array with the 
+   * component type of an anonymous class has a simple name of simply
+   * "[]".
+   *
+   * @param klass the class whose simple name should be returned. 
+   * @return the simple name for this class.
+   */
+  static String getSimpleName(Class klass)
+  {
+    if (isArray(klass))
+      {
+	return getComponentType(klass).getSimpleName() + "[]";
+      }
+    String fullName = getName(klass);
+    return fullName.substring(fullName.lastIndexOf(".") + 1);
+  }
+
+  /**
+   * Returns all annotations directly defined by the specified class.  If
+   * there are no annotations associated with this class, 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.
+   *
+   * @param klass the class whose annotations should be returned.
+   * @return the annotations directly defined by the specified class.
+   * @since 1.5
+   */
+  static native Annotation[] getDeclaredAnnotations(Class klass);
+
+  /**
+   * <p>
+   * Returns the canonical name of the specified class, as defined by section
+   * 6.7 of the Java language specification.  Each package, top-level class,
+   * top-level interface and primitive type has a canonical name.  A member
+   * class has a canonical name, if its parent class has one.  Likewise,
+   * an array type has a canonical name, if its component type does.
+   * Local or anonymous classes do not have canonical names.
+   * </p>
+   * <p>
+   * The canonical name for top-level classes, top-level interfaces and
+   * primitive types is always the same as the fully-qualified name.
+   * For array types, the canonical name is the canonical name of its
+   * component type with `[]' appended.  
+   * </p>
+   * <p>
+   * The canonical name of a member class always refers to the place where
+   * the class was defined, and is composed of the canonical name of the
+   * defining class and the simple name of the member class, joined by `.'.
+   *  For example, if a <code>Person</code> class has an inner class,
+   * <code>M</code>, then both its fully-qualified name and canonical name
+   * is <code>Person.M</code>.  A subclass, <code>Staff</code>, of
+   * <code>Person</code> refers to the same inner class by the fully-qualified
+   * name of <code>Staff.M</code>, but its canonical name is still
+   * <code>Person.M</code>.
+   * </p>
+   * <p>
+   * Where no canonical name is present, <code>null</code> is returned.
+   * </p>
+   *
+   * @param klass the class whose canonical name should be retrieved.
+   * @return the canonical name of the class, or <code>null</code> if the
+   *         class doesn't have a canonical name.
+   * @since 1.5
+   */
+  static String getCanonicalName(Class klass)
+  {
+    if (isArray(klass))
+      {
+	String componentName = getComponentType(klass).getCanonicalName();
+	if (componentName != null)
+	  return componentName + "[]";
+      }
+    if (isMemberClass(klass))
+      {
+	String memberName = getDeclaringClass(klass).getCanonicalName();
+	if (memberName != null)
+	  return memberName + "." + getSimpleName(klass);
+      }
+    if (isLocalClass(klass) || isAnonymousClass(klass))
+      return null;
+    return getName(klass);
+  }
+
+  /**
+   * Returns the class which immediately encloses the specified class.  If
+   * the class is a top-level class, this method returns <code>null</code>.
+   *
+   * @param klass the class whose enclosing class should be returned.
+   * @return the immediate enclosing class, or <code>null</code> if this is
+   *         a top-level class.
+   * @since 1.5
+   */
+  static native Class getEnclosingClass(Class klass);
+
+  /**
+   * Returns the constructor which immediately encloses the specified class.
+   * If the class is a top-level class, or a local or anonymous class 
+   * immediately enclosed by a type definition, instance initializer
+   * or static initializer, then <code>null</code> is returned.
+   *
+   * @param klass the class whose enclosing constructor should be returned.
+   * @return the immediate enclosing constructor if the specified class is
+   *         declared within a constructor.  Otherwise, <code>null</code>
+   *         is returned.
+   * @since 1.5
+   */
+  static native Constructor getEnclosingConstructor(Class klass);
+
+  /**
+   * Returns the method which immediately encloses the specified class.  If
+   * the class is a top-level class, or a local or anonymous class 
+   * immediately enclosed by a type definition, instance initializer
+   * or static initializer, then <code>null</code> is returned.
+   *
+   * @param klass the class whose enclosing method should be returned.
+   * @return the immediate enclosing method if the specified class is
+   *         declared within a method.  Otherwise, <code>null</code>
+   *         is returned.
+   * @since 1.5
+   */
+  static native Method getEnclosingMethod(Class klass);
+
+  /**
+   * Returns the class signature as specified in Class File Format
+   * chapter in the VM specification, or null if the class is not
+   * generic.
+   *
+   * @param klass the klass to test.
+   * @return a ClassSignature string.
+   * @since 1.5
+   */
+  static native String getClassSignature(Class klass);
+
+  /**
+   * Returns true if the specified class represents an anonymous class.
+   *
+   * @param klass the klass to test.
+   * @return true if the specified class represents an anonymous class.
+   * @since 1.5
+   */
+  static native boolean isAnonymousClass(Class klass);
+
+  /**
+   * Returns true if the specified class represents an local class.
+   *
+   * @param klass the klass to test.
+   * @return true if the specified class represents an local class.
+   * @since 1.5
+   */
+  static native boolean isLocalClass(Class klass);
+
+  /**
+   * Returns true if the specified class represents an member class.
+   *
+   * @param klass the klass to test. 
+   * @return true if the specified class represents an member class.
+   * @since 1.5
+   */
+  static native boolean isMemberClass(Class klass);
+
+} // class VMClass

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMClassLoader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMClassLoader.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMClassLoader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMClassLoader.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,430 @@
+/* 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;
+
+/**
+ * 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 at klomp.org)
+ * @author Eric Blake (ebb9 at 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();
+  }
+
+
+  /**
+   * 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()
+  {
+    URL indexList = getResource("META-INF/INDEX.LIST");
+    if (indexList != null)
+      {
+        try
+          {
+            Set packageSet = new HashSet();
+            String line;
+            int lineToSkip = 3;
+            BufferedReader reader = new BufferedReader(
+                                                       new InputStreamReader(
+                                                                             indexList.openStream()));
+            while ((line = reader.readLine()) != null)
+              {
+                if (lineToSkip == 0)
+                  {
+                    if (line.length() == 0)
+                      lineToSkip = 1;
+                    else
+                      packageSet.add(line.replace('/', '.'));
+                  }
+                else
+                  lineToSkip--;
+              }
+            reader.close();
+            return (String[]) packageSet.toArray(new String[packageSet.size()]);
+          }
+        catch (IOException e)
+          {
+            return new String[0];
+          }
+      }
+    else
+      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.
+   *
+   * XXX - Not implemented yet; this requires native help.
+   *
+   * @return the system-wide default assertion status
+   */
+  static final boolean defaultAssertionStatus()
+  {
+    return true;
+  }
+
+  /**
+   * 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.
+   *
+   * XXX - Not implemented yet; this requires native help.
+   *
+   * @return a (read-only) map for the default packageAssertionStatus
+   */
+  static final Map packageAssertionStatus()
+  {
+    return new HashMap();
+  }
+
+  /**
+   * 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
+   *
+   * XXX - Not implemented yet; this requires native help.
+   *
+   * @return a (read-only) map for the default classAssertionStatus
+   */
+  static final Map classAssertionStatus()
+  {
+    return new HashMap();
+  }
+
+  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);
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMCompiler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMCompiler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMCompiler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMCompiler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,112 @@
+/* VMClassLoader.java -- Reference implementation of compiler interface
+   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 java.lang;
+
+/**
+ * This class is just a per-VM reflection of java.lang.Compiler.
+ * All methods are defined identically.
+ */
+final class VMCompiler
+{
+  /**
+   * Don't allow new `Compiler's to be made.
+   */
+  private VMCompiler()
+  {
+  }
+
+  /**
+   * Compile the class named by <code>oneClass</code>.
+   *
+   * @param oneClass the class to compile
+   * @return <code>false</code> if no compiler is available or
+   *         compilation failed, <code>true</code> if compilation succeeded
+   * @throws NullPointerException if oneClass is null
+   */
+  public static boolean compileClass(Class oneClass)
+  {
+    // Never succeed.
+    return false;
+  }
+
+  /**
+   * Compile the classes whose name matches <code>classNames</code>.
+   *
+   * @param classNames the name of classes to compile
+   * @return <code>false</code> if no compiler is available or
+   *         compilation failed, <code>true</code> if compilation succeeded
+   * @throws NullPointerException if classNames is null
+   */
+  public static boolean compileClasses(String classNames)
+  {
+    // Note the incredibly lame interface.  Always fail.
+    return false;
+  }
+
+  /**
+   * This method examines the argument and performs an operation
+   * according to the compilers documentation.  No specific operation
+   * is required.
+   *
+   * @param arg a compiler-specific argument
+   * @return a compiler-specific value, including null
+   * @throws NullPointerException if the compiler doesn't like a null arg
+   */
+  public static Object command(Object arg)
+  {
+    // Our implementation defines this to a no-op.
+    return null;
+  }
+
+  /**
+   * Calling <code>Compiler.enable()</code> will cause the compiler
+   * to resume operation if it was previously disabled; provided that a
+   * compiler even exists.
+   */
+  public static void enable()
+  {
+  }
+
+  /**
+   * Calling <code>Compiler.disable()</code> will cause the compiler
+   * to be suspended; provided that a compiler even exists.
+   */
+  public static void disable()
+  {
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMDouble.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMDouble.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMDouble.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMDouble.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,131 @@
+/* VMDouble.java -- VM Specific Double methods
+   Copyright (C) 2003, 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 java.lang;
+
+import gnu.classpath.Configuration;
+
+/*
+ * 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.Double by 
+ * @author Dave Grove (groved at us.ibm.com)
+ */
+final class VMDouble
+{
+
+  /**
+   * Load native routines necessary for this class.
+   */
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+	System.loadLibrary("javalang");
+      }
+
+    initIDs();
+  }
+
+  /**
+   * Convert the double to the IEEE 754 floating-point "double format" bit
+   * layout. Bit 63 (the most significant) is the sign bit, bits 62-52
+   * (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0
+   * (masked by 0x000fffffffffffffL) are the mantissa. This function
+   * collapses all versions of NaN to 0x7ff8000000000000L. The result of this
+   * function can be used as the argument to
+   * <code>Double.longBitsToDouble(long)</code> to obtain the original
+   * <code>double</code> value.
+   *
+   * @param value the <code>double</code> to convert
+   * @return the bits of the <code>double</code>
+   * @see #longBitsToDouble(long)
+   */
+  public static native long doubleToLongBits(double value);
+
+  /**
+   * Convert the double to the IEEE 754 floating-point "double format" bit
+   * layout. Bit 63 (the most significant) is the sign bit, bits 62-52
+   * (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0
+   * (masked by 0x000fffffffffffffL) are the mantissa. This function
+   * leaves NaN alone, rather than collapsing to a canonical value. The
+   * result of this function can be used as the argument to
+   * <code>Double.longBitsToDouble(long)</code> to obtain the original
+   * <code>double</code> value.
+   *
+   * @param value the <code>double</code> to convert
+   * @return the bits of the <code>double</code>
+   * @see #longBitsToDouble(long)
+   */
+  public static native long doubleToRawLongBits(double value);
+
+  /**
+   * Convert the argument in IEEE 754 floating-point "double format" bit
+   * layout to the corresponding float. Bit 63 (the most significant) is the
+   * sign bit, bits 62-52 (masked by 0x7ff0000000000000L) represent the
+   * exponent, and bits 51-0 (masked by 0x000fffffffffffffL) are the mantissa.
+   * This function leaves NaN alone, so that you can recover the bit pattern
+   * with <code>Double.doubleToRawLongBits(double)</code>.
+   *
+   * @param bits the bits to convert
+   * @return the <code>double</code> represented by the bits
+   * @see #doubleToLongBits(double)
+   * @see #doubleToRawLongBits(double)
+   */
+  public static native double longBitsToDouble(long bits);
+
+  /**
+   * Helper method to convert to string.
+   *
+   * @param d the double to convert
+   * @param isFloat true if the conversion is requested by Float (results in
+   *        fewer digits)
+   */
+  public static native String toString(double d, boolean isFloat);
+
+  /**
+   * Initialize JNI cache.  This method is called only by the
+   * static initializer when using JNI.
+   */
+  public static native void initIDs();
+
+  public static native double parseDouble(String str);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMFloat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMFloat.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMFloat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMFloat.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,111 @@
+/* VMFloat.java -- VM Specific Float 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 gnu.classpath.Configuration;
+
+/*
+ * 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.Float by 
+ * @author Dave Grove <groved at us.ibm.com>
+ */
+final class VMFloat
+{
+
+  /**
+   * Load native routines necessary for this class.
+   */
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+        System.loadLibrary("javalang");
+      }
+  }
+
+  /**
+   * Convert the float to the IEEE 754 floating-point "single format" bit
+   * layout. Bit 31 (the most significant) is the sign bit, bits 30-23
+   * (masked by 0x7f800000) represent the exponent, and bits 22-0
+   * (masked by 0x007fffff) are the mantissa. This function collapses all
+   * versions of NaN to 0x7fc00000. The result of this function can be used
+   * as the argument to <code>Float.intBitsToFloat(int)</code> to obtain the
+   * original <code>float</code> value.
+   *
+   * @param value the <code>float</code> to convert
+   * @return the bits of the <code>float</code>
+   * @see #intBitsToFloat(int)
+   */
+  static native int floatToIntBits(float value);
+
+  /**
+   * Convert the float to the IEEE 754 floating-point "single format" bit
+   * layout. Bit 31 (the most significant) is the sign bit, bits 30-23
+   * (masked by 0x7f800000) represent the exponent, and bits 22-0
+   * (masked by 0x007fffff) are the mantissa. This function leaves NaN alone,
+   * rather than collapsing to a canonical value. The result of this function
+   * can be used as the argument to <code>Float.intBitsToFloat(int)</code> to
+   * obtain the original <code>float</code> value.
+   *
+   * @param value the <code>float</code> to convert
+   * @return the bits of the <code>float</code>
+   * @see #intBitsToFloat(int)
+   */
+  static native int floatToRawIntBits(float value);
+
+  /**
+   * Convert the argument in IEEE 754 floating-point "single format" bit
+   * layout to the corresponding float. Bit 31 (the most significant) is the
+   * sign bit, bits 30-23 (masked by 0x7f800000) represent the exponent, and
+   * bits 22-0 (masked by 0x007fffff) are the mantissa. This function leaves
+   * NaN alone, so that you can recover the bit pattern with
+   * <code>Float.floatToRawIntBits(float)</code>.
+   *
+   * @param bits the bits to convert
+   * @return the <code>float</code> represented by the bits
+   * @see #floatToIntBits(float)
+   * @see #floatToRawIntBits(float)
+   */
+  static native float intBitsToFloat(int bits);
+
+} // class VMFloat

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMMath.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMMath.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMMath.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMMath.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,493 @@
+/* VMMath.java -- Common mathematical functions.
+   Copyright (C) 2006  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;
+
+import gnu.classpath.Configuration;
+
+class VMMath
+{
+
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+	System.loadLibrary("javalang");
+      }
+  }
+
+  /**
+   * The trigonometric function <em>sin</em>. The sine of NaN or infinity is
+   * NaN, and the sine of 0 retains its sign. This is accurate within 1 ulp,
+   * and is semi-monotonic.
+   *
+   * @param a the angle (in radians)
+   * @return sin(a)
+   */
+  public static native double sin(double a);
+
+  /**
+   * The trigonometric function <em>cos</em>. The cosine of NaN or infinity is
+   * NaN. This is accurate within 1 ulp, and is semi-monotonic.
+   *
+   * @param a the angle (in radians)
+   * @return cos(a)
+   */
+  public static native double cos(double a);
+
+  /**
+   * The trigonometric function <em>tan</em>. The tangent of NaN or infinity
+   * is NaN, and the tangent of 0 retains its sign. This is accurate within 1
+   * ulp, and is semi-monotonic.
+   *
+   * @param a the angle (in radians)
+   * @return tan(a)
+   */
+  public static native double tan(double a);
+
+  /**
+   * The trigonometric function <em>arcsin</em>. The range of angles returned
+   * is -pi/2 to pi/2 radians (-90 to 90 degrees). If the argument is NaN or
+   * its absolute value is beyond 1, the result is NaN; and the arcsine of
+   * 0 retains its sign. This is accurate within 1 ulp, and is semi-monotonic.
+   *
+   * @param a the sin to turn back into an angle
+   * @return arcsin(a)
+   */
+  public static native double asin(double a);
+
+  /**
+   * The trigonometric function <em>arccos</em>. The range of angles returned
+   * is 0 to pi radians (0 to 180 degrees). If the argument is NaN or
+   * its absolute value is beyond 1, the result is NaN. This is accurate
+   * within 1 ulp, and is semi-monotonic.
+   *
+   * @param a the cos to turn back into an angle
+   * @return arccos(a)
+   */
+  public static native double acos(double a);
+
+  /**
+   * The trigonometric function <em>arcsin</em>. The range of angles returned
+   * is -pi/2 to pi/2 radians (-90 to 90 degrees). If the argument is NaN, the
+   * result is NaN; and the arctangent of 0 retains its sign. This is accurate
+   * within 1 ulp, and is semi-monotonic.
+   *
+   * @param a the tan to turn back into an angle
+   * @return arcsin(a)
+   * @see #atan2(double, double)
+   */
+  public static native double atan(double a);
+
+  /**
+   * A special version of the trigonometric function <em>arctan</em>, for
+   * converting rectangular coordinates <em>(x, y)</em> to polar
+   * <em>(r, theta)</em>. This computes the arctangent of x/y in the range
+   * of -pi to pi radians (-180 to 180 degrees). Special cases:<ul>
+   * <li>If either argument is NaN, the result is NaN.</li>
+   * <li>If the first argument is positive zero and the second argument is
+   * positive, or the first argument is positive and finite and the second
+   * argument is positive infinity, then the result is positive zero.</li>
+   * <li>If the first argument is negative zero and the second argument is
+   * positive, or the first argument is negative and finite and the second
+   * argument is positive infinity, then the result is negative zero.</li>
+   * <li>If the first argument is positive zero and the second argument is
+   * negative, or the first argument is positive and finite and the second
+   * argument is negative infinity, then the result is the double value
+   * closest to pi.</li>
+   * <li>If the first argument is negative zero and the second argument is
+   * negative, or the first argument is negative and finite and the second
+   * argument is negative infinity, then the result is the double value
+   * closest to -pi.</li>
+   * <li>If the first argument is positive and the second argument is
+   * positive zero or negative zero, or the first argument is positive
+   * infinity and the second argument is finite, then the result is the
+   * double value closest to pi/2.</li>
+   * <li>If the first argument is negative and the second argument is
+   * positive zero or negative zero, or the first argument is negative
+   * infinity and the second argument is finite, then the result is the
+   * double value closest to -pi/2.</li>
+   * <li>If both arguments are positive infinity, then the result is the
+   * double value closest to pi/4.</li>
+   * <li>If the first argument is positive infinity and the second argument
+   * is negative infinity, then the result is the double value closest to
+   * 3*pi/4.</li>
+   * <li>If the first argument is negative infinity and the second argument
+   * is positive infinity, then the result is the double value closest to
+   * -pi/4.</li>
+   * <li>If both arguments are negative infinity, then the result is the
+   * double value closest to -3*pi/4.</li>
+   *
+   * </ul><p>This is accurate within 2 ulps, and is semi-monotonic. To get r,
+   * use sqrt(x*x+y*y).
+   *
+   * @param y the y position
+   * @param x the x position
+   * @return <em>theta</em> in the conversion of (x, y) to (r, theta)
+   * @see #atan(double)
+   */
+  public static native double atan2(double y, double x);
+
+  /**
+   * Take <em>e</em><sup>a</sup>.  The opposite of <code>log()</code>. If the
+   * argument is NaN, the result is NaN; if the argument is positive infinity,
+   * the result is positive infinity; and if the argument is negative
+   * infinity, the result is positive zero. This is accurate within 1 ulp,
+   * and is semi-monotonic.
+   *
+   * @param a the number to raise to the power
+   * @return the number raised to the power of <em>e</em>
+   * @see #log(double)
+   * @see #pow(double, double)
+   */
+  public static native double exp(double a);
+
+  /**
+   * Take ln(a) (the natural log).  The opposite of <code>exp()</code>. If the
+   * argument is NaN or negative, the result is NaN; if the argument is
+   * positive infinity, the result is positive infinity; and if the argument
+   * is either zero, the result is negative infinity. This is accurate within
+   * 1 ulp, and is semi-monotonic.
+   *
+   * <p>Note that the way to get log<sub>b</sub>(a) is to do this:
+   * <code>ln(a) / ln(b)</code>.
+   *
+   * @param a the number to take the natural log of
+   * @return the natural log of <code>a</code>
+   * @see #exp(double)
+   */
+  public static native double log(double a);
+
+  /**
+   * Take a square root. If the argument is NaN or negative, the result is
+   * NaN; if the argument is positive infinity, the result is positive
+   * infinity; and if the result is either zero, the result is the same.
+   * This is accurate within the limits of doubles.
+   *
+   * <p>For other roots, use pow(a, 1 / rootNumber).
+   *
+   * @param a the numeric argument
+   * @return the square root of the argument
+   * @see #pow(double, double)
+   */
+  public static native double sqrt(double a);
+
+  /**
+   * Raise a number to a power. Special cases:<ul>
+   * <li>If the second argument is positive or negative zero, then the result
+   * is 1.0.</li>
+   * <li>If the second argument is 1.0, then the result is the same as the
+   * first argument.</li>
+   * <li>If the second argument is NaN, then the result is NaN.</li>
+   * <li>If the first argument is NaN and the second argument is nonzero,
+   * then the result is NaN.</li>
+   * <li>If the absolute value of the first argument is greater than 1 and
+   * the second argument is positive infinity, or the absolute value of the
+   * first argument is less than 1 and the second argument is negative
+   * infinity, then the result is positive infinity.</li>
+   * <li>If the absolute value of the first argument is greater than 1 and
+   * the second argument is negative infinity, or the absolute value of the
+   * first argument is less than 1 and the second argument is positive
+   * infinity, then the result is positive zero.</li>
+   * <li>If the absolute value of the first argument equals 1 and the second
+   * argument is infinite, then the result is NaN.</li>
+   * <li>If the first argument is positive zero and the second argument is
+   * greater than zero, or the first argument is positive infinity and the
+   * second argument is less than zero, then the result is positive zero.</li>
+   * <li>If the first argument is positive zero and the second argument is
+   * less than zero, or the first argument is positive infinity and the
+   * second argument is greater than zero, then the result is positive
+   * infinity.</li>
+   * <li>If the first argument is negative zero and the second argument is
+   * greater than zero but not a finite odd integer, or the first argument is
+   * negative infinity and the second argument is less than zero but not a
+   * finite odd integer, then the result is positive zero.</li>
+   * <li>If the first argument is negative zero and the second argument is a
+   * positive finite odd integer, or the first argument is negative infinity
+   * and the second argument is a negative finite odd integer, then the result
+   * is negative zero.</li>
+   * <li>If the first argument is negative zero and the second argument is
+   * less than zero but not a finite odd integer, or the first argument is
+   * negative infinity and the second argument is greater than zero but not a
+   * finite odd integer, then the result is positive infinity.</li>
+   * <li>If the first argument is negative zero and the second argument is a
+   * negative finite odd integer, or the first argument is negative infinity
+   * and the second argument is a positive finite odd integer, then the result
+   * is negative infinity.</li>
+   * <li>If the first argument is less than zero and the second argument is a
+   * finite even integer, then the result is equal to the result of raising
+   * the absolute value of the first argument to the power of the second
+   * argument.</li>
+   * <li>If the first argument is less than zero and the second argument is a
+   * finite odd integer, then the result is equal to the negative of the
+   * result of raising the absolute value of the first argument to the power
+   * of the second argument.</li>
+   * <li>If the first argument is finite and less than zero and the second
+   * argument is finite and not an integer, then the result is NaN.</li>
+   * <li>If both arguments are integers, then the result is exactly equal to
+   * the mathematical result of raising the first argument to the power of
+   * the second argument if that result can in fact be represented exactly as
+   * a double value.</li>
+   *
+   * </ul><p>(In the foregoing descriptions, a floating-point value is
+   * considered to be an integer if and only if it is a fixed point of the
+   * method {@link #ceil(double)} or, equivalently, a fixed point of the
+   * method {@link #floor(double)}. A value is a fixed point of a one-argument
+   * method if and only if the result of applying the method to the value is
+   * equal to the value.) This is accurate within 1 ulp, and is semi-monotonic.
+   *
+   * @param a the number to raise
+   * @param b the power to raise it to
+   * @return a<sup>b</sup>
+   */
+  public static native double pow(double a, double b);
+
+  /**
+   * Get the IEEE 754 floating point remainder on two numbers. This is the
+   * value of <code>x - y * <em>n</em></code>, where <em>n</em> is the closest
+   * double to <code>x / y</code> (ties go to the even n); for a zero
+   * remainder, the sign is that of <code>x</code>. If either argument is NaN,
+   * the first argument is infinite, or the second argument is zero, the result
+   * is NaN; if x is finite but y is infinite, the result is x. This is
+   * accurate within the limits of doubles.
+   *
+   * @param x the dividend (the top half)
+   * @param y the divisor (the bottom half)
+   * @return the IEEE 754-defined floating point remainder of x/y
+   * @see #rint(double)
+   */
+  public static native double IEEEremainder(double x, double y);
+
+  /**
+   * Take the nearest integer that is that is greater than or equal to the
+   * argument. If the argument is NaN, infinite, or zero, the result is the
+   * same; if the argument is between -1 and 0, the result is negative zero.
+   * Note that <code>Math.ceil(x) == -Math.floor(-x)</code>.
+   *
+   * @param a the value to act upon
+   * @return the nearest integer >= <code>a</code>
+   */
+  public static native double ceil(double a);
+
+  /**
+   * Take the nearest integer that is that is less than or equal to the
+   * argument. If the argument is NaN, infinite, or zero, the result is the
+   * same. Note that <code>Math.ceil(x) == -Math.floor(-x)</code>.
+   *
+   * @param a the value to act upon
+   * @return the nearest integer <= <code>a</code>
+   */
+  public static native double floor(double a);
+
+  /**
+   * Take the nearest integer to the argument.  If it is exactly between
+   * two integers, the even integer is taken. If the argument is NaN,
+   * infinite, or zero, the result is the same.
+   *
+   * @param a the value to act upon
+   * @return the nearest integer to <code>a</code>
+   */
+  public static native double rint(double a);
+
+  /**
+   * <p>
+   * Take a cube root. If the argument is NaN, an infinity or zero, then
+   * the original value is returned.  The returned result must be within 1 ulp
+   * of the exact result.  For a finite value, <code>x</code>, the cube root
+   * of <code>-x</code> is equal to the negation of the cube root
+   * of <code>x</code>. 
+   * </p>
+   * <p>
+   * For a square root, use <code>sqrt</code>.  For other roots, use
+   * <code>pow(a, 1 / rootNumber)</code>.
+   * </p>
+   *
+   * @param a the numeric argument
+   * @return the cube root of the argument
+   * @see #sqrt(double)
+   * @see #pow(double, double)
+   */
+  public static native double cbrt(double a);
+
+  /**
+   * <p>
+   * Returns the hyperbolic cosine of the given value.  For a value,
+   * <code>x</code>, the hyperbolic cosine is <code>(e<sup>x</sup> + 
+   * e<sup>-x</sup>)/2</code>
+   * with <code>e</code> being <a href="#E">Euler's number</a>.  The returned
+   * result must be within 2.5 ulps of the exact result.
+   * </p>
+   * <p>
+   * If the supplied value is <code>NaN</code>, then the original value is
+   * returned.  For either infinity, positive infinity is returned.
+   * The hyperbolic cosine of zero must be 1.0.
+   * </p>
+   * 
+   * @param a the numeric argument
+   * @return the hyperbolic cosine of <code>a</code>.
+   * @since 1.5
+   */
+  public static native double cosh(double a);
+
+  /**
+   * <p>
+   * Returns <code>e<sup>a</sup> - 1.  For values close to 0, the
+   * result of <code>expm1(a) + 1</code> tend to be much closer to the
+   * exact result than simply <code>exp(x)</code>.  The result must be within
+   * 1 ulp of the exact result, and results must be semi-monotonic.  For finite
+   * inputs, the returned value must be greater than or equal to -1.0.  Once
+   * a result enters within half a ulp of this limit, the limit is returned.
+   * </p>   
+   * <p>
+   * For <code>NaN</code>, positive infinity and zero, the original value
+   * is returned.  Negative infinity returns a result of -1.0 (the limit).
+   * </p>
+   * 
+   * @param a the numeric argument
+   * @return <code>e<sup>a</sup> - 1</code>
+   * @since 1.5
+   */
+  public static native double expm1(double a);
+
+  /**
+   * <p>
+   * Returns the hypotenuse, <code>a<sup>2</sup> + b<sup>2</sup></code>,
+   * without intermediate overflow or underflow.  The returned result must be
+   * within 1 ulp of the exact result.  If one parameter is held constant,
+   * then the result in the other parameter must be semi-monotonic.
+   * </p>
+   * <p>
+   * If either of the arguments is an infinity, then the returned result
+   * is positive infinity.  Otherwise, if either argument is <code>NaN</code>,
+   * then <code>NaN</code> is returned.
+   * </p>
+   * 
+   * @param a the first parameter.
+   * @param b the second parameter.
+   * @return the hypotenuse matching the supplied parameters.
+   * @since 1.5
+   */
+  public static native double hypot(double a, double b);
+
+  /**
+   * <p>
+   * Returns the base 10 logarithm of the supplied value.  The returned
+   * result must within 1 ulp of the exact result, and the results must be
+   * semi-monotonic.
+   * </p>
+   * <p>
+   * Arguments of either <code>NaN</code> or less than zero return
+   * <code>NaN</code>.  An argument of positive infinity returns positive
+   * infinity.  Negative infinity is returned if either positive or negative
+   * zero is supplied.  Where the argument is the result of
+   * <code>10<sup>n</sup</code>, then <code>n</code> is returned.
+   * </p>
+   *
+   * @param a the numeric argument.
+   * @return the base 10 logarithm of <code>a</code>.
+   * @since 1.5
+   */
+  public static native double log10(double a);
+
+  /**
+   * <p>
+   * Returns the natural logarithm resulting from the sum of the argument,
+   * <code>a</code> and 1.  For values close to 0, the
+   * result of <code>log1p(a)</code> tend to be much closer to the
+   * exact result than simply <code>log(1.0+a)</code>.  The returned
+   * result must be within 1 ulp of the exact result, and the results must be
+   * semi-monotonic.
+   * </p>
+   * <p>
+   * Arguments of either <code>NaN</code> or less than -1 return
+   * <code>NaN</code>.  An argument of positive infinity or zero
+   * returns the original argument.  Negative infinity is returned from an
+   * argument of -1.
+   * </p>
+   *
+   * @param a the numeric argument.
+   * @return the natural logarithm of <code>a</code> + 1.
+   * @since 1.5
+   */
+  public static native double log1p(double a);
+
+  /**
+   * <p>
+   * Returns the hyperbolic sine of the given value.  For a value,
+   * <code>x</code>, the hyperbolic sine is <code>(e<sup>x</sup> - 
+   * e<sup>-x</sup>)/2</code>
+   * with <code>e</code> being <a href="#E">Euler's number</a>.  The returned
+   * result must be within 2.5 ulps of the exact result.
+   * </p>
+   * <p>
+   * If the supplied value is <code>NaN</code>, an infinity or a zero, then the
+   * original value is returned.
+   * </p>
+   * 
+   * @param a the numeric argument
+   * @return the hyperbolic sine of <code>a</code>.
+   * @since 1.5
+   */
+  public static native double sinh(double a);
+
+  /**
+   * <p>
+   * Returns the hyperbolic tangent of the given value.  For a value,
+   * <code>x</code>, the hyperbolic tangent is <code>(e<sup>x</sup> - 
+   * e<sup>-x</sup>)/(e<sup>x</sup> + e<sup>-x</sup>)</code>
+   * (i.e. <code>sinh(a)/cosh(a)</code>)
+   * with <code>e</code> being <a href="#E">Euler's number</a>.  The returned
+   * result must be within 2.5 ulps of the exact result.  The absolute value
+   * of the exact result is always less than 1.  Computed results are thus
+   * less than or equal to 1 for finite arguments, with results within
+   * half a ulp of either positive or negative 1 returning the appropriate
+   * limit value (i.e. as if the argument was an infinity).
+   * </p>
+   * <p>
+   * If the supplied value is <code>NaN</code> or zero, then the original
+   * value is returned.  Positive infinity returns +1.0 and negative infinity
+   * returns -1.0.
+   * </p>
+   * 
+   * @param a the numeric argument
+   * @return the hyperbolic tangent of <code>a</code>.
+   * @since 1.5
+   */
+  public static native double tanh(double a);
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMObject.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMObject.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMObject.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMObject.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,105 @@
+/* VMObject.java -- Reference implementation for VM hooks used by Object
+   Copyright (C) 1998, 2002, 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 java.lang;
+
+/**
+ * Object is the ultimate superclass of every class (excepting interfaces).
+ * As such, it needs help from the VM.
+ *
+ * @author John Keiser
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ */
+final class VMObject
+{
+  /**
+   * Returns the runtime {@link Class} of a given Object.
+   *
+   * @param obj the object to return the class for.
+   *
+   * @return the class of the Object.
+   */
+  static native Class getClass(Object obj);
+  
+  /**
+   * The VM is expected to make a field-for-field shallow copy of the
+   * argument. Thus, the copy has the same runtime type as the argument.
+   * Note, however, that the cloned object must still be finalizable, even
+   * if the original has already had finalize() invoked on it.
+   *
+   * @param c the Cloneable to clone
+   * @return the clone
+   */
+  static native Object clone(Cloneable c);
+
+  /**
+   * Wakes up one of the threads that is waiting on this Object's monitor.
+   * Only the owner of a lock on the Object may call this method. The Thread
+   * to wake up is chosen arbitrarily.
+   *
+   * @param o the object doing the notify
+   * @throw IllegalMonitorStateException if this Thread does not own the
+   *        lock on the Object
+   */
+  static native void notify(Object o) throws IllegalMonitorStateException;
+
+  /**
+   * Wakes up all of the threads waiting on this Object's monitor.  Only
+   * the owner of the lock on this Object may call this method.
+   *
+   * @param o the object doing the notifyAll
+   * @throws IllegalMonitorStateException if this Thread does not own the
+   *         lock on the Object
+   */
+  static native void notifyAll(Object o) throws IllegalMonitorStateException;
+
+  /**
+   * Waits a specified amount of time for notify() or notifyAll() to be
+   * called on this Object.  The VM does not have to pay attention to the
+   * ns argument, if it does not have that much granularity.
+   *
+   * @param o the object to suspend on
+   * @param ms milliseconds to wait (1,000 milliseconds = 1 second)
+   * @param ns nanoseconds to wait beyond ms (1,000,000 nanoseconds
+   *        == 1 millisecond)
+   * @throws IllegalMonitorStateException if this Thread does not own the
+   *         lock on the Object
+   * @throws InterruptedException if some other Thread interrupts this Thread
+   */
+  static native void wait(Object o, long ms, int ns)
+    throws IllegalMonitorStateException, InterruptedException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMProcess.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMProcess.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMProcess.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMProcess.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,402 @@
+/* java.lang.VMProcess -- VM implementation of java.lang.Process
+   Copyright (C) 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;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents one external process. Each instance of this class is in
+ * one of three states: INITIAL, RUNNING, or TERMINATED. The instance
+ * is {@link Object#notifyAll notifyAll()}'d each time the state changes.
+ * The state of all instances is managed by a single dedicated thread
+ * which does the actual fork()/exec() and wait() system calls. User
+ * threads {@link Object#wait()} on the instance when creating the
+ * process or waiting for it to terminate.
+ *
+ * <p>
+ * See
+ * <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11801">GCC bug
+ * #11801</a> for the motivation behind the design of this class.
+ *
+ * @author Archie Cobbs
+ * @see Process
+ * @see Runtime#exec(String)
+ */
+final class VMProcess extends Process
+{
+
+  // Possible states for a VMProcess
+  private static final int INITIAL = 0;
+  private static final int RUNNING = 1;
+  private static final int TERMINATED = 2;
+
+  // Dedicated thread that does all the fork()'ing and wait()'ing.
+  static Thread processThread;
+
+  // New processes waiting to be spawned by processThread.
+  static final LinkedList workList = new LinkedList();
+
+  // Return values set by nativeReap() when a child is reaped.
+  // These are only accessed by processThread so no locking required.
+  static long reapedPid;
+  static int reapedExitValue;
+
+  // Information about this process
+  int state;				       // current state of process
+  final String[] cmd;			       // copied from Runtime.exec()
+  final String[] env;			       // copied from Runtime.exec()
+  final File dir;			       // copied from Runtime.exec()
+  Throwable exception;			       // if process failed to start
+  long pid;				       // process id
+  OutputStream stdin;			       // process input stream
+  InputStream stdout;			       // process output stream
+  InputStream stderr;			       // process error stream
+  int exitValue;			       // process exit value
+  boolean redirect;			       // redirect stderr -> stdout
+
+  //
+  // Dedicated thread that does all the fork()'ing and wait()'ing
+  // for external processes. This is needed because some systems like
+  // Linux use a process-per-thread model, which means the same thread
+  // that did the fork()/exec() must also do the wait().
+  //
+  private static class ProcessThread extends Thread
+  {
+
+    // Max time (in ms) we'll delay before trying to reap another child.
+    private static final int MAX_REAP_DELAY = 1000;
+
+    // Processes created but not yet terminated; maps Long(pid) -> VMProcess
+    // Only used in run() and spawn() method from this Thread, so no locking.
+    private final HashMap activeMap = new HashMap();
+
+    // We have an explicit constructor, because the default
+    // constructor will be private, which means the compiler will have
+    // to generate a second package-private constructor, which is
+    // bogus.
+    ProcessThread ()
+    {
+    }
+
+    public void run()
+    {
+      final LinkedList workList = VMProcess.workList;
+      while (true)
+	{
+
+	  // Get the next process to spawn (if any) and spawn it. Spawn
+	  // at most one at a time before checking for reapable children.
+	  VMProcess process = null;
+	  synchronized (workList)
+	    {
+	      if (!workList.isEmpty())
+		process = (VMProcess)workList.removeFirst();
+	    }
+
+	  if (process != null)
+	    spawn(process);
+
+
+	  // Check for termination of active child processes
+	  while (!activeMap.isEmpty() && VMProcess.nativeReap())
+	    {
+	      long pid = VMProcess.reapedPid;
+	      int exitValue = VMProcess.reapedExitValue;
+	      process = (VMProcess)activeMap.remove(new Long(pid));
+	      if (process != null)
+		{
+		  synchronized (process)
+		    {
+		      process.exitValue = exitValue;
+		      process.state = TERMINATED;
+		      process.notify();
+		    }
+		}
+	      else
+		System.err.println("VMProcess WARNING reaped unknown process: "
+				   + pid);
+	    }
+
+
+	  // If there are more new processes to create, go do that now.
+	  // If there is nothing left to do, exit this thread. Otherwise,
+	  // sleep a little while, and then check again for reapable children.
+	  // We will get woken up immediately if there are new processes to
+	  // spawn, but not if there are new children to reap. So we only
+	  // sleep a short time, in effect polling while processes are active.
+	  synchronized (workList)
+	    {
+	      if (!workList.isEmpty())
+		continue;
+	      if (activeMap.isEmpty())
+		{
+		  processThread = null;
+		  break;
+		}
+	
+	      try
+		{
+		  workList.wait(MAX_REAP_DELAY);
+		}
+	      catch (InterruptedException e)
+		{
+		  /* ignore */
+		}
+	    }
+	}
+    }
+
+    // Spawn a process
+    private void spawn(VMProcess process)
+    {
+      
+      // Spawn the process and put it in our active map indexed by pid.
+      // If the spawn operation fails, store the exception with the process.
+      // In either case, wake up thread that created the process.
+      synchronized (process)
+	{
+	  try
+	    {
+	      process.nativeSpawn(process.cmd, process.env, process.dir,
+				  process.redirect);
+	      process.state = RUNNING;
+	      activeMap.put(new Long(process.pid), process);
+	    }
+          catch (ThreadDeath death)
+            {
+              throw death;
+            }
+	  catch (Throwable t)
+	    {
+	      process.state = TERMINATED;
+	      process.exception = t;
+	    }
+	  process.notify();
+	}
+    }
+  }
+
+  // Constructor
+  private VMProcess(String[] cmd, String[] env, File dir, boolean redirect)
+    throws IOException
+  {
+    
+    // Initialize this process
+    this.state = INITIAL;
+    this.cmd = cmd;
+    this.env = env;
+    this.dir = dir;
+    this.redirect = redirect;
+  
+    // Add process to the new process work list and wakeup processThread
+    synchronized (workList)
+      {
+	workList.add(this);
+	if (processThread == null)
+	  {
+	    processThread = new ProcessThread();
+	    processThread.setDaemon(true);
+	    processThread.start();
+	  }
+	else
+	  {
+	    workList.notify();
+	  }
+      }
+
+    // Wait for processThread to spawn this process and update its state
+    synchronized (this)
+      {
+	while (state == INITIAL)
+	  {
+	    try
+	      {
+		wait();
+	      }
+	    catch (InterruptedException e)
+	      {
+		/* ignore */
+	      }
+	  }
+      }
+
+    // If spawning failed, rethrow the exception in this thread
+    if (exception != null)
+      {
+	exception.fillInStackTrace();
+	if (exception instanceof IOException)
+	  throw (IOException)exception;
+
+	if (exception instanceof Error)
+	  throw (Error)exception;
+
+	if (exception instanceof RuntimeException)
+	  throw (RuntimeException)exception;
+
+	throw new RuntimeException(exception);
+      }
+  }
+
+  // Invoked by native code (from nativeSpawn()) to record process info.
+  private void setProcessInfo(OutputStream stdin,
+			      InputStream stdout, InputStream stderr, long pid)
+  {
+    this.stdin = stdin;
+    this.stdout = stdout;
+    if (stderr == null)
+      this.stderr = new InputStream()
+	{
+	  public int read() throws IOException
+	  {
+	    return -1;
+	  }
+	};
+    else
+      this.stderr = stderr;
+    this.pid = pid;
+  }
+
+  /**
+   * Entry point from Runtime.exec().
+   */
+  static Process exec(String[] cmd, String[] env, File dir) throws IOException
+  {
+    return new VMProcess(cmd, env, dir, false);
+  }
+
+  static Process exec(List cmd, Map env,
+		      File dir, boolean redirect) throws IOException
+  {
+    String[] acmd = (String[]) cmd.toArray(new String[cmd.size()]);
+    String[] aenv = new String[env.size()];
+
+    int i = 0;
+    Iterator iter = env.entrySet().iterator();
+    while (iter.hasNext())
+      {
+	Map.Entry entry = (Map.Entry) iter.next();
+	aenv[i++] = entry.getKey() + "=" + entry.getValue();
+      }
+
+    return new VMProcess(acmd, aenv, dir, redirect);
+  }
+
+  public OutputStream getOutputStream()
+  {
+    return stdin;
+  }
+
+  public InputStream getInputStream()
+  {
+    return stdout;
+  }
+
+  public InputStream getErrorStream()
+  {
+    return stderr;
+  }
+
+  public synchronized int waitFor() throws InterruptedException
+  {
+    while (state != TERMINATED)
+      wait();
+    return exitValue;
+  }
+
+  public synchronized int exitValue()
+  {
+    if (state != TERMINATED)
+      throw new IllegalThreadStateException();
+    return exitValue;
+  }
+
+  public synchronized void destroy()
+  {
+    if (state == TERMINATED)
+      return;
+
+    nativeKill(pid);
+    
+    while (state != TERMINATED)
+      {
+	try
+	  {
+	    wait();
+	  }
+	catch (InterruptedException e)
+	  {
+	    /* ignore */
+	  }
+      }
+  }
+
+  /**
+   * Does the fork()/exec() thing to create the O/S process.
+   * Must invoke setProcessInfo() before returning successfully.
+   * This method is only invoked by processThread.
+   *
+   * @throws IOException if the O/S process could not be created.
+   */
+  native void nativeSpawn(String[] cmd, String[] env, File dir,
+			  boolean redirect)
+    throws IOException;
+
+  /**
+   * Test for a reapable child process, and reap if so. Does not block.
+   * If a child was reaped, this method must set reapedPid and
+   * reapedExitValue appropriately before returning.
+   * This method is only invoked by processThread.
+   *
+   * @return true if a child was reaped, otherwise false
+   */
+  // This is not private as it is called from an inner class.
+  static native boolean nativeReap();
+
+  /**
+   * Kill a process. This sends it a fatal signal but does not reap it.
+   */
+  private static native void nativeKill(long pid);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMRuntime.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMRuntime.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMRuntime.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMRuntime.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,192 @@
+/* VMRuntime.java -- VM interface to Runtime
+   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.io.File;
+import java.io.IOException;
+
+/**
+ * VMRuntime represents the interface to the Virtual Machine.
+ *
+ * @author Jeroen Frijters
+ */
+final class VMRuntime
+{
+    /**
+     * No instance is ever created.
+     */
+    private VMRuntime() 
+    {
+    }
+
+    /**
+     * Returns the number of available processors currently available to the
+     * virtual machine. This number may change over time; so a multi-processor
+     * program want to poll this to determine maximal resource usage.
+     *
+     * @return the number of processors available, at least 1
+     */
+    static native int availableProcessors();
+
+    /**
+     * Find out how much memory is still free for allocating Objects on the heap.
+     *
+     * @return the number of bytes of free memory for more Objects
+     */
+    static native long freeMemory();
+
+    /**
+     * Find out how much memory total is available on the heap for allocating
+     * Objects.
+     *
+     * @return the total number of bytes of memory for Objects
+     */
+    static native long totalMemory();
+
+    /**
+     * Returns the maximum amount of memory the virtual machine can attempt to
+     * use. This may be <code>Long.MAX_VALUE</code> if there is no inherent
+     * limit (or if you really do have a 8 exabyte memory!).
+     *
+     * @return the maximum number of bytes the virtual machine will attempt
+     *         to allocate
+     */
+    static native long maxMemory();
+
+    /**
+     * Run the garbage collector. This method is more of a suggestion than
+     * anything. All this method guarantees is that the garbage collector will
+     * have "done its best" by the time it returns. Notice that garbage
+     * collection takes place even without calling this method.
+     */
+    static native void gc();
+
+    /**
+     * Run finalization on all Objects that are waiting to be finalized. Again,
+     * a suggestion, though a stronger one than {@link #gc()}. This calls the
+     * <code>finalize</code> method of all objects waiting to be collected.
+     *
+     * @see #finalize()
+     */
+    static native void runFinalization();
+
+    /**
+     * Run finalization on all finalizable Objects (even live ones). This
+     * should only be called immediately prior to VM termination.
+     *
+     * @see #finalize()
+     */
+    static native void runFinalizationForExit();
+
+    /**
+     * Tell the VM to trace every bytecode instruction that executes (print out
+     * a trace of it).  No guarantees are made as to where it will be printed,
+     * and the VM is allowed to ignore this request.
+     *
+     * @param on whether to turn instruction tracing on
+     */
+    static native void traceInstructions(boolean on);
+
+    /**
+     * Tell the VM to trace every method call that executes (print out a trace
+     * of it).  No guarantees are made as to where it will be printed, and the
+     * VM is allowed to ignore this request.
+     *
+     * @param on whether to turn method tracing on
+     */
+    static native void traceMethodCalls(boolean on);
+
+    /**
+     * Native method that actually sets the finalizer setting.
+     *
+     * @param value whether to run finalizers on exit
+     */
+    static native void runFinalizersOnExit(boolean value);
+
+    /**
+     * Native method that actually shuts down the virtual machine.
+     *
+     * @param status the status to end the process with
+     */
+    static native void exit(int status);
+
+    /**
+     * Load a file. If it has already been loaded, do nothing. The name has
+     * already been mapped to a true filename.
+     *
+     * @param filename the file to load
+     * @param loader class loader, or <code>null</code> for the boot loader
+     * @return 0 on failure, nonzero on success
+     */
+    static native int nativeLoad(String filename, ClassLoader loader);
+
+    /**
+     * Map a system-independent "short name" to the full file name.
+     *
+     * @param libname the short version of the library name
+     * @return the full filename
+     */
+    static native String mapLibraryName(String libname);
+
+    /**
+     * Execute a process. The command line has already been tokenized, and
+     * the environment should contain name=value mappings. If directory is null,
+     * use the current working directory; otherwise start the process in that
+     * directory.  If env is null, then the new process should inherit
+     * the environment of this process.
+     *
+     * @param cmd the non-null command tokens
+     * @param env the environment setup
+     * @param dir the directory to use, may be null
+     * @return the newly created process
+     * @throws NullPointerException if cmd or env have null elements
+     */
+    static Process exec(String[] cmd, String[] env, File dir)
+	throws IOException {
+      return VMProcess.exec(cmd, env, dir);
+    }
+
+    /**
+     * This method is called by Runtime.addShutdownHook() when it is
+     * called for the first time. It enables the VM to lazily setup
+     * an exit handler, should it so desire.
+     */
+    static void enableShutdownHooks()
+    {
+    }
+} // class VMRuntime

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMString.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMString.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMString.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMString.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* 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 at 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;
+  }
+
+} // class VMString

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMSystem.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMSystem.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMSystem.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMSystem.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,220 @@
+/* VMSystem.java -- helper for java.lang.system
+   Copyright (C) 1998, 2002, 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 java.lang;
+
+import java.util.List;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.PrintStream;
+
+/**
+ * VMSystem is a package-private helper class for System that the
+ * VM must implement.
+ *
+ * @author John Keiser
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ */
+final class VMSystem
+{
+  /**
+   * Copy one array onto another from <code>src[srcStart]</code> ...
+   * <code>src[srcStart+len-1]</code> to <code>dest[destStart]</code> ...
+   * <code>dest[destStart+len-1]</code>. First, the arguments are validated:
+   * neither array may be null, they must be of compatible types, and the
+   * start and length must fit within both arrays. Then the copying starts,
+   * and proceeds through increasing slots.  If src and dest are the same
+   * array, this will appear to copy the data to a temporary location first.
+   * An ArrayStoreException in the middle of copying will leave earlier
+   * elements copied, but later elements unchanged.
+   *
+   * @param src the array to copy elements from
+   * @param srcStart the starting position in src
+   * @param dest the array to copy elements to
+   * @param destStart the starting position in dest
+   * @param len the number of elements to copy
+   * @throws NullPointerException if src or dest is null
+   * @throws ArrayStoreException if src or dest is not an array, if they are
+   *         not compatible array types, or if an incompatible runtime type
+   *         is stored in dest
+   * @throws IndexOutOfBoundsException if len is negative, or if the start or
+   *         end copy position in either array is out of bounds
+   */
+  static native void arraycopy(Object src, int srcStart,
+                               Object dest, int destStart, int len);
+
+  /**
+   * Get a hash code computed by the VM for the Object. This hash code will
+   * be the same as Object's hashCode() method.  It is usually some
+   * convolution of the pointer to the Object internal to the VM.  It
+   * follows standard hash code rules, in that it will remain the same for a
+   * given Object for the lifetime of that Object.
+   *
+   * @param o the Object to get the hash code for
+   * @return the VM-dependent hash code for this Object
+   */
+  static native int identityHashCode(Object o);
+
+  /**
+   * Convert a library name to its platform-specific variant.
+   *
+   * @param libname the library name, as used in <code>loadLibrary</code>
+   * @return the platform-specific mangling of the name
+   * @XXX Add this method
+  static native String mapLibraryName(String libname);
+   */
+
+  /**
+   * Set {@link System#in} to a new InputStream.
+   *
+   * @param in the new InputStream
+   * @see #setIn(InputStream)
+   */
+  static native void setIn(InputStream in);
+
+  /**
+   * Set {@link System#out} to a new PrintStream.
+   *
+   * @param out the new PrintStream
+   * @see #setOut(PrintStream)
+   */
+  static native void setOut(PrintStream out);
+
+  /**
+   * Set {@link System#err} to a new PrintStream.
+   *
+   * @param err the new PrintStream
+   * @see #setErr(PrintStream)
+   */
+  static native void setErr(PrintStream err);
+
+  /**
+   * Get the current time, measured in the number of milliseconds from the
+   * beginning of Jan. 1, 1970. This is gathered from the system clock, with
+   * any attendant incorrectness (it may be timezone dependent).
+   *
+   * @return the current time
+   * @see java.util.Date
+   */
+   public static long currentTimeMillis()
+   {
+     return nanoTime() / 1000000L;
+   }
+
+  /**
+   * <p>
+   * Returns the current value of a nanosecond-precise system timer.
+   * The value of the timer is an offset relative to some arbitrary fixed
+   * time, which may be in the future (making the value negative).  This
+   * method is useful for timing events where nanosecond precision is
+   * required.  This is achieved by calling this method before and after the
+   * event, and taking the difference betweent the two times:
+   * </p>
+   * <p>
+   * <code>long startTime = System.nanoTime();</code><br />
+   * <code>... <emph>event code</emph> ...</code><br />
+   * <code>long endTime = System.nanoTime();</code><br />
+   * <code>long duration = endTime - startTime;</code><br />
+   * </p>
+   * <p>
+   * Note that the value is only nanosecond-precise, and not accurate; there
+   * is no guarantee that the difference between two values is really a
+   * nanosecond.  Also, the value is prone to overflow if the offset
+   * exceeds 2^63.
+   * </p>
+   *
+   * @return the time of a system timer in nanoseconds.
+   * @since 1.5 
+   */
+  public static native long nanoTime();
+
+  /**
+   * Returns a list of 'name=value' pairs representing the current environment
+   * variables.
+   *
+   * @return a list of 'name=value' pairs.
+   */
+  static native List environ();
+
+  /**
+   * Helper method which creates the standard input stream.
+   * VM implementors may choose to construct these streams differently.
+   * This method can also return null if the stream is created somewhere 
+   * else in the VM startup sequence.
+   */
+  static InputStream makeStandardInputStream()
+  {
+    return new BufferedInputStream(new FileInputStream(FileDescriptor.in));
+  }
+  
+  /**
+   * Helper method which creates the standard output stream.
+   * VM implementors may choose to construct these streams differently.
+   * This method can also return null if the stream is created somewhere 
+   * else in the VM startup sequence.
+   */
+  static PrintStream makeStandardOutputStream()
+  {
+    return new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out)), true);
+  }
+
+  /**
+   * Helper method which creates the standard error stream.
+   * VM implementors may choose to construct these streams differently.
+   * This method can also return null if the stream is created somewhere 
+   * else in the VM startup sequence.
+   */
+  static PrintStream makeStandardErrorStream()
+  {
+    return new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err)), true);
+  }
+  
+  /**
+   * Gets the value of an environment variable.
+   * Always returning null is a valid (but not very useful) implementation.
+   *
+   * @param name The name of the environment variable (will not be null).
+   * @return The string value of the variable or null when the
+   *         environment variable is not defined.
+   */
+  static native String getenv(String name);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMThread.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMThread.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMThread.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMThread.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,461 @@
+/* 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 at frijters.net)
+ * @author Dalibor Topic (robilad at 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);
+	vmThread.start(stacksize);
+	thread.vmThread = vmThread;
+    }
+
+    /**
+     * 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;
+	}
+    }
+
+  /**
+   * 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();
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMThrowable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMThrowable.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMThrowable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/VMThrowable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,82 @@
+/* java.lang.VMThrowable -- VM support methods for Throwable.
+   Copyright (C) 1998, 1999, 2002 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;
+
+/**
+ * VM dependant state and support methods for Throwable.
+ * It is deliberately package local and final and should only be accessed
+ * by the Throwable class.
+ * <p>
+ * This is the GNU Classpath reference implementation, it should be adapted
+ * for a specific VM. The reference implementation does nothing.
+ *
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+final class VMThrowable
+{
+  /**
+   * VM private data.
+   */
+  private transient Object vmdata;
+
+  /**
+   * Private contructor, create VMThrowables with fillInStackTrace();
+   */
+  private VMThrowable() { }
+
+  /**
+   * Fill in the stack trace with the current execution stack.
+   * Called by <code>Throwable.fillInStackTrace()</code> to get the state of
+   * the VM. Can return null when the VM does not support caputing the VM
+   * execution state.
+   *
+   * @return a new VMThrowable containing the current execution stack trace.
+   * @see Throwable#fillInStackTrace()
+   */
+  static native VMThrowable fillInStackTrace(Throwable t);
+
+  /**
+   * Returns an <code>StackTraceElement</code> array based on the execution
+   * state of the VM as captured by <code>fillInStackTrace</code>.
+   * Called by <code>Throwable.getStackTrace()</code>.
+   *
+   * @return a non-null but possible zero length array of StackTraceElement.
+   * @see Throwable#getStackTrace()
+   */
+  native StackTraceElement[] getStackTrace(Throwable t);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/management/VMManagementFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/management/VMManagementFactory.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/management/VMManagementFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/management/VMManagementFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* VMManagementFactory.java - VM interface for obtaining system beans.
+   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 java.lang.management;
+
+/**
+ * Provides lists of resources required by the
+ * {@link java.lang.management.ManagementFactory} for
+ * creating beans.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+final class VMManagementFactory
+{
+
+  /**
+   * Return a list of the names of the currently available
+   * memory pools within the virtual machine.
+   *
+   * @return a list of memory pool names.
+   */
+  static native String[] getMemoryPoolNames();
+
+  /**
+   * Return a list of the names of the currently available
+   * memory managers within the virtual machine.  This should
+   * not include the garbage collectors listed below.
+   *
+   * @return a list of memory manager names.
+   */
+  static native String[] getMemoryManagerNames();
+
+  /**
+   * Return a list of the names of the currently available
+   * garbage collectors within the virtual machine.
+   *
+   * @return a list of garbage collector names.
+   */
+  static native String[] getGarbageCollectorNames();
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/Constructor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/Constructor.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/Constructor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/Constructor.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,398 @@
+/* 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.reflect.MethodSignatureParser;
+
+import java.util.Arrays;
+
+/**
+ * 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 at 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
+  extends AccessibleObject
+  implements GenericDeclaration, Member
+{
+  private Class clazz;
+  private int slot;
+  
+  private static final int CONSTRUCTOR_MODIFIERS
+    = Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC;
+
+  /**
+   * This class is uninstantiable except from native code.
+   */
+  private Constructor(Class declaringClass,int slot)
+  {
+    this.clazz = declaringClass;
+    this.slot = slot;
+  }
+
+  private Constructor()
+  {
+  }
+
+  /**
+   * Gets the class that declared this constructor.
+   * @return the class that declared this member
+   */
+  public Class getDeclaringClass()
+  {
+    return clazz;
+  }
+
+  /**
+   * 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 getDeclaringClass().getName();
+  }
+
+  /**
+   * Return the raw modifiers for this constructor.  In particular
+   * this will include the synthetic and varargs bits.
+   * @return the constructor's modifiers
+   */
+  private native int getModifiersInternal();
+
+  /**
+   * 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 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 (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 (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
+   */
+  public 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
+   */
+  public native Class[] 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)
+  {
+    if (!(o instanceof Constructor))
+      return false;
+    Constructor that = (Constructor)o; 
+    if (this.getDeclaringClass() != that.getDeclaringClass())
+      return false;
+    if (!Arrays.equals(this.getParameterTypes(), that.getParameterTypes()))
+      return false;
+    return true;
+  }
+
+  /**
+   * 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 getDeclaringClass().getName().hashCode();
+  }
+
+  /**
+   * Get a String representation of the Constructor. A Constructor's String
+   * representation is "<modifier> <classname>(<paramtypes>)
+   * throws <exceptions>", 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
+    StringBuilder sb = new StringBuilder(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();
+  }
+
+  /* FIXME[GENERICS]: Add X extends GenericDeclaration and TypeVariable<X> */
+  static void addTypeParameters(StringBuilder sb, TypeVariable[] 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()
+  {
+    StringBuilder sb = new StringBuilder(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
+   */
+  public Object newInstance(Object args[])
+    throws InstantiationException, IllegalAccessException,
+           InvocationTargetException
+  {
+    return constructNative(args, clazz, slot);
+  }
+
+  private native Object constructNative(Object[] args, Class declaringClass,
+                                        int slot)
+    throws InstantiationException, IllegalAccessException,
+           InvocationTargetException;
+
+  /**
+   * 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
+   */
+  /* FIXME[GENERICS]: Add <Constructor<T>> */
+  public TypeVariable[] getTypeParameters()
+  {
+    String sig = getSignature();
+    if (sig == null)
+      return new TypeVariable[0];
+    MethodSignatureParser p = new MethodSignatureParser(this, sig);
+    return p.getTypeParameters();
+  }
+
+  /**
+   * Return the String in the Signature attribute for this constructor. If there
+   * is no Signature attribute, return null.
+   */
+  private native String getSignature();
+
+  /**
+   * 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()
+  {
+    String sig = getSignature();
+    if (sig == null)
+      return getExceptionTypes();
+    MethodSignatureParser 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()
+  {
+    String sig = getSignature();
+    if (sig == null)
+      return getParameterTypes();
+    MethodSignatureParser p = new MethodSignatureParser(this, sig);
+    return p.getGenericParameterTypes();
+  }
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/Field.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/Field.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/Field.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/Field.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,662 @@
+/* java.lang.reflect.Field - reflection of Java fields
+   Copyright (C) 1998, 2001, 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.reflect.FieldSignatureParser;
+
+/**
+ * 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 at 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
+{
+  private Class declaringClass;
+  private String name;
+  private int slot;
+
+  private static final int FIELD_MODIFIERS
+    = Modifier.FINAL | Modifier.PRIVATE | Modifier.PROTECTED
+      | Modifier.PUBLIC | Modifier.STATIC | Modifier.TRANSIENT
+      | Modifier.VOLATILE;
+
+  /**
+   * This class is uninstantiable except natively.
+   */
+  private Field(Class declaringClass, String name, int slot)
+  {
+    this.declaringClass = declaringClass;
+    this.name = name;
+    this.slot = slot;
+  }
+
+  /**
+   * 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
+   */
+  public Class getDeclaringClass()
+  {
+    return declaringClass;
+  }
+
+  /**
+   * Gets the name of this field.
+   * @return the name of this field
+   */
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Return the raw modifiers for this field.
+   * @return the field's modifiers
+   */
+  private native int getModifiersInternal();
+
+  /**
+   * 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 getModifiersInternal() & FIELD_MODIFIERS;
+  }
+
+  /**
+   * Return true if this field is synthetic, false otherwise.
+   * @since 1.5
+   */
+  public boolean isSynthetic()
+  {
+    return (getModifiersInternal() & Modifier.SYNTHETIC) != 0;
+  }
+
+  /**
+   * Return true if this field represents an enum constant,
+   * false otherwise.
+   * @since 1.5
+   */
+  public boolean isEnumConstant()
+  {
+    return (getModifiersInternal() & Modifier.ENUM) != 0;
+  }
+
+  /**
+   * Gets the type of this field.
+   * @return the type of this field
+   */
+  public native Class 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)
+  {
+    if (!(o instanceof Field))
+      return false;
+    Field that = (Field)o; 
+    if (this.getDeclaringClass() != that.getDeclaringClass())
+      return false;
+    if (!this.getName().equals(that.getName()))
+      return false;
+    if (this.getType() != that.getType())
+      return false;
+    return true;
+  }
+
+  /**
+   * 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 getDeclaringClass().getName().hashCode() ^ getName().hashCode();
+  }
+
+  /**
+   * Get a String representation of the Field. A Field's String
+   * representation is "<modifiers> <type>
+   * <class>.<fieldname>".<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
+    StringBuilder sb = new StringBuilder(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()
+  {
+    StringBuilder sb = new StringBuilder(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 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)
+   */
+  public 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)
+   */
+  public 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.
+   *
+   * @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 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)
+   */
+  public 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)
+   */
+  public 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)
+   */
+  public 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)
+   */
+  public 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)
+   */
+  public 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)
+   */
+  public 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)
+   */
+  public 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)
+   */
+  public 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)
+   */
+  public 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)
+   */
+  public 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)
+   */
+  public 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)
+   */
+  public 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)
+   */
+  public 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)
+   */
+  public native void setDouble(Object o, double value)
+    throws IllegalAccessException;
+
+  /**
+   * 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()
+  {
+    String signature = getSignature();
+    if (signature == null)
+      return getType();
+    FieldSignatureParser p = new FieldSignatureParser(getDeclaringClass(),
+                                                      signature);
+    return p.getFieldType();
+  }
+
+  /**
+   * Return the String in the Signature attribute for this field. If there
+   * is no Signature attribute, return null.
+   */
+  private native String getSignature();
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/Method.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/Method.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/Method.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/Method.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,454 @@
+/* java.lang.reflect.Method - reflection of Java methods
+   Copyright (C) 1998, 2001, 2002, 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.reflect.MethodSignatureParser;
+
+import java.util.Arrays;
+
+/**
+ * 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 at 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
+{
+  Class declaringClass;
+  String name;
+  int slot;
+
+  private static final int METHOD_MODIFIERS
+    = Modifier.ABSTRACT | Modifier.FINAL | Modifier.NATIVE
+      | Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC
+      | Modifier.STATIC | Modifier.STRICT | Modifier.SYNCHRONIZED;
+
+  /**
+   * This class is uninstantiable.
+   */
+  private Method(Class declaringClass, String name, int slot)
+  {
+    this.declaringClass = declaringClass;
+    this.name = name;
+    this.slot = slot;
+  }
+
+  /**
+   * 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
+   */
+  public Class getDeclaringClass()
+  {
+    return declaringClass;
+  }
+
+  /**
+   * Gets the name of this method.
+   * @return the name of this method
+   */
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Return the raw modifiers for this method.
+   * @return the method's modifiers
+   */
+  private native int getModifiersInternal();
+
+  /**
+   * 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 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 (getModifiersInternal() & Modifier.BRIDGE) != 0;
+  }
+
+  /**
+   * Return true if this method is synthetic, false otherwise.
+   * @since 1.5
+   */
+  public boolean isSynthetic()
+  {
+    return (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 (getModifiersInternal() & Modifier.VARARGS) != 0;
+  }
+
+  /**
+   * Gets the return type of this method.
+   * @return the type of this method
+   */
+  public 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
+   */
+  public 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
+   */
+  public native Class[] 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)
+  {
+      // 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 (this.getDeclaringClass() != that.getDeclaringClass())
+      return false;
+    if (!this.getName().equals(that.getName()))
+      return false;
+    if (this.getReturnType() != that.getReturnType())
+      return false;
+    if (!Arrays.equals(this.getParameterTypes(), that.getParameterTypes()))
+      return false;
+    return true;
+  }
+
+  /**
+   * 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 getDeclaringClass().getName().hashCode() ^ getName().hashCode();
+  }
+
+  /**
+   * Get a String representation of the Method. A Method's String
+   * representation is "<modifiers> <returntype>
+   * <methodname>(<paramtypes>) throws <exceptions>", 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
+    StringBuilder sb = new StringBuilder(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
+    StringBuilder sb = new StringBuilder(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 invokeNative(o, args, declaringClass, slot);
+  }
+
+  /*
+   * NATIVE HELPERS
+   */
+
+  private native Object invokeNative(Object o, Object[] args,
+                                     Class declaringClass, int slot)
+    throws IllegalAccessException, InvocationTargetException;
+
+  /**
+   * 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
+   */
+  /* FIXME[GENERICS]: Should be TypeVariable<Method>[] */
+  public TypeVariable[] getTypeParameters()
+  {
+    String sig = getSignature();
+    if (sig == null)
+      return new TypeVariable[0];
+    MethodSignatureParser p = new MethodSignatureParser(this, sig);
+    return p.getTypeParameters();
+  }
+
+  /**
+   * Return the String in the Signature attribute for this method. If there
+   * is no Signature attribute, return null.
+   */
+  private native String getSignature();
+
+  /**
+   * 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()
+  {
+    String sig = getSignature();
+    if (sig == null)
+      return getExceptionTypes();
+    MethodSignatureParser 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()
+  {
+    String sig = getSignature();
+    if (sig == null)
+      return getParameterTypes();
+    MethodSignatureParser 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()
+  {
+    String sig = getSignature();
+    if (sig == null)
+      return getReturnType();
+    MethodSignatureParser p = new MethodSignatureParser(this, sig);
+    return p.getGenericReturnType();
+  }
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/VMArray.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/VMArray.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/VMArray.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/VMArray.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* java.lang.reflect.VMArray - VM class for array manipulation by reflection.
+   Copyright (C) 1998, 1999, 2001, 2003, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+import gnu.classpath.Configuration;
+
+class VMArray
+{
+
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+        System.loadLibrary("javalangreflect");
+      }
+  }
+
+  /**
+   * Dynamically create an array of objects.
+   *
+   * @param type guaranteed to be a valid object type
+   * @param dim the length of the array
+   * @return the new array
+   * @throws NegativeArraySizeException if dim is negative
+   * @throws OutOfMemoryError if memory allocation fails
+   */
+  static native Object createObjectArray(Class type, int dim);
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/VMProxy.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/VMProxy.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/VMProxy.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/lang/reflect/VMProxy.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,135 @@
+/* VMProxy.java -- VM interface for proxy class
+   Copyright (C) 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;
+
+final class VMProxy
+{
+  /**
+   * Set to true if the VM provides a native method to implement
+   * Proxy.getProxyClass completely, including argument verification.
+   * If this is true, HAVE_NATIVE_GET_PROXY_DATA and
+   * HAVE_NATIVE_GENERATE_PROXY_CLASS should be false.
+   * @see java.lang.reflect.Proxy
+   */
+  static boolean HAVE_NATIVE_GET_PROXY_CLASS = false;
+
+  /**
+   * Set to true if the VM provides a native method to implement
+   * the first part of Proxy.getProxyClass: generation of the array
+   * of methods to convert, and verification of the arguments.
+   * If this is true, HAVE_NATIVE_GET_PROXY_CLASS should be false.
+   * @see java.lang.reflect.Proxy
+   */
+  static boolean HAVE_NATIVE_GET_PROXY_DATA = false;
+
+  /**
+   * Set to true if the VM provides a native method to implement
+   * the second part of Proxy.getProxyClass: conversion of an array of
+   * methods into an actual proxy class.
+   * If this is true, HAVE_NATIVE_GET_PROXY_CLASS should be false.
+   * @see java.lang.reflect.Proxy
+   */
+  static boolean HAVE_NATIVE_GENERATE_PROXY_CLASS = false;
+
+  /**
+   * Optional native method to replace (and speed up) the pure Java
+   * implementation of getProxyClass.  Only needed if
+   * VMProxy.HAVE_NATIVE_GET_PROXY_CLASS is true, this does the
+   * work of both getProxyData and generateProxyClass with no
+   * intermediate form in Java. The native code may safely assume that
+   * this class must be created, and does not already exist.
+   *
+   * @param loader the class loader to define the proxy class in; null
+   *        implies the bootstrap class loader
+   * @param interfaces the interfaces the class will extend
+   * @return the generated proxy class
+   * @throws IllegalArgumentException if the constraints for getProxyClass
+   *         were violated, except for problems with null
+   * @throws NullPointerException if `interfaces' is null or contains
+   *         a null entry, or if handler is null
+   * @see #HAVE_NATIVE_GET_PROXY_CLASS
+   * @see #getProxyClass(ClassLoader, Class[])
+   * @see #getProxyData(ClassLoader, Class[])
+   * @see #generateProxyClass(ClassLoader, Proxy.ProxyData)
+   */
+  static native Class getProxyClass(ClassLoader loader, Class[] interfaces);
+
+  /**
+   * Optional native method to replace (and speed up) the pure Java
+   * implementation of getProxyData.  Only needed if
+   * Configuration.HAVE_NATIVE_GET_PROXY_DATA is true. The native code
+   * may safely assume that a new ProxyData object must be created which
+   * does not duplicate any existing ones.
+   *
+   * @param loader the class loader to define the proxy class in; null
+   *        implies the bootstrap class loader
+   * @param interfaces the interfaces the class will extend
+   * @return all data that is required to make this proxy class
+   * @throws IllegalArgumentException if the constraints for getProxyClass
+   *         were violated, except for problems with null
+   * @throws NullPointerException if `interfaces' is null or contains
+   *         a null entry, or if handler is null
+   * @see #HAVE_NATIVE_GET_PROXY_DATA
+   * @see #getProxyClass(ClassLoader, Class[])
+   * @see #getProxyClass(ClassLoader, Class[])
+   * @see Proxy.ProxyData#getProxyData(Proxy.ProxyType)
+   */
+  static native Proxy.ProxyData getProxyData(ClassLoader loader,
+                                             Class[] interfaces);
+
+  /**
+   * Optional native method to replace (and speed up) the pure Java
+   * implementation of generateProxyClass.  Only needed if
+   * Configuration.HAVE_NATIVE_GENERATE_PROXY_CLASS is true. The native
+   * code may safely assume that a new Class must be created, and that
+   * the ProxyData object does not describe any existing class.
+   *
+   * @param loader the class loader to define the proxy class in; null
+   *        implies the bootstrap class loader
+   * @param data the struct of information to convert to a Class. This
+   *        has already been verified for all problems except exceeding
+   *        VM limitations
+   * @return the newly generated class
+   * @throws IllegalArgumentException if VM limitations are exceeded
+   * @see #getProxyClass(ClassLoader, Class[])
+   * @see #getProxyClass(ClassLoader, Class[])
+   */
+  static native Class generateProxyClass(ClassLoader loader,
+                                         Proxy.ProxyData data);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/net/VMInetAddress.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/net/VMInetAddress.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/net/VMInetAddress.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/net/VMInetAddress.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,87 @@
+/* VMInetAddress.java -- Class to model an Internet address
+   Copyright (C) 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.net;
+
+import gnu.classpath.Configuration;
+
+import java.io.Serializable;
+
+class VMInetAddress implements Serializable
+{
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      System.loadLibrary("javanet");
+  }
+
+  /**
+   * This method looks up the hostname of the local machine
+   * we are on.  If the actual hostname cannot be determined, then the
+   * value "localhost" will be used.  This native method wrappers the
+   * "gethostname" function.
+   *
+   * @return The local hostname.
+   */
+  public static native String getLocalHostname();
+
+  /**
+   * Returns the value of the special address INADDR_ANY
+   */
+  public static native byte[] lookupInaddrAny() throws UnknownHostException;
+
+  /**
+   * This method returns the hostname for a given IP address.  It will
+   * throw an UnknownHostException if the hostname cannot be determined.
+   *
+   * @param ip The IP address as a byte array
+   *
+   * @return The hostname
+   *
+   * @exception UnknownHostException If the reverse lookup fails
+   */
+  public static native String getHostByAddr(byte[] ip)
+    throws UnknownHostException;
+
+  /**
+   * Returns a list of all IP addresses for a given hostname.  Will throw
+   * an UnknownHostException if the hostname cannot be resolved.
+   */
+  public static native byte[][] getHostByName(String hostname)
+    throws UnknownHostException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/net/VMNetworkInterface.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/net/VMNetworkInterface.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/net/VMNetworkInterface.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/net/VMNetworkInterface.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* VMNetworkInterface.java --
+   Copyright (C) 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.net;
+
+import gnu.classpath.Configuration;
+
+import java.util.Vector;
+
+/**
+ * This class models a network interface on the host computer.  A network
+ * interface contains a name (typically associated with a specific
+ * hardware adapter) and a list of addresses that are bound to it.
+ * For example, an ethernet interface may be named "eth0" and have the
+ * address 192.168.1.101 assigned to it.
+ *
+ * @author Michael Koch (konqueror at gmx.de)
+ * @since 1.4
+ */
+final class VMNetworkInterface
+{
+  static
+    {
+      if (Configuration.INIT_LOAD_LIBRARY)
+	System.loadLibrary("javanet");
+    }
+
+  /**
+   * Returns a Vector of InetAddresses. The returned value will be
+   * 'condensed', meaning that all elements with the same interface
+   * name will be collapesed into one InetAddress for that name
+   * containing all addresses before the returning the result to the
+   * user. This means the native method can be implemented in a naive
+   * way mapping each address/interface to a name even if that means
+   * that the Vector contains multiple InetAddresses with the same
+   * interface name.
+   */
+  public static native Vector getInterfaces()
+    throws SocketException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/net/VMURLConnection.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/net/VMURLConnection.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/net/VMURLConnection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/net/VMURLConnection.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* VMURLConnection - VM code for URLConnection
+   Copyright (C) 2006  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.net;
+
+import gnu.classpath.Configuration;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+final class VMURLConnection
+{
+  public static final int LENGTH = 1024;
+
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      System.loadLibrary("javanet");
+    init();
+  }
+
+  private static native void init();
+
+  private static native String guessContentTypeFromBuffer(byte[] b, int valid);
+
+  /**
+   * This is called from URLConnection to guess the mime type of a
+   * stream.  This method may return null to indicate that it could
+   * not guess a type.
+   */
+  static String guessContentTypeFromStream(InputStream is)
+    throws IOException
+  {
+    if (! is.markSupported())
+      return null;
+    is.mark(LENGTH);
+    byte[] bytes = new byte[LENGTH];
+    int r = is.read(bytes);
+    if (r < 0)
+      return null;
+    is.reset();
+    return guessContentTypeFromBuffer(bytes, r);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/nio/VMDirectByteBuffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/nio/VMDirectByteBuffer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/nio/VMDirectByteBuffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/nio/VMDirectByteBuffer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* VMDirectByteBuffer.java --
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.Pointer;
+
+final class VMDirectByteBuffer
+{
+  static
+  {
+    // load the shared library needed for native methods.
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+        System.loadLibrary("javanio");
+      }
+  }
+
+  static native Pointer allocate (int capacity);
+  static native void free(Pointer address);
+  static native byte get(Pointer address, int index);
+  static native void get(Pointer address, int index, byte[] dst, int offset, int length);
+  static native void put(Pointer address, int index, byte value);
+  static native void put(Pointer address, int index, byte[] src, int offset, int length);
+  static native Pointer adjustAddress(Pointer address, int offset);
+  static native void shiftDown(Pointer address, int dst_offset, int src_offset, int count);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/nio/channels/VMChannels.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/nio/channels/VMChannels.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/nio/channels/VMChannels.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/nio/channels/VMChannels.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,116 @@
+/* VMChannels.java --
+   Copyright (C) 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.nio.channels;
+
+import gnu.java.nio.ChannelInputStream;
+import gnu.java.nio.ChannelOutputStream;
+import gnu.java.nio.channels.FileChannelImpl;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+final class VMChannels
+{
+  /**
+   * This class isn't intended to be instantiated.
+   */
+  private VMChannels()
+  {
+    // Do nothing here.
+  }
+
+  private static Object createStream(Class streamClass, Channel ch)
+  {
+    try
+      {
+	Class[] argTypes = new Class[1];
+	argTypes[0] = FileChannelImpl.class;
+	Constructor constructor =
+	  streamClass.getDeclaredConstructor(argTypes);
+	constructor.setAccessible(true);
+	Object[] args = new Object[1];
+	args[0] = ch;
+	return constructor.newInstance(args);
+      }
+    catch (IllegalAccessException e)
+      {
+	// Ignored.
+      }
+    catch (InstantiationException e)
+      {
+	// Ignored.
+      }
+    catch (InvocationTargetException e)
+      {
+	// Ignored.
+      }
+    catch (NoSuchMethodException e)
+      {
+	// Ignored.
+      }
+
+    return null;
+  }
+  
+  /**
+   * Constructs a stream that reads bytes from the given channel.
+   */
+  static InputStream newInputStream(ReadableByteChannel ch)
+  {
+    if (ch instanceof FileChannelImpl)
+      return (FileInputStream) createStream(FileInputStream.class, ch);
+    
+    return  new ChannelInputStream(ch);
+  }
+
+  /**
+   * Constructs a stream that writes bytes to the given channel.
+   */
+  static OutputStream newOutputStream(WritableByteChannel ch)
+  {
+    if (ch instanceof FileChannelImpl)
+      return (FileOutputStream) createStream(FileOutputStream.class, ch);
+    
+    return new ChannelOutputStream(ch);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/security/VMAccessController.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/security/VMAccessController.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/security/VMAccessController.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/security/VMAccessController.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,280 @@
+/* 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] };
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/security/VMSecureRandom.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/security/VMSecureRandom.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/security/VMSecureRandom.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/security/VMSecureRandom.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,134 @@
+/* VMSecureRandom.java -- random seed generator.
+   Copyright (C) 2006  Free Software Foundation, Inc.
+
+This file is a 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 of the License, 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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, 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 gnu.classpath.SystemProperties;
+import gnu.java.security.action.GetSecurityPropertyAction;
+
+import java.net.URL;
+
+/**
+ * VM-specific methods for generating real (or almost real) random
+ * seeds. VM implementors should write a version of this class that
+ * reads random bytes from some system source.
+ *
+ * <p>The default implementation of this class runs eight threads that
+ * increment counters in a tight loop, and XORs each counter to
+ * produce one byte of seed data. This is not very efficient, and is
+ * not guaranteed to be random (the thread scheduler is probably
+ * deterministic, after all). If possible, VM implementors should
+ * reimplement this class so it obtains a random seed from a system
+ * facility, such as a system entropy gathering device or hardware
+ * random number generator.
+ */
+final class VMSecureRandom
+{
+
+  /**
+   * Generate a random seed. Implementations are free to generate
+   * fewer random bytes than are requested, and leave the remaining
+   * bytes of the destination buffer as zeros. Implementations SHOULD,
+   * however, make a best-effort attempt to satisfy the request.
+   *
+   * @param buffer The destination buffer.
+   * @param offset The offset in the buffer to start putting bytes.
+   * @param length The number of random bytes to generate.
+   */
+  static int generateSeed(byte[] buffer, int offset, int length)
+  {
+    if (length < 0)
+      throw new IllegalArgumentException("length must be nonnegative");
+    if (offset < 0 || offset + length > buffer.length)
+      throw new IndexOutOfBoundsException();
+
+    Spinner[] spinners = new Spinner[8];
+    int n = 0x1;
+    for (int i = 0; i < spinners.length; i++)
+      {
+        spinners[i] = new Spinner((byte) n);
+        Thread t = new Thread(spinners[i]);
+        t.start();
+        n <<= 1;
+      }
+
+    // Wait until at least one spinner has started.
+    while (!(spinners[0].running || spinners[1].running || spinners[2].running
+             || spinners[3].running || spinners[4].running || spinners[5].running
+             || spinners[6].running || spinners[7].running))
+      {
+        Thread.yield();
+      }
+
+    for (int i = offset; i < length; i++)
+      {
+        buffer[i] = (byte) (spinners[0].value ^ spinners[1].value ^ spinners[2].value
+                            ^ spinners[3].value ^ spinners[4].value ^ spinners[5].value
+                            ^ spinners[6].value ^ spinners[7].value);
+        Thread.yield();
+      }
+
+    for (int i = 0; i < spinners.length; i++)
+      spinners[i].stop();
+
+    return length;
+  }
+
+  static class Spinner implements Runnable
+  {
+    volatile byte value;
+    volatile boolean running;
+
+    Spinner(final byte initial)
+    {
+      value = initial;
+    }
+
+    public void run()
+    {
+      running = true;
+      while (running)
+        value++;
+    }
+
+    private void stop()
+    {
+      running = false;
+    }
+  }
+}
\ No newline at end of file

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/util/VMTimeZone.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/util/VMTimeZone.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/util/VMTimeZone.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/java/util/VMTimeZone.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,345 @@
+/* java.util.VMTimeZone
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+import gnu.classpath.Configuration;
+
+import java.io.*;
+
+/**
+ *
+ */
+final class VMTimeZone
+{
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+	System.loadLibrary("javautil");
+      }
+  }
+		
+  /**
+   * This method returns a time zone id string which is in the form
+   * (standard zone name) or (standard zone name)(GMT offset) or
+   * (standard zone name)(GMT offset)(daylight time zone name).  The
+   * GMT offset can be in seconds, or where it is evenly divisible by
+   * 3600, then it can be in hours.  The offset must be the time to
+   * add to the local time to get GMT.  If a offset is given and the
+   * time zone observes daylight saving then the (daylight time zone
+   * name) must also be given (otherwise it is assumed the time zone
+   * does not observe any daylight savings).
+   * <p>
+   * The result of this method is given to the method
+   * TimeZone.getDefaultTimeZone(String) which tries to map the time
+   * zone id to a known TimeZone.  See that method on how the returned
+   * String is mapped to a real TimeZone object.
+   * <p>
+   * The reference implementation which is made for GNU/Posix like
+   * systems calls <code>System.getenv("TZ")</code>,
+   * <code>readTimeZoneFile("/etc/timezone")</code>,
+   * <code>readtzFile("/etc/localtime")</code> and finally
+   * <code>getSystemTimeZoneId()</code> till a supported TimeZone is
+   * found through <code>TimeZone.getDefaultTimeZone(String)</code>.
+   * If every method fails <code>null</code> is returned (which means
+   * the TimeZone code will fall back on GMT as default time zone).
+   * <p>
+   * Note that this method is called inside a
+   * <code>AccessController.doPrivileged()</code> block and runs with
+   * the priviliges of the java.util system classes.  It will only be
+   * called when the default time zone is not yet set, the system
+   * property user.timezone isn't set and it is requested for the
+   * first time.
+   */
+  static TimeZone getDefaultTimeZoneId()
+  {
+    TimeZone zone = null;
+
+    // See if TZ environment variable is set and accessible.
+    String tzid = System.getenv("TZ");
+    if (tzid != null && !tzid.equals(""))
+      zone = TimeZone.getDefaultTimeZone(tzid);
+
+    // Try to parse /etc/timezone.
+    if (zone == null)
+      {
+	tzid = readTimeZoneFile("/etc/timezone");
+	if (tzid != null && !tzid.equals(""))
+	  zone = TimeZone.getDefaultTimeZone(tzid);
+      }
+    
+    // Try to parse /etc/localtime
+    if (zone == null)
+      {
+	tzid = readtzFile("/etc/localtime");
+	if (tzid != null && !tzid.equals(""))
+	  zone = TimeZone.getDefaultTimeZone(tzid);
+      }
+
+    // Try some system specific way
+    if (zone == null)
+      {
+	tzid = getSystemTimeZoneId();
+	if (tzid != null && !tzid.equals(""))
+	  zone = TimeZone.getDefaultTimeZone(tzid);
+      }
+
+    return zone;
+  }
+
+  /**
+   * Tries to read the time zone name from a file. Only the first
+   * consecutive letters, digits, slashes, dashes and underscores are
+   * read from the file. If the file cannot be read or an IOException
+   * occurs null is returned.
+   * <p>
+   * The /etc/timezone file is not standard, but a lot of systems have
+   * it. If it exist the first line always contains a string
+   * describing the timezone of the host of domain. Some systems
+   * contain a /etc/TIMEZONE file which is used to set the TZ
+   * environment variable (which is checked before /etc/timezone is
+   * read).
+   */
+  private static String readTimeZoneFile(String file)
+  {
+    File f = new File(file);
+    if (!f.exists())
+      return null;
+
+    InputStreamReader isr = null;
+    try
+      {
+	FileInputStream fis = new FileInputStream(f);
+	BufferedInputStream bis = new BufferedInputStream(fis);
+	isr = new InputStreamReader(bis);
+	
+	StringBuffer sb = new StringBuffer();
+	int i = isr.read();
+	while (i != -1)
+	  {
+	    char c = (char) i;
+	    if (Character.isLetter(c) || Character.isDigit(c)
+		|| c == '/' || c == '-' || c == '_')
+	      {
+		sb.append(c);
+		i = isr.read();
+	      }
+	    else
+	      break;
+	  }
+	return sb.toString();
+      }
+    catch (IOException ioe)
+      {
+	// Parse error, not a proper tzfile.
+	return null;
+      }
+    finally
+      {
+	try
+	  {
+	    if (isr != null)
+	      isr.close();
+	  }
+	catch (IOException ioe)
+	  {
+	    // Error while close, nothing we can do.
+	  }
+      }
+  }
+
+  /**
+   * Tries to read a file as a "standard" tzfile and return a time
+   * zone id string as expected by <code>getDefaultTimeZone(String)</code>.
+   * If the file doesn't exist, an IOException occurs or it isn't a tzfile
+   * that can be parsed null is returned.
+   * <p>
+   * The tzfile structure (as also used by glibc) is described in the Olson
+   * tz database archive as can be found at
+   * <code>ftp://elsie.nci.nih.gov/pub/</code>.
+   * <p>
+   * At least the following platforms support the tzdata file format
+   * and /etc/localtime (GNU/Linux, Darwin, Solaris and FreeBSD at
+   * least). Some systems (like Darwin) don't start the file with the
+   * required magic bytes 'TZif', this implementation can handle
+   * that).
+   */
+  private static String readtzFile(String file)
+  {
+    File f = new File(file);
+    if (!f.exists())
+      return null;
+    
+    DataInputStream dis = null;
+    try
+      {
+        FileInputStream fis = new FileInputStream(f);
+        BufferedInputStream bis = new BufferedInputStream(fis);
+        dis = new DataInputStream(bis);
+	
+        // Make sure we are reading a tzfile.
+        byte[] tzif = new byte[4];
+        dis.readFully(tzif);
+        if (tzif[0] == 'T' && tzif[1] == 'Z'
+            && tzif[2] == 'i' && tzif[3] == 'f')
+	  // Reserved bytes, ttisgmtcnt, ttisstdcnt and leapcnt
+	  skipFully(dis, 16 + 3 * 4);
+	else
+	  // Darwin has tzdata files that don't start with the TZif marker
+	  skipFully(dis, 16 + 3 * 4 - 4);
+	
+	int timecnt = dis.readInt();
+	int typecnt = dis.readInt();
+	if (typecnt > 0)
+	  {
+	    int charcnt = dis.readInt();
+	    // Transition times plus indexed transition times.
+	    skipFully(dis, timecnt * (4 + 1));
+	    
+	    // Get last gmt_offset and dst/non-dst time zone names.
+	    int abbrind = -1;
+	    int dst_abbrind = -1;
+	    int gmt_offset = 0;
+	    while (typecnt-- > 0)
+	      {
+		// gmtoff
+		int offset = dis.readInt();
+		int dst = dis.readByte();
+		if (dst == 0)
+		  {
+		    abbrind = dis.readByte();
+		    gmt_offset = offset;
+		  }
+		else
+		  dst_abbrind = dis.readByte();
+	      }
+	    
+	    // gmt_offset is the offset you must add to UTC/GMT to
+	    // get the local time, we need the offset to add to
+	    // the local time to get UTC/GMT.
+	    gmt_offset *= -1;
+	    
+	    // Turn into hours if possible.
+	    if (gmt_offset % 3600 == 0)
+	      gmt_offset /= 3600;
+	    
+	    if (abbrind >= 0)
+	      {
+		byte[] names = new byte[charcnt];
+		dis.readFully(names);
+		int j = abbrind;
+		while (j < charcnt && names[j] != 0)
+		  j++;
+		
+		String zonename = new String(names, abbrind, j - abbrind,
+					     "ASCII");
+		
+		String dst_zonename;
+		if (dst_abbrind >= 0)
+		  {
+		    j = dst_abbrind;
+		    while (j < charcnt && names[j] != 0)
+		      j++;
+		    dst_zonename = new String(names, dst_abbrind,
+					      j - dst_abbrind, "ASCII");
+		  }
+		else
+		  dst_zonename = "";
+		
+		// Only use gmt offset when necessary.
+		// Also special case GMT+/- timezones.
+		String offset_string;
+		if ("".equals(dst_zonename)
+		    && (gmt_offset == 0
+			|| zonename.startsWith("GMT+")
+			|| zonename.startsWith("GMT-")))
+		  offset_string = "";
+		else
+		  offset_string = Integer.toString(gmt_offset);
+		
+		String id = zonename + offset_string + dst_zonename;
+		
+		return id;
+	      }
+	  }
+	
+	// Something didn't match while reading the file.
+	return null;
+      }
+    catch (IOException ioe)
+      {
+	// Parse error, not a proper tzfile.
+	return null;
+      }
+    finally
+      {
+	try
+	  {
+	    if (dis != null)
+	      dis.close();
+	  }
+	catch(IOException ioe)
+	  {
+	    // Error while close, nothing we can do.
+	  }
+      }
+  }
+  
+  /**
+   * Skips the requested number of bytes in the given InputStream.
+   * Throws EOFException if not enough bytes could be skipped.
+   * Negative numbers of bytes to skip are ignored.
+   */
+  private static void skipFully(InputStream is, long l) throws IOException
+  {
+    while (l > 0)
+      {
+        long k = is.skip(l);
+        if (k <= 0)
+          throw new EOFException();
+        l -= k;
+      }
+  }
+
+  /**
+   * Tries to get the system time zone id through native code.
+   */
+  private static native String getSystemTimeZoneId();
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/sun/misc/Unsafe.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/sun/misc/Unsafe.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/sun/misc/Unsafe.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/sun/misc/Unsafe.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,328 @@
+/* Unsafe.java - Unsafe operations needed for concurrency
+   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 sun.misc;
+
+import java.lang.reflect.Field;
+
+/**
+ * This class should provide access to low-level operations and its
+ * use should be limited to trusted code.  Fields can be accessed using
+ * memory addresses, with undefined behaviour occurring if invalid memory
+ * addresses are given.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ */
+public class Unsafe
+{
+  // Singleton class.
+  private static Unsafe unsafe = new Unsafe();
+
+  /**
+   * Private default constructor to prevent creation of an arbitrary
+   * number of instances.
+   */
+  private Unsafe()
+  {
+  }
+
+  /**
+   * Retrieve the singleton instance of <code>Unsafe</code>.  The calling
+   * method should guard this instance from untrusted code, as it provides
+   * access to low-level operations such as direct memory access.
+   *
+   * @throws SecurityException if a security manager exists and prevents
+   *                           access to the system properties.
+   */
+  public static Unsafe getUnsafe()
+  {
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkPropertiesAccess();
+    return unsafe;
+  }
+  
+  /**
+   * Returns the memory address offset of the given static field.
+   * The offset is merely used as a means to access a particular field
+   * in the other methods of this class.  The value is unique to the given
+   * field and the same value should be returned on each subsequent call.
+   *
+   * @param field the field whose offset should be returned.
+   * @return the offset of the given field.
+   */
+  public native long objectFieldOffset(Field field);
+
+  /**
+   * Compares the value of the integer field at the specified offset
+   * in the supplied object with the given expected value, and updates
+   * it if they match.  The operation of this method should be atomic,
+   * thus providing an uninterruptible way of updating an integer field.
+   *
+   * @param obj the object containing the field to modify.
+   * @param offset the offset of the integer field within <code>obj</code>.
+   * @param expect the expected value of the field.
+   * @param update the new value of the field if it equals <code>expect</code>.
+   * @return true if the field was changed.
+   */
+  public native boolean compareAndSwapInt(Object obj, long offset,
+                                          int expect, int update);
+
+  /**
+   * Compares the value of the long field at the specified offset
+   * in the supplied object with the given expected value, and updates
+   * it if they match.  The operation of this method should be atomic,
+   * thus providing an uninterruptible way of updating a long field.
+   *
+   * @param obj the object containing the field to modify.
+   * @param offset the offset of the long field within <code>obj</code>.
+   * @param expect the expected value of the field.
+   * @param update the new value of the field if it equals <code>expect</code>.
+   * @return true if the field was changed.
+   */
+  public native boolean compareAndSwapLong(Object obj, long offset,
+                                           long expect, long update);
+
+  /**
+   * Compares the value of the object field at the specified offset
+   * in the supplied object with the given expected value, and updates
+   * it if they match.  The operation of this method should be atomic,
+   * thus providing an uninterruptible way of updating an object field.
+   *
+   * @param obj the object containing the field to modify.
+   * @param offset the offset of the object field within <code>obj</code>.
+   * @param expect the expected value of the field.
+   * @param update the new value of the field if it equals <code>expect</code>.
+   * @return true if the field was changed.
+   */
+  public native boolean compareAndSwapObject(Object obj, long offset,
+                                             Object expect, Object update);
+
+  /**
+   * Sets the value of the integer field at the specified offset in the
+   * supplied object to the given value.  This is an ordered or lazy
+   * version of <code>putIntVolatile(Object,long,int)</code>, which
+   * doesn't guarantee the immediate visibility of the change to other
+   * threads.  It is only really useful where the integer field is
+   * <code>volatile</code>, and is thus expected to change unexpectedly.
+   *
+   * @param obj the object containing the field to modify.
+   * @param offset the offset of the integer field within <code>obj</code>.
+   * @param value the new value of the field.
+   * @see #putIntVolatile(Object,long,int)
+   */
+  public native void putOrderedInt(Object obj, long offset, int value);
+
+  /**
+   * Sets the value of the long field at the specified offset in the
+   * supplied object to the given value.  This is an ordered or lazy
+   * version of <code>putLongVolatile(Object,long,long)</code>, which
+   * doesn't guarantee the immediate visibility of the change to other
+   * threads.  It is only really useful where the long field is
+   * <code>volatile</code>, and is thus expected to change unexpectedly.
+   *
+   * @param obj the object containing the field to modify.
+   * @param offset the offset of the long field within <code>obj</code>.
+   * @param value the new value of the field.
+   * @see #putLongVolatile(Object,long,long)
+   */
+  public native void putOrderedLong(Object obj, long offset, long value);
+
+  /**
+   * Sets the value of the object field at the specified offset in the
+   * supplied object to the given value.  This is an ordered or lazy
+   * version of <code>putObjectVolatile(Object,long,Object)</code>, which
+   * doesn't guarantee the immediate visibility of the change to other
+   * threads.  It is only really useful where the object field is
+   * <code>volatile</code>, and is thus expected to change unexpectedly.
+   *
+   * @param obj the object containing the field to modify.
+   * @param offset the offset of the object field within <code>obj</code>.
+   * @param value the new value of the field.
+   */
+  public native void putOrderedObject(Object obj, long offset, Object value);
+
+  /**
+   * Sets the value of the integer field at the specified offset in the
+   * supplied object to the given value, with volatile store semantics.
+   *
+   * @param obj the object containing the field to modify.
+   * @param offset the offset of the integer field within <code>obj</code>.
+   * @param value the new value of the field.
+   */
+  public native void putIntVolatile(Object obj, long offset, int value);
+
+  /**
+   * Retrieves the value of the integer field at the specified offset in the
+   * supplied object with volatile load semantics.
+   *
+   * @param obj the object containing the field to read.
+   * @param offset the offset of the integer field within <code>obj</code>.
+   */
+  public native int getIntVolatile(Object obj, long offset);
+
+  /**
+   * Sets the value of the long field at the specified offset in the
+   * supplied object to the given value, with volatile store semantics.
+   *
+   * @param obj the object containing the field to modify.
+   * @param offset the offset of the long field within <code>obj</code>.
+   * @param value the new value of the field.
+   * @see #putLong(Object,long,long)
+   */
+  public native void putLongVolatile(Object obj, long offset, long value);
+
+  /**
+   * Sets the value of the long field at the specified offset in the
+   * supplied object to the given value.
+   *
+   * @param obj the object containing the field to modify.
+   * @param offset the offset of the long field within <code>obj</code>.
+   * @param value the new value of the field.
+   * @see #putLongVolatile(Object,long,long)
+   */
+  public native void putLong(Object obj, long offset, long value);
+
+  /**
+   * Retrieves the value of the long field at the specified offset in the
+   * supplied object with volatile load semantics.
+   *
+   * @param obj the object containing the field to read.
+   * @param offset the offset of the long field within <code>obj</code>.
+   * @see #getLong(Object,long)
+   */
+  public native long getLongVolatile(Object obj, long offset);
+
+  /**
+   * Retrieves the value of the long field at the specified offset in the
+   * supplied object.
+   *
+   * @param obj the object containing the field to read.
+   * @param offset the offset of the long field within <code>obj</code>.
+   * @see #getLongVolatile(Object,long)
+   */
+  public native long getLong(Object obj, long offset);
+
+  /**
+   * Sets the value of the object field at the specified offset in the
+   * supplied object to the given value, with volatile store semantics.
+   *
+   * @param obj the object containing the field to modify.
+   * @param offset the offset of the object field within <code>obj</code>.
+   * @param value the new value of the field.
+   * @see #putObject(Object,long,Object)
+   */
+  public native void putObjectVolatile(Object obj, long offset, Object value);
+
+  /**
+   * Sets the value of the object field at the specified offset in the
+   * supplied object to the given value.
+   *
+   * @param obj the object containing the field to modify.
+   * @param offset the offset of the object field within <code>obj</code>.
+   * @param value the new value of the field.
+   * @see #putObjectVolatile(Object,long,Object)
+   */
+  public native void putObject(Object obj, long offset, Object value);
+
+  /**
+   * Retrieves the value of the object field at the specified offset in the
+   * supplied object with volatile load semantics.
+   *
+   * @param obj the object containing the field to read.
+   * @param offset the offset of the object field within <code>obj</code>.
+   */
+  public native Object getObjectVolatile(Object obj, long offset);
+
+  /**
+   * Returns the offset of the first element for a given array class.
+   * To access elements of the array class, this value may be used along
+   * with that returned by 
+   * <a href="#arrayIndexScale"><code>arrayIndexScale</code></a>,
+   * if non-zero.
+   *
+   * @param arrayClass the class for which the first element's address should
+   *                   be obtained.
+   * @return the offset of the first element of the array class.
+   * @see arrayIndexScale(Class)
+   */
+  public native int arrayBaseOffset(Class arrayClass);
+
+  /**
+   * Returns the scale factor used for addressing elements of the supplied
+   * array class.  Where a suitable scale factor can not be returned (e.g.
+   * for primitive types), zero should be returned.  The returned value
+   * can be used with 
+   * <a href="#arrayBaseOffset"><code>arrayBaseOffset</code></a>
+   * to access elements of the class.
+   *
+   * @param arrayClass the class whose scale factor should be returned.
+   * @return the scale factor, or zero if not supported for this array class.
+   */
+  public native int arrayIndexScale(Class arrayClass);
+  
+  /**
+   * Releases the block on a thread created by 
+   * <a href="#park"><code>park</code></a>.  This method can also be used
+   * to terminate a blockage caused by a prior call to <code>park</code>.
+   * This operation is unsafe, as the thread must be guaranteed to be
+   * live.  This is true of Java, but not native code.
+   *
+   * @param thread the thread to unblock.
+   */
+  public native void unpark(Thread thread);
+
+  /**
+   * Blocks the thread until a matching 
+   * <a href="#unpark"><code>unpark</code></a> occurs, the thread is
+   * interrupted or the optional timeout expires.  If an <code>unpark</code>
+   * call has already occurred, this also counts.  A timeout value of zero
+   * is defined as no timeout.  When <code>isAbsolute</code> is
+   * <code>true</code>, the timeout is in milliseconds relative to the
+   * epoch.  Otherwise, the value is the number of nanoseconds which must
+   * occur before timeout.  This call may also return spuriously (i.e.
+   * for no apparent reason).
+   *
+   * @param isAbsolute true if the timeout is specified in milliseconds from
+   *                   the epoch.
+   * @param time either the number of nanoseconds to wait, or a time in
+   *             milliseconds from the epoch to wait for.
+   */
+  public native void park(boolean isAbsolute, long time);
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/sun/reflect/Reflection.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/sun/reflect/Reflection.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/sun/reflect/Reflection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/sun/reflect/Reflection.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,51 @@
+/* Reflection.java - JSR 166 reflection hooks
+   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 sun.reflect;
+
+import gnu.classpath.VMStackWalker;
+
+public class Reflection
+{
+  /**
+   * A stack-walking wrapper method used by the JSR 166 RI. 
+   */
+  public static Class getCallerClass(int depth)
+  {
+    return VMStackWalker.getClassContext()[depth];
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,92 @@
+/* ReflectUtil.java - JSR 166 reflection hooks
+   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 sun.reflect.misc;
+
+import java.lang.reflect.Modifier;
+
+public class ReflectUtil
+{
+  // We use this inaccessible inner class as an argument type
+  // in verifyMemberAccess.  All current users of this method
+  // in the JSR 166 RI pass 'null' for this argument, and
+  // consequently we don't know what it means.  Using a funny
+  // type like this for the argument means that if the RI changes,
+  // we will see a compilation error.
+  private static class MustBeNull
+  {
+  }
+
+  public static void checkPackageAccess(Class declaringClass)
+  {
+    // FIXME: not sure what to check here.
+  }
+
+  /**
+   * Perform access checks on a member of a class.  This API is
+   * derived from the public domain code in the JSR 166 reference
+   * implementation.
+   * @param caller the class requesting access to the member
+   * @param declarer the declaring class of the member
+   * @param ignored unknown parameter; always null
+   * @param modifiers the modifiers on the member
+   */
+  public static void ensureMemberAccess(Class caller,
+                                        Class declarer,
+                                        MustBeNull ignored,
+                                        int modifiers)
+  {
+    // Same class, always ok.
+    if (caller == declarer)
+      return;
+    // Public access is ok.
+    if ((modifiers & Modifier.PUBLIC) != 0)
+      return;
+    // Protected access and request comes from
+    // a subclass of the declarer -- ok.
+    if ((modifiers & Modifier.PROTECTED) != 0
+        && declarer.isAssignableFrom(caller))
+      return;
+    // Package-private access, or protected access,
+    // and the packages are the same --ok.
+    if ((modifiers & Modifier.PRIVATE) == 0
+        && caller.getPackage() == declarer.getPackage())
+      return;
+    // Otherwise, no.
+    throw new IllegalAccessError();
+  }
+}





More information about the llvm-commits mailing list