comparison graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java @ 15839:2838203d4231

Add method ResolvedJavaType.getStaticFields
author Christian Wimmer <christian.wimmer@oracle.com>
date Tue, 20 May 2014 19:06:41 -0700
parents 920b7bb058a6
children 8fde32ece68e
comparison
equal deleted inserted replaced
15838:15771ff797b4 15839:2838203d4231
605 return Arrays.copyOfRange(instanceFields, myFieldsStart, instanceFields.length); 605 return Arrays.copyOfRange(instanceFields, myFieldsStart, instanceFields.length);
606 } 606 }
607 return instanceFields; 607 return instanceFields;
608 } 608 }
609 609
610 @Override
611 public ResolvedJavaField[] getStaticFields() {
612 if (isArray()) {
613 return new HotSpotResolvedJavaField[0];
614 } else {
615 final int fieldCount = getFieldCount();
616 ArrayList<HotSpotResolvedJavaField> fieldsArray = new ArrayList<>(fieldCount);
617
618 for (int i = 0; i < fieldCount; i++) {
619 FieldInfo field = new FieldInfo(i);
620
621 // We are only interested in static fields.
622 if (field.isStatic()) {
623 HotSpotResolvedJavaField resolvedJavaField = createField(field.getName(), field.getType(), field.getOffset(), field.getAccessFlags());
624 fieldsArray.add(resolvedJavaField);
625 }
626 }
627
628 fieldsArray.sort(new OffsetComparator());
629 return fieldsArray.toArray(new HotSpotResolvedJavaField[fieldsArray.size()]);
630 }
631 }
632
610 /** 633 /**
611 * Returns the actual field count of this class's internal {@code InstanceKlass::_fields} array 634 * Returns the actual field count of this class's internal {@code InstanceKlass::_fields} array
612 * by walking the array and discounting the generic signature slots at the end of the array. 635 * by walking the array and discounting the generic signature slots at the end of the array.
613 * 636 *
614 * <p> 637 * <p>