Category: Proxy usage

Q

What else should I know about array types?

A

Array types are the types with the biggest differences to expected behavior. This is mostly due to the fact that both .NET and Java have their own array types that are not terribly accessible to outsiders.

Java arrays have some interesting type compatibility characteristics, expressible as is a relationships:

  • String[] is an Object[]
  • String[][] is an Object[][]
  • String[][] is an Object[]

The whole point of arrays is of course to hold an ordered sequence of elements, often many elements. While you can access proxy array elements one by one through convenient subscript operators, that's not always the most efficient way to do so. Even in pure .NET, you sometimes optimize array initialization by block-copying data directly into the array's memory range. Imagine how much more effective this optimization is if every array element access has a measurable cost (due of the JNI overhead). Therefore, if you perform an activity with every member of a large array, you might be better off copying all members into a native array using a block accessor and then operating on the elements there.


Copyright 2006-2011 by Codemesh, Inc., ALL RIGHTS RESERVED

:
frequently asked questions
home products support customers partners newsroom about us contact us