<taskdef name="forbiddenapis"
classname="de.thetaphi.forbiddenapis.ant.AntTask"
classpath="${forbidden.jar}"/>
+
+ <!-- first check rules that apply to all the source code -->
<forbiddenapis
internalRuntimeForbidden="true"
classpathref="forbiddenapis.classpath"
<fileset dir="${excelant.output.test.dir}"/>
-->
</forbiddenapis>
+
+ <!-- then check some advanced rules which we only apply to the core code and not tests or examples -->
+ <forbiddenapis
+ internalRuntimeForbidden="true"
+ classpathref="forbiddenapis.classpath"
+ suppressAnnotation="org.apache.poi.util.SuppressForbidden"
+ >
+ <signaturesFileset file="src/resources/devtools/forbidden-signatures-prod.txt"/>
+ <!-- sources -->
+ <fileset dir="${main.output.dir}"/>
+ <fileset dir="${ooxml.output.dir}"/>
+ <fileset dir="${scratchpad.output.dir}"/>
+ <fileset dir="${excelant.output.dir}"/>
+ </forbiddenapis>
</target>
<target name="findbugs">
--- /dev/null
+# (C) Copyright Uwe Schindler (Generics Policeman) and others.
+# Parts of this work are licensed to the Apache Software Foundation (ASF)
+# under one or more contributor license agreements.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# This file contains API signatures which are specific to POI.
+# The goal is to minimize implicit defaults
+
+@defaultMessage POI forbidden APIs which are tolerated in non-production code, e.g. in tests and examples
+
+# We have applications which use this to return error codes on invalid commandline parameters...
+#@defaultMessage Please do not terminate the application
+#java.lang.System#exit(int)
+#java.lang.Runtime#exit(int)
+#java.lang.Runtime#halt(int)
+
+@defaultMessage Please do not try to stop the world
+java.lang.System#gc()
\r
java.text.DecimalFormatSymbols#DecimalFormatSymbols() @ use DecimalFormatSymbols.getInstance()\r
java.text.DecimalFormatSymbols#DecimalFormatSymbols(Locale) @ use DecimalFormatSymbols.getInstance()\r
+\r
+# the following are taken from the Elasticsearch source at https://github.com/elastic/elasticsearch/tree/master/buildSrc/src/main/resources/forbidden\r
+\r
+@defaultMessage Convert to URI\r
+java.net.URL#getPath()\r
+java.net.URL#getFile()\r
+\r
+@defaultMessage Usage of getLocalHost is discouraged\r
+java.net.InetAddress#getLocalHost()\r
+\r
+@defaultMessage Specify a location for the temp file/directory instead.\r
+java.nio.file.Files#createTempDirectory(java.lang.String,java.nio.file.attribute.FileAttribute[])\r
+java.nio.file.Files#createTempFile(java.lang.String,java.lang.String,java.nio.file.attribute.FileAttribute[])\r
+\r
+@defaultMessage Specify a location for the temp file/directory instead.\r
+java.nio.file.Files#createTempDirectory(java.lang.String,java.nio.file.attribute.FileAttribute[])\r
+java.nio.file.Files#createTempFile(java.lang.String,java.lang.String,java.nio.file.attribute.FileAttribute[])\r
+\r
+@defaultMessage Don't use java serialization - this can break BWC without noticing it\r
+java.io.ObjectOutputStream\r
+java.io.ObjectOutput\r
+java.io.ObjectInputStream\r
+java.io.ObjectInput\r
+\r
+@defaultMessage Resolve hosts explicitly to the address(es) you want with InetAddress.\r
+java.net.InetSocketAddress#<init>(java.lang.String,int)\r
+java.net.Socket#<init>(java.lang.String,int)\r
+java.net.Socket#<init>(java.lang.String,int,java.net.InetAddress,int)\r
+\r
+@defaultMessage Don't bind to wildcard addresses. Be specific.\r
+java.net.DatagramSocket#<init>()\r
+java.net.DatagramSocket#<init>(int)\r
+java.net.InetSocketAddress#<init>(int)\r
+java.net.MulticastSocket#<init>()\r
+java.net.MulticastSocket#<init>(int)\r
+java.net.ServerSocket#<init>(int)\r
+java.net.ServerSocket#<init>(int,int)\r
+\r
+@defaultMessage use NetworkAddress format/formatAddress to print IP or IP+ports\r
+java.net.InetAddress#toString()\r
+java.net.InetAddress#getHostAddress()\r
+java.net.Inet4Address#getHostAddress()\r
+java.net.Inet6Address#getHostAddress()\r
+java.net.InetSocketAddress#toString()\r
+\r
+@defaultMessage avoid DNS lookups by accident: if you have a valid reason, then @SuppressWarnings with that reason so its completely clear\r
+java.net.InetAddress#getHostName()\r
+java.net.InetAddress#getCanonicalHostName()\r
+\r
+java.net.InetSocketAddress#getHostName() @ Use getHostString() instead, which avoids a DNS lookup\r
+\r
+@defaultMessage this method needs special permission\r
+java.lang.Thread#getAllStackTraces()\r
+\r
+@defaultMessage Avoid unchecked warnings by using Collections#empty(List|Map|Set) methods\r
+java.util.Collections#EMPTY_LIST\r
+java.util.Collections#EMPTY_MAP\r
+java.util.Collections#EMPTY_SET\r
+\r
+\r
+@defaultMessage spawns threads with vague names; use a custom thread factory and name threads so that you can tell (by its name) which executor it is associated with\r
+java.util.concurrent.Executors#newFixedThreadPool(int)\r
+java.util.concurrent.Executors#newSingleThreadExecutor()\r
+java.util.concurrent.Executors#newCachedThreadPool()\r
+java.util.concurrent.Executors#newSingleThreadScheduledExecutor()\r
+java.util.concurrent.Executors#newScheduledThreadPool(int)\r
+java.util.concurrent.Executors#defaultThreadFactory()\r
+java.util.concurrent.Executors#privilegedThreadFactory()\r
+\r
+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\r
+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\r
+\r
+@defaultMessage Only use wait / notify when really needed try to use concurrency primitives, latches or callbacks instead.\r
+java.lang.Object#wait()\r
+java.lang.Object#wait(long)\r
+java.lang.Object#wait(long,int)\r
+java.lang.Object#notify()\r
+java.lang.Object#notifyAll()\r
+\r
+@defaultMessage Don't interrupt threads use FutureUtils#cancel(Future<T>) instead\r
+java.util.concurrent.Future#cancel(boolean)\r