• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reflection API's behaving different on AIX  RSS feed

 
Chinmay Bajikar
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have my code running on AIX and it uses Reflection API's.
I use Class.getFields() and the Field[] that I get from doing that is from the last field to the first.The Field[] that I get when I run the same code on Windows is from the first to the last field.

ex:
class SampleObject
{
public String member1;
public String member2;
public String member3;
}

On AIX,the Field[] is {member3,member2,member1}
On windows,the Field[] is {member1,member2,member3}

This causes a lot of probs with the initialization of objects on AIX.

Anybdy who has faced the same prob?
Any solutions or any justification on why AIX JRE behaves in that way?

Thanks,
Chinmay.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The official Javadocs say:


The elements in the array returned are not sorted and are not in any particular order.


There's your answer right there: your code is not supposed to depend on tjhe fields being in any particular order.
 
Chinmay Bajikar
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!