Skip to content

Commit 2d07c2e

Browse files
authored
Merge pull request #320 from kephale/fix-getfield
Fix behavior of ClassUtils.getField
2 parents ccfb5c4 + d10f86f commit 2d07c2e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/org/scijava/util/ClassUtils.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,13 +627,21 @@ public static Type getGenericType(final Field field, final Class<?> type) {
627627
/** @deprecated Use {@link Types#field} instead. */
628628
@Deprecated
629629
public static Field getField(final String className, final String fieldName) {
630-
return Types.field(Types.load(className), fieldName);
630+
try {
631+
return Types.field(Types.load(className), fieldName);
632+
} catch (final IllegalArgumentException e) {
633+
return null;
634+
}
631635
}
632636

633637
/** @deprecated Use {@link Types#field} instead. */
634638
@Deprecated
635639
public static Field getField(final Class<?> c, final String fieldName) {
636-
return Types.field(c, fieldName);
640+
try {
641+
return Types.field(c, fieldName);
642+
} catch (final IllegalArgumentException e) {
643+
return null;
644+
}
637645
}
638646

639647
/** @deprecated Use {@link Types#array(Class)} instead. */

0 commit comments

Comments
 (0)