[llvm-commits] [llvm-gcc-4.2] r43913 [40/80] - in /llvm-gcc-4.2/trunk: boehm-gc/ boehm-gc/Mac_files/ boehm-gc/cord/ boehm-gc/doc/ boehm-gc/include/ boehm-gc/include/private/ boehm-gc/tests/ libffi/ libffi/include/ libffi/src/ libffi/src/alpha/ libffi/src/arm/ libffi/src/cris/ libffi/src/frv/ libffi/src/ia64/ libffi/src/m32r/ libffi/src/m68k/ libffi/src/mips/ libffi/src/pa/ libffi/src/powerpc/ libffi/src/s390/ libffi/src/sh/ libffi/src/sh64/ libffi/src/sparc/ libffi/src/x86/ libffi/testsuite/ libffi/testsuite/config/ li...
Bill Wendling
isanbard at gmail.com
Thu Nov 8 14:57:11 PST 2007
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/net/URI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/net/URI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/URI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/URI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1443 @@
+/* URI.java -- An URI class
+ Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.net;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * <p>
+ * A URI instance represents that defined by
+ * <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC3986</a>,
+ * with some deviations.
+ * </p>
+ * <p>
+ * At its highest level, a URI consists of:
+ * </p>
+ * <code>[<em>scheme</em><strong>:</strong>]<em>scheme-specific-part</em>
+ * [<strong>#</strong><em>fragment</em>]</code>
+ * </p>
+ * <p>
+ * where <strong>#</strong> and <strong>:</strong> are literal characters,
+ * and those parts enclosed in square brackets are optional.
+ * </p>
+ * <p>
+ * There are two main types of URI. An <em>opaque</em> URI is one
+ * which just consists of the above three parts, and is not further
+ * defined. An example of such a URI would be <em>mailto:</em> URI.
+ * In contrast, <em>hierarchical</em> URIs give further definition
+ * to the scheme-specific part, so as represent some part of a hierarchical
+ * structure.
+ * </p>
+ * <p>
+ * <code>[<strong>//</strong><em>authority</em>][<em>path</em>]
+ * [<strong>?</strong><em>query</em>]</code>
+ * </p>
+ * <p>
+ * with <strong>/</strong> and <strong>?</strong> being literal characters.
+ * When server-based, the authority section is further subdivided into:
+ * </p>
+ * <p>
+ * <code>[<em>user-info</em><strong>@</strong>]<em>host</em>
+ * [<strong>:</strong><em>port</em>]</code>
+ * </p>
+ * <p>
+ * with <strong>@</strong> and <strong>:</strong> as literal characters.
+ * Authority sections that are not server-based are said to be registry-based.
+ * </p>
+ * <p>
+ * Hierarchical URIs can be either relative or absolute. Absolute URIs
+ * always start with a `<strong>/</strong>', while relative URIs don't
+ * specify a scheme. Opaque URIs are always absolute.
+ * </p>
+ * <p>
+ * Each part of the URI may have one of three states: undefined, empty
+ * or containing some content. The former two of these are represented
+ * by <code>null</code> and the empty string in Java, respectively.
+ * The scheme-specific part may never be undefined. It also follows from
+ * this that the path sub-part may also not be undefined, so as to ensure
+ * the former.
+ * </p>
+ * <h2>Character Escaping and Quoting</h2>
+ * <p>
+ * The characters that can be used within a valid URI are restricted.
+ * There are two main classes of characters which can't be used as is
+ * within the URI:
+ * </p>
+ * <ol>
+ * <li><strong>Characters outside the US-ASCII character set</strong>.
+ * These have to be <strong>escaped</strong> in order to create
+ * an RFC-compliant URI; this means replacing the character with the
+ * appropriate hexadecimal value, preceded by a `%'.</li>
+ * <li><strong>Illegal characters</strong> (e.g. space characters,
+ * control characters) are quoted, which results in them being encoded
+ * in the same way as non-US-ASCII characters.</li>
+ * </ol>
+ * <p>
+ * The set of valid characters differs depending on the section of the URI:
+ * </p>
+ * <ul>
+ * <li><strong>Scheme</strong>: Must be an alphanumeric, `-', `.' or '+'.</li>
+ * <li><strong>Authority</strong>:Composed of the username, host, port, `@'
+ * and `:'.</li>
+ * <li><strong>Username</strong>: Allows unreserved or percent-encoded
+ * characters, sub-delimiters and `:'.</li>
+ * <li><strong>Host</strong>: Allows unreserved or percent-encoded
+ * characters, sub-delimiters and square brackets (`[' and `]') for IPv6
+ * addresses.</li>
+ * <li><strong>Port</strong>: Digits only.</li>
+ * <li><strong>Path</strong>: Allows the path characters and `/'.
+ * <li><strong>Query</strong>: Allows the path characters, `?' and '/'.
+ * <li><strong>Fragment</strong>: Allows the path characters, `?' and '/'.
+ * </ul>
+ * <p>
+ * These definitions reference the following sets of characters:
+ * </p>
+ * <ul>
+ * <li><strong>Unreserved characters</strong>: The alphanumerics plus
+ * `-', `.', `_', and `~'.</li>
+ * <li><strong>Sub-delimiters</strong>: `!', `$', `&', `(', `)', `*',
+ * `+', `,', `;', `=' and the single-quote itself.</li>
+ * <li><strong>Path characters</strong>: Unreserved and percent-encoded
+ * characters and the sub-delimiters along with `@' and `:'.</li>
+ * </ul>
+ * <p>
+ * The constructors and accessor methods allow the use and retrieval of
+ * URI components which contain non-US-ASCII characters directly.
+ * They are only escaped when the <code>toASCIIString()</code> method
+ * is used. In contrast, illegal characters are always quoted, with the
+ * exception of the return values of the non-raw accessors.
+ * </p>
+ *
+ * @author Ito Kazumitsu (ito.kazumitsu at hitachi-cable.co.jp)
+ * @author Dalibor Topic (robilad at kaffe.org)
+ * @author Michael Koch (konqueror at gmx.de)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.4
+ */
+public final class URI
+ implements Comparable, Serializable
+{
+ /**
+ * For serialization compatability.
+ */
+ static final long serialVersionUID = -6052424284110960213L;
+
+ /**
+ * Regular expression for parsing URIs.
+ *
+ * Taken from RFC 2396, Appendix B.
+ * This expression doesn't parse IPv6 addresses.
+ */
+ private static final String URI_REGEXP =
+ "^(([^:/?#]+):)?((//([^/?#]*))?([^?#]*)(\\?([^#]*))?)?(#(.*))?";
+
+ /**
+ * Regular expression for parsing the authority segment.
+ */
+ private static final String AUTHORITY_REGEXP =
+ "(([^?#]*)@)?([^?#:]*)(:([0-9]*))?";
+
+ /**
+ * Valid characters (taken from rfc2396/3986)
+ */
+ private static final String RFC2396_DIGIT = "0123456789";
+ private static final String RFC2396_LOWALPHA = "abcdefghijklmnopqrstuvwxyz";
+ private static final String RFC2396_UPALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ private static final String RFC2396_ALPHA =
+ RFC2396_LOWALPHA + RFC2396_UPALPHA;
+ private static final String RFC2396_ALPHANUM = RFC2396_DIGIT + RFC2396_ALPHA;
+ private static final String RFC3986_UNRESERVED = RFC2396_ALPHANUM + "-._~";
+ private static final String RFC3986_SUBDELIMS = "!$&'()*+,;=";
+ private static final String RFC3986_REG_NAME =
+ RFC3986_UNRESERVED + RFC3986_SUBDELIMS + "%";
+ private static final String RFC3986_PCHAR = RFC3986_UNRESERVED +
+ RFC3986_SUBDELIMS + ":@%";
+ private static final String RFC3986_SEGMENT = RFC3986_PCHAR;
+ private static final String RFC3986_PATH_SEGMENTS = RFC3986_SEGMENT + "/";
+ private static final String RFC3986_SSP = RFC3986_PCHAR + "?/";
+ private static final String RFC3986_HOST = RFC3986_REG_NAME + "[]";
+ private static final String RFC3986_USERINFO = RFC3986_REG_NAME + ":";
+
+ /**
+ * Index of scheme component in parsed URI.
+ */
+ private static final int SCHEME_GROUP = 2;
+
+ /**
+ * Index of scheme-specific-part in parsed URI.
+ */
+ private static final int SCHEME_SPEC_PART_GROUP = 3;
+
+ /**
+ * Index of authority component in parsed URI.
+ */
+ private static final int AUTHORITY_GROUP = 5;
+
+ /**
+ * Index of path component in parsed URI.
+ */
+ private static final int PATH_GROUP = 6;
+
+ /**
+ * Index of query component in parsed URI.
+ */
+ private static final int QUERY_GROUP = 8;
+
+ /**
+ * Index of fragment component in parsed URI.
+ */
+ private static final int FRAGMENT_GROUP = 10;
+
+ /**
+ * Index of userinfo component in parsed authority section.
+ */
+ private static final int AUTHORITY_USERINFO_GROUP = 2;
+
+ /**
+ * Index of host component in parsed authority section.
+ */
+ private static final int AUTHORITY_HOST_GROUP = 3;
+
+ /**
+ * Index of port component in parsed authority section.
+ */
+ private static final int AUTHORITY_PORT_GROUP = 5;
+
+ /**
+ * The compiled version of the URI regular expression.
+ */
+ private static final Pattern URI_PATTERN;
+
+ /**
+ * The compiled version of the authority regular expression.
+ */
+ private static final Pattern AUTHORITY_PATTERN;
+
+ /**
+ * The set of valid hexadecimal characters.
+ */
+ private static final String HEX = "0123456789ABCDEF";
+
+ private transient String scheme;
+ private transient String rawSchemeSpecificPart;
+ private transient String schemeSpecificPart;
+ private transient String rawAuthority;
+ private transient String authority;
+ private transient String rawUserInfo;
+ private transient String userInfo;
+ private transient String rawHost;
+ private transient String host;
+ private transient int port = -1;
+ private transient String rawPath;
+ private transient String path;
+ private transient String rawQuery;
+ private transient String query;
+ private transient String rawFragment;
+ private transient String fragment;
+ private String string;
+
+ /**
+ * Static initializer to pre-compile the regular expressions.
+ */
+ static
+ {
+ URI_PATTERN = Pattern.compile(URI_REGEXP);
+ AUTHORITY_PATTERN = Pattern.compile(AUTHORITY_REGEXP);
+ }
+
+ private void readObject(ObjectInputStream is)
+ throws ClassNotFoundException, IOException
+ {
+ this.string = (String) is.readObject();
+ try
+ {
+ parseURI(this.string);
+ }
+ catch (URISyntaxException x)
+ {
+ // Should not happen.
+ throw new RuntimeException(x);
+ }
+ }
+
+ private void writeObject(ObjectOutputStream os) throws IOException
+ {
+ if (string == null)
+ string = toString();
+ os.writeObject(string);
+ }
+
+ /**
+ * <p>
+ * Returns the string content of the specified group of the supplied
+ * matcher. The returned value is modified according to the following:
+ * </p>
+ * <ul>
+ * <li>If the resulting string has a length greater than 0, then
+ * that string is returned.</li>
+ * <li>If a string of zero length, is matched, then the content
+ * of the preceding group is considered. If this is also an empty
+ * string, then <code>null</code> is returned to indicate an undefined
+ * value. Otherwise, the value is truly the empty string and this is
+ * the returned value.</li>
+ * </ul>
+ * <p>
+ * This method is used for matching against all parts of the URI
+ * that may be either undefined or empty (i.e. all those but the
+ * scheme-specific part and the path). In each case, the preceding
+ * group is the content of the original group, along with some
+ * additional distinguishing feature. For example, the preceding
+ * group for the query includes the preceding question mark,
+ * while that of the fragment includes the hash symbol. The presence
+ * of these features enables disambiguation between the two cases
+ * of a completely unspecified value and a simple non-existant value.
+ * The scheme differs in that it will never return an empty string;
+ * the delimiter follows the scheme rather than preceding it, so
+ * it becomes part of the following section. The same is true
+ * of the user information.
+ * </p>
+ *
+ * @param match the matcher, which contains the results of the URI
+ * matched against the URI regular expression.
+ * @return either the matched content, <code>null</code> for undefined
+ * values, or an empty string for a URI part with empty content.
+ */
+ private static String getURIGroup(Matcher match, int group)
+ {
+ String matched = match.group(group);
+ if (matched == null || matched.length() == 0)
+ {
+ String prevMatched = match.group(group -1);
+ if (prevMatched == null || prevMatched.length() == 0)
+ return null;
+ else
+ return "";
+ }
+ return matched;
+ }
+
+ /**
+ * Sets fields of this URI by parsing the given string.
+ *
+ * @param str The string to parse
+ *
+ * @exception URISyntaxException If the given string violates RFC 2396
+ */
+ private void parseURI(String str) throws URISyntaxException
+ {
+ Matcher matcher = URI_PATTERN.matcher(str);
+
+ if (matcher.matches())
+ {
+ scheme = getURIGroup(matcher, SCHEME_GROUP);
+ rawSchemeSpecificPart = matcher.group(SCHEME_SPEC_PART_GROUP);
+ schemeSpecificPart = unquote(rawSchemeSpecificPart);
+ if (!isOpaque())
+ {
+ rawAuthority = getURIGroup(matcher, AUTHORITY_GROUP);
+ rawPath = matcher.group(PATH_GROUP);
+ rawQuery = getURIGroup(matcher, QUERY_GROUP);
+ }
+ rawFragment = getURIGroup(matcher, FRAGMENT_GROUP);
+ }
+ else
+ throw new URISyntaxException(str,
+ "doesn't match URI regular expression");
+ parseServerAuthority();
+
+ // We must eagerly unquote the parts, because this is the only time
+ // we may throw an exception.
+ authority = unquote(rawAuthority);
+ userInfo = unquote(rawUserInfo);
+ host = unquote(rawHost);
+ path = unquote(rawPath);
+ query = unquote(rawQuery);
+ fragment = unquote(rawFragment);
+ }
+
+ /**
+ * Unquote "%" + hex quotes characters
+ *
+ * @param str The string to unquote or null.
+ *
+ * @return The unquoted string or null if str was null.
+ *
+ * @exception URISyntaxException If the given string contains invalid
+ * escape sequences.
+ */
+ private static String unquote(String str) throws URISyntaxException
+ {
+ if (str == null)
+ return null;
+ byte[] buf = new byte[str.length()];
+ int pos = 0;
+ for (int i = 0; i < str.length(); i++)
+ {
+ char c = str.charAt(i);
+ if (c == '%')
+ {
+ if (i + 2 >= str.length())
+ throw new URISyntaxException(str, "Invalid quoted character");
+ int hi = Character.digit(str.charAt(++i), 16);
+ int lo = Character.digit(str.charAt(++i), 16);
+ if (lo < 0 || hi < 0)
+ throw new URISyntaxException(str, "Invalid quoted character");
+ buf[pos++] = (byte) (hi * 16 + lo);
+ }
+ else
+ buf[pos++] = (byte) c;
+ }
+ try
+ {
+ return new String(buf, 0, pos, "utf-8");
+ }
+ catch (java.io.UnsupportedEncodingException x2)
+ {
+ throw (Error) new InternalError().initCause(x2);
+ }
+ }
+
+ /**
+ * Quote characters illegal in URIs in given string.
+ *
+ * Replace illegal characters by encoding their UTF-8
+ * representation as "%" + hex code for each resulting
+ * UTF-8 character.
+ *
+ * @param str The string to quote
+ *
+ * @return The quoted string.
+ */
+ private static String quote(String str)
+ {
+ return quote(str, RFC3986_SSP);
+ }
+
+ /**
+ * Quote characters illegal in URI authorities in given string.
+ *
+ * Replace illegal characters by encoding their UTF-8
+ * representation as "%" + hex code for each resulting
+ * UTF-8 character.
+ *
+ * @param str The string to quote
+ *
+ * @return The quoted string.
+ */
+ private static String quoteAuthority(String str)
+ {
+ // Technically, we should be using RFC2396_AUTHORITY, but
+ // it contains no additional characters.
+ return quote(str, RFC3986_REG_NAME);
+ }
+
+ /**
+ * Quotes the characters in the supplied string that are not part of
+ * the specified set of legal characters.
+ *
+ * @param str the string to quote
+ * @param legalCharacters the set of legal characters
+ *
+ * @return the quoted string.
+ */
+ private static String quote(String str, String legalCharacters)
+ {
+ StringBuffer sb = new StringBuffer(str.length());
+ for (int i = 0; i < str.length(); i++)
+ {
+ char c = str.charAt(i);
+ if ((legalCharacters.indexOf(c) == -1)
+ && (c <= 127))
+ {
+ sb.append('%');
+ sb.append(HEX.charAt(c / 16));
+ sb.append(HEX.charAt(c % 16));
+ }
+ else
+ sb.append(c);
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Quote characters illegal in URI hosts in given string.
+ *
+ * Replace illegal characters by encoding their UTF-8
+ * representation as "%" + hex code for each resulting
+ * UTF-8 character.
+ *
+ * @param str The string to quote
+ *
+ * @return The quoted string.
+ */
+ private static String quoteHost(String str)
+ {
+ return quote(str, RFC3986_HOST);
+ }
+
+ /**
+ * Quote characters illegal in URI paths in given string.
+ *
+ * Replace illegal characters by encoding their UTF-8
+ * representation as "%" + hex code for each resulting
+ * UTF-8 character.
+ *
+ * @param str The string to quote
+ *
+ * @return The quoted string.
+ */
+ private static String quotePath(String str)
+ {
+ // Technically, we should be using RFC2396_PATH, but
+ // it contains no additional characters.
+ return quote(str, RFC3986_PATH_SEGMENTS);
+ }
+
+ /**
+ * Quote characters illegal in URI user infos in given string.
+ *
+ * Replace illegal characters by encoding their UTF-8
+ * representation as "%" + hex code for each resulting
+ * UTF-8 character.
+ *
+ * @param str The string to quote
+ *
+ * @return The quoted string.
+ */
+ private static String quoteUserInfo(String str)
+ {
+ return quote(str, RFC3986_USERINFO);
+ }
+
+ /**
+ * Creates an URI from the given string
+ *
+ * @param str The string to create the URI from
+ *
+ * @exception URISyntaxException If the given string violates RFC 2396
+ * @exception NullPointerException If str is null
+ */
+ public URI(String str) throws URISyntaxException
+ {
+ this.string = str;
+ parseURI(str);
+ }
+
+ /**
+ * Create an URI from the given components
+ *
+ * @param scheme The scheme name
+ * @param userInfo The username and authorization info
+ * @param host The hostname
+ * @param port The port number
+ * @param path The path
+ * @param query The query
+ * @param fragment The fragment
+ *
+ * @exception URISyntaxException If the given string violates RFC 2396
+ */
+ public URI(String scheme, String userInfo, String host, int port,
+ String path, String query, String fragment)
+ throws URISyntaxException
+ {
+ this((scheme == null ? "" : scheme + ":")
+ + (userInfo == null && host == null && port == -1 ? "" : "//")
+ + (userInfo == null ? "" : quoteUserInfo(userInfo) + "@")
+ + (host == null ? "" : quoteHost(host))
+ + (port == -1 ? "" : ":" + String.valueOf(port))
+ + (path == null ? "" : quotePath(path))
+ + (query == null ? "" : "?" + quote(query))
+ + (fragment == null ? "" : "#" + quote(fragment)));
+ }
+
+ /**
+ * Create an URI from the given components
+ *
+ * @param scheme The scheme name
+ * @param authority The authority
+ * @param path The apth
+ * @param query The query
+ * @param fragment The fragment
+ *
+ * @exception URISyntaxException If the given string violates RFC 2396
+ */
+ public URI(String scheme, String authority, String path, String query,
+ String fragment) throws URISyntaxException
+ {
+ this((scheme == null ? "" : scheme + ":")
+ + (authority == null ? "" : "//" + quoteAuthority(authority))
+ + (path == null ? "" : quotePath(path))
+ + (query == null ? "" : "?" + quote(query))
+ + (fragment == null ? "" : "#" + quote(fragment)));
+ }
+
+ /**
+ * Create an URI from the given components
+ *
+ * @param scheme The scheme name
+ * @param host The hostname
+ * @param path The path
+ * @param fragment The fragment
+ *
+ * @exception URISyntaxException If the given string violates RFC 2396
+ */
+ public URI(String scheme, String host, String path, String fragment)
+ throws URISyntaxException
+ {
+ this(scheme, null, host, -1, path, null, fragment);
+ }
+
+ /**
+ * Create an URI from the given components
+ *
+ * @param scheme The scheme name
+ * @param ssp The scheme specific part
+ * @param fragment The fragment
+ *
+ * @exception URISyntaxException If the given string violates RFC 2396
+ */
+ public URI(String scheme, String ssp, String fragment)
+ throws URISyntaxException
+ {
+ this((scheme == null ? "" : scheme + ":")
+ + (ssp == null ? "" : quote(ssp))
+ + (fragment == null ? "" : "#" + quote(fragment)));
+ }
+
+ /**
+ * Create an URI from the given string
+ *
+ * @param str The string to create the URI from
+ *
+ * @exception IllegalArgumentException If the given string violates RFC 2396
+ * @exception NullPointerException If str is null
+ */
+ public static URI create(String str)
+ {
+ try
+ {
+ return new URI(str);
+ }
+ catch (URISyntaxException e)
+ {
+ throw (IllegalArgumentException) new IllegalArgumentException()
+ .initCause(e);
+ }
+ }
+
+ /**
+ * Attempts to parse this URI's authority component, if defined,
+ * into user-information, host, and port components. The purpose
+ * of this method was to disambiguate between some authority sections,
+ * which form invalid server-based authories, but valid registry
+ * based authorities. In the updated RFC 3986, the authority section
+ * is defined differently, with registry-based authorities part of
+ * the host section. Thus, this method is now simply an explicit
+ * way of parsing any authority section.
+ *
+ * @return the URI, with the authority section parsed into user
+ * information, host and port components.
+ * @throws URISyntaxException if the given string violates RFC 2396
+ */
+ public URI parseServerAuthority() throws URISyntaxException
+ {
+ if (rawAuthority != null)
+ {
+ Matcher matcher = AUTHORITY_PATTERN.matcher(rawAuthority);
+
+ if (matcher.matches())
+ {
+ rawUserInfo = getURIGroup(matcher, AUTHORITY_USERINFO_GROUP);
+ rawHost = getURIGroup(matcher, AUTHORITY_HOST_GROUP);
+
+ String portStr = getURIGroup(matcher, AUTHORITY_PORT_GROUP);
+
+ if (portStr != null)
+ try
+ {
+ port = Integer.parseInt(portStr);
+ }
+ catch (NumberFormatException e)
+ {
+ URISyntaxException use =
+ new URISyntaxException
+ (string, "doesn't match URI regular expression");
+ use.initCause(e);
+ throw use;
+ }
+ }
+ else
+ throw new URISyntaxException(string,
+ "doesn't match URI regular expression");
+ }
+ return this;
+ }
+
+ /**
+ * <p>
+ * Returns a normalized version of the URI. If the URI is opaque,
+ * or its path is already in normal form, then this URI is simply
+ * returned. Otherwise, the following transformation of the path
+ * element takes place:
+ * </p>
+ * <ol>
+ * <li>All `.' segments are removed.</li>
+ * <li>Each `..' segment which can be paired with a prior non-`..' segment
+ * is removed along with the preceding segment.</li>
+ * <li>A `.' segment is added to the front if the first segment contains
+ * a colon (`:'). This is a deviation from the RFC, which prevents
+ * confusion between the path and the scheme.</li>
+ * </ol>
+ * <p>
+ * The resulting URI will be free of `.' and `..' segments, barring those
+ * that were prepended or which couldn't be paired, respectively.
+ * </p>
+ *
+ * @return the normalized URI.
+ */
+ public URI normalize()
+ {
+ if (isOpaque() || path.indexOf("/./") == -1 && path.indexOf("/../") == -1)
+ return this;
+ try
+ {
+ return new URI(scheme, authority, normalizePath(path), query,
+ fragment);
+ }
+ catch (URISyntaxException e)
+ {
+ throw (Error) new InternalError("Normalized URI variant could not "+
+ "be constructed").initCause(e);
+ }
+ }
+
+ /**
+ * <p>
+ * Normalize the given path. The following transformation takes place:
+ * </p>
+ * <ol>
+ * <li>All `.' segments are removed.</li>
+ * <li>Each `..' segment which can be paired with a prior non-`..' segment
+ * is removed along with the preceding segment.</li>
+ * <li>A `.' segment is added to the front if the first segment contains
+ * a colon (`:'). This is a deviation from the RFC, which prevents
+ * confusion between the path and the scheme.</li>
+ * </ol>
+ * <p>
+ * The resulting URI will be free of `.' and `..' segments, barring those
+ * that were prepended or which couldn't be paired, respectively.
+ * </p>
+ *
+ * @param relativePath the relative path to be normalized.
+ * @return the normalized path.
+ */
+ private String normalizePath(String relativePath)
+ {
+ /*
+ This follows the algorithm in section 5.2.4. of RFC3986,
+ but doesn't modify the input buffer.
+ */
+ StringBuffer input = new StringBuffer(relativePath);
+ StringBuffer output = new StringBuffer();
+ int start = 0;
+ while (start < input.length())
+ {
+ /* A */
+ if (input.indexOf("../",start) == start)
+ {
+ start += 3;
+ continue;
+ }
+ if (input.indexOf("./",start) == start)
+ {
+ start += 2;
+ continue;
+ }
+ /* B */
+ if (input.indexOf("/./",start) == start)
+ {
+ start += 2;
+ continue;
+ }
+ if (input.indexOf("/.",start) == start
+ && input.charAt(start + 2) != '.')
+ {
+ start += 1;
+ input.setCharAt(start,'/');
+ continue;
+ }
+ /* C */
+ if (input.indexOf("/../",start) == start)
+ {
+ start += 3;
+ removeLastSegment(output);
+ continue;
+ }
+ if (input.indexOf("/..",start) == start)
+ {
+ start += 2;
+ input.setCharAt(start,'/');
+ removeLastSegment(output);
+ continue;
+ }
+ /* D */
+ if (start == input.length() - 1 && input.indexOf(".",start) == start)
+ {
+ input.delete(0,1);
+ continue;
+ }
+ if (start == input.length() - 2 && input.indexOf("..",start) == start)
+ {
+ input.delete(0,2);
+ continue;
+ }
+ /* E */
+ int indexOfSlash = input.indexOf("/",start);
+ while (indexOfSlash == start)
+ {
+ output.append("/");
+ ++start;
+ indexOfSlash = input.indexOf("/",start);
+ }
+ if (indexOfSlash == -1)
+ indexOfSlash = input.length();
+ output.append(input.substring(start, indexOfSlash));
+ start = indexOfSlash;
+ }
+ return output.toString();
+ }
+
+ /**
+ * Removes the last segment of the path from the specified buffer.
+ *
+ * @param buffer the buffer containing the path.
+ */
+ private void removeLastSegment(StringBuffer buffer)
+ {
+ int lastSlash = buffer.lastIndexOf("/");
+ if (lastSlash == -1)
+ buffer.setLength(0);
+ else
+ buffer.setLength(lastSlash);
+ }
+
+ /**
+ * Resolves the given URI against this URI
+ *
+ * @param uri The URI to resolve against this URI
+ *
+ * @return The resulting URI, or null when it couldn't be resolved
+ * for some reason.
+ *
+ * @throws NullPointerException if uri is null
+ */
+ public URI resolve(URI uri)
+ {
+ if (uri.isAbsolute())
+ return uri;
+ if (uri.isOpaque())
+ return uri;
+
+ String scheme = uri.getScheme();
+ String schemeSpecificPart = uri.getSchemeSpecificPart();
+ String authority = uri.getAuthority();
+ String path = uri.getPath();
+ String query = uri.getQuery();
+ String fragment = uri.getFragment();
+
+ try
+ {
+ if (fragment != null && path != null && path.equals("")
+ && scheme == null && authority == null && query == null)
+ return new URI(this.scheme, this.schemeSpecificPart, fragment);
+
+ if (authority == null)
+ {
+ authority = this.authority;
+ if (path == null)
+ path = "";
+ if (! (path.startsWith("/")))
+ {
+ StringBuffer basepath = new StringBuffer(this.path);
+ int i = this.path.lastIndexOf('/');
+
+ if (i >= 0)
+ basepath.delete(i + 1, basepath.length());
+
+ basepath.append(path);
+ path = normalizePath(basepath.toString());
+ }
+ }
+ return new URI(this.scheme, authority, path, query, fragment);
+ }
+ catch (URISyntaxException e)
+ {
+ throw (Error) new InternalError("Resolved URI variant could not "+
+ "be constructed").initCause(e);
+ }
+ }
+
+ /**
+ * Resolves the given URI string against this URI
+ *
+ * @param str The URI as string to resolve against this URI
+ *
+ * @return The resulting URI
+ *
+ * @throws IllegalArgumentException If the given URI string
+ * violates RFC 2396
+ * @throws NullPointerException If uri is null
+ */
+ public URI resolve(String str) throws IllegalArgumentException
+ {
+ return resolve(create(str));
+ }
+
+ /**
+ * <p>
+ * Relativizes the given URI against this URI. The following
+ * algorithm is used:
+ * </p>
+ * <ul>
+ * <li>If either URI is opaque, the given URI is returned.</li>
+ * <li>If the schemes of the URIs differ, the given URI is returned.</li>
+ * <li>If the authority components of the URIs differ, then the given
+ * URI is returned.</li>
+ * <li>If the path of this URI is not a prefix of the supplied URI,
+ * then the given URI is returned.</li>
+ * <li>If all the above conditions hold, a new URI is created using the
+ * query and fragment components of the given URI, along with a path
+ * computed by removing the path of this URI from the start of the path
+ * of the supplied URI.</li>
+ * </ul>
+ *
+ * @param uri the URI to relativize agsint this URI
+ * @return the resulting URI
+ * @throws NullPointerException if the uri is null
+ */
+ public URI relativize(URI uri)
+ {
+ if (isOpaque() || uri.isOpaque())
+ return uri;
+ if (scheme == null && uri.getScheme() != null)
+ return uri;
+ if (scheme != null && !(scheme.equals(uri.getScheme())))
+ return uri;
+ if (rawAuthority == null && uri.getRawAuthority() != null)
+ return uri;
+ if (rawAuthority != null && !(rawAuthority.equals(uri.getRawAuthority())))
+ return uri;
+ if (!(uri.getRawPath().startsWith(rawPath)))
+ return uri;
+ try
+ {
+ return new URI(null, null,
+ uri.getRawPath().substring(rawPath.length()),
+ uri.getRawQuery(), uri.getRawFragment());
+ }
+ catch (URISyntaxException e)
+ {
+ throw (Error) new InternalError("Relativized URI variant could not "+
+ "be constructed").initCause(e);
+ }
+ }
+
+ /**
+ * Creates an URL from an URI
+ *
+ * @throws MalformedURLException If a protocol handler for the URL could
+ * not be found, or if some other error occurred while constructing the URL
+ * @throws IllegalArgumentException If the URI is not absolute
+ */
+ public URL toURL() throws IllegalArgumentException, MalformedURLException
+ {
+ if (isAbsolute())
+ return new URL(this.toString());
+
+ throw new IllegalArgumentException("not absolute");
+ }
+
+ /**
+ * Returns the scheme of the URI
+ */
+ public String getScheme()
+ {
+ return scheme;
+ }
+
+ /**
+ * Tells whether this URI is absolute or not
+ */
+ public boolean isAbsolute()
+ {
+ return scheme != null;
+ }
+
+ /**
+ * Tell whether this URI is opaque or not
+ */
+ public boolean isOpaque()
+ {
+ return ((scheme != null) && ! (schemeSpecificPart.startsWith("/")));
+ }
+
+ /**
+ * Returns the raw scheme specific part of this URI.
+ * The scheme-specific part is never undefined, though it may be empty
+ */
+ public String getRawSchemeSpecificPart()
+ {
+ return rawSchemeSpecificPart;
+ }
+
+ /**
+ * Returns the decoded scheme specific part of this URI.
+ */
+ public String getSchemeSpecificPart()
+ {
+ return schemeSpecificPart;
+ }
+
+ /**
+ * Returns the raw authority part of this URI
+ */
+ public String getRawAuthority()
+ {
+ return rawAuthority;
+ }
+
+ /**
+ * Returns the decoded authority part of this URI
+ */
+ public String getAuthority()
+ {
+ return authority;
+ }
+
+ /**
+ * Returns the raw user info part of this URI
+ */
+ public String getRawUserInfo()
+ {
+ return rawUserInfo;
+ }
+
+ /**
+ * Returns the decoded user info part of this URI
+ */
+ public String getUserInfo()
+ {
+ return userInfo;
+ }
+
+ /**
+ * Returns the hostname of the URI
+ */
+ public String getHost()
+ {
+ return host;
+ }
+
+ /**
+ * Returns the port number of the URI
+ */
+ public int getPort()
+ {
+ return port;
+ }
+
+ /**
+ * Returns the raw path part of this URI
+ */
+ public String getRawPath()
+ {
+ return rawPath;
+ }
+
+ /**
+ * Returns the path of the URI
+ */
+ public String getPath()
+ {
+ return path;
+ }
+
+ /**
+ * Returns the raw query part of this URI
+ */
+ public String getRawQuery()
+ {
+ return rawQuery;
+ }
+
+ /**
+ * Returns the query of the URI
+ */
+ public String getQuery()
+ {
+ return query;
+ }
+
+ /**
+ * Return the raw fragment part of this URI
+ */
+ public String getRawFragment()
+ {
+ return rawFragment;
+ }
+
+ /**
+ * Returns the fragment of the URI
+ */
+ public String getFragment()
+ {
+ return fragment;
+ }
+
+ /**
+ * <p>
+ * Compares the URI with the given object for equality. If the
+ * object is not a <code>URI</code>, then the method returns false.
+ * Otherwise, the following criteria are observed:
+ * </p>
+ * <ul>
+ * <li>The scheme of the URIs must either be null (undefined) in both cases,
+ * or equal, ignorant of case.</li>
+ * <li>The raw fragment of the URIs must either be null (undefined) in both
+ * cases, or equal, ignorant of case.</li>
+ * <li>Both URIs must be of the same type (opaque or hierarchial)</li>
+ * <li><strong>For opaque URIs:</strong></li>
+ * <ul>
+ * <li>The raw scheme-specific parts must be equal.</li>
+ * </ul>
+ * <li>For hierarchical URIs:</li>
+ * <ul>
+ * <li>The raw paths must be equal, ignorant of case.</li>
+ * <li>The raw queries are either both undefined or both equal, ignorant
+ * of case.</li>
+ * <li>The raw authority sections are either both undefined or:</li>
+ * <li><strong>For registry-based authorities:</strong></li>
+ * <ul><li>they are equal.</li></ul>
+ * <li><strong>For server-based authorities:</strong></li>
+ * <ul>
+ * <li>the hosts are equal, ignoring case</li>
+ * <li>the ports are equal</li>
+ * <li>the user information components are equal</li>
+ * </ul>
+ * </ul>
+ * </ul>
+ *
+ * @param obj the obj to compare the URI with.
+ * @return <code>true</code> if the objects are equal, according to
+ * the specification above.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof URI))
+ return false;
+ URI uriObj = (URI) obj;
+ if (scheme == null)
+ {
+ if (uriObj.getScheme() != null)
+ return false;
+ }
+ else
+ if (!(scheme.equalsIgnoreCase(uriObj.getScheme())))
+ return false;
+ if (rawFragment == null)
+ {
+ if (uriObj.getRawFragment() != null)
+ return false;
+ }
+ else
+ if (!(rawFragment.equalsIgnoreCase(uriObj.getRawFragment())))
+ return false;
+ boolean opaqueThis = isOpaque();
+ boolean opaqueObj = uriObj.isOpaque();
+ if (opaqueThis && opaqueObj)
+ return rawSchemeSpecificPart.equals(uriObj.getRawSchemeSpecificPart());
+ else if (!opaqueThis && !opaqueObj)
+ {
+ boolean common = rawPath.equalsIgnoreCase(uriObj.getRawPath())
+ && ((rawQuery == null && uriObj.getRawQuery() == null)
+ || rawQuery.equalsIgnoreCase(uriObj.getRawQuery()));
+ if (rawAuthority == null && uriObj.getRawAuthority() == null)
+ return common;
+ if (host == null)
+ return common
+ && rawAuthority.equalsIgnoreCase(uriObj.getRawAuthority());
+ return common
+ && host.equalsIgnoreCase(uriObj.getHost())
+ && port == uriObj.getPort()
+ && (rawUserInfo == null ?
+ uriObj.getRawUserInfo() == null :
+ rawUserInfo.equalsIgnoreCase(uriObj.getRawUserInfo()));
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Computes the hashcode of the URI
+ */
+ public int hashCode()
+ {
+ return (getScheme() == null ? 0 : 13 * getScheme().hashCode())
+ + 17 * getRawSchemeSpecificPart().hashCode()
+ + (getRawFragment() == null ? 0 : 21 + getRawFragment().hashCode());
+ }
+
+ /**
+ * Compare the URI with another object that must also be a URI.
+ * Undefined components are taken to be less than any other component.
+ * The following criteria are observed:
+ * </p>
+ * <ul>
+ * <li>Two URIs with different schemes are compared according to their
+ * scheme, regardless of case.</li>
+ * <li>A hierarchical URI is less than an opaque URI with the same
+ * scheme.</li>
+ * <li><strong>For opaque URIs:</strong></li>
+ * <ul>
+ * <li>URIs with differing scheme-specific parts are ordered according
+ * to the ordering of the scheme-specific part.</li>
+ * <li>URIs with the same scheme-specific part are ordered by the
+ * raw fragment.</li>
+ * </ul>
+ * <li>For hierarchical URIs:</li>
+ * <ul>
+ * <li>URIs are ordered according to their raw authority sections,
+ * if they are unequal.</li>
+ * <li><strong>For registry-based authorities:</strong></li>
+ * <ul><li>they are ordered according to the ordering of the authority
+ * component.</li></ul>
+ * <li><strong>For server-based authorities:</strong></li>
+ * <ul>
+ * <li>URIs are ordered according to the raw user information.</li>
+ * <li>URIs with the same user information are ordered by the host,
+ * ignoring case.</li>
+ * <lI>URIs with the same host are ordered by the port.</li>
+ * </ul>
+ * <li>URIs with the same authority section are ordered by the raw path.</li>
+ * <li>URIs with the same path are ordered by their raw query.</li>
+ * <li>URIs with the same query are ordered by their raw fragments.</li>
+ * </ul>
+ * </ul>
+ *
+ * @param obj This object to compare this URI with
+ * @return a negative integer, zero or a positive integer depending
+ * on whether this URI is less than, equal to or greater
+ * than that supplied, respectively.
+ * @throws ClassCastException if the given object is not a URI
+ */
+ public int compareTo(Object obj)
+ throws ClassCastException
+ {
+ URI uri = (URI) obj;
+ if (scheme == null && uri.getScheme() != null)
+ return -1;
+ if (scheme != null)
+ {
+ int sCompare = scheme.compareToIgnoreCase(uri.getScheme());
+ if (sCompare != 0)
+ return sCompare;
+ }
+ boolean opaqueThis = isOpaque();
+ boolean opaqueObj = uri.isOpaque();
+ if (opaqueThis && !opaqueObj)
+ return 1;
+ if (!opaqueThis && opaqueObj)
+ return -1;
+ if (opaqueThis)
+ {
+ int ssCompare =
+ rawSchemeSpecificPart.compareTo(uri.getRawSchemeSpecificPart());
+ if (ssCompare == 0)
+ return compareFragments(uri);
+ else
+ return ssCompare;
+ }
+ if (rawAuthority == null && uri.getRawAuthority() != null)
+ return -1;
+ if (rawAuthority != null)
+ {
+ int aCompare = rawAuthority.compareTo(uri.getRawAuthority());
+ if (aCompare != 0)
+ {
+ if (host == null)
+ return aCompare;
+ if (rawUserInfo == null && uri.getRawUserInfo() != null)
+ return -1;
+ int uCompare = rawUserInfo.compareTo(uri.getRawUserInfo());
+ if (uCompare != 0)
+ return uCompare;
+ if (host == null && uri.getHost() != null)
+ return -1;
+ int hCompare = host.compareTo(uri.getHost());
+ if (hCompare != 0)
+ return hCompare;
+ return new Integer(port).compareTo(new Integer(uri.getPort()));
+ }
+ }
+ if (rawPath == null && uri.getRawPath() != null)
+ return -1;
+ if (rawPath != null)
+ {
+ int pCompare = rawPath.compareTo(uri.getRawPath());
+ if (pCompare != 0)
+ return pCompare;
+ }
+ if (rawQuery == null && uri.getRawQuery() != null)
+ return -1;
+ if (rawQuery != null)
+ {
+ int qCompare = rawQuery.compareTo(uri.getRawQuery());
+ if (qCompare != 0)
+ return qCompare;
+ }
+ return compareFragments(uri);
+ }
+
+ /**
+ * Compares the fragment of this URI with that of the supplied URI.
+ *
+ * @param uri the URI to compare with this one.
+ * @return a negative integer, zero or a positive integer depending
+ * on whether this uri's fragment is less than, equal to
+ * or greater than the fragment of the uri supplied, respectively.
+ */
+ private int compareFragments(URI uri)
+ {
+ if (rawFragment == null && uri.getRawFragment() != null)
+ return -1;
+ else if (rawFragment == null)
+ return 0;
+ else
+ return rawFragment.compareTo(uri.getRawFragment());
+ }
+
+ /**
+ * Returns the URI as a String. If the URI was created using a constructor,
+ * then this will be the same as the original input string.
+ *
+ * @return a string representation of the URI.
+ */
+ public String toString()
+ {
+ return (scheme == null ? "" : scheme + ":")
+ + rawSchemeSpecificPart
+ + (rawFragment == null ? "" : "#" + rawFragment);
+ }
+
+ /**
+ * Returns the URI as US-ASCII string. This is the same as the result
+ * from <code>toString()</code> for URIs that don't contain any non-US-ASCII
+ * characters. Otherwise, the non-US-ASCII characters are replaced
+ * by their percent-encoded representations.
+ *
+ * @return a string representation of the URI, containing only US-ASCII
+ * characters.
+ */
+ public String toASCIIString()
+ {
+ String strRep = toString();
+ boolean inNonAsciiBlock = false;
+ StringBuffer buffer = new StringBuffer();
+ StringBuffer encBuffer = null;
+ for (int i = 0; i < strRep.length(); i++)
+ {
+ char c = strRep.charAt(i);
+ if (c <= 127)
+ {
+ if (inNonAsciiBlock)
+ {
+ buffer.append(escapeCharacters(encBuffer.toString()));
+ inNonAsciiBlock = false;
+ }
+ buffer.append(c);
+ }
+ else
+ {
+ if (!inNonAsciiBlock)
+ {
+ encBuffer = new StringBuffer();
+ inNonAsciiBlock = true;
+ }
+ encBuffer.append(c);
+ }
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Converts the non-ASCII characters in the supplied string
+ * to their equivalent percent-encoded representations.
+ * That is, they are replaced by "%" followed by their hexadecimal value.
+ *
+ * @param str a string including non-ASCII characters.
+ * @return the string with the non-ASCII characters converted to their
+ * percent-encoded representations.
+ */
+ private static String escapeCharacters(String str)
+ {
+ try
+ {
+ StringBuffer sb = new StringBuffer();
+ // this is far from optimal, but it works
+ byte[] utf8 = str.getBytes("utf-8");
+ for (int j = 0; j < utf8.length; j++)
+ {
+ sb.append('%');
+ sb.append(HEX.charAt((utf8[j] & 0xff) / 16));
+ sb.append(HEX.charAt((utf8[j] & 0xff) % 16));
+ }
+ return sb.toString();
+ }
+ catch (java.io.UnsupportedEncodingException x)
+ {
+ throw (Error) new InternalError("Escaping error").initCause(x);
+ }
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/net/URISyntaxException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/net/URISyntaxException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/URISyntaxException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/URISyntaxException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,144 @@
+/* URISyntaxException.java -- a string could not be parsed as a URI
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.net;
+
+
+/**
+ * This exception is thrown when a String cannot be parsed as a URI.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see URI
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public class URISyntaxException extends Exception
+{
+ /**
+ * Compatible with JDK 1.4+.
+ */
+ private static final long serialVersionUID = 2137979680897488891L;
+
+ /**
+ * The failed input.
+ *
+ * @serial the bad URI
+ */
+ private final String input;
+
+ /**
+ * The index of failure.
+ *
+ * @serial the location of the problem
+ */
+ private final int index;
+
+ /**
+ * Create an exception from the invalid string, with the index set to -1.
+ *
+ * @param input the bad URI
+ * @param msg the descriptive error message
+ * @throws NullPointerException if input or msg are null
+ */
+ public URISyntaxException(String input, String msg)
+ {
+ this(input, msg, -1);
+ }
+
+ /**
+ * Create an exception from the invalid string, with the index of the
+ * point of failure.
+ *
+ * @param input the bad URI
+ * @param msg the descriptive error message
+ * @param index the index of the parse error, or -1
+ * @throws NullPointerException if input or msg are null
+ * @throws IllegalArgumentException if index < -1
+ */
+ public URISyntaxException(String input, String msg, int index)
+ {
+ // The toString() hack checks for null.
+ super(msg.toString());
+ this.input = input.toString();
+ this.index = index;
+ if (index < -1)
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * Returns the bad input string.
+ *
+ * @return the bad URI, guaranteed non-null
+ */
+ public String getInput()
+ {
+ return input;
+ }
+
+ /**
+ * Returns the reason for the failure.
+ *
+ * @return the message, guaranteed non-null
+ */
+ public String getReason()
+ {
+ return super.getMessage();
+ }
+
+ /**
+ * Returns the index of the failure, or -1.
+ *
+ * @return the index of failure
+ */
+ public int getIndex()
+ {
+ return index;
+ }
+
+ /**
+ * Returns a message describing the parse error, as if by
+ * <code>getReason() + (getIndex() >= 0 ? " at index " + getIndex() : "")
+ * + ": " + getInput()</code>.
+ *
+ * @return the message string
+ */
+ public String getMessage()
+ {
+ return (super.getMessage() + (index >= 0 ? " at index " + index : "")
+ + ": " + input);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/net/URL.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/net/URL.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/URL.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/URL.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,985 @@
+/* URL.java -- Uniform Resource Locator Class
+ Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.net;
+
+import gnu.classpath.SystemProperties;
+import gnu.java.net.URLParseError;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
+
+/*
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status: Believed complete and correct.
+ */
+
+/**
+ * This final class represents an Internet Uniform Resource Locator (URL).
+ * For details on the syntax of URL's and what they can be used for,
+ * refer to RFC 1738, available from <a
+ * href="http://ds.internic.net/rfcs/rfc1738.txt">
+ * http://ds.internic.net/rfcs/rfc1738.txt</a>
+ * <p>
+ * There are a great many protocols supported by URL's such as "http",
+ * "ftp", and "file". This object can handle any arbitrary URL for which
+ * a URLStreamHandler object can be written. Default protocol handlers
+ * are provided for the "http" and "ftp" protocols. Additional protocols
+ * handler implementations may be provided in the future. In any case,
+ * an application or applet can install its own protocol handlers that
+ * can be "chained" with other protocol hanlders in the system to extend
+ * the base functionality provided with this class. (Note, however, that
+ * unsigned applets cannot access properties by default or install their
+ * own protocol handlers).
+ * <p>
+ * This chaining is done via the system property java.protocol.handler.pkgs
+ * If this property is set, it is assumed to be a "|" separated list of
+ * package names in which to attempt locating protocol handlers. The
+ * protocol handler is searched for by appending the string
+ * ".<protocol>.Handler" to each packed in the list until a hander is
+ * found. If a protocol handler is not found in this list of packages, or if
+ * the property does not exist, then the default protocol handler of
+ * "gnu.java.net.<protocol>.Handler" is tried. If this is
+ * unsuccessful, a MalformedURLException is thrown.
+ * <p>
+ * All of the constructor methods of URL attempt to load a protocol
+ * handler and so any needed protocol handlers must be installed when
+ * the URL is constructed.
+ * <p>
+ * Here is an example of how URL searches for protocol handlers. Assume
+ * the value of java.protocol.handler.pkgs is "com.foo|com.bar" and the
+ * URL is "news://comp.lang.java.programmer". URL would looking the
+ * following places for protocol handlers:
+ * <p><pre>
+ * com.foo.news.Handler
+ * com.bar.news.Handler
+ * gnu.java.net.news.Handler
+ * </pre><p>
+ * If the protocol handler is not found in any of those locations, a
+ * MalformedURLException would be thrown.
+ * <p>
+ * Please note that a protocol handler must be a subclass of
+ * URLStreamHandler.
+ * <p>
+ * Normally, this class caches protocol handlers. Once it finds a handler
+ * for a particular protocol, it never tries to look up a new handler
+ * again. However, if the system property
+ * gnu.java.net.nocache_protocol_handlers is set, then this
+ * caching behavior is disabled. This property is specific to this
+ * implementation. Sun's JDK may or may not do protocol caching, but it
+ * almost certainly does not examine this property.
+ * <p>
+ * Please also note that an application can install its own factory for
+ * loading protocol handlers (see setURLStreamHandlerFactory). If this is
+ * done, then the above information is superseded and the behavior of this
+ * class in loading protocol handlers is dependent on that factory.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ *
+ * @see URLStreamHandler
+ */
+public final class URL implements Serializable
+{
+ private static final String DEFAULT_SEARCH_PATH =
+ "gnu.java.net.protocol|gnu.inet";
+
+ // Cached System ClassLoader
+ private static ClassLoader systemClassLoader;
+
+ /**
+ * The name of the protocol for this URL.
+ * The protocol is always stored in lower case.
+ */
+ private String protocol;
+
+ /**
+ * The "authority" portion of the URL.
+ */
+ private String authority;
+
+ /**
+ * The hostname or IP address of this protocol.
+ * This includes a possible user. For example <code>joe at some.host.net</code>.
+ */
+ private String host;
+
+ /**
+ * The user information necessary to establish the connection.
+ */
+ private String userInfo;
+
+ /**
+ * The port number of this protocol or -1 if the port number used is
+ * the default for this protocol.
+ */
+ private int port = -1; // Initialize for constructor using context.
+
+ /**
+ * The "file" portion of the URL. It is defined as <code>path[?query]</code>.
+ */
+ private String file;
+
+ /**
+ * The anchor portion of the URL.
+ */
+ private String ref;
+
+ /**
+ * This is the hashCode for this URL
+ */
+ private int hashCode;
+
+ /**
+ * The protocol handler in use for this URL
+ */
+ transient URLStreamHandler ph;
+
+ /**
+ * If an application installs its own protocol handler factory, this is
+ * where we keep track of it.
+ */
+ private static URLStreamHandlerFactory factory;
+ private static final long serialVersionUID = -7627629688361524110L;
+
+ /**
+ * This a table where we cache protocol handlers to avoid the overhead
+ * of looking them up each time.
+ */
+ private static HashMap ph_cache = new HashMap();
+
+ /**
+ * Whether or not to cache protocol handlers.
+ */
+ private static boolean cache_handlers;
+
+ static
+ {
+ String s = SystemProperties.getProperty("gnu.java.net.nocache_protocol_handlers");
+
+ if (s == null)
+ cache_handlers = true;
+ else
+ cache_handlers = false;
+ }
+
+ /**
+ * Constructs a URL and loads a protocol handler for the values passed as
+ * arguments.
+ *
+ * @param protocol The protocol for this URL ("http", "ftp", etc)
+ * @param host The hostname or IP address to connect to
+ * @param port The port number to use, or -1 to use the protocol's
+ * default port
+ * @param file The "file" portion of the URL.
+ *
+ * @exception MalformedURLException If a protocol handler cannot be loaded or
+ * a parse error occurs.
+ */
+ public URL(String protocol, String host, int port, String file)
+ throws MalformedURLException
+ {
+ this(protocol, host, port, file, null);
+ }
+
+ /**
+ * Constructs a URL and loads a protocol handler for the values passed in
+ * as arugments. Uses the default port for the protocol.
+ *
+ * @param protocol The protocol for this URL ("http", "ftp", etc)
+ * @param host The hostname or IP address for this URL
+ * @param file The "file" portion of this URL.
+ *
+ * @exception MalformedURLException If a protocol handler cannot be loaded or
+ * a parse error occurs.
+ */
+ public URL(String protocol, String host, String file)
+ throws MalformedURLException
+ {
+ this(protocol, host, -1, file, null);
+ }
+
+ /**
+ * This method initializes a new instance of <code>URL</code> with the
+ * specified protocol, host, port, and file. Additionally, this method
+ * allows the caller to specify a protocol handler to use instead of
+ * the default. If this handler is specified, the caller must have
+ * the "specifyStreamHandler" permission (see <code>NetPermission</code>)
+ * or a <code>SecurityException</code> will be thrown.
+ *
+ * @param protocol The protocol for this URL ("http", "ftp", etc)
+ * @param host The hostname or IP address to connect to
+ * @param port The port number to use, or -1 to use the protocol's default
+ * port
+ * @param file The "file" portion of the URL.
+ * @param ph The protocol handler to use with this URL.
+ *
+ * @exception MalformedURLException If no protocol handler can be loaded
+ * for the specified protocol.
+ * @exception SecurityException If the <code>SecurityManager</code> exists
+ * and does not allow the caller to specify its own protocol handler.
+ *
+ * @since 1.2
+ */
+ public URL(String protocol, String host, int port, String file,
+ URLStreamHandler ph) throws MalformedURLException
+ {
+ if (protocol == null)
+ throw new MalformedURLException("null protocol");
+ protocol = protocol.toLowerCase();
+ this.protocol = protocol;
+
+ if (ph != null)
+ {
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkPermission(new NetPermission("specifyStreamHandler"));
+
+ this.ph = ph;
+ }
+ else
+ this.ph = getURLStreamHandler(protocol);
+
+ if (this.ph == null)
+ throw new MalformedURLException("Protocol handler not found: "
+ + protocol);
+
+ this.host = host;
+ this.port = port;
+ this.authority = (host != null) ? host : "";
+ if (port >= 0 && host != null)
+ this.authority += ":" + port;
+
+ int hashAt = file.indexOf('#');
+ if (hashAt < 0)
+ {
+ this.file = file;
+ this.ref = null;
+ }
+ else
+ {
+ this.file = file.substring(0, hashAt);
+ this.ref = file.substring(hashAt + 1);
+ }
+ hashCode = hashCode(); // Used for serialization.
+ }
+
+ /**
+ * Initializes a URL from a complete string specification such as
+ * "http://www.urbanophile.com/arenn/". First the protocol name is parsed
+ * out of the string. Then a handler is located for that protocol and
+ * the parseURL() method of that protocol handler is used to parse the
+ * remaining fields.
+ *
+ * @param spec The complete String representation of a URL
+ *
+ * @exception MalformedURLException If a protocol handler cannot be found
+ * or the URL cannot be parsed
+ */
+ public URL(String spec) throws MalformedURLException
+ {
+ this((URL) null, spec != null ? spec : "", (URLStreamHandler) null);
+ }
+
+ /**
+ * This method parses a String representation of a URL within the
+ * context of an existing URL. Principally this means that any
+ * fields not present the URL are inheritied from the context URL.
+ * This allows relative URL's to be easily constructed. If the
+ * context argument is null, then a complete URL must be specified
+ * in the URL string. If the protocol parsed out of the URL is
+ * different from the context URL's protocol, then then URL String
+ * is also expected to be a complete URL.
+ *
+ * @param context The context on which to parse the specification
+ * @param spec The string to parse an URL
+ *
+ * @exception MalformedURLException If a protocol handler cannot be found
+ * for the URL cannot be parsed
+ */
+ public URL(URL context, String spec) throws MalformedURLException
+ {
+ this(context, spec, (context == null) ? (URLStreamHandler)null : context.ph);
+ }
+
+ /**
+ * Creates an URL from given arguments
+ * This method parses a String representation of a URL within the
+ * context of an existing URL. Principally this means that any fields
+ * not present the URL are inheritied from the context URL. This allows
+ * relative URL's to be easily constructed. If the context argument is
+ * null, then a complete URL must be specified in the URL string.
+ * If the protocol parsed out of the URL is different
+ * from the context URL's protocol, then then URL String is also
+ * expected to be a complete URL.
+ * <p>
+ * Additionally, this method allows the caller to specify a protocol handler
+ * to use instead of the default. If this handler is specified, the caller
+ * must have the "specifyStreamHandler" permission
+ * (see <code>NetPermission</code>) or a <code>SecurityException</code>
+ * will be thrown.
+ *
+ * @param context The context in which to parse the specification
+ * @param spec The string to parse as an URL
+ * @param ph The stream handler for the URL
+ *
+ * @exception MalformedURLException If a protocol handler cannot be found
+ * or the URL cannot be parsed
+ * @exception SecurityException If the <code>SecurityManager</code> exists
+ * and does not allow the caller to specify its own protocol handler.
+ *
+ * @since 1.2
+ */
+ public URL(URL context, String spec, URLStreamHandler ph)
+ throws MalformedURLException
+ {
+ /* A protocol is defined by the doc as the substring before a ':'
+ * as long as the ':' occurs before any '/'.
+ *
+ * If context is null, then spec must be an absolute URL.
+ *
+ * The relative URL need not specify all the components of a URL.
+ * If the protocol, host name, or port number is missing, the value
+ * is inherited from the context. A bare file component is appended
+ * to the context's file. The optional anchor is not inherited.
+ */
+
+ // If this is an absolute URL, then ignore context completely.
+ // An absolute URL must have chars prior to "://" but cannot have a colon
+ // right after the "://". The second colon is for an optional port value
+ // and implies that the host from the context is used if available.
+ int colon;
+ int slash = spec.indexOf('/');
+ if ((colon = spec.indexOf("://", 1)) > 0
+ && ((colon < slash || slash < 0))
+ && ! spec.regionMatches(colon, "://:", 0, 4))
+ context = null;
+
+ boolean protocolSpecified = false;
+
+ if ((colon = spec.indexOf(':')) > 0
+ && (colon < slash || slash < 0))
+ {
+ // Protocol may have been specified in spec string.
+ protocolSpecified = true;
+ protocol = spec.substring(0, colon).toLowerCase();
+ if (context != null)
+ {
+ if (context.protocol.equals(protocol))
+ {
+ // The 1.2 doc specifically says these are copied to the new URL.
+ host = context.host;
+ port = context.port;
+ userInfo = context.userInfo;
+ authority = context.authority;
+ }
+ else
+ {
+ // There was a colon in the spec. Check to see if
+ // what precedes it is a valid protocol. If it was
+ // not, assume that it is relative to the context.
+ URLStreamHandler specPh = getURLStreamHandler(protocol.trim());
+ if (null == specPh)
+ protocolSpecified = false;
+ }
+ }
+ }
+
+ if (!protocolSpecified)
+ {
+ if (context != null)
+ {
+ // Protocol NOT specified in spec string.
+ // Use context fields (except ref) as a foundation for relative URLs.
+ colon = -1;
+ protocol = context.protocol;
+ host = context.host;
+ port = context.port;
+ userInfo = context.userInfo;
+ if (spec.indexOf(":/", 1) < 0)
+ {
+ file = context.file;
+ if (file == null || file.length() == 0)
+ file = "/";
+ }
+ authority = context.authority;
+ }
+ else // Protocol NOT specified in spec. and no context available.
+ throw new MalformedURLException("Absolute URL required with null"
+ + " context: " + spec);
+ }
+
+ protocol = protocol.trim();
+
+ if (ph != null)
+ {
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkPermission(new NetPermission("specifyStreamHandler"));
+
+ this.ph = ph;
+ }
+ else
+ this.ph = getURLStreamHandler(protocol);
+
+ if (this.ph == null)
+ throw new MalformedURLException("Protocol handler not found: "
+ + protocol);
+
+ // JDK 1.2 doc for parseURL specifically states that any '#' ref
+ // is to be excluded by passing the 'limit' as the indexOf the '#'
+ // if one exists, otherwise pass the end of the string.
+ int hashAt = spec.indexOf('#', colon + 1);
+
+ try
+ {
+ this.ph.parseURL(this, spec, colon + 1,
+ hashAt < 0 ? spec.length() : hashAt);
+ }
+ catch (URLParseError e)
+ {
+ MalformedURLException mue = new MalformedURLException(e.getMessage());
+ mue.initCause(e);
+ throw mue;
+ }
+ catch (RuntimeException e)
+ {
+ // This isn't documented, but the JDK also catches
+ // RuntimeExceptions here.
+ MalformedURLException mue = new MalformedURLException(e.getMessage());
+ mue.initCause(e);
+ throw mue;
+ }
+
+ if (hashAt >= 0)
+ ref = spec.substring(hashAt + 1);
+
+ hashCode = hashCode(); // Used for serialization.
+ }
+
+ /**
+ * Test another URL for equality with this one. This will be true only if
+ * the argument is non-null and all of the fields in the URL's match
+ * exactly (ie, protocol, host, port, file, and ref). Overrides
+ * Object.equals(), implemented by calling the equals method of the handler.
+ *
+ * @param obj The URL to compare with
+ *
+ * @return true if the URL is equal, false otherwise
+ */
+ public boolean equals(Object obj)
+ {
+ if (! (obj instanceof URL))
+ return false;
+
+ return ph.equals(this, (URL) obj);
+ }
+
+ /**
+ * Returns the contents of this URL as an object by first opening a
+ * connection, then calling the getContent() method against the connection
+ *
+ * @return A content object for this URL
+ * @exception IOException If opening the connection or getting the
+ * content fails.
+ *
+ * @since 1.3
+ */
+ public Object getContent() throws IOException
+ {
+ return openConnection().getContent();
+ }
+
+ /**
+ * Gets the contents of this URL
+ *
+ * @param classes The allow classes for the content object.
+ *
+ * @return a context object for this URL.
+ *
+ * @exception IOException If an error occurs
+ */
+ public Object getContent(Class[] classes) throws IOException
+ {
+ return openConnection().getContent(classes);
+ }
+
+ /**
+ * Returns the file portion of the URL.
+ * Defined as <code>path[?query]</code>.
+ * Returns the empty string if there is no file portion.
+ *
+ * @return The filename specified in this URL, or an empty string if empty.
+ */
+ public String getFile()
+ {
+ return file == null ? "" : file;
+ }
+
+ /**
+ * Returns the path of the URL. This is the part of the file before any '?'
+ * character.
+ *
+ * @return The path specified in this URL, or null if empty.
+ *
+ * @since 1.3
+ */
+ public String getPath()
+ {
+ // The spec says we need to return an empty string, but some
+ // applications depends on receiving null when the path is empty.
+ if (file == null)
+ return null;
+ int quest = file.indexOf('?');
+ return quest < 0 ? getFile() : file.substring(0, quest);
+ }
+
+ /**
+ * Returns the authority of the URL
+ *
+ * @return The authority specified in this URL.
+ *
+ * @since 1.3
+ */
+ public String getAuthority()
+ {
+ return authority;
+ }
+
+ /**
+ * Returns the host of the URL
+ *
+ * @return The host specified in this URL.
+ */
+ public String getHost()
+ {
+ int at = (host == null) ? -1 : host.indexOf('@');
+ return at < 0 ? host : host.substring(at + 1, host.length());
+ }
+
+ /**
+ * Returns the port number of this URL or -1 if the default port number is
+ * being used.
+ *
+ * @return The port number
+ *
+ * @see #getDefaultPort()
+ */
+ public int getPort()
+ {
+ return port;
+ }
+
+ /**
+ * Returns the default port of the URL. If the StreamHandler for the URL
+ * protocol does not define a default port it returns -1.
+ *
+ * @return The default port of the current protocol.
+ */
+ public int getDefaultPort()
+ {
+ return ph.getDefaultPort();
+ }
+
+ /**
+ * Returns the protocol of the URL
+ *
+ * @return The specified protocol.
+ */
+ public String getProtocol()
+ {
+ return protocol;
+ }
+
+ /**
+ * Returns the ref (sometimes called the "# reference" or "anchor") portion
+ * of the URL.
+ *
+ * @return The ref
+ */
+ public String getRef()
+ {
+ return ref;
+ }
+
+ /**
+ * Returns the user information of the URL. This is the part of the host
+ * name before the '@'.
+ *
+ * @return the user at a particular host or null when no user defined.
+ */
+ public String getUserInfo()
+ {
+ if (userInfo != null)
+ return userInfo;
+ int at = (host == null) ? -1 : host.indexOf('@');
+ return at < 0 ? null : host.substring(0, at);
+ }
+
+ /**
+ * Returns the query of the URL. This is the part of the file before the
+ * '?'.
+ *
+ * @return the query part of the file, or null when there is no query part.
+ */
+ public String getQuery()
+ {
+ int quest = (file == null) ? -1 : file.indexOf('?');
+ return quest < 0 ? null : file.substring(quest + 1, file.length());
+ }
+
+ /**
+ * Returns a hashcode computed by the URLStreamHandler of this URL
+ *
+ * @return The hashcode for this URL.
+ */
+ public int hashCode()
+ {
+ if (hashCode != 0)
+ return hashCode; // Use cached value if available.
+ else
+ return ph.hashCode(this);
+ }
+
+ /**
+ * Returns a URLConnection object that represents a connection to the remote
+ * object referred to by the URL. The URLConnection is created by calling the
+ * openConnection() method of the protocol handler
+ *
+ * @return A URLConnection for this URL
+ *
+ * @exception IOException If an error occurs
+ */
+ public URLConnection openConnection() throws IOException
+ {
+ return ph.openConnection(this);
+ }
+
+ /**
+ * Opens a connection to this URL and returns an InputStream for reading
+ * from that connection
+ *
+ * @return An <code>InputStream</code> for this URL.
+ *
+ * @exception IOException If an error occurs
+ */
+ public InputStream openStream() throws IOException
+ {
+ return openConnection().getInputStream();
+ }
+
+ /**
+ * Tests whether or not another URL refers to the same "file" as this one.
+ * This will be true if and only if the passed object is not null, is a
+ * URL, and matches all fields but the ref (ie, protocol, host, port,
+ * and file);
+ *
+ * @param url The URL object to test with
+ *
+ * @return true if URL matches this URL's file, false otherwise
+ */
+ public boolean sameFile(URL url)
+ {
+ return ph.sameFile(this, url);
+ }
+
+ /**
+ * Sets the specified fields of the URL. This is not a public method so
+ * that only URLStreamHandlers can modify URL fields. This might be called
+ * by the <code>parseURL()</code> method in that class. URLs are otherwise
+ * constant. If the given protocol does not exist, it will keep the previously
+ * set protocol.
+ *
+ * @param protocol The protocol name for this URL
+ * @param host The hostname or IP address for this URL
+ * @param port The port number of this URL
+ * @param file The "file" portion of this URL.
+ * @param ref The anchor portion of this URL.
+ */
+ protected void set(String protocol, String host, int port, String file,
+ String ref)
+ {
+ URLStreamHandler protocolHandler = null;
+ protocol = protocol.toLowerCase();
+ if (! this.protocol.equals(protocol))
+ protocolHandler = getURLStreamHandler(protocol);
+
+ // It is an hidden feature of the JDK. If the protocol does not exist,
+ // we keep the previously initialized protocol.
+ if (protocolHandler != null)
+ {
+ this.ph = protocolHandler;
+ this.protocol = protocol;
+ }
+ this.authority = "";
+ this.port = port;
+ this.host = host;
+ this.file = file;
+ this.ref = ref;
+
+ if (host != null)
+ this.authority += host;
+ if (port >= 0)
+ this.authority += ":" + port;
+
+ hashCode = hashCode(); // Used for serialization.
+ }
+
+ /**
+ * Sets the specified fields of the URL. This is not a public method so
+ * that only URLStreamHandlers can modify URL fields. URLs are otherwise
+ * constant. If the given protocol does not exist, it will keep the previously
+ * set protocol.
+ *
+ * @param protocol The protocol name for this URL.
+ * @param host The hostname or IP address for this URL.
+ * @param port The port number of this URL.
+ * @param authority The authority of this URL.
+ * @param userInfo The user and password (if needed) of this URL.
+ * @param path The "path" portion of this URL.
+ * @param query The query of this URL.
+ * @param ref The anchor portion of this URL.
+ *
+ * @since 1.3
+ */
+ protected void set(String protocol, String host, int port, String authority,
+ String userInfo, String path, String query, String ref)
+ {
+ URLStreamHandler protocolHandler = null;
+ protocol = protocol.toLowerCase();
+ if (! this.protocol.equals(protocol))
+ protocolHandler = getURLStreamHandler(protocol);
+
+ // It is an hidden feature of the JDK. If the protocol does not exist,
+ // we keep the previously initialized protocol.
+ if (protocolHandler != null)
+ {
+ this.ph = protocolHandler;
+ this.protocol = protocol;
+ }
+ this.host = host;
+ this.userInfo = userInfo;
+ this.port = port;
+ this.authority = authority;
+ if (query == null)
+ this.file = path;
+ else
+ this.file = path + "?" + query;
+ this.ref = ref;
+ hashCode = hashCode(); // Used for serialization.
+ }
+
+ /**
+ * Sets the URLStreamHandlerFactory for this class. This factory is
+ * responsible for returning the appropriate protocol handler for
+ * a given URL.
+ *
+ * @param fac The URLStreamHandlerFactory class to use
+ *
+ * @exception Error If the factory is alread set.
+ * @exception SecurityException If a security manager exists and its
+ * checkSetFactory method doesn't allow the operation
+ */
+ public static synchronized void setURLStreamHandlerFactory(URLStreamHandlerFactory fac)
+ {
+ if (factory != null)
+ throw new Error("URLStreamHandlerFactory already set");
+
+ // Throw an exception if an extant security mgr precludes
+ // setting the factory.
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkSetFactory();
+ factory = fac;
+ }
+
+ /**
+ * Returns a String representing this URL. The String returned is
+ * created by calling the protocol handler's toExternalForm() method.
+ *
+ * @return A string for this URL
+ */
+ public String toExternalForm()
+ {
+ // Identical to toString().
+ return ph.toExternalForm(this);
+ }
+
+ /**
+ * Returns a String representing this URL. Identical to toExternalForm().
+ * The value returned is created by the protocol handler's
+ * toExternalForm method. Overrides Object.toString()
+ *
+ * @return A string for this URL
+ */
+ public String toString()
+ {
+ // Identical to toExternalForm().
+ return ph.toExternalForm(this);
+ }
+
+ /**
+ * This internal method is used in two different constructors to load
+ * a protocol handler for this URL.
+ *
+ * @param protocol The protocol to load a handler for
+ *
+ * @return A URLStreamHandler for this protocol, or null when not found.
+ */
+ private static synchronized URLStreamHandler getURLStreamHandler(String protocol)
+ {
+ URLStreamHandler ph = null;
+
+ // First, see if a protocol handler is in our cache.
+ if (cache_handlers)
+ {
+ if ((ph = (URLStreamHandler) ph_cache.get(protocol)) != null)
+ return ph;
+ }
+
+ // If a non-default factory has been set, use it to find the protocol.
+ if (factory != null)
+ {
+ ph = factory.createURLStreamHandler(protocol);
+ }
+
+ // Non-default factory may have returned null or a factory wasn't set.
+ // Use the default search algorithm to find a handler for this protocol.
+ if (ph == null)
+ {
+ // Get the list of packages to check and append our default handler
+ // to it, along with the JDK specified default as a last resort.
+ // Except in very unusual environments the JDK specified one shouldn't
+ // ever be needed (or available).
+ String ph_search_path =
+ SystemProperties.getProperty("java.protocol.handler.pkgs");
+
+ // Tack our default package on at the ends.
+ if (ph_search_path != null)
+ ph_search_path += "|" + DEFAULT_SEARCH_PATH;
+ else
+ ph_search_path = DEFAULT_SEARCH_PATH;
+
+ // Finally loop through our search path looking for a match.
+ StringTokenizer pkgPrefix = new StringTokenizer(ph_search_path, "|");
+
+ // Cache the systemClassLoader
+ if (systemClassLoader == null)
+ {
+ systemClassLoader = (ClassLoader) AccessController.doPrivileged
+ (new PrivilegedAction() {
+ public Object run()
+ {
+ return ClassLoader.getSystemClassLoader();
+ }
+ });
+ }
+
+ do
+ {
+ try
+ {
+ // Try to get a class from the system/application
+ // classloader, initialize it, make an instance
+ // and try to cast it to a URLStreamHandler.
+ String clsName =
+ (pkgPrefix.nextToken() + "." + protocol + ".Handler");
+ Class c = Class.forName(clsName, true, systemClassLoader);
+ ph = (URLStreamHandler) c.newInstance();
+ }
+ catch (ThreadDeath death)
+ {
+ throw death;
+ }
+ catch (Throwable t)
+ {
+ // Ignored.
+ }
+ }
+ while (ph == null && pkgPrefix.hasMoreTokens());
+ }
+
+ // Update the hashtable with the new protocol handler.
+ if (ph != null && cache_handlers)
+ ph_cache.put(protocol, ph);
+ else
+ ph = null;
+
+ return ph;
+ }
+
+ private void readObject(ObjectInputStream ois)
+ throws IOException, ClassNotFoundException
+ {
+ ois.defaultReadObject();
+ this.ph = getURLStreamHandler(protocol);
+ if (this.ph == null)
+ throw new IOException("Handler for protocol " + protocol + " not found");
+ }
+
+ private void writeObject(ObjectOutputStream oos) throws IOException
+ {
+ oos.defaultWriteObject();
+ }
+
+ /**
+ * Returns the equivalent <code>URI</code> object for this <code>URL</code>.
+ * This is the same as calling <code>new URI(this.toString())</code>.
+ * RFC2396-compliant URLs are guaranteed a successful conversion to
+ * a <code>URI</code> instance. However, there are some values which
+ * form valid URLs, but which do not also form RFC2396-compliant URIs.
+ *
+ * @throws URISyntaxException if this URL is not RFC2396-compliant,
+ * and thus can not be successfully converted to a URI.
+ */
+ public URI toURI()
+ throws URISyntaxException
+ {
+ return new URI(toString());
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLClassLoader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLClassLoader.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLClassLoader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLClassLoader.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,863 @@
+/* URLClassLoader.java -- ClassLoader that loads classes from one or more URLs
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.net;
+
+import gnu.java.net.loader.FileURLLoader;
+import gnu.java.net.loader.JarURLLoader;
+import gnu.java.net.loader.RemoteURLLoader;
+import gnu.java.net.loader.Resource;
+import gnu.java.net.loader.URLLoader;
+import gnu.java.net.loader.URLStreamHandlerCache;
+
+import java.io.ByteArrayOutputStream;
+import java.io.EOFException;
+import java.io.File;
+import java.io.FilePermission;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.CodeSource;
+import java.security.PermissionCollection;
+import java.security.PrivilegedAction;
+import java.security.SecureClassLoader;
+import java.security.cert.Certificate;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Vector;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+
+/**
+ * A secure class loader that can load classes and resources from
+ * multiple locations. Given an array of <code>URL</code>s this class
+ * loader will retrieve classes and resources by fetching them from
+ * possible remote locations. Each <code>URL</code> is searched in
+ * order in which it was added. If the file portion of the
+ * <code>URL</code> ends with a '/' character then it is interpreted
+ * as a base directory, otherwise it is interpreted as a jar file from
+ * which the classes/resources are resolved.
+ *
+ * <p>New instances can be created by two static
+ * <code>newInstance()</code> methods or by three public
+ * contructors. Both ways give the option to supply an initial array
+ * of <code>URL</code>s and (optionally) a parent classloader (that is
+ * different from the standard system class loader).</p>
+ *
+ * <p>Normally creating a <code>URLClassLoader</code> throws a
+ * <code>SecurityException</code> if a <code>SecurityManager</code> is
+ * installed and the <code>checkCreateClassLoader()</code> method does
+ * not return true. But the <code>newInstance()</code> methods may be
+ * used by any code as long as it has permission to acces the given
+ * <code>URL</code>s. <code>URLClassLoaders</code> created by the
+ * <code>newInstance()</code> methods also explicitly call the
+ * <code>checkPackageAccess()</code> method of
+ * <code>SecurityManager</code> if one is installed before trying to
+ * load a class. Note that only subclasses of
+ * <code>URLClassLoader</code> can add new URLs after the
+ * URLClassLoader had been created. But it is always possible to get
+ * an array of all URLs that the class loader uses to resolve classes
+ * and resources by way of the <code>getURLs()</code> method.</p>
+ *
+ * <p>Open issues:
+ * <ul>
+ *
+ * <li>Should the URLClassLoader actually add the locations found in
+ * the manifest or is this the responsibility of some other
+ * loader/(sub)class? (see <a
+ * href="http://java.sun.com/products/jdk/1.4/docs/guide/extensions/spec.html">
+ * Extension Mechanism Architecture - Bundles Extensions</a>)</li>
+ *
+ * <li>How does <code>definePackage()</code> and sealing work
+ * precisely?</li>
+ *
+ * <li>We save and use the security context (when a created by
+ * <code>newInstance()</code> but do we have to use it in more
+ * places?</li>
+ *
+ * <li>The use of <code>URLStreamHandler</code>s has not been tested.</li>
+ *
+ * </ul>
+ * </p>
+ *
+ * @since 1.2
+ *
+ * @author Mark Wielaard (mark at klomp.org)
+ * @author Wu Gansha (gansha.wu at intel.com)
+ */
+public class URLClassLoader extends SecureClassLoader
+{
+ // Class Variables
+
+ /**
+ * A cache to store mappings between handler factory and its
+ * private protocol handler cache (also a HashMap), so we can avoid
+ * creating handlers each time the same protocol comes.
+ */
+ private static URLStreamHandlerCache factoryCache
+ = new URLStreamHandlerCache();
+
+ /**
+ * The prefix for URL loaders.
+ */
+ private static final String URL_LOADER_PREFIX = "gnu.java.net.loader.Load_";
+
+ // Instance variables
+
+ /** Locations to load classes from */
+ private final Vector urls = new Vector();
+
+ /**
+ * Store pre-parsed information for each url into this vector: each
+ * element is a URL loader. A jar file has its own class-path
+ * attribute which adds to the URLs that will be searched, but this
+ * does not add to the list of urls.
+ */
+ private final Vector urlinfos = new Vector();
+
+ /** Factory used to get the protocol handlers of the URLs */
+ private final URLStreamHandlerFactory factory;
+
+ /**
+ * The security context when created from <code>newInstance()</code>
+ * or null when created through a normal constructor or when no
+ * <code>SecurityManager</code> was installed.
+ */
+ private final AccessControlContext securityContext;
+
+ // Helper classes
+
+ /**
+ * Creates a URLClassLoader that gets classes from the supplied URLs.
+ * To determine if this classloader may be created the constructor of
+ * the super class (<code>SecureClassLoader</code>) is called first, which
+ * can throw a SecurityException. Then the supplied URLs are added
+ * in the order given to the URLClassLoader which uses these URLs to
+ * load classes and resources (after using the default parent ClassLoader).
+ *
+ * @param urls Locations that should be searched by this ClassLoader when
+ * resolving Classes or Resources.
+ * @exception SecurityException if the SecurityManager disallows the
+ * creation of a ClassLoader.
+ * @see SecureClassLoader
+ */
+ public URLClassLoader(URL[] urls) throws SecurityException
+ {
+ super();
+ this.factory = null;
+ this.securityContext = null;
+ addURLs(urls);
+ }
+
+ /**
+ * Creates a <code>URLClassLoader</code> that gets classes from the supplied
+ * <code>URL</code>s.
+ * To determine if this classloader may be created the constructor of
+ * the super class (<code>SecureClassLoader</code>) is called first, which
+ * can throw a SecurityException. Then the supplied URLs are added
+ * in the order given to the URLClassLoader which uses these URLs to
+ * load classes and resources (after using the supplied parent ClassLoader).
+ * @param urls Locations that should be searched by this ClassLoader when
+ * resolving Classes or Resources.
+ * @param parent The parent class loader used before trying this class
+ * loader.
+ * @exception SecurityException if the SecurityManager disallows the
+ * creation of a ClassLoader.
+ * @exception SecurityException
+ * @see SecureClassLoader
+ */
+ public URLClassLoader(URL[] urls, ClassLoader parent)
+ throws SecurityException
+ {
+ super(parent);
+ this.factory = null;
+ this.securityContext = null;
+ addURLs(urls);
+ }
+
+ // Package-private to avoid a trampoline constructor.
+ /**
+ * Package-private constructor used by the static
+ * <code>newInstance(URL[])</code> method. Creates an
+ * <code>URLClassLoader</code> with the given parent but without any
+ * <code>URL</code>s yet. This is used to bypass the normal security
+ * check for creating classloaders, but remembers the security
+ * context which will be used when defining classes. The
+ * <code>URL</code>s to load from must be added by the
+ * <code>newInstance()</code> method in the security context of the
+ * caller.
+ *
+ * @param securityContext the security context of the unprivileged code.
+ */
+ URLClassLoader(ClassLoader parent, AccessControlContext securityContext)
+ {
+ super(parent);
+ this.factory = null;
+ this.securityContext = securityContext;
+ }
+
+ /**
+ * Creates a URLClassLoader that gets classes from the supplied URLs.
+ * To determine if this classloader may be created the constructor of
+ * the super class (<CODE>SecureClassLoader</CODE>) is called first, which
+ * can throw a SecurityException. Then the supplied URLs are added
+ * in the order given to the URLClassLoader which uses these URLs to
+ * load classes and resources (after using the supplied parent ClassLoader).
+ * It will use the supplied <CODE>URLStreamHandlerFactory</CODE> to get the
+ * protocol handlers of the supplied URLs.
+ * @param urls Locations that should be searched by this ClassLoader when
+ * resolving Classes or Resources.
+ * @param parent The parent class loader used before trying this class
+ * loader.
+ * @param factory Used to get the protocol handler for the URLs.
+ * @exception SecurityException if the SecurityManager disallows the
+ * creation of a ClassLoader.
+ * @exception SecurityException
+ * @see SecureClassLoader
+ */
+ public URLClassLoader(URL[] urls, ClassLoader parent,
+ URLStreamHandlerFactory factory)
+ throws SecurityException
+ {
+ super(parent);
+ this.securityContext = null;
+ this.factory = factory;
+ addURLs(urls);
+
+ // If this factory is still not in factoryCache, add it.
+ factoryCache.add(factory);
+ }
+
+ // Methods
+
+ /**
+ * Adds a new location to the end of the internal URL store.
+ * @param newUrl the location to add
+ */
+ protected void addURL(URL newUrl)
+ {
+ urls.add(newUrl);
+ addURLImpl(newUrl);
+ }
+
+ private void addURLImpl(URL newUrl)
+ {
+ synchronized (this)
+ {
+ if (newUrl == null)
+ return; // Silently ignore...
+
+ // Reset the toString() value.
+ thisString = null;
+
+ // Create a loader for this URL.
+ URLLoader loader = null;
+ String file = newUrl.getFile();
+ String protocol = newUrl.getProtocol();
+
+ // If we have a file: URL, we want to make it absolute
+ // here, before we decide whether it is really a jar.
+ URL absoluteURL;
+ if ("file".equals (protocol))
+ {
+ File dir = new File(file);
+ URL absUrl;
+ try
+ {
+ absoluteURL = dir.getCanonicalFile().toURL();
+ }
+ catch (IOException ignore)
+ {
+ try
+ {
+ absoluteURL = dir.getAbsoluteFile().toURL();
+ }
+ catch (MalformedURLException _)
+ {
+ // This really should not happen.
+ absoluteURL = newUrl;
+ }
+ }
+ }
+ else
+ {
+ // This doesn't hurt, and it simplifies the logic a
+ // little.
+ absoluteURL = newUrl;
+ }
+
+ // First see if we can find a handler with the correct name.
+ try
+ {
+ Class handler = Class.forName(URL_LOADER_PREFIX + protocol);
+ Class[] argTypes = new Class[] { URLClassLoader.class,
+ URLStreamHandlerCache.class,
+ URLStreamHandlerFactory.class,
+ URL.class,
+ URL.class };
+ Constructor k = handler.getDeclaredConstructor(argTypes);
+ loader
+ = (URLLoader) k.newInstance(new Object[] { this,
+ factoryCache,
+ factory,
+ newUrl,
+ absoluteURL });
+ }
+ catch (ClassNotFoundException ignore)
+ {
+ // Fall through.
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ // Programming error in the class library.
+ InternalError vme
+ = new InternalError("couldn't find URLLoader constructor");
+ vme.initCause(nsme);
+ throw vme;
+ }
+ catch (InstantiationException inste)
+ {
+ // Programming error in the class library.
+ InternalError vme
+ = new InternalError("couldn't instantiate URLLoader");
+ vme.initCause(inste);
+ throw vme;
+ }
+ catch (InvocationTargetException ite)
+ {
+ // Programming error in the class library.
+ InternalError vme
+ = new InternalError("error instantiating URLLoader");
+ vme.initCause(ite);
+ throw vme;
+ }
+ catch (IllegalAccessException illae)
+ {
+ // Programming error in the class library.
+ InternalError vme
+ = new InternalError("invalid access to URLLoader");
+ vme.initCause(illae);
+ throw vme;
+ }
+
+ if (loader == null)
+ {
+ // If it is not a directory, use the jar loader.
+ if (! (file.endsWith("/") || file.endsWith(File.separator)))
+ loader = new JarURLLoader(this, factoryCache, factory,
+ newUrl, absoluteURL);
+ else if ("file".equals(protocol))
+ loader = new FileURLLoader(this, factoryCache, factory,
+ newUrl, absoluteURL);
+ else
+ loader = new RemoteURLLoader(this, factoryCache, factory,
+ newUrl);
+ }
+
+ urlinfos.add(loader);
+ ArrayList extra = loader.getClassPath();
+ if (extra != null)
+ urlinfos.addAll(extra);
+ }
+ }
+
+ /**
+ * Adds an array of new locations to the end of the internal URL
+ * store. Called from the the constructors. Should not call to the
+ * protected addURL() method since that can be overridden and
+ * subclasses are not yet in a good state at this point.
+ * jboss 4.0.3 for example depends on this.
+ *
+ * @param newUrls the locations to add
+ */
+ private void addURLs(URL[] newUrls)
+ {
+ for (int i = 0; i < newUrls.length; i++)
+ {
+ urls.add(newUrls[i]);
+ addURLImpl(newUrls[i]);
+ }
+ }
+
+ /**
+ * Look in both Attributes for a given value. The first Attributes
+ * object, if not null, has precedence.
+ */
+ private String getAttributeValue(Attributes.Name name, Attributes first,
+ Attributes second)
+ {
+ String result = null;
+ if (first != null)
+ result = first.getValue(name);
+ if (result == null)
+ result = second.getValue(name);
+ return result;
+ }
+
+ /**
+ * Defines a Package based on the given name and the supplied manifest
+ * information. The manifest indicates the title, version and
+ * vendor information of the specification and implementation and whether the
+ * package is sealed. If the Manifest indicates that the package is sealed
+ * then the Package will be sealed with respect to the supplied URL.
+ *
+ * @param name The name of the package
+ * @param manifest The manifest describing the specification,
+ * implementation and sealing details of the package
+ * @param url the code source url to seal the package
+ * @return the defined Package
+ * @throws IllegalArgumentException If this package name already exists
+ * in this class loader
+ */
+ protected Package definePackage(String name, Manifest manifest, URL url)
+ throws IllegalArgumentException
+ {
+ // Compute the name of the package as it may appear in the
+ // Manifest.
+ StringBuffer xform = new StringBuffer(name);
+ for (int i = xform.length () - 1; i >= 0; --i)
+ if (xform.charAt(i) == '.')
+ xform.setCharAt(i, '/');
+ xform.append('/');
+ String xformName = xform.toString();
+
+ Attributes entryAttr = manifest.getAttributes(xformName);
+ Attributes attr = manifest.getMainAttributes();
+
+ String specTitle
+ = getAttributeValue(Attributes.Name.SPECIFICATION_TITLE,
+ entryAttr, attr);
+ String specVersion
+ = getAttributeValue(Attributes.Name.SPECIFICATION_VERSION,
+ entryAttr, attr);
+ String specVendor
+ = getAttributeValue(Attributes.Name.SPECIFICATION_VENDOR,
+ entryAttr, attr);
+ String implTitle
+ = getAttributeValue(Attributes.Name.IMPLEMENTATION_TITLE,
+ entryAttr, attr);
+ String implVersion
+ = getAttributeValue(Attributes.Name.IMPLEMENTATION_VERSION,
+ entryAttr, attr);
+ String implVendor
+ = getAttributeValue(Attributes.Name.IMPLEMENTATION_VENDOR,
+ entryAttr, attr);
+
+ // Look if the Manifest indicates that this package is sealed
+ // XXX - most likely not completely correct!
+ // Shouldn't we also check the sealed attribute of the complete jar?
+ // http://java.sun.com/products/jdk/1.4/docs/guide/extensions/spec.html#bundled
+ // But how do we get that jar manifest here?
+ String sealed = attr.getValue(Attributes.Name.SEALED);
+ if ("false".equals(sealed))
+ // make sure that the URL is null so the package is not sealed
+ url = null;
+
+ return definePackage(name,
+ specTitle, specVendor, specVersion,
+ implTitle, implVendor, implVersion,
+ url);
+ }
+
+ /**
+ * Finds (the first) class by name from one of the locations. The locations
+ * are searched in the order they were added to the URLClassLoader.
+ *
+ * @param className the classname to find
+ * @exception ClassNotFoundException when the class could not be found or
+ * loaded
+ * @return a Class object representing the found class
+ */
+ protected Class findClass(final String className)
+ throws ClassNotFoundException
+ {
+ // Just try to find the resource by the (almost) same name
+ String resourceName = className.replace('.', '/') + ".class";
+ int max = urlinfos.size();
+ Resource resource = null;
+ for (int i = 0; i < max && resource == null; i++)
+ {
+ URLLoader loader = (URLLoader)urlinfos.elementAt(i);
+ if (loader == null)
+ continue;
+
+ Class k = loader.getClass(className);
+ if (k != null)
+ return k;
+
+ resource = loader.getResource(resourceName);
+ }
+ if (resource == null)
+ throw new ClassNotFoundException(className + " not found in " + this);
+
+ // Try to read the class data, create the CodeSource, Package and
+ // construct the class (and watch out for those nasty IOExceptions)
+ try
+ {
+ byte[] data;
+ InputStream in = resource.getInputStream();
+ try
+ {
+ int length = resource.getLength();
+ if (length != -1)
+ {
+ // We know the length of the data.
+ // Just try to read it in all at once
+ data = new byte[length];
+ int pos = 0;
+ while (length - pos > 0)
+ {
+ int len = in.read(data, pos, length - pos);
+ if (len == -1)
+ throw new EOFException("Not enough data reading from: "
+ + in);
+ pos += len;
+ }
+ }
+ else
+ {
+ // We don't know the data length.
+ // Have to read it in chunks.
+ ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
+ byte[] b = new byte[4096];
+ int l = 0;
+ while (l != -1)
+ {
+ l = in.read(b);
+ if (l != -1)
+ out.write(b, 0, l);
+ }
+ data = out.toByteArray();
+ }
+ }
+ finally
+ {
+ in.close();
+ }
+ final byte[] classData = data;
+
+ // Now get the CodeSource
+ final CodeSource source = resource.getCodeSource();
+
+ // Find out package name
+ String packageName = null;
+ int lastDot = className.lastIndexOf('.');
+ if (lastDot != -1)
+ packageName = className.substring(0, lastDot);
+
+ if (packageName != null && getPackage(packageName) == null)
+ {
+ // define the package
+ Manifest manifest = resource.getLoader().getManifest();
+ if (manifest == null)
+ definePackage(packageName, null, null, null, null, null, null,
+ null);
+ else
+ definePackage(packageName, manifest,
+ resource.getLoader().getBaseURL());
+ }
+
+ // And finally construct the class!
+ SecurityManager sm = System.getSecurityManager();
+ Class result = null;
+ if (sm != null && securityContext != null)
+ {
+ result = (Class)AccessController.doPrivileged
+ (new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return defineClass(className, classData,
+ 0, classData.length,
+ source);
+ }
+ }, securityContext);
+ }
+ else
+ result = defineClass(className, classData, 0, classData.length, source);
+
+ // Avoid NullPointerExceptions.
+ Certificate[] resourceCertificates = resource.getCertificates();
+ if(resourceCertificates != null)
+ super.setSigners(result, resourceCertificates);
+
+ return result;
+ }
+ catch (IOException ioe)
+ {
+ ClassNotFoundException cnfe;
+ cnfe = new ClassNotFoundException(className + " not found in " + this);
+ cnfe.initCause(ioe);
+ throw cnfe;
+ }
+ }
+
+ // Cached String representation of this URLClassLoader
+ private String thisString;
+
+ /**
+ * Returns a String representation of this URLClassLoader giving the
+ * actual Class name, the URLs that are searched and the parent
+ * ClassLoader.
+ */
+ public String toString()
+ {
+ synchronized (this)
+ {
+ if (thisString == null)
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append(this.getClass().getName());
+ sb.append("{urls=[" );
+ URL[] thisURLs = getURLs();
+ for (int i = 0; i < thisURLs.length; i++)
+ {
+ sb.append(thisURLs[i]);
+ if (i < thisURLs.length - 1)
+ sb.append(',');
+ }
+ sb.append(']');
+ sb.append(", parent=");
+ sb.append(getParent());
+ sb.append('}');
+ thisString = sb.toString();
+ }
+ return thisString;
+ }
+ }
+
+ /**
+ * Finds the first occurrence of a resource that can be found. The locations
+ * are searched in the order they were added to the URLClassLoader.
+ *
+ * @param resourceName the resource name to look for
+ * @return the URLResource for the resource if found, null otherwise
+ */
+ private Resource findURLResource(String resourceName)
+ {
+ int max = urlinfos.size();
+ for (int i = 0; i < max; i++)
+ {
+ URLLoader loader = (URLLoader) urlinfos.elementAt(i);
+ if (loader == null)
+ continue;
+
+ Resource resource = loader.getResource(resourceName);
+ if (resource != null)
+ return resource;
+ }
+ return null;
+ }
+
+ /**
+ * Finds the first occurrence of a resource that can be found.
+ *
+ * @param resourceName the resource name to look for
+ * @return the URL if found, null otherwise
+ */
+ public URL findResource(String resourceName)
+ {
+ Resource resource = findURLResource(resourceName);
+ if (resource != null)
+ return resource.getURL();
+
+ // Resource not found
+ return null;
+ }
+
+ /**
+ * Finds all the resources with a particular name from all the locations.
+ *
+ * @param resourceName the name of the resource to lookup
+ * @return a (possible empty) enumeration of URLs where the resource can be
+ * found
+ * @exception IOException when an error occurs accessing one of the
+ * locations
+ */
+ public Enumeration findResources(String resourceName)
+ throws IOException
+ {
+ Vector resources = new Vector();
+ int max = urlinfos.size();
+ for (int i = 0; i < max; i++)
+ {
+ URLLoader loader = (URLLoader) urlinfos.elementAt(i);
+ Resource resource = loader.getResource(resourceName);
+ if (resource != null)
+ resources.add(resource.getURL());
+ }
+ return resources.elements();
+ }
+
+ /**
+ * Returns the permissions needed to access a particular code
+ * source. These permissions includes those returned by
+ * <code>SecureClassLoader.getPermissions()</code> and the actual
+ * permissions to access the objects referenced by the URL of the
+ * code source. The extra permissions added depend on the protocol
+ * and file portion of the URL in the code source. If the URL has
+ * the "file" protocol ends with a '/' character then it must be a
+ * directory and a file Permission to read everything in that
+ * directory and all subdirectories is added. If the URL had the
+ * "file" protocol and doesn't end with a '/' character then it must
+ * be a normal file and a file permission to read that file is
+ * added. If the <code>URL</code> has any other protocol then a
+ * socket permission to connect and accept connections from the host
+ * portion of the URL is added.
+ *
+ * @param source The codesource that needs the permissions to be accessed
+ * @return the collection of permissions needed to access the code resource
+ * @see java.security.SecureClassLoader#getPermissions(CodeSource)
+ */
+ protected PermissionCollection getPermissions(CodeSource source)
+ {
+ // XXX - This implementation does exactly as the Javadoc describes.
+ // But maybe we should/could use URLConnection.getPermissions()?
+ // First get the permissions that would normally be granted
+ PermissionCollection permissions = super.getPermissions(source);
+
+ // Now add any extra permissions depending on the URL location.
+ URL url = source.getLocation();
+ String protocol = url.getProtocol();
+ if (protocol.equals("file"))
+ {
+ String file = url.getFile();
+
+ // If the file end in / it must be an directory.
+ if (file.endsWith("/") || file.endsWith(File.separator))
+ {
+ // Grant permission to read everything in that directory and
+ // all subdirectories.
+ permissions.add(new FilePermission(file + "-", "read"));
+ }
+ else
+ {
+ // It is a 'normal' file.
+ // Grant permission to access that file.
+ permissions.add(new FilePermission(file, "read"));
+ }
+ }
+ else
+ {
+ // Grant permission to connect to and accept connections from host
+ String host = url.getHost();
+ if (host != null)
+ permissions.add(new SocketPermission(host, "connect,accept"));
+ }
+
+ return permissions;
+ }
+
+ /**
+ * Returns all the locations that this class loader currently uses the
+ * resolve classes and resource. This includes both the initially supplied
+ * URLs as any URLs added later by the loader.
+ * @return All the currently used URLs
+ */
+ public URL[] getURLs()
+ {
+ return (URL[]) urls.toArray(new URL[urls.size()]);
+ }
+
+ /**
+ * Creates a new instance of a <code>URLClassLoader</code> that gets
+ * classes from the supplied <code>URL</code>s. This class loader
+ * will have as parent the standard system class loader.
+ *
+ * @param urls the initial URLs used to resolve classes and
+ * resources
+ *
+ * @return the class loader
+ *
+ * @exception SecurityException when the calling code does not have
+ * permission to access the given <code>URL</code>s
+ */
+ public static URLClassLoader newInstance(URL[] urls)
+ throws SecurityException
+ {
+ return newInstance(urls, null);
+ }
+
+ /**
+ * Creates a new instance of a <code>URLClassLoader</code> that gets
+ * classes from the supplied <code>URL</code>s and with the supplied
+ * loader as parent class loader.
+ *
+ * @param urls the initial URLs used to resolve classes and
+ * resources
+ * @param parent the parent class loader
+ *
+ * @return the class loader
+ *
+ * @exception SecurityException when the calling code does not have
+ * permission to access the given <code>URL</code>s
+ */
+ public static URLClassLoader newInstance(URL[] urls, final ClassLoader parent)
+ throws SecurityException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ return new URLClassLoader(urls, parent);
+ else
+ {
+ final Object securityContext = sm.getSecurityContext();
+
+ // XXX - What to do with anything else then an AccessControlContext?
+ if (! (securityContext instanceof AccessControlContext))
+ throw new SecurityException("securityContext must be AccessControlContext: "
+ + securityContext);
+
+ URLClassLoader loader =
+ (URLClassLoader) AccessController.doPrivileged(new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return new URLClassLoader(parent,
+ (AccessControlContext) securityContext);
+ }
+ });
+ loader.addURLs(urls);
+ return loader;
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLConnection.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLConnection.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLConnection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLConnection.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1106 @@
+/* URLConnection.java -- Abstract superclass for reading from URL's
+ Copyright (C) 1998, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.net;
+
+import gnu.classpath.SystemProperties;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.AllPermission;
+import java.security.Permission;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status: One guessContentTypeFrom... methods not implemented.
+ * getContent method assumes content type from response; see comment there.
+ */
+/**
+ * This class models a connection that retrieves the information pointed
+ * to by a URL object. This is typically a connection to a remote node
+ * on the network, but could be a simple disk read.
+ * <p>
+ * A URLConnection object is normally created by calling the openConnection()
+ * method of a URL object. This method is somewhat misnamed because it does
+ * not actually open the connection. Instead, it return an unconnected
+ * instance of this object. The caller then has the opportunity to set
+ * various connection options prior to calling the actual connect() method.
+ * <p>
+ * After the connection has been opened, there are a number of methods in
+ * this class that access various attributes of the data, typically
+ * represented by headers sent in advance of the actual data itself.
+ * <p>
+ * Also of note are the getInputStream and getContent() methods which allow
+ * the caller to retrieve the actual data from the connection. Note that
+ * for some types of connections, writing is also allowed. The setDoOutput()
+ * method must be called prior to connecing in order to enable this, then
+ * the getOutputStream method called after the connection in order to
+ * obtain a stream to write the output to.
+ * <p>
+ * The getContent() method is of particular note. This method returns an
+ * Object that encapsulates the data returned. There is no way do determine
+ * the type of object that will be returned in advance. This is determined
+ * by the actual content handlers as described in the description of that
+ * method.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ */
+public abstract class URLConnection
+{
+ /**
+ * This is an object that maps filenames to MIME types. The interface
+ * to do this is implemented by this class, so just create an empty
+ * instance and store it here.
+ */
+ private static FileNameMap fileNameMap;
+
+ /**
+ * This is the ContentHandlerFactory set by the caller, if any
+ */
+ private static ContentHandlerFactory factory;
+
+ /**
+ * This is the default value that will be used to determine whether or
+ * not user interaction should be allowed.
+ */
+ private static boolean defaultAllowUserInteraction;
+
+ /**
+ * This is the default flag indicating whether or not to use caches to
+ * store the data returned from a server
+ */
+ private static boolean defaultUseCaches = true;
+
+ /**
+ * Default internal content handler factory.
+ */
+ private static ContentHandlerFactory defaultFactory
+ = new gnu.java.net.DefaultContentHandlerFactory();
+
+ /**
+ * This variable determines whether or not interaction is allowed with
+ * the user. For example, to prompt for a username and password.
+ */
+ protected boolean allowUserInteraction;
+
+ /**
+ * Indicates whether or not a connection has been established to the
+ * destination specified in the URL
+ */
+ protected boolean connected;
+
+ /**
+ * Indicates whether or not input can be read from this URL
+ */
+ protected boolean doInput = true;
+
+ /**
+ * Indicates whether or not output can be sent to this URL
+ */
+ protected boolean doOutput;
+
+ /**
+ * If this flag is set, the protocol is allowed to cache data whenever
+ * it can (caching is not guaranteed). If it is not set, the protocol
+ * must a get a fresh copy of the data.
+ * <p>
+ * This field is set by the setUseCaches method and returned by the
+ * getUseCaches method.
+ *
+ * Its default value is that determined by the last invocation of
+ * setDefaultUseCaches
+ */
+ protected boolean useCaches;
+
+ /**
+ * If this value is non-zero, then the connection will only attempt to
+ * fetch the document pointed to by the URL if the document has been
+ * modified more recently than the date set in this variable. That date
+ * should be specified as the number of seconds since 1/1/1970 GMT.
+ */
+ protected long ifModifiedSince;
+
+ /**
+ * This is the URL associated with this connection
+ */
+ protected URL url;
+
+ private static SimpleDateFormat[] dateFormats;
+ private static boolean dateformats_initialized;
+
+ /**
+ * The timeout period.
+ */
+ private int timeout;
+
+ /* Cached ParsePosition, used when parsing dates. */
+ private ParsePosition position;
+
+ /**
+ * Creates a URL connection to a given URL. A real connection is not made.
+ * Use <code>connect()</code> to do this.
+ *
+ * @param url The Object to create the URL connection to
+ *
+ * @see URLConnection#connect()
+ */
+ protected URLConnection(URL url)
+ {
+ // Set up all our instance variables
+ this.url = url;
+ allowUserInteraction = defaultAllowUserInteraction;
+ useCaches = defaultUseCaches;
+ }
+
+ /**
+ * Establishes the actual connection to the URL associated with this
+ * connection object
+ *
+ * @exception IOException if an error occurs
+ */
+ public abstract void connect() throws IOException;
+
+ /**
+ * Returns the URL object associated with this connection
+ *
+ * @return The URL for this connection.
+ */
+ public URL getURL()
+ {
+ return url;
+ }
+
+ /**
+ * Returns the connection timeout speed, in milliseconds, or zero if the timeout
+ * is infinite or not set.
+ *
+ * @return The timeout.
+ *
+ * @since 1.5
+ */
+ public int getConnectTimeout()
+ {
+ return timeout;
+ }
+
+ /**
+ * Set the connection timeout speed, in milliseconds, or zero if the timeout
+ * is to be considered infinite. Note that in certain socket
+ * implementations/platforms this method may not have any effect.
+ *
+ * Throws an <code>IllegalArgumentException</code> if timeout < 0.
+ *
+ * @param timeout - The timeout, in milliseconds.
+ *
+ * @since 1.5
+ */
+ public void setConnectTimeout(int timeout)
+ throws IllegalArgumentException
+ {
+ if( timeout < 0 )
+ throw new IllegalArgumentException("Timeout must be 0 or positive.");
+ this.timeout = timeout;
+ }
+
+ /**
+ * Returns the value of the content-length header field or -1 if the value
+ * is not known or not present.
+ *
+ * @return The content-length field
+ */
+ public int getContentLength()
+ {
+ return getHeaderFieldInt("content-length", -1);
+ }
+
+ /**
+ * Returns the the content-type of the data pointed to by the URL. This
+ * method first tries looking for a content-type header. If that is not
+ * present, it attempts to use the file name to determine the content's
+ * MIME type. If that is unsuccessful, the method returns null. The caller
+ * may then still attempt to determine the MIME type by a call to
+ * guessContentTypeFromStream()
+ *
+ * @return The content MIME type
+ */
+ public String getContentType()
+ {
+ return getHeaderField("content-type");
+ }
+
+ /**
+ * Returns the value of the content-encoding field or null if it is not
+ * known or not present.
+ *
+ * @return The content-encoding field
+ */
+ public String getContentEncoding()
+ {
+ return getHeaderField("content-encoding");
+ }
+
+ /**
+ * Returns the value of the expires header or 0 if not known or present.
+ * If populated, the return value is number of seconds since midnight
+ * on 1/1/1970 GMT.
+ *
+ * @return The expiration time.
+ */
+ public long getExpiration()
+ {
+ return getHeaderFieldDate("expires", 0L);
+ }
+
+ /**
+ * Returns the date of the document pointed to by the URL as reported in
+ * the date field of the header or 0 if the value is not present or not
+ * known. If populated, the return value is number of seconds since
+ * midnight on 1/1/1970 GMT.
+ *
+ * @return The document date
+ */
+ public long getDate()
+ {
+ return getHeaderFieldDate("date", 0L);
+ }
+
+ /**
+ * Returns the value of the last-modified header field or 0 if not known known
+ * or not present. If populated, the return value is the number of seconds
+ * since midnight on 1/1/1970.
+ *
+ * @return The last modified time
+ */
+ public long getLastModified()
+ {
+ return getHeaderFieldDate("last-modified", 0L);
+ }
+
+ /**
+ * Return a String representing the header value at the specified index.
+ * This allows the caller to walk the list of header fields. The analogous
+ * {@link #getHeaderField(int)} method allows access to the corresponding
+ * key for this header field
+ *
+ * @param index The index into the header field list to retrieve the value for
+ *
+ * @return The header value or null if index is past the end of the headers
+ */
+ public String getHeaderField(int index)
+ {
+ // Subclasses for specific protocols override this.
+ return null;
+ }
+
+ /**
+ * Returns a String representing the value of the header field having
+ * the named key. Returns null if the header field does not exist.
+ *
+ * @param name The key of the header field
+ *
+ * @return The value of the header field as a String
+ */
+ public String getHeaderField(String name)
+ {
+ // Subclasses for specific protocols override this.
+ return null;
+ }
+
+ /**
+ * Returns an unmodifiable Map containing all sent header fields.
+ *
+ * @return The map of header fields. The map consists of String keys with
+ * an unmodifiable List of String objects as value.
+ *
+ * @since 1.4
+ */
+ public Map getHeaderFields()
+ {
+ // Subclasses for specific protocols override this.
+ return Collections.EMPTY_MAP;
+ }
+
+ /**
+ * Returns the value of the named header field as an int. If the field
+ * is not present or cannot be parsed as an integer, the default value
+ * will be returned.
+ *
+ * @param name The header field key to lookup
+ * @param defaultValue The defaule value if the header field is not found
+ * or can't be parsed.
+ *
+ * @return The value of the header field or the default value if the field
+ * is missing or malformed
+ */
+ public int getHeaderFieldInt(String name, int defaultValue)
+ {
+ String value = getHeaderField(name);
+
+ if (value == null)
+ return defaultValue;
+
+ try
+ {
+ return Integer.parseInt(value);
+ }
+ catch (NumberFormatException e)
+ {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * Returns the value of the named header field as a date. This date will
+ * be the number of seconds since midnight 1/1/1970 GMT or the default
+ * value if the field is not present or cannot be converted to a date.
+ *
+ * @param name The name of the header field
+ * @param defaultValue The default date if the header field is not found
+ * or can't be converted.
+ *
+ * @return The date value of the header filed or the default value
+ * if the field is missing or malformed
+ */
+ public long getHeaderFieldDate(String name, long defaultValue)
+ {
+ if (! dateformats_initialized)
+ initializeDateFormats();
+
+ if (position == null)
+ position = new ParsePosition(0);
+
+ long result = defaultValue;
+ String str = getHeaderField(name);
+
+ if (str != null)
+ {
+ for (int i = 0; i < dateFormats.length; i++)
+ {
+ SimpleDateFormat df = dateFormats[i];
+ position.setIndex(0);
+ position.setErrorIndex(0);
+ Date date = df.parse(str, position);
+ if (date != null)
+ return date.getTime();
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns a String representing the header key at the specified index.
+ * This allows the caller to walk the list of header fields. The analogous
+ * {@link #getHeaderField(int)} method allows access to the corresponding
+ * value for this tag.
+ *
+ * @param index The index into the header field list to retrieve the key for.
+ *
+ * @return The header field key or null if index is past the end
+ * of the headers.
+ */
+ public String getHeaderFieldKey(int index)
+ {
+ // Subclasses for specific protocols override this.
+ return null;
+ }
+
+ /**
+ * This method returns the content of the document pointed to by the
+ * URL as an Object. The type of object depends on the MIME type of
+ * the object and particular content hander loaded. Most text type
+ * content handlers will return a subclass of
+ * <code>InputStream</code>. Images usually return a class that
+ * implements <code>ImageProducer</code>. There is not guarantee
+ * what type of object will be returned, however.
+ *
+ * <p>This class first determines the MIME type of the content, then
+ * creates a ContentHandler object to process the input. If the
+ * <code>ContentHandlerFactory</code> is set, then that object is
+ * called to load a content handler, otherwise a class called
+ * gnu.java.net.content.<content_type> is tried. If this
+ * handler does not exist, the method will simple return the
+ * <code>InputStream</code> returned by
+ * <code>getInputStream()</code>. Note that the default
+ * implementation of <code>getInputStream()</code> throws a
+ * <code>UnknownServiceException</code> so subclasses are encouraged
+ * to override this method.</p>
+ *
+ * @return the content
+ *
+ * @exception IOException If an error with the connection occurs.
+ * @exception UnknownServiceException If the protocol does not support the
+ * content type at all.
+ */
+ public Object getContent() throws IOException
+ {
+ if (!connected)
+ connect();
+
+ // FIXME: Doc indicates that other criteria should be applied as
+ // heuristics to determine the true content type, e.g. see
+ // guessContentTypeFromName() and guessContentTypeFromStream methods
+ // as well as FileNameMap class & fileNameMap field & get/set methods.
+ String type = getContentType();
+ ContentHandler ch = getContentHandler(type);
+
+ if (ch != null)
+ return ch.getContent(this);
+
+ return getInputStream();
+ }
+
+ /**
+ * Retrieves the content of this URLConnection
+ *
+ * @param classes The allowed classes for the content
+ *
+ * @return the content
+ *
+ * @exception IOException If an error occurs
+ * @exception UnknownServiceException If the protocol does not support the
+ * content type
+ */
+ public Object getContent(Class[] classes)
+ throws IOException
+ {
+ if (! connected)
+ connect();
+ String type = getContentType();
+ ContentHandler ch = getContentHandler(type);
+ if (ch != null)
+ return ch.getContent(this, classes);
+ throw new UnknownServiceException("protocol does not support the content type");
+ }
+
+ /**
+ * This method returns a <code>Permission</code> object representing the
+ * permissions required to access this URL. This method returns
+ * <code>java.security.AllPermission</code> by default. Subclasses should
+ * override it to return a more specific permission. For example, an
+ * HTTP URL should return an instance of <code>SocketPermission</code>
+ * for the appropriate host and port.
+ * <p>
+ * Note that because of items such as HTTP redirects, the permission
+ * object returned might be different before and after connecting.
+ *
+ * @return A Permission object
+ *
+ * @exception IOException If the computation of the permission requires
+ * network or file I/O and an exception occurs while computing it
+ */
+ public Permission getPermission() throws IOException
+ {
+ // Subclasses may override this.
+ return new AllPermission();
+ }
+
+ /**
+ * Returns an InputStream for this connection. As this default
+ * implementation returns null, subclasses should override this method
+ *
+ * @return An InputStream for this connection
+ *
+ * @exception IOException If an error occurs
+ * @exception UnknownServiceException If the protocol does not support input
+ */
+ public InputStream getInputStream() throws IOException
+ {
+ // Subclasses for specific protocols override this.
+ throw new UnknownServiceException("Protocol " + url.getProtocol()
+ + " does not support input.");
+ }
+
+ /**
+ * Returns an OutputStream for this connection. As this default
+ * implementation returns null, subclasses should override this method
+ *
+ * @return An OutputStream for this connection
+ *
+ * @exception IOException If an error occurs
+ * @exception UnknownServiceException If the protocol does not support output
+ */
+ public OutputStream getOutputStream() throws IOException
+ {
+ // Subclasses for specific protocols override this.
+ throw new UnknownServiceException("Protocol " + url.getProtocol()
+ + " does not support output.");
+ }
+
+ /**
+ * The methods prints the value of this object as a String by calling the
+ * toString() method of its associated URL. Overrides Object.toString()
+ *
+ * @return A String representation of this object
+ */
+ public String toString()
+ {
+ return this.getClass().getName() + ":" + url.toString();
+ }
+
+ /**
+ * Sets the value of a flag indicating whether or not input is going
+ * to be done for this connection. This default to true unless the
+ * doOutput flag is set to false, in which case this defaults to false.
+ *
+ * @param input <code>true</code> if input is to be done,
+ * <code>false</code> otherwise
+ *
+ * @exception IllegalStateException If already connected
+ */
+ public void setDoInput(boolean input)
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ doInput = input;
+ }
+
+ /**
+ * Returns the value of a flag indicating whether or not input is going
+ * to be done for this connection. This default to true unless the
+ * doOutput flag is set to false, in which case this defaults to false.
+ *
+ * @return true if input is to be done, false otherwise
+ */
+ public boolean getDoInput()
+ {
+ return doInput;
+ }
+
+ /**
+ * Sets a boolean flag indicating whether or not output will be done
+ * on this connection. The default value is false, so this method can
+ * be used to override the default
+ *
+ * @param output ture if output is to be done, false otherwise
+ *
+ * @exception IllegalStateException If already connected
+ */
+ public void setDoOutput(boolean output)
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ doOutput = output;
+ }
+
+ /**
+ * Returns a boolean flag indicating whether or not output will be done
+ * on this connection. This defaults to false.
+ *
+ * @return true if output is to be done, false otherwise
+ */
+ public boolean getDoOutput()
+ {
+ return doOutput;
+ }
+
+ /**
+ * Sets a boolean flag indicating whether or not user interaction is
+ * allowed for this connection. (For example, in order to prompt for
+ * username and password info.
+ *
+ * @param allow true if user interaction should be allowed, false otherwise.
+ *
+ * @exception IllegalStateException If already connected
+ */
+ public void setAllowUserInteraction(boolean allow)
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ allowUserInteraction = allow;
+ }
+
+ /**
+ * Returns a boolean flag indicating whether or not user interaction is
+ * allowed for this connection. (For example, in order to prompt for
+ * username and password info.
+ *
+ * @return true if user interaction is allowed, false otherwise
+ */
+ public boolean getAllowUserInteraction()
+ {
+ return allowUserInteraction;
+ }
+
+ /**
+ * Sets the default flag for whether or not interaction with a user
+ * is allowed. This will be used for all connections unless overridden
+ *
+ * @param allow true to allow user interaction, false otherwise
+ */
+ public static void setDefaultAllowUserInteraction(boolean allow)
+ {
+ defaultAllowUserInteraction = allow;
+ }
+
+ /**
+ * Returns the default flag for whether or not interaction with a user
+ * is allowed. This will be used for all connections unless overridden
+ *
+ * @return true if user interaction is allowed, false otherwise
+ */
+ public static boolean getDefaultAllowUserInteraction()
+ {
+ return defaultAllowUserInteraction;
+ }
+
+ /**
+ * Sets a boolean flag indicating whether or not caching will be used
+ * (if possible) to store data downloaded via the connection.
+ *
+ * @param usecaches The new value
+ *
+ * @exception IllegalStateException If already connected
+ */
+ public void setUseCaches(boolean usecaches)
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ useCaches = usecaches;
+ }
+
+ /**
+ * Returns a boolean flag indicating whether or not caching will be used
+ * (if possible) to store data downloaded via the connection.
+ *
+ * @return true if caching should be used if possible, false otherwise
+ */
+ public boolean getUseCaches()
+ {
+ return useCaches;
+ }
+
+ /**
+ * Sets the ifModified since instance variable. If this value is non
+ * zero and the underlying protocol supports it, the actual document will
+ * not be fetched unless it has been modified since this time. The value
+ * passed should be 0 if this feature is to be disabled or the time expressed
+ * as the number of seconds since midnight 1/1/1970 GMT otherwise.
+ *
+ * @param ifmodifiedsince The new value in milliseconds
+ * since January 1, 1970 GMT
+ *
+ * @exception IllegalStateException If already connected
+ */
+ public void setIfModifiedSince(long ifmodifiedsince)
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ ifModifiedSince = ifmodifiedsince;
+ }
+
+ /**
+ * Returns the ifModified since instance variable. If this value is non
+ * zero and the underlying protocol supports it, the actual document will
+ * not be fetched unless it has been modified since this time. The value
+ * returned will be 0 if this feature is disabled or the time expressed
+ * as the number of seconds since midnight 1/1/1970 GMT otherwise
+ *
+ * @return The ifModifiedSince value
+ */
+ public long getIfModifiedSince()
+ {
+ return ifModifiedSince;
+ }
+
+ /**
+ * Returns the default value used to determine whether or not caching
+ * of documents will be done when possible.
+ *
+ * @return true if caches will be used, false otherwise
+ */
+ public boolean getDefaultUseCaches()
+ {
+ return defaultUseCaches;
+ }
+
+ /**
+ * Sets the default value used to determine whether or not caching
+ * of documents will be done when possible.
+ *
+ * @param use true to use caches if possible by default, false otherwise
+ */
+ public void setDefaultUseCaches(boolean use)
+ {
+ defaultUseCaches = use;
+ }
+
+ /**
+ * Sets the value of the named request property.
+ * This method does overwrite the value of existing properties with
+ * the new value.
+ *
+ * @param key The name of the property
+ * @param value The value of the property
+ *
+ * @exception IllegalStateException If already connected
+ * @exception NullPointerException If key is null
+ *
+ * @see URLConnection#getRequestProperty(String key)
+ * @see URLConnection#addRequestProperty(String key, String value)
+ *
+ * @since 1.4
+ */
+ public void setRequestProperty(String key, String value)
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ if (key == null)
+ throw new NullPointerException("key is null");
+
+ // Do nothing unless overridden by subclasses that support setting
+ // header fields in the request.
+ }
+
+ /**
+ * Adds a new request property by a key/value pair.
+ * This method does not overwrite existing properties with the same key.
+ *
+ * @param key Key of the property to add
+ * @param value Value of the Property to add
+ *
+ * @exception IllegalStateException If already connected
+ * @exception NullPointerException If key is null
+ *
+ * @see URLConnection#getRequestProperty(String)
+ * @see URLConnection#setRequestProperty(String, String)
+ *
+ * @since 1.4
+ */
+ public void addRequestProperty(String key, String value)
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ if (key == null)
+ throw new NullPointerException("key is null");
+
+ // Do nothing unless overridden by subclasses that support adding
+ // header fields in the request.
+ }
+
+ /**
+ * Returns the value of the named request property.
+ *
+ * @param key The name of the property
+ *
+ * @return Value of the property, or <code>null</code> if key is null.
+ *
+ * @exception IllegalStateException If already connected
+ *
+ * @see URLConnection#setRequestProperty(String, String)
+ * @see URLConnection#addRequestProperty(String, String)
+ */
+ public String getRequestProperty(String key)
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ // Overridden by subclasses that support reading header fields from the
+ // request.
+ return null;
+ }
+
+ /**
+ * Returns an unmodifiable Map containing the request properties.
+ *
+ * @return The map of properties. The map consists of String keys with an
+ * unmodifiable List of String objects as value.
+ *
+ * @exception IllegalStateException If already connected
+ *
+ * @since 1.4
+ */
+ public Map getRequestProperties()
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ // Overridden by subclasses that support reading header fields from the
+ // request.
+ return Collections.EMPTY_MAP;
+ }
+
+ /**
+ * Sets the default value of a request property. This will be used
+ * for all connections unless the value of the property is manually
+ * overridden.
+ *
+ * @param key The request property name the default is being set for
+ * @param value The value to set the default to
+ *
+ * @deprecated 1.3 The method setRequestProperty should be used instead.
+ * This method does nothing now.
+ *
+ * @see URLConnection#setRequestProperty(String, String)
+ */
+ public static void setDefaultRequestProperty(String key, String value)
+ {
+ // This method does nothing since JDK 1.3.
+ }
+
+ /**
+ * Returns the default value of a request property. This will be used
+ * for all connections unless the value of the property is manually
+ * overridden.
+ *
+ * @param key The request property to return the default value of
+ *
+ * @return The value of the default property or null if not available
+ *
+ * @deprecated 1.3 The method getRequestProperty should be used instead.
+ * This method does nothing now.
+ *
+ * @see URLConnection#getRequestProperty(String)
+ */
+ public static String getDefaultRequestProperty(String key)
+ {
+ // This method does nothing since JDK 1.3.
+ return null;
+ }
+
+ /**
+ * Sets the ContentHandlerFactory for an application. This can be called
+ * once and only once. If it is called again, then an Error is thrown.
+ * Unlike for other set factory methods, this one does not do a security
+ * check prior to setting the factory.
+ *
+ * @param factory The ContentHandlerFactory for this application
+ *
+ * @exception Error If the factory has already been defined
+ * @exception SecurityException If a security manager exists and its
+ * checkSetFactory method doesn't allow the operation
+ */
+ public static synchronized void setContentHandlerFactory(ContentHandlerFactory factory)
+ {
+ if (URLConnection.factory != null)
+ throw new Error("ContentHandlerFactory already set");
+
+ // Throw an exception if an extant security mgr precludes
+ // setting the factory.
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkSetFactory();
+
+ URLConnection.factory = factory;
+ }
+
+ /**
+ * Returns the MIME type of a file based on the name of the file. This
+ * works by searching for the file's extension in a list of file extensions
+ * and returning the MIME type associated with it. If no type is found,
+ * then a MIME type of "application/octet-stream" will be returned.
+ *
+ * @param filename The filename to determine the MIME type for
+ *
+ * @return The MIME type String
+ *
+ * @specnote public since JDK 1.4
+ */
+ public static String guessContentTypeFromName(String filename)
+ {
+ return getFileNameMap().getContentTypeFor(filename.toLowerCase());
+ }
+
+ /**
+ * Returns the MIME type of a stream based on the first few characters
+ * at the beginning of the stream. This routine can be used to determine
+ * the MIME type if a server is believed to be returning an incorrect
+ * MIME type. This method returns "application/octet-stream" if it
+ * cannot determine the MIME type.
+ * <p>
+ * NOTE: Overriding MIME types sent from the server can be obnoxious
+ * to user's. See Internet Exploder 4 if you don't believe me.
+ *
+ * @param is The InputStream to determine the MIME type from
+ *
+ * @return The MIME type
+ *
+ * @exception IOException If an error occurs
+ */
+ public static String guessContentTypeFromStream(InputStream is)
+ throws IOException
+ {
+ String result = VMURLConnection.guessContentTypeFromStream(is);
+ if (result == null)
+ return "application/octet-stream";
+ return result;
+ }
+
+ /**
+ * This method returns the <code>FileNameMap</code> object being used
+ * to decode MIME types by file extension.
+ *
+ * @return The <code>FileNameMap</code>.
+ *
+ * @since 1.2
+ */
+ public static synchronized FileNameMap getFileNameMap()
+ {
+ // Delayed initialization.
+ if (fileNameMap == null)
+ fileNameMap = new MimeTypeMapper();
+
+ return fileNameMap;
+ }
+
+ /**
+ * This method sets the <code>FileNameMap</code> object being used
+ * to decode MIME types by file extension.
+ *
+ * @param map The <code>FileNameMap</code>.
+ *
+ * @exception SecurityException If a security manager exists and its
+ * checkSetFactory method doesn't allow the operation
+ *
+ * @since 1.2
+ */
+ public static synchronized void setFileNameMap(FileNameMap map)
+ {
+ // Throw an exception if an extant security manager precludes
+ // setting the factory.
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkSetFactory();
+
+ fileNameMap = map;
+ }
+
+ private ContentHandler getContentHandler(String contentType)
+ {
+ // No content type so just handle it as the default.
+ if (contentType == null || contentType.equals(""))
+ return null;
+
+ ContentHandler handler = null;
+
+ // If a non-default factory has been set, use it.
+ if (factory != null)
+ handler = factory.createContentHandler(contentType);
+
+ // Now try default factory. Using this factory to instantiate built-in
+ // content handlers is preferable
+ if (handler == null)
+ handler = defaultFactory.createContentHandler(contentType);
+
+ // User-set factory has not returned a handler. Use the default search
+ // algorithm.
+ if (handler == null)
+ {
+ // Get the list of packages to check and append our default handler
+ // to it, along with the JDK specified default as a last resort.
+ // Except in very unusual environments the JDK specified one shouldn't
+ // ever be needed (or available).
+ String propVal = SystemProperties.getProperty("java.content.handler.pkgs");
+ propVal = (((propVal == null) ? "" : (propVal + "|"))
+ + "gnu.java.net.content|sun.net.www.content");
+
+ // Deal with "Content-Type: text/html; charset=ISO-8859-1".
+ int parameterBegin = contentType.indexOf(';');
+ if (parameterBegin >= 1)
+ contentType = contentType.substring(0, parameterBegin);
+ contentType = contentType.trim();
+
+ // Replace the '/' character in the content type with '.' and
+ // all other non-alphabetic, non-numeric characters with '_'.
+ char[] cArray = contentType.toCharArray();
+ for (int i = 0; i < cArray.length; i++)
+ {
+ if (cArray[i] == '/')
+ cArray[i] = '.';
+ else if (! ((cArray[i] >= 'A' && cArray[i] <= 'Z') ||
+ (cArray[i] >= 'a' && cArray[i] <= 'z') ||
+ (cArray[i] >= '0' && cArray[i] <= '9')))
+ cArray[i] = '_';
+ }
+ String contentClass = new String(cArray);
+
+ // See if a class of this content type exists in any of the packages.
+ StringTokenizer pkgPrefix = new StringTokenizer(propVal, "|");
+ do
+ {
+ String facName = pkgPrefix.nextToken() + "." + contentClass;
+ try
+ {
+ handler =
+ (ContentHandler) Class.forName(facName).newInstance();
+ }
+ catch (Exception e)
+ {
+ // Can't instantiate; handler still null, go on to next element.
+ }
+ } while (handler == null && pkgPrefix.hasMoreTokens());
+ }
+
+ return handler;
+ }
+
+ // We don't put these in a static initializer, because it creates problems
+ // with initializer co-dependency: SimpleDateFormat's constructors
+ // eventually depend on URLConnection (via the java.text.*Symbols classes).
+ private static synchronized void initializeDateFormats()
+ {
+ if (dateformats_initialized)
+ return;
+
+ Locale locale = new Locale("En", "Us", "Unix");
+ dateFormats = new SimpleDateFormat[3];
+ dateFormats[0] =
+ new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss 'GMT'", locale);
+ dateFormats[1] =
+ new SimpleDateFormat("EEEE, dd-MMM-yy hh:mm:ss 'GMT'", locale);
+ dateFormats[2] = new SimpleDateFormat("EEE MMM d hh:mm:ss yyyy", locale);
+ dateformats_initialized = true;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLDecoder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLDecoder.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLDecoder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLDecoder.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,180 @@
+/* URLDecoder.java -- Class to decode URL's from encoded form.
+ Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.net;
+
+import java.io.UnsupportedEncodingException;
+
+
+/**
+ * This utility class contains static methods that converts a
+ * string encoded in the x-www-form-urlencoded format to the original
+ * text. The x-www-form-urlencoded format replaces certain disallowed
+ * characters with encoded equivalents. All upper case and lower case
+ * letters in the US alphabet remain as is, the space character (' ')
+ * is replaced with '+' sign, and all other characters are converted to a
+ * "%XX" format where XX is the hexadecimal representation of that character
+ * in a given character encoding (default is "UTF-8").
+ * <p>
+ * This method is very useful for decoding strings sent to CGI scripts
+ *
+ * Written using on-line Java Platform 1.2/1.4 API Specification.
+ * Status: Believed complete and correct.
+ *
+ * @since 1.2
+ *
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com) (documentation comments)
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+public class URLDecoder
+{
+ /**
+ * Public contructor. Note that this class has only static methods.
+ */
+ public URLDecoder()
+ {
+ }
+
+ /**
+ * This method translates the passed in string from x-www-form-urlencoded
+ * format using the default encoding "UTF-8" to decode the hex encoded
+ * unsafe characters.
+ *
+ * @param s the String to convert
+ *
+ * @return the converted String
+ *
+ * @deprecated
+ */
+ public static String decode(String s)
+ {
+ try
+ {
+ return decode(s, "UTF-8");
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ // Should never happen since UTF-8 encoding should always be supported
+ return s;
+ }
+ }
+
+ /**
+ * This method translates the passed in string from x-www-form-urlencoded
+ * format using the given character encoding to decode the hex encoded
+ * unsafe characters.
+ *
+ * This implementation will decode the string even if it contains
+ * unsafe characters (characters that should have been encoded) or if the
+ * two characters following a % do not represent a hex encoded byte.
+ * In those cases the unsafe character or the % character will be added
+ * verbatim to the decoded result.
+ *
+ * @param s the String to convert
+ * @param encoding the character encoding to use the decode the hex encoded
+ * unsafe characters
+ *
+ * @return the converted String
+ *
+ * @exception UnsupportedEncodingException If the named encoding is not
+ * supported
+ *
+ * @since 1.4
+ */
+ public static String decode(String s, String encoding)
+ throws UnsupportedEncodingException
+ {
+ // First convert all '+' characters to spaces.
+ String str = s.replace('+', ' ');
+
+ // Then go through the whole string looking for byte encoded characters
+ int i;
+ int start = 0;
+ byte[] bytes = null;
+ int length = str.length();
+ StringBuffer result = new StringBuffer(length);
+ while ((i = str.indexOf('%', start)) >= 0)
+ {
+ // Add all non-encoded characters to the result buffer
+ result.append(str.substring(start, i));
+ start = i;
+
+ // Get all consecutive encoded bytes
+ while ((i + 2 < length) && (str.charAt(i) == '%'))
+ i += 3;
+
+ // Decode all these bytes
+ if ((bytes == null) || (bytes.length < ((i - start) / 3)))
+ bytes = new byte[((i - start) / 3)];
+
+ int index = 0;
+ try
+ {
+ while (start < i)
+ {
+ String sub = str.substring(start + 1, start + 3);
+ bytes[index] = (byte) Integer.parseInt(sub, 16);
+ index++;
+ start += 3;
+ }
+ }
+ catch (NumberFormatException nfe)
+ {
+ // One of the hex encoded strings was bad
+ }
+
+ // Add the bytes as characters according to the given encoding
+ result.append(new String(bytes, 0, index, encoding));
+
+ // Make sure we skip to just after a % sign
+ // There might not have been enough encoded characters after the %
+ // or the hex chars were not actually hex chars (NumberFormatException)
+ if (start < length && s.charAt(start) == '%')
+ {
+ result.append('%');
+ start++;
+ }
+ }
+
+ // Add any characters left
+ if (start < str.length())
+ result.append(str.substring(start));
+
+ return result.toString();
+ }
+} // class URLDecoder
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLEncoder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLEncoder.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLEncoder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLEncoder.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,184 @@
+/* URLEncoder.java -- Class to convert strings to a properly encoded URL
+ Copyright (C) 1998, 1999, 2001, 2002, 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 java.net;
+
+import java.io.UnsupportedEncodingException;
+
+
+/*
+ * Written using on-line Java Platform 1.2/1.4 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status: Believed complete and correct.
+ */
+
+/**
+ * This utility class contains static methods that converts a
+ * string into a fully encoded URL string in x-www-form-urlencoded
+ * format. This format replaces certain disallowed characters with
+ * encoded equivalents. All upper case and lower case letters in the
+ * US alphabet remain as is, the space character (' ') is replaced with
+ * '+' sign, and all other characters are converted to a "%XX" format
+ * where XX is the hexadecimal representation of that character in a
+ * certain encoding (by default, the platform encoding, though the
+ * standard is "UTF-8").
+ * <p>
+ * This method is very useful for encoding strings to be sent to CGI scripts
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+public class URLEncoder
+{
+ /**
+ * This method translates the passed in string into x-www-form-urlencoded
+ * format using the default encoding. The standard encoding is
+ * "UTF-8", and the two-argument form of this method should be used
+ * instead.
+ *
+ * @param s The String to convert
+ *
+ * @return The converted String
+ *
+ * @deprecated
+ */
+ public static String encode(String s)
+ {
+ try
+ {
+ // We default to 8859_1 for compatibility with the same
+ // default elsewhere in the library.
+ return encode(s, System.getProperty("file.encoding", "8859_1"));
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ // Should never happen since default should always be supported
+ return s;
+ }
+ }
+
+ /**
+ * This method translates the passed in string into x-www-form-urlencoded
+ * format using the character encoding to hex-encode the unsafe characters.
+ *
+ * @param s The String to convert
+ * @param encoding The encoding to use for unsafe characters
+ *
+ * @return The converted String
+ *
+ * @exception UnsupportedEncodingException If the named encoding is not
+ * supported
+ *
+ * @since 1.4
+ */
+ public static String encode(String s, String encoding)
+ throws UnsupportedEncodingException
+ {
+ int length = s.length();
+ int start = 0;
+ int i = 0;
+
+ StringBuffer result = new StringBuffer(length);
+ while (true)
+ {
+ while (i < length && isSafe(s.charAt(i)))
+ i++;
+
+ // Safe character can just be added
+ result.append(s.substring(start, i));
+
+ // Are we done?
+ if (i >= length)
+ return result.toString();
+ else if (s.charAt(i) == ' ')
+ {
+ result.append('+'); // Replace space char with plus symbol.
+ i++;
+ }
+ else
+ {
+ // Get all unsafe characters
+ start = i;
+ char c;
+ while (i < length && (c = s.charAt(i)) != ' ' && ! isSafe(c))
+ i++;
+
+ // Convert them to %XY encoded strings
+ String unsafe = s.substring(start, i);
+ byte[] bytes = unsafe.getBytes(encoding);
+ for (int j = 0; j < bytes.length; j++)
+ {
+ result.append('%');
+ int val = bytes[j];
+ result.append(hex.charAt((val & 0xf0) >> 4));
+ result.append(hex.charAt(val & 0x0f));
+ }
+ }
+ start = i;
+ }
+ }
+
+ /**
+ * Private static method that returns true if the given char is either
+ * a uppercase or lowercase letter from 'a' till 'z', or a digit froim
+ * '0' till '9', or one of the characters '-', '_', '.' or '*'. Such
+ * 'safe' character don't have to be url encoded.
+ */
+ private static boolean isSafe(char c)
+ {
+ return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
+ || (c >= '0' && c <= '9') || c == '-' || c == '_' || c == '.'
+ || c == '*');
+ }
+
+ /**
+ * Private constructor that does nothing. Included to avoid a default
+ * public constructor being created by the compiler.
+ */
+ private URLEncoder()
+ {
+ }
+
+ /**
+ * Used to convert to hex. We don't use Integer.toHexString, since
+ * it converts to lower case (and the Sun docs pretty clearly
+ * specify upper case here), and because it doesn't provide a
+ * leading 0.
+ */
+ private static final String hex = "0123456789ABCDEF";
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLStreamHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLStreamHandler.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLStreamHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLStreamHandler.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,539 @@
+/* URLStreamHandler.java -- Abstract superclass for all protocol handlers
+ Copyright (C) 1998, 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.net;
+
+import java.io.File;
+import java.io.IOException;
+
+
+/*
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status: Believed complete and correct.
+ */
+
+/**
+ * This class is the superclass of all URL protocol handlers. The URL
+ * class loads the appropriate protocol handler to establish a connection
+ * to a (possibly) remote service (eg, "http", "ftp") and to do protocol
+ * specific parsing of URL's. Refer to the URL class documentation for
+ * details on how that class locates and loads protocol handlers.
+ * <p>
+ * A protocol handler implementation should override the openConnection()
+ * method, and optionally override the parseURL() and toExternalForm()
+ * methods if necessary. (The default implementations will parse/write all
+ * URL's in the same form as http URL's). A protocol specific subclass
+ * of URLConnection will most likely need to be created as well.
+ * <p>
+ * Note that the instance methods in this class are called as if they
+ * were static methods. That is, a URL object to act on is passed with
+ * every call rather than the caller assuming the URL is stored in an
+ * instance variable of the "this" object.
+ * <p>
+ * The methods in this class are protected and accessible only to subclasses.
+ * URLStreamConnection objects are intended for use by the URL class only,
+ * not by other classes (unless those classes are implementing protocols).
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ *
+ * @see URL
+ */
+public abstract class URLStreamHandler
+{
+ /**
+ * Creates a URLStreamHander
+ */
+ public URLStreamHandler()
+ {
+ }
+
+ /**
+ * Returns a URLConnection for the passed in URL. Note that this should
+ * not actually create the connection to the (possibly) remote host, but
+ * rather simply return a URLConnection object. The connect() method of
+ * URL connection is used to establish the actual connection, possibly
+ * after the caller sets up various connection options.
+ *
+ * @param url The URL to get a connection object for
+ *
+ * @return A URLConnection object for the given URL
+ *
+ * @exception IOException If an error occurs
+ */
+ protected abstract URLConnection openConnection(URL url)
+ throws IOException;
+
+ /**
+ * This method parses the string passed in as a URL and set's the
+ * instance data fields in the URL object passed in to the various values
+ * parsed out of the string. The start parameter is the position to start
+ * scanning the string. This is usually the position after the ":" which
+ * terminates the protocol name. The end parameter is the position to
+ * stop scanning. This will be either the end of the String, or the
+ * position of the "#" character, which separates the "file" portion of
+ * the URL from the "anchor" portion.
+ * <p>
+ * This method assumes URL's are formatted like http protocol URL's, so
+ * subclasses that implement protocols with URL's the follow a different
+ * syntax should override this method. The lone exception is that if
+ * the protocol name set in the URL is "file", this method will accept
+ * an empty hostname (i.e., "file:///"), which is legal for that protocol
+ *
+ * @param url The URL object in which to store the results
+ * @param spec The String-ized URL to parse
+ * @param start The position in the string to start scanning from
+ * @param end The position in the string to stop scanning
+ */
+ protected void parseURL(URL url, String spec, int start, int end)
+ {
+ String host = url.getHost();
+ int port = url.getPort();
+ String file = url.getFile();
+ String ref = url.getRef();
+ String userInfo = url.getUserInfo();
+ String authority = url.getAuthority();
+ String query = null;
+
+ // On Windows we need to change \ to / for file URLs
+ char separator = File.separatorChar;
+ if (url.getProtocol().equals("file") && separator != '/')
+ {
+ file = file.replace(separator, '/');
+ spec = spec.replace(separator, '/');
+ }
+
+ if (spec.regionMatches(start, "//", 0, 2))
+ {
+ String genuineHost;
+ int hostEnd;
+ int colon;
+ int at_host;
+
+ start += 2;
+ int slash = spec.indexOf('/', start);
+ if (slash >= 0)
+ hostEnd = slash;
+ else
+ hostEnd = end;
+
+ authority = host = spec.substring(start, hostEnd);
+
+ // We first need a genuine host name (with userinfo).
+ // So we check for '@': if it's present check the port in the
+ // section after '@' in the other case check it in the full string.
+ // P.S.: We don't care having '@' at the beginning of the string.
+ if ((at_host = host.indexOf('@')) >= 0)
+ {
+ genuineHost = host.substring(at_host);
+ userInfo = host.substring(0, at_host);
+ }
+ else
+ genuineHost = host;
+
+ // Look for optional port number. It is valid for the non-port
+ // part of the host name to be null (e.g. a URL "http://:80").
+ // TBD: JDK 1.2 in this case sets host to null rather than "";
+ // this is undocumented and likely an unintended side effect in 1.2
+ // so we'll be simple here and stick with "". Note that
+ // "http://" or "http:///" produce a "" host in JDK 1.2.
+ if ((colon = genuineHost.indexOf(':')) >= 0)
+ {
+ try
+ {
+ port = Integer.parseInt(genuineHost.substring(colon + 1));
+ }
+ catch (NumberFormatException e)
+ {
+ // Ignore invalid port values; port is already set to u's
+ // port.
+ }
+
+ // Now we must cut the port number in the original string.
+ if (at_host >= 0)
+ host = host.substring(0, at_host + colon);
+ else
+ host = host.substring(0, colon);
+ }
+ file = null;
+ start = hostEnd;
+ }
+ else if (host == null)
+ host = "";
+
+ if (file == null || file.length() == 0
+ || (start < end && spec.charAt(start) == '/'))
+ {
+ // No file context available; just spec for file.
+ // Or this is an absolute path name; ignore any file context.
+ file = spec.substring(start, end);
+ ref = null;
+ }
+ else if (start < end)
+ {
+ // Context is available, but only override it if there is a new file.
+ int lastSlash = file.lastIndexOf('/');
+ if (lastSlash < 0)
+ file = spec.substring(start, end);
+ else
+ file = (file.substring(0, lastSlash)
+ + '/' + spec.substring(start, end));
+
+ // For URLs constructed relative to a context, we
+ // need to canonicalise the file path.
+ file = canonicalizeFilename(file);
+
+ ref = null;
+ }
+
+ if (ref == null)
+ {
+ // Normally there should be no '#' in the file part,
+ // but we are nice.
+ int hash = file.indexOf('#');
+ if (hash != -1)
+ {
+ ref = file.substring(hash + 1, file.length());
+ file = file.substring(0, hash);
+ }
+ }
+
+ // We care about the query tag only if there is no reference at all.
+ if (ref == null)
+ {
+ int queryTag = file.indexOf('?');
+ if (queryTag != -1)
+ {
+ query = file.substring(queryTag + 1);
+ file = file.substring(0, queryTag);
+ }
+ }
+
+ // XXX - Classpath used to call PlatformHelper.toCanonicalForm() on
+ // the file part. It seems like overhead, but supposedly there is some
+ // benefit in windows based systems (it also lowercased the string).
+ setURL(url, url.getProtocol(), host, port, authority, userInfo, file, query, ref);
+ }
+
+ /*
+ * Canonicalize a filename.
+ */
+ private static String canonicalizeFilename(String file)
+ {
+ // XXX - GNU Classpath has an implementation that might be more appropriate
+ // for Windows based systems (gnu.java.io.PlatformHelper.toCanonicalForm)
+ int index;
+
+ // Replace "/./" with "/". This probably isn't very efficient in
+ // the general case, but it's probably not bad most of the time.
+ while ((index = file.indexOf("/./")) >= 0)
+ file = file.substring(0, index) + file.substring(index + 2);
+
+ // Process "/../" correctly. This probably isn't very efficient in
+ // the general case, but it's probably not bad most of the time.
+ while ((index = file.indexOf("/../")) >= 0)
+ {
+ // Strip of the previous directory - if it exists.
+ int previous = file.lastIndexOf('/', index - 1);
+ if (previous >= 0)
+ file = file.substring(0, previous) + file.substring(index + 3);
+ else
+ break;
+ }
+ return file;
+ }
+
+ /**
+ * Compares two URLs, excluding the fragment component
+ *
+ * @param url1 The first url
+ * @param url2 The second url to compare with the first
+ *
+ * @return True if both URLs point to the same file, false otherwise.
+ *
+ * @specnote Now protected
+ */
+ protected boolean sameFile(URL url1, URL url2)
+ {
+ if (url1 == url2)
+ return true;
+
+ // This comparison is very conservative. It assumes that any
+ // field can be null.
+ if (url1 == null || url2 == null)
+ return false;
+ int p1 = url1.getPort();
+ if (p1 == -1)
+ p1 = url1.ph.getDefaultPort();
+ int p2 = url2.getPort();
+ if (p2 == -1)
+ p2 = url2.ph.getDefaultPort();
+ if (p1 != p2)
+ return false;
+ String s1;
+ String s2;
+ s1 = url1.getProtocol();
+ s2 = url2.getProtocol();
+ if (s1 != s2 && (s1 == null || ! s1.equals(s2)))
+ return false;
+ s1 = url1.getHost();
+ s2 = url2.getHost();
+ if (s1 != s2 && (s1 == null || ! s1.equals(s2)))
+ return false;
+ s1 = canonicalizeFilename(url1.getFile());
+ s2 = canonicalizeFilename(url2.getFile());
+ if (s1 != s2 && (s1 == null || ! s1.equals(s2)))
+ return false;
+ return true;
+ }
+
+ /**
+ * This methods sets the instance variables representing the various fields
+ * of the URL to the values passed in.
+ *
+ * @param u The URL to modify
+ * @param protocol The protocol to set
+ * @param host The host name to et
+ * @param port The port number to set
+ * @param file The filename to set
+ * @param ref The reference
+ *
+ * @exception SecurityException If the protocol handler of the URL is
+ * different from this one
+ *
+ * @deprecated 1.2 Please use
+ * #setURL(URL,String,String,int,String,String,String,String);
+ */
+ protected void setURL(URL u, String protocol, String host, int port,
+ String file, String ref)
+ {
+ u.set(protocol, host, port, file, ref);
+ }
+
+ /**
+ * Sets the fields of the URL argument to the indicated values
+ *
+ * @param u The URL to modify
+ * @param protocol The protocol to set
+ * @param host The host name to set
+ * @param port The port number to set
+ * @param authority The authority to set
+ * @param userInfo The user information to set
+ * @param path The path/filename to set
+ * @param query The query part to set
+ * @param ref The reference
+ *
+ * @exception SecurityException If the protocol handler of the URL is
+ * different from this one
+ */
+ protected void setURL(URL u, String protocol, String host, int port,
+ String authority, String userInfo, String path,
+ String query, String ref)
+ {
+ u.set(protocol, host, port, authority, userInfo, path, query, ref);
+ }
+
+ /**
+ * This is the default method for computing whether two URLs are
+ * equivalent. This method assumes that neither URL is null.
+ *
+ * @param url1 An URL object
+ * @param url2 Another URL object
+ *
+ * @return True if both given URLs are equal, false otherwise.
+ */
+ protected boolean equals(URL url1, URL url2)
+ {
+ // This comparison is very conservative. It assumes that any
+ // field can be null.
+ int port1 = url1.getPort();
+ if (port1 == -1)
+ port1 = url1.getDefaultPort();
+ int port2 = url2.getPort();
+ if (port2 == -1)
+ port2 = url2.getDefaultPort();
+ // Note that we don't bother checking the 'authority'; it is
+ // redundant.
+ return (port1 == port2
+ && ((url1.getProtocol() == null && url2.getProtocol() == null)
+ || (url1.getProtocol() != null
+ && url1.getProtocol().equals(url2.getProtocol())))
+ && ((url1.getUserInfo() == null && url2.getUserInfo() == null)
+ || (url1.getUserInfo() != null
+ && url1.getUserInfo().equals(url2.getUserInfo())))
+ && ((url1.getHost() == null && url2.getHost() == null)
+ || (url1.getHost() != null && url1.getHost().equals(url2.getHost())))
+ && ((url1.getPath() == null && url2.getPath() == null)
+ || (url1.getPath() != null && url1.getPath().equals(url2.getPath())))
+ && ((url1.getQuery() == null && url2.getQuery() == null)
+ || (url1.getQuery() != null
+ && url1.getQuery().equals(url2.getQuery())))
+ && ((url1.getRef() == null && url2.getRef() == null)
+ || (url1.getRef() != null && url1.getRef().equals(url2.getRef()))));
+ }
+
+ /**
+ * Compares the host components of two URLs.
+ *
+ * @param url1 The first URL.
+ * @param url2 The second URL.
+ *
+ * @return True if both URLs contain the same host.
+ */
+ protected boolean hostsEqual(URL url1, URL url2)
+ {
+ InetAddress addr1 = getHostAddress(url1);
+ InetAddress addr2 = getHostAddress(url2);
+
+ if (addr1 != null && addr2 != null)
+ return addr1.equals(addr2);
+
+ String host1 = url1.getHost();
+ String host2 = url2.getHost();
+
+ if (host1 != null && host2 != null)
+ return host1.equalsIgnoreCase(host2);
+
+ return host1 == null && host2 == null;
+ }
+
+ /**
+ * Get the IP address of our host. An empty host field or a DNS failure will
+ * result in a null return.
+ *
+ * @param url The URL to return the host address for.
+ *
+ * @return The address of the hostname in url.
+ */
+ protected InetAddress getHostAddress(URL url)
+ {
+ String hostname = url.getHost();
+
+ if (hostname.equals(""))
+ return null;
+
+ try
+ {
+ return InetAddress.getByName(hostname);
+ }
+ catch (UnknownHostException e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns the default port for a URL parsed by this handler. This method is
+ * meant to be overidden by handlers with default port numbers.
+ *
+ * @return The default port number.
+ */
+ protected int getDefaultPort()
+ {
+ return -1;
+ }
+
+ /**
+ * Provides the default hash calculation. May be overidden by handlers for
+ * other protocols that have different requirements for hashCode calculation.
+ *
+ * @param url The URL to calc the hashcode for.
+ *
+ * @return The hashcode for the given URL.
+ */
+ protected int hashCode(URL url)
+ {
+ return url.getProtocol().hashCode()
+ + ((url.getHost() == null) ? 0 : url.getHost().hashCode())
+ + url.getFile().hashCode() + url.getPort();
+ }
+
+ /**
+ * This method converts a URL object into a String. This method creates
+ * Strings in the mold of http URL's, so protocol handlers which use URL's
+ * that have a different syntax should override this method
+ *
+ * @param url The URL object to convert
+ *
+ * @return A string representation of the url
+ */
+ protected String toExternalForm(URL url)
+ {
+ String protocol;
+ String file;
+ String ref;
+ String authority;
+
+ protocol = url.getProtocol();
+ authority = url.getAuthority();
+ if (authority == null)
+ authority = "";
+
+ file = url.getFile();
+ ref = url.getRef();
+
+ // Guess a reasonable size for the string buffer so we have to resize
+ // at most once.
+ int size = protocol.length() + authority.length() + file.length() + 24;
+ StringBuffer sb = new StringBuffer(size);
+
+ if (protocol.length() > 0)
+ {
+ sb.append(protocol);
+ sb.append(":");
+ }
+
+ // If we have superfluous leading slashes (that means, at least 2)
+ // we always add the authority component ("//" + host) to
+ // avoid ambiguity. Otherwise we would generate an URL like
+ // proto://home/foo
+ // where we meant:
+ // host: <empty> - file: //home/foo
+ // but URL spec says it is:
+ // host: home - file: /foo
+ if (authority.length() != 0 || file.startsWith("//") )
+ sb.append("//").append(authority).append(file);
+ else
+ sb.append(file);
+
+ if (ref != null)
+ sb.append('#').append(ref);
+
+ return sb.toString();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLStreamHandlerFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLStreamHandlerFactory.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLStreamHandlerFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/URLStreamHandlerFactory.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* URLStreamHandlerFactory.java -- Maps protocols to URLStreamHandlers
+ Copyright (C) 1998, 1999, 2000, 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 java.net;
+
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status: Believed complete and correct.
+ */
+/**
+ * This interface contains one method which maps the protocol portion of
+ * a URL (eg, "http" in "http://www.urbanophile.com/arenn/") to a
+ * <code>URLStreamHandler</code> object.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ */
+public interface URLStreamHandlerFactory
+{
+ /**
+ * This method maps the protocol portion of a URL to a
+ * <code>URLStreamHandler</code> object.
+ *
+ * @param protocol The protocol name to map ("http", "ftp", etc).
+ *
+ * @return The <code>URLStreamHandler</code> for the specified protocol
+ */
+ URLStreamHandler createURLStreamHandler(String protocol);
+} // interface URLStreamHandlerFactory
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/net/UnknownHostException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/net/UnknownHostException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/UnknownHostException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/UnknownHostException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,77 @@
+/* UnknownHostException.java -- The hostname is unknown
+ Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.net;
+
+import java.io.IOException;
+
+
+/**
+ * This exception indicates that an attempt was made to reference a hostname
+ * or IP address that is not valid. This could possibly indicate that a
+ * DNS problem has occurred, but most often means that the host was not
+ * correctly specified.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Per Bothner
+ * @status updated to 1.4
+ */
+public class UnknownHostException extends IOException
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -4639126076052875403L;
+
+ /**
+ * Create a new instance without a descriptive error message.
+ */
+ public UnknownHostException()
+ {
+ }
+
+ /**
+ * Create a new instance with a descriptive error message, such as the
+ * name of the host that could not be resolved.
+ *
+ * @param message a message describing the error that occurred
+ */
+ public UnknownHostException(String message)
+ {
+ super(message);
+ }
+} // class UnknownHostException
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/net/UnknownServiceException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/net/UnknownServiceException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/UnknownServiceException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/UnknownServiceException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* UnknownServiceException.java -- A service error occurred
+ Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.net;
+
+import java.io.IOException;
+
+
+/**
+ * Contrary to what you might think, this does not indicate that the
+ * TCP/IP service name specified was invalid. Instead it indicates that
+ * the MIME type returned from a URL could not be determined or that an
+ * attempt was made to write to a read-only URL.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class UnknownServiceException extends IOException
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -4169033248853639508L;
+
+ /**
+ * Create a new instance without a descriptive error message.
+ */
+ public UnknownServiceException()
+ {
+ }
+
+ /**
+ * Create a new instance with a descriptive error message.
+ *
+ * @param message a message describing the error that occurred
+ */
+ public UnknownServiceException(String message)
+ {
+ super(message);
+ }
+} // class UnknownServiceException
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/net/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/net/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.net package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.net</title></head>
+
+<body>
+<p>Network communication through TCP and UDP sockets or URLs.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/Buffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/Buffer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/Buffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/Buffer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,361 @@
+/* Buffer.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+import gnu.classpath.Pointer;
+
+/**
+ * @since 1.4
+ */
+public abstract class Buffer
+{
+ int cap = 0;
+ int limit = 0;
+ int pos = 0;
+ int mark = -1;
+ Pointer address;
+
+ /**
+ * Creates a new Buffer.
+ *
+ * Should be package private.
+ */
+ Buffer (int capacity, int limit, int position, int mark)
+ {
+ if (capacity < 0)
+ throw new IllegalArgumentException ();
+
+ cap = capacity;
+ limit (limit);
+ position (position);
+
+ if (mark >= 0)
+ {
+ if (mark > pos)
+ throw new IllegalArgumentException ();
+
+ this.mark = mark;
+ }
+ }
+
+ /**
+ * Retrieves the capacity of the buffer.
+ *
+ * @return the capacity of the buffer
+ */
+ public final int capacity ()
+ {
+ return cap;
+ }
+
+ /**
+ * Clears the buffer.
+ *
+ * @return this buffer
+ */
+ public final Buffer clear ()
+ {
+ limit = cap;
+ pos = 0;
+ mark = -1;
+ return this;
+ }
+
+ /**
+ * Flips the buffer.
+ *
+ * @return this buffer
+ */
+ public final Buffer flip ()
+ {
+ limit = pos;
+ pos = 0;
+ mark = -1;
+ return this;
+ }
+
+ /**
+ * Tells whether the buffer has remaining data to read or not.
+ *
+ * @return true if the buffer contains remaining data to read,
+ * false otherwise
+ */
+ public final boolean hasRemaining ()
+ {
+ return remaining() > 0;
+ }
+
+ /**
+ * Tells whether this buffer is read only or not.
+ *
+ * @return true if the buffer is read only, false otherwise
+ */
+ public abstract boolean isReadOnly ();
+
+ /**
+ * Retrieves the current limit of the buffer.
+ *
+ * @return the limit of the buffer
+ */
+ public final int limit ()
+ {
+ return limit;
+ }
+
+ /**
+ * Sets this buffer's limit.
+ *
+ * @param newLimit The new limit value; must be non-negative and no larger
+ * than this buffer's capacity.
+ *
+ * @return this buffer
+ *
+ * @exception IllegalArgumentException If the preconditions on newLimit
+ * do not hold.
+ */
+ public final Buffer limit (int newLimit)
+ {
+ if ((newLimit < 0) || (newLimit > cap))
+ throw new IllegalArgumentException ();
+
+ if (newLimit < mark)
+ mark = -1;
+
+ if (pos > newLimit)
+ pos = newLimit;
+
+ limit = newLimit;
+ return this;
+ }
+
+ /**
+ * Sets this buffer's mark at its position.
+ *
+ * @return this buffer
+ */
+ public final Buffer mark ()
+ {
+ mark = pos;
+ return this;
+ }
+
+ /**
+ * Retrieves the current position of this buffer.
+ *
+ * @return the current position of this buffer
+ */
+ public final int position ()
+ {
+ return pos;
+ }
+
+ /**
+ * Sets this buffer's position. If the mark is defined and larger than the
+ * new position then it is discarded.
+ *
+ * @param newPosition The new position value; must be non-negative and no
+ * larger than the current limit.
+ *
+ * @return this buffer
+ *
+ * @exception IllegalArgumentException If the preconditions on newPosition
+ * do not hold
+ */
+ public final Buffer position (int newPosition)
+ {
+ if ((newPosition < 0) || (newPosition > limit))
+ throw new IllegalArgumentException ();
+
+ if (newPosition <= mark)
+ mark = -1;
+
+ pos = newPosition;
+ return this;
+ }
+
+ /**
+ * Returns the number of elements between the current position and the limit.
+ *
+ * @return the number of remaining elements
+ */
+ public final int remaining()
+ {
+ return limit - pos;
+ }
+
+ /**
+ * Resets this buffer's position to the previously-marked position.
+ *
+ * @return this buffer
+ *
+ * @exception InvalidMarkException If the mark has not been set.
+ */
+ public final Buffer reset()
+ {
+ if (mark == -1)
+ throw new InvalidMarkException ();
+
+ pos = mark;
+ return this;
+ }
+
+ /**
+ * Rewinds this buffer. The position is set to zero and the mark
+ * is discarded.
+ *
+ * @return this buffer
+ */
+ public final Buffer rewind()
+ {
+ pos = 0;
+ mark = -1;
+ return this;
+ }
+
+ /**
+ * Checks for underflow. This method is used internally to check
+ * whether a buffer has enough elements left to satisfy a read
+ * request.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * elements in this buffer.
+ */
+ final void checkForUnderflow()
+ {
+ if (!hasRemaining())
+ throw new BufferUnderflowException();
+ }
+
+ /**
+ * Checks for underflow. This method is used internally to check
+ * whether a buffer has enough elements left to satisfy a read
+ * request for a given number of elements.
+ *
+ * @param length The length of a sequence of elements.
+ *
+ * @exception BufferUnderflowException If there are not enough
+ * remaining elements in this buffer.
+ */
+ final void checkForUnderflow(int length)
+ {
+ if (remaining() < length)
+ throw new BufferUnderflowException();
+ }
+
+ /**
+ * Checks for overflow. This method is used internally to check
+ * whether a buffer has enough space left to satisfy a write
+ * request.
+ *
+ * @exception BufferOverflowException If there is no remaining
+ * space in this buffer.
+ */
+ final void checkForOverflow()
+ {
+ if (!hasRemaining())
+ throw new BufferOverflowException();
+ }
+
+ /**
+ * Checks for overflow. This method is used internally to check
+ * whether a buffer has enough space left to satisfy a write
+ * request for a given number of elements.
+ *
+ * @param length The length of a sequence of elements.
+ *
+ * @exception BufferUnderflowException If there is not enough
+ * remaining space in this buffer.
+ */
+ final void checkForOverflow(int length)
+ {
+ if (remaining() < length)
+ throw new BufferOverflowException();
+ }
+
+ /**
+ * Checks if index is negative or not smaller than the buffer's
+ * limit. This method is used internally to check whether
+ * an indexed request can be fulfilled.
+ *
+ * @param index The requested position in the buffer.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ final void checkIndex(int index)
+ {
+ if (index < 0
+ || index >= limit ())
+ throw new IndexOutOfBoundsException ();
+ }
+
+ /**
+ * Checks if buffer is read-only. This method is used internally to
+ * check if elements can be put into a buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ final void checkIfReadOnly()
+ {
+ if (isReadOnly())
+ throw new ReadOnlyBufferException ();
+ }
+
+ /**
+ * Checks whether an array is large enough to hold the given number of
+ * elements at the given offset. This method is used internally to
+ * check if an array is big enough.
+ *
+ * @param arraylength The length of the array.
+ * @param offset The offset within the array of the first byte to be read;
+ * must be non-negative and no larger than arraylength.
+ * @param length The number of bytes to be read from the given array;
+ * must be non-negative and no larger than arraylength - offset.
+ *
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ */
+ static final void checkArraySize(int arraylength, int offset, int length)
+ {
+ if ((offset < 0) ||
+ (length < 0) ||
+ (arraylength < length + offset))
+ throw new IndexOutOfBoundsException ();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/BufferOverflowException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/BufferOverflowException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/BufferOverflowException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/BufferOverflowException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,53 @@
+/* BufferOverflowException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio;
+
+/**
+ * @since 1.4
+ */
+public class BufferOverflowException extends RuntimeException
+{
+ private static final long serialVersionUID = - 5484897634319144535L;
+
+ /**
+ * Creates the exception
+ */
+ public BufferOverflowException ()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/BufferUnderflowException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/BufferUnderflowException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/BufferUnderflowException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/BufferUnderflowException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,53 @@
+/* BufferUnderflowException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio;
+
+/**
+ * @since 1.4
+ */
+public class BufferUnderflowException extends RuntimeException
+{
+ private static final long serialVersionUID = - 1713313658691622206L;
+
+ /**
+ * Creates the exception
+ */
+ public BufferUnderflowException ()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteBuffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteBuffer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteBuffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteBuffer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,651 @@
+/* ByteBuffer.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * @since 1.4
+ */
+public abstract class ByteBuffer extends Buffer
+ implements Comparable
+{
+ ByteOrder endian = ByteOrder.BIG_ENDIAN;
+
+ int array_offset;
+ byte[] backing_buffer;
+
+ ByteBuffer (int capacity, int limit, int position, int mark)
+ {
+ super (capacity, limit, position, mark);
+ }
+
+ /**
+ * Allocates a new direct byte buffer.
+ */
+ public static ByteBuffer allocateDirect (int capacity)
+ {
+ return DirectByteBufferImpl.allocate (capacity);
+ }
+
+ /**
+ * Allocates a new <code>ByteBuffer</code> object with a given capacity.
+ */
+ public static ByteBuffer allocate (int capacity)
+ {
+ return wrap(new byte[capacity], 0, capacity);
+ }
+
+ /**
+ * Wraps a <code>byte</code> array into a <code>ByteBuffer</code>
+ * object.
+ *
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ */
+ public static final ByteBuffer wrap (byte[] array, int offset, int length)
+ {
+ // FIXME: In GCJ and other implementations where arrays may not
+ // move we might consider, at least when offset==0:
+ // return new DirectByteBufferImpl(array,
+ // address_of_data(array) + offset,
+ // length, length, 0, false);
+ // This may be more efficient, mainly because we can then use the
+ // same logic for all ByteBuffers.
+
+ return new ByteBufferImpl (array, 0, array.length, offset + length, offset, -1, false);
+ }
+
+ /**
+ * Wraps a <code>byte</code> array into a <code>ByteBuffer</code>
+ * object.
+ */
+ public static final ByteBuffer wrap (byte[] array)
+ {
+ return wrap (array, 0, array.length);
+ }
+
+ /**
+ * This method transfers <code>byte</code>s from this buffer into the given
+ * destination array. Before the transfer, it checks if there are fewer than
+ * length <code>byte</code>s remaining in this buffer.
+ *
+ * @param dst The destination array
+ * @param offset The offset within the array of the first <code>byte</code>
+ * to be written; must be non-negative and no larger than dst.length.
+ * @param length The maximum number of bytes to be written to the given array;
+ * must be non-negative and no larger than dst.length - offset.
+ *
+ * @exception BufferUnderflowException If there are fewer than length
+ * <code>byte</code>s remaining in this buffer.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold.
+ */
+ public ByteBuffer get (byte[] dst, int offset, int length)
+ {
+ checkArraySize(dst.length, offset, length);
+ checkForUnderflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ {
+ dst [i] = get ();
+ }
+
+ return this;
+ }
+
+ /**
+ * This method transfers <code>byte</code>s from this buffer into the given
+ * destination array.
+ *
+ * @param dst The byte array to write into.
+ *
+ * @exception BufferUnderflowException If there are fewer than dst.length
+ * <code>byte</code>s remaining in this buffer.
+ */
+ public ByteBuffer get (byte[] dst)
+ {
+ return get (dst, 0, dst.length);
+ }
+
+ /**
+ * Writes the content of the the <code>ByteBUFFER</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * <code>src.remaining()</code> space remaining in this buffer.
+ *
+ * @param src The source data.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>byte</code>s in the source buffer.
+ * @exception IllegalArgumentException If the source buffer is this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public ByteBuffer put (ByteBuffer src)
+ {
+ if (src == this)
+ throw new IllegalArgumentException ();
+
+ checkForOverflow(src.remaining());
+
+ if (src.remaining () > 0)
+ {
+ byte[] toPut = new byte [src.remaining ()];
+ src.get (toPut);
+ put (toPut);
+ }
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>byte array</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * length space remaining in this buffer.
+ *
+ * @param src The array to copy into the buffer.
+ * @param offset The offset within the array of the first byte to be read;
+ * must be non-negative and no larger than src.length.
+ * @param length The number of bytes to be read from the given array;
+ * must be non-negative and no larger than src.length - offset.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>byte</code>s in the source array.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public ByteBuffer put (byte[] src, int offset, int length)
+ {
+ checkArraySize(src.length, offset, length);
+ checkForOverflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ put (src [i]);
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>byte array</code> src
+ * into the buffer.
+ *
+ * @param src The array to copy into the buffer.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>byte</code>s in the source array.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public final ByteBuffer put (byte[] src)
+ {
+ return put (src, 0, src.length);
+ }
+
+ /**
+ * Tells whether ot not this buffer is backed by an accessible
+ * <code>byte</code> array.
+ */
+ public final boolean hasArray ()
+ {
+ return (backing_buffer != null
+ && !isReadOnly ());
+ }
+
+ /**
+ * Returns the <code>byte</code> array that backs this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final byte[] array ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return backing_buffer;
+ }
+
+ /**
+ * Returns the offset within this buffer's backing array of the first element.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final int arrayOffset ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return array_offset;
+ }
+
+ /**
+ * Calculates a hash code for this buffer.
+ *
+ * This is done with <code>int</code> arithmetic,
+ * where ** represents exponentiation, by this formula:<br>
+ * <code>s[position()] + 31 + (s[position()+1] + 30)*31**1 + ... +
+ * (s[limit()-1]+30)*31**(limit()-1)</code>.
+ * Where s is the buffer data. Note that the hashcode is dependent
+ * on buffer content, and therefore is not useful if the buffer
+ * content may change.
+ *
+ * @return the hash code
+ */
+ public int hashCode ()
+ {
+ int hashCode = get(position()) + 31;
+ int multiplier = 1;
+ for (int i = position() + 1; i < limit(); ++i)
+ {
+ multiplier *= 31;
+ hashCode += (get(i) + 30)*multiplier;
+ }
+ return hashCode;
+ }
+
+ /**
+ * Checks if this buffer is equal to obj.
+ */
+ public boolean equals (Object obj)
+ {
+ if (obj instanceof ByteBuffer)
+ {
+ return compareTo (obj) == 0;
+ }
+
+ return false;
+ }
+
+ /**
+ * Compares two <code>ByteBuffer</code> objects.
+ *
+ * @exception ClassCastException If obj is not an object derived from
+ * <code>ByteBuffer</code>.
+ */
+ public int compareTo (Object obj)
+ {
+ ByteBuffer other = (ByteBuffer) obj;
+
+ int num = Math.min(remaining(), other.remaining());
+ int pos_this = position();
+ int pos_other = other.position();
+
+ for (int count = 0; count < num; count++)
+ {
+ byte a = get(pos_this++);
+ byte b = other.get(pos_other++);
+
+ if (a == b)
+ continue;
+
+ if (a < b)
+ return -1;
+
+ return 1;
+ }
+
+ return remaining() - other.remaining();
+ }
+
+ /**
+ * Returns the byte order of this buffer.
+ */
+ public final ByteOrder order ()
+ {
+ return endian;
+ }
+
+ /**
+ * Modifies this buffer's byte order.
+ */
+ public final ByteBuffer order (ByteOrder endian)
+ {
+ this.endian = endian;
+ return this;
+ }
+
+ /**
+ * Reads the <code>byte</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>byte</code>s in this buffer.
+ */
+ public abstract byte get ();
+
+ /**
+ * Writes the <code>byte</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferOverflowException If there no remaining
+ * <code>byte</code>s in this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract ByteBuffer put (byte b);
+
+ /**
+ * Absolute get method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public abstract byte get (int index);
+
+ /**
+ * Absolute put method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract ByteBuffer put (int index, byte b);
+
+ /**
+ * Compacts this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract ByteBuffer compact ();
+
+ void shiftDown (int dst_offset, int src_offset, int count)
+ {
+ for (int i = 0; i < count; i++)
+ put(dst_offset + i, get(src_offset + i));
+ }
+
+ /**
+ * Tells whether or not this buffer is direct.
+ */
+ public abstract boolean isDirect ();
+
+ /**
+ * Creates a new <code>ByteBuffer</code> whose content is a shared
+ * subsequence of this buffer's content.
+ */
+ public abstract ByteBuffer slice ();
+
+ /**
+ * Creates a new <code>ByteBuffer</code> that shares this buffer's
+ * content.
+ */
+ public abstract ByteBuffer duplicate ();
+
+ /**
+ * Creates a new read-only <code>ByteBuffer</code> that shares this
+ * buffer's content.
+ */
+ public abstract ByteBuffer asReadOnlyBuffer ();
+
+ /**
+ * Creates a view of this byte buffer as a short buffer.
+ */
+ public abstract ShortBuffer asShortBuffer ();
+
+ /**
+ * Creates a view of this byte buffer as a char buffer.
+ */
+ public abstract CharBuffer asCharBuffer ();
+
+ /**
+ * Creates a view of this byte buffer as an integer buffer.
+ */
+ public abstract IntBuffer asIntBuffer ();
+
+ /**
+ * Creates a view of this byte buffer as a long buffer.
+ */
+ public abstract LongBuffer asLongBuffer ();
+
+ /**
+ * Creates a view of this byte buffer as a float buffer.
+ */
+ public abstract FloatBuffer asFloatBuffer ();
+
+ /**
+ * Creates a view of this byte buffer as a double buffer.
+ */
+ public abstract DoubleBuffer asDoubleBuffer ();
+
+ /**
+ * Relative get method for reading a character value.
+ *
+ * @exception BufferUnderflowException If there are fewer than two bytes
+ * remaining in this buffer.
+ */
+ public abstract char getChar ();
+
+ /**
+ * Relative put method for writing a character value.
+ *
+ * @exception BufferOverflowException If this buffer's current position is
+ * not smaller than its limit.
+ */
+ public abstract ByteBuffer putChar (char value);
+
+ /**
+ * Absolute get method for reading a character value.
+ *
+ * @exception IndexOutOfBoundsException If there are fewer than two bytes
+ * remaining in this buffer
+ */
+ public abstract char getChar (int index);
+
+ /**
+ * Absolute put method for writing a character value.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit, minus one.
+ */
+ public abstract ByteBuffer putChar (int index, char value);
+
+ /**
+ * Relative get method for reading a short value.
+ *
+ * @exception BufferUnderflowException If index is negative or not smaller
+ * than the buffer's limit, minus one.
+ */
+ public abstract short getShort ();
+
+ /**
+ * Relative put method for writing a short value.
+ *
+ * @exception BufferOverflowException If this buffer's current position is
+ * not smaller than its limit.
+ */
+ public abstract ByteBuffer putShort (short value);
+
+ /**
+ * Absolute get method for reading a short value.
+ *
+ * @exception IndexOutOfBoundsException If there are fewer than two bytes
+ * remaining in this buffer
+ */
+ public abstract short getShort (int index);
+
+ /**
+ * Absolute put method for writing a short value.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit, minus one.
+ */
+ public abstract ByteBuffer putShort (int index, short value);
+
+ /**
+ * Relative get method for reading an integer value.
+ *
+ * @exception BufferUnderflowException If there are fewer than four bytes
+ * remaining in this buffer.
+ */
+ public abstract int getInt ();
+
+ /**
+ * Relative put method for writing an integer value.
+ *
+ * @exception BufferOverflowException If this buffer's current position is
+ * not smaller than its limit.
+ */
+ public abstract ByteBuffer putInt (int value);
+
+ /**
+ * Absolute get method for reading an integer value.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit, minus three.
+ */
+ public abstract int getInt (int index);
+
+ /**
+ * Absolute put method for writing an integer value.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit, minus three.
+ */
+ public abstract ByteBuffer putInt (int index, int value);
+
+ /**
+ * Relative get method for reading a long value.
+ *
+ * @exception BufferUnderflowException If there are fewer than eight bytes
+ * remaining in this buffer.
+ */
+ public abstract long getLong ();
+
+ /**
+ * Relative put method for writing a long value.
+ *
+ * @exception BufferOverflowException If this buffer's current position is
+ * not smaller than its limit.
+ */
+ public abstract ByteBuffer putLong (long value);
+
+ /**
+ * Absolute get method for reading a long value.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit, minus seven.
+ */
+ public abstract long getLong (int index);
+
+ /**
+ * Absolute put method for writing a float value.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit, minus seven.
+ */
+ public abstract ByteBuffer putLong (int index, long value);
+
+ /**
+ * Relative get method for reading a float value.
+ *
+ * @exception BufferUnderflowException If there are fewer than four bytes
+ * remaining in this buffer.
+ */
+ public abstract float getFloat ();
+
+ /**
+ * Relative put method for writing a float value.
+ *
+ * @exception BufferOverflowException If there are fewer than four bytes
+ * remaining in this buffer.
+ */
+ public abstract ByteBuffer putFloat (float value);
+
+ /**
+ * Absolute get method for reading a float value.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit, minus three.
+ */
+ public abstract float getFloat (int index);
+
+ /**
+ * Relative put method for writing a float value.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit, minus three.
+ */
+ public abstract ByteBuffer putFloat (int index, float value);
+
+ /**
+ * Relative get method for reading a double value.
+ *
+ * @exception BufferUnderflowException If there are fewer than eight bytes
+ * remaining in this buffer.
+ */
+ public abstract double getDouble ();
+
+ /**
+ * Relative put method for writing a double value.
+ *
+ * @exception BufferOverflowException If this buffer's current position is
+ * not smaller than its limit.
+ */
+ public abstract ByteBuffer putDouble (double value);
+
+ /**
+ * Absolute get method for reading a double value.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit, minus seven.
+ */
+ public abstract double getDouble (int index);
+
+ /**
+ * Absolute put method for writing a double value.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit, minus seven.
+ */
+ public abstract ByteBuffer putDouble (int index, double value);
+
+ /**
+ * Returns a string summarizing the state of this buffer.
+ */
+ public String toString ()
+ {
+ return getClass ().getName () +
+ "[pos=" + position () +
+ " lim=" + limit () +
+ " cap=" + capacity () + "]";
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteBufferHelper.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteBufferHelper.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteBufferHelper.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteBufferHelper.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,344 @@
+/* ByteBufferImpl.java --
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+final class ByteBufferHelper
+{
+ public static char getChar (ByteBuffer buffer, ByteOrder order)
+ {
+ return (char) getShort (buffer, order);
+ }
+
+ public static void putChar (ByteBuffer buffer, char value, ByteOrder order)
+ {
+ putShort (buffer, (short) value, order);
+ }
+
+ public static char getChar (ByteBuffer buffer, int index, ByteOrder order)
+ {
+ return (char) getShort (buffer, index, order);
+ }
+
+ public static void putChar (ByteBuffer buffer, int index,
+ char value, ByteOrder order)
+ {
+ putShort (buffer, index, (short) value, order);
+ }
+
+ public static short getShort (ByteBuffer buffer, ByteOrder order)
+ {
+ buffer.checkForUnderflow(2);
+
+ if (order == ByteOrder.LITTLE_ENDIAN)
+ {
+ return (short) ((buffer.get() & 0xff)
+ + (buffer.get() << 8));
+ }
+
+ return (short) ((buffer.get() << 8)
+ + (buffer.get() & 0xff));
+ }
+
+ public static void putShort (ByteBuffer buffer, short value, ByteOrder order)
+ {
+ buffer.checkForOverflow(2);
+
+ if (order == ByteOrder.LITTLE_ENDIAN)
+ {
+ buffer.put ((byte) value);
+ buffer.put ((byte) (value >> 8));
+ }
+ else
+ {
+ buffer.put ((byte) (value >> 8));
+ buffer.put ((byte) value);
+ }
+ }
+
+ public static short getShort (ByteBuffer buffer,
+ int index, ByteOrder order)
+ {
+ if (order == ByteOrder.LITTLE_ENDIAN)
+ {
+ return (short) ((buffer.get (index) & 0xff)
+ + (buffer.get (++index) << 8));
+ }
+
+ return (short) ((buffer.get (index) << 8)
+ + (buffer.get (++index) & 0xff));
+ }
+
+ public static void putShort (ByteBuffer buffer, int index,
+ short value, ByteOrder order)
+ {
+ if (order == ByteOrder.LITTLE_ENDIAN)
+ {
+ buffer.put (index, (byte) value);
+ buffer.put (++index, (byte) (value >> 8));
+ }
+ else
+ {
+ buffer.put (index, (byte) (value >> 8));
+ buffer.put (++index, (byte) value);
+ }
+ }
+
+ public static int getInt (ByteBuffer buffer, ByteOrder order)
+ {
+ buffer.checkForUnderflow(4);
+
+ if (order == ByteOrder.LITTLE_ENDIAN)
+ {
+ return ((buffer.get() & 0xff)
+ + ((buffer.get() & 0xff) << 8)
+ + ((buffer.get() & 0xff) << 16)
+ + (buffer.get() << 24));
+ }
+
+ return (int) ((buffer.get() << 24)
+ + ((buffer.get() & 0xff) << 16)
+ + ((buffer.get() & 0xff) << 8)
+ + (buffer.get() & 0xff));
+ }
+
+ public static void putInt (ByteBuffer buffer, int value, ByteOrder order)
+ {
+ buffer.checkForOverflow(4);
+
+ if (order == ByteOrder.LITTLE_ENDIAN)
+ {
+ buffer.put ((byte) value);
+ buffer.put ((byte) (value >> 8));
+ buffer.put ((byte) (value >> 16));
+ buffer.put ((byte) (value >> 24));
+ }
+ else
+ {
+ buffer.put ((byte) (value >> 24));
+ buffer.put ((byte) (value >> 16));
+ buffer.put ((byte) (value >> 8));
+ buffer.put ((byte) value);
+ }
+ }
+
+ public static int getInt (ByteBuffer buffer, int index, ByteOrder order)
+ {
+ if (order == ByteOrder.LITTLE_ENDIAN)
+ {
+ return ((buffer.get (index) & 0xff)
+ + ((buffer.get (++index) & 0xff) << 8)
+ + ((buffer.get (++index) & 0xff) << 16)
+ + (buffer.get (++index) << 24));
+ }
+
+ return ((buffer.get (index) << 24)
+ + ((buffer.get (++index) & 0xff) << 16)
+ + ((buffer.get (++index) & 0xff) << 8)
+ + (buffer.get (++index) & 0xff));
+ }
+
+ public static void putInt (ByteBuffer buffer, int index,
+ int value, ByteOrder order)
+ {
+ if (order == ByteOrder.LITTLE_ENDIAN)
+ {
+ buffer.put (index, (byte) value);
+ buffer.put (++index, (byte) (value >> 8));
+ buffer.put (++index, (byte) (value >> 16));
+ buffer.put (++index, (byte) (value >> 24));
+ }
+ else
+ {
+ buffer.put (index, (byte) (value >> 24));
+ buffer.put (++index, (byte) (value >> 16));
+ buffer.put (++index, (byte) (value >> 8));
+ buffer.put (++index, (byte) value);
+ }
+ }
+
+ public static long getLong (ByteBuffer buffer, ByteOrder order)
+ {
+ buffer.checkForUnderflow(8);
+
+ if (order == ByteOrder.LITTLE_ENDIAN)
+ {
+ return ((buffer.get() & 0xff)
+ + (((buffer.get() & 0xff)) << 8)
+ + (((buffer.get() & 0xff)) << 16)
+ + (((buffer.get() & 0xffL)) << 24)
+ + (((buffer.get() & 0xffL)) << 32)
+ + (((buffer.get() & 0xffL)) << 40)
+ + (((buffer.get() & 0xffL)) << 48)
+ + (((long) buffer.get()) << 56));
+ }
+
+ return ((((long) buffer.get()) << 56)
+ + ((buffer.get() & 0xffL) << 48)
+ + ((buffer.get() & 0xffL) << 40)
+ + ((buffer.get() & 0xffL) << 32)
+ + ((buffer.get() & 0xffL) << 24)
+ + ((buffer.get() & 0xff) << 16)
+ + ((buffer.get() & 0xff) << 8)
+ + (buffer.get() & 0xff));
+ }
+
+ public static void putLong (ByteBuffer buffer, long value, ByteOrder order)
+ {
+ buffer.checkForOverflow(8);
+
+ if (order == ByteOrder.LITTLE_ENDIAN)
+ {
+ buffer.put ((byte) value);
+ buffer.put ((byte) (value >> 8));
+ buffer.put ((byte) (value >> 16));
+ buffer.put ((byte) (value >> 24));
+ buffer.put ((byte) (value >> 32));
+ buffer.put ((byte) (value >> 40));
+ buffer.put ((byte) (value >> 48));
+ buffer.put ((byte) (value >> 56));
+ }
+ else
+ {
+ buffer.put ((byte) (value >> 56));
+ buffer.put ((byte) (value >> 48));
+ buffer.put ((byte) (value >> 40));
+ buffer.put ((byte) (value >> 32));
+ buffer.put ((byte) (value >> 24));
+ buffer.put ((byte) (value >> 16));
+ buffer.put ((byte) (value >> 8));
+ buffer.put ((byte) value);
+ }
+ }
+
+ public static long getLong (ByteBuffer buffer, int index, ByteOrder order)
+ {
+ if (order == ByteOrder.LITTLE_ENDIAN)
+ {
+ return ((buffer.get (index) & 0xff)
+ + ((buffer.get (++index) & 0xff) << 8)
+ + ((buffer.get (++index) & 0xff) << 16)
+ + ((buffer.get (++index) & 0xffL) << 24)
+ + ((buffer.get (++index) & 0xffL) << 32)
+ + ((buffer.get (++index) & 0xffL) << 40)
+ + ((buffer.get (++index) & 0xffL) << 48)
+ + (((long) buffer.get (++index)) << 56));
+ }
+
+ return ((((long) buffer.get (index)) << 56)
+ + ((buffer.get (++index) & 0xffL) << 48)
+ + ((buffer.get (++index) & 0xffL) << 40)
+ + ((buffer.get (++index) & 0xffL) << 32)
+ + ((buffer.get (++index) & 0xffL) << 24)
+ + ((buffer.get (++index) & 0xff) << 16)
+ + ((buffer.get (++index) & 0xff) << 8)
+ + (buffer.get (++index) & 0xff));
+ }
+
+ public static void putLong (ByteBuffer buffer, int index,
+ long value, ByteOrder order)
+ {
+ if (order == ByteOrder.LITTLE_ENDIAN)
+ {
+ buffer.put (index, (byte) value);
+ buffer.put (++index, (byte) (value >> 8));
+ buffer.put (++index, (byte) (value >> 16));
+ buffer.put (++index, (byte) (value >> 24));
+ buffer.put (++index, (byte) (value >> 32));
+ buffer.put (++index, (byte) (value >> 40));
+ buffer.put (++index, (byte) (value >> 48));
+ buffer.put (++index, (byte) (value >> 56));
+ }
+ else
+ {
+ buffer.put (index, (byte) (value >> 56));
+ buffer.put (++index, (byte) (value >> 48));
+ buffer.put (++index, (byte) (value >> 40));
+ buffer.put (++index, (byte) (value >> 32));
+ buffer.put (++index, (byte) (value >> 24));
+ buffer.put (++index, (byte) (value >> 16));
+ buffer.put (++index, (byte) (value >> 8));
+ buffer.put (++index, (byte) value);
+ }
+ }
+
+ public static float getFloat (ByteBuffer buffer, ByteOrder order)
+ {
+ return Float.intBitsToFloat (getInt (buffer, order));
+ }
+
+ public static void putFloat (ByteBuffer buffer, float value, ByteOrder order)
+ {
+ putInt (buffer, Float.floatToRawIntBits (value), order);
+ }
+
+ public static float getFloat (ByteBuffer buffer, int index, ByteOrder order)
+ {
+ return Float.intBitsToFloat (getInt (buffer, index, order));
+ }
+
+ public static void putFloat (ByteBuffer buffer, int index,
+ float value, ByteOrder order)
+ {
+ putInt (buffer, index, Float.floatToRawIntBits (value), order);
+ }
+
+ public static double getDouble (ByteBuffer buffer, ByteOrder order)
+ {
+ return Double.longBitsToDouble (getLong (buffer, order));
+ }
+
+ public static void putDouble (ByteBuffer buffer, double value, ByteOrder order)
+ {
+ putLong (buffer, Double.doubleToRawLongBits (value), order);
+ }
+
+ public static double getDouble (ByteBuffer buffer, int index, ByteOrder order)
+ {
+ return Double.longBitsToDouble (getLong (buffer, index, order));
+ }
+
+ public static void putDouble (ByteBuffer buffer, int index,
+ double value, ByteOrder order)
+ {
+ putLong (buffer, index, Double.doubleToRawLongBits (value), order);
+ }
+} // ByteBufferHelper
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,372 @@
+/* ByteBufferImpl.java --
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * This is a Heap memory implementation
+ */
+final class ByteBufferImpl extends ByteBuffer
+{
+ private boolean readOnly;
+
+ ByteBufferImpl (byte[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
+ {
+ super (capacity, limit, position, mark);
+ this.backing_buffer = buffer;
+ this.array_offset = offset;
+ this.readOnly = readOnly;
+ }
+
+ public CharBuffer asCharBuffer ()
+ {
+ return new CharViewBufferImpl (this, remaining() >> 1);
+ }
+
+ public ShortBuffer asShortBuffer ()
+ {
+ return new ShortViewBufferImpl (this, remaining() >> 1);
+ }
+
+ public IntBuffer asIntBuffer ()
+ {
+ return new IntViewBufferImpl (this, remaining() >> 2);
+ }
+
+ public LongBuffer asLongBuffer ()
+ {
+ return new LongViewBufferImpl (this, remaining() >> 3);
+ }
+
+ public FloatBuffer asFloatBuffer ()
+ {
+ return new FloatViewBufferImpl (this, remaining() >> 2);
+ }
+
+ public DoubleBuffer asDoubleBuffer ()
+ {
+ return new DoubleViewBufferImpl (this, remaining() >> 3);
+ }
+
+ public boolean isReadOnly ()
+ {
+ return readOnly;
+ }
+
+ public ByteBuffer slice ()
+ {
+ return new ByteBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
+ }
+
+ public ByteBuffer duplicate ()
+ {
+ return new ByteBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
+ }
+
+ public ByteBuffer asReadOnlyBuffer ()
+ {
+ return new ByteBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
+ }
+
+ void shiftDown (int dst_offset, int src_offset, int count)
+ {
+ System.arraycopy(backing_buffer, array_offset + src_offset,
+ backing_buffer, array_offset + dst_offset,
+ count);
+ }
+
+ public ByteBuffer compact ()
+ {
+ checkIfReadOnly();
+ mark = -1;
+ int pos = position();
+ int n = limit() - pos;
+ if (n > 0)
+ shiftDown(0, pos, n);
+ position(n);
+ limit(capacity());
+ return this;
+ }
+
+ public boolean isDirect ()
+ {
+ return false;
+ }
+
+ /**
+ * Reads the <code>byte</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>bytes</code> in this buffer.
+ */
+ public byte get ()
+ {
+ if (pos >= limit)
+ throw new BufferUnderflowException();
+
+ return backing_buffer [(pos++) + array_offset];
+ }
+
+ /**
+ * Bulk get
+ */
+ public ByteBuffer get (byte[] dst, int offset, int length)
+ {
+ checkArraySize(dst.length, offset, length);
+ if ( (limit - pos) < length) // check for overflow
+ throw new BufferUnderflowException();
+
+ System.arraycopy(backing_buffer, pos + array_offset,
+ dst, offset, length);
+ pos += length;
+
+ return this;
+ }
+
+ /**
+ * Relative bulk put(), overloads the ByteBuffer impl.
+ */
+ public ByteBuffer put (byte[] src, int offset, int length)
+ {
+ if ( (limit - pos) < length) // check for overflow
+ throw new BufferOverflowException();
+ checkArraySize(src.length, offset, length);
+
+ System.arraycopy(src, offset, backing_buffer, pos + array_offset, length);
+ pos += length;
+
+ return this;
+ }
+
+ /**
+ * Relative put method. Writes <code>value</code> to the next position
+ * in the buffer.
+ *
+ * @exception BufferOverflowException If there is no remaining
+ * space in this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public ByteBuffer put (byte value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException();
+ if (pos >= limit)
+ throw new BufferOverflowException();
+
+ backing_buffer [(pos++) + array_offset] = value;
+ return this;
+ }
+
+ /**
+ * Absolute get method. Reads the <code>byte</code> at position
+ * <code>index</code>.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public byte get (int index)
+ {
+ checkIndex(index);
+
+ return backing_buffer [index + array_offset];
+ }
+
+ /**
+ * Absolute put method. Writes <code>value</code> to position
+ * <code>index</code> in the buffer.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public ByteBuffer put (int index, byte value)
+ {
+ checkIfReadOnly();
+ checkIndex(index);
+
+ backing_buffer [index + array_offset] = value;
+ return this;
+ }
+
+ public char getChar ()
+ {
+ return ByteBufferHelper.getChar(this, order());
+ }
+
+ public ByteBuffer putChar (char value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+ if ( (limit-pos) < 2)
+ throw new BufferOverflowException();
+
+ if (endian == ByteOrder.LITTLE_ENDIAN)
+ {
+ backing_buffer [(pos++) + array_offset] = (byte)(value&0xFF);
+ backing_buffer [(pos++) + array_offset] = (byte)(value>>8);
+ }
+ else
+ {
+ backing_buffer [(pos++) + array_offset] = (byte)(value>>8);
+ backing_buffer [(pos++) + array_offset] = (byte)(value&0xFF);
+ }
+ return this;
+ }
+
+ public char getChar (int index)
+ {
+ return ByteBufferHelper.getChar(this, index, order());
+ }
+
+ public ByteBuffer putChar (int index, char value)
+ {
+ ByteBufferHelper.putChar(this, index, value, order());
+ return this;
+ }
+
+ public short getShort ()
+ {
+ return ByteBufferHelper.getShort(this, order());
+ }
+
+ public ByteBuffer putShort (short value)
+ {
+ ByteBufferHelper.putShort(this, value, order());
+ return this;
+ }
+
+ public short getShort (int index)
+ {
+ return ByteBufferHelper.getShort(this, index, order());
+ }
+
+ public ByteBuffer putShort (int index, short value)
+ {
+ ByteBufferHelper.putShort(this, index, value, order());
+ return this;
+ }
+
+ public int getInt ()
+ {
+ return ByteBufferHelper.getInt(this, order());
+ }
+
+ public ByteBuffer putInt (int value)
+ {
+ ByteBufferHelper.putInt(this, value, order());
+ return this;
+ }
+
+ public int getInt (int index)
+ {
+ return ByteBufferHelper.getInt(this, index, order());
+ }
+
+ public ByteBuffer putInt (int index, int value)
+ {
+ ByteBufferHelper.putInt(this, index, value, order());
+ return this;
+ }
+
+ public long getLong ()
+ {
+ return ByteBufferHelper.getLong(this, order());
+ }
+
+ public ByteBuffer putLong (long value)
+ {
+ ByteBufferHelper.putLong (this, value, order());
+ return this;
+ }
+
+ public long getLong (int index)
+ {
+ return ByteBufferHelper.getLong (this, index, order());
+ }
+
+ public ByteBuffer putLong (int index, long value)
+ {
+ ByteBufferHelper.putLong (this, index, value, order());
+ return this;
+ }
+
+ public float getFloat ()
+ {
+ return ByteBufferHelper.getFloat (this, order());
+ }
+
+ public ByteBuffer putFloat (float value)
+ {
+ ByteBufferHelper.putFloat (this, value, order());
+ return this;
+ }
+
+ public float getFloat (int index)
+ {
+ return ByteBufferHelper.getFloat (this, index, order());
+ }
+
+ public ByteBuffer putFloat (int index, float value)
+ {
+ ByteBufferHelper.putFloat (this, index, value, order());
+ return this;
+ }
+
+ public double getDouble ()
+ {
+ return ByteBufferHelper.getDouble (this, order());
+ }
+
+ public ByteBuffer putDouble (double value)
+ {
+ ByteBufferHelper.putDouble (this, value, order());
+ return this;
+ }
+
+ public double getDouble (int index)
+ {
+ return ByteBufferHelper.getDouble (this, index, order());
+ }
+
+ public ByteBuffer putDouble (int index, double value)
+ {
+ ByteBufferHelper.putDouble (this, index, value, order());
+ return this;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteOrder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteOrder.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteOrder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ByteOrder.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,82 @@
+/* ByteOrder.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ * @since 1.4
+ */
+public final class ByteOrder
+{
+ /**
+ * Constant indicating big endian byte order.
+ */
+ public static final ByteOrder BIG_ENDIAN = new ByteOrder();
+
+ /**
+ * Constant indicating little endian byte order.
+ */
+ public static final ByteOrder LITTLE_ENDIAN = new ByteOrder();
+
+ /**
+ * Returns the native byte order of the platform currently running.
+ *
+ * @return the native byte order
+ */
+ public static ByteOrder nativeOrder()
+ {
+ return (System.getProperty ("gnu.cpu.endian").equals("big")
+ ? BIG_ENDIAN : LITTLE_ENDIAN);
+ }
+
+ /**
+ * Returns a string representation of the byte order.
+ *
+ * @return the string
+ */
+ public String toString()
+ {
+ return this == BIG_ENDIAN ? "BIG_ENDIAN" : "LITTLE_ENDIAN";
+ }
+
+ // This class can only be instantiated here.
+ private ByteOrder()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/CharBuffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/CharBuffer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/CharBuffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/CharBuffer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,506 @@
+/* CharBuffer.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * @since 1.4
+ */
+public abstract class CharBuffer extends Buffer
+ implements Comparable, CharSequence
+{
+ int array_offset;
+ char[] backing_buffer;
+
+ CharBuffer (int capacity, int limit, int position, int mark)
+ {
+ super (capacity, limit, position, mark);
+ array_offset = 0;
+ }
+
+ /**
+ * Allocates a new <code>CharBuffer</code> object with a given capacity.
+ */
+ public static CharBuffer allocate (int capacity)
+ {
+ return new CharBufferImpl (capacity);
+ }
+
+ /**
+ * Wraps a <code>char</code> array into a <code>CharBuffer</code>
+ * object.
+ *
+ * @param array the array to wrap
+ * @param offset the offset of the region in the array to wrap
+ * @param length the length of the region in the array to wrap
+ *
+ * @return a new <code>CharBuffer</code> object
+ *
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ */
+ public static final CharBuffer wrap(char[] array, int offset, int length)
+ {
+ return new CharBufferImpl(array, 0, array.length, offset + length, offset, -1, false);
+ }
+
+ /**
+ * Wraps a character sequence into a <code>CharBuffer</code> object.
+ *
+ * @param seq the sequence to wrap
+ *
+ * @return a new <code>CharBuffer</code> object
+ */
+ public static final CharBuffer wrap(CharSequence seq)
+ {
+ return wrap(seq, 0, seq.length());
+ }
+
+ /**
+ * Wraps a character sequence into a <code>CharBuffer</code> object.
+ *
+ * @param seq the sequence to wrap
+ * @param start the index of the first character to wrap
+ * @param end the index of the first character not to wrap
+ *
+ * @return a new <code>CharBuffer</code> object
+ *
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ */
+ public static final CharBuffer wrap(CharSequence seq, int start, int end)
+ {
+ // FIXME: implement better handling of java.lang.String.
+ // Probably share data with String via reflection.
+
+ int len = end - start;
+
+ if( len < 0 )
+ throw new IndexOutOfBoundsException();
+
+ char[] buffer = new char[len];
+
+ for (int i = 0; i < len; i++)
+ buffer[i] = seq.charAt(i + start);
+
+ return wrap(buffer, 0, len).asReadOnlyBuffer();
+ }
+
+ /**
+ * Wraps a <code>char</code> array into a <code>CharBuffer</code>
+ * object.
+ *
+ * @param array the array to wrap
+ *
+ * @return a new <code>CharBuffer</code> object
+ */
+ public static final CharBuffer wrap(char[] array)
+ {
+ return wrap(array, 0, array.length);
+ }
+
+ /**
+ * This method transfers <code>char</code>s from this buffer into the given
+ * destination array. Before the transfer, it checks if there are fewer than
+ * length <code>char</code>s remaining in this buffer.
+ *
+ * @param dst The destination array
+ * @param offset The offset within the array of the first <code>char</code>
+ * to be written; must be non-negative and no larger than dst.length.
+ * @param length The maximum number of bytes to be written to the given array;
+ * must be non-negative and no larger than dst.length - offset.
+ *
+ * @exception BufferUnderflowException If there are fewer than length
+ * <code>char</code>s remaining in this buffer.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold.
+ */
+ public CharBuffer get (char[] dst, int offset, int length)
+ {
+ checkArraySize(dst.length, offset, length);
+ checkForUnderflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ {
+ dst [i] = get ();
+ }
+
+ return this;
+ }
+
+ /**
+ * This method transfers <code>char</code>s from this buffer into the given
+ * destination array.
+ *
+ * @param dst The byte array to write into.
+ *
+ * @exception BufferUnderflowException If there are fewer than dst.length
+ * <code>char</code>s remaining in this buffer.
+ */
+ public CharBuffer get (char[] dst)
+ {
+ return get (dst, 0, dst.length);
+ }
+
+ /**
+ * Writes the content of the the <code>CharBUFFER</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * <code>src.remaining()</code> space remaining in this buffer.
+ *
+ * @param src The source data.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>char</code>s in the source buffer.
+ * @exception IllegalArgumentException If the source buffer is this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public CharBuffer put (CharBuffer src)
+ {
+ if (src == this)
+ throw new IllegalArgumentException ();
+
+ checkForOverflow(src.remaining());
+
+ if (src.remaining () > 0)
+ {
+ char[] toPut = new char [src.remaining ()];
+ src.get (toPut);
+ put (toPut);
+ }
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>char array</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * length space remaining in this buffer.
+ *
+ * @param src The array to copy into the buffer.
+ * @param offset The offset within the array of the first byte to be read;
+ * must be non-negative and no larger than src.length.
+ * @param length The number of bytes to be read from the given array;
+ * must be non-negative and no larger than src.length - offset.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>char</code>s in the source array.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public CharBuffer put (char[] src, int offset, int length)
+ {
+ checkArraySize(src.length, offset, length);
+ checkForOverflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ put (src [i]);
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>char array</code> src
+ * into the buffer.
+ *
+ * @param src The array to copy into the buffer.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>char</code>s in the source array.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public final CharBuffer put (char[] src)
+ {
+ return put (src, 0, src.length);
+ }
+
+ /**
+ * Tells whether ot not this buffer is backed by an accessible
+ * <code>char</code> array.
+ */
+ public final boolean hasArray ()
+ {
+ return (backing_buffer != null
+ && !isReadOnly ());
+ }
+
+ /**
+ * Returns the <code>char</code> array that backs this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final char[] array ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return backing_buffer;
+ }
+
+ /**
+ * Returns the offset within this buffer's backing array of the first element.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final int arrayOffset ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return array_offset;
+ }
+
+ /**
+ * Calculates a hash code for this buffer.
+ *
+ * This is done with int arithmetic,
+ * where ** represents exponentiation, by this formula:<br>
+ * <code>s[position()] + 31 + (s[position()+1] + 30)*31**1 + ... +
+ * (s[limit()-1]+30)*31**(limit()-1)</code>.
+ * Where s is the buffer data. Note that the hashcode is dependent
+ * on buffer content, and therefore is not useful if the buffer
+ * content may change.
+ */
+ public int hashCode ()
+ {
+ int hashCode = get(position()) + 31;
+ int multiplier = 1;
+ for (int i = position() + 1; i < limit(); ++i)
+ {
+ multiplier *= 31;
+ hashCode += (get(i) + 30)*multiplier;
+ }
+ return hashCode;
+ }
+
+ /**
+ * Checks if this buffer is equal to obj.
+ */
+ public boolean equals (Object obj)
+ {
+ if (obj instanceof CharBuffer)
+ {
+ return compareTo (obj) == 0;
+ }
+
+ return false;
+ }
+
+ /**
+ * Compares two <code>CharBuffer</code> objects.
+ *
+ * @exception ClassCastException If obj is not an object derived from
+ * <code>CharBuffer</code>.
+ */
+ public int compareTo (Object obj)
+ {
+ CharBuffer other = (CharBuffer) obj;
+
+ int num = Math.min(remaining(), other.remaining());
+ int pos_this = position();
+ int pos_other = other.position();
+
+ for (int count = 0; count < num; count++)
+ {
+ char a = get(pos_this++);
+ char b = other.get(pos_other++);
+
+ if (a == b)
+ continue;
+
+ if (a < b)
+ return -1;
+
+ return 1;
+ }
+
+ return remaining() - other.remaining();
+ }
+
+ /**
+ * Returns the byte order of this buffer.
+ */
+ public abstract ByteOrder order ();
+
+ /**
+ * Reads the <code>char</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>char</code>s in this buffer.
+ */
+ public abstract char get ();
+
+ /**
+ * Writes the <code>char</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferOverflowException If there no remaining
+ * <code>char</code>s in this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract CharBuffer put (char b);
+
+ /**
+ * Absolute get method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public abstract char get (int index);
+
+ /**
+ * Absolute put method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract CharBuffer put (int index, char b);
+
+ /**
+ * Compacts this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract CharBuffer compact ();
+
+ /**
+ * Tells wether or not this buffer is direct.
+ */
+ public abstract boolean isDirect ();
+
+ /**
+ * Creates a new <code>CharBuffer</code> whose content is a shared
+ * subsequence of this buffer's content.
+ */
+ public abstract CharBuffer slice ();
+
+ /**
+ * Creates a new <code>CharBuffer</code> that shares this buffer's
+ * content.
+ */
+ public abstract CharBuffer duplicate ();
+
+ /**
+ * Creates a new read-only <code>CharBuffer</code> that shares this
+ * buffer's content.
+ */
+ public abstract CharBuffer asReadOnlyBuffer ();
+
+ /**
+ * Returns the remaining content of the buffer as a string.
+ */
+ public String toString ()
+ {
+ if (hasArray ())
+ return new String (array (), position (), length ());
+
+ char[] buf = new char [length ()];
+ int pos = position ();
+ get (buf, 0, buf.length);
+ position (pos);
+ return new String (buf);
+ }
+
+ /**
+ * Returns the length of the remaining chars in this buffer.
+ */
+ public final int length ()
+ {
+ return remaining ();
+ }
+
+ /**
+ * Creates a new character buffer that represents the specified subsequence
+ * of this buffer, relative to the current position.
+ *
+ * @exception IndexOutOfBoundsException If the preconditions on start and
+ * end do not hold.
+ */
+ public abstract CharSequence subSequence (int start, int length);
+
+ /**
+ * Relative put method.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer.
+ * @exception IndexOutOfBoundsException If the preconditions on the start
+ * and end parameters do not hold.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public CharBuffer put (String str, int start, int length)
+ {
+ return put (str.toCharArray (), start, length);
+ }
+
+ /**
+ * Relative put method.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public final CharBuffer put (String str)
+ {
+ return put (str.toCharArray (), 0, str.length ());
+ }
+
+ /**
+ * Returns the character at <code>position() + index</code>.
+ *
+ * @exception IndexOutOfBoundsException If index is negative not smaller than
+ * <code>remaining()</code>.
+ */
+ public final char charAt (int index)
+ {
+ if (index < 0
+ || index >= remaining ())
+ throw new IndexOutOfBoundsException ();
+
+ return get (position () + index);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/CharBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/CharBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/CharBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/CharBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,218 @@
+/* CharBufferImpl.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * This is a Heap memory implementation
+ */
+final class CharBufferImpl extends CharBuffer
+{
+ private boolean readOnly;
+
+ CharBufferImpl (int capacity)
+ {
+ this (new char [capacity], 0, capacity, capacity, 0, -1, false);
+ }
+
+ CharBufferImpl (char[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
+ {
+ super (capacity, limit, position, mark);
+ this.backing_buffer = buffer;
+ this.array_offset = offset;
+ this.readOnly = readOnly;
+ }
+
+ public CharBufferImpl (CharBufferImpl copy)
+ {
+ super (copy.capacity (), copy.limit (), copy.position (), 0);
+ backing_buffer = copy.backing_buffer;
+ array_offset = copy.array_offset;
+ readOnly = copy.isReadOnly ();
+ }
+
+ public boolean isReadOnly ()
+ {
+ return readOnly;
+ }
+
+ public CharBuffer slice ()
+ {
+ return new CharBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
+ }
+
+ public CharBuffer duplicate ()
+ {
+ return new CharBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
+ }
+
+ public CharBuffer asReadOnlyBuffer ()
+ {
+ return new CharBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
+ }
+
+ public CharBuffer compact ()
+ {
+ checkIfReadOnly();
+ mark = -1;
+ int p = position();
+ int n = limit() - p;
+ if (n > 0)
+ {
+ System.arraycopy(backing_buffer, array_offset + p,
+ backing_buffer, array_offset, n);
+ }
+ position(n);
+ limit(capacity());
+ return this;
+ }
+
+ public boolean isDirect ()
+ {
+ return false;
+ }
+
+ public CharSequence subSequence (int start, int end)
+ {
+ if (start < 0
+ || start > length ()
+ || end < start
+ || end > length ())
+ throw new IndexOutOfBoundsException ();
+
+ return new CharBufferImpl (backing_buffer, array_offset, capacity (), position () + end, position () + start, -1, isReadOnly ());
+ }
+
+ /**
+ * Reads the <code>char</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>char</code>s in this buffer.
+ */
+ public char get ()
+ {
+ if (pos >= limit)
+ throw new BufferUnderflowException();
+
+ return backing_buffer [(pos++) + array_offset];
+ }
+
+ /**
+ * Relative put method. Writes <code>value</code> to the next position
+ * in the buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public CharBuffer put (char value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException();
+ if (pos >= limit)
+ throw new BufferOverflowException();
+
+ backing_buffer [(pos++) + array_offset] = value;
+ return this;
+ }
+
+ /**
+ * Absolute get method. Reads the <code>char</code> at position
+ * <code>index</code>.
+ *
+ * @param index Position to read the <code>char</code> from.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public char get (int index)
+ {
+ checkIndex(index);
+
+ return backing_buffer [index + array_offset];
+ }
+
+ /**
+ * Bulk get, overloaded for speed.
+ */
+ public CharBuffer get (char[] dst, int offset, int length)
+ {
+ checkArraySize(dst.length, offset, length);
+ checkForUnderflow(length);
+
+ System.arraycopy(backing_buffer, pos + array_offset,
+ dst, offset, length);
+ pos += length;
+ return this;
+ }
+
+ /**
+ * Bulk put, overloaded for speed.
+ */
+ public CharBuffer put (char[] src, int offset, int length)
+ {
+ checkArraySize(src.length, offset, length);
+ checkForOverflow(length);
+
+ System.arraycopy(src, offset,
+ backing_buffer, pos + array_offset, length);
+ pos += length;
+ return this;
+ }
+
+ /**
+ * Absolute put method. Writes <code>value</code> to position
+ * <code>index</code> in the buffer.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public CharBuffer put (int index, char value)
+ {
+ checkIndex(index);
+ checkIfReadOnly();
+
+ backing_buffer [index + array_offset] = value;
+ return this;
+ }
+
+ public ByteOrder order ()
+ {
+ return ByteOrder.nativeOrder ();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/CharViewBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/CharViewBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/CharViewBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/CharViewBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,187 @@
+/* CharViewBufferImpl.java --
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+class CharViewBufferImpl extends CharBuffer
+{
+ /** Position in bb (i.e. a byte offset) where this buffer starts. */
+ private int offset;
+ private ByteBuffer bb;
+ private boolean readOnly;
+ private ByteOrder endian;
+
+ CharViewBufferImpl (ByteBuffer bb, int capacity)
+ {
+ super (capacity, capacity, 0, -1);
+ this.bb = bb;
+ this.offset = bb.position();
+ this.readOnly = bb.isReadOnly();
+ this.endian = bb.order();
+ if (bb.isDirect())
+ this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
+ }
+
+ public CharViewBufferImpl (ByteBuffer bb, int offset, int capacity,
+ int limit, int position, int mark,
+ boolean readOnly, ByteOrder endian)
+ {
+ super (capacity, limit, position, mark);
+ this.bb = bb;
+ this.offset = offset;
+ this.readOnly = readOnly;
+ this.endian = endian;
+ if (bb.isDirect())
+ this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
+ }
+
+ /**
+ * Reads the <code>char</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>char</code>s in this buffer.
+ */
+ public char get ()
+ {
+ int p = position();
+ char result = ByteBufferHelper.getChar(bb, (p << 1) + offset, endian);
+ position(p + 1);
+ return result;
+ }
+
+ /**
+ * Absolute get method. Reads the <code>char</code> at position
+ * <code>index</code>.
+ *
+ * @param index Position to read the <code>char</code> from.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public char get (int index)
+ {
+ return ByteBufferHelper.getChar(bb, (index << 1) + offset, endian);
+ }
+
+ public CharBuffer put (char value)
+ {
+ int p = position();
+ ByteBufferHelper.putChar(bb, (p << 1) + offset, value, endian);
+ position(p + 1);
+ return this;
+ }
+
+ public CharBuffer put (int index, char value)
+ {
+ ByteBufferHelper.putChar(bb, (index << 1) + offset, value, endian);
+ return this;
+ }
+
+ public CharBuffer compact ()
+ {
+ if (position () > 0)
+ {
+ int count = limit () - position ();
+ bb.shiftDown(offset, offset + 2 * position(), 2 * count);
+ position (count);
+ limit (capacity ());
+ }
+ else
+ {
+ position(limit());
+ limit(capacity());
+ }
+ return this;
+ }
+
+ public CharBuffer slice ()
+ {
+ // Create a sliced copy of this object that shares its content.
+ return new CharViewBufferImpl (bb, (position () >> 1) + offset,
+ remaining (), remaining (), 0, -1,
+ isReadOnly (), endian);
+ }
+
+ CharBuffer duplicate (boolean readOnly)
+ {
+ int pos = position();
+ reset();
+ int mark = position();
+ position(pos);
+ return new CharViewBufferImpl (bb, offset, capacity(), limit(),
+ pos, mark, readOnly, endian);
+ }
+
+ public CharBuffer duplicate ()
+ {
+ return duplicate(readOnly);
+ }
+
+ public CharBuffer asReadOnlyBuffer ()
+ {
+ return duplicate(true);
+ }
+
+ public CharSequence subSequence (int start, int end)
+ {
+ if (start < 0
+ || end < start
+ || end > length ())
+ throw new IndexOutOfBoundsException ();
+
+ return new CharViewBufferImpl (bb, array_offset, capacity (),
+ position () + end, position () + start,
+ -1, isReadOnly (), endian);
+ }
+
+ public boolean isReadOnly ()
+ {
+ return readOnly;
+ }
+
+ public boolean isDirect ()
+ {
+ return bb.isDirect ();
+ }
+
+ public ByteOrder order ()
+ {
+ return endian;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DirectByteBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DirectByteBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DirectByteBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DirectByteBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,432 @@
+/* DirectByteBufferImpl.java --
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+import gnu.classpath.Pointer;
+
+abstract class DirectByteBufferImpl extends ByteBuffer
+{
+ /**
+ * The owner is used to keep alive the object that actually owns the
+ * memory. There are three possibilities:
+ * 1) owner == this: We allocated the memory and we should free it,
+ * but *only* in finalize (if we've been sliced
+ * other objects will also have access to the
+ * memory).
+ * 2) owner == null: The byte buffer was created thru
+ * JNI.NewDirectByteBuffer. The JNI code is
+ * responsible for freeing the memory.
+ * 3) owner == some other object: The other object allocated the
+ * memory and should free it.
+ */
+ private final Object owner;
+
+ static final class ReadOnly extends DirectByteBufferImpl
+ {
+ ReadOnly(Object owner, Pointer address,
+ int capacity, int limit,
+ int position)
+ {
+ super(owner, address, capacity, limit, position);
+ }
+
+ public ByteBuffer put(byte value)
+ {
+ throw new ReadOnlyBufferException ();
+ }
+
+ public ByteBuffer put(int index, byte value)
+ {
+ throw new ReadOnlyBufferException ();
+ }
+
+ public boolean isReadOnly()
+ {
+ return true;
+ }
+ }
+
+ static final class ReadWrite extends DirectByteBufferImpl
+ {
+ ReadWrite(int capacity)
+ {
+ super(capacity);
+ }
+
+ ReadWrite(Object owner, Pointer address,
+ int capacity, int limit,
+ int position)
+ {
+ super(owner, address, capacity, limit, position);
+ }
+
+ public boolean isReadOnly()
+ {
+ return false;
+ }
+ }
+
+ DirectByteBufferImpl(int capacity)
+ {
+ super(capacity, capacity, 0, -1);
+ this.owner = this;
+ this.address = VMDirectByteBuffer.allocate(capacity);
+ }
+
+ DirectByteBufferImpl(Object owner, Pointer address,
+ int capacity, int limit,
+ int position)
+ {
+ super(capacity, limit, position, -1);
+ this.owner = owner;
+ this.address = address;
+ }
+
+ /**
+ * Allocates a new direct byte buffer.
+ */
+ public static ByteBuffer allocate(int capacity)
+ {
+ return new DirectByteBufferImpl.ReadWrite(capacity);
+ }
+
+ protected void finalize() throws Throwable
+ {
+ if (owner == this)
+ VMDirectByteBuffer.free(address);
+ }
+
+ public byte get()
+ {
+ checkForUnderflow();
+
+ int pos = position();
+ byte result = VMDirectByteBuffer.get(address, pos);
+ position(pos + 1);
+ return result;
+ }
+
+ public byte get(int index)
+ {
+ checkIndex(index);
+
+ return VMDirectByteBuffer.get(address, index);
+ }
+
+ public ByteBuffer get(byte[] dst, int offset, int length)
+ {
+ checkArraySize(dst.length, offset, length);
+ checkForUnderflow(length);
+
+ int index = position();
+ VMDirectByteBuffer.get(address, index, dst, offset, length);
+ position(index+length);
+
+ return this;
+ }
+
+ public ByteBuffer put(byte value)
+ {
+ checkForOverflow();
+
+ int pos = position();
+ VMDirectByteBuffer.put(address, pos, value);
+ position(pos + 1);
+ return this;
+ }
+
+ public ByteBuffer put(int index, byte value)
+ {
+ checkIndex(index);
+
+ VMDirectByteBuffer.put(address, index, value);
+ return this;
+ }
+
+ public ByteBuffer put (byte[] src, int offset, int length)
+ {
+ checkArraySize (src.length, offset, length);
+ checkForUnderflow (length);
+
+ int index = position ();
+ VMDirectByteBuffer.put (address, index, src, offset, length);
+ position (index + length);
+
+ return this;
+ }
+
+ void shiftDown(int dst_offset, int src_offset, int count)
+ {
+ VMDirectByteBuffer.shiftDown(address, dst_offset, src_offset, count);
+ }
+
+ public ByteBuffer compact()
+ {
+ checkIfReadOnly();
+ mark = -1;
+ int pos = position();
+ if (pos > 0)
+ {
+ int count = remaining();
+ VMDirectByteBuffer.shiftDown(address, 0, pos, count);
+ position(count);
+ limit(capacity());
+ }
+ else
+ {
+ position(limit());
+ limit(capacity());
+ }
+ return this;
+ }
+
+ public ByteBuffer slice()
+ {
+ int rem = remaining();
+ if (isReadOnly())
+ return new DirectByteBufferImpl.ReadOnly
+ (owner, VMDirectByteBuffer.adjustAddress(address, position()),
+ rem, rem, 0);
+ else
+ return new DirectByteBufferImpl.ReadWrite
+ (owner, VMDirectByteBuffer.adjustAddress(address, position()),
+ rem, rem, 0);
+ }
+
+ private ByteBuffer duplicate(boolean readOnly)
+ {
+ int pos = position();
+ if (this.mark != -1)
+ reset();
+ int mark = position();
+ position(pos);
+ DirectByteBufferImpl result;
+ if (readOnly)
+ result = new DirectByteBufferImpl.ReadOnly(owner, address, capacity(),
+ limit(), pos);
+ else
+ result = new DirectByteBufferImpl.ReadWrite(owner, address, capacity(),
+ limit(), pos);
+
+ if (mark != pos)
+ {
+ result.position(mark);
+ result.mark();
+ result.position(pos);
+ }
+ return result;
+ }
+
+ public ByteBuffer duplicate()
+ {
+ return duplicate(isReadOnly());
+ }
+
+ public ByteBuffer asReadOnlyBuffer()
+ {
+ return duplicate(true);
+ }
+
+ public boolean isDirect()
+ {
+ return true;
+ }
+
+ public CharBuffer asCharBuffer()
+ {
+ return new CharViewBufferImpl(this, remaining() >> 1);
+ }
+
+ public ShortBuffer asShortBuffer()
+ {
+ return new ShortViewBufferImpl(this, remaining() >> 1);
+ }
+
+ public IntBuffer asIntBuffer()
+ {
+ return new IntViewBufferImpl(this, remaining() >> 2);
+ }
+
+ public LongBuffer asLongBuffer()
+ {
+ return new LongViewBufferImpl(this, remaining() >> 3);
+ }
+
+ public FloatBuffer asFloatBuffer()
+ {
+ return new FloatViewBufferImpl(this, remaining() >> 2);
+ }
+
+ public DoubleBuffer asDoubleBuffer()
+ {
+ return new DoubleViewBufferImpl(this, remaining() >> 3);
+ }
+
+ public char getChar()
+ {
+ return ByteBufferHelper.getChar(this, order());
+ }
+
+ public ByteBuffer putChar(char value)
+ {
+ ByteBufferHelper.putChar(this, value, order());
+ return this;
+ }
+
+ public char getChar(int index)
+ {
+ return ByteBufferHelper.getChar(this, index, order());
+ }
+
+ public ByteBuffer putChar(int index, char value)
+ {
+ ByteBufferHelper.putChar(this, index, value, order());
+ return this;
+ }
+
+ public short getShort()
+ {
+ return ByteBufferHelper.getShort(this, order());
+ }
+
+ public ByteBuffer putShort(short value)
+ {
+ ByteBufferHelper.putShort(this, value, order());
+ return this;
+ }
+
+ public short getShort(int index)
+ {
+ return ByteBufferHelper.getShort(this, index, order());
+ }
+
+ public ByteBuffer putShort(int index, short value)
+ {
+ ByteBufferHelper.putShort(this, index, value, order());
+ return this;
+ }
+
+ public int getInt()
+ {
+ return ByteBufferHelper.getInt(this, order());
+ }
+
+ public ByteBuffer putInt(int value)
+ {
+ ByteBufferHelper.putInt(this, value, order());
+ return this;
+ }
+
+ public int getInt(int index)
+ {
+ return ByteBufferHelper.getInt(this, index, order());
+ }
+
+ public ByteBuffer putInt(int index, int value)
+ {
+ ByteBufferHelper.putInt(this, index, value, order());
+ return this;
+ }
+
+ public long getLong()
+ {
+ return ByteBufferHelper.getLong(this, order());
+ }
+
+ public ByteBuffer putLong(long value)
+ {
+ ByteBufferHelper.putLong(this, value, order());
+ return this;
+ }
+
+ public long getLong(int index)
+ {
+ return ByteBufferHelper.getLong(this, index, order());
+ }
+
+ public ByteBuffer putLong(int index, long value)
+ {
+ ByteBufferHelper.putLong(this, index, value, order());
+ return this;
+ }
+
+ public float getFloat()
+ {
+ return ByteBufferHelper.getFloat(this, order());
+ }
+
+ public ByteBuffer putFloat(float value)
+ {
+ ByteBufferHelper.putFloat(this, value, order());
+ return this;
+ }
+
+ public float getFloat(int index)
+ {
+ return ByteBufferHelper.getFloat(this, index, order());
+ }
+
+ public ByteBuffer putFloat(int index, float value)
+ {
+ ByteBufferHelper.putFloat(this, index, value, order());
+ return this;
+ }
+
+ public double getDouble()
+ {
+ return ByteBufferHelper.getDouble(this, order());
+ }
+
+ public ByteBuffer putDouble(double value)
+ {
+ ByteBufferHelper.putDouble(this, value, order());
+ return this;
+ }
+
+ public double getDouble(int index)
+ {
+ return ByteBufferHelper.getDouble(this, index, order());
+ }
+
+ public ByteBuffer putDouble(int index, double value)
+ {
+ ByteBufferHelper.putDouble(this, index, value, order());
+ return this;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DoubleBuffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DoubleBuffer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DoubleBuffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DoubleBuffer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,383 @@
+/* DoubleBuffer.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * @since 1.4
+ */
+public abstract class DoubleBuffer extends Buffer
+ implements Comparable
+{
+ int array_offset;
+ double[] backing_buffer;
+
+ DoubleBuffer (int capacity, int limit, int position, int mark)
+ {
+ super (capacity, limit, position, mark);
+ array_offset = 0;
+ }
+
+ /**
+ * Allocates a new <code>DoubleBuffer</code> object with a given capacity.
+ */
+ public static DoubleBuffer allocate (int capacity)
+ {
+ return new DoubleBufferImpl (capacity);
+ }
+
+ /**
+ * Wraps a <code>double</code> array into a <code>DoubleBuffer</code>
+ * object.
+ *
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ */
+ public static final DoubleBuffer wrap (double[] array, int offset, int length)
+ {
+ return new DoubleBufferImpl (array, 0, array.length, offset + length, offset, -1, false);
+ }
+
+ /**
+ * Wraps a <code>double</code> array into a <code>DoubleBuffer</code>
+ * object.
+ */
+ public static final DoubleBuffer wrap (double[] array)
+ {
+ return wrap (array, 0, array.length);
+ }
+
+ /**
+ * This method transfers <code>double</code>s from this buffer into the given
+ * destination array. Before the transfer, it checks if there are fewer than
+ * length <code>double</code>s remaining in this buffer.
+ *
+ * @param dst The destination array
+ * @param offset The offset within the array of the first <code>double</code>
+ * to be written; must be non-negative and no larger than dst.length.
+ * @param length The maximum number of bytes to be written to the given array;
+ * must be non-negative and no larger than dst.length - offset.
+ *
+ * @exception BufferUnderflowException If there are fewer than length
+ * <code>double</code>s remaining in this buffer.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold.
+ */
+ public DoubleBuffer get (double[] dst, int offset, int length)
+ {
+ checkArraySize(dst.length, offset, length);
+ checkForUnderflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ {
+ dst [i] = get ();
+ }
+
+ return this;
+ }
+
+ /**
+ * This method transfers <code>double</code>s from this buffer into the given
+ * destination array.
+ *
+ * @param dst The byte array to write into.
+ *
+ * @exception BufferUnderflowException If there are fewer than dst.length
+ * <code>double</code>s remaining in this buffer.
+ */
+ public DoubleBuffer get (double[] dst)
+ {
+ return get (dst, 0, dst.length);
+ }
+
+ /**
+ * Writes the content of the the <code>DoubleBUFFER</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * <code>src.remaining()</code> space remaining in this buffer.
+ *
+ * @param src The source data.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>double</code>s in the source buffer.
+ * @exception IllegalArgumentException If the source buffer is this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public DoubleBuffer put (DoubleBuffer src)
+ {
+ if (src == this)
+ throw new IllegalArgumentException ();
+
+ checkForOverflow(src.remaining ());
+
+ if (src.remaining () > 0)
+ {
+ double[] toPut = new double [src.remaining ()];
+ src.get (toPut);
+ put (toPut);
+ }
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>double array</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * length space remaining in this buffer.
+ *
+ * @param src The array to copy into the buffer.
+ * @param offset The offset within the array of the first byte to be read;
+ * must be non-negative and no larger than src.length.
+ * @param length The number of bytes to be read from the given array;
+ * must be non-negative and no larger than src.length - offset.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>double</code>s in the source array.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public DoubleBuffer put (double[] src, int offset, int length)
+ {
+ checkArraySize(src.length, offset, length);
+ checkForOverflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ put (src [i]);
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>double array</code> src
+ * into the buffer.
+ *
+ * @param src The array to copy into the buffer.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>double</code>s in the source array.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public final DoubleBuffer put (double[] src)
+ {
+ return put (src, 0, src.length);
+ }
+
+ /**
+ * Tells whether ot not this buffer is backed by an accessible
+ * <code>double</code> array.
+ */
+ public final boolean hasArray ()
+ {
+ return (backing_buffer != null
+ && !isReadOnly ());
+ }
+
+ /**
+ * Returns the <code>double</code> array that backs this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final double[] array ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return backing_buffer;
+ }
+
+ /**
+ * Returns the offset within this buffer's backing array of the first element.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final int arrayOffset ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return array_offset;
+ }
+
+ /**
+ * Calculates a hash code for this buffer.
+ *
+ * This is done with <code>long</code> arithmetic,
+ * where ** represents exponentiation, by this formula:<br>
+ * <code>s[position()] + 31 + (s[position()+1] + 30)*31**1 + ... +
+ * (s[limit()-1]+30)*31**(limit()-1)</code>.
+ * Where s is the buffer data, in Double.doubleToLongBits() form
+ * Note that the hashcode is dependent on buffer content,
+ * and therefore is not useful if the buffer content may change.
+ *
+ * @return the hash code (casted to int)
+ */
+ public int hashCode ()
+ {
+ long hashCode = Double.doubleToLongBits(get(position())) + 31;
+ long multiplier = 1;
+ for (int i = position() + 1; i < limit(); ++i)
+ {
+ multiplier *= 31;
+ hashCode += (Double.doubleToLongBits(get(i)) + 30)*multiplier;
+ }
+ return ((int)hashCode);
+ }
+
+ /**
+ * Checks if this buffer is equal to obj.
+ */
+ public boolean equals (Object obj)
+ {
+ if (obj instanceof DoubleBuffer)
+ {
+ return compareTo (obj) == 0;
+ }
+
+ return false;
+ }
+
+ /**
+ * Compares two <code>DoubleBuffer</code> objects.
+ *
+ * @exception ClassCastException If obj is not an object derived from
+ * <code>DoubleBuffer</code>.
+ */
+ public int compareTo (Object obj)
+ {
+ DoubleBuffer other = (DoubleBuffer) obj;
+
+ int num = Math.min(remaining(), other.remaining());
+ int pos_this = position();
+ int pos_other = other.position();
+
+ for (int count = 0; count < num; count++)
+ {
+ double a = get(pos_this++);
+ double b = other.get(pos_other++);
+
+ if (a == b)
+ continue;
+
+ if (a < b)
+ return -1;
+
+ return 1;
+ }
+
+ return remaining() - other.remaining();
+ }
+
+ /**
+ * Returns the byte order of this buffer.
+ */
+ public abstract ByteOrder order ();
+
+ /**
+ * Reads the <code>double</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>double</code>s in this buffer.
+ */
+ public abstract double get ();
+
+ /**
+ * Writes the <code>double</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferOverflowException If there no remaining
+ * <code>double</code>s in this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract DoubleBuffer put (double b);
+
+ /**
+ * Absolute get method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public abstract double get (int index);
+
+ /**
+ * Absolute put method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract DoubleBuffer put (int index, double b);
+
+ /**
+ * Compacts this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract DoubleBuffer compact ();
+
+ /**
+ * Tells wether or not this buffer is direct.
+ */
+ public abstract boolean isDirect ();
+
+ /**
+ * Creates a new <code>DoubleBuffer</code> whose content is a shared
+ * subsequence of this buffer's content.
+ */
+ public abstract DoubleBuffer slice ();
+
+ /**
+ * Creates a new <code>DoubleBuffer</code> that shares this buffer's
+ * content.
+ */
+ public abstract DoubleBuffer duplicate ();
+
+ /**
+ * Creates a new read-only <code>DoubleBuffer</code> that shares this
+ * buffer's content.
+ */
+ public abstract DoubleBuffer asReadOnlyBuffer ();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DoubleBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DoubleBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DoubleBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DoubleBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,171 @@
+/* DoubleBufferImpl.java --
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * This is a Heap memory implementation
+ */
+final class DoubleBufferImpl extends DoubleBuffer
+{
+ private boolean readOnly;
+
+ DoubleBufferImpl (int capacity)
+ {
+ this (new double [capacity], 0, capacity, capacity, 0, -1, false);
+ }
+
+ DoubleBufferImpl (double[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
+ {
+ super (capacity, limit, position, mark);
+ this.backing_buffer = buffer;
+ this.array_offset = offset;
+ this.readOnly = readOnly;
+ }
+
+ public boolean isReadOnly ()
+ {
+ return readOnly;
+ }
+
+ public DoubleBuffer slice ()
+ {
+ return new DoubleBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
+ }
+
+ public DoubleBuffer duplicate ()
+ {
+ return new DoubleBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
+ }
+
+ public DoubleBuffer asReadOnlyBuffer ()
+ {
+ return new DoubleBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
+ }
+
+ public DoubleBuffer compact ()
+ {
+ checkIfReadOnly();
+ mark = -1;
+ int p = position();
+ int n = limit() - p;
+ if (n > 0)
+ {
+ System.arraycopy(backing_buffer, array_offset + p,
+ backing_buffer, array_offset, n);
+ }
+ position(n);
+ limit(capacity());
+ return this;
+ }
+
+ public boolean isDirect ()
+ {
+ return false;
+ }
+
+ /**
+ * Reads the <code>double</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>double</code>s in this buffer.
+ */
+ public double get ()
+ {
+ checkForUnderflow();
+
+ double result = backing_buffer [position ()];
+ position (position () + 1);
+ return result;
+ }
+
+ /**
+ * Relative put method. Writes <code>value</code> to the next position
+ * in the buffer.
+ *
+ * @exception BufferOverflowException If there no remaining
+ * space in this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public DoubleBuffer put (double value)
+ {
+ checkIfReadOnly();
+ checkForOverflow();
+
+ backing_buffer [position ()] = value;
+ position (position () + 1);
+ return this;
+ }
+
+ /**
+ * Absolute get method. Reads the <code>double</code> at position
+ * <code>index</code>.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public double get (int index)
+ {
+ checkIndex(index);
+
+ return backing_buffer [index];
+ }
+
+ /**
+ * Absolute put method. Writes <code>value</code> to position
+ * <code>index</code> in the buffer.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public DoubleBuffer put (int index, double value)
+ {
+ checkIfReadOnly();
+ checkIndex(index);
+
+ backing_buffer [index] = value;
+ return this;
+ }
+
+ public ByteOrder order ()
+ {
+ return ByteOrder.nativeOrder ();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DoubleViewBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DoubleViewBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DoubleViewBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/DoubleViewBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,172 @@
+/* DoubleViewBufferImpl.java --
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+final class DoubleViewBufferImpl extends DoubleBuffer
+{
+ /** Position in bb (i.e. a byte offset) where this buffer starts. */
+ private int offset;
+ private ByteBuffer bb;
+ private boolean readOnly;
+ private ByteOrder endian;
+
+ DoubleViewBufferImpl (ByteBuffer bb, int capacity)
+ {
+ super (capacity, capacity, 0, -1);
+ this.bb = bb;
+ this.offset = bb.position();
+ this.readOnly = bb.isReadOnly();
+ this.endian = bb.order();
+ if (bb.isDirect())
+ this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
+ }
+
+ public DoubleViewBufferImpl (ByteBuffer bb, int offset, int capacity,
+ int limit, int position, int mark,
+ boolean readOnly, ByteOrder endian)
+ {
+ super (capacity, limit, position, mark);
+ this.bb = bb;
+ this.offset = offset;
+ this.readOnly = readOnly;
+ this.endian = endian;
+ if (bb.isDirect())
+ this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
+ }
+
+ /**
+ * Reads the <code>double</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>double</code>s in this buffer.
+ */
+ public double get ()
+ {
+ int p = position();
+ double result = ByteBufferHelper.getDouble(bb, (p << 3) + offset, endian);
+ position(p + 1);
+ return result;
+ }
+
+ /**
+ * Absolute get method. Reads the <code>double</code> at position
+ * <code>index</code>.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public double get (int index)
+ {
+ return ByteBufferHelper.getDouble(bb, (index << 3) + offset, endian);
+ }
+
+ public DoubleBuffer put (double value)
+ {
+ int p = position();
+ ByteBufferHelper.putDouble(bb, (p << 3) + offset, value, endian);
+ position(p + 1);
+ return this;
+ }
+
+ public DoubleBuffer put (int index, double value)
+ {
+ ByteBufferHelper.putDouble(bb, (index << 3) + offset, value, endian);
+ return this;
+ }
+
+ public DoubleBuffer compact ()
+ {
+ if (position () > 0)
+ {
+ int count = limit () - position ();
+ bb.shiftDown(offset, offset + 8 * position(), 8 * count);
+ position (count);
+ limit (capacity ());
+ }
+ else
+ {
+ position(limit());
+ limit(capacity());
+ }
+ return this;
+ }
+
+ public DoubleBuffer slice ()
+ {
+ return new DoubleViewBufferImpl (bb, (position () >> 3) + offset,
+ remaining(), remaining(), 0, -1,
+ readOnly, endian);
+ }
+
+ DoubleBuffer duplicate (boolean readOnly)
+ {
+ int pos = position();
+ reset();
+ int mark = position();
+ position(pos);
+ return new DoubleViewBufferImpl (bb, offset, capacity(), limit(),
+ pos, mark, readOnly, endian);
+ }
+
+ public DoubleBuffer duplicate ()
+ {
+ return duplicate(readOnly);
+ }
+
+ public DoubleBuffer asReadOnlyBuffer ()
+ {
+ return duplicate(true);
+ }
+
+ public boolean isReadOnly ()
+ {
+ return readOnly;
+ }
+
+ public boolean isDirect ()
+ {
+ return bb.isDirect ();
+ }
+
+ public ByteOrder order ()
+ {
+ return endian;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/FloatBuffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/FloatBuffer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/FloatBuffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/FloatBuffer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,383 @@
+/* FloatBuffer.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * @since 1.4
+ */
+public abstract class FloatBuffer extends Buffer
+ implements Comparable
+{
+ int array_offset;
+ float[] backing_buffer;
+
+ FloatBuffer (int capacity, int limit, int position, int mark)
+ {
+ super (capacity, limit, position, mark);
+ array_offset = 0;
+ }
+
+ /**
+ * Allocates a new <code>FloatBuffer</code> object with a given capacity.
+ */
+ public static FloatBuffer allocate (int capacity)
+ {
+ return new FloatBufferImpl (capacity);
+ }
+
+ /**
+ * Wraps a <code>float</code> array into a <code>FloatBuffer</code>
+ * object.
+ *
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ */
+ public static final FloatBuffer wrap (float[] array, int offset, int length)
+ {
+ return new FloatBufferImpl (array, 0, array.length, offset + length, offset, -1, false);
+ }
+
+ /**
+ * Wraps a <code>float</code> array into a <code>FloatBuffer</code>
+ * object.
+ */
+ public static final FloatBuffer wrap (float[] array)
+ {
+ return wrap (array, 0, array.length);
+ }
+
+ /**
+ * This method transfers <code>float</code>s from this buffer into the given
+ * destination array. Before the transfer, it checks if there are fewer than
+ * length <code>float</code>s remaining in this buffer.
+ *
+ * @param dst The destination array
+ * @param offset The offset within the array of the first <code>float</code>
+ * to be written; must be non-negative and no larger than dst.length.
+ * @param length The maximum number of bytes to be written to the given array;
+ * must be non-negative and no larger than dst.length - offset.
+ *
+ * @exception BufferUnderflowException If there are fewer than length
+ * <code>float</code>s remaining in this buffer.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold.
+ */
+ public FloatBuffer get (float[] dst, int offset, int length)
+ {
+ checkArraySize(dst.length, offset, length);
+ checkForUnderflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ {
+ dst [i] = get ();
+ }
+
+ return this;
+ }
+
+ /**
+ * This method transfers <code>float</code>s from this buffer into the given
+ * destination array.
+ *
+ * @param dst The byte array to write into.
+ *
+ * @exception BufferUnderflowException If there are fewer than dst.length
+ * <code>float</code>s remaining in this buffer.
+ */
+ public FloatBuffer get (float[] dst)
+ {
+ return get (dst, 0, dst.length);
+ }
+
+ /**
+ * Writes the content of the the <code>FloatBUFFER</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * <code>src.remaining()</code> space remaining in this buffer.
+ *
+ * @param src The source data.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>float</code>s in the source buffer.
+ * @exception IllegalArgumentException If the source buffer is this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public FloatBuffer put (FloatBuffer src)
+ {
+ if (src == this)
+ throw new IllegalArgumentException ();
+
+ checkForOverflow(src.remaining());
+
+ if (src.remaining () > 0)
+ {
+ float[] toPut = new float [src.remaining ()];
+ src.get (toPut);
+ put (toPut);
+ }
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>float array</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * length space remaining in this buffer.
+ *
+ * @param src The array to copy into the buffer.
+ * @param offset The offset within the array of the first byte to be read;
+ * must be non-negative and no larger than src.length.
+ * @param length The number of bytes to be read from the given array;
+ * must be non-negative and no larger than src.length - offset.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>float</code>s in the source array.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public FloatBuffer put (float[] src, int offset, int length)
+ {
+ checkArraySize(src.length, offset, length);
+ checkForOverflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ put (src [i]);
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>float array</code> src
+ * into the buffer.
+ *
+ * @param src The array to copy into the buffer.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>float</code>s in the source array.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public final FloatBuffer put (float[] src)
+ {
+ return put (src, 0, src.length);
+ }
+
+ /**
+ * Tells whether ot not this buffer is backed by an accessible
+ * <code>float</code> array.
+ */
+ public final boolean hasArray ()
+ {
+ return (backing_buffer != null
+ && !isReadOnly ());
+ }
+
+ /**
+ * Returns the <code>float</code> array that backs this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final float[] array ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return backing_buffer;
+ }
+
+ /**
+ * Returns the offset within this buffer's backing array of the first element.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final int arrayOffset ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return array_offset;
+ }
+
+ /**
+ * Calculates a hash code for this buffer.
+ *
+ * This is done with <code>int</code> arithmetic,
+ * where ** represents exponentiation, by this formula:<br>
+ * <code>s[position()] + 31 + (s[position()+1] + 30)*31**1 + ... +
+ * (s[limit()-1]+30)*31**(limit()-1)</code>.
+ * Where s is the buffer data, in Float.floatToIntBits() form
+ * Note that the hashcode is dependent on buffer content,
+ * and therefore is not useful if the buffer content may change.
+ *
+ * @return the hash code
+ */
+ public int hashCode ()
+ {
+ int hashCode = Float.floatToIntBits(get(position())) + 31;
+ int multiplier = 1;
+ for (int i = position() + 1; i < limit(); ++i)
+ {
+ multiplier *= 31;
+ hashCode += (Float.floatToIntBits(get(i)) + 30)*multiplier;
+ }
+ return hashCode;
+ }
+
+ /**
+ * Checks if this buffer is equal to obj.
+ */
+ public boolean equals (Object obj)
+ {
+ if (obj instanceof FloatBuffer)
+ {
+ return compareTo (obj) == 0;
+ }
+
+ return false;
+ }
+
+ /**
+ * Compares two <code>FloatBuffer</code> objects.
+ *
+ * @exception ClassCastException If obj is not an object derived from
+ * <code>FloatBuffer</code>.
+ */
+ public int compareTo (Object obj)
+ {
+ FloatBuffer other = (FloatBuffer) obj;
+
+ int num = Math.min(remaining(), other.remaining());
+ int pos_this = position();
+ int pos_other = other.position();
+
+ for (int count = 0; count < num; count++)
+ {
+ float a = get(pos_this++);
+ float b = other.get(pos_other++);
+
+ if (a == b)
+ continue;
+
+ if (a < b)
+ return -1;
+
+ return 1;
+ }
+
+ return remaining() - other.remaining();
+ }
+
+ /**
+ * Returns the byte order of this buffer.
+ */
+ public abstract ByteOrder order ();
+
+ /**
+ * Reads the <code>float</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>float</code>s in this buffer.
+ */
+ public abstract float get ();
+
+ /**
+ * Writes the <code>float</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferOverflowException If there no remaining
+ * <code>float</code>s in this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract FloatBuffer put (float b);
+
+ /**
+ * Absolute get method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public abstract float get (int index);
+
+ /**
+ * Absolute put method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract FloatBuffer put (int index, float b);
+
+ /**
+ * Compacts this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract FloatBuffer compact ();
+
+ /**
+ * Tells wether or not this buffer is direct.
+ */
+ public abstract boolean isDirect ();
+
+ /**
+ * Creates a new <code>FloatBuffer</code> whose content is a shared
+ * subsequence of this buffer's content.
+ */
+ public abstract FloatBuffer slice ();
+
+ /**
+ * Creates a new <code>FloatBuffer</code> that shares this buffer's
+ * content.
+ */
+ public abstract FloatBuffer duplicate ();
+
+ /**
+ * Creates a new read-only <code>FloatBuffer</code> that shares this
+ * buffer's content.
+ */
+ public abstract FloatBuffer asReadOnlyBuffer ();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/FloatBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/FloatBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/FloatBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/FloatBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,171 @@
+/* FloatBufferImpl.java --
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * This is a Heap memory implementation
+ */
+final class FloatBufferImpl extends FloatBuffer
+{
+ private boolean readOnly;
+
+ FloatBufferImpl (int capacity)
+ {
+ this (new float [capacity], 0, capacity, capacity, 0, -1, false);
+ }
+
+ FloatBufferImpl (float[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
+ {
+ super (capacity, limit, position, mark);
+ this.backing_buffer = buffer;
+ this.array_offset = offset;
+ this.readOnly = readOnly;
+ }
+
+ public boolean isReadOnly ()
+ {
+ return readOnly;
+ }
+
+ public FloatBuffer slice ()
+ {
+ return new FloatBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
+ }
+
+ public FloatBuffer duplicate ()
+ {
+ return new FloatBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
+ }
+
+ public FloatBuffer asReadOnlyBuffer ()
+ {
+ return new FloatBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
+ }
+
+ public FloatBuffer compact ()
+ {
+ checkIfReadOnly();
+ mark = -1;
+ int p = position();
+ int n = limit() - p;
+ if (n > 0)
+ {
+ System.arraycopy(backing_buffer, array_offset + p,
+ backing_buffer, array_offset, n);
+ }
+ position(n);
+ limit(capacity());
+ return this;
+ }
+
+ public boolean isDirect ()
+ {
+ return false;
+ }
+
+ /**
+ * Reads the <code>float</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>floats</code> in this buffer.
+ */
+ public float get ()
+ {
+ checkForUnderflow();
+
+ float result = backing_buffer [position ()];
+ position (position () + 1);
+ return result;
+ }
+
+ /**
+ * Relative put method. Writes <code>value</code> to the next position
+ * in the buffer.
+ *
+ * @exception BufferOverflowException If there no remaining
+ * space in this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public FloatBuffer put (float value)
+ {
+ checkIfReadOnly();
+ checkForOverflow();
+
+ backing_buffer [position ()] = value;
+ position (position () + 1);
+ return this;
+ }
+
+ /**
+ * Absolute get method. Reads the <code>float</code> at position
+ * <code>index</code>.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public float get (int index)
+ {
+ checkIndex(index);
+
+ return backing_buffer [index];
+ }
+
+ /**
+ * Absolute put method. Writes <code>value</code> to position
+ * <code>index</code> in the buffer.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public FloatBuffer put (int index, float value)
+ {
+ checkIfReadOnly();
+ checkIndex(index);
+
+ backing_buffer [index] = value;
+ return this;
+ }
+
+ public ByteOrder order ()
+ {
+ return ByteOrder.nativeOrder ();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/FloatViewBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/FloatViewBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/FloatViewBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/FloatViewBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,173 @@
+/* FloatViewBufferImpl.java --
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+final class FloatViewBufferImpl extends FloatBuffer
+{
+ /** Position in bb (i.e. a byte offset) where this buffer starts. */
+ private int offset;
+ private ByteBuffer bb;
+ private boolean readOnly;
+ private ByteOrder endian;
+
+ FloatViewBufferImpl (ByteBuffer bb, int capacity)
+ {
+ super (capacity, capacity, 0, -1);
+ this.bb = bb;
+ this.offset = bb.position();
+ this.readOnly = bb.isReadOnly();
+ this.endian = bb.order();
+ if (bb.isDirect())
+ this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
+ }
+
+ public FloatViewBufferImpl (ByteBuffer bb, int offset, int capacity,
+ int limit, int position, int mark,
+ boolean readOnly, ByteOrder endian)
+ {
+ super (capacity, limit, position, mark);
+ this.bb = bb;
+ this.offset = offset;
+ this.readOnly = readOnly;
+ this.endian = endian;
+ if (bb.isDirect())
+ this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
+ }
+
+ /**
+ * Reads the <code>float</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>floats</code> in this buffer.
+ */
+ public float get ()
+ {
+ int p = position();
+ float result = ByteBufferHelper.getFloat(bb, (p << 2) + offset, endian);
+ position(p + 1);
+ return result;
+ }
+
+ /**
+ * Absolute get method. Reads the <code>float</code> at position
+ * <code>index</code>.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public float get (int index)
+ {
+ return ByteBufferHelper.getFloat(bb, (index << 2) + offset, endian);
+ }
+
+ public FloatBuffer put (float value)
+ {
+ int p = position();
+ ByteBufferHelper.putFloat(bb, (p << 2) + offset, value, endian);
+ position(p + 1);
+ return this;
+ }
+
+ public FloatBuffer put (int index, float value)
+ {
+ ByteBufferHelper.putFloat(bb, (index << 2) + offset, value, endian);
+ return this;
+ }
+
+ public FloatBuffer compact ()
+ {
+ if (position () > 0)
+ {
+ int count = limit () - position ();
+ bb.shiftDown(offset, offset + 4 * position(), 4 * count);
+ position (count);
+ limit (capacity ());
+ }
+ else
+ {
+ position(limit());
+ limit(capacity());
+ }
+ return this;
+ }
+
+ public FloatBuffer slice ()
+ {
+ // Create a sliced copy of this object that shares its content.
+ return new FloatViewBufferImpl (bb, (position () >> 2) + offset,
+ remaining(), remaining(), 0, -1,
+ readOnly, endian);
+ }
+
+ FloatBuffer duplicate (boolean readOnly)
+ {
+ int pos = position();
+ reset();
+ int mark = position();
+ position(pos);
+ return new FloatViewBufferImpl (bb, offset, capacity(), limit(),
+ pos, mark, readOnly, endian);
+ }
+
+ public FloatBuffer duplicate ()
+ {
+ return duplicate(readOnly);
+ }
+
+ public FloatBuffer asReadOnlyBuffer ()
+ {
+ return duplicate(true);
+ }
+
+ public boolean isReadOnly ()
+ {
+ return readOnly;
+ }
+
+ public boolean isDirect ()
+ {
+ return bb.isDirect ();
+ }
+
+ public ByteOrder order ()
+ {
+ return endian;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/IntBuffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/IntBuffer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/IntBuffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/IntBuffer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,383 @@
+/* IntBuffer.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * @since 1.4
+ */
+public abstract class IntBuffer extends Buffer
+ implements Comparable
+{
+ int array_offset;
+ int[] backing_buffer;
+
+ IntBuffer (int capacity, int limit, int position, int mark)
+ {
+ super (capacity, limit, position, mark);
+ array_offset = 0;
+ }
+
+ /**
+ * Allocates a new <code>IntBuffer</code> object with a given capacity.
+ */
+ public static IntBuffer allocate (int capacity)
+ {
+ return new IntBufferImpl (capacity);
+ }
+
+ /**
+ * Wraps a <code>int</code> array into a <code>IntBuffer</code>
+ * object.
+ *
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ */
+ public static final IntBuffer wrap (int[] array, int offset, int length)
+ {
+ return new IntBufferImpl (array, 0, array.length, offset + length, offset, -1, false);
+ }
+
+ /**
+ * Wraps a <code>int</code> array into a <code>IntBuffer</code>
+ * object.
+ */
+ public static final IntBuffer wrap (int[] array)
+ {
+ return wrap (array, 0, array.length);
+ }
+
+ /**
+ * This method transfers <code>int</code>s from this buffer into the given
+ * destination array. Before the transfer, it checks if there are fewer than
+ * length <code>int</code>s remaining in this buffer.
+ *
+ * @param dst The destination array
+ * @param offset The offset within the array of the first <code>int</code>
+ * to be written; must be non-negative and no larger than dst.length.
+ * @param length The maximum number of bytes to be written to the given array;
+ * must be non-negative and no larger than dst.length - offset.
+ *
+ * @exception BufferUnderflowException If there are fewer than length
+ * <code>int</code>s remaining in this buffer.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold.
+ */
+ public IntBuffer get (int[] dst, int offset, int length)
+ {
+ checkArraySize(dst.length, offset, length);
+ checkForUnderflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ {
+ dst [i] = get ();
+ }
+
+ return this;
+ }
+
+ /**
+ * This method transfers <code>int</code>s from this buffer into the given
+ * destination array.
+ *
+ * @param dst The byte array to write into.
+ *
+ * @exception BufferUnderflowException If there are fewer than dst.length
+ * <code>int</code>s remaining in this buffer.
+ */
+ public IntBuffer get (int[] dst)
+ {
+ return get (dst, 0, dst.length);
+ }
+
+ /**
+ * Writes the content of the the <code>IntBUFFER</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * <code>src.remaining()</code> space remaining in this buffer.
+ *
+ * @param src The source data.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>int</code>s in the source buffer.
+ * @exception IllegalArgumentException If the source buffer is this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public IntBuffer put (IntBuffer src)
+ {
+ if (src == this)
+ throw new IllegalArgumentException ();
+
+ checkForOverflow(src.remaining ());
+
+ if (src.remaining () > 0)
+ {
+ int[] toPut = new int [src.remaining ()];
+ src.get (toPut);
+ put (toPut);
+ }
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>int array</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * length space remaining in this buffer.
+ *
+ * @param src The array to copy into the buffer.
+ * @param offset The offset within the array of the first byte to be read;
+ * must be non-negative and no larger than src.length.
+ * @param length The number of bytes to be read from the given array;
+ * must be non-negative and no larger than src.length - offset.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>int</code>s in the source array.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public IntBuffer put (int[] src, int offset, int length)
+ {
+ checkArraySize(src.length, offset, length);
+ checkForOverflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ put (src [i]);
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>int array</code> src
+ * into the buffer.
+ *
+ * @param src The array to copy into the buffer.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>int</code>s in the source array.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public final IntBuffer put (int[] src)
+ {
+ return put (src, 0, src.length);
+ }
+
+ /**
+ * Tells whether ot not this buffer is backed by an accessible
+ * <code>int</code> array.
+ */
+ public final boolean hasArray ()
+ {
+ return (backing_buffer != null
+ && !isReadOnly ());
+ }
+
+ /**
+ * Returns the <code>int</code> array that backs this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final int[] array ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return backing_buffer;
+ }
+
+ /**
+ * Returns the offset within this buffer's backing array of the first element.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final int arrayOffset ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return array_offset;
+ }
+
+ /**
+ * Calculates a hash code for this buffer.
+ *
+ * This is done with <code>int</code> arithmetic,
+ * where ** represents exponentiation, by this formula:<br>
+ * <code>s[position()] + 31 + (s[position()+1] + 30)*31**1 + ... +
+ * (s[limit()-1]+30)*31**(limit()-1)</code>.
+ * Where s is the buffer data. Note that the hashcode is dependent
+ * on buffer content, and therefore is not useful if the buffer
+ * content may change.
+ *
+ * @return the hash code
+ */
+ public int hashCode ()
+ {
+ int hashCode = get(position()) + 31;
+ int multiplier = 1;
+ for (int i = position() + 1; i < limit(); ++i)
+ {
+ multiplier *= 31;
+ hashCode += (get(i) + 30)*multiplier;
+ }
+ return hashCode;
+ }
+
+ /**
+ * Checks if this buffer is equal to obj.
+ */
+ public boolean equals (Object obj)
+ {
+ if (obj instanceof IntBuffer)
+ {
+ return compareTo (obj) == 0;
+ }
+
+ return false;
+ }
+
+ /**
+ * Compares two <code>IntBuffer</code> objects.
+ *
+ * @exception ClassCastException If obj is not an object derived from
+ * <code>IntBuffer</code>.
+ */
+ public int compareTo (Object obj)
+ {
+ IntBuffer other = (IntBuffer) obj;
+
+ int num = Math.min(remaining(), other.remaining());
+ int pos_this = position();
+ int pos_other = other.position();
+
+ for (int count = 0; count < num; count++)
+ {
+ int a = get(pos_this++);
+ int b = other.get(pos_other++);
+
+ if (a == b)
+ continue;
+
+ if (a < b)
+ return -1;
+
+ return 1;
+ }
+
+ return remaining() - other.remaining();
+ }
+
+ /**
+ * Returns the byte order of this buffer.
+ */
+ public abstract ByteOrder order ();
+
+ /**
+ * Reads the <code>int</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>int</code>s in this buffer.
+ */
+ public abstract int get ();
+
+ /**
+ * Writes the <code>int</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferOverflowException If there no remaining
+ * <code>int</code>s in this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract IntBuffer put (int b);
+
+ /**
+ * Absolute get method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public abstract int get (int index);
+
+ /**
+ * Absolute put method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract IntBuffer put (int index, int b);
+
+ /**
+ * Compacts this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract IntBuffer compact ();
+
+ /**
+ * Tells wether or not this buffer is direct.
+ */
+ public abstract boolean isDirect ();
+
+ /**
+ * Creates a new <code>IntBuffer</code> whose content is a shared
+ * subsequence of this buffer's content.
+ */
+ public abstract IntBuffer slice ();
+
+ /**
+ * Creates a new <code>IntBuffer</code> that shares this buffer's
+ * content.
+ */
+ public abstract IntBuffer duplicate ();
+
+ /**
+ * Creates a new read-only <code>IntBuffer</code> that shares this
+ * buffer's content.
+ */
+ public abstract IntBuffer asReadOnlyBuffer ();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/IntBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/IntBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/IntBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/IntBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,171 @@
+/* IntBufferImpl.java --
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * This is a Heap memory implementation
+ */
+final class IntBufferImpl extends IntBuffer
+{
+ private boolean readOnly;
+
+ IntBufferImpl (int capacity)
+ {
+ this (new int [capacity], 0, capacity, capacity, 0, -1, false);
+ }
+
+ IntBufferImpl (int[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
+ {
+ super (capacity, limit, position, mark);
+ this.backing_buffer = buffer;
+ this.array_offset = offset;
+ this.readOnly = readOnly;
+ }
+
+ public boolean isReadOnly ()
+ {
+ return readOnly;
+ }
+
+ public IntBuffer slice ()
+ {
+ return new IntBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
+ }
+
+ public IntBuffer duplicate ()
+ {
+ return new IntBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
+ }
+
+ public IntBuffer asReadOnlyBuffer ()
+ {
+ return new IntBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
+ }
+
+ public IntBuffer compact ()
+ {
+ checkIfReadOnly();
+ mark = -1;
+ int p = position();
+ int n = limit() - p;
+ if (n > 0)
+ {
+ System.arraycopy(backing_buffer, array_offset + p,
+ backing_buffer, array_offset, n);
+ }
+ position(n);
+ limit(capacity());
+ return this;
+ }
+
+ public boolean isDirect ()
+ {
+ return false;
+ }
+
+ /**
+ * Reads the <code>int</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>ints</code> in this buffer.
+ */
+ public int get ()
+ {
+ checkForUnderflow();
+
+ int result = backing_buffer [position ()];
+ position (position () + 1);
+ return result;
+ }
+
+ /**
+ * Relative put method. Writes <code>value</code> to the next position
+ * in the buffer.
+ *
+ * @exception BufferOverflowException If there no remaining
+ * space in this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public IntBuffer put (int value)
+ {
+ checkIfReadOnly();
+ checkForOverflow();
+
+ backing_buffer [position ()] = value;
+ position (position () + 1);
+ return this;
+ }
+
+ /**
+ * Absolute get method. Reads the <code>int</code> at position
+ * <code>index</code>.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public int get (int index)
+ {
+ checkIndex(index);
+
+ return backing_buffer [index];
+ }
+
+ /**
+ * Absolute put method. Writes <code>value</code> to position
+ * <code>index</code> in the buffer.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public IntBuffer put (int index, int value)
+ {
+ checkIfReadOnly();
+ checkIndex(index);
+
+ backing_buffer [index] = value;
+ return this;
+ }
+
+ public ByteOrder order ()
+ {
+ return ByteOrder.nativeOrder ();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/IntViewBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/IntViewBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/IntViewBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/IntViewBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,173 @@
+/* IntViewBufferImpl.java --
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+final class IntViewBufferImpl extends IntBuffer
+{
+ /** Position in bb (i.e. a byte offset) where this buffer starts. */
+ private int offset;
+ private ByteBuffer bb;
+ private boolean readOnly;
+ private ByteOrder endian;
+
+ IntViewBufferImpl (ByteBuffer bb, int capacity)
+ {
+ super (capacity, capacity, 0, -1);
+ this.bb = bb;
+ this.offset = bb.position();
+ this.readOnly = bb.isReadOnly();
+ this.endian = bb.order();
+ if (bb.isDirect())
+ this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
+ }
+
+ public IntViewBufferImpl (ByteBuffer bb, int offset, int capacity,
+ int limit, int position, int mark,
+ boolean readOnly, ByteOrder endian)
+ {
+ super (capacity, limit, position, mark);
+ this.bb = bb;
+ this.offset = offset;
+ this.readOnly = readOnly;
+ this.endian = endian;
+ if (bb.isDirect())
+ this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
+ }
+
+ /**
+ * Reads the <code>int</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>ints</code> in this buffer.
+ */
+ public int get ()
+ {
+ int p = position();
+ int result = ByteBufferHelper.getInt(bb, (p << 2) + offset, endian);
+ position(p + 1);
+ return result;
+ }
+
+ /**
+ * Absolute get method. Reads the <code>int</code> at position
+ * <code>index</code>.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public int get (int index)
+ {
+ return ByteBufferHelper.getInt(bb, (index << 2) + offset, endian);
+ }
+
+ public IntBuffer put (int value)
+ {
+ int p = position();
+ ByteBufferHelper.putInt(bb, (p << 2) + offset, value, endian);
+ position(p + 1);
+ return this;
+ }
+
+ public IntBuffer put (int index, int value)
+ {
+ ByteBufferHelper.putInt(bb, (index << 2) + offset, value, endian);
+ return this;
+ }
+
+ public IntBuffer compact ()
+ {
+ if (position () > 0)
+ {
+ int count = limit () - position ();
+ bb.shiftDown(offset, offset + 4 * position(), 4 * count);
+ position (count);
+ limit (capacity ());
+ }
+ else
+ {
+ position(limit());
+ limit(capacity());
+ }
+ return this;
+ }
+
+ public IntBuffer slice ()
+ {
+ // Create a sliced copy of this object that shares its content.
+ return new IntViewBufferImpl (bb, (position () >> 2) + offset,
+ remaining(), remaining(), 0, -1,
+ readOnly, endian);
+ }
+
+ IntBuffer duplicate (boolean readOnly)
+ {
+ int pos = position();
+ reset();
+ int mark = position();
+ position(pos);
+ return new IntViewBufferImpl (bb, offset, capacity(), limit(),
+ pos, mark, readOnly, endian);
+ }
+
+ public IntBuffer duplicate ()
+ {
+ return duplicate(readOnly);
+ }
+
+ public IntBuffer asReadOnlyBuffer ()
+ {
+ return duplicate(true);
+ }
+
+ public boolean isReadOnly ()
+ {
+ return readOnly;
+ }
+
+ public boolean isDirect ()
+ {
+ return bb.isDirect ();
+ }
+
+ public ByteOrder order ()
+ {
+ return endian;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/InvalidMarkException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/InvalidMarkException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/InvalidMarkException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/InvalidMarkException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,54 @@
+/* InvalidMarkException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class InvalidMarkException extends IllegalStateException
+{
+ private static final long serialVersionUID = 1698329710438510774L;
+
+ /**
+ * Creates the exception
+ */
+ public InvalidMarkException ()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/LongBuffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/LongBuffer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/LongBuffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/LongBuffer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,383 @@
+/* LongBuffer.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * @since 1.4
+ */
+public abstract class LongBuffer extends Buffer
+ implements Comparable
+{
+ int array_offset;
+ long[] backing_buffer;
+
+ LongBuffer (int capacity, int limit, int position, int mark)
+ {
+ super (capacity, limit, position, mark);
+ array_offset = 0;
+ }
+
+ /**
+ * Allocates a new <code>LongBuffer</code> object with a given capacity.
+ */
+ public static LongBuffer allocate (int capacity)
+ {
+ return new LongBufferImpl (capacity);
+ }
+
+ /**
+ * Wraps a <code>long</code> array into a <code>LongBuffer</code>
+ * object.
+ *
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ */
+ public static final LongBuffer wrap (long[] array, int offset, int length)
+ {
+ return new LongBufferImpl (array, 0, array.length, offset + length, offset, -1, false);
+ }
+
+ /**
+ * Wraps a <code>long</code> array into a <code>LongBuffer</code>
+ * object.
+ */
+ public static final LongBuffer wrap (long[] array)
+ {
+ return wrap (array, 0, array.length);
+ }
+
+ /**
+ * This method transfers <code>long</code>s from this buffer into the given
+ * destination array. Before the transfer, it checks if there are fewer than
+ * length <code>long</code>s remaining in this buffer.
+ *
+ * @param dst The destination array
+ * @param offset The offset within the array of the first <code>long</code>
+ * to be written; must be non-negative and no larger than dst.length.
+ * @param length The maximum number of bytes to be written to the given array;
+ * must be non-negative and no larger than dst.length - offset.
+ *
+ * @exception BufferUnderflowException If there are fewer than length
+ * <code>long</code>s remaining in this buffer.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold.
+ */
+ public LongBuffer get (long[] dst, int offset, int length)
+ {
+ checkArraySize(dst.length, offset, length);
+ checkForUnderflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ {
+ dst [i] = get ();
+ }
+
+ return this;
+ }
+
+ /**
+ * This method transfers <code>long</code>s from this buffer into the given
+ * destination array.
+ *
+ * @param dst The byte array to write into.
+ *
+ * @exception BufferUnderflowException If there are fewer than dst.length
+ * <code>long</code>s remaining in this buffer.
+ */
+ public LongBuffer get (long[] dst)
+ {
+ return get (dst, 0, dst.length);
+ }
+
+ /**
+ * Writes the content of the the <code>LongBUFFER</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * <code>src.remaining()</code> space remaining in this buffer.
+ *
+ * @param src The source data.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>long</code>s in the source buffer.
+ * @exception IllegalArgumentException If the source buffer is this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public LongBuffer put (LongBuffer src)
+ {
+ if (src == this)
+ throw new IllegalArgumentException ();
+
+ checkForOverflow(src.remaining ());
+
+ if (src.remaining () > 0)
+ {
+ long[] toPut = new long [src.remaining ()];
+ src.get (toPut);
+ put (toPut);
+ }
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>long array</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * length space remaining in this buffer.
+ *
+ * @param src The array to copy into the buffer.
+ * @param offset The offset within the array of the first byte to be read;
+ * must be non-negative and no larger than src.length.
+ * @param length The number of bytes to be read from the given array;
+ * must be non-negative and no larger than src.length - offset.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>long</code>s in the source array.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public LongBuffer put (long[] src, int offset, int length)
+ {
+ checkArraySize(src.length, offset, length);
+ checkForOverflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ put (src [i]);
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>long array</code> src
+ * into the buffer.
+ *
+ * @param src The array to copy into the buffer.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>long</code>s in the source array.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public final LongBuffer put (long[] src)
+ {
+ return put (src, 0, src.length);
+ }
+
+ /**
+ * Tells whether ot not this buffer is backed by an accessible
+ * <code>long</code> array.
+ */
+ public final boolean hasArray ()
+ {
+ return (backing_buffer != null
+ && !isReadOnly ());
+ }
+
+ /**
+ * Returns the <code>long</code> array that backs this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final long[] array ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return backing_buffer;
+ }
+
+ /**
+ * Returns the offset within this buffer's backing array of the first element.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final int arrayOffset ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return array_offset;
+ }
+
+ /**
+ * Calculates a hash code for this buffer.
+ *
+ * This is done with <code>long</code> arithmetic,
+ * where ** represents exponentiation, by this formula:<br>
+ * <code>s[position()] + 31 + (s[position()+1] + 30)*31**1 + ... +
+ * (s[limit()-1]+30)*31**(limit()-1)</code>.
+ * Where s is the buffer data. Note that the hashcode is dependent
+ * on buffer content, and therefore is not useful if the buffer
+ * content may change.
+ *
+ * @return the hash code (casted to int)
+ */
+ public int hashCode ()
+ {
+ long hashCode = get(position()) + 31;
+ long multiplier = 1;
+ for (int i = position() + 1; i < limit(); ++i)
+ {
+ multiplier *= 31;
+ hashCode += (get(i) + 30)*multiplier;
+ }
+ return ((int)hashCode);
+ }
+
+ /**
+ * Checks if this buffer is equal to obj.
+ */
+ public boolean equals (Object obj)
+ {
+ if (obj instanceof LongBuffer)
+ {
+ return compareTo (obj) == 0;
+ }
+
+ return false;
+ }
+
+ /**
+ * Compares two <code>LongBuffer</code> objects.
+ *
+ * @exception ClassCastException If obj is not an object derived from
+ * <code>LongBuffer</code>.
+ */
+ public int compareTo (Object obj)
+ {
+ LongBuffer other = (LongBuffer) obj;
+
+ int num = Math.min(remaining(), other.remaining());
+ int pos_this = position();
+ int pos_other = other.position();
+
+ for (int count = 0; count < num; count++)
+ {
+ long a = get(pos_this++);
+ long b = other.get(pos_other++);
+
+ if (a == b)
+ continue;
+
+ if (a < b)
+ return -1;
+
+ return 1;
+ }
+
+ return remaining() - other.remaining();
+ }
+
+ /**
+ * Returns the byte order of this buffer.
+ */
+ public abstract ByteOrder order ();
+
+ /**
+ * Reads the <code>long</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>long</code>s in this buffer.
+ */
+ public abstract long get ();
+
+ /**
+ * Writes the <code>long</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferOverflowException If there no remaining
+ * <code>long</code>s in this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract LongBuffer put (long b);
+
+ /**
+ * Absolute get method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public abstract long get (int index);
+
+ /**
+ * Absolute put method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract LongBuffer put (int index, long b);
+
+ /**
+ * Compacts this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract LongBuffer compact ();
+
+ /**
+ * Tells wether or not this buffer is direct.
+ */
+ public abstract boolean isDirect ();
+
+ /**
+ * Creates a new <code>LongBuffer</code> whose content is a shared
+ * subsequence of this buffer's content.
+ */
+ public abstract LongBuffer slice ();
+
+ /**
+ * Creates a new <code>LongBuffer</code> that shares this buffer's
+ * content.
+ */
+ public abstract LongBuffer duplicate ();
+
+ /**
+ * Creates a new read-only <code>LongBuffer</code> that shares this
+ * buffer's content.
+ */
+ public abstract LongBuffer asReadOnlyBuffer ();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/LongBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/LongBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/LongBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/LongBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,171 @@
+/* LongBufferImpl.java --
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * This is a Heap memory implementation
+ */
+final class LongBufferImpl extends LongBuffer
+{
+ private boolean readOnly;
+
+ LongBufferImpl (int capacity)
+ {
+ this (new long [capacity], 0, capacity, capacity, 0, -1, false);
+ }
+
+ LongBufferImpl (long[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
+ {
+ super (capacity, limit, position, mark);
+ this.backing_buffer = buffer;
+ this.array_offset = offset;
+ this.readOnly = readOnly;
+ }
+
+ public boolean isReadOnly ()
+ {
+ return readOnly;
+ }
+
+ public LongBuffer slice ()
+ {
+ return new LongBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
+ }
+
+ public LongBuffer duplicate ()
+ {
+ return new LongBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
+ }
+
+ public LongBuffer asReadOnlyBuffer ()
+ {
+ return new LongBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
+ }
+
+ public LongBuffer compact ()
+ {
+ checkIfReadOnly();
+ mark = -1;
+ int p = position();
+ int n = limit() - p;
+ if (n > 0)
+ {
+ System.arraycopy(backing_buffer, array_offset + p,
+ backing_buffer, array_offset, n);
+ }
+ position(n);
+ limit(capacity());
+ return this;
+ }
+
+ public boolean isDirect ()
+ {
+ return false;
+ }
+
+ /**
+ * Reads the <code>long</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>longs</code> in this buffer.
+ */
+ public long get ()
+ {
+ checkForUnderflow();
+
+ long result = backing_buffer [position ()];
+ position (position () + 1);
+ return result;
+ }
+
+ /**
+ * Relative put method. Writes <code>value</code> to the next position
+ * in the buffer.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public LongBuffer put (long value)
+ {
+ checkIfReadOnly();
+ checkForOverflow();
+
+ backing_buffer [position ()] = value;
+ position (position () + 1);
+ return this;
+ }
+
+ /**
+ * Absolute get method. Reads the <code>long</code> at position
+ * <code>index</code>.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public long get (int index)
+ {
+ checkIndex(index);
+
+ return backing_buffer [index];
+ }
+
+ /**
+ * Absolute put method. Writes <code>value</code> to position
+ * <code>index</code> in the buffer.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public LongBuffer put (int index, long value)
+ {
+ checkIfReadOnly();
+ checkIndex(index);
+
+ backing_buffer [index] = value;
+ return this;
+ }
+
+ public ByteOrder order ()
+ {
+ return ByteOrder.nativeOrder ();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/LongViewBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/LongViewBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/LongViewBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/LongViewBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,173 @@
+/* LongViewBufferImpl.java --
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+final class LongViewBufferImpl extends LongBuffer
+{
+ /** Position in bb (i.e. a byte offset) where this buffer starts. */
+ private int offset;
+ private ByteBuffer bb;
+ private boolean readOnly;
+ private ByteOrder endian;
+
+ LongViewBufferImpl (ByteBuffer bb, int capacity)
+ {
+ super (capacity, capacity, 0, -1);
+ this.bb = bb;
+ this.offset = bb.position();
+ this.readOnly = bb.isReadOnly();
+ this.endian = bb.order();
+ if (bb.isDirect())
+ this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
+ }
+
+ public LongViewBufferImpl (ByteBuffer bb, int offset, int capacity,
+ int limit, int position, int mark,
+ boolean readOnly, ByteOrder endian)
+ {
+ super (capacity, limit, position, mark);
+ this.bb = bb;
+ this.offset = offset;
+ this.readOnly = readOnly;
+ this.endian = endian;
+ if (bb.isDirect())
+ this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
+ }
+
+ /**
+ * Reads the <code>long</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>longs</code> in this buffer.
+ */
+ public long get ()
+ {
+ int p = position();
+ long result = ByteBufferHelper.getLong(bb, (p << 3) + offset, endian);
+ position(p + 1);
+ return result;
+ }
+
+ /**
+ * Absolute get method. Reads the <code>long</code> at position
+ * <code>index</code>.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public long get (int index)
+ {
+ return ByteBufferHelper.getLong(bb, (index << 3) + offset, endian);
+ }
+
+ public LongBuffer put (long value)
+ {
+ int p = position();
+ ByteBufferHelper.putLong(bb, (p << 3) + offset, value, endian);
+ position(p + 1);
+ return this;
+ }
+
+ public LongBuffer put (int index, long value)
+ {
+ ByteBufferHelper.putLong(bb, (index << 3) + offset, value, endian);
+ return this;
+ }
+
+ public LongBuffer compact ()
+ {
+ if (position () > 0)
+ {
+ int count = limit () - position ();
+ bb.shiftDown(offset, offset + 8 * position(), 8 * count);
+ position (count);
+ limit (capacity ());
+ }
+ else
+ {
+ position(limit());
+ limit(capacity());
+ }
+ return this;
+ }
+
+ public LongBuffer slice ()
+ {
+ // Create a sliced copy of this object that shares its content.
+ return new LongViewBufferImpl (bb, (position () >> 3) + offset,
+ remaining(), remaining(), 0, -1,
+ readOnly, endian);
+ }
+
+ LongBuffer duplicate (boolean readOnly)
+ {
+ int pos = position();
+ reset();
+ int mark = position();
+ position(pos);
+ return new LongViewBufferImpl (bb, offset, capacity(), limit(),
+ pos, mark, readOnly, endian);
+ }
+
+ public LongBuffer duplicate ()
+ {
+ return duplicate(readOnly);
+ }
+
+ public LongBuffer asReadOnlyBuffer ()
+ {
+ return duplicate(true);
+ }
+
+ public boolean isReadOnly ()
+ {
+ return readOnly;
+ }
+
+ public boolean isDirect ()
+ {
+ return bb.isDirect ();
+ }
+
+ public ByteOrder order ()
+ {
+ return endian;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/MappedByteBuffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/MappedByteBuffer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/MappedByteBuffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/MappedByteBuffer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,93 @@
+/* MappedByteBuffer.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ * @since 1.4
+ */
+public abstract class MappedByteBuffer extends ByteBuffer
+{
+ MappedByteBuffer (int capacity, int limit, int position, int mark)
+ {
+ super (capacity, limit, position, mark);
+ }
+
+ void forceImpl()
+ {
+ }
+
+ public final MappedByteBuffer force ()
+ {
+ forceImpl();
+ return this;
+ }
+
+ boolean isLoadedImpl()
+ {
+ load();
+ return true;
+ }
+
+ public final boolean isLoaded ()
+ {
+ return isLoadedImpl();
+ }
+
+ void loadImpl()
+ {
+ }
+
+ public final MappedByteBuffer load ()
+ {
+ loadImpl();
+ return this;
+ }
+
+ void unmapImpl ()
+ {
+ forceImpl();
+ }
+
+ protected void finalize()
+ throws Throwable
+ {
+ unmapImpl();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/MappedByteBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/MappedByteBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/MappedByteBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/MappedByteBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,360 @@
+/* MappedByteBufferImpl.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+import gnu.classpath.Pointer;
+
+import java.io.IOException;
+
+final class MappedByteBufferImpl extends MappedByteBuffer
+{
+ boolean readOnly;
+
+ /** Posix uses this for the pointer returned by mmap;
+ * Win32 uses it for the pointer returned by MapViewOfFile. */
+ public Pointer implPtr;
+ /** Posix uses this for the actual length passed to mmap;
+ * Win32 uses it for the pointer returned by CreateFileMapping. */
+ public long implLen;
+
+ public MappedByteBufferImpl(Pointer address, int size, boolean readOnly)
+ throws IOException
+ {
+ super(size, size, 0, -1);
+ this.address = address;
+ this.readOnly = readOnly;
+ }
+
+ public boolean isReadOnly()
+ {
+ return readOnly;
+ }
+
+ public byte get()
+ {
+ checkForUnderflow();
+
+ int pos = position();
+ byte result = VMDirectByteBuffer.get(address, pos);
+ position(pos + 1);
+ return result;
+ }
+
+ public ByteBuffer put(byte value)
+ {
+ checkIfReadOnly();
+ checkForOverflow();
+
+ int pos = position();
+ VMDirectByteBuffer.put(address, pos, value);
+ position(pos + 1);
+ return this;
+ }
+
+ public byte get(int index)
+ {
+ checkIndex(index);
+
+ return VMDirectByteBuffer.get(address, index);
+ }
+
+ public ByteBuffer get(byte[] dst, int offset, int length)
+ {
+ checkArraySize(dst.length, offset, length);
+ checkForUnderflow(length);
+
+ int index = position();
+ VMDirectByteBuffer.get(address, index, dst, offset, length);
+ position(index+length);
+
+ return this;
+ }
+
+ public ByteBuffer put(int index, byte value)
+ {
+ checkIfReadOnly();
+ checkIndex(index);
+
+ VMDirectByteBuffer.put(address, index, value);
+ return this;
+ }
+
+ public ByteBuffer compact()
+ {
+ checkIfReadOnly();
+ mark = -1;
+ int pos = position();
+ if (pos > 0)
+ {
+ int count = remaining();
+ // Call shiftDown method optimized for direct buffers.
+ VMDirectByteBuffer.shiftDown(address, 0, pos, count);
+ position(count);
+ limit(capacity());
+ }
+ else
+ {
+ position(limit());
+ limit(capacity());
+ }
+ return this;
+ }
+
+ public boolean isDirect()
+ {
+ return true;
+ }
+
+ public ByteBuffer slice()
+ {
+ int rem = remaining();
+ if (isReadOnly())
+ return new DirectByteBufferImpl.ReadOnly
+ (this, VMDirectByteBuffer.adjustAddress(address, position()),
+ rem, rem, 0);
+ else
+ return new DirectByteBufferImpl.ReadWrite
+ (this, VMDirectByteBuffer.adjustAddress(address, position()),
+ rem, rem, 0);
+ }
+
+ private ByteBuffer duplicate(boolean readOnly)
+ {
+ int pos = position();
+ reset();
+ int mark = position();
+ position(pos);
+ DirectByteBufferImpl result;
+ if (readOnly)
+ result = new DirectByteBufferImpl.ReadOnly(this, address, capacity(),
+ limit(), pos);
+ else
+ result = new DirectByteBufferImpl.ReadWrite(this, address, capacity(),
+ limit(), pos);
+
+ if (mark != pos)
+ {
+ result.position(mark);
+ result.mark();
+ result.position(pos);
+ }
+ return result;
+ }
+
+ public ByteBuffer duplicate()
+ {
+ return duplicate(isReadOnly());
+ }
+
+ public ByteBuffer asReadOnlyBuffer()
+ {
+ return duplicate(true);
+ }
+
+ public CharBuffer asCharBuffer()
+ {
+ return new CharViewBufferImpl(this, remaining() >> 1);
+ }
+
+ public ShortBuffer asShortBuffer()
+ {
+ return new ShortViewBufferImpl(this, remaining() >> 1);
+ }
+
+ public IntBuffer asIntBuffer()
+ {
+ return new IntViewBufferImpl(this, remaining() >> 2);
+ }
+
+ public LongBuffer asLongBuffer()
+ {
+ return new LongViewBufferImpl(this, remaining() >> 3);
+ }
+
+ public FloatBuffer asFloatBuffer()
+ {
+ return new FloatViewBufferImpl(this, remaining() >> 2);
+ }
+
+ public DoubleBuffer asDoubleBuffer()
+ {
+ return new DoubleViewBufferImpl(this, remaining() >> 3);
+ }
+
+ public char getChar()
+ {
+ return ByteBufferHelper.getChar(this, order());
+ }
+
+ public ByteBuffer putChar(char value)
+ {
+ ByteBufferHelper.putChar(this, value, order());
+ return this;
+ }
+
+ public char getChar(int index)
+ {
+ return ByteBufferHelper.getChar(this, index, order());
+ }
+
+ public ByteBuffer putChar(int index, char value)
+ {
+ ByteBufferHelper.putChar(this, index, value, order());
+ return this;
+ }
+
+ public short getShort()
+ {
+ return ByteBufferHelper.getShort(this, order());
+ }
+
+ public ByteBuffer putShort(short value)
+ {
+ ByteBufferHelper.putShort(this, value, order());
+ return this;
+ }
+
+ public short getShort(int index)
+ {
+ return ByteBufferHelper.getShort(this, index, order());
+ }
+
+ public ByteBuffer putShort(int index, short value)
+ {
+ ByteBufferHelper.putShort(this, index, value, order());
+ return this;
+ }
+
+ public int getInt()
+ {
+ return ByteBufferHelper.getInt(this, order());
+ }
+
+ public ByteBuffer putInt(int value)
+ {
+ ByteBufferHelper.putInt(this, value, order());
+ return this;
+ }
+
+ public int getInt(int index)
+ {
+ return ByteBufferHelper.getInt(this, index, order());
+ }
+
+ public ByteBuffer putInt(int index, int value)
+ {
+ ByteBufferHelper.putInt(this, index, value, order());
+ return this;
+ }
+
+ public long getLong()
+ {
+ return ByteBufferHelper.getLong(this, order());
+ }
+
+ public ByteBuffer putLong(long value)
+ {
+ ByteBufferHelper.putLong(this, value, order());
+ return this;
+ }
+
+ public long getLong(int index)
+ {
+ return ByteBufferHelper.getLong(this, index, order());
+ }
+
+ public ByteBuffer putLong(int index, long value)
+ {
+ ByteBufferHelper.putLong(this, index, value, order());
+ return this;
+ }
+
+ public float getFloat()
+ {
+ return ByteBufferHelper.getFloat(this, order());
+ }
+
+ public ByteBuffer putFloat(float value)
+ {
+ ByteBufferHelper.putFloat(this, value, order());
+ return this;
+ }
+
+ public float getFloat(int index)
+ {
+ return ByteBufferHelper.getFloat(this, index, order());
+ }
+
+ public ByteBuffer putFloat(int index, float value)
+ {
+ ByteBufferHelper.putFloat(this, index, value, order());
+ return this;
+ }
+
+ public double getDouble()
+ {
+ return ByteBufferHelper.getDouble(this, order());
+ }
+
+ public ByteBuffer putDouble(double value)
+ {
+ ByteBufferHelper.putDouble(this, value, order());
+ return this;
+ }
+
+ public double getDouble(int index)
+ {
+ return ByteBufferHelper.getDouble(this, index, order());
+ }
+
+ public ByteBuffer putDouble(int index, double value)
+ {
+ ByteBufferHelper.putDouble(this, index, value, order());
+ return this;
+ }
+
+ // NOTE: In libgcj these methods are implemented in natFileChannelXxx.cc,
+ // because they're small, and to put them next to FileChannelImpl::mapImpl.
+ native void unmapImpl();
+ native boolean isLoadedImpl();
+ // FIXME: Try to load all pages into memory.
+ native void loadImpl();
+
+ native void forceImpl();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ReadOnlyBufferException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ReadOnlyBufferException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ReadOnlyBufferException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ReadOnlyBufferException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,54 @@
+/* ReadOnlyBufferException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class ReadOnlyBufferException extends UnsupportedOperationException
+{
+ private static final long serialVersionUID = - 1210063976496234090L;
+
+ /**
+ * Creates the exception
+ */
+ public ReadOnlyBufferException ()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ShortBuffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ShortBuffer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ShortBuffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ShortBuffer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,383 @@
+/* ShortBuffer.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * @since 1.4
+ */
+public abstract class ShortBuffer extends Buffer
+ implements Comparable
+{
+ int array_offset;
+ short[] backing_buffer;
+
+ ShortBuffer (int capacity, int limit, int position, int mark)
+ {
+ super (capacity, limit, position, mark);
+ array_offset = 0;
+ }
+
+ /**
+ * Allocates a new <code>ShortBuffer</code> object with a given capacity.
+ */
+ public static ShortBuffer allocate (int capacity)
+ {
+ return new ShortBufferImpl (capacity);
+ }
+
+ /**
+ * Wraps a <code>short</code> array into a <code>ShortBuffer</code>
+ * object.
+ *
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ */
+ public static final ShortBuffer wrap (short[] array, int offset, int length)
+ {
+ return new ShortBufferImpl (array, 0, array.length, offset + length, offset, -1, false);
+ }
+
+ /**
+ * Wraps a <code>short</code> array into a <code>ShortBuffer</code>
+ * object.
+ */
+ public static final ShortBuffer wrap (short[] array)
+ {
+ return wrap (array, 0, array.length);
+ }
+
+ /**
+ * This method transfers <code>short</code>s from this buffer into the given
+ * destination array. Before the transfer, it checks if there are fewer than
+ * length <code>short</code>s remaining in this buffer.
+ *
+ * @param dst The destination array
+ * @param offset The offset within the array of the first <code>short</code>
+ * to be written; must be non-negative and no larger than dst.length.
+ * @param length The maximum number of bytes to be written to the given array;
+ * must be non-negative and no larger than dst.length - offset.
+ *
+ * @exception BufferUnderflowException If there are fewer than length
+ * <code>short</code>s remaining in this buffer.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold.
+ */
+ public ShortBuffer get (short[] dst, int offset, int length)
+ {
+ checkArraySize(dst.length, offset, length);
+ checkForUnderflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ {
+ dst [i] = get ();
+ }
+
+ return this;
+ }
+
+ /**
+ * This method transfers <code>short</code>s from this buffer into the given
+ * destination array.
+ *
+ * @param dst The byte array to write into.
+ *
+ * @exception BufferUnderflowException If there are fewer than dst.length
+ * <code>short</code>s remaining in this buffer.
+ */
+ public ShortBuffer get (short[] dst)
+ {
+ return get (dst, 0, dst.length);
+ }
+
+ /**
+ * Writes the content of the the <code>ShortBUFFER</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * <code>src.remaining()</code> space remaining in this buffer.
+ *
+ * @param src The source data.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>short</code>s in the source buffer.
+ * @exception IllegalArgumentException If the source buffer is this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public ShortBuffer put (ShortBuffer src)
+ {
+ if (src == this)
+ throw new IllegalArgumentException ();
+
+ checkForOverflow(src.remaining ());
+
+ if (src.remaining () > 0)
+ {
+ short[] toPut = new short [src.remaining ()];
+ src.get (toPut);
+ put (toPut);
+ }
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>short array</code> src
+ * into the buffer. Before the transfer, it checks if there is fewer than
+ * length space remaining in this buffer.
+ *
+ * @param src The array to copy into the buffer.
+ * @param offset The offset within the array of the first byte to be read;
+ * must be non-negative and no larger than src.length.
+ * @param length The number of bytes to be read from the given array;
+ * must be non-negative and no larger than src.length - offset.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>short</code>s in the source array.
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public ShortBuffer put (short[] src, int offset, int length)
+ {
+ checkArraySize(src.length, offset, length);
+ checkForOverflow(length);
+
+ for (int i = offset; i < offset + length; i++)
+ put (src [i]);
+
+ return this;
+ }
+
+ /**
+ * Writes the content of the the <code>short array</code> src
+ * into the buffer.
+ *
+ * @param src The array to copy into the buffer.
+ *
+ * @exception BufferOverflowException If there is insufficient space in this
+ * buffer for the remaining <code>short</code>s in the source array.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public final ShortBuffer put (short[] src)
+ {
+ return put (src, 0, src.length);
+ }
+
+ /**
+ * Tells whether ot not this buffer is backed by an accessible
+ * <code>short</code> array.
+ */
+ public final boolean hasArray ()
+ {
+ return (backing_buffer != null
+ && !isReadOnly ());
+ }
+
+ /**
+ * Returns the <code>short</code> array that backs this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final short[] array ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return backing_buffer;
+ }
+
+ /**
+ * Returns the offset within this buffer's backing array of the first element.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ * @exception UnsupportedOperationException If this buffer is not backed
+ * by an accessible array.
+ */
+ public final int arrayOffset ()
+ {
+ if (backing_buffer == null)
+ throw new UnsupportedOperationException ();
+
+ checkIfReadOnly();
+
+ return array_offset;
+ }
+
+ /**
+ * Calculates a hash code for this buffer.
+ *
+ * This is done with <code>int</code> arithmetic,
+ * where ** represents exponentiation, by this formula:<br>
+ * <code>s[position()] + 31 + (s[position()+1] + 30)*31**1 + ... +
+ * (s[limit()-1]+30)*31**(limit()-1)</code>.
+ * Where s is the buffer data. Note that the hashcode is dependent
+ * on buffer content, and therefore is not useful if the buffer
+ * content may change.
+ *
+ * @return the hash code
+ */
+ public int hashCode ()
+ {
+ int hashCode = get(position()) + 31;
+ int multiplier = 1;
+ for (int i = position() + 1; i < limit(); ++i)
+ {
+ multiplier *= 31;
+ hashCode += (get(i) + 30)*multiplier;
+ }
+ return hashCode;
+ }
+
+ /**
+ * Checks if this buffer is equal to obj.
+ */
+ public boolean equals (Object obj)
+ {
+ if (obj instanceof ShortBuffer)
+ {
+ return compareTo (obj) == 0;
+ }
+
+ return false;
+ }
+
+ /**
+ * Compares two <code>ShortBuffer</code> objects.
+ *
+ * @exception ClassCastException If obj is not an object derived from
+ * <code>ShortBuffer</code>.
+ */
+ public int compareTo (Object obj)
+ {
+ ShortBuffer other = (ShortBuffer) obj;
+
+ int num = Math.min(remaining(), other.remaining());
+ int pos_this = position();
+ int pos_other = other.position();
+
+ for (int count = 0; count < num; count++)
+ {
+ short a = get(pos_this++);
+ short b = other.get(pos_other++);
+
+ if (a == b)
+ continue;
+
+ if (a < b)
+ return -1;
+
+ return 1;
+ }
+
+ return remaining() - other.remaining();
+ }
+
+ /**
+ * Returns the byte order of this buffer.
+ */
+ public abstract ByteOrder order ();
+
+ /**
+ * Reads the <code>short</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>short</code>s in this buffer.
+ */
+ public abstract short get ();
+
+ /**
+ * Writes the <code>short</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferOverflowException If there no remaining
+ * <code>short</code>s in this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract ShortBuffer put (short b);
+
+ /**
+ * Absolute get method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public abstract short get (int index);
+
+ /**
+ * Absolute put method.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract ShortBuffer put (int index, short b);
+
+ /**
+ * Compacts this buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public abstract ShortBuffer compact ();
+
+ /**
+ * Tells wether or not this buffer is direct.
+ */
+ public abstract boolean isDirect ();
+
+ /**
+ * Creates a new <code>ShortBuffer</code> whose content is a shared
+ * subsequence of this buffer's content.
+ */
+ public abstract ShortBuffer slice ();
+
+ /**
+ * Creates a new <code>ShortBuffer</code> that shares this buffer's
+ * content.
+ */
+ public abstract ShortBuffer duplicate ();
+
+ /**
+ * Creates a new read-only <code>ShortBuffer</code> that shares this
+ * buffer's content.
+ */
+ public abstract ShortBuffer asReadOnlyBuffer ();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ShortBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ShortBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ShortBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ShortBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,171 @@
+/* ShortBufferImpl.java --
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * This is a Heap memory implementation
+ */
+final class ShortBufferImpl extends ShortBuffer
+{
+ private boolean readOnly;
+
+ ShortBufferImpl (int capacity)
+ {
+ this (new short [capacity], 0, capacity, capacity, 0, -1, false);
+ }
+
+ ShortBufferImpl (short[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
+ {
+ super (capacity, limit, position, mark);
+ this.backing_buffer = buffer;
+ this.array_offset = offset;
+ this.readOnly = readOnly;
+ }
+
+ public boolean isReadOnly ()
+ {
+ return readOnly;
+ }
+
+ public ShortBuffer slice ()
+ {
+ return new ShortBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
+ }
+
+ public ShortBuffer duplicate ()
+ {
+ return new ShortBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
+ }
+
+ public ShortBuffer asReadOnlyBuffer ()
+ {
+ return new ShortBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
+ }
+
+ public ShortBuffer compact ()
+ {
+ checkIfReadOnly();
+ mark = -1;
+ int p = position();
+ int n = limit() - p;
+ if (n > 0)
+ {
+ System.arraycopy(backing_buffer, array_offset + p,
+ backing_buffer, array_offset, n);
+ }
+ position(n);
+ limit(capacity());
+ return this;
+ }
+
+ public boolean isDirect ()
+ {
+ return false;
+ }
+
+ /**
+ * Reads the <code>short</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>short</code>s in this buffer.
+ */
+ public short get ()
+ {
+ checkForUnderflow();
+
+ short result = backing_buffer [position ()];
+ position (position () + 1);
+ return result;
+ }
+
+ /**
+ * Relative put method. Writes <code>value</code> to the next position
+ * in the buffer.
+ *
+ * @exception BufferOverflowException If there no remaining
+ * space in this buffer.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public ShortBuffer put (short value)
+ {
+ checkIfReadOnly();
+ checkForOverflow();
+
+ backing_buffer [position ()] = value;
+ position (position () + 1);
+ return this;
+ }
+
+ /**
+ * Absolute get method. Reads the <code>short</code> at position
+ * <code>index</code>.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public short get (int index)
+ {
+ checkIndex(index);
+
+ return backing_buffer [index];
+ }
+
+ /**
+ * Absolute put method. Writes <code>value</code> to position
+ * <code>index</code> in the buffer.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ public ShortBuffer put (int index, short value)
+ {
+ checkIfReadOnly();
+ checkIndex(index);
+
+ backing_buffer [index] = value;
+ return this;
+ }
+
+ public ByteOrder order ()
+ {
+ return ByteOrder.nativeOrder ();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ShortViewBufferImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ShortViewBufferImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ShortViewBufferImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/ShortViewBufferImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,173 @@
+/* ShortViewBufferImpl.java --
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+final class ShortViewBufferImpl extends ShortBuffer
+{
+ /** Position in bb (i.e. a byte offset) where this buffer starts. */
+ private int offset;
+ private ByteBuffer bb;
+ private boolean readOnly;
+ private ByteOrder endian;
+
+ ShortViewBufferImpl (ByteBuffer bb, int capacity)
+ {
+ super (capacity, capacity, 0, -1);
+ this.bb = bb;
+ this.offset = bb.position();
+ this.readOnly = bb.isReadOnly();
+ this.endian = bb.order();
+ if (bb.isDirect())
+ this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
+ }
+
+ public ShortViewBufferImpl (ByteBuffer bb, int offset, int capacity,
+ int limit, int position, int mark,
+ boolean readOnly, ByteOrder endian)
+ {
+ super (capacity, limit, position, mark);
+ this.bb = bb;
+ this.offset = offset;
+ this.readOnly = readOnly;
+ this.endian = endian;
+ if (bb.isDirect())
+ this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
+ }
+
+ /**
+ * Reads the <code>short</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>short</code>s in this buffer.
+ */
+ public short get ()
+ {
+ int p = position();
+ short result = ByteBufferHelper.getShort(bb, (p << 1) + offset, endian);
+ position(p + 1);
+ return result;
+ }
+
+ /**
+ * Absolute get method. Reads the <code>short</code> at position
+ * <code>index</code>.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ public short get (int index)
+ {
+ return ByteBufferHelper.getShort(bb, (index << 1) + offset, endian);
+ }
+
+ public ShortBuffer put (short value)
+ {
+ int p = position();
+ ByteBufferHelper.putShort(bb, (p << 1) + offset, value, endian);
+ position(p + 1);
+ return this;
+ }
+
+ public ShortBuffer put (int index, short value)
+ {
+ ByteBufferHelper.putShort(bb, (index << 1) + offset, value, endian);
+ return this;
+ }
+
+ public ShortBuffer compact ()
+ {
+ if (position () > 0)
+ {
+ int count = limit () - position ();
+ bb.shiftDown(offset, offset + 2 * position(), 2 * count);
+ position (count);
+ limit (capacity ());
+ }
+ else
+ {
+ position(limit());
+ limit(capacity());
+ }
+ return this;
+ }
+
+ public ShortBuffer slice ()
+ {
+ // Create a sliced copy of this object that shares its content.
+ return new ShortViewBufferImpl (bb, (position () >> 1) + offset,
+ remaining(), remaining(), 0, -1,
+ readOnly, endian);
+ }
+
+ ShortBuffer duplicate (boolean readOnly)
+ {
+ int pos = position();
+ reset();
+ int mark = position();
+ position(pos);
+ return new ShortViewBufferImpl (bb, offset, capacity(), limit(),
+ pos, mark, readOnly, endian);
+ }
+
+ public ShortBuffer duplicate ()
+ {
+ return duplicate(readOnly);
+ }
+
+ public ShortBuffer asReadOnlyBuffer ()
+ {
+ return duplicate(true);
+ }
+
+ public boolean isReadOnly ()
+ {
+ return readOnly;
+ }
+
+ public boolean isDirect ()
+ {
+ return bb.isDirect ();
+ }
+
+ public ByteOrder order ()
+ {
+ return endian;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/AlreadyConnectedException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/AlreadyConnectedException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/AlreadyConnectedException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/AlreadyConnectedException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,50 @@
+/* AlreadyConnectedException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+public class AlreadyConnectedException extends IllegalStateException
+{
+ private static final long serialVersionUID = - 7331895245053773357L;
+
+ /**
+ * Creates the exception
+ */
+ public AlreadyConnectedException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/AsynchronousCloseException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/AsynchronousCloseException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/AsynchronousCloseException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/AsynchronousCloseException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* AsynchronousCloseException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class AsynchronousCloseException extends ClosedChannelException
+{
+ private static final long serialVersionUID = 6891178312432313966L;
+
+ /**
+ * Creates the exception
+ */
+ public AsynchronousCloseException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ByteChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ByteChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ByteChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ByteChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,43 @@
+/* ByteChannel.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+public interface ByteChannel extends ReadableByteChannel,
+ WritableByteChannel
+{
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/CancelledKeyException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/CancelledKeyException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/CancelledKeyException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/CancelledKeyException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* CancelledKeyException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class CancelledKeyException extends IllegalStateException
+{
+ private static final long serialVersionUID = - 8438032138028814268L;
+
+ /**
+ * Creates the exception
+ */
+ public CancelledKeyException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Channel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Channel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Channel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Channel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* Channel.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio.channels;
+
+import java.io.IOException;
+
+public interface Channel
+{
+ /**
+ * Tells whether this channel is open or not
+ *
+ * @return <code>true</code>if channel is open,
+ * <code>false</code> otherwise
+ */
+ boolean isOpen();
+
+ /**
+ * Closes this channel
+ *
+ * @exception IOException If an error occurs
+ */
+ void close() throws IOException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Channels.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Channels.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Channels.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Channels.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,144 @@
+/* Channels.java --
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio.channels;
+
+import gnu.java.nio.ChannelReader;
+import gnu.java.nio.ChannelWriter;
+import gnu.java.nio.InputStreamChannel;
+import gnu.java.nio.OutputStreamChannel;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.UnsupportedCharsetException;
+
+
+/**
+ * @since 1.4
+ */
+public final class Channels
+{
+ /**
+ * This class isn't intended to be instantiated.
+ */
+ private Channels()
+ {
+ // Do nothing here.
+ }
+
+ /**
+ * Constructs a stream that reads bytes from the given channel.
+ */
+ public static InputStream newInputStream(ReadableByteChannel ch)
+ {
+ return VMChannels.newInputStream(ch);
+ }
+
+ /**
+ * Constructs a stream that writes bytes to the given channel.
+ */
+ public static OutputStream newOutputStream(WritableByteChannel ch)
+ {
+ return VMChannels.newOutputStream(ch);
+ }
+
+ /**
+ * Constructs a channel that reads bytes from the given stream.
+ */
+ public static ReadableByteChannel newChannel(InputStream in)
+ {
+ return new InputStreamChannel(in);
+ }
+
+ /**
+ * Constructs a channel that writes bytes to the given stream.
+ */
+ public static WritableByteChannel newChannel(OutputStream out)
+ {
+ return new OutputStreamChannel(out);
+ }
+
+ /**
+ * Constructs a reader that decodes bytes from the given channel using the
+ * given decoder.
+ */
+ public static Reader newReader(ReadableByteChannel ch, CharsetDecoder dec,
+ int minBufferCap)
+ {
+ return new ChannelReader(ch, dec, minBufferCap);
+ }
+
+ /**
+ * Constructs a reader that decodes bytes from the given channel according to
+ * the named charset.
+ *
+ * @exception UnsupportedCharsetException If no support for the named charset
+ * is available in this instance of the Java virtual machine.
+ */
+ public static Reader newReader(ReadableByteChannel ch, String csName)
+ {
+ return newReader(ch, Charset.forName(csName).newDecoder(), -1);
+ }
+
+ /**
+ * Constructs a writer that encodes characters using the given encoder and
+ * writes the resulting bytes to the given channel.
+ */
+ public static Writer newWriter(WritableByteChannel ch, CharsetEncoder enc,
+ int minBufferCap)
+ {
+ return new ChannelWriter(ch, enc, minBufferCap);
+ }
+
+ /**
+ * Constructs a writer that encodes characters according to the named charset
+ * and writes the resulting bytes to the given channel.
+ *
+ * @exception UnsupportedCharsetException If no support for the named charset
+ * is available in this instance of the Java virtual machine.
+ */
+ public static Writer newWriter(WritableByteChannel ch, String csName)
+ {
+ return newWriter(ch, Charset.forName(csName).newEncoder(), -1);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ClosedByInterruptException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ClosedByInterruptException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ClosedByInterruptException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ClosedByInterruptException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* ClosedByInterruptException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class ClosedByInterruptException extends AsynchronousCloseException
+{
+ private static final long serialVersionUID = - 4488191543534286750L;
+
+ /**
+ * Creates the exception
+ */
+ public ClosedByInterruptException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ClosedChannelException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ClosedChannelException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ClosedChannelException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ClosedChannelException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* ClosedChannelException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class ClosedChannelException extends IOException
+{
+ private static final long serialVersionUID = 882777185433553857L;
+
+ /**
+ * Creates the exception
+ */
+ public ClosedChannelException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ClosedSelectorException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ClosedSelectorException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ClosedSelectorException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ClosedSelectorException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* ClosedSelectorException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class ClosedSelectorException extends IllegalStateException
+{
+ private static final long serialVersionUID = 6466297122317847835L;
+
+ /**
+ * Creates the exception
+ */
+ public ClosedSelectorException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ConnectionPendingException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ConnectionPendingException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ConnectionPendingException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ConnectionPendingException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* ConnectionPendingException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class ConnectionPendingException extends IllegalStateException
+{
+ private static final long serialVersionUID = 2008393366501760879L;
+
+ /**
+ * Creates the exception
+ */
+ public ConnectionPendingException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/DatagramChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/DatagramChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/DatagramChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/DatagramChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,208 @@
+/* DatagramChannel.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+import java.net.DatagramSocket;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.channels.spi.AbstractSelectableChannel;
+import java.nio.channels.spi.SelectorProvider;
+
+
+/**
+ * @since 1.4
+ */
+public abstract class DatagramChannel extends AbstractSelectableChannel
+ implements ByteChannel, ScatteringByteChannel, GatheringByteChannel
+{
+ /**
+ * Initializes the channel.
+ */
+ protected DatagramChannel(SelectorProvider provider)
+ {
+ super(provider);
+ }
+
+ /**
+ * Opens a datagram channel.
+ *
+ * @exception IOException If an error occurs
+ */
+ public static DatagramChannel open() throws IOException
+ {
+ return SelectorProvider.provider().openDatagramChannel();
+ }
+
+ /**
+ * Reads data from this channel.
+ */
+ public final long read(ByteBuffer[] dsts) throws IOException
+ {
+ long b = 0;
+
+ for (int i = 0; i < dsts.length; i++)
+ b += read(dsts[i]);
+
+ return b;
+ }
+
+ /**
+ * Writes data to this channel.
+ *
+ * @exception IOException If an error occurs
+ * @exception NotYetConnectedException The channel's socket is not connected.
+ */
+ public final long write(ByteBuffer[] srcs) throws IOException
+ {
+ long b = 0;
+
+ for (int i = 0; i < srcs.length; i++)
+ b += write(srcs[i]);
+
+ return b;
+ }
+
+ /**
+ * Connects this channel's socket.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the connect operation is in progress.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the read operation is in progress, thereby closing the
+ * channel and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IOException If an error occurs.
+ * @exception SecurityException If a security manager has been installed and
+ * it does not permit datagrams to be sent to the given address.
+ */
+ public abstract DatagramChannel connect(SocketAddress remote)
+ throws IOException;
+
+ /**
+ * Disonnects this channel's socket.
+ *
+ * @exception IOException If an error occurs
+ */
+ public abstract DatagramChannel disconnect() throws IOException;
+
+ /**
+ * Tells whether or not this channel's socket is connected.
+ *
+ * @exception NotYetConnectedException The channel's socket is not connected.
+ */
+ public abstract boolean isConnected();
+
+ /**
+ * Reads data from this channel.
+ */
+ public abstract int read(ByteBuffer dst) throws IOException;
+
+ /**
+ * Reads data from this channel.
+ *
+ * @exception IOException If an error occurs.
+ * @exception NotYetConnectedException The channel's socket is not connected.
+ */
+ public abstract long read(ByteBuffer[] dsts, int offset, int length)
+ throws IOException;
+
+ /**
+ * Receives a datagram via this channel.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the connect operation is in progress.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the read operation is in progress, thereby closing the
+ * channel and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IOException If an error occurs
+ * @exception SecurityException If a security manager has been installed and
+ * it does not permit datagrams to be sent to the given address.
+ */
+ public abstract SocketAddress receive(ByteBuffer dst)
+ throws IOException;
+
+ /**
+ * Sends a datagram via this channel.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the connect operation is in progress.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the read operation is in progress, thereby closing the
+ * channel and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IOException If an error occurs
+ * @exception SecurityException If a security manager has been installed and
+ * it does not permit datagrams to be sent to the given address.
+ */
+ public abstract int send(ByteBuffer src, SocketAddress target)
+ throws IOException;
+
+ /**
+ * Retrieves the channel's socket.
+ */
+ public abstract DatagramSocket socket();
+
+ /**
+ * Writes data to this channel.
+ *
+ * @exception IOException If an error occurs.
+ * @exception NotYetConnectedException The channel's socket is not connected.
+ */
+ public abstract int write(ByteBuffer src) throws IOException;
+
+ /**
+ * Writes data to this channel.
+ *
+ * @exception IOException If an error occurs.
+ * @exception NotYetConnectedException The channel's socket is not connected.
+ */
+ public abstract long write(ByteBuffer[] srcs, int offset, int length)
+ throws IOException;
+
+ /**
+ * Retrieves the valid operations for this channel.
+ *
+ * @exception NotYetConnectedException The channel's socket is not connected.
+ */
+ public final int validOps()
+ {
+ return SelectionKey.OP_READ | SelectionKey.OP_WRITE;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/FileChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/FileChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/FileChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/FileChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,357 @@
+/* FileChannel.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.spi.AbstractInterruptibleChannel;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public abstract class FileChannel extends AbstractInterruptibleChannel
+ implements ByteChannel, GatheringByteChannel, ScatteringByteChannel
+{
+ public static class MapMode
+ {
+ int m;
+ public static final MapMode READ_ONLY = new MapMode(0);
+ public static final MapMode READ_WRITE = new MapMode(1);
+ public static final MapMode PRIVATE = new MapMode(2);
+
+ /**
+ * Initializes the MapMode.
+ */
+ MapMode(int a)
+ {
+ m = a;
+ }
+
+ /**
+ * Returns a string representation of the <code>MapMode</code> object.
+ */
+ public String toString()
+ {
+ if (this == READ_ONLY)
+ return "READ_ONLY";
+ else if (this == READ_WRITE)
+ return "READ_WRITE";
+
+ return "PRIVATE";
+ }
+ }
+
+ /**
+ * Initializes the channel.
+ */
+ protected FileChannel()
+ {
+ }
+
+ /**
+ * Maps the file into the memory.
+ *
+ * @exception IllegalArgumentException If the preconditions on the parameters
+ * do not hold.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonReadableChannelException If mode is READ_ONLY but this channel was
+ * not opened for reading.
+ * @exception NonWritableChannelException If mode is READ_WRITE or PRIVATE but this
+ * channel was not opened for writing.
+ */
+ public abstract MappedByteBuffer map(MapMode mode, long position, long size)
+ throws IOException;
+
+ /**
+ * Return the size of the file thus far
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ */
+ public abstract long size() throws IOException;
+
+ /**
+ * Writes data to the channel.
+ *
+ * @exception IOException If an I/O error occurs.
+ */
+ public final long write(ByteBuffer[] srcs) throws IOException
+ {
+ return write(srcs, 0, srcs.length);
+ }
+
+ /**
+ * Writes data to the channel.
+ *
+ * @exception IOException If an I/O error occurs.
+ */
+ public abstract int write(ByteBuffer src) throws IOException;
+
+ /**
+ * Writes data to the channel.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the transfer is in progress.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the transfer is in progress, thereby closing both
+ * channels and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If position is negative.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonWritableChannelException If this channel was not opened for
+ * writing.
+ */
+ public abstract int write(ByteBuffer srcs, long position)
+ throws IOException;
+
+ /**
+ * Writes data to the channel.
+ *
+ * @exception IOException If an I/O error occurs.
+ */
+ public abstract long write(ByteBuffer[] srcs, int offset, int length)
+ throws IOException;
+
+ /**
+ * Reads data from the channel.
+ *
+ * @exception IOException If an I/O error occurs.
+ */
+ public abstract long read(ByteBuffer[] dsts, int offset, int length)
+ throws IOException;
+
+ /**
+ * Reads data from the channel.
+ *
+ * @exception IOException If an I/O error occurs.
+ */
+ public final long read(ByteBuffer[] dsts) throws IOException
+ {
+ return read(dsts, 0, dsts.length);
+ }
+
+ /**
+ * Reads data from the channel.
+ *
+ * @exception IOException If an I/O error occurs.
+ */
+ public abstract int read(ByteBuffer dst) throws IOException;
+
+ /**
+ * Reads data from the channel.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the transfer is in progress.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the transfer is in progress, thereby closing both
+ * channels and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If position is negative.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonReadableChannelException If this channel was not opened for
+ * reading.
+ */
+ public abstract int read(ByteBuffer dst, long position)
+ throws IOException;
+
+ /**
+ * Closes the channel.
+ *
+ * This is called from @see close.
+ *
+ * @exception IOException If an I/O error occurs.
+ */
+ protected abstract void implCloseChannel() throws IOException;
+
+ /**
+ * msync with the disk
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IOException If an I/O error occurs.
+ */
+ public abstract void force(boolean metaData) throws IOException;
+
+ /**
+ * Creates a file lock for the whole associated file.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the transfer is in progress.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception FileLockInterruptionException If the invoking thread is
+ * interrupted while blocked in this method.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonReadableChannelException If shared is true and this channel
+ * was not opened for reading.
+ * @exception NonWritableChannelException If shared is false and this channel
+ * was not opened for writing.
+ * @exception OverlappingFileLockException If a lock that overlaps the
+ * requested region is already held by this Java virtual machine, or if
+ * another thread is already blocked in this method and is attempting to lock
+ * an overlapping region.
+ */
+ public final FileLock lock() throws IOException
+ {
+ return lock(0, Long.MAX_VALUE, false);
+ }
+
+ /**
+ * Creates a file lock for a region of the associated file.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the transfer is in progress.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception FileLockInterruptionException If the invoking thread is
+ * interrupted while blocked in this method.
+ * @exception IllegalArgumentException If the preconditions on the parameters
+ * do not hold.
+ * @exception IOException If an I/O error occurs.
+ * @exception OverlappingFileLockException If a lock that overlaps the
+ * requested region is already held by this Java virtual machine, or if
+ * another thread is already blocked in this method and is attempting to lock
+ * an overlapping region.
+ * @exception NonReadableChannelException If shared is true and this channel
+ * was not opened for reading.
+ * @exception NonWritableChannelException If shared is false and this channel
+ * was not opened for writing.
+ */
+ public abstract FileLock lock(long position, long size, boolean shared)
+ throws IOException;
+
+ /**
+ * Tries to aqquire alock on the whole associated file.
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IOException If an I/O error occurs.
+ * @exception OverlappingFileLockException If a lock that overlaps the
+ * requested region is already held by this Java virtual machine, or if
+ * another thread is already blocked in this method and is attempting to lock
+ * an overlapping region.
+ */
+ public final FileLock tryLock() throws IOException
+ {
+ return tryLock(0, Long.MAX_VALUE, false);
+ }
+
+ /**
+ * Tries to aqquire a lock on a region of the associated file.
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If the preconditions on the parameters
+ * do not hold.
+ * @exception IOException If an I/O error occurs.
+ * @exception OverlappingFileLockException If a lock that overlaps the
+ * requested region is already held by this Java virtual machine, or if
+ * another thread is already blocked in this method and is attempting to lock
+ * an overlapping region.
+ */
+ public abstract FileLock tryLock(long position, long size, boolean shared)
+ throws IOException;
+
+ /**
+ * Returns the current position on the file.
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IOException If an I/O error occurs.
+ */
+ public abstract long position() throws IOException;
+
+ /**
+ * Sets the position of the channel on the assoziated file.
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If newPosition is negative.
+ * @exception IOException If an I/O error occurs.
+ */
+ public abstract FileChannel position(long newPosition)
+ throws IOException;
+
+ /**
+ * Transfers bytes from this channel's file to the given writable byte
+ * channel.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the transfer is in progress.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the transfer is in progress, thereby closing both
+ * channels and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If the preconditions on the parameters
+ * do not hold.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonReadableChannelException If this channel was not opened for
+ * reading.
+ * @exception NonWritableChannelException If the target channel was not
+ * opened for writing.
+ */
+ public abstract long transferTo(long position, long count,
+ WritableByteChannel target)
+ throws IOException;
+
+ /**
+ * Transfers bytes from the given readable channel into this channel.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the transfer is in progress.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the transfer is in progress, thereby closing both
+ * channels and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If the preconditions on the parameters
+ * do not hold.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonReadableChannelException If the source channel was not
+ * opened for reading.
+ * @exception NonWritableChannelException If this channel was not opened for
+ * writing.
+ */
+ public abstract long transferFrom(ReadableByteChannel src, long position,
+ long count) throws IOException;
+
+ /**
+ * Truncates the channel's file at <code>size</code>.
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If size is negative.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonWritableChannelException If this channel was not opened for
+ * writing.
+ */
+ public abstract FileChannel truncate(long size) throws IOException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/FileLock.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/FileLock.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/FileLock.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/FileLock.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,150 @@
+/* FileLock.java --
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+
+
+/**
+ * @since 1.4
+ */
+public abstract class FileLock
+{
+ private final FileChannel channel;
+ private final long position;
+ private final long size;
+ private final boolean shared;
+
+ /**
+ * Initializes the file lock.
+ *
+ * @exception IllegalArgumentException If the preconditions on the parameters do not hold
+ */
+ protected FileLock(FileChannel channel, long position, long size,
+ boolean shared)
+ {
+ if (position < 0 || size < 0)
+ throw new IllegalArgumentException();
+
+ this.channel = channel;
+ this.position = position;
+ this.size = size;
+ this.shared = shared;
+ }
+
+ /**
+ * Tells whether or not this lock is valid.
+ */
+ public abstract boolean isValid();
+
+ /**
+ * Releases this lock.
+ *
+ * @exception IOException If an error occurs
+ * @exception ClosedChannelException If the locked channel is no longer open.
+ */
+ public abstract void release() throws IOException;
+
+ /**
+ * Returns the file channel upon whose file this lock is held.
+ */
+ public final FileChannel channel()
+ {
+ return channel;
+ }
+
+ /**
+ * Tells whether this lock is shared.
+ */
+ public final boolean isShared()
+ {
+ return shared;
+ }
+
+ /**
+ * Tells whether or not this lock overlaps the given lock range.
+ */
+ public final boolean overlaps(long position, long size)
+ {
+ if (position > this.position + this.size)
+ return false;
+
+ if (position + size < this.position)
+ return false;
+
+ return true;
+ }
+
+ /**
+ * Returns the position within the file of the first byte of the
+ * locked region.
+ */
+ public final long position()
+ {
+ return position;
+ }
+
+ /**
+ * Returns the size of the locked region in bytes.
+ */
+ public final long size()
+ {
+ return size;
+ }
+
+ /**
+ * Returns a string describing the range, type, and validity of this lock.
+ */
+ public final String toString()
+ {
+ StringBuffer buf = new StringBuffer(getClass().getName());
+ buf.append("[");
+ buf.append(position);
+ buf.append(":");
+ buf.append(size);
+ if (shared)
+ buf.append(" shared");
+ else
+ buf.append(" exclusive");
+ if (isValid())
+ buf.append(" valid]");
+ else
+ buf.append(" invalid]");
+ return buf.toString();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/FileLockInterruptionException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/FileLockInterruptionException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/FileLockInterruptionException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/FileLockInterruptionException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* FileLockInterruptionException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class FileLockInterruptionException extends IOException
+{
+ private static final long serialVersionUID = 7104080643653532383L;
+
+ /**
+ * Creates the exception
+ */
+ public FileLockInterruptionException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/GatheringByteChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/GatheringByteChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/GatheringByteChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/GatheringByteChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* GatheringByteChannel.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+
+public interface GatheringByteChannel extends WritableByteChannel
+{
+ /**
+ * Writes a sequence of bytes to this channel from a subsequence of
+ * the given buffers
+ *
+ * @exception AsynchronousCloseException If another thread closes this
+ * channel while the write operation is in progress
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the write operation is in progress, thereby closing
+ * the channel and setting the current thread's interrupt status
+ * @exception ClosedChannelException If this channel is closed
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ * @exception IOException If an error occurs
+ * @exception NonWritableChannelException If this channel was not opened for
+ * writing
+ */
+ long write(ByteBuffer[] srcs, int offset, int length)
+ throws IOException;
+
+ /**
+ * Writes a sequence of bytes to this channel from the given buffers
+ *
+ * @exception AsynchronousCloseException If another thread closes this
+ * channel while the write operation is in progress
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the write operation is in progress, thereby closing
+ * the channel and setting the current thread's interrupt status
+ * @exception ClosedChannelException If this channel is closed
+ * @exception IOException If an error occurs
+ * @exception NonWritableChannelException If this channel was not opened for
+ * writing
+ */
+ long write(ByteBuffer[] srcs) throws IOException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/IllegalBlockingModeException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/IllegalBlockingModeException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/IllegalBlockingModeException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/IllegalBlockingModeException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* IllegalBlockingModeException.java --
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ * @since 1.4
+ *
+ * Written using JDK 1.4.1 Online API from Sun
+ * Status: JDK 1.4 complete
+ */
+public class IllegalBlockingModeException extends IllegalStateException
+{
+ private static final long serialVersionUID = - 3335774961855590474L;
+
+ /**
+ * Creates the exception
+ */
+ public IllegalBlockingModeException()
+ {
+ super();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/IllegalSelectorException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/IllegalSelectorException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/IllegalSelectorException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/IllegalSelectorException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* IllegalSelectorException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class IllegalSelectorException extends IllegalArgumentException
+{
+ private static final long serialVersionUID = - 8406323347253320987L;
+
+ /**
+ * Creates the exception
+ */
+ public IllegalSelectorException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/InterruptibleChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/InterruptibleChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/InterruptibleChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/InterruptibleChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,51 @@
+/* InterruptibleChannel.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+
+
+public interface InterruptibleChannel extends Channel
+{
+ /**
+ * Closes this channel
+ *
+ * @exception IOException If an error occurs
+ */
+ void close() throws IOException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NoConnectionPendingException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NoConnectionPendingException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NoConnectionPendingException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NoConnectionPendingException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* NoConnectionPendingException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class NoConnectionPendingException extends IllegalStateException
+{
+ private static final long serialVersionUID = - 8296561183633134743L;
+
+ /**
+ * Creates the exception
+ */
+ public NoConnectionPendingException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NonReadableChannelException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NonReadableChannelException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NonReadableChannelException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NonReadableChannelException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* NonReadableChannelException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class NonReadableChannelException extends IllegalStateException
+{
+ private static final long serialVersionUID = - 3200915679294993514L;
+
+ /**
+ * Creates the exception
+ */
+ public NonReadableChannelException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NonWritableChannelException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NonWritableChannelException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NonWritableChannelException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NonWritableChannelException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* NonWritableChannelException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class NonWritableChannelException extends IllegalStateException
+{
+ private static final long serialVersionUID = - 7071230488279011621L;
+
+ /**
+ * Creates the exception
+ */
+ public NonWritableChannelException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NotYetBoundException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NotYetBoundException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NotYetBoundException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NotYetBoundException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* NotYetBoundException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class NotYetBoundException extends IllegalStateException
+{
+ private static final long serialVersionUID = 4640999303950202242L;
+
+ /**
+ * Creates the exception
+ */
+ public NotYetBoundException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NotYetConnectedException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NotYetConnectedException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NotYetConnectedException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/NotYetConnectedException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* NotYetConnectedException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class NotYetConnectedException extends IllegalStateException
+{
+ private static final long serialVersionUID = 4697316551909513464L;
+
+ /**
+ * Creates the exception
+ */
+ public NotYetConnectedException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/OverlappingFileLockException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/OverlappingFileLockException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/OverlappingFileLockException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/OverlappingFileLockException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* OverlappingFileLockException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class OverlappingFileLockException extends IllegalStateException
+{
+ private static final long serialVersionUID = 2047812138163068433L;
+
+ /**
+ * Creates the exception
+ */
+ public OverlappingFileLockException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Pipe.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Pipe.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Pipe.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Pipe.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,121 @@
+/* Pipe.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+import java.nio.channels.spi.AbstractSelectableChannel;
+import java.nio.channels.spi.SelectorProvider;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public abstract class Pipe
+{
+ public abstract static class SinkChannel extends AbstractSelectableChannel
+ implements WritableByteChannel, GatheringByteChannel
+ {
+ /**
+ * Initializes the channel.
+ */
+ protected SinkChannel(SelectorProvider provider)
+ {
+ super(provider);
+ }
+
+ /**
+ * Returns an operation set that is valid on this channel.
+ *
+ * The only valid operation on this channel is @see SelectionKey.OP_WRITE.
+ */
+ public final int validOps()
+ {
+ return SelectionKey.OP_WRITE;
+ }
+ }
+
+ public abstract static class SourceChannel extends AbstractSelectableChannel
+ implements ReadableByteChannel, ScatteringByteChannel
+ {
+ /**
+ * Initializes the channel.
+ */
+ protected SourceChannel(SelectorProvider provider)
+ {
+ super(provider);
+ }
+
+ /**
+ * Returns an operation set that is valid on this channel.
+ *
+ * The only valid operation on this channel is @see SelectionKey.OP_READ.
+ */
+ public final int validOps()
+ {
+ return SelectionKey.OP_READ;
+ }
+ }
+
+ /**
+ * Initializes the pipe.
+ */
+ protected Pipe()
+ {
+ }
+
+ /**
+ * Opens a pipe.
+ *
+ * @exception IOException If an error occurs
+ */
+ public static Pipe open() throws IOException
+ {
+ return SelectorProvider.provider().openPipe();
+ }
+
+ /**
+ * Returns a pipe's sink channel.
+ */
+ public abstract Pipe.SinkChannel sink();
+
+ /**
+ * Returns a pipe's source channel
+ */
+ public abstract Pipe.SourceChannel source();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ReadableByteChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ReadableByteChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ReadableByteChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ReadableByteChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,64 @@
+/* ReadableByteChannel.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+
+public interface ReadableByteChannel extends Channel
+{
+ /**
+ * Reads a sequence of bytes from this channel into the given buffer
+ *
+ * @param dst the buffer to put the read data into
+ *
+ * @return the numer of bytes read
+ *
+ * @exception AsynchronousCloseException If another thread closes this
+ * channel while the read operation is in progress
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the read operation is in progress, thereby closing
+ * the channel and setting the current thread's interrupt status
+ * @exception ClosedChannelException If this channel is closed
+ * @exception IOException If an error occurs
+ * @exception NonReadableChannelException If this channel was not opened for
+ * reading
+ */
+ int read(ByteBuffer dst) throws IOException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ScatteringByteChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ScatteringByteChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ScatteringByteChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ScatteringByteChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* ScatteringByteChannel.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+
+public interface ScatteringByteChannel extends ReadableByteChannel
+{
+ /**
+ * Reads a sequence of bytes from this channel into a subsequence of the
+ * given buffers
+ *
+ * @exception AsynchronousCloseException If another thread closes this
+ * channel while the write operation is in progress
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the write operation is in progress, thereby closing
+ * the channel and setting the current thread's interrupt status
+ * @exception ClosedChannelException If this channel is closed
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ * @exception IOException If an error occurs
+ * @exception NonReadableChannelException If this channel was not opened for
+ * reading
+ */
+ long read(ByteBuffer[] srcs, int offset, int length)
+ throws IOException;
+
+ /**
+ * Reads a sequence of bytes from this channel into the given buffers
+ *
+ * @exception AsynchronousCloseException If another thread closes this
+ * channel while the write operation is in progress
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the write operation is in progress, thereby closing
+ * the channel and setting the current thread's interrupt status
+ * @exception ClosedChannelException If this channel is closed
+ * @exception IOException If an error occurs
+ * @exception NonReadableChannelException If this channel was not opened for
+ * reading
+ */
+ long read(ByteBuffer[] srcs) throws IOException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/SelectableChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/SelectableChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/SelectableChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/SelectableChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,140 @@
+/* SelectableChannel.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+import java.nio.channels.spi.AbstractInterruptibleChannel;
+import java.nio.channels.spi.SelectorProvider;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public abstract class SelectableChannel extends AbstractInterruptibleChannel
+{
+ /**
+ * Initializes the channel.
+ */
+ protected SelectableChannel()
+ {
+ }
+
+ /**
+ * Returns the lock of this channel.
+ */
+ public abstract Object blockingLock();
+
+ /**
+ * Adjusts this channel's blocking mode.
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalBlockingModeException If block is true and this channel
+ * is registered with one or more selectors.
+ * @exception IOException If an error occurs.
+ */
+ public abstract SelectableChannel configureBlocking(boolean block)
+ throws IOException;
+
+ /**
+ * Tells whether this channel is blocking or not.
+ */
+ public abstract boolean isBlocking();
+
+ /**
+ * Tells whether or not this channel is currently registered with
+ * any selectors.
+ */
+ public abstract boolean isRegistered();
+
+ /**
+ * Retrieves the key representing the channel's registration with
+ * the given selector.
+ */
+ public abstract SelectionKey keyFor(Selector sel);
+
+ /**
+ * Returns the provider that created this channel.
+ */
+ public abstract SelectorProvider provider();
+
+ /**
+ * Registers this channel with the given selector,
+ * returning a selection key.
+ *
+ * @exception CancelledKeyException If this channel is currently registered
+ * with the given selector but the corresponding key has already been cancelled
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If a bit in ops does not correspond
+ * to an operation that is supported by this channel, that is, if
+ * set & ~validOps() != 0.
+ * @exception IllegalBlockingModeException If block is true and this channel
+ * is registered with one or more selectors.
+ * @exception IllegalSelectorException If this channel was not created by
+ * the same provider as the given selector.
+ */
+ public final SelectionKey register(Selector sel, int ops)
+ throws ClosedChannelException
+ {
+ return register(sel, ops, null);
+ }
+
+ /**
+ * Registers this channel with the given selector,
+ * returning a selection key.
+ *
+ * @exception CancelledKeyException If this channel is currently registered
+ * with the given selector but the corresponding key has already been
+ * cancelled.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If a bit in ops does not correspond
+ * to an operation that is supported by this channel, that is, if
+ * set & ~validOps() != 0.
+ * @exception IllegalBlockingModeException If block is true and this channel
+ * is registered with one or more selectors.
+ * @exception IllegalSelectorException If this channel was not created by
+ * the same provider as the given selector.
+ */
+ public abstract SelectionKey register(Selector sel, int ops, Object att)
+ throws ClosedChannelException;
+
+ /**
+ * Returns a set of valid operations on this channel.
+ */
+ public abstract int validOps();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/SelectionKey.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/SelectionKey.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/SelectionKey.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/SelectionKey.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,164 @@
+/* SelectionKey.java --
+ Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public abstract class SelectionKey
+{
+ public static final int OP_ACCEPT = 16;
+ public static final int OP_CONNECT = 8;
+ public static final int OP_READ = 1;
+ public static final int OP_WRITE = 4;
+ Object attached;
+
+ /**
+ * Initializes the selection key.
+ */
+ protected SelectionKey()
+ {
+ }
+
+ /**
+ * Attaches obj to the key and returns the old attached object.
+ */
+ public final synchronized Object attach(Object obj)
+ {
+ Object old = attached;
+ attached = obj;
+ return old;
+ }
+
+ /**
+ * Returns the object attached to the key.
+ */
+ public final synchronized Object attachment()
+ {
+ return attached;
+ }
+
+ /**
+ * Tests if the channel attached to this key is ready to accept
+ * a new socket connection.
+ *
+ * @exception CancelledKeyException If this key has been cancelled
+ */
+ public final boolean isAcceptable()
+ {
+ return (readyOps() & OP_ACCEPT) != 0;
+ }
+
+ /**
+ * Tests whether this key's channel has either finished,
+ * or failed to finish, its socket-connection operation.
+ *
+ * @exception CancelledKeyException If this key has been cancelled
+ */
+ public final boolean isConnectable()
+ {
+ return (readyOps() & OP_CONNECT) != 0;
+ }
+
+ /**
+ * Tests if the channel attached to the key is readable.
+ *
+ * @exception CancelledKeyException If this key has been cancelled
+ */
+ public final boolean isReadable()
+ {
+ return (readyOps() & OP_READ) != 0;
+ }
+
+ /**
+ * Tests if the channel attached to the key is writable.
+ *
+ * @exception CancelledKeyException If this key has been cancelled
+ */
+ public final boolean isWritable()
+ {
+ return (readyOps() & OP_WRITE) != 0;
+ }
+
+ /**
+ * Requests that the registration of this key's channel with
+ * its selector be cancelled.
+ */
+ public abstract void cancel();
+
+ /**
+ * return the channel attached to the key.
+ */
+ public abstract SelectableChannel channel();
+
+ /**
+ * Returns the key's interest set.
+ *
+ * @exception CancelledKeyException If this key has been cancelled
+ */
+ public abstract int interestOps();
+
+ /**
+ * Sets this key's interest set to the given value.
+ *
+ * @exception CancelledKeyException If this key has been cancelled
+ * @exception IllegalArgumentException If a bit in the set does not
+ * correspond to an operation that is supported by this key's channel,
+ * that is, if set & ~(channel().validOps()) != 0
+ */
+ public abstract SelectionKey interestOps(int ops);
+
+ /**
+ * Tells whether or not this key is valid.
+ */
+ public abstract boolean isValid();
+
+ /**
+ * Retrieves this key's ready-operation set.
+ *
+ * @exception CancelledKeyException If this key has been cancelled
+ */
+ public abstract int readyOps();
+
+ /**
+ * Returns the selector for which this key was created.
+ */
+ public abstract Selector selector();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Selector.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Selector.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Selector.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/Selector.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,134 @@
+/* Selector.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+import java.nio.channels.spi.SelectorProvider;
+import java.util.Set;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public abstract class Selector
+{
+ /**
+ * Initializes the selector.
+ */
+ protected Selector()
+ {
+ }
+
+ /**
+ * Opens a selector.
+ *
+ * @exception IOException If an error occurs
+ */
+ public static Selector open() throws IOException
+ {
+ return SelectorProvider.provider().openSelector();
+ }
+
+ /**
+ * Closes the selector.
+ *
+ * @exception IOException If an error occurs
+ */
+ public abstract void close() throws IOException;
+
+ /**
+ * Tells whether the selector is open or not.
+ */
+ public abstract boolean isOpen();
+
+ /**
+ * Returns this selector's key set.
+ *
+ * @exception ClosedSelectorException If this selector is closed.
+ */
+ public abstract Set keys();
+
+ /**
+ * Returns the SelectorProvider that created the selector.
+ */
+ public abstract SelectorProvider provider();
+
+ /**
+ * Selects a set of keys whose corresponding channels are ready
+ * for I/O operations.
+ *
+ * @exception ClosedSelectorException If this selector is closed.
+ * @exception IOException If an error occurs
+ */
+ public abstract int select() throws IOException;
+
+ /**
+ * Selects a set of keys whose corresponding channels are ready
+ * for I/O operations.
+ *
+ * @param timeout The timeout to use.
+ *
+ * @exception ClosedSelectorException If this selector is closed.
+ * @exception IllegalArgumentException If the timeout value is negative.
+ * @exception IOException If an error occurs
+ */
+ public abstract int select(long timeout) throws IOException;
+
+ /**
+ * Returns this selector's selected-key set.
+ *
+ * @exception ClosedSelectorException If this selector is closed.
+ */
+ public abstract Set selectedKeys();
+
+ /**
+ * Selects a set of keys whose corresponding channels are ready
+ * for I/O operations.
+ *
+ * @exception ClosedSelectorException If this selector is closed.
+ * @exception IOException If an error occurs
+ */
+ public abstract int selectNow() throws IOException;
+
+ /**
+ * Causes the first selection operation that has not yet returned to
+ * return immediately.
+ */
+ public abstract Selector wakeup();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ServerSocketChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ServerSocketChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ServerSocketChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/ServerSocketChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,98 @@
+/* ServerSocketChannel.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.nio.channels.spi.AbstractSelectableChannel;
+import java.nio.channels.spi.SelectorProvider;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public abstract class ServerSocketChannel extends AbstractSelectableChannel
+{
+ /**
+ * Initializes this channel.
+ */
+ protected ServerSocketChannel(SelectorProvider provider)
+ {
+ super(provider);
+ }
+
+ /**
+ * Accepts a connection made to this channel's socket.
+ *
+ * @exception IOException If an error occurs
+ * @exception AsynchronousCloseException If another thread closes this
+ * channel while the accept operation is in progress.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the accept operation is in progress, thereby closing
+ * the channel and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If the channel is closed.
+ * @exception NotYetBoundException If the channel's socket is not yet bound.
+ * @exception SecurityException If a security manager has been installed and
+ * it does not permit access to the remote endpoint of the new connection.
+ */
+ public abstract SocketChannel accept() throws IOException;
+
+ /**
+ * Retrieves the channels socket.
+ */
+ public abstract ServerSocket socket();
+
+ /**
+ * Opens a server socket channel.
+ *
+ * @exception IOException If an error occurs
+ */
+ public static ServerSocketChannel open() throws IOException
+ {
+ return SelectorProvider.provider().openServerSocketChannel();
+ }
+
+ /**
+ * Retrieves the valid operations for this channel.
+ */
+ public final int validOps()
+ {
+ return SelectionKey.OP_ACCEPT;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/SocketChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/SocketChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/SocketChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/SocketChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,248 @@
+/* SocketChannel.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio.channels;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.channels.spi.AbstractSelectableChannel;
+import java.nio.channels.spi.SelectorProvider;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ * @since 1.4
+ */
+public abstract class SocketChannel extends AbstractSelectableChannel
+ implements ByteChannel, ScatteringByteChannel, GatheringByteChannel
+{
+ /**
+ * Initializes this socket channel.
+ */
+ protected SocketChannel(SelectorProvider provider)
+ {
+ super(provider);
+ }
+
+ /**
+ * Opens a socket channel.
+ *
+ * @return the new <code>SocketChannel</code> object
+ *
+ * @exception IOException If an error occurs
+ */
+ public static SocketChannel open() throws IOException
+ {
+ return SelectorProvider.provider().openSocketChannel();
+ }
+
+ /**
+ * Opens a channel and connects it to a remote address.
+ *
+ * @return the new <code>SocketChannel</code> object
+ *
+ * @exception AsynchronousCloseException If this channel is already connected.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the connect operation is in progress, thereby closing
+ * the channel and setting the current thread's interrupt status.
+ * @exception IOException If an error occurs
+ * @exception SecurityException If a security manager has been installed and
+ * it does not permit access to the given remote endpoint.
+ * @exception UnresolvedAddressException If the given remote address is not
+ * fully resolved.
+ * @exception UnsupportedAddressTypeException If the type of the given remote
+ * address is not supported.
+ */
+ public static SocketChannel open(SocketAddress remote)
+ throws IOException
+ {
+ SocketChannel ch = open();
+ ch.connect(remote);
+ return ch;
+ }
+
+ /**
+ * Reads data from the channel.
+ *
+ * @return the number of bytes read, zero is valid too, -1 if end of stream
+ * is reached
+ *
+ * @exception IOException If an error occurs
+ * @exception NotYetConnectedException If this channel is not yet connected.
+ */
+ public final long read(ByteBuffer[] dsts) throws IOException
+ {
+ long b = 0;
+
+ for (int i = 0; i < dsts.length; i++)
+ b += read(dsts[i]);
+
+ return b;
+ }
+
+ /**
+ * Writes data to the channel.
+ *
+ * @return the number of bytes written, zero is valid too
+ *
+ * @exception IOException If an error occurs
+ * @exception NotYetConnectedException If this channel is not yet connected.
+ */
+ public final long write(ByteBuffer[] dsts) throws IOException
+ {
+ long b = 0;
+
+ for (int i = 0; i < dsts.length; i++)
+ b += write(dsts[i]);
+
+ return b;
+ }
+
+ /**
+ * Retrieves the valid operations for this channel.
+ *
+ * @return the valid operations
+ */
+ public final int validOps()
+ {
+ return SelectionKey.OP_CONNECT | SelectionKey.OP_READ
+ | SelectionKey.OP_WRITE;
+ }
+
+ /**
+ * Reads data from the channel.
+ *
+ * @return the number of bytes read, zero is valid too, -1 if end of stream
+ * is reached
+ *
+ * @exception IOException If an error occurs
+ * @exception NotYetConnectedException If this channel is not yet connected.
+ */
+ public abstract int read(ByteBuffer dst) throws IOException;
+
+ /**
+ * Connects the channel's socket to the remote address.
+ *
+ * @return <code>true</code> if the channel got successfully connected,
+ * <code>false</code> if the channel is in non-blocking mode and connection
+ * operation is still in progress.
+ *
+ * @exception AlreadyConnectedException If this channel is already connected.
+ * @exception AsynchronousCloseException If this channel is already connected.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the connect operation is in progress, thereby closing
+ * the channel and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception ConnectionPendingException If a non-blocking connection
+ * operation is already in progress on this channel.
+ * @exception IOException If an error occurs
+ * @exception SecurityException If a security manager has been installed and
+ * it does not permit access to the given remote endpoint.
+ * @exception UnresolvedAddressException If the given remote address is not
+ * fully resolved.
+ * @exception UnsupportedAddressTypeException If the type of the given remote
+ * address is not supported.
+ */
+ public abstract boolean connect(SocketAddress remote)
+ throws IOException;
+
+ /**
+ * Finishes the process of connecting a socket channel.
+ *
+ * @exception AsynchronousCloseException If this channel is already connected.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the connect operation is in progress, thereby closing
+ * the channel and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IOException If an error occurs
+ * @exception NoConnectionPendingException If this channel is not connected
+ * and a connection operation has not been initiated.
+ */
+ public abstract boolean finishConnect() throws IOException;
+
+ /**
+ * Tells whether or not the channel's socket is connected.
+ */
+ public abstract boolean isConnected();
+
+ /**
+ * Tells whether or not a connection operation is in progress on this channel.
+ */
+ public abstract boolean isConnectionPending();
+
+ /**
+ * Reads data from the channel.
+ *
+ * @return the number of bytes read, zero is valid too, -1 if end of stream
+ * is reached
+ *
+ * @exception IOException If an error occurs
+ * @exception NotYetConnectedException If this channel is not yet connected.
+ */
+ public abstract long read(ByteBuffer[] dsts, int offset, int length)
+ throws IOException;
+
+ /**
+ * Retrieves the channel's socket.
+ *
+ * @return the socket
+ */
+ public abstract Socket socket();
+
+ /**
+ * Writes data to the channel.
+ *
+ * @return the number of bytes written, zero is valid too
+ *
+ * @exception IOException If an error occurs
+ * @exception NotYetConnectedException If this channel is not yet connected.
+ */
+ public abstract int write(ByteBuffer src) throws IOException;
+
+ /**
+ * Writes data to the channel.
+ *
+ * @return the number of bytes written, zero is valid too
+ *
+ * @exception IOException If an error occurs
+ * @exception NotYetConnectedException If this channel is not yet connected.
+ */
+ public abstract long write(ByteBuffer[] srcs, int offset, int length)
+ throws IOException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/UnresolvedAddressException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/UnresolvedAddressException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/UnresolvedAddressException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/UnresolvedAddressException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* UnresolvedAddressException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class UnresolvedAddressException extends IllegalArgumentException
+{
+ private static final long serialVersionUID = 6136959093620794148L;
+
+ /**
+ * Creates the exception
+ */
+ public UnresolvedAddressException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/UnsupportedAddressTypeException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/UnsupportedAddressTypeException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/UnsupportedAddressTypeException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/UnsupportedAddressTypeException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* UnsupportedAddressTypeException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class UnsupportedAddressTypeException extends IllegalArgumentException
+{
+ private static final long serialVersionUID = - 2964323842829700493L;
+
+ /**
+ * Creates the exception
+ */
+ public UnsupportedAddressTypeException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/WritableByteChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/WritableByteChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/WritableByteChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/WritableByteChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,60 @@
+/* WritableByteChannel.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+
+public interface WritableByteChannel extends Channel
+{
+ /**
+ * Writes a sequence of bytes to this channel from the given buffer
+ *
+ * @exception AsynchronousCloseException If another thread closes this
+ * channel while the write operation is in progress
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the write operation is in progress, thereby closing
+ * the channel and setting the current thread's interrupt status
+ * @exception ClosedChannelException If this channel is closed
+ * @exception IOException If an error occurs
+ * @exception NonWritableChannelException If this channel was not opened for
+ * writing
+ */
+ int write(ByteBuffer src) throws IOException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.nio.channels package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.nio.channels</title></head>
+
+<body>
+<p>Classes for creating, selecting and non-blocking reading and writing of
+buffers from files and sockets.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractInterruptibleChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractInterruptibleChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractInterruptibleChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractInterruptibleChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,119 @@
+/* AbstractInterruptibleChannel.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels.spi;
+
+import java.io.IOException;
+import java.nio.channels.AsynchronousCloseException;
+import java.nio.channels.Channel;
+import java.nio.channels.ClosedByInterruptException;
+import java.nio.channels.InterruptibleChannel;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public abstract class AbstractInterruptibleChannel
+ implements Channel, InterruptibleChannel
+{
+ private boolean closed;
+
+ /**
+ * Initializes the channel.
+ */
+ protected AbstractInterruptibleChannel()
+ {
+ }
+
+ /**
+ * Marks the beginning of an I/O operation that might block indefinitely.
+ */
+ protected final void begin()
+ {
+ }
+
+ /**
+ * Closes the channel.
+ *
+ * @exception IOException If an error occurs
+ */
+ public final void close() throws IOException
+ {
+ if (! closed)
+ {
+ closed = true;
+ implCloseChannel();
+ }
+ }
+
+ /**
+ * Marks the end of an I/O operation that might block indefinitely.
+ *
+ * @param completed true if the task completed successfully,
+ * false otherwise
+ *
+ * @exception AsynchronousCloseException If the channel was asynchronously
+ * closed.
+ * @exception ClosedByInterruptException If the thread blocked in the
+ * I/O operation was interrupted.
+ */
+ protected final void end(boolean completed)
+ throws AsynchronousCloseException
+ {
+ // FIXME: check more here.
+
+ if (closed) throw new AsynchronousCloseException();
+ }
+
+ /**
+ * Closes the channel.
+ *
+ * @exception IOException If an error occurs
+ */
+ protected abstract void implCloseChannel() throws IOException;
+
+ /**
+ * Tells whether or not this channel is open.
+ *
+ * @return true if the channel is open, false otherwise
+ */
+ public final boolean isOpen()
+ {
+ return ! closed;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,262 @@
+/* AbstractSelectableChannel.java
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio.channels.spi;
+
+import java.io.IOException;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.IllegalBlockingModeException;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+public abstract class AbstractSelectableChannel extends SelectableChannel
+{
+ private boolean blocking = true;
+ private Object LOCK = new Object();
+ private SelectorProvider provider;
+ private LinkedList keys = new LinkedList();
+
+ /**
+ * Initializes the channel
+ *
+ * @param provider the provider that created this channel
+ */
+ protected AbstractSelectableChannel(SelectorProvider provider)
+ {
+ this.provider = provider;
+ }
+
+ /**
+ * Retrieves the object upon which the configureBlocking and register
+ * methods synchronize.
+ *
+ * @return the blocking lock
+ */
+ public final Object blockingLock()
+ {
+ return LOCK;
+ }
+
+ /**
+ * Adjusts this channel's blocking mode.
+ *
+ * @param blocking true if blocking should be enabled, false otherwise
+ *
+ * @return this channel
+ *
+ * @exception IOException If an error occurs
+ */
+ public final SelectableChannel configureBlocking(boolean blocking)
+ throws IOException
+ {
+ synchronized (blockingLock())
+ {
+ if (this.blocking != blocking)
+ {
+ implConfigureBlocking(blocking);
+ this.blocking = blocking;
+ }
+ }
+
+ return this;
+ }
+
+ /**
+ * Closes this channel.
+ *
+ * @exception IOException If an error occurs
+ */
+ protected final void implCloseChannel() throws IOException
+ {
+ implCloseSelectableChannel();
+ }
+
+ /**
+ * Closes this selectable channel.
+ *
+ * @exception IOException If an error occurs
+ */
+ protected abstract void implCloseSelectableChannel()
+ throws IOException;
+
+ /**
+ * Adjusts this channel's blocking mode.
+ *
+ * @param blocking true if blocking should be enabled, false otherwise
+ *
+ * @exception IOException If an error occurs
+ */
+ protected abstract void implConfigureBlocking(boolean blocking)
+ throws IOException;
+
+ /**
+ * Tells whether or not every I/O operation on this channel will block
+ * until it completes.
+ *
+ * @return true of this channel is blocking, false otherwise
+ */
+ public final boolean isBlocking()
+ {
+ return blocking;
+ }
+
+ /**
+ * Tells whether or not this channel is currently registered with
+ * any selectors.
+ *
+ * @return true if this channel is registered, false otherwise
+ */
+ public final boolean isRegistered()
+ {
+ return ! keys.isEmpty();
+ }
+
+ /**
+ * Retrieves the key representing the channel's registration with the
+ * given selector.
+ *
+ * @param selector the selector to get a selection key for
+ *
+ * @return the selection key this channel is registered with
+ */
+ public final SelectionKey keyFor(Selector selector)
+ {
+ if (! isOpen())
+ return null;
+
+ try
+ {
+ synchronized (blockingLock())
+ {
+ return locate(selector);
+ }
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns the provider that created this channel.
+ *
+ * @return the selector provider that created this channel
+ */
+ public final SelectorProvider provider()
+ {
+ return provider;
+ }
+
+ private SelectionKey locate(Selector selector)
+ {
+ ListIterator it = keys.listIterator();
+
+ while (it.hasNext())
+ {
+ SelectionKey key = (SelectionKey) it.next();
+
+ if (key.selector() == selector)
+ return key;
+ }
+
+ return null;
+ }
+
+ /**
+ * Registers this channel with the given selector, returning a selection key.
+ *
+ * @param selin the seletor to use
+ * @param ops the interested operations
+ * @param att an attachment for the returned selection key
+ *
+ * @return the registered selection key
+ *
+ * @exception ClosedChannelException If the channel is already closed.
+ * @exception IllegalBlockingModeException If the channel is configured in
+ * blocking mode.
+ */
+ public final SelectionKey register(Selector selin, int ops, Object att)
+ throws ClosedChannelException
+ {
+ if (! isOpen())
+ throw new ClosedChannelException();
+
+ if ((ops & ~validOps()) != 0)
+ throw new IllegalArgumentException();
+
+ SelectionKey key = null;
+ AbstractSelector selector = (AbstractSelector) selin;
+
+ synchronized (blockingLock())
+ {
+ if (blocking)
+ throw new IllegalBlockingModeException();
+
+ key = locate(selector);
+
+ if (key != null && key.isValid())
+ {
+ if (att != null)
+ key.attach(att);
+ }
+ else
+ {
+ key = selector.register(this, ops, att);
+
+ if (key != null)
+ addSelectionKey(key);
+ }
+ }
+
+ return key;
+ }
+
+ void addSelectionKey(SelectionKey key)
+ {
+ keys.add(key);
+ }
+
+ // This method gets called by AbstractSelector.deregister().
+ void removeSelectionKey(SelectionKey key)
+ {
+ keys.remove(key);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* AbstractSelectionKey.java --
+ Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels.spi;
+
+import java.nio.channels.SelectionKey;
+
+
+/**
+ * @since 1.4
+ */
+public abstract class AbstractSelectionKey extends SelectionKey
+{
+ private boolean cancelled;
+
+ /**
+ * Initializes the key.
+ */
+ protected AbstractSelectionKey()
+ {
+ }
+
+ /**
+ * Cancels this key.
+ */
+ public final synchronized void cancel()
+ {
+ if (isValid())
+ {
+ ((AbstractSelector) selector()).cancelKey(this);
+ cancelled = true;
+ }
+ }
+
+ /**
+ * Tells whether this key is valid or not.
+ *
+ * @return true if this key is valid, false otherwise
+ */
+ public final synchronized boolean isValid()
+ {
+ return ! cancelled;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractSelector.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractSelector.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractSelector.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/AbstractSelector.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,167 @@
+/* AbstractSelector.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels.spi;
+
+import java.io.IOException;
+import java.nio.channels.ClosedSelectorException;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.util.HashSet;
+import java.util.Set;
+
+
+public abstract class AbstractSelector extends Selector
+{
+ private boolean closed;
+ private SelectorProvider provider;
+ private HashSet cancelledKeys;
+
+ /**
+ * Initializes the slector.
+ *
+ * @param provider the provider that created this selector
+ */
+ protected AbstractSelector(SelectorProvider provider)
+ {
+ this.provider = provider;
+ this.cancelledKeys = new HashSet();
+ }
+
+ /**
+ * Closes the channel.
+ *
+ * @exception IOException If an error occurs
+ */
+ public final synchronized void close() throws IOException
+ {
+ if (closed)
+ return;
+
+ implCloseSelector();
+ closed = true;
+ }
+
+ /**
+ * Tells whether this channel is open or not.
+ *
+ * @return true if channel is open, false otherwise.
+ */
+ public final boolean isOpen()
+ {
+ return ! closed;
+ }
+
+ /**
+ * Marks the beginning of an I/O operation that might block indefinitely.
+ */
+ protected final void begin()
+ {
+ }
+
+ /**
+ * Marks the end of an I/O operation that might block indefinitely.
+ */
+ protected final void end()
+ {
+ }
+
+ /**
+ * Returns the provider for this selector object.
+ *
+ * @return the SelectorProvider object that created this seletor
+ */
+ public final SelectorProvider provider()
+ {
+ return provider;
+ }
+
+ /**
+ * Returns the cancelled keys set.
+ *
+ * @return the cancelled keys set
+ */
+ protected final Set cancelledKeys()
+ {
+ if (! isOpen())
+ throw new ClosedSelectorException();
+
+ return cancelledKeys;
+ }
+
+ /**
+ * Cancels a selection key.
+ */
+
+ // This method is only called by AbstractSelectionKey.cancel().
+ final void cancelKey(AbstractSelectionKey key)
+ {
+ synchronized (cancelledKeys)
+ {
+ cancelledKeys.add(key);
+ }
+ }
+
+ /**
+ * Closes the channel.
+ *
+ * @exception IOException if an error occurs
+ */
+ protected abstract void implCloseSelector() throws IOException;
+
+ /**
+ * Registers a channel for the selection process.
+ *
+ * @param ch the channel register
+ * @param ops the interested operations
+ * @param att an attachement to the selection key
+ *
+ * @return the registered selection key
+ */
+ protected abstract SelectionKey register(AbstractSelectableChannel ch,
+ int ops, Object att);
+
+ /**
+ * Deregisters the given selection key.
+ *
+ * @param key the key to deregister
+ */
+ protected final void deregister(AbstractSelectionKey key)
+ {
+ ((AbstractSelectableChannel) key.channel()).removeSelectionKey(key);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/SelectorProvider.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/SelectorProvider.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/SelectorProvider.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/SelectorProvider.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,151 @@
+/* SelectorProvider.java
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.channels.spi;
+
+import gnu.java.nio.SelectorProviderImpl;
+
+import java.io.IOException;
+import java.nio.channels.DatagramChannel;
+import java.nio.channels.Pipe;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public abstract class SelectorProvider
+{
+ private static SelectorProvider systemDefaultProvider;
+
+ /**
+ * Initializes the selector provider.
+ *
+ * @exception SecurityException If a security manager has been installed and
+ * it denies @see RuntimePermission ("selectorProvider").
+ */
+ protected SelectorProvider()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new RuntimePermission("selectorProvider"));
+ }
+
+ /**
+ * Opens a datagram channel.
+ *
+ * @return a new datagram channel object
+ *
+ * @exception IOException if an error occurs
+ */
+ public abstract DatagramChannel openDatagramChannel()
+ throws IOException;
+
+ /**
+ * Opens a pipe.
+ *
+ * @return a new pipe object
+ *
+ * @exception IOException if an error occurs
+ */
+ public abstract Pipe openPipe() throws IOException;
+
+ /**
+ * Opens a selector.
+ *
+ * @return a new selector object
+ *
+ * @exception IOException if an error occurs
+ */
+ public abstract AbstractSelector openSelector() throws IOException;
+
+ /**
+ * Opens a server socket channel.
+ *
+ * @return a new server socket channel object
+ *
+ * @exception IOException if an error occurs
+ */
+ public abstract ServerSocketChannel openServerSocketChannel()
+ throws IOException;
+
+ /**
+ * Opens a socket channel.
+ *
+ * @return a new socket channel object
+ *
+ * @exception IOException if an error occurs
+ */
+ public abstract SocketChannel openSocketChannel() throws IOException;
+
+ /**
+ * Returns the system-wide default selector provider for this invocation
+ * of the Java virtual machine.
+ *
+ * @return the default seletor provider
+ */
+ public static synchronized SelectorProvider provider()
+ {
+ if (systemDefaultProvider == null)
+ {
+ String propertyValue =
+ System.getProperty("java.nio.channels.spi.SelectorProvider");
+
+ if (propertyValue == null || propertyValue.equals(""))
+ systemDefaultProvider = new SelectorProviderImpl();
+ else
+ {
+ try
+ {
+ systemDefaultProvider =
+ (SelectorProvider) Class.forName(propertyValue)
+ .newInstance();
+ }
+ catch (Exception e)
+ {
+ System.err.println("Could not instantiate class: "
+ + propertyValue);
+ systemDefaultProvider = new SelectorProviderImpl();
+ }
+ }
+ }
+
+ return systemDefaultProvider;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/channels/spi/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.nio.channels.spi package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.nio.channels.spi</title></head>
+
+<body>
+<p>Utility classes and interfaces for implementing channels.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CharacterCodingException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CharacterCodingException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CharacterCodingException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CharacterCodingException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* CharacterCodingException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.charset;
+
+import java.io.IOException;
+
+/**
+ * @since 1.4
+ */
+public class CharacterCodingException extends IOException
+{
+ private static final long serialVersionUID = 8421532232154627783L;
+
+ /**
+ * Creates the exception
+ */
+ public CharacterCodingException()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/Charset.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/Charset.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/Charset.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/Charset.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,401 @@
+/* Charset.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio.charset;
+
+import gnu.classpath.ServiceFactory;
+import gnu.classpath.SystemProperties;
+import gnu.java.nio.charset.Provider;
+import gnu.java.nio.charset.iconv.IconvProvider;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.spi.CharsetProvider;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Locale;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * @author Jesse Rosenstock
+ * @since 1.4
+ * @status updated to 1.5
+ */
+public abstract class Charset implements Comparable
+{
+ private CharsetEncoder cachedEncoder;
+ private CharsetDecoder cachedDecoder;
+
+ /**
+ * Extra Charset providers.
+ */
+ private static CharsetProvider[] providers;
+
+ private final String canonicalName;
+ private final String[] aliases;
+
+ protected Charset (String canonicalName, String[] aliases)
+ {
+ checkName (canonicalName);
+ if (aliases != null)
+ {
+ int n = aliases.length;
+ for (int i = 0; i < n; ++i)
+ checkName (aliases[i]);
+ }
+
+ cachedEncoder = null;
+ cachedDecoder = null;
+ this.canonicalName = canonicalName;
+ this.aliases = aliases;
+ }
+
+ /**
+ * @throws IllegalCharsetNameException if the name is illegal
+ */
+ private static void checkName (String name)
+ {
+ int n = name.length ();
+
+ if (n == 0)
+ throw new IllegalCharsetNameException (name);
+
+ char ch = name.charAt (0);
+ if (!(('A' <= ch && ch <= 'Z')
+ || ('a' <= ch && ch <= 'z')
+ || ('0' <= ch && ch <= '9')))
+ throw new IllegalCharsetNameException (name);
+
+ for (int i = 1; i < n; ++i)
+ {
+ ch = name.charAt (i);
+ if (!(('A' <= ch && ch <= 'Z')
+ || ('a' <= ch && ch <= 'z')
+ || ('0' <= ch && ch <= '9')
+ || ch == '-' || ch == '.' || ch == ':' || ch == '_'))
+ throw new IllegalCharsetNameException (name);
+ }
+ }
+
+ /**
+ * Returns the system default charset.
+ *
+ * This may be set by the user or VM with the file.encoding
+ * property.
+ *
+ * @since 1.5
+ */
+ public static Charset defaultCharset()
+ {
+ String encoding;
+
+ try
+ {
+ encoding = SystemProperties.getProperty("file.encoding");
+ }
+ catch(SecurityException e)
+ {
+ // Use fallback.
+ encoding = "ISO-8859-1";
+ }
+ catch(IllegalArgumentException e)
+ {
+ // Use fallback.
+ encoding = "ISO-8859-1";
+ }
+
+ try
+ {
+ return forName(encoding);
+ }
+ catch(UnsupportedCharsetException e)
+ {
+ // Ignore.
+ }
+ catch(IllegalCharsetNameException e)
+ {
+ // Ignore.
+ }
+ catch(IllegalArgumentException e)
+ {
+ // Ignore.
+ }
+
+ throw new IllegalStateException("Can't get default charset!");
+ }
+
+ public static boolean isSupported (String charsetName)
+ {
+ return charsetForName (charsetName) != null;
+ }
+
+ /**
+ * Returns the Charset instance for the charset of the given name.
+ *
+ * @param charsetName
+ * @return the Charset instance for the indicated charset
+ * @throws UnsupportedCharsetException if this VM does not support
+ * the charset of the given name.
+ * @throws IllegalCharsetNameException if the given charset name is
+ * legal.
+ * @throws IllegalArgumentException if <code>charsetName</code> is null.
+ */
+ public static Charset forName (String charsetName)
+ {
+ // Throws IllegalArgumentException as the JDK does.
+ if(charsetName == null)
+ throw new IllegalArgumentException("Charset name must not be null.");
+
+ Charset cs = charsetForName (charsetName);
+ if (cs == null)
+ throw new UnsupportedCharsetException (charsetName);
+ return cs;
+ }
+
+ /**
+ * Retrieves a charset for the given charset name.
+ *
+ * @return A charset object for the charset with the specified name, or
+ * <code>null</code> if no such charset exists.
+ *
+ * @throws IllegalCharsetNameException if the name is illegal
+ */
+ private static Charset charsetForName(String charsetName)
+ {
+ checkName (charsetName);
+ // Try the default provider first
+ // (so we don't need to load external providers unless really necessary)
+ // if it is an exotic charset try loading the external providers.
+ Charset cs = provider().charsetForName(charsetName);
+ if (cs == null)
+ {
+ CharsetProvider[] providers = providers2();
+ for (int i = 0; i < providers.length; i++)
+ {
+ cs = providers[i].charsetForName(charsetName);
+ if (cs != null)
+ break;
+ }
+ }
+ return cs;
+ }
+
+ public static SortedMap availableCharsets()
+ {
+ TreeMap charsets = new TreeMap(String.CASE_INSENSITIVE_ORDER);
+ for (Iterator i = provider().charsets(); i.hasNext(); )
+ {
+ Charset cs = (Charset) i.next();
+ charsets.put(cs.name(), cs);
+ }
+
+ CharsetProvider[] providers = providers2();
+ for (int j = 0; j < providers.length; j++)
+ {
+ for (Iterator i = providers[j].charsets(); i.hasNext(); )
+ {
+ Charset cs = (Charset) i.next();
+ charsets.put(cs.name(), cs);
+ }
+ }
+
+ return Collections.unmodifiableSortedMap(charsets);
+ }
+
+ private static CharsetProvider provider()
+ {
+ String useIconv = SystemProperties.getProperty
+ ("gnu.classpath.nio.charset.provider.iconv");
+
+ if (useIconv != null)
+ return IconvProvider.provider();
+
+ return Provider.provider();
+ }
+
+ /**
+ * We need to support multiple providers, reading them from
+ * java.nio.charset.spi.CharsetProvider in the resource directory
+ * META-INF/services. This returns the "extra" charset providers.
+ */
+ private static CharsetProvider[] providers2()
+ {
+ if (providers == null)
+ {
+ try
+ {
+ Iterator i = ServiceFactory.lookupProviders(CharsetProvider.class);
+ LinkedHashSet set = new LinkedHashSet();
+ while (i.hasNext())
+ set.add(i.next());
+
+ providers = new CharsetProvider[set.size()];
+ set.toArray(providers);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return providers;
+ }
+
+ public final String name ()
+ {
+ return canonicalName;
+ }
+
+ public final Set aliases ()
+ {
+ if (aliases == null)
+ return Collections.EMPTY_SET;
+
+ // should we cache the aliasSet instead?
+ int n = aliases.length;
+ HashSet aliasSet = new HashSet (n);
+ for (int i = 0; i < n; ++i)
+ aliasSet.add (aliases[i]);
+ return Collections.unmodifiableSet (aliasSet);
+ }
+
+ public String displayName ()
+ {
+ return canonicalName;
+ }
+
+ public String displayName (Locale locale)
+ {
+ return canonicalName;
+ }
+
+ public final boolean isRegistered ()
+ {
+ return (!canonicalName.startsWith ("x-")
+ && !canonicalName.startsWith ("X-"));
+ }
+
+ public abstract boolean contains (Charset cs);
+
+ public abstract CharsetDecoder newDecoder ();
+
+ public abstract CharsetEncoder newEncoder ();
+
+ public boolean canEncode ()
+ {
+ return true;
+ }
+
+ // NB: This implementation serializes different threads calling
+ // Charset.encode(), a potential performance problem. It might
+ // be better to remove the cache, or use ThreadLocal to cache on
+ // a per-thread basis.
+ public final synchronized ByteBuffer encode (CharBuffer cb)
+ {
+ try
+ {
+ if (cachedEncoder == null)
+ {
+ cachedEncoder = newEncoder ()
+ .onMalformedInput (CodingErrorAction.REPLACE)
+ .onUnmappableCharacter (CodingErrorAction.REPLACE);
+ } else
+ cachedEncoder.reset();
+ return cachedEncoder.encode (cb);
+ }
+ catch (CharacterCodingException e)
+ {
+ throw new AssertionError (e);
+ }
+ }
+
+ public final ByteBuffer encode (String str)
+ {
+ return encode (CharBuffer.wrap (str));
+ }
+
+ // NB: This implementation serializes different threads calling
+ // Charset.decode(), a potential performance problem. It might
+ // be better to remove the cache, or use ThreadLocal to cache on
+ // a per-thread basis.
+ public final synchronized CharBuffer decode (ByteBuffer bb)
+ {
+ try
+ {
+ if (cachedDecoder == null)
+ {
+ cachedDecoder = newDecoder ()
+ .onMalformedInput (CodingErrorAction.REPLACE)
+ .onUnmappableCharacter (CodingErrorAction.REPLACE);
+ } else
+ cachedDecoder.reset();
+
+ return cachedDecoder.decode (bb);
+ }
+ catch (CharacterCodingException e)
+ {
+ throw new AssertionError (e);
+ }
+ }
+
+ public final int compareTo (Object ob)
+ {
+ return canonicalName.compareToIgnoreCase (((Charset) ob).canonicalName);
+ }
+
+ public final int hashCode ()
+ {
+ return canonicalName.hashCode ();
+ }
+
+ public final boolean equals (Object ob)
+ {
+ if (ob instanceof Charset)
+ return canonicalName.equalsIgnoreCase (((Charset) ob).canonicalName);
+ else
+ return false;
+ }
+
+ public final String toString ()
+ {
+ return canonicalName;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CharsetDecoder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CharsetDecoder.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CharsetDecoder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CharsetDecoder.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,317 @@
+/* CharsetDecoder.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+
+/**
+ * @author Jesse Rosenstock
+ * @since 1.4
+ */
+public abstract class CharsetDecoder
+{
+ private static final int STATE_RESET = 0;
+ private static final int STATE_CODING = 1;
+ private static final int STATE_END = 2;
+ private static final int STATE_FLUSHED = 3;
+
+ private static final String DEFAULT_REPLACEMENT = "\uFFFD";
+
+ private final Charset charset;
+ private final float averageCharsPerByte;
+ private final float maxCharsPerByte;
+ private String replacement;
+
+ private int state = STATE_RESET;
+
+ private CodingErrorAction malformedInputAction
+ = CodingErrorAction.REPORT;
+ private CodingErrorAction unmappableCharacterAction
+ = CodingErrorAction.REPORT;
+
+ private CharsetDecoder (Charset cs, float averageCharsPerByte,
+ float maxCharsPerByte, String replacement)
+ {
+ if (averageCharsPerByte <= 0.0f)
+ throw new IllegalArgumentException ("Non-positive averageCharsPerByte");
+ if (maxCharsPerByte <= 0.0f)
+ throw new IllegalArgumentException ("Non-positive maxCharsPerByte");
+
+ this.charset = cs;
+ this.averageCharsPerByte
+ = averageCharsPerByte;
+ this.maxCharsPerByte
+ = maxCharsPerByte;
+ this.replacement = replacement;
+ implReplaceWith (replacement);
+ }
+
+ protected CharsetDecoder (Charset cs, float averageCharsPerByte,
+ float maxCharsPerByte)
+ {
+ this (cs, averageCharsPerByte, maxCharsPerByte, DEFAULT_REPLACEMENT);
+ }
+
+ public final float averageCharsPerByte ()
+ {
+ return averageCharsPerByte;
+ }
+
+ public final Charset charset ()
+ {
+ return charset;
+ }
+
+ public final CharBuffer decode (ByteBuffer in)
+ throws CharacterCodingException
+ {
+ // XXX: Sun's Javadoc seems to contradict itself saying an
+ // IllegalStateException is thrown "if a decoding operation is already
+ // in progress" and also that "it resets this Decoder".
+ // Should we check to see that the state is reset, or should we
+ // call reset()?
+ if (state != STATE_RESET)
+ throw new IllegalStateException ();
+
+ // REVIEW: Using max instead of average may allocate a very large
+ // buffer. Maybe we should do something more efficient?
+ int remaining = in.remaining ();
+ int n = (int) (remaining * maxCharsPerByte ());
+ CharBuffer out = CharBuffer.allocate (n);
+
+ if (remaining == 0)
+ {
+ state = STATE_FLUSHED;
+ return out;
+ }
+
+ CoderResult cr = decode (in, out, true);
+ if (cr.isError ())
+ cr.throwException ();
+
+ cr = flush (out);
+ if (cr.isError ())
+ cr.throwException ();
+
+ reset();
+ out.flip ();
+
+ // Unfortunately, resizing the actual charbuffer array is required.
+ char[] resized = new char[out.remaining()];
+ out.get(resized);
+ return CharBuffer.wrap(resized);
+ }
+
+ public final CoderResult decode (ByteBuffer in, CharBuffer out,
+ boolean endOfInput)
+ {
+ int newState = endOfInput ? STATE_END : STATE_CODING;
+ // XXX: Need to check for "previous step was an invocation [not] of
+ // this method with a value of true for the endOfInput parameter but
+ // a return value indicating an incomplete decoding operation"
+ // XXX: We will not check the previous return value, just
+ // that the previous call passed true for endOfInput
+ if (state != STATE_RESET && state != STATE_CODING
+ && !(endOfInput && state == STATE_END))
+ throw new IllegalStateException ();
+ state = newState;
+
+ for (;;)
+ {
+ CoderResult cr;
+ try
+ {
+ cr = decodeLoop (in, out);
+ }
+ catch (RuntimeException e)
+ {
+ throw new CoderMalfunctionError (e);
+ }
+
+ if (cr.isOverflow ())
+ return cr;
+
+ if (cr.isUnderflow ())
+ {
+ if (endOfInput && in.hasRemaining ())
+ cr = CoderResult.malformedForLength (in.remaining ());
+ else
+ return cr;
+ }
+
+ CodingErrorAction action = cr.isMalformed ()
+ ? malformedInputAction
+ : unmappableCharacterAction;
+
+ if (action == CodingErrorAction.REPORT)
+ return cr;
+
+ if (action == CodingErrorAction.REPLACE)
+ {
+ if (out.remaining () < replacement.length ())
+ return CoderResult.OVERFLOW;
+ out.put (replacement);
+ }
+
+ in.position (in.position () + cr.length ());
+ }
+ }
+
+ protected abstract CoderResult decodeLoop (ByteBuffer in, CharBuffer out);
+
+ public Charset detectedCharset ()
+ {
+ throw new UnsupportedOperationException ();
+ }
+
+ public final CoderResult flush (CharBuffer out)
+ {
+ // It seems weird that you can flush after reset, but Sun's javadoc
+ // says an IllegalStateException is thrown "If the previous step of the
+ // current decoding operation was an invocation neither of the reset
+ // method nor ... of the three-argument decode method with a value of
+ // true for the endOfInput parameter."
+ // Further note that flush() only requires that there not be
+ // an IllegalStateException if the previous step was a call to
+ // decode with true as the last argument. It does not require
+ // that the call succeeded. decode() does require that it succeeded.
+ // XXX: test this to see if reality matches javadoc
+ if (state != STATE_RESET && state != STATE_END)
+ throw new IllegalStateException ();
+
+ state = STATE_FLUSHED;
+ return implFlush (out);
+ }
+
+ protected CoderResult implFlush (CharBuffer out)
+ {
+ return CoderResult.UNDERFLOW;
+ }
+
+ public final CharsetDecoder onMalformedInput (CodingErrorAction newAction)
+ {
+ if (newAction == null)
+ throw new IllegalArgumentException ("Null action");
+
+ malformedInputAction = newAction;
+ implOnMalformedInput (newAction);
+ return this;
+ }
+
+ protected void implOnMalformedInput (CodingErrorAction newAction)
+ {
+ // default implementation does nothing
+ }
+
+ protected void implOnUnmappableCharacter (CodingErrorAction newAction)
+ {
+ // default implementation does nothing
+ }
+
+ protected void implReplaceWith (String newReplacement)
+ {
+ // default implementation does nothing
+ }
+
+ protected void implReset ()
+ {
+ // default implementation does nothing
+ }
+
+ public boolean isAutoDetecting ()
+ {
+ return false;
+ }
+
+ public boolean isCharsetDetected ()
+ {
+ throw new UnsupportedOperationException ();
+ }
+
+ public CodingErrorAction malformedInputAction ()
+ {
+ return malformedInputAction;
+ }
+
+ public final float maxCharsPerByte ()
+ {
+ return maxCharsPerByte;
+ }
+
+ public final CharsetDecoder onUnmappableCharacter
+ (CodingErrorAction newAction)
+ {
+ if (newAction == null)
+ throw new IllegalArgumentException ("Null action");
+
+ unmappableCharacterAction = newAction;
+ implOnUnmappableCharacter (newAction);
+ return this;
+ }
+
+ public final String replacement ()
+ {
+ return replacement;
+ }
+
+ public final CharsetDecoder replaceWith (String newReplacement)
+ {
+ if (newReplacement == null)
+ throw new IllegalArgumentException ("Null replacement");
+ if (newReplacement.length () == 0)
+ throw new IllegalArgumentException ("Empty replacement");
+ // XXX: what about maxCharsPerByte?
+
+ this.replacement = newReplacement;
+ implReplaceWith (newReplacement);
+ return this;
+ }
+
+ public final CharsetDecoder reset ()
+ {
+ state = STATE_RESET;
+ implReset ();
+ return this;
+ }
+
+ public CodingErrorAction unmappableCharacterAction ()
+ {
+ return unmappableCharacterAction;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CharsetEncoder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CharsetEncoder.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CharsetEncoder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CharsetEncoder.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,369 @@
+/* CharsetEncoder.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+
+/**
+ * @author Jesse Rosenstock
+ * @since 1.4
+ */
+public abstract class CharsetEncoder
+{
+ private static final int STATE_RESET = 0;
+ private static final int STATE_CODING = 1;
+ private static final int STATE_END = 2;
+ private static final int STATE_FLUSHED = 3;
+
+ private static final byte[] DEFAULT_REPLACEMENT = {(byte)'?'};
+
+ private final Charset charset;
+ private final float averageBytesPerChar;
+ private final float maxBytesPerChar;
+ private byte[] replacement;
+
+ private int state = STATE_RESET;
+
+ private CodingErrorAction malformedInputAction
+ = CodingErrorAction.REPORT;
+ private CodingErrorAction unmappableCharacterAction
+ = CodingErrorAction.REPORT;
+
+ protected CharsetEncoder (Charset cs, float averageBytesPerChar,
+ float maxBytesPerChar)
+ {
+ this (cs, averageBytesPerChar, maxBytesPerChar, DEFAULT_REPLACEMENT);
+ }
+
+ protected CharsetEncoder (Charset cs, float averageBytesPerChar,
+ float maxBytesPerChar, byte[] replacement)
+ {
+ if (averageBytesPerChar <= 0.0f)
+ throw new IllegalArgumentException ("Non-positive averageBytesPerChar");
+ if (maxBytesPerChar <= 0.0f)
+ throw new IllegalArgumentException ("Non-positive maxBytesPerChar");
+
+ this.charset = cs;
+ this.averageBytesPerChar
+ = averageBytesPerChar;
+ this.maxBytesPerChar
+ = maxBytesPerChar;
+ this.replacement = replacement;
+ implReplaceWith (replacement);
+ }
+
+ public final float averageBytesPerChar ()
+ {
+ return averageBytesPerChar;
+ }
+
+ public boolean canEncode (char c)
+ {
+ CharBuffer cb = CharBuffer.allocate (1).put (c);
+ cb.flip ();
+ return canEncode (cb);
+ }
+
+ public boolean canEncode (CharSequence cs)
+ {
+ CharBuffer cb;
+ if (cs instanceof CharBuffer)
+ cb = ((CharBuffer) cs).duplicate ();
+ else
+ cb = CharBuffer.wrap (cs);
+ return canEncode (cb);
+ }
+
+ private boolean canEncode (CharBuffer cb)
+ {
+ // It is an error if a coding operation is "in progress"
+ // I take that to mean the state is not reset or flushed.
+ // XXX: check "in progress" everywhere
+ if (state == STATE_FLUSHED)
+ reset ();
+ else if (state != STATE_RESET)
+ throw new IllegalStateException ();
+
+ CodingErrorAction oldMalformedInputAction = malformedInputAction;
+ CodingErrorAction oldUnmappableCharacterAction
+ = unmappableCharacterAction;
+
+ try
+ {
+ if (oldMalformedInputAction != CodingErrorAction.REPORT)
+ onMalformedInput (CodingErrorAction.REPORT);
+ if (oldUnmappableCharacterAction != CodingErrorAction.REPORT)
+ onUnmappableCharacter (CodingErrorAction.REPORT);
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ finally
+ {
+ if (oldMalformedInputAction != CodingErrorAction.REPORT)
+ onMalformedInput (oldMalformedInputAction);
+ if (oldUnmappableCharacterAction != CodingErrorAction.REPORT)
+ onUnmappableCharacter (oldUnmappableCharacterAction);
+ }
+
+ return true;
+ }
+
+ public final Charset charset ()
+ {
+ return charset;
+ }
+
+ public final ByteBuffer encode (CharBuffer in)
+ throws CharacterCodingException
+ {
+ // XXX: Sun's Javadoc seems to contradict itself saying an
+ // IllegalStateException is thrown "if a decoding operation is already
+ // in progress" and also that "it resets this Encoder".
+ // Should we check to see that the state is reset, or should we
+ // call reset()?
+ if (state != STATE_RESET)
+ throw new IllegalStateException ();
+
+ // REVIEW: Using max instead of average may allocate a very large
+ // buffer. Maybe we should do something more efficient?
+ int remaining = in.remaining ();
+ int n = (int) (remaining * maxBytesPerChar ());
+ ByteBuffer out = ByteBuffer.allocate (n);
+
+ if (remaining == 0)
+ {
+ state = STATE_FLUSHED;
+ return out;
+ }
+
+ CoderResult cr = encode (in, out, true);
+ if (cr.isError ())
+ cr.throwException ();
+
+ cr = flush (out);
+ if (cr.isError ())
+ cr.throwException ();
+
+ out.flip ();
+
+ // Unfortunately, resizing the actual bytebuffer array is required.
+ byte[] resized = new byte[out.remaining()];
+ out.get(resized);
+ return ByteBuffer.wrap(resized);
+ }
+
+ public final CoderResult encode (CharBuffer in, ByteBuffer out,
+ boolean endOfInput)
+ {
+ int newState = endOfInput ? STATE_END : STATE_CODING;
+ // XXX: Need to check for "previous step was an invocation [not] of
+ // this method with a value of true for the endOfInput parameter but
+ // a return value indicating an incomplete decoding operation"
+ // XXX: We will not check the previous return value, just
+ // that the previous call passed true for endOfInput
+ if (state != STATE_RESET && state != STATE_CODING
+ && !(endOfInput && state == STATE_END))
+ throw new IllegalStateException ();
+ state = newState;
+
+ for (;;)
+ {
+ CoderResult cr;
+ try
+ {
+ cr = encodeLoop (in, out);
+ }
+ catch (RuntimeException e)
+ {
+ throw new CoderMalfunctionError (e);
+ }
+
+ if (cr.isOverflow ())
+ return cr;
+
+ if (cr.isUnderflow ())
+ {
+ if (endOfInput && in.hasRemaining ())
+ cr = CoderResult.malformedForLength (in.remaining ());
+ else
+ return cr;
+ }
+
+ CodingErrorAction action = cr.isMalformed ()
+ ? malformedInputAction
+ : unmappableCharacterAction;
+
+ if (action == CodingErrorAction.REPORT)
+ return cr;
+
+ if (action == CodingErrorAction.REPLACE)
+ {
+ if (out.remaining () < replacement.length)
+ return CoderResult.OVERFLOW;
+ out.put (replacement);
+ }
+
+ in.position (in.position () + cr.length ());
+ }
+ }
+
+ protected abstract CoderResult encodeLoop (CharBuffer in, ByteBuffer out);
+
+ public final CoderResult flush (ByteBuffer out)
+ {
+ // It seems weird that you can flush after reset, but Sun's javadoc
+ // says an IllegalStateException is thrown "If the previous step of the
+ // current decoding operation was an invocation neither of the reset
+ // method nor ... of the three-argument encode method with a value of
+ // true for the endOfInput parameter."
+ // Further note that flush() only requires that there not be
+ // an IllegalStateException if the previous step was a call to
+ // encode with true as the last argument. It does not require
+ // that the call succeeded. encode() does require that it succeeded.
+ // XXX: test this to see if reality matches javadoc
+ if (state != STATE_RESET && state != STATE_END)
+ throw new IllegalStateException ();
+
+ state = STATE_FLUSHED;
+ return implFlush (out);
+ }
+
+ protected CoderResult implFlush (ByteBuffer out)
+ {
+ return CoderResult.UNDERFLOW;
+ }
+
+ protected void implOnMalformedInput (CodingErrorAction newAction)
+ {
+ // default implementation does nothing
+ }
+
+ protected void implOnUnmappableCharacter (CodingErrorAction newAction)
+ {
+ // default implementation does nothing
+ }
+
+ protected void implReplaceWith (byte[] newReplacement)
+ {
+ // default implementation does nothing
+ }
+
+ protected void implReset ()
+ {
+ // default implementation does nothing
+ }
+
+ public boolean isLegalReplacement (byte[] replacement)
+ {
+ // TODO: cache the decoder
+ // error actions will be REPORT after construction
+ CharsetDecoder decoder = charset.newDecoder ();
+ ByteBuffer bb = ByteBuffer.wrap (replacement);
+ CharBuffer cb
+ = CharBuffer.allocate ((int) (replacement.length
+ * decoder.maxCharsPerByte ()));
+ return !decoder.decode (bb, cb, true).isError ();
+ }
+
+ public CodingErrorAction malformedInputAction ()
+ {
+ return malformedInputAction;
+ }
+
+ public final float maxBytesPerChar ()
+ {
+ return maxBytesPerChar;
+ }
+
+ public final CharsetEncoder onMalformedInput (CodingErrorAction newAction)
+ {
+ if (newAction == null)
+ throw new IllegalArgumentException ("Null action");
+
+ malformedInputAction = newAction;
+ implOnMalformedInput (newAction);
+ return this;
+ }
+
+ public CodingErrorAction unmappableCharacterAction ()
+ {
+ return unmappableCharacterAction;
+ }
+
+ public final CharsetEncoder onUnmappableCharacter
+ (CodingErrorAction newAction)
+ {
+ if (newAction == null)
+ throw new IllegalArgumentException ("Null action");
+
+ unmappableCharacterAction = newAction;
+ implOnUnmappableCharacter (newAction);
+ return this;
+ }
+
+ public final byte[] replacement ()
+ {
+ return replacement;
+ }
+
+ public final CharsetEncoder replaceWith (byte[] newReplacement)
+ {
+ if (newReplacement == null)
+ throw new IllegalArgumentException ("Null replacement");
+ if (newReplacement.length == 0)
+ throw new IllegalArgumentException ("Empty replacement");
+ // XXX: what about maxBytesPerChar?
+
+ if (!isLegalReplacement (newReplacement))
+ throw new IllegalArgumentException ("Illegal replacement");
+
+ this.replacement = newReplacement;
+ implReplaceWith (newReplacement);
+ return this;
+ }
+
+ public final CharsetEncoder reset ()
+ {
+ state = STATE_RESET;
+ implReset ();
+ return this;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CoderMalfunctionError.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CoderMalfunctionError.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CoderMalfunctionError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CoderMalfunctionError.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,54 @@
+/* CoderMalfunctionError.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.charset;
+
+/**
+ * @since 1.4
+ */
+public class CoderMalfunctionError extends Error
+{
+ private static final long serialVersionUID = - 1151412348057794301L;
+
+ /**
+ * Creates the error
+ */
+ public CoderMalfunctionError(Exception cause)
+ {
+ super (cause);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CoderResult.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CoderResult.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CoderResult.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CoderResult.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,189 @@
+/* CoderResult.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.charset;
+
+import java.lang.ref.WeakReference;
+import java.nio.BufferOverflowException;
+import java.nio.BufferUnderflowException;
+import java.util.HashMap;
+
+/**
+ * @author Jesse Rosenstock
+ * @since 1.4
+ */
+public class CoderResult
+{
+ private static final int TYPE_MALFORMED = 0;
+ private static final int TYPE_OVERFLOW = 1;
+ private static final int TYPE_UNDERFLOW = 2;
+ private static final int TYPE_UNMAPPABLE = 3;
+
+ public static final CoderResult OVERFLOW
+ = new CoderResult (TYPE_OVERFLOW, 0);
+ public static final CoderResult UNDERFLOW
+ = new CoderResult (TYPE_UNDERFLOW, 0);
+
+ private static final String[] names
+ = { "MALFORMED", "OVERFLOW", "UNDERFLOW", "UNMAPPABLE" };
+
+ private static final Cache malformedCache
+ = new Cache ()
+ {
+ protected CoderResult make (int length)
+ {
+ return new CoderResult (TYPE_MALFORMED, length);
+ }
+ };
+
+ private static final Cache unmappableCache
+ = new Cache ()
+ {
+ protected CoderResult make (int length)
+ {
+ return new CoderResult (TYPE_UNMAPPABLE, length);
+ }
+ };
+
+ private final int type;
+ private final int length;
+
+ // Package-private to avoid a trampoline constructor.
+ CoderResult (int type, int length)
+ {
+ this.type = type;
+ this.length = length;
+ }
+
+ public boolean isError ()
+ {
+ return length > 0;
+ }
+
+ public boolean isMalformed ()
+ {
+ return type == TYPE_MALFORMED;
+ }
+
+ public boolean isOverflow ()
+ {
+ return type == TYPE_OVERFLOW;
+ }
+
+ public boolean isUnderflow ()
+ {
+ return type == TYPE_UNDERFLOW;
+ }
+
+ public boolean isUnmappable ()
+ {
+ return type == TYPE_UNMAPPABLE;
+ }
+
+ public int length ()
+ {
+ if (length <= 0)
+ throw new UnsupportedOperationException ();
+ else
+ return length;
+ }
+
+ public static CoderResult malformedForLength (int length)
+ {
+ return malformedCache.get (length);
+ }
+
+ public void throwException ()
+ throws CharacterCodingException
+ {
+ switch (type)
+ {
+ case TYPE_MALFORMED:
+ throw new MalformedInputException (length);
+ case TYPE_OVERFLOW:
+ throw new BufferOverflowException ();
+ case TYPE_UNDERFLOW:
+ throw new BufferUnderflowException ();
+ case TYPE_UNMAPPABLE:
+ throw new UnmappableCharacterException (length);
+ }
+ }
+
+ public String toString ()
+ {
+ String name = names[type];
+ return (length > 0) ? name + '[' + length + ']' : name;
+ }
+
+ public static CoderResult unmappableForLength (int length)
+ {
+ return unmappableCache.get (length);
+ }
+
+ private abstract static class Cache
+ {
+ private final HashMap cache;
+
+ // Package-private to avoid a trampoline constructor.
+ Cache ()
+ {
+ cache = new HashMap ();
+ }
+
+ // Package-private to avoid a trampoline.
+ synchronized CoderResult get (int length)
+ {
+ if (length <= 0)
+ throw new IllegalArgumentException ("Non-positive length");
+
+ Integer len = new Integer (length);
+ CoderResult cr = null;
+ Object o;
+ if ((o = cache.get (len)) != null)
+ cr = (CoderResult) ((WeakReference) o).get ();
+ if (cr == null)
+ {
+ cr = make (length);
+ cache.put (len, new WeakReference (cr));
+ }
+
+ return cr;
+ }
+
+ protected abstract CoderResult make (int length);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CodingErrorAction.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CodingErrorAction.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CodingErrorAction.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/CodingErrorAction.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,66 @@
+/* CodingErrorAction.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.charset;
+
+public class CodingErrorAction
+{
+ public static final CodingErrorAction IGNORE
+ = new CodingErrorAction("ignore");
+ public static final CodingErrorAction REPLACE
+ = new CodingErrorAction("replace");
+ public static final CodingErrorAction REPORT
+ = new CodingErrorAction("report");
+
+ private final String name;
+
+ /**
+ * Private constructor only used to create the constant CodingErrorActions.
+ */
+ private CodingErrorAction(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Returns the name of the CodingErrorAction.
+ */
+ public String toString ()
+ {
+ return name;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/IllegalCharsetNameException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/IllegalCharsetNameException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/IllegalCharsetNameException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/IllegalCharsetNameException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* IllegalCharsetNameException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.charset;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class IllegalCharsetNameException extends IllegalArgumentException
+{
+ /**
+ * Compatible with JDK 1.4+
+ */
+ private static final long serialVersionUID = 1457525358470002989L;
+
+ private String charsetName;
+
+ /**
+ * Creates the exception
+ *
+ * @param charsetName name of the illegal charset
+ */
+ public IllegalCharsetNameException (String charsetName)
+ {
+ super ();
+ this.charsetName = charsetName;
+ }
+
+ /**
+ * Retrieves the illegal charset name
+ *
+ * @return the illegal charset name
+ */
+ public String getCharsetName ()
+ {
+ return charsetName;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/MalformedInputException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/MalformedInputException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/MalformedInputException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/MalformedInputException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* MalformedInputException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.charset;
+
+/**
+ * @since 1.4
+ */
+public class MalformedInputException extends CharacterCodingException
+{
+ private static final long serialVersionUID = - 3438823399834806194L;
+
+ private int inputLength;
+
+ /**
+ * Creates the exception
+ *
+ * @param inputLength the position of malformed input in the input stream
+ */
+ public MalformedInputException (int inputLength)
+ {
+ super ();
+ this.inputLength = inputLength;
+ }
+
+ /**
+ * Retrieves the position of the malformed input in the input stream.
+ *
+ * @return the position
+ */
+ public int getInputLength ()
+ {
+ return inputLength;
+ }
+
+ /**
+ * Returns the detail message string of this throwable
+ *
+ * @return the message
+ */
+ public String getMessage ()
+ {
+ return "Input length = " + inputLength;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/UnmappableCharacterException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/UnmappableCharacterException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/UnmappableCharacterException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/UnmappableCharacterException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* UnmappableCharacterException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.charset;
+
+/**
+ * @since 1.4
+ */
+public class UnmappableCharacterException extends CharacterCodingException
+{
+ private static final long serialVersionUID = - 7026962371537706123L;
+
+ private int inputLength;
+
+ /**
+ * Creates the exception
+ */
+ public UnmappableCharacterException (int inputLength)
+ {
+ super ();
+ this.inputLength = inputLength;
+ }
+
+ /**
+ * Retrieves the illegal charset name
+ */
+ public int getInputLength ()
+ {
+ return inputLength;
+ }
+
+ /**
+ * Returns the detail message string of this throwable
+ */
+ public String getMessage ()
+ {
+ return "Input length = " + inputLength;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/UnsupportedCharsetException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/UnsupportedCharsetException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/UnsupportedCharsetException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/UnsupportedCharsetException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,69 @@
+/* UnsupportedCharsetException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.charset;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class UnsupportedCharsetException extends IllegalArgumentException
+{
+ /**
+ * Compatible with JDK 1.4+
+ */
+ private static final long serialVersionUID = 1490765524727386367L;
+
+ String charsetName;
+
+ /**
+ * Creates the exception
+ */
+ public UnsupportedCharsetException (String charsetName)
+ {
+ super ();
+ this.charsetName = charsetName;
+ }
+
+ /**
+ * Retrieves the illegal charset name
+ */
+ public String getCharsetName ()
+ {
+ return charsetName;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.nio.charset package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.nio.charset</title></head>
+
+<body>
+<p>Classes to manipulate, encode and decode different character sets from
+and to bytes.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/spi/CharsetProvider.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/spi/CharsetProvider.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/spi/CharsetProvider.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/spi/CharsetProvider.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,95 @@
+/* CharsetProvider.java -- charset service provider interface
+ Copyright (C) 2002, 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.charset.spi;
+
+import java.nio.charset.Charset;
+import java.util.Iterator;
+
+
+/**
+ * This class allows an implementor to provide additional character sets. The
+ * subclass must have a nullary constructor, and be attached to charset
+ * implementation classes. These extensions are loaded via the context class
+ * loader. To provide the charset extension, all files named
+ * <code>META-INF/services/java.nio.charset.spi.CharsetProvider</code> are
+ * read from the classpath. Each one should be a UTF-8 encoded list of
+ * fully-qualified names of concrete subclasses of this class; whitespace is
+ * ignored, and '#' starts comments. Duplicates are ignored. The
+ * implementations must be accessible to the classloader that requests them.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Charset
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public abstract class CharsetProvider
+{
+ /**
+ * Initialize a new charset provider. This performs a security check on
+ * RuntimePermission("charsetProvider").
+ *
+ * @throws SecurityException if building a new set is not allowed
+ */
+ protected CharsetProvider()
+ {
+ // We only do the security check for custom providers, not for the
+ // built in ones.
+ SecurityManager s = System.getSecurityManager();
+ if (s != null &&
+ ! (this instanceof gnu.java.nio.charset.Provider
+ || this instanceof gnu.java.nio.charset.iconv.IconvProvider))
+ s.checkPermission(new RuntimePermission("charsetProvider"));
+ }
+
+ /**
+ * Returns an iterator over the charsets defined by this provider.
+ *
+ * @return the iterator
+ * @see Charset#availableCharsets()
+ */
+ public abstract Iterator charsets();
+
+ /**
+ * Returns the named charset, by canonical name or alias.
+ *
+ * @param name the name of the character
+ *
+ * @return the charset, or null if not supported
+ */
+ public abstract Charset charsetForName(String name);
+} // class CharsetProvider
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/spi/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/spi/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/spi/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/charset/spi/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.nio.charset.spi package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.nio.charset.spi</title></head>
+
+<body>
+<p>Classes to provide new character sets.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/nio/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/nio/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/nio/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/nio/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.nio package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.nio</title></head>
+
+<body>
+<p>Abstract classes for manipulating buffers of different primitive types.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/AccessException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/AccessException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/AccessException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/AccessException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,77 @@
+/* AccessException.java -- thrown if the caller does not have access
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown to indicate that the caller does not have permission to access
+ * certain data, such as <code>bind</code> in an ActivationSystem.
+ *
+ * @author unknown
+ * @see Naming
+ * @see java.rmi.activation.ActivationSystem
+ * @since 1.1
+ */
+public class AccessException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 6314925228044966088l;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public AccessException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public AccessException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/AlreadyBoundException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/AlreadyBoundException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/AlreadyBoundException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/AlreadyBoundException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* AlreadyBoundException.java -- thrown if a binding is already bound
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown on an attempt to bind an object in the registry that is already
+ * bound.
+ *
+ * @author unknown
+ * @see java.rmi.Naming#bind(String, Remote)
+ * @see java.rmi.registry.Registry#bind(String, Remote)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class AlreadyBoundException extends Exception
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 9218657361741657110L;
+
+ /**
+ * Create an exception with no message.
+ */
+ public AlreadyBoundException()
+ {
+ }
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public AlreadyBoundException(String s)
+ {
+ super(s);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ConnectException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ConnectException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ConnectException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ConnectException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* ConnectException.java -- thrown if a connection is refused
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown if a connection is refused for a remote call.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ConnectException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 4863550261346652506L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public ConnectException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public ConnectException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ConnectIOException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ConnectIOException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ConnectIOException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ConnectIOException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* ConnectIOException.java -- thrown if an IO exception occurs during connect
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Wraps an I/O Exception thrown while connecting for a remote call.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ConnectIOException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -8087809532704668744L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public ConnectIOException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public ConnectIOException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/MarshalException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/MarshalException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/MarshalException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/MarshalException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* MarshalException.java -- wraps error while marshalling parameters
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown if an exception occurs while marshalling data to send in a remote
+ * call. The call may not be retransmitted, if the "at most once" semantics
+ * are to be preserved.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class MarshalException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 6223554758134037936L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public MarshalException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public MarshalException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/MarshalledObject.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/MarshalledObject.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/MarshalledObject.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/MarshalledObject.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,154 @@
+/* MarshalledObject.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi;
+
+import gnu.java.rmi.RMIMarshalledObjectInputStream;
+import gnu.java.rmi.RMIMarshalledObjectOutputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.Serializable;
+
+/**
+ * A <code>MarshalledObject</code> consists of a serialized object which is
+ * marshalled according to the RMI specification.
+ * <p>
+ * An object passed to the constructor is serialized and tagged with the needed
+ * URL to retrieve its class definition for remote usage. If the object is a
+ * remote reference its stub is serialized instead. The instance of this
+ * marshalled object can be later retrieved by its <code>get()</code> method.
+ * </p>
+ *
+ * @author unknown
+ */
+public final class MarshalledObject
+ implements Serializable
+{
+ // The following fields are from Java API Documentation "Serialized form"
+ private static final long serialVersionUID = 8988374069173025854L;
+
+ byte[] objBytes;
+ byte[] locBytes;
+ int hash;
+
+ /**
+ * Constructs a <code>MarshalledObject</code> from the given object.
+ *
+ * @param obj the object to marshal
+ * @throws IOException if an I/O error during serialization occurs.
+ */
+ public MarshalledObject(Object obj) throws IOException
+ {
+ ByteArrayOutputStream objStream = new ByteArrayOutputStream();
+ RMIMarshalledObjectOutputStream stream =
+ new RMIMarshalledObjectOutputStream(objStream);
+ stream.writeObject(obj);
+ stream.flush();
+ objBytes = objStream.toByteArray();
+ locBytes = stream.getLocBytes();
+
+ // The following algorithm of calculating hashCode is similar to String
+ hash = 0;
+ for (int i = 0; i < objBytes.length; i++)
+ hash = hash * 31 + objBytes[i];
+
+ if (locBytes != null)
+ for (int i = 0; i < locBytes.length; i++)
+ hash = hash * 31 + locBytes[i];
+ }
+
+ /**
+ * Checks if the given object is equal to this marshalled object.
+ *
+ * <p>Marshalled objects are considered equal if they contain the
+ * same serialized object. Codebase annotations where the class
+ * definition can be downloaded are ignored in the equals test.</p>
+ *
+ * @param obj the object to compare.
+ * @return <code>true</code> if equal, <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (! (obj instanceof MarshalledObject))
+ return false;
+
+ // hashCode even differs, don't do the time-consuming comparisons
+ if (obj.hashCode() != hash)
+ return false;
+
+ MarshalledObject aobj = (MarshalledObject) obj;
+ if (objBytes == null || aobj.objBytes == null)
+ return objBytes == aobj.objBytes;
+ if (objBytes.length != aobj.objBytes.length)
+ return false;
+ for (int i = 0; i < objBytes.length; i++)
+ {
+ if (objBytes[i] != aobj.objBytes[i])
+ return false;
+ }
+ // Ignore comparison of locBytes(annotation)
+ return true;
+ }
+
+ /**
+ * Constructs and returns a copy of the internal serialized object.
+ *
+ * @return The deserialized object.
+ *
+ * @throws IOException if an I/O exception occurs during deserialization.
+ * @throws ClassNotFoundException if the class of the deserialized object
+ * cannot be found.
+ */
+ public Object get() throws IOException, ClassNotFoundException
+ {
+ if (objBytes == null)
+ return null;
+
+ RMIMarshalledObjectInputStream stream =
+ new RMIMarshalledObjectInputStream(objBytes, locBytes);
+ return stream.readObject();
+ }
+
+ public int hashCode()
+ {
+ return hash;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/Naming.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/Naming.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/Naming.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/Naming.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,234 @@
+/* Naming.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+/**
+ * <p>
+ * The <code>Naming</code> class handles interactions with RMI registries.
+ * Each method takes a URL in <code>String</code> form, which points to
+ * the RMI registry. The scheme of the URL is irrelevant. The relevant
+ * part is:
+ * </p>
+ * <p>
+ * <code>//host:port/name</code>
+ * </p>
+ * <p>
+ * which tells the method how to locate and access the registry. The host
+ * and port are both optional, and default to `localhost' and the standard
+ * RMI registry port (1099) respectively. The name is simply a string
+ * used to refer to a particular service hosted by the registry. The
+ * registry does not attempt to interpret this further.
+ * </p>
+ * <p>
+ * RMI services are registered using one of these names, and the same name
+ * is later used by the client to lookup the service and access its methods.
+ * Registries can be shared by multiple services, or a service can create
+ * its own registry using <code>createRegistry()</code>.
+ * </p>
+ *
+ * @author Original author unknown.
+ * @author Ingo Proetel (proetel at aicas.com)
+ * @author Guilhem Lavaux (guilhem at kaffe.org)
+ * @author Jeroen Frijters (jeroen at frijters.net)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.1
+ */
+public final class Naming
+{
+ /**
+ * This class isn't intended to be instantiated.
+ */
+ private Naming()
+ {
+ }
+
+ /**
+ * Looks for the remote object that is associated with the named service.
+ * Name and location is given in form of a URL without a scheme:
+ *
+ * <pre>
+ * //host:port/service-name
+ * </pre>
+ *
+ * The port is optional.
+ *
+ * @param name the service name and location
+ * @return Remote-object that implements the named service
+ * @throws NotBoundException if no object implements the service
+ * @throws MalformedURLException
+ * @throws RemoteException
+ */
+ public static Remote lookup(String name) throws NotBoundException,
+ MalformedURLException, RemoteException
+ {
+ URL u = parseURL(name);
+ String serviceName = getName(u);
+ return (getRegistry(u).lookup(serviceName));
+ }
+
+ /**
+ * Try to bind the given object to the given service name.
+ *
+ * @param name
+ * @param obj
+ * @throws AlreadyBoundException
+ * @throws MalformedURLException
+ * @throws RemoteException
+ */
+ public static void bind(String name, Remote obj)
+ throws AlreadyBoundException, MalformedURLException, RemoteException
+ {
+ URL u = parseURL(name);
+ String serviceName = getName(u);
+ getRegistry(u).bind(serviceName, obj);
+ }
+
+ /**
+ * Remove a binding for a given service name.
+ *
+ * @param name
+ * @throws RemoteException
+ * @throws NotBoundException
+ * @throws MalformedURLException
+ */
+ public static void unbind(String name) throws RemoteException,
+ NotBoundException, MalformedURLException
+ {
+ URL u = parseURL(name);
+ String serviceName = getName(u);
+ getRegistry(u).unbind(serviceName);
+ }
+
+ /**
+ * Forces the binding between the given Remote-object and the given service
+ * name, even if there was already an object bound to this name.
+ *
+ * @param name
+ * @param obj
+ * @throws RemoteException
+ * @throws MalformedURLException
+ */
+ public static void rebind(String name, Remote obj) throws RemoteException,
+ MalformedURLException
+ {
+ URL u = parseURL(name);
+ String serviceName = getName(u);
+ getRegistry(u).rebind(serviceName, obj);
+ }
+
+ /**
+ * Lists all services at the named registry.
+ *
+ * @param name url that specifies the registry
+ * @return list of services at the name registry
+ * @throws RemoteException
+ * @throws MalformedURLException
+ */
+ public static String[] list(String name) throws RemoteException,
+ MalformedURLException
+ {
+ return (getRegistry(parseURL(name)).list());
+ }
+
+ private static Registry getRegistry(URL u) throws RemoteException
+ {
+ if (u.getPort() == - 1)
+ {
+ return (LocateRegistry.getRegistry(u.getHost()));
+ }
+ else
+ {
+ return (LocateRegistry.getRegistry(u.getHost(), u.getPort()));
+ }
+ }
+
+ /**
+ * Parses the supplied URL and converts it to use the HTTP protocol. From an
+ * RMI perspective, the scheme is irrelevant and we want to be able to create
+ * a URL for which a handler is available.
+ *
+ * @param name the URL in String form.
+ * @throws MalformedURLException if the URL is invalid.
+ */
+ private static URL parseURL(String name) throws MalformedURLException
+ {
+ try
+ {
+ URI uri = new URI(name);
+ String host = uri.getHost();
+ int port = uri.getPort();
+ String query = uri.getQuery();
+ String path = uri.getPath();
+ return new URL("http", (host == null ? "localhost" : host),
+ (port == - 1 ? 1099 : port), uri.getPath()
+ + (query == null ? "" : query));
+ }
+ catch (URISyntaxException e)
+ {
+ throw new MalformedURLException("The URL syntax was invalid: "
+ + e.getMessage());
+ }
+ }
+
+ /**
+ * Checks that the URL contains a name, and removes any leading slashes.
+ *
+ * @param url the URL to check.
+ * @throws MalformedURLException if no name is specified.
+ */
+ private static String getName(URL url) throws MalformedURLException
+ {
+ String filename = url.getFile();
+ if (filename.length() == 0)
+ throw new MalformedURLException("No path specified: " + url);
+ // If the filename begins with a slash we must cut it for
+ // name resolution.
+ if (filename.charAt(0) == '/')
+ return filename.substring(1);
+ return filename;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/NoSuchObjectException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/NoSuchObjectException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/NoSuchObjectException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/NoSuchObjectException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,69 @@
+/* NoSuchObjectException.java -- thrown if the remote object no longer exists
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown on an attempt to invoke a call on an object that no longer exists
+ * in the remote Virtual Machine. The call may be retransmitted and still
+ * obey the semantics of "at most once".
+ *
+ * @author unknown
+ * @see java.rmi.server.RemoteObject#toStub(Remote)
+ * @see java.rmi.server.UnicastRemoteObject#unexportObject(Remote, boolean)
+ * @see java.rmi.activation.Activatable#unexportObject(Remote, boolean)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class NoSuchObjectException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 6619395951570472985L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public NoSuchObjectException(String s)
+ {
+ super(s);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/NotBoundException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/NotBoundException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/NotBoundException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/NotBoundException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* NotBoundException.java -- attempt to use a registry name with no binding
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown on an attempt to lookup or unbind a registry name that has no
+ * associated binding.
+ *
+ * @author unknown
+ * @see java.rmi.Naming#lookup(String)
+ * @see java.rmi.Naming#unbind(String)
+ * @see java.rmi.registry.Registry#lookup(String)
+ * @see java.rmi.registry.Registry#unbind(String)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class NotBoundException extends Exception
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -1857741824849069317l;
+
+ /**
+ * Create an exception with no message.
+ */
+ public NotBoundException()
+ {
+ }
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public NotBoundException(String s)
+ {
+ super(s);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/RMISecurityException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/RMISecurityException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/RMISecurityException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/RMISecurityException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* RMISecurityException.java -- deprecated version of SecurityException
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Never thrown, but originally intended to wrap a
+ * {@link java.lang.SecurityException} in the case of RMI.
+ *
+ * @author unknown
+ * @since 1.1
+ * @deprecated use {@link java.lang.SecurityException} instead
+ * @status updated to 1.4
+ */
+public class RMISecurityException extends SecurityException
+{
+ /**
+ * Compatible with JDK 1.1.
+ */
+ private static final long serialVersionUID = -8433406075740433514L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param n the message
+ * @deprecated no longer needed
+ */
+ public RMISecurityException(String n)
+ {
+ super(n);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param n the message
+ * @param a the cause (ignored)
+ * @deprecated no longer needed
+ */
+ public RMISecurityException(String n, String a)
+ {
+ super(n);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/RMISecurityManager.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/RMISecurityManager.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/RMISecurityManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/RMISecurityManager.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,48 @@
+/* RMISecurityManager.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 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 java.rmi;
+
+/**
+ * @since 1.1
+ */
+public class RMISecurityManager extends SecurityManager
+{
+ public RMISecurityManager()
+ {
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/Remote.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/Remote.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/Remote.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/Remote.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,58 @@
+/* Remote.java
+ Copyright (c) 1996, 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Marker interface for interfaces which methods are invokable
+ * from outside of this virtual machine through remote method calls.
+ * <p>
+ * Remote invokable methods of remote object implementations are specified
+ * as the methods defined in the implemented remote interfaces. Typically
+ * remote object implementations are subclasses of the convenience classes
+ * {@link java.rmi.server.UnicastRemoteObject} or
+ * {@link java.rmi.activation.Activatable} implementing one or more remote
+ * interfaces indicating their remotely accessible methods. The convenience
+ * classes provide implementations for correct remote object creation,
+ * hash, equals and toString methods.
+ * </p>
+ *
+ * @author unknown
+ */
+public interface Remote {
+ // marker interface
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/RemoteException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/RemoteException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/RemoteException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/RemoteException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,128 @@
+/* RemoteException.java -- common superclass for exceptions in java.rmi
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+import java.io.IOException;
+
+/**
+ * The superclass of exceptions related to RMI (remote method invocation).
+ * Classes that implement <code>java.rmi.Remote</code> should list this
+ * exception in their throws clause.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class RemoteException extends IOException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = -5148567311918794206l;
+
+ /**
+ * The cause of this exception. This pre-dates the exception chaining
+ * of Throwable; and although you can change this field, you are wiser
+ * to leave it alone.
+ *
+ * @serial the exception cause
+ */
+ public Throwable detail;
+
+ /**
+ * Create an exception with no message, and cause initialized to null.
+ */
+ public RemoteException()
+ {
+ this(null, null);
+ }
+
+ /**
+ * Create an exception with the given message, and cause initialized to null.
+ *
+ * @param s the message
+ */
+ public RemoteException(String s)
+ {
+ this(s, null);
+ }
+
+ /**
+ * Create an exception with the given message and cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public RemoteException(String s, Throwable e)
+ {
+ super(s);
+ initCause(e);
+ detail = e;
+ }
+
+ /**
+ * This method returns a message indicating what went wrong, in this
+ * format:
+ * <code>super.getMessage() + (detail == null ? ""
+ * : "; nested exception is:\n\t" + detail)</code>.
+ *
+ * @return the chained message
+ */
+ public String getMessage()
+ {
+ if (detail == this || detail == null)
+ return super.getMessage();
+ return super.getMessage() + "; nested exception is:\n\t" + detail;
+ }
+
+ /**
+ * Returns the cause of this exception. Note that this may not be the
+ * original cause, thanks to the <code>detail</code> field being public
+ * and non-final (yuck). However, to avoid violating the contract of
+ * Throwable.getCause(), this returns null if <code>detail == this</code>,
+ * as no exception can be its own cause.
+ *
+ * @return the cause
+ * @since 1.4
+ */
+ public Throwable getCause()
+ {
+ return detail == this ? null : detail;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ServerError.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ServerError.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ServerError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ServerError.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,64 @@
+/* ServerError.java -- wraps an error while creating the server
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Wraps any error thrown while processing the server of a remote call.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ServerError extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 8455284893909696482L;
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public ServerError(String s, Error e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ServerException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ServerException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ServerException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ServerException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* ServerException.java -- wraps an exception while creating the server
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Wraps any exception thrown while processing the server of a remote call.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ServerException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -4775845313121906682l;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public ServerException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public ServerException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ServerRuntimeException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ServerRuntimeException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ServerRuntimeException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/ServerRuntimeException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,67 @@
+/* ServerRuntimeException.java -- wraps an exception while creating the server
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Wraps any runtime exception thrown while processing the server of a
+ * remote call. Note, this exception is no longer used.
+ *
+ * @author unknown
+ * @since 1.1
+ * @deprecated no replacement
+ * @status updated to 1.4
+ */
+public class ServerRuntimeException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1.
+ */
+ private static final long serialVersionUID = 7054464920481467219L;
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ * @deprecated no longer needed
+ */
+ public ServerRuntimeException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/StubNotFoundException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/StubNotFoundException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/StubNotFoundException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/StubNotFoundException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* StubNotFoundException.java -- thrown if a valid stub is not found
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown if a valid stub class is not found for an object when it is exported.
+ *
+ * @author unknown
+ * @see java.rmi.server.UnicastRemoteObject
+ * @see java.rmi.activation.Activatable
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class StubNotFoundException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = -7088199405468872373L;
+
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public StubNotFoundException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public StubNotFoundException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/UnexpectedException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/UnexpectedException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/UnexpectedException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/UnexpectedException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* UnexpectedException.java -- an unexpected checked exception was received
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown if an unexpected checked exception was received in a remote
+ * procedure call.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class UnexpectedException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 1800467484195073863L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public UnexpectedException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public UnexpectedException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/UnknownHostException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/UnknownHostException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/UnknownHostException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/UnknownHostException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* UnknownHostException.java -- wraps java.net.UnknownHostException in RMI
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown if a java.net.UnknownHostException occurs during a remote
+ * procedure call.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class UnknownHostException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -8152710247442114228L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public UnknownHostException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public UnknownHostException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/UnmarshalException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/UnmarshalException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/UnmarshalException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/UnmarshalException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,88 @@
+/* UnmarshalException.java -- wraps error while unmarshalling parameters
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown if an exception occurs while unmarshalling parameters or results
+ * of a remote method call. This includes:<br><ul>
+ * <li>if an exception occurs while unmarshalling the call header</li>
+ * <li>if the protocol for the return value is invalid</li>
+ * <li>if a java.io.IOException occurs unmarshalling parameters (on the
+ * server side) or the return value (on the client side).</li>
+ * <li>if a java.lang.ClassNotFoundException occurs during unmarshalling
+ * parameters or return values</li>
+ * <li>if no skeleton can be loaded on the server-side; note that skeletons
+ * are required in the 1.1 stub protocol, but not in the 1.2 stub
+ * protocol.</li>
+ * <li>if the method hash is invalid (i.e., missing method).</li>
+ * <li>if there is a failure to create a remote reference object for a remote
+ * object's stub when it is unmarshalled.</li>
+ * </ul>
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class UnmarshalException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 594380845140740218l;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public UnmarshalException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public UnmarshalException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/Activatable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/Activatable.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/Activatable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/Activatable.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,531 @@
+/* Activatable.java -- A common ancestor for the activatable objects.
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import gnu.java.rmi.server.ActivatableServerRef;
+import gnu.java.rmi.server.UnicastServer;
+import gnu.java.rmi.server.UnicastServerRef;
+
+import java.lang.reflect.Field;
+import java.rmi.MarshalledObject;
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.server.ObjID;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.RemoteObject;
+import java.rmi.server.RemoteServer;
+import java.rmi.server.UnicastRemoteObject;
+
+/**
+ * A common ancestor for the implementations of the activatable objects. Such
+ * objects require persistent access over time and can be activated by the
+ * system. The derived classes also implements the needed interface of some
+ * remote object and usually have the two parameter constructor, the first
+ * parameter being the {@link ActivationID} and the second the
+ * {@link MarshalledObject}. Activatable is the main class that developers need
+ * to use to implement and manage activatable objects. It also contains methods
+ * for making activatable remote objects that are not derived from the
+ * Activatable class.
+ *
+ * @author Audrius Meskauskas (audriusa at bioinformatics.org) (from stub)
+ */
+public abstract class Activatable
+ extends RemoteServer
+{
+
+ /**
+ * Use SVUID for interoperability.
+ */
+ static final long serialVersionUID = - 3120617863591563455L;
+
+ /**
+ * The object activation id.
+ */
+ final ActivationID id;
+
+ /**
+ * This constructor is used to register export the object on the given port. A
+ * subclass of the Activatable class calls this constructor to register and
+ * export the object during initial construction. As a side-effect of
+ * activatable object construction, the remote object is both "registered"
+ * with the activation system and "exported" (on an anonymous port, if port is
+ * zero) to the RMI runtime so that it is available to accept incoming calls
+ * from clients.
+ *
+ * @param codebase the object code base url
+ * @param data the data, needed to activate the object.
+ * @param restart specifies reactivation mode after crash. If true, the object
+ * is activated when activator is restarted or the activation group
+ * is restarted. If false, the object is only activated on demand.
+ * This flag does has no effect during the normal operation (the
+ * object is normally activated on demand).
+ * @param port the port, on which the object will become available. The value
+ * 0 means anonymous port.
+ * @throws ActivationException if the activation failed
+ * @throws RemoteException if the remote call failed.
+ */
+ protected Activatable(String codebase, MarshalledObject data,
+ boolean restart, int port) throws ActivationException,
+ RemoteException
+ {
+ ActivationDesc descriptor = new ActivationDesc(getClass().getName(),
+ codebase, data, restart);
+ id = obtainId(descriptor);
+ exportObject(this, id, port);
+ }
+
+ /**
+ * This constructor is used to register export the object on the given port,
+ * additionally specifying the socket factories. A subclass of the Activatable
+ * class calls this constructor to register and export the object during
+ * initial construction.
+ *
+ * @param codebase the object code base url
+ * @param data the data, needed to activate the object.
+ * @param restart specifies reactivation mode after crash. If true, the object
+ * is activated when activator is restarted or the activation group
+ * is restarted. If false, the object is only activated on demand.
+ * This flag does has no effect during the normal operation (the
+ * object is normally activated on demand).
+ * @param port the port, on which the object will become available. The value
+ * 0 means anonymous port.
+ * @param csf the client socket factory
+ * @param ssf the server socket factory
+ * @throws ActivationException if the activation failed
+ * @throws RemoteException if the remote call failed.
+ */
+ protected Activatable(String codebase, MarshalledObject data,
+ boolean restart, int port, RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf) throws ActivationException,
+ RemoteException
+ {
+ ActivationDesc descriptor = new ActivationDesc(getClass().getName(),
+ codebase, data, restart);
+ id = obtainId(descriptor);
+ exportObject(this, id, port);
+ }
+
+ /**
+ * Creates the new instance of activatable with the given activation id and is
+ * listening at the given port. A subclass of the Activatable class calls this
+ * constructor when the object itself is activated via its special
+ * "activation" constructor with the two parameters ({@link ActivationID},
+ * {@link MarshalledObject}). As a side effect, the object is exported and is
+ * available to accept incomming calls.
+ *
+ * @param anId the activation id
+ * @param port the port, on which the activatable will be listening
+ * @throws RemoteException if the activation failed.
+ */
+ protected Activatable(ActivationID anId, int port) throws RemoteException
+ {
+ id = anId;
+ try
+ {
+ exportObject(this, anId, port);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ RemoteException acex =
+ new RemoteException("cannot export Activatable", e);
+ throw acex;
+ }
+ }
+
+ /**
+ * Creates the new instance of activatable with the given activation id and is
+ * listening at the given port, using the specified client and server sockets
+ * factories. A subclass of the Activatable class calls this
+ * constructor when the object itself is activated via its special
+ * "activation" constructor with the two parameters ({@link ActivationID},
+ * {@link MarshalledObject}). As a side effect, the object is exported and is
+ * available to accept incomming calls.
+ *
+ * @param anId the activation id
+ * @param port the port, on which the activatable will be listening
+ * @param csf the client socket factory
+ * @param ssf the server socket factory
+ *
+ * @throws RemoteException if the remote call failed
+ */
+ protected Activatable(ActivationID anId, int port, RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf) throws RemoteException
+ {
+ id = anId;
+ try
+ {
+ exportObject(this, anId, port, csf, ssf);
+ }
+ catch (Exception e)
+ {
+ RemoteException acex = new RemoteException();
+ acex.initCause(e);
+ throw acex;
+ }
+ }
+
+ /**
+ * Get the objects activation identifier.
+ *
+ * @return the object activation identifier
+ */
+ protected ActivationID getID()
+ {
+ return id;
+ }
+
+ /**
+ * Obtain the activation Id from the activation descriptor by registering
+ * within the current group.
+ */
+ static ActivationID obtainId(ActivationDesc descriptor)
+ throws RemoteException, UnknownGroupException, ActivationException
+ {
+ ActivationGroupID id = descriptor.getGroupID();
+ ActivationSystem system;
+
+ if (id != null)
+ system = id.getSystem();
+ else
+ system = ActivationGroup.currentGroupID().getSystem();
+ return system.registerObject(descriptor);
+ }
+
+ /**
+ * This method registers an activatable object. The object is expected to be
+ * on the anonymous port (null client and server socket factories).
+ *
+ * @param desc the object description.
+ * @return the remote stub for the activatable object (the first call on this
+ * stub will activate the object).
+ * @throws UnknownGroupException if the object group identifier is unknown
+ * @throws ActivationException if the activation system is not running
+ * @throws RemoteException if the remote call fails
+ */
+ public static Remote register(ActivationDesc desc)
+ throws UnknownGroupException, ActivationException, RemoteException
+ {
+ ActivationID id = obtainId(desc);
+ try
+ {
+ return toStub(
+ id,
+ Thread.currentThread().getContextClassLoader().loadClass(
+ desc.getClassName()));
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new ActivationException("Class not found: "+desc.getClassName());
+ }
+ }
+
+ /**
+ * Inactivates and unexports the object. The subsequent calls will activate
+ * the object again. The object is not inactivated if it is currently
+ * executing calls.
+ *
+ * @param id the id of the object being inactivated
+ * @return true if the object has been inactivated, false if it has not been
+ * inactivated because of the running or pending calls.
+ * @throws UnknownObjectException if the object is unknown.
+ * @throws ActivationException if the object group is not active
+ * @throws RemoteException if the remote call fails
+ */
+ public static boolean inactive(ActivationID id)
+ throws UnknownObjectException, ActivationException, RemoteException
+ {
+ if (id.group!=null)
+ id.group.inactiveObject(id);
+ return UnicastRemoteObject.unexportObject(id.activate(false), false);
+ }
+
+ /**
+ * Unregister the object (the object will no longer be activable with that id)
+ *
+ * @param id the object id
+ * @throws UnknownObjectException if the id is unknown
+ * @throws ActivationException if the activation system is not running
+ * @throws RemoteException if the remote call fails.
+ */
+ public static void unregister(ActivationID id) throws UnknownObjectException,
+ ActivationException, RemoteException
+ {
+ ActivationGroup.currentGroupId.getSystem().unregisterObject(id);
+ UnicastServer.unregisterActivatable(id);
+ }
+
+ /**
+ * Register and export the object that activatable object that is not derived
+ * from the Activatable super class. It creates and registers the object
+ * activation descriptor. There is no need to call this method if the object
+ * extends Activable, as its work is done in the constructor
+ * {@link #Activatable(String, MarshalledObject, boolean, int)}.
+ *
+ * @param obj the object, that is exported, becoming available at the given
+ * port.
+ * @param location the object code location (codebase).
+ * @param data the data, needed to activate the object
+ * @param restart the restart mode
+ * @param port the port, where the object will be available
+ *
+ * @return the created object activation ID.
+ *
+ * @throws ActivationException if the activation group is not active
+ * @throws RemoteException if the registration or export fails
+ */
+ public static ActivationID exportObject(Remote obj, String location,
+ MarshalledObject data,
+ boolean restart, int port)
+ throws ActivationException, RemoteException
+ {
+ ActivationDesc descriptor = new ActivationDesc(obj.getClass().getName(),
+ location, data, restart);
+ ActivationID id = obtainId(descriptor);
+ Remote stub = exportObject(obj, id, port);
+ return id;
+ }
+
+ /**
+ * Register and export the object that activatable object that is not derived
+ * from the Activatable super class. It creates and registers the object
+ * activation descriptor. There is no need to call this method if the object
+ * extends Activable, as its work is done in the constructor
+ * {@link #Activatable(String, MarshalledObject, boolean, int, RMIClientSocketFactory, RMIServerSocketFactory)}
+ *
+ * @param obj the object, that is exported, becoming available at the given
+ * port.
+ * @param location the object code location (codebase).
+ * @param data the data, needed to activate the object
+ * @param restart the restart mode
+ * @param port the port, where the object will be available
+ * @param csf the client socket factory
+ * @param ssf the server socket factory
+ *
+ * @return the created object activation ID.
+ *
+ * @throws ActivationException if the activation group is not active
+ * @throws RemoteException if the registration or export fails
+ */
+ public static ActivationID exportObject(Remote obj, String location,
+ MarshalledObject data,
+ boolean restart, int port,
+ RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf)
+ throws ActivationException, RemoteException
+ {
+ ActivationDesc descriptor = new ActivationDesc(obj.getClass().getName(),
+ location, data, restart);
+ ActivationID id = obtainId(descriptor);
+ Remote stub = exportObject(obj, id, port, csf, ssf);
+ return id;
+
+ }
+
+ /**
+ * During activation, this exportObject method should be invoked explicitly by
+ * the activatable object, that does is not derived from the Activatable
+ * class. There is no need to call this method if the object extends
+ * Activable, as its work is done in the constructor
+ * {@link #Activatable(ActivationID, int)}
+ *
+ * @param obj the object
+ * @param id the known activation id
+ * @param port the object port
+ *
+ * @return the remote stub of the activatable object
+ *
+ * @throws RemoteException if the object export fails
+ */
+ public static Remote exportObject(Remote obj, ActivationID id, int port)
+ throws RemoteException
+ {
+ Remote stub = export(id, obj, port, null);
+ return stub;
+ }
+
+ /**
+ * During activation, this exportObject method should be invoked explicitly by
+ * the activatable object, that does is not derived from the Activatable
+ * class. There is no need to call this method if the object extends
+ * Activable, as its work is done in the constructor
+ * {@link #Activatable(ActivationID, int)}
+ *
+ * @param obj the object
+ * @param id the known activation id
+ * @param port the object port
+ * @param csf the client socket factory
+ * @param ssf the server socket factory
+ *
+ * @return the remote stub of the activatable object
+ *
+ * @throws RemoteException if the object export fails
+ */
+ public static Remote exportObject(Remote obj, ActivationID id, int port,
+ RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf)
+ throws RemoteException
+ {
+ Remote stub = export(id, obj, port, ssf);
+ return stub;
+
+ }
+
+ /**
+ * Make the remote object unavailable for incoming calls. This method also
+ * unregisters the object, so it cannot be activated again by incomming call
+ * (unless registered).
+ *
+ * @param obj the object to unexport
+ * @param force if true, cancel all pending or running calls to that object
+ * (if false, the object with such calls is not unexported and false
+ * is returned by this method).
+ * @return if the object was successfully unexported, false otherwise
+ * @throws NoSuchObjectException if such object is not known
+ */
+ public static boolean unexportObject(Remote obj, boolean force)
+ throws NoSuchObjectException
+ {
+ Object aref = UnicastServer.getExportedRef(obj);
+
+ // Unregister it also (otherwise will be activated during the subsequent
+ // call.
+ if (aref instanceof ActivatableServerRef)
+ {
+ ActivatableServerRef aar = (ActivatableServerRef) aref;
+ UnicastServer.unregisterActivatable(aar.actId);
+ }
+ return UnicastRemoteObject.unexportObject(obj, force);
+ }
+
+ static Remote exportObject(Remote obj, int port,
+ RMIServerSocketFactory serverSocketFactory)
+ throws RemoteException
+ {
+ UnicastServerRef sref = null;
+ if (obj instanceof RemoteObject)
+ sref = (UnicastServerRef) ((RemoteObject) obj).getRef();
+
+ if (sref == null)
+ sref = new UnicastServerRef(new ObjID(), port, serverSocketFactory);
+
+ Remote stub = sref.exportObject(obj);
+ // addStub(obj, stub);
+ // TODO Need to change the place of the stub repository
+ return stub;
+ }
+
+ /**
+ * Create and export the new remote object, making it available at the given
+ * port, using sockets, produced by the specified factories.
+ *
+ * @param port the port, on that the object should become available. Zero
+ * means anonymous port.
+ * @param serverSocketFactory the server socket factory
+ */
+ public static Remote export(ActivationID id, Remote obj, int port,
+ RMIServerSocketFactory serverSocketFactory)
+ throws RemoteException
+ {
+ ActivatableServerRef sref = null;
+ sref = new ActivatableServerRef(makeId(id), id, port, serverSocketFactory);
+ return sref.exportObject(obj);
+ }
+
+ /**
+ * Make the object ID from the activation ID. The same activation ID always
+ * produces the identical object id.
+ *
+ * @param aid the activation id
+ *
+ * @return the object id
+ */
+ public static ObjID makeId(ActivationID aid)
+ {
+ ObjID id = new ObjID(0);
+
+ // The fields of both ObjID and ActivationID must be package private,
+ // so we need to use the reflection to access them anyway.
+ // Probably other implementations use some very different approach.
+
+ try
+ {
+ Field idUid = ObjID.class.getDeclaredField("space");
+ Field aidUid = ActivationID.class.getDeclaredField("uid");
+
+ aidUid.setAccessible(true);
+ idUid.setAccessible(true);
+
+ idUid.set(id, aidUid.get(aid));
+ }
+ catch (Exception e)
+ {
+ InternalError ierr = new InternalError("Unable to set UID field");
+ ierr.initCause(e);
+ throw ierr;
+ }
+
+ return id;
+ }
+
+ /**
+ * Connect the object to the UnicastServer (export), but not activate it.
+ * The object will be activated on the first call.
+ */
+ static Remote toStub(ActivationID anId, Class stubFor)
+ {
+ try
+ {
+ ActivatableServerRef asr =
+ new ActivatableServerRef(makeId(anId), anId, 0, null);
+ UnicastServer.exportActivatableObject(asr);
+ return asr.exportClass(stubFor);
+ }
+ catch (RemoteException e)
+ {
+ InternalError ierr = new InternalError(
+ "Failed to obtain activatable stub");
+ ierr.initCause(e);
+ throw ierr;
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivateFailedException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivateFailedException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivateFailedException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivateFailedException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* ActivateFailedException.java -- thrown when activation fails
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.activation;
+
+import java.rmi.RemoteException;
+
+/**
+ * Thrown when activation fails on a remote call to an activatable object.
+ *
+ * @author unknown
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class ActivateFailedException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 4863550261346652506L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public ActivateFailedException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param ex the cause
+ */
+ public ActivateFailedException(String s, Exception ex)
+ {
+ super(s, ex);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationDesc.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationDesc.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationDesc.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationDesc.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,254 @@
+/* ActivationDesc.java -- record with info to activate an object
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.activation;
+
+import java.io.Serializable;
+import java.rmi.MarshalledObject;
+
+/**
+ * Contains the information, necessary to activate the object. This information
+ * includes:
+ * <ul>
+ * <li>the object class name</li>
+ * <li>the object group identifier</li>
+ * <li>the code location (codebase URL) that can be used to load the class
+ * remotely</li>
+ * <li>the object restart mode</li>
+ * <li>the object specific intialization information</li>
+ * </ul>
+ *
+ * @author Audrius Meskauskas (audriusa at bioinformatics.org) (from stub)
+ */
+public final class ActivationDesc
+ implements Serializable
+{
+ /**
+ * Use SVUID for interoperability.
+ */
+ static final long serialVersionUID = 7455834104417690957L;
+
+ /**
+ * The group id.
+ */
+ private ActivationGroupID groupid;
+
+ /**
+ * The class name.
+ */
+ private String classname;
+
+ /**
+ * The code location URL.
+ */
+ private String location;
+
+ /**
+ * The object specific intitalization data.
+ */
+ private MarshalledObject data;
+
+ /**
+ * The start mode.
+ */
+ private boolean restart;
+
+ /**
+ * Create the new activation description, assuming the object group is the
+ * {@link ActivationGroup#currentGroupID()}.
+ *
+ * @param className the object fully qualified class name
+ * @param location the code base URL
+ * @param data the object initialization data, contained in a marshalled form
+ */
+ public ActivationDesc(String className, String location, MarshalledObject data)
+ throws ActivationException
+ {
+ this(ActivationGroup.currentGroupID(), className, location, data, false);
+ }
+
+ /**
+ * Create the new activation description, assuming the object group is the
+ * {@link ActivationGroup#currentGroupID()}.
+ *
+ * @param className the object fully qualified class name
+ * @param location the code base URL
+ * @param data the object initialization data, contained in a marshalled form
+ * @param restart specifies reactivation mode after crash. If true, the object
+ * is activated when activator is restarted or the activation group
+ * is restarted. If false, the object is only activated on demand.
+ * This flag does has no effect during the normal operation (the
+ * object is normally activated on demand).
+ */
+ public ActivationDesc(String className, String location,
+ MarshalledObject data, boolean restart)
+ throws ActivationException
+ {
+ this(ActivationGroup.currentGroupID(), className, location, data, restart);
+ }
+
+ /**
+ * Create the new activation description. Under crash, the object will only
+ * be reactivated on demand.
+ *
+ * @param groupID the object group id.
+ * @param className the object fully qualified class name
+ * @param location the code base URL
+ * @param data the object initialization data, contained in a marshalled form
+ */
+ public ActivationDesc(ActivationGroupID groupID, String className,
+ String location, MarshalledObject data)
+ {
+ this(groupID, className, location, data, false);
+ }
+
+ /**
+ * Create the new activation description, providing full information.
+ *
+ * @param groupID the object group id.
+ * @param className the object fully qualified class name
+ * @param location the code base URL
+ * @param data the object initialization data, contained in a marshalled form
+ * @param restart specifies reactivation mode after crash. If true, the object
+ * is activated when activator is restarted or the activation group
+ * is restarted. If false, the object is only activated on demand.
+ * This flag does has no effect during the normal operation (the
+ * object is normally activated on demand).
+ */
+ public ActivationDesc(ActivationGroupID groupID, String className,
+ String location, MarshalledObject data, boolean restart)
+ {
+ this.groupid = groupID;
+ this.classname = className;
+ this.location = location;
+ this.data = data;
+ this.restart = restart;
+ }
+
+ public ActivationGroupID getGroupID()
+ {
+ return groupid;
+ }
+
+ /**
+ * Get the class name of the object being activated
+ *
+ * @return the fully qualified class name of the object being activated
+ */
+ public String getClassName()
+ {
+ return classname;
+ }
+
+ /**
+ * Get the code location URL ("codebase") of the object being activated.
+ *
+ * @return the codebase of the object being activated.
+ */
+ public String getLocation()
+ {
+ return location;
+ }
+
+ public MarshalledObject getData()
+ {
+ return data;
+ }
+
+ /**
+ * Get the object reactivation strategy after crash.
+ *
+ * @return true ir the object is activated when activator is restarted or the
+ * activation group is restarted. False if the object is only
+ * activated on demand. This flag does has no effect during the normal
+ * operation (the object is normally activated on demand).
+ */
+ public boolean getRestartMode()
+ {
+ return restart;
+ }
+
+ /**
+ * Compare this object with another activation description for equality.
+ *
+ * @return true if all fields have the equal values, false otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ActivationDesc)
+ {
+ ActivationDesc that = (ActivationDesc) obj;
+ return eq(groupid, that.groupid) &&
+ eq(classname, that.classname) &&
+ eq(location, that.location) &&
+ eq(data, that.data)
+ && restart == that.restart;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Get the hash code of this object (overridden to make the returned value
+ * consistent with .equals(..).
+ */
+ public int hashCode()
+ {
+ return hash(groupid) ^ hash(classname) ^
+ hash(location) ^ hash(data);
+ }
+
+ /**
+ * Get the hashcode of x or 0 if x == null.
+ */
+ static final int hash(Object x)
+ {
+ return x == null ? 0 : x.hashCode();
+ }
+
+ /**
+ * Compare by .equals if both a and b are not null, compare directly if at
+ * least one of them is null.
+ */
+ static final boolean eq(Object a, Object b)
+ {
+ if (a == null || b == null)
+ return a == b;
+ else
+ return a.equals(b);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,122 @@
+/* ActivationException.java -- general Activation exception
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.activation;
+
+/**
+ * General exception class for <code>java.rmi.activation</code>.
+ *
+ * @author unknown
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class ActivationException extends Exception
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = -4320118837291406071L;
+
+ /**
+ * The cause of this exception. This pre-dates the exception chaining
+ * of Throwable; and although you can change this field, you are wiser
+ * to leave it alone.
+ *
+ * @serial the exception cause
+ */
+ public Throwable detail;
+
+ /**
+ * Create an exception with no message, and cause initialized to null.
+ */
+ public ActivationException()
+ {
+ this(null, null);
+ }
+
+ /**
+ * Create an exception with the given message, and cause initialized to null.
+ *
+ * @param s the message
+ */
+ public ActivationException(String s)
+ {
+ this(s, null);
+ }
+
+ /**
+ * Create an exception with the given message and cause.
+ *
+ * @param s the message
+ * @param ex the cause
+ */
+ public ActivationException(String s, Throwable ex)
+ {
+ super(s, ex);
+ detail = ex;
+ }
+
+ /**
+ * This method returns a message indicating what went wrong, in this
+ * format:
+ * <code>super.getMessage() + (detail == null ? ""
+ * : "; nested exception is:\n\t" + detail)</code>.
+ *
+ * @return the chained message
+ */
+ public String getMessage()
+ {
+ if (detail == this || detail == null)
+ return super.getMessage();
+ return super.getMessage() + "; nested exception is:\n\t" + detail;
+ }
+
+ /**
+ * Returns the cause of this exception. Note that this may not be the
+ * original cause, thanks to the <code>detail</code> field being public
+ * and non-final (yuck). However, to avoid violating the contract of
+ * Throwable.getCause(), this returns null if <code>detail == this</code>,
+ * as no exception can be its own cause.
+ *
+ * @return the cause
+ * @since 1.4
+ */
+ public Throwable getCause()
+ {
+ return detail == this ? null : detail;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroup.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroup.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroup.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroup.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,339 @@
+/* ActivationGroup.java -- the RMI activation group.
+ Copyright (c) 1996, 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import gnu.java.rmi.activation.DefaultActivationGroup;
+import gnu.java.rmi.activation.DefaultActivationSystem;
+
+import java.lang.reflect.Constructor;
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+/**
+ * The entity that receives the request to activate object and activates it.
+ * Frequently there is one activation group per virtual machine.
+ *
+ * @author Audrius Meskauskas (audriusa at Bioinformatics.org) (from stub)
+ */
+public abstract class ActivationGroup
+ extends UnicastRemoteObject
+ implements ActivationInstantiator
+{
+
+ /**
+ * Use the SVUID for interoperability.
+ */
+ static final long serialVersionUID = - 7696947875314805420L;
+
+ /**
+ * The Id of the current group on this VM (null if none).
+ */
+ static ActivationGroupID currentGroupId = null;
+
+ /**
+ * The groups identifier.
+ */
+ final ActivationGroupID groupId;
+
+ /**
+ * The groups activation monitor.
+ */
+ ActivationMonitor monitor;
+
+ /**
+ * The groups incarnation number.
+ */
+ long incarnation;
+
+ /**
+ * The groups activation system.
+ */
+ static ActivationSystem system;
+
+ /**
+ * Used during the group creation (required constructor).
+ */
+ static final Class[] cConstructorTypes = new Class[]
+ {
+ ActivationGroupID.class,
+ MarshalledObject.class
+ };
+
+ /**
+ * Create the new activation group with the given group id.
+ *
+ * @param aGroupId the group Id.
+ *
+ * @throws RemoteException if the group export fails.
+ */
+ protected ActivationGroup(ActivationGroupID aGroupId) throws RemoteException
+ {
+ groupId = aGroupId;
+ }
+
+ /**
+ * The method is called when the object is exported. The group must notify
+ * the activation monitor, if this was not already done before.
+ *
+ * @param id the object activation id
+ * @param obj the remote object implementation
+ *
+ * @throws ActivationException if the group is inactive
+ * @throws UnknownObjectException if such object is not known
+ * @throws RemoteException if the call to monitor fails
+ */
+ public abstract void activeObject(ActivationID id, Remote obj)
+ throws ActivationException, UnknownObjectException, RemoteException;
+
+ /**
+ * Notifies the monitor about the object being inactivated.
+ *
+ * @param id the object being inactivated.
+ * @return true always (must be overridden to return other values).
+ * @throws ActivationException never
+ * @throws UnknownObjectException if the object is not known
+ * @throws RemoteException if the remote call to monitor fails
+ */
+ public boolean inactiveObject(ActivationID id) throws ActivationException,
+ UnknownObjectException, RemoteException
+ {
+ if (monitor != null)
+ monitor.inactiveObject(id);
+ return true;
+ }
+
+ /**
+ * Create the new instance of the activation group, using the class name and
+ * location information, stored in the passed descriptor. The method expects
+ * the group class to have the two parameter constructor, the first parameter
+ * being the {@link ActivationGroupID} and the second the
+ * {@link MarshalledObject}. The group must be first be registered with the
+ * ActivationSystem. Once a group is created, the currentGroupID method
+ * returns the identifier for this group until the group becomes inactive.
+ *
+ * @param id the activation group id
+ * @param desc the group descriptor, providing the information, necessary to
+ * create the group
+ * @param incarnation the incarnation number
+ * @return the created group instance
+ * @throws ActivationException if the activation fails due any reason
+ */
+ public static ActivationGroup createGroup(ActivationGroupID id,
+ ActivationGroupDesc desc,
+ long incarnation)
+ throws ActivationException
+ {
+ // If the activation system is not yet set, set it to the system.
+ // passed in the group id.
+ if (system == null)
+ system = id.system;
+
+ ActivationGroup group = null;
+
+ // TODO at the moment all groups are created on the current jre and the
+ // group class must be reachable via thread context class loader.
+ Class groupClass;
+
+ if (desc.className != null)
+ {
+ try
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ groupClass = loader.loadClass(desc.className);
+ }
+ catch (ClassNotFoundException e)
+ {
+ ActivationException acex = new ActivationException(
+ "Cannot load " + desc.className);
+ acex.detail = e;
+ throw acex;
+ }
+ }
+ else
+ groupClass = DefaultActivationGroup.class;
+
+ try
+ {
+ Constructor constructor = groupClass.getConstructor(cConstructorTypes);
+ group = (ActivationGroup) constructor.newInstance(
+ new Object[] { id, desc.data });
+ }
+ catch (Exception e)
+ {
+ ActivationException acex = new ActivationException(
+ "Cannot instantiate " + desc.className);
+ acex.detail = e;
+ throw acex;
+ }
+
+ currentGroupId = id;
+ try
+ {
+ group.monitor = getSystem().activeGroup(id, group, incarnation);
+ return group;
+ }
+ catch (RemoteException e)
+ {
+ ActivationException acex = new ActivationException("createGroup");
+ acex.detail = e;
+ throw acex;
+ }
+ }
+
+ /**
+ * Get the id of current activation group.
+ *
+ * @return the id of the current activation group or null if none exists.
+ */
+ public static ActivationGroupID currentGroupID()
+ {
+ try
+ {
+ if (currentGroupId==null)
+ {
+ // This will also assing the currentGroupId to the current
+ // (default) group of the default system.
+ setSystem(DefaultActivationSystem.get());
+ }
+ }
+ catch (ActivationException e)
+ {
+ InternalError ierr = new InternalError("Unable to activate AS");
+ ierr.initCause(e);
+ throw ierr;
+ }
+
+ return currentGroupId;
+ }
+
+ /**
+ * Set the activation system for this virtual machine. The system can only
+ * be set if no group is active.
+ *
+ * @param aSystem the system to set
+ *
+ * @throws ActivationException if some group is active now.
+ */
+ public static void setSystem(ActivationSystem aSystem)
+ throws ActivationException
+ {
+ if (currentGroupId!=null)
+ throw new ActivationException("Group active");
+ else
+ {
+ try
+ {
+ // Register the default transient activation system and group.
+ system = aSystem;
+ ActivationGroupDesc def = new ActivationGroupDesc(
+ DefaultActivationGroup.class.getName(),
+ "",
+ null,
+ null,
+ null);
+ currentGroupId = system.registerGroup(def);
+ }
+ catch (Exception ex)
+ {
+ InternalError ierr = new InternalError("Unable to start default AG");
+ ierr.initCause(ex);
+ throw ierr;
+ }
+ }
+ }
+
+ /**
+ * Get the current activation system. If the system is not set via
+ * {@link #setSystem} method, the default system for this virtual machine is
+ * returned. The default system is first searched by name
+ * "java.rmi.activation.ActivationSystem" on the activation registry port. The
+ * default value of the activation registry port is
+ * {@link ActivationSystem#SYSTEM_PORT}, but it can be changed by putting the
+ * system property java.rmi.activation.port. Both activation system and
+ * activation registry are provided by the RMI daemon tool, RMID, if it is
+ * running on the local host. If the RMID is not running, the internal
+ * transient activation system will be created and returned. This internal
+ * system is highly limited in in capabilities and is not intended to be used
+ * anywhere apart automated testing.
+ *
+ * @return the activation system for this virtual machine
+ * @throws ActivationException
+ */
+ public static ActivationSystem getSystem() throws ActivationException
+ {
+ if (system == null)
+ system = DefaultActivationSystem.get();
+ return system;
+ }
+
+ /**
+ * Makes the call back to the groups {@link ActivationMonitor}.
+ *
+ * @param id the id obj the object being activated
+ * @param mObject the marshalled object, contains the activated remote object
+ * stub.
+ * @throws ActivationException on activation error
+ * @throws UnknownObjectException if such object is not registered
+ * @throws RemoteException on remote call (to monitor) error
+ */
+ protected void activeObject(ActivationID id, MarshalledObject mObject)
+ throws ActivationException, UnknownObjectException, RemoteException
+ {
+ if (monitor!=null)
+ monitor.activeObject(id, mObject);
+
+ id.group = this;
+ }
+
+ /**
+ * Makes the call back to the groups {@link ActivationMonitor} and sets
+ * the current group to null.
+ */
+ protected void inactiveGroup() throws UnknownGroupException, RemoteException
+ {
+ if (monitor!=null)
+ monitor.inactiveGroup(groupId, incarnation);
+
+ if (currentGroupId!=null && currentGroupId.equals(groupId))
+ currentGroupId = null;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroupDesc.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroupDesc.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroupDesc.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroupDesc.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,433 @@
+/* ActivationGroupDesc.java -- the RMI activation group descriptor
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import gnu.java.rmi.activation.DefaultActivationGroup;
+
+import java.io.Serializable;
+import java.rmi.MarshalledObject;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.TreeSet;
+import java.util.zip.Adler32;
+
+/**
+ * Contains information, necessary to create of recreate the activation objects.
+ * The group descriptor contains:
+ * <ul>
+ * <li>The name of the group's class. This class is derived from the
+ * {@link ActivationGroup}.</li>
+ * <li>The group class code location.</li>
+ * <li>The marshalled object that contains the group specific initialization
+ * information</li>
+ * </ul>
+ * The groups are created by the {@link ActivationGroup#createGroup} method that
+ * expectes the group class to have the two parameter constructor, the first
+ * parameter being the {@link ActivationGroupID} and the second the
+ * {@link MarshalledObject}.
+ *
+ * @author Audrius Meskauskas (audriusa at bioinformatics.org) (from stub)
+ */
+public final class ActivationGroupDesc
+ implements Serializable
+{
+ /**
+ * Contains the startup options for the {@link ActivationGroup}
+ * implementations. Allows to override system properties and specify other
+ * options for the implementation groups.
+ *
+ * @author Audrius Meskauskas (audriusa at bioinformatics.org) (from stub)
+ */
+ public static class CommandEnvironment
+ implements Serializable
+ {
+
+ /**
+ * Use the SVUID for interoperability.
+ */
+ static final long serialVersionUID = 6165754737887770191L;
+
+ /**
+ * The zero size string array used as argv value when null is passed.
+ */
+ private static final String[] NO_ARGS = new String[0];
+
+ /**
+ * The path to the java executable (or null for using default jre).
+ */
+ final String command;
+
+ /**
+ * The extra parameters (may be empty array but never null).
+ */
+ final String[] options;
+
+ /**
+ * Create the new command environment.
+ *
+ * @param commandPatch the full path (and name) to the java executable of
+ * null for using the default executable.
+ * @param args extra options that will be used when creating the activation
+ * group. Null has the same effect as the empty list.
+ */
+ public CommandEnvironment(String commandPatch, String[] args)
+ {
+ command = commandPatch;
+ if (args != null)
+ options = args;
+ else
+ options = NO_ARGS;
+ }
+
+ /**
+ * Get the path to the java executable.
+ *
+ * @return the path to the java executable or null for using the default
+ * jre.
+ */
+ public String getCommandPath()
+ {
+ return command;
+ }
+
+ /**
+ * Get the additional command options.
+ *
+ * @return the command options array, may be empty string
+ */
+ public String[] getCommandOptions()
+ {
+ return options;
+ }
+
+ /**
+ * Compare for content equality.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof CommandEnvironment)
+ {
+ CommandEnvironment that = (CommandEnvironment) obj;
+
+ if (command == null || that.command == null)
+ {
+ // Use direct comparison if null is involved.
+ if (command != that.command)
+ return false;
+ }
+ else
+ {
+ // Use .equals if null is not involved.
+ if (! this.command.equals(that.command))
+ return false;
+ }
+
+ return Arrays.equals(options, that.options);
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Get the hash code.
+ */
+ public int hashCode()
+ {
+ int h = command == null ? 0 : command.hashCode();
+ for (int i = 0; i < options.length; i++)
+ h ^= options[i].hashCode();
+
+ return h;
+ }
+ }
+
+ /**
+ * Use the SVUID for interoperability.
+ */
+ static final long serialVersionUID = - 4936225423168276595L;
+
+ /**
+ * The group class name or null for the default group class implementation.
+ */
+ final String className;
+
+ /**
+ * The group class download location URL (codebase), ignored by the
+ * default implementation.
+ */
+ final String location;
+
+ /**
+ * The group initialization data.
+ */
+ final MarshalledObject data;
+
+ /**
+ * The path to the group jre and the parameters of this jre, may be
+ * null for the default jre.
+ */
+ final ActivationGroupDesc.CommandEnvironment env;
+
+ /**
+ * The properties that override the system properties.
+ */
+ final Properties props;
+
+ /**
+ * The cached hash code.
+ */
+ transient long hash;
+
+ /**
+ * Create the new activation group descriptor that will use the default
+ * activation group implementation with the given properties and
+ * environment.
+ *
+ * @param aProperties the properties that override the system properties
+ * @param environment the command line (and parameters), indicating, where to
+ * find the jre executable and with that parameters to call it. May
+ * be null if the default executable should be used. In this case,
+ * the activation group with the null name (the system default group)
+ * will be created.
+ */
+ public ActivationGroupDesc(Properties aProperties,
+ ActivationGroupDesc.CommandEnvironment environment)
+ {
+ this(DefaultActivationGroup.class.getName(), null, null, aProperties,
+ environment);
+ }
+
+ /**
+ * Create the new activation group descriptor.
+ *
+ * @param aClassName the name of the group implementation class. The null
+ * value indicates the default implementation.
+ * @param aLocation the location, from where the group implementation class
+ * should be loaded (ignored for the system default implementation).
+ * @param aData the group intialization data
+ * @param aProperties the properties that will override the system properties
+ * of the new group. These properties will be translated into -D
+ * options.
+ * @param environment the record, containing path to the jre executable and
+ * start options for the jre or null for using the default jre and
+ * options.
+ */
+ public ActivationGroupDesc(String aClassName, String aLocation,
+ MarshalledObject aData, Properties aProperties,
+ ActivationGroupDesc.CommandEnvironment environment)
+ {
+ className = aClassName;
+ location = aLocation;
+ data = aData;
+ props = aProperties;
+ env = environment;
+ }
+
+ /**
+ * Get the activation group class name.
+ *
+ * @return the activation group class name (null for default implementation)
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Get the location, from where the group class will be loaded
+ *
+ * @return the location, from where the implementation should be loaded (null
+ * for the default implementation)
+ */
+ public String getLocation()
+ {
+ return location;
+ }
+
+ /**
+ * Get the group intialization data.
+ *
+ * @return the group intialization data in the marshalled form.
+ */
+ public MarshalledObject getData()
+ {
+ return data;
+ }
+
+ /**
+ * Get the overridded system properties.
+ *
+ * @return the overridden group system properties.
+ */
+ public Properties getPropertyOverrides()
+ {
+ return props;
+ }
+
+ /**
+ * Get the group command environment, containing path to the jre executable
+ * and startup options.
+ *
+ * @return the command environment or null if the default environment should
+ * be used.
+ */
+ public ActivationGroupDesc.CommandEnvironment getCommandEnvironment()
+ {
+ return env;
+ }
+
+ /**
+ * Compare for the content equality.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ActivationGroupDesc)
+ {
+ ActivationGroupDesc that = (ActivationGroupDesc) obj;
+
+ // Ensure the hashcodes are computed.
+ if (hash == 0)
+ hashCode();
+ if (that.hash == 0)
+ that.hashCode();
+
+ // We compare the hash fields as they are type long rather than int.
+ if (hash != that.hash)
+ return false;
+
+ if (! eq(className, that.className))
+ return false;
+ if (! eq(data, that.data))
+ return false;
+ if (! eq(env, that.env))
+ return false;
+ if (! eq(location, that.location))
+ return false;
+
+ // Compare the properties.
+ if (eq(props, that.props))
+ return true;
+
+ if (props.size() != that.props.size())
+ return false;
+
+ Enumeration en = props.propertyNames();
+ Object key, value;
+
+ while (en.hasMoreElements())
+ {
+ key = en.nextElement();
+ if (! that.props.containsKey(key))
+ return false;
+ if (! eq(props.get(key), that.props.get(key)))
+ return false;
+ }
+ return true;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Compare for direct equality if one or both parameters are null, otherwise
+ * call .equals.
+ */
+ static boolean eq(Object a, Object b)
+ {
+ if (a == null || b == null)
+ return a == b;
+ else
+ return a.equals(b);
+ }
+
+ /**
+ * Return the hashcode.
+ */
+ public int hashCode()
+ {
+ if (hash==0)
+ {
+ // Using Adler32 - the hashcode is cached, will be computed only
+ // once and due need to scan properties is the expensive operation
+ // anyway. Reliability is more important.
+ Adler32 adler = new Adler32();
+ if (className!=null)
+ adler.update(className.getBytes());
+ if (data!=null)
+ adler.update(data.hashCode());
+ if (env!=null)
+ adler.update(env.hashCode());
+ if (location!=null)
+ adler.update(location.getBytes());
+ if (props!=null)
+ {
+ Enumeration en = props.propertyNames();
+
+ // Using the intermediate sorted set to ensure that the
+ // properties are sorted.
+ TreeSet pr = new TreeSet();
+
+ Object key;
+ Object value;
+ while (en.hasMoreElements())
+ {
+ key = en.nextElement();
+ if (key!=null)
+ pr.add(key);
+ }
+
+ Iterator it = pr.iterator();
+ while (it.hasNext())
+ {
+ key = it.next();
+ value = props.get(key);
+ adler.update(key.hashCode());
+ if (value!=null)
+ adler.update(value.hashCode());
+ }
+ }
+ hash = adler.getValue();
+ }
+ return (int) hash;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroupID.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroupID.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroupID.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroupID.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,122 @@
+/* ActivationGroupID.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.io.Serializable;
+import java.rmi.server.UID;
+
+/**
+ * This identifier identifies the activation group inside the scope of its
+ * activation system. It also contains (and can provide) the reference to the
+ * groups activation system.
+ *
+ * @see ActivationSystem#registerGroup(ActivationGroupDesc)
+ */
+public class ActivationGroupID
+ implements Serializable
+{
+ /**
+ * Use SVUID for interoperability.
+ */
+ static final long serialVersionUID = - 1648432278909740833L;
+
+ /**
+ * The associated activation system.
+ */
+ final ActivationSystem system;
+
+ /**
+ * The object identifier, making the ID unique.
+ */
+ final UID uid;
+
+ /**
+ * Create the new activation group id in the scope of the given activation
+ * system
+ *
+ * @param aSystem the activation system
+ */
+ public ActivationGroupID(ActivationSystem aSystem)
+ {
+ system = aSystem;
+ uid = new UID();
+ }
+
+ /**
+ * Get the associated activation system
+ *
+ * @return the associated activation system
+ */
+ public ActivationSystem getSystem()
+ {
+ return system;
+ }
+
+ /**
+ * Get the hash code of the associated activation system.
+ */
+ public int hashCode()
+ {
+ return uid.hashCode();
+ }
+
+ /**
+ * Copmare for equality, returns true if the passed object is also the
+ * activation group id and its activation system is the same.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ActivationGroupID)
+ {
+ ActivationGroupID that = (ActivationGroupID) obj;
+ return uid.equals(that.uid);
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Get the string representation
+ */
+ public String toString()
+ {
+ return uid.toString();
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroup_Stub.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroup_Stub.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroup_Stub.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationGroup_Stub.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,110 @@
+/* ActivationGroup_Stub.java -- Stub class for ActivationGroup impls.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.lang.reflect.Method;
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+
+/**
+ * A stub class for {@link ActivationGroup} implementations.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ */
+public final class ActivationGroup_Stub extends RemoteStub
+ implements ActivationInstantiator, Remote
+{
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * Creates a new instance of ActivationGroup_Stub.
+ *
+ * @param ref the remote reference
+ */
+ public ActivationGroup_Stub(RemoteRef ref)
+ {
+ super(ref);
+ }
+
+ /**
+ * Stub method for <code>ActivationGroup.newInstance()</code>.
+ *
+ * @param id the activation ID
+ * @param desc the activation description
+ *
+ * @return the return value of the invocation
+ *
+ * @throws RemoteException if the invocation throws a RemoteException
+ * @throws ActivationException if the invocation throws an
+ * ActivationException
+ */
+ public MarshalledObject newInstance(ActivationID id, ActivationDesc desc)
+ throws RemoteException, ActivationException
+ {
+ try
+ {
+ Method method = ActivationGroup_Stub.class.getDeclaredMethod
+ ("newInstance", new Class[]{ ActivationID.class,
+ ActivationDesc.class });
+ return (MarshalledObject) ref.invoke(this, method,
+ new Object[]{id, desc},
+ -5274445189091581345L);
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (RemoteException ex)
+ {
+ throw ex;
+ }
+ catch (ActivationException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new UnexpectedException("Unexpected exception", ex);
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationID.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationID.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationID.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationID.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,199 @@
+/* ActivationID.java -- the object activation identifier
+ Copyright (c) 1996, 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.server.UID;
+
+/**
+ * Denotes the object that can be activated over time. The instance of the
+ * ActivationID for the given object can be obtained in the following ways:
+ * <ul>
+ * <li>via {@link Activatable#register(ActivationDesc)}</li>
+ * <li>via Activatable constructor</li>
+ * <li>via Activatable.exportObject
+ * <li>
+ * </ul>
+ * An instance of the ActivationID has the {@link UID} as its component and
+ * hence is globally unique.
+ *
+ * @author Audrius Meskauskas (audriusa at bioinformatics.org) (from stub)
+ */
+public class ActivationID
+ implements Serializable
+{
+ /**
+ * Use SVUID for interoperability.
+ */
+ static final long serialVersionUID = - 4608673054848209235L;
+
+ /**
+ * The activator.
+ */
+ transient Activator activator;
+
+ /**
+ * The UID, making this instance unique.
+ */
+ transient UID uid;
+
+ /**
+ * The activation group that has activated the object with this
+ * activation id. The field is filled in inside the group and is used
+ * to notify the group about the request to inactivated the object.
+ */
+ transient ActivationGroup group;
+
+ /**
+ * Create a new instance with the given activator.
+ *
+ * @param an_activator tha activator that should activate the object.
+ */
+ public ActivationID(Activator an_activator)
+ {
+ activator = an_activator;
+ uid = new UID();
+ }
+
+ /**
+ * Activate the object.
+ *
+ * @param force if true, always contact the group. Otherwise, the cached value
+ * may be returned.
+ * @return the activated object
+ * @throws UnknownObjectException if the object is unknown
+ * @throws ActivationException if the activation has failed
+ * @throws RemoteException if the remote call has failed
+ */
+ public Remote activate(boolean force) throws ActivationException,
+ UnknownObjectException, RemoteException
+ {
+ try
+ {
+ return (Remote) activator.activate(this, force).get();
+ }
+ catch (IOException e)
+ {
+ ActivationException acex = new ActivationException("id "+uid, e);
+ throw acex;
+ }
+ catch (ClassNotFoundException e)
+ {
+ ActivationException acex = new ActivationException("id "+uid, e);
+ throw acex;
+ }
+ }
+
+ /**
+ * Returns the hash code of the activator.
+ */
+ public int hashCode()
+ {
+ return uid == null ? 0 : uid.hashCode();
+ }
+
+ /**
+ * Compares the activators for equality.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ActivationID)
+ {
+ ActivationID that = (ActivationID) obj;
+ return eq(uid, that.uid);
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Read the object from the input stream.
+ *
+ * @param in the stream to read from
+ *
+ * @throws IOException if thrown by the stream
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream in) throws IOException,
+ ClassNotFoundException
+ {
+ uid = (UID) in.readObject();
+ activator = (Activator) in.readObject();
+ }
+
+ /**
+ * Write the object to the output stream.
+ *
+ * @param out the stream to write int
+ * @throws IOException if thrown by the stream
+ * @throws ClassNotFoundException
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException,
+ ClassNotFoundException
+ {
+ out.writeObject(uid);
+ out.writeObject(activator);
+ };
+
+ /**
+ * Compare by .equals if both a and b are not null, compare directly if at
+ * least one of them is null.
+ */
+ static final boolean eq(Object a, Object b)
+ {
+ if (a == null || b == null)
+ return a == b;
+ else
+ return a.equals(b);
+ }
+
+ /**
+ * Return the content based string representation.
+ */
+ public String toString()
+ {
+ return uid.toString();
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationInstantiator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationInstantiator.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationInstantiator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationInstantiator.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* ActivationInstantiator.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * The implementation of this interface creates (instantiates) the new remote
+ * objects in response to the activation request. The instantiator is returned
+ * by the {@link ActivationGroup} that calls
+ * {@link ActivationSystem#activeGroup(ActivationGroupID, ActivationInstantiator, long)}.
+ */
+public interface ActivationInstantiator
+ extends Remote
+{
+ /**
+ * Creates and instantiate a new remote object. This method performs the
+ * following tasks:
+ * <ul>
+ * <li>Finds and loads (if not already loaded) the class of the object being
+ * instantiated</li>
+ * <li>Creates an instance of the object using its special two parameter
+ * activation constructor, the first parameter being the {@link ActivationID}
+ * and the second the {@link MarshalledObject}.</li>
+ *
+ * @param id the id of the object being instantiated
+ * @param desc the activation descriptor being instantiated
+ * @return the MarshalledObject, containing the stub to the newly created
+ * object.
+ * @throws ActivationException if the activation fails
+ * @throws RemoteException if the remote call fails
+ */
+ MarshalledObject newInstance (ActivationID id, ActivationDesc desc)
+ throws ActivationException, RemoteException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationMonitor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationMonitor.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationMonitor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationMonitor.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,87 @@
+/* ActivationMonitor.java -- the RMI activation/inactivation event listener
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * The activation and inactivation event listener. The group obtains this
+ * listener via {@link ActivationSystem#activeGroup} and must notify it
+ * when the group objects are activated or inactivated and also when the
+ * whole group becomes inactive.
+ * @author root.
+ */
+public interface ActivationMonitor extends Remote
+{
+ /**
+ * Informs that the object is now active.
+ *
+ * @param id the activation id of the object that is now active
+ * @throws UnknownObjectException is such object is not known in this group
+ * @throws RemoteException if remote call fails
+ */
+ void activeObject (ActivationID id, MarshalledObject obj)
+ throws UnknownObjectException, RemoteException;
+
+ /**
+ * Informs that the object is not inactive.
+ *
+ * @param id the activation id of the object that is now inactive
+ * @throws UnknownObjectException is such object is not known in this group
+ * @throws RemoteException if remote call fails
+ */
+ void inactiveObject (ActivationID id)
+ throws UnknownObjectException, RemoteException;
+
+ /**
+ * Informs that the whole group is now inactive because all group objects are
+ * inactive. The group will be recreated upon the later request to activate
+ * any object, belonging to the group.
+ *
+ * @param groupId the group id
+ * @param incarnation the group incarnation number
+ * @throws UnknownGroupException if the group id is not known
+ * @throws RemoteException if the remote call fails
+ */
+ void inactiveGroup (ActivationGroupID groupId, long incarnation)
+ throws UnknownGroupException, RemoteException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationSystem.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationSystem.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationSystem.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/ActivationSystem.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,206 @@
+/* ActivationSystem.java -- registers groups and objects to be activated.
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * <p>
+ * The ActivationSystem registers groups and activatable objects to be activated
+ * within those groups. The ActivationSystem cooperates with both the Activator,
+ * which activates objects registered via the ActivationSystem, and the
+ * ActivationMonitor, which obtains information about active and inactive
+ * objects and inactive groups.
+ * </p>
+ * <p>
+ * The activation system if frequently a remote object. As a security mean, all
+ * methods in this interface throw {@link java.rmi.AccessException} if called
+ * from the client that is not reside on the same host as the activation system.
+ * </p>
+ * @see ActivationGroup#getSystem()
+ */
+public interface ActivationSystem
+ extends Remote
+{
+ /**
+ * The port, used by the activation system. The value is equal to 1098 by
+ * default, but it can be changed by putting the system property
+ * .
+ */
+ int SYSTEM_PORT = 1098;
+
+ /**
+ * Registers the activation descriptor and creates (and returns) its
+ * activation identifier. The map entry (identifier to descriptor) is stored
+ * in the stable map and used when the {@link Activator} receives the request
+ * to activate the object.
+ *
+ * @param desc the activation descriptor to register.
+ * @return the created activation identifier that is mapped to the passed
+ * descriptor.
+ * @throws ActivationException if the registration fails (database update
+ * problems, etc).
+ * @throws UnknownGroupException the if group, specified in decriptor, is
+ * unknown.
+ * @throws RemoteException if the remote call fails.
+ */
+ ActivationID registerObject(ActivationDesc desc) throws ActivationException,
+ UnknownGroupException, RemoteException;
+
+ /**
+ * Removes the stored identifier-description map entry. The object will no
+ * longer be activable using the passed activation id
+ *
+ * @param id the activation id to remove
+ * @throws ActivationException if the entry removing operation failed
+ * (database update problems, etc)
+ * @throws UnknownObjectException if the passed id is not known to the system
+ * @throws RemoteException if the remote call fails
+ */
+ void unregisterObject(ActivationID id) throws ActivationException,
+ UnknownObjectException, RemoteException;
+
+ /**
+ * Register the new activation group. For instance, it can be one activation
+ * group per virtual machine.
+ *
+ * @param groupDesc the activation group descriptor.
+ * @return the created activation group ID for the activation group
+ * @throws ActivationException if the group registration fails
+ * @throws RemoteException if the remote call fails
+ */
+ ActivationGroupID registerGroup(ActivationGroupDesc groupDesc)
+ throws ActivationException, RemoteException;
+
+ /**
+ * This method is called from the {@link ActivationGroup} to inform the
+ * ActivatinSystem that the group is now active and there is the
+ * {@link ActivationInstantiator} for that group. This call is made internally
+ * from the {@link ActivationGroup#createGroup}.
+ *
+ * @param id the group id
+ * @param group the group activation instantiator
+ * @param incarnation the groups incarnatin number.
+ * @return the activation monitor that should be informed about the group
+ * state changes
+ * @throws UnknownGroupException if this group has not been registered
+ * @throws ActivationException if this group is already active
+ * @throws RemoteException if the remote call fails
+ */
+ ActivationMonitor activeGroup(ActivationGroupID id,
+ ActivationInstantiator group, long incarnation)
+ throws UnknownGroupException, ActivationException, RemoteException;
+
+ /**
+ * Removes the activation group with the given identifier. The group calls
+ * back, informing the activator about the shutdown.
+ *
+ * @param id the group activation id.
+ * @throws ActivationException if the database update fails
+ * @throws UnknownGroupException if such group is not registered
+ * @throws RemoteException if the remote call fails
+ */
+ void unregisterGroup(ActivationGroupID id) throws ActivationException,
+ UnknownGroupException, RemoteException;
+
+ /**
+ * Shutdown the activation system and all associated activation groups
+ *
+ * @throws RemoteException if the remote call fails
+ */
+ void shutdown() throws RemoteException;
+
+ /**
+ * Replace the activation descriptor for the object with the given activation
+ * id.
+ *
+ * @param id the activation id
+ * @param desc the new activation descriptor
+ * @return the previous activation descriptor for that object.
+ * @throws ActivationException if the database update fails
+ * @throws UnknownObjectException if the object with such id is not known
+ * @throws UnknownGroupException if the activation group (in desc) is not
+ * known.
+ * @throws RemoteException if the remote call fails
+ */
+ ActivationDesc setActivationDesc(ActivationID id, ActivationDesc desc)
+ throws ActivationException, UnknownObjectException,
+ UnknownGroupException, RemoteException;
+
+ /**
+ * Replaces the group descriptor for the group with the given group activation
+ * id.
+ *
+ * @param groupId the group id
+ * @param groupDesc the new group descriptor
+ * @return the previous group descriptor
+ * @throws ActivationException if the database update fails
+ * @throws UnknownGroupException if such group is not known
+ * @throws RemoteException if the remote call fails
+ */
+ ActivationGroupDesc setActivationGroupDesc(ActivationGroupID groupId,
+ ActivationGroupDesc groupDesc)
+ throws ActivationException, UnknownGroupException, RemoteException;
+
+ /**
+ * Get the activation descriptor for the object with the given activation id.
+ *
+ * @param id the object activation id
+ * @return the activation descriptor for that object
+ * @throws ActivationException if the database access fails
+ * @throws UnknownObjectException if this object is not known
+ * @throws RemoteException if the remote call fails
+ */
+ ActivationDesc getActivationDesc(ActivationID id) throws ActivationException,
+ UnknownObjectException, RemoteException;
+
+ /**
+ * Get the group descriptor for the group with the given id.
+ *
+ * @param groupId the group id
+ * @return the group descriptor
+ * @throws ActivationException if the database access fails
+ * @throws UnknownGroupException if the group with such id is not known
+ * @throws RemoteException if the remote call fails
+ */
+ ActivationGroupDesc getActivationGroupDesc(ActivationGroupID groupId)
+ throws ActivationException, UnknownGroupException, RemoteException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/Activator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/Activator.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/Activator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/Activator.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* Activator.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * Activates remote object, providing the live reference to the activable remote
+ * object. Usually there is only one activator per host.
+ *
+ * @see ActivationSystem
+ * @see ActivationMonitor
+ */
+public interface Activator
+ extends Remote
+{
+ /**
+ * Activate the object, associated with the given activation identifier. The
+ * activator looks for the {@link ActivationDesc}riptor for the passed
+ * identifier, determines the object activation group and initiates object
+ * recreation either via {@link ActivationInstantiator} or via
+ * {@link Class#newInstance()}.
+ *
+ * @param id the identifier of the object to activate.
+ * @param force if true, the activator always contacts the group to obtain the
+ * reference. If false, it may return the cached value.
+ * @return the activated remote object (its stub).
+ * @throws UnknownObjectException if the object with this id is unknown
+ * @throws ActivationException if the activation has failed due other reason
+ * @throws RemoteException if the remote call has failed.
+ */
+ MarshalledObject activate (ActivationID id, boolean force)
+ throws ActivationException, UnknownObjectException, RemoteException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/UnknownGroupException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/UnknownGroupException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/UnknownGroupException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/UnknownGroupException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,69 @@
+/* UnknownGroupException.java -- thrown on an invalid ActivationGroupID
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.activation;
+
+/**
+ * Thrown when an <code>ActivationGroupID</code> parameter is invalid or
+ * unknown.
+ *
+ * @author unknown
+ * @see Activatable
+ * @see ActivationGroup
+ * @see ActivationID
+ * @see ActivationMonitor
+ * @see ActivationSystem
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class UnknownGroupException extends ActivationException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 7056094974750002460L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public UnknownGroupException(String s)
+ {
+ super(s);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/UnknownObjectException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/UnknownObjectException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/UnknownObjectException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/UnknownObjectException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,69 @@
+/* UnknownObjectException.java -- thrown on an invalid ActivationID
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.activation;
+
+/**
+ * Thrown when an <code>ActivationID</code> parameter is invalid or unknown.
+ *
+ * @author unknown
+ * @see Activatable
+ * @see ActivationGroup
+ * @see ActivationID
+ * @see ActivationMonitor
+ * @see ActivationSystem
+ * @see Activator
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class UnknownObjectException extends ActivationException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 3425547551622251430L;
+
+ /**
+ * Create an exception with an error message.
+ *
+ * @param s the message
+ */
+ public UnknownObjectException(String s)
+ {
+ super(s);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/activation/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.rmi.activation package.
+ Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.rmi.activation</title></head>
+
+<body>
+In the previous Classpath releases, an instance of a UnicastRemoteObject
+could be accessed from a server that:
+<ul>
+<li>has created an instance of that object<li>
+<li>has been running <i>all<i> the time</li>
+</ul>
+<p>The the activation system allows to activate and execute the object
+implementation on demand rather than running all time. If the activation
+system is persistent, the server can be terminated and then restarted.
+The clients, still holding remote references to the server side
+activatable objects, will activate those objects again. The server side
+objects will be reinstantiated (activated) during the first call of any
+remote method of such object.
+</p><p>
+The RMI client code for activatable objects is no different than the code for
+accessing non-activatable remote objects. Activation is a server-side feature.
+</p><p>
+In order for an object to be activated, the "activatable" object class
+(independently if it extends the {@link Activatable} class or not) defines a
+special public constructor that takes two arguments, its activation identifier
+({@link ActivationID}) and its activation data ({@link java.rmi.MarshalledObject}),
+supplied in the activation descriptor used during registration. When an
+activation group activates a remote object, it constructs the object via
+this special constructor. The remote object implementation may use the
+activation data to initialize itself in a needed manner. The remote object may
+also retain its activation identifier, so that it can inform the activation
+group when it becomes inactive (via a call to the Activatable.inactive method).
+</p>
+ at author Audrius Meskauskas (audriusa at bioinformatics.org) (from empty)
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/DGC.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/DGC.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/DGC.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/DGC.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,80 @@
+/* DGC.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.dgc;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.server.ObjID;
+
+/**
+ * The DGC implementation is used for the server side during the distributed
+ * garbage collection. This interface contains the two methods: dirty and clean.
+ * A dirty call is made when a remote reference is unmarshaled in a client. A
+ * corresponding clean call is made by client it no longer uses that remote
+ * reference. A reference to a remote object is also automatically released
+ * after so called lease period that starts after the dirty call is received. It
+ * is the client's responsibility to renew the leases, by making additional
+ * dirty calls before such leases expire.
+ */
+public interface DGC
+ extends Remote
+{
+ /**
+ * Mark the given objects referecnes as used on the client side.
+ *
+ * @param ids the ids of the used objects.
+ * @param sequenceNum the number of the call (used to detect and discard late
+ * calls).
+ * @param lease the requested lease
+ * @return the granted lease
+ */
+ Lease dirty(ObjID[] ids, long sequenceNum, Lease lease)
+ throws RemoteException;
+
+ /**
+ * Mark the given objects as no longer used on the client side.
+ *
+ * @param ids the ids of the objects that are no longer used.
+ * @param sequenceNum the number of the call (used to detect and discard late
+ * @param vmid the VMID of the client.
+ * @param strong make the "strong" clean call ("strong" calls are scheduled
+ * after the failed dirty calls).
+ */
+ void clean(ObjID[] ids, long sequenceNum, VMID vmid, boolean strong)
+ throws RemoteException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/Lease.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/Lease.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/Lease.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/Lease.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,100 @@
+/* Lease.java
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.dgc;
+
+import java.io.Serializable;
+
+/**
+ * A lease object is used to request and grant leases for the remote objects. It
+ * contains the lease duration and the unique VM indentifier.
+ */
+public final class Lease
+ implements Serializable
+{
+
+ static final long serialVersionUID = - 5713411624328831948L;
+
+ private VMID vmid;
+
+ private long value;
+
+ /**
+ * Create the new lease with the given id and duration
+ *
+ * @param id the lease id
+ * @param duration the lease duration
+ */
+ public Lease(VMID id, long duration)
+ {
+ vmid = id;
+ value = duration;
+ }
+
+ /**
+ * Get the lease id.
+ *
+ * @return the lease id
+ */
+ public VMID getVMID()
+ {
+ return (vmid);
+ }
+
+ /**
+ * Get the lease duration
+ *
+ * @return the lease duration
+ */
+ public long getValue()
+ {
+ return (value);
+ }
+
+ /**
+ * Get the string representation of this lease
+ *
+ * @return the string represenation (lease id, followed by the lease
+ * duration).
+ */
+ public String toString()
+ {
+ return ("[" + vmid.toString() + ", " + Long.toString(value) + "]");
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/VMID.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/VMID.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/VMID.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/VMID.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,189 @@
+/* VMID.java -- The object ID, unique between all virtual machines.
+ Copyright (c) 1996, 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.dgc;
+
+import java.io.Serializable;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.rmi.server.UID;
+import java.util.Arrays;
+
+/**
+ * An identifier that is unique accross the all virtual machines. This class is
+ * used by distributed garbage collector to identify the virtual machine of
+ * the client, but may also be used in various other cases, when such identifier
+ * is required. This class separately stores and transfers the host IP
+ * address, but will try to do its best also for the case if it failed to
+ * determine it. The alternative algorithms are used in {@link UID} that is
+ * part of this class. The VMID's, created on the same host, but in the two
+ * separately (parallely) running virtual machines are different.
+ */
+public final class VMID implements Serializable
+{
+ /**
+ * Use SVUID for interoperability.
+ */
+ static final long serialVersionUID = -538642295484486218L;
+
+ /**
+ * If true, the IP of this host can ve reliably determined.
+ */
+ static boolean areWeUnique;
+
+ /**
+ * The IP address of the local host.
+ */
+ static byte[] localAddr;
+
+ /**
+ * The IP address of the local host.
+ */
+ private byte[] addr;
+
+ /**
+ * The cached hash code.
+ */
+ transient int hash;
+
+ /**
+ * The UID of this VMID.
+ */
+ private UID uid;
+
+ static
+ {
+ // This "local host" value usually indicates that the local
+ // IP address cannot be reliably determined.
+ byte[] localHost = new byte[] { 127, 0, 0, 1 };
+
+ try
+ {
+ localAddr = InetAddress.getLocalHost().getAddress();
+ areWeUnique = !Arrays.equals(localHost, localAddr);
+ }
+ catch (UnknownHostException uhex)
+ {
+ localAddr = localHost;
+ areWeUnique = false;
+ }
+ }
+
+ /**
+ * Create the new VMID. All VMID's are unique accross tha all virtual
+ * machines.
+ */
+ public VMID()
+ {
+ addr = localAddr;
+ uid = new UID();
+ }
+
+ /**
+ * Return true if it is possible to get the accurate address of this host.
+ * If false is returned, the created VMID's are less reliable, but the
+ * starting time and possibly the memory allocation are also taken into
+ * consideration in the incorporated UID. Hence the VMID's, created on the
+ * different virtual machines, still should be different.
+ *
+ * @deprecated VMID's are more or less always reliable.
+ *
+ * @return false if the local host ip address is 127.0.0.1 or unknown,
+ * true otherwise.
+ */
+ public static boolean isUnique ()
+ {
+ return areWeUnique;
+ }
+
+ /**
+ * Get the hash code of this VMID.
+ */
+ public int hashCode ()
+ {
+ if (hash==0)
+ {
+ for (int i = 0; i < localAddr.length; i++)
+ hash += addr[i];
+ hash = hash ^ uid.hashCode();
+ }
+ return hash;
+ }
+
+ /**
+ * Returns true if the passed parameter is also VMID and it is equal to this
+ * VMID. The VMID should only be equal to itself (also if the passed value is
+ * another instance, cloned by serialization).
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof VMID)
+ {
+ VMID other = (VMID) obj;
+
+ // The UID's are compared faster than arrays.
+ return uid.equals(other.uid) && Arrays.equals(addr, other.addr);
+ }
+ else
+ return false;
+
+ }
+
+ /**
+ * Get the string representation of this VMID.
+ */
+ public String toString ()
+ {
+ StringBuffer buf = new StringBuffer ("[VMID: ");
+
+ for (int i = 0; i < addr.length; i++)
+ {
+ if (i > 0)
+ {
+ buf.append (".");
+ }
+
+ buf.append (Integer.toString (addr [i]));
+ }
+
+ buf.append (" ");
+ buf.append (uid.toString ());
+ buf.append ("]");
+
+ return buf.toString();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/dgc/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,52 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.rmi.dgc package.
+ Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.rmi.dgc</title></head>
+
+<body>
+The Distributed Garbage Collector (DGC). The DGC is reponsible for keeping all
+locally created and exported remote objects as long as they are referenced
+by some remote clients. The client must periodically notify the server that
+it still wants to keep the remote object on the server side. The client
+notifies the server by calling methods, defined in the DGC interface.
+Other classes in this package define the parameters that are used in this
+interface. The DGC object of some host can be found and accessed by its
+object identifier (ObjID.DGC_ID), without involving the name service.
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.rmi package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.rmi</title></head>
+
+<body>
+<p>Provides basic Remote Method Invocation (RMI) interfaces, classes and exceptions.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/LocateRegistry.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/LocateRegistry.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/LocateRegistry.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/LocateRegistry.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,87 @@
+/* LocateRegistry.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.registry;
+
+import gnu.java.rmi.registry.RegistryImpl;
+import gnu.java.rmi.registry.RegistryImpl_Stub;
+import gnu.java.rmi.server.UnicastRef;
+
+import java.rmi.RemoteException;
+import java.rmi.server.ObjID;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.RMISocketFactory;
+import java.rmi.server.RemoteRef;
+
+public final class LocateRegistry {
+ /**
+ * This class isn't intended to be instantiated.
+ */
+ private LocateRegistry() {}
+
+public static Registry getRegistry() throws RemoteException {
+ return (getRegistry("localhost", Registry.REGISTRY_PORT));
+}
+
+public static Registry getRegistry(int port) throws RemoteException {
+ return (getRegistry("localhost", port));
+}
+
+public static Registry getRegistry(String host) throws RemoteException {
+ return (getRegistry(host, Registry.REGISTRY_PORT));
+}
+
+public static Registry getRegistry(String host, int port) throws RemoteException {
+ return (getRegistry(host, port, RMISocketFactory.getSocketFactory()));
+}
+
+public static Registry getRegistry(String host, int port, RMIClientSocketFactory csf) throws RemoteException {
+ RemoteRef ref = new UnicastRef(new ObjID(ObjID.REGISTRY_ID), host, port, csf);
+ return (new RegistryImpl_Stub(ref));
+}
+
+public static Registry createRegistry(int port) throws RemoteException {
+ return (createRegistry(port, RMISocketFactory.getSocketFactory(), RMISocketFactory.getSocketFactory()));
+}
+
+public static Registry createRegistry(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException {
+ return (new RegistryImpl(port, csf, ssf));
+}
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/Registry.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/Registry.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/Registry.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/Registry.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,87 @@
+/* Registry.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.registry;
+
+import java.rmi.AccessException;
+import java.rmi.AlreadyBoundException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface Registry extends Remote
+{
+ int REGISTRY_PORT = 1099;
+
+ /**
+ * Find and return the reference to the object that was previously bound
+ * to the registry by this name. For remote objects, this method returns
+ * the stub instances, containing the code for remote invocations.
+ *
+ * Since jdk 1.5 this method does not longer require the stub class
+ * (nameImpl_Stub) to be present. If such class is not found, the stub is
+ * replaced by the dynamically constructed proxy class. No attempt to find
+ * and load the stubs is made if the system property
+ * java.rmi.server.ignoreStubClasses is set to true (set to reduce the
+ * starting time if the stubs are surely not present and exclusively 1.2
+ * RMI is used).
+ *
+ * @param name the name of the object
+ *
+ * @return the reference to that object on that it is possible to invoke
+ * the (usually remote) object methods.
+ *
+ * @throws RemoteException
+ * @throws NotBoundException
+ * @throws AccessException
+ */
+ Remote lookup(String name)
+ throws RemoteException, NotBoundException, AccessException;
+
+ void bind(String name, Remote obj)
+ throws RemoteException, AlreadyBoundException, AccessException;
+
+ void unbind(String name)
+ throws RemoteException, NotBoundException, AccessException;
+
+ void rebind(String name, Remote obj)
+ throws RemoteException, AccessException;
+
+ String[] list()
+ throws RemoteException, AccessException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/RegistryHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/RegistryHandler.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/RegistryHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/RegistryHandler.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,58 @@
+/* RegistryHandler.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.registry;
+
+import java.rmi.RemoteException;
+import java.rmi.UnknownHostException;
+
+/**
+ * @deprecated
+ */
+public interface RegistryHandler
+{
+ /**
+ * @deprecated
+ */
+ Registry registryStub (String host, int port)
+ throws RemoteException, UnknownHostException;
+
+ /**
+ * @deprecated
+ */
+ Registry registryImpl (int port) throws RemoteException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/registry/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.rmi.registry package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.rmi.registry</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ExportException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ExportException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ExportException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ExportException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* ExportException.java -- an export attempt failed
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import java.rmi.RemoteException;
+
+/**
+ * Thrown if an attempt to export a remote object fails.
+ *
+ * @author unknown
+ * @see UnicastRemoteObject
+ * @see Activatable
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ExportException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -9155485338494060170L;
+
+ /**
+ * Create an exception with the specified message.
+ *
+ * @param s the message
+ */
+ public ExportException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with the specified message and cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public ExportException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/LoaderHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/LoaderHandler.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/LoaderHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/LoaderHandler.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,70 @@
+/* LoaderHandler.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * @deprecated
+ */
+public interface LoaderHandler
+{
+ /**
+ * For binary compatibility with the JDK, the string "sun.rmi.server".
+ * Not actually used for anything.
+ */
+ String packagePrefix = "sun.rmi.server";
+
+ /**
+ * @deprecated
+ */
+ Class loadClass(String name)
+ throws MalformedURLException, ClassNotFoundException;
+
+ /**
+ * @deprecated
+ */
+ Class loadClass(URL codebase, String name)
+ throws MalformedURLException, ClassNotFoundException;
+
+ /**
+ * @deprecated
+ */
+ Object getSecurityContext(ClassLoader loader);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/LogStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/LogStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/LogStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/LogStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,146 @@
+/* LogStream.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+/**
+ * @deprecated
+ */
+public class LogStream extends PrintStream
+{
+ public static final int SILENT = 0;
+ public static final int BRIEF = 10;
+ public static final int VERBOSE = 20;
+
+ private static PrintStream defStream;
+
+ private LogStream (OutputStream s)
+ {
+ super (s);
+ }
+
+ /**
+ * @deprecated
+ */
+ public static LogStream log (String name)
+ {
+ throw new Error ("Not implemented");
+ }
+
+ /**
+ * @deprecated
+ */
+ public static PrintStream getDefaultStream ()
+ {
+ return defStream;
+ }
+
+ /**
+ * @deprecated
+ */
+ public static void setDefaultStream (PrintStream s)
+ {
+ defStream = s;
+ }
+
+ /**
+ * @deprecated
+ */
+ public OutputStream getOutputStream ()
+ {
+ return out;
+ }
+
+ /**
+ * @deprecated
+ */
+ public void setOutputStream (OutputStream s)
+ {
+ out = s;
+ }
+
+ /**
+ * @deprecated
+ */
+ public void write (int buffer)
+ {
+ super.write (buffer);
+ }
+
+ /**
+ * @deprecated
+ */
+ public void write (byte[] buffer, int offset, int len)
+ {
+ super.write (buffer, offset, len);
+ }
+
+ /**
+ * @deprecated
+ */
+ public String toString ()
+ {
+ throw new Error ("Not implemented");
+ }
+
+ /**
+ * @deprecated
+ */
+ public static int parseLevel (String s)
+ {
+ if (s.equalsIgnoreCase ("silent"))
+ {
+ return SILENT;
+ }
+
+ if (s.equalsIgnoreCase ("brief"))
+ {
+ return BRIEF;
+ }
+
+ if (s.equalsIgnoreCase ("verbose"))
+ {
+ return VERBOSE;
+ }
+
+ return SILENT;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ObjID.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ObjID.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ObjID.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ObjID.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,197 @@
+/* ObjID.java -- Unique object id with respect to the given host.
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+
+/**
+ * Represents the object identifier, unique for the host that generated it.
+ * The ObjID contains inside the integer object identifier that, if needed,
+ * may indicated that this is a reference to one of the well known objects
+ * on that host (registry, activator or dgc) and the {@link UID} that
+ * ensures uniqueness.
+ */
+public final class ObjID
+ implements Serializable
+{
+
+ /**
+ * Use serial version uid for interoperability.
+ */
+ static final long serialVersionUID = - 6386392263968365220L;
+
+ /**
+ * The object counter, which value is assigned when creating the ordinary
+ * objects without the known object id. The counter is incremented each time
+ * the new ObjID is constructed.
+ */
+ private static long next = 0x8000000000000000L;
+
+ /**
+ * The object to put the lock on when incrementing {@link #next}
+ */
+ private static final Object lock = ObjID.class;
+
+ /**
+ * Defines the ID of the naming service.
+ */
+ public static final int REGISTRY_ID = 0;
+
+ /**
+ * Defines the ID of the activator.
+ */
+ public static final int ACTIVATOR_ID = 1;
+
+ /**
+ * Defines the ID of the distributed garbage collector.
+ */
+ public static final int DGC_ID = 2;
+
+ /**
+ * The object Id (either well-known value or the value of the incrementing
+ * object counter.
+ */
+ long objNum;
+
+ /**
+ * The object unique identifier, generated individually for each object.
+ */
+ UID space;
+
+ /**
+ * Create the new object id, unique for this host.
+ */
+ public ObjID()
+ {
+ synchronized (lock)
+ {
+ objNum = next++;
+ }
+ space = new UID();
+ }
+
+ /**
+ * Create the new object id defining the well known remotely accessible
+ * object, present in this host. The well - known objects are:
+ * <ul>
+ * <li>{@link #REGISTRY_ID} - RMI naming service.</li>
+ * <li>{@link #ACTIVATOR_ID} - activator</li>
+ * <li>{@link #DGC_ID} - distributed garbage collector (grants lease
+ * durations to keep the object before it is garbage collected.</li>
+ * </ul>
+ *
+ * @param id the well known object id, one of the above.
+ */
+ public ObjID(int id)
+ {
+ objNum = (long) id;
+ space = new UID((short) 0);
+ }
+
+ /**
+ * Write object id as long, then the object {@link UID}.
+ */
+ public void write(ObjectOutput out) throws IOException
+ {
+ DataOutput dout = (DataOutput) out;
+ dout.writeLong(objNum);
+ space.write(dout);
+ }
+
+ /**
+ * Read object id (as long), then the object {@link UID}.
+ */
+ public static ObjID read(ObjectInput in) throws IOException
+ {
+ DataInput din = (DataInput) in;
+ ObjID id = new ObjID();
+ id.objNum = din.readLong();
+ id.space = UID.read(din);
+ return (id);
+ }
+
+ /**
+ * Get the hashcode.
+ */
+ public int hashCode()
+ {
+ return space == null ? (int) objNum : space.hashCode() ^ (int) objNum;
+ }
+
+ /**
+ * Compare for equality.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ObjID)
+ {
+ ObjID that = (ObjID) obj;
+ return that.objNum == objNum && eq(that.space, space);
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Compare by .equals if both a and b are not null, compare directly if at
+ * least one of them is null.
+ */
+ static final boolean eq(Object a, Object b)
+ {
+ if (a == null || b == null)
+ return a == b;
+ else
+ return a.equals(b);
+ }
+
+ /**
+ * Get the string representation.
+ */
+ public String toString()
+ {
+ return (objNum + ":" + space);
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/Operation.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/Operation.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/Operation.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/Operation.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* Operation.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+/**
+ * This class was used with jdk 1.1 stubs and skeletons. It is no longer
+ * needed since jdk 1.2 and higher.
+ *
+ * @deprecated
+ */
+public class Operation
+{
+ private String operation;
+
+ /**
+ * Create operation with the given name.
+ * @deprecated
+ */
+ public Operation (String op)
+ {
+ operation = op;
+ }
+
+ /**
+ * Get the name of the operation.
+ *
+ * @deprecated
+ */
+ public String getOperation ()
+ {
+ return operation;
+ }
+
+ /**
+ * Return the name of the operation.
+ *
+ * @deprecated
+ */
+ public String toString ()
+ {
+ return operation;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIClassLoader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIClassLoader.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIClassLoader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIClassLoader.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,203 @@
+/* RMIClassLoader.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import gnu.classpath.ServiceFactory;
+import gnu.classpath.SystemProperties;
+import gnu.java.rmi.server.RMIClassLoaderImpl;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+
+/**
+ * This class provides a set of public static utility methods for supporting
+ * network-based class loading in RMI. These methods are called by RMI's
+ * internal marshal streams to implement the dynamic class loading of types for
+ * RMI parameters and return values.
+ */
+public class RMIClassLoader
+{
+ /**
+ * This class isn't intended to be instantiated.
+ */
+ private RMIClassLoader() {}
+
+ /**
+ * @deprecated
+ */
+ public static Class loadClass(String name)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ return loadClass("", name);
+ }
+
+ public static Class loadClass(String codebase, String name)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadClass(codebase, name, null);
+ }
+
+ public static Class loadClass(String codebase, String name,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadClass(codebase, name, defaultLoader);
+ }
+
+ public static Class loadProxyClass (String codeBase, String[] interfaces,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadProxyClass(codeBase, interfaces, defaultLoader);
+ }
+
+ /**
+ * Loads a class from <code>codeBase</code>.
+ *
+ * This method delegates to
+ * {@link RMIClassLoaderSpi#loadClass(String, String, ClassLoader)} and
+ * passes <code>codeBase.toString()</code> as first argument,
+ * <code>name</code> as second argument and <code>null</code> as third
+ * argument.
+ *
+ * @param codeBase the code base from which to load the class
+ * @param name the name of the class
+ *
+ * @return the loaded class
+ *
+ * @throws MalformedURLException if the URL is not well formed
+ * @throws ClassNotFoundException if the requested class cannot be found
+ */
+ public static Class loadClass(URL codeBase, String name)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadClass(codeBase.toString(), name, null);
+ }
+
+ /**
+ * Gets a classloader for the given codebase and with the current
+ * context classloader as parent.
+ *
+ * @param codebase
+ *
+ * @return a classloader for the given codebase
+ *
+ * @throws MalformedURLException if the codebase contains a malformed URL
+ */
+ public static ClassLoader getClassLoader(String codebase)
+ throws MalformedURLException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.getClassLoader(codebase);
+ }
+
+ /**
+ * Returns a string representation of the network location where a remote
+ * endpoint can get the class-definition of the given class.
+ *
+ * @param cl
+ *
+ * @return a space seperated list of URLs where the class-definition
+ * of cl may be found
+ */
+ public static String getClassAnnotation(Class cl)
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.getClassAnnotation(cl);
+ }
+
+ /**
+ * @deprecated
+ */
+ public static Object getSecurityContext (ClassLoader loader)
+ {
+ throw new Error ("Not implemented");
+ }
+
+ /**
+ * Returns the default service provider for <code>RMIClassLoader</code>.
+ *
+ * @return the default provider for <code>RMIClassLoader</code>
+ */
+ public static RMIClassLoaderSpi getDefaultProviderInstance()
+ {
+ return RMIClassLoaderImpl.getInstance();
+ }
+
+ /**
+ * Chooses, instantiates and returns a service provider.
+ *
+ * @return a service provider
+ */
+ private static RMIClassLoaderSpi getProviderInstance()
+ {
+ // If the user asked for the default, return it. We do a special
+ // check here because our standard service lookup function does not
+ // handle this -- nor should it.
+ String prop = SystemProperties.getProperty("java.rmi.server.RMIClassLoaderSpi");
+ if ("default".equals(prop))
+ return null;
+ Iterator it = ServiceFactory.lookupProviders(RMIClassLoaderSpi.class,
+ null);
+ if (it == null || ! it.hasNext())
+ return null;
+ // FIXME: the spec says we ought to throw an Error of some kind if
+ // the specified provider is not suitable for some reason. However
+ // our service factory simply logs the problem and moves on to the next
+ // provider in this situation.
+ return (RMIClassLoaderSpi) it.next();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIClassLoaderSpi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIClassLoaderSpi.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIClassLoaderSpi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIClassLoaderSpi.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,64 @@
+/* RMIClassLoaderSpi.java --
+ Copyright (c) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import java.net.MalformedURLException;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public abstract class RMIClassLoaderSpi
+{
+ public RMIClassLoaderSpi()
+ {
+ }
+
+ public abstract Class loadClass (String codeBase, String name,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException;
+
+ public abstract Class loadProxyClass (String codeBase, String[] interfaces,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException;
+
+ public abstract ClassLoader getClassLoader (String codebase)
+ throws MalformedURLException;
+
+ public abstract String getClassAnnotation (Class cl);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIClientSocketFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIClientSocketFactory.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIClientSocketFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIClientSocketFactory.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+/* RMIClientSocketFactory.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.IOException;
+import java.net.Socket;
+
+public interface RMIClientSocketFactory
+{
+ Socket createSocket (String host, int port) throws IOException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIFailureHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIFailureHandler.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIFailureHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIFailureHandler.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+/* RMIFailureHandler.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+public interface RMIFailureHandler
+{
+ /**
+ * @exception IOException If an error occurs
+ */
+ boolean failure (Exception ex);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIServerSocketFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIServerSocketFactory.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIServerSocketFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMIServerSocketFactory.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+/* RMIServerSocketFactory.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+
+public interface RMIServerSocketFactory
+{
+ ServerSocket createServerSocket(int port) throws IOException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMISocketFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMISocketFactory.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMISocketFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RMISocketFactory.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,108 @@
+/* RMISocketFactory.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import gnu.java.rmi.server.RMIDefaultSocketFactory;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+public abstract class RMISocketFactory
+ implements RMIClientSocketFactory, RMIServerSocketFactory
+{
+ private static RMISocketFactory defaultFactory;
+ private static RMISocketFactory currentFactory;
+ private static RMIFailureHandler currentHandler;
+
+ static
+ {
+ defaultFactory = new RMIDefaultSocketFactory();
+ currentFactory = defaultFactory;
+ }
+
+ public RMISocketFactory ()
+ {
+ }
+
+ /**
+ * @exception IOException If an error occurs
+ */
+ public abstract Socket createSocket (String host, int port)
+ throws IOException;
+
+ /**
+ * @exception IOException If an error occurs
+ */
+ public abstract ServerSocket createServerSocket (int port)
+ throws IOException;
+
+ /**
+ * @exception IOException If an error occurs
+ * @exception SecurityException FIXME
+ */
+ public static void setSocketFactory (RMISocketFactory fac)
+ throws IOException
+ {
+ currentFactory = fac;
+ }
+
+ public static RMISocketFactory getSocketFactory ()
+ {
+ return currentFactory;
+ }
+
+ public static RMISocketFactory getDefaultSocketFactory ()
+ {
+ return defaultFactory;
+ }
+
+ /**
+ * @exception SecurityException FIXME
+ */
+ public static void setFailureHandler (RMIFailureHandler fh)
+ {
+ currentHandler = fh;
+ }
+
+ public static RMIFailureHandler getFailureHandler ()
+ {
+ return currentHandler;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteCall.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteCall.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteCall.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteCall.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,86 @@
+/* RemoteCall.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.StreamCorruptedException;
+
+/**
+ * @deprecated
+ */
+public interface RemoteCall
+{
+ /**
+ * @deprecated
+ */
+ ObjectOutput getOutputStream () throws IOException;
+
+ /**
+ * @deprecated
+ */
+ void releaseOutputStream () throws IOException;
+
+ /**
+ * @deprecated
+ */
+ ObjectInput getInputStream () throws IOException;
+
+ /**
+ * @deprecated
+ */
+ void releaseInputStream () throws IOException;
+
+ /**
+ * @deprecated
+ */
+ ObjectOutput getResultStream (boolean success)
+ throws IOException, StreamCorruptedException;
+
+ /**
+ * @deprecated
+ */
+ void executeCall () throws Exception;
+
+ /**
+ * @deprecated
+ */
+ void done () throws IOException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteObject.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteObject.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteObject.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteObject.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,202 @@
+/* RemoteObject.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.rmi.UnmarshalException;
+import java.util.WeakHashMap;
+
+public abstract class RemoteObject
+ implements Remote, Serializable {
+
+private static final long serialVersionUID = -3215090123894869218l;
+
+protected transient RemoteRef ref;
+
+private static final WeakHashMap stubs = new WeakHashMap();
+
+protected RemoteObject() {
+ this(null);
+}
+
+protected RemoteObject(RemoteRef newref) {
+ ref = newref;
+}
+
+public RemoteRef getRef() {
+ return (ref);
+}
+
+synchronized static void addStub(Remote obj, Remote stub)
+{
+ stubs.put(obj, stub);
+}
+
+synchronized static void deleteStub(Remote obj)
+{
+ stubs.remove(obj);
+}
+
+ public static Remote toStub(Remote obj) throws NoSuchObjectException
+ {
+ Remote stub = (Remote)stubs.get(obj);
+
+ if (stub == null)
+ throw new NoSuchObjectException(obj.getClass().getName());
+
+ return stub;
+ }
+
+public int hashCode() {
+ if (ref == null) {
+ return (0);
+ }
+ else {
+ return (ref.hashCode());
+ }
+}
+
+public boolean equals(Object obj) {
+ // We only compare references.
+ return (this == obj);
+}
+
+/**
+ * Get the string representation of this remote object.
+ */
+ public String toString()
+ {
+ if (ref == null)
+ return getClass ().toString ();
+ return (ref.toString ());
+ }
+
+ /**
+ * Read the remote object from the input stream. Expects the class name
+ * without package first. Then the method creates and assigns the {@link #ref}
+ * an instance of this class and calls its .readExternal method. The standard
+ * packageless class names are UnicastRef, UnicastRef2, UnicastServerRef,
+ * UnicastServerRef2, ActivatableRef or ActivatableServerRef.
+ *
+ * @param in the stream to read from
+ * @throws IOException if the IO exception occurs
+ * @throws ClassNotFoundException if the class with the given name is not
+ * present in the package gnu.java.rmi.server (for the case of the
+ * GNU Classpath.
+ */
+ private void readObject(ObjectInputStream in) throws IOException,
+ ClassNotFoundException
+ {
+ String cname = in.readUTF();
+ if (! cname.equals(""))
+ {
+ if (cname.equals("UnicastRef2"))
+ {
+ // hack for interoperating with JDK
+ cname = "UnicastRef";
+ in.read(); // some unknown UnicastRef2 field
+ }
+
+ // It would be nice to use RemoteRef.packagePrefix here, but for binary
+ // compatibility with the JDK that has to contain "sun.rmi.server"...
+ cname = "gnu.java.rmi.server." + cname;
+ try
+ {
+ Class cls = Class.forName(cname);
+ ref = (RemoteRef) cls.newInstance();
+ }
+ catch (InstantiationException e1)
+ {
+ throw new UnmarshalException("failed to create ref", e1);
+ }
+ catch (IllegalAccessException e2)
+ {
+ throw new UnmarshalException("failed to create ref", e2);
+ }
+ ref.readExternal(in);
+ }
+ else
+ {
+ ref = (RemoteRef) in.readObject();
+ }
+ }
+
+ /**
+ * Write the remote object to the output stream. This method first calls
+ * {@link RemoteRef#getRefClass(ObjectOutput)} on the {@link #ref} to get the
+ * class name without package, writes this name and then calls the
+ * ref.writeObject to write the data. The standard packageless class names are
+ * UnicastRef, UnicastRef2, UnicastServerRef, UnicastServerRef2,
+ * ActivatableRef or ActivatableServerRef. The empty string with the
+ * subsequently following serialized ref instance be written if the
+ * ref.getRefClass returns null.
+ *
+ * @param out the stream to write to
+ * @throws IOException if one occurs during writing
+ * @throws ClassNotFoundException never in this implementation (specified as
+ * part of the API standard)
+ * @throws UnmarshalException if the remote reference of this remote object is
+ * null.
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException,
+ ClassNotFoundException
+ {
+ if (ref == null)
+ {
+ throw new UnmarshalException("no ref to serialize");
+ }
+ String cname = ref.getRefClass(out);
+ if (cname != null && cname.length() > 0)
+ {
+ out.writeUTF(cname);
+ ref.writeExternal(out);
+ }
+ else
+ {
+ out.writeUTF("");
+ out.writeObject(ref);
+ }
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteObjectInvocationHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteObjectInvocationHandler.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteObjectInvocationHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteObjectInvocationHandler.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,229 @@
+/* RemoteObjectInvocationHandler.java -- RMI stub replacement.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package java.rmi.server;
+
+import gnu.java.rmi.server.RMIHashes;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+import java.rmi.registry.Registry;
+import java.rmi.server.RemoteObject;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.Hashtable;
+
+/**
+ * Together with dynamic proxy instance, this class replaces the generated RMI
+ * stub (*_Stub) classes that (following 1.5 specification) should be no longer
+ * required. It is unusual to use the instances of this class directly in the
+ * user program. Such instances are automatically created and returned by
+ * {@link Registry} or {@link UnicastRemoteObject} methods if the remote
+ * reference is known but the corresponding stub class is not accessible.
+ *
+ * @see Registry#lookup
+ *
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)
+ */
+public class RemoteObjectInvocationHandler extends RemoteObject implements
+ InvocationHandler, Remote, Serializable
+{
+ /**
+ * Use the jdk 1.5 SUID for interoperability.
+ */
+ static final long serialVersionUID = 2L;
+
+ /**
+ * The RMI method hash codes, computed once as described in the section 8.3
+ * of the Java Remote Method Invocation (RMI) Specification.
+ */
+ static Hashtable methodHashCodes = new Hashtable();
+
+ /**
+ * The empty class array to define parameters of .hashCode and .toString.
+ */
+ static final Class[] noArgsC = new Class[0];
+
+ /**
+ * The class array to define parameters of .equals
+ */
+ static final Class[] anObjectC = new Class[] { Object.class };
+
+ /**
+ * The empty object array to replace null when no args are passed.
+ */
+ static final Object[] noArgs = new Object[0];
+
+ /**
+ * Construct the remote invocation handler that forwards calls to the given
+ * remote object.
+ *
+ * @param reference the reference to the remote object where the method
+ * calls should be forwarded.
+ */
+ public RemoteObjectInvocationHandler(RemoteRef reference)
+ {
+ super(reference);
+ }
+
+ /**
+ * Invoke the remote method. When the known method is invoked on a created RMI
+ * stub proxy class, the call is delivered to this method and then transferred
+ * to the {@link RemoteRef#invoke(Remote, Method, Object[], long)} of the
+ * remote reference that was passed in constructor. The methods are handled as
+ * following:
+ * <ul>
+ * <li> The toString() method is delegated to the passed proxy instance.</li>
+ * <li>The .equals method only returns true if the passed object is an
+ * instance of proxy class and its invocation handler is equal to this
+ * invocation handles.</li>
+ * <li>The .hashCode returns the hashCode of this invocation handler (if the.</li>
+ * <li>All other methods are converted to remote calls and forwarded to the
+ * remote reference. </li>
+ * </ul>
+ *
+ * @param proxyInstance
+ * the instance of the proxy stub
+ * @param method
+ * the method being invoked
+ * @param parameters
+ * the method parameters
+ * @return the method return value, returned by RemoteRef.invoke
+ * @throws IllegalAccessException
+ * if the passed proxy instance does not implement Remote interface.
+ * @throws UnexpectedException
+ * if remote call throws some exception, not listed in the
+ * <code>throws</code> clause of the method being called.
+ * @throws Throwable
+ * that is thrown by remote call, if that exception is listend in
+ * the <code>throws</code> clause of the method being called.
+ */
+ public Object invoke(Object proxyInstance, Method method, Object[] parameters)
+ throws Throwable
+ {
+ if (!(proxyInstance instanceof Remote))
+ {
+ String name = proxyInstance == null ? "null"
+ : proxyInstance.getClass().getName();
+ throw new IllegalAccessException(name + " does not implement "
+ + Remote.class.getName());
+ }
+
+ if (parameters == null)
+ parameters = noArgs;
+
+ String name = method.getName();
+ switch (name.charAt(0))
+ {
+ case 'e':
+ if (parameters.length == 1 && name.equals("equals")
+ && method.getParameterTypes()[0].equals(Object.class))
+ {
+ if (parameters[0] instanceof Proxy)
+ {
+ Object handler = Proxy.getInvocationHandler(parameters[0]);
+ if (handler == null)
+ return Boolean.FALSE;
+ else
+ return handler.equals(this) ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else
+ return Boolean.FALSE;
+ }
+ break;
+ case 'h':
+ if (parameters.length == 0 && name.equals("hashCode"))
+ {
+ int hashC = Proxy.getInvocationHandler(proxyInstance).hashCode();
+ return new Integer(hashC);
+ }
+ break;
+ case 't':
+ if (parameters.length == 0 && name.equals("toString"))
+ return "Proxy stub:"+ref.remoteToString();
+ break;
+ default:
+ break;
+ }
+
+ Long hash = (Long) methodHashCodes.get(method);
+ if (hash == null)
+ {
+ hash = new Long(RMIHashes.getMethodHash(method));
+ methodHashCodes.put(method, hash);
+ }
+
+ try
+ {
+ return getRef().invoke((Remote) proxyInstance, method, parameters,
+ hash.longValue());
+ }
+ catch (RuntimeException exception)
+ {
+ // RuntimeException is always supported.
+ throw exception;
+ }
+ catch (RemoteException exception)
+ {
+ // All remote methods can throw RemoteException.
+ throw exception;
+ }
+ catch (Error exception)
+ {
+ throw exception;
+ }
+ catch (Exception exception)
+ {
+ Class[] exceptions = method.getExceptionTypes();
+ Class exceptionClass = exception.getClass();
+
+ for (int i = 0; i < exceptions.length; i++)
+ {
+ if (exceptions[i].equals(exceptionClass))
+ throw exception;
+ }
+ throw new UnexpectedException(method.getName(), exception);
+ }
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteRef.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteRef.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteRef.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteRef.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,137 @@
+/* RemoteRef.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * Represents a handler to the remote object. Each instance of the
+ * {@link RemoteStub} contains such handler and uses it to invoke remote
+ * methods via {@link #invoke(Remote, Method, Object[], long)}.
+ */
+public interface RemoteRef extends Externalizable
+{
+ /**
+ * Indicates compatibility with JDK 1.1.*
+ */
+ long serialVersionUID = 3632638527362204081L;
+
+ /**
+ * For binary compatibility with the JDK, the string "sun.rmi.server".
+ * Not actually used for anything.
+ */
+ String packagePrefix = "sun.rmi.server";
+
+ /**
+ * @deprecated use {@link #invoke(Remote, Method, Object[], long)} instead.
+ */
+ void invoke (RemoteCall call) throws Exception;
+
+ /**
+ * Invoke a method. This method either returns the result of remote invocation
+ * or throws RemoteException if the remote call failed. Other exceptions may
+ * be thrown if some problem has occured in the application level.
+ *
+ * @param obj the object, containing the remote reference (for instance,
+ * remote stub, generated by rmic).
+ * @param method the method to invoke
+ * @param params the method parameters
+ * @param methodHash a persistent hash code that can be used to represent a
+ * method
+ * @return the result of the remote invocation
+ * @throws RemoteException if the remote call has failed
+ * @throws Exception if one is raised at the application level
+ */
+ Object invoke (Remote obj, Method method, Object[] params, long methodHash)
+ throws Exception;
+
+ /**
+ * @deprecated use {@link #invoke(Remote, Method, Object[], long)} instead.
+ */
+ RemoteCall newCall (RemoteObject obj, Operation[] op, int opnum, long hash)
+ throws RemoteException;
+
+ /**
+ * @deprecated use {@link #invoke(Remote, Method, Object[], long)} instead.
+ */
+ void done (RemoteCall call) throws RemoteException;
+
+ /**
+ * Compare two remote objects for equality. The references are equal if
+ * they point to the same remote object.
+ *
+ * @param ref the reference to compare.
+ *
+ * @return true if this and passed references both point to the same remote
+ * object, false otherwise.
+ */
+ boolean remoteEquals (RemoteRef ref);
+
+ /**
+ * Get the hashcode for a remote object. Two remote object stubs, referring
+ * to the same remote object, have the same hash code.
+ *
+ * @return the hashcode of the remote object
+ */
+ int remoteHashCode();
+
+
+ /**
+ * Returns the class name of the reference type that must be written to the
+ * given stream. When writing, this returned name is passed first, and
+ * the reference.writeExternal(out) writes the reference specific data.
+ *
+ * @param out the stream, where the data must be written
+ *
+ * @return the class name.
+ */
+ String getRefClass (ObjectOutput out);
+
+ /**
+ * Get the string representation of this remote reference.
+ *
+ * @return the string representation.
+ */
+ String remoteToString();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteServer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteServer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteServer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteServer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,115 @@
+/* RemoteServer.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import gnu.java.rmi.server.RMIIncomingThread;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+/**
+ * A common superclass for the server implementations.
+ */
+public abstract class RemoteServer
+ extends RemoteObject
+{
+ private static final long serialVersionUID = - 4100238210092549637L;
+
+ /**
+ * Does nothing, delegates to super().
+ */
+ protected RemoteServer()
+ {
+ super();
+ }
+
+ /**
+ * Does nothing, delegates to super(ref).
+ */
+ protected RemoteServer(RemoteRef ref)
+ {
+ super(ref);
+ }
+
+ /**
+ * Get the host of the calling client. The current thread must be an instance
+ * of the {@link RMIIncomingThread}.
+ *
+ * @return the client host address
+ *
+ * @throws ServerNotActiveException if the current thread is not an instance
+ * of the RMIIncomingThread.
+ */
+ public static String getClientHost() throws ServerNotActiveException
+ {
+ Thread currThread = Thread.currentThread();
+ if (currThread instanceof RMIIncomingThread)
+ {
+ RMIIncomingThread incomingThread = (RMIIncomingThread) currThread;
+ return incomingThread.getClientHost();
+ }
+ else
+ {
+ throw new ServerNotActiveException(
+ "Unknown client host - current thread not instance of 'RMIIncomingThread'");
+ }
+ }
+
+ /**
+ * Set the stream for logging RMI calls.
+ *
+ * @param out the stream to set or null to turn the logging off.
+ */
+ public static void setLog(OutputStream out)
+ {
+ throw new Error("Not implemented");
+ }
+
+ /**
+ * Get the stream for logging RMI calls.
+ *
+ * @return the associated stream.
+ */
+ public static PrintStream getLog()
+ {
+ throw new Error("Not implemented");
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteStub.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteStub.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteStub.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/RemoteStub.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,80 @@
+/* RemoteStub.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+/**
+ * This is a base class for the automatically generated RMI stubs.
+ */
+public abstract class RemoteStub extends RemoteObject
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ static final long serialVersionUID = -1585587260594494182l;
+
+ /**
+ * Constructs the remote stub with no reference set.
+ */
+ protected RemoteStub ()
+ {
+ super ();
+ }
+
+ /**
+ * Constructs the remote stub that uses given remote reference for the
+ * method invocations.
+ *
+ * @param ref the remote reference for the method invocation.
+ */
+ protected RemoteStub (RemoteRef ref)
+ {
+ super (ref);
+ }
+
+ /**
+ * Sets the given remote reference for the given stub. This method is
+ * deprecated. Pass the stub remote reference to the RemoteStub
+ * constructor instead.
+ *
+ * @deprecated
+ */
+ protected static void setRef (RemoteStub stub, RemoteRef ref)
+ {
+ stub.ref = ref;
+ }
+} // class RemoteSub
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ServerCloneException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ServerCloneException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ServerCloneException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ServerCloneException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,117 @@
+/* ServerCloneException.java -- a UnicastRemoteObject could not be cloned
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+/**
+ * Thrown if a remote exception occurs during the cloning process of a
+ * <code>UnicastRemoteObject</code>.
+ *
+ * @author unknown
+ * @see UnicastRemoteObject#clone()
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ServerCloneException extends CloneNotSupportedException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 6617456357664815945L;
+
+ /**
+ * The cause of this exception. This pre-dates the exception chaining
+ * of Throwable; and although you can change this field, you are wiser
+ * to leave it alone.
+ *
+ * @serial the exception cause
+ */
+ public Exception detail;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public ServerCloneException(String s)
+ {
+ this(s, null);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public ServerCloneException(String s, Exception e)
+ {
+ super(s);
+ initCause(e);
+ detail = e;
+ }
+
+ /**
+ * This method returns a message indicating what went wrong, in this
+ * format:
+ * <code>super.getMessage() + (detail == null ? ""
+ * : "; nested exception is:\n\t" + detail)</code>.
+ *
+ * @return the chained message
+ */
+ public String getMessage()
+ {
+ if (detail == this || detail == null)
+ return super.getMessage();
+ return super.getMessage() + "; nested exception is:\n\t" + detail;
+ }
+
+ /**
+ * Returns the cause of this exception. Note that this may not be the
+ * original cause, thanks to the <code>detail</code> field being public
+ * and non-final (yuck). However, to avoid violating the contract of
+ * Throwable.getCause(), this returns null if <code>detail == this</code>,
+ * as no exception can be its own cause.
+ *
+ * @return the cause
+ * @since 1.4
+ */
+ public Throwable getCause()
+ {
+ return detail == this ? null : detail;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ServerNotActiveException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ServerNotActiveException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ServerNotActiveException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ServerNotActiveException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* ServerNotActiveException.java -- the method is not servicing a remote call
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+/**
+ * Thrown during <code>RemoteServer.getClientHost</code> if the host is
+ * not servicing a remote method call.
+ *
+ * @author unknown
+ * @see RemoteServer#getClientHost()
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ServerNotActiveException extends Exception
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 4687940720827538231L;
+
+ /**
+ * Create an exception with no message.
+ */
+ public ServerNotActiveException()
+ {
+ }
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public ServerNotActiveException(String s)
+ {
+ super(s);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ServerRef.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ServerRef.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ServerRef.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/ServerRef.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,51 @@
+/* ServerRef.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface ServerRef extends RemoteRef
+{
+ long serialVersionUID = -4557750989390278438L;
+
+ RemoteStub exportObject(Remote obj, Object data) throws RemoteException;
+
+ String getClientHost() throws ServerNotActiveException;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/Skeleton.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/Skeleton.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/Skeleton.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/Skeleton.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* Skeleton.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import java.rmi.Remote;
+
+/**
+ * @deprecated
+ */
+public interface Skeleton
+{
+ /**
+ * @deprecated
+ */
+ void dispatch (Remote obj, RemoteCall theCall, int opnum, long hash)
+ throws Exception;
+
+ /**
+ * @deprecated
+ */
+ Operation[] getOperations();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/SkeletonMismatchException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/SkeletonMismatchException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/SkeletonMismatchException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/SkeletonMismatchException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,68 @@
+/* SkeletonMismatchException.java -- thrown when stub class versions mismatch
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import java.rmi.RemoteException;
+
+/**
+ * Thrown if a call is received that does not match a Skeleton. Note that
+ * Skeletons are no longer required.
+ *
+ * @author unknown
+ * @since 1.1
+ * @deprecated no replacement. Skeletons are no longer required.
+ * @status updated to 1.4
+ */
+public class SkeletonMismatchException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1.
+ */
+ private static final long serialVersionUID = -7780460454818859281l;
+
+ /**
+ * Create an exception with the specified message.
+ *
+ * @param s the message
+ * @deprecated no longer needed
+ */
+ public SkeletonMismatchException(String s)
+ {
+ super(s);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/SkeletonNotFoundException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/SkeletonNotFoundException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/SkeletonNotFoundException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/SkeletonNotFoundException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* SkeletonNotFoundException.java -- thrown if a Skeleton is not found
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.rmi.RemoteException;
+
+/**
+ * Thrown if a Skeleton corresponding to the remote object is not found.
+ * Note that Skeletons are no longer required.
+ *
+ * @author unknown
+ * @since 1.1
+ * @deprecated no replacement. Skeletons are no longer required.
+ * @status updated to 1.4
+ */
+public class SkeletonNotFoundException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1.
+ */
+ private static final long serialVersionUID = -7860299673822761231L;
+
+ /**
+ * Create an exception with the specified message.
+ *
+ * @param s the message
+ */
+ public SkeletonNotFoundException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with the specified message and cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public SkeletonNotFoundException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/SocketSecurityException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/SocketSecurityException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/SocketSecurityException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/SocketSecurityException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* SocketSecurityException.java -- the socket could not be created
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+/**
+ * Thrown during remote object export if the code does not have permission
+ * to create a <code>java.net.ServerSocket</code> on the specified port.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class SocketSecurityException extends ExportException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -7622072999407781979L;
+
+ /**
+ * Create an exception with the specified message.
+ *
+ * @param s the message
+ */
+ public SocketSecurityException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with the specified message and cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public SocketSecurityException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/UID.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/UID.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/UID.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/UID.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,225 @@
+/* UID.java -- The unique object Id
+ Copyright (c) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.InetAddress;
+
+/**
+ * Represents the unique identifier over time for the host which has generated
+ * it. It contains time (when created), counter (the number of the UID
+ * creation order) and virtual machine id components. The UID can also be
+ * constructed specifying a "well known" identifier in the for of short:
+ * this identifier defines the UID uniqueness alone.
+ *
+ * @author Audrius Meskauskas (audriusa at bioinformatics.org)
+ */
+public final class UID
+ implements Serializable
+{
+ /**
+ * Use the serial version uid for interoperability.
+ */
+ private static final long serialVersionUID = 1086053664494604050L;
+
+ /**
+ * The UID counter (the ordinary number in the sequence of number of UID's,
+ * created during the recent millisecond). In the next millisecond, it
+ * starts from the minimal value again. In the unlikely case of creating
+ * more than 65536 uids per millisecond the process pauses till the next
+ * ms.
+ */
+ private static short uidCounter = Short.MIN_VALUE;
+
+ /**
+ * The time, when the last UID has been created.
+ */
+ private static long last;
+
+ /**
+ * This constant tries to be the unique identifier of the virtual machine.
+ */
+ private static final int machineId = getMachineId();
+
+ /**
+ * The UID number in the UID creation sequence.
+ */
+ private short count;
+
+ /**
+ * Always gets the uniqueNr value.
+ */
+ private int unique;
+
+ /**
+ * The time stamp, when the UID was created.
+ */
+ private long time;
+
+ /**
+ * Create the new UID that would have the described features of the
+ * uniqueness.
+ */
+ public UID()
+ {
+ synchronized (UID.class)
+ {
+ time = System.currentTimeMillis();
+ unique = machineId;
+ if (time > last)
+ {
+ last = time;
+ count = uidCounter = Short.MIN_VALUE;
+ }
+ else
+ {
+ if (uidCounter == Short.MAX_VALUE)
+ {
+ // Make a 2 ms pause if the counter has reached the maximal
+ // value. This should seldom happen.
+ try
+ {
+ Thread.sleep(2);
+ }
+ catch (InterruptedException e)
+ {
+ }
+ uidCounter = Short.MIN_VALUE;
+ time = last = System.currentTimeMillis();
+ }
+ count = ++uidCounter;
+ }
+ }
+ }
+
+ /**
+ * Create the new UID with the well known id (number). All UIDs, creates
+ * with the this constructor having the same parameter are equal to each
+ * other (regardless to the host and time where they were created.
+ *
+ * @param wellKnownId the well known UID.
+ */
+ public UID(short wellKnownId)
+ {
+ unique = wellKnownId;
+ }
+
+ /**
+ * Get the hashCode of this UID.
+ */
+ public int hashCode()
+ {
+ return (int) (unique ^ time ^ count);
+ }
+
+ /**
+ * Compare this UID with another UID for equality (not equal to other types of
+ * objects).
+ */
+ public boolean equals(Object other)
+ {
+ if (other instanceof UID)
+ {
+ UID ui = (UID) other;
+ return unique == ui.unique && time == ui.time && count == ui.count;
+ }
+ else
+ return false;
+ }
+
+ public static UID read(DataInput in) throws IOException
+ {
+ UID uid = new UID();
+ uid.unique = in.readInt();
+ uid.time = in.readLong();
+ uid.count = in.readShort();
+ return (uid);
+ }
+
+ public void write(DataOutput out) throws IOException
+ {
+ out.writeInt(unique);
+ out.writeLong(time);
+ out.writeShort(count);
+ }
+
+ /**
+ * Do our best to get the Id of this virtual machine.
+ */
+ static int getMachineId()
+ {
+ int hostIpHash;
+
+ try
+ {
+ // Try to get the host IP.
+ String host = InetAddress.getLocalHost().toString();
+ // This hash is content - based, not the address based.
+ hostIpHash = host.hashCode();
+ }
+ catch (Exception e)
+ {
+ // Failed due some reason.
+ hostIpHash = 0;
+ }
+
+ // Should be the unque address if hashcodes are addresses.
+ // Additionally, add the time when the RMI system was probably started
+ // (this class was first instantiated).
+ return new Object().hashCode() ^ (int) System.currentTimeMillis()
+ ^ hostIpHash;
+ }
+
+ /**
+ * Get the string representation of this UID.
+ *
+ * @return a string, uniquely identifying this id.
+ */
+ public String toString()
+ {
+ int max = Character.MAX_RADIX;
+ // Translate into object count, counting from 0.
+ long lc = (count - Short.MIN_VALUE) & 0xFFFF;
+ return Long.toString(unique, max) + ":" + Long.toString(time, max) + "."
+ + Long.toString(lc, max);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/UnicastRemoteObject.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/UnicastRemoteObject.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/UnicastRemoteObject.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/UnicastRemoteObject.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,250 @@
+/* UnicastRemoteObject.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2003, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import gnu.java.rmi.server.UnicastServerRef;
+
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * This class obtains stub that communicates with the remote object.
+ */
+public class UnicastRemoteObject extends RemoteServer
+{
+ /**
+ * Use SVUID for interoperability.
+ */
+ private static final long serialVersionUID = 4974527148936298033L;
+
+ //The following serialized fields are from Java API Documentation
+ // "Serialized form"
+
+ /**
+ * The port, on that the created remote object becomes available,
+ * zero meaning the anonymous port.
+ */
+ private int port;
+
+ /**
+ * The client socket factory for producing client sockets, used by this
+ * object.
+ */
+ private RMIClientSocketFactory csf;
+
+ /**
+ * The server socket factory for producing server sockets, used by this
+ * object.
+ */
+ private RMIServerSocketFactory ssf;
+
+ /**
+ * Create and export new remote object without specifying the port value.
+ *
+ * @throws RemoteException if the attempt to export the object failed.
+ */
+ protected UnicastRemoteObject()
+ throws RemoteException
+ {
+ this(0);
+ }
+
+ /**
+ * Create and export the new remote object, making it available at the
+ * given port, local host.
+ *
+ * @param port the port, on that the object should become available.
+ * Zero means anonymous port.
+ *
+ * @throws RemoteException if the attempt to export the object failed.
+ */
+ protected UnicastRemoteObject(int port)
+ throws RemoteException
+ {
+ this(port, RMISocketFactory.getSocketFactory(),
+ RMISocketFactory.getSocketFactory());
+ }
+
+ /**
+ * Create and export the new remote object, making it available at the
+ * given port, using sockets, produced by the specified factories.
+ *
+ * @param port the port, on that the object should become available.
+ * Zero means anonymous port.
+ *
+ * @param clientSocketFactory the client socket factory
+ * @param serverSocketFactory the server socket factory
+ *
+ * @throws RemoteException if the attempt to export the object failed.
+ */
+ protected UnicastRemoteObject(int port,
+ RMIClientSocketFactory clientSocketFactory,
+ RMIServerSocketFactory serverSocketFactory)
+ throws RemoteException
+ {
+ this.port = port;
+ //Is RMIXXXSocketFactory serializable
+ //this.csf = csf;
+ //this.ssf = ssf;
+ this.ref = new UnicastServerRef(new ObjID(), port, serverSocketFactory);
+ exportObject(this, port);
+ }
+
+ protected UnicastRemoteObject(RemoteRef ref)
+ throws RemoteException
+ {
+ super((UnicastServerRef) ref);
+ exportObject(this, 0);
+ }
+
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ throw new Error("Not implemented");
+ }
+
+ /**
+ * Export object, making it available for the remote calls at the
+ * anonymous port.
+ *
+ * This method returns the instance of the abstract class, not an interface.
+ * Hence it will not work with the proxy stubs that are supported since
+ * jdk 1.5 (such stubs cannot be derived from the RemoteStub). Only use
+ * this method if you are sure that the stub class will be accessible.
+ *
+ * @param obj the object being exported.
+ *
+ * @return the remote object stub
+ *
+ * @throws RemoteException if the attempt to export the object failed.
+ */
+ public static RemoteStub exportObject(Remote obj)
+ throws RemoteException
+ {
+ return (RemoteStub) exportObject(obj, 0);
+ }
+
+ /**
+ * Export object, making it available for the remote calls at the
+ * specified port.
+ *
+ * Since jdk 1.5 this method does not longer require the stub class to be
+ * present. If such class is not found, the stub is replaced by the
+ * dynamically constructed proxy class. No attempt to find and load the stubs
+ * is made if the system property java.rmi.server.ignoreStubClasses
+ * is set to true (set to reduce the starting time if the stubs are
+ * surely not present and exclusively 1.2 RMI is used).
+ *
+ * @param obj the object being exported.
+ * @param port the remote object port
+ *
+ * @return the remote object stub
+ *
+ * @throws RemoteException if the attempt to export the object failed.
+ */
+ public static Remote exportObject(Remote obj, int port)
+ throws RemoteException
+ {
+ return exportObject(obj, port, null);
+ }
+
+ /**
+ * Create and export the new remote object, making it available at the
+ * given port, using sockets, produced by the specified factories.
+ *
+ * Since jdk 1.5 this method does not longer require the stub class to be
+ * present. If such class is not found, the stub is replaced by the
+ * dynamically constructed proxy class. No attempt to find and load the stubs
+ * is made if the system property java.rmi.server.ignoreStubClasses
+ * is set to true (set to reduce the starting time if the stubs are
+ * surely not present and exclusively 1.2 RMI is used).
+ *
+ * @param port the port, on that the object should become available.
+ * Zero means anonymous port.
+ *
+ * @param serverSocketFactory the server socket factory
+ */
+ static Remote exportObject(Remote obj, int port,
+ RMIServerSocketFactory serverSocketFactory)
+ throws RemoteException
+ {
+ UnicastServerRef sref = null;
+ if (obj instanceof RemoteObject)
+ sref = (UnicastServerRef) ((RemoteObject) obj).getRef();
+
+ if (sref == null)
+ sref = new UnicastServerRef(new ObjID(), port, serverSocketFactory);
+
+ Remote stub = sref.exportObject(obj);
+ addStub(obj, stub);
+ return stub;
+ }
+
+ /**
+ * FIXME
+ */
+ public static Remote exportObject(Remote obj, int port,
+ RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf)
+ throws RemoteException
+ {
+ return (exportObject(obj, port, ssf));
+ }
+
+ public static boolean unexportObject(Remote obj, boolean force)
+ throws NoSuchObjectException
+ {
+ if (obj instanceof RemoteObject)
+ {
+ deleteStub(obj);
+ UnicastServerRef sref =
+ (UnicastServerRef) ((RemoteObject) obj).getRef();
+ return sref.unexportObject(obj, force);
+ }
+ else
+ {
+ // FIXME
+ ;
+ }
+ return true;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/Unreferenced.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/Unreferenced.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/Unreferenced.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/Unreferenced.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,43 @@
+/* Unreferenced.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+public interface Unreferenced
+{
+ void unreferenced();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/rmi/server/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.rmi.server package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.rmi.server</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
More information about the llvm-commits
mailing list