diff --git a/config/forbidden-apis/signatures.txt b/config/forbidden-apis/signatures.txt new file mode 100644 index 0000000000..ca9c9c62f4 --- /dev/null +++ b/config/forbidden-apis/signatures.txt @@ -0,0 +1,71 @@ +@defaultMessage Use a custom thread factory to ensure proper thread naming. +java.util.concurrent.Executors#defaultThreadFactory() +java.util.concurrent.Executors#newCachedThreadPool() +java.util.concurrent.Executors#newFixedThreadPool(int) +java.util.concurrent.Executors#newScheduledThreadPool(int) +java.util.concurrent.Executors#newSingleThreadExecutor() +java.util.concurrent.Executors#newSingleThreadScheduledExecutor() +java.util.concurrent.Executors#privilegedThreadFactory() + +@defaultMessage Do not create a DateTime without an explicit time zone. +org.joda.time.DateTime#() +org.joda.time.DateTime#(long) +org.joda.time.DateTime#(int, int, int, int, int) +org.joda.time.DateTime#(int, int, int, int, int, int) +org.joda.time.DateTime#(int, int, int, int, int, int, int) +org.joda.time.DateTime#now() + +@defaultMessage Please do not try to stop the world +java.lang.System#gc() + +java.lang.Character#codePointBefore(char[],int) @ Implicit start offset is error-prone when the char[] is a buffer and the first chars are random chars +java.lang.Character#codePointAt(char[],int) @ Implicit end offset is error-prone when the char[] is a buffer and the last chars are random chars + +@defaultMessage Only use wait / notify when really needed try to use concurrency primitives, latches or callbacks instead. +java.lang.Object#wait() +java.lang.Object#wait(long) +java.lang.Object#wait(long,int) +java.lang.Object#notify() +java.lang.Object#notifyAll() + +@defaultMessage Beware of the behavior of this method on MIN_VALUE +java.lang.Math#abs(int) +java.lang.Math#abs(long) + +@defaultMessage Use Channels.* methods to write to channels. Do not write directly. +java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer) +java.nio.channels.FileChannel#write(java.nio.ByteBuffer, long) +java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[], int, int) +java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[]) +java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer) +java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[]) +java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[], int, int) +java.nio.channels.FileChannel#read(java.nio.ByteBuffer, long) + +@defaultMessage Convert to URI +java.net.URL#getPath() +java.net.URL#getFile() + +@defaultMessage Use java.nio.file instead of java.io.File API +java.util.jar.JarFile +java.util.zip.ZipFile +java.io.File +java.io.FileInputStream +java.io.FileOutputStream +java.io.PrintStream#(java.lang.String,java.lang.String) +java.io.PrintWriter#(java.lang.String,java.lang.String) +java.util.Formatter#(java.lang.String,java.lang.String,java.util.Locale) +java.io.RandomAccessFile +java.nio.file.Path#toFile() + +@defaultMessage Specify a location for the temp file/directory instead. +java.nio.file.Files#createTempDirectory(java.lang.String,java.nio.file.attribute.FileAttribute[]) +java.nio.file.Files#createTempFile(java.lang.String,java.lang.String,java.nio.file.attribute.FileAttribute[]) + +com.google.common.collect.Iterators#emptyIterator() @ Use Collections.emptyIterator instead + +@defaultMessage Don't use java serialization - this can break BWC without noticing it +java.io.ObjectOutputStream +java.io.ObjectOutput +java.io.ObjectInputStream +java.io.ObjectInput \ No newline at end of file diff --git a/pom.xml b/pom.xml index d2000697af..cce17f29c3 100644 --- a/pom.xml +++ b/pom.xml @@ -961,6 +961,11 @@ maven-site-plugin 3.4 + + de.thetaphi + forbiddenapis + 2.0 + @@ -1222,6 +1227,35 @@ org.codehaus.mojo cobertura-maven-plugin + + de.thetaphi + forbiddenapis + + + true + + false + false + + + jdk-unsafe + jdk-deprecated + jdk-system-out + + + ${project.basedir}/../config/forbidden-apis/signatures.txt + + + + + compile + + check + testCheck + + + +