I've been fiddling with the Java support lately, and it appears that while the Java bridge has no real documentation, it's pretty full featured. That said, I'm trying to get a feel for the limitations, and ran into one that just doesn't seem right:
if I create a new java array of any type other than string, I can't assign values to it:
example using string:
import Java; object t=machine->find_class("java/lang/String"); object o=pkg["java/lang/reflect/Array"]->newInstance(t, 5); o[0]="foo"; o[1]="bar";
works just fine, but this example using integers doesnt:
import Java; object t=machine->find_class("java/lang/Integer"); object o=pkg["java/lang/reflect/Array"]->newInstance(t, 5); o[0]=12; o[1]=5;
incompatible types passed to method. jvm.c:3550: jvm.c:3550()->`[]=(0,1) /usr/local/pike/7.4.20/lib/modules/Java.pmod:301: Java.jarray()->`[]=(0,1) test.pike:7: test()->main()
Any ideas? I had been using java the manual way by manually connecting methods, and it worked fine using Array.set() (admittedly a different technique).
I have no idea if this is correct or not, but it's not an issue with int vs Integer and pike not converting a Pike int to Java Integer automatically? Can you create an Integer object and assign that?
/ David Hedbor
Previous text:
2003-09-04 20:13: Subject: arrays in Java
I've been fiddling with the Java support lately, and it appears that while the Java bridge has no real documentation, it's pretty full featured. That said, I'm trying to get a feel for the limitations, and ran into one that just doesn't seem right:
if I create a new java array of any type other than string, I can't assign values to it:
example using string:
import Java; object t=machine->find_class("java/lang/String"); object o=pkg["java/lang/reflect/Array"]->newInstance(t, 5); o[0]="foo"; o[1]="bar";
works just fine, but this example using integers doesnt:
import Java; object t=machine->find_class("java/lang/Integer"); object o=pkg["java/lang/reflect/Array"]->newInstance(t, 5); o[0]=12; o[1]=5;
incompatible types passed to method. jvm.c:3550: jvm.c:3550()->`[]=(0,1) /usr/local/pike/7.4.20/lib/modules/Java.pmod:301: Java.jarray()->`[]=(0,1) test.pike:7: test()->main()
Any ideas? I had been using java the manual way by manually connecting methods, and it worked fine using Array.set() (admittedly a different technique).
Thanks!
Bill
/ Brevbäraren