Major merge with Classpath.

Removed many duplicate files.
	* HACKING: Updated.x
	* classpath: Imported new directory.
	* standard.omit: New file.
	* Makefile.in, aclocal.m4, configure: Rebuilt.
	* sources.am: New file.
	* configure.ac: Run Classpath configure script.  Moved code around
	to support.  Disable xlib AWT peers (temporarily).
	* Makefile.am (SUBDIRS): Added 'classpath'
	(JAVAC): Removed.
	(AM_CPPFLAGS): Added more -I options.
	(BOOTCLASSPATH): Simplified.
	Completely redid how sources are built.
	Include sources.am.
	* include/Makefile.am (tool_include__HEADERS): Removed jni.h.
	* include/jni.h: Removed (in Classpath).
	* scripts/classes.pl: Updated to look at built classes.
	* scripts/makemake.tcl: New file.
	* testsuite/libjava.jni/jni.exp (gcj_jni_compile_c_to_so): Added
	-I options.
	(gcj_jni_invocation_compile_c_to_binary): Likewise.

From-SVN: r102082
This commit is contained in:
Tom Tromey
2005-07-16 01:27:14 +00:00
committed by Tom Tromey
parent ea54b29342
commit b0fa81eea9
2817 changed files with 11656 additions and 643398 deletions
@@ -1,62 +0,0 @@
/* gnu.classpath.Configuration
Copyright (C) 1998, 2001, 2003 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 DEBUG is substituted according to whether the
// "--enable-libgcj-debug" argument was passed to configure. Code
// which is made conditional based on the value of this flag will
// be removed by the optimizer in a non-debug build.
boolean DEBUG = @LIBGCJDEBUG@;
// For libgcj we never load the JNI libraries.
boolean INIT_LOAD_LIBRARY = false;
// For libgcj we have native methods for dynamic proxy support....
boolean HAVE_NATIVE_GET_PROXY_DATA = false;
boolean HAVE_NATIVE_GET_PROXY_CLASS = false;
boolean HAVE_NATIVE_GENERATE_PROXY_CLASS = false;
// Name of default AWT peer library.
String default_awt_peer_toolkit = "@TOOLKIT@";
}
-573
View File
@@ -1,573 +0,0 @@
/* 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.
* *
* * &lt;p&gt;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@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}.
*
* @author <a href="mailto:brawer@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/&lt;org.foo.SomeService&gt;</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} 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/&lt;org.foo.SomeService&gt;</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 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);
}
}
@@ -1,149 +0,0 @@
/* 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} was called, even
* though the actual loading is delayed to the time when the provider
* is actually needed.
*
* @author <a href="mailto:brawer@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;
}
}
@@ -1,63 +0,0 @@
/* 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@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);
}
}
@@ -1,61 +0,0 @@
/* 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@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);
}
}
@@ -1,63 +0,0 @@
/* 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@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);
}
}
@@ -1,63 +0,0 @@
/* 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@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);
}
}
@@ -1,63 +0,0 @@
/* InvalidStringException.java -- an invalid string 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 the debugger uses an invalid String
* id
*
* @author Keith Seitz <keiths@redhat.com>
*/
public class InvalidStringException
extends JdwpException
{
public InvalidStringException (String str)
{
super (JdwpConstants.Error.INVALID_STRING,
"invalid string (" + str + ")");
}
public InvalidStringException (Throwable t)
{
super (JdwpConstants.Error.INVALID_STRING, t);
}
}
@@ -1,63 +0,0 @@
/* InvalidThreadException.java -- an invalid thread 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 thread id is used
* by the debugger
*
* @author Keith Seitz <keiths@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);
}
}
@@ -1,63 +0,0 @@
/* InvalidThreadGroupException.java -- an invalid thread group 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 thread group id is used
* by the debugger
*
* @author Keith Seitz <keiths@redhat.com>
*/
public class InvalidThreadGroupException
extends JdwpException
{
public InvalidThreadGroupException (long id)
{
super (JdwpConstants.Error.INVALID_THREAD_GROUP,
"invalid thread id (" + id + ")");
}
public InvalidThreadException (Throwable t)
{
super (JdwpConstants.Error.INVALID_THREAD_GROUP, t);
}
}
@@ -1,86 +0,0 @@
/* 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@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;
}
}
@@ -1,58 +0,0 @@
/* JdwpInternalErrorException.java -- an internal error exception
features or functions
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@redhat.com>
*/
public class JdwpInternalErrorException
extends JdwpException
{
public JdwpInternalErrorException (Throwable cause)
{
super (JdwpConstants.Error.INTERNAL, cause);
}
}
@@ -1,59 +0,0 @@
/* NotImplementedException.java -- an exception for unimplemented JDWP
features or functions
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@redhat.com>
*/
public class NotImplementedException
extends JdwpException
{
public NotImplementedException (String feature)
{
super (JdwpConstants.Error.NOT_IMPLEMENTED,
feature + " is not yet implemented");
}
}
@@ -1,55 +0,0 @@
/* Jdwp.java -- Virtual machine to JDWP back-end programming interface
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@redhat.com>
*/
public class VmDeadException
extends JdwpException
{
public VmDeadException ()
{
super (JdwpConstants.Error.VM_DEAD, "Virtual machine is dead");
}
}
@@ -1,62 +0,0 @@
/* 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@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);
}
}
@@ -1,59 +0,0 @@
/* 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@redhat.com>
*/
public class ArrayReferenceTypeId
extends ReferenceTypeId
{
/**
* Constructs a new <code>ArrayReferenceTypeId</code>
*/
public ArrayReferenceTypeId ()
{
super (JdwpConstants.TypeTag.ARRAY);
}
}
@@ -1,64 +0,0 @@
/* 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;
/**
* A class which represents a JDWP thread id
*
* @author Keith Seitz <keiths@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);
}
}
@@ -1,64 +0,0 @@
/* 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;
/**
* A class which represents a JDWP class object id
*
* @author Keith Seitz <keiths@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);
}
}
@@ -1,59 +0,0 @@
/* 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@redhat.com>
*/
public class ClassReferenceTypeId
extends ReferenceTypeId
{
/**
* Constructs a new <code>ClassReferenceTypeId</code>
*/
public ClassReferenceTypeId ()
{
super (JdwpConstants.TypeTag.CLASS);
}
}
@@ -1,59 +0,0 @@
/* 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@redhat.com>
*/
public class InterfaceReferenceTypeId
extends ReferenceTypeId
{
/**
* Constructs a new <code>InterfaceReferenceTypeId</code>
*/
public InterfaceReferenceTypeId ()
{
super (JdwpConstants.TypeTag.INTERFACE);
}
}
-127
View File
@@ -1,127 +0,0 @@
/* JdwpId.java -- base class for all object ID 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.id;
import java.io.DataOutputStream;
import java.io.IOException;
/**
* A baseclass for all object types reported to the debugger
*
* @author Keith Seitz <keiths@redhat.com>
*/
public abstract class JdwpId
{
/**
* 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.JdwpConstants.TypeTag}) for reference type IDs.
*/
private byte _tag;
/**
* Constructs an empty <code>JdwpId</code>
*/
public JdwpId (byte tag)
{
_tag = tag;
}
/**
* Sets the id for this object reference
*/
void setId (long id)
{
_id = id;
}
/**
* Returns the id for this object reference
*/
public long getId ()
{
return _id;
}
/**
* 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. (NOTE: This is a much stricter check
* than is necessary: all <code>JdwpId</code>s have unique
* ids.)
*/
public boolean equals (JdwpId id)
{
return ((id.getClass () == getClass ()) && (id.getId () == getId ()));
}
/**
* Returns size of this type (used by IDSizes)
*/
public abstract int size ();
/**
* 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);
}
}
@@ -1,165 +0,0 @@
/* JdwpIdFactory.java -- factory for generating type and 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 java.util.HashMap;
/**
* This factory generates ids for objects and types that may
* be sent to a debugger.
*
* @author Keith Seitz (keiths@redhat.com)
*/
public class JdwpIdFactory
{
// ID of last object / referencetype
private static Object _idLock = new Object ();
private static Object _ridLock = new Object ();
private static long _lastId = 0;
private static long _lastRid = 0;
// A list of all ID types
private static HashMap _idList = new HashMap ();
// Initialize the id list with known types
static
{
// ObjectId and ArrayId are special cases. See newId.
_idList.put (ClassLoaderId.typeClass, ClassLoaderId.class);
_idList.put (ClassObjectId.typeClass, ClassObjectId.class);
//_idList.put (FieldId.typeClass, FieldId.class);
//_idList.put (FrameId.typeClass, FrameId.class);
//_idList.put (MethodId.typeClass, MethodId.class);
_idList.put (StringId.typeClass, StringId.class);
_idList.put (ThreadId.typeClass, ThreadId.class);
_idList.put (ThreadGroupId.typeClass, ThreadGroupId.class);
}
/**
* Returns a new id for the given object
*
* @param object the object for which an id is desired
* @returns a suitable object id
*/
public static JdwpId newId (Object object)
{
JdwpId id = null;
// Special case: arrays
if (object.getClass ().isArray ())
id = new ArrayId ();
else
{
// Loop through all classes until we hit baseclass
Class myClass;
for (myClass = object.getClass (); myClass != null;
myClass = myClass.getSuperclass ())
{
Class clz = (Class) _idList.get (myClass);
if (clz != null)
{
try
{
id = (JdwpId) clz.newInstance ();
synchronized (_idLock)
{
id.setId (++_lastId);
}
return id;
}
catch (InstantiationException ie)
{
// This really should not happen
throw new RuntimeException ("cannot create new ID", ie);
}
catch (IllegalAccessException iae)
{
// This really should not happen
throw new RuntimeException ("illegal access of ID", iae);
}
}
}
/* getSuperclass returned null and no matching ID type found.
So it must derive from Object. */
id = new ObjectId ();
}
synchronized (_idLock)
{
id.setId (++_lastId);
}
return id;
}
/**
* Returns a new reference type id for the given class
*
* @param clazz the <code>Class</code> for which an id is desired
* @returns a suitable reference type id or <code>null</code>
*/
public static ReferenceTypeId newReferenceTypeId (Class clazz)
{
ReferenceTypeId id = null;
try
{
if (clazz.isArray ())
id = new ArrayReferenceTypeId ();
else if (clazz.isInterface ())
id = new InterfaceReferenceTypeId ();
else
id = new ClassReferenceTypeId ();
synchronized (_ridLock)
{
id.setId (++_lastRid);
}
return id;
}
catch (InstantiationException ie)
{
return null;
}
catch (IllegalAccessException iae)
{
return null;
}
}
}
@@ -1,99 +0,0 @@
/* ObjectId.java -- 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 java.io.DataOutputStream;
import java.io.IOException;
/**
* A class which represents a JDWP object id for an object
*
* @author Keith Seitz <keiths@redhat.com>
*/
public class ObjectId
extends JdwpId
{
/**
* The object class that this id represents
*/
public static final Class typeClass = Object.class;
/**
* 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 size of this id type
*/
public int size ()
{
return 8;
}
/**
* 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);
}
}
@@ -1,81 +0,0 @@
/* ReferenceTypeId.java -- a base class for all 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 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@redhat.com>
*/
public class ReferenceTypeId
extends JdwpId
{
/**
* Constructor used by {Array,Interface,Class}ReferenceTypeId
*/
public ReferenceTypeId (byte tag)
{
super (tag);
}
/**
* Returns the size of this ID type
*/
public int size ()
{
return 8;
}
/**
* 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);
}
}
@@ -1,64 +0,0 @@
/* 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;
/**
* A class which represents a JDWP string id
*
* @author Keith Seitz <keiths@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);
}
}
@@ -1,64 +0,0 @@
/* 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;
/**
* A class which represents a JDWP thread group id
*
* @author Keith Seitz <keiths@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);
}
}
@@ -1,64 +0,0 @@
/* 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;
/**
* A class which represents a JDWP thread id
*
* @author Keith Seitz <keiths@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);
}
}
@@ -1,68 +0,0 @@
/* 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., 59 Temple Place, Suite 330, Boston, MA
02111-1307 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 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@redhat.com>
*/
public interface CommandSet
{
/**
* 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 boolean runCommand(ByteBuffer bb, DataOutputStream os,
byte command)
throws JdwpException;
}
@@ -1,66 +0,0 @@
/* 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@redhat.com>
*/
public class FieldCommandSet implements 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.");
}
}
@@ -1,67 +0,0 @@
/* 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@redhat.com>
*/
public class InterfaceTypeCommandSet implements 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.");
}
}
@@ -1,249 +0,0 @@
/* ObjectReferenceCommandSet.java -- lass 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.IVirtualMachine;
import gnu.classpath.jdwp.Jdwp;
import gnu.classpath.jdwp.JdwpConstants;
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.IdManager;
import gnu.classpath.jdwp.id.ObjectId;
import gnu.classpath.jdwp.id.ReferenceTypeId;
import gnu.classpath.jdwp.util.Value;
import gnu.classpath.jdwp.util.MethodInvoker;
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@redhat.com>
*/
public class ObjectReferenceCommandSet implements CommandSet
{
// Our hook into the jvm
private final IVirtualMachine vm = Jdwp.getIVirtualMachine();
// Manages all the different ids that are assigned by jdwp
private final IdManager idMan = Jdwp.getIdManager();
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 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 true;
}
private void executeReferenceType(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
ObjectId oid = idMan.readId(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.readId(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.readId(bb).getObject();
Value.writeValueFromField(os, field, obj);
}
}
private void executeSetValues(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
ObjectId oid = idMan.readId(bb);
Object obj = oid.getObject();
int numFields = bb.getInt();
for (int i = 0; i < numFields; i++)
{
Field field = (Field) idMan.readId(bb).getObject();
Object value = Value.getObj(bb, field);
try
{
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)
{
// We should be able to access any field
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.readId(bb);
Object obj = oid.getObject();
ObjectId tid = idMan.readId(bb);
Thread thread = (Thread) tid.getObject();
ReferenceTypeId rid = idMan.readReferenceTypeId(bb);
Class clazz = rid.getType();
ObjectId mid = idMan.readId(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();
if ((invokeOptions & JdwpConstants.InvokeOptions.INVOKE_SINGLE_THREADED) != 0)
{ // We must suspend all other running threads first
vm.suspendAllThreads();
}
boolean nonVirtual;
if ((invokeOptions & JdwpConstants.InvokeOptions.INVOKE_NONVIRTUAL) != 0)
nonVirtual = true;
else
nonVirtual = false;
MethodInvoker vmi = new MethodInvoker(vm);
vmi.executeMethod(obj, thread, clazz, method, values, nonVirtual);
Object value = vmi.getReturnedValue();
ObjectId exceptionId = vmi.getExceptionId();
Value.writeValue(os, value);
exceptionId.writeTagged(os);
}
private void executeDisableCollection(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
ObjectId oid = idMan.readId(bb);
oid.disableCollection();
}
private void executeEnableCollection(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
ObjectId oid = idMan.readId(bb);
oid.enableCollection();
}
private void executeIsCollected(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
ObjectId oid = idMan.readId(bb);
boolean collected = oid.isCollected();
os.writeBoolean(collected);
}
}
@@ -1,216 +0,0 @@
/* PacketProcessor.java -- a thread which processes command packets
from the debugger
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.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;
/**
* 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@redhat.com)
*/
public class PacketProcessor
extends Thread
{
// 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 void run ()
{
try
{
while (!_shutdown)
{
_processOnePacket ();
}
}
catch (IOException ex)
{
ex.printStackTrace();
}
// Time to shutdown, tell Jdwp to shutdown
Jdwp.getDefault().shutdown();
}
/**
* Shutdown the packet processor
*/
public void shutdown ()
{
_shutdown = true;
interrupt ();
}
// 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);
}
}
}
@@ -1,321 +0,0 @@
/* ReferenceTypeCommandSet.java -- lass to implement the ReferenceType
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.IVirtualMachine;
import gnu.classpath.jdwp.Jdwp;
import gnu.classpath.jdwp.JdwpConstants;
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.IdManager;
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.lang.reflect.Method;
import java.nio.ByteBuffer;
/**
* A class representing the ReferenceType Command Set.
*
* @author Aaron Luchko <aluchko@redhat.com>
*/
public class ReferenceTypeCommandSet implements CommandSet
{
// Our hook into the jvm
private final IVirtualMachine vm = Jdwp.getIVirtualMachine();
// Manages all the different ids that are assigned by jdwp
private final IdManager idMan = Jdwp.getIdManager();
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 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 true;
}
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.getId(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.getId(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
{
ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
Class clazz = refId.getType();
Method[] methods = clazz.getMethods();
os.writeInt(methods.length);
for (int i = 0; i < methods.length; i++)
{
Method method = methods[i];
idMan.getId(method).write(os);
JdwpString.writeString(os, method.getName());
JdwpString.writeString(os, Signature.computeMethodSignature(method));
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.readId(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))
Value.writeStaticValueFromField(os, field);
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 = vm.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 = vm.getStatus(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.getId(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.");
}
}
@@ -1,98 +0,0 @@
/* 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., 59 Temple Place, Suite 330, Boston, MA
02111-1307 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.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@redhat.com>
*/
public class StringReferenceCommandSet implements 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 true;
}
private void executeValue(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
ObjectId oid = Jdwp.getIdManager().readId(bb);
String str = (String) oid.getObject();
JdwpString.writeString(os, str);
}
}
@@ -1,474 +0,0 @@
/* VirtualMachineCommandSet.java -- class to implement the VirtualMachine
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.IVirtualMachine;
import gnu.classpath.jdwp.Jdwp;
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.IdManager;
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@redhat.com>
*/
public class VirtualMachineCommandSet implements CommandSet
{
// Our hook into the jvm
private final IVirtualMachine vm = Jdwp.getIVirtualMachine();
// Manages all the different ids that are assigned by jdwp
private final IdManager idMan = Jdwp.getIdManager();
// The Jdwp object
private final Jdwp jdwp = Jdwp.getDefault();
public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
throws JdwpException
{
boolean keepRunning = true;
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:
keepRunning = false;
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:
keepRunning = false;
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:
break;
}
}
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 keepRunning;
}
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.write(jdwpMajor);
os.write(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 = vm.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 = vm.getStatus(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
vm.disableGarbageCollection();
int classCount = vm.getAllLoadedClassesCount();
os.writeInt(classCount);
// This will be an Iterator over all loaded Classes
Iterator iter = vm.getAllLoadedClasses();
vm.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 = vm.getStatus(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, true);
// 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.getId(thread).write(os);
}
}
private void executeTopLevelThreadGroups(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
ThreadGroup jdwpGroup = jdwp.getJdwpThreadGroup();
ThreadGroup root = getRootThreadGroup(jdwpGroup);
os.writeInt(1); // Just one top level group allowed?
idMan.getId(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
// vm.resumeAllThreadsExcept(jdwp.getJdwpThreadGroup());
// Simply shutting down the jdwp layer will take care of the rest of the
// shutdown other than disabling debugging in the VM
// vm.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
{
ObjectId oid = new ObjectId();
os.writeInt(oid.size()); // fieldId
os.writeInt(oid.size()); // methodId
os.writeInt(oid.size()); // objectId
os.writeInt(new ReferenceTypeId((byte) 0x00).size()); // referenceTypeId
os.writeInt(oid.size()); // frameId
}
private void executeSuspend(ByteBuffer bb, DataOutputStream os)
throws JdwpException
{
vm.suspendAllThreadsExcept(jdwp.getJdwpThreadGroup());
}
private void executeResume(ByteBuffer bb, DataOutputStream os)
throws JdwpException
{
vm.resumeAllThreadsExcept(jdwp.getJdwpThreadGroup());
}
private void executeExit(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
int exitCode = bb.getInt();
jdwp.setExit(exitCode);
}
private void executeCreateString(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
String string = JdwpString.readString(bb);
ObjectId stringId = Jdwp.getIdManager().getId(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
}
}
@@ -1,84 +0,0 @@
/* 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.lang.IllegalArgumentException;
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@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;
/**
* Get the input stream for the transport
*/
public InputStream getInputStream ()
throws IOException;
/**
* Get the output stream for the transport
*/
public OutputStream getOutputStream ()
throws IOException;
}
@@ -1,149 +0,0 @@
/* 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@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 ());
}
}
@@ -1,298 +0,0 @@
/* JdwpConnection.java -- A JDWP-speaking connection
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.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@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 (ITransport transport)
{
_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 ()
{
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.getInstance().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 ();
}
}
}
@@ -1,278 +0,0 @@
/* 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.transprot.JdwpReplyPacket}.
*
* @author Keith Seitz <keiths@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
* @param index index into <code>bytes</code> to start processing
* @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);
}
}
@@ -1,137 +0,0 @@
/* 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.transport.JdwpPacket} and adds additional
* reply packet-specific processing.
*
* @author Keith Seitz <keiths@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 ());
}
}
@@ -1,171 +0,0 @@
/* 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@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);
}
}
/**
* 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 ();
}
}
@@ -1,75 +0,0 @@
/* 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@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);
}
}
@@ -1,115 +0,0 @@
/* 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@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");
}
}
@@ -1,95 +0,0 @@
/* 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., 59 Temple Place, Suite 330, Boston, MA
02111-1307 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@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);
}
}
}
@@ -1,149 +0,0 @@
/* 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@redhat.com)
* @author Keith Seitz (keiths@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(';');
}
}