use of com.ibm.j9ddr.GeneratedFieldAccessor in project openj9 by eclipse-openj9.
the class StructurePointer method getStructureFields.
public StructureField[] getStructureFields() {
List<StructureField> fields = new LinkedList<StructureField>();
Class<?> working = this.getClass();
while (working != null) {
GeneratedPointerClass classAnnotation = working.getAnnotation(GeneratedPointerClass.class);
if (null == classAnnotation) {
break;
}
for (Method thisMethod : working.getMethods()) {
if (thisMethod.isAnnotationPresent(GeneratedFieldAccessor.class)) {
GeneratedFieldAccessor fieldAnnotation = thisMethod.getAnnotation(GeneratedFieldAccessor.class);
Field offsetField = null;
try {
offsetField = classAnnotation.structureClass().getField(fieldAnnotation.offsetFieldName());
} catch (SecurityException e) {
throw new Error("Unexpected security exception", e);
} catch (NoSuchFieldException e) {
// This will happen if we reach for a field that doesn't exist on this level
continue;
}
int offset = -1;
try {
offset = offsetField.getInt(null);
} catch (Exception e) {
throw new Error(e);
}
DataType result = null;
CorruptDataException cde = null;
try {
result = (DataType) thisMethod.invoke(this);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof CorruptDataException) {
cde = (CorruptDataException) cause;
} else {
throw new RuntimeException(e);
}
}
fields.add(new StructureField(thisMethod.getName(), fieldAnnotation.declaredType(), offset, result, cde));
}
}
working = working.getSuperclass();
}
Collections.sort(fields);
StructureField[] result = new StructureField[fields.size()];
fields.toArray(result);
return result;
}
use of com.ibm.j9ddr.GeneratedFieldAccessor in project openj9 by eclipse.
the class StructurePointer method getStructureFields.
public StructureField[] getStructureFields() {
List<StructureField> fields = new LinkedList<StructureField>();
Class<?> working = this.getClass();
while (working != null) {
GeneratedPointerClass classAnnotation = working.getAnnotation(GeneratedPointerClass.class);
if (null == classAnnotation) {
break;
}
for (Method thisMethod : working.getMethods()) {
if (thisMethod.isAnnotationPresent(GeneratedFieldAccessor.class)) {
GeneratedFieldAccessor fieldAnnotation = thisMethod.getAnnotation(GeneratedFieldAccessor.class);
Field offsetField = null;
try {
offsetField = classAnnotation.structureClass().getField(fieldAnnotation.offsetFieldName());
} catch (SecurityException e) {
throw new Error("Unexpected security exception", e);
} catch (NoSuchFieldException e) {
// This will happen if we reach for a field that doesn't exist on this level
continue;
}
int offset = -1;
try {
offset = offsetField.getInt(null);
} catch (Exception e) {
throw new Error(e);
}
DataType result = null;
CorruptDataException cde = null;
try {
result = (DataType) thisMethod.invoke(this);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof CorruptDataException) {
cde = (CorruptDataException) cause;
} else {
throw new RuntimeException(e);
}
}
fields.add(new StructureField(thisMethod.getName(), fieldAnnotation.declaredType(), offset, result, cde));
}
}
working = working.getSuperclass();
}
Collections.sort(fields);
StructureField[] result = new StructureField[fields.size()];
fields.toArray(result);
return result;
}
Aggregations