Ignore:
Timestamp:
Apr 27, 2004, 8:39:34 PM (21 years ago)
Author:
bird
Message:

GCC v3.3.3 sources.

Location:
branches/GNU/src/gcc
Files:
44 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gcc

    • Property svn:ignore
      •  

        old new  
        2626configure.vr
        2727configure.vrs
         28dir.info
        2829Makefile
        29 dir.info
        3030lost+found
        3131update.out
  • branches/GNU/src/gcc/libjava/gnu/awt/j2d/DirectRasterGraphics.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 2000  Free Software Foundation
     1/* Copyright (C) 2000, 2003  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    6262  public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints);
    6363 
    64   public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
     64  public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints,
     65                          int translateX, int translateY);
    6566 
    6667  public void drawString(String str, int x, int y);
  • branches/GNU/src/gcc/libjava/gnu/awt/j2d/Graphics2DImpl.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 2000  Free Software Foundation
     1/* Copyright (C) 2000, 2002, 2003  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    1010
    1111import java.awt.Color;
     12import java.awt.Composite;
    1213import java.awt.Image;
    1314import java.awt.Shape;
     
    2021import java.awt.Paint;
    2122import java.awt.RenderingHints;
     23import java.awt.Stroke;
    2224import java.awt.geom.AffineTransform;
    2325import java.awt.image.ImageObserver;
     26import java.awt.image.BufferedImage;
     27import java.awt.image.BufferedImageOp;
     28import java.awt.image.RenderedImage;
     29import java.awt.image.renderable.RenderableImage;
     30import java.text.AttributedCharacterIterator;
     31import java.util.Map;
    2432
    2533/**
     
    452460    throw new UnsupportedOperationException(msg);
    453461  }
     462 
     463  public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
     464  {
     465    throw new UnsupportedOperationException("not implemented yet"); 
     466  }
     467
     468  public void drawRenderedImage(RenderedImage image, AffineTransform xform)
     469  {
     470    throw new UnsupportedOperationException("not implemented yet"); 
     471  }
     472
     473  public void drawRenderableImage(RenderableImage image, AffineTransform xform)
     474  {
     475    throw new UnsupportedOperationException("not implemented yet");
     476  }
     477
     478  public void drawString(AttributedCharacterIterator iterator,
     479                                  int x, int y)
     480  {
     481    throw new UnsupportedOperationException("not implemented yet"); 
     482  }
     483
     484  public void drawString(AttributedCharacterIterator iterator, float x,
     485                         float y)
     486  {
     487    throw new UnsupportedOperationException("not implemented yet");
     488  }
     489
     490  public void setComposite(Composite comp)
     491  {
     492    throw new UnsupportedOperationException("not implemented yet");
     493  }
     494
     495  public void setStroke(Stroke stroke)
     496  {
     497    throw new UnsupportedOperationException("not implemented yet");
     498  }
     499
     500  public void setRenderingHints(Map hints)
     501  {
     502    throw new UnsupportedOperationException("not implemented yet");
     503  }
     504
     505  public void addRenderingHints(Map hints)
     506  {
     507    throw new UnsupportedOperationException("not implemented yet");
     508  }
     509
     510  public Composite getComposite()
     511  {
     512    throw new UnsupportedOperationException("not implemented yet");
     513  }
     514
     515  public Stroke getStroke()
     516  {
     517    throw new UnsupportedOperationException("not implemented yet");
     518  }
    454519}
  • branches/GNU/src/gcc/libjava/gnu/awt/j2d/IntegerGraphicsState.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 2000  Free Software Foundation
     1/* Copyright (C) 2000, 2003  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    213213  public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
    214214  {
    215     if ((tx == 0) || (ty == 0))
     215    if ((tx == 0) && (ty == 0))
    216216      {
    217217        directGfx.drawPolyline(xPoints, yPoints, nPoints);
     
    224224  public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
    225225  {
    226     if ((tx == 0) || (ty == 0))
     226    if ((tx == 0) && (ty == 0))
    227227      {
    228228        directGfx.drawPolygon(xPoints, yPoints, nPoints);
     
    233233  }
    234234 
    235   public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
    236   {
    237     if ((tx == 0) || (ty == 0))
    238       {
    239         directGfx.fillPolygon(xPoints, yPoints, nPoints);
    240         return;
    241       }
    242    
    243     throw new UnsupportedOperationException("translate not implemented");
     235  public void fillPolygon (int[] xPoints, int[] yPoints, int nPoints)
     236  {
     237    // FIXME: remove tx & ty args once translation via AffineTransform
     238    // is implemented.
     239    directGfx.fillPolygon (xPoints, yPoints, nPoints, tx, ty);
    244240  }
    245241
  • branches/GNU/src/gcc/libjava/gnu/awt/xlib/XGraphics.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 2000  Free Software Foundation
     1/* Copyright (C) 2000, 2003  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    177177  }
    178178   
    179   public void fillPolygon(int[] xPoints, int[] yPoints, int
    180                           nPoints)
    181   {
    182     throw new UnsupportedOperationException("not implemented");
     179  public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints,
     180                          int translateX, int translateY)
     181  {
     182    context.fillPolygon(xPoints, yPoints, nPoints, translateX, translateY);
    183183  }
    184184
  • branches/GNU/src/gcc/libjava/gnu/awt/xlib/XGraphicsConfiguration.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 2000  Free Software Foundation
     1/* Copyright (C) 2000, 2003  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    1313import java.awt.Graphics2D;
    1414import java.awt.Graphics;
     15import java.awt.GraphicsDevice;
    1516import java.awt.Point;
    1617import java.awt.Color;
     
    129130   *
    130131   * @param offset Offset to data. The given offset does not include
    131    * data buffer offset, which will also be added.  */
     132   * data buffer offset, which will also be added. 
     133   */
    132134  static void attachData(XImage ximage, DataBuffer dataB, int offset)
    133135  {
     
    237239  }
    238240
     241  /**
     242   * Gets the associated device that this configuration describes.
     243   *
     244   * @return the device
     245   */
     246  public GraphicsDevice getDevice()
     247  {
     248    throw new UnsupportedOperationException("not implemented"); 
     249  }
     250
     251  /**
     252   * Returns a buffered image optimized to this device, so that blitting can
     253   * be supported in the buffered image.
     254   *
     255   * @param w the width of the buffer
     256   * @param h the height of the buffer
     257   * @return the buffered image, or null if none is supported
     258   */
    239259  public BufferedImage createCompatibleImage(int width,
    240260                                             int height,
     
    243263    throw new UnsupportedOperationException("not implemented");
    244264  }
    245    
     265
     266  /**
     267   * Returns a buffered volatile image optimized to this device, so that
     268   * blitting can be supported in the buffered image. Because the buffer is
     269   * volatile, it can be optimized by native graphics accelerators.
     270   *
     271   * @param w the width of the buffer
     272   * @param h the height of the buffer
     273   * @return the buffered image, or null if none is supported
     274   * @see Component#createVolatileImage(int, int)
     275   * @since 1.4
     276   */
     277  public VolatileImage createCompatibleVolatileImage(int w, int h)
     278  {
     279    throw new UnsupportedOperationException("not implemented");
     280  }
     281
    246282  /**
    247283   * FIXME: I'm not sure which color model that should be returned here.
     
    354390  int getPixel(Color color)
    355391  {
     392    /* FIXME: consider an integer technique whenever
     393     * the ColorModel is 8 bits per color.
     394     * The problem with using integers is that it doesn't work unless
     395     * the colors are 8 bits each (as in the array), since ColorModel.getDataElement(int[],int)
     396     * expects non-normalized values.  For example, in a 16-bit display mode, you
     397     * would typically have 5 bits each for red and blue, and 6 bits for green.
    356398    int[] components =
    357         {
    358           color.getRed(),
    359           color.getGreen(),
    360           color.getBlue(),
    361           0xff
    362         };
    363        
    364     ColorModel cm = getColorModel();
    365     return cm.getDataElement(components, 0);
     399    {
     400      color.getRed (),
     401      color.getGreen (),
     402      color.getBlue (),
     403      0xff
     404    };
     405     */
     406   
     407    float[] normalizedComponents =
     408    {
     409      ((float)color.getRed ()) / 255F,
     410      ((float)color.getGreen ()) / 255F,
     411      ((float)color.getBlue ()) / 255F,
     412      1
     413    };
     414    int[] unnormalizedComponents = { 0, 0, 0, 0xff };
     415    ColorModel cm = getColorModel ();
     416    cm.getUnnormalizedComponents(normalizedComponents, 0,
     417                                 unnormalizedComponents, 0);
     418    return cm.getDataElement (unnormalizedComponents, 0);
    366419  }
    367420}
  • branches/GNU/src/gcc/libjava/gnu/awt/xlib/XToolkit.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 2000, 2002  Free Software Foundation
     1/* Copyright (C) 2000, 2002, 2003  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    1010
    1111import java.awt.*;
     12import java.awt.dnd.*;
     13import java.awt.dnd.peer.*;
     14import java.awt.im.*;
    1215import java.awt.peer.*;
    1316import java.awt.image.ImageProducer;
     
    1619import java.awt.datatransfer.Clipboard;
    1720import java.util.Properties;
     21import java.util.Map;
    1822
    1923import gnu.gcj.xlib.Display;
     
    170174  public java.awt.image.ColorModel getColorModel()
    171175  {
    172     throw new UnsupportedOperationException("not implemented yet");
     176    return getDefaultXGraphicsConfiguration().getColorModel();
    173177  }
    174178
     
    319323  }
    320324
    321 
    322     /*
    323     public DragSourceContextPeer
    324         createDragSourceContextPeer(DragGestureEvent dge)
    325         throws InvalidDnDOperationException;
    326 
    327     public DragGestureRecognizer
    328         createDragGestureRecognizer(Class abstractRecognizerClass,
    329                                     DragSource ds, Component c,
    330                                     int srcActions, DragGestureListener dgl) {
    331         throw new UnsupportedOperationException("not implemented");
    332     }
    333     */
    334 
    335    
    336     /*
    337     public Map mapInputMethodHighlight(InputMethodHighlight highlight);
    338     */
     325  public DragSourceContextPeer
     326    createDragSourceContextPeer(DragGestureEvent dge)
     327    throws InvalidDnDOperationException
     328  {
     329    throw new UnsupportedOperationException("not implemented"); 
     330  }
     331
     332  public DragGestureRecognizer
     333    createDragGestureRecognizer(Class abstractRecognizerClass,
     334                                DragSource ds, Component c,
     335                                int srcActions, DragGestureListener dgl)
     336  {
     337    throw new UnsupportedOperationException("not implemented");
     338  }
     339
     340   
     341  public Map mapInputMethodHighlight(InputMethodHighlight highlight)
     342  {
     343    throw new UnsupportedOperationException("not implemented");
     344  }
    339345}
  • branches/GNU/src/gcc/libjava/gnu/classpath/Configuration.java.in

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    5252  // For libgcj we never load the JNI libraries.
    5353  boolean INIT_LOAD_LIBRARY = false;
     54       
     55  // For libgcj we have native methods for proxy support....
     56  boolean HAVE_NATIVE_GET_PROXY_DATA = false;
     57  boolean HAVE_NATIVE_GET_PROXY_CLASS = false;
     58  boolean HAVE_NATIVE_GENERATE_PROXY_CLASS = false;
    5459}
  • branches/GNU/src/gcc/libjava/gnu/gcj/convert/Output_EUCJIS.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 1999  Free Software Foundation
     1/* Copyright (C) 1999, 2003  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    2323  public native int write (String str, int inpos, int inlength, char[] work);
    2424
     25  public boolean havePendingBytes()
     26  {
     27    return pending1 >= 0;
     28  }
     29
    2530  int pending1 = -1;
    2631  int pending2;
  • branches/GNU/src/gcc/libjava/gnu/gcj/convert/Output_SJIS.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 1999  Free Software Foundation
     1/* Copyright (C) 1999, 2003  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    2323  public native int write (String str, int inpos, int inlength, char[] work);
    2424
     25  public boolean havePendingBytes()
     26  {
     27    return pending >= 0;
     28  }
     29
    2530  int pending = -1;
    2631}
  • branches/GNU/src/gcc/libjava/gnu/gcj/convert/Output_UTF8.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 1999, 2000  Free Software Foundation
     1/* Copyright (C) 1999, 2000, 2003  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    105105                value = (hi_part - 0xD800) * 0x400 + (ch - 0xDC00) + 0x10000;
    106106                buf[count++] = (byte) (0xF0 | (value >> 18));
     107                avail--;
    107108                bytes_todo = 3;
    108109                hi_part = 0;
     
    119120    return inpos - start_pos;
    120121  }
     122
     123  public boolean havePendingBytes()
     124  {
     125    return bytes_todo > 0;
     126  }
     127
    121128}
  • branches/GNU/src/gcc/libjava/gnu/gcj/convert/UnicodeToBytes.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 1999, 2000, 2001  Free Software Foundation
     1/* Copyright (C) 1999, 2000, 2001, 2003  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    147147  }
    148148
     149  /**
     150   * Returns true when the converter has consumed some bytes that are
     151   * not yet converted to characters because further continuation
     152   * bytes are needed.  Defaults to false, should be overridden by
     153   * decoders that internally store some bytes.
     154   */
     155  public boolean havePendingBytes()
     156  {
     157    return false;
     158  }
     159
    149160  /** Indicate that the converter is resuable.
    150161   * This class keeps track of converters on a per-encoding basis.
  • branches/GNU/src/gcc/libjava/gnu/gcj/convert/natIconv.cc

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    269269      if (r != (size_t) -1 && inc == 0 && outc == 0)
    270270        result = (c != 0xfeff);
     271
     272      // Release iconv handle.
     273      iconv_close (handle);
    271274    }
    272275#endif /* HAVE_ICONV */
  • branches/GNU/src/gcc/libjava/gnu/gcj/protocol/core/Connection.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1414import java.net.*;
    1515import java.io.*;
     16import java.util.Map;
    1617import java.util.Vector;
    1718import java.util.Hashtable;
     
    7071      }
    7172    return (String) hdrHash.get(name.toLowerCase());
     73  }
     74
     75  // Override default method in URLConnection.
     76  public Map getHeaderFields()
     77  {
     78    try
     79      {
     80        getHeaders();
     81      }
     82    catch (IOException x)
     83      {
     84        return null;
     85      }
     86    return hdrHash;
    7287  }
    7388
  • branches/GNU/src/gcc/libjava/gnu/gcj/protocol/file/Connection.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1313import java.net.*;
    1414import java.io.*;
     15import java.util.Map;
    1516import java.util.Vector;
    1617import java.util.Hashtable;
     
    9798
    9899  // Override default method in URLConnection.
     100  public Map getHeaderFields()
     101  {
     102    try
     103      {
     104        getHeaders();
     105      }
     106    catch (IOException x)
     107      {
     108        return null;
     109      }
     110    return hdrHash;
     111  }
     112
     113  // Override default method in URLConnection.
    99114  public String getHeaderField(int n)
    100115  {
  • branches/GNU/src/gcc/libjava/gnu/gcj/protocol/http/Connection.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11// Connection.java - Implementation of HttpURLConnection for http protocol.
    22
    3 /* Copyright (C) 1999, 2000  Free Software Foundation
     3/* Copyright (C) 1999, 2000, 2003  Free Software Foundation
    44
    55   This file is part of libgcj.
     
    1313import java.net.*;
    1414import java.io.*;
     15import java.util.Map;
    1516import java.util.Vector;
    1617import java.util.Hashtable;
     
    2526 * Written using on-line Java Platform 1.2 API Specification, as well
    2627 * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
    27  * Status:  Minimal subset of functionality.  Proxies and Redirects
    28  *      not yet handled.  FileNameMap handling needs to be considered.
    29  *      useCaches, ifModifiedSince, and allowUserInteraction need
    30  *      consideration as well as doInput and doOutput.
     28 * Status: Minimal subset of functionality.  Proxies only partially
     29 * handled; Redirects not yet handled.  FileNameMap handling needs to
     30 * be considered.  useCaches, ifModifiedSince, and
     31 * allowUserInteraction need consideration as well as doInput and
     32 * doOutput.
    3133 */
    3234
     
    4042  private BufferedInputStream bufferedIn;
    4143
     44  private static int proxyPort = 80;
     45  private static boolean proxyInUse = false;
     46  private static String proxyHost = null;
     47
     48  static
     49  {
     50    // Recognize some networking properties listed at
     51    // http://java.sun.com/j2se/1.4/docs/guide/net/properties.html.
     52    String port = null;
     53    proxyHost = System.getProperty("http.proxyHost");
     54    if (proxyHost != null)
     55      {
     56        proxyInUse = true;
     57        if ((port = System.getProperty("http.proxyPort")) != null)
     58          {
     59            try
     60              {
     61                proxyPort = Integer.parseInt(port);
     62              }
     63            catch (Throwable t)
     64              {
     65                // Nothing. 
     66              }
     67          }
     68      }
     69  }
     70
    4271  public Connection(URL url)
    4372  {
     
    85114    // Get address and port number.
    86115    int port;
    87     InetAddress destAddr = InetAddress.getByName(url.getHost());
    88     if ((port = url.getPort()) == -1)
    89       port = 80;
    90 
    91     // Open socket and output stream.
    92     sock = new Socket(destAddr, port);
     116    if (proxyInUse)
     117      {
     118        port = proxyPort;
     119        sock = new Socket(proxyHost, port);
     120      }
     121    else
     122      {
     123        InetAddress destAddr = InetAddress.getByName(url.getHost());
     124        if ((port = url.getPort()) == -1)
     125          port = 80;
     126        // Open socket and output stream.
     127        sock = new Socket(destAddr, port);
     128      }
     129
    93130    PrintWriter out = new PrintWriter(sock.getOutputStream());
    94131
     
    123160  }
    124161
    125   // TODO: public boolean usingProxy()
    126162  public boolean usingProxy()
    127163  {
    128     return false;
     164    return proxyInUse;
    129165  }
    130166
     
    166202
    167203    return (String) hdrHash.get(name.toLowerCase());
     204  }
     205
     206  // Override default method in URLConnection.
     207  public Map getHeaderFields()
     208  {
     209    if (!connected)
     210      try
     211        {
     212          connect();
     213        }
     214      catch (IOException x)
     215        {
     216          return null;
     217        }
     218
     219    return hdrHash;
    168220  }
    169221
  • branches/GNU/src/gcc/libjava/gnu/gcj/protocol/jar/Connection.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 1999  Free Software Foundation
     1/* Copyright (C) 1999, 2002  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    1010
    1111import java.net.URL;
     12import java.net.URLConnection;
    1213import java.net.JarURLConnection;
    1314import java.net.URLStreamHandler;
     
    1516import java.net.ProtocolException;
    1617import java.io.IOException;
     18import java.io.InputStream;
     19import java.io.File;
     20import java.io.FileOutputStream;
    1721import java.util.jar.JarFile;
     22import java.util.zip.ZipFile;
    1823import java.util.Hashtable;
    1924
    2025/**
    2126 * Written using on-line Java Platform 1.2 API Specification.
    22  * Status: Needs a way to download jar files and store them in the local file
    23  * system.  I don't know how to do that in a portable way.  For now, it can only handle
    24  * connections to a jar:file: url's.
    2527 *
    2628 * @author Kresten Krab Thorup <krab@gnu.org>
     
    7173    else
    7274      {
    73         /*
    74           FIXME: Here we need to download and cache the jar
    75           file in the local file system!  Stupid design.  Why
    76           can't we just create a JarFile from a bag of bytes?
    77         */
    78 
    79         throw new java.io.IOException("cannot create jar file from " +
    80                                       jarFileURL);
     75        URLConnection urlconn = jarFileURL.openConnection();
     76        InputStream is = urlconn.getInputStream();
     77        byte[] buf = new byte[4*1024];
     78        File f = File.createTempFile("cache", "jar");
     79        FileOutputStream fos = new FileOutputStream(f);
     80        int len = 0;
     81        while((len = is.read(buf)) != -1)
     82          fos.write(buf, 0, len);
     83        fos.close();
     84        // Always verify the Manifest, open read only and delete when done.
     85        // XXX ZipFile.OPEN_DELETE not yet implemented.
     86        // jf = new JarFile(f, true, ZipFile.OPEN_READ | ZipFile.OPEN_DELETE);
     87        jarfile = new JarFile(f, true, ZipFile.OPEN_READ);
    8188      }
    8289
  • branches/GNU/src/gcc/libjava/gnu/gcj/runtime/FirstThread.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    9595  static final Class Khttp = gnu.gcj.protocol.http.Handler.class;
    9696  static final Class Kjar  = gnu.gcj.protocol.jar.Handler.class;
     97  static final Class KinputASCII  = gnu.gcj.convert.Input_ASCII.class;
     98  static final Class KoutputASCII = gnu.gcj.convert.Output_ASCII.class;
    9799}
  • branches/GNU/src/gcc/libjava/gnu/gcj/runtime/SharedLibLoader.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 2001  Free Software Foundation
     1/* Copyright (C) 2001, 2003  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    2828   * @param libname named of shared library (passed to dlopen)
    2929   * @param parent the parent ClassLoader
    30    * @parem flags passed to dlopen
     30   * @param flags passed to dlopen
    3131   */
    3232  public SharedLibLoader(String libname, ClassLoader parent, int flags)
  • branches/GNU/src/gcc/libjava/gnu/gcj/runtime/VMClassLoader.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 1999, 2001  Free Software Foundation
     1/* Copyright (C) 1999, 2001, 2002  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    3434        try
    3535          {
    36             if (e.endsWith(".jar") || e.endsWith (".zip"))
    37               {
    38                 File archive = new File (e);
    39                 try {
    40                   p.addElement(new URL("jar", "", -1, "file://"
    41                                        + archive.getCanonicalPath ()
    42                                        + "!/"));
    43                 } catch (IOException ex) {
    44                   // empty
    45                 }
    46               }
    47             else if (e.endsWith ("/"))
     36            if (!e.endsWith (File.separator) && new File (e).isDirectory ())
     37              p.addElement (new URL("file", "", -1, e + File.separator));
     38            else
    4839              p.addElement (new URL("file", "", -1, e));
    49             else if (new File (e).isDirectory ())
    50               p.addElement (new URL("file", "", -1, e + "/"));
    51             else
    52               /* Ignore path element. */;
    5340          }
    5441        catch (java.net.MalformedURLException x)
  • branches/GNU/src/gcc/libjava/gnu/gcj/runtime/natSharedLibLoader.cc

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11// natSharedLibLoader.cc - Implementation of FirstThread native methods.
    22
    3 /* Copyright (C) 2001  Free Software Foundation
     3/* Copyright (C) 2001, 2003  Free Software Foundation
    44
    55   This file is part of libgcj.
     
    6363  handler = (gnu::gcj::RawData*) h;
    6464#else
    65   const char *msg = "ShareedLibLoader is not supported on this platform";
     65  const char *msg = "SharedLibLoader is not supported on this platform";
    6666  throw new java::lang::UnsupportedOperationException(JvNewStringLatin1(msg));
    6767#endif
  • branches/GNU/src/gcc/libjava/gnu/gcj/xlib/GC.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 2000  Free Software Foundation
     1/* Copyright (C) 2000, 2003  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    8585
    8686  public native void fillRectangle(int x, int y, int w, int h);
     87  public native void fillPolygon(int[] xPoints, int[] yPoints, int nPoints,
     88                                 int translateX, int translateY);
    8789
    8890  /**
  • branches/GNU/src/gcc/libjava/gnu/gcj/xlib/natGC.cc

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* Copyright (C) 2000  Free Software Foundation
     1/* Copyright (C) 2000, 2003  Free Software Foundation
    22
    33   This file is part of libgcj.
     
    1212
    1313#include <gcj/cni.h>
     14#include <gcj/array.h>
    1415#include <gnu/gcj/RawData.h>
    1516#include <java/lang/String.h>
     
    155156}
    156157
     158void gnu::gcj::xlib::GC::fillPolygon(jintArray xPoints, jintArray yPoints,
     159                                     jint nPoints,
     160                                     jint translateX, jint translateY)
     161{
     162  Display* display = target->getDisplay();
     163  ::Display* dpy = (::Display*) (display->display);
     164  ::Drawable drawableXID = target->getXID();
     165  ::GC gc = (::GC) structure;
     166  typedef ::XPoint xpoint;
     167  std::vector<xpoint> points(nPoints+1);
     168  for (int i=0; i<nPoints; i++)
     169    {
     170      points[i].x = elements(xPoints)[i] + translateX;
     171      points[i].y = elements(yPoints)[i] + translateY;
     172    }
     173  points[nPoints] = points[0];
     174  XFillPolygon(dpy, drawableXID, gc, &(points.front()), nPoints,
     175               Complex, CoordModeOrigin);
     176  // no fast fail
     177}
     178
    157179void gnu::gcj::xlib::GC::clearArea(jint x, jint y, jint w, jint h,
    158180                                   jboolean exposures)
  • branches/GNU/src/gcc/libjava/gnu/java/lang/reflect/TypeSignature.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* TypeSignature.java -- Class used to compute type signatures
    2    Copyright (C) 1998 Free Software Foundation, Inc.
     2   Copyright (C) 1998, 2000, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    88the Free Software Foundation; either version 2, or (at your option)
    99any later version.
    10  
     10
    1111GNU Classpath is distributed in the hope that it will be useful, but
    1212WITHOUT ANY WARRANTY; without even the implied warranty of
     
    4545
    4646/**
    47    This class provides static methods that can be used to compute
    48    type-signatures of <code>Class</code>s or <code>Member</code>s.
    49    More specific methods are also provided for computing the
    50    type-signature of <code>Constructor</code>s and
    51    <code>Method</code>s.  Methods are also provided to go in the
    52    reverse direction.
    53 */
     47 * This class provides static methods that can be used to compute
     48 * type-signatures of <code>Class</code>s or <code>Member</code>s.
     49 * More specific methods are also provided for computing the
     50 * type-signature of <code>Constructor</code>s and
     51 * <code>Method</code>s.  Methods are also provided to go in the
     52 * reverse direction.
     53 *
     54 * @author Eric Blake <ebb9@email.byu.edu>
     55 */
    5456public class TypeSignature
    5557{
    56  
    57   /**
    58      Returns a <code>String</code> representing the type-encoding of
    59      CLAZZ.  Type-encodings are computed as follows:
    60 
    61      <pre>
    62      boolean -> "Z"
    63      byte    -> "B"
    64      char    -> "C"
    65      double  -> "D"
    66      float   -> "F"
    67      int     -> "I"
    68      long    -> "J"
    69      short   -> "S"
    70      void    -> "V"
    71      arrays  -> "[" + type-encoding of component type
    72      object  -> "L"
    73                  + fully qualified class name with "."'s replaced by "/"'s
    74                  + ";"</pre>
    75   */
    76   public static String getEncodingOfClass( Class clazz )
    77   {
    78     if( clazz.isPrimitive() )
    79     {
    80       if( clazz == Boolean.TYPE )
    81         return "Z";
    82       if( clazz == Byte.TYPE )
    83         return "B";
    84       if( clazz == Character.TYPE )
    85         return "C";
    86       if( clazz == Double.TYPE )
    87         return "D";
    88       if( clazz == Float.TYPE )
    89         return "F";
    90       if( clazz == Integer.TYPE )
    91         return "I";
    92       if( clazz == Long.TYPE )
    93         return "J";
    94       if( clazz == Short.TYPE )
    95         return "S";
    96       if( clazz == Void.TYPE )
    97         return "V";
    98       else
    99         throw new RuntimeException( "Unknown primitive class " + clazz );
    100     }
    101     else if( clazz.isArray() )
    102     {
    103       return '[' + getEncodingOfClass( clazz.getComponentType() );
    104     }
    105     else
    106     {
    107       String classname = clazz.getName();
    108       int name_len = classname.length();
    109       char[] buf = new char[ name_len + 2 ];
    110       buf[0] = 'L';
    111       classname.getChars( 0, name_len, buf, 1 );
    112      
    113       int i;
    114       for( i=1; i <= name_len; i++ )
     58  /**
     59   * Returns a <code>String</code> representing the type-encoding of a class.
     60   * The .class file format has different encodings for classes, depending
     61   * on whether it must be disambiguated from primitive types or not; hence
     62   * the descriptor parameter to choose between them. If you are planning
     63   * on decoding primitive types along with classes, then descriptor should
     64   * be true for correct results. Type-encodings are computed as follows:
     65   *
     66   * <pre>
     67   * boolean -> "Z"
     68   * byte    -> "B"
     69   * char    -> "C"
     70   * double  -> "D"
     71   * float   -> "F"
     72   * int     -> "I"
     73   * long    -> "J"
     74   * short   -> "S"
     75   * void    -> "V"
     76   * arrays  -> "[" + descriptor format of component type
     77   * object  -> class format: fully qualified name with '.' replaced by '/'
     78   *            descriptor format: "L" + class format + ";"
     79   * </pre>
     80   *
     81   * @param type the class name to encode
     82   * @param descriptor true to return objects in descriptor format
     83   * @return the class name, as it appears in bytecode constant pools
     84   * @see #getClassForEncoding(String)
     85   */
     86  public static String getEncodingOfClass(String type, boolean descriptor)
     87  {
     88    if (! descriptor || type.charAt(0) == '[')
     89      return type.replace('.', '/');
     90    if (type.equals("boolean"))
     91      return "Z";
     92    if (type.equals("byte"))
     93      return "B";
     94    if (type.equals("short"))
     95      return "S";
     96    if (type.equals("char"))
     97      return "C";
     98    if (type.equals("int"))
     99      return "I";
     100    if (type.equals("long"))
     101      return "J";
     102    if (type.equals("float"))
     103      return "F";
     104    if (type.equals("double"))
     105      return "D";
     106    if (type.equals("void"))
     107      return "V";
     108    return 'L' + type.replace('.', '/') + ';';
     109  }
     110
     111  /**
     112   * Gets the descriptor encoding for a class.
     113   *
     114   * @param clazz the class to encode
     115   * @param descriptor true to return objects in descriptor format
     116   * @return the class name, as it appears in bytecode constant pools
     117   * @see #getEncodingOfClass(String, boolean)
     118   */
     119  public static String getEncodingOfClass(Class clazz, boolean descriptor)
     120  {
     121    return getEncodingOfClass(clazz.getName(), descriptor);
     122  }
     123
     124  /**
     125   * Gets the descriptor encoding for a class.
     126   *
     127   * @param clazz the class to encode
     128   * @return the class name, as it appears in bytecode constant pools
     129   * @see #getEncodingOfClass(String, boolean)
     130   */
     131  public static String getEncodingOfClass(Class clazz)
     132  {
     133    return getEncodingOfClass(clazz.getName(), true);
     134  }
     135
     136
     137  /**
     138   * This function is the inverse of <code>getEncodingOfClass</code>. This
     139   * accepts both object and descriptor formats, but must know which style
     140   * of string is being passed in (usually, descriptor should be true). In
     141   * descriptor format, "I" is treated as int.class, in object format, it
     142   * is treated as a class named I in the unnamed package.
     143   *
     144   * @param type_code the class name to decode
     145   * @param descriptor if the string is in descriptor format
     146   * @return the corresponding Class object
     147   * @throws ClassNotFoundException if the class cannot be located
     148   * @see #getEncodingOfClass(Class, boolean)
     149   */
     150  public static Class getClassForEncoding(String type_code, boolean descriptor)
     151    throws ClassNotFoundException
     152  {
     153    if (descriptor)
    115154      {
    116         if( buf[i] == '.' )
    117           buf[i] = '/';
     155        switch (type_code.charAt(0))
     156          {
     157          case 'B':
     158            return byte.class;
     159          case 'C':
     160            return char.class;
     161          case 'D':
     162            return double.class;
     163          case 'F':
     164            return float.class;
     165          case 'I':
     166            return int.class;
     167          case 'J':
     168            return long.class;
     169          case 'S':
     170            return short.class;
     171          case 'V':
     172            return void.class;
     173          case 'Z':
     174            return boolean.class;
     175          default:
     176            throw new ClassNotFoundException("Invalid class name: "
     177                                             + type_code);
     178          case 'L':
     179            type_code = type_code.substring(1, type_code.length() - 1);
     180            // Fallthrough.
     181          case '[':
     182          }
    118183      }
    119      
    120       buf[i] = ';';
    121       return new String( buf );
    122     }
    123   }
    124 
    125  
    126   /**
    127      This function is the inverse of <code>getEncodingOfClass</code>.
    128 
    129      @see getEncodingOfClass
    130 
    131      @exception ClassNotFoundException If class encoded as type_code
    132      cannot be located.
    133   */
    134   public static Class getClassForEncoding( String type_code )
     184    return Class.forName(type_code.replace('/', '.'));
     185  }
     186
     187  /**
     188   * Gets the Class object for a type name.
     189   *
     190   * @param type_code the class name to decode
     191   * @return the corresponding Class object
     192   * @throws ClassNotFoundException if the class cannot be located
     193   * @see #getClassForEncoding(String, boolean)
     194   */
     195  public static Class getClassForEncoding(String type_code)
    135196    throws ClassNotFoundException
    136197  {
    137     if( type_code.equals( "B" ) )
    138       return Byte.TYPE;
    139     if( type_code.equals( "C" ) )
    140       return Character.TYPE;
    141     if( type_code.equals( "D" ) )
    142       return Double.TYPE;
    143     if( type_code.equals( "F" ) )
    144       return Float.TYPE;
    145     if( type_code.equals( "I" ) )
    146       return Integer.TYPE;
    147     if( type_code.equals( "J" ) )
    148       return Long.TYPE;
    149     if( type_code.equals( "S" ) )
    150       return Short.TYPE;
    151     if( type_code.equals( "Z" ) )
    152       return Boolean.TYPE;
    153     if( type_code.charAt( 0 ) == 'L' )
    154     {
    155       return Class.forName(
    156         type_code.substring( 1, type_code.length() - 1 ).replace( '/', '.' ));
    157     }
    158     if( type_code.charAt( 0 ) == '[' )
    159     {
    160       int last_bracket = type_code.lastIndexOf( '[' );
    161       String brackets = type_code.substring( 0, last_bracket + 1 );
    162       String component = type_code.substring( last_bracket + 1 );
    163      
    164 // ??? This is what the Classpath implementation did, but I don't
    165 // think that it's correct.  The JLS says that Class.forName takes the
    166 // classname of an array element in fully qualified form, whereas this
    167 // code is tring to strip off the punctuation.
    168 
    169 //        if( component.charAt( 0 ) == 'L' )
    170 //      component =
    171 //        component.substring( 1, component.length() - 1 ).replace('/', '.');
    172 
    173       if( component.charAt( 0 ) == 'L' )
    174         component = component.replace('/', '.');
    175        
    176       return Class.forName( brackets + component );
    177     }
    178     else
    179       throw new ClassNotFoundException( "Type code cannot be parsed as a valid class name" );
    180   }
    181  
    182 
    183   /**
    184      Returns a <code>String</code> representing the type-encoding of
    185      M.  The type-encoding of a method is:
    186 
    187      "(" + type-encodings of parameter types + ")"
    188      + type-encoding of return type
    189   */
    190   public static String getEncodingOfMethod( Method m )
    191   {
    192     String returnEncoding = getEncodingOfClass( m.getReturnType() );
     198    return getClassForEncoding(type_code, true);
     199  }
     200
     201  /**
     202   * Returns a <code>String</code> representing the type-encoding of a
     203   * method.  The type-encoding of a method is:
     204   *
     205   * "(" + parameter type descriptors + ")" + return type descriptor
     206   *
     207   * XXX This could be faster if it were implemented natively.
     208   *
     209   * @param m the method to encode
     210   * @return the encoding
     211   */
     212  public static String getEncodingOfMethod(Method m)
     213  {
    193214    Class[] paramTypes = m.getParameterTypes();
    194     String[] paramEncodings = new String[ paramTypes.length ];
    195 
    196     String paramEncoding;
    197     int size = 2; // make room for parens
    198     for( int i=0; i < paramTypes.length; i++ )
    199     {
    200       paramEncoding = getEncodingOfClass( paramTypes[i] );
    201       size += paramEncoding.length();
    202       paramEncodings[i] = paramEncoding;
    203     }
    204    
    205     size += returnEncoding.length();
    206 
    207     StringBuffer buf = new StringBuffer( size );
    208     buf.append( '(' );
    209    
    210     for( int i=0; i < paramTypes.length; i++ )
    211     {
    212       buf.append( paramEncodings[i] );
    213     }
    214    
    215     buf.append( ')' );
    216     buf.append( returnEncoding );
    217    
     215    StringBuffer buf = new StringBuffer().append('(');
     216    for (int i = 0; i < paramTypes.length; i++)
     217      buf.append(getEncodingOfClass(paramTypes[i].getName(), true));
     218    buf.append(')').append(getEncodingOfClass(m.getReturnType().getName(),
     219                                              true));
    218220    return buf.toString();
    219221  }
    220222
    221 
    222   /**
    223      Returns a <code>String</code> representing the type-encoding of
    224      C.  The type-encoding of a method is:
    225 
    226      "(" + type-encodings of parameter types + ")V"
    227   */
    228   public static String getEncodingOfConstructor( Constructor c )
     223  /**
     224   * Returns a <code>String</code> representing the type-encoding of a
     225   * constructor. The type-encoding of a method is:
     226   *
     227   * "(" + parameter type descriptors + ")V"
     228   *
     229   * XXX This could be faster if it were implemented natively.
     230   *
     231   * @param c the constructor to encode
     232   * @return the encoding
     233   */
     234  public static String getEncodingOfConstructor(Constructor c)
    229235  {
    230236    Class[] paramTypes = c.getParameterTypes();
    231     String[] paramEncodings = new String[ paramTypes.length ];
    232 
    233     String paramEncoding;
    234     int size = 3; // make room for parens and V for return type
    235     for( int i=0; i < paramTypes.length; i++ )
    236     {
    237       paramEncoding = getEncodingOfClass( paramTypes[i] );
    238       size += paramEncoding.length();
    239       paramEncodings[i] = paramEncoding;
    240     }
    241    
    242     StringBuffer buf = new StringBuffer( size );
    243     buf.append( '(' );
    244    
    245     for( int i=0; i < paramTypes.length; i++ )
    246     {
    247       buf.append( paramEncodings[i] );
    248     }
    249    
    250     buf.append( ")V" );
    251    
     237    StringBuffer buf = new StringBuffer().append('(');
     238    for (int i = 0; i < paramTypes.length; i++)
     239      buf.append(getEncodingOfClass(paramTypes[i].getName(), true));
     240    buf.append(")V");
    252241    return buf.toString();
    253242  }
    254243
    255 
    256   /**
    257      Returns a <code>String</code> representing the type-encoding of
    258      MEM.  <code>Constructor</code>s are handled by
    259      <code>getEncodingOfConstructor</code>.  <code>Method</code>s are
    260      handled by <code>getEncodingOfMethod</code>.  <code>Field</code>s
    261      are handled by returning the encoding of the type of the
    262      <code>Field</code>.
    263   */
    264   public static String getEncodingOfMember( Member mem )
    265   {
    266     if( mem instanceof Constructor )
    267       return getEncodingOfConstructor( (Constructor)mem );
    268     if( mem instanceof Method )
    269       return getEncodingOfMethod( (Method)mem );
     244  /**
     245   * Returns a <code>String</code> representing the type-encoding of a
     246   * class member. This appropriately handles Constructors, Methods, and
     247   * Fields.
     248   *
     249   * @param mem the member to encode
     250   * @return the encoding
     251   */
     252  public static String getEncodingOfMember(Member mem)
     253  {
     254    if (mem instanceof Constructor)
     255      return getEncodingOfConstructor((Constructor) mem);
     256    if (mem instanceof Method)
     257      return getEncodingOfMethod((Method) mem);
    270258    else // Field
    271       return getEncodingOfClass( ((Field)mem).getType() );
    272   }
    273 }
     259      return getEncodingOfClass(((Field) mem).getType().getName(), true);
     260  }
     261} // class TypeSignature
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/dgc/DGCImpl.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/*
    2   Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
     2  Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    4747import gnu.java.rmi.server.UnicastServerRef;
    4848
     49import java.util.Hashtable;
     50
     51/**
     52  * I let DGCImpl to extend UnicastServerRef, but not
     53  * UnicastRemoteObject, because UnicastRemoteObject must
     54  * exportObject automatically.
     55  */
    4956public class DGCImpl
    50         extends UnicastRemoteObject implements DGC {
     57    extends UnicastServerRef implements DGC {
     58
     59    private static final long LEASE_VALUE = 600000L;
     60    // leaseCache caches a LeaseRecord associated with a vmid
     61    private Hashtable leaseCache = new Hashtable();
    5162
    5263public DGCImpl() throws RemoteException {
    53         super(new UnicastServerRef(new ObjID(ObjID.DGC_ID), 0, RMISocketFactory.getSocketFactory()));
     64        super(new ObjID(ObjID.DGC_ID), 0, RMISocketFactory.getSocketFactory());
    5465}
    5566
    5667public Lease dirty(ObjID[] ids, long sequenceNum, Lease lease) throws RemoteException {
    57         System.out.println("DGCImpl.dirty - not implemented");
     68        VMID vmid = lease.getVMID();
     69        if (vmid == null)
     70            vmid = new VMID();
     71        long leaseValue = LEASE_VALUE;
     72        //long leaseValue = lease.getValue();
     73    lease = new Lease(vmid, leaseValue);
     74        synchronized(leaseCache){
     75            LeaseRecord lr = (LeaseRecord)leaseCache.get(vmid);
     76            if (lr != null)
     77                lr.reset(leaseValue);
     78            else{
     79                lr = new LeaseRecord(vmid, leaseValue);
     80                leaseCache.put(vmid, lr);
     81            }
     82        }
     83       
    5884        return (lease);
    5985}
    6086
    6187public void clean(ObjID[] ids, long sequenceNum, VMID vmid, boolean strong) throws RemoteException {
    62         System.out.println("DGCImpl.clean - not implemented");
     88  // Not implemented
    6389}
     90   
     91  /**
     92   * LeaseRecord associates a vmid to expireTime.
     93   */
     94  private static class LeaseRecord{
     95    private VMID vmid;
     96    private long expireTime;
     97   
     98    LeaseRecord(VMID vmid, long leaseValue){
     99      this.vmid = vmid;
     100      reset(leaseValue);
     101    }
     102   
     103    // reset expireTime
     104    void reset(long leaseValue){
     105      long l = System.currentTimeMillis();
     106      expireTime = l + leaseValue;
     107    }
    64108
    65 }
     109    boolean isExpired(){
     110      long l = System.currentTimeMillis();
     111      if ( l > expireTime)
     112        return true;
     113      return false;
     114    }
     115       
     116  } //End of LeaseRecord
     117
     118} //End of DGCImpl
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/dgc/DGCImpl_Skel.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
     1/* DGCImpl_Skel.java
     2   Copyright (C) 2002 Free Software Foundation, Inc.
     3
     4This file is part of GNU Classpath.
     5
     6GNU Classpath is free software; you can redistribute it and/or modify
     7it under the terms of the GNU General Public License as published by
     8the Free Software Foundation; either version 2, or (at your option)
     9any later version.
     10
     11GNU Classpath is distributed in the hope that it will be useful, but
     12WITHOUT ANY WARRANTY; without even the implied warranty of
     13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14General Public License for more details.
     15
     16You should have received a copy of the GNU General Public License
     17along with GNU Classpath; see the file COPYING.  If not, write to the
     18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     1902111-1307 USA.
     20
     21Linking this library statically or dynamically with other modules is
     22making a combined work based on this library.  Thus, the terms and
     23conditions of the GNU General Public License cover the whole
     24combination.
     25
     26As a special exception, the copyright holders of this library give you
     27permission to link this library with independent modules to produce an
     28executable, regardless of the license terms of these independent
     29modules, and to copy and distribute the resulting executable under
     30terms of your choice, provided that you also meet, for each linked
     31independent module, the terms and conditions of the license of that
     32module.  An independent module is a module which is not derived from
     33or based on this library.  If you modify this library, you may extend
     34this exception to your version of the library, but you are not
     35obligated to do so.  If you do not wish to do so, delete this
     36exception statement from your version. */
     37
     38
    139// Skel class generated by rmic - DO NOT EDIT!
    240
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/dgc/DGCImpl_Stub.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
     1/* DGCImpl_Stub.java
     2   Copyright (C) 2002 Free Software Foundation, Inc.
     3
     4This file is part of GNU Classpath.
     5
     6GNU Classpath is free software; you can redistribute it and/or modify
     7it under the terms of the GNU General Public License as published by
     8the Free Software Foundation; either version 2, or (at your option)
     9any later version.
     10
     11GNU Classpath is distributed in the hope that it will be useful, but
     12WITHOUT ANY WARRANTY; without even the implied warranty of
     13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14General Public License for more details.
     15
     16You should have received a copy of the GNU General Public License
     17along with GNU Classpath; see the file COPYING.  If not, write to the
     18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     1902111-1307 USA.
     20
     21Linking this library statically or dynamically with other modules is
     22making a combined work based on this library.  Thus, the terms and
     23conditions of the GNU General Public License cover the whole
     24combination.
     25
     26As a special exception, the copyright holders of this library give you
     27permission to link this library with independent modules to produce an
     28executable, regardless of the license terms of these independent
     29modules, and to copy and distribute the resulting executable under
     30terms of your choice, provided that you also meet, for each linked
     31independent module, the terms and conditions of the license of that
     32module.  An independent module is a module which is not derived from
     33or based on this library.  If you modify this library, you may extend
     34this exception to your version of the library, but you are not
     35obligated to do so.  If you do not wish to do so, delete this
     36exception statement from your version. */
     37
     38
    139// Stub class generated by rmic - DO NOT EDIT!
    240
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/registry/RegistryImpl.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    6565public RegistryImpl(int port, RMIClientSocketFactory cf, RMIServerSocketFactory sf) throws RemoteException {
    6666        super(new UnicastServerRef(new ObjID(ObjID.REGISTRY_ID), port, sf));
    67         ((UnicastServerRef)getRef()).exportObject(this);
     67        // The following is unnecessary, because UnicastRemoteObject export itself automatically.
     68        //((UnicastServerRef)getRef()).exportObject(this);
    6869}
    6970
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/registry/RegistryImpl_Skel.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
     1/* RegistryImpl_Skel.java
     2   Copyright (C) 2002 Free Software Foundation, Inc.
     3
     4This file is part of GNU Classpath.
     5
     6GNU Classpath is free software; you can redistribute it and/or modify
     7it under the terms of the GNU General Public License as published by
     8the Free Software Foundation; either version 2, or (at your option)
     9any later version.
     10
     11GNU Classpath is distributed in the hope that it will be useful, but
     12WITHOUT ANY WARRANTY; without even the implied warranty of
     13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14General Public License for more details.
     15
     16You should have received a copy of the GNU General Public License
     17along with GNU Classpath; see the file COPYING.  If not, write to the
     18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     1902111-1307 USA.
     20
     21Linking this library statically or dynamically with other modules is
     22making a combined work based on this library.  Thus, the terms and
     23conditions of the GNU General Public License cover the whole
     24combination.
     25
     26As a special exception, the copyright holders of this library give you
     27permission to link this library with independent modules to produce an
     28executable, regardless of the license terms of these independent
     29modules, and to copy and distribute the resulting executable under
     30terms of your choice, provided that you also meet, for each linked
     31independent module, the terms and conditions of the license of that
     32module.  An independent module is a module which is not derived from
     33or based on this library.  If you modify this library, you may extend
     34this exception to your version of the library, but you are not
     35obligated to do so.  If you do not wish to do so, delete this
     36exception statement from your version. */
     37
     38
    139// Skel class generated by rmic - DO NOT EDIT!
    240
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/registry/RegistryImpl_Stub.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
     1/* RegistryImpl_Stub.java
     2   Copyright (C) 2002 Free Software Foundation, Inc.
     3
     4This file is part of GNU Classpath.
     5
     6GNU Classpath is free software; you can redistribute it and/or modify
     7it under the terms of the GNU General Public License as published by
     8the Free Software Foundation; either version 2, or (at your option)
     9any later version.
     10
     11GNU Classpath is distributed in the hope that it will be useful, but
     12WITHOUT ANY WARRANTY; without even the implied warranty of
     13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14General Public License for more details.
     15
     16You should have received a copy of the GNU General Public License
     17along with GNU Classpath; see the file COPYING.  If not, write to the
     18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     1902111-1307 USA.
     20
     21Linking this library statically or dynamically with other modules is
     22making a combined work based on this library.  Thus, the terms and
     23conditions of the GNU General Public License cover the whole
     24combination.
     25
     26As a special exception, the copyright holders of this library give you
     27permission to link this library with independent modules to produce an
     28executable, regardless of the license terms of these independent
     29modules, and to copy and distribute the resulting executable under
     30terms of your choice, provided that you also meet, for each linked
     31independent module, the terms and conditions of the license of that
     32module.  An independent module is a module which is not derived from
     33or based on this library.  If you modify this library, you may extend
     34this exception to your version of the library, but you are not
     35obligated to do so.  If you do not wish to do so, delete this
     36exception statement from your version. */
     37
     38
    139// Stub class generated by rmic - DO NOT EDIT!
    240
     
    3068        try {
    3169            java.rmi.server.RemoteRef.class.getMethod("invoke", new java.lang.Class[] { java.rmi.Remote.class, java.lang.reflect.Method.class, java.lang.Object[].class, long.class });
    32             useNewInvoke = true;
     70            useNewInvoke = false;
    3371            $method_bind_0 = gnu.java.rmi.registry.RegistryImpl.class.getMethod("bind", new java.lang.Class[] {java.lang.String.class, java.rmi.Remote.class});
    3472            $method_list_1 = gnu.java.rmi.registry.RegistryImpl.class.getMethod("list", new java.lang.Class[] {});
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/server/RMIHashes.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    4040import java.lang.reflect.Method;
    4141import java.lang.Class;
    42 import gnu.java.security.provider.SHA;
     42import gnu.java.io.NullOutputStream;
     43import gnu.java.lang.reflect.TypeSignature;
     44import java.security.MessageDigest;
     45import java.security.DigestOutputStream;
     46import java.io.DataOutputStream;
     47import java.io.ByteArrayOutputStream;
    4348
    4449public class RMIHashes
    4550{
     51  //There're other places using DigestOutputStream to generate hash in classpath, but I think the way I used
     52  //here is more efficient, anyway, you can switch to DigestOutputStream by doing like "//or:" comments say.
     53 
     54  //or:add this statement: private static final NullOutputStream nullOutputStream = new NullOutputStream ();
    4655  public static long getMethodHash(Method meth)
    4756  {
    48     return meth.hashCode ();
     57    //Object Serialization Spec 8.3
     58    try
     59    {
     60        MessageDigest md = MessageDigest.getInstance ("SHA");
     61        //or:remove this statement: DigestOutputStream digest_out = new DigestOutputStream (nullOutputStream, md);
     62        ByteArrayOutputStream digest_out = new ByteArrayOutputStream();
     63        DataOutputStream data_out = new DataOutputStream (digest_out);
     64       
     65        StringBuffer sbuf = new StringBuffer();
     66        sbuf.append(meth.getName());
     67        sbuf.append('(');
     68        Class params[] = meth.getParameterTypes();
     69        for(int i = 0; i < params.length; i++)
     70            sbuf.append(TypeSignature.getEncodingOfClass(params[i]));
     71        sbuf.append(')');
     72        Class rcls = meth.getReturnType();
     73        if(rcls != Void.TYPE)
     74            sbuf.append(TypeSignature.getEncodingOfClass(rcls));
     75        else
     76            sbuf.append('V');
     77       
     78        data_out.writeUTF (sbuf.toString());
     79        data_out.flush();
     80        data_out.close ();
     81
     82        md.update(digest_out.toByteArray()); //or:remove this statement
     83        byte[] sha = md.digest ();
     84        long result = 0;
     85        int len = sha.length < 8 ? sha.length : 8;
     86        for (int i=0; i < len; i++)
     87            result += (long)(sha[i] & 0xFF) << (8 * i);
     88        return result;
     89    }catch(Exception _){
     90        return -1L;
     91        }
    4992  }
    5093
     
    5497  }
    5598}
     99
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/server/RMIObjectInputStream.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/*
    2   Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
     2  Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    4545import java.net.MalformedURLException;
    4646import java.rmi.server.RMIClassLoader;
     47import java.lang.ClassNotFoundException;
     48import java.lang.reflect.Proxy;
    4749
    4850public class RMIObjectInputStream
    4951        extends ObjectInputStream {
    5052
    51 UnicastConnectionManager manager;
    52 
    53 public RMIObjectInputStream(InputStream strm, UnicastConnectionManager man) throws IOException {
     53public RMIObjectInputStream(InputStream strm) throws IOException {
    5454        super(strm);
    55         manager = man;
    5655        enableResolveObject(true);
    5756}
    5857
    5958protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
    60 //System.out.println("Resolving class: " + desc.getName());
    61         String annotation = (String)readObject();
    62         if (annotation == null) {
    63                 return (super.resolveClass(desc));
     59        String annotation = (String)getAnnotation();
     60       
     61        try {
     62                if(annotation == null)
     63                    return (RMIClassLoader.loadClass(desc.getName()));
     64                else
     65                    return (RMIClassLoader.loadClass(annotation, desc.getName()));
    6466        }
    65         else {
    66                 try {
    67                         return (RMIClassLoader.loadClass(new URL(annotation), desc.getName()));
    68                 }
    69                 catch (MalformedURLException _) {
    70                         throw new ClassNotFoundException(desc.getName());
    71                 }
     67        catch (MalformedURLException _) {
     68                throw new ClassNotFoundException(desc.getName());
    7269        }
    7370}
    7471
     72//Separate it for override by MarshalledObject
     73protected Object getAnnotation()
     74            throws IOException, ClassNotFoundException
     75{
     76    return readObject();
    7577}
     78       
     79protected Class resolveProxyClass(String intfs[])
     80        throws IOException, ClassNotFoundException
     81{
     82    String annotation = (String)getAnnotation();
     83       
     84    Class clss[] = new Class[intfs.length];
     85    if(annotation == null)
     86        clss[0] = RMIClassLoader.loadClass(intfs[0]);
     87    else
     88        clss[0] = RMIClassLoader.loadClass(annotation, intfs[0]);
     89   
     90    //assume all interfaces can be loaded by the same classloader
     91    ClassLoader loader = clss[0].getClassLoader();
     92    for (int i = 0; i < intfs.length; i++)
     93        clss[i] = Class.forName(intfs[i], false, loader);
     94       
     95    try {
     96    return Proxy.getProxyClass(loader, clss);
     97        } catch (IllegalArgumentException e) {
     98            throw new ClassNotFoundException(null, e);
     99        } 
     100}
     101
     102protected Object readValue(Class valueClass) throws IOException, ClassNotFoundException {
     103    if(valueClass.isPrimitive()){
     104        if(valueClass == Boolean.TYPE)
     105            return new Boolean(readBoolean());
     106        if(valueClass == Byte.TYPE)
     107            return new Byte(readByte());
     108        if(valueClass == Character.TYPE)
     109            return new Character(readChar());
     110        if(valueClass == Short.TYPE)
     111            return new Short(readShort());
     112        if(valueClass == Integer.TYPE)
     113            return new Integer(readInt());
     114        if(valueClass == Long.TYPE)
     115            return new Long(readLong());
     116        if(valueClass == Float.TYPE)
     117            return new Float(readFloat());
     118        if(valueClass == Double.TYPE)
     119            return new Double(readDouble());
     120        else
     121            throw new Error("Unsupported primitive class: " + valueClass);
     122    } else
     123        return readObject();
     124}
     125
     126}
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/server/RMIObjectOutputStream.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/*
    2   Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
     2  Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    4242import java.io.IOException;
    4343import java.rmi.server.RMIClassLoader;
     44import java.rmi.Remote;
     45import java.rmi.server.RemoteStub;
     46import java.rmi.server.ObjID;
    4447
    4548public class RMIObjectOutputStream
     
    4851public RMIObjectOutputStream(OutputStream strm) throws IOException {
    4952        super(strm);
     53        enableReplaceObject(true);
     54}
     55
     56//Separate it for override by MarshalledObject
     57protected void setAnnotation(String annotation) throws IOException{
     58    writeObject(annotation);
    5059}
    5160
    5261protected void annotateClass(Class cls) throws IOException {
    53 //System.out.println("Annotating class: " + cls);
    54         writeObject(RMIClassLoader.getClassAnnotation(cls));
     62        setAnnotation(RMIClassLoader.getClassAnnotation(cls));
     63}
     64
     65protected void annotateProxyClass(Class cls)
     66        throws IOException
     67{
     68    annotateClass(cls);
     69}
     70   
     71protected Object replaceObject(Object obj)
     72        throws IOException
     73{
     74    if((obj instanceof Remote) && !(obj instanceof RemoteStub)){
     75            UnicastServerRef ref = UnicastServer.getExportedRef((Remote)obj);
     76            if (ref != null)
     77                    return ref.getStub();
     78    }
     79    return obj;
     80}
     81
     82protected void writeValue(Object value, Class valueClass) throws IOException{
     83    if(valueClass.isPrimitive()){
     84        if(valueClass == Boolean.TYPE)
     85            writeBoolean(((Boolean)value).booleanValue());
     86        else
     87        if(valueClass == Byte.TYPE)
     88            writeByte(((Byte)value).byteValue());
     89        else
     90        if(valueClass == Character.TYPE)
     91            writeChar(((Character)value).charValue());
     92        else
     93        if(valueClass == Short.TYPE)
     94            writeShort(((Short)value).shortValue());
     95        else
     96        if(valueClass == Integer.TYPE)
     97            writeInt(((Integer)value).intValue());
     98        else
     99        if(valueClass == Long.TYPE)
     100            writeLong(((Long)value).longValue());
     101        else
     102        if(valueClass == Float.TYPE)
     103            writeFloat(((Float)value).floatValue());
     104        else
     105        if(valueClass == Double.TYPE)
     106            writeDouble(((Double)value).doubleValue());
     107        else
     108            throw new Error("Unsupported primitive class: " + valueClass);
     109    } else
     110        writeObject(value);
    55111}
    56112
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/server/UnicastConnection.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/*
    2   Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
     2  Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    4545import java.io.ObjectInputStream;
    4646import java.io.ObjectOutputStream;
     47import java.io.BufferedInputStream;
     48import java.io.BufferedOutputStream;
    4749import java.io.ObjectOutput;
    4850import java.io.ObjectInput;
     
    6062ObjectOutputStream oout;
    6163
     64// reviveTime and expireTime make UnicastConnection pool-able
     65long reviveTime = 0;
     66long expireTime = Long.MAX_VALUE;
     67
    6268UnicastConnection(UnicastConnectionManager man, Socket sock) {
    6369        this.manager = man;
     
    6672
    6773void acceptConnection() throws IOException {
    68 //System.out.println("Accepting connection on " + lport);
    69         din = new DataInputStream(sock.getInputStream());
    70         dout = new DataOutputStream(sock.getOutputStream());
     74//System.out.println("Accepting connection on " + sock);
     75    //Use BufferedXXXStream would be more efficient
     76        din = new DataInputStream(new BufferedInputStream(sock.getInputStream()));
     77        dout = new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));
    7178
    7279        int sig = din.readInt();
     
    8693                dout.writeUTF(manager.serverName);
    8794                dout.writeInt(manager.serverPort);
     95                dout.flush();
    8896
    8997                // Read their hostname and port
     
    95103
    96104void makeConnection(int protocol) throws IOException {
    97         dout = new DataOutputStream(sock.getOutputStream());
    98         din = new DataInputStream(sock.getInputStream());
     105    //Use BufferedXXXStream would be more efficient
     106        din = new DataInputStream(new BufferedInputStream(sock.getInputStream()));
     107        dout = new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));
    99108
    100109        // Send header
     
    102111        dout.writeShort(PROTOCOL_VERSION);
    103112        dout.writeByte(protocol);
    104         dout.flush();
    105 
     113    dout.flush();
     114   
    106115        if (protocol != SINGLE_OP_PROTOCOL) {
    107116                // Get back ack.
     
    118127                dout.writeUTF(manager.serverName);
    119128                dout.writeInt(manager.serverPort);
     129                dout.flush();
    120130        }
    121131        // Okay, ready to roll ...
     
    132142ObjectInputStream getObjectInputStream() throws IOException {
    133143        if (oin == null) {
    134                 oin = new RMIObjectInputStream(din, manager);
     144        oin = new RMIObjectInputStream(din);
    135145        }
    136146        return (oin);
     
    145155
    146156void disconnect() {
     157        try {
     158            if(oout != null)
     159                oout.close();
     160        sock.close();
     161        }
     162        catch (IOException _) {
     163    }
     164
    147165        oin = null;
    148         oout = null;
    149         try {
    150                 sock.close();
    151         }
    152         catch (IOException _) {
    153         }
     166    oout = null;
    154167        din = null;
    155168        dout = null;
    156169        sock = null;
     170}
     171
     172public static final long CONNECTION_TIMEOUT = 10000L;
     173
     174static boolean isExpired(UnicastConnection conn, long l){
     175    if (l <= conn.expireTime )
     176        return false;
     177    return true;
     178}
     179
     180static void resetTime(UnicastConnection conn){
     181    long l = System.currentTimeMillis();
     182    conn.reviveTime = l;
     183    conn.expireTime = l + CONNECTION_TIMEOUT;
    157184}
    158185
     
    161188 */
    162189public void run() {
     190    do{
    163191        try {
    164192                UnicastServer.dispatch(this);
     193            //don't discardConnection explicitly, only when
     194            //  exception happens or the connection's expireTime
     195            //  comes
     196        } catch (Exception e ){
    165197                manager.discardConnection(this);
    166         }
    167         catch (Exception e) {
    168                 e.printStackTrace();
    169         }
    170 }
    171 
    172 }
     198            break;
     199        }
     200    }while(true);
     201}
     202
     203}
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/server/UnicastConnectionManager.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/*
    2   Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
     2  Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    4242import java.rmi.server.RMIClientSocketFactory;
    4343import java.rmi.RemoteException;
    44 import gnu.java.rmi.server.UnicastConnection;
    45 import java.util.Hashtable;
    46 import java.net.Socket;
    47 import java.net.ServerSocket;
    4844import java.io.IOException;
    4945import java.io.ObjectOutput;
    5046import java.io.ObjectInput;
     47import java.io.DataInputStream;
    5148import java.lang.Thread;
    5249import java.lang.Runnable;
    5350import java.net.InetAddress;
     51import java.net.Socket;
     52import java.net.ServerSocket;
    5453import java.net.UnknownHostException;
     54
     55import java.util.ArrayList;
     56import java.util.ConcurrentModificationException;
     57import java.util.Enumeration;
     58import java.util.Hashtable;
     59import java.util.Iterator;
     60
     61import gnu.java.rmi.server.UnicastConnection;
    5562
    5663public class UnicastConnectionManager
     
    5865
    5966private static String localhost;
     67// use different maps for server/client type UnicastConnectionManager
    6068private static Hashtable servers = new Hashtable();
    61 
    62 private Thread serverThread;
     69private static Hashtable clients = new Hashtable();
     70private ArrayList connections; //client connection pool
     71
     72// make serverThread volatile for poll
     73private volatile Thread serverThread;
    6374private ServerSocket ssock;
    6475String serverName;
    6576int serverPort;
     77
     78static private Thread scavenger;
     79
     80// If client and server are in the same VM, serverobj represents server
     81Object serverobj;
     82
     83private static RMISocketFactory defaultSocketFactory = RMISocketFactory.getSocketFactory();
    6684private RMIServerSocketFactory serverFactory;
    6785private RMIClientSocketFactory clientFactory;
    6886
     87// The following is for debug
     88private static int ncsock = 0;    //count of client socket
     89private static int nssock = 0;    //count of server socket
     90private static int ncmanager = 0; //count of client manager
     91private static int nsmanager = 0; //count of server manager
     92
     93private static final boolean debug = false;
     94
     95private static final Object GLOBAL_LOCK = new Object();
     96
    6997static {
    7098        try {
    71                 localhost = InetAddress.getLocalHost().getHostName();
     99                //Use host address instead of host name to avoid name resolving issues
     100                //localhost = InetAddress.getLocalHost().getHostName();
     101                localhost = InetAddress.getLocalHost().getHostAddress();
    72102        }
    73103        catch (UnknownHostException _) {
    74104                localhost = "localhost";
    75105        }
    76 }
    77 
     106       
     107       
     108}
     109
     110//Only one scavenger thread running globally
     111private static void startScavenger(){
     112    scavenger = new Thread(new Runnable(){
     113        public void run(){
     114            if (debug) System.out.println("************* start scavenger.");
     115            boolean liveon = true;
     116            while (liveon){
     117                // Sleep for the expire timeout
     118                try{
     119                    Thread.sleep(UnicastConnection.CONNECTION_TIMEOUT);
     120                }catch(InterruptedException _ie){
     121                    break;
     122                }
     123                liveon = false;
     124                // Scavenge all clients' connections that're expired
     125                Iterator iter = clients.values().iterator();
     126                long l = System.currentTimeMillis();
     127                try{
     128                    while(iter.hasNext()){
     129                        UnicastConnectionManager man = (UnicastConnectionManager)iter.next();
     130                        ArrayList conns = man.connections;
     131                        synchronized(conns) { // is the lock a little coarser?
     132                            for (int last = conns.size() - 1;
     133                                 last >= 0;
     134                                 --last)
     135                            {
     136                                UnicastConnection conn = (UnicastConnection)conns.get(last);
     137                                if (UnicastConnection.isExpired(conn, l)){
     138                                    conns.remove(last);
     139                                    conn.disconnect();
     140                                    conn = null;   
     141                                }else
     142                                    liveon = true; //there're still live connections
     143                            }
     144                        }
     145                    }
     146                }catch(ConcurrentModificationException cme) {
     147                    // handle it lazily
     148                    liveon = true;
     149                }
     150            }
     151            scavenger = null;
     152            if (debug) System.out.println("************* exit scavenger.");
     153        }
     154    });
     155    scavenger.start();
     156}
     157
     158/**
     159  * Client UnicastConnectionManager constructor
     160  */
    78161private UnicastConnectionManager(String host, int port, RMIClientSocketFactory csf) {
    79162        ssock = null;
     
    82165        serverFactory = null;
    83166        clientFactory = csf;
    84 }
    85 
     167    connections = new ArrayList();
     168}
     169
     170/**
     171  * Server UnicastConnectionManager constructor
     172  */
    86173private UnicastConnectionManager(int port, RMIServerSocketFactory ssf) {
    87174        try {
     
    111198//System.out.println("getInstance: " + host + "," + port + "," + csf);
    112199        if (csf == null) {
    113                 csf = RMISocketFactory.getSocketFactory();
    114         }
     200        csf = defaultSocketFactory;
     201        }
     202        // change host name to host address to avoid name resolving issues
     203        try{
     204        host = InetAddress.getByName(host).getHostAddress();
     205    }catch(Exception _){}
     206   
    115207        TripleKey key = new TripleKey(host, port, csf);
    116         UnicastConnectionManager man = (UnicastConnectionManager)servers.get(key);
     208        UnicastConnectionManager man = (UnicastConnectionManager)clients.get(key);
    117209        if (man == null) {
    118210                man = new UnicastConnectionManager(host, port, csf);
    119                 servers.put(key, man);
     211        if (debug) {
     212            ncmanager++;
     213            System.out.println("\n\n ====== " + ncmanager + " client managers.\n\n");
     214        }
     215                clients.put(key, man);
     216       
     217        // Detect if client and server are in the same VM, i.e., their keys are equal
     218        UnicastConnectionManager svrman = (UnicastConnectionManager)servers.get(key);
     219        if(svrman != null){ // server and client are in the same VM
     220            man.serverobj = svrman.serverobj;
     221        }
    120222        }
    121223        return (man);
     
    129231//System.out.println("getInstance: " + port + "," + ssf);
    130232        if (ssf == null) {
    131                 ssf = RMISocketFactory.getSocketFactory();
     233        ssf = defaultSocketFactory;
    132234        }
    133235        TripleKey key = new TripleKey(localhost, port, ssf);
     
    135237        if (man == null) {
    136238                man = new UnicastConnectionManager(port, ssf);
     239        if (debug) {
     240            nsmanager++;
     241            System.out.println("\n\n ****** " + nsmanager + " server managers.\n\n");
     242        }
    137243                // The provided port might not be the set port.
    138244                key.port = man.serverPort;
     
    159265private UnicastConnection getServerConnection() throws IOException {
    160266        Socket sock = ssock.accept();
     267    sock.setTcpNoDelay(true); //??
    161268        UnicastConnection conn = new UnicastConnection(this, sock);
    162269        conn.acceptConnection();
    163 //System.out.println("Server connection " + conn);
     270    if (debug){
     271        nssock++;
     272        System.out.println("\n\n ****** " + nssock + " server socks.\n\n");
     273    }
     274    //System.out.println("Server connection " + sock);
    164275        return (conn);
    165276}
     
    169280 */
    170281private UnicastConnection getClientConnection() throws IOException {
     282    ArrayList conns = connections;
     283    UnicastConnection conn;
     284   
     285    synchronized(conns) {
     286        int nconn = conns.size() - 1;
     287   
     288        // if there're free connections in connection pool
     289        if(nconn >= 0) {
     290            conn = (UnicastConnection)conns.get(nconn);
     291            //Should we check if conn is alive using Ping??
     292            conns.remove(nconn);
     293           
     294            // Check if the connection is already expired
     295            long l = System.currentTimeMillis();
     296            if (!UnicastConnection.isExpired(conn, l)){
     297                return conn;
     298            }else {
     299                conn.disconnect();
     300                conn = null;   
     301            }
     302        }
     303    }
     304   
    171305        Socket sock = clientFactory.createSocket(serverName, serverPort);
    172         UnicastConnection conn = new UnicastConnection(this, sock);
     306    conn = new UnicastConnection(this, sock);
    173307        conn.makeConnection(DEFAULT_PROTOCOL);
    174 //System.out.println("Client connection " + conn);
     308   
     309    if (debug) {
     310        ncsock++;
     311        System.out.println("\n\n ====== " + ncsock + " client socks.\n\n");
     312    }
     313
    175314        return (conn);
    176315}
     
    182321public void discardConnection(UnicastConnection conn) {
    183322//System.out.println("Discarding connection " + conn);
     323    //conn.disconnect();
     324    if (ssock != null) //server connection
    184325        conn.disconnect();
     326    else {
     327        // To client connection, we'd like to return back to pool
     328        UnicastConnection.resetTime(conn);
     329        //Ensure there're only one scavenger globally
     330        synchronized(GLOBAL_LOCK) {
     331            connections.add(conn); //borrow this lock to garantee thread safety
     332            if (scavenger == null)
     333                startScavenger();
     334        }
     335    }
    185336}
    186337
     
    195346                }
    196347                serverThread = new Thread(this);
     348        // The following is not necessary when java.lang.Thread's constructor do this.
     349        // serverThread.setContextClassLoader(Thread.currentThread().getContextClassLoader());
    197350        }
    198351        serverThread.start();
     
    200353
    201354/**
     355 * Stop a server on this manager
     356 */
     357public void stopServer() {
     358    synchronized(this) {
     359        if(serverThread != null){
     360            serverThread = null;
     361            try{
     362                ssock.close();
     363            }catch(Exception _){}
     364        }
     365    }
     366}
     367
     368/**
    202369 * Server thread for connection manager.
    203370 */
    204371public void run() {
    205         for (;;) {
     372        for (;serverThread != null;) { // if serverThread==null, then exit thread
    206373                try {
    207374//System.out.println("Waiting for connection on " + serverPort);
    208375                        UnicastConnection conn = getServerConnection();
    209                         (new Thread(conn)).start();
     376                        // use a thread pool to improve performance
     377            //ConnectionRunnerPool.dispatchConnection(conn);
     378            (new Thread(conn)).start();
    210379                }
    211380                catch (Exception e) {
    212                         e.printStackTrace();
     381            e.printStackTrace();
    213382                }
    214383        }
     
    229398        String host = in.readUTF();
    230399        int port = in.readInt();
    231         RMIClientSocketFactory csf = ((RMIObjectInputStream)in).manager.clientFactory;
    232         return (getInstance(host, port, csf));
     400        //RMIClientSocketFactory csf = ((RMIObjectInputStream)in).manager.clientFactory;
     401        //return (getInstance(host, port, csf));
     402        return (getInstance(host, port, null));
    233403}
    234404
     
    263433                if (this.host.equals(other.host) &&
    264434                    this.other == other.other &&
    265                     (this.port == other.port || this.port == 0 || other.port == 0)) {
     435            (this.port == other.port /* || this.port == 0 || other.port == 0*/)) {
    266436                        return (true);
    267437                }
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/server/UnicastRef.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/*
    2   Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
     2  Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    6363import java.io.DataOutputStream;
    6464
     65import java.lang.reflect.InvocationTargetException;
     66
    6567public class UnicastRef
    6668        implements RemoteRef, ProtocolConstants {
     
    7072
    7173/**
    72  * Used by serialization.
    73  */
    74 private UnicastRef() {
     74 * Used by serialization, and let subclass capable of having default constructor
     75 */
     76//private
     77UnicastRef() {
    7578}
    7679
     
    8588
    8689public Object invoke(Remote obj, Method method, Object[] params, long opnum) throws Exception {
     90    // Check if client and server are in the same VM, then local call can be used to
     91    // replace remote call, but it's somewhat violating remote semantic.
     92    Object svrobj = manager.serverobj;
     93    if(svrobj != null){
     94        //local call
     95                Object ret = null;
     96                try{
     97                    ret = method.invoke(svrobj, params);
     98                }catch(InvocationTargetException e){
     99                    throw (Exception)e.getTargetException();
     100                }
     101                //System.out.println("\n\n ***** local call: " + method + "\nreturn: " + ret + "\n\n");
     102                return ret;
     103        }
     104        //System.out.println("***************** remote call:" + manager.serverPort);
    87105        return (invokeCommon(obj, method, params, -1, opnum));
    88106}
     
    108126                out.writeInt(opnum);
    109127                out.writeLong(hash);
    110                 if (params != null) {
    111                         for (int i = 0; i < params.length; i++) {
    112                                 if (params[i] instanceof UnicastRemoteObject) {
    113                                         out.writeObject(UnicastRemoteObject.exportObject((UnicastRemoteObject)params[i]));
    114                                 }
    115                                 else {
    116                                         out.writeObject(params[i]);
    117                                 }
    118                         }
    119                 }
     128               
     129                // must handle primitive class and their wrapper classes
     130                Class clss[] = method.getParameterTypes();
     131            for(int i = 0; i < clss.length; i++)
     132                ((RMIObjectOutputStream)out).writeValue(params[i], clss[i]);
    120133
    121134                out.flush();
     
    132145        try {
    133146                din = conn.getDataInputStream();
    134                 if (din.readUnsignedByte() != MESSAGE_CALL_ACK) {
    135                         throw new RemoteException("Call not acked");
     147               
     148                if ((returncode = din.readUnsignedByte()) != MESSAGE_CALL_ACK) {
     149                    conn.disconnect();
     150                        throw new RemoteException("Call not acked:" + returncode);
    136151                }
    137152
    138153                in = conn.getObjectInputStream();
    139 
    140154                returncode = in.readUnsignedByte();
    141155                ack = UID.read(in);
    142                 returnval = in.readObject();
     156
     157                Class cls = method.getReturnType();
     158        if(cls == Void.TYPE){
     159            returnval = null;
     160            in.readObject();
     161        }else
     162            returnval = ((RMIObjectInputStream)in).readValue(cls);
     163
    143164        }
    144165        catch (IOException e3) {
     166            //for debug: e3.printStackTrace();
    145167                throw new RemoteException("call return failed: ", e3);
    146168        }
    147169
     170    /* if DGCAck is necessary??
     171    //According to RMI wire protocol, send a DGCAck
     172    // to indicate receiving return value
     173    dout.writeByte(MESSAGE_DGCACK);
     174    ack.write(dout);
     175    out.flush();
     176    */
     177   
    148178        manager.discardConnection(conn);
    149179
    150         if (returncode != RETURN_ACK) {
     180        if (returncode != RETURN_ACK && returnval != null) {
    151181                throw (Exception)returnval;
    152182        }
     
    159189 */
    160190public RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum, long hash) throws RemoteException {
    161         return (new UnicastRemoteCall(obj, opnum, hash));
     191    UnicastConnection conn;
     192   
     193        try {
     194                conn = manager.getConnection();
     195        }
     196        catch (IOException e1) {
     197                throw new RemoteException("connection failed to host: " + manager.serverName, e1);
     198        }
     199
     200    //obj: useless?
     201
     202        return (new UnicastRemoteCall(conn, objid, opnum, hash));
    162203}
    163204
     
    167208public void invoke(RemoteCall call) throws Exception {
    168209        UnicastRemoteCall c = (UnicastRemoteCall)call;
    169         Object ret = invokeCommon((Remote)c.getObject(), (Method)null, c.getArguments(), c.getOpnum(), c.getHash());
    170         c.setReturnValue(ret);
     210        call.executeCall();
    171211}
    172212
     
    175215 */
    176216public void done(RemoteCall call) throws RemoteException {
    177         /* Does nothing */
     217        UnicastRemoteCall c = (UnicastRemoteCall)call;
     218        try{
     219            c.done();
     220        } catch(IOException e){}
     221    UnicastConnection conn = c.getConnection();
     222        manager.discardConnection(conn);
    178223}
    179224
     
    184229        manager.write(out);
    185230        objid.write(out);
    186         out.writeByte(RETURN_ACK);
     231        // This byte is somewhat confusing when interoperating with JDK
     232        out.writeByte(0); //RETURN_ACK);
    187233}
    188234
     
    190236        manager = UnicastConnectionManager.read(in);
    191237        objid = ObjID.read(in);
    192         if (in.readByte() != RETURN_ACK) {
     238        byte ack = in.readByte();
     239        // This byte is somewhat confusing when interoperating with JDK
     240        if (ack != RETURN_ACK && ack != 0/*jdk ack value*/) {
    193241                throw new IOException("no ack found");
    194242        }
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/server/UnicastRemoteCall.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    3939
    4040import java.lang.Exception;
     41import java.io.DataInputStream;
     42import java.io.DataOutputStream;
    4143import java.io.IOException;
    4244import java.io.ObjectOutput;
     
    4446import java.io.StreamCorruptedException;
    4547import java.rmi.server.RemoteCall;
     48import java.rmi.RemoteException;
     49import java.rmi.MarshalException;
     50import java.rmi.UnmarshalException;
     51import java.rmi.server.UID;
     52import java.rmi.server.ObjID;
     53import java.rmi.server.RemoteObject;
     54
    4655import java.util.Vector;
    4756
    48 public class UnicastRemoteCall implements RemoteCall
     57public class UnicastRemoteCall
     58        implements RemoteCall, ProtocolConstants
    4959{
    5060
     
    5767  private int ptr;
    5868
     69  private ObjectOutput oout;
     70  private ObjectInput oin;
     71
    5972  /**
    6073   * Incoming call.
     
    6881   * Outgoing call.
    6982   */
    70   UnicastRemoteCall(Object obj, int opnum, long hash)
    71   {
    72     this.object = obj;
     83  UnicastRemoteCall(UnicastConnection conn, ObjID objid, int opnum, long hash)
     84    throws RemoteException
     85  {
     86    this.conn = conn;
    7387    this.opnum = opnum;
    7488    this.hash = hash;
    75   }
    76 
     89   
     90    // signal the call when constructing
     91    try
     92      {
     93        DataOutputStream dout = conn.getDataOutputStream();
     94        dout.write(MESSAGE_CALL);
     95       
     96        oout = conn.getObjectOutputStream();
     97        objid.write(oout);
     98        oout.writeInt(opnum);
     99        oout.writeLong(hash);
     100      }
     101    catch(IOException ex)
     102      {
     103        throw new MarshalException("Try to write header but failed.", ex);
     104      }
     105  }
     106 
     107  UnicastConnection getConnection()
     108  {
     109    return conn;
     110  }
     111 
    77112  public ObjectOutput getOutputStream() throws IOException
     113  {
     114    if (conn != null)
     115      {
     116        if(oout == null)
     117          return (oout = conn.getObjectOutputStream());
     118        else
     119          return oout;
     120      }
     121    else
     122      {
     123        vec = new Vector();
     124        return (new DummyObjectOutputStream());
     125      }
     126  }
     127
     128  public void releaseOutputStream() throws IOException
     129  {
     130    if(oout != null)
     131      oout.flush();
     132  }
     133
     134  public ObjectInput getInputStream() throws IOException
     135  {
     136    if (conn != null)
     137      {
     138        if(oin == null)
     139          return (oin = conn.getObjectInputStream());
     140        else
     141          return oin;
     142      }
     143    else
     144      {
     145        ptr = 0;
     146        return (new DummyObjectInputStream());
     147      }
     148  }
     149
     150  public void releaseInputStream() throws IOException
     151  {
     152    // Does nothing.
     153  }
     154
     155  public ObjectOutput getResultStream(boolean success)
     156    throws IOException, StreamCorruptedException
    78157  {
    79158    vec = new Vector();
    80159    return new DummyObjectOutputStream();
    81160  }
    82 
    83   public void releaseOutputStream() throws IOException
    84   {
    85     // Does nothing.
    86   }
    87 
    88   public ObjectInput getInputStream() throws IOException
    89   {
    90     if (conn != null)
    91       return conn.getObjectInputStream();
    92     ptr = 0;
    93     return new DummyObjectInputStream();
    94   }
    95 
    96   public void releaseInputStream() throws IOException
    97   {
    98     // Does nothing.
    99   }
    100 
    101   public ObjectOutput getResultStream(boolean success)
    102     throws IOException, StreamCorruptedException
    103   {
    104     vec = new Vector();
    105     return new DummyObjectOutputStream();
    106   }
    107 
     161 
    108162  public void executeCall() throws Exception
    109163  {
    110     throw new Error("Not implemented");
     164    byte returncode;
     165    ObjectInput oin;
     166    try
     167      {
     168        releaseOutputStream();
     169        DataInputStream din = conn.getDataInputStream();
     170        if (din.readByte() != MESSAGE_CALL_ACK)
     171            throw new RemoteException("Call not acked");
     172
     173        oin = getInputStream();
     174        returncode = oin.readByte();
     175        UID.read(oin);
     176      }
     177    catch(IOException ex)
     178      {
     179        throw new UnmarshalException("Try to read header but failed:", ex);
     180      }
     181   
     182    //check return code
     183    switch(returncode)
     184      {
     185      case RETURN_ACK: //it's ok
     186        return;
     187      case RETURN_NACK:
     188        Object returnobj;
     189        try
     190          {
     191            returnobj = oin.readObject();
     192          }
     193        catch(Exception ex2)
     194          {
     195            throw new UnmarshalException
     196              ("Try to read exception object but failed", ex2);
     197          }
     198       
     199        if(!(returnobj instanceof Exception))
     200          throw new UnmarshalException("Should be Exception type here: "
     201                                       + returnobj);
     202        throw (Exception)returnobj;
     203       
     204      default:
     205        throw new UnmarshalException("Invalid return code");
     206      }
    111207  }
    112208
    113209  public void done() throws IOException
    114210  {
    115     /* Does nothing */
     211    // conn.disconnect();
    116212  }
    117213
    118214  Object returnValue()
    119215  {
    120     return vec.elementAt(0);
     216    return (vec.size() > 0 ? vec.elementAt(0) : null);
    121217  }
    122218
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/server/UnicastServer.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/*
    2   Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
     2  Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    4646import java.util.Hashtable;
    4747import java.net.UnknownHostException;
     48import java.rmi.Remote;
    4849import java.rmi.server.ObjID;
    4950import java.rmi.server.UnicastRemoteObject;
     
    5758        implements ProtocolConstants {
    5859
    59 static private Hashtable objects = new Hashtable();
     60static private Hashtable objects = new Hashtable();  //mapping OBJID to server ref
     61static private Hashtable refcache = new Hashtable(); //mapping obj itself to server ref
    6062static private DGCImpl dgc;
    6163
     
    6365        startDGC();
    6466        objects.put(obj.objid, obj);
     67        refcache.put(obj.myself, obj);
    6568        obj.manager.startServer();
     69}
     70
     71// FIX ME: I haven't handle force parameter
     72public static boolean unexportObject(UnicastServerRef obj, boolean force) {
     73        objects.remove(obj.objid);
     74        refcache.remove(obj.myself);
     75        obj.manager.stopServer();
     76        return true;
     77}
     78
     79public static UnicastServerRef getExportedRef(Remote remote){
     80    return (UnicastServerRef)refcache.get(remote);
    6681}
    6782
     
    7085                try {
    7186                        dgc = new DGCImpl();
    72                         ((UnicastServerRef)dgc.getRef()).exportObject(dgc);
     87                        // Changed DGCImpl to inherit UnicastServerRef directly
     88                        //((UnicastServerRef)dgc.getRef()).exportObject(dgc);
     89                        dgc.exportObject(dgc);
    7390                }
    7491                catch (RemoteException e) {
     
    101118        Object returnval;
    102119        int returncode = RETURN_ACK;
     120        // returnval is from Method.invoke(), so we must check the return class to see
     121        // if it's primitive type
     122        Class returncls = null;
    103123        if (uref != null) {
    104124                try {
    105125                        // Dispatch the call to it.
    106126                        returnval = uref.incomingMessageCall(conn, method, hash);
     127                        returncls = uref.getMethodReturnType(method, hash);
    107128                }
    108129                catch (Exception e) {
     
    122143        out.writeByte(returncode);
    123144        (new UID()).write(out);
    124         out.writeObject(returnval);
     145        if(returnval != null && returncls != null)
     146            ((RMIObjectOutputStream)out).writeValue(returnval, returncls);
     147        else
     148            out.writeObject(returnval);
    125149
    126150        out.flush();
  • branches/GNU/src/gcc/libjava/gnu/java/rmi/server/UnicastServerRef.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/*
    2   Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
     2  Copyright (c) 1996, 1997, 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    6464import java.io.ObjectInputStream;
    6565import java.io.ObjectOutputStream;
     66import java.io.ObjectInput;
     67import java.io.ObjectOutput;
    6668import java.util.Hashtable;
    6769
    6870public class UnicastServerRef
    69         extends UnicastRef {
     71        extends UnicastRef
     72        implements ServerRef{ //SHOULD implement ServerRef
    7073
    7174final static private Class[] stubprototype = new Class[] { RemoteRef.class };
    7275
    73 Remote myself;
     76Remote myself; //save the remote object itself
    7477private Skeleton skel;
    7578private RemoteStub stub;
    76 private Hashtable methods;
     79private Hashtable methods = new Hashtable();
     80
     81/**
     82 * Used by serialization.
     83 */
     84UnicastServerRef()
     85{
     86}
    7787
    7888public UnicastServerRef(ObjID id, int port, RMIServerSocketFactory ssf) {
     
    8494        if (myself == null) {
    8595                myself = obj;
     96                // Save it to server manager, to let client calls in the same VM to issue
     97                //  local call
     98                manager.serverobj = obj;
    8699
    87100                // Find and install the stub
     
    96109
    97110                // Build hash of methods which may be called.
    98                 buildMethodHash(obj.getClass());
     111                buildMethodHash(obj.getClass(), true);
    99112
    100113                // Export it.
     
    105118}
    106119
     120public RemoteStub exportObject(Remote remote, Object obj)
     121        throws RemoteException
     122{
     123    //FIX ME
     124        return exportObject(remote);
     125}
     126
     127public RemoteStub getStub(){
     128    return stub;
     129}
     130
     131
     132public boolean unexportObject(Remote obj, boolean force) {
     133    // Remove all hashes of methods which may be called.
     134    buildMethodHash(obj.getClass(), false);
     135    return UnicastServer.unexportObject(this, force);
     136}
     137
    107138private Object getHelperClass(Class cls, String type) {
    108139        try {   
    109                 String classname = cls.getName();
    110                 Class scls = Class.forName(classname + type);
     140            String classname = cls.getName();
     141                ClassLoader cl = cls.getClassLoader(); //DONT use "Class scls = Class.forName(classname + type);"
     142                Class scls = cl.loadClass(classname + type);
    111143                if (type.equals("_Stub")) {
    112144                        try {
     
    148180}
    149181
    150 private void buildMethodHash(Class cls) {
    151         methods = new Hashtable();
     182private void buildMethodHash(Class cls, boolean build) {
    152183        Method[] meths = cls.getMethods();
    153184        for (int i = 0; i < meths.length; i++) {
     
    157188                }
    158189                long hash = RMIHashes.getMethodHash(meths[i]);
    159                 methods.put(new Long (hash), meths[i]);
     190                if(build)
     191                    methods.put(new Long (hash), meths[i]);
     192                else
     193                    methods.remove(new Long (hash));
    160194//System.out.println("meth = " + meths[i] + ", hash = " + hash);
    161195        }
     196}
     197
     198Class getMethodReturnType(int method, long hash) throws Exception
     199{
     200    if (method == -1) {
     201        Method meth = (Method)methods.get(new Long (hash));
     202        return meth.getReturnType();
     203    }else
     204        return null;
    162205}
    163206
     
    190233                        }
    191234                }
    192                 return (meth.invoke(myself, args));
     235                //We must reinterpret the exception thrown by meth.invoke()
     236                //return (meth.invoke(myself, args));
     237                Object ret = null;
     238                try{
     239                    ret = meth.invoke(myself, args);
     240                }catch(InvocationTargetException e){
     241                    throw (Exception)(e.getTargetException());
     242                }
     243                return ret;
    193244        }
    194245        // Otherwise this is JDK 1.1 style RMI - we find the skeleton
  • branches/GNU/src/gcc/libjava/gnu/java/security/provider/DefaultPolicy.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* DefaultPolicy.java
    2    Copyright (C) 2001 Free Software Foundation, Inc.
     2   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    4848public class DefaultPolicy extends Policy
    4949{
    50   static Permissions allPermissions = new Permissions();
    51  
    52   static
    53   {
    54     allPermissions.add(new AllPermission());
    55   }
     50  static Permission allPermission = new AllPermission();
    5651
    5752  public PermissionCollection getPermissions(CodeSource codesource)
    5853  {
    59     return allPermissions;
     54    Permissions perms = new Permissions();
     55    perms.add(allPermission);
     56    return perms;
    6057  }
    6158 
  • branches/GNU/src/gcc/libjava/gnu/java/security/provider/Gnu.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* Gnu.java --- Gnu provider main class
    2    Copyright (C) 1999 Free Software Foundation, Inc.
     2   Copyright (C) 1999, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    4646    super( "GNU", 1.0, "GNU provider v1.0 implementing SHA-1, MD5, DSA");
    4747
     48    // Note that all implementation class names are referenced by using
     49    // Class.getName(). That way when we staticly link the Gnu provider
     50    // we automatically get all the implementation classes.
     51
    4852    // Signature
    49     put("Signature.SHA1withDSA", "gnu.java.security.provider.DSASignature");
     53    put("Signature.SHA1withDSA",
     54        gnu.java.security.provider.DSASignature.class.getName());
    5055
    5156    put("Alg.Alias.Signature.DSS", "SHA1withDSA");
     
    6368
    6469    // Key Pair Generator
    65     put("KeyPairGenerator.DSA", "gnu.java.security.provider.DSAKeyPairGenerator");
     70    put("KeyPairGenerator.DSA",
     71        gnu.java.security.provider.DSAKeyPairGenerator.class.getName());
    6672
    6773    put("Alg.Alias.KeyPairGenerator.OID.1.2.840.10040.4.1", "DSA");
     
    7076
    7177    // Message Digests
    72     put("MessageDigest.SHA", "gnu.java.security.provider.SHA");
    73     put("MessageDigest.MD5", "gnu.java.security.provider.MD5");
     78    put("MessageDigest.SHA", gnu.java.security.provider.SHA.class.getName());
     79    put("MessageDigest.MD5", gnu.java.security.provider.MD5.class.getName());
    7480
    7581    // Format "Alias", "Actual Name"
     
    7884
    7985    // Algorithm Parameters
    80     put("AlgorithmParameters.DSA", "gnu.java.security.provider.DSAAlgorithmParameters");
     86    put("AlgorithmParameters.DSA",
     87        gnu.java.security.provider.DSAParameters.class.getName());
    8188
    8289    // Algorithm Parameter Generator
    83     put("AlgorithmParameterGenerator.DSA", "gnu.java.security.provider.DSAAlgorithmParameterGenerator");
     90    put("AlgorithmParameterGenerator.DSA",
     91     gnu.java.security.provider.DSAParameterGenerator.class.getName());
    8492
    8593    // SecureRandom
    86     put("SecureRandom.SHA1PRNG", "gnu.java.security.provider.SHA1PRNG");
    87 
     94    put("SecureRandom.SHA1PRNG",
     95        gnu.java.security.provider.SHA1PRNG.class.getName());
    8896
    8997  }
  • branches/GNU/src/gcc/libjava/gnu/java/security/provider/SHA.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* SHA.java -- Class implementing the SHA-1 algorithm as specified in [1].
    2    Copyright (C) 1999, 2000 Free Software Foundation, Inc.
     2   Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    5959  public int engineGetDigestLength()
    6060  {
    61     return 16;
     61    return 20;
    6262  }
    6363
    6464  public void engineUpdate (byte b)
    6565  {
    66     int i = (int)bytecount % 64;
    67     int shift = (3 - i % 4) * 8;
     66    int i = ((int)bytecount) & 0x3f; //wgs
     67    int shift = (3 - i % 4) << 3;
    6868    int idx = i / 4;
    6969
    70     // if you could index ints, this would be: W[idx][shift/8] = b
    71     W[idx] = (W[idx] & ~(0xff << shift)) | ((b & 0xff) << shift);
     70    i = (int)b;
     71    W[idx] = (W[idx] & ~(0xff << shift)) | ((i & 0xff) << shift);
    7272
    7373    // if we've filled up a block, then process it
    74     if ((++ bytecount) % 64 == 0)
     74    if (((++bytecount) & 0x3f) == 0)
    7575      munch ();
    7676  }
     
    100100  public byte[] engineDigest ()
    101101  {
    102     long bitcount = bytecount * 8;
     102    long bitcount = bytecount << 3;
    103103    engineUpdate ((byte)0x80); // 10000000 in binary; the start of the padding
    104104
    105105    // add the rest of the padding to fill this block out, but leave 8
    106106    // bytes to put in the original bytecount
    107     while ((int)bytecount % 64 != 56)
     107    while ((bytecount & 0x3f) != 56)
    108108      engineUpdate ((byte)0);
    109109
  • branches/GNU/src/gcc/libjava/gnu/java/security/provider/SHA1PRNG.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* SHA1PRNG.java --- Secure Random SPI SHA1PRNG
    2    Copyright (C) 1999, 2001 Free Software Foundation, Inc.
     2   Copyright (C) 1999, 2001, 2003 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    5252  int seedpos;
    5353  int datapos;
     54  private boolean seeded = false; // set to true when we seed this
    5455
    5556  public SHA1PRNG()
     
    5859      digest = MessageDigest.getInstance("SHA");
    5960    } catch ( NoSuchAlgorithmException nsae) {
    60       System.out.println("Failed to find SHA Message Digest: " + nsae);
    61       nsae.printStackTrace();
     61//      System.out.println("Failed to find SHA Message Digest: " + nsae);
     62//      nsae.printStackTrace();
     63      throw new InternalError ("no SHA implementation found");
    6264    }
    6365
     
    6567    seedpos = 0;
    6668    data = new byte[40];
    67     datapos = 0;
    68 
    69     new Random().nextBytes(seed);
    70 
    71     byte digestdata[];
    72     digestdata = digest.digest( data );
    73     System.arraycopy( digestdata, 0, data, 0, 20);
    74 
     69    datapos = 20;  // try to force hashing a first block
    7570  }
    7671
     
    8580  public void engineNextBytes(byte[] bytes)
    8681  {
     82    ensureIsSeeded ();
    8783    int loc = 0;
    8884    while (loc < bytes.length)
     
    114110    return tmp;
    115111  }
     112
     113  private void ensureIsSeeded()
     114  {
     115    if (!seeded)
     116      {
     117        new Random(0L).nextBytes(seed);
     118
     119        byte[] digestdata = digest.digest(data);
     120        System.arraycopy(digestdata, 0, data, 0, 20);
     121
     122        seeded = true;
     123      }
     124  }
     125
    116126}
  • branches/GNU/src/gcc/libjava/gnu/java/text/SentenceBreakIterator.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* SentenceBreakIterator.java - Default sentence BreakIterator.
    2    Copyright (C) 1999, 2001 Free Software Foundation, Inc.
     2   Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    9292                   && Character.getType(n) == Character.END_PUNCTUATION)
    9393              n = iter.next();
    94             // Skip spaces.
    95             while (n != CharacterIterator.DONE
    96                    && Character.getType(n) == Character.SPACE_SEPARATOR)
    97               n = iter.next();
    98             // Skip optional paragraph separator.
    99             if (n != CharacterIterator.DONE
    100                 && Character.getType(n) == Character.PARAGRAPH_SEPARATOR)
     94            // Skip (java) space, line and paragraph separators.
     95            while (n != CharacterIterator.DONE && Character.isWhitespace(n))
    10196              n = iter.next();
    10297
     
    112107                   && Character.getType(n) == Character.END_PUNCTUATION)
    113108              n = iter.next();
    114             // Skip spaces.  We keep count because we need at least
    115             // one for this period to represent a terminator.
     109            // Skip (java) space, line and paragraph separators.
     110            // We keep count because we need at least one for this period to
     111            // represent a terminator.
    116112            int spcount = 0;
    117             while (n != CharacterIterator.DONE
    118                    && Character.getType(n) == Character.SPACE_SEPARATOR)
     113            while (n != CharacterIterator.DONE && Character.isWhitespace(n))
    119114              {
    120115                n = iter.next();
     
    163158        if (! Character.isLowerCase(c)
    164159            && (nt == Character.START_PUNCTUATION
    165                 || nt == Character.SPACE_SEPARATOR))
     160                || Character.isWhitespace(n)))
    166161          {
    167162            int save = iter.getIndex();
     
    174169            if (n == CharacterIterator.DONE)
    175170              break;
    176             if (Character.getType(n) == Character.SPACE_SEPARATOR)
    177               {
    178                 // Must have at least once space after the `.'.
     171            if (Character.isWhitespace(n))
     172              {
     173                // Must have at least one (java) space after the `.'.
    179174                int save2 = iter.getIndex();
    180175                while (n != CharacterIterator.DONE
    181                        && Character.getType(n) == Character.SPACE_SEPARATOR)
     176                       && Character.isWhitespace(n))
    182177                  n = iter.previous();
    183178                // Skip close punctuation.
     
    204199            break;
    205200          }
    206         else if (nt == Character.SPACE_SEPARATOR
     201        else if (Character.isWhitespace(n)
    207202                 || nt == Character.END_PUNCTUATION)
    208203          {
    209204            int save = iter.getIndex();
    210             // Skip spaces.
    211             while (n != CharacterIterator.DONE
    212                    && Character.getType(n) == Character.SPACE_SEPARATOR)
     205            // Skip (java) space, line and paragraph separators.
     206            while (n != CharacterIterator.DONE
     207                   && Character.isWhitespace(n))
    213208              n = iter.previous();
    214209            // Skip close punctuation.
Note: See TracChangeset for help on using the changeset viewer.