diff --git a/.pmd-ruleset.xml b/.pmd-ruleset.xml
new file mode 100644
index 00000000..bdb5cab1
--- /dev/null
+++ b/.pmd-ruleset.xml
@@ -0,0 +1,365 @@
+
+
+ Java PMD rules.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build.gradle b/build.gradle
index 7a788080..25143557 100644
--- a/build.gradle
+++ b/build.gradle
@@ -11,9 +11,8 @@ plugins {
// Error Prone linter
id("net.ltgt.errorprone").version("4.3.0") apply false
- // TODO: reinstate when all PMD warnings have been addressed.
- // // PMD linter
- // id("pmd")
+ // PMD linter
+ id("pmd")
// Checker Framework pluggable type-checking
id("org.checkerframework").version("0.6.60")
@@ -114,16 +113,17 @@ if (isJava21orHigher) {
}
}
-// TODO: reinstate when all PMD warnings have been addressed.
-// // PMD linter
-//
-// pmd {
-// toolVersion = "7.17.0"
-// ruleSetFiles =(files("${rootDir}/.pmd-ruleset.xml"))
-// consoleOutput = true
-// ignoreFailures = false
-// incrementalAnalysis = true
-// }
+
+// PMD linter
+
+pmd {
+ toolVersion = "7.17.0"
+ ruleSetFiles = files("${rootDir}/.pmd-ruleset.xml")
+ consoleOutput = true
+ ignoreFailures = false
+ incrementalAnalysis = true
+}
+pmdTest.enabled = false
// Checker Framework pluggable type-checking
diff --git a/gradle/mavencentral.gradle b/gradle/mavencentral.gradle
index 7233c520..a53090ec 100644
--- a/gradle/mavencentral.gradle
+++ b/gradle/mavencentral.gradle
@@ -33,8 +33,9 @@ java {
withSourcesJar()
}
-artifacts {
- archives(javadocJar, sourcesJar)
+tasks.named("assemble") {
+ dependsOn(javadocJar)
+ dependsOn(sourcesJar)
}
publishing {
diff --git a/src/main/java/org/plumelib/reflection/ReflectionPlume.java b/src/main/java/org/plumelib/reflection/ReflectionPlume.java
index a22d737d..a7104d55 100644
--- a/src/main/java/org/plumelib/reflection/ReflectionPlume.java
+++ b/src/main/java/org/plumelib/reflection/ReflectionPlume.java
@@ -4,11 +4,13 @@
package org.plumelib.reflection;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
@@ -206,7 +208,7 @@ public Class> defineClassFromFile(@BinaryName String className, String pathnam
int numbytes;
byte[] classBytes;
int bytesRead;
- try (FileInputStream fi = new FileInputStream(pathname)) {
+ try (InputStream fi = Files.newInputStream(Path.of(pathname))) {
numbytes = fi.available();
classBytes = new byte[numbytes];
bytesRead = fi.read(classBytes);
@@ -309,7 +311,7 @@ public static String classpathToString() {
* @throws NoSuchMethodException if the method is not found
*/
public static Method methodForName(String method)
- throws ClassNotFoundException, NoSuchMethodException, SecurityException {
+ throws ClassNotFoundException, NoSuchMethodException {
int oparenpos = method.indexOf('(');
int dotpos = method.lastIndexOf('.', oparenpos);
@@ -374,7 +376,7 @@ public static Method methodForName(String method)
*/
public static Method methodForName(
@BinaryName String classname, String methodname, Class>[] params)
- throws ClassNotFoundException, NoSuchMethodException, SecurityException {
+ throws ClassNotFoundException, NoSuchMethodException {
Class> c = Class.forName(classname);
Method m = c.getDeclaredMethod(methodname, params);
diff --git a/src/main/java/org/plumelib/reflection/SignatureRegexes.java b/src/main/java/org/plumelib/reflection/SignatureRegexes.java
index c6939e60..c54112e0 100644
--- a/src/main/java/org/plumelib/reflection/SignatureRegexes.java
+++ b/src/main/java/org/plumelib/reflection/SignatureRegexes.java
@@ -9,7 +9,7 @@
* This class defines regular expressions for types supported by the Signature String Checker.
*/
-public class SignatureRegexes {
+public final class SignatureRegexes {
/** Do not instantiate this class. */
private SignatureRegexes() {