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 a4a5452fc1..73aa1d4d32 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 @@ -1355,9 +1355,19 @@ public class ClassTypeResolver extends JavaParserVisitorAdapter { private Class processOnDemand(String qualifiedName) { for (String entry : importedOnDemand) { + String fullClassName = entry + "." + qualifiedName; try { - return pmdClassLoader.loadClass(entry + "." + qualifiedName); - } catch (Throwable e) { + return pmdClassLoader.loadClass(fullClassName); + } catch (ClassNotFoundException ignored) { + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "Tried to load class " + fullClassName + " from on demand import, " + + "which apparently doesn't exist.", ignored); + } + } catch (LinkageError ignored) { + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "Tried to load class " + fullClassName + " from on demand import, " + + "which apparently doesn't exist.", ignored); + } } } return null; diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java index a503b10ff5..d883eed39f 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java @@ -138,9 +138,9 @@ public abstract class RuleTst { report = processUsingStringReader(test, rule); res = report.size(); - } catch (Throwable t) { - t.printStackTrace(); - throw new RuntimeException('"' + test.getDescription() + "\" failed", t); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException('"' + test.getDescription() + "\" failed", e); } if (test.getNumberOfProblemsExpected() != res) { printReport(test, report); diff --git a/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/util/VelocityCharStream.java b/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/util/VelocityCharStream.java index 7e21bda02b..78a3e91fa3 100644 --- a/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/util/VelocityCharStream.java +++ b/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/util/VelocityCharStream.java @@ -113,37 +113,33 @@ public final class VelocityCharStream implements CharStream { int[] newbufline = new int[bufsize + nextBufExpand]; int[] newbufcolumn = new int[bufsize + nextBufExpand]; - try { - if (wrapAround) { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); - buffer = newbuffer; + if (wrapAround) { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); + buffer = newbuffer; - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); - bufline = newbufline; + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); + bufline = newbufline; - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); - bufcolumn = newbufcolumn; + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); + bufcolumn = newbufcolumn; - bufpos += bufsize - tokenBegin; - maxNextCharInd = bufpos; - } else { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - buffer = newbuffer; + bufpos += bufsize - tokenBegin; + maxNextCharInd = bufpos; + } else { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - bufline = newbufline; + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + bufline = newbufline; - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - bufcolumn = newbufcolumn; + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + bufcolumn = newbufcolumn; - bufpos -= tokenBegin; - maxNextCharInd = bufpos; - } - } catch (Throwable t) { - throw new Error(t.getMessage()); + bufpos -= tokenBegin; + maxNextCharInd = bufpos; } bufsize += nextBufExpand;