From b4051ef67e56d2ba2ce39660f1128c5079fec777 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Thu, 19 Apr 2007 21:25:45 +0000 Subject: [PATCH] Whoops, we want declared fields for generating the constants but all fields for determining the public key. As always, the plot is thicker. --- .../jdbc/depot/tools/GenRecordTask.java | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/tools/GenRecordTask.java b/src/java/com/samskivert/jdbc/depot/tools/GenRecordTask.java index 6973281..352d38c 100644 --- a/src/java/com/samskivert/jdbc/depot/tools/GenRecordTask.java +++ b/src/java/com/samskivert/jdbc/depot/tools/GenRecordTask.java @@ -146,30 +146,29 @@ public class GenRecordTask extends Task return; } - // determine which fields we need to deal with and those that make up our primary key - List flist = new ArrayList(), kflist = new ArrayList(); - // we'd just use Class.getFields() but that returns things in a random order whereas - // ClassUtil returns fields in declaration order starting from the top-most class with - // derived class fields showing up after super class fields - Field[] fields = ClassUtil.getFields(oclass); - for (int ii = 0; ii < fields.length; ii++) { - Field f = fields[ii]; - int mods = f.getModifiers(); + // determine which fields make up our primary key; we'd just use Class.getFields() but that + // returns things in a random order whereas ClassUtil returns fields in declaration order + // starting from the top-most class and going down the line + List kflist = new ArrayList(); + FIELD_LOOP: + for (Field field : ClassUtil.getFields(oclass)) { + // iterate becase getAnnotation() fails if we're dealing with multiple classloaders + for (Annotation a : field.getAnnotations()) { + if (Id.class.getName().equals(a.annotationType().getName())) { + kflist.add(field); + continue FIELD_LOOP; + } + } + } + + // determine which fields we need to generate constants for + List flist = new ArrayList(); + for (Field field : oclass.getDeclaredFields()) { + int mods = field.getModifiers(); if (!Modifier.isPublic(mods) || Modifier.isStatic(mods) || Modifier.isTransient(mods)) { continue; } - boolean found = false; - // 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); + flist.add(field); } // slurp our source file into newline separated strings