rmi and java/lang/String.java

alice dubois alice.dubois at lemel.fr
Thu Dec 3 06:28:59 PST 1998


Hi,

To use commands 'rmic' and 'rmiregistry' from kaffe, I use sun/rmi package.

Here's what I do:
#> javac Client.java KaraokeBox.java KaraokeBoxImpl.java    //OK
#> rmic KaraokeBoxImpl					    //OK
#> rmiregistry &
#> kaffe KaraokeBoxImpl
java.lang.StringIndexOutOfBoundsException: 7
        at java/lang/Throwable.<init>(37)
        at java/lang/Exception.<init>(21)
        at java/lang/RuntimeException.<init>(21)
        at java/lang/IndexOutOfBoundsException.<init>(21)
        at java/lang/StringIndexOutOfBoundsException.<init>(25)
        at java/lang/String.substring(419)
        at java/net/URL.<init>(44)
        at java/rmi/Naming.cleanURL(176)
        at java/rmi/Naming.rebind(109)
        at KaraokeBoxImpl.main(19)

Here's the method of java/lang/String.java where the exception is caught:

public String substring( int sIdx, int eIdx) {
	if ( sIdx < 0)     throw new StringIndexOutOfBoundsException( sIdx);
	if ( eIdx > count) throw new StringIndexOutOfBoundsException( eIdx);
	if ( sIdx > eIdx)  throw new StringIndexOutOfBoundsException( eIdx-sIdx);
	if ( ( sIdx == 0) && ( eIdx  == count ) )
		return this;
	return new String( offset+sIdx, offset+eIdx, value);
}

(I've found that it was at the second line ( if ( eIdx > count) ...) ).
Is it because of sun/rmi package ? (it works with jdk )
Or is there something to add in "KaraokeBoxImpl.java" ?

source:

"Client.java":
class Client{
   public static void main(String argv[]){
       String name = (argv.length == 1) ? argv[0] : "-";
       try{                                                                 
             
         KaraokeBox box =
(KaraokeBox)java.rmi.Naming.lookup("rmi://kinta/karaokebox1"); 
         box.hello(name);
       }                                                                    
             
       catch(Exception e){e.printStackTrace();}                             
             
  }
}

"KaraokeBox.java":
interface KaraokeBox extends java.rmi.Remote{
   public void hello(String s) throws java.rmi.RemoteException;
}

"KaraokeBoxImpl.java":
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
public class KaraokeBoxImpl extends UnicastRemoteObject implements 
KaraokeBox{
    public KaraokeBoxImpl() throws RemoteException{
        super();
    }
    public void hello(String s) throws RemoteException{
        System.out.println("Client Name " + s);
    }
    public static void main(String argv[]){
        System.setSecurityManager(new RMISecurityManager());
         try{
	    KaraokeBox box = new KaraokeBoxImpl();
	    java.rmi.Naming.rebind("karaokebox1", box);
         }
         catch(Exception e)e.printStackTrace();
		
     }
}

Thanks, 

Alice


More information about the kaffe mailing list