Skip to content

Commit 5a225ef

Browse files
committed
fix(generator-accessor-runtime): always walk inheritance tree when searching for members
1 parent 20e591d commit 5a225ef

File tree

2 files changed

+19
-25
lines changed

2 files changed

+19
-25
lines changed

generator/accessor-runtime/src/main/java/me/kcra/takenaka/accessor/mapping/FieldMapping.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,19 +216,16 @@ public FieldMapping(
216216
return null;
217217
}
218218

219-
try {
220-
return clazz.getField(name);
221-
} catch (NoSuchFieldException ignored) {
222-
do {
223-
try {
224-
final Field field = clazz.getDeclaredField(name);
225-
field.setAccessible(true);
226-
227-
return field;
228-
} catch (NoSuchFieldException ignored2) {
229-
}
230-
} while ((clazz = clazz.getSuperclass()) != null && clazz != Object.class);
231-
}
219+
do {
220+
try {
221+
final Field field = clazz.getDeclaredField(name);
222+
field.setAccessible(true);
223+
224+
return field;
225+
} catch (NoSuchFieldException ignored) {
226+
}
227+
} while ((clazz = clazz.getSuperclass()) != null && clazz != Object.class);
228+
232229
return null;
233230
}
234231

generator/accessor-runtime/src/main/java/me/kcra/takenaka/accessor/mapping/MethodMapping.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,19 +245,16 @@ public MethodMapping(
245245
paramClasses[i] = paramClass;
246246
}
247247

248-
try {
249-
return clazz.getMethod(namePair.getName(), paramClasses);
250-
} catch (NoSuchMethodException ignored) {
251-
do {
252-
try {
253-
final Method method = clazz.getDeclaredMethod(namePair.getName(), paramClasses);
254-
method.setAccessible(true);
248+
do {
249+
try {
250+
final Method method = clazz.getDeclaredMethod(namePair.getName(), paramClasses);
251+
method.setAccessible(true);
252+
253+
return method;
254+
} catch (NoSuchMethodException ignored) {
255+
}
256+
} while ((clazz = clazz.getSuperclass()) != null && clazz != Object.class);
255257

256-
return method;
257-
} catch (NoSuchMethodException ignored2) {
258-
}
259-
} while ((clazz = clazz.getSuperclass()) != null && clazz != Object.class);
260-
}
261258
return null;
262259
}
263260

0 commit comments

Comments
 (0)