Whoops, we want declared fields for generating the constants but all fields for
determining the public key. As always, the plot is thicker.
This commit is contained in:
@@ -146,30 +146,29 @@ public class GenRecordTask extends Task
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine which fields we need to deal with and those that make up our primary key
|
// determine which fields make up our primary key; we'd just use Class.getFields() but that
|
||||||
List<Field> flist = new ArrayList<Field>(), kflist = new ArrayList<Field>();
|
// returns things in a random order whereas ClassUtil returns fields in declaration order
|
||||||
// we'd just use Class.getFields() but that returns things in a random order whereas
|
// starting from the top-most class and going down the line
|
||||||
// ClassUtil returns fields in declaration order starting from the top-most class with
|
List<Field> kflist = new ArrayList<Field>();
|
||||||
// derived class fields showing up after super class fields
|
FIELD_LOOP:
|
||||||
Field[] fields = ClassUtil.getFields(oclass);
|
for (Field field : ClassUtil.getFields(oclass)) {
|
||||||
for (int ii = 0; ii < fields.length; ii++) {
|
// iterate becase getAnnotation() fails if we're dealing with multiple classloaders
|
||||||
Field f = fields[ii];
|
for (Annotation a : field.getAnnotations()) {
|
||||||
int mods = f.getModifiers();
|
if (Id.class.getName().equals(a.annotationType().getName())) {
|
||||||
|
kflist.add(field);
|
||||||
|
continue FIELD_LOOP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine which fields we need to generate constants for
|
||||||
|
List<Field> flist = new ArrayList<Field>();
|
||||||
|
for (Field field : oclass.getDeclaredFields()) {
|
||||||
|
int mods = field.getModifiers();
|
||||||
if (!Modifier.isPublic(mods) || Modifier.isStatic(mods) || Modifier.isTransient(mods)) {
|
if (!Modifier.isPublic(mods) || Modifier.isStatic(mods) || Modifier.isTransient(mods)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean found = false;
|
flist.add(field);
|
||||||
// iterate becase getAnnotation() fails if we're dealing with multiple classloaders
|
|
||||||
for (Annotation a : f.getAnnotations()) {
|
|
||||||
if (Id.class.getName().equals(a.annotationType().getName())) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found) {
|
|
||||||
kflist.add(f);
|
|
||||||
}
|
|
||||||
flist.add(f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// slurp our source file into newline separated strings
|
// slurp our source file into newline separated strings
|
||||||
|
|||||||
Reference in New Issue
Block a user