On Jan 10, 2008, at 11:30 AM, Paul Loy wrote:
Hi All,
I am trying to create a Variable length Structure, where the
variability is the length of an array of Structures inside the
Variable length Structure. (please see attached unit tests)
I get a NPE in Structure.getNativeSize(Class, Object) due to the fact
that in Structure.getNativeAlignment(Class, Object, boolean), when it
finds an Array it sends null as value back into itself:
...
else if (type.isArray()) {
alignment = getNativeAlignment(type.getComponentType(), null,
firstElement);
}
...
I guess this is a bug?
Your description doesn't match up against your test. An inner array
of fixed-size structures must be initialized before
Structure.allocateMemory/calculateSize is called; are you using the
latest SVN sources?
Note that the inner, fixed-size structure must have a public no-arg
constructor, and that Structure.size() must return a valid value
after the object is created.
When I run your test, the explicit "fail" is invoked on the last two
test methods, so perhaps we're using different codebases.
(BTW, I'll be posting an "official" 3.0 release sometime this week)
T.