rmi and java/lang/String.java
Archie Cobbs
archie at whistle.com
Thu Dec 3 12:28:08 PST 1998
alice dubois writes:
> 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)
There were a couple of bugs in the URL(String x) constructor.
Please apply the patch below, rebuild Klasses.jar, and try again
if you can. Not sure whether this patch will fix your particular
problem or just move it to another place..
-Archie
___________________________________________________________________________
Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com
Index: URL.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/net/URL.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- URL.java 1998/09/03 20:58:41 1.3
+++ URL.java 1998/12/03 21:30:20 1.4
@@ -40,22 +40,36 @@
}
protocol = spec.substring(0, pend);
- int hstart = pend+3;
- if (spec.substring(pend+1, hstart).equals("//")) {
+ boolean hasHostPart = false;
+ try {
+ hasHostPart = spec.substring(pend + 1, pend + 3).equals("//");
+ } catch (IndexOutOfBoundsException e) { }
+
+ if (hasHostPart) {
+ int hstart = pend + 3;
int hend = spec.indexOf(':', hstart);
+
if (hend == -1) {
hend = spec.indexOf('/', hstart);
if (hend == -1) {
- throw new MalformedURLException("no host");
+ throw new MalformedURLException("no file");
}
host = spec.substring(hstart, hend);
port = getDefaultPort(protocol);
}
else {
host = spec.substring(hstart, hend);
- int postart = hend+1;
+ int postart = hend + 1;
int poend = spec.indexOf('/', postart);
- port = Integer.parseInt(spec.substring(postart, poend));
+ if (poend == -1) {
+ throw new MalformedURLException("no file");
+ }
+ try {
+ port = Integer.parseInt(
+ spec.substring(postart, poend));
+ } catch (NumberFormatException e) {
+ throw new MalformedURLException("bad port");
+ }
}
fstart = spec.indexOf( '/', hstart);
}
More information about the kaffe
mailing list