This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
CNI array syntax
- To: java at gcc dot gnu dot org
- Subject: CNI array syntax
- From: Bryce McKinlay <bryce at albatross dot co dot nz>
- Date: Thu, 29 Mar 2001 17:31:56 +1200
Has a more natural syntax for creating java arrays from CNI ever been
considered?
Today I wanted to do the equivilant of "new java.io.File[1]" in C++.
The code for this (afaik) is quite ugly:
myfile = reinterpret_cast <JArray< ::java::io::File *>*>
(JvNewObjectArray (1, &java::io::File::class$, f));
But it should be able to be much more cleanly expressed as:
myfile = new JArray<java::io::File *> (1);
After a quick look it seems like some hacking of the
TYPE_FOR_JAVA logic in the C++ compiler would be required, as well as
adding special recognition for JArray types to C++'s "new" code and
calling _Jv_NewObjectArray instead of _Jv_AllocObject. I don't see
anything that would make this particularly difficult though. Just a
thought.
regards
[ bryce ]