This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

CNI array syntax


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 ]



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]