[llvm-commits] [llvm-gcc-4.2] r43913 [19/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/gnu/CORBA/gnuRequest.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/gnuRequest.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/gnuRequest.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/gnuRequest.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1425 @@
+/* gnuRequest.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 gnu.CORBA;
+
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
+import gnu.CORBA.GIOP.MessageHeader;
+import gnu.CORBA.GIOP.ReplyHeader;
+import gnu.CORBA.GIOP.RequestHeader;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
+import gnu.CORBA.Interceptor.gnuClientRequestInfo;
+import gnu.CORBA.Poa.ORB_1_4;
+
+import org.omg.CORBA.ARG_IN;
+import org.omg.CORBA.ARG_INOUT;
+import org.omg.CORBA.ARG_OUT;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.Bounds;
+import org.omg.CORBA.COMM_FAILURE;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.Environment;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.INV_POLICY;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.NO_RESOURCES;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.UnknownUserException;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.IOP.ServiceContext;
+import org.omg.IOP.TAG_CODE_SETS;
+import org.omg.IOP.TAG_INTERNET_IOP;
+import org.omg.IOP.TaggedComponent;
+import org.omg.IOP.TaggedProfile;
+import org.omg.PortableInterceptor.ClientRequestInfo;
+import org.omg.PortableInterceptor.ClientRequestInterceptorOperations;
+import org.omg.PortableInterceptor.ForwardRequest;
+import org.omg.PortableInterceptor.InvalidSlot;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import java.net.BindException;
+import java.net.Socket;
+
+import java.util.ArrayList;
+
+/**
+ * The implementation of the CORBA request.
+ *
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)
+ */
+public class gnuRequest extends Request implements Cloneable
+{
+  /**
+   * The maximal supported GIOP version.
+   */
+  public static Version MAX_SUPPORTED = new Version(1, 2);
+
+  /**
+   * The initial pause that the Request makes when the required port is not
+   * available.
+   */
+  public static int PAUSE_INITIAL = 50;
+
+  /**
+   * The number of repretetive attempts to get a required port, if it is not
+   * immediately available.
+   */
+  public static int PAUSE_STEPS = 12;
+
+  /**
+   * The maximal pausing interval between two repetetive attempts. The interval
+   * doubles after each unsuccessful attempt, but will not exceed this value.
+   */
+  public static int PAUSE_MAX = 1000;
+
+  /**
+   * The interceptor, listening the major request submission points.
+   */
+  ClientRequestInterceptorOperations m_interceptor;
+
+  /**
+   * The request info, used by interceptor.
+   */
+  ClientRequestInfo m_info = new gnuClientRequestInfo(this);
+
+  /**
+   * The empty byte array.
+   */
+  private static final RawReply EMPTY =
+    new RawReply(null, new MessageHeader(), new byte[ 0 ]);
+
+  /**
+   * The context holder for methods ctx(Context) and ctx().
+   */
+  protected Context m_context;
+
+  /**
+   * The context list for method contexts().
+   */
+  protected ContextList m_context_list;
+
+  /**
+   * The request environment for holding the exception the has possibly been
+   * thrown by the method being invoked.
+   */
+  protected Environment m_environment = new gnuEnvironment();
+
+  /**
+   * The list of all exceptions that can be thrown by the method being invoked.
+   */
+  protected ExceptionList m_exceptions = new gnuExceptionList();
+
+  /**
+   * The result, returned by the invoked method (function).
+   */
+  protected NamedValue m_result = new gnuNamedValue();
+
+  /**
+   * The exception id, received from the server, null if none.
+   */
+  protected String m_exception_id;
+
+  /**
+   * The thrown system exception.
+   */
+  protected SystemException m_sys_ex;
+
+  /**
+   * The invocation target.
+   */
+  protected org.omg.CORBA.Object m_target;
+
+  /**
+   * The name of the method being invoked.
+   */
+  protected String m_operation;
+
+  /**
+   * This field temporary remembers the value of the forwarded ior reference. If
+   * it is not null, the request was forwarded and the effective target is not
+   * the same as the default target.
+   */
+  public IOR m_forward_ior;
+
+  /**
+   * Is set when object, and not IOR is directly available.
+   */
+  public org.omg.CORBA.Object m_forwarding_target;
+
+  /**
+   * The flag, indicating that the request has been sent and the result is
+   * already received.
+   */
+  protected boolean complete;
+
+  /**
+   * The flag, indicating that the response to this request must be ignored
+   * (used with {@link #send_oneway()}).
+   */
+  protected boolean oneWay;
+
+  /**
+   * The flag, indicating that the request has been sent and no result is yet
+   * received.
+   */
+  protected boolean running;
+
+  /**
+   * The request arguments.
+   */
+  protected gnuNVList m_args = new gnuNVList();
+
+  /**
+   * The request arguments in the case when they are directly written into the
+   * parameter buffer.
+   */
+  protected StreamBasedRequest m_parameter_buffer;
+
+  /**
+   * The array of slots.
+   */
+  protected Any[] m_slots;
+
+  /**
+   * The request header currently in use.
+   */
+  protected RequestHeader m_rqh;
+
+  /**
+   * The reply header currently in use.
+   */
+  protected ReplyHeader m_rph;
+
+  /**
+   * The IOR of the target.
+   */
+  private IOR ior;
+
+  /**
+   * The ORB of the target.
+   */
+  private ORB orb;
+
+  /**
+   * The encoding, used to send the message.
+   *
+   * The default encoding is inherited from the set IOR (that string reference
+   * can be encoded in either Big or Little endian). If the IOR encoding is not
+   * known (for example, by obtaining the reference from the naming service),
+   * the Big Endian is used.
+   */
+  private boolean Big_endian = true;
+
+  /**
+   * Set the IOR data, sufficient to find the invocation target. This also sets
+   * default endian encoding for invocations.
+   *
+   * @see IOR.parse(String)
+   */
+  public void setIor(IOR an_ior)
+  {
+    ior = an_ior;
+    setBigEndian(ior.Big_Endian);
+  }
+
+  /**
+   * Used when redirecting request to another target.
+   */
+  gnuRequest redirected;
+
+  /**
+   * Get the IOR data, sufficient to find the invocation target.
+   *
+   * @return the IOR data.
+   */
+  public IOR getIor()
+  {
+    return ior;
+  }
+
+  /**
+   * Set the ORB, related to the invocation target.
+   */
+  public void setORB(ORB an_orb)
+  {
+    orb = an_orb;
+
+    // Take the interceptor from the ORB.
+    if (orb instanceof OrbRestricted)
+      m_interceptor = ((OrbRestricted) orb).iClient;
+
+    if (m_interceptor != null && orb instanceof ORB_1_4)
+      {
+        m_slots = ((ORB_1_4) orb).ic_current.clone_slots();
+      }
+  }
+
+  /**
+   * Set the encoding that will be used to send the message. The default
+   * encoding is inherited from the set IOR (that string reference can be
+   * encoded in either Big or Little endian). If the IOR encoding is not known
+   * (for example, by obtaining the reference from the naming service), the Big
+   * Endian is used.
+   *
+   * @param use_big_endian true to use the Big Endian, false to use the Little
+   * Endian encoding.
+   */
+  public void setBigEndian(boolean use_big_endian)
+  {
+    Big_endian = use_big_endian;
+  }
+
+  /**
+   * The the method name to invoke.
+   *
+   * @param operation the method name.
+   */
+  public void setOperation(String operation)
+  {
+    m_operation = operation;
+  }
+
+  /**
+   * Get the parameter stream, where the invocation arguments should be written
+   * if they are written into the stream directly.
+   */
+  public StreamBasedRequest getParameterStream()
+  {
+    m_parameter_buffer = new StreamBasedRequest();
+    m_parameter_buffer.request = this;
+    m_parameter_buffer.setVersion(ior.Internet.version);
+    m_parameter_buffer.setCodeSet(CodeSetServiceContext.negotiate(ior.Internet.CodeSets));
+    m_parameter_buffer.setOrb(orb);
+    m_parameter_buffer.setBigEndian(Big_endian);
+
+    // For the old iiop versions, it is important to set the size
+    // correctly.
+    if (ior.Internet.version.until_inclusive(1, 1))
+      {
+        BufferedCdrOutput measure = new BufferedCdrOutput();
+        measure.setOffset(12);
+        if (m_rqh == null)
+          m_rqh = new gnu.CORBA.GIOP.v1_0.RequestHeader();
+        m_rqh.operation = m_operation;
+        m_rqh.object_key = ior.key;
+        m_rqh.write(measure);
+        m_parameter_buffer.setOffset(12 + measure.buffer.size());
+      }
+
+    return m_parameter_buffer;
+  }
+
+  /**
+   * Creates a shallow copy of this request.
+   */
+  public gnuRequest Clone()
+  {
+    try
+      {
+        return (gnuRequest) clone();
+      }
+    catch (CloneNotSupportedException ex)
+      {
+        throw new Unexpected(ex);
+      }
+  }
+
+  /** {@inheritDoc} */
+  public Any add_in_arg()
+  {
+    gnuNamedValue v = new gnuNamedValue();
+    v.setFlags(ARG_IN.value);
+    m_args.add(v);
+    return v.value();
+  }
+
+  /** {@inheritDoc} */
+  public Any add_inout_arg()
+  {
+    gnuNamedValue v = new gnuNamedValue();
+    v.setFlags(ARG_INOUT.value);
+    m_args.add(v);
+    return v.value();
+  }
+
+  /** {@inheritDoc} */
+  public Any add_named_in_arg(String name)
+  {
+    gnuNamedValue v = new gnuNamedValue();
+    v.setFlags(ARG_IN.value);
+    v.setName(name);
+    m_args.add(v);
+    return v.value();
+  }
+
+  /** {@inheritDoc} */
+  public Any add_named_inout_arg(String name)
+  {
+    gnuNamedValue v = new gnuNamedValue();
+    v.setFlags(ARG_INOUT.value);
+    v.setName(name);
+    m_args.add(v);
+    return v.value();
+  }
+
+  /** {@inheritDoc} */
+  public Any add_named_out_arg(String name)
+  {
+    gnuNamedValue v = new gnuNamedValue();
+    v.setFlags(ARG_OUT.value);
+    v.setName(name);
+    m_args.add(v);
+    return v.value();
+  }
+
+  /** {@inheritDoc} */
+  public Any add_out_arg()
+  {
+    gnuNamedValue v = new gnuNamedValue();
+    v.setFlags(ARG_OUT.value);
+    m_args.add(v);
+    return v.value();
+  }
+
+  /** {@inheritDoc} */
+  public NVList arguments()
+  {
+    return m_args;
+  }
+
+  /** {@inheritDoc} */
+  public ContextList contexts()
+  {
+    return m_context_list;
+  }
+
+  /** {@inheritDoc} */
+  public Context ctx()
+  {
+    return m_context;
+  }
+
+  /** {@inheritDoc} */
+  public void ctx(Context a_context)
+  {
+    m_context = a_context;
+  }
+
+  /** {@inheritDoc} */
+  public Environment env()
+  {
+    return m_environment;
+  }
+
+  /** {@inheritDoc} */
+  public ExceptionList exceptions()
+  {
+    return m_exceptions;
+  }
+
+  /** {@inheritDoc} */
+  public void get_response() throws org.omg.CORBA.WrongTransaction
+  {
+    /**
+     * The response is ready after it is received. FIXME implement context
+     * checks and any other functionality, if required.
+     */
+  }
+
+  /**
+   * Submit the request, suspending the current thread until the answer is
+   * received.
+   *
+   * This implementation requires to set the IOR property ({@link #setIOR(IOR)}
+   * before calling this method.
+   *
+   * @throws BAD_INV_ORDER, minor code 0, if the IOR has not been previously
+   * set.
+   *
+   * @throws SystemException if this exception has been thrown on remote side.
+   * The exact exception type and the minor code are the same as they have been
+   * for the exception, thrown on remoted side.
+   */
+  public synchronized void invoke() throws BAD_INV_ORDER
+  {
+    waitWhileBusy();
+    complete = false;
+    running = true;
+
+    if (ior == null)
+      throw new BAD_INV_ORDER("Set IOR property first");
+
+    try
+      {
+        Forwardings:
+        while (true)
+          {
+            try
+              {
+                p_invoke();
+                break Forwardings;
+              }
+            catch (ForwardRequest e)
+              {
+                try
+                  {
+                    ObjectImpl impl = (ObjectImpl) e.forward;
+                    SimpleDelegate delegate =
+                      (SimpleDelegate) impl._get_delegate();
+                    ior = delegate.getIor();
+                  }
+                catch (Exception ex)
+                  {
+                    BAD_PARAM bad =
+                      new BAD_PARAM("Unsupported forwarding target");
+                    bad.initCause(ex);
+                    throw bad;
+                  }
+              }
+          }
+      }
+    finally
+      {
+        running = false;
+        complete = true;
+      }
+  }
+
+  /** {@inheritDoc} */
+  public String operation()
+  {
+    return m_operation;
+  }
+
+  /**
+   * Get the orb, related to the invocation target.
+   */
+  public ORB orb()
+  {
+    return orb;
+  }
+
+  /** {@inheritDoc} */
+  public boolean poll_response()
+  {
+    return complete && !running;
+  }
+
+  /** {@inheritDoc} */
+  public NamedValue result()
+  {
+    return m_result;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   */
+  public Any return_value()
+  {
+    return m_result.value();
+  }
+
+  /** {@inheritDoc} */
+  public synchronized void send_deferred()
+  {
+    waitWhileBusy();
+    new Thread()
+      {
+        public void run()
+        {
+          invoke();
+        }
+      }.start();
+  }
+
+  /**
+   * Send a request and forget about it, not waiting for a response. This can be
+   * done also for methods that normally are expected to return some values.
+   *
+   * TODO It is generally recommended to reuse the threads. Reuse?
+   */
+  public void send_oneway()
+  {
+    final gnuRequest cloned = Clone();
+    cloned.oneWay = true;
+    
+    new Thread()
+      {
+        public void run()
+        {
+          cloned.invoke();
+        }
+      }.start();
+  }
+
+  /**
+   * Set the argument list. This field is initialised as empty non null instance
+   * by default, so the method is only used in cases when the direct replacement
+   * is desired.
+   *
+   * @param a_args the argument list.
+   */
+  public void set_args(NVList a_args)
+  {
+    if (a_args instanceof gnuNVList)
+      m_args = (gnuNVList) a_args;
+    else
+      {
+        try
+          {
+            // In case if this is another implementation of the NVList.
+            m_args.list.clear();
+            for (int i = 0; i < a_args.count(); i++)
+              {
+                m_args.add(a_args.item(i));
+              }
+          }
+        catch (Bounds ex)
+          {
+            Unexpected.error(ex);
+          }
+      }
+  }
+
+  /**
+   * Set the context list that is later returned by the method
+   * {@link #contexts()}.
+   *
+   * @param a_context_list a new context list.
+   */
+  public void set_context_list(ContextList a_context_list)
+  {
+    m_context_list = a_context_list;
+  }
+
+  /**
+   * Set the exception container. This field is initialised as empty non null
+   * instance by default, so the method is only used in cases when the direct
+   * replacement is desired.
+   *
+   * @param a_environment the new exception container.
+   */
+  public void set_environment(Environment a_environment)
+  {
+    m_environment = a_environment;
+  }
+
+  /**
+   * Set the list of exceptions. This field is initialised as empty non null
+   * instance by default, so the method is only used in cases when the direct
+   * replacement is desired.
+   *
+   * @param a_exceptions a list of exceptions.
+   */
+  public void set_exceptions(ExceptionList a_exceptions)
+  {
+    m_exceptions = a_exceptions;
+  }
+
+  /**
+   * Set the operation name.
+   *
+   * @param a_operation the operation name.
+   */
+  public void set_operation(String a_operation)
+  {
+    m_operation = a_operation;
+  }
+
+  /**
+   * Set the named value, returned as result. This field is initialised as empty
+   * non null instance by default, so the method is only used in cases when the
+   * direct replacement is desired.
+   *
+   * @param a_result the result keeper.
+   */
+  public void set_result(NamedValue a_result)
+  {
+    m_result = a_result;
+  }
+
+  /**
+   * Set the type of the named value, returned as a result. Instantiates a new
+   * instance of the result value.
+   */
+  public void set_return_type(TypeCode returns)
+  {
+    if (m_result == null || !returns.equal(m_result.value().type()))
+      {
+        m_result = new gnuNamedValue();
+        m_result.value().type(returns);
+      }
+  }
+
+  /**
+   * Set the invocation target.
+   *
+   * @param a_target the CORBA object for that the method will be invoked.
+   */
+  public void set_target(org.omg.CORBA.Object a_target)
+  {
+    m_target = a_target;
+  }
+
+  /**
+   * Do the actual invocation. This implementation requires to set the IOR
+   * property ({@link #setIOR(IOR)} before calling this method.
+   * 
+   * @throws BAD_INV_ORDER, minor code 0, if the IOR has not been previously set
+   *           or if the direct argument addition is mixed with the direct
+   *           argument writing into the output stream.
+   * @return the server response in binary form.
+   */
+public synchronized RawReply submit()
+    throws ForwardRequest
+  {
+    gnu.CORBA.GIOP.MessageHeader header = new gnu.CORBA.GIOP.MessageHeader();
+
+    header.setBigEndian(Big_endian);
+
+    // The byte order will be Big Endian by default.
+    header.message_type = gnu.CORBA.GIOP.MessageHeader.REQUEST;
+    header.version = useVersion(ior.Internet.version);
+
+    RequestHeader rh = header.create_request_header();
+    rh.operation = m_operation;
+    rh.object_key = ior.key;
+
+    // Update interceptor.
+    m_rqh = rh;
+
+    if (m_interceptor != null)
+      m_interceptor.send_request(m_info);
+
+    // Prepare the submission.
+    BufferedCdrOutput request_part = new BufferedCdrOutput();
+
+    request_part.setOffset(header.getHeaderSize());
+    request_part.setVersion(header.version);
+    request_part.setCodeSet(CodeSetServiceContext.negotiate(ior.Internet.CodeSets));
+    request_part.setOrb(orb);
+    request_part.setBigEndian(header.isBigEndian());
+
+    // This also sets the stream encoding to the encoding, specified
+    // in the header.
+    rh.write(request_part);
+
+    if (m_args != null && m_args.count() > 0)
+      {
+        write_parameters(header, request_part);
+
+        if (m_parameter_buffer != null)
+          throw new BAD_INV_ORDER("Please either add parameters or "
+            + "write them into stream, but not both " + "at once.");
+      }
+
+    if (m_parameter_buffer != null)
+      {
+        write_parameter_buffer(header, request_part);
+      }
+
+    // Now the message size is available.
+    header.message_size = request_part.buffer.size();
+
+    Socket socket = null;
+
+    java.lang.Object key = ior.Internet.host + ":" + ior.Internet.port;
+
+    synchronized (SocketRepository.class)
+      {
+        socket = SocketRepository.get_socket(key);
+      }
+
+    try
+      {
+        long pause = PAUSE_INITIAL;
+
+        if (socket == null)
+          {
+            // The IOException may be thrown under very heavy parallel
+            // load. For some time, just wait, exceptiong the socket to free.
+            Open: for (int i = 0; i < PAUSE_STEPS; i++)
+              {
+                try
+                  {
+                    if (orb instanceof OrbFunctional)
+                      socket = ((OrbFunctional) orb).socketFactory.
+                        createClientSocket(
+                          ior.Internet.host, ior.Internet.port);
+                    else
+                      socket = new Socket(ior.Internet.host, ior.Internet.port);
+                    break Open;
+                  }
+                catch (IOException ex)
+                  {
+                    try
+                      {
+                        // Expecting to free a socket via finaliser.
+                        System.gc();
+                        Thread.sleep(pause);
+                        pause = pause * 2;
+                        if (pause > PAUSE_MAX)
+                          pause = PAUSE_MAX;
+                      }
+                    catch (InterruptedException iex)
+                      {
+                      }
+                  }
+              }
+          }
+
+        if (socket == null)
+          throw new NO_RESOURCES(ior.Internet.host + ":" + ior.Internet.port
+            + " in use");
+        socket.setKeepAlive(true);
+
+        OutputStream socketOutput = socket.getOutputStream();
+
+        // Write the message header.
+        header.write(socketOutput);
+
+        // Write the request header and parameters (if present).
+        request_part.buffer.writeTo(socketOutput);
+
+        socketOutput.flush();
+        if (!socket.isClosed() && !oneWay)
+          {
+            MessageHeader response_header = new MessageHeader();
+            InputStream socketInput = socket.getInputStream();
+            response_header.read(socketInput);
+
+            byte[] r;
+            if (orb instanceof OrbFunctional)
+              {
+                OrbFunctional fo = (OrbFunctional) orb;
+                r = response_header.readMessage(socketInput, socket,
+                  fo.TOUT_WHILE_READING, fo.TOUT_AFTER_RECEIVING);
+              }
+            else
+              r = response_header.readMessage(socketInput, null, 0, 0);
+
+            return new RawReply(orb, response_header, r);
+          }
+        else
+          return EMPTY;
+      }
+    catch (IOException io_ex)
+      {
+        COMM_FAILURE m = new COMM_FAILURE("Unable to open a socket at "
+          + ior.Internet.host + ":" + ior.Internet.port, 0xC9,
+          CompletionStatus.COMPLETED_NO);
+        m.initCause(io_ex);
+        throw m;
+      }
+    finally
+      {
+        try
+          {
+            if (socket != null && !socket.isClosed())
+              {
+                socket.setSoTimeout(OrbFunctional.TANDEM_REQUESTS);
+                SocketRepository.put_socket(key, socket);
+              }
+          }
+        catch (IOException scx)
+          {
+            InternalError ierr = new InternalError();
+            ierr.initCause(scx);
+            throw ierr;
+          }
+      }
+  }
+
+  /** {@inheritDoc} */
+  public org.omg.CORBA.Object target()
+  {
+    return m_target;
+  }
+
+  /**
+   * Get the used version. Normally, it is better to respond using the same
+   * version as it is specified in IOR, but not above the maximal supported
+   * version.
+   */
+  public Version useVersion(Version desired)
+  {
+    if (desired.until_inclusive(MAX_SUPPORTED.major, MAX_SUPPORTED.minor))
+      return desired;
+    else
+      return MAX_SUPPORTED;
+  }
+
+  /**
+   * Wait while the response to request, submitted using
+   * {@link #send_deferred()} or {@link #invoke()} (from other thread) is
+   * returned.
+   *
+   * FIXME It is possible to rewrite this using Object.wait() and
+   * Object.notify(), but be sure to prepare the test as well.
+   */
+  public synchronized void waitWhileBusy()
+  {
+    // Waiting constants.
+    long wait = 10;
+    long increment = 2;
+    long max = 5000;
+
+    while (running)
+      {
+        try
+          {
+            Thread.sleep(wait);
+            if (wait < max)
+              wait = wait * increment;
+          }
+        catch (InterruptedException ex)
+          {
+          }
+      }
+  }
+
+  /**
+   * Do actual invocation. This method recursively calls itself if the
+   * redirection is detected.
+   */
+  private void p_invoke()
+    throws SystemException, ForwardRequest
+  {
+    RawReply response = submit();
+    
+    // If this is a one way message, do not care about the response.
+    if (oneWay && response == EMPTY)
+      return;
+
+    if (m_rph == null)
+      m_rph = response.header.create_reply_header();
+
+    BufferredCdrInput input = response.getStream();
+    input.setOrb(orb);
+
+    m_rph.read(input);
+
+    // The stream must be aligned sinve v1.2, but only once.
+    boolean align = response.header.version.since_inclusive(1, 2);
+
+    switch (m_rph.reply_status)
+      {
+        case ReplyHeader.NO_EXCEPTION:
+
+          NamedValue arg;
+
+          // Read return value, if set.
+          if (m_result != null)
+            {
+              if (align)
+                {
+                  input.align(8);
+                  align = false;
+                }
+              m_result.value().read_value(input, m_result.value().type());
+            }
+
+          // Read returned parameters, if set.
+          if (m_args != null)
+            for (int i = 0; i < m_args.count(); i++)
+              {
+                try
+                  {
+                    arg = m_args.item(i);
+
+                    // Both ARG_INOUT and ARG_OUT have this binary flag set.
+                    if ((arg.flags() & ARG_OUT.value) != 0)
+                      {
+                        if (align)
+                          {
+                            input.align(8);
+                            align = false;
+                          }
+
+                        arg.value().read_value(input, arg.value().type());
+                      }
+                  }
+                catch (Bounds ex)
+                  {
+                    Unexpected.error(ex);
+                  }
+              }
+
+          if (m_interceptor != null)
+            m_interceptor.receive_reply(m_info);
+
+          break;
+
+        case ReplyHeader.SYSTEM_EXCEPTION:
+          if (align)
+            {
+              input.align(8);
+              align = false;
+            }
+          readExceptionId(input);
+
+          m_sys_ex = ObjectCreator.readSystemException(input,
+            m_rph.service_context);
+          m_environment.exception(m_sys_ex);
+
+          if (m_interceptor != null)
+            m_interceptor.receive_exception(m_info);
+
+          throw m_sys_ex;
+
+        case ReplyHeader.USER_EXCEPTION:
+          if (align)
+            {
+              input.align(8);
+              align = false;
+            }
+          readExceptionId(input);
+
+          // Prepare an Any that will hold the exception.
+          gnuAny exc = new gnuAny();
+          exc.setOrb(orb);
+
+          exc.insert_Streamable(new StreamHolder(input));
+
+          UnknownUserException unuex = new UnknownUserException(exc);
+          m_environment.exception(unuex);
+
+          if (m_interceptor != null)
+            m_interceptor.receive_exception(m_info);
+
+          break;
+
+        case ReplyHeader.LOCATION_FORWARD_PERM:
+        case ReplyHeader.LOCATION_FORWARD:
+          if (response.header.version.since_inclusive(1, 2))
+            input.align(8);
+
+          IOR forwarded = new IOR();
+          try
+            {
+              forwarded._read_no_endian(input);
+            }
+          catch (IOException ex)
+            {
+              new MARSHAL("Cant read forwarding info", 5103,
+                CompletionStatus.COMPLETED_NO);
+            }
+
+          setIor(forwarded);
+
+          m_forward_ior = forwarded;
+
+          if (m_interceptor != null)
+            m_interceptor.receive_other(m_info);
+
+          // Repeat with the forwarded information.
+          p_invoke();
+          return;
+
+        default:
+          throw new MARSHAL("Unknow reply status", 8100 + m_rph.reply_status,
+            CompletionStatus.COMPLETED_NO);
+      }
+  }
+
+  /**
+   * Read exception id without changing the stream pointer position.
+   */
+  void readExceptionId(BufferredCdrInput input)
+  {
+    input.mark(2048);
+    m_exception_id = input.read_string();
+    input.reset();
+  }
+
+  /**
+   * Write the operation parameters.
+   *
+   * @param header the message header
+   * @param request_part the stream to write parameters into
+   *
+   * @throws MARSHAL if the attempt to write the parameters has failde.
+   */
+  protected void write_parameter_buffer(MessageHeader header,
+    BufferedCdrOutput request_part
+  ) throws MARSHAL
+  {
+    try
+      {
+        if (header.version.since_inclusive(1, 2))
+          {
+            request_part.align(8);
+          }
+        m_parameter_buffer.buffer.writeTo(request_part);
+      }
+    catch (IOException ex)
+      {
+        MARSHAL m = new MARSHAL("Unable to write method arguments to CDR output.");
+        m.minor = Minor.CDR;
+        throw m;
+      }
+  }
+
+  /**
+   * Write the operation parameters.
+   *
+   * @param header the message header
+   * @param request_part the stream to write parameters into
+   *
+   * @throws MARSHAL if the attempt to write the parameters has failde.
+   */
+  protected void write_parameters(MessageHeader header,
+    BufferedCdrOutput request_part
+  ) throws MARSHAL
+  {
+    // Align after 1.2, but only once.
+    boolean align = header.version.since_inclusive(1, 2);
+    NamedValue para;
+
+    try
+      {
+        // Write parameters now.
+        for (int i = 0; i < m_args.count(); i++)
+          {
+            para = m_args.item(i);
+
+            // This bit is set both for ARG_IN and ARG_INOUT
+            if ((para.flags() & ARG_IN.value) != 0)
+              {
+                if (align)
+                  {
+                    request_part.align(8);
+                    align = false;
+                  }
+                para.value().write_value(request_part);
+              }
+          }
+      }
+    catch (Bounds ex)
+      {
+        InternalError ierr = new InternalError();
+        ierr.initCause(ex);
+        throw ierr;
+      }
+  }
+
+  /* **************Implementation of the request info operations. ***** */
+
+  /**
+   * Add context to request.
+   */
+  public void add_request_service_context(ServiceContext service_context,
+    boolean replace
+  )
+  {
+    m_rqh.addContext(service_context, replace);
+  }
+
+  /**
+   * Get the Internet profile as an effective profile.
+   */
+  public TaggedProfile effective_profile()
+  {
+    BufferedCdrOutput buf = new BufferedCdrOutput(512);
+    buf.setOrb(orb);
+    ior.Internet.write(buf);
+
+    TaggedProfile p = new TaggedProfile();
+    p.tag = TAG_INTERNET_IOP.value;
+    p.profile_data = buf.buffer.toByteArray();
+    return p;
+  }
+
+  /**
+   * Return either target or forwarded targed.
+   */
+  public org.omg.CORBA.Object effective_target()
+  {
+    return new IorObject(orb, ior);
+  }
+
+  /**
+   * Get effective component with the give id from the Internet profile.
+   */
+  public TaggedComponent get_effective_component(int id)
+    throws BAD_PARAM
+  {
+    if (id == TAG_CODE_SETS.value)
+      {
+        // Codesets are encoded separately.
+        BufferedCdrOutput buf = new BufferedCdrOutput(512);
+        buf.setOrb(orb);
+        ior.Internet.CodeSets.write(buf);
+
+        TaggedComponent t = new TaggedComponent();
+        t.tag = TAG_CODE_SETS.value;
+        t.component_data = buf.buffer.toByteArray();
+        return t;
+      }
+    else
+      {
+        for (int i = 0; i < ior.Internet.components.size(); i++)
+          {
+            TaggedComponent c =
+              (TaggedComponent) ior.Internet.components.get(i);
+            if (c.tag == id)
+              return c;
+          }
+      }
+    throw new BAD_PARAM("No component " + id + " in the Internet profile", 28,
+      CompletionStatus.COMPLETED_MAYBE
+    );
+  }
+
+  /**
+   * Get all components with the given id from the internet profile.
+   */
+  public TaggedComponent[] get_effective_components(int id)
+    throws BAD_PARAM
+  {
+    if (id == TAG_CODE_SETS.value)
+      return new TaggedComponent[] { get_effective_component(TAG_CODE_SETS.value) };
+    else
+      {
+        ArrayList components = new ArrayList(ior.Internet.components.size());
+        for (int i = 0; i < ior.Internet.components.size(); i++)
+          {
+            TaggedComponent c =
+              (TaggedComponent) ior.Internet.components.get(i);
+            if (c.tag == id)
+              components.add(c);
+          }
+        if (components.size() == 0)
+          throw new BAD_PARAM("No component " + id +
+            " in the Internet profile", 28, CompletionStatus.COMPLETED_MAYBE
+          );
+        else
+          {
+            TaggedComponent[] t = new TaggedComponent[ components.size() ];
+            for (int i = 0; i < t.length; i++)
+              t [ i ] = (TaggedComponent) components.get(i);
+            return t;
+          }
+      }
+  }
+
+  /**
+   * This should be not implemented up till jdk 1.5 inclusive.
+   */
+  public Policy get_request_policy(int type) throws INV_POLICY
+  {
+    throw new NO_IMPLEMENT();
+  }
+
+  /** @inheritDoc */
+  public String received_exception_id()
+  {
+    return m_exception_id;
+  }
+
+  /** @inheritDoc */
+  public Any received_exception()
+  {
+    if (m_exception_id == null)
+      return null;
+
+    if (m_sys_ex != null)
+      {
+        Any a = orb.create_any();
+        ObjectCreator.insertSysException(a, m_sys_ex);
+        return a;
+      }
+
+    Exception mex = m_environment.exception();
+
+    UnknownUserException ex = (UnknownUserException) mex;
+    if (ex == null)
+      return null;
+    else
+      return ex.except;
+  }
+
+  /**
+   * Return the forwarded reference, null if none.
+   */
+  public org.omg.CORBA.Object forward_reference()
+  {
+    if (m_forwarding_target != null)
+      return m_forwarding_target;
+
+    if (m_forward_ior != null)
+      return new IorObject(orb, m_forward_ior);
+    else
+      return null;
+  }
+
+  /**
+   * Get the slot from the slot array inside this request.
+   */
+  public Any get_slot(int id) throws InvalidSlot
+  {
+    try
+      {
+        return m_slots [ id ];
+      }
+    catch (Exception e)
+      {
+        throw new InvalidSlot("slot id " + id + ":" + e);
+      }
+  }
+
+  /**
+   * Get the reply status.
+   */
+  public short reply_status()
+  {
+    if (m_rph == null)
+      throw new BAD_INV_ORDER("Request not yet sent", 14,
+        CompletionStatus.COMPLETED_NO
+      );
+    return (short) m_rph.reply_status;
+  }
+
+  /**
+   * Get the request id.
+   */
+  public int request_id()
+  {
+    return m_rqh.request_id;
+  }
+
+  /**
+   * Return true if the response is expected.
+   */
+  public boolean response_expected()
+  {
+    return !oneWay;
+  }
+
+  /**
+   * Determines how far the request shall progress before control is returned to
+   * the client. However up till JDK 1.5 inclusive this method always returns
+   * SYNC_WITH_TRANSPORT.
+   *
+   * @return {@link org.omg.Messaging.SYNC_WITH_TRANSPORT.value (1), always.
+   *
+   * @specnote as defined in the Suns 1.5 JDK API.
+   */
+  public short sync_scope()
+  {
+    return org.omg.Messaging.SYNC_WITH_TRANSPORT.value;
+  }
+
+  /** @inheritDoc */
+  public ServiceContext get_request_service_context(int ctx_name)
+    throws BAD_PARAM
+  {
+    return gnu.CORBA.GIOP.ServiceContext.findContext(ctx_name,
+      m_rqh.service_context
+    );
+  }
+
+  /** @inheritDoc */
+  public ServiceContext get_reply_service_context(int ctx_name)
+    throws BAD_PARAM
+  {
+    if (m_rph == null)
+      throw new BAD_INV_ORDER("Reply context not yet available");
+    return gnu.CORBA.GIOP.ServiceContext.findContext(ctx_name,
+      m_rph.service_context
+    );
+  }
+
+  /** @inheritDoc */
+  public String[] operation_context()
+  {
+    return ice_contexts();
+  }
+
+  /**
+   * Get contexts as required by interceptor.
+   */
+  public String[] ice_contexts()
+  {
+    if (m_context_list == null)
+      return new String[ 0 ];
+    else
+      {
+        try
+          {
+            String[] cn = new String[ m_context_list.count() ];
+            for (int i = 0; i < cn.length; i++)
+              cn [ i ] = m_context_list.item(i);
+            return cn;
+          }
+        catch (Bounds e)
+          {
+            throw new Unexpected(e);
+          }
+      }
+  }
+
+  /**
+   * Check if the call is done via DII.
+   */
+  public void checkDii()
+  {
+    if (m_parameter_buffer != null)
+      throw new NO_RESOURCES("The invocation method provides " +
+        "no access to this resource. DII call required.", 1,
+        CompletionStatus.COMPLETED_MAYBE
+      );
+  }
+}
\ No newline at end of file

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/gnuValueHolder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/gnuValueHolder.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,135 @@
+/* gnuValueHolder.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 gnu.CORBA;
+
+import gnu.CORBA.CDR.Vio;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ValueBaseHolder;
+import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.io.Serializable;
+
+/**
+ * Boxed value holder that also remembers the value type and the value helper.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class gnuValueHolder
+  extends ValueBaseHolder
+{
+  /**
+   * The type code of the stored value.
+   */
+  TypeCode type;
+
+  /**
+   * The helper that could read and write fields of the boxed value.
+   */
+  transient BoxedValueHelper helper;
+
+  /**
+   * If true, the helper not available.
+   */
+  transient boolean helper_NA;
+
+  /**
+   * Create a new instance for the given value and given type.
+   */
+  public gnuValueHolder(Serializable value, TypeCode a_type)
+  {
+    super(value);
+    type = a_type;
+  }
+
+  /**
+   * Get the true type, as it was passed in the constructor.
+   */
+  public TypeCode _type()
+  {
+    return type;
+  }
+
+  /**
+   * Write content to the output stream. Tries to locate the
+   * corresponding helper class.
+   */
+  public void _write(OutputStream output)
+  {
+    findHelper();
+    if (helper == null)
+      super._write(output);
+    else
+      Vio.write(output, value, helper);
+  }
+
+  /**
+   * Read, trying to locate helper, if possible.
+   */
+  public void _read(InputStream input)
+  {
+    findHelper();
+    if (helper == null)
+      super._read(input);
+    else
+      value = Vio.read(input, helper);
+  }
+
+  /**
+   * Set the read and write methods.
+   */
+  void findHelper()
+  {
+    if (helper != null || helper_NA)
+      return;
+    try
+      {
+        Class helperClass =
+          ObjectCreator.forName(ObjectCreator.toHelperName(type.id()));
+
+        helper = (BoxedValueHelper) helperClass.newInstance();
+      }
+    catch (Exception ex)
+      {
+        helper_NA = true;
+      }
+  }
+}
\ No newline at end of file

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/interfaces/SocketFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/interfaces/SocketFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,95 @@
+/* SocketFactory.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 gnu.CORBA.interfaces;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * This class produces sockets for serving and submitting CORBA requests. The
+ * socket factory can be set using {@link gnuOrb.setSocketFactory()} for
+ * producting all sockets for that ORB. This is needed for using secure sockets,
+ * for implementing the desired timeout policies, for HTTP tunnels and in some
+ * other similar cases. While such functionality is provided by near all
+ * existing CORBA implementations, no standard mechanism is defined.
+ * 
+ * The socket factory may need to put additional information to the IORs of the
+ * objects, released by the ORB. Because of this reason, this interface extends
+ * IORInterceptorOperations.
+ * 
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public interface SocketFactory
+{
+  /**
+   * The name of the ORB property that forces the ORB to use the socket
+   * factory class, the name of that (String) is the value of this property.
+   */
+  final String PROPERTY = "gnu.CORBA.SocketFactory";
+  
+  /**
+   * Create a server socket that should serve remote invocations on the given
+   * port. The ORB may use this socket to serve either one or more objects.
+   * 
+   * @param port the port, on that the socket should be listening for requests.
+   * The port policy can be controlled by {@link gnuPortManager}.
+   * 
+   * @throws IOException if the socket cannot be created on the given port due
+   * any reasons. The ORB may try to open the socket on another port, calling
+   * this method with the different parameter.
+   */
+  ServerSocket createServerSocket(int port)
+    throws IOException;
+  
+  /**
+   * Create a client socket that should send a request to the remote side. When
+   * returned, the socket should be opened and ready to communicate.
+   * 
+   * @param port the port, on that the socket should be openend. The port is
+   * usually part of the internet profile.
+   * 
+   * @throws IOException if the socket cannot be created on the given port due
+   * any reasons. The ORB may try to open the socket on another port, calling
+   * this method with the different parameter.
+   */
+  Socket createClientSocket(String host, int port)
+    throws IOException;
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/interfaces/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/interfaces/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/interfaces/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/interfaces/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html -
+   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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.CORBA.interfaces</title></head>
+
+<body>
+<p>This package contains Classpath specific interfaces that
+the user program may be forced to use in cases when no
+other, better solution of the problem is available. The
+existing classes and methods in this package should not
+be removed without the real need</p>
+</body>
+</html>

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/AliasTypeCode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/AliasTypeCode.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,148 @@
+/* AliasTypeCode.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 gnu.CORBA.typecodes;
+
+
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+
+/**
+ * The type code that is an alias of another type code.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class AliasTypeCode
+  extends PrimitiveTypeCode
+{
+  /** 
+   * Use serialVersionUID for interoperability. 
+   */
+  private static final long serialVersionUID = 1;
+  
+  /**
+   * The typecode repository id.
+   */
+  protected final String id;
+
+  /**
+   * The typecode name.
+   */
+  protected final String name;
+
+  /**
+   * The type code for that this typecode is an alias.
+   */
+  protected final TypeCode aliasFor;
+
+  /**
+   * Create the typecode, specifying for that typecode it is an
+   * alias and the id and name of the newly created typecode.
+   *
+   * @param an_aliasFor the typecode, for that this typecode is an
+   * alias.
+   *
+   * @param an_id the repository id fo the newly created typecode.
+   *
+   * @param a_name the name of the newly created typecode.
+   */
+  public AliasTypeCode(TypeCode an_aliasFor, String an_id, String a_name)
+  {
+    super(TCKind.tk_alias);
+    aliasFor = an_aliasFor;
+    id = an_id;
+    name = a_name;
+  }
+
+  /**
+   * Get the typecode, for that this typecode is an alias.
+   */
+  public TypeCode content_type()
+  {
+    return aliasFor;
+  }
+
+  /**
+   * The objects are assumed to be equal if they repository
+   * ids are both equal or both unavailable and the
+   * kind values are equal.
+   *
+   * @param other the other typecode to compare.
+   */
+  public boolean equal(TypeCode other)
+  {
+    if (super.equal(other))
+      return true;
+    try
+      {
+        return id.equals(other.id());
+      }
+    catch (BadKind ex)
+      {
+        return false;
+      }
+  }
+
+  /**
+   * Return true if the given typecode is equal for
+   * either this typecode of the alias typecode.
+   *
+   * @param other the typecode to compare.
+   */
+  public boolean equivalent(TypeCode other)
+  {
+    return other.equal(this) || other.equal(aliasFor);
+  }
+
+  /**
+   * Get the repository id of this typecode.
+   */
+  public String id()
+  {
+    return id;
+  }
+
+  /**
+   * Get the name of this typecode.
+   */
+  public String name()
+  {
+    return name;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/ArrayTypeCode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/ArrayTypeCode.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,272 @@
+/* ArrayTypeCode.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 gnu.CORBA.typecodes;
+
+
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+
+/**
+ * A TypeCode for arrays.
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)
+ */
+public class ArrayTypeCode
+  extends PrimitiveTypeCode
+{
+  /** 
+   * Use serialVersionUID for interoperability. 
+   */
+  private static final long serialVersionUID = 1;
+  
+  
+  /**
+   * The array components.
+   */
+  TypeCode of;
+
+  /**
+   * The length of the array, must be updated when setting
+   * a new value.
+   */
+  private int length;
+
+  /**
+   * Create a primitive array type code, defining the sequence
+   * {@link TCKind.tk_sequence)} with
+   * the given member type.
+   *
+   * @param array_of the sequence member type.
+   */
+  public ArrayTypeCode(TCKind array_of)
+  {
+    super(TCKind.tk_sequence);
+    of = new PrimitiveTypeCode(array_of);
+  }
+
+  /**
+   * Create a primitive array type code, defining the array, sequence
+   * or other type  with the given member type.
+   *
+   * @param this_type the type of this type (normally either
+   * sequence of array).
+   * @param array_of the sequence member type.
+   */
+  public ArrayTypeCode(TCKind this_type, TypeCode array_of)
+  {
+    super(this_type);
+    of = array_of;
+  }
+
+  /**
+   * Return the array component type.
+   * @return the array component type
+   * @throws org.omg.CORBA.TypeCodePackage.BadKind
+   */
+  public TypeCode content_type()
+                        throws org.omg.CORBA.TypeCodePackage.BadKind
+  {
+    return of;
+  }
+
+  /**
+   * Return true if the other TypeCode defines the array, having elements
+   * of the same type. The sizes of arrays are not taken into
+   * consideration.
+   *
+   * @param other the other TypeCode
+   * @return true if <code>other</code> is an array with the same
+   * component type.
+   */
+  public boolean equal(TypeCode other)
+  {
+    try
+      {
+        return kind() == other.kind() &&
+               content_type() == other.content_type();
+      }
+    catch (BadKind ex)
+      {
+        // Should not be thrown.
+        return false;
+      }
+  }
+
+  /**
+   * Returns the agreed Id in the form of
+   * <code>IDL:omg.org/CORBA/ {type name} Seq:1.0</code>.
+   *
+   * @return the Id of this TypeCode.
+   *
+   * @throws org.omg.CORBA.TypeCodePackage.BadKind if the content type
+   * is not one of the constants, defined in {@link TCKind}.
+   * This package class should not be used as TypeCode for the arrays,
+   * holding the user defined components.
+   */
+  public String id()
+            throws org.omg.CORBA.TypeCodePackage.BadKind
+  {
+    switch (content_type().kind().value())
+      {
+        case TCKind._tk_null :
+          return "IDL:omg.org/CORBA/NullSeq:1.0";
+
+        case TCKind._tk_void :
+          return "IDL:omg.org/CORBA/VoidSeq:1.0";
+
+        case TCKind._tk_short :
+          return "IDL:omg.org/CORBA/ShortSeq:1.0";
+
+        case TCKind._tk_long :
+          return "IDL:omg.org/CORBA/LongSeq:1.0";
+
+        case TCKind._tk_ushort :
+          return "IDL:omg.org/CORBA/UShortSeq:1.0";
+
+        case TCKind._tk_ulong :
+          return "IDL:omg.org/CORBA/ULongSeq:1.0";
+
+        case TCKind._tk_float :
+          return "IDL:omg.org/CORBA/FloatSeq:1.0";
+
+        case TCKind._tk_double :
+          return "IDL:omg.org/CORBA/DoubleSeq:1.0";
+
+        case TCKind._tk_boolean :
+          return "IDL:omg.org/CORBA/BooleanSeq:1.0";
+
+        case TCKind._tk_char :
+          return "IDL:omg.org/CORBA/CharSeq:1.0";
+
+        case TCKind._tk_octet :
+          return "IDL:omg.org/CORBA/OctetSeq:1.0";
+
+        case TCKind._tk_any :
+          return "IDL:omg.org/CORBA/AnySeq:1.0";
+
+        case TCKind._tk_TypeCode :
+          return "IDL:omg.org/CORBA/TypeCodeSeq:1.0";
+
+        case TCKind._tk_Principal :
+          return "IDL:omg.org/CORBA/PrincipalSeq:1.0";
+
+        case TCKind._tk_objref :
+          return "IDL:omg.org/CORBA/ObjrefSeq:1.0";
+
+        case TCKind._tk_struct :
+          return "IDL:omg.org/CORBA/StructSeq:1.0";
+
+        case TCKind._tk_union :
+          return "IDL:omg.org/CORBA/UnionSeq:1.0";
+
+        case TCKind._tk_enum :
+          return "IDL:omg.org/CORBA/EnumSeq:1.0";
+
+        case TCKind._tk_string :
+          return "IDL:omg.org/CORBA/StringSeq:1.0";
+
+        case TCKind._tk_sequence :
+          return "IDL:omg.org/CORBA/SequenceSeq:1.0";
+
+        case TCKind._tk_array :
+          return "IDL:omg.org/CORBA/ArraySeq:1.0";
+
+        case TCKind._tk_alias :
+          return "IDL:omg.org/CORBA/AliasSeq:1.0";
+
+        case TCKind._tk_except :
+          return "IDL:omg.org/CORBA/ExceptSeq:1.0";
+
+        case TCKind._tk_longlong :
+          return "IDL:omg.org/CORBA/LongLongSeq:1.0";
+
+        case TCKind._tk_ulonglong :
+          return "IDL:omg.org/CORBA/ULongLongSeq:1.0";
+
+        case TCKind._tk_longdouble :
+          return "IDL:omg.org/CORBA/LongDoubleSeq:1.0";
+
+        case TCKind._tk_wchar :
+          return "IDL:omg.org/CORBA/WCharSeq:1.0";
+
+        case TCKind._tk_wstring :
+          return "IDL:omg.org/CORBA/WStringSeq:1.0";
+
+        case TCKind._tk_fixed :
+          return "IDL:omg.org/CORBA/FixedSeq:1.0";
+
+        case TCKind._tk_value :
+          return "IDL:omg.org/CORBA/ValueSeq:1.0";
+
+        case TCKind._tk_value_box :
+          return "IDL:omg.org/CORBA/Value_boxSeq:1.0";
+
+        case TCKind._tk_native :
+          return "IDL:omg.org/CORBA/NativeSeq:1.0";
+
+        case TCKind._tk_abstract_interface :
+          return "IDL:omg.org/CORBA/Abstract_interfaceSeq:1.0";
+
+        default :
+          throw new BadKind();
+      }
+  }
+
+  /**
+   * Return the array length.
+   * @return the length of the array.
+   * @throws org.omg.CORBA.TypeCodePackage.BadKind
+   */
+  public int length()
+             throws org.omg.CORBA.TypeCodePackage.BadKind
+  {
+    return length;
+  }
+
+  /**
+   * Sets the array length to the supplied value.
+   *
+   * @param l the new length.
+   */
+  public void setLength(int l)
+  {
+    this.length = l;
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/FixedTypeCode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/FixedTypeCode.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,152 @@
+/* FixedTypeCode.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 gnu.CORBA.typecodes;
+
+
+import java.math.BigDecimal;
+
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+
+/**
+ * A typecode for CORBA <code>fixed</code>
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)
+ */
+public class FixedTypeCode
+  extends PrimitiveTypeCode
+{
+  /** 
+   * Use serialVersionUID for interoperability. 
+   */
+  private static final long serialVersionUID = 1;
+  
+  
+  /**
+   * The number of the used digits.
+   */
+  private short digits;
+
+  /**
+   * The number of the digits after the decimal point.
+   */
+  private short scale;
+
+  /**
+   * Creates the instance of the fixed type code.
+   */
+  public FixedTypeCode()
+  {
+    super(TCKind.tk_fixed);
+  }
+
+  /**
+   * Creates the instance of the fixed type code,
+   * setting the digits and scale by example.
+   */
+  public FixedTypeCode(BigDecimal example)
+  {
+    super(TCKind.tk_fixed);
+    if (example != null)
+      {
+        setScale(example.scale());
+        setDigits(countDigits(example));
+      }
+  }
+
+  /**
+   * Set the number of digits.
+   */
+  public void setDigits(int a_digits)
+  {
+    this.digits = (short) a_digits;
+  }
+
+  /**
+   * Set the number of digits after the decimal point.
+   */
+  public void setScale(int a_scale)
+  {
+    this.scale = (short) a_scale;
+  }
+
+  /**
+   * Get the number of digits in thid BigDecimal
+   *
+   * @param x a BigDecimal to check.
+   */
+  public static int countDigits(BigDecimal number)
+  {
+    return number.unscaledValue().abs().toString().length();
+  }
+
+  /**
+   * Compare with other type code for equality.
+   */
+  public boolean equal(TypeCode other)
+  {
+    if (other == this) return true;
+    try
+      {
+        TypeCode that = (TypeCode) other;
+        return kind() == that.kind() && digits == that.fixed_digits() &&
+               scale == that.fixed_scale();
+      }
+    catch (BadKind ex)
+      {
+        return false;
+      }
+  }
+
+  /**
+   * Get the number of digits.
+   */
+  public short fixed_digits()
+  {
+    return digits;
+  }
+
+  /**
+   * Get the number of digits after the decimal point.
+   */
+  public short fixed_scale()
+  {
+    return scale;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/GeneralTypeCode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/GeneralTypeCode.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,249 @@
+/* GeneralTypeCode.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 gnu.CORBA.typecodes;
+
+import gnu.CORBA.CDR.BufferedCdrOutput;
+
+import java.util.Arrays;
+import java.util.BitSet;
+
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+
+/**
+ * A typecode for types, requiring to provide various additional
+ * properties but still not requiring to store the
+ * members of the structure. The property can be retrieved
+ * by the corresponding method if it has been previously assigned.
+ * Otherwise, a {@link BadKind} is thrown.
+ *
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)
+ */
+public class GeneralTypeCode
+  extends PrimitiveTypeCode
+{
+  /** 
+   * Use serialVersionUID for interoperability. 
+   */
+  private static final long serialVersionUID = 1;
+  
+  
+  /**
+   * Indicates that the field value has not been previously set.
+   */
+  protected static int UNSET = Integer.MIN_VALUE;
+
+  /**
+   * The kinds for that the length() must return 0 even if it
+   * has not been previously set.
+   */
+  private static final BitSet lengthAllowed = new BitSet();
+
+  static
+  {
+    lengthAllowed.set(TCKind._tk_array);
+    lengthAllowed.set(TCKind._tk_sequence);
+    lengthAllowed.set(TCKind._tk_string);
+    lengthAllowed.set(TCKind._tk_wstring);
+  }
+
+  private String id;
+  private String name;
+  private TypeCode concrete_base_type;
+  private TypeCode content_type;
+  private int len;
+  private int type_modifier = UNSET;
+
+  /**
+   * Create a new instance, setting kind to the given kind.
+   * @param a_kind the kind of the typecode being created.
+   */
+  public GeneralTypeCode(TCKind a_kind)
+  {
+    super(a_kind);
+    if (!lengthAllowed.get(a_kind.value()))
+      len = UNSET;
+  }
+
+  /**
+   * Set this property.
+   */
+  public void setConcreteBase_type(TypeCode a_concrete_base_type)
+  {
+    this.concrete_base_type = a_concrete_base_type;
+  }
+
+  /**
+   * Set the component content type.
+   */
+  public void setContentType(TypeCode a_content_type)
+  {
+    this.content_type = a_content_type;
+  }
+
+  /**
+   * Set this property.
+   */
+  public void setId(String an_id)
+  {
+    this.id = an_id;
+  }
+
+  /**
+   * Set the length property.
+   * @param l
+   */
+  public void setLength(int l)
+  {
+    len = l;
+  }
+
+  /**
+   * Set this property.
+   */
+  public void setName(String a_name)
+  {
+    this.name = a_name;
+  }
+
+  /**
+   * Set the type modifier.
+   */
+  public void setTypeModifier(int a_type_modifier)
+  {
+    this.type_modifier = a_type_modifier;
+  }
+
+  /** {@inheritDoc} */
+  public TypeCode concrete_base_type()
+                              throws BadKind
+  {
+    if (concrete_base_type != null)
+      return concrete_base_type;
+    throw new BadKind("concrete_base_type");
+  }
+
+  /**
+   * Returns the content type that must be explicitly set
+   * for this class.
+   *
+   * @throws BadKind if the content type has not been set.
+   */
+  public TypeCode content_type()
+                        throws BadKind
+  {
+    if (content_type != null)
+      return content_type;
+    throw new BadKind("content_type");
+  }
+
+  /**
+   * Returns true if both typecodes, if written into CDR
+   * stream, would result the same stream content.
+   */
+  public boolean equal(TypeCode other)
+  {
+    if (this == other)
+      return true;
+    if (kind() != other.kind())
+      return false;
+
+    BufferedCdrOutput a = new BufferedCdrOutput(16);
+    BufferedCdrOutput b = new BufferedCdrOutput(16);
+
+    a.write_TypeCode(this);
+    b.write_TypeCode(other);
+
+    return Arrays.equals(a.buffer.toByteArray(), b.buffer.toByteArray());
+  }
+
+  /**
+   * Delegates functionality to {@link #equal}.
+   */
+  public boolean equivalent(TypeCode other)
+  {
+    return equal(other);
+  }
+
+  /** {@inheritDoc} */
+  public String id()
+            throws BadKind
+  {
+    if (id != null)
+      return id;
+    throw new BadKind("id");
+  }
+
+  /**
+   * Get the length. For sequences, arrays, strings and wstrings
+   * this method returns 0 rather than throwing a BadKind even
+   * if {@link setLength(int)} has not been previously called.
+   *
+   * @return the length of string, array or sequence.
+   *
+   * @throws BadKind if the method cannot be invoked for the
+   * given kind of typecode.
+   */
+  public int length()
+             throws BadKind
+  {
+    if (len != UNSET)
+      return len;
+    throw new BadKind("length");
+  }
+
+  /** {@inheritDoc} */
+  public String name()
+              throws BadKind
+  {
+    if (name != null)
+      return name;
+    throw new BadKind("name");
+  }
+
+  /** {@inheritDoc} */
+  public short type_modifier()
+                      throws BadKind
+  {
+    if (type_modifier != UNSET)
+      return (short) type_modifier;
+    throw new BadKind("type_modifier");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/PrimitiveTypeCode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/PrimitiveTypeCode.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,201 @@
+/* PrimitiveTypeCode.java --
+    Copyright (C) 2005 Free Software Foundation, Inc.
+
+   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.CORBA.typecodes;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.TypeCodePackage.Bounds;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * An information about a primitive CORBA data type
+ * (boolean, char, wchar, octet and also signed or unsigned short, long,
+ * long long, float and double).
+ * This class only implements the methods {@link #kind() }
+ * and {@link equal() } that are valid for
+ * all TypeCode kinds. Other methods are implemented in derived
+ * subclasses.
+ *
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)
+ */
+public class PrimitiveTypeCode
+  extends TypeCode
+  implements IDLEntity, Serializable
+{
+  /** 
+   * Use serialVersionUID for interoperability. 
+   */
+  private static final long serialVersionUID = 1;
+  
+  /**
+   * The kind of this TypeCode.
+   */
+  protected final TCKind kind;
+
+  public PrimitiveTypeCode(TCKind a_kind)
+  {
+    kind = a_kind;
+  }
+
+  public TypeCode concrete_base_type()
+                              throws BadKind
+  {
+    throw new BadKind();
+  }
+
+  public TypeCode content_type()
+                        throws BadKind
+  {
+    throw new BadKind();
+  }
+
+  public int default_index()
+                    throws BadKind
+  {
+    throw new BadKind();
+  }
+
+  public TypeCode discriminator_type()
+                              throws BadKind
+  {
+    throw new BadKind();
+  }
+
+  /**
+   * Test two types for equality. The default implementation
+   * returs true of the types of the same kind.
+   * @param other the other type to compere with
+   * @return true if the types are interchangeable.
+   */
+  public boolean equal(TypeCode other)
+  {
+    return kind() == other.kind();
+  }
+
+  public boolean equivalent(TypeCode parm1)
+  {
+    throw new NO_IMPLEMENT();
+  }
+
+  public short fixed_digits()
+                     throws BadKind
+  {
+    throw new BadKind("fixed_digits");
+  }
+
+  public short fixed_scale()
+                    throws BadKind
+  {
+    throw new BadKind("fixed_scale");
+  }
+
+  public TypeCode get_compact_typecode()
+  {
+    throw new NO_IMPLEMENT();
+  }
+
+  public String id()
+            throws BadKind
+  {
+    throw new BadKind("id");
+  }
+
+  /**
+   * Return the kind of this type code object.
+   * @return one of the <code>TCKind.t_..</code> fields.
+   */
+  public TCKind kind()
+  {
+    return kind;
+  }
+
+  public int length()
+             throws BadKind
+  {
+    throw new BadKind("length");
+  }
+
+  public int member_count()
+                   throws BadKind
+  {
+    throw new BadKind("member_count");
+  }
+
+  public Any member_label(int index)
+                   throws BadKind, Bounds
+  {
+    throw new BadKind("member_label");
+  }
+
+  public String member_name(int index)
+                     throws BadKind, Bounds
+  {
+    throw new BadKind("member_name");
+  }
+
+  public TypeCode member_type(int index)
+                       throws BadKind, Bounds
+  {
+    throw new BadKind("member_type");
+  }
+
+  public short member_visibility(int index)
+                          throws BadKind, Bounds
+  {
+    throw new BadKind("member_visibility");
+  }
+
+  public String name()
+              throws BadKind
+  {
+    throw new BadKind("name");
+  }
+
+  public short type_modifier()
+                      throws BadKind
+  {
+    throw new BadKind("type_modifier");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/RecordTypeCode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/RecordTypeCode.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,252 @@
+/* RecordTypeCode.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 gnu.CORBA.typecodes;
+
+import gnu.CORBA.CorbaList;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.TypeCodePackage.Bounds;
+import org.omg.CORBA.UnionMember;
+import org.omg.CORBA.ValueMember;
+
+/**
+ * The type code that also has the member property getters
+ * supported.
+ *
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)
+ */
+public class RecordTypeCode
+  extends GeneralTypeCode
+{
+  /** 
+   * Use serialVersionUID for interoperability. 
+   */
+  private static final long serialVersionUID = 1;
+  
+  /**
+   * The individual field of the record.
+   */
+  public static class Field
+  {
+    /**
+     * The record label.
+     */
+    public Any label;
+
+    /**
+     * The record name.
+     */
+    public String name;
+
+    /**
+     * The record type.
+     */
+    public TypeCode type;
+
+    /**
+     * The record visibility.
+     */
+    public int visibility = UNSET;
+  }
+
+  /**
+   * The members of this data structure.
+   */
+  protected CorbaList members = new CorbaList();
+  private TypeCode discriminator_type;
+  private int default_index = UNSET;
+
+  /**
+   * Creates the type code of the given kind.
+   */
+  public RecordTypeCode(TCKind a_kind)
+  {
+    super(a_kind);
+  }
+
+  /**
+   * Set the default index.
+   */
+  public void setDefaultIndex(int a_default_index)
+  {
+    this.default_index = a_default_index;
+  }
+
+  /**
+   * Set the discriminator type.
+   */
+  public void setDiscriminator_type(TypeCode a_discriminator_type)
+  {
+    this.discriminator_type = a_discriminator_type;
+  }
+
+  public Field getField(int p)
+  {
+    return (Field) members.get(p);
+  }
+
+  public void add(Field field)
+  {
+    members.add(field);
+  }
+
+  /**
+   * Adds a new field, taking values from the passed
+   * {@link StructMember}.
+   */
+  public void add(StructMember m)
+  {
+    Field f = field();
+    f.name = m.name;
+    f.type = m.type;
+  }
+
+  /**
+   * Adds a new field, taking values from the passed
+   * {@link ValueMember}.
+   */
+  public void add(ValueMember m)
+  {
+    Field f = field();
+    f.name = m.name;
+    f.type = m.type;
+    f.visibility = m.access;
+    
+  }
+
+  /**
+   * Adds a new field, taking values from the passed
+   * {@link UnionMember}.
+   */
+  public void add(UnionMember m)
+  {
+    Field f = field();
+    f.name = m.name;
+    f.type = m.type;
+    f.label = m.label;
+  }
+
+  public int default_index()
+                    throws BadKind
+  {
+    if (default_index != UNSET)
+      return default_index;
+    throw new BadKind();
+  }
+
+  public TypeCode discriminator_type()
+                              throws BadKind
+  {
+    if (discriminator_type != null)
+      return discriminator_type;
+    throw new BadKind();
+  }
+
+  /**
+   * Creates, adds and returns new field.
+   */
+  public Field field()
+  {
+    Field f = new Field();
+    members.add(f);
+    return f;
+  }
+
+  /** {@inheritDoc} */
+  public int member_count()
+  {
+    return members.size();
+  }
+
+  /** {@inheritDoc} */
+  public Any member_label(int index)
+                   throws BadKind, Bounds
+  {
+    Field f = getField(index);
+    if (f.label != null)
+      {
+        return f.label;
+      }
+    else
+      throw new BadKind();
+  }
+
+  /** {@inheritDoc} */
+  public String member_name(int index)
+                     throws BadKind
+  {
+    Field f = getField(index);
+    if (f.name != null)
+      {
+        return f.name;
+      }
+    else
+      throw new BadKind();
+  }
+
+  /** {@inheritDoc} */
+  public TypeCode member_type(int index)
+                       throws BadKind, Bounds
+  {
+    Field f = getField(index);
+    if (f.type != null)
+      {
+        return f.type;
+      }
+    else
+      throw new BadKind();
+  }
+
+  /** {@inheritDoc} */
+  public short member_visibility(int index)
+                          throws BadKind, Bounds
+  {
+    Field f = getField(index);
+    if (f.visibility != UNSET)
+      {
+        return (short) f.visibility;
+      }
+    else
+      throw new BadKind();
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/RecursiveTypeCode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/RecursiveTypeCode.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,84 @@
+/* RecursiveTypeCode.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 gnu.CORBA.typecodes;
+
+
+import org.omg.CORBA.TCKind;
+
+/**
+ * The typecode, serving as a placeholder in defining
+ * typecodes, containing recursion.
+ */
+public class RecursiveTypeCode
+  extends PrimitiveTypeCode
+{
+  /** 
+   * Use serialVersionUID for interoperability. 
+   */
+  private static final long serialVersionUID = 1;
+  
+  /**
+   * The id of the type for that this type serves as a
+   * placeholder.
+   */
+  private final String the_id;
+
+  /**
+   * Create a typecode that serves as a placeholder for
+   * the typecode with the given id.
+   *
+   * @param id the Id of the type for that this type serves as a
+   * placeholder.
+   */
+  public RecursiveTypeCode(String an_id)
+  {
+    super(TCKind.tk_null);
+    the_id = an_id;
+  }
+
+  /**
+   * Get the id of the type for that this type serves as a
+   * placeholder.
+   */
+  public String id()
+            throws org.omg.CORBA.TypeCodePackage.BadKind
+  {
+    return the_id;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/StringTypeCode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/StringTypeCode.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* StringTypeCode.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 gnu.CORBA.typecodes;
+
+
+import org.omg.CORBA.TCKind;
+
+/**
+ * The typecode for string and wide string.
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)
+ */
+public class StringTypeCode
+  extends PrimitiveTypeCode
+{
+  /** 
+   * Use serialVersionUID for interoperability. 
+   */
+  private static final long serialVersionUID = 1;
+  
+  private int len = 0;
+
+  /**
+   * Create a new instance of the string type code.
+   *
+   * @param a_kind a kind of this typecode, normally
+   * either tk_string or tk_wstring.
+   */
+  public StringTypeCode(TCKind a_kind)
+  {
+    super(a_kind);
+  }
+
+  /**
+   * Set the length property.
+   *
+   * @param a_length a length.
+   */
+  public void setLength(int a_length)
+  {
+    len = a_length;
+  }
+
+  /**
+   * Get the length of the string. This method returns 0
+   * (unbounded) if the property has not been set.
+   *
+   * @return the length (bound) of the string.
+   */
+  public int length()
+  {
+    return len;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/CORBA/typecodes/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html
+   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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.CORBA.typecodes</title></head>
+
+<body>
+ Contains GNU Classpath specific typecode definitions.   
+  
+ @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+</body>
+</html>
+

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/Configuration.java.in (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/Configuration.java.in Thu Nov  8 16:56:19 2007
@@ -0,0 +1,98 @@
+/* Configuration.java --
+   Copyright (C) 1998, 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 gnu.classpath;
+
+/**
+ * This file defines compile-time constants that can be accessed by
+ * java code. It is pre-processed by configure.  
+ */
+public interface Configuration
+{
+  /**
+   * The value of CLASSPATH_HOME is the location that the classpath
+   * libraries and support files where installed in. It is set according to
+   * the argument for --prefix given to configure and used to set the
+   * System property gnu.classpath.home.
+   */
+  String CLASSPATH_HOME = "@prefix@";
+
+  /**
+   * The release version number of GNU Classpath.
+   * It is set according to the value of 'version' in the configure[.in] file
+   * and used to set the System property gnu.classpath.version.
+   */
+  String CLASSPATH_VERSION = "@VERSION@";
+
+  /**
+   * The value of DEBUG is substituted according to whether the
+   * "--enable-debug" argument was passed to configure. Code
+   * which is made conditional based on the value of this flag - typically 
+   * code that generates debugging output - will be removed by the optimizer 
+   * in a non-debug build.
+   */
+  boolean DEBUG = @LIBDEBUG@;
+
+  /**
+   * The value of LOAD_LIBRARY is substituted according to whether the
+   * "--enable-load-library" or "--disable-load-library" argument was passed 
+   * to configure.  By default, configure should define this is as true.
+   * If set to false, loadLibrary() calls to load native function
+   * implementations, typically found in static initializers of classes
+   * which contain native functions, will be omitted.  This is useful for
+   * runtimes which pre-link their native function implementations and do
+   * not require additional shared libraries to be loaded.
+   */
+  boolean INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@;
+
+  /**
+   * Name of default AWT peer library.
+   */
+  String default_awt_peer_toolkit = "@default_toolkit@";
+
+  /**
+   * Whether to automatically run the init* methods in java.lang.System
+   * (the default) at class initialization time or whether to have the VM
+   * explicitly invoke them.
+   *
+   * The default is false, meaning the VM does not explicitly run the
+   * initializers. 
+   * 
+   */
+  boolean JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = 
+	  @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@;
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/NotImplementedException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/NotImplementedException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,61 @@
+/* NotImplementedException.java -- Marker for stub methods
+   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;
+
+/**
+ * This class is used as a marker to indicate that a given method
+ * is merely a stub, requiring implementation.  For historical
+ * reasons, GNU Classpath includes a number of stub methods.  We
+ * don't wish to remove them, but we do want to make them easily
+ * discoverable.  JAPI will notice methods declared as throwing
+ * this exception and mark them appropriately.
+ */
+public class NotImplementedException
+    extends RuntimeException
+{
+  private static final long serialVersionUID = 5112972057211125814L;
+
+  /**
+   * This class is not instantiable.  It should only be used
+   * in a method 'throws' clause -- not actually ever thrown.
+   */
+  private NotImplementedException()
+  {
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/Pointer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/Pointer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,47 @@
+/* Pointer.java -- Pointer to VM specific data
+   Copyright (C) 1999, 2000, 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. */
+
+/* This file is originally part of libgcj. */
+
+package gnu.classpath;
+
+/** A type used to indicate special data used by native code that should not 
+    be marked by the garbage collector. */
+
+public abstract class Pointer
+{
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/Pointer32.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/Pointer32.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,52 @@
+/* Pointer32.java -- 32 bit Pointer
+   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;
+
+/**
+ * A type used to indicate special data used by native code that should not 
+ * be marked by the garbage collector.
+ */
+public final class Pointer32 extends Pointer
+{
+   final int data;
+   
+   public Pointer32(int data)
+   {
+     this.data = data;
+   }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/Pointer64.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/Pointer64.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,52 @@
+/* Pointer64.java -- 64 bit Pointer
+   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;
+
+/**
+ * A type used to indicate special data used by native code that should not 
+ * be marked by the garbage collector.
+ */
+public final class Pointer64 extends Pointer
+{
+   final long data;
+   
+   public Pointer64(long data)
+   {
+     this.data = data;
+   }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/ServiceFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/ServiceFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,574 @@
+/* ServiceFactory.java -- Factory for plug-in services.
+   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.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+
+/**
+ * A factory for plug-ins that conform to a service provider
+ * interface. This is a general mechanism that gets used by a number
+ * of packages in the Java API. For instance, {@link
+ * java.nio.charset.spi.CharsetProvider} allows to write custom
+ * encoders and decoders for character sets, {@link
+ * javax.imageio.spi.ImageReaderSpi} allows to support custom image
+ * formats, and {@link javax.print.PrintService} makes it possible to
+ * write custom printer drivers.
+ *
+ * <p>The plug-ins are concrete implementations of the service
+ * provider interface, which is defined as an interface or an abstract
+ * class. The implementation classes must be public and have a public
+ * constructor that takes no arguments.
+ *
+ * <p>Plug-ins are usually deployed in JAR files. A JAR that provides
+ * an implementation of a service must declare this in a resource file
+ * whose name is the fully qualified service name and whose location
+ * is the directory <code>META-INF/services</code>. This UTF-8 encoded
+ * text file lists, on separate lines, the fully qualified names of
+ * the concrete implementations. Thus, one JAR file can provide an
+ * arbitrary number of implementations for an arbitrary count of
+ * service provider interfaces.
+ *
+ * <p><b>Example</b>
+ *
+ * <p>For example, a JAR might provide two implementations of the
+ * service provider interface <code>org.foo.ThinkService</code>,
+ * namely <code>com.acme.QuickThinker</code> and
+ * <code>com.acme.DeepThinker</code>. The code for <code>QuickThinker</code>
+ * woud look as follows:
+ *
+ * <pre>
+ * package com.acme;
+ *
+ * &#x2f;**
+ * * Provices a super-quick, but not very deep implementation of ThinkService.
+ * *&#x2f;
+ * public class QuickThinker
+ *   implements org.foo.ThinkService
+ * {
+ *   &#x2f;**
+ *   * Constructs a new QuickThinker. The service factory (which is
+ *   * part of the Java environment) calls this no-argument constructor
+ *   * when it looks up the available implementations of ThinkService.
+ *   *
+ *   * <p>Note that an application might query all available
+ *   * ThinkService providers, but use just one of them. Therefore,
+ *   * constructing an instance should be very inexpensive. For example,
+ *   * large data structures should only be allocated when the service
+ *   * actually gets used.
+ *   *&#x2f;
+ *   public QuickThinker()
+ *   {
+ *   }
+ *
+ *   &#x2f;**
+ *   * Returns the speed of this ThinkService in thoughts per second.
+ *   * Applications can choose among the available service providers
+ *   * based on this value.
+ *   *&#x2f;
+ *   public double getSpeed()
+ *   {
+ *     return 314159.2654;
+ *   }
+ *
+ *   &#x2f;**
+ *   * Produces a thought. While the returned thoughts are not very
+ *   * deep, they are generated in very short time.
+ *   *&#x2f;
+ *   public Thought think()
+ *   {
+ *     return null;
+ *   }
+ * }
+ * </pre>
+ *
+ * <p>The code for <code>com.acme.DeepThinker</code> is left as an
+ * exercise to the reader.
+ *
+ * <p>Acme&#x2019;s <code>ThinkService</code> plug-in gets deployed as
+ * a JAR file. Besides the bytecode and resources for
+ * <code>QuickThinker</code> and <code>DeepThinker</code>, it also
+ * contains the text file
+ * <code>META-INF/services/org.foo.ThinkService</code>:
+ *
+ * <pre>
+ * # Available implementations of org.foo.ThinkService
+ * com.acme.QuickThinker
+ * com.acme.DeepThinker
+ * </pre>
+ *
+ * <p><b>Thread Safety</b>
+ *
+ * <p>It is safe to use <code>ServiceFactory</code> from multiple
+ * concurrent threads without external synchronization.
+ *
+ * <p><b>Note for User Applications</b>
+ *
+ * <p>User applications that want to load plug-ins should not directly
+ * use <code>gnu.classpath.ServiceFactory</code>, because this class
+ * is only available in Java environments that are based on GNU
+ * Classpath. Instead, it is recommended that user applications call
+ * {@link
+ * javax.imageio.spi.ServiceRegistry#lookupProviders(Class)}. This API
+ * is actually independent of image I/O, and it is available on every
+ * environment.
+ *
+ * @author <a href="mailto:brawer at dandelis.ch">Sascha Brawer</a>
+ */
+public final class ServiceFactory
+{
+  /**
+   * A logger that gets informed when a service gets loaded, or
+   * when there is a problem with loading a service.
+   *
+   * <p>Because {@link java.util.logging.Logger#getLogger(String)}
+   * is thread-safe, we do not need to worry about synchronization
+   * here.
+   */
+  private static final Logger LOGGER = Logger.getLogger("gnu.classpath");
+
+
+  /**
+   * Declared private in order to prevent constructing instances of
+   * this utility class.
+   */
+  private ServiceFactory()
+  {
+  }
+
+
+  /**
+   * Finds service providers that are implementing the specified
+   * Service Provider Interface.
+   *
+   * <p><b>On-demand loading:</b> Loading and initializing service
+   * providers is delayed as much as possible. The rationale is that
+   * typical clients will iterate through the set of installed service
+   * providers until one is found that matches some criteria (like
+   * supported formats, or quality of service). In such scenarios, it
+   * might make sense to install only the frequently needed service
+   * providers on the local machine. More exotic providers can be put
+   * onto a server; the server will only be contacted when no suitable
+   * service could be found locally.
+   *
+   * <p><b>Security considerations:</b> Any loaded service providers
+   * are loaded through the specified ClassLoader, or the system
+   * ClassLoader if <code>classLoader</code> is
+   * <code>null</code>. When <code>lookupProviders</code> is called,
+   * the current {@link AccessControlContext} gets recorded. This
+   * captured security context will determine the permissions when
+   * services get loaded via the <code>next()</code> method of the
+   * returned <code>Iterator</code>.
+   *
+   * @param spi the service provider interface which must be
+   * implemented by any loaded service providers.
+   *
+   * @param loader the class loader that will be used to load the
+   * service providers, or <code>null</code> for the system class
+   * loader. For using the context class loader, see {@link
+   * #lookupProviders(Class)}.
+   *
+   * @return an iterator over instances of <code>spi</code>.
+   *
+   * @throws IllegalArgumentException if <code>spi</code> is
+   * <code>null</code>.
+   */
+  public static Iterator lookupProviders(Class spi,
+                                         ClassLoader loader)
+  {
+    String resourceName;
+    Enumeration urls;
+
+    if (spi == null)
+      throw new IllegalArgumentException();
+
+    if (loader == null)
+      loader = ClassLoader.getSystemClassLoader();
+
+    resourceName = "META-INF/services/" + spi.getName();
+    try
+      {
+        urls = loader.getResources(resourceName);
+      }
+    catch (IOException ioex)
+      {
+        /* If an I/O error occurs here, we cannot provide any service
+         * providers. In this case, we simply return an iterator that
+         * does not return anything (no providers installed).
+         */
+        log(Level.WARNING, "cannot access {0}", resourceName, ioex);
+        return Collections.EMPTY_LIST.iterator();
+      }
+
+    return new ServiceIterator(spi, urls, loader,
+                               AccessController.getContext());
+  }
+
+
+  /**
+   * Finds service providers that are implementing the specified
+   * Service Provider Interface, using the context class loader
+   * for loading providers.
+   *
+   * @param spi the service provider interface which must be
+   * implemented by any loaded service providers.
+   *
+   * @return an iterator over instances of <code>spi</code>.
+   *
+   * @throws IllegalArgumentException if <code>spi</code> is
+   * <code>null</code>.
+   *
+   * @see #lookupProviders(Class, ClassLoader)
+   */
+  public static Iterator lookupProviders(Class spi)
+  {
+    ClassLoader ctxLoader;
+
+    ctxLoader = Thread.currentThread().getContextClassLoader();
+    return lookupProviders(spi, ctxLoader);
+  }
+
+
+  /**
+   * An iterator over service providers that are listed in service
+   * provider configuration files, which get passed as an Enumeration
+   * of URLs. This is a helper class for {@link
+   * ServiceFactory#lookupProviders(Class, ClassLoader)}.
+   *
+   * @author <a href="mailto:brawer at dandelis.ch">Sascha Brawer</a>
+   */
+  private static final class ServiceIterator
+    implements Iterator
+  {
+    /**
+     * The service provider interface (usually an interface, sometimes
+     * an abstract class) which the services must implement.
+     */
+    private final Class spi;
+
+
+    /**
+     * An Enumeration<URL> over the URLs that contain a resource
+     * <code>META-INF/services/<org.foo.SomeService></code>,
+     * as returned by {@link ClassLoader#getResources(String)}.
+     */
+    private final Enumeration urls;
+
+
+    /**
+     * The class loader used for loading service providers.
+     */
+    private final ClassLoader loader;
+
+
+    /**
+     * The security context used when loading and initializing service
+     * providers. We want to load and initialize all plug-in service
+     * providers under the same security context, namely the one that
+     * was active when {@link #lookupProviders(Class, ClassLoader)} has
+     * been called.
+     */
+    private final AccessControlContext securityContext;
+
+
+    /**
+     * A reader for the current file listing class names of service
+     * implementors, or <code>null</code> when the last reader has
+     * been fetched.
+     */
+    private BufferedReader reader;
+    
+
+    /**
+     * The URL currently being processed. This is only used for
+     * emitting error messages.
+     */
+    private URL currentURL;
+
+
+    /**
+     * The service provider that will be returned by the next call to
+     * {@link #next()}, or <code>null</code> if the iterator has
+     * already returned all service providers.
+     */
+    private Object nextProvider;
+
+
+    /**
+     * Constructs an Iterator that loads and initializes services on
+     * demand.
+     *
+     * @param spi the service provider interface which the services
+     * must implement. Usually, this is a Java interface type, but it
+     * might also be an abstract class or even a concrete superclass.
+     *
+     * @param urls an Enumeration<URL> over the URLs that contain a
+     * resource
+     * <code>META-INF/services/<org.foo.SomeService></code>, as
+     * determined by {@link ClassLoader#getResources(String)}.
+     *
+     * @param loader the ClassLoader that gets used for loading
+     * service providers.
+     *
+     * @param securityContext the security context to use when loading
+     * and initializing service providers.
+     */
+    ServiceIterator(Class spi, Enumeration urls, ClassLoader loader,
+                    AccessControlContext securityContext)
+    {
+      this.spi = spi;
+      this.urls = urls;
+      this.loader = loader;
+      this.securityContext = securityContext;
+      this.nextProvider = loadNextServiceProvider();
+    }
+
+
+    /**
+     * @throws NoSuchElementException if {@link #hasNext} returns
+     * <code>false</code>.
+     */
+    public Object next()
+    {
+      Object result;
+
+      if (!hasNext())
+        throw new NoSuchElementException();
+
+      result = nextProvider;
+      nextProvider = loadNextServiceProvider();
+      return result;
+    }
+
+
+    public boolean hasNext()
+    {
+      return nextProvider != null;
+    }
+
+
+    public void remove()
+    {
+      throw new UnsupportedOperationException();
+    }
+
+
+    private Object loadNextServiceProvider()
+    {
+      String line;
+      
+      if (reader == null)
+        advanceReader();
+
+      for (;;)
+        {
+          /* If we have reached the last provider list, we cannot
+           * retrieve any further lines.
+           */
+          if (reader == null)
+            return null;
+
+          try
+            {
+              line = reader.readLine();
+            }
+          catch (IOException readProblem)
+            {
+              log(Level.WARNING, "IOException upon reading {0}", currentURL,
+                  readProblem);
+              line = null;
+            }
+
+          /* When we are at the end of one list of services,
+           * switch over to the next one.
+           */
+          if (line == null)
+            {
+              advanceReader();
+              continue;
+            }
+
+
+          // Skip whitespace at the beginning and end of each line.
+          line = line.trim();
+
+          // Skip empty lines.
+          if (line.length() == 0)
+            continue;
+
+          // Skip comment lines.
+          if (line.charAt(0) == '#')
+            continue;
+
+          try
+            {
+              log(Level.FINE,
+                  "Loading service provider \"{0}\", specified"
+                  + " by \"META-INF/services/{1}\" in {2}.",
+                  new Object[] { line, spi.getName(), currentURL },
+                  null);
+
+              /* Load the class in the security context that was
+               * active when calling lookupProviders.
+               */
+              return AccessController.doPrivileged(
+                new ServiceProviderLoadingAction(spi, line, loader),
+                securityContext);
+            }
+          catch (Exception ex)
+            {
+              String msg = "Cannot load service provider class \"{0}\","
+                + " specified by \"META-INF/services/{1}\" in {2}";
+              if (ex instanceof PrivilegedActionException
+                  && ex.getCause() instanceof ClassCastException)
+                msg = "Service provider class \"{0}\" is not an instance"
+                  + " of \"{1}\". Specified"
+                  + " by \"META-INF/services/{1}\" in {2}.";
+
+              log(Level.WARNING, msg,                  
+                  new Object[] { line, spi.getName(), currentURL },
+                  ex);
+              continue;
+            }
+        }
+    }
+
+
+    private void advanceReader()
+    {
+      do
+        {
+          if (reader != null)
+            {
+              try
+                {
+                  reader.close();
+                  log(Level.FINE, "closed {0}", currentURL, null);
+                }
+              catch (Exception ex)
+                {
+                  log(Level.WARNING, "cannot close {0}", currentURL, ex);
+                }
+              reader = null;
+              currentURL = null;
+            }
+
+        if (!urls.hasMoreElements())
+          return;
+
+        currentURL = (URL) urls.nextElement();
+        try
+          {
+            reader = new BufferedReader(new InputStreamReader(
+              currentURL.openStream(), "UTF-8"));
+            log(Level.FINE, "opened {0}", currentURL, null);
+          }
+        catch (Exception ex)
+          {
+            log(Level.WARNING, "cannot open {0}", currentURL, ex);
+          }
+        }
+      while (reader == null);
+    }
+  }
+
+
+  // Package-private to avoid a trampoline.
+  /**
+   * Passes a log message to the <code>java.util.logging</code>
+   * framework. This call returns very quickly if no log message will
+   * be produced, so there is not much overhead in the standard case.
+   *
+   * @param level the severity of the message, for instance {@link
+   * Level#WARNING}.
+   *
+   * @param msg the log message, for instance <code>&#x201c;Could not
+   * load {0}.&#x201d;</code>
+   *
+   * @param param the parameter(s) for the log message, or
+   * <code>null</code> if <code>msg</code> does not specify any
+   * parameters. If <code>param</code> is not an array, an array with
+   * <code>param</code> as its single element gets passed to the
+   * logging framework.
+   *
+   * @param t a Throwable that is associated with the log record, or
+   * <code>null</code> if the log message is not associated with a
+   * Throwable.
+   */
+  static void log(Level level, String msg, Object param, Throwable t)
+  {
+    LogRecord rec;
+
+    // Return quickly if no log message will be produced.
+    if (!LOGGER.isLoggable(level))
+      return;
+
+    rec = new LogRecord(level, msg);
+    if (param != null && param.getClass().isArray())
+      rec.setParameters((Object[]) param);
+    else
+      rec.setParameters(new Object[] { param });
+
+    rec.setThrown(t);
+
+    // While java.util.logging can sometimes infer the class and
+    // method of the caller, this automatic inference is not reliable
+    // on highly optimizing VMs. Also, log messages make more sense to
+    // developers when they display a public method in a public class;
+    // otherwise, they might feel tempted to figure out the internals
+    // of ServiceFactory in order to understand the problem.
+    rec.setSourceClassName(ServiceFactory.class.getName());
+    rec.setSourceMethodName("lookupProviders");
+
+    LOGGER.log(rec);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/ServiceProviderLoadingAction.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/ServiceProviderLoadingAction.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,149 @@
+/* ServiceProviderLoadingAction.java -- Action for loading plug-in services.
+   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.security.PrivilegedExceptionAction;
+
+/**
+ * A privileged action for creating a new instance of a service
+ * provider.
+ *
+ * <p>Class loading and instantiation is encapsulated in a
+ * <code>PriviledgedAction</code> in order to restrict the loaded
+ * service providers to the {@link java.security.AccessControlContext}
+ * that was active when {@link
+ * gnu.classpath.ServiceFactory#lookupProviders(Class, ClassLoader)} was
+ * called, even though the actual loading is delayed to the time when the
+ * provider is actually needed.
+ *
+ * @author <a href="mailto:brawer at dandelis.ch">Sascha Brawer</a>
+ */
+final class ServiceProviderLoadingAction
+  implements PrivilegedExceptionAction
+{
+  /**
+   * The interface to which the loaded service provider implementation
+   * must conform.  Usually, this is a Java interface type, but it
+   * might also be an abstract class or even a concrete class.
+   */
+  private final Class spi;
+
+
+  /**
+   * The fully qualified name of the class that gets loaded when
+   * this action is executed.
+   */
+  private final String providerName;
+
+
+  /**
+   * The ClassLoader that gets used for loading the service provider
+   * class.
+   */
+  private final ClassLoader loader;
+
+
+  /**
+   * Constructs a privileged action for loading a service provider.
+   *
+   * @param spi the interface to which the loaded service provider
+   * implementation must conform. Usually, this is a Java interface
+   * type, but it might also be an abstract class or even a concrete
+   * superclass.
+   *
+   * @param providerName the fully qualified name of the class that
+   * gets loaded when this action is executed.
+   *
+   * @param loader the ClassLoader that gets used for loading the
+   * service provider class.
+   *
+   * @throws IllegalArgumentException if <code>spi</code>,
+   * <code>providerName</code> or <code>loader</code> is
+   * <code>null</code>.
+   */
+  ServiceProviderLoadingAction(Class spi, String providerName,
+                               ClassLoader loader)
+  {
+    if (spi == null || providerName == null || loader == null)
+      throw new IllegalArgumentException();
+
+    this.spi = spi;
+    this.providerName = providerName;
+    this.loader = loader;
+  }
+
+  
+  /**
+   * Loads an implementation class for a service provider, and creates
+   * a new instance of the loaded class by invoking its public
+   * no-argument constructor.
+   *
+   * @return a new instance of the class whose name was passed as
+   * <code>providerName</code> to the constructor.
+   *
+   * @throws ClassCastException if the service provider does not
+   * implement the <code>spi</code> interface that was passed to the
+   * constructor.
+   *
+   * @throws IllegalAccessException if the service provider class or
+   * its no-argument constructor are not <code>public</code>.
+   *
+   * @throws InstantiationException if the service provider class is
+   * <code>abstract</code>, an interface, a primitive type, an array
+   * class, or void; or if service provider class does not have a
+   * no-argument constructor; or if there some other problem with
+   * creating a new instance of the service provider.
+   */
+  public Object run()
+    throws Exception
+  {
+    Class loadedClass;
+    Object serviceProvider;
+
+    loadedClass = loader.loadClass(providerName);
+    serviceProvider = loadedClass.newInstance();
+
+    // Ensure that the loaded provider is actually implementing
+    // the service provider interface.
+    if (!spi.isInstance(serviceProvider))
+      throw new ClassCastException(spi.getName());
+
+    return serviceProvider;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/SystemProperties.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/SystemProperties.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,172 @@
+/* SystemProperties.java -- Manage the System properties.
+   Copyright (C) 2004, 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;
+
+import java.util.Properties;
+
+/**
+ * The class manages the System properties. This class is only available to
+ * privileged code (i.e. code loaded by the bootstrap class loader) and
+ * therefore doesn't do any security checks.
+ * This class is separated out from java.lang.System to simplify bootstrap
+ * dependencies and to allow trusted code a simple and efficient mechanism
+ * to access the system properties.
+ */
+public class SystemProperties
+{
+  /**
+   * Stores the current system properties. This can be modified by
+   * {@link #setProperties(Properties)}, but will never be null, because
+   * setProperties(null) sucks in the default properties.
+   */
+  private static Properties properties;
+
+  /**
+   * The default properties. Once the default is stabilized,
+   * it should not be modified;
+   * instead it is cloned when calling <code>setProperties(null)</code>.
+   */
+  private static final Properties defaultProperties = new Properties();
+
+  static
+  {
+    VMSystemProperties.preInit(defaultProperties);
+
+    defaultProperties.put("gnu.classpath.home", Configuration.CLASSPATH_HOME);
+    defaultProperties.put("gnu.classpath.version",
+                          Configuration.CLASSPATH_VERSION);
+
+    // Set base URL if not already set.
+    if (defaultProperties.get("gnu.classpath.home.url") == null)
+      defaultProperties.put("gnu.classpath.home.url",
+			    "file://"
+			    + Configuration.CLASSPATH_HOME
+	                    + "/lib");
+
+    // Set short name if not already set.
+    if (defaultProperties.get("gnu.classpath.vm.shortname") == null)
+      {
+	String value = defaultProperties.getProperty("java.vm.name");
+	int index = value.lastIndexOf(' ');
+	if (index != -1)
+	  value = value.substring(index + 1);
+	defaultProperties.put("gnu.classpath.vm.shortname", value);
+      }
+
+    // Network properties
+    if (defaultProperties.get("http.agent") == null)
+      {
+	String userAgent = ("gnu-classpath/"
+	                    + defaultProperties.getProperty("gnu.classpath.version")
+	                    + " ("
+	                    + defaultProperties.getProperty("gnu.classpath.vm.shortname")
+	                    + "/"
+	                    + defaultProperties.getProperty("java.vm.version")
+	                    + ")");
+	 defaultProperties.put("http.agent", userAgent);
+      }
+
+    // 8859_1 is a safe default encoding to use when not explicitly set
+    if (defaultProperties.get("file.encoding") == null)
+      defaultProperties.put("file.encoding", "8859_1");
+
+    // XXX FIXME - Temp hack for old systems that set the wrong property
+    if (defaultProperties.get("java.io.tmpdir") == null)
+      defaultProperties.put("java.io.tmpdir",
+                            defaultProperties.get("java.tmpdir"));
+
+    // FIXME: we need a better way to handle this.
+    // For instance, having a single VM class for each OS might help.
+    if (defaultProperties.get("gnu.classpath.mime.types.file") == null
+        && "Linux".equals(defaultProperties.get("os.name")))
+      defaultProperties.put("gnu.classpath.mime.types.file",
+                            "/etc/mime.types");
+
+    VMSystemProperties.postInit(defaultProperties);
+
+    // Note that we use clone here and not new.  Some programs assume
+    // that the system properties do not have a parent.
+    properties = (Properties) defaultProperties.clone();
+  }
+
+  public static String getProperty(String name)
+  {
+    return properties.getProperty(name);
+  }
+
+  public static String getProperty(String name, String defaultValue)
+  {
+    return properties.getProperty(name, defaultValue);
+  }
+
+  public static String setProperty(String name, String value)
+  {
+    return (String) properties.setProperty(name, value);
+  }
+
+  public static Properties getProperties()
+  {
+    return properties;
+  }
+
+  public static void setProperties(Properties properties)
+  {
+    if (properties == null)
+      {
+        // Note that we use clone here and not new.  Some programs
+        // assume that the system properties do not have a parent.
+        properties = (Properties)defaultProperties.clone();
+      }
+
+    SystemProperties.properties = properties;
+  }
+
+  /**
+   * Removes the supplied system property and its current value.
+   * If the specified property does not exist, nothing happens.
+   * 
+   * @throws NullPointerException if the property name is null.
+   * @return the value of the removed property, or null if no
+   *         such property exists.
+   */
+  public static String remove(String name)
+  {
+    return (String) properties.remove(name);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/Component.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/Component.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,170 @@
+/* Component.java -- a component log level.
+   Copyright (C) 2005, 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 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.debug;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.logging.Level;
+
+public final class Component extends Level
+{
+
+  /*
+   * HOW TO ADD NEW COMPONENTS:
+   *
+   * If you want to add a new, simple component, that you will use in
+   * logging statements, simply create a new class variable that
+   * instantiates this class, and choose an appropriate string name
+   * and a integer constant not used by any other component level.
+   *
+   * For example, if my component had to do with 'frobbing', I would
+   * add this entry below:
+   *
+   *   private static final Component FROBBING = new Component ("FROBBING", 7);
+   *
+   * Then, I would update the component 'EVERYTHING' to have and end
+   * index ONE GREATER THAN the index of the new component.
+   *
+   * ADDING NEW COMPONENT CLASSES:
+   *
+   * A "component class" is a run of more than one component, which can
+   * be enabled all at once. EVERYTHING and SSL are examples of component
+   * classes. To add a new class, create a new component with a start index
+   * equal to the index of the first member component, and with an end
+   * index equal to the index of the last member component plus one.
+   */
+
+  /**
+   * Signifies that everything should be logged. This should be used to
+   * enable or disable levels only; logging code should not use it.
+   */
+  public static final Component EVERYTHING = new Component ("*", 0, 11);
+
+  /**
+   * Signifies that all SSL related messages should be logged. This should
+   * be used to enable or disable levels only; logging code should not use
+   * it.
+   */
+  public static final Component SSL = new Component ("SSL", 0, 5);
+
+  /**
+   * Traces the progression of an SSL handshake.
+   */
+  public static final Component SSL_HANDSHAKE = new Component ("SSL HANDSHAKE", 0);
+
+  /**
+   * Traces record layer messages during SSL communications.
+   */
+  public static final Component SSL_RECORD_LAYER = new Component ("SSL RECORD LAYER", 1);
+
+  /**
+   * Trace details about the SSL key exchange.
+   */
+  public static final Component SSL_KEY_EXCHANGE = new Component ("SSL KEY EXCHANGE", 2);
+
+  /* Indices 3 and 4 reserved for future use by SSL components. */
+
+  /**
+   * Trace the operation of cryptographic primitives.
+   */
+  public static final Component CRYPTO = new Component ("CRYPTO", 5);
+
+  /**
+   * Trace the parsing of X.509 certificates and related objects.
+   */
+  public static final Component X509 = new Component ("X.509", 6);
+
+  /**
+   * Trace access control policies, including the parsing of
+   * java.policy files.
+   */
+  public static final Component POLICY = new Component ("POLICY", 7);
+  
+  /**
+   * Trace ipp implementation.
+   */
+  public static final Component IPP = new Component ("IPP", 10);
+
+  private final int startIndex;
+  private final int endIndex;
+
+  private Component (final String name, final int bitIndex)
+  {
+    this (name, bitIndex, bitIndex + 1);
+  }
+
+  private Component (final String name, final int startIndex, final int endIndex)
+  {
+    super (name, Level.FINE.intValue ());
+    this.startIndex = startIndex;
+    this.endIndex = endIndex;
+  }
+
+  /**
+   * Return the component for the given name.
+   *
+   * @param name The name of the component to get.
+   * @return The named component, or null if there is no such component.
+   */
+  public static Component forName (final String name)
+  {
+    try
+      {
+	Field f = Component.class.getField (name.toUpperCase ());
+	if (!Modifier.isStatic (f.getModifiers ())
+	    || Component.class.isAssignableFrom (f.getClass ()))
+	  return null;
+	return (Component) f.get (null);
+      }
+    catch (Throwable _)
+      {
+	return null;
+      }
+  }
+
+  public int startIndex ()
+  {
+    return startIndex;
+  }
+
+  public int endIndex ()
+  {
+    return endIndex;
+  }
+}
\ No newline at end of file

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/PreciseFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/PreciseFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,105 @@
+/* PreciseFilter.java -- filter log messages by precise level.
+   Copyright (C) 2005  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 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.debug;
+
+import java.util.BitSet;
+import java.util.logging.Filter;
+import java.util.logging.LogRecord;
+
+public final class PreciseFilter implements Filter
+{
+
+  /**
+   * The singleton filter instance.
+   */
+  public static final PreciseFilter GLOBAL = new PreciseFilter ();
+
+  private final BitSet enabled;
+
+  private PreciseFilter ()
+  {
+    enabled = new BitSet ();
+  }
+
+  /**
+   * Disable logging of a component.
+   *
+   * @param component The component to disable logging for.
+   * @throws NullPointerException If component is null.
+   */
+  public void disable (final Component component)
+  {
+    enabled.clear (component.startIndex (), component.endIndex ());
+  }
+
+  /**
+   * Enable logging of a component.
+   *
+   * @param component The component to enable logging for.
+   * @throws NullPointerException If component is null.
+   */
+  public void enable (final Component component)
+  {
+    enabled.set (component.startIndex (), component.endIndex ());
+  }
+
+  /**
+   * Tell if a component is enabled for logging.
+   *
+   * @param component The component to test.
+   * @return True iff the specified component is enabled for logging.
+   * @throws NullPointerException If component is null.
+   */
+  public boolean isEnabled (final Component component)
+  {
+    return (enabled.get (component.startIndex ()));
+  }
+
+  public boolean isLoggable (final LogRecord record)
+  {
+    try
+      {
+	return isEnabled ((Component) record.getLevel ());
+      }
+    catch (ClassCastException cce)
+      {
+	return true;
+      }
+  }
+}
\ No newline at end of file

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/Simple1LineFormatter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/Simple1LineFormatter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,161 @@
+/* Simple1LineFormatter.java -- A simple 1-line logging formatter
+   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.debug;
+
+import gnu.java.security.action.GetPropertyAction;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.security.AccessController;
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.logging.Formatter;
+import java.util.logging.LogRecord;
+
+/**
+ * A simple 1-line formatter to use instead of the 2-line SimpleFormatter used
+ * by default in the JDK logging handlers.
+ * <p>
+ * The fixed format of this formatter is as follows:
+ * <p>
+ * <ol>
+ *   <li>Date: As a yyyy-MM-dd string.</li>
+ *   <li>Time: As a HH:mm:ss.SSSS Z string.</li>
+ *   <li>Thread identifier, right-justified, and framed in an 11-digit field.</li>
+ *   <li>Class name, without its package name, left-justified, and framed in a
+ *   32-character field.</li>
+ *   <li>Method name, left-justified, and framed in a 32-character field.</li>
+ *   <li>Level name, left-justified, and framed in a 6-character field.</li>
+ *   <li>User message and arguments.</li>
+ *   <li>Platform-dependent line-separator.</li>
+ *   <li>Optionally, if the log-record contains a thrown exception, that
+ *   exception's stack trace is appended to the output.</li>
+ * </ol>
+ * <p>
+ * Here is an example of the output generated by this formatter:
+ * <p>
+ * <pre>
+ * 2006-02-27 21:59:12.0881 +1100 -1343151280 EncodedKeyFactory                engineGeneratePublic()           FINER - ENTRY java.security.spec.X509EncodedKeySpec at b00d7fc0
+ * 2006-02-27 21:59:12.0887 +1100 -1343151280 EncodedKeyFactory                engineGeneratePublic()           FINE  - Exception in DSSPublicKey.valueOf(). Ignore
+ * java.security.InvalidParameterException: Unexpected OID: 1.2.840.113549.1.1.1
+ *    at gnu.java.security.key.dss.DSSKeyPairX509Codec.decodePublicKey (DSSKeyPairX509Codec.java:205)
+ *    at gnu.java.security.key.dss.DSSPublicKey.valueOf (DSSPublicKey.java:136)
+ *    at gnu.java.security.jce.sig.EncodedKeyFactory.engineGeneratePublic (EncodedKeyFactory.java:218)
+ *    at java.security.KeyFactory.generatePublic (KeyFactory.java:219)
+ *    at gnu.java.security.x509.X509Certificate.parse (X509Certificate.java:657)
+ *    at gnu.java.security.x509.X509Certificate.<init> (X509Certificate.java:163)
+ *    ...
+ * 2006-02-27 21:59:12.0895 +1100 -1343151280 RSAKeyPairX509Codec              decodePublicKey()                FINER - ENTRY [B at b00d7fd0
+ * 2006-02-27 21:59:12.0897 +1100 -1343151280 RSAKeyPairX509Codec              decodePublicKey()                FINER - RETURN gnu.java.security.key.rsa.GnuRSAPublicKey at b00fb940
+ * </pre>
+ */
+public class Simple1LineFormatter
+    extends Formatter
+{
+  private static final String DAT_PATTERN = "yyyy-MM-dd HH:mm:ss.SSSS Z ";
+  private static final String THREAD_PATTERN = " #########0;-#########0";
+  private static final String SPACES_32 = "                                ";
+  private static final String SPACES_6 = "      ";
+  private static final String LS = (String) AccessController.doPrivileged
+    (new GetPropertyAction("line.separator"));
+  private DateFormat dateFormat;
+  private NumberFormat threadFormat;
+
+  // default 0-arguments constructor
+
+  public String format(LogRecord record)
+  {
+    if (dateFormat == null)
+      dateFormat = new SimpleDateFormat(DAT_PATTERN);
+
+    if (threadFormat == null)
+      threadFormat = new DecimalFormat(THREAD_PATTERN);
+
+    StringBuilder sb = new StringBuilder(180)
+        .append(dateFormat.format(new Date(record.getMillis())))
+        .append(threadFormat.format(record.getThreadID()))
+        .append(" ");
+    String s = record.getSourceClassName();
+    if (s == null)
+      sb.append(SPACES_32);
+    else
+      {
+        s = s.trim();
+        int i = s.lastIndexOf(".");
+        if (i != - 1)
+          s = s.substring(i + 1);
+
+        s = (s + SPACES_32).substring(0, 32);
+      }
+
+    sb.append(s).append(" ");
+    s = record.getSourceMethodName();
+    if (s == null)
+      sb.append(SPACES_32);
+    else
+      {
+        s = s.trim();
+        if (s.endsWith("()"))
+          s = (s.trim() + SPACES_32).substring(0, 32);
+        else
+          s = (s.trim() + "()" + SPACES_32).substring(0, 32);
+      }
+
+    sb.append(s).append(" ");
+    s = String.valueOf(record.getLevel());
+    if (s == null)
+      sb.append(SPACES_6);
+    else
+      s = (s.trim() + SPACES_6).substring(0, 6);
+
+    sb.append(s).append(" - ").append(formatMessage(record)).append(LS);
+    Throwable cause = record.getThrown();
+    if (cause != null)
+      {
+        StringWriter sw = new StringWriter();
+        cause.printStackTrace(new PrintWriter(sw, true));
+        sb.append(sw.toString());
+      }
+
+    return sb.toString();
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/SystemLogger.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/SystemLogger.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* SystemLogger.java -- Classpath's system debugging logger.
+   Copyright (C) 2005  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 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.debug;
+
+import gnu.java.security.action.GetPropertyAction;
+
+import java.security.AccessController;
+import java.util.StringTokenizer;
+import java.util.logging.Logger;
+
+public final class SystemLogger
+{
+  public static final Logger SYSTEM = Logger.getLogger ("gnu.classpath");
+
+  static
+  {
+    SYSTEM.setFilter (PreciseFilter.GLOBAL);
+    String defaults = (String) AccessController.doPrivileged
+      (new GetPropertyAction("gnu.classpath.debug.components"));
+
+    if (defaults != null)
+      {
+        StringTokenizer tok = new StringTokenizer (defaults, ",");
+        while (tok.hasMoreTokens ())
+          {
+            Component c = Component.forName (tok.nextToken ());
+            if (c != null)
+              PreciseFilter.GLOBAL.enable (c);
+            SYSTEM.log (java.util.logging.Level.INFO, "enabled: {0}", c);
+          }
+      }
+
+    java.util.logging.Handler[] h = SYSTEM.getHandlers ();
+    for (int i = 0; i < h.length; i++)
+        System.out.println (h[i]);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/TeeInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/TeeInputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,98 @@
+/* TeeInputStream.java
+   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 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.debug;
+
+import java.io.*;
+
+/**
+ * An input stream that copies all its input to a byte sink.
+ *
+ * @author Chris Burdess
+ */
+public class TeeInputStream
+  extends InputStream
+{
+
+  private final InputStream in;
+  private final OutputStream out;
+
+  /**
+   * Constructs a tee input stream.
+   * @param in the underlying input stream
+   * @param out the output sink
+   */
+  public TeeInputStream(InputStream in, OutputStream out)
+  {
+    this.in = in;
+    this.out = out;
+  }
+
+  public int read()
+    throws IOException
+  {
+    int ret = in.read();
+    out.write(ret);
+    out.flush();
+    return ret;
+  }
+
+  public int read(byte[] b, int off, int len)
+    throws IOException
+  {
+    int ret = in.read(b, off, len);
+    if (ret != -1)
+      {
+        out.write(b, off, ret);
+        out.flush();
+      }
+    return ret;
+  }
+
+  public void close()
+    throws IOException
+  {
+    in.close();
+    out.close();
+  }
+
+  public final boolean markSupported()
+  {
+    return false;
+  }
+  
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/TeeOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/TeeOutputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,93 @@
+/* TeeOutputStream.java
+   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 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.debug;
+
+import java.io.*;
+
+/**
+ * An output stream that copies all its output to an additional byte sink.
+ *
+ * @author Chris Burdess
+ */
+public class TeeOutputStream
+  extends OutputStream
+{
+
+  private final OutputStream out;
+  private final OutputStream sink;
+
+  /**
+   * Constructs a tee output stream.
+   * @param out the underlying output stream
+   * @param sink the output sink
+   */
+  public TeeOutputStream(OutputStream out, OutputStream sink)
+  {
+    this.out = out;
+    this.sink = sink;
+  }
+
+  public void write(int c)
+    throws IOException
+  {
+    out.write(c);
+    sink.write(c);
+  }
+
+  public void write(byte[] b, int off, int len)
+    throws IOException
+  {
+    out.write(b, off, len);
+    sink.write(b, off, len);
+  }
+
+  public void flush()
+    throws IOException
+  {
+    out.flush();
+    sink.flush();
+  }
+
+  public void close()
+    throws IOException
+  {
+    out.close();
+    sink.close();
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/TeeReader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/TeeReader.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,98 @@
+/* TeeReader.java
+   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 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.debug;
+
+import java.io.*;
+
+/**
+ * A reader that copies all characters read to an output sink.
+ *
+ * @author Chris Burdess
+ */
+public class TeeReader
+  extends Reader
+{
+
+  private final Reader in;
+  private final Writer out;
+
+  /**
+   * Constructs a tee reader.
+   * @param in the input
+   * @param out the output sink
+   */
+  public TeeReader(Reader in, Writer out)
+  {
+    this.in = in;
+    this.out = out;
+  }
+
+  public int read()
+    throws IOException
+  {
+    int ret = in.read();
+    out.write(ret);
+    out.flush();
+    return ret;
+  }
+
+  public int read(char[] b, int off, int len)
+    throws IOException
+  {
+    int ret = in.read(b, off, len);
+    if (ret != -1)
+      {
+        out.write(b, off, ret);
+        out.flush();
+      }
+    return ret;
+  }
+
+  public void close()
+    throws IOException
+  {
+    in.close();
+    out.close();
+  }
+
+  public final boolean markSupported()
+  {
+    return false;
+  }
+  
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/TeeWriter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/debug/TeeWriter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,93 @@
+/* TeeWriter.java
+   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 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.debug;
+
+import java.io.*;
+
+/**
+ * A writer that copies all its output to an additional character sink.
+ *
+ * @author Chris Burdess
+ */
+public class TeeWriter
+  extends Writer
+{
+
+  private final Writer out;
+  private final Writer sink;
+
+  /**
+   * Constructs a tee writer.
+   * @param out the underlying writer
+   * @param sink the output sink
+   */
+  public TeeWriter(Writer out, Writer sink)
+  {
+    this.out = out;
+    this.sink = sink;
+  }
+
+  public void write(int c)
+    throws IOException
+  {
+    out.write(c);
+    sink.write(c);
+  }
+
+  public void write(char[] b, int off, int len)
+    throws IOException
+  {
+    out.write(b, off, len);
+    sink.write(b, off, len);
+  }
+
+  public void flush()
+    throws IOException
+  {
+    out.flush();
+    sink.flush();
+  }
+
+  public void close()
+    throws IOException
+  {
+    out.close();
+    sink.close();
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/Jdwp.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/Jdwp.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,344 @@
+/* Jdwp.java -- Virtual machine to JDWP back-end programming interface
+   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.Event;
+import gnu.classpath.jdwp.event.EventManager;
+import gnu.classpath.jdwp.event.EventRequest;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.processor.PacketProcessor;
+import gnu.classpath.jdwp.transport.ITransport;
+import gnu.classpath.jdwp.transport.JdwpConnection;
+import gnu.classpath.jdwp.transport.TransportException;
+import gnu.classpath.jdwp.transport.TransportFactory;
+
+import java.io.IOException;
+import java.security.AccessController;
+import java.util.HashMap;
+
+/**
+ * Main interface from the virtual machine to the JDWP back-end.
+ *
+ * The thread created by this class is only used for initialization.
+ * Once it exits, the JDWP backend is fully initialized.
+ *
+ * @author Keith Seitz (keiths at redhat.com)
+ */
+public class Jdwp
+  extends Thread
+{
+  // The single instance of the back-end
+  private static Jdwp _instance = null;
+
+  /**
+   * Are we debugging? Only true if debugging
+   * *and* initialized.
+   */
+  public static boolean isDebugging = false;
+
+  // Packet processor
+  private PacketProcessor _packetProcessor;
+  private Thread _ppThread;
+
+  // JDWP configuration properties
+  private HashMap _properties;
+
+  // The suspend property of the configure string
+  // (-Xrunjdwp:..suspend=<boolean>)
+  private static final String _PROPERTY_SUSPEND = "suspend";
+
+  // Connection to debugger
+  private JdwpConnection _connection;
+
+  // Are we shutting down the current session?
+  private boolean _shutdown;
+
+  // A thread group for the JDWP threads
+  private ThreadGroup _group;
+
+  // Initialization synchronization
+  private Object _initLock = new Object ();
+  private int _initCount = 0;
+
+  /**
+   * constructor
+   */
+  public Jdwp ()
+  {
+    _shutdown = false;
+    _instance = this;
+  }
+
+  /**
+   * Returns the JDWP back-end, creating an instance of it
+   * if one does not already exist.
+   */
+  public static Jdwp getDefault ()
+  {
+    return _instance;
+  }
+
+  /**
+   * Get the thread group used by JDWP threads
+   * 
+   * @return the thread group
+   */
+  public ThreadGroup getJdwpThreadGroup()
+  {
+    return _group;
+  }
+  
+  /**
+   * Should the virtual machine suspend on startup?
+   */
+  public static boolean suspendOnStartup ()
+  {
+    Jdwp jdwp = getDefault ();
+    if (jdwp != null)
+      {
+	String suspend = (String) jdwp._properties.get (_PROPERTY_SUSPEND);
+	if (suspend != null && suspend.equals ("y"))
+	  return true;
+      }
+
+    return false;
+  }
+
+  /**
+   * Configures the back-end
+   *
+   * @param configArgs  a string of configury options
+   */
+  public void configure (String configArgs)
+  {
+    _processConfigury (configArgs);
+  }
+
+  // A helper function to initialize the transport layer
+  private void _doInitialization ()
+    throws TransportException
+  {
+    _group = new ThreadGroup ("JDWP threads");
+    // initialize transport
+    ITransport transport = TransportFactory.newInstance (_properties);
+    _connection = new JdwpConnection (_group, transport);
+    _connection.initialize ();
+    _connection.start ();
+
+    // Create processor
+    _packetProcessor = new PacketProcessor (_connection);
+    _ppThread = new Thread (_group, new Runnable ()
+      {
+	public void run ()
+	{
+	  AccessController.doPrivileged (_packetProcessor);
+	}
+      }, "packet processor");
+    _ppThread.start ();
+  }
+
+  /**
+   * Shutdown the JDWP back-end
+   *
+   * NOTE: This does not quite work properly. See notes in 
+   * run() on this subject (catch of InterruptedException).
+   */
+  public void shutdown ()
+  {
+    if (!_shutdown)
+      {
+	_packetProcessor.shutdown ();
+	_ppThread.interrupt ();
+	_connection.shutdown ();
+	_shutdown = true;
+	isDebugging = false;
+
+	/* FIXME: probably need to check state of user's
+	   program -- if it is suspended, we need to either
+	   resume or kill them. */
+
+	interrupt ();
+      }
+  }
+
+  /**
+   * Notify the debugger of an event. This method should not
+   * be called if debugging is not active (but it would not
+   * cause any harm). Places where event notifications occur
+   * should check isDebugging before doing anything.
+   *
+   * The event is filtered through the event manager before being
+   * sent.
+   *
+   * FIXME: Probably need logic to send multiple events
+   * @param event the event to report
+   */
+  public static void notify (Event event)
+  {
+    Jdwp jdwp = getDefault ();
+    if (jdwp != null)
+      {
+	EventManager em = EventManager.getDefault ();
+	EventRequest request = em.getEventRequest (event);
+	if (request != null)
+	  {
+	    try
+	      {
+		System.out.println ("Jdwp.notify: sending event " + event);
+		sendEvent (request, event);
+		jdwp._enforceSuspendPolicy (request.getSuspendPolicy ());
+	      }
+	    catch (Exception e)
+	      {
+		/* Really not much we can do. For now, just print out
+		   a warning to the user. */
+		System.out.println ("Jdwp.notify: caught exception: " + e);
+	      }
+	  }
+      }
+  }
+  
+  /**
+   * Sends the event to the debugger.
+   *
+   * This method bypasses the event manager's filtering.
+   *
+   * @param  request  the debugger request for the event
+   * @param  event    the event to send
+   * @throws IOException if a communications failure occurs
+   */
+  public static void sendEvent (EventRequest request, Event event)
+      throws IOException
+  {
+    Jdwp jdwp = getDefault ();
+    if (jdwp != null)
+      {
+	// !! May need to implement send queue?
+	synchronized (jdwp._connection)
+	  {
+	    jdwp._connection.sendEvent (request, event);
+	  }
+      }
+  }
+
+  // Helper function to enforce suspend policies on event notification
+  private void _enforceSuspendPolicy (byte suspendPolicy)
+    throws JdwpException
+  {
+    switch (suspendPolicy)
+      {
+      case EventRequest.SUSPEND_NONE:
+	// do nothing
+	break;
+
+      case EventRequest.SUSPEND_THREAD:
+	VMVirtualMachine.suspendThread (Thread.currentThread ());
+	break;
+
+      case EventRequest.SUSPEND_ALL:
+	VMVirtualMachine.suspendAllThreads ();
+	break;
+      }
+  }
+
+  /**
+   * Allows subcomponents to specify that they are
+   * initialized.
+   *
+   * Subcomponents include JdwpConnection and PacketProcessor.
+   */
+  public void subcomponentInitialized ()
+  {
+    synchronized (_initLock)
+      {
+	++_initCount;
+	_initLock.notify ();
+      }
+  }
+
+  public void run ()
+  {
+    try
+      {
+	_doInitialization ();
+
+	/* We need a little internal synchronization here, so that
+	   when this thread dies, the back-end will be fully initialized,
+	   ready to start servicing the VM and debugger. */
+	synchronized (_initLock)
+	  {
+	    while (_initCount != 2)
+	      _initLock.wait ();
+	  }
+	_initLock = null;
+      }
+    catch (Throwable t)
+      {
+	System.out.println ("Exception in JDWP back-end: " + t);
+	System.exit (1);
+      }
+
+    /* Force creation of the EventManager. If the event manager
+       has not been created when isDebugging is set, it is possible
+       that the VM will call Jdwp.notify (which uses EventManager)
+       while the EventManager is being created (or at least this is
+       a problem with gcj/gij). */
+    EventManager.getDefault();
+
+    // Now we are finally ready and initialized
+    isDebugging = true;
+  }
+
+  // A helper function to process the configure string "-Xrunjdwp:..."
+  private void _processConfigury (String configString)
+  {
+    // Loop through configuration arguments looking for a
+    // transport name
+    _properties = new HashMap ();
+    String[] options = configString.split (",");
+    for (int i = 0; i < options.length; ++i)
+      {
+	String[] property = options[i].split ("=");
+	if (property.length == 2)
+	  _properties.put (property[0], property[1]);
+	// ignore malformed options
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/JdwpConstants.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/JdwpConstants.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,901 @@
+/* JdwpConstants.java -- Constants defined by JDWP 1.4 specification
+   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
+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;
+
+/**
+ * Constants defined by JDWP specification.
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class JdwpConstants
+{
+  public static final class Version
+  {
+    public static final int MAJOR = 1;
+    public static final int MINOR = 4;
+  }
+  
+  ////////////////////////////////////////
+  //           Commands/Sets            //
+  ////////////////////////////////////////
+
+  public static final class CommandSet
+  {
+    public static final class VirtualMachine
+    {
+      public static final byte CS_VALUE = 1;
+
+      // commands
+      public static final byte VERSION = 1;
+      public static final byte CLASSES_BY_SIGNATURE = 2;
+      public static final byte ALL_CLASSES = 3;
+      public static final byte ALL_THREADS = 4;
+      public static final byte TOP_LEVEL_THREAD_GROUPS = 5;
+      public static final byte DISPOSE = 6;
+      public static final byte IDSIZES = 7;
+      public static final byte SUSPEND = 8;
+      public static final byte RESUME = 9;
+      public static final byte EXIT = 10;
+      public static final byte CREATE_STRING = 11;
+      public static final byte CAPABILITIES = 12;
+      public static final byte CLASS_PATHS = 13;
+      public static final byte DISPOSE_OBJECTS = 14;
+      public static final byte HOLD_EVENTS = 15; 
+      public static final byte RELEASE_EVENTS = 16;
+      public static final byte CAPABILITIES_NEW = 17;
+      public static final byte REDEFINE_CLASSES = 18;
+      public static final byte SET_DEFAULT_STRATUM = 19;
+      public static final byte ALL_CLASSES_WITH_GENERIC = 20;
+    }
+
+    public static final class ReferenceType
+    {
+      public static final byte CS_VALUE = 2;
+
+      // commands
+      public static final byte SIGNATURE= 1;
+      public static final byte CLASS_LOADER= 2;
+      public static final byte MODIFIERS = 3;
+      public static final byte FIELDS = 4;
+      public static final byte METHODS = 5; 
+      public static final byte GET_VALUES = 6;
+      public static final byte SOURCE_FILE = 7;
+      public static final byte NESTED_TYPES = 8;
+      public static final byte STATUS = 9;
+      public static final byte INTERFACES= 10;
+      public static final byte CLASS_OBJECT = 11;
+      public static final byte SOURCE_DEBUG_EXTENSION = 12;
+      public static final byte SIGNATURE_WITH_GENERIC = 13;
+      public static final byte FIELDS_WITH_GENERIC = 14;
+      public static final byte METHODS_WITH_GENERIC = 15;
+    }
+
+    public static final class ClassType
+    {
+      public static final byte CS_VALUE = 3;
+
+      // commands
+      public static final byte SUPERCLASS = 1;
+      public static final byte SET_VALUES = 2;
+      public static final byte INVOKE_METHOD = 3;
+      public static final byte NEW_INSTANCE = 4;
+    }
+
+    public static final class ArrayType
+    {
+      public static final byte CS_VALUE = 4;
+
+      // commands
+      public static final byte NEW_INSTANCE = 1;
+    }
+
+    public static final class InterfaceType
+    {
+      public static final byte CS_VALUE = 5;
+
+      // commands
+    }
+
+    public static final class Method
+    {
+      public static final byte CS_VALUE = 6;
+
+      // commands
+      public static final byte LINE_TABLE = 1;
+      public static final byte VARIABLE_TABLE = 2;
+      public static final byte BYTE_CODES = 3;
+      public static final byte IS_OBSOLETE = 4;
+      public static final byte VARIABLE_TABLE_WITH_GENERIC = 5;
+    }
+
+    public static final class Field
+    {
+      public static final byte CS_VALUE = 8;
+
+      // commands
+    }
+
+    public static final class ObjectReference
+    {
+      public static final byte CS_VALUE = 9;
+
+      // commands
+      public static final byte REFERENCE_TYPE = 1;
+      public static final byte GET_VALUES = 2;
+      public static final byte SET_VALUES = 3;
+      public static final byte MONITOR_INFO = 5;
+      public static final byte INVOKE_METHOD = 6;
+      public static final byte DISABLE_COLLECTION = 7;
+      public static final byte ENABLE_COLLECTION = 8;
+      public static final byte IS_COLLECTED = 9;
+    }
+
+    public static final class StringReference
+    {
+      public static final byte CS_VALUE = 10;
+
+      // commands
+      public static final byte VALUE = 1;
+    }
+
+    public static final class ThreadReference
+    {
+      public static final byte CS_VALUE = 11;
+
+      // commands
+      public static final byte NAME = 1;
+      public static final byte SUSPEND = 2;
+      public static final byte RESUME = 3;
+      public static final byte STATUS = 4;
+      public static final byte THREAD_GROUP = 5;
+      public static final byte FRAMES = 6;
+      public static final byte FRAME_COUNT = 7;
+      public static final byte OWNED_MONITORS = 8;
+      public static final byte CURRENT_CONTENDED_MONITOR = 9;
+      public static final byte STOP = 10;
+      public static final byte INTERRUPT = 11;
+      public static final byte SUSPEND_COUNT = 12;
+    }
+
+    public static final class ThreadGroupReference
+    {
+      public static final byte CS_VALUE = 12;
+
+      // commands
+      public static final byte NAME = 1;
+      public static final byte PARENT = 2;
+      public static final byte CHILDREN = 3;
+    }
+
+    public static final class ArrayReference
+    {
+      public static final byte CS_VALUE = 13;
+
+      // commands
+      public static final byte LENGTH = 1;
+      public static final byte GET_VALUES = 2;
+      public static final byte SET_VALUES = 3;
+    }
+
+    public static final class ClassLoaderReference
+    {
+      public static final byte CS_VALUE = 14;
+
+      // commands
+      public static final byte VISIBLE_CLASSES = 1;
+    }
+
+    public static final class EventRequest
+    {
+      public static final byte CS_VALUE = 15;
+
+      // commands
+      public static final byte SET = 1;
+      public static final byte CLEAR = 2;
+      public static final byte CLEAR_ALL_BREAKPOINTS = 3;
+    }
+
+    public static final class StackFrame
+    {
+      public static final byte CS_VALUE = 16;
+
+      // commands
+      public static final byte GET_VALUES = 1;
+      public static final byte SET_VALUES = 2;
+      public static final byte THIS_OBJECT = 3;
+      public static final byte POP_FRAMES = 4;
+    }
+
+    public static final class ClassObjectReference
+    {
+      public static final byte CS_VALUE = 17;
+
+      // commands
+      public static final byte REFLECTED_TYPE = 1;
+    }
+
+    public static final int MAXIMUM = ClassObjectReference.CS_VALUE;
+
+    public static final class Event
+    {
+      public static final byte CS_VALUE = 64;
+
+      // commands
+      public static final byte COMPOSITE = 100;
+    }
+  }
+
+  ////////////////////////////////////////
+  //             Constants              //
+  ////////////////////////////////////////
+
+  /*
+   * Error constants
+   */
+  public static final class Error
+  {
+    /**
+     * No error has occurred
+     */
+    public static final short NONE = 0;
+
+    /**
+     * Passed thread is null, is not a valid thread or has exited
+     */
+    public static final short INVALID_THREAD = 10;
+
+    /**
+     * Thread group invalid
+     */
+    public static final short INVALID_THREAD_GROUP = 11;
+
+    /**
+     * Invalid priority
+     */
+    public static final short INVALID_PRIORITY = 12;
+
+    /**
+     * Specified thread has not been suspended by an event
+     */
+    public static final short THREAD_NOT_SUSPENDED = 13;
+
+    /**
+     * Thread already suspended
+     */
+    public static final short THREAD_SUSPENDED = 14;
+
+    /**
+     * Reference type has been unloaded and garbage collected
+     */
+    public static final short INVALID_OBJECT = 20;
+
+    /**
+     * Invalid class
+     */
+    public static final short INVALID_CLASS = 21;
+
+    /**
+     * Class has been loaded but not yet prepared
+     */
+    public static final short CLASS_NOT_PREPARED = 22;
+
+    /**
+     * Invalid method
+     */
+    public static final short INVALID_METHODID = 23;
+
+    /**
+     * Invalid location
+     */
+    public static final short INVALID_LOCATION = 24;
+
+    /**
+     * Invalid field
+     */
+    public static final short INVALID_FIELDID = 25;
+
+    /**
+     * Invaliid frame
+     */
+    public static final short INVALID_FRAMEID = 30;
+
+    /**
+     * There are no more Java or JNI frames on the call stack
+     */
+    public static final short NO_MORE_FRAMES = 31;
+
+    /**
+     * Information about the frame is not available
+     */
+    public static final short OPAQUE_FRAME = 32;
+
+    /**
+     * Operation can only be performed on current frame
+     */
+    public static final short NOT_CURRENT_FRAME = 33;
+
+    /**
+     * Variable is not an appropriate type for the function used
+     */
+    public static final short TYPE_MISMATCH = 34;
+
+    /**
+     * Invalid slot
+     */
+    public static final short INVALID_SLOT = 35;
+
+    /**
+     * Item already set
+     */
+    public static final short DUPLICATE = 40;
+
+    /**
+     * Desired element not found
+     */
+    public static final short NOT_FOUND = 41;
+
+    /**
+     * Invalid monitor
+     */
+    public static final short INVALID_MONITOR = 50;
+
+    /**
+     * Thread doesn't own the monitor
+     */
+    public static final short NOT_MONITOR_OWNER = 51;
+
+    /**
+     * Call has been interrupted before completion
+     */
+    public static final short INTERRUPT = 52;
+
+    /**
+     * Virtual machine attempted to read a class file and determined that
+     * the file is malformed or otherwise cannot be interpreted as a class
+     * file
+     */
+    public static final short INVALID_CLASS_FORMAT = 60;
+
+    /**
+     * Circularity has been detected while initializing a class
+     */
+    public static final short CIRCULAR_CLASS_DEFINITION = 61;
+
+    /**
+     * Verifier detected that a class file, though well formed, contained
+     * some sort of internal inconsistency or security problem
+     */
+    public static final short FAILS_VERIFICATION = 62;
+
+    /**
+     * Adding methods has not been implemented
+     */
+    public static final short ADD_METHOD_NOT_IMPLEMENTED = 63;
+
+    /**
+     * Schema change has not been implemented
+     */
+    public static final short SCHEMA_CHANGE_NOT_IMPLEMENTED = 64;
+
+    /**
+     * State of the thread has been modified and is now inconsistent
+     */
+    public static final short INVALID_TYPESTATE = 65;
+
+    /**
+     * A direct superclass is different for the new class version, or the set
+     * of directly implemented interfaces is different and
+     * <code>canUnrestrictedlyRedefineClasses</code> is false
+     */
+    public static final short HIERARCHY_CHANGE_NOT_IMPLEMENTED = 66;
+
+    /**
+     * New class version does not declare a method declared in the old
+     * class version and <code>canUnrestrictedlyRedefineClasses</code>
+     * is false
+     */
+    public static final short DELETE_METHOD_NOT_IMPLEMENTED = 67;
+
+    /**
+     * Class file has a version number not supported by this VM
+     */
+    public static final short UNSUPPORTED_VERSION = 68;
+
+    /**
+     * Class name defined in the new class file is different from the name
+     * in the old class object
+     */
+    public static final short NAMES_DONT_MATCH = 69;
+
+    /**
+     * New class version has different modifiers and
+     * <code>canUnrestrictedlyRedefineClasses</code> is false
+     */
+    public static final short CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED = 70;
+
+    /**
+     * A method in the new class version has different modifiers than its
+     * counterpart in the old class version and
+     * <code>canUnrestrictedlyRedefineClasses</code> is false.
+     */
+    public static final short METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED = 71;
+
+    /**
+     * Functionality is not implemented in this virtual machine
+     */
+    public static final short NOT_IMPLEMENTED = 99;
+
+    /**
+     * Invalid pointer
+     */
+    public static final short NULL_POINTER = 100;
+
+    /**
+     * Desired information is not available
+     */
+    public static final short ABSENT_INFORMATION = 101;
+
+    /**
+     * Specified event type id is not recognized
+     */
+    public static final short INVALID_EVENT_TYPE = 102;
+
+    /**
+     * Illegal argument
+     */
+    public static final short ILLEGAL_ARGUMENT = 103;
+
+    /**
+     * The function needed to allocate memory and no more memory was
+     * available for allocation
+     */
+    public static final short OUT_OF_MEMORY = 110;
+
+    /**
+     * Debugging has not been enabled in this virtual machine. JVMDI cannot
+     * be used
+     */
+    public static final short ACCESS_DENIED = 111;
+
+    /**
+     * The virtual machine is not running
+     */
+    public static final short VM_DEAD = 112;
+
+    /**
+     * An unexpected internal error has occurred
+     */
+    public static final short INTERNAL = 113;
+
+    /**
+     * The thread being used to call this function is not attached to the
+     * virtual machine. Calls must be made from attached threads.
+     */
+    public static final short UNATTACHED_THREAD = 115;
+
+    /**
+     * Invalid object type id or class tag
+     */
+    public static final short INVALID_TAG = 500;
+
+    /**
+     * Previous invoke not complete
+     */
+    public static final short ALREADY_INVOKING = 502;
+
+    /**
+     * Invalid index
+     */
+    public static final short INVALID_INDEX = 503;
+
+    /**
+     * Invalid length
+     */
+    public static final short INVALID_LENGTH = 504;
+
+    /**
+     * Invalid string
+     */
+    public static final short INVALID_STRING = 506;
+
+    /**
+     * Invalid class loader
+     */
+    public static final short INVALID_CLASS_LOADER = 507;
+
+    /**
+     * Invalid array
+     */
+    public static final short INVALID_ARRAY = 508;
+
+    /**
+     * Unable to load the transport
+     */
+    public static final short TRANSPORT_LOAD = 509;
+
+    /**
+     * Unablie to initialize the transport
+     */
+    public static final short TRANSPORT_INIT = 510;
+
+    /**
+     * Method is native
+     */
+    public static final short NATIVE_METHOD = 511;
+
+    /**
+     * Invalid count
+     */
+    public static final short INVALID_COUNT = 512;
+  }
+
+  /*
+   * EventKind constants
+   */
+  public static final class EventKind
+  {
+    public static final byte SINGLE_STEP = 1;
+    public static final byte BREAKPOINT = 2;
+    public static final byte FRAME_POP = 3;
+    public static final byte EXCEPTION = 4;
+    public static final byte USER_DEFINED = 5;
+    public static final byte THREAD_START = 6;
+    public static final byte THREAD_END = 7;
+    public static final byte CLASS_PREPARE = 8;
+    public static final byte CLASS_UNLOAD = 9;
+    public static final byte CLASS_LOAD = 10;
+    public static final byte FIELD_ACCESS = 20;
+    public static final byte FIELD_MODIFICATION = 21;
+    public static final byte EXCEPTION_CATCH = 30;
+    public static final byte METHOD_ENTRY = 40;
+    public static final byte METHOD_EXIT = 41;
+    public static final byte VM_INIT = 90;
+    public static final byte VM_DEATH = 99;    
+    public static final byte VM_DISCONNECTED = 100;
+
+    public static final byte VM_START = VM_INIT;
+    public static final byte THREAD_DEATH = THREAD_END;
+  }
+
+  /*
+   * ModKind constants (event filters)
+   */
+  public static final class ModKind
+  {
+    /**
+     * Limit the requested event to be reported at most once after a
+     * given number of occurrences. May be used with any event.
+     */
+    public static final byte COUNT = 1;
+
+    /**
+     * Conditional on expression
+     */
+    public static final byte CONDITIONAL = 2;
+
+    /**
+     * Restricts reported events to those in the given thread.
+     * May be used with any event except for class unload.
+     */
+    public static final byte THREAD_ONLY = 3;
+
+    /**
+     * For class prepare events, restricts generated events 
+     * to be the preparation of the given reference type and any
+     * subtypes.
+     *
+     * For other events, restricts the generated events to those where
+     * location is in the given reference type or any of its subtypes.
+     *
+     * An event will be generated for any location in a reference type
+     * that can be safely cast to the given reference type.
+     *
+     * May be used with any event except class unload, thread start,
+     * and thread end.
+     */
+    public static final byte CLASS_ONLY = 4;
+
+    /**
+     * Restricts reported events to those for classes whose name matches
+     * the given restricted regular expression.
+     *
+     * For class prepare events, the prepared class name is matched.
+     * For class unload events, the unloaded class name is matched.
+     * For other events, the class name of the event's location is matched.
+     *
+     * May be used with any event except thread start and thread end.
+     */
+    public static final byte CLASS_MATCH = 5;
+
+    /**
+     * Restricts reported events to those for classes whose name does not
+     * match the given restricted regular expression.
+     * 
+     * For class prepare events, the prepared class name is matched.
+     * For class unload events, the unloaded class name is matched.
+     * For other events, the class name of the event's location is matched.
+     *
+     * May be used with any event except thread start and thread end.
+     */
+    public static final byte CLASS_EXCLUDE = 6;
+
+    /**
+     * Restricts reported events to those that occur at the given location.
+     *
+     * May be used with breakpoint, field access, field modification, step,
+     * and exception event kinds.
+     */
+    public static final byte LOCATION_ONLY = 7;
+
+    /**
+     * Restricts reported exceptions by their class and whether they are
+     * caught or uncaught.
+     *
+     * May be used with exception event kinds only.
+     */
+    public static final byte EXCEPTION_ONLY = 8;
+
+    /**
+     * Restricts reported events to those that occur for a given field.
+     *
+     * May be used with field access and field modification event kinds only.
+     */
+    public static final byte FIELD_ONLY = 9;
+
+    /**
+     * Restricts reported step events to those which satisfy depth and
+     * size constraints.
+     * 
+     * May be used with step event kinds only.
+     */
+    public static final byte STEP = 10;
+
+    /**
+     * Restricts reported events to those whose active 'this' object is
+     * the given object. Match value is the null object for static methods.
+     *
+     * May be used with any event except class prepare, class unload,
+     * thread start, and thread end.
+     */
+    public static final byte INSTANCE_ONLY = 11;
+  }
+
+  /*
+   * ThreadStatus constants
+   */
+  public static final class ThreadStatus
+  {
+    public static final int ZOMBIE = 0;
+    public static final int RUNNING = 1;
+    public static final int SLEEPING = 2;
+    public static final int MONITOR = 3;
+    public static final int WAIT = 4;
+  }
+
+  /*
+   * SuspendStatus constants
+   */
+  public static final class SuspendStatus
+  {
+    public static final byte SUSPENDED = 1;
+  }
+
+  /*
+   * ClassStatus constants
+   */
+  public static final class ClassStatus
+  {
+    public static final int VERIFIED = 1;
+    public static final int PREPARED = 2;
+    public static final int INITIALIZED = 4;
+    public static final int ERROR = 8;
+  }
+
+  /*
+   * TypeTag constants
+   */
+  public static final class TypeTag
+  {
+    public static final byte CLASS = 1;
+    public static final byte INTERFACE = 2;
+    public static final byte ARRAY = 3;
+  }
+
+  /*
+   * Tag constants
+   */
+  public static final class Tag
+  {
+    /**
+     * Array object (objectID size)
+     */
+    public static final byte ARRAY = '[';
+
+    /**
+     * Byte value (1 byte)
+     */
+    public static final byte BYTE = 'B';
+
+    /**
+     * Character value (2 bytes)
+     */
+    public static final byte CHAR = 'C';
+
+    /**
+     * Object (objectID size)
+     */
+    public static final byte OBJECT = 'L';
+
+    /**
+     * Float value (4 bytes)
+     */
+    public static final byte FLOAT = 'F';
+
+    /**
+     * Double value (8 bytes)
+     */
+    public static final byte DOUBLE = 'D';
+
+    /**
+     * Int value (4 bytes)
+     */
+    public static final byte INT = 'I';
+
+    /**
+     * Long value (8 bytes)
+     */
+    public static final byte LONG = 'J';
+
+    /**
+     * Short value (2 bytes)
+     */
+    public static final byte SHORT = 'S';
+
+    /**
+     * Void value (no bytes)
+     */
+    public static final byte  VOID = 'V';
+
+    /**
+     * Boolean value (1 byte)
+     */
+    public static final byte BOOLEAN = 'Z';
+
+    /**
+     * String object (objectID size)
+     */
+    public static final byte STRING = 's';
+
+    /**
+     * Thread object (objectID size)
+     */
+    public static final byte THREAD = 't';
+
+    /**
+     * ThreadGroup object (objectID size)
+     */
+    public static final byte THREAD_GROUP = 'g';
+
+    /**
+     * ClassLoader object (objectID size)
+     */
+    public static final byte CLASS_LOADER = 'l';
+
+    /**
+     * Class object object (objectID size)
+     */
+    public static final byte CLASS_OBJECT = 'c';
+  }
+
+  /*
+   * StepDepth constants
+   */
+  public static final class StepDepth
+  {
+    /**
+     * Step into any method calls that occur before the end of the step
+     */
+    public static final int INTO = 0;
+
+    /**
+     * Step over any method calls that occur before the end of the step
+     */
+    public static final int OVER = 1;
+
+    /**
+     * Step out of the current method
+     */
+    public static final int OUT = 2;
+  }
+
+  /*
+   * StepSize constants
+   */
+  public static final class StepSize
+  {
+    /**
+     * Step by the minimum possible amount (often a bytecode instruction)
+     */
+    public static final int MIN = 0;
+
+    /**
+     * Step to the next source line unless there is no line number information,
+     * in which case MIN step is done instead
+     */
+    public static final int LINE = 1;
+  }
+
+  /*
+   * SuspendPolicy constants
+   */
+  public static final class SuspendPolicy
+  {
+    /**
+     * Suspend no threads when this event is encountered
+     */
+    public static final byte NONE = 0;
+
+    /**
+     * Suspend the event thread when this event is encountered
+     */
+    public static final byte EVENT_THREAD = 1;
+
+    /**
+     * Suspend all threads when this event is encountered
+     */
+    public static final byte ALL = 2;
+  }
+
+  /*
+   * InvokeOptions flag constants
+   */
+  public static final class InvokeOptions
+  {
+    /**
+     * otherwise, all threads started
+     */
+    public static final int INVOKE_SINGLE_THREADED = 0x1;
+
+    /**
+     * otherwise, normal virtual invoke (instance methods only)
+     */
+    public static final int INVOKE_NONVIRTUAL = 0x2;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/BreakpointEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/BreakpointEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,117 @@
+/* BreakpointEvent.java -- An event specifying that the interpreter
+   has hit a breakpoint
+   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
+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.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * "Notification of a breakpoint in the target VM. The breakpoint event is
+ * generated before the code at its location is executed."
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class BreakpointEvent
+  extends Event
+{
+  // The thread in which this event occurred
+  private Thread _thread;
+
+  // Location where breakpoint occurred
+  private Location _location;
+  
+  //object instance
+  private Object _instance;
+
+  /**
+   * Constructs a new BreakpointEvent
+   *
+   * @param thread  thread in which event occurred
+   * @param loc     location where breakpoint occurred
+   * @param instance object instance
+   */
+  public BreakpointEvent(Thread thread, Location loc, Object instance)
+  {
+    super(JdwpConstants.EventKind.BREAKPOINT);
+    _thread = thread;
+    _location = loc;
+    _instance = instance;
+  }
+
+  /**
+   * Returns a specific filtering parameter for this event.
+   * Valid types are thread and location.
+   *
+   * @param type  the type of parameter desired
+   * @returns the desired parameter or null
+   */
+  public Object getParameter(int type)
+  {
+    if (type == EVENT_THREAD)
+      return _thread;
+    else if (type == EVENT_LOCATION)
+      return _location;
+    else if (type == EVENT_INSTANCE)
+      return _instance;
+
+    return null;
+  }
+
+  /**
+   * Writes the event to the given stream
+   *
+   * @param outStream  the output stream to write the event to
+   */
+  protected void _writeData (DataOutputStream outStream)
+    throws IOException
+  {
+    VMIdManager idm = VMIdManager.getDefault();
+    ThreadId tid = (ThreadId) idm.getObjectId(_thread);
+
+    tid.write(outStream);
+    _location.write(outStream);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,147 @@
+/* ClassPrepareEvent.java -- An event specifying that a class has been
+   prepared by the virtual machine
+   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
+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.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.JdwpString;
+import gnu.classpath.jdwp.util.Signature;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * "Notification of a class prepare in the target VM. See the JVM
+ * specification for a definition of class preparation. Class prepare
+ * events are not generated for primtiive classes (for example,
+ * <code>java.lang.Integer.TYPE</code>)." -- JDWP 1.4.2
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class ClassPrepareEvent
+  extends Event
+{
+  // The thread in which this event occurred
+  private Thread _thread;
+
+  // The class that was prepared
+  private Class _class;
+
+  // Prepare flags
+  private int _status;
+
+  /**
+   * Class has been verified
+   */
+  public static final int STATUS_VERIFIED
+      = JdwpConstants.ClassStatus.VERIFIED;
+
+  /**
+   * Class has been prepared
+   */
+  public static final int STATUS_PREPARED
+      = JdwpConstants.ClassStatus.PREPARED;
+
+  /**
+   * Class has been initialized
+   */
+  public static final int STATUS_INITIALIZED
+      = JdwpConstants.ClassStatus.INITIALIZED;
+
+  /**
+   * Error preparing class
+   */
+  public static final int STATUS_ERROR
+      = JdwpConstants.ClassStatus.ERROR;
+
+  /**
+   * Constructs a new <code>ClassPrepareEvent</code>
+   *
+   * @param thread  thread in which event occurred
+   * @param clazz   class which was prepared
+   * @param flags   prepare status flags
+   */
+  public ClassPrepareEvent (Thread thread, Class clazz, int flags)
+  {
+    super (JdwpConstants.EventKind.CLASS_PREPARE);
+    _thread = thread;
+    _class = clazz;
+    _status = flags;
+  }
+
+  /**
+   * Returns a specific filtering parameter for this event.
+   * Valid types are thread and class.
+   *
+   * @param type  the type of parameter desired
+   * @returns the desired parameter or <code>null</code>
+   */
+  public Object getParameter (int type)
+  {
+    if (type == EVENT_THREAD)
+      return _thread;
+    else if (type == EVENT_CLASS)
+      return _class;
+
+    return null;
+  }
+
+  /**
+   * Writes the event to the given stream
+   *
+   * @param outStream  the output stream to write the event to
+   */
+  protected void _writeData (DataOutputStream outStream)
+    throws IOException
+  {
+    VMIdManager idm = VMIdManager.getDefault();
+    ThreadId tid = (ThreadId) idm.getObjectId (_thread);
+    ReferenceTypeId rid = idm.getReferenceTypeId (_class);
+
+    tid.write (outStream);
+    rid.writeTagged (outStream);
+    JdwpString.writeString (outStream,
+			    Signature.computeClassSignature (_class));
+    outStream.writeInt (_status);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/ClassUnloadEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/ClassUnloadEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,96 @@
+/* ClassUnloadEvent.java -- event generated when a class is unloaded
+ 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.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.util.JdwpString;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * "Notification of a class unload in the target VM" -- JDWP 1.4.2
+ * 
+ * @author Kyle Galloway (kgallowa at redhat.com)
+ */
+public class ClassUnloadEvent
+    extends Event
+{
+  //signature directly from VM
+  private String _signature;
+
+  /**
+   * Constructs a new <code>ClassUnloadEvent</code>
+   * 
+   * @param signature the signature reported from the VM
+   */
+  public ClassUnloadEvent(String signature)
+  {
+    super(JdwpConstants.EventKind.CLASS_UNLOAD);
+    _signature = signature;
+  }
+
+  /**
+   * Returns a specific filtering parameter for this event. Class is the only
+   * valid type.
+   * 
+   * @param type the type of parameter desired
+   * @returns the desired parameter or <code>null</code>
+   */
+  public Object getParameter(int type)
+  {
+
+    return null;
+  }
+
+  /**
+   * Writes the event to the given stream
+   * 
+   * @param outStream the output stream to write the event to
+   */
+  protected void _writeData(DataOutputStream outStream) 
+    throws IOException
+  {
+    VMIdManager idm = VMIdManager.getDefault();
+
+    JdwpString.writeString(outStream, _signature);
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/Event.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/Event.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,165 @@
+/* Event.java -- a base class for all event types
+   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
+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.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.transport.JdwpCommandPacket;
+import gnu.classpath.jdwp.transport.JdwpPacket;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * This class is a base class for all VM->debugger event
+ * notifications.
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public abstract class Event
+{
+  /**
+   * The class of the object in which the event occurred
+   */
+  public static final int EVENT_CLASS = 1;
+  
+  /**
+   * The thread where the event occurred
+   */
+  public static final int EVENT_THREAD = 2;
+  
+  /**
+   * The location where an event occurred
+   */
+  public static final int EVENT_LOCATION = 3;
+  
+  /**
+   * The instance of the class where the event occurred
+   */
+  public static final int EVENT_INSTANCE = 4;
+  
+  /**
+   * The field acted on by an event
+   */
+  public static final int EVENT_FIELD = 5;
+
+  /**
+   * The class of the exception for ExceptionEvent
+   */
+  public static final int EVENT_EXCEPTION_CLASS = 6;
+
+  /**
+   * Whether this exception was caught (only valid for ExceptionEvents)
+   */
+  public static final int EVENT_EXCEPTION_CAUGHT = 7;
+  
+  // The kind of event represented by this event
+  private byte _eventKind;
+
+  /**
+   * Constructs an <code>Event</code> of the given kind
+   *
+   * @param kind  the type of event
+   */
+  public Event (byte kind)
+  {
+    _eventKind = kind;
+  }
+
+  /**
+   * Returns the event type of this event
+   *
+   * @returns  the event kind
+   */
+  public byte getEventKind ()
+  {
+    return _eventKind;
+  }
+
+  /**
+   * Abstract function used by implementing classes to fill in the
+   * event-specific data. Note that request ID is automatically added
+   * by this class (since it appears in all event notifications).
+   *
+   * @param outStream  the stream to which to write data
+   */
+  protected abstract void _writeData (DataOutputStream outStream)
+    throws IOException;
+
+  /**
+   * Returns a specific filtering parameter for this event. For example,
+   * most events may be filtered by thread. Consequently, a call to this
+   * method with <code>ThreadId.class</code> should return a
+   * <code>Thread</code>.
+   *
+   * @param type  the type of parameter to return
+   * @returns the parameter (not the ID) or <code>null</code> if none is
+   *          is defined for this event
+   */
+  public abstract Object getParameter (int type);
+
+  /**
+   * Converts this event into to a JDWP packet
+   *
+   * @param dos     the stream to which to write data
+   * @param request the request the wanted this notification
+   * @returns a <code>JdwpPacket</code> of the events
+   */
+  public JdwpPacket toPacket (DataOutputStream dos, EventRequest request)
+  {
+    JdwpPacket pkt;
+    try
+      {
+	dos.writeByte (request.getSuspendPolicy ());
+	dos.writeInt (1);
+	dos.writeByte (_eventKind);
+	dos.writeInt (request.getId ());
+	_writeData (dos);
+
+	pkt = new JdwpCommandPacket (JdwpConstants.CommandSet.Event.CS_VALUE,
+				     JdwpConstants.CommandSet.Event.COMPOSITE);
+      }
+    catch (IOException ioe)
+      {
+	pkt = null;
+      }
+
+    return pkt;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,302 @@
+/* EventManager.java -- event management and notification infrastructure
+   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.event;
+
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.InvalidEventTypeException;
+import gnu.classpath.jdwp.exception.JdwpException;
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+/**
+ * Manages event requests and filters event notifications.
+ *
+ * The purpose of this class is actually two-fold:
+ * 
+ * 1) Maintain a list of event requests from the debugger
+ * 2) Filter event notifications from the VM
+ * 
+ * If an event request arrives from the debugger, the back-end will
+ * call {@link #requestEvent}, which will first check for a valid event.
+ * If it is valid, <code>EventManager</code> will record the request
+ * internally and register the event with the virtual machine, which may
+ * choose to handle the request itself (as is likely the case with
+ * breakpoints and other execution-related events), or it may decide to
+ * allow the <code>EventManager</code> to handle notifications and all
+ * filtering (which is convenient for other events such as class (un)loading).
+ * 
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class EventManager
+{
+  // Single instance
+  private static EventManager _instance = null;
+
+  // maps event (EVENT_*) to lists of EventRequests
+  private Hashtable _requests = null;
+
+  /**
+   * Returns an instance of the event manager
+   *
+   * @return the event manager
+   */
+  public static EventManager getDefault()
+  {
+    if (_instance == null)
+      _instance = new EventManager();
+
+    return _instance;
+  }
+
+  // Private constructs a new <code>EventManager</code>
+  private EventManager ()
+  {
+    _requests = new Hashtable ();
+
+    // Add lists for all the event types
+    _requests.put (new Byte (EventRequest.EVENT_SINGLE_STEP),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_BREAKPOINT),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_FRAME_POP),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_EXCEPTION),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_USER_DEFINED),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_THREAD_START),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_THREAD_END),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_CLASS_PREPARE),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_CLASS_UNLOAD),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_CLASS_LOAD),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_FIELD_ACCESS),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_FIELD_MODIFY),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_METHOD_ENTRY),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_METHOD_EXIT),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_VM_INIT),
+		   new Hashtable ());
+    _requests.put (new Byte (EventRequest.EVENT_VM_DEATH),
+		   new Hashtable ());
+
+    // Add auto-generated event notifications
+    // only two: VM_INIT, VM_DEATH
+    try
+      {
+	requestEvent (new EventRequest (0,
+					EventRequest.EVENT_VM_INIT,
+					EventRequest.SUSPEND_NONE));
+	requestEvent (new EventRequest (0,
+					EventRequest.EVENT_VM_DEATH,
+					EventRequest.SUSPEND_NONE));
+      }
+    catch (JdwpException e)
+      {
+	// This can't happen
+      }
+  }
+
+  /**
+   * Returns a request for the given event. This method will only
+   * be used if the <code>EventManager</code> is handling event filtering.
+   *
+   * @param  event  the event
+   * @return request that was interested in this event
+   *         or <code>null</code> if none (and event should not be sent)
+   * @throws IllegalArgumentException for invalid event kind
+   */
+  public EventRequest getEventRequest (Event event)
+  {
+    EventRequest interestedRequest = null;
+    Hashtable requests;
+    Byte kind = new Byte (event.getEventKind ());
+    requests = (Hashtable) _requests.get (kind);
+    if (requests == null)
+      {
+	// Did not get a valid event type
+	throw new IllegalArgumentException ("invalid event kind: " + kind);
+      }
+    boolean match = false;
+
+    // Loop through the requests. Must look at ALL requests in order
+    // to evaluate all filters (think count filter).
+    // TODO: What if multiple matches? Spec isn't so clear on this.
+    Iterator rIter = requests.values().iterator ();
+    while (rIter.hasNext ())
+      {
+	EventRequest request = (EventRequest) rIter.next ();
+	if (request.matches (event))
+	  interestedRequest = request;
+      }
+
+    return interestedRequest;
+  }
+
+  /**
+   * Requests monitoring of an event.
+   *
+   * The debugger registers for event notification through
+   * an event filter. If no event filter is specified for an event
+   * in the VM, it is assumed that the debugger is not interested in
+   * receiving notifications of this event.
+   *
+   * The virtual machine will be notified of the request.
+   *
+   * @param request  the request to monitor
+   * @throws InvalidEventTypeException for invalid event kind
+   * @throws JdwpException for other errors involving request
+   */
+  public void requestEvent (EventRequest request)
+    throws JdwpException
+  {
+    // Add request to request list
+    Hashtable requests;
+    Byte kind = new Byte (request.getEventKind ());
+    requests = (Hashtable) _requests.get (kind);
+    if (requests == null)
+      {
+	// Did not get a valid event type
+	throw new InvalidEventTypeException (request.getEventKind ());
+      }
+
+    // Register the event with the VM
+    VMVirtualMachine.registerEvent (request);
+    requests.put (new Integer (request.getId ()), request);
+  }
+
+  /**
+   * Deletes the given request from the management table
+   *
+   * @param  kind  the event kind
+   * @param  id    the ID of the request to delete
+   * @throws IllegalArgumentException for invalid event kind
+   * @throws JdwpException for other errors deleting request
+   */
+  public void deleteRequest (byte kind, int id)
+    throws JdwpException
+  {
+    Hashtable requests;
+    requests = (Hashtable) _requests.get (new Byte (kind));
+    if (requests == null)
+      {
+	// Did not get a valid event type
+	throw new IllegalArgumentException ("invalid event kind: " + kind);
+      }
+
+    Integer iid = new Integer (id);
+    EventRequest request = (EventRequest) requests.get (iid);
+    if (request != null)
+      {
+	VMVirtualMachine.unregisterEvent (request);
+	requests.remove (iid);
+      }
+  }
+
+  /**
+   * Clears all the requests for a given event
+   *
+   * @param  kind  the event kind
+   * @throws IllegalArgumentException for invalid event kind
+   * @throws JdwpException for error clearing events
+   */
+  public void clearRequests (byte kind)
+    throws JdwpException
+  {
+    Hashtable requests = (Hashtable) _requests.get (new Byte (kind));
+    if (requests == null)
+      {
+	// Did not get a valid event type
+	throw new IllegalArgumentException ("invalid event kind: " + kind);
+      }
+
+    VMVirtualMachine.clearEvents (kind);
+    requests.clear ();
+  }
+
+  /**
+   * Returns a given event request for an event
+   *
+   * @param  kind  the kind of event for the request
+   * @param  id    the integer request id to return
+   * @return  the request for the given event kind with the given id
+   *          (or <code>null</code> if not found)
+   * @throws IllegalArgumentException for invalid event kind
+   */
+  public EventRequest getRequest (byte kind, int id)
+  {
+    Hashtable requests = (Hashtable) _requests.get (new Byte (kind));
+    if (requests == null)
+      {
+	// Did not get a valid event type
+	throw new IllegalArgumentException ("invalid event kind: " + kind);
+      }
+
+    return (EventRequest) requests.get (new Integer (id));
+  }
+
+  /**
+   * Returns all requests of the given event kind
+   *
+   * @param  kind  the event kind
+   * @returns a <code>Collection</code> of all the registered requests
+   * @throws IllegalArgumentException for invalid event kind
+   */
+  public Collection getRequests (byte kind)
+  {
+    Hashtable requests = (Hashtable) _requests.get (new Byte (kind));
+    if (requests == null)
+      {
+	// Did not get a valid event type
+	throw new IllegalArgumentException ("invalid event kind: " + kind);
+      }
+    
+    return requests.values ();
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/EventRequest.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/EventRequest.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,383 @@
+/* EventRequest.java -- an event request from the debugger
+   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.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.event.filters.*;
+import gnu.classpath.jdwp.exception.JdwpIllegalArgumentException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+/**
+ * A class which represents a request by the debugger for an event
+ * in the VM. <code>EventRequest</code>s usually have event filters
+ * associated with them, which allow the debugger to specify conditions
+ * under which the notification should be sent (specific thread, specific
+ * class, ignore count, etc).
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class EventRequest
+{
+  /*
+   * Event types
+   */
+
+  /**
+   * Single step event
+   */
+  public static final byte EVENT_SINGLE_STEP =
+    JdwpConstants.EventKind.SINGLE_STEP;
+
+  /**
+   * Breakpoint event
+   */
+  public static final byte EVENT_BREAKPOINT =
+    JdwpConstants.EventKind.BREAKPOINT;
+
+  /**
+   * Frame pop event
+   */
+  public static final byte EVENT_FRAME_POP =
+    JdwpConstants.EventKind.FRAME_POP;
+
+  /**
+   * Exception event
+   */
+  public static final byte EVENT_EXCEPTION =
+    JdwpConstants.EventKind.EXCEPTION;
+
+  /**
+   * User-defined event
+   */
+  public static final byte EVENT_USER_DEFINED = 
+    JdwpConstants.EventKind.USER_DEFINED;
+
+  /**
+   * Thread start event
+   */
+  public static final byte EVENT_THREAD_START = 
+    JdwpConstants.EventKind.THREAD_START;
+
+  /**
+   * Thread end/death event
+   */
+  public static final byte EVENT_THREAD_END =
+    JdwpConstants.EventKind.THREAD_END;
+
+  /**
+   * Class prepare event
+   */
+  public static final byte EVENT_CLASS_PREPARE =
+    JdwpConstants.EventKind.CLASS_PREPARE;
+
+  /**
+   * Class unload event
+   */
+  public static final byte EVENT_CLASS_UNLOAD =
+    JdwpConstants.EventKind.CLASS_UNLOAD;
+
+  /**
+   * Class load event
+   */
+  public static final byte EVENT_CLASS_LOAD =
+    JdwpConstants.EventKind.CLASS_LOAD;
+
+  /**
+   * Field access event
+   */
+  public static final byte EVENT_FIELD_ACCESS =
+    JdwpConstants.EventKind.FIELD_ACCESS;
+
+  /**
+   * Field modify event
+   */
+  public static final byte EVENT_FIELD_MODIFY =
+    JdwpConstants.EventKind.FIELD_MODIFICATION;
+
+  /**
+   * Method entry event
+   */
+  public static final byte EVENT_METHOD_ENTRY =
+    JdwpConstants.EventKind.METHOD_ENTRY;
+
+  /**
+   * Method exit event
+   */
+  public static final byte EVENT_METHOD_EXIT = 
+    JdwpConstants.EventKind.METHOD_EXIT;
+
+  /**
+   * Virtual machine initialization/start
+   */
+  public static final byte EVENT_VM_INIT =
+    JdwpConstants.EventKind.VM_INIT;
+
+  /**
+   * Virutal machine death
+   */
+  public static final byte EVENT_VM_DEATH =
+    JdwpConstants.EventKind.VM_DEATH;
+
+
+  /*
+   * Suspend policies
+   */
+
+  /**
+   * Do not suspend any threads
+   */
+  public static final byte SUSPEND_NONE = 
+    JdwpConstants.SuspendPolicy.NONE;
+
+  /**
+   * Suspend the thread in which the event occurred
+   */
+  public static final byte SUSPEND_THREAD =
+    JdwpConstants.SuspendPolicy.EVENT_THREAD;
+
+  /**
+   * Suspend all threads
+   */
+  public static final byte SUSPEND_ALL =
+    JdwpConstants.SuspendPolicy.ALL;
+
+  // ID of last EventRequest
+  private static int _last_id = 0;
+  private static Object _idLock = new Object ();
+
+  // A list of filters
+  private LinkedList _filters;
+
+  // The ID of this request
+  private int _id;
+
+  // The suspend policy to enforce when this event occurs
+  private byte _suspendPolicy;
+
+  // Kind of event requested
+  private byte _kind;
+
+  /**
+   * Construct a new <code>EventRequest</code>
+   *
+   * @param kind           the kind of event requested
+   * @param suspendPolicy  how to suspend threads when event occurs
+   */
+  public EventRequest (byte kind, byte suspendPolicy)
+  {
+    _filters = new LinkedList ();
+    synchronized (_idLock)
+      {
+	_id = ++_last_id;
+      }
+    _kind = kind;
+    _suspendPolicy = suspendPolicy;
+  }
+
+  /**
+   * Construct a new <code>EventRequest</code> with the given ID
+   *
+   * @param id             the id of the request to create
+   * @param kind           the kind of event requested
+   * @param suspendPolicy  how to suspend threads when event occurs
+   */
+  public EventRequest (int id, byte kind, byte suspendPolicy)
+  {
+    _filters = new LinkedList ();
+    _kind = kind;
+    _suspendPolicy = suspendPolicy;
+  }
+
+  /**
+   * Creates a new event filter, adding it to this request
+   *
+   * @param  filter  the filter to add
+   * @throws JdwpIllegalArgumentException if an invalid or illegal filter
+   *         is added to the request
+   */
+  public void addFilter (IEventFilter filter)
+    throws JdwpIllegalArgumentException
+  {
+    // Check validity of filter for this request
+    boolean valid = true;
+
+    Class clazz = filter.getClass ();
+    if (clazz == ClassExcludeFilter.class)
+      {
+	if (_kind == EVENT_THREAD_START
+	    || _kind == EVENT_THREAD_END)
+	  valid = false;
+      }
+    else if (clazz == ClassMatchFilter.class)
+      {
+	if (_kind == EVENT_THREAD_START
+	    || _kind == EVENT_THREAD_END)
+	  valid = false;
+      }
+    else if (clazz == ClassOnlyFilter.class)
+      {
+	if (_kind == EVENT_CLASS_UNLOAD
+	    || _kind == EVENT_THREAD_START
+	    || _kind == EVENT_THREAD_END)
+	  valid = false;
+      }
+    else if (clazz == ConditionalFilter.class)
+      {
+	// JDWP 1.4 does not say much about this
+      }
+    else if (clazz == CountFilter.class)
+      {
+	// may be used with any event
+      }
+    else if (clazz == ExceptionOnlyFilter.class)
+      {
+	if (_kind != EVENT_EXCEPTION)
+	  valid = false;
+      }
+    else if (clazz == FieldOnlyFilter.class)
+      {
+	if (_kind != EVENT_FIELD_ACCESS
+	    && _kind != EVENT_FIELD_MODIFY)
+	  valid = false;
+      }
+    else if (clazz == InstanceOnlyFilter.class)
+      {
+	if (_kind == EVENT_CLASS_PREPARE
+	    || _kind == EVENT_CLASS_UNLOAD
+	    || _kind == EVENT_THREAD_START
+	    || _kind == EVENT_THREAD_END)
+	  valid = false;
+      }
+    else if (clazz == LocationOnlyFilter.class)
+      {
+	if (_kind != EVENT_BREAKPOINT
+	    && _kind != EVENT_FIELD_ACCESS
+	    && _kind != EVENT_FIELD_MODIFY
+	    && _kind != EVENT_SINGLE_STEP
+	    && _kind != EVENT_EXCEPTION)
+	  valid = false;
+      }
+    else if (clazz == StepFilter.class)
+      {
+	if (_kind != EVENT_SINGLE_STEP)
+	  valid = false;
+      }
+    else if (clazz == ThreadOnlyFilter.class)
+      {
+	if (_kind == EVENT_CLASS_UNLOAD)
+	  valid = false;
+      }
+
+    if (!valid)
+      {
+	String msg = ("cannot use " + filter.getClass ().getName ()
+		      + " with class unload events");
+	throw new JdwpIllegalArgumentException (msg);
+      }
+
+    // Add filter to list
+    _filters.add (filter);
+  }
+
+  /**
+   * Returns the filters attached to this request
+   */
+  public Collection getFilters ()
+  {
+    return _filters;
+  }
+
+  /**
+   * Returns the suspend policy for this request
+   */
+  public byte getSuspendPolicy ()
+  {
+    return _suspendPolicy;
+  }
+
+  /**
+   * Returns the request id of this request
+   */
+  public int getId ()
+  {
+    return _id;
+  }
+
+  /**
+   * Sets the id of the request (used for auto-generated events)
+   */
+  public void setId (int id)
+  {
+    _id = id;
+  }
+
+  /**
+   * Returns the kind of event for this request
+   */
+  public byte getEventKind ()
+  {
+    return _kind;
+  }
+
+  /**
+   * Determines whether the given event matches this request
+   *
+   * @param  theEvent  the event to compare to
+   */
+  public boolean matches (Event theEvent)
+  {
+    boolean matches = true;
+
+    // Loop through filters; all must match
+    // Note that we must allow EVERY filter to evaluate. This way
+    // things like CountFilter will work.
+    Iterator iter = _filters.iterator ();
+    while (iter.hasNext ())
+      {
+	IEventFilter filter = (IEventFilter) iter.next ();
+	if (!filter.matches (theEvent))
+	  matches = false;
+      }
+
+    return matches;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/ExceptionEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/ExceptionEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,157 @@
+/* ExceptionEvent.java -- an event specifying an exception has been thrown
+ 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.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Notification from the VM that an exception has occurred along with where it
+ * occurred, and if and where it was caught.
+ * 
+ * @author Kyle Galloway (kgallowa at redhat.com)
+ */
+public class ExceptionEvent
+    extends Event
+{
+  //object instance
+  private Object _instance;
+  
+  // the exception thrown
+  private Throwable _exception;
+
+  // the thread in which the exception occurred
+  private Thread _thread;
+
+  // the location where the exception was thrown
+  private Location _location;
+  
+  //the location where the exception was caught
+  private Location _catchLocation;
+  
+  //the class where the exeption was thrown
+  private Class _klass;
+
+  /**
+   * Constructs a new <code>ExceptionEvent</code> where the exception was
+   * caught.
+   * 
+   * @param exception the throwable object that generated the event
+   * @param thread the thread where the exception occurred
+   * @param location the location where the exception was thrown
+   * @param catchLocation the location where the exception was caught
+   * @param instance the instance that threw the exception
+   */
+  public ExceptionEvent(Throwable exception, Thread thread, Location location,
+                        Location catchLocation, Class clazz, Object instance)
+  {
+    super(JdwpConstants.EventKind.EXCEPTION);
+    _exception = exception;
+    _thread = thread;
+    _location = location;
+    _catchLocation = catchLocation;
+    _klass = clazz;
+    _instance = instance;
+  }
+
+  /**
+   * Returns a specific filtering parameter for this event. Valid types are
+   * thread, location, and catchLocation.
+   * 
+   * @param type the type of parameter desired
+   * @returns the desired parameter or null
+   */
+  public Object getParameter(int type)
+  {
+    if (type == EVENT_THREAD)
+      return _thread;
+    else if (type == EVENT_LOCATION)
+      return _location;
+    else if (type == EVENT_INSTANCE)
+      return _instance;
+    else if (type == EVENT_CLASS)
+      return _klass;
+    else if (type == EVENT_EXCEPTION_CLASS)
+      return _exception.getClass();
+    else if (type == EVENT_EXCEPTION_CAUGHT)
+      if (_catchLocation.getMethod() != null)
+        return new Boolean(true);
+      else
+        return new Boolean(false);
+
+    return null;
+  }
+  
+  /**
+   * Sets the catchLocation, used for exceptions that are caught in different
+   * stack frames from where they are thrown.
+   * 
+   * @param catchLoc the location of the catch
+   */
+  public void setCatchLoc(Location catchLoc)
+  {
+    _catchLocation = catchLoc;
+  }
+
+  /**
+   * Writes the event to the given stream
+   * 
+   * @param outStream the output stream to write the event to
+   * @throws IOException
+   */
+  protected void _writeData(DataOutputStream outStream) 
+    throws IOException
+  {
+    VMIdManager idm = VMIdManager.getDefault();
+    ThreadId tid = (ThreadId) idm.getObjectId(_thread);
+    ObjectId oid = idm.getObjectId(_exception);
+
+    tid.write(outStream);
+    _location.write(outStream);
+    oid.writeTagged(outStream);
+    _catchLocation.write(outStream);
+
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/MethodEntryEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/MethodEntryEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,118 @@
+/* MethodEntryEvent.java -- an event specifying that a method has been invoked
+ 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.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Notification from the VM that that a method has been invoked
+ * 
+ * @author Kyle Galloway (kgallowa at redhat.com)
+ */
+public class MethodEntryEvent
+    extends Event
+{
+  // The thread where the event occurred
+  private Thread _thread;
+
+  // the location where the event occurred
+  private Location _location;
+
+  //object instance
+  private Object _instance;
+
+  /**
+   * Constructs a new <code>MethodEntryEvent</code>
+   * 
+   * @param thread the thread where the exception occurred
+   * @param location the location single stepped to
+   * @param instance instance from which the method was called
+   */
+  public MethodEntryEvent(Thread thread, Location location, Object instance)
+  {
+    super(JdwpConstants.EventKind.METHOD_ENTRY);
+    _thread = thread;
+    _location = location;
+    _instance = instance;
+  }
+
+  /**
+   * Returns a specific filtering parameter for this event. Valid types are
+   * thread and location
+   * 
+   * @param type the type of parameter desired
+   * @returns the desired parameter or null
+   */
+  public Object getParameter(int type)
+  {
+    if (type == EVENT_THREAD)
+      return _thread;
+    else if (type == EVENT_LOCATION)
+      return _location;
+    else if (type == EVENT_INSTANCE)
+      return _instance;
+    else if (type == EVENT_CLASS)
+      return _instance.getClass();
+
+    return null;
+  }
+
+  /**
+   * Writes the event to the given stream
+   * 
+   * @param outStream the output stream to write the event to
+   * @throws IOException
+   */
+  protected void _writeData(DataOutputStream outStream) 
+    throws IOException
+  {
+    VMIdManager idm = VMIdManager.getDefault();
+    ThreadId tid = (ThreadId) idm.getObjectId(_thread);
+
+    tid.write(outStream);
+    _location.write(outStream);
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/MethodExitEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/MethodExitEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,115 @@
+/* MethodExitEvent.java -- an event specifying that a method has returned
+ 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.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Notification from the VM that that a method has returned
+ * 
+ * @author Kyle Galloway (kgallowa at redhat.com)
+ */
+public class MethodExitEvent
+    extends Event
+{
+  // The thread where the event occurred
+  private Thread _thread;
+
+  // the location where the event occurred
+  private Location _location;
+
+  // object instance
+  private Object _instance;
+
+  /**
+   * Constructs a new <code>MethodExitEvent</code>
+   * 
+   * @param thread the thread where the exception occurred
+   * @param location the location single stepped to
+   * @param instance the instance from which the method was called
+   */
+  public MethodExitEvent(Thread thread, Location location, Object instance)
+  {
+    super(JdwpConstants.EventKind.METHOD_EXIT);
+    _thread = thread;
+    _location = location;
+    _instance = instance;
+  }
+
+  /**
+   * Returns a specific filtering parameter for this event. Valid types are
+   * thread and location
+   * 
+   * @param type the type of parameter desired
+   * @returns the desired parameter or null
+   */
+  public Object getParameter(int type)
+  {
+    if (type == EVENT_THREAD)
+      return _thread;
+    else if (type == EVENT_LOCATION)
+      return _location;
+    else if (type == EVENT_CLASS)
+      return _instance.getClass();
+
+    return null;
+  }
+
+  /**
+   * Writes the event to the given stream
+   * 
+   * @param outStream the output stream to write the event to
+   * @throws IOException
+   */
+  protected void _writeData(DataOutputStream outStream) 
+    throws IOException
+  {
+    VMIdManager idm = VMIdManager.getDefault();
+    ThreadId tid = (ThreadId) idm.getObjectId(_thread);
+
+    tid.write(outStream);
+    _location.write(outStream);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/SingleStepEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/SingleStepEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,121 @@
+/* SingleStepEvent.java -- an event specifying that a single step has
+ compleated
+ 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.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+
+/**
+ * Notification from the VM that a single step has compleated including the
+ * thread and location stepped to
+ * 
+ * @author Kyle Galloway (kgallowa at redhat.com)
+ */
+public class SingleStepEvent
+    extends Event
+{
+  // the thread where the event occurred
+  private Thread _thread;
+
+  // the location where the event occurred
+  private Location _location;
+
+  //object instance
+  private Object _instance;
+
+  /**
+   * Constructs a new <code>SingleStepEvent</code>
+   * 
+   * @param thread the thread where the exception occurred
+   * @param location the location single stepped to
+   * @param instance the instance in which the single step occurred
+   */
+  public SingleStepEvent(Thread thread, Location location, Object instance)
+  {
+    super(JdwpConstants.EventKind.SINGLE_STEP);
+    _thread = thread;
+    _location = location;
+    _instance = instance;
+  }
+
+  /**
+   * Returns a specific filtering parameter for this event. Valid types are
+   * thread and location
+   * 
+   * @param type the type of parameter desired
+   * @returns the desired parameter or null
+   */
+  public Object getParameter(int type)
+  {
+    if (type == EVENT_THREAD)
+      return _thread;
+    else if (type == EVENT_LOCATION)
+      return _location;
+    else if (type == EVENT_INSTANCE)
+      return _instance;
+    else if (type == EVENT_CLASS)
+      return _instance.getClass();
+
+    return null;
+  }
+
+  /**
+   * Writes the event to the given stream
+   * 
+   * @param outStream the output stream to write the event to
+   * @throws IOException
+   */
+  protected void _writeData(DataOutputStream outStream) 
+    throws IOException
+  {
+    VMIdManager idm = VMIdManager.getDefault();
+    ThreadId tid = (ThreadId) idm.getObjectId(_thread);
+
+    tid.write(outStream);
+    _location.write(outStream);
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,105 @@
+/* ThreadEndEvent.java -- An event specifying that a thread has died
+   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
+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.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ThreadId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * "Notification of a completed thread in the target VM. The notification
+ * is generated by the dying thread before it terminates. Because of this
+ * timing, it is possible for VirtualMachine.allThreads to return this
+ * thread after this event is received.
+ *
+ * <p>Note that this event gives no information about the lifetime of the
+ * thread object. It may or may not be collected soon depending on what
+ * references exist in the target VM." -- JDWP 1.4.2
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class ThreadEndEvent
+  extends Event
+{
+  private Thread _thread;
+
+  /**
+   * Constructs a new <code>ThreadEndEvent</code>
+   *
+   * @param thread  the deceased thread
+   */
+  public ThreadEndEvent (Thread thread)
+  {
+    super (JdwpConstants.EventKind.THREAD_END);
+    _thread = thread;
+  }
+
+  /**
+   * Returns a specific filtering parameter for this event.
+   * Valid types are ThreadId.
+   *
+   * @param type  the type of parameter desired
+   * @returns the desired parameter or <code>null</code>
+   */
+  public Object getParameter (int type)
+  {
+    if (type == EVENT_THREAD)
+      return _thread;
+
+    return null;
+  }
+
+  /**
+   * Writes the event to the given stream
+   *
+   * @param outStream  the output stream to write the event to
+   */
+  protected void _writeData (DataOutputStream outStream)
+    throws IOException
+  {
+    VMIdManager idm = VMIdManager.getDefault();
+    ThreadId tid = (ThreadId) idm.getObjectId (_thread);
+    tid.write (outStream);
+  }
+}
+

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,109 @@
+/* ThreadStartEvent.java -- An event specifying that a new thread
+   has started in the virtual machine
+   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
+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.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ThreadId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * "Notification of a new running thread in the target VM. The new
+ * thread can be the result of a call to {@link java.lang.Thread#start} or
+ * the result of attaching a new thread to the VM though JNI. The
+ * notification is generated by the new thread some time before its
+ * execution starts. Because of this timing, it is possible to receive
+ * other events for the thread before this event is received. (Notably,
+ * Method Entry Events and Method Exit Events might occur during thread
+ * initialization. It is also possible for the VirtualMachine AllThreads
+ * command to return a thread before its thread start event is received.
+ *
+ * <p>Note that this event gives no information about the creation of the
+ * thread object which may have happened much earlier, depending on the
+ * VM being debugged." -- JDWP 1.4.2
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class ThreadStartEvent
+  extends Event
+{
+  private Thread _thread;
+
+  /**
+   * Constructs a new ThreadStartEvent object
+   *
+   * @param thread  the thread ID in which event occurred
+   */
+  public ThreadStartEvent (Thread thread) {
+    super (JdwpConstants.EventKind.THREAD_END);
+    _thread = thread;
+  }
+
+  /**
+   * Returns a specific filtering parameter for this event.
+   * Valid types are ThreadId.
+   *
+   * @param type  the type of parameter desired
+   * @returns the desired parameter or <code>null</code>
+   */
+  public Object getParameter (int type)
+  {
+    if (type == EVENT_THREAD)
+      return _thread;
+
+    return null;
+  }
+
+  /**
+   * Writes the event to the given stream
+   *
+   * @param outStream  the output stream to write the event to
+   */
+  protected void _writeData (DataOutputStream outStream)
+    throws IOException
+  {
+    VMIdManager idm = VMIdManager.getDefault();
+    ThreadId tid = (ThreadId) idm.getObjectId (_thread);
+    tid.write (outStream);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/VmDeathEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/VmDeathEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,83 @@
+/* VmDeathEvent.java -- An event specifying that the VM has terminated
+   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
+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.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Event notifying the debugger that the virtual machine has terminated.
+ * 
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class VmDeathEvent
+  extends Event
+{
+  /**
+   * Constructs a new VmDeathEvent object
+   */
+  public VmDeathEvent ()
+  {
+    super (JdwpConstants.EventKind.VM_DEATH);
+  }
+
+  /**
+   * Returns a specific filtering parameter for this event.
+   * This event has no valid types.
+   *
+   * @param type  the type of parameter desired
+   * @returns the desired parameter or <code>null</code>
+   */
+  public Object getParameter (int type)
+  {
+    return null;
+  }
+
+  /**
+   * Writes out event-specific data
+   */
+  protected void _writeData (DataOutputStream outStream)
+    throws IOException
+  {
+    // no data (request ID done by VMIdManager)
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/VmInitEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/VmInitEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,94 @@
+/* VmInitEvent.java -- An event specifying that the VM has started
+   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
+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.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ThreadId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * "Notification of initialization of a target VM. This event is
+ * received before the main thread is started and before any application
+ * code has been executed." -- JDWP 1.4.2
+ * 
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class VmInitEvent
+  extends Event
+{
+  private Thread _initialThread;
+
+  /**
+   * Constructs a <code>VmInitEvent</code> object
+   *
+   * @param thread  the initial thread
+   */
+  public VmInitEvent (Thread thread)
+  {
+    super (JdwpConstants.EventKind.VM_INIT);
+    _initialThread = thread;
+  }
+
+  /**
+   * Returns a specific filtering parameter for this event.
+   * This event has no valid types.
+   *
+   * @param type  the type of parameter desired
+   * @returns the desired parameter or <code>null</code>
+   */
+  public Object getParameter (int type)
+  {
+    return null;
+  }
+
+  /**
+   * Writes out event-specific data
+   */
+  protected void _writeData (DataOutputStream outStream)
+    throws IOException
+  {
+    VMIdManager idm = VMIdManager.getDefault();
+    ThreadId tid = (ThreadId) idm.getObjectId (_initialThread);
+    tid.write (outStream);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassExcludeFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassExcludeFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* ClassExcludeFilter.java -- filter on class name (exclusive)
+   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
+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.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidStringException;
+
+/**
+ * An event filter which excludes events matching a 
+ * specified class pattern (exact match or start/end with "*").
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class ClassExcludeFilter
+  extends ClassMatchFilter
+{
+  /**
+   * Constructs a new <code>ClassExcludeFilter</code>
+   *
+   * @param  pattern  the pattern to use
+   * @throws InvalidStringException  if pattern is invalid
+   */
+  public ClassExcludeFilter (String pattern)
+    throws InvalidStringException
+  {
+    super (pattern);
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    return !super.matches (event);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,112 @@
+/* ClassMatchFilter.java -- filter on class name (inclusive)
+   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
+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.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidStringException;
+
+/**
+ * An event filter which includes events matching a 
+ * specified class pattern (exact match or start/end with "*").
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class ClassMatchFilter
+  implements IEventFilter
+{
+  // Pattern to match
+  private String _pattern;
+
+  /**
+   * Constructs a new <code>ClassMatchFilter</code>
+   *
+   * @param  pattern  the pattern to use
+   * @throws InvalidStringException  if pattern is invalid
+   */
+  public ClassMatchFilter (String pattern)
+    throws InvalidStringException
+  {
+    int index = pattern.indexOf ('*');
+    if (index != -1 && index != 0 && index != (pattern.length () - 1))
+      {
+	// '*' must be first char or last char
+	throw new InvalidStringException ("pattern may be an exact match or "
+					  + "start/end with \"*\"");
+      }
+    _pattern = pattern;
+  }
+
+  /**
+   * Returns the pattern to be matched
+   *
+   * @return the pattern
+   */
+  public String getPattern ()
+  {
+    return _pattern;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    Object type = event.getParameter (Event.EVENT_CLASS);
+    if (type != null)
+      {
+	Class eventClass = (Class) type;
+	String name = eventClass.getName ();
+	
+	if (_pattern.startsWith ("*"))
+	  return name.endsWith (_pattern.substring (1));
+	else if (_pattern.endsWith ("*"))
+	  {
+	    int end = _pattern.length () - 1;
+	    return name.startsWith (_pattern.substring (0, end));
+	  }
+	else
+	  return name.matches (_pattern);
+      }
+
+    return false;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,109 @@
+/* ClassOnlyFilter.java -- filter on specific class
+   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
+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.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+/**
+ * An event filter which filters out events in uninteresting
+ * classes.
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class ClassOnlyFilter
+  implements IEventFilter
+{
+  // Class ID for which to filter
+  private ReferenceTypeId _id;
+
+  /**
+   * Constructs a new <code>ClassOnlyFilter</code>
+   *
+   * @param refId  the reference type id for a class for which events
+   *               will be reported
+   * @throws InvalidClassException if the ID is no longer valid
+   */
+  public ClassOnlyFilter (ReferenceTypeId refId)
+    throws InvalidClassException
+  {
+    // validity check
+    refId.getType ();
+    _id = refId;
+  }
+
+  /**
+   * Returns the class to which to restrict events
+   *
+   * @return the class's ID
+   */
+  public ReferenceTypeId getType ()
+  {
+    return _id;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    Object type = event.getParameter (Event.EVENT_CLASS);
+    if (type != null)
+      {
+	try
+	  {
+	    Class clazz = _id.getType ();
+	    Class eventClass = (Class) type;
+	    if (clazz.isAssignableFrom (eventClass))
+	      return true;
+	  }
+	catch (InvalidClassException ice)
+	  {
+	    // class is no longer valid
+	    return false;
+	  }
+      }
+
+    return false;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/ConditionalFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/ConditionalFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,82 @@
+/* ConditionalFilter.java -- conditional expression filter
+   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
+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.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+
+/**
+ * An event filter which allows expression conditionals.
+ * Note that in JDWP 1.4, this class is marked "for the
+ * future".
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class ConditionalFilter
+  implements IEventFilter
+{
+  // private ConditionalId _exprId;
+
+  /**
+   * Constructs a new <code>ConditionalFilter</code> with the
+   * given conditional.
+   *
+   * <p><b>NOTE:</b> This filter is marked "for the future",
+   * i.e, there is no way to actually use this yet.
+   *
+   * @param  conditional  the conditional expression
+   * @throws NotImplementedException if used
+   */
+  public ConditionalFilter (Object conditional)
+    throws NotImplementedException
+  {
+    throw new NotImplementedException ("conditional filters");
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    return false;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/CountFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/CountFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,95 @@
+/* CountFilter.java -- a step filter
+   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
+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.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidCountException;
+
+/**
+ * An ignore count filter.
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class CountFilter
+  implements IEventFilter
+{
+  // the count
+  private int _count;
+
+  /**
+   * Constructs a new <code>CountFilter</code> with the given count.
+   *
+   * @param  count  the number of times the event will be ignored
+   * @throws InvalidCountException if count is invalid (< 1)
+   */
+  public CountFilter (int count)
+    throws InvalidCountException
+  {
+    // Check for valid count
+    if (count < 1)
+      throw new InvalidCountException (count);
+
+    _count = count;
+  }
+
+  /**
+   * Returns the ignore count
+   *
+   * @return the number of times the event should be ignored
+   */
+  public int getCount ()
+  {
+    return _count;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    // This filter only relies on its count
+    if (--_count == 0)
+      return true;
+
+    return false;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,123 @@
+/* ExceptionOnlyFilter.java -- filter for excetions by caught/uncaught and type
+   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.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+/**
+ * Restricts reported exceptions by their class and whether they are caught
+ * or uncaught.
+ * 
+ * This modifier can be used with exception event kinds only.
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class ExceptionOnlyFilter
+  implements IEventFilter
+{
+  private ReferenceTypeId _refId;
+  private boolean _caught;
+  private boolean _uncaught;
+
+  /**
+   * Constructs a new ExceptionOnlyFilter
+   *
+   * @param  refId     ID of the exception to report(null for all exceptions)
+   * @param  caught    Report caught exceptions
+   * @param  uncaught  Report uncaught exceptions
+   * @throws InvalidClassException if refid is invalid
+   */
+  public ExceptionOnlyFilter (ReferenceTypeId refId, boolean caught,
+			      boolean uncaught)
+    throws InvalidClassException
+  {
+    if (refId != null && refId.getReference().get() == null)
+      throw new InvalidClassException(refId.getId());
+
+    _refId = refId;
+    _caught = caught;
+    _uncaught = uncaught;
+  }
+
+  /**
+   * Returns the exception class to report (<code>null</code> for all)
+   *
+   * @return the class's ID
+   */
+  public ReferenceTypeId getType ()
+  {
+    return _refId;
+  }
+
+  
+  /**
+   * Does the given event match the filter?
+   * 
+   * @param event the <code>Event</code> to scrutinize
+   */
+  public boolean matches(Event event)
+  {
+    boolean classMatch = true;
+
+    // if not allowing all exceptions check if the exception matches
+    if (_refId != null)
+      {
+        try
+          {
+            Class klass 
+              = (Class) event.getParameter(Event.EVENT_EXCEPTION_CLASS);
+            classMatch = klass == _refId.getType();
+          }
+        catch (InvalidClassException ex)
+          {
+            classMatch = false;
+          }
+      }
+    
+    // check against the caught and uncaught options
+    Boolean caught 
+      = (Boolean) event.getParameter(Event.EVENT_EXCEPTION_CAUGHT);
+
+    return classMatch && ((caught.booleanValue()) ? _caught : _uncaught);
+  }
+  
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/FieldOnlyFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/FieldOnlyFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,112 @@
+/* FieldOnlyFilter.java -- filter on field
+   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
+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.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.exception.InvalidFieldException;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+/**
+ * Restricts reported events to those that occur for a given field.
+ * 
+ * This modifier can be used with field access and field modification event
+ * kinds only.
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class FieldOnlyFilter
+  implements IEventFilter
+{
+  private ReferenceTypeId _refId;
+  private ReferenceTypeId _fieldId;
+
+  /**
+   * Constructs a new <code>FieldOnlyFilter</code>.
+   *
+   * @param  refId  class for field
+   * @param  fid    field
+   * @throws InvalidClassException if class is invalid
+   * @throws InvalidFieldException if field is invalid
+   */
+  public FieldOnlyFilter (ReferenceTypeId refId, /*Field*/ReferenceTypeId fid)
+    throws InvalidClassException, InvalidFieldException
+  {
+    if (refId == null || refId.getReference().get () == null)
+      throw new InvalidClassException (refId.getId ());
+
+    if (fid == null)
+      throw new InvalidFieldException (fid.getId ());
+
+    _refId = refId;
+    _fieldId = fid;
+  }
+
+  /**
+   * Returns the class in which the field is declared 
+   *
+   * @return the class's id
+   */
+  public ReferenceTypeId getType ()
+  {
+    return _refId;
+  }
+
+  /**
+   * Returns the field for which to restrict events
+   *
+   * @return the field's id
+   */
+  public ReferenceTypeId getField ()
+  {
+    return _fieldId;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    // FIXME
+    throw new RuntimeException ("FieldOnlyFilter.matches not implemented");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/IEventFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/IEventFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* IEventFilter.java -- an interface for event filters
+   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
+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.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+
+/**
+ * An interface for event filters. The debugger registers an event
+ * filter for a given event when it is interested in receiving
+ * notifications about that event from the VM.
+ *
+ * <p>Filters are attached to {@link gnu.classpath.jdwp.event.EventRequest}s
+ * in order to allow the debugger to specify that an event should be sent
+ * only when the filters for the event request all match.
+ *
+ * <p>No filters means "send all notifications".
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public interface IEventFilter
+{
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event);
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,101 @@
+/* InstanceOnlyFilter.java -- filter on instance
+   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
+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.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.id.ObjectId;
+
+/**
+ * Restricts reported events to those whose active 'this' object is the
+ * given object. Match value is the null object for static methods.
+ * 
+ * This modifier can be used with any event kind except class prepare,
+ * class unload, thread start, and thread end. Introduced in JDWP version 1.4.
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class InstanceOnlyFilter
+  implements IEventFilter
+{
+  private ObjectId _instance;
+
+  /**
+   * Constructs a new <code>InstanceOnlyFilter</code>.
+   *
+   * @param  oid  the object to which to restrict events (may be null)
+   * @throws InvalidObjectException if Object is invalid
+   */
+  public InstanceOnlyFilter (ObjectId oid)
+    throws InvalidObjectException
+  {
+    if (oid != null && oid.getReference().get () == null)
+      throw new InvalidObjectException (oid.getId ());
+
+    _instance = oid;
+  }
+
+  /**
+   * Returns the instance to which to restrict events
+   *
+   * @return the object's ID
+   */
+  public ObjectId getInstance ()
+  {
+    return _instance;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    Object eventInstance = event.getParameter (Event.EVENT_INSTANCE);
+    if (eventInstance != null)
+      {
+	Object myInstance = _instance.getReference().get ();
+	return ((myInstance != null) && (myInstance == eventInstance));
+      }
+
+    return false;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/LocationOnlyFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/LocationOnlyFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,98 @@
+/* LocationOnlyFilter.java -- filter on location
+   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.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidLocationException;
+import gnu.classpath.jdwp.util.Location;
+
+/**
+ * Restricts reported events to those that occur at the given location.
+ *
+ * May be used with breakpoint, field access, field modification, step,
+ * and exception event kinds.
+ *
+ * This "filter" is not really a filter. It is simply a way to communicate
+ * location information for supported events in a generic way to ease 
+ * the burden of special casing several things in
+ * EventReqeustCommandSet.executeSet.
+ * 
+ * Consequently, this "filter" always matches any event.
+ * 
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class LocationOnlyFilter
+  implements IEventFilter
+{
+  private Location _location;
+
+  /**
+   * Constructs a new <code>LocationOnlyFilter</code>.
+   *
+   * @param  loc  the location for which to report events
+   * @throws InvalidLocationException if location is invalid
+   */
+  public LocationOnlyFilter (Location loc)
+    throws InvalidLocationException
+  {
+    _location = loc;
+  }
+
+  /**
+   * Returns the location at which to restrict events
+   *
+   * @return the location
+   */
+  public Location getLocation ()
+  {
+    return _location;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    // This filter always matches. See comments in class javadoc.
+    return true;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/StepFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/StepFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,121 @@
+/* StepFilter.java -- a step filter
+   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
+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.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidThreadException;
+import gnu.classpath.jdwp.id.ThreadId;
+
+/**
+ * "An event filter which restricts reported step events to those which
+ * satisfy depth and size constraints. This modifier can only be used with
+ * step event kinds."
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class StepFilter
+  implements IEventFilter
+{
+  private ThreadId _tid;
+  private int _size;
+  private int _depth;
+
+  /**
+   * Constructs a new StepFilter
+   *
+   * @param tid    ID of the thread in which to step
+   * @param size   size of each step
+   * @param depth  relative call stack limit
+   * @throws InvalidThreadException if thread is invalid
+   */
+  public StepFilter (ThreadId tid, int size, int depth)
+    throws InvalidThreadException
+  {
+    if (tid.getReference().get () == null)
+      throw new InvalidThreadException (tid.getId ());
+
+    _tid = tid;
+    _size = size;
+    _depth = depth;
+  }
+
+  /**
+   * Returns the thread in which to step
+   *
+   * @return the thread's ID
+   */
+  public ThreadId getThread ()
+  {
+    return _tid;
+  }
+
+  /**
+   * Returns the size of each step (insn, line)
+   *
+   * @return the step size
+   * @see gnu.classpath.jdwp.JdwpConstants.StepSize
+   */
+  public int getSize ()
+  {
+    return _size;
+  }
+
+  /**
+   * Returns the relative call stack limit (into, over, out)
+   *
+   * @return how to step
+   * @see gnu.classpath.jdwp.JdwpConstants.StepDepth
+   */
+  public int getDepth ()
+  {
+    return _depth;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    // FIXME
+    throw new RuntimeException ("StepFilter.matches not implemented");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,101 @@
+/* ThreadOnlyFilter.java -- a thread filter
+   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
+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.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidThreadException;
+import gnu.classpath.jdwp.id.ThreadId;
+
+/**
+ * An event filter which allows only events within a specific
+ * thread
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class ThreadOnlyFilter
+  implements IEventFilter
+{
+  // the thread
+  private ThreadId _tid;
+
+  /**
+   * Constructs a new <code>ThreadOnlyFilter</code> for the given
+   * thread id
+   *
+   * @param tid  ID of the thread on which to filter
+   * @throws InvalidThreadException if the thread is not valid
+   */
+  public ThreadOnlyFilter (ThreadId tid)
+    throws InvalidThreadException
+  {
+    if (tid == null || tid.getReference().get () == null)
+      throw new InvalidThreadException (tid.getId ());
+
+    _tid = tid;
+  }
+
+  /**
+   * Returns the thread in which to restrict events
+   *
+   * @return the thread's ID
+   */
+  public ThreadId getThread ()
+  {
+    return _tid;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    Object thread = event.getParameter (Event.EVENT_THREAD);
+    if (thread != null)
+      {
+	Thread eventThread = (Thread) thread;
+	Thread myThread = (Thread) _tid.getReference().get ();
+	return (eventThread == myThread);
+      }
+
+    return false;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidClassException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidClassException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* InvalidClassException.java -- invalid/unknown class reference id exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown by the JDWP back-end when an invalid reference
+ * type id is used by the debugger.
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class InvalidClassException
+  extends JdwpException
+{
+  public InvalidClassException (long id)
+  {
+    super (JdwpConstants.Error.INVALID_CLASS,
+	   "invalid class id (" + id + ")");
+  }
+
+  public InvalidClassException (Throwable t)
+  {
+    super (JdwpConstants.Error.INVALID_CLASS, t);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidClassLoaderException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidClassLoaderException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,62 @@
+/* InvalidClassLoaderException.java -- an invalid class loader exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when the debugger uses an invalid class loader
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class InvalidClassLoaderException
+  extends JdwpException
+{
+  public InvalidClassLoaderException (long id)
+  {
+    super (JdwpConstants.Error.INVALID_CLASS_LOADER,
+	   "invalid class loader (" + id + ")");
+  }
+
+  public InvalidClassLoaderException (Throwable t)
+  {
+    super (JdwpConstants.Error.INVALID_CLASS_LOADER, t);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidCountException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidCountException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,61 @@
+/* InvalidCountException -- an invalid count exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when a count filter is given an invalid count.
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class InvalidCountException
+  extends JdwpException
+{
+  public InvalidCountException (int id)
+  {
+    super (JdwpConstants.Error.INVALID_COUNT, "invalid count (" + id + ")");
+  }
+
+  public InvalidCountException (Throwable t)
+  {
+    super (JdwpConstants.Error.INVALID_COUNT, t);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidEventTypeException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidEventTypeException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* InvalidEventTypeException.java -- an invalid event kind exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when the debugger asks for an event request
+ * for a non-existant event
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class InvalidEventTypeException
+  extends JdwpException
+{
+  public InvalidEventTypeException (byte kind)
+  {
+    super (JdwpConstants.Error.INVALID_EVENT_TYPE,
+	   "invalid event type (" + kind + ")");
+  }
+
+  public InvalidEventTypeException (Throwable t)
+  {
+    super (JdwpConstants.Error.INVALID_EVENT_TYPE, t);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidFieldException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidFieldException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* InvalidFieldException.java -- an invalid field id exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when an invalid field id is used by the
+ * debugger
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class InvalidFieldException
+  extends JdwpException
+{
+  public InvalidFieldException (long id)
+  {
+    super (JdwpConstants.Error.INVALID_FIELDID,
+	   "invalid field id (" + id + ")");
+  }
+
+  public InvalidFieldException (Throwable t)
+  {
+    super (JdwpConstants.Error.INVALID_FIELDID, t);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidLocationException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidLocationException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,62 @@
+/* InvalidLocationException.java -- an invalid location exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when the debugger specifies an invalid location
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class InvalidLocationException
+  extends JdwpException
+{
+  public InvalidLocationException (/*something*/)
+  {
+    super (JdwpConstants.Error.INVALID_LOCATION,
+	   "invalid location (" + "something" + ")");
+  }
+
+  public InvalidLocationException (Throwable t)
+  {
+    super (JdwpConstants.Error.INVALID_LOCATION, t);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidMethodException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidMethodException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* InvalidMethodException.java -- an invalid method id exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when an invalid method id is used
+ * by the debugger
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class InvalidMethodException
+  extends JdwpException
+{
+  public InvalidMethodException (long id)
+  {
+    super (JdwpConstants.Error.INVALID_METHODID,
+	   "invalid method id (" + id + ")");
+  }
+
+  public InvalidMethodException (Throwable t)
+  {
+    super (JdwpConstants.Error.INVALID_METHODID, t);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidObjectException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidObjectException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* InvalidObjectException.java -- an invalid object id exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when an invalid object id is used by
+ * the debugger
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class InvalidObjectException
+  extends JdwpException
+{
+  public InvalidObjectException (long id)
+  {
+    super (JdwpConstants.Error.INVALID_OBJECT,
+	   "invalid object id (" + id + ")");
+  }
+
+  public InvalidObjectException (Throwable t)
+  {
+    super (JdwpConstants.Error.INVALID_OBJECT, t);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidStringException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidStringException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,68 @@
+/* InvalidStringException.java -- an invalid string exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when the debugger uses an invalid String.
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class InvalidStringException
+  extends JdwpException
+{
+  public InvalidStringException (String str)
+  {
+    super (JdwpConstants.Error.INVALID_STRING,
+	   "invalid string (" + str + ")");
+  }
+
+  public InvalidStringException (long id)
+  {
+    super (JdwpConstants.Error.INVALID_STRING,
+	   "invalid string id (" + id + ")");
+  }
+
+  public InvalidStringException (Throwable t)
+  {
+    super (JdwpConstants.Error.INVALID_STRING, t);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidThreadException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidThreadException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* InvalidThreadException.java -- an invalid thread exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when an invalid thread is used
+ * by the debugger
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class InvalidThreadException
+  extends JdwpException
+{
+  public InvalidThreadException (long id)
+  {
+    super (JdwpConstants.Error.INVALID_THREAD,
+	   "invalid thread id (" + id + ")");
+  }
+
+  public InvalidThreadException (Throwable t)
+  {
+    super (JdwpConstants.Error.INVALID_THREAD, t);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidThreadGroupException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/InvalidThreadGroupException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* InvalidThreadGroupException.java -- an invalid thread group exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when an invalid thread group is used
+ * by the debugger
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class InvalidThreadGroupException
+  extends JdwpException
+{
+  public InvalidThreadGroupException (long id)
+  {
+    super (JdwpConstants.Error.INVALID_THREAD_GROUP,
+	   "invalid thread group id (" + id + ")");
+  }
+
+  public InvalidThreadGroupException (Throwable t)
+  {
+    super (JdwpConstants.Error.INVALID_THREAD_GROUP, t);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/JdwpException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/JdwpException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,86 @@
+/* JdwpException.java -- an exception base class for all JDWP exceptions
+   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
+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.exception;
+
+/**
+ * A base class exception for all JDWP back-end exceptions
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class JdwpException
+  extends Exception
+{
+  // The integer error code defined by JDWP
+  private short _errorCode;
+
+  /**
+   * Constructs a new <code>JdwpException</code> with the
+   * given error code and given cause
+   *
+   * @param code  the JDWP error code
+   * @param t     the cause of the exception
+   */
+  public JdwpException (short code, Throwable t)
+  {
+    super (t);
+    _errorCode = code;
+  }
+
+  /**
+   * Constructs a new <code>JdwpException</code> with the
+   * given error code and string error message
+   *
+   * @param code  the JDWP error code
+   * @param str   an error message
+   */
+  public JdwpException (short code, String str)
+  {
+    super (str);
+    _errorCode = code;
+  }
+
+  /**
+   * Returns the JDWP error code represented by this exception
+   */
+  public short getErrorCode ()
+  {
+    return _errorCode;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/JdwpIllegalArgumentException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/JdwpIllegalArgumentException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,62 @@
+/* JdwpIllegalArgumentException.java -- an illegal argument exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An illegal argument exception for JDWP.
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class JdwpIllegalArgumentException
+  extends JdwpException
+{
+  /**
+   * Constructs a new <code>JdwpIllegalArgumentException</code> with
+   * the given error code and given cause
+   *
+   * @param msg  a message explaining the illegal argument
+   */
+  public JdwpIllegalArgumentException (String msg)
+  {
+    super (JdwpConstants.Error.ILLEGAL_ARGUMENT, msg);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/JdwpInternalErrorException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/JdwpInternalErrorException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,62 @@
+/* JdwpInternalErrorException.java -- an internal error exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown by the JDWP back-end when an unusual runtime
+ * error occurs internally
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class JdwpInternalErrorException
+  extends JdwpException
+{
+  public JdwpInternalErrorException(Throwable cause)
+  {
+    super(JdwpConstants.Error.INTERNAL, cause);
+  }
+
+  public JdwpInternalErrorException(String msg)
+  {
+    super(JdwpConstants.Error.INTERNAL, msg);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/NativeMethodException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/NativeMethodException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* NativeMethodException.java -- a native method exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when the debugger attempts to invoke
+ * an unsupported command on a native method (like setting a breakpoint).
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class NativeMethodException
+  extends JdwpException
+{
+  public NativeMethodException(long id)
+  {
+    super(JdwpConstants.Error.NATIVE_METHOD,
+	   "invalid method id (" + id + ")");
+  }
+
+  public NativeMethodException(Throwable t)
+  {
+    super(JdwpConstants.Error.NATIVE_METHOD, t);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/NotImplementedException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/NotImplementedException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,58 @@
+/* NotImplementedException.java -- an exception for unimplemented JDWP
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown by virtual machines when functionality
+ * or features are not implemented
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class NotImplementedException
+  extends JdwpException
+{
+  public NotImplementedException (String feature)
+  {
+    super (JdwpConstants.Error.NOT_IMPLEMENTED,
+	   feature + " is not yet implemented");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/VmDeadException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/exception/VmDeadException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* VmDeadException.java -- dead virtual machine exception
+   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
+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.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when the virtual machine is dead
+ *
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class VmDeadException
+  extends JdwpException
+{
+  public VmDeadException ()
+  {
+    super (JdwpConstants.Error.VM_DEAD, "Virtual machine is dead");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ArrayId.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ArrayId.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,62 @@
+/* ArrayId.java -- array object IDs
+   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
+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.id;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * A class which represents a JDWP array id
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class ArrayId
+  extends ObjectId
+{
+  // Arrays are handled a little differently than other IDs
+  //public static final Class typeClass = UNDEFINED
+
+  /**
+   * Constructs a new <code>ArrayId</code>
+   */
+  public ArrayId ()
+  {
+    super (JdwpConstants.Tag.ARRAY);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ArrayReferenceTypeId.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ArrayReferenceTypeId.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* ArrayReferenceTypeId.java -- array reference type ids
+   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
+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.id;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * A reference type ID representing java arrays
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class ArrayReferenceTypeId
+  extends ReferenceTypeId
+{
+  /**
+   * Constructs a new <code>ArrayReferenceTypeId</code>
+   */
+  public ArrayReferenceTypeId ()
+  {
+    super (JdwpConstants.TypeTag.ARRAY);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ClassLoaderId.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ClassLoaderId.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,82 @@
+/* ClassLoaderId.java -- class loader IDs
+   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
+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.id;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.InvalidClassLoaderException;
+
+/**
+ * A class which represents a JDWP thread id
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class ClassLoaderId
+  extends ObjectId
+{
+  /**
+   * The object class that this id represents
+   */
+  public static final Class typeClass = ClassLoader.class;
+
+  /**
+   * Constructs a new <code>ClassLoaderId</code>
+   */
+  public ClassLoaderId ()
+  {
+    super (JdwpConstants.Tag.CLASS_LOADER);
+  }
+
+  /**
+   * Gets the ClassLoader represented by this ID
+   *
+   * @throws InvalidClassLoaderException if ClassLoader is garbage collected,
+   *           or otherwise invalid
+   */
+  public ClassLoader getClassLoader ()
+    throws InvalidClassLoaderException
+  {
+    ClassLoader cl = (ClassLoader) _reference.get ();
+
+    if (cl == null)
+      throw new InvalidClassLoaderException (getId ());
+
+    return cl;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ClassObjectId.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ClassObjectId.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,82 @@
+/* ClassObjectId.java -- class object IDs
+   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
+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.id;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+
+/**
+ * A class which represents a JDWP class object id
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class ClassObjectId
+  extends ObjectId
+{
+  /**
+   * The object class that this id represents
+   */
+  public static final Class typeClass = Class.class;
+
+  /**
+   * Constructs a new <code>ClassObjectId</code>
+   */
+  public ClassObjectId ()
+  {
+    super (JdwpConstants.Tag.CLASS_OBJECT);
+  }
+
+  /**
+   * Gets the Class object represented by this ID
+   *
+   * @throws InvalidClassException if Class is garbage collected,
+   *           or otherwise invalid
+   */
+  public Class getClassObject ()
+    throws InvalidClassException
+  {
+    Class cl = (Class) _reference.get ();
+
+    if (cl == null)
+      throw new InvalidClassException (getId ());
+
+    return cl;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ClassReferenceTypeId.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ClassReferenceTypeId.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* ClassReferenceTypeId.java -- class reference type ids
+   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
+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.id;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * A reference type ID representing java classes
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class ClassReferenceTypeId
+  extends ReferenceTypeId
+{
+  /**
+   * Constructs a new <code>ClassReferenceTypeId</code>
+   */
+  public ClassReferenceTypeId ()
+  {
+    super (JdwpConstants.TypeTag.CLASS);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/InterfaceReferenceTypeId.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/InterfaceReferenceTypeId.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* InterfaceReferenceTypeId.java -- interface reference type ids
+   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
+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.id;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * A reference type ID representing java interfaces
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class InterfaceReferenceTypeId
+  extends ReferenceTypeId
+{
+  /**
+   * Constructs a new <code>InterfaceReferenceTypeId</code>
+   */
+  public InterfaceReferenceTypeId ()
+  {
+    super (JdwpConstants.TypeTag.INTERFACE);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/JdwpId.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/JdwpId.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,151 @@
+/* JdwpId.java -- base class for all object ID types
+   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.id;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.ref.SoftReference;
+
+/**
+ * A baseclass for all object types reported to the debugger
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public abstract class JdwpId
+{
+  /**
+   * The size of an ID. The default is 8 bytes (a long).
+   */
+   public static final int SIZE = 8;
+
+  /**
+   * ID assigned to this object
+   */
+  protected long _id;
+
+  /**
+   * Tag of ID's type (see {@link gnu.classpath.jdwp.JdwpConstants.Tag})
+   * for object-like IDs or the type tag (see {@link
+   * gnu.classpath.jdwp.JdwpConstants.TypeTag}) for reference type IDs.
+   */
+  private byte _tag;
+
+  /**
+   * The object/class represented by this Id
+   */
+  protected SoftReference _reference;
+
+  /**
+   * Constructs an empty <code>JdwpId</code>
+   */
+  public JdwpId (byte tag)
+  {
+    _tag = tag;
+  }
+
+  /**
+   * Sets the id for this object reference
+   */
+  public void setId (long id)
+  {
+    _id = id;
+  }
+
+  /**
+   * Returns the id for this object reference
+   */
+  public long getId ()
+  {
+    return _id;
+  }
+
+  /**
+   * Gets the object/class reference for this ID
+   *
+   * @returns a refernce to the object or class
+   */
+  public SoftReference getReference ()
+  {
+    return _reference;
+  }
+
+  /**
+   * Sets the object/class reference for this ID
+   *
+   * @param ref a refernce to the object or class
+   */
+  public void setReference (SoftReference ref)
+  {
+    _reference = ref;
+  }
+
+  /**
+   * Compares two object ids for equality. Two object ids
+   * are equal if they point to the same type and contain to
+   * the same id number. 
+   */
+  public boolean equals (JdwpId id)
+  {
+    return (id.getId () == getId ());
+  }
+
+  /**
+   * Writes the contents of this type to the <code>DataOutputStream</code>
+   * @param  outStream    the <code>DataOutputStream</code> to use
+   * @throws IOException  when an error occurs on the <code>OutputStream</code>
+   */
+  public abstract void write (DataOutputStream outStream)
+    throws IOException;
+
+  /**
+   * Writes the contents of this type to the output stream, preceded
+   * by a one-byte tag for tagged object IDs or type tag for
+   * reference type IDs.
+   *
+   * @param  outStream    the <code>DataOutputStream</code> to use
+   * @throws IOException  when an error occurs on the <code>OutputStream</code>
+   */
+  public void writeTagged (DataOutputStream outStream)
+    throws IOException
+  {
+    outStream.writeByte (_tag);
+    write (outStream);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ObjectId.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ObjectId.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,131 @@
+/* ObjectId.java -- object 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.id;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * This is a base class for all ObjectID-like entities in JDWP,
+ * inculding Objects, ClassObject, ClassLoader, Thread, ThreadGroup,
+ * etc.
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class ObjectId
+  extends JdwpId
+{
+  /**
+   * The object class that this id represents
+   */
+  public static final Class typeClass = Object.class;
+
+  // Handle to disable garbage collection
+  private Object _handle;
+
+  /**
+   * Constructs a new <code>ObjectId</code>
+   */
+  public ObjectId ()
+  {
+    super (JdwpConstants.Tag.OBJECT);
+  }
+
+  /**
+   * Constructs a new <code>ObjectId</code> of the
+   * given type.
+   *
+   * @param  tag  the tag of this type of object ID
+   */
+  public ObjectId (byte tag)
+  {
+    super (tag);
+  }
+
+  /**
+   * Returns the object referred to by this ID
+   *
+   * @returns the object
+   * @throws InvalidObjectException if the object was garbage collected
+   *           or is invalid
+   */
+  public Object getObject ()
+    throws InvalidObjectException
+  {
+    Object obj = _reference.get ();
+    if (obj == null)
+      throw new InvalidObjectException (_id);
+
+    return obj;
+  }
+
+  /**
+   * Writes the id to the stream
+   *
+   * @param outStream  the stream to which to write
+   * @throws IOException  when an error occurs on the <code>OutputStream</code>
+   */
+  public void write (DataOutputStream outStream)
+    throws IOException
+  {
+    // All we need to do is write out our id as an 8-byte integer
+    outStream.writeLong (_id);
+  }
+
+  /**
+   * Disable garbage collection on object
+   */
+  public void disableCollection ()
+    throws InvalidObjectException
+  {
+    _handle = getObject ();
+  }
+
+  /**
+   * Enable garbage collection on object
+   */
+  public void enableCollection ()
+  {
+    _handle = null;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ReferenceTypeId.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ReferenceTypeId.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* ReferenceTypeId.java -- a base class for all 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.id;
+
+import gnu.classpath.jdwp.exception.InvalidClassException;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Base class for reference type IDs. This class usurps
+ * <code>JdwpId</code>'s tag member for its own use (type tag).
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class ReferenceTypeId
+  extends JdwpId
+{
+  /**
+   * Constructor used by {Array,Interface,Class}ReferenceTypeId
+   */
+  public ReferenceTypeId (byte tag)
+  {
+    super (tag);
+  }
+
+  /**
+   * Gets the class associated with this ID
+   *
+   * @returns the class
+   * @throws InvalidClassException if the class is not valid
+   */
+  public Class getType ()
+    throws InvalidClassException
+  {
+    Class clazz = (Class) _reference.get ();
+    if (clazz == null)
+      throw new InvalidClassException (_id);
+
+    return clazz;
+  }
+
+  /**
+   * Outputs the reference type ID to the given output stream
+   *
+   * @param  outStream    the stream to which to write the data
+   * @throws IOException  for errors writing to the stream
+   */
+  public void write (DataOutputStream outStream)
+    throws IOException
+  {
+    outStream.writeLong (_id);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/StringId.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/StringId.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,82 @@
+/* StringId.java -- string IDs
+   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
+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.id;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.InvalidStringException;
+
+/**
+ * A class which represents a JDWP string id
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class StringId
+  extends ObjectId
+{
+  /**
+   * The object class that this id represents
+   */
+  public static final Class typeClass = String.class;
+
+  /**
+   * Constructs a new <code>StringId</code>
+   */
+  public StringId ()
+  {
+    super (JdwpConstants.Tag.STRING);
+  }
+
+  /**
+   * Gets the String represented by this ID
+   *
+   * @throws InvalidStringException if String is garbage collected,
+   *           or otherwise invalid
+   */
+  public String getString ()
+    throws InvalidStringException
+  {
+    String string = (String) _reference.get ();
+
+    if (string == null)
+      throw new InvalidStringException (getId ());
+
+    return string;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ThreadGroupId.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ThreadGroupId.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,82 @@
+/* ThreadGroupId.java -- thread group IDs
+   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
+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.id;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.InvalidThreadGroupException;
+
+/**
+ * A class which represents a JDWP thread group id
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class ThreadGroupId
+  extends ObjectId
+{
+  /**
+   * The object class that this id represents
+   */
+  public static final Class typeClass = ThreadGroup.class;
+
+  /**
+   * Constructs a new <code>ThreadGroupId</code>
+   */
+  public ThreadGroupId ()
+  {
+    super (JdwpConstants.Tag.THREAD_GROUP);
+  }
+
+  /**
+   * Gets the thread group represented by this ID
+   *
+   * @throws InvalidThreadGroupException if the group is invalid
+   *           or garbage collected
+   */
+  public ThreadGroup getThreadGroup ()
+    throws InvalidThreadGroupException
+  {
+    ThreadGroup group = (ThreadGroup) _reference.get ();
+
+    if (group == null)
+      throw new InvalidThreadGroupException (getId ());
+
+    return group;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ThreadId.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/id/ThreadId.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* ThreadId.java -- thread IDs
+   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
+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.id;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.InvalidThreadException;
+
+/**
+ * A class which represents a JDWP thread id
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class ThreadId
+  extends ObjectId
+{
+  /**
+   * The object class that this id represents
+   */
+  public static final Class typeClass = Thread.class;
+
+  /**
+   * Constructs a new <code>ThreadId</code>
+   */
+  public ThreadId ()
+  {
+    super (JdwpConstants.Tag.THREAD);
+  }
+
+  /**
+   * Gets the Thread represented by this ID
+   *
+   * @throws InvalidThreadException if thread is garbage collected,
+   *           exited, or otherwise invalid
+   */
+  public Thread getThread ()
+    throws InvalidThreadException
+  {
+    Thread thread = (Thread) _reference.get ();
+
+    /* Spec says if thread is null, not valid, or exited,
+       throw invalid thread */
+    // FIXME: not valid? exited? Is this check valid?
+    if (thread == null || !thread.isAlive ())
+      throw new InvalidThreadException (getId ());
+
+    return thread;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ArrayReferenceCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ArrayReferenceCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,175 @@
+/* ArrayReferenceCommandSet.java -- class to implement the Array
+   Reference Command Set
+   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
+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.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.util.Value;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the ArrayReference Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class ArrayReferenceCommandSet
+  extends CommandSet
+{
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+    throws JdwpException
+  {
+    try
+      {
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.ArrayReference.LENGTH:
+            executeLength(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ArrayReference.GET_VALUES:
+            executeGetValues(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ArrayReference.SET_VALUES:
+            executeSetValues(bb, os);
+            break;
+          default:
+            throw new NotImplementedException("Command " + command +
+              " not found in Array Reference Command Set.");
+          }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+    return false;
+  }
+
+  private void executeLength(ByteBuffer bb, DataOutputStream os)
+    throws InvalidObjectException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    Object array = oid.getObject();
+    os.writeInt(Array.getLength(array));
+  }
+
+  private void executeGetValues(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    Object array = oid.getObject();
+    int first = bb.getInt();
+    int length = bb.getInt();
+
+    // We need to write out the byte signifying the type of array first
+    Class clazz = array.getClass().getComponentType();
+
+    // Uugh, this is a little ugly but it's the only time we deal with
+    // arrayregions
+    if (clazz == byte.class)
+      os.writeByte(JdwpConstants.Tag.BYTE);
+    else if (clazz == char.class)
+      os.writeByte(JdwpConstants.Tag.CHAR);
+    else if (clazz == float.class)
+      os.writeByte(JdwpConstants.Tag.FLOAT);
+    else if (clazz == double.class)
+      os.writeByte(JdwpConstants.Tag.DOUBLE);
+    else if (clazz == int.class)
+      os.writeByte(JdwpConstants.Tag.BYTE);
+    else if (clazz == long.class)
+      os.writeByte(JdwpConstants.Tag.LONG);
+    else if (clazz == short.class)
+      os.writeByte(JdwpConstants.Tag.SHORT);
+    else if (clazz == void.class)
+      os.writeByte(JdwpConstants.Tag.VOID);
+    else if (clazz == boolean.class)
+      os.writeByte(JdwpConstants.Tag.BOOLEAN);
+    else if (clazz.isArray())
+      os.writeByte(JdwpConstants.Tag.ARRAY);
+    else if (String.class.isAssignableFrom(clazz))
+      os.writeByte(JdwpConstants.Tag.STRING);
+    else if (Thread.class.isAssignableFrom(clazz))
+      os.writeByte(JdwpConstants.Tag.THREAD);
+    else if (ThreadGroup.class.isAssignableFrom(clazz))
+      os.writeByte(JdwpConstants.Tag.THREAD_GROUP);
+    else if (ClassLoader.class.isAssignableFrom(clazz))
+      os.writeByte(JdwpConstants.Tag.CLASS_LOADER);
+    else if (Class.class.isAssignableFrom(clazz))
+      os.writeByte(JdwpConstants.Tag.CLASS_OBJECT);
+    else
+      os.writeByte(JdwpConstants.Tag.OBJECT);
+
+    // Write all the values, primitives should be untagged and Objects must be
+    // tagged
+    for (int i = first; i < first + length; i++)
+      {
+        Object value = Array.get(array, i);
+        if (clazz.isPrimitive())
+          Value.writeUntaggedValue(os, value);
+        else
+          Value.writeTaggedValue(os, value);
+      }
+  }
+
+  private void executeSetValues(ByteBuffer bb, DataOutputStream os)
+    throws IOException, JdwpException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    Object array = oid.getObject();
+    int first = bb.getInt();
+    int length = bb.getInt();
+    Class type = array.getClass().getComponentType();
+    for (int i = first; i < first + length; i++)
+      {
+        Object value = Value.getUntaggedObj(bb, type);
+        Array.set(array, i, value);
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ArrayTypeCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ArrayTypeCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,105 @@
+/* ArrayTypeCommandSet.java -- class to implement the ArrayType Command Set
+   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.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the ArrayType Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class ArrayTypeCommandSet
+  extends CommandSet
+{
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+    throws JdwpException
+  {
+
+    // Although there's only a single command to choose from we still use
+    // a switch to maintain consistency with the rest of the CommandSets
+    try
+      {
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.ArrayType.NEW_INSTANCE:
+            executeNewInstance(bb, os);
+            break;
+          default:
+            throw new NotImplementedException("Command " + command +
+              " not found in ArrayType Command Set.");
+        }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+    return false;
+  }
+
+  public void executeNewInstance(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+    Class arrayType = refId.getType();
+    Class componentType = arrayType.getComponentType();
+
+    int length = bb.getInt();
+    Object newArray = Array.newInstance(componentType, length);
+    ObjectId oid = idMan.getObjectId(newArray);
+
+    // Since this array isn't referenced anywhere we'll disable garbage
+    // collection on it so it's still around when the debugger gets back to it.
+    oid.disableCollection();
+    oid.writeTagged(os);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ClassLoaderReferenceCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ClassLoaderReferenceCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,108 @@
+/* ClassLoaderReferenceCommandSet.java -- class to implement the 
+   ClassLoaderReference Command Set
+   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
+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.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * A class representing the ClassLoaderReference Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class ClassLoaderReferenceCommandSet
+  extends CommandSet
+{
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+      throws JdwpException
+  {
+
+    // Although there's only a single command to choose from we still use
+    // a switch to maintain consistency with the rest of the CommandSets
+   try
+      {
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.ClassLoaderReference.VISIBLE_CLASSES:
+            executeVisibleClasses(bb, os);
+            break;
+          default:
+            throw new NotImplementedException("Command " + command +
+            " not found in ClassLoaderReference Command Set.");
+          }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+   return false;
+  }
+
+  public void executeVisibleClasses(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ObjectId oId = idMan.readObjectId(bb);
+    ClassLoader cl = (ClassLoader) oId.getObject();
+    ArrayList loadRequests = VMVirtualMachine.getLoadRequests(cl);
+    os.writeInt(loadRequests.size());
+    for (Iterator iter = loadRequests.iterator(); iter.hasNext();)
+      {
+        Class clazz = (Class)iter.next();
+        ReferenceTypeId refId = idMan.getReferenceTypeId(clazz);
+        refId.writeTagged(os);
+      }
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ClassObjectReferenceCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ClassObjectReferenceCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,97 @@
+/* ClassObjectReferenceCommandSet.java -- class to implement the 
+   ClassObjectReference Command Set
+   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.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the ClassObjectReference Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class ClassObjectReferenceCommandSet
+  extends CommandSet
+{
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+    throws JdwpException
+  {
+    try
+      {
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.ClassObjectReference.REFLECTED_TYPE:
+            executeReflectedType(bb, os);
+            break;
+          default:
+            throw new NotImplementedException("Command " + command +
+              " not found in ClassObject Reference Command Set.");
+          }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+    return false;
+  }
+
+  public void executeReflectedType(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    Class clazz = (Class) oid.getObject();
+
+    // The difference between a ClassObjectId and a ReferenceTypeId is one is
+    // stored as an ObjectId and the other as a ReferenceTypeId.
+    ReferenceTypeId refId = idMan.getReferenceTypeId(clazz);
+    refId.writeTagged(os);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,223 @@
+/* ClassTypeCommandSet.java -- class to implement the ClassType
+   Command Set
+   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
+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.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.InvalidFieldException;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.util.MethodResult;
+import gnu.classpath.jdwp.util.Value;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the ClassType Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class ClassTypeCommandSet
+  extends CommandSet
+{
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+      throws JdwpException
+  {
+    try
+      {
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.ClassType.SUPERCLASS:
+            executeSuperclass(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ClassType.SET_VALUES:
+            executeSetValues(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ClassType.INVOKE_METHOD:
+            executeInvokeMethod(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ClassType.NEW_INSTANCE:
+            executeNewInstance(bb, os);
+            break;
+          default:
+            throw new NotImplementedException("Command " + command +
+              " not found in ClassType Command Set.");
+          }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+    return false;
+  }
+
+  private void executeSuperclass(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+    Class clazz = refId.getType();
+    Class superClazz = clazz.getSuperclass();
+
+    if (superClazz == null) {
+    	os.writeLong(0L);
+    } else {
+    	ReferenceTypeId clazzId = idMan.getReferenceTypeId(superClazz);
+    	clazzId.write(os);
+    }
+  }
+
+  private void executeSetValues(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+
+    // We don't actually seem to need this...
+    Class clazz = refId.getType();
+
+    int numValues = bb.getInt();
+
+    for (int i = 0; i < numValues; i++)
+      {
+        ObjectId fieldId = idMan.readObjectId(bb);
+        Field field = (Field) (fieldId.getObject());
+        Object value = Value.getUntaggedObj(bb, field.getType());
+        try
+          {
+            field.setAccessible(true); // Might be a private field
+            field.set(null, value);
+          }
+        catch (IllegalArgumentException ex)
+          {
+            throw new InvalidFieldException(ex);
+          }
+        catch (IllegalAccessException ex)
+          { // Since we set it as accessible this really shouldn't happen
+            throw new JdwpInternalErrorException(ex);
+          }
+      }
+  }
+
+  private void executeInvokeMethod(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    MethodResult mr = invokeMethod(bb);
+
+    Object value = mr.getReturnedValue();
+    Exception exception = mr.getThrownException();
+    ObjectId eId = idMan.getObjectId(exception);
+
+    Value.writeTaggedValue(os, value);
+    eId.writeTagged(os);
+  }
+
+  private void executeNewInstance(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    MethodResult mr = invokeMethod(bb);
+
+    Object obj = mr.getReturnedValue();
+    ObjectId oId = idMan.getObjectId(obj);
+    Exception exception = mr.getThrownException();
+    ObjectId eId = idMan.getObjectId(exception);
+
+    oId.writeTagged(os);
+    eId.writeTagged(os);
+  }
+
+  /**
+   * Execute the static method and return the resulting MethodResult.
+   */
+  private MethodResult invokeMethod(ByteBuffer bb) throws JdwpException,
+      IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+    Class clazz = refId.getType();
+
+    ObjectId tId = idMan.readObjectId(bb);
+    Thread thread = (Thread) tId.getObject();
+
+    ObjectId mId = idMan.readObjectId(bb);
+    Method method = (Method) mId.getObject();
+
+    int args = bb.getInt();
+    Object[] values = new Object[args];
+
+    for (int i = 0; i < args; i++)
+      {
+        values[i] = Value.getObj(bb);
+      }
+
+    int invokeOpts = bb.getInt();
+    boolean suspend = ((invokeOpts
+			& JdwpConstants.InvokeOptions.INVOKE_SINGLE_THREADED)
+		       != 0);
+    try
+      {
+        if (suspend)
+	  VMVirtualMachine.suspendAllThreads ();
+
+        MethodResult mr = VMVirtualMachine.executeMethod(null, thread,
+							 clazz, method,
+							 values, false);
+        if (suspend)
+	  VMVirtualMachine.resumeAllThreads ();
+
+        return mr;
+      }
+    catch (Exception ex)
+      {
+        if (suspend)
+	  VMVirtualMachine.resumeAllThreads ();
+
+        throw new JdwpInternalErrorException(ex);
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/CommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/CommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* CommandSet.java -- An interface defining JDWP Command Sets
+   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
+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.processor;
+
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.VMIdManager;
+
+import java.io.DataOutputStream;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing a JDWP Command Set. This class serves as a generic
+ * interface for all Command Sets types used by JDWP.
+ *
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public abstract class CommandSet
+{
+  /**
+   * The VM's ID manager
+   */
+  protected final VMIdManager idMan = VMIdManager.getDefault ();
+
+  /**
+   * Runs the given command with the data in distr and writes the data for the
+   * reply packet to ostr.
+   * 
+   * @param bb holds the data portion of the Command Packet
+   * @param os data portion of the Reply Packet will be written here
+   * @param command the command field of the Command Packet
+   * @return true if the JDWP layer should shut down in response to this packet
+   * @throws JdwpException command wasn't carried out successfully
+   */
+  public abstract boolean runCommand(ByteBuffer bb, DataOutputStream os,
+				     byte command) 
+    throws JdwpException;
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,197 @@
+/* EventRequestCommandSet.java -- class to implement the EventRequest Command
+   Set
+   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.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.event.EventManager;
+import gnu.classpath.jdwp.event.EventRequest;
+import gnu.classpath.jdwp.event.filters.ClassExcludeFilter;
+import gnu.classpath.jdwp.event.filters.ClassMatchFilter;
+import gnu.classpath.jdwp.event.filters.ClassOnlyFilter;
+import gnu.classpath.jdwp.event.filters.ConditionalFilter;
+import gnu.classpath.jdwp.event.filters.CountFilter;
+import gnu.classpath.jdwp.event.filters.ExceptionOnlyFilter;
+import gnu.classpath.jdwp.event.filters.FieldOnlyFilter;
+import gnu.classpath.jdwp.event.filters.IEventFilter;
+import gnu.classpath.jdwp.event.filters.InstanceOnlyFilter;
+import gnu.classpath.jdwp.event.filters.LocationOnlyFilter;
+import gnu.classpath.jdwp.event.filters.StepFilter;
+import gnu.classpath.jdwp.event.filters.ThreadOnlyFilter;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.JdwpString;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the EventRequest Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class EventRequestCommandSet
+  extends CommandSet
+{
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+      throws JdwpException
+  {
+    try
+      {
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.EventRequest.SET:
+            executeSet(bb, os);
+            break;
+          case JdwpConstants.CommandSet.EventRequest.CLEAR:
+            executeClear(bb, os);
+            break;
+          case JdwpConstants.CommandSet.EventRequest.CLEAR_ALL_BREAKPOINTS:
+            executeClearAllBreakpoints(bb, os);
+            break;
+          default:
+            throw new NotImplementedException("Command " + command + 
+              " not found in EventRequest Reference Command Set.");
+          }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+    return false;
+  }
+
+  private void executeSet(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    byte eventKind = bb.get();
+    byte suspendPolicy = bb.get();
+    int modifiers = bb.getInt();
+
+    EventRequest eventReq = new EventRequest(eventKind, suspendPolicy);
+    IEventFilter filter = null;
+    ReferenceTypeId refId;
+    for (int i = 0; i < modifiers; i++)
+      {
+        byte modKind = bb.get();
+        switch (modKind)
+          {
+          case JdwpConstants.ModKind.COUNT:
+            filter = new CountFilter(bb.getInt());
+            break;
+          case JdwpConstants.ModKind.CONDITIONAL:
+            filter = new ConditionalFilter(idMan.readObjectId(bb));
+            break;
+          case JdwpConstants.ModKind.THREAD_ONLY:
+            filter = new ThreadOnlyFilter((ThreadId) idMan.readObjectId(bb));
+            break;
+          case JdwpConstants.ModKind.CLASS_ONLY:
+            filter = new ClassOnlyFilter(idMan.readReferenceTypeId(bb));
+            break;
+          case JdwpConstants.ModKind.CLASS_MATCH:
+            filter = new ClassMatchFilter(JdwpString.readString(bb));
+            break;
+          case JdwpConstants.ModKind.CLASS_EXCLUDE:
+            filter = new ClassExcludeFilter(JdwpString.readString(bb));
+            break;
+          case JdwpConstants.ModKind.LOCATION_ONLY:
+            filter = new LocationOnlyFilter(new Location(bb));
+            break;
+          case JdwpConstants.ModKind.EXCEPTION_ONLY:
+            long id = bb.getLong();
+            if (id == 0)
+              refId = null;
+            else
+              refId = idMan.getReferenceType(id);
+            boolean caught = (bb.get() == 0) ? false : true;
+            boolean unCaught = (bb.get() == 0) ? false : true;
+            filter = new ExceptionOnlyFilter(refId, caught, unCaught);
+            break;
+          case JdwpConstants.ModKind.FIELD_ONLY:
+            refId = idMan.readReferenceTypeId(bb);
+            ReferenceTypeId fieldId = idMan.readReferenceTypeId(bb);
+            filter = new FieldOnlyFilter(refId, fieldId);
+            break;
+          case JdwpConstants.ModKind.STEP:
+            ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+            int size = bb.getInt();
+            int depth = bb.getInt();
+            filter = new StepFilter(tid, size, depth);
+            break;
+          case JdwpConstants.ModKind.INSTANCE_ONLY:
+            ObjectId oid = idMan.readObjectId(bb);
+            filter = new InstanceOnlyFilter(oid);
+            break;
+          default:
+            throw new NotImplementedException("modKind " + modKind
+                                              + " is not implemented.");
+          }
+        eventReq.addFilter(filter);
+      }
+
+    EventManager.getDefault().requestEvent(eventReq);
+    os.writeInt(eventReq.getId());
+
+  }
+
+  private void executeClear(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    byte eventKind = bb.get();
+    int requestId = bb.getInt();
+    EventManager.getDefault().deleteRequest(eventKind, requestId);
+  }
+
+  private void executeClearAllBreakpoints(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    byte eventKind = bb.get ();
+    EventManager.getDefault().clearRequests (eventKind);
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/FieldCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/FieldCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,67 @@
+/* FieldCommandSet.java -- class to implement the Field Command Set
+   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.jdwp.processor;
+
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+
+import java.io.DataOutputStream;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the Field Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class FieldCommandSet
+  extends CommandSet
+{
+  /**
+   * There are no commands for this CommandSet at this time so we just throw a
+   * NotImplementedException whenever it's called.
+   * 
+   * @throws JdwpException An exception will always be thrown
+   */
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+    throws JdwpException
+  {
+    throw new NotImplementedException(
+      "No commands for command set Field implemented.");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/InterfaceTypeCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/InterfaceTypeCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,68 @@
+/* InterfaceTypeCommandSet.java -- class to implement the InterfaceType
+   Command Set
+   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.jdwp.processor;
+
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+
+import java.io.DataOutputStream;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the InterfaceType Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class InterfaceTypeCommandSet
+  extends CommandSet
+{
+  /**
+   * There are no commands for this CommandSet at this time so we just throw a
+   * NotImplementedException whenever it's called.
+   * 
+   * @throws JdwpException An exception will always be thrown
+   */
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+    throws JdwpException
+  {
+    throw new NotImplementedException(
+      "No commands for command set InterfaceType implemented.");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/MethodCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/MethodCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,149 @@
+/* MethodCommandSet.java -- class to implement the Method Command Set
+   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
+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.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMMethod;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ClassReferenceTypeId;
+import gnu.classpath.jdwp.util.LineTable;
+import gnu.classpath.jdwp.util.VariableTable;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the Method Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class MethodCommandSet
+  extends CommandSet
+{
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+      throws JdwpException
+  {
+    try
+      {
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.Method.LINE_TABLE:
+            executeLineTable(bb, os);
+            break;
+          case JdwpConstants.CommandSet.Method.VARIABLE_TABLE:
+            executeVariableTable(bb, os);
+            break;
+          case JdwpConstants.CommandSet.Method.BYTE_CODES:
+            executeByteCodes(bb, os);
+            break;
+          case JdwpConstants.CommandSet.Method.IS_OBSOLETE:
+            executeIsObsolete(bb, os);
+            break;
+          case JdwpConstants.CommandSet.Method.VARIABLE_TABLE_WITH_GENERIC:
+            executeVariableTableWithGeneric(bb, os);
+            break;
+          default:
+            throw new NotImplementedException(
+              "Command " + command + " not found in Method Command Set.");
+          }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+    return false;
+  }
+
+  private void executeLineTable(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ClassReferenceTypeId refId
+      = (ClassReferenceTypeId) idMan.readReferenceTypeId(bb);
+    Class clazz = refId.getType();
+
+    VMMethod method = VMMethod.readId(clazz, bb);
+    LineTable lt = method.getLineTable();
+    lt.write(os);
+  }
+
+  private void executeVariableTable(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+   ClassReferenceTypeId refId
+     = (ClassReferenceTypeId) idMan.readReferenceTypeId(bb);
+    Class clazz = refId.getType();
+
+    VMMethod method = VMMethod.readId(clazz, bb);
+    VariableTable vt = method.getVariableTable();
+    vt.write(os);
+  }
+
+  private void executeByteCodes(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException
+  {
+    // This command is optional, determined by VirtualMachines CapabilitiesNew
+    // so we'll leave it till later to implement
+    throw new NotImplementedException("Command ByteCodes not implemented.");
+  }
+
+  private void executeIsObsolete(ByteBuffer bb, DataOutputStream os)
+      throws IOException
+  {
+    // The debugger is really asking if this method has been redefined using
+    // VirtualMachineCommandSet.RedefineClasses. Since we don't implement that
+    // command the answer to this will always be false.
+    os.writeBoolean(false);
+  }
+
+  private void executeVariableTableWithGeneric(ByteBuffer bb,
+                                               DataOutputStream os)
+      throws JdwpException
+  {
+    // We don't have generics yet
+    throw new NotImplementedException(
+      "Command SourceDebugExtension not implemented.");
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,264 @@
+/* ObjectReferenceCommandSet.java -- class to implement the ObjectReference
+   Command Set
+   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.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.InvalidFieldException;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.util.Value;
+import gnu.classpath.jdwp.util.MethodResult;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the ObjectReference Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class ObjectReferenceCommandSet
+  extends CommandSet
+{
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+    throws JdwpException
+  {
+    try
+      {
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.ObjectReference.REFERENCE_TYPE:
+            executeReferenceType(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ObjectReference.GET_VALUES:
+            executeGetValues(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ObjectReference.SET_VALUES:
+            executeSetValues(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ObjectReference.MONITOR_INFO:
+            executeMonitorInfo(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ObjectReference.INVOKE_METHOD:
+            executeInvokeMethod(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ObjectReference.DISABLE_COLLECTION:
+            executeDisableCollection(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ObjectReference.ENABLE_COLLECTION:
+            executeEnableCollection(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ObjectReference.IS_COLLECTED:
+            executeIsCollected(bb, os);
+            break;
+          default:
+            throw new NotImplementedException("Command " + command +
+              " not found in ObjectReference Command Set.");
+          }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+    return false;
+  }
+
+  private void executeReferenceType(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    Object obj = oid.getObject();
+    Class clazz = obj.getClass();
+    ReferenceTypeId refId = idMan.getReferenceTypeId(clazz);
+    refId.writeTagged(os);
+  }
+
+  private void executeGetValues(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    Object obj = oid.getObject();
+
+    int numFields = bb.getInt();
+
+    os.writeInt(numFields); // Looks pointless but this is the protocol
+
+    for (int i = 0; i < numFields; i++)
+      {
+        Field field = (Field) idMan.readObjectId(bb).getObject();
+        try
+          {
+            field.setAccessible(true); // Might be a private field
+            Object value = field.get(obj);
+            Value.writeTaggedValue(os, value);
+          }
+        catch (IllegalArgumentException ex)
+          {
+            // I suppose this would best qualify as an invalid field then
+            throw new InvalidFieldException(ex);
+          }
+        catch (IllegalAccessException ex)
+          {
+            // Since we set it as accessible this really shouldn't happen
+            throw new JdwpInternalErrorException(ex);
+          }
+      }
+  }
+
+  private void executeSetValues(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    Object obj = oid.getObject();
+
+    int numFields = bb.getInt();
+
+    for (int i = 0; i < numFields; i++)
+      {
+        Field field = (Field) idMan.readObjectId(bb).getObject();
+        Object value = Value.getUntaggedObj(bb, field.getType());
+        try
+          {
+            field.setAccessible(true); // Might be a private field
+            field.set(obj, value);
+          }
+        catch (IllegalArgumentException ex)
+          {
+            // I suppose this would best qualify as an invalid field then
+            throw new InvalidFieldException(ex);
+          }
+        catch (IllegalAccessException ex)
+          {
+            // Since we set it as accessible this really shouldn't happen
+            throw new JdwpInternalErrorException(ex);
+          }
+      }
+  }
+
+  private void executeMonitorInfo(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException
+  {
+    // This command is optional, determined by VirtualMachines CapabilitiesNew
+    // so we'll leave it till later to implement
+    throw new NotImplementedException(
+      "Command ExecuteMonitorInfo not implemented.");
+
+  }
+
+  private void executeInvokeMethod(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    Object obj = oid.getObject();
+
+    ObjectId tid = idMan.readObjectId(bb);
+    Thread thread = (Thread) tid.getObject();
+
+    ReferenceTypeId rid = idMan.readReferenceTypeId(bb);
+    Class clazz = rid.getType();
+
+    ObjectId mid = idMan.readObjectId(bb);
+    Method method = (Method) mid.getObject();
+
+    int args = bb.getInt();
+    Object[] values = new Object[args];
+
+    for (int i = 0; i < args; i++)
+      {
+        values[i] = Value.getObj(bb);
+      }
+
+    int invokeOptions = bb.getInt();
+    boolean suspend = ((invokeOptions
+			& JdwpConstants.InvokeOptions.INVOKE_SINGLE_THREADED)
+		       != 0);
+    if (suspend)
+      {
+	// We must suspend all other running threads first
+        VMVirtualMachine.suspendAllThreads ();
+      }
+
+    boolean nonVirtual = ((invokeOptions
+			   & JdwpConstants.InvokeOptions.INVOKE_NONVIRTUAL)
+			  != 0);
+
+    MethodResult mr = VMVirtualMachine.executeMethod(obj, thread,
+						     clazz, method,
+						     values, nonVirtual);
+    Object value = mr.getReturnedValue();
+    Exception exception = mr.getThrownException();
+
+    ObjectId eId = idMan.getObjectId(exception);
+    Value.writeTaggedValue(os, value);
+    eId.writeTagged(os);
+  }
+
+  private void executeDisableCollection(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    oid.disableCollection();
+  }
+
+  private void executeEnableCollection(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    oid.enableCollection();
+  }
+
+  private void executeIsCollected(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    boolean collected = (oid.getReference().get () == null);
+    os.writeBoolean(collected);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/PacketProcessor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/PacketProcessor.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,221 @@
+/* PacketProcessor.java -- a thread which processes command packets
+   from the debugger
+   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.processor;
+
+import gnu.classpath.jdwp.Jdwp;
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.transport.JdwpCommandPacket;
+import gnu.classpath.jdwp.transport.JdwpConnection;
+import gnu.classpath.jdwp.transport.JdwpPacket;
+import gnu.classpath.jdwp.transport.JdwpReplyPacket;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.security.PrivilegedAction;
+
+/**
+ * This class is responsible for processing packets from the
+ * debugger. It waits for an available packet from the connection
+ * ({@link gnu.classpath.jdwp.transport.JdwpConnection}) and then
+ * processes the packet and any reply.
+ *
+ * @author Keith Seitz (keiths at redhat.com)
+ */
+public class PacketProcessor
+  implements PrivilegedAction
+{
+  // The connection to the debugger
+  private JdwpConnection _connection;
+  
+  // Shutdown this thread?
+  private boolean _shutdown;
+  
+  // A Mapping of the command set (Byte) to the specific CommandSet
+  private CommandSet[] _sets;
+
+  // Contents of the ReplyPackets data field
+  private ByteArrayOutputStream _outputBytes;
+
+  // Output stream around _outputBytes
+  private DataOutputStream _os;
+  
+  /**
+   * Constructs a new <code>PacketProcessor</code> object
+   * Connection must be validated before getting here!
+   *
+   * @param con  the connection
+   */
+  public PacketProcessor (JdwpConnection con)
+  {
+    _connection = con;
+    _shutdown = false;
+    
+    // MAXIMUM is the value of the largest command set we may receive 
+    _sets = new CommandSet[JdwpConstants.CommandSet.MAXIMUM + 1];
+    _outputBytes = new ByteArrayOutputStream();
+    _os = new DataOutputStream (_outputBytes);
+
+    // Create all the Command Sets and add them to our array
+    _sets[JdwpConstants.CommandSet.VirtualMachine.CS_VALUE] =
+      new VirtualMachineCommandSet();
+    _sets[JdwpConstants.CommandSet.ReferenceType.CS_VALUE] =
+      new ReferenceTypeCommandSet();
+    _sets[JdwpConstants.CommandSet.ClassType.CS_VALUE] =
+      new ClassTypeCommandSet();
+    _sets[JdwpConstants.CommandSet.ArrayType.CS_VALUE] =
+      new ArrayTypeCommandSet();
+    _sets[JdwpConstants.CommandSet.InterfaceType.CS_VALUE] =
+      new InterfaceTypeCommandSet();
+    _sets[JdwpConstants.CommandSet.Method.CS_VALUE] =
+      new MethodCommandSet();
+    _sets[JdwpConstants.CommandSet.Field.CS_VALUE] =
+      new FieldCommandSet();
+    _sets[JdwpConstants.CommandSet.ObjectReference.CS_VALUE] =
+      new ObjectReferenceCommandSet();
+    _sets[JdwpConstants.CommandSet.StringReference.CS_VALUE] =
+      new StringReferenceCommandSet();
+    _sets[JdwpConstants.CommandSet.ThreadReference.CS_VALUE] =
+      new ThreadReferenceCommandSet();
+    _sets[JdwpConstants.CommandSet.ThreadGroupReference.CS_VALUE] =
+      new ThreadGroupReferenceCommandSet();
+    _sets[JdwpConstants.CommandSet.ArrayReference.CS_VALUE] =
+      new ArrayReferenceCommandSet();
+    _sets[JdwpConstants.CommandSet.ClassLoaderReference.CS_VALUE] =
+      new ClassLoaderReferenceCommandSet();
+    _sets[JdwpConstants.CommandSet.EventRequest.CS_VALUE] =
+      new EventRequestCommandSet();
+    _sets[JdwpConstants.CommandSet.StackFrame.CS_VALUE] =
+      new StackFrameCommandSet();
+    _sets[JdwpConstants.CommandSet.ClassObjectReference.CS_VALUE] =
+      new ClassObjectReferenceCommandSet();
+  }
+  
+  /**
+   * Main run routine for this thread. Will loop getting packets
+   * from the connection and processing them.
+   */
+  public Object run ()
+  {
+    // Notify initialization thread (gnu.classpath.jdwp.Jdwp) that
+    // the PacketProcessor thread is ready.
+    Jdwp.getDefault().subcomponentInitialized ();
+	
+    try
+      {
+        while (!_shutdown)
+          {
+            _processOnePacket ();
+          }
+      }
+    catch (Exception ex)
+      {
+        ex.printStackTrace();
+      }
+    // Time to shutdown, tell Jdwp to shutdown
+    Jdwp.getDefault().shutdown();
+    return null;
+  }
+  
+  /**
+   * Shutdown the packet processor
+   */
+  public void shutdown ()
+  {
+    _shutdown = true;
+  }
+  
+  // Helper function which actually does all the work of waiting
+  // for a packet and getting it processed.
+  private void _processOnePacket ()
+    throws IOException
+  {
+    JdwpPacket pkt = _connection.getPacket ();
+    
+    if (!(pkt instanceof JdwpCommandPacket))
+      {
+        // We're not supposed to get these from the debugger!
+        // Drop it on the floor
+        return;
+      }
+    
+    if (pkt != null)
+      {
+        JdwpCommandPacket commandPkt = (JdwpCommandPacket) pkt;
+        JdwpReplyPacket reply = new JdwpReplyPacket(commandPkt);
+        
+        // Reset our output stream
+        _outputBytes.reset();
+        
+        // Create a ByteBuffer around the command packet 
+        ByteBuffer bb = ByteBuffer.wrap(commandPkt.getData());
+        byte command = commandPkt.getCommand();
+        byte commandSet = commandPkt.getCommandSet();
+        
+        CommandSet set = null;
+        try
+          {
+            // There is no command set with value 0
+            if (commandSet > 0 && commandSet < _sets.length)
+              {
+                set = _sets[commandPkt.getCommandSet()];
+              }
+            if (set != null) 
+              {
+                _shutdown = set.runCommand(bb, _os, command);
+                reply.setData(_outputBytes.toByteArray());
+              }
+            else
+              {
+                // This command set wasn't in our tree
+                reply.setErrorCode(JdwpConstants.Error.NOT_IMPLEMENTED);
+              }
+          }
+          catch (JdwpException ex)
+            {
+            reply.setErrorCode(ex.getErrorCode ());
+            }
+          _connection.sendPacket (reply);
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ReferenceTypeCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ReferenceTypeCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,335 @@
+/* ReferenceTypeCommandSet.java -- class to implement the ReferenceType
+   Command Set
+   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
+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.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMMethod;
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.InvalidFieldException;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ClassReferenceTypeId;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.util.JdwpString;
+import gnu.classpath.jdwp.util.Signature;
+import gnu.classpath.jdwp.util.Value;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the ReferenceType Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class ReferenceTypeCommandSet
+  extends CommandSet
+{
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+    throws JdwpException
+  {
+    try
+      {
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.ReferenceType.SIGNATURE:
+            executeSignature(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.CLASS_LOADER:
+            executeClassLoader(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.MODIFIERS:
+            executeModifiers(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.FIELDS:
+            executeFields(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.METHODS:
+            executeMethods(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.GET_VALUES:
+            executeGetValues(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.SOURCE_FILE:
+            executeSourceFile(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.NESTED_TYPES:
+            executeNestedTypes(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.STATUS:
+            executeStatus(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.INTERFACES:
+            executeInterfaces(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.CLASS_OBJECT:
+            executeClassObject(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.SOURCE_DEBUG_EXTENSION:
+            executeSourceDebugExtension(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.SIGNATURE_WITH_GENERIC:
+            executeSignatureWithGeneric(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.FIELDS_WITH_GENERIC:
+            executeFieldWithGeneric(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ReferenceType.METHODS_WITH_GENERIC:
+            executeMethodsWithGeneric(bb, os);
+            break;
+          default:
+            throw new NotImplementedException("Command " + command +
+              " not found in ReferenceType Command Set.");
+          }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+    return false;
+  }
+
+  private void executeSignature(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+    String sig = Signature.computeClassSignature(refId.getType());
+    JdwpString.writeString(os, sig);
+  }
+
+  private void executeClassLoader(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+
+    Class clazz = refId.getType();
+    ClassLoader loader = clazz.getClassLoader();
+    ObjectId oid = idMan.getObjectId(loader);
+    oid.write(os);
+  }
+
+  private void executeModifiers(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+
+    Class clazz = refId.getType();
+    os.writeInt(clazz.getModifiers());
+  }
+
+  private void executeFields(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+    Class clazz = refId.getType();
+
+    Field[] fields = clazz.getFields();
+    os.writeInt(fields.length);
+    for (int i = 0; i < fields.length; i++)
+      {
+        Field field = fields[i];
+        idMan.getObjectId(field).write(os);
+        JdwpString.writeString(os, field.getName());
+        JdwpString.writeString(os, Signature.computeFieldSignature(field));
+        os.writeInt(field.getModifiers());
+      }
+  }
+
+  private void executeMethods(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ClassReferenceTypeId refId
+      = (ClassReferenceTypeId) idMan.readReferenceTypeId(bb);
+    Class clazz = refId.getType();
+
+    VMMethod[] methods = VMVirtualMachine.getAllClassMethods(clazz);
+    os.writeInt (methods.length);
+    for (int i = 0; i < methods.length; i++)
+      {
+        VMMethod method = methods[i];
+        method.writeId(os);
+        JdwpString.writeString(os, method.getName());
+        JdwpString.writeString(os, method.getSignature());
+        os.writeInt(method.getModifiers());
+      }
+  }
+
+  private void executeGetValues(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+    Class clazz = refId.getType();
+
+    int numFields = bb.getInt();
+    os.writeInt(numFields); // Looks pointless but this is the protocol
+    for (int i = 0; i < numFields; i++)
+      {
+        ObjectId fieldId = idMan.readObjectId(bb);
+        Field field = (Field) (fieldId.getObject());
+        Class fieldClazz = field.getDeclaringClass();
+
+        // We don't actually need the clazz to get the field but we might as
+        // well check that the debugger got it right
+        if (fieldClazz.isAssignableFrom(clazz))
+          {
+            try
+              {
+                field.setAccessible(true); // Might be a private field
+                Object value = field.get(null);
+                Value.writeTaggedValue(os, value);
+              }
+            catch (IllegalArgumentException ex)
+              {
+                // I suppose this would best qualify as an invalid field then
+                throw new InvalidFieldException(ex);
+              }
+            catch (IllegalAccessException ex)
+              {
+                // Since we set it as accessible this really shouldn't happen
+                throw new JdwpInternalErrorException(ex);
+              }
+          }
+        else
+          throw new InvalidFieldException(fieldId.getId());
+      }
+  }
+
+  private void executeSourceFile(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+    Class clazz = refId.getType();
+
+    // We'll need to go into the jvm for this unless there's an easier way
+    String sourceFileName = VMVirtualMachine.getSourceFile(clazz);
+    JdwpString.writeString(os, sourceFileName);
+    // clazz.getProtectionDomain().getCodeSource().getLocation();
+  }
+
+  private void executeNestedTypes(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+    Class clazz = refId.getType();
+    Class[] declaredClazzes = clazz.getDeclaredClasses();
+    os.writeInt(declaredClazzes.length);
+    for (int i = 0; i < declaredClazzes.length; i++)
+      {
+        Class decClazz = declaredClazzes[i];
+        ReferenceTypeId clazzId = idMan.getReferenceTypeId(decClazz);
+        clazzId.writeTagged(os);
+      }
+  }
+
+  private void executeStatus(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+    Class clazz = refId.getType();
+
+    // I don't think there's any other way to get this
+    int status = VMVirtualMachine.getClassStatus(clazz);
+    os.writeInt(status);
+  }
+
+  private void executeInterfaces(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+    Class clazz = refId.getType();
+    Class[] interfaces = clazz.getInterfaces();
+    os.writeInt(interfaces.length);
+    for (int i = 0; i < interfaces.length; i++)
+      {
+        Class interfaceClass = interfaces[i];
+        ReferenceTypeId intId = idMan.getReferenceTypeId(interfaceClass);
+        intId.write(os);
+      }
+  }
+
+  private void executeClassObject(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+    Class clazz = refId.getType();
+    ObjectId clazzObjectId = idMan.getObjectId(clazz);
+    clazzObjectId.write(os);
+  }
+
+  private void executeSourceDebugExtension(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    // This command is optional, determined by VirtualMachines CapabilitiesNew
+    // so we'll leave it till later to implement
+    throw new NotImplementedException(
+      "Command SourceDebugExtension not implemented.");
+  }
+
+  private void executeSignatureWithGeneric(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    // We don't have generics yet
+    throw new NotImplementedException(
+      "Command SourceDebugExtension not implemented.");
+  }
+
+  private void executeFieldWithGeneric(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    // We don't have generics yet
+    throw new NotImplementedException(
+      "Command SourceDebugExtension not implemented.");
+  }
+
+  private void executeMethodsWithGeneric(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    // We don't have generics yet
+    throw new NotImplementedException(
+      "Command SourceDebugExtension not implemented.");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/StackFrameCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/StackFrameCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,158 @@
+/* StackFrameCommandSet.java -- class to implement the StackFrame Command Set
+   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
+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.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMFrame;
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.util.Value;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the StackFrame Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class StackFrameCommandSet
+  extends CommandSet
+{
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+      throws JdwpException
+  {
+    boolean keepRunning = true;
+    try
+      {
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.StackFrame.GET_VALUES:
+            executeGetValues(bb, os);
+            break;
+          case JdwpConstants.CommandSet.StackFrame.SET_VALUES:
+            executeSetValues(bb, os);
+            break;
+          case JdwpConstants.CommandSet.StackFrame.THIS_OBJECT:
+            executeThisObject(bb, os);
+            break;
+          case JdwpConstants.CommandSet.StackFrame.POP_FRAMES:
+            executePopFrames(bb, os);
+            break;
+          default:
+            throw new NotImplementedException("Command " + command + 
+            " not found in Stack Frame Command Set.");
+          }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+    return false;
+  }
+
+  private void executeGetValues(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ObjectId tId = idMan.readObjectId(bb);
+    Thread thread = (Thread) tId.getObject();
+
+    // Although Frames look like other ids they are not. First they are not
+    // ObjectIds since they don't exist in the users code. Storing them as an
+    // ObjectId would mean they could be garbage collected since no one else
+    // has a reference to them. Furthermore they are not ReferenceTypeIds since
+    // these are held permanently and we want these to be held only as long as
+    // the Thread is suspended.
+    VMFrame frame = VMVirtualMachine.getFrame(thread, bb);
+    int slots = bb.getInt();
+    os.writeInt(slots); // Looks pointless but this is the protocol
+    for (int i = 0; i < slots; i++)
+      {
+        int slot = bb.getInt();
+        byte sig = bb.get();
+        Object val = frame.getValue(slot);
+        Value.writeTaggedValue(os, val);
+      }
+  }
+
+  private void executeSetValues(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ObjectId tId = idMan.readObjectId(bb);
+    Thread thread = (Thread) tId.getObject();
+
+    VMFrame frame = VMVirtualMachine.getFrame(thread, bb);
+
+    int slots = bb.getInt();
+    for (int i = 0; i < slots; i++)
+      {
+        int slot = bb.getInt();
+        Object value = Value.getObj(bb);
+        frame.setValue(slot, value);
+      }
+  }
+
+  private void executeThisObject(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ObjectId tId = idMan.readObjectId(bb);
+    Thread thread = (Thread) tId.getObject();
+
+    VMFrame frame = VMVirtualMachine.getFrame(thread, bb);
+
+    Object thisObject = frame.getObject();
+    Value.writeTaggedValue(os, thisObject);
+  }
+
+  private void executePopFrames(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException
+  {
+    // This command is optional, determined by VirtualMachines CapabilitiesNew
+    // so we'll leave it till later to implement
+    throw new NotImplementedException("Command PopFrames not implemented.");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/StringReferenceCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/StringReferenceCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,99 @@
+/* StringReferenceCommandSet.java -- class to implement the StringReference
+   Command Set
+   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
+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.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.util.JdwpString;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the StringReference Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class StringReferenceCommandSet
+  extends CommandSet
+{
+
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+      throws JdwpException
+  {
+    try
+      {
+
+        // Although there's only a single command to choose from we still use
+        // a switch to maintain consistency with the rest of the CommandSets
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.StringReference.VALUE:
+            executeValue(bb, os);
+            break;
+          default:
+            throw new NotImplementedException("Command " + command +
+            " not found in String Reference Command Set.");
+          }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+    return false;
+  }
+
+  private void executeValue(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+
+    String str = (String) oid.getObject();
+    JdwpString.writeString(os, str);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,179 @@
+/* ThreadGroupReferenceCommandSet.java -- class to implement the 
+   ThreadGroupReference Command Set
+   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.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.util.JdwpString;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the ThreadGroupReference Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class ThreadGroupReferenceCommandSet
+  extends CommandSet
+{
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+    throws JdwpException
+  {
+    try
+      {
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.ThreadGroupReference.NAME:
+            executeName(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ThreadGroupReference.PARENT:
+            executeParent(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ThreadGroupReference.CHILDREN:
+            executeChildren(bb, os);
+            break;
+          default:
+            throw new NotImplementedException("Command " + command +
+              " not found in ThreadGroupReference Command Set.");
+          }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+    return false;
+  }
+
+  private void executeName(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    ThreadGroup group = (ThreadGroup) oid.getObject();
+    JdwpString.writeString(os, group.getName());
+  }
+
+  private void executeParent(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    ThreadGroup group = (ThreadGroup) oid.getObject();
+    ThreadGroup parent = group.getParent();
+    if (parent == null) {
+    	os.writeLong(0L);
+    } else {
+    	ObjectId parentId = idMan.getObjectId(parent);
+    	parentId.write(os);   	
+    }
+  }
+
+  private void executeChildren(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ObjectId oid = idMan.readObjectId(bb);
+    ThreadGroup group = (ThreadGroup) oid.getObject();
+
+    ThreadGroup jdwpGroup = Thread.currentThread().getThreadGroup();
+    int numThreads = group.activeCount();
+    Thread allThreads[] = new Thread[numThreads];
+
+    group.enumerate(allThreads, false);
+
+    // We need to loop through for the true count since some threads may have
+    // been destroyed since we got activeCount so those spots in the array will
+    // be null. As well we must ignore any threads that belong to jdwp
+    numThreads = 0;
+    for (int i = 0; i < allThreads.length; i++)
+      {
+        Thread thread = allThreads[i];
+        if (thread == null)
+          break; // No threads after this point
+        if (!thread.getThreadGroup().equals(jdwpGroup))
+          numThreads++;
+      }
+
+    os.writeInt(numThreads);
+
+    for (int i = 0; i < allThreads.length; i++)
+      {
+        Thread thread = allThreads[i];
+        if (thread == null)
+          break; // No threads after this point
+        if (!thread.getThreadGroup().equals(jdwpGroup))
+          idMan.getObjectId(thread).write(os);
+      }
+
+    int numGroups = group.activeCount();
+    ThreadGroup allGroups[] = new ThreadGroup[numGroups];
+
+    group.enumerate(allGroups, false);
+
+    // We need to loop through for the true count since some ThreadGroups may
+    // have been destroyed since we got activeCount so those spots in the array
+    // will be null. As well we must ignore any threads that belong to jdwp.
+    numGroups = 0;
+    for (int i = 0; i < allGroups.length; i++)
+      {
+        ThreadGroup tgroup = allGroups[i];
+        if (tgroup == null)
+          break; // No ThreadGroups after this point
+        if (!tgroup.equals(jdwpGroup))
+          numGroups++;
+      }
+
+    os.writeInt(numGroups);
+
+    for (int i = 0; i < allGroups.length; i++)
+      {
+        ThreadGroup tgroup = allGroups[i];
+        if (tgroup == null)
+          break; // No ThreadGroups after this point
+        if (!tgroup.equals(jdwpGroup))
+          idMan.getObjectId(tgroup).write(os);
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,245 @@
+/* ThreadReferenceCommandSet.java -- class to implement the ThreadReference
+   Command Set 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
+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.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMFrame;
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.JdwpString;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+
+/**
+ * A class representing the ThreadReference Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class ThreadReferenceCommandSet
+  extends CommandSet
+{
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+      throws JdwpException
+  {
+    try
+      {
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.ThreadReference.NAME:
+            executeName(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ThreadReference.SUSPEND:
+            executeSuspend(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ThreadReference.RESUME:
+            executeResume(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ThreadReference.STATUS:
+            executeStatus(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ThreadReference.THREAD_GROUP:
+            executeThreadGroup(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ThreadReference.FRAMES:
+            executeFrames(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ThreadReference.FRAME_COUNT:
+            executeFrameCount(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ThreadReference.OWNED_MONITORS:
+            executeOwnedMonitors(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ThreadReference.CURRENT_CONTENDED_MONITOR:
+            executeCurrentContendedMonitor(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ThreadReference.STOP:
+            executeStop(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ThreadReference.INTERRUPT:
+            executeInterrupt(bb, os);
+            break;
+          case JdwpConstants.CommandSet.ThreadReference.SUSPEND_COUNT:
+            executeSuspendCount(bb, os);
+            break;
+          default:
+            throw new NotImplementedException("Command " + command + 
+              " not found in Thread Reference Command Set.");
+          }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+    return false;
+  }
+
+  private void executeName(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+    Thread thread = tid.getThread();
+    JdwpString.writeString(os, thread.getName());
+  }
+
+  private void executeSuspend(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+    Thread thread = tid.getThread();
+    VMVirtualMachine.suspendThread(thread);
+  }
+
+  private void executeResume(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+    Thread thread = tid.getThread();
+    VMVirtualMachine.suspendThread(thread);
+  }
+
+  private void executeStatus(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+    Thread thread = tid.getThread();
+    int threadStatus = VMVirtualMachine.getThreadStatus(thread);
+    // There's only one possible SuspendStatus...
+    int suspendStatus = JdwpConstants.SuspendStatus.SUSPENDED;
+
+    os.writeInt(threadStatus);
+    os.writeInt(suspendStatus);
+  }
+
+  private void executeThreadGroup(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+    Thread thread = tid.getThread();
+    ThreadGroup group = thread.getThreadGroup();
+    ObjectId groupId = idMan.getObjectId(group);
+    groupId.write(os);
+  }
+
+  private void executeFrames(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+    Thread thread = tid.getThread();
+    int startFrame = bb.getInt();
+    int length = bb.getInt();
+
+    ArrayList frames = VMVirtualMachine.getFrames(thread, startFrame, length);
+    os.writeInt(frames.size());
+    for (int i = 0; i < frames.size(); i++)
+      {
+        VMFrame frame = (VMFrame) frames.get(i);
+        os.writeLong(frame.getId());
+        Location loc = frame.getLocation();
+        loc.write(os);
+      }
+  }
+
+  private void executeFrameCount(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+    Thread thread = tid.getThread();
+
+    int frameCount = VMVirtualMachine.getFrameCount(thread);
+    os.writeInt(frameCount);
+  }
+
+  private void executeOwnedMonitors(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException
+  {
+    // This command is optional, determined by VirtualMachines CapabilitiesNew
+    // so we'll leave it till later to implement
+    throw new NotImplementedException(
+      "Command OwnedMonitors not implemented.");
+  }
+
+  private void executeCurrentContendedMonitor(ByteBuffer bb,
+                                              DataOutputStream os)
+      throws JdwpException
+  {
+    // This command is optional, determined by VirtualMachines CapabilitiesNew
+    // so we'll leave it till later to implement
+    throw new NotImplementedException(
+      "Command CurrentContentedMonitors not implemented.");
+  }
+
+  private void executeStop(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+    Thread thread = tid.getThread();
+    ObjectId exception = idMan.readObjectId(bb);
+    Throwable throwable = (Throwable) exception.getObject();
+    thread.stop (throwable);
+  }
+
+  private void executeInterrupt(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+    Thread thread = tid.getThread();
+    thread.interrupt();
+  }
+
+  private void executeSuspendCount(ByteBuffer bb, DataOutputStream os)
+      throws JdwpException, IOException
+  {
+    ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+    Thread thread = tid.getThread();
+    int suspendCount = VMVirtualMachine.getSuspendCount(thread);
+    os.writeInt(suspendCount);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,465 @@
+/* VirtualMachineCommandSet.java -- class to implement the VirtualMachine
+   Command Set
+   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
+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.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMFrame;
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.util.JdwpString;
+import gnu.classpath.jdwp.util.Signature;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+
+/**
+ * A class representing the VirtualMachine Command Set.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class VirtualMachineCommandSet
+  extends CommandSet
+{
+  public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+    throws JdwpException
+  {
+    boolean shutdown = false;
+    try
+      {
+        switch (command)
+          {
+          case JdwpConstants.CommandSet.VirtualMachine.VERSION:
+            executeVersion(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.CLASSES_BY_SIGNATURE:
+            executeClassesBySignature(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.ALL_CLASSES:
+            executeAllClasses(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.ALL_THREADS:
+            executeAllThreads(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.TOP_LEVEL_THREAD_GROUPS:
+            executeTopLevelThreadGroups(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.IDSIZES:
+            executeIDsizes(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.DISPOSE:
+            shutdown = true;
+            executeDispose(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.SUSPEND:
+            executeSuspend(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.RESUME:
+            executeResume(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.EXIT:
+	    shutdown = true;
+            executeExit(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.CREATE_STRING:
+            executeCreateString(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.CAPABILITIES:
+            executeCapabilities(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.CLASS_PATHS:
+            executeClassPaths(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.DISPOSE_OBJECTS:
+            executeDisposeObjects(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.HOLD_EVENTS:
+            executeHoldEvents(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.RELEASE_EVENTS:
+            executeReleaseEvents(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.CAPABILITIES_NEW:
+            executeCapabilitiesNew(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.REDEFINE_CLASSES:
+            executeRedefineClasses(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.SET_DEFAULT_STRATUM:
+            executeSetDefaultStratum(bb, os);
+            break;
+          case JdwpConstants.CommandSet.VirtualMachine.ALL_CLASSES_WITH_GENERIC:
+            executeAllClassesWithGeneric(bb, os);
+            break;
+          default:
+            throw new NotImplementedException("Command " + command +
+            " not found in VirtualMachine Command Set.");
+          }
+      }
+    catch (IOException ex)
+      {
+        // The DataOutputStream we're using isn't talking to a socket at all
+        // So if we throw an IOException we're in serious trouble
+        throw new JdwpInternalErrorException(ex);
+      }
+
+    return shutdown;
+  }
+
+  private void executeVersion(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+
+    Properties props = System.getProperties();
+
+    int jdwpMajor = JdwpConstants.Version.MAJOR;
+    int jdwpMinor = JdwpConstants.Version.MINOR;
+    // The description field is pretty loosely defined
+    String description = "JDWP version " + jdwpMajor + "." + jdwpMinor
+                         + ", JVM version " + props.getProperty("java.vm.name")
+                         + " " + props.getProperty("java.vm.version") + " "
+                         + props.getProperty("java.version");
+    String vmVersion = props.getProperty("java.version");
+    String vmName = props.getProperty("java.vm.name");
+    JdwpString.writeString(os, description);
+    os.writeInt(jdwpMajor);
+    os.writeInt(jdwpMinor);
+    JdwpString.writeString(os, vmName);
+    JdwpString.writeString(os, vmVersion);
+  }
+
+  private void executeClassesBySignature(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    String sig = JdwpString.readString(bb);
+    ArrayList allMatchingClasses = new ArrayList();
+
+    // This will be an Iterator over all loaded Classes
+    Iterator iter = VMVirtualMachine.getAllLoadedClasses();
+
+    while (iter.hasNext())
+      {
+        Class clazz = (Class) iter.next();
+        String clazzSig = Signature.computeClassSignature(clazz);
+        if (clazzSig.equals(sig))
+          allMatchingClasses.add(clazz);
+      }
+
+    os.writeInt(allMatchingClasses.size());
+    for (int i = 0; i < allMatchingClasses.size(); i++)
+      {
+        Class clazz = (Class) allMatchingClasses.get(i);
+        ReferenceTypeId id = idMan.getReferenceTypeId(clazz);
+        id.writeTagged(os);
+        int status = VMVirtualMachine.getClassStatus(clazz);
+        os.writeInt(status);
+      }
+  }
+
+  private void executeAllClasses(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    // Disable garbage collection while we're collecting the info on loaded
+    // classes so we some classes don't get collected between the time we get
+    // the count and the time we get the list
+    //VMVirtualMachine.disableGarbageCollection();
+
+    int classCount = VMVirtualMachine.getAllLoadedClassesCount();
+    os.writeInt(classCount);
+
+    // This will be an Iterator over all loaded Classes
+    Iterator iter = VMVirtualMachine.getAllLoadedClasses();
+    //VMVirtualMachine.enableGarbageCollection();
+    int count = 0;
+
+    // Note it's possible classes were created since out classCount so make
+    // sure we don't write more classes than we told the debugger
+    while (iter.hasNext() && count++ < classCount)
+      {
+        Class clazz = (Class) iter.next();
+        ReferenceTypeId id = idMan.getReferenceTypeId(clazz);
+        id.writeTagged(os);
+        String sig = Signature.computeClassSignature(clazz);
+        JdwpString.writeString(os, sig);
+        int status = VMVirtualMachine.getClassStatus(clazz);
+        os.writeInt(status);
+      }
+  }
+
+  private void executeAllThreads(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ThreadGroup jdwpGroup = Thread.currentThread().getThreadGroup();
+    ThreadGroup root = getRootThreadGroup(jdwpGroup);
+
+    int numThreads = root.activeCount();
+    Thread allThreads[] = new Thread[numThreads];
+    root.enumerate(allThreads);
+
+    // We need to loop through for the true count since some threads may have
+    // been destroyed since we got
+    // activeCount so those spots in the array will be null. As well we must
+    // ignore any threads that belong to jdwp
+    numThreads = 0;
+    for (int i = 0; i < allThreads.length; i++)
+      {
+        Thread thread = allThreads[i];
+        if (thread == null)
+          break; // No threads after this point
+        if (!thread.getThreadGroup().equals(jdwpGroup))
+          numThreads++;
+      }
+
+    os.writeInt(numThreads);
+
+    for (int i = 0; i < allThreads.length; i++)
+      {
+        Thread thread = allThreads[i];
+        if (thread == null)
+          break; // No threads after this point
+        if (!thread.getThreadGroup().equals(jdwpGroup))
+          idMan.getObjectId(thread).write(os);
+      }
+  }
+
+  private void executeTopLevelThreadGroups(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    ThreadGroup jdwpGroup = Thread.currentThread().getThreadGroup ();
+    ThreadGroup root = getRootThreadGroup(jdwpGroup);
+
+    os.writeInt(1); // Just one top level group allowed?
+    idMan.getObjectId(root);
+  }
+
+  private void executeDispose(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException
+  {
+    // resumeAllThreads isn't sufficient as a thread may have been
+    // suspended multiple times, we likely need a way to keep track of how many
+    // times a thread has been suspended or else a stronger resume method for
+    // this purpose
+    // VMVirtualMachine.resumeAllThreads ();
+
+    // Simply shutting down the jdwp layer will take care of the rest of the
+    // shutdown other than disabling debugging in the VM
+    // VMVirtualMachine.disableDebugging();
+
+    // Don't implement this until we're sure how to remove all the debugging
+    // effects from the VM.
+    throw new NotImplementedException(
+      "Command VirtualMachine.Dispose not implemented");
+
+  }
+
+  private void executeIDsizes(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    os.writeInt(ObjectId.SIZE); // fieldId FIXME
+    os.writeInt(ObjectId.SIZE); // methodId FIXME
+    os.writeInt(ObjectId.SIZE); // objectId
+    os.writeInt(ReferenceTypeId.SIZE); // referenceTypeId
+    os.writeInt(VMFrame.SIZE); // frameId
+  }
+
+  private void executeSuspend(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException
+  {
+    VMVirtualMachine.suspendAllThreads ();
+  }
+
+  private void executeResume(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException
+  {
+    VMVirtualMachine.resumeAllThreads ();
+  }
+
+  private void executeExit(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    int exitCode = bb.getInt();
+    System.exit (exitCode);
+  }
+
+  private void executeCreateString(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    String string = JdwpString.readString(bb);
+    ObjectId stringId = idMan.getObjectId(string);
+    
+    // Since this string isn't referenced anywhere we'll disable garbage
+    // collection on it so it's still around when the debugger gets back to it.
+    stringId.disableCollection();
+    stringId.write(os);
+  }
+
+  private void executeCapabilities(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    // Store these somewhere?
+    os.writeBoolean(false); // canWatchFieldModification
+    os.writeBoolean(false); // canWatchFieldAccess
+    os.writeBoolean(false); // canGetBytecodes
+    os.writeBoolean(false); // canGetSyntheticAttribute
+    os.writeBoolean(false); // canGetOwnedMonitorInfo
+    os.writeBoolean(false); // canGetCurrentContendedMonitor
+    os.writeBoolean(false); // canGetMonitorInfo
+  }
+
+  private void executeClassPaths(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    String baseDir = System.getProperty("user.dir");
+    JdwpString.writeString(os, baseDir);
+
+    // Find and write the classpath
+    String classPath = System.getProperty("java.class.path");
+    String[] paths = classPath.split(":");
+
+    os.writeInt(paths.length);
+    for (int i = 0; i < paths.length; i++)
+      JdwpString.writeString(os, paths[i]);
+
+    // Now the bootpath
+    String bootPath = System.getProperty("sun.boot.class.path");
+    paths = bootPath.split(":");
+    os.writeInt(paths.length);
+    for (int i = 0; i < paths.length; i++)
+      JdwpString.writeString(os, paths[i]);
+  }
+
+  private void executeDisposeObjects(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException
+  {
+    // Instead of going through the list of objects they give us it's probably
+    // better just to find the garbage collected objects ourselves
+    //idMan.update();
+  }
+
+  private void executeHoldEvents(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException
+  {
+    // Going to have to implement a send queue somewhere and do this without
+    // triggering events
+    // Until then just don't implement
+    throw new NotImplementedException(
+      "Command VirtualMachine.HoldEvents not implemented");
+  }
+
+  // Opposite of executeHoldEvents
+  private void executeReleaseEvents(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException
+  {
+    throw new NotImplementedException(
+      "Command VirtualMachine.ReleaseEvents not implemented");
+  }
+
+  private void executeCapabilitiesNew(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException, IOException
+  {
+    // Store these somewhere?
+    final int CAPABILITIES_NEW_SIZE = 32;
+    os.writeBoolean(false); // canWatchFieldModification
+    os.writeBoolean(false); // canWatchFieldAccess
+    os.writeBoolean(false); // canGetBytecodes
+    os.writeBoolean(false); // canGetSyntheticAttribute
+    os.writeBoolean(false); // canGetOwnedMonitorInfo
+    os.writeBoolean(false); // canGetCurrentContendedMonitor
+    os.writeBoolean(false); // canGetMonitorInfo
+    os.writeBoolean(false); // canRedefineClasses
+    os.writeBoolean(false); // canAddMethod
+    os.writeBoolean(false); // canUnrestrictedlyRedefineClasses
+    os.writeBoolean(false); // canPopFrames
+    os.writeBoolean(false); // canUseInstanceFilters
+    os.writeBoolean(false); // canGetSourceDebugExtension
+    os.writeBoolean(false); // canRequestVMDeathEvent
+    os.writeBoolean(false); // canSetDefaultStratum
+    for (int i = 15; i < CAPABILITIES_NEW_SIZE; i++)
+      // Future capabilities
+      // currently unused
+      os.writeBoolean(false); // Set to false
+  }
+
+  private void executeRedefineClasses(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException
+  {
+    // Optional command, don't implement
+    throw new NotImplementedException(
+      "Command VirtualMachine.RedefineClasses not implemented");
+  }
+
+  private void executeSetDefaultStratum(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException
+  {
+    // Optional command, don't implement
+    throw new NotImplementedException(
+      "Command VirtualMachine.SetDefaultStratum not implemented");
+  }
+
+  private void executeAllClassesWithGeneric(ByteBuffer bb, DataOutputStream os)
+    throws JdwpException
+  {
+    // We don't handle generics
+    throw new NotImplementedException(
+      "Command VirtualMachine.AllClassesWithGeneric not implemented");
+  }
+
+  /**
+   * Find the root ThreadGroup of this ThreadGroup
+   */
+  private ThreadGroup getRootThreadGroup(ThreadGroup group)
+  {
+    ThreadGroup parent = group.getParent();
+
+    while (parent != null)
+      {
+        group = parent;
+        parent = group.getParent();
+      }
+    return group; // This group was the root
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/ITransport.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/ITransport.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,88 @@
+/* ITransport.java -- An interface defining JDWP transports
+   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
+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.transport;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+
+/**
+ * A class representing a transport layer. This class serves as a generic
+ * interface for all transport types used in the JDWP back-end.
+ *
+ * @author Keith Seitz (keiths at redhat.com)
+ */
+public interface ITransport
+{
+  /**
+   * Configure the transport with the given properties
+   *
+   * @param   properties  properties of the transport configuration
+   * @throws  TransportException on configury error
+   */
+  public void configure (HashMap properties)
+    throws TransportException;
+
+  /**
+   * Initialize the transport
+   *
+   * @throws  TransportException on initialization error
+   */
+  public void initialize ()
+    throws TransportException;
+
+  /**
+   * Shutdown the transport
+   */
+  public void shutdown ();
+
+  /**
+   * Get the input stream for the transport
+   */
+  public InputStream getInputStream ()
+    throws IOException;
+
+  /**
+   * Get the output stream for the transport
+   */
+  public OutputStream getOutputStream ()
+    throws IOException;
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/JdwpCommandPacket.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/JdwpCommandPacket.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,149 @@
+/* JdwpCommandPacket.java -- JDWP command packet
+   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
+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.transport;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * A class representing a JDWP command packet.
+ * This class adds command set and command to the packet header
+ * information in {@link gnu.classpath.jdwp.transport.JdwpPacket}
+ * and adds additional command packet-specific processing.
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class JdwpCommandPacket extends JdwpPacket
+{
+  /**
+   * Command set
+   */
+  protected byte _commandSet;
+
+  /**
+   * Command
+   */
+  protected byte _command;
+
+  // Minimum packet size [excluding super class]
+  // ( commandSet (1) + command (1) )
+  private static final int MINIMUM_LENGTH = 2;
+
+  /**
+   * Constructs a new <code>JdwpCommandPacket</code>
+   */
+  public JdwpCommandPacket ()
+  {
+    // Don't assign an id. This constructor is called by
+    // JdwpPacket.fromBytes, and that will assign a packet id.
+  }
+  
+  /**
+   * Constructs a new <code>JdwpCommandPacket</code>
+   * with the given command set and command
+   *
+   * @param set      the command set
+   * @param command  the command
+   */
+  public JdwpCommandPacket (byte set, byte command)
+  {
+    _id = ++_last_id;
+    _commandSet = set;
+    _command = command;
+  }
+
+  /**
+   * Retuns the length of this packet
+   */
+  public int getLength ()
+  {
+    return MINIMUM_LENGTH + super.getLength ();
+  }
+
+  /**
+   * Returns the command set
+   */
+  public byte getCommandSet ()
+  {
+    return _commandSet;
+  }
+
+  /**
+   * Sets the command set
+   */
+  public void setCommandSet (byte cs)
+  { 
+    _commandSet = cs;
+  }
+
+  /**
+   * Returns the command
+   */
+  public byte getCommand ()
+  {
+    return _command;
+  }
+
+  /**
+   * Sets the command
+   */
+  public void setCommand (byte cmd)
+  {
+    _command = cmd;
+  }
+
+  // Reads command packet data from the given buffer, starting
+  // at the given offset
+  protected int myFromBytes (byte[] bytes, int index)
+  {
+    int i = 0;
+    setCommandSet (bytes[index + i++]);
+    setCommand (bytes[index + i++]);
+    return i;
+  }
+
+  // Writes the command packet data into the given buffer
+  protected void myWrite (DataOutputStream dos)
+    throws IOException
+  {
+    dos.writeByte (getCommandSet ());
+    dos.writeByte (getCommand ());
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/JdwpConnection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/JdwpConnection.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,303 @@
+/* JdwpConnection.java -- A JDWP-speaking connection
+   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.transport;
+
+import gnu.classpath.jdwp.Jdwp;
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.event.EventRequest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * A connection via some transport to some JDWP-speaking entity.
+ * This is also a thread which handles all communications to/from
+ * the debugger. While access to the transport layer may be accessed by
+ * several threads, start-up and initialization should not be allowed
+ * to occur more than once.
+ *
+ * <p>This class is also a thread that is responsible for pulling
+ * packets off the wire and sticking them in a queue for packet
+ * processing threads.
+ * 
+ * @author Keith Seitz (keiths at redhat.com)
+ */
+public class JdwpConnection
+  extends Thread
+{
+  // The JDWP handshake
+  private static final byte[] _HANDSHAKE = {'J', 'D', 'W', 'P', '-', 'H', 'a',
+					    'n', 'd', 's', 'h', 'a', 'k', 'e'};
+
+  // Transport method
+  private ITransport _transport;
+
+  // Command queue
+  private ArrayList _commandQueue;
+
+  // Shutdown flag
+  private boolean _shutdown;
+
+  // Input stream from transport
+  private DataInputStream _inStream;
+
+  // Output stream from transprot
+  private DataOutputStream _outStream;
+
+  // A buffer used to construct the packet data
+  private ByteArrayOutputStream _bytes;
+
+  // A DataOutputStream for the byte buffer
+  private DataOutputStream _doStream;
+
+  /**
+   * Creates a new <code>JdwpConnection</code> instance
+   *
+   * @param transport  the transport to use for communications
+   */
+  public JdwpConnection (ThreadGroup group, ITransport transport)
+  {
+    super (group, "JDWP connection thread");
+    _transport = transport;
+    _commandQueue = new ArrayList ();
+    _shutdown = false;
+    _bytes = new ByteArrayOutputStream ();
+    _doStream = new DataOutputStream (_bytes);
+  }
+
+  /**
+   * Initializes the connection, including connecting
+   * to socket or shared memory endpoint
+   *
+   * @throws TransportException if initialization fails
+   */
+  public void initialize ()
+    throws TransportException
+  {
+    // Initialize transport (connect socket, e.g.)
+    _transport.initialize ();
+
+    // Do handshake
+    try
+      {
+	_inStream = new DataInputStream (_transport.getInputStream ());
+	_outStream = new DataOutputStream (_transport.getOutputStream ());
+	_doHandshake ();
+      }
+    catch (IOException ioe)
+      {
+	throw new TransportException (ioe);
+      }
+  }
+
+  /* Does the JDWP handshake -- this should not need synchronization
+     because this is called by VM startup code, i.e., no packet
+     processing threads have started yet. */
+  private void _doHandshake ()
+    throws IOException
+  {
+    // According to the spec, the handshake is always initiated by
+    // the debugger, regardless of whether the JVM is in client mode or
+    // server mode.
+
+    // Wait for handshake from debugger
+    byte[] hshake = new byte[_HANDSHAKE.length];
+    _inStream.readFully (hshake, 0, _HANDSHAKE.length);
+
+    if (Arrays.equals (hshake, _HANDSHAKE))
+      {
+	// Send reply handshake
+	_outStream.write (_HANDSHAKE, 0, _HANDSHAKE.length);
+	return;
+      }
+    else
+      {
+	throw new IOException ("invalid JDWP handshake (\"" + hshake + "\")");
+      }
+  }
+
+  /**
+   * Main run method for the thread. This thread loops waiting for
+   * packets to be read via the connection. When a packet is complete
+   * and ready for processing, it places the packet in a queue that can
+   * be accessed via <code>getPacket</code>
+   */
+  public void run ()
+  {
+    // Notify initialization thread (gnu.classpath.jdwp.Jdwp) that
+    // the JdwpConnection thread is ready.
+    Jdwp.getDefault().subcomponentInitialized ();
+
+    while (!_shutdown)
+      {
+	try
+	  {
+	    _readOnePacket ();
+	  }
+	catch (IOException ioe)
+	  {
+	    /* IOException can occur for two reasons:
+	       1. Lost connection with the other side
+	       2. Transport was shutdown
+	       In either case, we make sure that all of the
+	       back-end gets shutdown. */
+	    Jdwp.getDefault().shutdown ();
+	  }
+	catch (Throwable t)
+	  {
+	    System.out.println ("JdwpConnection.run: caught an exception: "
+				+ t);
+	    // Just keep going
+	  }
+      }
+  }
+
+  // Reads a single packet from the connection, adding it to the packet
+  // queue when a complete packet is ready.
+  private void _readOnePacket ()
+    throws IOException
+  {
+    byte[] data = null;
+
+    // Read in the packet
+    int length = _inStream.readInt ();
+    if (length < 11)
+      {
+	throw new IOException ("JDWP packet length < 11 (" 
+			       + length + ")");
+      }
+
+    data = new byte[length];
+    data[0] = (byte) (length >>> 24);
+    data[1] = (byte) (length >>> 16);
+    data[2] = (byte) (length >>> 8);
+    data[3] = (byte) length;
+    _inStream.readFully (data, 4, length - 4);
+
+    JdwpPacket packet = JdwpPacket.fromBytes (data);
+    if (packet != null)
+      {
+	synchronized (_commandQueue)
+	  {
+	    _commandQueue.add (packet);
+	    _commandQueue.notifyAll ();
+	  }
+      }
+  }
+
+  /**
+   * Returns a packet from the queue of ready packets
+   *
+   * @returns  a <code>JdwpPacket</code> ready for processing
+   *           <code>null</code> when shutting down
+   */
+  public JdwpPacket getPacket ()
+  {
+    synchronized (_commandQueue)
+      {
+	while (_commandQueue.isEmpty ())
+	  {
+	    try
+	      {
+		_commandQueue.wait ();
+	      }
+	    catch (InterruptedException ie)
+	      {
+		/* PacketProcessor is interrupted
+		   when shutting down */
+		return null;
+	      }
+	  }
+
+	return (JdwpPacket) _commandQueue.remove (0);
+      }
+  }
+
+  /**
+   * Send a packet to the debugger
+   *
+   * @param pkt a <code>JdwpPacket</code> to send
+   * @throws IOException
+   */
+  public void sendPacket (JdwpPacket pkt)
+    throws IOException
+  {
+    pkt.write (_outStream);
+  }
+
+  /**
+   * Send an event notification to the debugger
+   *
+   * @param request  the debugger request that wanted this event
+   * @param event    the event
+   * @throws IOException
+   */
+  public void sendEvent (EventRequest request, Event event)
+    throws IOException
+  {
+    JdwpPacket pkt;
+
+    synchronized (_bytes)
+      {
+	_bytes.reset ();
+	pkt = event.toPacket (_doStream, request);
+	pkt.setData (_bytes.toByteArray ());
+      }
+
+    sendPacket (pkt);
+  }
+
+  /**
+   * Shutdown the connection
+   */
+  public void shutdown ()
+  {
+    if (!_shutdown)
+      {
+	_transport.shutdown ();
+	_shutdown = true;
+	interrupt ();
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/JdwpPacket.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/JdwpPacket.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,277 @@
+/* JdwpPacket.java -- Base class for JDWP command and reply packets
+   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
+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.transport;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * All command and reply packets in JDWP share
+ * common header type information:
+ *
+ *    length (4 bytes) : size of entire packet, including length
+ *    id     (4 bytes) : unique packet id
+ *    flags  (1 byte)  : flag byte
+ *    [command packet stuff | reply packet stuff]
+ *    data   (variable) : unique command-/reply-specific data
+ *
+ * This class deal with everything except the command- and reply-specific
+ * data, which get handled in {@link
+ * gnu.classpath.jdwp.transport.JdwpCommandPacket} and {@link
+ * gnu.classpath.jdwp.transport.JdwpReplyPacket}.
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public abstract class JdwpPacket
+{
+  // Last id of packet constructed
+  protected static int _last_id = 0;
+
+  // JDWP reply packet flag
+  protected static final int JDWP_FLAG_REPLY = 0x80;
+
+  /**
+   * Minimum packet size excluding sub-class data
+   * ( length (4) + id (4) + flags (1) )
+   */
+  protected static final int MINIMUM_SIZE = 9;
+
+  /**
+   * Id of command/reply
+   */
+  protected int _id;
+
+  /**
+   * Packet flags
+   */
+  protected byte _flags;
+
+  /**
+   * Packet-specific data
+   */
+  protected byte[] _data;
+
+  /**
+   * Constructor
+   */
+  public JdwpPacket ()
+  {
+    // By default, DON'T assign an id. This way when a packet
+    // is constructed from fromBytes, _last_id won't increment (i.e.,
+    // it won't leave holes in the outgoing packet ids).
+  }
+
+  /**
+   * Constructs a <code>JdwpPacket</code> with the id
+   * from the given packet.
+   *
+   * @param pkt  a packet whose id will be used in this new packet
+   */
+  public JdwpPacket (JdwpPacket pkt)
+  {
+    _id = pkt.getId ();
+  }
+
+  /**
+   * Returns the packet id
+   */
+  public int getId ()
+  { 
+    return _id;
+  }
+
+  /**
+   * Sets the packet id
+   */
+  public void setId (int id)
+  { 
+    _id = id;
+  }
+
+  /**
+   * Returns the packet flags
+   */
+  public byte getFlags ()
+  { 
+    return _flags;
+  }
+
+  /**
+   * Sets the packet flags
+   */
+  public void setFlags (byte flags)
+  { 
+    _flags = flags;
+  }
+
+  /**
+   * Gets the command/reply-specific data in this packet
+   */
+  public byte[] getData ()
+  { 
+    return _data;
+  }
+
+  /**
+   * Sets the command/reply-specific data in this packet
+   */
+  public void setData (byte[] data)
+  { 
+    _data = data;
+  }
+
+  /**
+   * Returns the length of this entire packet
+   */
+  public int getLength ()
+  { 
+    return MINIMUM_SIZE + (_data == null ? 0 : _data.length);
+  }
+
+  /**
+   * Allow subclasses to initialize from data
+   * 
+   * @param   bytes  packet data from the wire
+   * @param   index  index into <code>bytes</code> to start processing
+   * @return         number of bytes in <code>bytes</code> processed
+   */
+  protected abstract int myFromBytes (byte[] bytes, int index);
+
+  /**
+   * Convert the given bytes into a <code>JdwpPacket</code>. Uses the
+   * abstract method <code>myFromBytes</code> to allow subclasses to
+   * process data.
+   *
+   * If the given data does not represent a valid JDWP packet, it returns
+   * <code>null</code>.
+   * 
+   * @param   bytes  packet data from the wire
+   * @return         number of bytes in <code>bytes</code> processed
+   */
+  public static JdwpPacket fromBytes (byte[] bytes)
+  {
+    int i = 0;
+    int length = ((bytes[i++] & 0xff) << 24 | (bytes[i++] & 0xff) << 16
+                  | (bytes[i++] & 0xff) << 8 | (bytes[i++] & 0xff));
+    int id = 0;
+    byte flags = 0;
+
+    if (bytes.length == length)
+      {
+	id = ((bytes[i++] & 0xff) << 24 | (bytes[i++] & 0xff) << 16
+              | (bytes[i++] & 0xff) << 8 | (bytes[i++] & 0xff));
+	flags = bytes[i++];
+
+	Class clazz = null;
+	if (flags == 0)
+	  clazz = JdwpCommandPacket.class;
+	else if ((flags & JDWP_FLAG_REPLY) != 0)
+	  clazz = JdwpReplyPacket.class;
+	else
+	  {
+	    // Malformed packet. Discard it.
+	    return null;
+	  }
+
+	JdwpPacket pkt = null;
+	try
+	  {
+	    pkt = (JdwpPacket) clazz.newInstance ();
+	  }
+	catch (InstantiationException ie)
+	  {
+	    // Discard packet
+	    return null;
+	  }
+	catch (IllegalAccessException iae)
+	  {
+	    // Discard packet
+	    return null;
+	  }
+
+	pkt.setId (id);
+	pkt.setFlags (flags);
+
+	i += pkt.myFromBytes (bytes, i);
+	byte[] data = new byte[length - i];
+	System.arraycopy (bytes, i, data, 0, data.length);
+	pkt.setData (data);
+
+	return pkt;
+      }
+	
+    return null;
+  }
+
+  /**
+   * Put subclass information onto the stream
+   *
+   * @param dos the output stream to which to write
+   */
+  protected abstract void myWrite (DataOutputStream dos)
+    throws IOException;
+
+  /**
+   * Writes the packet to the output stream
+   *
+   * @param dos  the output stream to which to write the packet
+   */
+  public void write (DataOutputStream dos)
+    throws IOException
+  {
+    // length
+    int length = getLength ();
+    dos.writeInt (length);
+
+    // ID
+    dos.writeInt (getId ());
+
+    // flag
+    dos.writeByte (getFlags ());
+
+    // packet-specific stuff
+    myWrite (dos);
+
+    // data (if any)
+    byte[] data = getData ();
+    if (data != null && data.length > 0)
+      dos.write (data, 0, data.length);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/JdwpReplyPacket.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/JdwpReplyPacket.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,137 @@
+/* JdwpReplyPacket.java -- JDWP reply packet
+   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
+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.transport;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * A class represents a JDWP reply packet.
+ * This class adds an error code to the packet header information
+ * in {@link gnu.classpath.jdwp.transport.JdwpPacket} and adds additional
+ * reply packet-specific processing.
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class JdwpReplyPacket extends JdwpPacket
+{
+  /**
+   * Error code
+   */
+  protected short _errorCode;
+
+  // Minimum packet size [excluding super class] ( errorCode (2) )
+  private static final int MINIMUM_LENGTH = 2;
+
+  /**
+   * Constructs a <code>JdwpReplyPacket</code>.
+   */
+  public JdwpReplyPacket ()
+  {
+    // Don't assign a packet id. This is called by JdwpPacket.fromBytes
+    // which assigns a packet id. (Not that a VM would do that...)
+  }
+
+  /**
+   * Constructs a <code>JdwpReplyPacket</code> with the
+   * id from the given packet and error code
+   *
+   * @param pkt        the packet whose id this packet will use
+   * @param errorCode  the error code
+   */
+  public JdwpReplyPacket (JdwpPacket pkt, short errorCode)
+  {
+    this(pkt);
+    _errorCode = errorCode;
+  }
+
+  /**
+   * Constructs a <code>JdwpReplyPacket</code> with the
+   * id from the given packet and an empty error code
+   *
+   * @param pkt        the packet whose id this packet will use
+   */
+  public JdwpReplyPacket (JdwpPacket pkt)
+  {
+    super (pkt);
+    _flags = (byte) JDWP_FLAG_REPLY;
+  }
+
+  /**
+   * Returns the length of this packet
+   */
+  public int getLength ()
+  {
+    return MINIMUM_LENGTH + super.getLength ();
+  }
+
+  /**
+   * Returns the error code
+   */
+  public short getErrorCode ()
+  {
+    return _errorCode;
+  }
+
+  /**
+   * Sets the error code
+   */
+  public void setErrorCode (short ec)
+  {
+    _errorCode = ec;
+  }
+
+  // Reads command packet data from the given buffer, starting
+  // at the given offset
+  protected int myFromBytes (byte[] bytes, int index)
+  {
+    int i = 0;
+    setErrorCode ((short) ((bytes[index + i++] & 0xff) << 8
+			   | (bytes[index + i++] & 0xff)));
+    return i;
+  }
+
+  // Writes the command packet data into the given buffer
+  protected void myWrite (DataOutputStream dos)
+    throws IOException
+ {
+    dos.writeShort (getErrorCode ());
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/SocketTransport.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/SocketTransport.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,187 @@
+/* SocketTransport.java -- a socket transport
+   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
+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.transport;
+
+import gnu.classpath.jdwp.transport.ITransport;
+import gnu.classpath.jdwp.transport.TransportException;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.HashMap;
+
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+
+/**
+ * A socket-based transport. This transport uses
+ * configury string that looks like "name=dt_socket,
+ * address=localhost:1234,server=y".
+ *
+ * @author Keith Seitz (keiths at redhat.com)
+ */
+class SocketTransport
+  implements ITransport
+{
+  /**
+   * Name of this transport
+   */
+  public static final String NAME = "dt_socket";
+
+  // Configure properties
+  private static final String _PROPERTY_ADDRESS = "address";
+  private static final String _PROPERTY_SERVER = "server";
+
+  // Port number
+  private int _port;
+
+  // Host name
+  private String _host;
+   
+  // Are we acting as a server?
+  private boolean _server = false;
+
+  // Socket
+  private Socket _socket;
+
+  /**
+   * Setup the connection configuration from the given properties
+   *
+   * @param  properties  the properties of the JDWP session
+   * @throws TransportException for any configury errors
+   */
+  public void configure (HashMap properties)
+    throws TransportException
+  {
+    // Get address [form: "hostname:port"]
+    String p = (String) properties.get (_PROPERTY_ADDRESS);
+    if (p != null)
+      {
+	String[] s = p.split (":");
+	if (s.length == 2)
+	  {
+	    _host = s[0];
+	    _port = Integer.parseInt (s[1]);
+	  }
+      }
+
+    // Get server [form: "y" or "n"]
+    p = (String) properties.get (_PROPERTY_SERVER);
+    if (p != null)
+      {
+	if (p.toLowerCase().equals ("y"))
+	  _server = true;
+      }
+  }
+
+  /**
+   * Initialize this socket connection. This includes
+   * connecting to the host (or listening for it).
+   *
+   * @throws TransportException if a transport-related error occurs
+   */
+  public void initialize ()
+    throws TransportException
+  {
+    try
+      {
+	if (_server)
+	  {
+	    // Get a server socket
+	    ServerSocketFactory ssf = ServerSocketFactory.getDefault ();
+	    ServerSocket ss = ssf.createServerSocket (_port, 1);
+	    _socket = ss.accept ();
+	  }
+	else
+	  {
+	    // Get a client socket (the factory will connect it)
+	    SocketFactory sf = SocketFactory.getDefault ();
+	    _socket = sf.createSocket (_host, _port);
+	  }
+      }
+    catch (IOException ioe)
+      {
+	// This will grab UnknownHostException, too.
+	throw new TransportException (ioe);
+      }
+  }
+
+  /**
+   * Shutdown the socket. This could cause SocketExceptions
+   * for anyone blocked on socket i/o
+   */
+  public void shutdown ()
+  {
+    try
+      {
+	_socket.close ();
+      }
+    catch (Throwable t)
+      {
+	// We don't really care about errors at this point
+      }
+  }
+
+  /**
+   * Returns an <code>InputStream</code> for the transport
+   *
+   * @throws IOException if an I/O error occurs creating the stream
+   *                     or the socket is not connected
+   */
+  public InputStream getInputStream ()
+    throws IOException
+  {
+    return _socket.getInputStream ();
+  }
+
+  /**
+   * Returns an <code>OutputStream</code> for the transport
+   *
+   * @throws IOException if an I/O error occurs creating the stream
+   *                     or the socket is not connected
+   */
+  public OutputStream getOutputStream ()
+    throws IOException
+  {
+    return _socket.getOutputStream ();
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/TransportException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/TransportException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* TransportException.java -- Exception for transport configury errors
+   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
+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.transport;
+
+/**
+ * A transport configury or initialization exception thrown by
+ * JDWP transports. This class is a generic exception class
+ * that the different transport layers use to report transport-specific
+ * exceptions that may occur (which could be very different from
+ * one transport to the next.).
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class TransportException
+  extends Exception
+{
+  /**
+   * Constructs a <code>TransportException</code> with the
+   * given message
+   *
+   * @param message  a message describing the exception
+   */
+  public TransportException (String message)
+  {
+    super (message);
+  }
+
+  /**
+   * Constructs a <code>TransportException</code> with the
+   * given <code>Throwable</code> root cause
+   *
+   * @param t  the cause of the exception
+   */
+  public TransportException (Throwable t)
+  {
+    super (t);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/TransportFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/transport/TransportFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,115 @@
+/* TransportFactory.java -- Factory for transports
+   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
+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.transport;
+
+import java.util.HashMap;
+
+/**
+ * A factory class that constructs transports for use by
+ * the JDWP back-end.
+ *
+ * @author Keith Seitz  <keiths at redhat.com>
+ */
+public class TransportFactory
+{
+  // Keyword in configspec that specifies transport method
+  private static final String _TRANSPORT_PROPERTY = "transport";
+
+  // A single transport method mapping
+  private static class TransportMethod
+  {
+    String name;
+    Class clazz;
+    public TransportMethod (String name, Class clazz)
+    {
+      this.name = name;
+      this.clazz = clazz;
+    }
+  }
+
+  // List of all supported transport methods
+  private static TransportMethod[] _transportMethods = new TransportMethod[]
+  {
+    new TransportMethod (SocketTransport.NAME, SocketTransport.class)
+    //new TransportMethod (ShmemTransport.NAME, ShmemTransport.class)
+  };
+
+  /**
+   * Get a transport configured as specified in the properties
+   *
+   * @param   properties  a <code>HashMap</code> specifying the JDWP
+   *                      configuration properties
+   * @returns             the created and configured transport
+   * @throws  TransportException for invalid configurations
+   */
+  public static ITransport newInstance (HashMap properties)
+    throws TransportException
+  {
+    String name = null;
+    if (properties != null)
+      name = (String) properties.get (_TRANSPORT_PROPERTY);
+    if (name == null)
+      throw new TransportException ("no transport specified");
+
+    for (int i = 0; i < _transportMethods.length; ++i)
+      {
+	if (_transportMethods[i].name.equals (name))
+	  {
+	    try
+	      {
+		ITransport t;
+		t = (ITransport) _transportMethods[i].clazz.newInstance ();
+		t.configure (properties);
+		return t;
+	      }
+	    catch (TransportException te)
+	      {
+		throw te;
+	      }
+	    catch (Exception e)
+	      {
+		throw new TransportException (e);
+	      }
+	  }
+      }
+
+    throw new TransportException ("transport \"" + name + "\" not found");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/JdwpString.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/JdwpString.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,95 @@
+/* JdwpString.java -- utility class to read and write jdwp strings
+   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.jdwp.util;
+
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class to compute the JDWP representation of Strings.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class JdwpString
+{
+
+  /**
+   * Write this String to the outStream as a string understood by jdwp.
+   * 
+   * @param os write the String here
+   * @param string the String to write
+   * @throws IOException
+   */
+  public static void writeString(DataOutputStream os, String string)
+      throws IOException
+  {
+    // Get the bytes of the string as a string in UTF-8
+    byte[] strBytes = string.getBytes("UTF-8");
+    os.writeInt(strBytes.length);
+    os.write(strBytes);
+  }
+
+  /**
+   * Read a jdwp style string from the ByteBuffer.
+   * 
+   * @param bb contains the string
+   * @return the String that was read
+   * @throws JdwpInternalErrorException bb didn't contain a value UTF-8 string
+   */
+  public static String readString(ByteBuffer bb)
+      throws JdwpInternalErrorException
+  {
+    int length = bb.getInt();
+    byte[] strBytes = new byte[length];
+    bb.get(strBytes);
+    try
+      {
+        return new String(strBytes, "UTF-8");
+      }
+    catch (UnsupportedEncodingException ex)
+      {
+        // Any string from the VM should be in UTF-8 so an encoding error
+        // shouldn't be possible
+        throw new JdwpInternalErrorException(ex);
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/LineTable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/LineTable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,95 @@
+/* LineTable.java -- A class representing a Line Table for a method
+   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.util;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * A class representing a Line Table for a method.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class LineTable
+{
+
+  private final long start;
+  private final long end;
+  private final int[] lineNum;
+  private final long[] lineCI;
+
+  /**
+   * Construct a line table with the given parameters.
+   * 
+   * @param start lowest code index for method, -1 if native
+   * @param end highest code index for method, -1 if native
+   * @param lineNum line numbers for in line tables
+   * @param lineCI code indicies for entries in line tables
+   */
+  public LineTable(long start, long end, int[] lineNum, long[] lineCI)
+  {
+    if (lineNum.length != lineCI.length)
+      throw new AssertionError("code index and line numbers tables "
+                               + "not same length");
+    this.start = start;
+    this.end = end;
+    this.lineNum = lineNum;
+    this.lineCI = lineCI;
+  }
+  
+  /**
+   * Writes this line table to the given DataOutputStream.
+   * 
+   * @param os the stream to write it to
+   * @throws IOException
+   */
+  public void write(DataOutputStream os)
+    throws IOException
+  {
+    os.writeLong(start);
+    os.writeLong(end);
+    os.writeInt(lineNum.length);
+    for (int i = 0; i < lineNum.length; i++)
+      {
+        os.writeLong(lineCI[i]);
+        os.writeInt(lineNum[i]);
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/Location.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/Location.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,156 @@
+/* Location.java -- class to read/write JDWP locations
+   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
+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.util;
+
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.VMMethod;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.id.ClassReferenceTypeId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class to read/write JDWP locations.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class Location
+{
+  private VMMethod method;
+  private long index;
+
+  /**
+   * Create a location with the given parameters.
+   * 
+   * @param method the method
+   * @param index location in the method
+   */
+  public Location(VMMethod method, long index)
+  {
+    this.method = method;
+    this.index = index;
+  }
+
+  /**
+   * Read a location from the given bytebuffer, consists of a TAG (byte),
+   * followed by a ReferenceTypeId, a MethodId and an index (long).
+   * 
+   * @param bb this holds the location
+   * @throws IOException    when an error occurs reading from the buffer
+   * @throws JdwpException  for invalid class or method IDs
+   */
+  public Location(ByteBuffer bb)
+    throws IOException, JdwpException
+  {
+    byte tag = bb.get();
+    ClassReferenceTypeId classId = 
+      (ClassReferenceTypeId) VMIdManager.getDefault().readReferenceTypeId(bb);
+    Class klass = classId.getType();
+    method = VMMethod.readId(klass, bb);
+    index = bb.getLong();
+  }
+
+  /**
+   * Write the given location to an output stream.
+   * 
+   * @param os stream to write to
+   * @throws IOException when an error occurs writing to the stream
+   */
+  public void write(DataOutputStream os) 
+    throws IOException
+  {
+    // check if this is an empty location
+    if (method != null)
+      {
+        VMIdManager idm = VMIdManager.getDefault();
+        ClassReferenceTypeId crti = 
+          (ClassReferenceTypeId) 
+          idm.getReferenceTypeId(method.getDeclaringClass());
+
+        crti.writeTagged(os);
+        method.writeId(os);
+        os.writeLong(index);
+      }
+    else
+      {
+        os.writeByte(1);
+        os.writeLong((long) 0);
+        os.writeLong((long) 0);
+        os.writeLong((long) 0);
+      }
+  }
+  
+  /**
+   * Sets up an empty location
+   * 
+   * @return new Location (setup as empty)
+   */
+  public static Location getEmptyLocation()
+  {
+       return new Location(null, 0);
+  }
+   
+  /**
+   * Gets the method of this location
+   * 
+   * @return the method
+   */
+  public VMMethod getMethod()
+  {
+    return method;
+  }
+
+  /**
+   * Gets the code index of this location
+   * 
+   * @return the code index
+   */
+  public long getIndex ()
+  {
+    return index;
+  }
+
+  // convenient for debugging
+  public String toString ()
+  {
+    return method.toString () + "." + index;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/MethodResult.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/MethodResult.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* MethodResult.java -- class to wrap around values returned from a Method call
+   in the VM 
+   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
+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.util;
+
+/**
+ * A class to wrap around values returned from a Method call in the VM.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class MethodResult
+{
+  // The Object returned by the executing method
+  private Object returnedValue;
+  
+  // Any Exception that was thrown by the executing method
+  private Exception thrownException;
+
+  public Object getReturnedValue()
+  {
+    return returnedValue;
+  }
+
+  public void setReturnedValue(Object returnedValue)
+  {
+    this.returnedValue = returnedValue;
+  }
+
+  public Exception getThrownException()
+  {
+    return thrownException;
+  }
+
+  public void setThrownException(Exception thrownException)
+  {
+    this.thrownException = thrownException;
+  }
+  
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/Signature.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/Signature.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,149 @@
+/* Signature.java -- utility class to compute class and method signatures
+   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
+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.util;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * A class to compute class and method signatures.
+ *
+ * @author Tom Tromey  (tromey at redhat.com)
+ * @author Keith Seitz  (keiths at redhat.com)
+ */
+public class Signature
+{
+  /**
+   * Computes the class signature, i.e., java.lang.String.class
+   * returns "Ljava/lang/String;".
+   *
+   * @param theClass  the class for which to compute the signature
+   * @return          the class's type signature
+   */
+  public static String computeClassSignature (Class theClass)
+  {
+    StringBuffer sb = new StringBuffer ();
+    _addToSignature (sb, theClass);
+    return sb.toString ();
+  }
+
+  /**
+   * Computes the field signature which is just the class signature of the
+   * field's type, ie a Field of type java.lang.String this will return
+   * "Ljava/lang/String;".
+   *
+   * @param field  the field for which to compute the signature
+   * @return       the field's type signature
+   */
+  public static String computeFieldSignature (Field field)
+  {
+    return computeClassSignature (field.getType());
+  }
+
+  /**
+   * Computes the method signature, i.e., java.lang.String.split (String, int)
+   * returns "(Ljava/lang/String;I)[Ljava/lang/String;"
+   *
+   * @param method  the method for which to compute the signature
+   * @return        the method's type signature
+   */
+  public static String computeMethodSignature (Method method)
+  {
+    return _computeSignature (method.getReturnType (),
+			      method.getParameterTypes ());
+  }
+
+  private static String _computeSignature (Class returnType,
+					   Class[] paramTypes)
+  {
+    StringBuffer sb = new StringBuffer ("(");
+    if (paramTypes != null)
+      {
+	for (int i = 0; i < paramTypes.length; ++i)
+	  _addToSignature (sb, paramTypes[i]);
+      }
+    sb.append (")");
+    _addToSignature (sb, returnType);
+    return sb.toString();
+  }
+
+  private static void _addToSignature (StringBuffer sb, Class k)
+  {
+    // For some reason there's no easy way to get the signature of a
+    // class.
+    if (k.isPrimitive ())
+      {
+        if (k == void.class)
+          sb.append('V');
+        else if (k == boolean.class)
+          sb.append('Z');
+        else if (k == byte.class)
+          sb.append('B');
+        else if (k == char.class)
+          sb.append('C');
+        else if (k == short.class)
+          sb.append('S');
+        else if (k == int.class)
+          sb.append('I');
+        else if (k == float.class)
+          sb.append('F');
+        else if (k == double.class)
+          sb.append('D');
+        else if (k == long.class)
+          sb.append('J');
+        return;
+      }
+    
+    String name = k.getName ();
+    int len = name.length ();
+    sb.ensureCapacity (len);
+    if (! k.isArray ())
+      sb.append('L');
+    for (int i = 0; i < len; ++i)
+      {
+	char c = name.charAt (i);
+	if (c == '.')
+	  c = '/';
+	sb.append (c);
+      }
+    if (! k.isArray ())
+      sb.append(';');
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/Value.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/Value.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,301 @@
+/* Value.java -- class to read/write JDWP tagged and untagged values
+   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
+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.util;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.exception.InvalidFieldException;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class to read/write JDWP tagged and untagged values.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class Value
+{
+  /**
+   * Will write the given object as an untagged value to the DataOutputStream.
+   * 
+   * @param os write the value here
+   * @param obj the Object to write
+   * @throws IOException
+   * @throws InvalidFieldException
+   */  
+  public static void writeUntaggedValue(DataOutputStream os, Object obj)
+    throws JdwpException, IOException
+  {
+    writeValue(os, obj, false);
+  }
+  
+  /**
+   * Will write the given object as a tagged value to the DataOutputStream.
+   * 
+   * @param os write the value here
+   * @param obj the Object to write
+   * @throws IOException
+   * @throws InvalidFieldException
+   */
+  public static void writeTaggedValue(DataOutputStream os, Object obj)
+    throws JdwpException, IOException
+  {
+    writeValue(os, obj, true);
+  }
+  
+  /**
+   * Will write the given object as either a value or an untagged value to the
+   * DataOutputStream.
+   * 
+   * @param os write the value here
+   * @param obj the Object to write
+   * @param tagged true if the value is tagged, false otherwise
+   * @throws IOException
+   * @throws InvalidFieldException
+   */
+  private static void writeValue(DataOutputStream os, Object obj,
+                                boolean tagged)
+    throws IOException, JdwpException
+  {
+    Class clazz = obj.getClass();
+    if (clazz.isPrimitive())
+      {
+        if (clazz == byte.class)
+          {
+            if (tagged)
+              os.writeByte(JdwpConstants.Tag.BYTE);
+            os.writeByte(((Byte) obj).byteValue());
+          }
+        else if (clazz == char.class)
+          {
+            if (tagged)
+              os.writeByte(JdwpConstants.Tag.CHAR);
+            os.writeChar(((Character) obj).charValue());
+          }
+        else if (clazz == float.class)
+          {
+            if (tagged)
+              os.writeByte(JdwpConstants.Tag.FLOAT);
+            os.writeFloat(((Float) obj).floatValue());
+          }
+        else if (clazz == double.class)
+          {
+            if (tagged)
+              os.writeByte(JdwpConstants.Tag.DOUBLE);
+            os.writeDouble(((Double) obj).doubleValue());
+          }
+        else if (clazz == int.class)
+          {
+            if (tagged)
+              os.writeByte(JdwpConstants.Tag.BYTE);
+            os.writeInt(((Integer) obj).intValue());
+          }
+        else if (clazz == long.class)
+          {
+            if (tagged)
+              os.writeByte(JdwpConstants.Tag.LONG);
+            os.writeLong(((Long) obj).longValue());
+          }
+        else if (clazz == short.class)
+          {
+            if (tagged)
+              os.writeByte(JdwpConstants.Tag.SHORT);
+            os.writeInt(((Short) obj).shortValue());
+          }
+        else if (clazz == void.class)
+          { // A 'void' has no data
+            if (tagged)
+              os.writeByte(JdwpConstants.Tag.VOID);
+          }
+        else if (clazz == boolean.class)
+          {
+            if (tagged)
+              os.writeByte(JdwpConstants.Tag.BOOLEAN);
+            os.writeBoolean(((Boolean) obj).booleanValue());
+          }
+        else
+          { // This shouldn't be possible
+            throw new JdwpInternalErrorException(
+              "Field has invalid primitive!");
+          }
+      }
+    else
+      {
+        // Object is an Object, not a primitive type wrapped in an object
+        // Write the appropriate tag
+        if (tagged)
+          {
+            if (clazz.isArray())
+              os.writeByte(JdwpConstants.Tag.ARRAY);
+            else if (obj instanceof String)
+              os.writeByte(JdwpConstants.Tag.STRING);
+            else if (obj instanceof Thread)
+              os.writeByte(JdwpConstants.Tag.THREAD);
+            else if (obj instanceof ThreadGroup)
+              os.writeByte(JdwpConstants.Tag.THREAD_GROUP);
+            else if (obj instanceof ClassLoader)
+              os.writeByte(JdwpConstants.Tag.CLASS_LOADER);
+            else if (obj instanceof Class)
+              os.writeByte(JdwpConstants.Tag.CLASS_OBJECT);
+            else
+              os.writeByte(JdwpConstants.Tag.OBJECT);
+          }
+        ObjectId oid = VMIdManager.getDefault().getObjectId(obj);
+        oid.write(os);
+      }
+  }
+
+  /**
+   * Reads the appropriate object for the tagged value contained in the 
+   * ByteBuffer.
+   * 
+   * @param bb contains the Object
+   * @return The Object referenced by the value
+   * @throws JdwpException
+   * @throws IOException
+   */
+  public static Object getObj(ByteBuffer bb)
+    throws JdwpException, IOException
+  {
+    return getUntaggedObj(bb, bb.get());
+  }
+
+  /**
+   * Reads an object of the given Class from the untagged value contained
+   * in the ByteBuffer.
+   * 
+   * @param bb   contains the Object
+   * @param type corresponds to the TAG of value to be read 
+   * @return the resultant object
+   * @throws JdwpException
+   * @throws IOException
+   */
+  public static Object getUntaggedObj(ByteBuffer bb, Class type)
+    throws JdwpException, IOException
+  {
+    if (type.isPrimitive())
+      {
+        if (type == byte.class)
+          return new Byte(bb.get());
+        else if (type == char.class)
+          return new Character(bb.getChar());
+        else if (type == float.class)
+          return new Float(bb.getFloat());
+        else if (type == double.class)
+          return new Double(bb.getDouble());
+        else if (type == int.class)
+          return new Integer(bb.getInt());
+        else if (type == long.class)
+          return new Long(bb.getLong());
+        else if (type == short.class)
+          return new Short(bb.getShort());
+        else if (type == boolean.class)
+          return Boolean.valueOf(bb.get() != 0);
+        else if (type == void.class)
+          return new byte[0];
+        else
+          { // This shouldn't be possible
+            throw new JdwpInternalErrorException(
+              "Field has invalid primitive!");
+          }
+      }
+    else
+      {
+        // Field is an object
+        ObjectId oid = VMIdManager.getDefault().readObjectId(bb);
+        return oid.getObject();
+      }
+  }
+
+  /**
+   * Reads the an object of the given Class from the untagged value contained
+   * in the ByteBuffer.
+   * 
+   * @param bb contains the Object
+   * @param tag TAG of the Value to be read
+   * @return the object
+   * @throws JdwpException
+   * @throws IOException
+   */
+  public static Object getUntaggedObj(ByteBuffer bb, byte tag)
+    throws JdwpException, IOException
+  {
+    switch (tag)
+      {
+      case JdwpConstants.Tag.BYTE:
+        return new Byte(bb.get());
+      case JdwpConstants.Tag.CHAR:
+        return new Character(bb.getChar());
+      case JdwpConstants.Tag.FLOAT:
+        return new Float(bb.getFloat());
+      case JdwpConstants.Tag.DOUBLE:
+        return new Double(bb.getDouble());
+      case JdwpConstants.Tag.INT:
+        return new Integer(bb.getInt());
+      case JdwpConstants.Tag.LONG:
+        return new Long(bb.getLong());
+      case JdwpConstants.Tag.SHORT:
+        return new Short(bb.getShort());
+      case JdwpConstants.Tag.VOID:
+        return new byte[0];
+      case JdwpConstants.Tag.BOOLEAN:
+        return (bb.get() == 0) ? new Boolean(false) : new Boolean(true);
+      case JdwpConstants.Tag.STRING:
+        return JdwpString.readString(bb);
+      case JdwpConstants.Tag.ARRAY:
+      case JdwpConstants.Tag.THREAD:
+      case JdwpConstants.Tag.OBJECT:
+      case JdwpConstants.Tag.THREAD_GROUP:
+      case JdwpConstants.Tag.CLASS_LOADER:
+      case JdwpConstants.Tag.CLASS_OBJECT:
+        // All these cases are ObjectIds
+        ObjectId oid = VMIdManager.getDefault().readObjectId(bb);
+        return oid.getObject();
+      default:
+        throw new NotImplementedException("Tag " + tag
+                                          + " is not implemented.");
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/VariableTable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/classpath/jdwp/util/VariableTable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,110 @@
+/* VariableTable.java -- A class representing a Variable Table for a method
+   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
+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.util;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * A class representing a Variable Table for a method.
+ * 
+ * @author Aaron Luchko <aluchko at redhat.com>
+ */
+public class VariableTable
+{
+
+  private final long argCnt;
+
+  private final long slots;
+
+  private final long[] lineCI;
+
+  private int[] slot;
+
+  private int[] lengths;
+
+  private String[] sigs;
+
+  private String[] names;
+
+  /**
+   * Make a new variable table with the given values.
+   * 
+   * @param argCnt number of words used by arguments in this frame
+   * @param slots number of variables
+   * @param lineCI first code index of given variable (size slots)
+   * @param names name of given variable (size slots)
+   * @param sigs signature of given variable (size slots)
+   * @param lengths size of region where variable is active (size slots)
+   * @param slot index of variable in this frame (size slots)
+   */
+  public VariableTable(int argCnt, int slots, long lineCI[], String names[],
+                       String sigs[], int lengths[], int slot[])
+  {
+    this.argCnt = argCnt;
+    this.slots = slots;
+    this.lineCI = lineCI;
+    this.names = names;
+    this.sigs = sigs;
+    this.lengths = lengths;
+    this.slot = slot;
+  }
+
+  /**
+   * Writes this line table to the given DataOutputStream.
+   * 
+   * @param os the stream to write it to
+   * @throws IOException
+   */
+  public void write(DataOutputStream os) throws IOException
+  {
+    os.writeLong(argCnt);
+    os.writeLong(slots);
+    for (int i = 0; i < slots; i++)
+      {
+        os.writeLong(lineCI[i]);
+        JdwpString.writeString(os, names[i]);
+        JdwpString.writeString(os, sigs[i]);
+        os.writeInt(lengths[i]);
+        os.writeInt(slot[i]);
+      }
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/AWTUtilities.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/AWTUtilities.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,697 @@
+/* AWTUtilities.java -- Common utility methods for AWT and Swing.
+   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.awt;
+
+import java.applet.Applet;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Insets;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.event.MouseEvent;
+import java.util.AbstractSequentialList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
+import java.util.WeakHashMap;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * This class mirrors the javax.swing.SwingUtilities class. It 
+ * provides commonly needed functionalities for AWT classes without
+ * the need to reference classes in the javax.swing package.
+ */
+public class AWTUtilities
+{
+
+  /**
+   * This List implementation wraps the Component[] returned by
+   * {@link Container#getComponents()} and iterates over the visible Components
+   * in that array. This class is used in {@link #getVisibleChildren}.
+   */
+  static class VisibleComponentList extends AbstractSequentialList
+  {
+    /**
+     * The ListIterator for this List.
+     */
+    class VisibleComponentIterator implements ListIterator
+    {
+      /** The current index in the Component[]. */
+      int index;
+
+      /** The index in the List of visible Components. */
+      int listIndex;
+
+      /**
+       * Creates a new VisibleComponentIterator that starts at the specified
+       * <code>listIndex</code>. The array of Components is searched from
+       * the beginning to find the matching array index.
+       *
+       * @param listIndex the index from where to begin iterating
+       */
+      VisibleComponentIterator(int listIndex)
+      {
+	this.listIndex = listIndex;
+	int visibleComponentsFound = 0;
+	for (index = 0; visibleComponentsFound != listIndex; index++)
+	  {
+	    if (components[index].isVisible())
+	      visibleComponentsFound++;
+	  }
+      }
+
+      /**
+       * Returns <code>true</code> if there are more visible components in the
+       * array, <code>false</code> otherwise.
+       *
+       * @return <code>true</code> if there are more visible components in the
+       *     array, <code>false</code> otherwise
+       */
+      public boolean hasNext()
+      {
+	boolean hasNext = false;
+	for (int i = index; i < components.length; i++)
+	  {
+	    if (components[i].isVisible())
+	      {
+		hasNext = true;
+		break;
+	      }
+	  }
+	return hasNext;
+      }
+
+      /**
+       * Returns the next visible <code>Component</code> in the List.
+       *
+       * @return the next visible <code>Component</code> in the List
+       *
+       * @throws if there is no next element
+       */
+      public Object next()
+      {
+	Object o = null;
+	for (; index < components.length; index++)
+	  {
+	    if (components[index].isVisible())
+	      {
+		o = components[index];
+		break;
+	      }
+	  }
+	if (o != null)
+	  {
+	    index++;
+	    listIndex++;
+	    return o;
+	  }
+	else
+	  throw new NoSuchElementException();
+      }
+
+      /**
+       * Returns <code>true</code> if there are more visible components in the
+       * array in the reverse direction, <code>false</code> otherwise.
+       *
+       * @return <code>true</code> if there are more visible components in the
+       *     array in the reverse direction, <code>false</code> otherwise
+       */
+      public boolean hasPrevious()
+      {
+	boolean hasPrevious = false;
+	for (int i = index - 1; i >= 0; i--)
+	  {
+	    if (components[i].isVisible())
+	      {
+		hasPrevious = true;
+		break;
+	      }
+	  }
+	return hasPrevious;
+      }
+
+      /**
+       * Returns the previous visible <code>Component</code> in the List.
+       *
+       * @return the previous visible <code>Component</code> in the List
+       *
+       * @throws NoSuchElementException if there is no previous element
+       */
+      public Object previous()
+      {
+	Object o = null;
+	for (index--; index >= 0; index--)
+	  {
+	    if (components[index].isVisible())
+	      {
+		o = components[index];
+		break;
+	      }
+	  }
+	if (o != null)
+	  {
+	    listIndex--;
+	    return o;
+	  }
+	else
+	  throw new NoSuchElementException();
+      }
+
+      /**
+       * Returns the index of the next element in the List.
+       *
+       * @return the index of the next element in the List
+       */
+      public int nextIndex()
+      {
+	return listIndex + 1;
+      }
+
+      /**
+       * Returns the index of the previous element in the List.
+       *
+       * @return the index of the previous element in the List
+       */
+      public int previousIndex()
+      {
+	return listIndex - 1;
+      }
+
+      /**
+       * This operation is not supported because the List is immutable.
+       *
+       * @throws UnsupportedOperationException because the List is immutable
+       */
+      public void remove()
+      {
+	throw new UnsupportedOperationException
+	  ("VisibleComponentList is immutable");
+      }
+
+      /**
+       * This operation is not supported because the List is immutable.
+       *
+       * @param o not used here
+       *
+       * @throws UnsupportedOperationException because the List is immutable
+       */
+      public void set(Object o)
+      {
+	throw new UnsupportedOperationException
+	  ("VisibleComponentList is immutable");
+      }
+
+      /**
+       * This operation is not supported because the List is immutable.
+       *
+       * @param o not used here
+       *
+       * @throws UnsupportedOperationException because the List is immutable
+       */
+      public void add(Object o)
+      {
+	throw new UnsupportedOperationException
+	  ("VisibleComponentList is immutable");
+      }
+    }
+
+    /**
+     * The components over which we iterate. Only the visible components
+     * are returned by this List.
+     */
+    Component[] components;
+
+    /**
+     * Creates a new instance of VisibleComponentList that wraps the specified
+     * <code>Component[]</code>.
+     *
+     * @param c the <code>Component[]</code> to be wrapped.
+     */
+    VisibleComponentList(Component[] c)
+    {
+      components = c;
+    }
+
+    /**
+     * Returns a {@link ListIterator} for iterating over this List.
+     *
+     * @return a {@link ListIterator} for iterating over this List
+     */
+    public ListIterator listIterator(int index)
+    {
+      return new VisibleComponentIterator(index);
+    }
+
+    /**
+     * Returns the number of visible components in the wrapped Component[].
+     *
+     * @return the number of visible components
+     */
+    public int size()
+    {
+      int visibleComponents = 0;
+      for (int i = 0; i < components.length; i++)
+	if (components[i].isVisible())
+	  visibleComponents++;
+      return visibleComponents;
+    }
+  }
+
+  /**
+   * The cache for our List instances. We try to hold one instance of
+   * VisibleComponentList for each Component[] that is requested. Note
+   * that we use a WeakHashMap for caching, so that the cache itself
+   * does not keep the array or the List from beeing garbage collected
+   * if no other objects hold references to it.
+   */
+  static WeakHashMap visibleChildrenCache = new WeakHashMap();
+
+  /**
+   * Returns the visible children of a {@link Container}. This method is
+   * commonly needed in LayoutManagers, because they only have to layout
+   * the visible children of a Container.
+   *
+   * @param c the Container from which to extract the visible children
+   *
+   * @return the visible children of <code>c</code>
+   */
+  public static List getVisibleChildren(Container c)
+  {
+    Component[] children = c.getComponents();
+    Object o = visibleChildrenCache.get(children);
+    VisibleComponentList visibleChildren = null;
+    if (o == null)
+      {
+	visibleChildren = new VisibleComponentList(children);
+	visibleChildrenCache.put(children, visibleChildren);
+      }
+    else
+      visibleChildren = (VisibleComponentList) o;
+
+    return visibleChildren;
+  }
+
+  /**
+   * Calculates the portion of the base rectangle which is inside the
+   * insets.
+   *
+   * @param base The rectangle to apply the insets to
+   * @param insets The insets to apply to the base rectangle
+   * @param ret A rectangle to use for storing the return value, or
+   * <code>null</code>
+   *
+   * @return The calculated area inside the base rectangle and its insets,
+   * either stored in ret or a new Rectangle if ret is <code>null</code>
+   *
+   * @see #calculateInnerArea
+   */
+  public static Rectangle calculateInsetArea(Rectangle base, Insets insets,
+                                             Rectangle ret)
+  {
+    if (ret == null)
+      ret = new Rectangle();
+    ret.setBounds(base.x + insets.left, base.y + insets.top,
+        base.width - (insets.left + insets.right),
+        base.height - (insets.top + insets.bottom));
+    return ret;
+  }
+
+  /**
+   * Calculates the bounds of a component in the component's own coordinate
+   * space. The result has the same height and width as the component's
+   * bounds, but its location is set to (0,0).
+   *
+   * @param aComponent The component to measure
+   *
+   * @return The component's bounds in its local coordinate space
+   */
+  public static Rectangle getLocalBounds(Component aComponent)
+  {
+    Rectangle bounds = aComponent.getBounds();
+    return new Rectangle(0, 0, bounds.width, bounds.height);
+  }
+
+  /**
+   * Returns the font metrics object for a given font. The metrics can be
+   * used to calculate crude bounding boxes and positioning information,
+   * for laying out components with textual elements.
+   *
+   * @param font The font to get metrics for
+   *
+   * @return The font's metrics
+   *
+   * @see java.awt.font.GlyphMetrics
+   */
+  public static FontMetrics getFontMetrics(Font font)
+  {
+    return Toolkit.getDefaultToolkit().getFontMetrics(font);
+  }
+
+  /**
+   * Returns the least ancestor of <code>comp</code> which has the
+   * specified name.
+   *
+   * @param name The name to search for
+   * @param comp The component to search the ancestors of
+   *
+   * @return The nearest ancestor of <code>comp</code> with the given
+   * name, or <code>null</code> if no such ancestor exists
+   *
+   * @see java.awt.Component#getName
+   * @see #getAncestorOfClass
+   */
+  public static Container getAncestorNamed(String name, Component comp)
+  {
+    while (comp != null && (comp.getName() != name))
+      comp = comp.getParent();
+    return (Container) comp;
+  }
+
+  /**
+   * Returns the least ancestor of <code>comp</code> which is an instance
+   * of the specified class.
+   *
+   * @param c The class to search for
+   * @param comp The component to search the ancestors of
+   *
+   * @return The nearest ancestor of <code>comp</code> which is an instance
+   * of the given class, or <code>null</code> if no such ancestor exists
+   *
+   * @see #getAncestorOfClass
+   * @see #windowForComponent
+   * @see 
+   * 
+   */
+  public static Container getAncestorOfClass(Class c, Component comp)
+  {
+    while (comp != null && (! c.isInstance(comp)))
+      comp = comp.getParent();
+    return (Container) comp;
+  }
+
+  /**
+   * Equivalent to calling <code>getAncestorOfClass(Window, comp)</code>.
+   *
+   * @param comp The component to search for an ancestor window 
+   *
+   * @return An ancestral window, or <code>null</code> if none exists
+   */
+  public static Window windowForComponent(Component comp)
+  {
+    return (Window) getAncestorOfClass(Window.class, comp);
+  }
+
+  /**
+   * Returns the "root" of the component tree containint <code>comp</code>
+   * The root is defined as either the <em>least</em> ancestor of
+   * <code>comp</code> which is a {@link Window}, or the <em>greatest</em>
+   * ancestor of <code>comp</code> which is a {@link Applet} if no {@link
+   * Window} ancestors are found.
+   *
+   * @param comp The component to search for a root
+   *
+   * @return The root of the component's tree, or <code>null</code>
+   */
+  public static Component getRoot(Component comp)
+  {
+    Applet app = null;
+    Window win = null;
+
+    while (comp != null)
+     {
+      if (win == null && comp instanceof Window)
+        win = (Window) comp;
+      else if (comp instanceof Applet)
+        app = (Applet) comp;
+      comp = comp.getParent();
+    }
+
+    if (win != null)
+      return win;
+    else
+      return app;
+  }
+
+  /**
+   * Return true if a descends from b, in other words if b is an
+   * ancestor of a.
+   *
+   * @param a The child to search the ancestry of
+   * @param b The potential ancestor to search for
+   *
+   * @return true if a is a descendent of b, false otherwise
+   */
+  public static boolean isDescendingFrom(Component a, Component b)
+  {
+    while (true)
+     {
+      if (a == null || b == null)
+        return false;
+      if (a == b)
+        return true;
+      a = a.getParent();
+    }
+  }
+
+  /**
+   * Returns the deepest descendent of parent which is both visible and
+   * contains the point <code>(x,y)</code>. Returns parent when either
+   * parent is not a container, or has no children which contain
+   * <code>(x,y)</code>. Returns <code>null</code> when either
+   * <code>(x,y)</code> is outside the bounds of parent, or parent is
+   * <code>null</code>.
+   * 
+   * @param parent The component to search the descendents of
+   * @param x Horizontal coordinate to search for
+   * @param y Vertical coordinate to search for
+   *
+   * @return A component containing <code>(x,y)</code>, or
+   * <code>null</code>
+   *
+   * @see java.awt.Container#findComponentAt
+   */
+  public static Component getDeepestComponentAt(Component parent, int x, int y)
+  {
+    if (parent == null || (! parent.contains(x, y)))
+      return null;
+
+    if (! (parent instanceof Container))
+      return parent;
+
+    Container c = (Container) parent;
+    return c.findComponentAt(x, y);
+  }
+
+  /**
+   * Converts a point from a component's local coordinate space to "screen"
+   * coordinates (such as the coordinate space mouse events are delivered
+   * in). This operation is equivalent to translating the point by the
+   * location of the component (which is the origin of its coordinate
+   * space).
+   *
+   * @param p The point to convert
+   * @param c The component which the point is expressed in terms of
+   *
+   * @see convertPointFromScreen
+   */
+  public static void convertPointToScreen(Point p, Component c)
+  {
+    Point c0 = c.getLocationOnScreen();
+    p.translate(c0.x, c0.y);
+  }
+
+  /**
+   * Converts a point from "screen" coordinates (such as the coordinate
+   * space mouse events are delivered in) to a component's local coordinate
+   * space. This operation is equivalent to translating the point by the
+   * negation of the component's location (which is the origin of its
+   * coordinate space).
+   *
+   * @param p The point to convert
+   * @param c The component which the point should be expressed in terms of
+   */
+  public static void convertPointFromScreen(Point p, Component c)
+  {
+    Point c0 = c.getLocationOnScreen();
+    p.translate(-c0.x, -c0.y);
+  }
+
+  /**
+   * Converts a point <code>(x,y)</code> from the coordinate space of one
+   * component to another. This is equivalent to converting the point from
+   * <code>source</code> space to screen space, then back from screen space
+   * to <code>destination</code> space. If exactly one of the two
+   * Components is <code>null</code>, it is taken to refer to the root
+   * ancestor of the other component. If both are <code>null</code>, no
+   * transformation is done.
+   *
+   * @param source The component which the point is expressed in terms of
+   * @param x Horizontal coordinate of point to transform
+   * @param y Vertical coordinate of point to transform
+   * @param destination The component which the return value will be
+   * expressed in terms of
+   *
+   * @return The point <code>(x,y)</code> converted from the coordinate
+   *         space of the
+   * source component to the coordinate space of the destination component
+   *
+   * @see #convertPointToScreen
+   * @see #convertPointFromScreen
+   * @see #convertRectangle
+   * @see #getRoot
+   */
+  public static Point convertPoint(Component source, int x, int y,
+                                   Component destination)
+  {
+    Point pt = new Point(x, y);
+
+    if (source == null && destination == null)
+      return pt;
+
+    if (source == null)
+      source = getRoot(destination);
+
+    if (destination == null)
+      destination = getRoot(source);
+    
+    if (source.isShowing() && destination.isShowing())
+      {
+        convertPointToScreen(pt, source);
+        convertPointFromScreen(pt, destination);
+      }
+
+    return pt;
+  }
+
+  
+  /**
+   * Converts a rectangle from the coordinate space of one component to
+   * another. This is equivalent to converting the rectangle from
+   * <code>source</code> space to screen space, then back from screen space
+   * to <code>destination</code> space. If exactly one of the two
+   * Components is <code>null</code>, it is taken to refer to the root
+   * ancestor of the other component. If both are <code>null</code>, no
+   * transformation is done.
+   *
+   * @param source The component which the rectangle is expressed in terms of
+   * @param rect The rectangle to convert
+   * @param destination The component which the return value will be
+   * expressed in terms of
+   *
+   * @return A new rectangle, equal in size to the input rectangle, but
+   * with its position converted from the coordinate space of the source
+   * component to the coordinate space of the destination component
+   *
+   * @see #convertPointToScreen
+   * @see #convertPointFromScreen
+   * @see #convertPoint
+   * @see #getRoot
+   */
+  public static Rectangle convertRectangle(Component source, Rectangle rect,
+                                           Component destination)
+  {
+    Point pt = convertPoint(source, rect.x, rect.y, destination);
+    return new Rectangle(pt.x, pt.y, rect.width, rect.height);
+  }
+
+  /**
+   * Convert a mouse event which refrers to one component to another.  This
+   * includes changing the mouse event's coordinate space, as well as the
+   * source property of the event. If <code>source</code> is
+   * <code>null</code>, it is taken to refer to <code>destination</code>'s
+   * root component. If <code>destination</code> is <code>null</code>, the
+   * new event will remain expressed in <code>source</code>'s coordinate
+   * system.
+   *
+   * @param source The component the mouse event currently refers to
+   * @param sourceEvent The mouse event to convert
+   * @param destination The component the new mouse event should refer to
+   *
+   * @return A new mouse event expressed in terms of the destination
+   * component's coordinate space, and with the destination component as
+   * its source
+   *
+   * @see #convertPoint
+   */
+  public static MouseEvent convertMouseEvent(Component source,
+                                             MouseEvent sourceEvent,
+                                             Component destination)
+  {
+    Point newpt = convertPoint(source, sourceEvent.getX(), sourceEvent.getY(),
+                               destination);
+
+    return new MouseEvent(destination, sourceEvent.getID(),
+                          sourceEvent.getWhen(), sourceEvent.getModifiers(),
+                          newpt.x, newpt.y, sourceEvent.getClickCount(),
+                          sourceEvent.isPopupTrigger(),
+                          sourceEvent.getButton());
+  }
+
+
+  /** 
+   * Calls {@link java.awt.EventQueue.invokeLater} with the
+   * specified {@link Runnable}. 
+   */
+  public static void invokeLater(Runnable doRun)
+  {
+    java.awt.EventQueue.invokeLater(doRun);
+  }
+
+  /** 
+   * Calls {@link java.awt.EventQueue.invokeAndWait} with the
+   * specified {@link Runnable}. 
+   */
+  public static void invokeAndWait(Runnable doRun)
+  throws InterruptedException,
+  InvocationTargetException
+  {
+    java.awt.EventQueue.invokeAndWait(doRun);
+  }
+
+  /** 
+   * Calls {@link java.awt.EventQueue.isEventDispatchThread}.
+   */
+  public static boolean isEventDispatchThread()
+  {
+    return java.awt.EventQueue.isDispatchThread();
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/BitMaskExtent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/BitMaskExtent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* Copyright (C) 2000, 2002  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.awt;
+
+/** 
+ * Simple transparent utility class that can be used to perform bit
+ * mask extent calculations.
+ */
+public final class BitMaskExtent
+{
+  /** The number of the least significant bit of the bit mask extent. */
+  public byte leastSignificantBit;
+
+  /** The number of bits in the bit mask extent. */
+  public byte bitWidth;
+  
+  /**
+   * Set the bit mask. This will calculate and set the leastSignificantBit
+   * and bitWidth fields.
+   *
+   * @see #leastSignificantBit
+   * @see #bitWidth
+   */
+  public void setMask(long mask)
+  {
+    leastSignificantBit = 0;
+    bitWidth = 0;
+    if (mask == 0) return;
+    long shiftMask = mask;
+    for (; (shiftMask&1) == 0; shiftMask >>>=1) leastSignificantBit++;
+    for (; (shiftMask&1) != 0; shiftMask >>>=1) bitWidth++;
+    
+    if (shiftMask != 0)
+      throw new IllegalArgumentException("mask must be continuous");
+  }
+  
+  /** 
+   * Calculate the bit mask based on the values of the
+   * leastSignificantBit and bitWidth fields.
+   */
+  public long toMask()
+  {
+    return ((1<<bitWidth)-1) << leastSignificantBit;
+  }  
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/BitwiseXORComposite.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/BitwiseXORComposite.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,295 @@
+/* BitwiseXORComposite.java -- Composite for emulating old-style XOR.
+   Copyright (C) 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 gnu.java.awt;
+
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.CompositeContext;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.image.ColorModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+
+/**
+ * A composite for emulating traditional bitwise XOR of pixel values.
+ * Please note that this composite does <i>not</i> implement the Porter-Duff
+ * XOR operator, but an exclusive or of overlapping subpixel regions.
+ *
+ * <p><img src="doc-files/BitwiseXORComposite-1.png" width="545"
+ * height="138" alt="A screen shot of BitwiseXORComposite in action"
+ * />
+ *
+ * <p>The above screen shot shows the result of applying six different
+ * BitwiseXORComposites. They were constructed with the colors
+ * white, blue, black, orange, green, and brown, respectively. Each
+ * composite was used to paint a fully white rectangle on top of the
+ * blue bar in the background.
+ * 
+ * <p>The purpose of this composite is to support the {@link
+ * Graphics#setXORMode(Color)} method in composite-aware graphics
+ * implementations. Applications typically would use
+ * <code>setXORMode</code> for drawing &#x201c;highlights&#x201d; such
+ * as text selections or cursors by inverting colors temporarily and
+ * then inverting them back.
+ *
+ * <p>A concrete <code>Graphics</code> implementation may contain
+ * the following code:
+ *
+ * <p><pre> public void setXORMode(Color xorColor)
+ * {
+ *   setComposite(new gnu.java.awt.BitwiseXORComposite(xorColor));
+ * }
+ *
+ * public void setPaintMode()
+ * {
+ *   setComposite(java.awt.AlphaComposite.SrcOver);
+ * }</pre>
+ *
+ * @author Graydon Hoare (graydon at redhat.com)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class BitwiseXORComposite
+  implements Composite
+{
+  /**
+   * The color whose RGB value is xor-ed with the values of each
+   * pixel.
+   */
+  protected Color xorColor;
+
+  
+  /**
+   * Constructs a new composite for xor-ing the pixel value.
+   *
+   * @param xorColor the color whose pixel value will be bitwise
+   * xor-ed with the source and destination pixels.
+   */
+  public BitwiseXORComposite(Color xorColor)
+  {
+    this.xorColor = xorColor;
+  }
+
+
+  /**
+   * Creates a context object for performing the compositing
+   * operation. Several contexts may co-exist for one composite; each
+   * context may simultaneously be called from concurrent threads.
+   *
+   * @param srcColorModel the color model of the source.
+   * @param dstColorModel the color model of the destination.
+   * @param hints hints for choosing between rendering alternatives.
+   */
+  public CompositeContext createContext(ColorModel srcColorModel,
+                                        ColorModel dstColorModel,
+                                        RenderingHints hints)
+  {
+    if (IntContext.isSupported(srcColorModel, dstColorModel, hints))
+      return new IntContext(srcColorModel, xorColor);
+
+    return new GeneralContext(srcColorModel, dstColorModel, xorColor);
+  }
+
+  
+  /**
+   * A fallback CompositeContext that performs bitwise XOR of pixel
+   * values with the pixel value of the specified <code>xorColor</code>.
+   *
+   * <p>Applying this CompositeContext on a 1024x1024 BufferedImage of
+   * <code>TYPE_INT_RGB</code> took 611 ms on a lightly loaded 2.4 GHz
+   * Intel Pentium 4 CPU running Sun J2SE 1.4.1_01 on GNU/Linux
+   * 2.4.20. The timing is the average of ten runs on the same
+   * BufferedImage. Since the measurements were taken with {@link
+   * System#currentTimeMillis()}, they are rather inaccurate.
+   *
+   * @author Graydon Hoare (graydon at redhat.com)
+   */
+  private static class GeneralContext
+    implements CompositeContext
+  {
+    ColorModel srcColorModel;
+    ColorModel dstColorModel;
+    Color xorColor;
+
+    public GeneralContext(ColorModel srcColorModel,
+                          ColorModel dstColorModel,
+                          Color xorColor)
+    {
+      this.srcColorModel = srcColorModel;
+      this.dstColorModel = dstColorModel;
+      this.xorColor = xorColor;
+    }
+
+
+    public void compose(Raster src, Raster dstIn, WritableRaster dstOut)
+    {
+      Rectangle srcRect = src.getBounds();
+      Rectangle dstInRect = dstIn.getBounds();
+      Rectangle dstOutRect = dstOut.getBounds();
+      
+      int xp = xorColor.getRGB();
+      int w = Math.min(Math.min(srcRect.width, dstOutRect.width),
+                       dstInRect.width);
+      int h = Math.min(Math.min(srcRect.height, dstOutRect.height),
+                       dstInRect.height);
+
+      Object srcPix = null, dstPix = null, rpPix = null;
+
+      // Re-using the rpPix object saved 1-2% of execution time in
+      // the 1024x1024 pixel benchmark.
+
+      for (int y = 0; y < h; y++)
+      {
+        for (int x = 0; x < w; x++)
+        {
+          srcPix = src.getDataElements(x + srcRect.x, y + srcRect.y, srcPix);
+          dstPix = dstIn.getDataElements(x + dstInRect.x, y + dstInRect.y,
+                                         dstPix);
+          int sp = srcColorModel.getRGB(srcPix);
+          int dp = dstColorModel.getRGB(dstPix);
+          int rp = sp ^ xp ^ dp;
+          dstOut.setDataElements(x + dstOutRect.x, y + dstOutRect.y, 
+                                 dstColorModel.getDataElements(rp, rpPix));
+        }
+      }
+    }
+
+
+    /**
+     * Disposes any cached resources. The default implementation does
+     * nothing because no resources are cached.
+     */
+    public void dispose()
+    {
+    }
+  }
+
+
+  /**
+   * An optimized CompositeContext that performs bitwise XOR of
+   * <code>int</code> pixel values with the pixel value of a specified
+   * <code>xorColor</code>.  This CompositeContext working only for
+   * rasters whose transfer format is {@link DataBuffer#TYPE_INT}.
+   *
+   * <p>Applying this CompositeContext on a 1024x1024 BufferedImage of
+   * <code>TYPE_INT_RGB</code> took 69 ms on a lightly loaded 2.4 GHz
+   * Intel Pentium 4 CPU running Sun J2SE 1.4.1_01 on GNU/Linux
+   * 2.4.20. The timing is the average of ten runs on the same
+   * BufferedImage. Since the measurements were taken with {@link
+   * System#currentTimeMillis()}, they are rather inaccurate.
+   *
+   * @author Sascha Brawer (brawer at dandelis.ch)
+   */
+  private static class IntContext
+    extends GeneralContext
+  {
+    public IntContext(ColorModel colorModel, Color xorColor)
+    {
+      super(colorModel, colorModel, xorColor);
+    }
+
+
+    public void compose(Raster src, Raster dstIn,
+                        WritableRaster dstOut)
+    {
+      int aX, bX, dstX, aY, bY, dstY, width, height;
+      int xorPixel;
+      int[] srcLine, dstLine;
+
+      aX = src.getMinX();
+      aY = src.getMinY();
+      bX = dstIn.getMinX();
+      bY = dstIn.getMinY();
+      dstX = dstOut.getMinX();
+      dstY = dstOut.getMinY();
+      width = Math.min(Math.min(src.getWidth(), dstIn.getWidth()),
+                       dstOut.getWidth());
+      height = Math.min(Math.min(src.getHeight(), dstIn.getHeight()),
+                        dstOut.getHeight());
+      if ((width < 1) || (height < 1))
+        return;
+
+      srcLine = new int[width];
+      dstLine = new int[width];
+      
+      /* We need an int[] array with at least one element here;
+       * srcLine is as good as any other.
+       */
+      srcColorModel.getDataElements(this.xorColor.getRGB(), srcLine);
+      xorPixel = srcLine[0];
+
+      for (int y = 0; y < height; y++)
+      {
+        src.getDataElements(aX, y + aY, width, 1, srcLine);
+        dstIn.getDataElements(bX, y + bY, width, 1, dstLine);
+
+        for (int x = 0; x < width; x++)
+          dstLine[x] ^= srcLine[x] ^ xorPixel;
+
+        dstOut.setDataElements(dstX, y + dstY, width, 1, dstLine);
+      }
+    }
+
+    
+    /**
+     * Determines whether an instance of this CompositeContext would
+     * be able to process the specified color models.
+     */
+    public static boolean isSupported(ColorModel srcColorModel,
+                                      ColorModel dstColorModel,
+                                      RenderingHints hints)
+    {
+      // FIXME: It would be good if someone could review these checks.
+      // They probably need to be more restrictive.
+
+      int transferType;
+
+      transferType = srcColorModel.getTransferType();
+      if (transferType != dstColorModel.getTransferType())
+        return false;
+
+      if (transferType != DataBuffer.TYPE_INT)
+        return false;
+
+      return true;
+    }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/Buffers.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/Buffers.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,225 @@
+/* Buffers.java --
+   Copyright (C) 2000, 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 gnu.java.awt;
+
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferDouble;
+import java.awt.image.DataBufferFloat;
+import java.awt.image.DataBufferInt;
+import java.awt.image.DataBufferShort;
+import java.awt.image.DataBufferUShort;
+
+/** 
+ * Utility class for creating and accessing data buffers of arbitrary
+ * data types.
+ */
+public final class Buffers
+{
+  /**
+   * Create a data buffer of a particular type.
+   *
+   * @param dataType the desired data type of the buffer.
+   * @param data an array containing data, or null
+   * @param size the size of the data buffer bank
+   */
+  public static DataBuffer createBuffer(int dataType, Object data,
+					int size)
+  {
+    if (data == null) return createBuffer(dataType, size, 1);
+
+    return createBufferFromData(dataType, data, size);
+  }
+
+
+  /**
+   * Create a data buffer of a particular type.
+   *
+   * @param dataType the desired data type of the buffer.
+   * @param size the size of the data buffer bank
+   */
+  public static DataBuffer createBuffer(int dataType, int size) {
+    return createBuffer(dataType, size, 1);
+  }
+
+  /**
+   * Create a data buffer of a particular type.
+   *
+   * @param dataType the desired data type of the buffer.
+   * @param size the size of the data buffer bank
+   * @param numBanks the number of banks the buffer should have
+   */
+  public static DataBuffer createBuffer(int dataType, int size, int numBanks)
+  {
+    switch (dataType)
+      {
+      case DataBuffer.TYPE_BYTE:
+	return new DataBufferByte(size, numBanks);
+      case DataBuffer.TYPE_SHORT:
+	return new DataBufferShort(size, numBanks);
+      case DataBuffer.TYPE_USHORT:
+	return new DataBufferUShort(size, numBanks);
+      case DataBuffer.TYPE_INT:
+	return new DataBufferInt(size, numBanks);
+      case DataBuffer.TYPE_FLOAT:
+	return new DataBufferFloat(size, numBanks);
+      case DataBuffer.TYPE_DOUBLE:
+	return new DataBufferDouble(size, numBanks);
+      default:
+	throw new UnsupportedOperationException();
+      }
+  }
+  
+  /**
+   * Create a data buffer of a particular type.
+   *
+   * @param dataType the desired data type of the buffer
+   * @param data an array containing the data
+   * @param size the size of the data buffer bank
+   */
+  public static DataBuffer createBufferFromData(int dataType, Object data,
+						int size)
+  {
+    switch (dataType)
+      {
+      case DataBuffer.TYPE_BYTE:
+	return new DataBufferByte((byte[]) data, size);
+      case DataBuffer.TYPE_SHORT:
+	return new DataBufferShort((short[]) data, size);
+      case DataBuffer.TYPE_USHORT:
+	return new DataBufferUShort((short[]) data, size);
+      case DataBuffer.TYPE_INT:
+	return new DataBufferInt((int[]) data, size);
+      case DataBuffer.TYPE_FLOAT:
+	return new DataBufferFloat((float[]) data, size);
+      case DataBuffer.TYPE_DOUBLE:
+	return new DataBufferDouble((double[]) data, size);
+      default:
+	throw new UnsupportedOperationException();
+      }
+  }
+
+  /** 
+   * Return the data array of a data buffer, regardless of the data
+   * type.
+   *
+   * @return an array of primitive values. The actual array type
+   * depends on the data type of the buffer.
+   */
+  public static Object getData(DataBuffer buffer)
+  {
+    return getData(buffer, 0, null, 0, buffer.getSize());
+  }
+
+    
+  /**
+   * Copy data from array contained in data buffer, much like
+   * System.arraycopy. Create a suitable destination array if the
+   * given destination array is null.
+   */
+  public static Object getData(DataBuffer src, int srcOffset,
+			       Object dest,  int dstOffset,
+			       int length)
+  {
+    Object from;
+    switch(src.getDataType())
+      {
+      case DataBuffer.TYPE_BYTE:
+	if (dest == null) dest = new byte[length+dstOffset];
+	for(int i = 0; i < length; i++)
+	  ((byte[])dest)[i + dstOffset] = (byte)src.getElem(i + srcOffset);
+	break;
+
+      case DataBuffer.TYPE_DOUBLE:
+	if (dest == null) dest = new double[length+dstOffset];
+	for(int i = 0; i < length; i++)
+	  ((double[])dest)[i + dstOffset] = src.getElemDouble(i + srcOffset);
+	break;
+
+      case DataBuffer.TYPE_FLOAT:
+	if (dest == null) dest = new float[length+dstOffset];
+	for(int i = 0; i < length; i++)
+	  ((float[])dest)[i + dstOffset] = src.getElemFloat(i + srcOffset);
+	break;
+
+      case DataBuffer.TYPE_INT:
+	if (dest == null) dest = new int[length+dstOffset];
+	for(int i = 0; i < length; i++)
+	  ((int[])dest)[i + dstOffset] = src.getElem(i + srcOffset);
+	break;
+
+      case DataBuffer.TYPE_SHORT:
+      case DataBuffer.TYPE_USHORT:
+	if (dest == null) dest = new short[length+dstOffset];
+	for(int i = 0; i < length; i++)
+	  ((short[])dest)[i + dstOffset] = (short)src.getElem(i + srcOffset);
+	break;
+
+      case DataBuffer.TYPE_UNDEFINED:
+	throw new ClassCastException("Unknown data buffer type");
+      }
+    return dest;
+  }
+  
+  /**
+   * @param bits the width of a data element measured in bits
+   *
+   * @return the smallest data type that can store data elements of
+   * the given number of bits, without any truncation.
+   */
+  public static int smallestAppropriateTransferType(int bits)
+  {
+    if (bits <= 8)
+      {
+	return DataBuffer.TYPE_BYTE;
+      }
+    else if (bits <= 16)
+      {
+	return DataBuffer.TYPE_USHORT;
+      } 
+    else if (bits <= 32)
+      {
+	return DataBuffer.TYPE_INT;
+      }
+    else
+      {
+	return DataBuffer.TYPE_UNDEFINED;
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/ClasspathToolkit.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/ClasspathToolkit.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,228 @@
+/* ClasspathToolkit.java -- Abstract superclass for Classpath toolkits.
+   Copyright (C) 2003, 2004, 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.awt;
+
+import gnu.java.awt.EmbeddedWindow;
+import gnu.java.awt.peer.ClasspathFontPeer;
+import gnu.java.awt.peer.EmbeddedWindowPeer;
+import gnu.java.security.action.SetAccessibleAction;
+
+import java.awt.AWTException;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.DisplayMode;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Toolkit;
+import java.awt.font.FontRenderContext;
+import java.awt.image.ColorModel;
+import java.awt.image.ImageProducer;
+import java.awt.peer.RobotPeer;
+import java.io.File;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.AttributedString;
+import java.util.HashMap;
+import java.util.Map;
+import java.security.AccessController;
+
+import javax.imageio.spi.IIORegistry;
+
+/**
+ * An abstract superclass for Classpath toolkits.
+ *
+ * <p>There exist some parts of AWT and Java2D that are specific to
+ * the underlying platform, but for which the {@link Toolkit} class
+ * does not provide suitable abstractions. Examples include some
+ * methods of {@link Font} or {@link GraphicsEnvironment}. Those
+ * methods use ClasspathToolkit as a central place for obtaining
+ * platform-specific functionality.
+ *
+ * <p>In addition, ClasspathToolkit implements some abstract methods
+ * of {@link java.awt.Toolkit} that are not really platform-specific,
+ * such as the maintenance of a cache of loaded images.
+ *
+ * <p><b>Thread Safety:</b> The methods of this class may safely be
+ * called without external synchronization. This also hold for any
+ * inherited {@link Toolkit} methods. Subclasses are responsible for
+ * the necessary synchronization.
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ClasspathToolkit
+  extends Toolkit
+{
+  /**
+   * Returns a shared instance of the local, platform-specific
+   * graphics environment.
+   *
+   * <p>This method is specific to GNU Classpath. It gets called by
+   * the Classpath implementation of {@link
+   * GraphicsEnvironment.getLocalGraphcisEnvironment()}.
+   */
+  public abstract GraphicsEnvironment getLocalGraphicsEnvironment();
+
+  /**
+   * Acquires an appropriate {@link ClasspathFontPeer}, for use in
+   * classpath's implementation of {@link java.awt.Font}.
+   *
+   * @param name The logical name of the font. This may be either a face
+   * name or a logical font name, or may even be null. A default
+   * implementation of name decoding is provided in 
+   * {@link ClasspathFontPeer}, but may be overridden in other toolkits.
+   *
+   * @param attrs Any extra {@link java.awt.font.TextAttribute} attributes
+   * this font peer should have, such as size, weight, family name, or
+   * transformation.
+   */
+  public abstract ClasspathFontPeer getClasspathFontPeer (String name, Map attrs); 
+
+  /** 
+   * Creates a {@link Font}, in a platform-specific manner.
+   * 
+   * The default implementation simply constructs a {@link Font}, but some
+   * toolkits may wish to override this, to return {@link Font} subclasses 
+   * which implement {@link java.awt.font.OpenType} or
+   * {@link java.awt.font.MultipleMaster}.
+   */
+  public Font getFont (String name, Map attrs) 
+  {
+    Font f = null;
+
+    // Circumvent the package-privateness of the
+    // java.awt.Font.Font(String,Map) constructor.
+    try
+      {
+        Constructor fontConstructor = Font.class.getDeclaredConstructor
+          (new Class[] { String.class, Map.class });
+        AccessController.doPrivileged
+          (new SetAccessibleAction(fontConstructor));
+        f = (Font) fontConstructor.newInstance(new Object[] { name, attrs });
+      }
+    catch (IllegalAccessException e)
+      {
+        throw new AssertionError(e);
+      }
+    catch (NoSuchMethodException e)
+      {
+        throw new AssertionError(e);
+      }
+    catch (InstantiationException e)
+      {
+        throw new AssertionError(e);
+      }
+    catch (InvocationTargetException e)
+      {
+        throw new AssertionError(e);
+      }
+    return f;
+  }
+
+  /**
+   * Creates a font, reading the glyph definitions from a stream.
+   *
+   * <p>This method provides the platform-specific implementation for
+   * the static factory method {@link Font#createFont(int,
+   * java.io.InputStream)}.
+   *
+   * @param format the format of the font data, such as {@link
+   * Font#TRUETYPE_FONT}. An implementation may ignore this argument
+   * if it is able to automatically recognize the font format from the
+   * provided data.
+   *
+   * @param stream an input stream from where the font data is read
+   * in. The stream will be advanced to the position after the font
+   * data, but not closed.
+   *
+   * @throws IllegalArgumentException if <code>format</code> is
+   * not supported.
+   * 
+   * @throws FontFormatException if <code>stream</code> does not
+   * contain data in the expected format, or if required tables are
+   * missing from a font.
+   *
+   * @throws IOException if a problem occurs while reading in the
+   * contents of <code>stream</code>.
+   */
+  public abstract Font createFont(int format, InputStream stream);
+
+  /**
+   * Creates a RobotPeer on a given GraphicsDevice.
+   */
+  public abstract RobotPeer createRobot (GraphicsDevice screen)
+    throws AWTException;
+
+  /**
+   * Creates an embedded window peer, and associates it with an
+   * EmbeddedWindow object.
+   *
+   * @param w The embedded window with which to associate a peer.
+   */
+  public abstract EmbeddedWindowPeer createEmbeddedWindow (EmbeddedWindow w);
+
+  /**
+   * Used to register ImageIO SPIs provided by the toolkit.
+   *
+   * Our default implementation does nothing.
+   */
+   public void registerImageIOSpis(IIORegistry reg)
+   {
+   }
+
+   /**
+    * Returns the number of mouse buttons.
+    * (used by java.awt.MouseInfo).
+    *
+    * This dummy implementation returns -1 (no mouse).
+    * toolkit implementors should overload this method if possible.
+    * @since 1.5
+    */
+   public int getMouseNumberOfButtons() 
+   {
+     return -1;
+   }
+}
+

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/ComponentDataBlitOp.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/ComponentDataBlitOp.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,156 @@
+/* Copyright (C) 2000, 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 gnu.java.awt;
+
+import java.awt.RenderingHints;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.Raster;
+import java.awt.image.RasterOp;
+import java.awt.image.WritableRaster;
+
+/**
+ * This raster copy operation assumes that both source and destination
+ * sample models are tightly pixel packed and contain the same number
+ * of bands.
+ *
+ * @throws java.lang.ClassCastException if the sample models of the
+ * rasters are not of type ComponentSampleModel.
+ * 
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ */
+public class ComponentDataBlitOp implements RasterOp
+{
+  public static final ComponentDataBlitOp INSTANCE = new ComponentDataBlitOp();
+
+  public WritableRaster filter(Raster src, WritableRaster dest)
+  {
+    if (dest == null)
+      dest = createCompatibleDestRaster(src);
+    
+    DataBuffer  srcDB =  src.getDataBuffer();
+    DataBuffer destDB = dest.getDataBuffer();
+    
+    ComponentSampleModel  srcSM = (ComponentSampleModel)  src.getSampleModel();
+    ComponentSampleModel destSM = (ComponentSampleModel) dest.getSampleModel();
+
+    
+    // Calculate offset to data in the underlying arrays:
+
+    int  srcScanlineStride =  srcSM.getScanlineStride();
+    int destScanlineStride = destSM.getScanlineStride();
+    int srcX  =  src.getMinX() -  src.getSampleModelTranslateX();
+    int srcY  =  src.getMinY() -  src.getSampleModelTranslateY();
+    int destX = dest.getMinX() - dest.getSampleModelTranslateX();
+    int destY = dest.getMinY() - dest.getSampleModelTranslateY();
+
+    int numBands = srcSM.getNumBands();
+
+    /* We can't use getOffset(x, y) from the sample model since we
+       don't want the band offset added in. */
+	
+    int srcOffset = 
+      numBands*srcX + srcScanlineStride*srcY +    // from sample model
+      srcDB.getOffset();                          // from data buffer
+
+    int destOffset =
+      numBands*destX + destScanlineStride*destY + // from sample model
+      destDB.getOffset();                         // from data buffer
+
+    // Determine how much, and how many times to blit.
+    
+    int rowSize = src.getWidth()*numBands;
+    int h = src.getHeight();
+    
+    if ((rowSize == srcScanlineStride) &&
+	(rowSize == destScanlineStride))
+      {
+	// collapse scan line blits to one large blit.
+	rowSize *= h;
+	h = 1;
+      }
+
+	
+    // Do blitting
+    
+    Object srcArray  = Buffers.getData(srcDB);
+    Object destArray = Buffers.getData(destDB);
+    
+    for (int yd = 0; yd<h; yd++)
+      {
+	System.arraycopy(srcArray, srcOffset, 
+			 destArray, destOffset,
+			 rowSize);
+	srcOffset  +=  srcScanlineStride;
+	destOffset += destScanlineStride;
+      }
+    
+
+    return dest;
+  }
+
+  public Rectangle2D getBounds2D(Raster src) 
+  {
+    return src.getBounds();
+  }
+
+  public WritableRaster createCompatibleDestRaster(Raster src) {
+    
+    /* FIXME: Maybe we should explicitly create a raster with a
+       tightly pixel packed sample model, rather than assuming
+       that the createCompatibleWritableRaster() method in Raster
+       will create one. */
+
+    return src.createCompatibleWritableRaster();
+  }
+
+  public Point2D getPoint2D(Point2D srcPoint, Point2D destPoint) 
+  {
+    if (destPoint == null)
+      return (Point2D) srcPoint.clone();
+
+    destPoint.setLocation(srcPoint);
+    return destPoint;
+  }
+
+  public RenderingHints getRenderingHints() 
+  {
+    throw new UnsupportedOperationException("not implemented");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/EmbeddedWindow.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/EmbeddedWindow.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,139 @@
+/* EmbeddedWindow.java --
+   Copyright (C) 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 gnu.java.awt;
+
+import gnu.java.awt.peer.EmbeddedWindowPeer;
+import gnu.java.security.action.SetAccessibleAction;
+
+import java.awt.Component;
+import java.awt.Frame;
+import java.awt.Toolkit;
+import java.lang.reflect.Field;
+import java.security.AccessController;
+
+/**
+ * Represents an AWT window that can be embedded into another
+ * application.
+ * 
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public class EmbeddedWindow extends Frame
+{
+  private long handle;
+  
+  /**
+   * Creates a window to be embedded into another application.  The
+   * window will only be embedded after its setHandle method has been
+   * called.
+   */
+  public EmbeddedWindow ()
+  {
+    super();
+    this.handle = 0;
+  }
+  
+  /**
+   * Creates a window to be embedded into another application.
+   *
+   * @param handle the native handle to the screen area where the AWT
+   * window should be embedded
+   */
+  public EmbeddedWindow (long handle)
+  {
+    super();
+    this.handle = handle;
+  }
+  
+  /**
+   * Creates the native peer for this embedded window.
+   */
+  public void addNotify()
+  {
+    // Assume we're using ClasspathToolkit
+    ClasspathToolkit tk = (ClasspathToolkit) getToolkit();
+
+    // Circumvent the package-privateness of the AWT internal
+    // java.awt.Component.peer member variable.
+    try
+      {
+	Field peerField = Component.class.getDeclaredField("peer");
+	AccessController.doPrivileged(new SetAccessibleAction(peerField));
+	peerField.set(this, tk.createEmbeddedWindow (this));
+      }
+    catch (IllegalAccessException e)
+      {
+        throw new AssertionError (e);
+      }
+    catch (NoSuchFieldException e)
+      {
+        throw new AssertionError (e);
+      }
+
+    super.addNotify();
+  }
+
+  /**
+   * If the native peer for this embedded window has been created,
+   * then setHandle will embed the window.  If not, setHandle tells
+   * us where to embed ourselves when our peer is created.
+   *
+   * @param handle the native handle to the screen area where the AWT
+   * window should be embedded
+   */
+  public void setHandle(long handle)
+  {
+    if (this.handle != 0)
+      throw new RuntimeException ("EmbeddedWindow is already embedded");
+
+    this.handle = handle;
+    if (getPeer() != null)
+      ((EmbeddedWindowPeer) getPeer()).embed (this.handle);
+  }
+
+  /**
+   * Gets the native handle of the screen area where the window will
+   * be embedded.
+   *
+   * @return The native handle that was passed to the constructor.
+   */
+  public long getHandle()
+  {
+    return handle;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/EventModifier.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/EventModifier.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,107 @@
+/* EventModifier.java -- tool for converting modifier bits to 1.4 syle
+   Copyright (C) 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 gnu.java.awt;
+
+import java.awt.event.InputEvent;
+
+public class EventModifier
+{
+  /** The mask for old events. */
+  public static final int OLD_MASK = 0x3f;
+
+  /** The mask for new events. */
+  public static final int NEW_MASK = 0x3fc0;
+
+  /**
+   * Non-instantiable.
+   */
+  private EventModifier()
+  {
+    throw new InternalError();
+  }
+
+  /**
+   * Converts the old style modifiers (0x3f) to the new style (0xffffffc0).
+   *
+   * @param mod the modifiers to convert
+   * @return the adjusted modifiers
+   */
+  public static int extend(int mod)
+  {
+    // Favor what we hope will be the common case.
+    if ((mod & OLD_MASK) == 0)
+      return mod;
+    if ((mod & InputEvent.SHIFT_MASK) != 0)
+      mod |= InputEvent.SHIFT_DOWN_MASK;
+    if ((mod & InputEvent.CTRL_MASK) != 0)
+      mod |= InputEvent.CTRL_DOWN_MASK;
+    if ((mod & InputEvent.META_MASK) != 0)
+      mod |= InputEvent.META_DOWN_MASK;
+    if ((mod & InputEvent.ALT_MASK) != 0)
+      mod |= InputEvent.ALT_DOWN_MASK;
+    if ((mod & InputEvent.BUTTON1_MASK) != 0)
+      mod |= InputEvent.BUTTON1_DOWN_MASK;
+    if ((mod & InputEvent.ALT_GRAPH_MASK) != 0)
+      mod |= InputEvent.ALT_GRAPH_DOWN_MASK;
+    return mod & ~OLD_MASK;
+  }
+
+  /**
+   * Converts the new style modifiers (0xffffffc0) to the old style (0x3f).
+   *
+   * @param mod the modifiers to convert
+   * @return the adjusted modifiers
+   */
+  public static int revert(int mod)
+  {
+    if ((mod & InputEvent.SHIFT_DOWN_MASK) != 0)
+      mod |= InputEvent.SHIFT_MASK;
+    if ((mod & InputEvent.CTRL_DOWN_MASK) != 0)
+      mod |= InputEvent.CTRL_MASK;
+    if ((mod & InputEvent.META_DOWN_MASK) != 0)
+      mod |= InputEvent.META_MASK;
+    if ((mod & InputEvent.ALT_DOWN_MASK) != 0)
+      mod |= InputEvent.ALT_MASK;
+    if ((mod & InputEvent.ALT_GRAPH_DOWN_MASK) != 0)
+      mod |= InputEvent.ALT_GRAPH_MASK;
+    if ((mod & InputEvent.BUTTON1_DOWN_MASK) != 0)
+      mod |= InputEvent.BUTTON1_MASK;
+    return mod & OLD_MASK;
+  }
+} // class EventModifier

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/GradientPaintContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/GradientPaintContext.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,164 @@
+/* GradientPaintContext.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 gnu.java.awt;
+
+import java.awt.geom.Point2D;
+import java.awt.image.ColorModel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.awt.PaintContext;
+import java.awt.Color;
+
+/**
+ * A {@link PaintContext} used by the {@link GradientPaint} class.
+ */
+public class GradientPaintContext implements PaintContext 
+{
+
+  // This implementation follows the technique described in 
+  // "Java(tm) 2D Graphics" by Jonathan Knudsen (O'Reilly 1999).
+    
+  /** The x-coordinate of the anchor point for color 1. */
+  private final float x1;
+    
+  /** The y-coordinate of the anchor point for color 1. */
+  private final float y1;
+    
+  /** Color 1. */
+  private final Color c1;
+    
+  /** The x-coordinate of the anchor point for color 2. */
+  private final float x2;
+    
+  /** The y-coordinate of the anchor point for color 2. */
+  private final float y2;
+    
+  /** Color 2. */
+  private final Color c2;
+    
+  /** A flag indicating whether the gradient is cyclic or acyclic. */
+  private final boolean cyclic;
+    
+  /** The length of the gradient line - computed from the two anchor points. */
+  private final double length; 
+
+  /**
+   * Creates a new instance.
+   * 
+   * @param x1  the x-coordinate for the anchor point for color 1.
+   * @param y1  the y-coordinate for the anchor point for color 1.
+   * @param c1  color 1.
+   * @param x2  the x-coordinate for the anchor point for color 2.
+   * @param y2  the y-coordinate for the anchor point for color 2.
+   * @param c2  color 2.
+   * @param cyclic  a flag that determines whether the gradient is cyclic
+   *                or acyclic.
+   */
+  public GradientPaintContext(float x1, float y1, Color c1, 
+                              float x2, float y2, Color c2, boolean cyclic) 
+  {     
+    this.x1 = x1;
+    this.y1 = y1;
+    this.c1 = c1;
+    this.x2 = x2;
+    this.y2 = y2;
+    this.c2 = c2;
+    this.cyclic = cyclic;
+    length = Point2D.distance(x1, y1, x2, y2);
+  }
+    
+  /**
+   * Return the color model of this context. It may be different from the
+   * hint specified during createContext, as not all contexts can generate
+   * color patterns in an arbitrary model.
+   *
+   * @return the context color model
+   */
+  public ColorModel getColorModel() 
+  {
+    return ColorModel.getRGBdefault();   
+  }
+
+  /**
+   * Return a raster containing the colors for the graphics operation.
+   *
+   * @param x the x-coordinate, in device space
+   * @param y the y-coordinate, in device space
+   * @param w the width, in device space
+   * @param h the height, in device space
+   * @return a raster for the given area and color
+   */
+  public Raster getRaster(int x, int y, int w, int h) {
+    ColorModel cm = getColorModel();
+    WritableRaster raster = cm.createCompatibleWritableRaster(w, h);
+    int[] data = new int[w * h * 4];
+    double pd2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
+    for (int r = 0; r < h; r++) {
+      for (int c = 0; c < w; c++) {
+        double u = 0.0;
+        if (pd2 != 0) 
+          u = (((x + c) - x1) * (x2 - x1) + ((y + r) - y1) * (y2 - y1)) 
+                  / Math.sqrt(pd2);
+        double ratio = u / length;
+        if (cyclic)
+          ratio = Math.abs(ratio - Math.floor((ratio + 1.0) / 2.0) * 2.0);
+        else 
+          ratio = Math.max(0.0, Math.min(1.0, ratio));
+        int base = (r * w + c) * 4;
+        data[base] = (int) (c1.getRed() + ratio * (c2.getRed() - c1.getRed()));
+        data[base + 1] 
+          = (int) (c1.getGreen() + ratio * (c2.getGreen() - c1.getGreen()));
+        data[base + 2] 
+          = (int) (c1.getBlue() + ratio * (c2.getBlue() - c1.getBlue()));
+        data[base + 3] 
+          = (int) (c1.getAlpha() + ratio * (c2.getAlpha() - c1.getAlpha()));
+      }
+    }
+    raster.setPixels(0, 0, w, h, data);
+    return raster;
+  }
+
+  /**
+   * Release the resources allocated for the paint (none in this 
+   * implementation).
+   */
+  public void dispose() {
+    // nothing to do    
+  }
+    
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/CieXyzConverter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/CieXyzConverter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* CieXyzConverter.java -- CieXyz conversion class
+   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.awt.color;
+
+
+/**
+ * CieXyzConverter - converts to/from a D50-relative CIE XYZ color space.
+ * 
+ * The sRGB<->CIE XYZ conversions in SrgbConverter are used.
+ *
+ * @author Sven de Marothy
+ */
+public class CieXyzConverter implements ColorSpaceConverter
+{
+  public float[] toCIEXYZ(float[] in)
+  {
+    float[] out = new float[3];
+    System.arraycopy(in, 0, out, 0, 3);
+    return out;
+  }
+
+  public float[] fromCIEXYZ(float[] in)
+  {
+    float[] out = new float[3];
+    System.arraycopy(in, 0, out, 0, 3);
+    return out;
+  }
+
+  public float[] toRGB(float[] in)
+  {
+    return SrgbConverter.XYZtoRGB(in);
+  }
+
+  public float[] fromRGB(float[] in)
+  {
+    return SrgbConverter.RGBtoXYZ(in);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/ClutProfileConverter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/ClutProfileConverter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,152 @@
+/* ClutProfileConverter.java -- Conversion routines for CLUT-Based profiles
+   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.awt.color;
+
+import java.awt.color.ICC_Profile;
+
+
+/**
+ * ClutProfileConverter - conversions through a CLUT-based profile
+ *
+ * @author Sven de Marothy
+ */
+public class ClutProfileConverter implements ColorSpaceConverter
+{
+  private ColorLookUpTable toPCS;
+  private ColorLookUpTable fromPCS;
+  private int nChannels;
+
+  public ClutProfileConverter(ICC_Profile profile)
+  {
+    nChannels = profile.getNumComponents();
+
+    // Sun does not specifiy which rendering intent should be used,
+    // neither does the ICC v2 spec really. 
+    // Try intent 0
+    try
+      {
+	toPCS = new ColorLookUpTable(profile, ICC_Profile.icSigAToB0Tag);
+      }
+    catch (Exception e)
+      {
+	toPCS = null;
+      }
+
+    try
+      {
+	fromPCS = new ColorLookUpTable(profile, ICC_Profile.icSigBToA0Tag);
+      }
+    catch (Exception e)
+      {
+	fromPCS = null;
+      }
+
+    if (toPCS != null || fromPCS != null)
+      return;
+
+    // If no intent 0 clut is available, look for a intent 1 clut.
+    try
+      {
+	toPCS = new ColorLookUpTable(profile, ICC_Profile.icSigAToB1Tag);
+      }
+    catch (Exception e)
+      {
+	toPCS = null;
+      }
+
+    try
+      {
+	fromPCS = new ColorLookUpTable(profile, ICC_Profile.icSigBToA1Tag);
+      }
+    catch (Exception e)
+      {
+	fromPCS = null;
+      }
+
+    if (toPCS != null || fromPCS != null)
+      return;
+
+    // Last shot.. intent 2 CLUT.
+    try
+      {
+	toPCS = new ColorLookUpTable(profile, ICC_Profile.icSigAToB2Tag);
+      }
+    catch (Exception e)
+      {
+	toPCS = null;
+      }
+
+    try
+      {
+	fromPCS = new ColorLookUpTable(profile, ICC_Profile.icSigBToA2Tag);
+      }
+    catch (Exception e)
+      {
+	fromPCS = null;
+      }
+
+    if (toPCS == null && fromPCS == null)
+      throw new IllegalArgumentException("No CLUTs in profile!");
+  }
+
+  public float[] toCIEXYZ(float[] in)
+  {
+    if (toPCS != null)
+      return toPCS.lookup(in);
+    else
+      return new float[3];
+  }
+
+  public float[] toRGB(float[] in)
+  {
+    return SrgbConverter.XYZtoRGB(toCIEXYZ(in));
+  }
+
+  public float[] fromCIEXYZ(float[] in)
+  {
+    if (fromPCS != null)
+      return fromPCS.lookup(in);
+    else
+      return new float[nChannels];
+  }
+
+  public float[] fromRGB(float[] in)
+  {
+    return fromCIEXYZ(SrgbConverter.RGBtoXYZ(in));
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/ColorLookUpTable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/ColorLookUpTable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,429 @@
+/* ColorLookUpTable.java -- ICC v2 CLUT
+   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.awt.color;
+
+import java.awt.color.ColorSpace;
+import java.awt.color.ICC_Profile;
+import java.nio.ByteBuffer;
+
+
+/**
+ * ColorLookUpTable handles color lookups through a color lookup table,
+ * as defined in the ICC specification.
+ * Both 'mft2' and 'mft1' (8 and 16-bit) type CLUTs are handled.
+ *
+ * This will have to be updated later for ICC 4.0.0
+ *
+ * @author Sven de Marothy
+ */
+public class ColorLookUpTable
+{
+  /**
+   * CIE 1931 D50 white point (in Lab coordinates)
+   */
+  private static float[] D50 = { 0.96422f, 1.00f, 0.82521f };
+
+  /**
+   * Number of input/output channels
+   */
+  int nIn;
+
+  /**
+   * Number of input/output channels
+   */
+  int nOut;
+  int nInTableEntries; // Number of input table entries
+  int nOutTableEntries; // Number of output table entries
+  int gridpoints; // Number of gridpoints
+  int nClut; // This is nOut*(gridpoints**nIn)
+  double[][] inTable; // 1D input table ([channel][table])
+  short[][] outTable; // 1D input table ([channel][table])
+  double[] clut; // The color lookup table
+  float[][] inMatrix; // input matrix (XYZ only)
+  boolean useMatrix; // Whether to use the matrix or not.
+  int[] multiplier;
+  int[] offsets; // Hypercube offsets 
+  boolean inputLab; // Set if the CLUT input CS is Lab
+  boolean outputLab; // Set if the CLUT output CS is Lab
+
+  /**
+   * Constructor
+   * Requires a profile file to get the CLUT from and the tag of the
+   * CLUT to create. (icSigXToYZTag where X,Y = [A | B], Z = [0,1,2])
+   */
+  public ColorLookUpTable(ICC_Profile profile, int tag)
+  {
+    useMatrix = false;
+
+    switch (tag)
+      {
+      case ICC_Profile.icSigAToB0Tag:
+      case ICC_Profile.icSigAToB1Tag:
+      case ICC_Profile.icSigAToB2Tag:
+	if (profile.getColorSpaceType() == ColorSpace.TYPE_XYZ)
+	  useMatrix = true;
+	inputLab = false;
+	outputLab = (profile.getPCSType() == ColorSpace.TYPE_Lab);
+	break;
+      case ICC_Profile.icSigBToA0Tag:
+      case ICC_Profile.icSigBToA1Tag:
+      case ICC_Profile.icSigBToA2Tag:
+	if (profile.getPCSType() == ColorSpace.TYPE_XYZ)
+	  useMatrix = true;
+	inputLab = (profile.getPCSType() == ColorSpace.TYPE_Lab);
+	outputLab = false;
+	break;
+      default:
+	throw new IllegalArgumentException("Not a clut-type tag.");
+      }
+
+    byte[] data = profile.getData(tag);
+    if (data == null)
+      throw new IllegalArgumentException("Unsuitable profile, does not contain a CLUT.");
+
+    // check 'mft'
+    if (data[0] != 0x6d || data[1] != 0x66 || data[2] != 0x74)
+      throw new IllegalArgumentException("Unsuitable profile, invalid CLUT data.");
+
+    if (data[3] == 0x32)
+      readClut16(data);
+    else if (data[3] == 0x31)
+      readClut8(data);
+    else
+      throw new IllegalArgumentException("Unknown/invalid CLUT type.");
+  }
+
+  /**
+   * Loads a 16-bit CLUT into our data structures
+   */
+  private void readClut16(byte[] data)
+  {
+    ByteBuffer buf = ByteBuffer.wrap(data);
+
+    nIn = data[8] & (0xFF);
+    nOut = data[9] & (0xFF);
+    nInTableEntries = buf.getShort(48);
+    nOutTableEntries = buf.getShort(50);
+    gridpoints = data[10] & (0xFF);
+
+    inMatrix = new float[3][3];
+    for (int i = 0; i < 3; i++)
+      for (int j = 0; j < 3; j++)
+	inMatrix[i][j] = ((float) (buf.getInt(12 + (i * 3 + j) * 4))) / 65536.0f;
+
+    inTable = new double[nIn][nInTableEntries];
+    for (int channel = 0; channel < nIn; channel++)
+      for (int i = 0; i < nInTableEntries; i++)
+	inTable[channel][i] = (double) ((int) buf.getShort(52
+	                                                   + (channel * nInTableEntries
+	                                                   + i) * 2)
+	                      & (0xFFFF)) / 65536.0;
+
+    nClut = nOut;
+    multiplier = new int[nIn];
+    multiplier[nIn - 1] = nOut;
+    for (int i = 0; i < nIn; i++)
+      {
+	nClut *= gridpoints;
+	if (i > 0)
+	  multiplier[nIn - i - 1] = multiplier[nIn - i] * gridpoints;
+      }
+
+    int clutOffset = 52 + nIn * nInTableEntries * 2;
+    clut = new double[nClut];
+    for (int i = 0; i < nClut; i++)
+      clut[i] = (double) ((int) buf.getShort(clutOffset + i * 2) & (0xFFFF)) / 65536.0;
+
+    outTable = new short[nOut][nOutTableEntries];
+    for (int channel = 0; channel < nOut; channel++)
+      for (int i = 0; i < nOutTableEntries; i++)
+	outTable[channel][i] = buf.getShort(clutOffset
+	                                    + (nClut
+	                                    + channel * nOutTableEntries + i) * 2);
+
+    // calculate the hypercube corner offsets
+    offsets = new int[(1 << nIn)];
+    offsets[0] = 0;
+    for (int j = 0; j < nIn; j++)
+      {
+	int factor = 1 << j;
+	for (int i = 0; i < factor; i++)
+	  offsets[factor + i] = offsets[i] + multiplier[j];
+      }
+  }
+
+  /**
+   * Loads a 8-bit CLUT into our data structures.
+   */
+  private void readClut8(byte[] data)
+  {
+    ByteBuffer buf = ByteBuffer.wrap(data);
+
+    nIn = (data[8] & (0xFF));
+    nOut = (data[9] & (0xFF));
+    nInTableEntries = 256; // always 256
+    nOutTableEntries = 256; // always 256
+    gridpoints = (data[10] & (0xFF));
+
+    inMatrix = new float[3][3];
+    for (int i = 0; i < 3; i++)
+      for (int j = 0; j < 3; j++)
+	inMatrix[i][j] = ((float) (buf.getInt(12 + (i * 3 + j) * 4))) / 65536.0f;
+
+    inTable = new double[nIn][nInTableEntries];
+    for (int channel = 0; channel < nIn; channel++)
+      for (int i = 0; i < nInTableEntries; i++)
+	inTable[channel][i] = (double) ((int) buf.get(48
+	                                              + (channel * nInTableEntries
+	                                              + i)) & (0xFF)) / 255.0;
+
+    nClut = nOut;
+    multiplier = new int[nIn];
+    multiplier[nIn - 1] = nOut;
+    for (int i = 0; i < nIn; i++)
+      {
+	nClut *= gridpoints;
+	if (i > 0)
+	  multiplier[nIn - i - 1] = multiplier[nIn - i] * gridpoints;
+      }
+
+    int clutOffset = 48 + nIn * nInTableEntries;
+    clut = new double[nClut];
+    for (int i = 0; i < nClut; i++)
+      clut[i] = (double) ((int) buf.get(clutOffset + i) & (0xFF)) / 255.0;
+
+    outTable = new short[nOut][nOutTableEntries];
+    for (int channel = 0; channel < nOut; channel++)
+      for (int i = 0; i < nOutTableEntries; i++)
+	outTable[channel][i] = (short) (buf.get(clutOffset + nClut
+	                                        + channel * nOutTableEntries
+	                                        + i) * 257);
+
+    // calculate the hypercube corner offsets
+    offsets = new int[(1 << nIn)];
+    offsets[0] = 0;
+    for (int j = 0; j < nIn; j++)
+      {
+	int factor = 1 << j;
+	for (int i = 0; i < factor; i++)
+	  offsets[factor + i] = offsets[i] + multiplier[j];
+      }
+  }
+
+  /**
+   * Performs a lookup through the Color LookUp Table.
+   * If the CLUT tag type is AtoB the conversion will be from the device
+   * color space to the PCS, BtoA type goes in the opposite direction.
+   *
+   * For convenience, the PCS values for input or output will always be
+   * CIE XYZ (D50), if the actual PCS is Lab, the values will be converted.
+   *
+   * N-dimensional linear interpolation is used.
+   */
+  float[] lookup(float[] in)
+  {
+    float[] in2 = new float[in.length];
+    if (useMatrix)
+      {
+	for (int i = 0; i < 3; i++)
+	  in2[i] = in[0] * inMatrix[i][0] + in[1] * inMatrix[i][1]
+	           + in[2] * inMatrix[i][2];
+      }
+    else if (inputLab)
+      in2 = XYZtoLab(in);
+    else
+      System.arraycopy(in, 0, in2, 0, in.length);
+
+    // input table 
+    for (int i = 0; i < nIn; i++)
+      {
+	int index = (int) Math.floor(in2[i] * (double) (nInTableEntries - 1)); // floor in
+
+	// clip values.
+	if (index >= nInTableEntries - 1)
+	  in2[i] = (float) inTable[i][nInTableEntries - 1];
+	else if (index < 0)
+	  in2[i] = (float) inTable[i][0];
+	else
+	  {
+	    // linear interpolation
+	    double alpha = in2[i] * ((double) nInTableEntries - 1.0) - index;
+	    in2[i] = (float) (inTable[i][index] * (1 - alpha)
+	             + inTable[i][index + 1] * alpha);
+	  }
+      }
+
+    // CLUT lookup
+    double[] output2 = new double[nOut];
+    double[] weights = new double[(1 << nIn)];
+    double[] clutalpha = new double[nIn]; // interpolation values
+    int offset = 0; // = gp
+    for (int i = 0; i < nIn; i++)
+      {
+	int index = (int) Math.floor(in2[i] * ((double) gridpoints - 1.0));
+	double alpha = in2[i] * ((double) gridpoints - 1.0) - (double) index;
+
+	// clip values.
+	if (index >= gridpoints - 1)
+	  {
+	    index = gridpoints - 1;
+	    alpha = 1.0;
+	  }
+	else if (index < 0)
+	  index = 0;
+	clutalpha[i] = alpha;
+	offset += index * multiplier[i];
+      }
+
+    // Calculate interpolation weights
+    weights[0] = 1.0;
+    for (int j = 0; j < nIn; j++)
+      {
+	int factor = 1 << j;
+	for (int i = 0; i < factor; i++)
+	  {
+	    weights[factor + i] = weights[i] * clutalpha[j];
+	    weights[i] *= (1.0 - clutalpha[j]);
+	  }
+      }
+
+    for (int i = 0; i < nOut; i++)
+      output2[i] = weights[0] * clut[offset + i];
+
+    for (int i = 1; i < (1 << nIn); i++)
+      {
+	int offset2 = offset + offsets[i];
+	for (int f = 0; f < nOut; f++)
+	  output2[f] += weights[i] * clut[offset2 + f];
+      }
+
+    // output table 
+    float[] output = new float[nOut];
+    for (int i = 0; i < nOut; i++)
+      {
+	int index = (int) Math.floor(output2[i] * ((double) nOutTableEntries
+	                             - 1.0));
+
+	// clip values.
+	if (index >= nOutTableEntries - 1)
+	  output[i] = outTable[i][nOutTableEntries - 1];
+	else if (index < 0)
+	  output[i] = outTable[i][0];
+	else
+	  {
+	    // linear interpolation
+	    double a = output2[i] * ((double) nOutTableEntries - 1.0)
+	               - (double) index;
+	    output[i] = (float) ((double) ((int) outTable[i][index] & (0xFFFF)) * (1
+	                - a)
+	                + (double) ((int) outTable[i][index + 1] & (0xFFFF)) * a) / 65536f;
+	  }
+      }
+
+    if (outputLab)
+      return LabtoXYZ(output);
+    return output;
+  }
+
+  /**
+   * Converts CIE Lab coordinates to (D50) XYZ ones.
+   */
+  private float[] LabtoXYZ(float[] in)
+  {
+    // Convert from byte-packed format to a 
+    // more convenient one (actual Lab values)
+    // (See ICC spec for details)
+    // factor is 100 * 65536 / 65280
+    in[0] = (float) (100.392156862745 * in[0]);
+    in[1] = (in[1] * 256.0f) - 128.0f;
+    in[2] = (in[2] * 256.0f) - 128.0f;
+
+    float[] out = new float[3];
+
+    out[1] = (in[0] + 16.0f) / 116.0f;
+    out[0] = in[1] / 500.0f + out[1];
+    out[2] = out[1] - in[2] / 200.0f;
+
+    for (int i = 0; i < 3; i++)
+      {
+	double exp = out[i] * out[i] * out[i];
+	if (exp <= 0.008856)
+	  out[i] = (out[i] - 16.0f / 116.0f) / 7.787f;
+	else
+	  out[i] = (float) exp;
+	out[i] = D50[i] * out[i];
+      }
+    return out;
+  }
+
+  /**
+   * Converts CIE XYZ coordinates to Lab ones.
+   */
+  private float[] XYZtoLab(float[] in)
+  {
+    float[] temp = new float[3];
+
+    for (int i = 0; i < 3; i++)
+      {
+	temp[i] = in[i] / D50[i];
+
+	if (temp[i] <= 0.008856f)
+	  temp[i] = (7.7870689f * temp[i]) + (16f / 116.0f);
+	else
+	  temp[i] = (float) Math.exp((1.0 / 3.0) * Math.log(temp[i]));
+      }
+
+    float[] out = new float[3];
+    out[0] = (116.0f * temp[1]) - 16f;
+    out[1] = 500.0f * (temp[0] - temp[1]);
+    out[2] = 200.0f * (temp[1] - temp[2]);
+
+    // Normalize to packed format
+    out[0] = (float) (out[0] / 100.392156862745);
+    out[1] = (out[1] + 128f) / 256f;
+    out[2] = (out[2] + 128f) / 256f;
+    for (int i = 0; i < 3; i++)
+      {
+	if (out[i] < 0f)
+	  out[i] = 0f;
+	if (out[i] > 1f)
+	  out[i] = 1f;
+      }
+    return out;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/ColorSpaceConverter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/ColorSpaceConverter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,69 @@
+/* ColorSpaceConverter.java -- an interface for colorspace conversion
+   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.awt.color;
+
+
+/**
+ * ColorSpaceConverter - used by java.awt.color.ICC_ColorSpace
+ *
+ * Color space conversion can occur in several ways:
+ *
+ * -Directly (for the built in spaces sRGB, linear RGB, gray, CIE XYZ and PYCC
+ * -ICC_ProfileRGB works through TRC curves and a matrix
+ * -ICC_ProfileGray works through a single TRC
+ * -Everything else is done through Color lookup tables.
+ *
+ * The different conversion methods are implemented through
+ * an interface. The built-in colorspaces are implemented directly
+ * with the relevant conversion equations.
+ *
+ * In this way, we hopefully will always use the fastest and most
+ * accurate method available.
+ *
+ * @author Sven de Marothy
+ */
+public interface ColorSpaceConverter
+{
+  float[] toCIEXYZ(float[] in);
+
+  float[] fromCIEXYZ(float[] in);
+
+  float[] toRGB(float[] in);
+
+  float[] fromRGB(float[] in);
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/GrayProfileConverter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/GrayProfileConverter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,137 @@
+/* GrayProfileConverter.java -- Gray profile conversion class
+   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.awt.color;
+
+import java.awt.color.ICC_Profile;
+import java.awt.color.ICC_ProfileGray;
+import java.awt.color.ProfileDataException;
+
+/**
+ * GrayProfileConverter - converts Grayscale profiles (ICC_ProfileGray)
+ *
+ * This type of profile contains a single tone reproduction curve (TRC).
+ * Conversion consists of simple TRC lookup.
+ *
+ * This implementation is very lazy and does everything applying the TRC and
+ * utilizing the built-in linear grayscale color space.
+ *
+ * @author Sven de Marothy
+ */
+public class GrayProfileConverter implements ColorSpaceConverter
+{
+  private GrayScaleConverter gc;
+  private ToneReproductionCurve trc;
+  private ColorLookUpTable toPCS;
+  private ColorLookUpTable fromPCS;
+
+  /**
+   * Constructs the converter described by an ICC_ProfileGray object
+   */
+  public GrayProfileConverter(ICC_ProfileGray profile)
+  {
+    try
+      {
+	trc = new ToneReproductionCurve(profile.getGamma());
+      }
+    catch (ProfileDataException e)
+      {
+	trc = new ToneReproductionCurve(profile.getTRC());
+      }
+
+    // linear grayscale converter
+    gc = new GrayScaleConverter();
+
+    // If a CLUT is available, it should be used, and the TRCs ignored.
+    // Note: A valid profile may only have CLUTs in one direction, and
+    // TRC:s without useful info, making reverse-transforms impossible.
+    // In this case the TRC will be used for the reverse-transform with
+    // unpredictable results. This is in line with the Java specification,
+    try
+      {
+	toPCS = new ColorLookUpTable(profile, ICC_Profile.icSigAToB0Tag);
+      }
+    catch (Exception e)
+      {
+	toPCS = null;
+      }
+
+    try
+      {
+	fromPCS = new ColorLookUpTable(profile, ICC_Profile.icSigBToA0Tag);
+      }
+    catch (Exception e)
+      {
+	fromPCS = null;
+      }
+  }
+
+  public float[] toCIEXYZ(float[] in)
+  {
+    if (toPCS != null)
+      return toPCS.lookup(in);
+    float[] gray = new float[1];
+    gray[0] = trc.lookup(in[0]);
+    return gc.toCIEXYZ(gray);
+  }
+
+  public float[] toRGB(float[] in)
+  {
+    float[] gray = new float[1];
+    gray[0] = trc.lookup(in[0]);
+    return gc.toRGB(gray);
+  }
+
+  public float[] fromRGB(float[] in)
+  {
+    // get linear grayscale value
+    float[] gray = gc.fromRGB(in);
+    gray[0] = trc.reverseLookup(gray[0]);
+    return gray;
+  }
+
+  public float[] fromCIEXYZ(float[] in)
+  {
+    if (fromPCS != null)
+      return fromPCS.lookup(in);
+
+    float[] gray = gc.fromCIEXYZ(in);
+    gray[0] = trc.reverseLookup(gray[0]);
+    return gray;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/GrayScaleConverter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/GrayScaleConverter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,110 @@
+/* GrayScaleConverter.java -- Linear grayscale conversion class
+   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.awt.color;
+
+
+/**
+ * Linear Grayscale converter
+ *
+ * @author Sven de Marothy
+ */
+public class GrayScaleConverter implements ColorSpaceConverter
+{
+  // intensity factors (ITU Rec. BT.709)
+  double[] coeff = { 0.2125f, 0.7154f, 0.0721f };
+
+  /**
+   * CIE 1931 D50 white point (in Lab coordinates)
+   */
+  private static float[] D50 = { 0.96422f, 1.00f, 0.82521f };
+
+  public float[] toCIEXYZ(float[] in)
+  {
+    float g = in[0];
+    if (g < 0)
+      g = 1 + g;
+    float[] out = { g * D50[0], g * D50[1], g * D50[2] }; // White spot
+    return out;
+  }
+
+  public float[] toRGB(float[] in)
+  {
+    float[] out = new float[3];
+    if (in[0] <= 0.00304f)
+      out[0] = in[0] * 12.92f;
+    else
+      out[0] = 1.055f * ((float) Math.exp((1 / 2.4) * Math.log(in[0])))
+               - 0.055f;
+    out[1] = out[2] = out[0];
+    return out;
+  }
+
+  public float[] fromCIEXYZ(float[] in)
+  {
+    float[] temp = new float[3];
+    temp[0] = 3.1338f * in[0] - 1.6171f * in[1] - 0.4907f * in[2];
+    temp[1] = -0.9785f * in[0] + 1.9160f * in[1] + 0.0334f * in[2];
+    temp[2] = 0.0720f * in[0] - 0.2290f * in[1] + 1.4056f * in[2];
+    float[] out = new float[1];
+    for (int i = 0; i < 3; i++)
+      out[0] = (float) (temp[i] * coeff[i]);
+    return out;
+  }
+
+  public float[] fromRGB(float[] in)
+  {
+    float[] out = new float[1];
+
+    // Convert non-linear RGB coordinates to linear ones,
+    //  numbers from the w3 spec.
+    out[0] = 0;
+    for (int i = 0; i < 3; i++)
+      {
+	float n = in[i];
+	if (n < 0)
+	  n = 0f;
+	if (n > 1)
+	  n = 1f;
+	if (n <= 0.03928f)
+	  out[0] += (float) (coeff[i] * n / 12.92);
+	else
+	  out[0] += (float) (coeff[i] * Math.exp(2.4 * Math.log((n + 0.055) / 1.055)));
+      }
+    return out;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/LinearRGBConverter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/LinearRGBConverter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,152 @@
+/* LinearRGBConverter.java -- conversion to a linear RGB color space
+   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.awt.color;
+
+
+/**
+ * LinearRGBConverter - conversion routines for a linear sRGB colorspace
+ * sRGB is a standard for RGB colorspaces, adopted by the w3c.
+ *
+ * The specification is available at:
+ * http://www.w3.org/Graphics/Color/sRGB.html
+ *
+ * @author Sven de Marothy
+ */
+public class LinearRGBConverter implements ColorSpaceConverter
+{
+  /**
+   * linear RGB --> sRGB
+   * Use the inverse gamma curve
+   */
+  public float[] toRGB(float[] in)
+  {
+    float[] out = new float[3];
+    for (int i = 0; i < 3; i++)
+      {
+	float n = in[i];
+	if (n < 0)
+	  n = 0f;
+	if (n > 1)
+	  n = 1f;
+	if (n <= 0.00304f)
+	  out[i] = in[0] * 12.92f;
+	else
+	  out[i] = 1.055f * ((float) Math.exp((1 / 2.4) * Math.log(n)))
+	           - 0.055f;
+      }
+    return out;
+  }
+
+  /**
+   * sRGB --> linear RGB
+   * Use the gamma curve (gamma=2.4 in sRGB)
+   */
+  public float[] fromRGB(float[] in)
+  {
+    float[] out = new float[3];
+
+    // Convert non-linear RGB coordinates to linear ones,
+    //  numbers from the w3 spec.
+    for (int i = 0; i < 3; i++)
+      {
+	float n = in[i];
+	if (n < 0)
+	  n = 0f;
+	if (n > 1)
+	  n = 1f;
+	if (n <= 0.03928f)
+	  out[i] = (float) (n / 12.92);
+	else
+	  out[i] = (float) (Math.exp(2.4 * Math.log((n + 0.055) / 1.055)));
+      }
+    return out;
+  }
+
+  /**
+   * Linear RGB --> CIE XYZ (D50 relative)
+   * This is a simple matrix transform, the matrix (relative D65)
+   * is given in the sRGB spec. This has been combined with a
+   * linear Bradford transform for the D65-->D50 mapping, resulting
+   * in a single matrix which does the whole thing.
+   *
+   */
+  public float[] fromCIEXYZ(float[] in)
+  {
+    /*
+     * Note: The numbers which were used to calculate this only had four
+     * digits of accuracy. So don't be fooled by the number of digits here.
+     * If someone has more accurate source, feel free to update this.
+     */
+    float[] out = new float[3];
+    out[0] = (float) (3.13383065124221 * in[0] - 1.61711949411313 * in[1]
+             - 0.49071914111101 * in[2]);
+    out[1] = (float) (-0.97847026691142 * in[0] + 1.91597856031996 * in[1]
+             + 0.03340430640699 * in[2]);
+    out[2] = (float) (0.07203679486279 * in[0] - 0.22903073553113 * in[1]
+             + 1.40557835776234 * in[2]);
+    if (out[0] < 0)
+      out[0] = 0f;
+    if (out[1] < 0)
+      out[1] = 0f;
+    if (out[2] < 0)
+      out[2] = 0f;
+    if (out[0] > 1.0f)
+      out[0] = 1.0f;
+    if (out[1] > 1.0f)
+      out[1] = 1.0f;
+    if (out[2] > 1.0f)
+      out[2] = 1.0f;
+    return out;
+  }
+
+  /**
+   * Linear RGB --> CIE XYZ (D50 relative)
+   * Uses the inverse of the above matrix.
+   */
+  public float[] toCIEXYZ(float[] in)
+  {
+    float[] out = new float[3];
+    out[0] = (float) (0.43606375022190 * in[0] + 0.38514960146481 * in[1]
+             + 0.14308641888799 * in[2]);
+    out[1] = (float) (0.22245089403542 * in[0] + 0.71692584775182 * in[1]
+             + 0.06062451125578 * in[2]);
+    out[2] = (float) (0.01389851860679 * in[0] + 0.09707969011198 * in[1]
+             + 0.71399604572506 * in[2]);
+    return out;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/ProfileHeader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/ProfileHeader.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,398 @@
+/* ProfileHeader.java -- Encapsules ICC Profile header data
+   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.awt.color;
+
+import java.awt.color.ColorSpace;
+import java.awt.color.ICC_Profile;
+import java.nio.ByteBuffer;
+
+
+/**
+ * Header, abstracts and validates the header data.
+ *
+ * @author Sven de Marothy
+ */
+public class ProfileHeader
+{
+  /**
+   * Magic identifier (ASCII 'acsp')
+   */
+  private static final int icMagicNumber = 0x61637370;
+
+  /**
+   * Mapping from ICC Profile signatures to ColorSpace types
+   */
+  private static final int[] csTypeMap = 
+                                         {
+                                           ICC_Profile.icSigXYZData,
+                                           ColorSpace.TYPE_XYZ,
+                                           ICC_Profile.icSigLabData,
+                                           ColorSpace.TYPE_Lab,
+                                           ICC_Profile.icSigLuvData,
+                                           ColorSpace.TYPE_Luv,
+                                           ICC_Profile.icSigYCbCrData,
+                                           ColorSpace.TYPE_YCbCr,
+                                           ICC_Profile.icSigYxyData,
+                                           ColorSpace.TYPE_Yxy,
+                                           ICC_Profile.icSigRgbData,
+                                           ColorSpace.TYPE_RGB,
+                                           ICC_Profile.icSigGrayData,
+                                           ColorSpace.TYPE_GRAY,
+                                           ICC_Profile.icSigHsvData,
+                                           ColorSpace.TYPE_HSV,
+                                           ICC_Profile.icSigHlsData,
+                                           ColorSpace.TYPE_HLS,
+                                           ICC_Profile.icSigCmykData,
+                                           ColorSpace.TYPE_CMYK,
+                                           ICC_Profile.icSigCmyData,
+                                           ColorSpace.TYPE_CMY,
+                                           ICC_Profile.icSigSpace2CLR,
+                                           ColorSpace.TYPE_2CLR,
+                                           ICC_Profile.icSigSpace3CLR,
+                                           ColorSpace.TYPE_3CLR,
+                                           ICC_Profile.icSigSpace4CLR,
+                                           ColorSpace.TYPE_4CLR,
+                                           ICC_Profile.icSigSpace5CLR,
+                                           ColorSpace.TYPE_5CLR,
+                                           ICC_Profile.icSigSpace6CLR,
+                                           ColorSpace.TYPE_6CLR,
+                                           ICC_Profile.icSigSpace7CLR,
+                                           ColorSpace.TYPE_7CLR,
+                                           ICC_Profile.icSigSpace8CLR,
+                                           ColorSpace.TYPE_8CLR,
+                                           ICC_Profile.icSigSpace9CLR,
+                                           ColorSpace.TYPE_9CLR,
+                                           ICC_Profile.icSigSpaceACLR,
+                                           ColorSpace.TYPE_ACLR,
+                                           ICC_Profile.icSigSpaceBCLR,
+                                           ColorSpace.TYPE_BCLR,
+                                           ICC_Profile.icSigSpaceCCLR,
+                                           ColorSpace.TYPE_CCLR,
+                                           ICC_Profile.icSigSpaceDCLR,
+                                           ColorSpace.TYPE_DCLR,
+                                           ICC_Profile.icSigSpaceECLR,
+                                           ColorSpace.TYPE_ECLR,
+                                           ICC_Profile.icSigSpaceFCLR,
+                                           ColorSpace.TYPE_FCLR
+                                         };
+
+  /**
+   * Size of an ICC header (128 bytes)
+   */
+  public static final int HEADERSIZE = 128;
+
+  /**
+   * Mapping of ICC class signatures to profile class constants
+   */
+  private static final int[] classMap = 
+                                        {
+                                          ICC_Profile.icSigInputClass,
+                                          ICC_Profile.CLASS_INPUT,
+                                          ICC_Profile.icSigDisplayClass,
+                                          ICC_Profile.CLASS_DISPLAY,
+                                          ICC_Profile.icSigOutputClass,
+                                          ICC_Profile.CLASS_OUTPUT,
+                                          ICC_Profile.icSigLinkClass,
+                                          ICC_Profile.CLASS_DEVICELINK,
+                                          ICC_Profile.icSigColorSpaceClass,
+                                          ICC_Profile.CLASS_COLORSPACECONVERSION,
+                                          ICC_Profile.icSigAbstractClass,
+                                          ICC_Profile.CLASS_ABSTRACT,
+                                          ICC_Profile.icSigNamedColorClass,
+                                          ICC_Profile.CLASS_NAMEDCOLOR
+                                        };
+  private int size;
+  private int cmmId;
+
+  // Major/Minor version, The ICC-1998 spec is major v2
+  private int majorVersion;
+
+  // Major/Minor version, The ICC-1998 spec is major v2
+  private int minorVersion;
+  private int profileClass; // profile device class
+  private int colorSpace; // data color space type
+  private int profileColorSpace; // profile connection space (PCS) type
+  private byte[] timestamp; // original creation timestamp
+  private int platform; // platform signature
+  private int flags; // flags
+  private int magic; // magic number.
+  private int manufacturerSig; // manufacturer sig
+  private int modelSig; // model sig
+  private byte[] attributes; // Attributes
+  private int intent; // rendering intent
+  private byte[] illuminant; // illuminant info (Coordinates of D50 in the PCS)
+  private int creatorSig; // Creator sig (same type as manufacturer)
+
+  /**
+   * Creates a 'default' header for use with our predefined profiles.
+   * Note the device and profile color spaces are not set.
+   */
+  public ProfileHeader()
+  {
+    creatorSig = 0;
+    intent = 0;
+    modelSig = manufacturerSig = (int) 0x6E6f6E65; // 'none'
+    magic = icMagicNumber;
+    cmmId = 0;
+    platform = 0; // no preferred platform
+    timestamp = new byte[8];
+    majorVersion = 2;
+    minorVersion = 0x10;
+    flags = 0;
+
+    // D50 in XYZ format (encoded)
+    illuminant = new byte[]
+                 {
+                   (byte) 0x00, (byte) 0x00, (byte) 0xf6, (byte) 0xd6,
+                   (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00,
+                   (byte) 0x00, (byte) 0x00, (byte) 0xd3, (byte) 0x2d
+                 };
+    attributes = new byte[8];
+    profileClass = ICC_Profile.CLASS_DISPLAY;
+  }
+
+  /**
+   * Creates a header from profile data. Only the header portion (128 bytes)
+   * is read, so the array passed need not be the full profile.
+   */
+  public ProfileHeader(byte[] data)
+  {
+    ByteBuffer buf = ByteBuffer.wrap(data);
+
+    // Get size (the sign bit shouldn't matter. 	
+    // A valid profile can never be +2Gb)
+    size = buf.getInt(ICC_Profile.icHdrSize);
+
+    // CMM ID
+    cmmId = buf.getInt(ICC_Profile.icHdrCmmId);
+
+    // Version number
+    majorVersion = (int) (data[ICC_Profile.icHdrVersion]);
+    minorVersion = (int) (data[ICC_Profile.icHdrVersion + 1]);
+
+    // Profile/Device class
+    int classSig = buf.getInt(ICC_Profile.icHdrDeviceClass);
+    profileClass = -1;
+    for (int i = 0; i < classMap.length; i += 2)
+      if (classMap[i] == classSig)
+        {
+	  profileClass = classMap[i + 1];
+	  break;
+        }
+
+    // get the data color space
+    int csSig = buf.getInt(ICC_Profile.icHdrColorSpace);
+    colorSpace = -1;
+    for (int i = 0; i < csTypeMap.length; i += 2)
+      if (csTypeMap[i] == csSig)
+        {
+	  colorSpace = csTypeMap[i + 1];
+	  break;
+        }
+
+    // get the profile color space (PCS), must be xyz or lab except
+    // for device-link-class profiles
+    int pcsSig = buf.getInt(ICC_Profile.icHdrPcs);
+    profileColorSpace = -1;
+    if (profileClass != ICC_Profile.CLASS_DEVICELINK)
+      {
+	if (pcsSig == ICC_Profile.icSigXYZData)
+	  profileColorSpace = ColorSpace.TYPE_XYZ;
+	if (pcsSig == ICC_Profile.icSigLabData)
+	  profileColorSpace = ColorSpace.TYPE_Lab;
+      }
+    else
+      {
+	for (int i = 0; i < csTypeMap.length; i += 2)
+	  if (csTypeMap[i] == pcsSig)
+	    {
+	      profileColorSpace = csTypeMap[i + 1];
+	      break;
+	    }
+      }
+
+    // creation timestamp
+    timestamp = new byte[8];
+    System.arraycopy(data, ICC_Profile.icHdrDate, timestamp, 0, 8);
+
+    // magic number
+    magic = buf.getInt(ICC_Profile.icHdrMagic);
+
+    //  platform info
+    platform = buf.getInt(ICC_Profile.icHdrPlatform);
+    // get flags
+    flags = buf.getInt(ICC_Profile.icHdrFlags);
+    // get manufacturer sign
+    manufacturerSig = buf.getInt(ICC_Profile.icHdrManufacturer);
+    // get header model
+    modelSig = buf.getInt(ICC_Profile.icHdrModel);
+    // attributes
+    attributes = new byte[8];
+    System.arraycopy(data, ICC_Profile.icHdrAttributes, attributes, 0, 8);
+    // rendering intent
+    intent = buf.getInt(ICC_Profile.icHdrRenderingIntent);
+    // illuminant info 
+    illuminant = new byte[12];
+    System.arraycopy(data, ICC_Profile.icHdrIlluminant, illuminant, 0, 12);
+    // Creator signature
+    creatorSig = buf.getInt(ICC_Profile.icHdrCreator);
+    // The rest of the header (Total size: 128 bytes) is unused..
+  }
+
+  /**
+   * Verify that the header is valid
+   * @param size equals the file size if it is to be verified, -1 otherwise
+   * @throws IllegalArgumentException if the header is found to be invalid.
+   */
+  public void verifyHeader(int size) throws IllegalArgumentException
+  {
+    // verify size
+    if (size != -1 && this.size != size)
+      throw new IllegalArgumentException("Invalid profile length:" + size);
+
+    // Check version number
+    if (majorVersion != 2)
+      throw new IllegalArgumentException("Wrong major version number:"
+                                         + majorVersion);
+
+    // Profile/Device class
+    if (profileClass == -1)
+      throw new IllegalArgumentException("Invalid profile/device class");
+
+    // get the data color space
+    if (colorSpace == -1)
+      throw new IllegalArgumentException("Invalid colorspace");
+
+    // profile color space
+    if (profileColorSpace == -1)
+      throw new IllegalArgumentException("Invalid PCS.");
+
+    // check magic number
+    if (magic != icMagicNumber)
+      throw new IllegalArgumentException("Invalid magic number!");
+  }
+
+  /**
+   * Creates a header, setting the header file size at the same time.
+   * @param size the profile file size.
+   */
+  public byte[] getData(int size)
+  {
+    byte[] data = new byte[HEADERSIZE];
+    ByteBuffer buf = ByteBuffer.wrap(data);
+    buf.putInt(ICC_Profile.icHdrSize, size);
+    buf.putInt(ICC_Profile.icHdrCmmId, cmmId);
+    buf.putShort(ICC_Profile.icHdrVersion,
+                 (short) (majorVersion << 8 | minorVersion));
+    for (int i = 1; i < classMap.length; i += 2)
+      if (profileClass == classMap[i])
+	buf.putInt(ICC_Profile.icHdrDeviceClass, classMap[i - 1]);
+    for (int i = 1; i < csTypeMap.length; i += 2)
+      if (csTypeMap[i] == colorSpace)
+	buf.putInt(ICC_Profile.icHdrColorSpace, csTypeMap[i - 1]);
+    for (int i = 1; i < csTypeMap.length; i += 2)
+      if (csTypeMap[i] == profileColorSpace)
+	buf.putInt(ICC_Profile.icHdrPcs, csTypeMap[i - 1]);
+
+    System.arraycopy(timestamp, 0, data, ICC_Profile.icHdrDate,
+                     timestamp.length);
+    buf.putInt(ICC_Profile.icHdrMagic, icMagicNumber);
+    buf.putInt(ICC_Profile.icHdrPlatform, platform);
+    buf.putInt(ICC_Profile.icHdrFlags, flags);
+    buf.putInt(ICC_Profile.icHdrManufacturer, manufacturerSig);
+    buf.putInt(ICC_Profile.icHdrModel, modelSig);
+    System.arraycopy(attributes, 0, data, ICC_Profile.icHdrAttributes,
+                     attributes.length);
+    buf.putInt(ICC_Profile.icHdrRenderingIntent, intent);
+    System.arraycopy(illuminant, 0, data, ICC_Profile.icHdrIlluminant,
+                     illuminant.length);
+    buf.putInt(ICC_Profile.icHdrCreator, creatorSig);
+    return buf.array();
+  }
+
+  public int getSize()
+  {
+    return size;
+  }
+
+  public void setSize(int s)
+  {
+    size = s;
+  }
+
+  public int getMajorVersion()
+  {
+    return majorVersion;
+  }
+
+  public int getMinorVersion()
+  {
+    return minorVersion;
+  }
+
+  public int getProfileClass()
+  {
+    return profileClass;
+  }
+
+  public void setProfileClass(int pc)
+  {
+    profileClass = pc;
+  }
+
+  public int getColorSpace()
+  {
+    return colorSpace;
+  }
+
+  public int getProfileColorSpace()
+  {
+    return profileColorSpace;
+  }
+
+  public void setColorSpace(int cs)
+  {
+    colorSpace = cs;
+  }
+
+  public void setProfileColorSpace(int pcs)
+  {
+    profileColorSpace = pcs;
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/PyccConverter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/PyccConverter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* PyccConverter.java -- PhotoYCC conversion class
+   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.awt.color;
+
+
+/**
+ * PyccConverter - conversion routines for the PhotoYCC colorspace
+ *
+ * Also known as PhotoCD YCC, it is an expansion of the conventional
+ * YCC color space to also include colors with over 100% white.
+ *
+ * XXX FIXME: Not yet implemented, implementation pending.
+ *
+ * @author Sven de Marothy
+ */
+public class PyccConverter implements ColorSpaceConverter
+{
+  public float[] toRGB(float[] in)
+  {
+    return null;
+  }
+
+  public float[] fromRGB(float[] in)
+  {
+    return null;
+  }
+
+  public float[] toCIEXYZ(float[] in)
+  {
+    return null;
+  }
+
+  public float[] fromCIEXYZ(float[] in)
+  {
+    return null;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/RgbProfileConverter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/RgbProfileConverter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,244 @@
+/* RgbProfileConverter.java -- RGB Profile conversion class
+   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.awt.color;
+
+import java.awt.color.ICC_Profile;
+import java.awt.color.ICC_ProfileRGB;
+import java.awt.color.ProfileDataException;
+
+/**
+ * RgbProfileConverter - converts RGB profiles (ICC_ProfileRGB)
+ *
+ * This type of profile contains a matrix and three
+ * tone reproduction curves (TRCs).
+ *
+ * Device RGB --> CIE XYZ is done through first multiplying with
+ * a matrix, then each component is looked-up against it's TRC.
+ *
+ * The opposite transform is done using the inverse of the matrix,
+ * and TRC:s.
+ *
+ * @author Sven de Marothy
+ */
+public class RgbProfileConverter implements ColorSpaceConverter
+{
+  private float[][] matrix;
+  private float[][] inv_matrix;
+  private ToneReproductionCurve rTRC;
+  private ToneReproductionCurve gTRC;
+  private ToneReproductionCurve bTRC;
+  private ColorLookUpTable toPCS;
+  private ColorLookUpTable fromPCS;
+
+  /**
+   * CIE 1931 D50 white point (in Lab coordinates)
+   */
+  private static float[] D50 = { 0.96422f, 1.00f, 0.82521f };
+
+  /**
+   * Constructs an RgbProfileConverter from a given ICC_ProfileRGB
+   */
+  public RgbProfileConverter(ICC_ProfileRGB profile)
+  {
+    toPCS = fromPCS = null;
+    matrix = profile.getMatrix();
+
+    // get TRCs
+    try
+      {
+	rTRC = new ToneReproductionCurve(profile.getGamma(ICC_ProfileRGB.REDCOMPONENT));
+      }
+    catch (ProfileDataException e)
+      {
+	rTRC = new ToneReproductionCurve(profile.getTRC(ICC_ProfileRGB.REDCOMPONENT));
+      }
+    try
+      {
+	gTRC = new ToneReproductionCurve(profile.getGamma(ICC_ProfileRGB.GREENCOMPONENT));
+      }
+    catch (ProfileDataException e)
+      {
+	gTRC = new ToneReproductionCurve(profile.getTRC(ICC_ProfileRGB.GREENCOMPONENT));
+      }
+    try
+      {
+	bTRC = new ToneReproductionCurve(profile.getGamma(ICC_ProfileRGB.BLUECOMPONENT));
+      }
+    catch (ProfileDataException e)
+      {
+	bTRC = new ToneReproductionCurve(profile.getTRC(ICC_ProfileRGB.BLUECOMPONENT));
+      }
+
+    // If a CLUT is available, it should be used, and the TRCs ignored.
+    // Note: A valid profile may only have CLUTs in one direction, and
+    // TRC:s without useful info, making reverse-transforms impossible.
+    // In this case the TRC will be used for the reverse-transform with
+    // unpredictable results. This is in line with the Java specification,
+    try
+      {
+	toPCS = new ColorLookUpTable(profile, ICC_Profile.icSigAToB0Tag);
+      }
+    catch (Exception e)
+      {
+	toPCS = null;
+      }
+
+    try
+      {
+	fromPCS = new ColorLookUpTable(profile, ICC_Profile.icSigBToA0Tag);
+      }
+    catch (Exception e)
+      {
+	fromPCS = null;
+      }
+
+    // Calculate the inverse matrix if no reverse CLUT is available
+    if(fromPCS == null)
+	inv_matrix = invertMatrix(matrix);
+    else 
+      {
+        // otherwise just set it to an identity matrix
+	inv_matrix = new float[3][3];
+	inv_matrix[0][0] = inv_matrix[1][1] = inv_matrix[2][2] = 1.0f;
+      }
+  }
+
+  public float[] toCIEXYZ(float[] in)
+  {
+    // CLUT takes precedence
+    if (toPCS != null)
+      return toPCS.lookup(in);
+
+    float[] temp = new float[3];
+    float[] out = new float[3];
+
+    // device space --> linear gamma
+    temp[0] = rTRC.lookup(in[0]);
+    temp[1] = gTRC.lookup(in[1]);
+    temp[2] = bTRC.lookup(in[2]);
+
+    // matrix multiplication
+    out[0] = matrix[0][0] * temp[0] + matrix[0][1] * temp[1]
+             + matrix[0][2] * temp[2];
+    out[1] = matrix[1][0] * temp[0] + matrix[1][1] * temp[1]
+             + matrix[1][2] * temp[2];
+    out[2] = matrix[2][0] * temp[0] + matrix[2][1] * temp[1]
+             + matrix[2][2] * temp[2];
+
+    return out;
+  }
+
+  public float[] toRGB(float[] in)
+  {
+    return SrgbConverter.XYZtoRGB(toCIEXYZ(in));
+  }
+
+  public float[] fromCIEXYZ(float[] in)
+  {
+    if (fromPCS != null)
+      return fromPCS.lookup(in);
+
+    float[] temp = new float[3];
+    float[] out = new float[3];
+
+    // matrix multiplication
+    temp[0] = inv_matrix[0][0] * in[0] + inv_matrix[0][1] * in[1]
+              + inv_matrix[0][2] * in[2];
+    temp[1] = inv_matrix[1][0] * in[0] + inv_matrix[1][1] * in[1]
+              + inv_matrix[1][2] * in[2];
+    temp[2] = inv_matrix[2][0] * in[0] + inv_matrix[2][1] * in[1]
+              + inv_matrix[2][2] * in[2];
+
+    // device space --> linear gamma
+    out[0] = rTRC.reverseLookup(temp[0]);
+    out[1] = gTRC.reverseLookup(temp[1]);
+    out[2] = bTRC.reverseLookup(temp[2]);
+
+    // FIXME: Sun appears to clip the return values to [0,1]
+    // I don't believe that is a Good Thing, 
+    // (some colorspaces may allow values outside that range.)
+    // So we return the actual values here.
+    return out;
+  }
+
+  public float[] fromRGB(float[] in)
+  {
+    return fromCIEXYZ(SrgbConverter.RGBtoXYZ(in));
+  }
+
+  /**
+   * Inverts a 3x3 matrix, returns the inverse,
+   * throws an IllegalArgumentException if the matrix is not
+   * invertible (this shouldn't happen for a valid profile)
+   */
+  private float[][] invertMatrix(float[][] matrix)
+  {
+    float[][] out = new float[3][3];
+    double determinant = matrix[0][0] * (matrix[1][1] * matrix[2][2]
+                         - matrix[2][1] * matrix[1][2])
+                         - matrix[0][1] * (matrix[1][0] * matrix[2][2]
+                         - matrix[2][0] * matrix[1][2])
+                         + matrix[0][2] * (matrix[1][0] * matrix[2][1]
+                         - matrix[2][0] * matrix[1][1]);
+
+    if (determinant == 0.0)
+      throw new IllegalArgumentException("Can't invert conversion matrix.");
+    float invdet = (float) (1.0 / determinant);
+
+    out[0][0] = invdet * (matrix[1][1] * matrix[2][2]
+                - matrix[1][2] * matrix[2][1]);
+    out[0][1] = invdet * (matrix[0][2] * matrix[2][1]
+                - matrix[0][1] * matrix[2][2]);
+    out[0][2] = invdet * (matrix[0][1] * matrix[1][2]
+                - matrix[0][2] * matrix[1][1]);
+    out[1][0] = invdet * (matrix[1][2] * matrix[2][0]
+                - matrix[1][0] * matrix[2][2]);
+    out[1][1] = invdet * (matrix[0][0] * matrix[2][2]
+                - matrix[0][2] * matrix[2][0]);
+    out[1][2] = invdet * (matrix[0][2] * matrix[1][0]
+                - matrix[0][0] * matrix[1][2]);
+    out[2][0] = invdet * (matrix[1][0] * matrix[2][1]
+                - matrix[1][1] * matrix[2][0]);
+    out[2][1] = invdet * (matrix[0][1] * matrix[2][0]
+                - matrix[0][0] * matrix[2][1]);
+    out[2][2] = invdet * (matrix[0][0] * matrix[1][1]
+                - matrix[0][1] * matrix[1][0]);
+    return out;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/SrgbConverter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/SrgbConverter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,152 @@
+/* SrgbConverter.java -- sRGB conversion class
+   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.awt.color;
+
+
+/**
+ * SrgbConverter - conversion routines for the sRGB colorspace
+ * sRGB is a standard for RGB colorspaces, adopted by the w3c.
+ *
+ * The specification is available at:
+ * http://www.w3.org/Graphics/Color/sRGB.html
+ *
+ * @author Sven de Marothy
+ */
+/**
+ *
+ * Note the matrix numbers used here are NOT identical to those in the
+ * w3 spec, as those numbers are CIE XYZ relative a D65 white point.
+ * The CIE XYZ we use is relative a D50 white point, so therefore a
+ * linear Bradford transform matrix for D65->D50 mapping has been applied.
+ * (The ICC documents describe this transform)
+ *
+ *   Linearized Bradford transform:
+ *    0.8951    0.2664   -0.1614
+ *   -0.7502    1.7135    0.0367
+ *    0.0389   -0.0685    1.0296
+ *
+ *   Inverse:
+ *   0.9870   -0.1471    0.1600
+ *   0.4323    0.5184    0.0493
+ *  -0.00853   0.0400    0.9685
+ */
+public class SrgbConverter implements ColorSpaceConverter
+{
+  public float[] fromCIEXYZ(float[] in)
+  {
+    return XYZtoRGB(in);
+  }
+
+  public float[] toCIEXYZ(float[] in)
+  {
+    return RGBtoXYZ(in);
+  }
+
+  public float[] toRGB(float[] in)
+  {
+    float[] out = new float[3];
+    System.arraycopy(in, 0, out, 0, 3);
+    return out;
+  }
+
+  public float[] fromRGB(float[] in)
+  {
+    float[] out = new float[3];
+    System.arraycopy(in, 0, out, 0, 3);
+    return out;
+  }
+
+  /**
+   * CIE XYZ (D50 relative) --> sRGB
+   *
+   * Static as it's used by other ColorSpaceConverters to
+   * convert to sRGB if the color space is defined in XYZ.
+   */
+  public static float[] XYZtoRGB(float[] in)
+  {
+    float[] temp = new float[3];
+    temp[0] = 3.1338f * in[0] - 1.6171f * in[1] - 0.4907f * in[2];
+    temp[1] = -0.9785f * in[0] + 1.9160f * in[1] + 0.0334f * in[2];
+    temp[2] = 0.0720f * in[0] - 0.2290f * in[1] + 1.4056f * in[2];
+
+    float[] out = new float[3];
+    for (int i = 0; i < 3; i++)
+      {
+	if (temp[i] < 0)
+	  temp[i] = 0.0f;
+	if (temp[i] > 1)
+	  temp[i] = 1.0f;
+	if (temp[i] <= 0.00304f)
+	  out[i] = temp[i] * 12.92f;
+	else
+	  out[i] = 1.055f * ((float) Math.exp((1 / 2.4) * Math.log(temp[i])))
+	           - 0.055f;
+      }
+    return out;
+  }
+
+  /**
+   * sRGB --> CIE XYZ (D50 relative)
+   *
+   * Static as it's used by other ColorSpaceConverters to
+   * convert to XYZ if the color space is defined in RGB.
+   */
+  public static float[] RGBtoXYZ(float[] in)
+  {
+    float[] temp = new float[3];
+    float[] out = new float[3];
+    for (int i = 0; i < 3; i++)
+      if (in[i] <= 0.03928f)
+	temp[i] = in[i] / 12.92f;
+      else
+	temp[i] = (float) Math.exp(2.4 * Math.log((in[i] + 0.055) / 1.055));
+
+    /*
+     * Note: The numbers which were used to calculate this only had four
+     * digits of accuracy. So don't be fooled by the number of digits here.
+     * If someone has more accurate source, feel free to update this.
+     */
+    out[0] = (float) (0.436063750222 * temp[0] + 0.385149601465 * temp[1]
+             + 0.143086418888 * temp[2]);
+    out[1] = (float) (0.222450894035 * temp[0] + 0.71692584775 * temp[1]
+             + 0.060624511256 * temp[2]);
+    out[2] = (float) (0.0138985186 * temp[0] + 0.097079690112 * temp[1]
+             + 0.713996045725 * temp[2]);
+    return out;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/TagEntry.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/TagEntry.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,121 @@
+/* TagEntry.java -- A utility class used for storing the tags in ICC_Profile
+   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.awt.color;
+
+
+/**
+ * TagEntry - stores a profile tag.
+ * These are conveniently stored in a hashtable with the tag signature
+ * as a key. A legal profile can only have one tag with a given sig,
+ * so we can conveniently ignore collisions.
+ *
+ * @author Sven de Marothy
+ */
+public class TagEntry
+{
+  // tag table entry size
+  public static final int entrySize = 12;
+  private int signature;
+  private int size;
+  private int offset;
+  private byte[] data;
+
+  public TagEntry(int sig, int offset, int size, byte[] data)
+  {
+    this.signature = sig;
+    this.offset = offset;
+    this.size = size;
+    this.data = new byte[size];
+    System.arraycopy(data, offset, this.data, 0, size);
+  }
+
+  public TagEntry(int sig, byte[] data)
+  {
+    this.signature = sig;
+    this.size = data.length;
+    this.data = new byte[size];
+    System.arraycopy(data, offset, this.data, 0, size);
+  }
+
+  public byte[] getData()
+  {
+    byte[] d = new byte[size];
+    System.arraycopy(this.data, 0, d, 0, size);
+    return d;
+  }
+
+  public String hashKey()
+  {
+    return tagHashKey(signature);
+  }
+
+  public String toString()
+  {
+    String s = "";
+    s = s + (char) ((byte) ((signature >> 24) & 0xFF));
+    s = s + (char) ((byte) ((signature >> 16) & 0xFF));
+    s = s + (char) ((byte) ((signature >> 8) & 0xFF));
+    s = s + (char) ((byte) (signature & 0xFF));
+    return s;
+  }
+
+  public int getSignature()
+  {
+    return signature;
+  }
+
+  public int getSize()
+  {
+    return size;
+  }
+
+  public int getOffset()
+  {
+    return offset;
+  }
+
+  public void setOffset(int offset)
+  {
+    this.offset = offset;
+  }
+
+  public static String tagHashKey(int sig)
+  {
+    return "" + sig;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/ToneReproductionCurve.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/ToneReproductionCurve.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,177 @@
+/* ToneReproductionCurve.java -- Representation of an ICC 'curv' type TRC
+   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.awt.color;
+
+
+/**
+ * ToneReproductionCurve - TRCs are used to describe RGB
+ * and Grayscale profiles. The TRC is essentially the gamma
+ * function of the color space.
+ *
+ * For example, Apple RGB has a gamma of 1.8, most monitors are ~2.2,
+ * sRGB is 2.4 with a small linear part near 0.
+ * Linear spaces are of course 1.0.
+ * (The exact function is implemented in SrgbConverter)
+ *
+ * The ICC specification allows the TRC to be described as a single
+ * Gamma value, where the function is thus out = in**gamma.
+ * Alternatively, the gamma function may be represented by a lookup table
+ * of values, in which case linear interpolation is used.
+ *
+ * @author Sven de Marothy
+ */
+public class ToneReproductionCurve
+{
+  private float[] trc;
+  private float gamma;
+  private float[] reverseTrc;
+
+  /**
+   * Constructs a TRC from a gamma values
+   */
+  public ToneReproductionCurve(float gamma)
+  {
+    trc = null;
+    reverseTrc = null;
+    this.gamma = gamma;
+  }
+
+  /**
+   * Constructs a TRC from a set of float values
+   */
+  public ToneReproductionCurve(float[] trcValues)
+  {
+    trc = new float[trcValues.length];
+    System.arraycopy(trcValues, 0, trc, 0, trcValues.length);
+    setupReverseTrc();
+  }
+
+  /**
+   * Constructs a TRC from a set of short values normalized to
+   * the 0-65535 range (as in the ICC profile file).
+   * (Note the values are treated as unsigned)
+   */
+  public ToneReproductionCurve(short[] trcValues)
+  {
+    trc = new float[trcValues.length];
+    for (int i = 0; i < trcValues.length; i++)
+      trc[i] = (float) ((int) trcValues[i] & (0xFFFF)) / 65535.0f;
+    setupReverseTrc();
+  }
+
+  /**
+   * Performs a TRC lookup
+   */
+  public float lookup(float in)
+  {
+    float out;
+
+    if (trc == null)
+      {
+	if (in == 0f)
+	  return 0.0f;
+	return (float) Math.exp(gamma * Math.log(in));
+      }
+    else
+      {
+	double alpha = in * (trc.length - 1);
+	int index = (int) Math.floor(alpha);
+	alpha = alpha - (double) index;
+	if (index >= trc.length - 1)
+	  return trc[trc.length - 1];
+	if (index <= 0)
+	  return trc[0];
+	out = (float) (trc[index] * (1.0 - alpha) + trc[index + 1] * alpha);
+      }
+    return out;
+  }
+
+  /**
+   * Performs an reverse lookup
+   */
+  public float reverseLookup(float in)
+  {
+    float out;
+
+    if (trc == null)
+      {
+	if (in == 0f)
+	  return 0.0f;
+	return (float) Math.exp((1.0 / gamma) * Math.log(in));
+      }
+    else
+      {
+	double alpha = in * (reverseTrc.length - 1);
+	int index = (int) Math.floor(alpha);
+	alpha = alpha - (double) index;
+	if (index >= reverseTrc.length - 1)
+	  return reverseTrc[reverseTrc.length - 1];
+	if (index <= 0)
+	  return reverseTrc[0];
+	out = (float) (reverseTrc[index] * (1.0 - alpha)
+	      + reverseTrc[index + 1] * alpha);
+      }
+    return out;
+  }
+
+  /**
+   * Calculates a reverse-lookup table.
+   * We use a whopping 10,000 entries.. This is should be more than any
+   * real-life TRC table (typically around 256-1024) so we won't be losing
+   * any precision.
+   *
+   * This will of course generate completely invalid results if the curve
+   * is not monotonic and invertable. But what's the alternative?
+   */
+  public void setupReverseTrc()
+  {
+    reverseTrc = new float[10000];
+    int j = 0;
+    for (int i = 0; i < 10000; i++)
+      {
+	float n = ((float) i) / 10000f;
+	while (trc[j + 1] < n && j < trc.length - 2)
+	  j++;
+
+	if (j == trc.length - 2)
+	  reverseTrc[i] = trc[trc.length - 1];
+	else
+	  reverseTrc[i] = (j + (n - trc[j]) / (trc[j + 1] - trc[j])) / ((float) trc.length);
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/color/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.awt.color package.
+   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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.java.awt.color</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,172 @@
+/* GtkMouseDragGestureRecognizer.java --
+   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.awt.dnd;
+
+import java.awt.Component;
+import java.awt.Point;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.MouseDragGestureRecognizer;
+import java.awt.event.MouseEvent;
+
+public class GtkMouseDragGestureRecognizer
+    extends MouseDragGestureRecognizer
+{
+
+  public GtkMouseDragGestureRecognizer (DragSource ds)
+  {
+    this(ds, null, 0, null);
+  }
+
+  public GtkMouseDragGestureRecognizer (DragSource ds, Component c)
+  {
+    this (ds, c, 0, null);
+  }
+  
+  public GtkMouseDragGestureRecognizer (DragSource ds, Component c, int act)
+  {
+    this(ds, c, act, null);
+  }
+  
+  public GtkMouseDragGestureRecognizer (DragSource ds, Component c, int act,
+                                        DragGestureListener dgl)
+  {
+    super(ds, c, act, dgl);
+  }
+  
+  public void registerListeners ()
+  {
+    super.registerListeners();
+  }
+  
+  public void unregisterListeners ()
+  {
+    super.unregisterListeners();
+  }
+  
+  public void mouseClicked (MouseEvent e)
+  {
+    // Nothing to do here.
+  }
+
+  public void mousePressed (MouseEvent e)
+  {
+    events.clear();
+    if (getDropActionFromEvent(e) != DnDConstants.ACTION_NONE)
+      appendEvent(e);
+  }
+
+  public void mouseReleased (MouseEvent e)
+  {
+    events.clear();
+  }
+
+  public void mouseEntered (MouseEvent e)
+  {
+    events.clear();
+  }
+
+  public void mouseExited(MouseEvent e)
+  {
+    if (!events.isEmpty())
+      if (getDropActionFromEvent(e) == DnDConstants.ACTION_NONE)
+        events.clear();
+  }
+
+  public void mouseDragged(MouseEvent e)
+  {
+    if (!events.isEmpty())
+      {
+        int act = getDropActionFromEvent(e);
+        
+        if (act == DnDConstants.ACTION_NONE)
+          return;
+
+        Point origin = ((MouseEvent) events.get(0)).getPoint();
+        Point current = e.getPoint();
+        int dx = Math.abs(origin.x - current.x);
+        int dy = Math.abs(origin.y - current.y);
+        int threshold = DragSource.getDragThreshold();
+        
+        if (dx > threshold || dy > threshold)
+          fireDragGestureRecognized(act, origin);
+        else
+          appendEvent(e);
+      }
+  }
+  
+  public void mouseMoved (MouseEvent e)
+  {
+    // Nothing to do here.
+  }
+
+  private int getDropActionFromEvent(MouseEvent e)
+  {
+    int modEx = e.getModifiersEx();
+    int buttons =  modEx & (MouseEvent.BUTTON1_DOWN_MASK
+               | MouseEvent.BUTTON2_DOWN_MASK | MouseEvent.BUTTON3_DOWN_MASK);
+    if (!(buttons == MouseEvent.BUTTON1_DOWN_MASK || 
+        buttons == MouseEvent.BUTTON2_DOWN_MASK))
+      return DnDConstants.ACTION_NONE;
+    
+    // Convert modifier to a drop action
+    int sourceActions = getSourceActions();
+    int mod = modEx
+              & (MouseEvent.SHIFT_DOWN_MASK | MouseEvent.CTRL_DOWN_MASK);
+    switch (mod)
+      {
+      case MouseEvent.SHIFT_DOWN_MASK | MouseEvent.CTRL_DOWN_MASK:
+        return DnDConstants.ACTION_LINK & sourceActions;
+      case MouseEvent.CTRL_DOWN_MASK:
+        return DnDConstants.ACTION_COPY & sourceActions;
+      case MouseEvent.SHIFT_DOWN_MASK:
+        return DnDConstants.ACTION_MOVE & sourceActions;
+      default:
+        if ((sourceActions & DnDConstants.ACTION_MOVE) != 0)
+          return DnDConstants.ACTION_MOVE & sourceActions;
+        else if ((sourceActions & DnDConstants.ACTION_COPY) != 0)
+          return DnDConstants.ACTION_COPY & sourceActions;
+        else if ((sourceActions & DnDConstants.ACTION_LINK) != 0)
+          return DnDConstants.ACTION_LINK & sourceActions;
+      }
+
+    return DnDConstants.ACTION_NONE & sourceActions;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,174 @@
+/* GtkDragSourceContextPeer.java --
+   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.awt.dnd.peer.gtk;
+
+import gnu.java.awt.peer.gtk.GtkGenericPeer;
+
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragSourceContext;
+import java.awt.dnd.DragSourceDragEvent;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceEvent;
+import java.awt.dnd.InvalidDnDOperationException;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.LightweightPeer;
+
+public class GtkDragSourceContextPeer
+    extends GtkGenericPeer
+    implements DragSourceContextPeer
+{
+  private ComponentPeer peer;
+  private Cursor cursor;
+  private DragSourceContext context;
+  
+  native void nativeStartDrag(Image i, int x, int y, int action, String target);
+  native void connectSignals(ComponentPeer comp);
+  native void create(ComponentPeer comp);
+  native void nativeSetCursor(int cursor);
+  
+  public GtkDragSourceContextPeer(DragGestureEvent e)
+  {
+    super(e.getComponent());
+    Component comp = e.getComponent();
+    peer = getComponentPeer(comp);
+    
+    create(peer);
+    connectSignals(peer);
+    cursor = comp.getCursor();
+  }
+  
+  ComponentPeer getComponentPeer(Component c)
+  {
+    Component curr = c;
+    while (curr.getPeer() instanceof LightweightPeer)
+      curr = curr.getParent();
+    
+    if (curr != null)
+      return curr.getPeer();
+    return null;
+  }
+  
+  public void startDrag(DragSourceContext context, Cursor c, Image i, Point p)
+      throws InvalidDnDOperationException
+  {   
+    this.context = context;
+    
+    if (p == null)
+      p = new Point();
+    
+    // FIXME: use proper DataFlavor, not "text/plain".
+    // Also, add check to determine if dragging.
+    
+    setCursor(c);
+    nativeStartDrag(i, p.x, p.y, context.getTrigger().getDragAction(),
+                    "text/plain");
+  }
+
+  public Cursor getCursor()
+  {
+    return cursor;
+  }
+
+  public void setCursor(Cursor c) throws InvalidDnDOperationException
+  {
+    if (c != null)
+      {
+        nativeSetCursor(c.getType());
+        cursor = c;
+      }
+  }
+
+  public void transferablesFlavorsChanged()
+  {
+    // Nothing to do here.
+  }
+  
+  /**
+   * Called from native code.
+   */
+
+  public void dragEnter(int action, int modifiers)
+  {
+    context.dragEnter(new DragSourceDragEvent(context, action,
+                                              action
+                                                  & context.getSourceActions(),
+                                              modifiers));
+  }
+
+  public void dragExit(int action, int x, int y)
+  {
+    context.dragExit(new DragSourceEvent(context, x, y));
+  }
+
+  public void dragDropEnd(int action, boolean success, int x, int y)
+  {
+    context.dragDropEnd(new DragSourceDropEvent(context, action, success, x, y));
+  }
+
+  public void dragMouseMoved(int action, int modifiers)
+  {
+    context.dragMouseMoved(new DragSourceDragEvent(context,
+                                                   action,
+                                                   action
+                                                       & context.getSourceActions(),
+                                                   modifiers));
+  }
+
+  public void dragOver(int action, int modifiers)
+  {
+    context.dragOver(new DragSourceDragEvent(context, action,
+                                             action
+                                                 & context.getSourceActions(),
+                                             modifiers));
+  }
+
+  public void dragActionChanged(int newAction, int modifiers)
+  {
+    context.dropActionChanged(new DragSourceDragEvent(context,
+                                                      newAction,
+                                                      newAction
+                                                          & context.getSourceActions(),
+                                                      modifiers));
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,125 @@
+/* GtkDropTargetContextPeer.java --
+   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.awt.dnd.peer.gtk;
+
+import gnu.java.awt.peer.gtk.GtkGenericPeer;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.InvalidDnDOperationException;
+import java.awt.dnd.peer.DropTargetContextPeer;
+
+public class GtkDropTargetContextPeer
+    extends GtkGenericPeer
+    implements DropTargetContextPeer
+{
+
+  public GtkDropTargetContextPeer()
+  {
+    super(null);
+  }
+  
+  public void setTargetActions(int actions)
+  {
+    // FIXME: Not Implemented
+
+  }
+
+  public int getTargetActions()
+  {
+    // FIXME: Not Implemented
+    return 0;
+  }
+
+  public DropTarget getDropTarget()
+  {
+    // FIXME: Not Implemented
+    return null;
+  }
+
+  public DataFlavor[] getTransferDataFlavors()
+  {
+    // FIXME: Not Implemented
+    return null;
+  }
+
+  public Transferable getTransferable() throws InvalidDnDOperationException
+  {
+    // FIXME: Not Implemented
+    return null;
+  }
+
+  public boolean isTransferableJVMLocal()
+  {
+    // FIXME: Not Implemented
+    return false;
+  }
+
+  public void acceptDrag(int dragAction)
+  {
+    // FIXME: Not Implemented
+
+  }
+
+  public void rejectDrag()
+  {
+    // FIXME: Not Implemented
+
+  }
+
+  public void acceptDrop(int dropAction)
+  {
+    // FIXME: Not Implemented
+
+  }
+
+  public void rejectDrop()
+  {
+    // FIXME: Not Implemented
+
+  }
+
+  public void dropComplete(boolean success)
+  {
+    // FIXME: Not Implemented
+
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,68 @@
+/* GtkDropTargetPeer.java --
+   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.awt.dnd.peer.gtk;
+
+import gnu.java.awt.peer.gtk.GtkGenericPeer;
+
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.peer.DropTargetPeer;
+
+public class GtkDropTargetPeer
+    extends GtkGenericPeer
+    implements DropTargetPeer
+{
+
+  public GtkDropTargetPeer()
+  {
+    super(null);
+  }
+  
+  public void addDropTarget(DropTarget target)
+  {
+    // FIXME: Not Implemented
+
+  }
+
+  public void removeDropTarget(DropTarget target)
+  {
+    // FIXME: Not Implemented
+
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/doc-files/BitwiseXORComposite-1.png
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/doc-files/BitwiseXORComposite-1.png?rev=43913&view=auto

==============================================================================
Binary file - no diff available.

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/doc-files/BitwiseXORComposite-1.png

------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/FontDelegate.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/FontDelegate.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,313 @@
+/* FontDelegate.java -- Interface implemented by all font delegates.
+   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.awt.font;
+
+import java.awt.Font;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+import java.text.CharacterIterator;
+import java.util.Locale;
+
+
+/**
+ * The interface that all font delegate objects implement,
+ * irrespective of where they get their information from.
+ *
+ * <p><b>Thread Safety:</b> All classes that implement the
+ * <code>FontDelegate</code> interface must allow calling these
+ * methods from multiple concurrent threads. The delegates are
+ * responsible for performing the necessary synchronization.
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public interface FontDelegate
+{
+  /**
+   * Returns the full name of this font face in the specified
+   * locale, for example <i>&#x201c;Univers Light&#x201d;</i>.
+   *
+   * @param locale the locale for which to localize the name.
+   *
+   * @return the face name.
+   */
+  public String getFullName(Locale locale);
+  
+  
+  /**
+   * Returns the name of the family to which this font face belongs,
+   * for example <i>&#x201c;Univers&#x201d;</i>.
+   *
+   * @param locale the locale for which to localize the name.
+   *
+   * @return the family name.
+   */
+  public String getFamilyName(Locale locale);
+
+
+  /**
+   * Returns the name of this font face inside the family, for example
+   * <i>&#x201c;Light&#x201d;</i>.
+   *
+   * @param locale the locale for which to localize the name.
+   *
+   * @return the name of the face inside its family.
+   */
+  public String getSubFamilyName(Locale locale);
+  
+  
+  /**
+   * Returns the PostScript name of this font face, for example
+   * <i>&#x201c;Helvetica-Bold&#x201d;</i>.
+   *
+   * @return the PostScript name, or <code>null</code> if the font
+   * does not provide a PostScript name.
+   */
+  public String getPostScriptName();
+
+
+  /**
+   * Returns the number of glyphs in this font face.
+   */
+  public int getNumGlyphs();
+  
+  
+  /**
+   * Returns the index of the glyph which gets displayed if the font
+   * cannot map a Unicode code point to a glyph. Many fonts show this
+   * glyph as an empty box.
+   */
+  public int getMissingGlyphCode();
+  
+
+  /**
+   * Creates a GlyphVector by mapping each character in a
+   * CharacterIterator to the corresponding glyph.
+   *
+   * <p>The mapping takes only the font&#x2019;s <code>cmap</code>
+   * tables into consideration. No other operations (such as glyph
+   * re-ordering, composition, or ligature substitution) are
+   * performed. This means that the resulting GlyphVector will not be
+   * correct for text in languages that have complex
+   * character-to-glyph mappings, such as Arabic, Hebrew, Hindi, or
+   * Thai.
+   *
+   * @param font the font object that the created GlyphVector
+   * will return when it gets asked for its font. This argument is
+   * needed because the public API works with java.awt.Font,
+   * not with some private delegate like OpenTypeFont.
+   *
+   * @param frc the font rendering parameters that are used for
+   * measuring glyphs. The exact placement of text slightly depends on
+   * device-specific characteristics, for instance the device
+   * resolution or anti-aliasing. For this reason, any measurements
+   * will only be accurate if the passed
+   * <code>FontRenderContext</code> correctly reflects the relevant
+   * parameters. Hence, <code>frc</code> should be obtained from the
+   * same <code>Graphics2D</code> that will be used for drawing, and
+   * any rendering hints should be set to the desired values before
+   * obtaining <code>frc</code>.
+   *
+   * @param ci a CharacterIterator for iterating over the
+   * characters to be displayed.
+   */
+  public GlyphVector createGlyphVector(Font font,
+                                       FontRenderContext frc,
+                                       CharacterIterator ci);
+
+
+  /**
+   * Determines the advance width and height for a glyph.
+   *
+   * @param glyphIndex the glyph whose advance width is to be
+   * determined.
+   *
+   * @param pointSize the point size of the font.
+   *
+   * @param transform a transform that is applied in addition to
+   * scaling to the specified point size. This is often used for
+   * scaling according to the device resolution. Those who lack any
+   * aesthetic sense may also use the transform to slant or stretch
+   * glyphs.
+   *
+   * @param antialias <code>true</code> for anti-aliased rendering,
+   * <code>false</code> for normal rendering. For hinted fonts,
+   * this parameter may indeed affect the result.
+   *
+   * @param fractionalMetrics <code>true</code> for fractional metrics,
+   * <code>false</code> for rounding the result to a pixel boundary.
+   *
+   * @param horizontal <code>true</code> for horizontal line layout,
+   * <code>false</code> for vertical line layout.
+   *
+   * @param advance a point whose <code>x</code> and <code>y</code>
+   * fields will hold the advance in each direction. It is well
+   * possible that both values are non-zero, for example for rotated
+   * text or for Urdu fonts.
+   */
+  public void getAdvance(int glyphIndex,
+                         float pointSize,
+                         AffineTransform transform,
+                         boolean antialias,
+                         boolean fractionalMetrics,
+                         boolean horizontal,
+                         Point2D advance);
+  
+
+  /**
+   * Returns the shape of a glyph.
+   *
+   * @param glyphIndex the glyph whose advance width is to be
+   * determined.
+   *
+   * @param pointSize the point size of the font.
+   *
+   * @param transform a transform that is applied in addition to
+   * scaling to the specified point size. This is often used for
+   * scaling according to the device resolution. Those who lack any
+   * aesthetic sense may also use the transform to slant or stretch
+   * glyphs.
+   *
+   * @param antialias <code>true</code> for anti-aliased rendering,
+   * <code>false</code> for normal rendering. For hinted fonts, this
+   * parameter may indeed affect the result.
+   *
+   * @param fractionalMetrics <code>true</code> for fractional
+   * metrics, <code>false</code> for rounding the result to a pixel
+   * boundary.
+   *
+   * @return the scaled and grid-fitted outline of the specified
+   * glyph, or <code>null</code> for bitmap fonts.
+   */
+  public GeneralPath getGlyphOutline(int glyphIndex,
+                                     float pointSize,
+                                     AffineTransform transform,
+                                     boolean antialias,
+                                     boolean fractionalMetrics);
+
+
+  /**
+   * Returns a name for the specified glyph. This is useful for
+   * generating PostScript or PDF files that embed some glyphs of a
+   * font.
+   *
+   * <p><b>Names are not unique:</b> Under some rare circumstances,
+   * the same name can be returned for different glyphs. It is
+   * therefore recommended that printer drivers check whether the same
+   * name has already been returned for antoher glyph, and make the
+   * name unique by adding the string ".alt" followed by the glyph
+   * index.</p>
+   *
+   * <p>This situation would occur for an OpenType or TrueType font
+   * that has a <code>post</code> table of format 3 and provides a
+   * mapping from glyph IDs to Unicode sequences through a
+   * <code>Zapf</code> table. If the same sequence of Unicode
+   * codepoints leads to different glyphs (depending on contextual
+   * position, for example, or on typographic sophistication level),
+   * the same name would get synthesized for those glyphs.
+   *
+   * @param glyphIndex the glyph whose name the caller wants to
+   * retrieve.
+   */
+  public String getGlyphName(int glyphIndex);
+
+
+  /**
+   * Determines the distance between the base line and the highest
+   * ascender.
+   *
+   * @param pointSize the point size of the font.
+   *
+   * @param transform a transform that is applied in addition to
+   * scaling to the specified point size. This is often used for
+   * scaling according to the device resolution. Those who lack any
+   * aesthetic sense may also use the transform to slant or stretch
+   * glyphs.
+   *
+   * @param antialiased <code>true</code> for anti-aliased rendering,
+   * <code>false</code> for normal rendering. For hinted fonts,
+   * this parameter may indeed affect the result.
+   *
+   * @param fractionalMetrics <code>true</code> for fractional metrics,
+   * <code>false</code> for rounding the result to a pixel boundary.
+   *
+   * @param horizontal <code>true</code> for horizontal line layout,
+   * <code>false</code> for vertical line layout.
+   *
+   * @return the ascent, which usually is a positive number.
+   */
+  public float getAscent(float pointSize,
+                         AffineTransform transform,
+                         boolean antialiased,
+                         boolean fractionalMetrics,
+                         boolean horizontal);
+
+
+  /**
+   * Determines the distance between the base line and the lowest
+   * descender.
+   *
+   * @param pointSize the point size of the font.
+   *
+   * @param transform a transform that is applied in addition to
+   * scaling to the specified point size. This is often used for
+   * scaling according to the device resolution. Those who lack any
+   * aesthetic sense may also use the transform to slant or stretch
+   * glyphs.
+   *
+   * @param antialiased <code>true</code> for anti-aliased rendering,
+   * <code>false</code> for normal rendering. For hinted fonts,
+   * this parameter may indeed affect the result.
+   *
+   * @param fractionalMetrics <code>true</code> for fractional metrics,
+   * <code>false</code> for rounding the result to a pixel boundary.
+   *
+   * @param horizontal <code>true</code> for horizontal line layout,
+   * <code>false</code> for vertical line layout.
+   *
+   * @return the descent, which usually is a nagative number.
+   */
+  public float getDescent(float pointSize,
+                          AffineTransform transform,
+                          boolean antialiased,
+                          boolean fractionalMetrics,
+                          boolean horizontal);
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/FontFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/FontFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,90 @@
+/* FontFactory.java -- Factory for font delegates.
+   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.awt.font;
+
+import java.nio.ByteBuffer;
+
+import java.awt.FontFormatException;
+import gnu.java.awt.font.opentype.OpenTypeFontFactory;
+
+
+/**
+ * A factory for creating font delegate objects.
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public final class FontFactory
+{
+  /**
+   * The constructor is private so nobody can construct an instance
+   */
+  private FontFactory()
+  {
+  }
+
+  
+  /**
+   * Creates FontDelegate objects for the fonts in the specified buffer.
+   * The following font formats are currently recognized:
+   * recognized font formats are:
+   *
+   * <p><ul>
+   * <li>OpenType (*.otf);</li>
+   * <li>TrueType (*.ttf);</li>
+   * <li>TrueType Collections (*.ttc);</li>
+   * <li>Apple MacOS X data-fork font (*.dfont).</li></ul>
+   *
+   * <p>Some formats may contain more than a single font, for example
+   * *.ttc and *.dfont files. This is the reason why this function
+   * returns an array.
+   *
+   * <p>The implementation reads data from the buffer only when
+   * needed. Therefore, it greatly increases efficiency if
+   * <code>buf</code> has been obtained through mapping a file into
+   * the virtual address space.
+   *
+   * @throws FontFormatException if the font data is not in one of the
+   * known formats.
+   */
+  public static FontDelegate[] createFonts(ByteBuffer buf)
+    throws FontFormatException
+  {
+    return OpenTypeFontFactory.createFonts(buf);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/GNUGlyphVector.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/GNUGlyphVector.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,596 @@
+/* GNUGlyphVector.java -- The GNU implementation of GlyphVector.
+   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.awt.font;
+
+import java.awt.Font;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphMetrics;
+import java.awt.font.GlyphJustificationInfo;
+import java.awt.font.GlyphVector;
+
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+
+/**
+ * The GNU implementation of the abstract GlyphVector class, which
+ * uses the services provided by a FontDelegate for its functionality.
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class GNUGlyphVector
+  extends GlyphVector
+{
+  private FontDelegate fontDelegate;
+  private Font font;
+  private FontRenderContext renderContext;
+  private int[] glyphs;
+  private float fontSize;
+  private AffineTransform transform;
+  private boolean valid;
+
+
+  /**
+   * The position of each glyph. The horizontal position of the
+   * <code>i</code>-th glyph is at <code>pos[i * 2]</code>, its
+   * vertical position at <code>pos[i * 2 + 1]</code>. The total
+   * advance width of the entire vector is stored at
+   * <code>pos[numGlyphs]</code>, the total advance height at
+   * <code>pos[numGlyphs + 1]</code>.
+   */
+  private float[] pos;
+
+
+  private AffineTransform[] transforms;
+  private int layoutFlags;
+
+
+  /**
+   * Constructs a new GNUGlyphVector.
+   *
+   * @param fontDelegate the FontDelegate that creates this vector.
+   *
+   * @param font the Font that this GlyphVector will return for {@link
+   * #getFont()}. That object is also used to determine the point
+   * size, which affects the affine transformation used by the font
+   * scaler.
+   *
+   * @param renderContext an object with parameters for font
+   * rendering, such as whether anti-aliasing is enabled.
+   *
+   * @param glyphs the glyphs in this vector.
+   */
+  public GNUGlyphVector(FontDelegate fontDelegate,
+                        Font font,
+                        FontRenderContext renderContext,
+                        int[] glyphs)
+  {
+    this.fontDelegate = fontDelegate;
+    this.font = font;
+    this.renderContext = renderContext;
+    this.glyphs = glyphs;
+    
+    fontSize = font.getSize2D();
+    transform = font.getTransform(); // returns a modifiable copy
+    //transform.concatenate(renderContext.getTransform());
+  }
+
+
+
+  /**
+   * Returns the font of the glyphs in this GlyphVector.
+   */
+  public Font getFont()
+  {
+    return font;
+  }
+
+
+  /**
+   * Returns the FontRenderContext that is used to calculate the
+   * extent and position of the glyphs.
+   */
+  public FontRenderContext getFontRenderContext()
+  {
+    return renderContext;
+  }
+
+
+  /**
+   * Moves each glyph in the vector to its default position.
+   */
+  public void performDefaultLayout()
+  {
+    float x, y, advanceWidth, advanceHeight;
+    int i, p;
+    AffineTransform tx;
+    Point2D.Float advance = new Point2D.Float();
+
+    pos = new float[(glyphs.length + 1) * 2];
+    x = y = 0.0f;
+    p = 0;
+    for (i = p = 0; i < glyphs.length; i++)
+    {
+      p += 2;
+      
+      if ((transforms == null) || (tx = transforms[i]) == null)
+        tx = this.transform;
+      else
+      {
+        tx = new AffineTransform(tx);
+        tx.concatenate(this.transform);
+      }
+      
+      fontDelegate.getAdvance(glyphs[i], fontSize, tx,
+                              renderContext.isAntiAliased(),
+                              renderContext.usesFractionalMetrics(),
+                              /* horizontal */ true,
+                              advance);
+      pos[p] = x += advance.x;
+      pos[p + 1] = y += advance.y;
+    }
+    valid = true;
+  }
+
+
+  /**
+   * Determines the number of glyphs in this GlyphVector.
+   */
+  public int getNumGlyphs()
+  {
+    return glyphs.length;
+  }
+
+
+  /**
+   * Determines the glyph number by index in this vector.
+   * Glyph numbers are specific to each font, so two fonts
+   * will likely assign different numbers to the same glyph.
+   *
+   * @param glyphIndex the index of the glyph whose glyph number is to
+   * be retrieved.
+   *
+   * @throws IndexOutOfBoundsException if <code>glyphIndex</code>
+   * is not in the range <code[0 .. getNumGlyphs() - 1]</code>.
+   */
+  public int getGlyphCode(int glyphIndex)
+  {
+    /* The exception is thrown automatically if the index is out
+     * of the valid bounds.
+     */
+    return glyphs[glyphIndex];
+  }
+
+
+  /**
+   * Returns a slice of this GlyphVector.
+   *
+   * @param firstGlyphIndex the index of the first glyph in the
+   * returned slice.
+   *
+   * @param numEntries the size of the returned slice.
+   *
+   * @param outCodes a pre-allocated array for storing the slice,
+   * or <code>null</code> to cause allocation of a new array.
+   *
+   * @return a slice of this GlyphVector. If <code>outCodes</code>
+   * is <code>null</code>, the slice will be stored into a freshly
+   * allocated array; otherwise, the result will be stored into
+   * <code>outCodes</code>.
+   */
+  public int[] getGlyphCodes(int firstGlyphIndex,
+                             int numEntries,
+                             int[] outCodes)
+  {
+    if (numEntries < 0)
+      throw new IllegalArgumentException();
+    if (outCodes == null)
+      outCodes = new int[numEntries];
+    System.arraycopy(glyphs, firstGlyphIndex, outCodes, 0, numEntries);
+    return outCodes;
+  }
+
+
+  public Rectangle2D getLogicalBounds()
+  {
+    float ascent, descent;
+
+    validate();
+
+    return new Rectangle2D.Float(0, 0,
+                                 pos[pos.length - 2],
+                                 getAscent() - getDescent());
+  }
+
+
+  public Rectangle2D getVisualBounds()
+  {
+    validate();
+
+    // FIXME: Not yet implemented.
+    return getLogicalBounds();
+  }
+
+
+  /**
+   * Returns the shape of this GlyphVector.
+   */
+  public Shape getOutline()
+  {
+    validate();
+    return getOutline(0.0f, 0.0f);
+  }
+
+
+  /**
+   * Returns the shape of this GlyphVector, translated to the
+   * specified position.
+   *
+   * @param x the horizontal position for rendering this vector.
+   * @param y the vertical position for rendering this vector.
+   */
+  public Shape getOutline(float x, float y)
+  {
+    validate();
+
+    GeneralPath outline = new GeneralPath();
+    int len = glyphs.length;
+    for (int i = 0; i < len; i++)
+      {
+        GeneralPath p = new GeneralPath(getGlyphOutline(i));
+        outline.append(p, false);
+      }
+    AffineTransform t = new AffineTransform();
+    t.translate(x, y);
+    outline.transform(t);
+    return outline;
+  }
+
+
+  /**
+   * Determines the shape of the specified glyph.
+   *
+   * @throws IndexOutOfBoundsException if <code>glyphIndex</code> is
+   * not in the range <code[0 .. getNumGlyphs()]</code>.
+   */
+  public Shape getGlyphOutline(int glyphIndex)
+  {
+    AffineTransform tx, glyphTx;
+    GeneralPath path;
+
+    validate();
+
+    if ((transforms != null)
+        && ((glyphTx = transforms[glyphIndex]) != null))
+    {
+      tx =  new AffineTransform(transform);
+      tx.concatenate(glyphTx);
+    }
+    else
+      tx = transform;
+
+    path = fontDelegate.getGlyphOutline(glyphs[glyphIndex], fontSize, tx,
+                                        renderContext.isAntiAliased(),
+                                        renderContext.usesFractionalMetrics());
+
+    tx = new AffineTransform();
+    tx.translate(pos[glyphIndex * 2], pos[glyphIndex * 2 + 1]);
+    path.transform(tx);
+    return path;
+  }
+
+
+  /**
+   * Determines the position of the specified glyph, or the
+   * total advance width and height of the vector.
+   *
+   * @param glyphIndex the index of the glyph in question.
+   * If this value equals <code>getNumGlyphs()</code>, the
+   * position <i>after</i> the last glyph will be returned,
+   * which is the total advance width and height of the vector.
+   *
+   * @throws IndexOutOfBoundsException if <code>glyphIndex</code> is
+   * not in the range <code[0 .. getNumGlyphs()]</code>.
+   */
+  public Point2D getGlyphPosition(int glyphIndex)
+  {
+    validate();
+    return new Point2D.Float(pos[glyphIndex * 2],
+                             pos[glyphIndex * 2 + 1]);
+  }
+
+
+  /**
+   * Moves the specified glyph to a new position, or changes the
+   * advance width and height of the entire glyph vector.
+   *
+   * <p>Note that the position of an individual glyph may also
+   * affected by its affine transformation.
+   *
+   * @param glyphIndex the index of the moved glyph. If
+   * <code>glyphIndex</code> equals the total number of glyphs in this
+   * vector, the advance width and height of the vector is changed.
+   *
+   * @param position the new position of the glyph.
+   *
+   * @throws IndexOutOfBoundsException if <code>glyphIndex</code> is
+   * not in the range <code[0 .. getNumGlyphs()]</code>.
+   */
+  public void setGlyphPosition(int glyphIndex, Point2D position)
+  {
+    validate();
+    pos[glyphIndex * 2] = (float) position.getX();
+    pos[glyphIndex * 2 + 1] = (float) position.getY();
+  }
+
+
+  /**
+   * Returns the affine transformation that is applied to the
+   * glyph at the specified index.
+   *
+   * @param glyphIndex the index of the glyph whose transformation
+   * is to be retrieved.
+   *
+   * @return an affine transformation, or <code>null</code>
+   * for the identity transformation.
+   *
+   * @throws IndexOutOfBoundsException if <code>glyphIndex</code> is
+   * not in the range <code[0 .. getNumGlyphs() - 1]</code>.
+   */
+  public AffineTransform getGlyphTransform(int glyphIndex)
+  {
+    if (transforms == null)
+      return null;
+    else
+      return transforms[glyphIndex];
+  }
+
+
+  /**
+   * Applies an affine transformation to the glyph at the specified
+   * index.
+   *
+   * @param glyphIndex the index of the glyph to which the
+   * transformation is applied.
+   *
+   * @param transform the affine transformation for the glyph, or
+   * <code>null</code> for an identity transformation.
+   */
+  public void setGlyphTransform(int glyphIndex,
+                                AffineTransform transform)
+  {
+    if (transforms == null)
+      transforms = new AffineTransform[glyphs.length];
+    transforms[glyphIndex] = transform;
+
+    /* If the GlyphVector has only a transform for a single glyph, and
+     * the caller clears its transform, the FLAG_HAS_TRANSFORMS bit
+     * should be cleared in layoutFlags.  However, this would require
+     * that we keep track of the number of transformed glyphs, or that
+     * we count them when a transform is cleared. This would
+     * complicate the code quite a bit. Note that the only drawback of
+     * wrongly setting FLAG_HAS_TRANSFORMS is that a slower code path
+     * might be taken for rendering the vector. Right now, we never
+     * really look at the flag, so it does not make any difference.
+     */
+    if (transform != null)
+      layoutFlags |= FLAG_HAS_TRANSFORMS;
+    valid = false;
+  }
+
+
+  /**
+   * Returns flags that can be used for optimizing the rendering
+   * of this GlyphVector.
+   *
+   * @return a bit mask with the applicable flags set.
+   *
+   * @since 1.4
+   *
+   * @see GlyphVector#FLAG_HAS_POSITION_ADJUSTMENTS
+   * @see GlyphVector#FLAG_HAS_TRANSFORMS
+   * @see GlyphVector#FLAG_RUN_RTL
+   * @see GlyphVector#FLAG_COMPLEX_GLYPHS
+   * @see GlyphVector#FLAG_MASK
+   */
+  public int getLayoutFlags()
+  {
+    return layoutFlags;
+  }
+  
+  
+  /**
+   * Returns the positions of a range of glyphs in this vector.
+   * 
+   * @param firstGlyphIndex the index of the first glyph whose
+   * position is retrieved.
+   *
+   * @param numGlyphs the number of glyphs whose positions
+   * are retrieved.
+   *
+   * @param outPositions an array for storing the results
+   * (the length must be at least twice <code>numGlyphs</code>),
+   * or <code>null</code> for freshly allocating an array.
+   *
+   * @return an array with the glyph positions. The horizontal
+   * position of the <code>i</code>-th glyph is at index <code>2 *
+   * i</code>, the vertical position at index <code>2 * i + 1</code>.
+   *
+   * @throws IllegalArgumentException if <code>numGlyphs</code>
+   * is less than zero.
+   *
+   * @throws IndexOutOfBoundsException if either
+   * <code>firstGlyphIndex</code> or <code>(firstGlyphIndex +
+   * numGlyphs)</code> is not in the range <code>[0 .. getNumGlyphs() -
+   * 1]</code>.
+   */
+  public float[] getGlyphPositions(int firstGlyphIndex,
+                                   int numGlyphs,
+                                   float[] outPositions)
+  {
+    if (numGlyphs < 0)
+      throw new IllegalArgumentException();
+
+    validate();
+    if (outPositions == null)
+      outPositions = new float[numGlyphs * 2];
+
+    System.arraycopy(/*src */ pos, /* srcStart */ firstGlyphIndex * 2,
+                     /* dest */ outPositions, /* destStart */ 0,
+                     /* length */ numGlyphs * 2);
+    return outPositions;
+  }
+
+  
+  private float getAscent()
+  {
+    return fontDelegate.getAscent(fontSize, transform,
+                                  renderContext.isAntiAliased(),
+                                  renderContext.usesFractionalMetrics(),
+                                  /* horizontal */ true);
+  }
+
+
+  private float getDescent()
+  {
+    return fontDelegate.getDescent(fontSize, transform,
+                                   renderContext.isAntiAliased(),
+                                   renderContext.usesFractionalMetrics(),
+                                   /* horizontal */ true);    
+  }
+
+
+  public Shape getGlyphLogicalBounds(int glyphIndex)
+  {
+    float x, y, ascent;
+
+    validate();
+    ascent = getAscent();
+    x = pos[glyphIndex * 2];
+    y = pos[glyphIndex * 2 + 1];
+
+    return new Rectangle2D.Float(x, y - ascent,
+                                 pos[(glyphIndex + 1) * 2] - x,
+                                 ascent - getDescent());
+  }
+
+
+  public Shape getGlyphVisualBounds(int glyphIndex)
+  {
+    return getGlyphOutline(glyphIndex).getBounds2D();
+  }
+
+
+  /**
+   * Determines the metrics of the glyph at the specified index.
+   *
+   * @param glyphIndex the index of the glyph whose metrics is to be
+   * retrieved.
+   *
+   * @throws IndexOutOfBoundsException if <code>glyphIndex</code> is
+   * not in the range <code[0 .. getNumGlyphs() - 1]</code>.
+   */
+  public GlyphMetrics getGlyphMetrics(int glyphIndex)
+  {
+    // FIXME: Not yet implemented.
+    throw new UnsupportedOperationException();
+  }
+
+
+  /**
+   * Determines the justification information for the glyph at the
+   * specified index.
+   *
+   * @param glyphIndex the index of the glyph whose justification
+   * information is to be retrieved.
+   *
+   * @throws IndexOutOfBoundsException if <code>glyphIndex</code> is
+   * not in the range <code[0 .. getNumGlyphs() - 1]</code>.
+   */
+  public GlyphJustificationInfo getGlyphJustificationInfo(int glyphIndex)
+  {
+    // FIXME: Not yet implemented.
+    throw new UnsupportedOperationException();
+  }
+
+
+  /**
+   * Determines whether another GlyphVector is for the same font and
+   * rendering context, uses the same glyphs and positions them to the
+   * same location.
+   *
+   * @param other the GlyphVector to compare with.
+   *
+   * @return <code>true</code> if the two vectors are equal,
+   * <code>false</code> otherwise.
+   */
+  public boolean equals(GlyphVector other)
+  {
+    GNUGlyphVector o;
+    if (!(other instanceof GNUGlyphVector))
+      return false;
+
+    o = (GNUGlyphVector) other;
+    if ((this.font != o.font)
+        || (this.fontDelegate != o.fontDelegate)
+        || (this.renderContext != o.renderContext)
+        || (this.glyphs.length != o.glyphs.length))
+      return false;
+
+    for (int i = 0; i < glyphs.length; i++)
+      if (this.glyphs[i] != o.glyphs[i])
+        return false;
+
+    validate();
+    o.validate();
+    for (int i = 0; i < pos.length; i++)
+      if (this.pos[i] != o.pos[i])
+        return false;
+
+    return true;
+  }
+
+  private void validate()
+  {
+    if (!valid)
+      performDefaultLayout();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/CharGlyphMap.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/CharGlyphMap.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/CharGlyphMap.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/CharGlyphMap.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1027 @@
+/* CharGlyphMap.java -- Manages the 'cmap' table of TrueType fonts
+   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.awt.font.opentype;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.ShortBuffer;
+import java.nio.IntBuffer;
+
+
+/**
+ * A mapping from Unicode codepoints to glyphs. This mapping
+ * does not perform any re-ordering or decomposition, so it
+ * is not everything that is needed to support Unicode.
+ *
+ * <p>This class manages the <code>cmap</code> table of
+ * OpenType and TrueType fonts.
+ *
+ * @see <a href="http://partners.adobe.com/asn/tech/type/opentype/cmap.jsp">
+ *      the <code>cmap</code> part of Adobe&#x2019; OpenType Specification</a>
+ *
+ * @see <a href="http://developer.apple.com/fonts/TTRefMan/RM06/Chap6cmap.html">
+ *      the <code>cmap</code> section of Apple&#x2019;s TrueType Reference
+ *      Manual</a>
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+abstract class CharGlyphMap
+{
+  private static final int PLATFORM_UNICODE = 0;
+  private static final int PLATFORM_MACINTOSH = 1;
+  private static final int PLATFORM_MICROSOFT = 3;
+
+
+  /**
+   * Determines the glyph index for a given Unicode codepoint.  Users
+   * should be aware that the character-to-glyph mapping not not
+   * everything that is needed for full Unicode support.  For example,
+   * the <code>cmap</code> table is not able to synthesize accented
+   * glyphs from the canonical decomposition sequence, even if the
+   * font would contain a glyph for the composed form.
+   *
+   * @param ucs4 the Unicode codepoint in UCS-4 encoding. Surrogates
+   * (U+D800 to U+DFFF) cannot be passed, they must be mapped to
+   * UCS-4 first.
+   *
+   * @return the glyph index, or 0 if the font does not contain
+   * a glyph for this codepoint.
+   */
+  public abstract int getGlyph(int ucs4);
+
+
+  /**
+   * Reads a CharGlyphMap from an OpenType or TrueType <code>cmap</code>
+   * table. The current implementation works as follows:
+   * 
+   * <p><ol><li>If the font has a type 4 cmap for the Unicode platform
+   * (encoding 0, 1, 2, 3 or 4), or a type 4 cmap for the Microsoft
+   * platform (encodings 1 or 10), that table is used to map Unicode
+   * codepoints to glyphs.  Most recent fonts, both for Macintosh and
+   * Windows, should provide such a table.</li>
+   *
+   * <li>Otherwise, if the font has any type 0 cmap for the Macintosh
+   * platform, a Unicode-to-glyph mapping is synthesized from certain
+   * type 0 cmaps. The current implementation collects mappings from
+   * Roman, Icelandic, Turkish, Croatian, Romanian, Eastern European,
+   * Cyrillic, Greek, Hebrew, Arabic and Farsi cmaps.</li>.</ol>
+   *
+   * @param buf a buffer whose position is right at the start
+   * of the entire <code>cmap</code> table, and whose limit
+   * is at its end.
+   *
+   * @return a concrete subclass of <code>CharGlyphMap</code>
+   * that performs the mapping.
+   *
+   * @see <a href=
+   * "http://partners.adobe.com/asn/tech/type/opentype/cmap.jsp"
+   * >the <code>cmap</code> part of Adobe&#x2019; OpenType Specification</a>
+   *
+   * @see <a href=
+   * "http://developer.apple.com/fonts/TTRefMan/RM06/Chap6cmap.html"
+   * >the <code>cmap</code> section of Apple&#x2019;s TrueType Reference
+   * Manual</a>
+   */
+  public static CharGlyphMap forTable(ByteBuffer buf)
+  {
+    boolean hasType0 = false;
+    int start4 = -1, platform4 = 0, encoding4 = 0;
+    int start12 = -1, platform12 = 0, encoding12 = 0;
+    int version;
+    int numTables;
+    int tableStart = buf.position();
+    int limit = buf.limit();
+    int format, platform, language, encoding, length, offset;
+
+    version = buf.getChar();
+    if (version != 0)
+      return null;
+    
+    numTables = buf.getChar();
+    for (int i = 0; i < numTables; i++)
+    {
+      buf.limit(limit).position(tableStart + 4 + i * 8);
+      platform = buf.getChar();
+      encoding = buf.getChar();
+      offset = tableStart + buf.getInt();
+
+      buf.position(offset);
+      format = buf.getChar();
+
+      switch (format)
+      {
+      case 0:
+        hasType0 = true;
+        break;
+
+      case 4:
+        length = buf.getChar();
+        language = buf.getChar();
+        if ((start4 == -1)
+            && Type4.isSupported(platform, language, encoding))
+        {
+          start4 = offset;
+          platform4 = platform;
+          encoding4 = encoding;
+        }
+        break;
+
+      case 12:
+        if ((start12 == -1) && Type12.isSupported(platform, encoding))
+        {
+          start12 = offset;
+          platform12 = platform;
+          encoding12 = encoding;
+        }
+        break;
+      }
+    }
+
+
+    if (start12 >= 0)
+    {
+      try
+      {
+        buf.limit(limit).position(start12);
+        return new Type12(buf, platform12, encoding12);
+      }
+      catch (Exception ex)
+      {
+        ex.printStackTrace();
+      }
+    }
+
+    if (start4 >= 0)
+    {
+      try
+      {
+        buf.limit(limit).position(start4);
+        return Type4.readTable(buf, platform4, encoding4);
+      }
+      catch (Exception ex)
+      {
+      }
+    }
+
+    if (hasType0)
+    {
+      try
+      {
+        buf.limit(limit).position(tableStart);
+        return new Type0(buf);
+      }
+      catch (Exception ex)
+      {
+      }
+    }
+
+    return new Dummy();
+  }
+
+
+  /**
+   * A dummy mapping that maps anything to the undefined glyph.
+   * Used if no other cmap is understood in a font.
+   *
+   * @author Sascha Brawer (brawer at dandelis.ch)
+   */
+  private static final class Dummy
+    extends CharGlyphMap
+  {
+    public int getGlyph(int ucs4)
+    {
+      return 0;
+    }
+  }
+  
+  
+  /**
+   * A mapping from Unicode code points to glyph IDs through CMAP Type
+   * 0 tables. These tables have serious limitations: Only the first
+   * 256 glyphs can be addressed, and the source of the mapping is not
+   * Unicode, but an encoding used on the Macintosh.
+   *
+   * <p>However, some fonts have only a Type 0 cmap. In this case, we
+   * process all the Type 0 tables we understand, and establish
+   * a reversed glyph-to-Unicode mapping. When a glyph is requested
+   * for a given Unicode character, we perform a linear search on the
+   * reversed table to find the glyph which maps to the requested
+   * character. While not blazingly fast, this gives a reasonable
+   * fallback for old fonts.
+   *
+   * @author Sascha Brawer (brawer at dandelis.ch)
+   */
+  private static final class Type0
+    extends CharGlyphMap
+  {
+    /**
+     * An array whose <code>i</code>-th element indicates the
+     * Unicode code point of glyph <code>i</code> in the font.
+     */
+    private char[] glyphToUCS2 = new char[256];
+    
+    
+    /**
+     * A String whose <code>charAt(i)</code> is the Unicode character
+     * that corresponds to the codepoint <code>i + 127</code> in the
+     * MacOS Arabic encoding.
+     *
+     * @see <a href=
+     * "http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ARABIC.TXT"
+     * >the Unicode mapping table for the MacOS Arabic encoding</a>
+     */
+    private static final String UPPER_ARABIC
+      = "\u007e\u0000\u00c4\u00a0\u00c7\u00c9\u00d1\u00d6\u00dc\u00e1"
+      + "\u00e0\u00e2\u00e4\u06ba\u00ab\u00e7\u00e9\u00e8\u00ea\u00eb"
+      + "\u00ed\u2026\u00ee\u00ef\u00f1\u00f3\u00bb\u00f4\u00f6\u00f7"
+      + "\u00fa\u00f9\u00fb\u00fc\u0020\u0021\"\u0023\u0024\u066a"
+      + "\u0026\u0027\u0028\u0029\u002a\u002b\u060c\u002d\u002e\u002f"
+      + "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669"
+      + "\u003a\u061b\u003c\u003d\u003e\u061f\u274a\u0621\u0622\u0623"
+      + "\u0624\u0625\u0626\u0627\u0628\u0629\u062a\u062b\u062c\u062d"
+      + "\u062e\u062f\u0630\u0631\u0632\u0633\u0634\u0635\u0636\u0637"
+      + "\u0638\u0639\u063a\u005b\\\u005d\u005e\u005f\u0640\u0641"
+      + "\u0642\u0643\u0644\u0645\u0646\u0647\u0648\u0649\u064a\u064b"
+      + "\u064c\u064d\u064e\u064f\u0650\u0651\u0652\u067e\u0679\u0686"
+      + "\u06d5\u06a4\u06af\u0688\u0691\u007b\u007c\u007d\u0698\u06d2";
+
+
+    /**
+     * A String whose <code>charAt(i)</code> is the Unicode character
+     * that corresponds to the codepoint <code>i + 127</code> in the
+     * MacOS East European Roman encoding.
+     *
+     * @see <a href=
+     * "http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CENTEURO.TXT"
+     * >the Unicode mapping table for the MacOS Central European
+     * encoding</a>
+     */
+    private static final String UPPER_EAST_EUROPEAN_ROMAN
+      = "\u007e\u0000\u00c4\u0100\u0101\u00c9\u0104\u00d6\u00dc\u00e1"
+      + "\u0105\u010c\u00e4\u010d\u0106\u0107\u00e9\u0179\u017a\u010e"
+      + "\u00ed\u010f\u0112\u0113\u0116\u00f3\u0117\u00f4\u00f6\u00f5"
+      + "\u00fa\u011a\u011b\u00fc\u2020\u00b0\u0118\u00a3\u00a7\u2022"
+      + "\u00b6\u00df\u00ae\u00a9\u2122\u0119\u00a8\u2260\u0123\u012e"
+      + "\u012f\u012a\u2264\u2265\u012b\u0136\u2202\u2211\u0142\u013b"
+      + "\u013c\u013d\u013e\u0139\u013a\u0145\u0146\u0143\u00ac\u221a"
+      + "\u0144\u0147\u2206\u00ab\u00bb\u2026\u00a0\u0148\u0150\u00d5"
+      + "\u0151\u014c\u2013\u2014\u201c\u201d\u2018\u2019\u00f7\u25ca"
+      + "\u014d\u0154\u0155\u0158\u2039\u203a\u0159\u0156\u0157\u0160"
+      + "\u201a\u201e\u0161\u015a\u015b\u00c1\u0164\u0165\u00cd\u017d"
+      + "\u017e\u016a\u00d3\u00d4\u016b\u016e\u00da\u016f\u0170\u0171"
+      + "\u0172\u0173\u00dd\u00fd\u0137\u017b\u0141\u017c\u0122\u02c7";
+
+
+    /**
+     * A String whose <code>charAt(i)</code> is the Unicode character
+     * that corresponds to the codepoint <code>i + 127</code> in the
+     * MacOS Roman encoding for the Croatian language.
+     *
+     * @see <a href=
+     * "http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CROATIAN.TXT"
+     * >the Unicode mapping table for the MacOS Croatian encoding</a>
+     */
+    private static final String UPPER_CROATIAN
+      = "\u007e\u0000\u00c4\u00c5\u00c7\u00c9\u00d1\u00d6\u00dc\u00e1"
+      + "\u00e0\u00e2\u00e4\u00e3\u00e5\u00e7\u00e9\u00e8\u00ea\u00eb"
+      + "\u00ed\u00ec\u00ee\u00ef\u00f1\u00f3\u00f2\u00f4\u00f6\u00f5"
+      + "\u00fa\u00f9\u00fb\u00fc\u2020\u00b0\u00a2\u00a3\u00a7\u2022"
+      + "\u00b6\u00df\u00ae\u0160\u2122\u00b4\u00a8\u2260\u017d\u00d8"
+      + "\u221e\u00b1\u2264\u2265\u2206\u00b5\u2202\u2211\u220f\u0161"
+      + "\u222b\u00aa\u00ba\u03a9\u017e\u00f8\u00bf\u00a1\u00ac\u221a"
+      + "\u0192\u2248\u0106\u00ab\u010c\u2026\u00a0\u00c0\u00c3\u00d5"
+      + "\u0152\u0153\u0110\u2014\u201c\u201d\u2018\u2019\u00f7\u25ca"
+      + "\uf8ff\u00a9\u2044\u20ac\u2039\u203a\u00c6\u00bb\u2013\u00b7"
+      + "\u201a\u201e\u2030\u00c2\u0107\u00c1\u010d\u00c8\u00cd\u00ce"
+      + "\u00cf\u00cc\u00d3\u00d4\u0111\u00d2\u00da\u00db\u00d9\u0131"
+      + "\u02c6\u02dc\u00af\u03c0\u00cb\u02da\u00b8\u00ca\u00e6\u02c7";
+
+
+    /**
+     * A String whose <code>charAt(i)</code> is the Unicode character
+     * that corresponds to the codepoint <code>i + 127</code> in the
+     * MacOS Cyrillic encoding.
+     *
+     * @see <a href=
+     * "http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CYRILLIC.TXT"
+     * >the Unicode mapping table for the MacOS Cyrillic encoding</a>
+     */
+    private static final String UPPER_CYRILLIC
+      = "\u007e\u0000\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417"
+      + "\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f\u0420\u0421"
+      + "\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042a\u042b"
+      + "\u042c\u042d\u042e\u042f\u2020\u00b0\u0490\u00a3\u00a7\u2022"
+      + "\u00b6\u0406\u00ae\u00a9\u2122\u0402\u0452\u2260\u0403\u0453"
+      + "\u221e\u00b1\u2264\u2265\u0456\u00b5\u0491\u0408\u0404\u0454"
+      + "\u0407\u0457\u0409\u0459\u040a\u045a\u0458\u0405\u00ac\u221a"
+      + "\u0192\u2248\u2206\u00ab\u00bb\u2026\u00a0\u040b\u045b\u040c"
+      + "\u045c\u0455\u2013\u2014\u201c\u201d\u2018\u2019\u00f7\u201e"
+      + "\u040e\u045e\u040f\u045f\u2116\u0401\u0451\u044f\u0430\u0431"
+      + "\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043a\u043b"
+      + "\u043c\u043d\u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445"
+      + "\u0446\u0447\u0448\u0449\u044a\u044b\u044c\u044d\u044e\u20ac";
+
+
+    /**
+     * A String whose <code>charAt(i)</code> is the Unicode character
+     * that corresponds to the codepoint <code>i + 127</code> in the
+     * MacOS Arabic encoding with the Farsi language.
+     *
+     * @see <a href=
+     * "http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/FARSI.TXT"
+     * >the Unicode mapping table for the MacOS Farsi encoding</a>
+     */
+    private static final String UPPER_FARSI
+      = "\u007e\u0000\u00c4\u00a0\u00c7\u00c9\u00d1\u00d6\u00dc\u00e1"
+      + "\u00e0\u00e2\u00e4\u06ba\u00ab\u00e7\u00e9\u00e8\u00ea\u00eb"
+      + "\u00ed\u2026\u00ee\u00ef\u00f1\u00f3\u00bb\u00f4\u00f6\u00f7"
+      + "\u00fa\u00f9\u00fb\u00fc\u0020\u0021\"\u0023\u0024\u066a"
+      + "\u0026\u0027\u0028\u0029\u002a\u002b\u060c\u002d\u002e\u002f"
+      + "\u06f0\u06f1\u06f2\u06f3\u06f4\u06f5\u06f6\u06f7\u06f8\u06f9"
+      + "\u003a\u061b\u003c\u003d\u003e\u061f\u274a\u0621\u0622\u0623"
+      + "\u0624\u0625\u0626\u0627\u0628\u0629\u062a\u062b\u062c\u062d"
+      + "\u062e\u062f\u0630\u0631\u0632\u0633\u0634\u0635\u0636\u0637"
+      + "\u0638\u0639\u063a\u005b\\\u005d\u005e\u005f\u0640\u0641"
+      + "\u0642\u0643\u0644\u0645\u0646\u0647\u0648\u0649\u064a\u064b"
+      + "\u064c\u064d\u064e\u064f\u0650\u0651\u0652\u067e\u0679\u0686"
+      + "\u06d5\u06a4\u06af\u0688\u0691\u007b\u007c\u007d\u0698\u06d2";
+
+
+    /**
+     * A String whose <code>charAt(i)</code> is the Unicode character
+     * that corresponds to the codepoint <code>i + 127</code> in the
+     * MacOS Greek encoding.
+     *
+     * @see <a
+     * href="http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/GREEK.TXT"
+     * >the Unicode mapping table for the MacOS Greek encoding</a>
+     */
+    private static final String UPPER_GREEK
+      = "\u007e\u0000\u00c4\u00b9\u00b2\u00c9\u00b3\u00d6\u00dc\u0385"
+      + "\u00e0\u00e2\u00e4\u0384\u00a8\u00e7\u00e9\u00e8\u00ea\u00eb"
+      + "\u00a3\u2122\u00ee\u00ef\u2022\u00bd\u2030\u00f4\u00f6\u00a6"
+      + "\u20ac\u00f9\u00fb\u00fc\u2020\u0393\u0394\u0398\u039b\u039e"
+      + "\u03a0\u00df\u00ae\u00a9\u03a3\u03aa\u00a7\u2260\u00b0\u00b7"
+      + "\u0391\u00b1\u2264\u2265\u00a5\u0392\u0395\u0396\u0397\u0399"
+      + "\u039a\u039c\u03a6\u03ab\u03a8\u03a9\u03ac\u039d\u00ac\u039f"
+      + "\u03a1\u2248\u03a4\u00ab\u00bb\u2026\u00a0\u03a5\u03a7\u0386"
+      + "\u0388\u0153\u2013\u2015\u201c\u201d\u2018\u2019\u00f7\u0389"
+      + "\u038a\u038c\u038e\u03ad\u03ae\u03af\u03cc\u038f\u03cd\u03b1"
+      + "\u03b2\u03c8\u03b4\u03b5\u03c6\u03b3\u03b7\u03b9\u03be\u03ba"
+      + "\u03bb\u03bc\u03bd\u03bf\u03c0\u03ce\u03c1\u03c3\u03c4\u03b8"
+      + "\u03c9\u03c2\u03c7\u03c5\u03b6\u03ca\u03cb\u0390\u03b0\u00ad";
+
+
+    /**
+     * A String whose <code>charAt(i)</code> is the Unicode character
+     * that corresponds to the codepoint <code>i + 127</code> in the
+     * MacOS Hebrew encoding.
+     *
+     * <p>The codepoint 0x81 (HEBREW LIGATURE YIDDISH YOD YOD PATAH)
+     * has no composed Unicode equivalent, but is expressed as the
+     * sequence U+05F2 U+05B7 in Unicode. A similar situation exists
+     * with the codepoint 0xC0 (HEBREW LIGATURE LAMED HOLAM), which
+     * MacOS converts to U+F86A U+05DC U+05B9. To correctly deal
+     * with these sequences, we probably should synthesize a ligature
+     * table if a Hebrew font only provides a Type 0 CMAP.
+     *
+     * @see <a href=
+     * "http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/HEBREW.TXT"
+     * >the Unicode mapping table for the MacOS Hebrew encoding</a>
+     */
+    private static final String UPPER_HEBREW
+      = "\u007e\u0000\u00c4\u0000\u00c7\u00c9\u00d1\u00d6\u00dc\u00e1"
+      + "\u00e0\u00e2\u00e4\u00e3\u00e5\u00e7\u00e9\u00e8\u00ea\u00eb"
+      + "\u00ed\u00ec\u00ee\u00ef\u00f1\u00f3\u00f2\u00f4\u00f6\u00f5"
+      + "\u00fa\u00f9\u00fb\u00fc\u0020\u0021\"\u0023\u0024\u0025"
+      + "\u20aa\u0027\u0029\u0028\u002a\u002b\u002c\u002d\u002e\u002f"
+      + "\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037\u0038\u0039"
+      + "\u003a\u003b\u003c\u003d\u003e\u003f\u0000\u201e\uf89b\uf89c"
+      + "\uf89d\uf89e\u05bc\ufb4b\ufb35\u2026\u00a0\u05b8\u05b7\u05b5"
+      + "\u05b6\u05b4\u2013\u2014\u201c\u201d\u2018\u2019\ufb2a\ufb2b"
+      + "\u05bf\u05b0\u05b2\u05b1\u05bb\u05b9\u0000\u05b3\u05d0\u05d1"
+      + "\u05d2\u05d3\u05d4\u05d5\u05d6\u05d7\u05d8\u05d9\u05da\u05db"
+      + "\u05dc\u05dd\u05de\u05df\u05e0\u05e1\u05e2\u05e3\u05e4\u05e5"
+      + "\u05e6\u05e7\u05e8\u05e9\u05ea\u007d\u005d\u007b\u005b\u007c";
+
+
+    /**
+     * A String whose <code>charAt(i)</code> is the Unicode character
+     * that corresponds to the codepoint <code>i + 127</code> in the
+     * MacOS Roman encoding with the Icelandic language.
+     *
+     * @see <a href=
+     * "http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ICELAND.TXT"
+     * >the Unicode mapping table for the MacOS Icelandic encoding</a>
+     */
+    private static final String UPPER_ICELANDIC
+      = "\u007e\u0000\u00c4\u00c5\u00c7\u00c9\u00d1\u00d6\u00dc\u00e1"
+      + "\u00e0\u00e2\u00e4\u00e3\u00e5\u00e7\u00e9\u00e8\u00ea\u00eb"
+      + "\u00ed\u00ec\u00ee\u00ef\u00f1\u00f3\u00f2\u00f4\u00f6\u00f5"
+      + "\u00fa\u00f9\u00fb\u00fc\u00dd\u00b0\u00a2\u00a3\u00a7\u2022"
+      + "\u00b6\u00df\u00ae\u00a9\u2122\u00b4\u00a8\u2260\u00c6\u00d8"
+      + "\u221e\u00b1\u2264\u2265\u00a5\u00b5\u2202\u2211\u220f\u03c0"
+      + "\u222b\u00aa\u00ba\u03a9\u00e6\u00f8\u00bf\u00a1\u00ac\u221a"
+      + "\u0192\u2248\u2206\u00ab\u00bb\u2026\u00a0\u00c0\u00c3\u00d5"
+      + "\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\u00f7\u25ca"
+      + "\u00ff\u0178\u2044\u20ac\u00d0\u00f0\u00de\u00fe\u00fd\u00b7"
+      + "\u201a\u201e\u2030\u00c2\u00ca\u00c1\u00cb\u00c8\u00cd\u00ce"
+      + "\u00cf\u00cc\u00d3\u00d4\uf8ff\u00d2\u00da\u00db\u00d9\u0131"
+      + "\u02c6\u02dc\u00af\u02d8\u02d9\u02da\u00b8\u02dd\u02db\u02c7";
+
+
+    /**
+     * A String whose <code>charAt(i)</code> is the Unicode character
+     * that corresponds to the codepoint <code>i + 127</code> in the
+     * MacOS Roman encoding for most languages. Exceptions include
+     * Croatian, Icelandic, Romanian, and Turkish.
+     *
+     * @see <a
+     * href="http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMAN.TXT"
+     * >the Unicode mapping table for the MacOS Roman encoding</a>
+     */
+    private static final String UPPER_ROMAN
+      = "\u007e\u0000\u00c4\u00c5\u00c7\u00c9\u00d1\u00d6\u00dc\u00e1"
+      + "\u00e0\u00e2\u00e4\u00e3\u00e5\u00e7\u00e9\u00e8\u00ea\u00eb"
+      + "\u00ed\u00ec\u00ee\u00ef\u00f1\u00f3\u00f2\u00f4\u00f6\u00f5"
+      + "\u00fa\u00f9\u00fb\u00fc\u2020\u00b0\u00a2\u00a3\u00a7\u2022"
+      + "\u00b6\u00df\u00ae\u00a9\u2122\u00b4\u00a8\u2260\u00c6\u00d8"
+      + "\u221e\u00b1\u2264\u2265\u00a5\u00b5\u2202\u2211\u220f\u03c0"
+      + "\u222b\u00aa\u00ba\u03a9\u00e6\u00f8\u00bf\u00a1\u00ac\u221a"
+      + "\u0192\u2248\u2206\u00ab\u00bb\u2026\u00a0\u00c0\u00c3\u00d5"
+      + "\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\u00f7\u25ca"
+      + "\u00ff\u0178\u2044\u20ac\u2039\u203a\ufb01\ufb02\u2021\u00b7"
+      + "\u201a\u201e\u2030\u00c2\u00ca\u00c1\u00cb\u00c8\u00cd\u00ce"
+      + "\u00cf\u00cc\u00d3\u00d4\uf8ff\u00d2\u00da\u00db\u00d9\u0131"
+      + "\u02c6\u02dc\u00af\u02d8\u02d9\u02da\u00b8\u02dd\u02db\u02c7";
+
+
+    /**
+     * A String whose <code>charAt(i)</code> is the Unicode character
+     * that corresponds to the codepoint <code>i + 127</code> in the
+     * MacOS Roman encoding with the Romanian language.
+     *
+     * @see <a href=
+     * "http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMANIAN.TXT"
+     * >the Unicode mapping table for the MacOS Romanian encoding</a>
+     */
+    private static final String UPPER_ROMANIAN
+      = "\u007e\u0000\u00c4\u00c5\u00c7\u00c9\u00d1\u00d6\u00dc\u00e1"
+      + "\u00e0\u00e2\u00e4\u00e3\u00e5\u00e7\u00e9\u00e8\u00ea\u00eb"
+      + "\u00ed\u00ec\u00ee\u00ef\u00f1\u00f3\u00f2\u00f4\u00f6\u00f5"
+      + "\u00fa\u00f9\u00fb\u00fc\u2020\u00b0\u00a2\u00a3\u00a7\u2022"
+      + "\u00b6\u00df\u00ae\u00a9\u2122\u00b4\u00a8\u2260\u0102\u0218"
+      + "\u221e\u00b1\u2264\u2265\u00a5\u00b5\u2202\u2211\u220f\u03c0"
+      + "\u222b\u00aa\u00ba\u03a9\u0103\u0219\u00bf\u00a1\u00ac\u221a"
+      + "\u0192\u2248\u2206\u00ab\u00bb\u2026\u00a0\u00c0\u00c3\u00d5"
+      + "\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\u00f7\u25ca"
+      + "\u00ff\u0178\u2044\u20ac\u2039\u203a\u021a\u021b\u2021\u00b7"
+      + "\u201a\u201e\u2030\u00c2\u00ca\u00c1\u00cb\u00c8\u00cd\u00ce"
+      + "\u00cf\u00cc\u00d3\u00d4\uf8ff\u00d2\u00da\u00db\u00d9\u0131"
+      + "\u02c6\u02dc\u00af\u02d8\u02d9\u02da\u00b8\u02dd\u02db\u02c7";
+
+
+    /**
+     * A String whose <code>charAt(i)</code> is the Unicode character
+     * that corresponds to the codepoint <code>i + 127</code> in the
+     * MacOS Roman encoding with the Turkish language.
+     *
+     * @see <a href=
+     * "http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/TURKISH.TXT"
+     * >the Unicode mapping table for the MacOS Turkish encoding</a>
+     */
+    private static final String UPPER_TURKISH
+      = "\u007e\u0000\u00c4\u00c5\u00c7\u00c9\u00d1\u00d6\u00dc\u00e1"
+      + "\u00e0\u00e2\u00e4\u00e3\u00e5\u00e7\u00e9\u00e8\u00ea\u00eb"
+      + "\u00ed\u00ec\u00ee\u00ef\u00f1\u00f3\u00f2\u00f4\u00f6\u00f5"
+      + "\u00fa\u00f9\u00fb\u00fc\u2020\u00b0\u00a2\u00a3\u00a7\u2022"
+      + "\u00b6\u00df\u00ae\u00a9\u2122\u00b4\u00a8\u2260\u00c6\u00d8"
+      + "\u221e\u00b1\u2264\u2265\u00a5\u00b5\u2202\u2211\u220f\u03c0"
+      + "\u222b\u00aa\u00ba\u03a9\u00e6\u00f8\u00bf\u00a1\u00ac\u221a"
+      + "\u0192\u2248\u2206\u00ab\u00bb\u2026\u00a0\u00c0\u00c3\u00d5"
+      + "\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\u00f7\u25ca"
+      + "\u00ff\u0178\u011e\u011f\u0130\u0131\u015e\u015f\u2021\u00b7"
+      + "\u201a\u201e\u2030\u00c2\u00ca\u00c1\u00cb\u00c8\u00cd\u00ce"
+      + "\u00cf\u00cc\u00d3\u00d4\uf8ff\u00d2\u00da\u00db\u00d9\uf8a0"
+      + "\u02c6\u02dc\u00af\u02d8\u02d9\u02da\u00b8\u02dd\u02db\u02c7";
+
+
+    /**
+     * Constructs a CharGlyphMap.Type0 from all type 0 cmaps provided
+     * by the font. The implementation is able to fuse multiple type
+     * 0 cmaps, such as the MacRoman, Turkish, Icelandic and Croatian
+     * encoding, into a single map from Unicode characters to glyph
+     * indices.
+     *
+     * @param buf a ByteBuffer whose position is right at the
+     * beginning of the entire cmap table of the font (<i>not</i>
+     * at some subtable).
+     */
+    public Type0(ByteBuffer buf)
+    {
+      int numTables;
+      int tableStart = buf.position();
+      int limit = buf.limit();
+
+      /* The CMAP version must be 0. */
+      if (buf.getChar() != 0)
+        throw new IllegalStateException();
+    
+      numTables = buf.getChar();
+      for (int i = 0; i < numTables; i++)
+      {
+        buf.limit(limit).position(tableStart + 4 + i * 8);
+        int platform = buf.getChar();
+        int encoding = buf.getChar();
+        int offset = tableStart + buf.getInt();
+
+        buf.position(offset);
+        int format = buf.getChar();
+        int length = buf.getChar();
+        buf.limit(offset + length);
+        int language = buf.getChar();
+
+        if (format == 0)
+          readSingleTable(buf, platform, language, encoding);
+      }
+    }
+
+
+    /**
+     * Processes a CMAP Type 0 table whose platform, encoding and
+     * language are already known.
+     *
+     * @param buf the buffer to read the table from, positioned
+     *        right after the language tag.
+     */
+    private void readSingleTable(ByteBuffer buf,
+                                 int platform, int language,
+                                 int encoding)
+    {
+      String upper = getUpper129(platform, encoding, language);
+      if (upper == null)
+        return;
+
+      /* Skip the MacOS codepoints [0 .. 31] because they do not
+       * correspond to any Unicode codepoint.
+       */
+      buf.position(buf.position() + 32);
+
+      /* Irrespective of script and language, the MacOS codepoints
+       * [32 .. 126] correspond to the same Unicode codepoint.
+       */
+      for (int i = 32; i < 126; i++)
+        glyphToUCS2[buf.get() & 0xff] = (char) i;
+
+      for (int i = 127; i < 256; i++)
+        glyphToUCS2[buf.get() & 0xff] = upper.charAt(i - 127);
+
+      /* Glyph 0 is always the undefined character, which has
+       * no codepoint in Unicode.
+       */
+      glyphToUCS2[0] = 0;
+    }
+
+
+    /**
+     * Determines the glyph index for a given Unicode codepoint.
+     *
+     * @param ucs4 the Unicode codepoint in UCS-4 encoding.
+     *
+     * @return the glyph index, or 0 if the font does not contain
+     * a glyph for this codepoint.
+     */
+    public int getGlyph(int ucs4)
+    {
+      /* This linear search is not exactly super fast. However,
+       * only really ancient fonts have only a type 0 cmap,
+       * so it should not hurt in very many cases. If it shows
+       * to be a performance problem, one could do a binary search
+       * on a 256-entry table sorted by Unicode codepoint. The
+       * matching index of that table could then be used to look
+       * up the glyph ID at that position.
+       */
+      for (int i = 0; i < 256; i++)
+        if (glyphToUCS2[i] == ucs4)
+          return i;
+      return 0;
+    }
+
+
+    /**
+     * Returns a String whose <code>charAt(i)</code> is the Unicode
+     * character that corresponds to the codepoint <code>i +
+     * 127</code> in the encoding specified by the platform, script
+     * and language tag of a Type 0 CMAP.
+     *
+     * @param language the language tag in the cmap subtable.  For the
+     * Macintosh platform, this is 0 to indicate language-neutral
+     * encoding, or the MacOS language code <i>plus one.</i> The
+     * Apple documentation does not mention that one needs to be
+     * added, but the Adobe OpenType specification does.
+     *
+     * @return a String for mapping the top 129 characters to
+     * UCS-2. If <code>platform</code> is not <code>1</code>
+     * (indicating Macintosh), or if the combination of
+     * <code>script</code> and <code>language</code> is not
+     * recognized, <code>null</code> will be returned.
+     */
+    private static String getUpper129(int platform, int script, int language)
+    {
+      if (platform != PLATFORM_MACINTOSH)
+        return null;
+
+      switch (script)
+      {
+      case 0: /* smRoman */
+        if (language == /* langIcelandic+1 */ 16)
+          return UPPER_ICELANDIC;
+        else if (language == /* langTurkish+1 */ 18)
+          return UPPER_TURKISH;
+        else if (language == /* langCroatian+1 */ 19)
+          return UPPER_CROATIAN;
+        else if (language == /* langRomanian+1 */ 38)
+          return UPPER_ROMANIAN;
+        else if (language == /* language-neutral */ 0)
+          return UPPER_ROMAN;
+        else
+          return null;
+
+      case 4: /* smArabic */
+        if (language == /* langFarsi+1 */ 32)
+          return UPPER_FARSI;
+        else
+          return UPPER_ARABIC;
+
+      case 5: /* smHebrew */
+        return UPPER_HEBREW;
+
+      case 6: /* smGreek */
+        return UPPER_GREEK;
+
+      case 7: /* smCyrillic */
+        return UPPER_CYRILLIC;
+
+      case 29: /* smSlavic == smEastEurRoman */
+        return UPPER_EAST_EUROPEAN_ROMAN;
+      }
+
+      return null;
+    }
+  }
+  
+
+  /**
+   * A mapping from Unicode code points to glyph IDs through CMAP Type
+   * 4 tables. These tables are able to map two-byte encoded text
+   * to glyph IDs, such as Unicode Basic Multilingual Plane which
+   * contains U+0000 .. U+FFFE without surrogates.
+   *
+   * @author Sascha Brawer (brawer at dandelis.ch)
+   */
+  private static final class Type4
+    extends CharGlyphMap
+  {
+    /**
+     * Determines whether this implementation supports a combination
+     * of platform, language and encoding is supported for a type 4
+     * <code>cmap</code> table.
+     *
+     * <p>Currently, we support the following combinations:
+     *
+     * <ul><li>the Unicode platform in encodings 0, 1, 2, 3 and
+     * 4;</li>
+     *
+     * <li>the Microsoft platform in encodings 1 (Basic Multilingual
+     * Plane) and 10 (full Unicode).</li></ul>
+     *
+     * <p>Most recent Macintosh fonts provide a type 4
+     * <code>cmap</code> for Unicode. Microsoft recommends providing a
+     * type 4 <code>cmap</code> for encoding 1 of the Microsoft
+     * platform. The implementation of GNU Classpath supports both
+     * variants.
+     *
+     * <p>Not supported are ShiftJIS, Big5, Wansung, Johab, and other
+     * non-Unicode encodings. Text can easily be converted to Unicode
+     * using the java.nio.charset package.
+     */
+    static boolean isSupported(int platform, int language, int encoding)
+    {
+      switch (platform)
+      {
+      case PLATFORM_UNICODE:
+        return (encoding >= 0) && (encoding <= 4);
+
+      case PLATFORM_MICROSOFT:
+        return (encoding == /* Basic Multilingual Plane */ 1)
+          || (encoding == /* Full Unicode */ 10);
+      }
+
+      return false;
+    }
+
+
+    /**
+     * Processes a CMAP Type 4 table whose platform, encoding and
+     * language are already known. We understand the Unicode platform
+     * with encodings 0, 1, 2, 3 and 4, and the Microsoft platform
+     * with encodings 1 (Unicode BMP) and 10 (UCS-4).
+     *
+     * @param buf the buffer to read the table from, positioned at
+     * its beginning.
+     *
+     * @return a Type4 table, or <code>null</code> if the combination
+     * of platform and encoding is not understood.
+     */
+    static Type4 readTable(ByteBuffer buf,
+                           int platform, int encoding)
+    {
+      int tableStart = buf.position();
+      char format = buf.getChar();
+      int length = buf.getChar();
+      int language = buf.getChar();
+
+      if ((format != 4) || !isSupported(platform, language, encoding))
+        throw new IllegalArgumentException();
+
+      buf.limit(tableStart + length);
+
+      int segCountX2 = buf.getChar();
+      int segCount = segCountX2 / 2;
+      int searchRange = buf.getChar();
+      int entrySelector = buf.getChar();
+      int rangeShift = buf.getChar();
+
+      CharBuffer endCode, startCode, idRangeOffset_glyphID;
+      ShortBuffer idDelta;
+
+      int pos = buf.position();
+      endCode = buf.asCharBuffer();
+      pos += segCountX2 + /* reservedPad */ 2;
+
+      buf.position(pos);
+      startCode = buf.asCharBuffer();
+      pos += segCountX2;
+
+      buf.position(pos);
+      idDelta = buf.asShortBuffer();
+      pos += segCountX2;
+
+      buf.position(pos);
+      idRangeOffset_glyphID = buf.asCharBuffer();
+      
+      endCode.limit(segCount);
+      startCode.limit(segCount);
+      idDelta.limit(segCount);
+      idRangeOffset_glyphID.limit((buf.limit() - pos) / 2);
+
+      return new Type4(segCount,
+                       endCode, startCode, idDelta,
+                       idRangeOffset_glyphID);
+    }
+
+
+    private CharBuffer lastChar;
+    private CharBuffer firstChar;
+    private ShortBuffer idDelta;
+    private CharBuffer rangeID;
+    private int numSegments;
+
+    private Type4(int numSegments,
+                  CharBuffer lastChar, CharBuffer firstChar,
+                  ShortBuffer idDelta, CharBuffer rangeID)
+    {
+      this.numSegments = numSegments;
+      this.lastChar = lastChar;
+      this.firstChar = firstChar;
+      this.idDelta = idDelta;
+      this.rangeID = rangeID;
+    }
+
+
+    /**
+     * Determines the glyph index for a given Unicode codepoint.
+     *
+     * @param ucs4 the Unicode codepoint in UCS-4 encoding.
+     *
+     * @return the glyph index, or 0 if the font does not contain
+     * a glyph for this codepoint.
+     */
+    public int getGlyph(int ucs4)
+    {
+      char c, segStart;
+      int segment, idRangeOffset;
+
+      if (ucs4 > 0xffff)
+        return 0;
+
+      c = (char) ucs4;
+      segment = find(c);
+      segStart = firstChar.get(segment);
+      if ((c < segStart) || (c > lastChar.get(segment)))
+        return 0;
+      
+      /*
+       *      System.out.println("seg " + segment
+       *                 + ", range=" + (int) rangeID[segment]
+       *                 + ", delta=" + delta[segment]);
+       */
+
+      idRangeOffset = rangeID.get(segment);
+      if (idRangeOffset == 0)
+        return (int) (char) (((int) c) + idDelta.get(segment));
+      int result = rangeID.get((idRangeOffset >> 1)
+                               + (c - segStart) + segment);
+      if (result == 0)
+        return 0;
+      return (int) (char) (result + idDelta.get(segment));
+    }
+
+
+    private int find(char c)
+    {
+      int min, max, mid;
+
+      min = 0;
+      max = numSegments - 1;
+      mid = max >> 1;
+
+      while (min < max)
+      {
+        // System.out.println("(" + min + "," + max + ") " + mid);
+        char val = lastChar.get(mid);
+        if (val == c)
+          break;
+        else if (val < c)
+          min = mid + 1;
+        else if (val > c)
+          max = mid;
+        mid = (min + max) >> 1;
+      }
+
+      return mid;
+    }
+  }
+
+
+  /**
+   * A mapping from Unicode code points to glyph IDs through CMAP Type
+   * 12 tables. These tables are able to map four-byte encoded text
+   * to glyph IDs, such as Unicode UCS-4.
+   *
+   * @author Sascha Brawer (brawer at dandelis.ch)
+   */
+  private static final class Type12
+    extends CharGlyphMap
+  {
+    int numGroups;
+    IntBuffer data;
+    
+    
+    /**
+     * Determines whether this implementation supports a combination
+     * of platform and encoding for a type 12 <code>cmap</code> table.
+     *
+     * <p>Currently, we support the following combinations:
+     *
+     * <ul><li>the Unicode platform in encodings 0, 1, 2, 3 and
+     * 4;</li>
+     *
+     * <li>the Microsoft platform in encodings 1 (Basic Multilingual
+     * Plane) and 10 (full Unicode).</li></ul>
+     */
+    static boolean isSupported(int platform, int encoding)
+    {
+      switch (platform)
+      {
+      case PLATFORM_UNICODE:
+        return (encoding >= 0) && (encoding <= 4);
+
+      case PLATFORM_MICROSOFT:
+        return (encoding == /* Basic Multilingual Plane */ 1)
+          || (encoding == /* Full Unicode */ 10);
+      }
+
+      return false;
+    }
+
+
+    /**
+     * Constructs a <code>cmap</code> type 12 table whose platform and
+     * encoding are already known. We understand the Unicode platform
+     * with encodings 0, 1, 2, 3 and 4, and the Microsoft platform
+     * with encodings 1 (Unicode BMP) and 10 (UCS-4).
+     *
+     * @param buf the buffer to read the table from, positioned at
+     * its beginning.
+     */
+    Type12(ByteBuffer buf, int platform, int encoding)
+    {
+      int tableStart = buf.position();
+      int format = buf.getChar();
+      if ((format != 12) || !isSupported(platform, encoding))
+        throw new IllegalStateException();
+
+      buf.getChar(); // skip reserved field
+      buf.limit(tableStart + buf.getInt());
+      int language = buf.getInt();
+      numGroups = buf.getInt();
+      data = buf.asIntBuffer();
+    }
+    
+    
+    /**
+     * Determines the glyph index for a given Unicode codepoint.  Users
+     * should be aware that the character-to-glyph mapping not not
+     * everything that is needed for full Unicode support.  For example,
+     * the <code>cmap</code> table is not able to synthesize accented
+     * glyphs from the canonical decomposition sequence, even if the
+     * font would contain a glyph for the composed form.
+     *
+     * @param ucs4 the Unicode codepoint in UCS-4 encoding. Surrogates
+     * (U+D800 to U+DFFF) cannot be passed, they must be mapped to
+     * UCS-4 first.
+     *
+     * @return the glyph index, or 0 if the font does not contain
+     * a glyph for this codepoint.
+     */
+    public int getGlyph(int ucs4)
+    {
+      int min, max, mid, startCharCode, endCharCode;
+
+      min = 0;
+      max = numGroups - 1;
+      mid = max >> 1;
+      do
+      {
+        startCharCode = data.get(3 * mid);
+        endCharCode = data.get(3 * mid + 1);
+
+        
+        /*
+        System.out.println("group " + mid + " (U+"
+        + Integer.toHexString(startCharCode)
+        + " .. U+" + Integer.toHexString(endCharCode)
+        + "): glyph " + (int) data.get(mid*3+2));
+        */
+
+        if ((startCharCode <= ucs4)  && (ucs4 <= endCharCode))
+          return ucs4
+            - startCharCode
+            + /* startGlyphID */ data.get(mid * 3 + 2);
+        
+        if (endCharCode < ucs4)
+          min = mid + 1;
+        else
+          max = mid;
+        mid = (min + max) >> 1;
+      }
+      while (min < max);
+
+      startCharCode = data.get(3 * mid);
+      endCharCode = data.get(3 * mid + 1);
+      if ((startCharCode <= ucs4)  && (ucs4 <= endCharCode))
+        return ucs4
+          - startCharCode
+          + /* startGlyphID */ data.get(mid * 3 + 2);
+
+      return 0;
+    }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/GlyphNamer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/GlyphNamer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/GlyphNamer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/GlyphNamer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1133 @@
+/* GlyphNamer.java -- Provides glyph names.
+   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.awt.font.opentype;
+
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+import java.nio.CharBuffer;
+
+
+/**
+ * Provides names for glyphs, which is useful when embedding fonts
+ * in PostScript or PDF documents.
+ *
+ * <p>If the font has a <code>Zapf</code> table, it is used to map
+ * glyph IDs back to a sequence of Unicode codepoints, which then
+ * makes it possible to look up or synthesize a PostScript glyph name
+ * according to Adobe&#x2019;s conventions. This allows to extract the
+ * original text from the generated PDF or PostScript file, which is
+ * important for indexing, searching and extracting.
+ *
+ * <p>Otherwise, glyph names are taken from the <a href=
+ * "http://developer.apple.com/fonts/TTRefMan/RM06/Chap6post.html"
+ * ><code>post</code> table</a>. All known formats (1, 2, 2.5, 3 and
+ * 4) are supported.
+ *
+ * <p><b>Open Tasks:</b> The code could be cleaner structured by
+ * having separate sub-classes for each variant of the POST table.
+ * Also, the implementation should not read in all glyph names if a
+ * font provides them in a POST table of type 2. It would be
+ * sufficient to just read in the offsets and delay the String
+ * fetching and conversion to the time when the glyph name is actually
+ * requested.
+ *
+ * <p><b>Lack of Thread Safety:</b> The GlyphNamer class is
+ * intentionally <i>not</i> safe to access from multiple concurrent
+ * threads. Synchronization needs to be performed externally. Usually,
+ * the font has already obtained a lock before calling the GlyphNamer.
+ * It would thus be wasteful to acquire additional locks for the
+ * GlyphNamer.
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+final class GlyphNamer
+{
+  /**
+   * The 'post' table of the font.
+   */
+  private ByteBuffer postTable;
+
+
+  /**
+   * The 'Zapf' table of the font, or null if the font has no
+   * such table.
+   */
+  private ByteBuffer zapfTable;
+
+
+  /**
+   * The offset of each glyph relative to the Zapf table,
+   * or null if the font does not have a Zapf table.
+   */
+  private IntBuffer zapfOffsets;
+
+
+  /**
+   * The offset from the start of the Zapf table to the start
+   * of the extra info area.
+   */
+  private int zapfExtraInfo;
+
+
+  /**
+   * The format of the post table, a Fixed 16.16 number.
+   */
+  private int postFormat;
+
+
+  /**
+   * An array of glyph names. Used for table formats 1, 2, 2.5.
+   */
+  private String[] glyphNames;
+
+
+  /**
+   * An array from glyph to character codes. Similar to the
+   * workings of a Zapf table, but maps to CID instead of
+   * Unicode. Used for table format 4.
+   */
+  private CharBuffer glyphCharacterCodes;
+
+
+  /**
+   * The PostScript names of the 258 standard Macintosh glyphs.  Note
+   * that some of these glyphs are not in the Adobe Standard Glyph
+   * List for New Fonts, namely .notdef, .null, nonmarkingreturn,
+   * nonbreakingspace, apple, onesuperior, twosuperior, and
+   * threesuperior.
+   */
+  private static final String[] STANDARD_POSTSCRIPT_GLYPH_NAMES =
+  {
+    ".notdef",               // glyph #0
+    ".null",                 // glyph #1
+    "nonmarkingreturn",      // glyph #2
+    "space",                 // glyph #3
+    "exclam",                // glyph #4
+    "quotedbl",              // glyph #5
+    "numbersign",            // glyph #6
+    "dollar",                // glyph #7
+    "percent",               // glyph #8
+    "ampersand",             // glyph #9
+    "quotesingle",           // glyph #10
+    "parenleft",             // glyph #11
+    "parenright",            // glyph #12
+    "asterisk",              // glyph #13
+    "plus",                  // glyph #14
+    "comma",                 // glyph #15
+    "hyphen",                // glyph #16
+    "period",                // glyph #17
+    "slash",                 // glyph #18
+    "zero",                  // glyph #19
+    "one",                   // glyph #20
+    "two",                   // glyph #21
+    "three",                 // glyph #22
+    "four",                  // glyph #23
+    "five",                  // glyph #24
+    "six",                   // glyph #25
+    "seven",                 // glyph #26
+    "eight",                 // glyph #27
+    "nine",                  // glyph #28
+    "colon",                 // glyph #29
+    "semicolon",             // glyph #30
+    "less",                  // glyph #31
+    "equal",                 // glyph #32
+    "greater",               // glyph #33
+    "question",              // glyph #34
+    "at",                    // glyph #35
+    "A",                     // glyph #36
+    "B",                     // glyph #37
+    "C",                     // glyph #38
+    "D",                     // glyph #39
+    "E",                     // glyph #40
+    "F",                     // glyph #41
+    "G",                     // glyph #42
+    "H",                     // glyph #43
+    "I",                     // glyph #44
+    "J",                     // glyph #45
+    "K",                     // glyph #46
+    "L",                     // glyph #47
+    "M",                     // glyph #48
+    "N",                     // glyph #49
+    "O",                     // glyph #50
+    "P",                     // glyph #51
+    "Q",                     // glyph #52
+    "R",                     // glyph #53
+    "S",                     // glyph #54
+    "T",                     // glyph #55
+    "U",                     // glyph #56
+    "V",                     // glyph #57
+    "W",                     // glyph #58
+    "X",                     // glyph #59
+    "Y",                     // glyph #60
+    "Z",                     // glyph #61
+    "bracketleft",           // glyph #62
+    "backslash",             // glyph #63
+    "bracketright",          // glyph #64
+    "asciicircum",           // glyph #65
+    "underscore",            // glyph #66
+    "grave",                 // glyph #67
+    "a",                     // glyph #68
+    "b",                     // glyph #69
+    "c",                     // glyph #70
+    "d",                     // glyph #71
+    "e",                     // glyph #72
+    "f",                     // glyph #73
+    "g",                     // glyph #74
+    "h",                     // glyph #75
+    "i",                     // glyph #76
+    "j",                     // glyph #77
+    "k",                     // glyph #78
+    "l",                     // glyph #79
+    "m",                     // glyph #80
+    "n",                     // glyph #81
+    "o",                     // glyph #82
+    "p",                     // glyph #83
+    "q",                     // glyph #84
+    "r",                     // glyph #85
+    "s",                     // glyph #86
+    "t",                     // glyph #87
+    "u",                     // glyph #88
+    "v",                     // glyph #89
+    "w",                     // glyph #90
+    "x",                     // glyph #91
+    "y",                     // glyph #92
+    "z",                     // glyph #93
+    "braceleft",             // glyph #94
+    "bar",                   // glyph #95
+    "braceright",            // glyph #96
+    "asciitilde",            // glyph #97
+    "Adieresis",             // glyph #98
+    "Aring",                 // glyph #99
+    "Ccedilla",              // glyph #100
+    "Eacute",                // glyph #101
+    "Ntilde",                // glyph #102
+    "Odieresis",             // glyph #103
+    "Udieresis",             // glyph #104
+    "aacute",                // glyph #105
+    "agrave",                // glyph #106
+    "acircumflex",           // glyph #107
+    "adieresis",             // glyph #108
+    "atilde",                // glyph #109
+    "aring",                 // glyph #110
+    "ccedilla",              // glyph #111
+    "eacute",                // glyph #112
+    "egrave",                // glyph #113
+    "ecircumflex",           // glyph #114
+    "edieresis",             // glyph #115
+    "iacute",                // glyph #116
+    "igrave",                // glyph #117
+    "icircumflex",           // glyph #118
+    "idieresis",             // glyph #119
+    "ntilde",                // glyph #120
+    "oacute",                // glyph #121
+    "ograve",                // glyph #122
+    "ocircumflex",           // glyph #123
+    "odieresis",             // glyph #124
+    "otilde",                // glyph #125
+    "uacute",                // glyph #126
+    "ugrave",                // glyph #127
+    "ucircumflex",           // glyph #128
+    "udieresis",             // glyph #129
+    "dagger",                // glyph #130
+    "degree",                // glyph #131
+    "cent",                  // glyph #132
+    "sterling",              // glyph #133
+    "section",               // glyph #134
+    "bullet",                // glyph #135
+    "paragraph",             // glyph #136
+    "germandbls",            // glyph #137
+    "registered",            // glyph #138
+    "copyright",             // glyph #139
+    "trademark",             // glyph #140
+    "acute",                 // glyph #141
+    "dieresis",              // glyph #142
+    "notequal",              // glyph #143
+    "AE",                    // glyph #144
+    "Oslash",                // glyph #145
+    "infinity",              // glyph #146
+    "plusminus",             // glyph #147
+    "lessequal",             // glyph #148
+    "greaterequal",          // glyph #149
+    "yen",                   // glyph #150
+    "mu",                    // glyph #151
+    "partialdiff",           // glyph #152
+    "summation",             // glyph #153
+    "product",               // glyph #154
+    "pi",                    // glyph #155
+    "integral",              // glyph #156
+    "ordfeminine",           // glyph #157
+    "ordmasculine",          // glyph #158
+    "Omega",                 // glyph #159
+    "ae",                    // glyph #160
+    "oslash",                // glyph #161
+    "questiondown",          // glyph #162
+    "exclamdown",            // glyph #163
+    "logicalnot",            // glyph #164
+    "radical",               // glyph #165
+    "florin",                // glyph #166
+    "approxequal",           // glyph #167
+    "Delta",                 // glyph #168
+    "guillemotleft",         // glyph #169
+    "guillemotright",        // glyph #170
+    "ellipsis",              // glyph #171
+    "nonbreakingspace",      // glyph #172
+    "Agrave",                // glyph #173
+    "Atilde",                // glyph #174
+    "Otilde",                // glyph #175
+    "OE",                    // glyph #176
+    "oe",                    // glyph #177
+    "endash",                // glyph #178
+    "emdash",                // glyph #179
+    "quotedblleft",          // glyph #180
+    "quotedblright",         // glyph #181
+    "quoteleft",             // glyph #182
+    "quoteright",            // glyph #183
+    "divide",                // glyph #184
+    "lozenge",               // glyph #185
+    "ydieresis",             // glyph #186
+    "Ydieresis",             // glyph #187
+    "fraction",              // glyph #188
+    "currency",              // glyph #189
+    "guilsinglleft",         // glyph #190
+    "guilsinglright",        // glyph #191
+    "fi",                    // glyph #192
+    "fl",                    // glyph #193
+    "daggerdbl",             // glyph #194
+    "periodcentered",        // glyph #195
+    "quotesinglbase",        // glyph #196
+    "quotedblbase",          // glyph #197
+    "perthousand",           // glyph #198
+    "Acircumflex",           // glyph #199
+    "Ecircumflex",           // glyph #200
+    "Aacute",                // glyph #201
+    "Edieresis",             // glyph #202
+    "Egrave",                // glyph #203
+    "Iacute",                // glyph #204
+    "Icircumflex",           // glyph #205
+    "Idieresis",             // glyph #206
+    "Igrave",                // glyph #207
+    "Oacute",                // glyph #208
+    "Ocircumflex",           // glyph #209
+    "apple",                 // glyph #210
+    "Ograve",                // glyph #211
+    "Uacute",                // glyph #212
+    "Ucircumflex",           // glyph #213
+    "Ugrave",                // glyph #214
+    "dotlessi",              // glyph #215
+    "circumflex",            // glyph #216
+    "tilde",                 // glyph #217
+    "macron",                // glyph #218
+    "breve",                 // glyph #219
+    "dotaccent",             // glyph #220
+    "ring",                  // glyph #221
+    "cedilla",               // glyph #222
+    "hungarumlaut",          // glyph #223
+    "ogonek",                // glyph #224
+    "caron",                 // glyph #225
+    "Lslash",                // glyph #226
+    "lslash",                // glyph #227
+    "Scaron",                // glyph #228
+    "scaron",                // glyph #229
+    "Zcaron",                // glyph #230
+    "zcaron",                // glyph #231
+    "brokenbar",             // glyph #232
+    "Eth",                   // glyph #233
+    "eth",                   // glyph #234
+    "Yacute",                // glyph #235
+    "yacute",                // glyph #236
+    "Thorn",                 // glyph #237
+    "thorn",                 // glyph #238
+    "minus",                 // glyph #239
+    "multiply",              // glyph #240
+    "onesuperior",           // glyph #241
+    "twosuperior",           // glyph #242
+    "threesuperior",         // glyph #243
+    "onehalf",               // glyph #244
+    "onequarter",            // glyph #245
+    "threequarters",         // glyph #246
+    "franc",                 // glyph #247
+    "Gbreve",                // glyph #248
+    "gbreve",                // glyph #249
+    "Idotaccent",            // glyph #250
+    "Scedilla",              // glyph #251
+    "scedilla",              // glyph #252
+    "Cacute",                // glyph #253
+    "cacute",                // glyph #254
+    "Ccaron",                // glyph #255
+    "ccaron",                // glyph #256
+    "dcroat"                 // glyph #257
+  };
+
+
+  private GlyphNamer(int numGlyphs,
+                     ByteBuffer postTable,
+                     ByteBuffer zapfTable)
+  {
+    this.postTable = postTable;
+    this.zapfTable = zapfTable;
+
+    if ((zapfTable != null) && (zapfTable.getInt(0) == 0x00010000))
+    {
+      readZapf(numGlyphs);
+      return;
+    }
+
+    readPost();
+  }
+  
+
+  /**
+   * Sets up the information which allows to retrieve the information
+   * on demand.
+   *
+   * @param numGlyphs the number of glyphs in the font. This value
+   * comes from the <code>maxp</code> table.
+   */
+  public static GlyphNamer forTables(int numGlyphs,
+                                     ByteBuffer postTable,
+                                     ByteBuffer zapfTable)
+  {
+    return new GlyphNamer(numGlyphs, postTable, zapfTable);
+  }
+
+
+  /**
+   * Retrieves or synthesizes a PostScript name for the glyph.
+   * Although the code is reasonably fast, it is recommended
+   * to cache the results in the printer driver.
+   *
+   * <p>If a font provides a 'Zapf' table, the reverse mapping
+   * from glyph to UTF-16 sequence is performed, and a glyph
+   * name is synthesized following the recommendations by Adobe.
+   * This allows to extract the original text from the generated
+   * PostScript or PDF, which is a requirement for indexing
+   * and searching.
+   *
+   * <p>If a font does not provide a 'Zapf' table, the glyph name
+   * is taken from the 'post' table. Note that some fonts have
+   * wrong data in their post data, in which case the resulting
+   * name will be garbage. Usually, this does not hurt, unless
+   * the user wants to extract text from the generated PostScript
+   * or PDF file. The GNU implementation understands all known
+   * formats of the post table (1, 2, 2.5, 3 and 4).
+   *
+   * @param glyph the index of the glyph whose name is to be
+   * retrieved.
+   *
+   * @return the glyph name, such as <code>A</code>,
+   * <code>gcircumflex</code>, <code>z_uni0302</code>, or
+   * <code>u11C42</code>.</li>
+   */
+  String getGlyphName(int glyph)
+  {
+    if (zapfOffsets != null)
+    {
+      zapfTable.position(zapfOffsets.get(glyph) + 8);
+      int numChars = zapfTable.getChar();
+      char[] chars = new char[numChars];
+      for (int i = 0; i < numChars; i++)
+        chars[i] = zapfTable.getChar();
+      return getGlyphName(chars);
+    }
+
+
+    /* Type 1, Type 2, Type 2.5 */
+    if (glyphNames != null)
+      return glyphNames[glyph];
+
+    /* Type 4: Synthesized glyph name. */
+    if (glyphCharacterCodes != null)
+      return "a" + glyphCharacterCodes.get(glyph);
+
+    /* Type 3: Arbitrary, but unique name for the glyph.
+     *
+     * To find out what a good naming scheme would be, we have printed
+     * a document containing the character U+201C in the font
+     * "Hiragino Kaku Gothic Pro W3" (by Dainippon Screen Mfg. Co.,
+     * Ltd.) on Apple MacOS X 10.1.5.  This font has a type 3 'post'
+     * table, and its 'cmap' maps U+201C to glyph #108. The generated
+     * PostScript file defined a character whose name was "g108".
+     *
+     * Therefore, we use 'g' as name prefix. According to the
+     * TrueType/OpenType specification, it should not matter what
+     * prefix we use. On the other hand, it does not hurt either to be
+     * compatible with a good printer driver.
+     *
+     * Actually, that specific font also contains a 'Zapf' table,
+     * which allows to generate glyph names according to Adobe's
+     * conventions, so that extracting text from and searching in the
+     * generated PostScript or PDF becomes possible. While the Apple
+     * PostScript printer driver does not seem to use the 'Zapf' table
+     * for this purpose, we do.
+     */
+    return "g" + glyph;
+  }
+
+
+  /**
+   * Sets up some buffers which allow to quickly read information from
+   * the Zapf table.
+   *
+   * @see <a href=
+   *      "http://developer.apple.com/fonts/TTRefMan/RM06/Chap6Zapf.html">
+   *      Apple&#x2019;s documentation of the <code>Zapf</code> table</a>
+   */
+  private void readZapf(int numGlyphs)
+  {
+    zapfExtraInfo = zapfTable.getInt(4);
+    zapfTable.position(8);
+    zapfOffsets = zapfTable.asIntBuffer();
+    zapfOffsets.limit(numGlyphs);
+  }
+
+
+  /**
+   * Reads in the PostScript data from a <code>post</code> table of a
+   * TrueType or OpenType font. The implementation currently
+   * understands the table formats 1, 2, 2.5, 3, and 4.
+   */
+  private void readPost()
+  {
+    int numGlyphs, nameIndex, maxNameIndex;
+    char[] nameIndices;
+    String[] names;
+    byte[] pascalName;
+
+    postTable.position(0);
+    postFormat = postTable.getInt();
+    switch (postFormat)
+    {
+    case 0x00010000:
+      glyphNames = STANDARD_POSTSCRIPT_GLYPH_NAMES;
+      return;
+
+    case 0x00020000:
+      postTable.position(32);
+      numGlyphs = postTable.getChar();
+      glyphNames = new String[numGlyphs];
+      pascalName = new byte[255];
+      nameIndices = new char[numGlyphs];
+      maxNameIndex = 0;
+      for (int i = 0; i < numGlyphs; i++)
+        maxNameIndex = Math.max(maxNameIndex,
+                                nameIndices[i] = postTable.getChar());
+
+      names = new String[Math.max(maxNameIndex - 258 + 1, 0)];
+      for (int i = 258; i <= maxNameIndex; i++)
+      {
+        int nameLen = (postTable.get() & 0xff);
+        postTable.get(pascalName, 0, nameLen);
+        names[i - 258] = new String(pascalName, 0, nameLen);
+      }
+      for (int i = 0; i < numGlyphs; i++)
+      {
+        nameIndex = nameIndices[i];
+        if (nameIndex < 258)
+          glyphNames[i] = STANDARD_POSTSCRIPT_GLYPH_NAMES[nameIndex];
+        else
+          glyphNames[i] = names[nameIndex - 258];
+      }
+      return;
+
+    case 0x00025000: // in case some font has a wrong representation of 2.5
+    case 0x00028000:
+      /* Format 2.5 is a re-ordering of the standard names. It has
+       * been deprecated in February 2000, but might still occasionally
+       * float around. Since it can be supported with so little code,
+       * we do so.
+       */
+      postTable.position(32);
+      numGlyphs = postTable.getChar();
+      glyphNames = new String[numGlyphs];
+      for (int i = 0; i < numGlyphs; i++)
+        glyphNames[i] = STANDARD_POSTSCRIPT_GLYPH_NAMES[i + postTable.get()];
+      return;
+
+    case 0x00030000:
+      /* Format 3 leaves it to the printer driver to choose whatever
+       * name it wants to.
+       */
+      return;
+
+    case 0x00040000:
+      /* Format 4 is used by Apple for composite fonts that have
+       * synthetic glyph names. The name of a glyph is "a" plus
+       * the integer (in decimal notation) that follows the table
+       * after numGlyphs.
+       */
+      postTable.position(32);
+      numGlyphs = postTable.getChar();
+      glyphCharacterCodes = postTable.asCharBuffer();
+      glyphCharacterCodes.limit(numGlyphs);
+      return;
+    }
+  }
+
+
+
+  /* For generating the following tables, a quick-and-dirty Python
+   * script was used. It is unlikely that we ever need to run it
+   * again, but for information and convenient access, it is included
+   * below. Initial '#' characters need to be removed from the generated
+   * strings, they are present so that the lines not break in the middle
+   * of Java escape sequences (no, this is not very clean).
+   *
+   * import string
+   *
+   * javaEscapes = {0x22:'\\"', 0x5c:'\\\\'}
+   * def escape(c):
+   *     if javaEscapes.has_key(c):
+   *         return javaEscapes[c]
+   *     elif 0x20 <= c <= 0x7e:
+   *         return chr(c)
+   *     else:
+   *         return '\\u%04x' % c
+   *
+   * def dump(name, s, stride):
+   *     s = ('#' * stride) + s
+   *     print "  private static final String %s" % name
+   *     for i in range(0, len(s), 60):
+   *         print '    + "%s"' % s[i:i+60]
+   *     
+   * glyphs = {}
+   * for line in open('aglfn13.txt', 'r').readlines():
+   *     if line[0] == '#': continue
+   *     [ucs, glyphName, desc] = line.split(';')
+   *     glyph = int('0x' + ucs, 0)
+   *     assert (not glyphs.has_key(glyph)) or (glyphs[glyph] == glyphName)
+   *     glyphs[glyph] = glyphName
+   * del glyphs[0] # arrowvertex
+   * k = glyphs.keys()
+   * k.sort()
+   * numGlyphs = len(k)
+   * names = ''
+   * pos = []
+   * for glyph in k:
+   *     pos.append(len(names) + 1)
+   *     names = names + '/' + glyphs[glyph]
+   * dump('AGLFN_GLYPHS', string.join(map(escape, k), ''), 5)
+   * dump('AGLFN_NAME_OFFSET', string.join(map(escape, pos), ''), 4)
+   * dump('AGLFN_NAMES', names + '/', 0)
+   */
+
+
+  /**
+   * A String that contains the Unicode codepoint for each glyph
+   * in the Adobe Glyph List. The characters are in sorted order.
+   *
+   * Generated from the Adobe Glyph List for New Fonts, version 1.1
+   * of 17 April 2003.
+   *
+   * @see <a href=
+   * "http://partners.adobe.com/asn/tech/type/aglfn13.txt" >Adobe
+   * Glyph List for New Fonts</a>
+   */
+  private static final String AGLFN_GLYPHS
+    = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTU"
+    + "VWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u00a1\u00a2\u00a3"
+    + "\u00a4\u00a5\u00a6\u00a7\u00a8\u00a9\u00aa\u00ab\u00ac\u00ae"
+    + "\u00af\u00b0\u00b1\u00b4\u00b5\u00b6\u00b7\u00b8\u00ba\u00bb"
+    + "\u00bc\u00bd\u00be\u00bf\u00c0\u00c1\u00c2\u00c3\u00c4\u00c5"
+    + "\u00c6\u00c7\u00c8\u00c9\u00ca\u00cb\u00cc\u00cd\u00ce\u00cf"
+    + "\u00d0\u00d1\u00d2\u00d3\u00d4\u00d5\u00d6\u00d7\u00d8\u00d9"
+    + "\u00da\u00db\u00dc\u00dd\u00de\u00df\u00e0\u00e1\u00e2\u00e3"
+    + "\u00e4\u00e5\u00e6\u00e7\u00e8\u00e9\u00ea\u00eb\u00ec\u00ed"
+    + "\u00ee\u00ef\u00f0\u00f1\u00f2\u00f3\u00f4\u00f5\u00f6\u00f7"
+    + "\u00f8\u00f9\u00fa\u00fb\u00fc\u00fd\u00fe\u00ff\u0100\u0101"
+    + "\u0102\u0103\u0104\u0105\u0106\u0107\u0108\u0109\u010a\u010b"
+    + "\u010c\u010d\u010e\u010f\u0110\u0111\u0112\u0113\u0114\u0115"
+    + "\u0116\u0117\u0118\u0119\u011a\u011b\u011c\u011d\u011e\u011f"
+    + "\u0120\u0121\u0122\u0123\u0124\u0125\u0126\u0127\u0128\u0129"
+    + "\u012a\u012b\u012c\u012d\u012e\u012f\u0130\u0131\u0132\u0133"
+    + "\u0134\u0135\u0136\u0137\u0138\u0139\u013a\u013b\u013c\u013d"
+    + "\u013e\u013f\u0140\u0141\u0142\u0143\u0144\u0145\u0146\u0147"
+    + "\u0148\u0149\u014a\u014b\u014c\u014d\u014e\u014f\u0150\u0151"
+    + "\u0152\u0153\u0154\u0155\u0156\u0157\u0158\u0159\u015a\u015b"
+    + "\u015c\u015d\u015e\u015f\u0160\u0161\u0162\u0163\u0164\u0165"
+    + "\u0166\u0167\u0168\u0169\u016a\u016b\u016c\u016d\u016e\u016f"
+    + "\u0170\u0171\u0172\u0173\u0174\u0175\u0176\u0177\u0178\u0179"
+    + "\u017a\u017b\u017c\u017d\u017e\u017f\u0192\u01a0\u01a1\u01af"
+    + "\u01b0\u01e6\u01e7\u01fa\u01fb\u01fc\u01fd\u01fe\u01ff\u0218"
+    + "\u0219\u02bc\u02bd\u02c6\u02c7\u02d8\u02d9\u02da\u02db\u02dc"
+    + "\u02dd\u0300\u0301\u0303\u0309\u0323\u0384\u0385\u0386\u0387"
+    + "\u0388\u0389\u038a\u038c\u038e\u038f\u0390\u0391\u0392\u0393"
+    + "\u0395\u0396\u0397\u0398\u0399\u039a\u039b\u039c\u039d\u039e"
+    + "\u039f\u03a0\u03a1\u03a3\u03a4\u03a5\u03a6\u03a7\u03a8\u03aa"
+    + "\u03ab\u03ac\u03ad\u03ae\u03af\u03b0\u03b1\u03b2\u03b3\u03b4"
+    + "\u03b5\u03b6\u03b7\u03b8\u03b9\u03ba\u03bb\u03bd\u03be\u03bf"
+    + "\u03c0\u03c1\u03c2\u03c3\u03c4\u03c5\u03c6\u03c7\u03c8\u03c9"
+    + "\u03ca\u03cb\u03cc\u03cd\u03ce\u03d1\u03d2\u03d5\u03d6\u0401"
+    + "\u0402\u0403\u0404\u0405\u0406\u0407\u0408\u0409\u040a\u040b"
+    + "\u040c\u040e\u040f\u0410\u0411\u0412\u0413\u0414\u0415\u0416"
+    + "\u0417\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f\u0420"
+    + "\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042a"
+    + "\u042b\u042c\u042d\u042e\u042f\u0430\u0431\u0432\u0433\u0434"
+    + "\u0435\u0436\u0437\u0438\u0439\u043a\u043b\u043c\u043d\u043e"
+    + "\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448"
+    + "\u0449\u044a\u044b\u044c\u044d\u044e\u044f\u0451\u0452\u0453"
+    + "\u0454\u0455\u0456\u0457\u0458\u0459\u045a\u045b\u045c\u045e"
+    + "\u045f\u0462\u0463\u0472\u0473\u0474\u0475\u0490\u0491\u04d9"
+    + "\u05b0\u05b1\u05b2\u05b3\u05b4\u05b5\u05b6\u05b7\u05b8\u05b9"
+    + "\u05bb\u05bc\u05bd\u05be\u05bf\u05c0\u05c1\u05c2\u05c3\u05d0"
+    + "\u05d1\u05d2\u05d3\u05d4\u05d5\u05d6\u05d7\u05d8\u05d9\u05da"
+    + "\u05db\u05dc\u05dd\u05de\u05df\u05e0\u05e1\u05e2\u05e3\u05e4"
+    + "\u05e5\u05e6\u05e7\u05e8\u05e9\u05ea\u05f0\u05f1\u05f2\u060c"
+    + "\u061b\u061f\u0621\u0622\u0623\u0624\u0625\u0626\u0627\u0628"
+    + "\u0629\u062a\u062b\u062c\u062d\u062e\u062f\u0630\u0631\u0632"
+    + "\u0633\u0634\u0635\u0636\u0637\u0638\u0639\u063a\u0640\u0641"
+    + "\u0642\u0643\u0644\u0645\u0646\u0647\u0648\u0649\u064a\u064b"
+    + "\u064c\u064d\u064e\u064f\u0650\u0651\u0652\u0660\u0661\u0662"
+    + "\u0663\u0664\u0665\u0666\u0667\u0668\u0669\u066a\u066d\u0679"
+    + "\u067e\u0686\u0688\u0691\u0698\u06a4\u06af\u06ba\u06d2\u06d5"
+    + "\u1e80\u1e81\u1e82\u1e83\u1e84\u1e85\u1ef2\u1ef3\u200c\u200d"
+    + "\u200e\u200f\u2012\u2013\u2014\u2015\u2017\u2018\u2019\u201a"
+    + "\u201b\u201c\u201d\u201e\u2020\u2021\u2022\u2024\u2025\u2026"
+    + "\u202c\u202d\u202e\u2030\u2032\u2033\u2039\u203a\u203c\u2044"
+    + "\u20a1\u20a3\u20a4\u20a7\u20aa\u20ab\u20ac\u2105\u2111\u2113"
+    + "\u2116\u2118\u211c\u211e\u2122\u2126\u212e\u2135\u2153\u2154"
+    + "\u215b\u215c\u215d\u215e\u2190\u2191\u2192\u2193\u2194\u2195"
+    + "\u21a8\u21b5\u21d0\u21d1\u21d2\u21d3\u21d4\u2200\u2202\u2203"
+    + "\u2205\u2206\u2207\u2208\u2209\u220b\u220f\u2211\u2212\u2217"
+    + "\u221a\u221d\u221e\u221f\u2220\u2227\u2228\u2229\u222a\u222b"
+    + "\u2234\u223c\u2245\u2248\u2260\u2261\u2264\u2265\u2282\u2283"
+    + "\u2284\u2286\u2287\u2295\u2297\u22a5\u22c5\u2302\u2310\u2320"
+    + "\u2321\u2329\u232a\u2500\u2502\u250c\u2510\u2514\u2518\u251c"
+    + "\u2524\u252c\u2534\u253c\u2550\u2551\u2552\u2553\u2554\u2555"
+    + "\u2556\u2557\u2558\u2559\u255a\u255b\u255c\u255d\u255e\u255f"
+    + "\u2560\u2561\u2562\u2563\u2564\u2565\u2566\u2567\u2568\u2569"
+    + "\u256a\u256b\u256c\u2580\u2584\u2588\u258c\u2590\u2591\u2592"
+    + "\u2593\u25a0\u25a1\u25aa\u25ab\u25ac\u25b2\u25ba\u25bc\u25c4"
+    + "\u25ca\u25cb\u25cf\u25d8\u25d9\u25e6\u263a\u263b\u263c\u2640"
+    + "\u2642\u2660\u2663\u2665\u2666\u266a\u266b";
+
+
+  /**
+   * The offset of each glyph name in AGLFN_NAMES.
+   *
+   * Generated from the Adobe Glyph List for New Fonts, version 1.1
+   * of 17 April 2003.
+   *
+   * @see <a href=
+   * "http://partners.adobe.com/asn/tech/type/aglfn13.txt" >Adobe
+   * Glyph List for New Fonts</a>
+   */
+  private static final String AGLFN_NAME_OFFSET
+    = "\u0001\u0007\u000e\u0017\")1;GQ\\ejpw~\u0084\u0089\u008d"
+    + "\u0091\u0097\u009c\u00a1\u00a5\u00ab\u00b1\u00b6\u00bc\u00c6"
+    + "\u00cb\u00d1\u00d9\u00e2\u00e5\u00e7\u00e9\u00eb\u00ed\u00ef"
+    + "\u00f1\u00f3\u00f5\u00f7\u00f9\u00fb\u00fd\u00ff\u0101\u0103"
+    + "\u0105\u0107\u0109\u010b\u010d\u010f\u0111\u0113\u0115\u0117"
+    + "\u0119\u0125\u012f\u013c\u0148\u0153\u0159\u015b\u015d\u015f"
+    + "\u0161\u0163\u0165\u0167\u0169\u016b\u016d\u016f\u0171\u0173"
+    + "\u0175\u0177\u0179\u017b\u017d\u017f\u0181\u0183\u0185\u0187"
+    + "\u0189\u018b\u018d\u0197\u019b\u01a6\u01b1\u01bc\u01c1\u01ca"
+    + "\u01d3\u01d7\u01e1\u01e9\u01f2\u01fc\u0208\u0216\u0221\u022c"
+    + "\u0233\u023a\u0244\u024a\u024d\u0257\u0266\u026e\u027b\u028a"
+    + "\u0295\u029d\u02ab\u02b8\u02bf\u02c6\u02d2\u02d9\u02e3\u02e9"
+    + "\u02ec\u02f5\u02fc\u0303\u030f\u0319\u0320\u0327\u0333\u033d"
+    + "\u0341\u0348\u034f\u0356\u0362\u0369\u0373\u037c\u0383\u038a"
+    + "\u0391\u039d\u03a7\u03ae\u03b4\u03bf\u03c6\u03cd\u03d9\u03e0"
+    + "\u03ea\u03f0\u03f3\u03fc\u0403\u040a\u0416\u0420\u0427\u042e"
+    + "\u043a\u0444\u0448\u044f\u0456\u045d\u0469\u0470\u047a\u0481"
+    + "\u0488\u048f\u0496\u04a2\u04ac\u04b3\u04b9\u04c3\u04cb\u04d3"
+    + "\u04da\u04e1\u04e9\u04f1\u04f8\u04ff\u050b\u0517\u0522\u052d"
+    + "\u0534\u053b\u0542\u0549\u0550\u0557\u055f\u0567\u056e\u0575"
+    + "\u0580\u058b\u0593\u059b\u05a2\u05a9\u05b5\u05c1\u05c8\u05cf"
+    + "\u05da\u05e5\u05f2\u05ff\u060b\u0617\u061c\u0621\u0628\u062f"
+    + "\u0637\u063f\u0646\u064d\u0655\u065d\u0668\u0671\u0674\u0677"
+    + "\u0683\u068f\u069c\u06a9\u06b6\u06bd\u06c4\u06d1\u06de\u06e5"
+    + "\u06ec\u06f1\u06f6\u06fd\u0704\u070b\u0712\u071f\u072c\u0733"
+    + "\u073a\u0746\u074a\u074e\u0756\u075e\u0765\u076c\u077a\u0788"
+    + "\u078b\u078e\u0795\u079c\u07a9\u07b6\u07bd\u07c4\u07cb\u07d2"
+    + "\u07de\u07ea\u07f3\u07fc\u0803\u080a\u0817\u0824\u082b\u0832"
+    + "\u0837\u083c\u0843\u084a\u0852\u085a\u0861\u0868\u086e\u0874"
+    + "\u0882\u0890\u0898\u08a0\u08ac\u08b8\u08c4\u08d0\u08da\u08e1"
+    + "\u08e8\u08f3\u08fe\u0905\u090c\u0912\u0919\u091f\u0925\u092b"
+    + "\u0931\u0938\u093f\u094a\u0955\u095d\u0965\u0971\u097d\u098a"
+    + "\u0997\u09a1\u09ab\u09b6\u09bc\u09c2\u09cc\u09d1\u09d8\u09de"
+    + "\u09eb\u09f5\u09ff\u0a09\u0a17\u0a24\u0a2a\u0a38\u0a43\u0a4d"
+    + "\u0a5a\u0a63\u0a6d\u0a7a\u0a87\u0a92\u0aa4\u0aaa\u0aaf\u0ab5"
+    + "\u0abd\u0ac2\u0ac6\u0acc\u0ad1\u0ad7\u0ade\u0ae1\u0ae4\u0ae7"
+    + "\u0aef\u0af2\u0af6\u0afc\u0b00\u0b08\u0b0c\u0b10\u0b14\u0b21"
+    + "\u0b31\u0b3c\u0b49\u0b52\u0b5c\u0b71\u0b77\u0b7c\u0b82\u0b88"
+    + "\u0b90\u0b95\u0b99\u0b9f\u0ba4\u0baa\u0bb1\u0bb4\u0bb7\u0bbf"
+    + "\u0bc2\u0bc6\u0bcd\u0bd3\u0bd7\u0bdf\u0be3\u0be7\u0beb\u0bf1"
+    + "\u0bfe\u0c0e\u0c1b\u0c28\u0c33\u0c3a\u0c43\u0c48\u0c4f\u0c59"
+    + "\u0c63\u0c6d\u0c77\u0c81\u0c8b\u0c95\u0c9f\u0ca9\u0cb3\u0cbd"
+    + "\u0cc7\u0cd1\u0cdb\u0ce5\u0cef\u0cf9\u0d03\u0d0d\u0d17\u0d21"
+    + "\u0d2b\u0d35\u0d3f\u0d49\u0d53\u0d5d\u0d67\u0d71\u0d7b\u0d85"
+    + "\u0d8f\u0d99\u0da3\u0dad\u0db7\u0dc1\u0dcb\u0dd5\u0ddf\u0de9"
+    + "\u0df3\u0dfd\u0e07\u0e11\u0e1b\u0e25\u0e2f\u0e39\u0e43\u0e4d"
+    + "\u0e57\u0e61\u0e6b\u0e75\u0e7f\u0e89\u0e93\u0e9d\u0ea7\u0eb1"
+    + "\u0ebb\u0ec5\u0ecf\u0ed9\u0ee3\u0eed\u0ef7\u0f01\u0f0b\u0f15"
+    + "\u0f1f\u0f29\u0f33\u0f3d\u0f47\u0f51\u0f5b\u0f65\u0f6f\u0f79"
+    + "\u0f83\u0f8d\u0f97\u0fa1\u0fab\u0fb5\u0fbf\u0fc9\u0fd3\u0fdd"
+    + "\u0fe7\u0ff1\u0ffb\u1005\u100f\u1019\u1023\u102d\u1037\u1041"
+    + "\u104b\u1055\u105f\u1069\u1073\u107d\u1087\u1091\u109b\u10a5"
+    + "\u10af\u10b9\u10c3\u10cd\u10d7\u10e1\u10eb\u10f5\u10ff\u1109"
+    + "\u1113\u111d\u1127\u1131\u113b\u1145\u114f\u1159\u1163\u116d"
+    + "\u1177\u1181\u118b\u1195\u119f\u11a9\u11b3\u11bd\u11c7\u11d1"
+    + "\u11db\u11e5\u11ef\u11f9\u1203\u120d\u1217\u1221\u122b\u1235"
+    + "\u123f\u1249\u1253\u125d\u1267\u1271\u127b\u1285\u128f\u1299"
+    + "\u12a3\u12ad\u12b7\u12c1\u12cb\u12d5\u12df\u12e9\u12f3\u12fd"
+    + "\u1307\u1311\u131b\u1325\u132f\u1339\u1343\u134d\u1357\u1361"
+    + "\u136b\u1375\u137f\u1389\u1393\u139d\u13a7\u13b1\u13bb\u13c5"
+    + "\u13cf\u13d9\u13e3\u13ed\u13f7\u1401\u140b\u1415\u141f\u1429"
+    + "\u1433\u143d\u1447\u1451\u145b\u1465\u146f\u1479\u1483\u148d"
+    + "\u1497\u14a1\u14ab\u14b5\u14bf\u14c9\u14d3\u14dd\u14e7\u14f1"
+    + "\u14f8\u14ff\u1506\u150d\u1517\u1521\u1528\u152f\u1539\u1541"
+    + "\u1549\u1551\u155c\u1563\u156a\u1574\u1582\u158c\u1597\u15a6"
+    + "\u15b4\u15c1\u15cf\u15dc\u15e3\u15ed\u15f4\u1603\u1612\u161b"
+    + "\u1625\u162f\u1639\u1645\u164c\u1653\u1661\u1670\u167a\u1683"
+    + "\u1691\u1697\u169c\u16a3\u16ad\u16b2\u16b7\u16c1\u16ca\u16d4"
+    + "\u16de\u16ea\u16f3\u1700\u170a\u1710\u171a\u1720\u1729\u1733"
+    + "\u173d\u174a\u1756\u1763\u176d\u1775\u1780\u178a\u1794\u179e"
+    + "\u17ab\u17ba\u17c7\u17d2\u17e0\u17ed\u17fa\u1804\u1810\u181c"
+    + "\u1825\u182b\u1834\u183c\u1847\u1850\u1858\u1862\u1868\u1875"
+    + "\u187d\u188a\u1893\u189e\u18a4\u18af\u18b9\u18c6\u18cc\u18d5"
+    + "\u18df\u18e7\u18f1\u18fd\u1906\u1912\u191c\u1929\u1936\u1945"
+    + "\u194f\u195c\u196b\u1976\u1985\u1993\u199b\u19a1\u19af\u19ba"
+    + "\u19c5\u19cf\u19da\u19e3\u19ec\u19f5\u19fe\u1a07\u1a10\u1a19"
+    + "\u1a22\u1a2b\u1a34\u1a3d\u1a46\u1a4f\u1a58\u1a61\u1a6a\u1a73"
+    + "\u1a7c\u1a85\u1a8e\u1a97\u1aa0\u1aa9\u1ab2\u1abb\u1ac4\u1acd"
+    + "\u1ad6\u1adf\u1ae8\u1af1\u1afa\u1b03\u1b0c\u1b15\u1b1e\u1b27"
+    + "\u1b30\u1b39\u1b42\u1b4a\u1b52\u1b58\u1b60\u1b68\u1b70\u1b76"
+    + "\u1b7e\u1b88\u1b8f\u1b96\u1b9d\u1ba8\u1bb0\u1bb8\u1bc0\u1bc8"
+    + "\u1bd0\u1bd7\u1bde\u1be8\u1bf2\u1bfd\u1c07\u1c14\u1c18\u1c1f"
+    + "\u1c24\u1c2a\u1c2f\u1c35\u1c3d\u1c49";
+
+
+  /**
+   * The name of each glyph in the Adobe Glyph List for New Fonts
+   * (AGLFN). The name of the n-th glyph starts at position
+   * AGLFN_NAME_OFFSET.charAt(n). It ends before the following
+   * slash (slashes cannot be part of a PostScript name, which
+   * is why we use it for separation).
+   *
+   * <p>Generated from the Adobe Glyph List for New Fonts, version 1.1
+   * of 17 April 2003.
+   *
+   * @see <a href=
+   * "http://partners.adobe.com/asn/tech/type/aglfn13.txt" >Adobe
+   * Glyph List for New Fonts</a>
+   */
+  private static final String AGLFN_NAMES
+    = "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/q"
+    + "uotesingle/parenleft/parenright/asterisk/plus/comma/hyphen/p"
+    + "eriod/slash/zero/one/two/three/four/five/six/seven/eight/nin"
+    + "e/colon/semicolon/less/equal/greater/question/at/A/B/C/D/E/F"
+    + "/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backsla"
+    + "sh/bracketright/asciicircum/underscore/grave/a/b/c/d/e/f/g/h"
+    + "/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/bracerigh"
+    + "t/asciitilde/exclamdown/cent/sterling/currency/yen/brokenbar"
+    + "/section/dieresis/copyright/ordfeminine/guillemotleft/logica"
+    + "lnot/registered/macron/degree/plusminus/acute/mu/paragraph/p"
+    + "eriodcentered/cedilla/ordmasculine/guillemotright/onequarter"
+    + "/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumfle"
+    + "x/Atilde/Adieresis/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumfl"
+    + "ex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis/Eth/Ntilde/"
+    + "Ograve/Oacute/Ocircumflex/Otilde/Odieresis/multiply/Oslash/U"
+    + "grave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls/a"
+    + "grave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/"
+    + "egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumfle"
+    + "x/idieresis/eth/ntilde/ograve/oacute/ocircumflex/otilde/odie"
+    + "resis/divide/oslash/ugrave/uacute/ucircumflex/udieresis/yacu"
+    + "te/thorn/ydieresis/Amacron/amacron/Abreve/abreve/Aogonek/aog"
+    + "onek/Cacute/cacute/Ccircumflex/ccircumflex/Cdotaccent/cdotac"
+    + "cent/Ccaron/ccaron/Dcaron/dcaron/Dcroat/dcroat/Emacron/emacr"
+    + "on/Ebreve/ebreve/Edotaccent/edotaccent/Eogonek/eogonek/Ecaro"
+    + "n/ecaron/Gcircumflex/gcircumflex/Gbreve/gbreve/Gdotaccent/gd"
+    + "otaccent/Gcommaaccent/gcommaaccent/Hcircumflex/hcircumflex/H"
+    + "bar/hbar/Itilde/itilde/Imacron/imacron/Ibreve/ibreve/Iogonek"
+    + "/iogonek/Idotaccent/dotlessi/IJ/ij/Jcircumflex/jcircumflex/K"
+    + "commaaccent/kcommaaccent/kgreenlandic/Lacute/lacute/Lcommaac"
+    + "cent/lcommaaccent/Lcaron/lcaron/Ldot/ldot/Lslash/lslash/Nacu"
+    + "te/nacute/Ncommaaccent/ncommaaccent/Ncaron/ncaron/napostroph"
+    + "e/Eng/eng/Omacron/omacron/Obreve/obreve/Ohungarumlaut/ohunga"
+    + "rumlaut/OE/oe/Racute/racute/Rcommaaccent/rcommaaccent/Rcaron"
+    + "/rcaron/Sacute/sacute/Scircumflex/scircumflex/Scedilla/scedi"
+    + "lla/Scaron/scaron/Tcommaaccent/tcommaaccent/Tcaron/tcaron/Tb"
+    + "ar/tbar/Utilde/utilde/Umacron/umacron/Ubreve/ubreve/Uring/ur"
+    + "ing/Uhungarumlaut/uhungarumlaut/Uogonek/uogonek/Wcircumflex/"
+    + "wcircumflex/Ycircumflex/ycircumflex/Ydieresis/Zacute/zacute/"
+    + "Zdotaccent/zdotaccent/Zcaron/zcaron/longs/florin/Ohorn/ohorn"
+    + "/Uhorn/uhorn/Gcaron/gcaron/Aringacute/aringacute/AEacute/aea"
+    + "cute/Oslashacute/oslashacute/Scommaaccent/scommaaccent/afii5"
+    + "7929/afii64937/circumflex/caron/breve/dotaccent/ring/ogonek/"
+    + "tilde/hungarumlaut/gravecomb/acutecomb/tildecomb/hookaboveco"
+    + "mb/dotbelowcomb/tonos/dieresistonos/Alphatonos/anoteleia/Eps"
+    + "ilontonos/Etatonos/Iotatonos/Omicrontonos/Upsilontonos/Omega"
+    + "tonos/iotadieresistonos/Alpha/Beta/Gamma/Epsilon/Zeta/Eta/Th"
+    + "eta/Iota/Kappa/Lambda/Mu/Nu/Xi/Omicron/Pi/Rho/Sigma/Tau/Upsi"
+    + "lon/Phi/Chi/Psi/Iotadieresis/Upsilondieresis/alphatonos/epsi"
+    + "lontonos/etatonos/iotatonos/upsilondieresistonos/alpha/beta/"
+    + "gamma/delta/epsilon/zeta/eta/theta/iota/kappa/lambda/nu/xi/o"
+    + "micron/pi/rho/sigma1/sigma/tau/upsilon/phi/chi/psi/omega/iot"
+    + "adieresis/upsilondieresis/omicrontonos/upsilontonos/omegaton"
+    + "os/theta1/Upsilon1/phi1/omega1/afii10023/afii10051/afii10052"
+    + "/afii10053/afii10054/afii10055/afii10056/afii10057/afii10058"
+    + "/afii10059/afii10060/afii10061/afii10062/afii10145/afii10017"
+    + "/afii10018/afii10019/afii10020/afii10021/afii10022/afii10024"
+    + "/afii10025/afii10026/afii10027/afii10028/afii10029/afii10030"
+    + "/afii10031/afii10032/afii10033/afii10034/afii10035/afii10036"
+    + "/afii10037/afii10038/afii10039/afii10040/afii10041/afii10042"
+    + "/afii10043/afii10044/afii10045/afii10046/afii10047/afii10048"
+    + "/afii10049/afii10065/afii10066/afii10067/afii10068/afii10069"
+    + "/afii10070/afii10072/afii10073/afii10074/afii10075/afii10076"
+    + "/afii10077/afii10078/afii10079/afii10080/afii10081/afii10082"
+    + "/afii10083/afii10084/afii10085/afii10086/afii10087/afii10088"
+    + "/afii10089/afii10090/afii10091/afii10092/afii10093/afii10094"
+    + "/afii10095/afii10096/afii10097/afii10071/afii10099/afii10100"
+    + "/afii10101/afii10102/afii10103/afii10104/afii10105/afii10106"
+    + "/afii10107/afii10108/afii10109/afii10110/afii10193/afii10146"
+    + "/afii10194/afii10147/afii10195/afii10148/afii10196/afii10050"
+    + "/afii10098/afii10846/afii57799/afii57801/afii57800/afii57802"
+    + "/afii57793/afii57794/afii57795/afii57798/afii57797/afii57806"
+    + "/afii57796/afii57807/afii57839/afii57645/afii57841/afii57842"
+    + "/afii57804/afii57803/afii57658/afii57664/afii57665/afii57666"
+    + "/afii57667/afii57668/afii57669/afii57670/afii57671/afii57672"
+    + "/afii57673/afii57674/afii57675/afii57676/afii57677/afii57678"
+    + "/afii57679/afii57680/afii57681/afii57682/afii57683/afii57684"
+    + "/afii57685/afii57686/afii57687/afii57688/afii57689/afii57690"
+    + "/afii57716/afii57717/afii57718/afii57388/afii57403/afii57407"
+    + "/afii57409/afii57410/afii57411/afii57412/afii57413/afii57414"
+    + "/afii57415/afii57416/afii57417/afii57418/afii57419/afii57420"
+    + "/afii57421/afii57422/afii57423/afii57424/afii57425/afii57426"
+    + "/afii57427/afii57428/afii57429/afii57430/afii57431/afii57432"
+    + "/afii57433/afii57434/afii57440/afii57441/afii57442/afii57443"
+    + "/afii57444/afii57445/afii57446/afii57470/afii57448/afii57449"
+    + "/afii57450/afii57451/afii57452/afii57453/afii57454/afii57455"
+    + "/afii57456/afii57457/afii57458/afii57392/afii57393/afii57394"
+    + "/afii57395/afii57396/afii57397/afii57398/afii57399/afii57400"
+    + "/afii57401/afii57381/afii63167/afii57511/afii57506/afii57507"
+    + "/afii57512/afii57513/afii57508/afii57505/afii57509/afii57514"
+    + "/afii57519/afii57534/Wgrave/wgrave/Wacute/wacute/Wdieresis/w"
+    + "dieresis/Ygrave/ygrave/afii61664/afii301/afii299/afii300/fig"
+    + "uredash/endash/emdash/afii00208/underscoredbl/quoteleft/quot"
+    + "eright/quotesinglbase/quotereversed/quotedblleft/quotedblrig"
+    + "ht/quotedblbase/dagger/daggerdbl/bullet/onedotenleader/twodo"
+    + "tenleader/ellipsis/afii61573/afii61574/afii61575/perthousand"
+    + "/minute/second/guilsinglleft/guilsinglright/exclamdbl/fracti"
+    + "on/colonmonetary/franc/lira/peseta/afii57636/dong/Euro/afii6"
+    + "1248/Ifraktur/afii61289/afii61352/weierstrass/Rfraktur/presc"
+    + "ription/trademark/Omega/estimated/aleph/onethird/twothirds/o"
+    + "neeighth/threeeighths/fiveeighths/seveneighths/arrowleft/arr"
+    + "owup/arrowright/arrowdown/arrowboth/arrowupdn/arrowupdnbse/c"
+    + "arriagereturn/arrowdblleft/arrowdblup/arrowdblright/arrowdbl"
+    + "down/arrowdblboth/universal/partialdiff/existential/emptyset"
+    + "/Delta/gradient/element/notelement/suchthat/product/summatio"
+    + "n/minus/asteriskmath/radical/proportional/infinity/orthogona"
+    + "l/angle/logicaland/logicalor/intersection/union/integral/the"
+    + "refore/similar/congruent/approxequal/notequal/equivalence/le"
+    + "ssequal/greaterequal/propersubset/propersuperset/notsubset/r"
+    + "eflexsubset/reflexsuperset/circleplus/circlemultiply/perpend"
+    + "icular/dotmath/house/revlogicalnot/integraltp/integralbt/ang"
+    + "leleft/angleright/SF100000/SF110000/SF010000/SF030000/SF0200"
+    + "00/SF040000/SF080000/SF090000/SF060000/SF070000/SF050000/SF4"
+    + "30000/SF240000/SF510000/SF520000/SF390000/SF220000/SF210000/"
+    + "SF250000/SF500000/SF490000/SF380000/SF280000/SF270000/SF2600"
+    + "00/SF360000/SF370000/SF420000/SF190000/SF200000/SF230000/SF4"
+    + "70000/SF480000/SF410000/SF450000/SF460000/SF400000/SF540000/"
+    + "SF530000/SF440000/upblock/dnblock/block/lfblock/rtblock/ltsh"
+    + "ade/shade/dkshade/filledbox/H22073/H18543/H18551/filledrect/"
+    + "triagup/triagrt/triagdn/triaglf/lozenge/circle/H18533/invbul"
+    + "let/invcircle/openbullet/smileface/invsmileface/sun/female/m"
+    + "ale/spade/club/heart/diamond/musicalnote/musicalnotedbl/";
+
+
+  /**
+   * Determines the name of a glyph according to the Adobe Glyph List
+   * for New Fonts (AGLFN). Because all glyphs in AGLFN correspond to
+   * a precomposed Unicode codepoint, the mismatch between characters
+   * and glyphs is not an issue here.
+   *
+   * @param c the Unicode codepoint that corresponds to the glyph, for
+   * example <code>0x010a</code> for <code>LATIN CAPITAL LETTER C WITH
+   * DOT ABOVE</code>.
+   *
+   * @return the glyph name, for example <code>Cdotaccent</code>. If
+   * the glyph is not in the <i>Adobe Glyph List for New Fonts</i>,
+   * <code>null</code> is returned.
+   *
+   * @see <a href=
+   * "http://partners.adobe.com/asn/tech/type/aglfn13.txt" >Adobe
+   * Glyph List for New Fonts (AGLFN), version 1.1 of April 17,
+   * 2003</a>
+   *
+   * @see <a href=
+   * "http://partners.adobe.com/asn/developer/type/unicodegn.html#6"
+   * >Adobe&#x2019;s guidelines related to Unicode</a>
+   */
+  private static String getAGLFNName(char c)
+  {
+    int min, max, mid;
+    char midChar;
+
+    /* Performs a binary search in the sorted array (actually, a
+     * String) of glyphs in the Adobe Glyph List for New Fonts.
+     *
+     * A good compiler might be able to optimize a call to charAt for
+     * a static final String, but this routine is probably not that
+     * critical to performance.
+     */
+    min = 0;
+    max = AGLFN_GLYPHS.length() - 1;
+    mid = max >> 1;    
+    midChar = AGLFN_GLYPHS.charAt(mid);
+    do
+    {
+      if (midChar == c)
+        break;
+      else if (midChar < c)
+        min = mid + 1;
+      else
+        max = mid;
+      mid = (min + max) >> 1;
+      midChar = AGLFN_GLYPHS.charAt(mid);
+    }
+    while (min < max);
+    
+    if (midChar != c)
+      return null;
+
+    int pos = AGLFN_NAME_OFFSET.charAt(mid);
+    return AGLFN_NAMES.substring(pos, AGLFN_NAMES.indexOf('/', pos));
+  }
+
+
+  /**
+   * Returns the PostScript name of a glyph, given the sequence of
+   * Unicode characters that is required to produce the glyph.  The
+   * returned name follows Adobe&#x2019;s glyph naming recommendations
+   * in order to allow searching and indexing of the produced
+   * PostScript and PDF.
+   *
+   * <p>Some examples:
+   * <ul><li><code>U+0041</code> gives <code>A</code>;</li>
+   * <li><code>U+011D</code> gives <code>gcircumflex</code>;</li>
+   * <li><code>U+007A U+0302</code> gives <code>z_uni0302</code>;</li>
+   * <li><code>U+D807 U+DC42</code> (an UTF-16 escape sequence)
+   * gives <code>u11C42</code>;</li>
+   *  </ul>.
+   *
+   * <p>The routine does <i>not</i> bring sequences in any canonical
+   * form. Therefore, the result for <code>U+0067 U+0302</code> (the
+   * decomposition of <code>U+011D</code>) will be
+   * <code>g_uni0302</code>, not <code>gcircumflex</code>.
+   *
+   * @see <a href=
+   * "http://partners.adobe.com/asn/tech/type/unicodegn.jsp" >Unicode
+   * and Glyph Names</a> and <a href=
+   * "http://partners.adobe.com/asn/tech/type/glyphnamelimits.jsp"
+   * >Glyph Names and Current Implementations</a>
+   */
+  private static String getGlyphName(char[] chars)
+  {
+    char c;
+    String name;
+    int numChars;
+    boolean hasSurrogates = false;
+
+    if ((chars == null) || ((numChars = chars.length) == 0))
+      return ".notdef";
+
+    /* The vast majority of cases will be just a single character.
+     * Therefore, we have a special code path for this case.
+     */
+    if (numChars == 1)
+    {
+      c = chars[0];
+      name = getAGLFNName(c);
+      if (name != null)
+        return name;
+    }
+    
+    StringBuffer buf = new StringBuffer(numChars * 8);
+    for (int i = 0; i < numChars; i++)
+    {
+      if (i > 0)
+        buf.append('_');
+      c = chars[i];
+
+      /* handle surrogate pairs */
+      if (c >> 10 == 0x36) // U+D800 .. U+DBFF: High surrogate
+      {
+        /* Adobe recommends using the 'u' prefix only for
+         * characters outside the Unicode Basic Multilingual Plane,
+         * because Acrobat 4 and 5 understand only the "uni" prefix.
+         * The 'u' prefix will be supported by Acrobat 6 and later.
+         *
+         * For further information, please refer to this page:
+         * http://partners.adobe.com/asn/tech/type/glyphnamelimits.jsp#3
+         */
+        int ucs4 = (((c & 0x3ff) << 10) | (chars[++i] & 0x3ff)) + 0x10000;
+        buf.append('u');
+        buf.append(Integer.toHexString(ucs4).toUpperCase());
+      }
+      else
+      {
+        /* Try the Adobe Glyph List. */
+        name = getAGLFNName(c);
+        if (name != null)
+          buf.append(name);
+        else
+        {
+          char nibble;
+          buf.append("uni");
+          nibble = (char) (((c >> 12) & 0xf) + 0x30);
+          if (nibble > 0x39)
+            nibble += 7;
+          buf.append(nibble);
+          nibble = (char) (((c >> 8) & 0xf) + 0x30);
+          if (nibble > 0x39)
+            nibble += 7;
+          buf.append(nibble);
+          nibble = (char) (((c >> 4) & 0xf) + 0x30);
+          if (nibble > 0x39)
+            nibble += 7;
+          buf.append(nibble);
+          nibble = (char) (((c >> 0) & 0xf) + 0x30);
+          if (nibble > 0x39)
+            nibble += 7;
+          buf.append(nibble);
+        }
+      }
+    }
+    return buf.toString();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/MacResourceFork.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/MacResourceFork.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/MacResourceFork.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/MacResourceFork.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,235 @@
+/* MacResourceFork.java -- Parses MacOS resource forks.
+   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.awt.font.opentype;
+
+import java.nio.ByteBuffer;
+
+
+/**
+ * A class for accessing data that is stored in the resource fork of
+ * Macintosh files. Writing resource forks is currently not supported.
+ *
+ * <p>The gnu.java.awt.font package uses this class for accessing
+ * fonts in the MacOS X ".dfont" format, which is is a file in the
+ * format of a Macintosh resource fork, but stored in the normal data
+ * fork of the file.
+ *
+ * <p>The implementation has been designed to work efficiently with
+ * the virtual memory subsystem. It is recommended to pass an
+ * instance of {@link java.nio.MappedByteBuffer} to the constructor.
+ *
+ * <p>Thread Safety: All access is synchronized on the ByteBuffer
+ * that is passed to the constructor.
+ *
+ * @see <a href=
+ * "http://developer.apple.com/documentation/mac/MoreToolbox/MoreToolbox-99.html"
+ * >Apple&#x2019; developer documentation about the Resource File
+ * Format</a>
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+final class MacResourceFork
+{
+  int[] types;
+  Resource[][] resources;
+  ByteBuffer buf;
+
+  public MacResourceFork(ByteBuffer buf)
+  {
+    int typeListOffset;
+    int refListOffset;
+    int nameListOffset;
+    int mapOffset, mapLen;
+    int dataOffset, dataLen;
+    int numTypes;
+
+    synchronized (buf)
+    {
+      buf = buf.duplicate();
+      this.buf = buf;
+      buf.position(0);
+      dataOffset = buf.getInt();
+      mapOffset = buf.getInt();
+      dataLen = buf.getInt();
+      mapLen = buf.getInt();
+      buf.position(mapOffset + 24);
+      refListOffset = mapOffset + buf.getChar();
+      nameListOffset = mapOffset + buf.getChar();
+      numTypes = buf.getChar() + 1;
+      types = new int[numTypes];
+      resources = new Resource[numTypes][];
+
+      /* Parse resource type list. */
+      typeListOffset = buf.position();
+      for (int i = 0; i < numTypes; i++)
+      {
+        buf.position(typeListOffset + 8 * i);
+        int resType = buf.getInt();
+        int numRes = buf.getChar() + 1;
+
+        types[i] = resType;
+        resources[i] = new Resource[numRes];
+
+        buf.position(refListOffset + buf.getChar());
+        for (int j = 0; j < numRes; j++)
+        {
+          short resID = buf.getShort();
+          int resNameOffset = nameListOffset + buf.getChar();
+          int resDataOffset = buf.getInt();
+          byte resAttr = (byte) (resDataOffset >> 24);
+          resDataOffset = dataOffset + (resDataOffset & 0x00ffffff);
+          buf.getInt(); /* skip four reserved bytes */
+
+          Resource rsrc = new Resource(buf, resType, resID, resDataOffset,
+                                       resNameOffset);
+          resources[i][j] = rsrc;
+        }
+      }
+    }
+  }
+  
+
+  public Resource[] getResources(int type)
+  {
+    synchronized (buf)
+    {
+      for (int i = 0; i < types.length; i++)
+      {
+        if (types[i] == type)
+          return resources[i];
+      }
+    }
+    return null;
+  }
+  
+
+  public Resource getResource(int type, short id)
+  {
+    Resource[] res;
+
+    synchronized (buf)
+    {
+      for (int i = 0; i < types.length; i++)
+      {
+        if (types[i] != type)
+          continue;
+          
+        res = resources[i];
+        for (int j = 0; j < res.length; j++)
+          if (res[j].getID() == id)
+            return res[j];
+      }
+    }
+
+    return null;
+  }
+
+
+  /**
+   * A single resource that is contained in a resource fork.
+   */
+  public static final class Resource
+  {
+    int type;
+    short id;
+    byte attribute;
+    int nameOffset;
+    int dataOffset;
+    ByteBuffer buf;
+
+    private Resource(ByteBuffer buf,
+                     int type, short id, int dataOffset, int nameOffset)
+    {
+      this.buf = buf;
+      this.type = type;
+      this.id = id;
+      this.dataOffset = dataOffset;
+      this.nameOffset = nameOffset;
+    }
+
+
+    /**
+     * Returns the type of this resource.
+     *
+     * @return an <code>int</code> encoding a four-byte type tag,
+     * such as <code>0x464f4e54</code> for <code>'FONT'</code>.
+     */
+    public int getType()
+    {
+      return type;
+    }
+
+
+    /**
+     * Returns the ID of this resource.
+     */
+    public short getID()
+    {
+      return id;
+    }
+
+
+    /**
+     * Retrieves the content of the resource. Only one page of memory
+     * is touched, irrespective of the actual size of the resource.
+     */
+    public ByteBuffer getContent()
+    {
+      synchronized (buf)
+      {
+        buf.limit(buf.capacity());
+        int len = buf.getInt(dataOffset);
+        buf.position(dataOffset + 4).limit(dataOffset + 4 + len);
+        return buf.slice();
+      }
+    }
+
+
+    /**
+     * Determines the length of the resource in bytes.
+     */
+    public int getLength()
+    {
+      synchronized (buf)
+      {
+        return buf.getInt(dataOffset);
+      }
+    }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/NameDecoder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/NameDecoder.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/NameDecoder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/awt/font/opentype/NameDecoder.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,702 @@
+/* NameDecoder.java -- Decodes names of OpenType and TrueType fonts.
+   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.awt.font.opentype;
+
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.util.Locale;
+
+
+/**
+ * A utility class that helps with decoding the names of OpenType
+ * and TrueType fonts.
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class NameDecoder
+{
+  public static final int NAME_COPYRIGHT = 0;
+
+
+  /**
+   * Specifies the name of the family to which a font belongs, for
+   * example &#x201c;Univers&#x201d;.
+   */
+  public static final int NAME_FAMILY = 1;
+
+
+  /**
+   * Specified the name of the font inside its family, for
+   * example &#x201c;Light&#x201d;.
+   */
+  public static final int NAME_SUBFAMILY = 2;
+
+
+  public static final int NAME_UNIQUE = 3;
+
+
+  /**
+   * Specifies the full human-readable name of a font, for example
+   * &#x201c;Univers Light&#x201d;
+   */
+  public static final int NAME_FULL = 4;
+
+
+  public static final int NAME_VERSION = 5;
+
+
+  /**
+   * Specifies the PostScript name of a font, for example
+   * &#x201c;Univers-Light&#x201d;.
+   */
+  public static final int NAME_POSTSCRIPT = 6;
+
+
+  public static final int NAME_TRADEMARK = 7;
+  public static final int NAME_MANUFACTURER = 8;
+  public static final int NAME_DESIGNER = 9;
+  public static final int NAME_DESCRIPTION = 10;
+  public static final int NAME_VENDOR_URL = 11;
+  public static final int NAME_DESIGNER_URL = 12;
+  public static final int NAME_LICENSE = 13;
+  public static final int NAME_LICENSE_URL = 14;
+  public static final int NAME_PREFERRED_FAMILY = 16;
+  public static final int NAME_PREFERRED_SUBFAMILY = 17;
+  public static final int NAME_FULL_MACCOMPATIBLE = 18;
+  public static final int NAME_SAMPLE_TEXT = 19;
+  public static final int NAME_POSTSCRIPT_CID = 20;
+
+
+  private static final int PLATFORM_MACINTOSH = 1;
+  private static final int PLATFORM_MICROSOFT = 3;
+
+
+  public static String getName(ByteBuffer nameTable,
+                               int name, Locale locale)
+  {
+    int numRecords;
+    int macLanguage, msLanguage;
+    int offset;
+    int namePlatform, nameEncoding, nameLanguage, nameID, nameLen;
+    int nameStart;
+    String result;
+    boolean match;
+
+    if (nameTable == null)
+      return null;
+
+    nameTable.position(0);
+    /* We understand only format 0 of the name table. */
+    if (nameTable.getShort() != 0)
+      return null;
+
+    macLanguage = getMacLanguageCode(locale);
+    msLanguage = getMicrosoftLanguageCode(locale);
+    numRecords = nameTable.getShort();
+    offset = nameTable.getShort();
+
+    for (int i = 0; i < numRecords; i++)
+    {
+      namePlatform = nameTable.getShort();
+      nameEncoding = nameTable.getShort();
+      nameLanguage = nameTable.getShort();
+      nameID = nameTable.getShort();
+      nameLen = nameTable.getShort();
+      nameStart = offset + nameTable.getShort();
+
+      
+      if (nameID != name)
+        continue;
+
+      // Handle PS seperately as it can be only ASCII, although
+      // possibly encoded as UTF-16BE
+      if ( name == NAME_POSTSCRIPT )
+	{
+	  if( nameTable.get(nameStart) == 0 ) // Peek at top byte
+	    result = decodeName("UTF-16BE", nameTable, nameStart, nameLen);
+	  else
+	    result = decodeName("ASCII", nameTable, nameStart, nameLen);
+	  return result;
+	}
+
+      match = false;
+      switch (namePlatform)
+      {
+      case PLATFORM_MACINTOSH:
+        if ((nameLanguage == macLanguage) || (locale == null))
+          match = true;
+        else
+        {
+          switch (macLanguage)
+          {
+          case 49: /* Azerbaijani/Cyrillic */
+            match = (nameLanguage == /* Azerbaijani/Arabic */ 50)
+              || (nameLanguage == /* Azerbaijani/Roman */ 150);
+            break;
+
+          case 57: /* Mongolian/Mongolian */
+            match = (nameLanguage == /* Mongolian/Cyrillic */ 58);
+            break;
+
+          case 83: /* Malay/Roman */
+            match = (nameLanguage == /* Malay/Arabic */ 84);
+            break;
+          }
+        }
+        break;
+
+      case PLATFORM_MICROSOFT:
+        if (((nameLanguage & 0xff) == msLanguage) || (locale == null))
+          match = true;
+        break;
+      }
+
+      
+      if (match)
+      {
+        result = decodeName(namePlatform, nameEncoding, nameLanguage,
+                            nameTable, nameStart, nameLen);
+        if (result != null)
+          return result;
+      }
+    }
+
+    return null;
+  }
+
+
+  /**
+   * The language codes used by the Macintosh operating system.  MacOS
+   * defines numeric language identifiers in the range [0 .. 95] and
+   * [128 .. 150]. To map this numeric identifier into an ISO 639
+   * language code, multiply it by two and take the substring at that
+   * position.
+   *
+   * <p>ISO 639 has revised the code for some languages, namely
+   * <code>he</code> for Hebrew (formerly <code>iw</code>),
+   * <code>yi</code> (formerly <code>ji</code>), and <code>id</code>
+   * for Indonesian (formerly <code>in</code>). In those cases, this
+   * table intentionally contains the older, obsolete code.  The
+   * reason is that this is the code which
+   * java.util.Locale.getLanguage() is specified to return.  The
+   * implementation of {@link #getMacLanguageCode} depends on this.
+   *
+   * @see <a href=
+   * "http://www.unicode.org/unicode/onlinedat/languages.html"
+   * >Language Codes: ISO 639, Microsoft and Macintosh</a>
+   */
+  private static final String macLanguageCodes
+    // 0                   1                   2
+    // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
+    = "enfrdeitnlsvesdaptnoiwjaarfielismttrhrzhurhithkoltplhuetlv  "
+
+    // 3                   4                   5
+    // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
+    + "fofaruzhnlgdsqrocssksljisrmkbgukbeuzkkazazhykamokytgtkmnmnps"
+
+    // 6                   7                   8
+    // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
+    + "kukssdbonesamrbnasgupaormlkntatesimykmloviintlmsmsamti  sosw"
+
+    // 9                   10                  11
+    // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
+    + "rwrn  mgeo                                                  "
+
+    // 12                  13                  14
+    // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
+    + "                cyeucalaqugnayttugtsjwsuglafbriugdgvgatoelkl"
+
+    // 15
+    // 0
+    + "az";
+
+
+  /**
+   * The primary language IDs used by the Microsoft operating systems.
+   *
+   * <p>ISO 639 has revised the code for some languages, namely
+   * <code>he</code> for Hebrew (formerly <code>iw</code>),
+   * <code>yi</code> (formerly <code>ji</code>), and <code>id</code>
+   * for Indonesian (formerly <code>in</code>). In those cases, this
+   * table intentionally contains the older, obsolete code.  The
+   * reason is that this is the code which
+   * java.util.Locale.getLanguage() is specified to return.  The
+   * implementation of {@link #getMicrosoftLanguageCode} depends on
+   * this.
+   *
+   * @see <a href=
+   * "http://www.unicode.org/unicode/onlinedat/languages.html"
+   * >Language Codes: ISO 639, Microsoft and Macintosh</a>
+   */
+  private static final String microsoftLanguageCodes
+    // 0                   1                   2
+    // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
+    = "  arbgcazhcsdadeelenesfifriwhuisitjakonlnoplptrmrorushsksqsv"
+
+    // 3                   4                   5
+    // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
+    + "thtrurinukbesletlvlttgfavihyazeu  mk  ts    xhzuafkafohimt  "
+
+    // 6                   7                   8
+    // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
+    + "gajimskkkyswtkuzttbnpaguortateknmlasmrsamnbocykmlomygl    sd"
+
+    // 9                   10                  11
+    // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
+    + "  si  iuam  ksnefypstl      ha  yo              omtign  laso";
+
+
+  /**
+   * Maps a Java Locale into a MacOS language code.
+   *
+   * <p>For languages that are written in several script systems,
+   * MacOS defines multiple language codes. Java Locales have a
+   * variant which could be used for that purpose, but a small
+   * test program revealed that with Sun's JDK 1.4.1_01, only two
+   * of 134 available Locales have a variant tag (namely no_NO_NY
+   * and th_TH_TH).</p>
+   *
+   * <p>The following cases are problematic:
+   *
+   * <ul> <li>Azerbaijani (az): The MacOS language code is 49 if
+   * Azerbaijani is written in the Cyrillic script; 50 if written in
+   * the Arabic script; 150 if written in the Roman script.  This
+   * method will always return 49 for the Azerbaijani locale.</li>
+   *
+   * <li>Mongolian (mn): The MacOS language code is 57 if Mongolian is
+   * written in the Mongolian script; 58 if written in the Cyrillic
+   * script. This method will always return 57 for the Mongolian
+   * locale.</li>
+   *
+   * <li>Malay (ms): The MacOS language code is 83 if Malay is written
+   * in the Roman script; 84 if written in the Arabic script. This
+   * method will always return 83 for the Malay locale.</li> </ul>
+   *
+   * @return a MacOS language code, or -1 if there is no such code for
+   * <code>loc</code>&#x2019;s language.
+   */
+  private static int getMacLanguageCode(Locale loc)
+  {
+    int code;
+
+    if (loc == null)
+      return -1;
+    
+    code = findLanguageCode(loc.getLanguage(), macLanguageCodes);
+    switch (code)
+    {
+    case 19:
+      /* Traditional Chinese (MacOS language #19) and and Simplified
+       * Chinese (MacOS language #33) both have "zh" as their ISO 639
+       * code.
+       */
+      if (loc.equals(Locale.SIMPLIFIED_CHINESE))
+        code = 33;
+      break;
+
+      // Other special cases would be 49, 57 and 83, but we do not
+      // know what do do about them. See the method documentation for
+      // details.
+    }
+    
+    return code;
+  }
+  
+
+  /**
+   * Maps a Java Locale into a Microsoft language code.
+   */
+  private static int getMicrosoftLanguageCode(Locale locale)
+  {
+    String isoCode;
+    int code;
+
+    if (locale == null)
+      return -1;
+    
+    isoCode = locale.getLanguage();
+    code = findLanguageCode(isoCode, microsoftLanguageCodes);
+    if (code == -1)
+    {
+      if (isoCode.equals("hr") || isoCode.equals("sr"))
+      {
+        /* Microsoft uses code 26 for "sh" (Serbo-Croatian),
+         * "hr" (Croatian) and "sr" (Serbian). Our table contains
+         * "sh".
+         */
+        code = 26;
+      }
+      else if (isoCode.equals("gd"))
+      {
+        /* Microsoft uses code 60 for "gd" (Scottish Gaelic) and
+         * "ga" (Irish Gaelic). Out table contains "ga".
+         */
+        code = 60;
+      }
+    }
+    return code;
+  }
+
+
+  private static int findLanguageCode(String lang, String langCodes)
+  {
+    int index;
+    if (lang == null)
+      return -1;
+
+    if (lang.length() != 2)
+      return -1;
+
+    index = 0;
+    do
+    {
+      index = langCodes.indexOf(lang, index);
+
+      /* The index must be even to be considered a match. Otherwise, we
+       * could match with the second letter of one language and the
+       * first of antoher one.
+       */
+    }
+    while (!((index < 0) || ((index & 1) == 0)));
+    if (index < 0)
+      return -1;
+
+    index = index / 2;
+    return index;
+  }
+
+
+  private static String decodeName(int platform, int encoding, int language,
+                                   ByteBuffer buffer, int offset, int len)
+  {
+    String charsetName = getCharsetName(platform, language, encoding);
+    if (charsetName == null)
+      return null;
+
+    return decodeName(charsetName, buffer, offset, len);
+  }
+
+  private static String decodeName(String charsetName,
+                                   ByteBuffer buffer, int offset, int len)
+  {
+    byte[] byteBuf;
+    int oldPosition;
+
+    byteBuf = new byte[len];
+    oldPosition = buffer.position();
+    try
+    {
+      buffer.position(offset);
+      buffer.get(byteBuf);
+      try
+      {
+        return new String(byteBuf, charsetName);
+      }
+      catch (UnsupportedEncodingException uex)
+      {
+      }
+    }
+    finally
+    {
+      buffer.position(oldPosition);
+    }
+
+    return null;
+  }
+
+
+  /**
+   * Maps a MacOS language code into a Java Locale.
+   *
+   * @param macLanguageCode the MacOS language code for
+   * the language whose Java locale is to be retrieved.
+   *
+   * @return an suitable Locale, or <code>null</code> if
+   * the mapping cannot be performed.
+   */
+  private static Locale getMacLocale(int macLanguageCode)
+  {
+    String isoCode;
+
+    switch (macLanguageCode)
+    {
+    case 0: return Locale.ENGLISH;
+    case 1: return Locale.FRENCH;
+    case 2: return Locale.GERMAN;
+    case 3: return Locale.ITALIAN;
+    case 11: return Locale.JAPANESE;
+    case 23: return Locale.KOREAN;
+    case 19: return Locale.TRADITIONAL_CHINESE;
+    case 33: return Locale.SIMPLIFIED_CHINESE;
+    }
+
+    if ((macLanguageCode < 0) || (macLanguageCode > 150))
+      return null;
+
+    isoCode = macLanguageCodes.substring(macLanguageCode << 1,
+                                         (macLanguageCode + 1) << 1);
+    if (isoCode.charAt(0) == ' ')
+      return null;
+
+    return new Locale(isoCode);
+  }
+
+
+
+  /**
+   * Maps a Windows LCID into a Java Locale.
+   *
+   * @param lcid the Windows language ID whose Java locale
+   * is to be retrieved.
+   *
+   * @return an suitable Locale, or <code>null</code> if
+   * the mapping cannot be performed.
+   */
+  private static Locale getWindowsLocale(int lcid)
+  {
+    /* FIXME: This is grossly incomplete. */
+    switch (lcid)
+    {
+    case 0x0407: return Locale.GERMAN;
+    case 0x0408: return new Locale("el", "GR");
+    case 0x0409: return Locale.ENGLISH;
+    case 0x040b: return new Locale("fi");
+    case 0x040c: return Locale.FRENCH;
+    case 0x0416: return new Locale("pt");
+    case 0x0807: return new Locale("de", "CH");
+    case 0x0809: return new Locale("en", "UK");
+    case 0x080c: return new Locale("fr", "BE");
+    case 0x0816: return new Locale("pt", "BR");
+    case 0x0c07: return new Locale("de", "AT");
+    case 0x0c09: return new Locale("en", "AU");
+    case 0x0c0c: return new Locale("fr", "CA");
+    case 0x1007: return new Locale("de", "LU");
+    case 0x1009: return new Locale("en", "CA");
+    case 0x100c: return new Locale("fr", "CH");
+    case 0x1407: return new Locale("de", "LI");
+    case 0x1409: return new Locale("en", "NZ");
+    case 0x140c: return new Locale("fr", "LU");
+    case 0x1809: return new Locale("en", "IE");
+
+    default:
+      return null;
+    }
+  }
+
+
+  /**
+   * Maps a Macintosh Script Manager code to the name of the
+   * corresponding Java Charset.
+   *
+   * @param macScript a MacOS ScriptCode, for example
+   * 6 for <code>smGreek</code>.
+   *
+   * @return a String that can be used to retrieve a Java
+   * CharsetDecorder, for example <code>MacGreek</code>, or
+   * <code>null</code> if <code>macScript</code> has an
+   * unsupported value.
+   */
+  private static String getMacCharsetName(int macScript)
+  {
+    switch (macScript)
+    {
+    case 0: return "MacRoman";
+    case 1: return "MacJapanese";
+    case 2: return "MacKorean";
+    case 3: return "MacTradChinese";
+    case 4: return "MacArabic";
+    case 5: return "MacHebrew";
+    case 6: return "MacGreek";
+    case 7: return "MacCyrillic";
+    case 8: return "MacRSymbol";
+    case 9: return "MacDevanagari";
+    case 10: return "MacGurmukhi";
+    case 11: return "MacGujarati";
+    case 12: return "MacOriya";
+    case 13: return "MacBengali";
+    case 14: return "MacTamil";
+    case 15: return "MacTelugu";
+    case 16: return "MacKannada";
+    case 17: return "MacMalayalam";
+    case 18: return "MacSinhalese";
+    case 19: return "MacBurmese";
+    case 20: return "MacKhmer";
+    case 21: return "MacThai";
+    case 22: return "MacLao";
+    case 23: return "MacGeorgian";
+    case 24: return "MacArmenian";
+    case 25: return "MacSimpChinese";
+    case 26: return "MacTibetan";
+    case 27: return "MacMongolian";
+    case 28: return "MacEthiopic";
+    case 29: return "MacCentralEurope";
+    case 30: return "MacVietnamese";
+    case 31: return "MacExtArabic";
+
+    default: return null;
+    }
+  }
+
+  
+  /**
+   * Maps a Microsoft locale ID (LCID) to the name of the
+   * corresponding Java Charset.
+   *
+   * @param lcid the Microsoft locale ID.
+   *
+   * @return a String that can be used to retrieve a Java
+   * CharsetDecorder, for example <code>windows-1252</code>, or
+   * <code>null</code> if <code>lcid</code> has an unsupported value.
+   */
+  private static String getMicrosoftCharsetName(int lcid)
+  {
+    int lang;
+    char codePage = '?';
+
+    /* Extract the language code from the LCID. */
+    lang = lcid & 0x3ff;
+
+    /* In the majority of cases, the language alone determines the
+     * codepage.
+     */
+    if (lang < 100)
+      codePage = (" 612D022322225022EC2202201?002A462110777 68 ?2 1  "
+                  + "    2 2     2112 ?1           1     2           2 ")
+        .charAt(lang);
+
+    /* There are a few exceptions, however, where multiple code pages
+     * are used for the same language. */
+    if (codePage == '?')
+    {
+      switch (lcid)
+      {
+      case 0x041a: // Croatian --> Windows-1250 (Central Europe)
+      case 0x081a: // Serbian (Latin) --> Windows-1250 (Central Europe)
+        codePage = '0';
+        break;
+
+      case 0x42c: // Azeri (Latin) --> Windows-1254 (Turkish)
+      case 0x443: // Uzbek (Latin) --> Windows-1254 (Turkish)
+        codePage = '4';
+        break;
+
+      case 0x82c: // Azeri (Cyrillic) --> Windows-1251 (Cyrillic)
+      case 0x843: // Uzbek (Cyrillic) --> Windows-1251 (Cyrillic)
+      case 0xc1a: // Serbian (Cyrillic) --> Windows-1251 (Cyrillic)
+        codePage = '1';
+        break;
+      }
+    }
+
+    switch (codePage)
+    {
+    case '0': return "windows-1250"; // Central Europe
+    case '1': return "windows-1251"; // Cyrillic
+    case '2': return "windows-1252"; // Latin 1
+    case '3': return "windows-1253"; // Greek
+    case '4': return "windows-1254"; // Turkish
+    case '5': return "windows-1255"; // Hebrew
+    case '6': return "windows-1256"; // Arabic
+    case '7': return "windows-1257"; // Baltic
+    case '8': return "windows-1258"; // Vietnam
+    case 'A': return "windows-874";  // Thai
+    case 'B': return "windows-936";  // Simplified Chinese, GBK
+    case 'C': return "windows-949";  // Korean
+    case 'D': return "windows-950";  // Traditional Chinese, Big5
+    case 'E': return "windows-932";  // Japanese Shift-JIS
+    default: return null;
+    }
+  }
+
+
+  /**
+   * Returns the Locale of an OpenType name.
+   *
+   * @param platform the OpenType platform ID.
+   *
+   * @param language the language tag of the OpenType name. If
+   * <code>platform</code> is 1, this is the MacOS language code.
+   *
+   * @param encoding the encoding tag of the OpenType name. If
+   * <code>platform</code> is 1, this is the MacOS script code.
+   */
+  public static Locale getLocale(int platform, int language, int encoding)
+  {
+    switch (platform)
+    {
+    case 1: /* Apple Macintosh */
+      return getMacLocale(language);
+
+    case 3: /* Microsoft Windows */
+      return getWindowsLocale(language);
+      
+    default:
+      return null;
+    }
+  }
+
+
+  /**
+   * Determines the name of the charset for an OpenType font name.
+   *
+   * @param platform the OpenType platform ID.
+   *
+   * @param language the language tag of the OpenType name. If
+   * <code>platform</code> is 1, this is the MacOS language code.
+   *
+   * @param encoding the encoding tag of the OpenType name. If
+   * <code>platform</code> is 1, this is the MacOS script code.
+   *
+   * @return a charset name such as <code>"MacRoman"</code>,
+   * or <code>null</code> if the combination is not known.
+   */
+  public static String getCharsetName(int platform, int language, int encoding)
+  {
+    switch (platform)
+    {
+    case 1: /* Apple Macintosh */
+      return getMacCharsetName(encoding);
+
+    case 3: /* Microsoft Windows */
+      return getMicrosoftCharsetName(language);
+
+    default:
+      return null;
+    }
+  }
+}





More information about the llvm-commits mailing list