Re: [java-gnome-hackers] gnome.UIInfo array out of bound.
Brought to you by:
afcowie
From: Tom B. <Tom...@Su...> - 2002-12-23 19:04:21
|
Hi Mark, The AppExample works for me using either Sun's 1.4.1 or gcj, but both runtimes report four 'uiinfo->widget != NULL' assertion failures (so the problem is most likely in our code). Sun's 1.3.1_03 segv's however, which is weird. What VM and version do you use? I don't know the UIInfo code, but a quick review shows that it's sloppy about byte versus char arrays with its string parameters. That's understandable because in ASCII byte and char arrays are often swapped in C, but in Java (and outside the USA) they are very different types (String.getBytes can return ugly results with localized strings). Your exception is thrown when a String.getBytes() call is passed to an overloaded method that takes either byte or char arrays, suggesting that just cleaning up the char/byte array handling may fix your problem as a side-effect. I think that all the byte array methods should be replaced with char arrays until the actual native GTK or GNOME call is made. In Java, char arrays should always be used with characters, while byte arrays should only be used for raw data. If we adopt this policy now, we probably won't be broken by future internationalization fixes in GTK and GNOME. If you'd rather I clean up UIInfo, let me know. Tom P.S. There's never a need to call either "new String()" or "new String(<string>)", since strings are immutable. If you need an empty string, just use '""'; since all constant strings are interned, there is only one instance of it is shared by the whole runtime. On Sat, 2002-12-21 at 04:01, Mark Howard wrote: > Hi, > Whenever trying to use the UIInfo object, I get the following > exception: > java.lang.ArrayIndexOutOfBoundsException > at org.gnu.gnome.UIInfo.setPixmapInfo(UIInfo.java:native) > at org.gnu.gnome.UIInfo.<init>(UIInfo.java:142) > at org.gnu.gnome.UIInfo.newItem(UIInfo.java:441) > at app.AppExample.buildMyMenus(AppExample.java:59) > at app.AppExample.<init>(AppExample.java:43) > at app.AppExample.main(AppExample.java:165) > This is even done in src/examples/gnome/app/AppExample.java > > Would it be possible for someone to fix this please (I'm guessing the > person who wrote it would be able to do it far quicker than anyone > else). > > Also: > I've just been trying a number of the other gnome example apps. These > often seem to segfault after a while (sometimes when you click on a > widget, but not always). Nothing is written to the console. Does > everyone else encounter this? -- Tom Ball <Tom...@Su...> |