diff --git a/pmd/src/main/java/net/sourceforge/pmd/RuleSet.java b/pmd/src/main/java/net/sourceforge/pmd/RuleSet.java index 35a7487f5b..d02e7bb9d8 100644 --- a/pmd/src/main/java/net/sourceforge/pmd/RuleSet.java +++ b/pmd/src/main/java/net/sourceforge/pmd/RuleSet.java @@ -8,6 +8,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; import net.sourceforge.pmd.benchmark.Benchmark; import net.sourceforge.pmd.benchmark.Benchmarker; @@ -29,6 +31,8 @@ import net.sourceforge.pmd.util.filter.Filters; //FUTURE Implement Cloneable and clone() public class RuleSet { + private static final Logger LOG = Logger.getLogger(RuleSet.class.getName()); + private List rules = new ArrayList(); private String fileName; private String name = ""; @@ -207,12 +211,18 @@ public class RuleSet { public void apply(List acuList, RuleContext ctx) { long start = System.nanoTime(); for (Rule rule : rules) { - if (!rule.usesRuleChain() && applies(rule, ctx.getLanguageVersion())) { - rule.apply(acuList, ctx); - long end = System.nanoTime(); - Benchmarker.mark(Benchmark.Rule, rule.getName(), end - start, 1); - start = end; - } + try { + if (!rule.usesRuleChain() && applies(rule, ctx.getLanguageVersion())) { + rule.apply(acuList, ctx); + long end = System.nanoTime(); + Benchmarker.mark(Benchmark.Rule, rule.getName(), end - start, 1); + start = end; + } + } catch (ThreadDeath td) { + throw td; + } catch (Throwable t) { + LOG.log(Level.WARNING, "Exception applying rule " + rule.getName() + ", continuing with next rule", t); + } } } diff --git a/pmd/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/ClassTypeResolver.java b/pmd/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/ClassTypeResolver.java index c1d070cf01..36cc7003c3 100644 --- a/pmd/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/ClassTypeResolver.java +++ b/pmd/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/ClassTypeResolver.java @@ -150,9 +150,7 @@ public class ClassTypeResolver extends JavaParserVisitorAdapter { } } catch (ClassNotFoundException e) { LOG.log(Level.FINE, "Could not find class " + className + ", due to: " + e.getClass().getName() + ": " + e.getMessage()); - } catch (NoClassDefFoundError e) { - LOG.log(Level.WARNING, "Could not find class " + className + ", due to: " + e.getClass().getName() + ": " + e.getMessage()); - } catch (ClassFormatError e) { + } catch (LinkageError e) { LOG.log(Level.WARNING, "Could not find class " + className + ", due to: " + e.getClass().getName() + ": " + e.getMessage()); } finally { populateImports(node); @@ -636,9 +634,7 @@ public class ClassTypeResolver extends JavaParserVisitorAdapter { myType = pmdClassLoader.loadClass(qualifiedName); } catch (ClassNotFoundException e) { myType = processOnDemand(qualifiedName); - } catch (NoClassDefFoundError e) { - myType = processOnDemand(qualifiedName); - } catch (ClassFormatError e) { + } catch (LinkageError e) { myType = processOnDemand(qualifiedName); } }