diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/ClassTypeResolver.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/ClassTypeResolver.java index 8b63821bd7..6ffe9310df 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/ClassTypeResolver.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/ClassTypeResolver.java @@ -333,7 +333,12 @@ public class ClassTypeResolver extends JavaParserVisitorAdapter { if (isMemberVisibleFromClass(typeToSearch.getType(), field.getModifiers(), accessingClass)) { return typeToSearch.resolveTypeDefinition(field.getGenericType()); } - } catch (NoSuchFieldException e) { /* swallow */ } + } catch (final NoSuchFieldException ignored) { + // swallow + } catch (final NoClassDefFoundError e) { + // TODO : report a missing class once we start doing that... + return null; + } // transform the type into it's supertype typeToSearch = typeToSearch.resolveTypeDefinition(typeToSearch.getType().getGenericSuperclass()); diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverTest.java index effb9d7a29..a649724400 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverTest.java @@ -5,6 +5,7 @@ package net.sourceforge.pmd.typeresolution; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame;