Exception handler not found

Sami Tikka sami.tikka at research.nokia.com
Sat Sep 5 06:53:38 PDT 1998


I have this short Java program that I've built that doesn't work with
Kaffe but does with JDK. The program is supposed to get an URL from the
command line, get the contents of the URL and write it to stdout.
A useful little tool. Here's what happens:

melkor lib$ CLASSPATH=HttpGet.jar
melkor lib$ export CLASSPATH
melkor lib$ kaffe fi.iki.sti.util.Http get
http://hollywood.research.nokia.com/
sp out of range: 2 <8> 7
Kaffe: code-analyse.c:1887: mergeFrame: Assertion `to != 0' failed.
Aborted (core dumped)
melkor lib$

I used kaffe-snap.tar.gz from www.transvirtual.com which I downloaded
and compiled today on Linux 2.1.118.

I've attached the files and a jar file of the classes I used to invoke
the above test.
I hope this helps you to fix kaffe. I really enjoyed using the 0.1.0
version of kaffe to learn Java programming.

Sami Tikka

-------------- next part --------------
A non-text attachment was scrubbed...
Name: HttpGet.jar
Type: application/java-archive
Size: 2565 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/19980905/0c8596c3/attachment-0007.jar 
-------------- next part --------------
/*
 * HTTP.java
 *
 * A general-purpose, command line HTTP tool.
 *
 * Sami Tikka, July 1997
 *
 * $Revision: 1.4 $
 * $Date: 1998/05/31 19:31:08 $
 * $Author: tikka $
 * $Locker: tikka $
 * $State: Exp $
 *
 * Changes:
 * $Log: Http.java,v $
 * Revision 1.4  1998/05/31 19:31:08  tikka
 * Http is now part of util package
 *
 * Revision 1.3  1997/07/25 12:07:40  tikka
 * *** empty log message ***
 *
 * Revision 1.2  1997/07/19 23:21:14  tikka
 * Removed debug msgs.
 *
 * Revision 1.1  1997/07/19 22:01:59  tikka
 * Initial revision
 *
 */

package fi.iki.sti.util;

import java.lang.*;
import java.io.*;
import java.net.*;

public class Http {

  public static void main(String argv[]) {

    try {

      if (argv.length == 0) {
	System.out.println("USAGE: method URL [method params...]");
	System.out.println("The only supported method at the moment is \"get\"");
      } else if (argv[0].equals("get")) {
	HttpGet hg = new HttpGet(argv);
	hg.doit();
      } else if (argv[0].equals("post")) {
      } else {
	System.out.println("Unknon method \"" + argv[0] + "\" requested.");
      }

    } catch (IOException e) {
      System.err.println(e);
      e.printStackTrace();
    }
  }
}


    
-------------- next part --------------
/*
 * HttpGet.java
 *
 * Handle the GET method for HTTP.
 *
 * Sami Tikka, July 1997.
 *
 * $Revision: 1.5 $
 * $Date: 1998/05/31 19:31:37 $
 * $Author: tikka $
 * $Locker:  $
 * $State: Exp $
 *
 * Changes:
 * $Log: HttpGet.java,v $
 * Revision 1.5  1998/05/31 19:31:37  tikka
 * HttpGet is now part of util package and uses buffered streams.
 *
 * Revision 1.4  1997/07/27 20:39:03  tikka
 * Output to optional file argument after URL.
 *
 * Revision 1.3  1997/07/25 12:07:52  tikka
 * *** empty log message ***
 *
 * Revision 1.2  1997/07/19 23:20:33  tikka
 * Prints HTTP reply headers to stderr.
 *
 * Revision 1.1  1997/07/19 22:03:33  tikka
 * Initial revision
 *
 */

package fi.iki.sti.util;

import java.lang.*;
import java.io.*;
import java.net.*;

public class HttpGet {

  URL url;
  URLConnection uc;
  BufferedOutputStream out;
  
  public HttpGet(String argv[]) throws IOException {

    int lastoi = argv.length - 2;
    out = new BufferedOutputStream(System.out);

    try {
      url = new URL(argv[argv.length - 1]);
    } catch (MalformedURLException e) {
      try {
	url = new URL(argv[argv.length - 2]);
	lastoi--;
	out = new BufferedOutputStream(new FileOutputStream(argv[argv.length - 1]));
      } catch (MalformedURLException e2) {
	System.err.println("No URL found!");
	return;
      }
    }
    
    uc = url.openConnection();

    for (int oi = 1; oi <= lastoi; oi++) {
      if (argv[oi].equals("-nocache")) {
	uc.setUseCaches(false);
	continue;
      }
      System.err.println("Unknown option " + argv[oi]);
    }
  }

  public void doit() throws IOException {

    uc.connect();

    int i = 1;
    String headerFieldKey;

    while ((headerFieldKey = uc.getHeaderFieldKey(i)) != null) {
      System.err.println(headerFieldKey + ": " + uc.getHeaderField(i++));
    }

    int contentLength = uc.getContentLength();
    int actualContentLength = 0;
    BufferedInputStream in = new BufferedInputStream(uc.getInputStream());
    int b;
    while ((b = in.read()) != -1) {
      out.write(b);
      actualContentLength++;
    }
    out.flush();
    if (contentLength != -1 && contentLength != actualContentLength) {
      System.err.println("WARNING: document is " +
			(contentLength - actualContentLength) +
			" bytes short!");
    }
  }
}


More information about the kaffe mailing list