RFR: make FieldLayout#data() public
Aleksey Shipilev
shade at openjdk.java.net
Fri Nov 19 12:01:57 UTC 2021
On Wed, 10 Nov 2021 08:26:28 GMT, Ivan Ponomarev <duke at openjdk.java.net> wrote:
> > Can you pseudo-code or point the usage example?
>
> ```
> for (FieldLayout fieldLayout : ClassLayout.parseClass(obj.getClass()).fields()) {
> Field f = fieldLayout.data().refField();
>
> Object v = ObjectUtils.value(obj, f); //primitives are wrapped, type information lost!
>
> //We need everything that can be extracted from Field...
> refField.getAnnotations()... //e.g. paint the field a specific color
> refField.getGenericType()... //e.g. label the field with type information
>
> if (refField.getType() is primitive or can be treated as primitive per LJV setup){
> //treat the value as primitive...
>
> } else {
> //walk further the object's graph...
> }
> }
> ```
It looks to me that this code tries to do the iteration that `GraphLayout.parseInstance` already does. Maybe you just want to extend `GraphWalker` to get this walk?
-------------
PR: https://git.openjdk.java.net/jol/pull/19
More information about the jol-dev
mailing list