diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2003-12-20 23:43:39 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2003-12-20 23:43:39 +0000 |
commit | 1a1b9d2feccc15e1bd1a26ff7a7709630d478fe8 (patch) | |
tree | bb44f7e1845acf7976503f3cd0f25f17ea476f37 /src/main/javassist/CtClassType.java | |
parent | 8e20f83d119aef0c906488cd87c7f665fbc3daf6 (diff) | |
download | javassist-1a1b9d2feccc15e1bd1a26ff7a7709630d478fe8.tar.gz javassist-1a1b9d2feccc15e1bd1a26ff7a7709630d478fe8.zip |
Fixed a bug of the token analyzer (double constant).
Improved compilation speed.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@58 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/CtClassType.java')
-rw-r--r-- | src/main/javassist/CtClassType.java | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/main/javassist/CtClassType.java b/src/main/javassist/CtClassType.java index de1b2f19..943f9ea9 100644 --- a/src/main/javassist/CtClassType.java +++ b/src/main/javassist/CtClassType.java @@ -331,30 +331,33 @@ class CtClassType extends CtClass { } public CtField getField(String name) throws NotFoundException { - try { - return getDeclaredField(name); - } - catch (NotFoundException e) {} + CtField f = getField2(name); + if (f == null) + throw new NotFoundException("field: " + name + " in " + getName()); + else + return f; + } + + CtField getField2(String name) { + CtField df = getDeclaredField2(name); + if (df != null) + return df; try { CtClass[] ifs = getInterfaces(); int num = ifs.length; - for (int i = 0; i < num; ++i) - try { - return ifs[i].getField(name); - } - catch (NotFoundException e) {} - } - catch (NotFoundException e) {} + for (int i = 0; i < num; ++i) { + CtField f = ifs[i].getField2(name); + if (f != null) + return f; + } - try { CtClass s = getSuperclass(); if (s != null) - return s.getField(name); + return s.getField2(name); } catch (NotFoundException e) {} - - throw new NotFoundException(name); + return null; } public CtField[] getDeclaredFields() { @@ -385,6 +388,14 @@ class CtClassType extends CtClass { } public CtField getDeclaredField(String name) throws NotFoundException { + CtField f = getDeclaredField2(name); + if (f == null) + throw new NotFoundException("field: " + name + " in " + getName()); + else + return f; + } + + private CtField getDeclaredField2(String name) { CtField cf = getFieldsCache(); while (cf != null) { if (cf.getName().equals(name)) @@ -393,7 +404,7 @@ class CtClassType extends CtClass { cf = cf.next; } - throw new NotFoundException(name); + return null; } public CtBehavior[] getDeclaredBehaviors() { |