java.lang.ArrayIndexOutOfBoundsException
"floriola2000" <[email protected]> Tue, 30 Mar 2004 20:15:00 -0000
| Newsgroups | gmane.text.xml.xmlpull.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I am trying to decode the wbxml Login-Request document sent by a
Wireless Village phone. I have captured this document into a file
called file.wbxml using a sniffer, and I made a simple parser, like
below.
I am using the latest kxml2 version from CVS and the xmlpull
xmlpull_1_1_3_4a_src.zip, without any modifications.
Here is my code:
public class WvParser extends WV {
// Do nothing
public WvParser() {};
}
public class WvTestParser {
public static void main(String[] argv) throws Exception {
WvParser wp = new WvParser();
XmlPullParser xp = wp.createParser();
xp.setInput(new FileInputStream("file.wbxml"), null);
XmlSerializer xs = new KXmlSerializer();
xs.setOutput(System.out, null);
new Roundtrip(xp, xs).roundTrip();
}
}
Now when I run this code, I get the following error:
<?xml version='1.0' ?><WV-CSP-Message xmlns="http://www.wireless-
village.org/CSP1.1"><Session><SessionDescriptor>
java.lang.ArrayIndexOutOfBoundsException: 4
at org.kxml2.wap.WbxmlParser.getNamespaceCount
(WbxmlParser.java:113)
at Roundtrip.writeStartTag(Roundtrip.java:36)
at Roundtrip.writeToken(Roundtrip.java:69)
at Roundtrip.roundTrip(Roundtrip.java:122)
at WvTestParser.main(WvTestParser.java:27)
Exception in thread "main"
The problem is this java.lang.ArrayIndexOutOfBoundsException
I looked into the code and in WbxmlParser.java file, around line 885,
I found the following commented code:
/* if (depth >= nspCounts.length) {
int[] bigger = new int[depth + 4];
System.arraycopy(nspCounts, 0, bigger, 0,
nspCounts.length);
nspCounts = bigger;
}
nspCounts[depth] = nspCounts[depth - 1]; */
If you uncomment this code, this ArrayIndexOutOfBoundsException
error disapear.
I also noticed that the code that I have uncommentd is doing the same
thing like ensureCapacity method, the diference is that
ensureCapacity has a String[] as first argument and returns a String
[], while the uncomented code is using an int[] nspCounts.
Would it be possible that you overload this ensureCapacity method, so
that it can handle also int[]? In this way the code that I have
uncommented can be changed like this:
nspCounts = ensureCapacity(nspCounts, depth + 4);
nspCounts[depth] = nspCounts[depth - 1];
Would it also be possible to keep this code uncommented?
Thanks and best regards,
Floriola
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/2U_rlB/TM
---------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/xmlpull-dev/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/