├── .github └── workflows │ └── ant.yml ├── .gitignore ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── build.xml ├── bundled-licenses ├── asm-LICENSE-BSD_LIKE.txt ├── commons-cli-LICENSE-ASL.txt └── plexus-utils-LICENSE-ASL.txt ├── ivy-settings.xml ├── ivy.xml └── src ├── main ├── docs │ ├── ant-task.html │ ├── bundled-signatures.html │ ├── classic-stylesheet.css │ ├── docindex.xsl │ ├── signatures-syntax.html │ └── xdoc2html.xsl ├── groovy │ └── de │ │ └── thetaphi │ │ └── forbiddenapis │ │ └── gradle │ │ └── ForbiddenApisPlugin.groovy ├── java │ ├── de │ │ └── thetaphi │ │ │ └── forbiddenapis │ │ │ ├── AsmUtils.java │ │ │ ├── Checker.java │ │ │ ├── ClassMetadata.java │ │ │ ├── ClassPatternRule.java │ │ │ ├── ClassScanner.java │ │ │ ├── Constants.java │ │ │ ├── ForbiddenApiException.java │ │ │ ├── ForbiddenViolation.java │ │ │ ├── Logger.java │ │ │ ├── ParseException.java │ │ │ ├── RelatedClassLoadingException.java │ │ │ ├── RelatedClassLookup.java │ │ │ ├── Signatures.java │ │ │ ├── StdIoLogger.java │ │ │ ├── SuppressForbidden.java │ │ │ ├── ant │ │ │ ├── AntTask.java │ │ │ ├── BundledSignaturesType.java │ │ │ ├── SeverityOverrideType.java │ │ │ ├── SignaturesResources.java │ │ │ └── SuppressAnnotationType.java │ │ │ ├── cli │ │ │ ├── CliMain.java │ │ │ └── ExitException.java │ │ │ ├── gradle │ │ │ ├── CheckForbiddenApis.java │ │ │ ├── CheckForbiddenApisExtension.java │ │ │ └── ForbiddenApisPluginBase.java │ │ │ └── maven │ │ │ ├── AbstractCheckMojo.java │ │ │ ├── CheckMojo.java │ │ │ ├── SignaturesArtifact.java │ │ │ └── TestCheckMojo.java │ └── org │ │ └── gradle │ │ └── api │ │ └── tasks │ │ └── IgnoreEmptyDirectories.java ├── maven │ ├── pom-build.xml.template │ ├── pom-deploy.xml.template │ └── settings.xml.template └── resources │ ├── META-INF │ ├── gradle-plugins │ │ └── de.thetaphi.forbiddenapis.properties │ └── m2e │ │ └── lifecycle-mapping-metadata.xml │ └── de │ └── thetaphi │ └── forbiddenapis │ ├── antlib.xml │ └── signatures │ ├── commons-io-unsafe-1.0.txt │ ├── commons-io-unsafe-1.1.txt │ ├── commons-io-unsafe-1.2.txt │ ├── commons-io-unsafe-1.3.txt │ ├── commons-io-unsafe-1.4.txt │ ├── commons-io-unsafe-2.0.txt │ ├── commons-io-unsafe-2.1.txt │ ├── commons-io-unsafe-2.10.0.txt │ ├── commons-io-unsafe-2.11.0.txt │ ├── commons-io-unsafe-2.12.0.txt │ ├── commons-io-unsafe-2.13.0.txt │ ├── commons-io-unsafe-2.14.0.txt │ ├── commons-io-unsafe-2.15.0.txt │ ├── commons-io-unsafe-2.15.1.txt │ ├── commons-io-unsafe-2.16.0.txt │ ├── commons-io-unsafe-2.16.1.txt │ ├── commons-io-unsafe-2.17.0.txt │ ├── commons-io-unsafe-2.18.0.txt │ ├── commons-io-unsafe-2.2.txt │ ├── commons-io-unsafe-2.3.txt │ ├── commons-io-unsafe-2.4.txt │ ├── commons-io-unsafe-2.5.txt │ ├── commons-io-unsafe-2.6.txt │ ├── commons-io-unsafe-2.7.txt │ ├── commons-io-unsafe-2.8.0.txt │ ├── commons-io-unsafe-2.9.0.txt │ ├── incr-jdk-unsafe-11-till-20.txt │ ├── incr-jdk-unsafe-12.txt │ ├── incr-jdk-unsafe-15.txt │ ├── jdk-deprecated-1.7.txt │ ├── jdk-deprecated-1.8.txt │ ├── jdk-deprecated-10.txt │ ├── jdk-deprecated-11.txt │ ├── jdk-deprecated-12.txt │ ├── jdk-deprecated-13.txt │ ├── jdk-deprecated-14.txt │ ├── jdk-deprecated-15.txt │ ├── jdk-deprecated-16.txt │ ├── jdk-deprecated-17.txt │ ├── jdk-deprecated-18.txt │ ├── jdk-deprecated-19.txt │ ├── jdk-deprecated-20.txt │ ├── jdk-deprecated-21.txt │ ├── jdk-deprecated-22.txt │ ├── jdk-deprecated-23.txt │ ├── jdk-deprecated-24.txt │ ├── jdk-deprecated-9.txt │ ├── jdk-internal-1.7.txt │ ├── jdk-internal-1.8.txt │ ├── jdk-internal-10.txt │ ├── jdk-internal-11.txt │ ├── jdk-internal-12.txt │ ├── jdk-internal-13.txt │ ├── jdk-internal-14.txt │ ├── jdk-internal-15.txt │ ├── jdk-internal-16.txt │ ├── jdk-internal-17.txt │ ├── jdk-internal-18.txt │ ├── jdk-internal-19.txt │ ├── jdk-internal-20.txt │ ├── jdk-internal-21.txt │ ├── jdk-internal-22.txt │ ├── jdk-internal-23.txt │ ├── jdk-internal-24.txt │ ├── jdk-internal-9.txt │ ├── jdk-reflection.txt │ ├── jdk-system-out.txt │ ├── jdk-unsafe-1.7.txt │ ├── jdk-unsafe-1.8.txt │ ├── jdk-unsafe-10.txt │ ├── jdk-unsafe-11.txt │ ├── jdk-unsafe-12.txt │ ├── jdk-unsafe-13.txt │ ├── jdk-unsafe-14.txt │ ├── jdk-unsafe-15.txt │ ├── jdk-unsafe-16.txt │ ├── jdk-unsafe-17.txt │ ├── jdk-unsafe-18.txt │ ├── jdk-unsafe-19.txt │ ├── jdk-unsafe-20.txt │ ├── jdk-unsafe-21.txt │ ├── jdk-unsafe-22.txt │ ├── jdk-unsafe-23.txt │ ├── jdk-unsafe-24.txt │ └── jdk-unsafe-9.txt ├── test ├── antunit │ ├── Java7ClassReferences.class │ ├── Java7ClassReferences.java │ ├── Java7DeprecatedAnnotation.class │ ├── Java7DeprecatedAnnotation.java │ ├── Java7MethodHandles.class │ ├── Java7MethodHandles.java │ ├── Java7Reflection.class │ ├── Java7Reflection.java │ ├── Java7StaticVsVirtual$X.class │ ├── Java7StaticVsVirtual$Y.class │ ├── Java7StaticVsVirtual$Z.class │ ├── Java7StaticVsVirtual.class │ ├── Java7StaticVsVirtual.java │ ├── Java8Annotations$ClassFileOnly.class │ ├── Java8Annotations$FooBar.class │ ├── Java8Annotations$InnerClassWithCtorParam.class │ ├── Java8Annotations.class │ ├── Java8Annotations.java │ ├── Java8Closures.class │ ├── Java8Closures.java │ ├── OracleInternalRuntime.class │ ├── OracleInternalRuntime.java │ ├── TestAnnotations.xml │ ├── TestClassDeclaration.xml │ ├── TestClassLoader.xml │ ├── TestClassReferences.xml │ ├── TestCli.xml │ ├── TestCommonsIOSignatures.xml │ ├── TestFailOnViolation.xml │ ├── TestFileSignatures.xml │ ├── TestFinalJAR.xml │ ├── TestInlineSignatures.xml │ ├── TestInternalRuntimeCalls.xml │ ├── TestJava6Reflection.xml │ ├── TestJava7.xml │ ├── TestJava8.xml │ ├── TestMavenMojo.xml │ ├── TestSeverityOverrides.xml │ ├── TestStaticVsVirtual.xml │ ├── dummy.xml │ ├── pom-InclExclSuppress.xml │ ├── pom-generator.xsl │ ├── pom-sigArtifacts.xml │ └── signatures1.txt ├── gradle │ └── build.gradle └── java │ └── de │ └── thetaphi │ └── forbiddenapis │ ├── AsmUtilsTest.java │ ├── CheckerSetupTest.java │ └── SignaturesParserTest.java └── tools ├── gradle-plugin-portal ├── build.gradle.template └── settings.gradle.template ├── groovy ├── generate-deprecated-java7.groovy ├── generate-deprecated-java9.groovy └── generate-deprecated.groovy ├── java └── de │ └── thetaphi │ └── forbiddenapis │ ├── DeprecatedGen.java │ └── InternalApiGen.java └── signatures └── mysignatures.txt /.github/workflows/ant.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Ant 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-ant 3 | 4 | name: Java CI 5 | 6 | on: 7 | push: 8 | branches: [ "main" ] 9 | pull_request: 10 | branches: [ "main" ] 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v3 17 | - name: Set up JDK 8 18 | uses: actions/setup-java@v3 19 | with: 20 | java-version: '8' 21 | distribution: 'temurin' 22 | - name: Build and test with Ant 23 | run: ant -noinput -buildfile build.xml test -Dgradle.exe=gradle 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /build 3 | /.ivy 4 | *.iml 5 | *.classpath 6 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | "Policeman's Forbidden API Checker" 2 | Allows to parse Java byte code to find invocations of method/class/field 3 | signatures and fail build (Apache Ant, Apache Maven, Gradle, CLI) 4 | 5 | 6 | Copyright © Uwe Schindler (Generics Policeman) and others. 7 | Parts of this work are licensed to the Apache Software Foundation (ASF) 8 | under one or more contributor license agreements. 9 | 10 | This product was forked from the Apache Lucene Project and improved and 11 | extended by adding Apache Maven, Gradle, and CLI support. 12 | 13 | Apache Ant and Apache Maven are trademarks of The Apache Software Foundation. 14 | Gradle is an open source build system, developed under the Apache 2.0 15 | License. 16 | 17 | 18 | This product bundles software (jarjar'ed to new package name) developed by: 19 | 20 | * ASM - Lightweight Java Bytecode Manipulation Framework 21 | Copyright © 1999-2012, OW2 Consortium 22 | http://asm.ow2.org/ 23 | 24 | * Plexus-Utils - A collection of various utility classes 25 | to ease working with strings, files, command lines, XML and more. 26 | Copyright ©, The Codehaus Foundation & Apache Software Foundation 27 | http://plexus.codehaus.org/plexus-utils/ 28 | 29 | * Commons-CLI - The Apache Commons CLI library provides an API for 30 | parsing command line options passed to programs. It's also able to 31 | print help messages detailing the options available for a command 32 | line tool. 33 | Copyright © Apache Software Foundation 34 | http://commons.apache.org/cli/ 35 | 36 | (see the "bundled-licenses/" folder for full license information) 37 | 38 | 39 | The documentation package contains a CSS file "Classic Javadoc 40 | StyleSheet", developed by S.Ishigaki under the MIT License. 41 | http://junk-box.appspot.com/stylesheet/classic-javadoc-stylesheet/index.html 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Policeman's Forbidden API Checker # 2 | 3 | Allows to parse Java byte code to find invocations of method/class/field 4 | signatures and fail build (Apache Ant, Apache Maven, or Gradle). 5 | 6 | [![Maven Central](https://img.shields.io/maven-central/v/de.thetaphi/forbiddenapis.svg)](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22de.thetaphi%22%20AND%20a%3A%22forbiddenapis%22) 7 | [![Build Status](https://jenkins.thetaphi.de/job/Forbidden-APIs/badge/icon)](https://jenkins.thetaphi.de/job/Forbidden-APIs/) 8 | 9 | ## Documentation ## 10 | 11 | Please refer to the Github 12 | [Wiki & Documentation](https://github.com/policeman-tools/forbidden-apis/wiki). 13 | 14 | The checker is available as Apache Ant Task, Apache Maven Mojo, and Gradle plugin. 15 | In addition there is a command line tool (CLI): 16 | 17 | * [Apache Ant](https://github.com/policeman-tools/forbidden-apis/wiki/AntUsage) 18 | * [Apache Maven](https://github.com/policeman-tools/forbidden-apis/wiki/MavenUsage) 19 | * [Gradle](https://github.com/policeman-tools/forbidden-apis/wiki/GradleUsage) 20 | * [Command Line](https://github.com/policeman-tools/forbidden-apis/wiki/CliUsage) 21 | 22 | This project uses Apache Ant (and Apache Ivy) to build. The minimum 23 | Ant version is 1.8.0 and it is recommended to not have Apache Ivy in 24 | the Ant lib folder, because the build script will download the correct 25 | version of Ivy automatically. 26 | 27 | ## Project Resources ## 28 | 29 | * [Github Homepage](https://github.com/policeman-tools/forbidden-apis) 30 | * [Blog Post](https://blog.thetaphi.de/2012/07/default-locales-default-charsets-and.html) 31 | * [Jenkins CI](https://jenkins.thetaphi.de/job/Forbidden-APIs/) 32 | * [Open HUB](https://www.openhub.net/p/forbidden-apis) 33 | -------------------------------------------------------------------------------- /bundled-licenses/asm-LICENSE-BSD_LIKE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2000-2011 INRIA, France Telecom 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holders nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 29 | THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /bundled-licenses/plexus-utils-LICENSE-ASL.txt: -------------------------------------------------------------------------------- 1 | /* ==================================================================== 2 | * The Apache Software License, Version 1.1 3 | * 4 | * Copyright (c) 2000 The Apache Software Foundation. All rights 5 | * reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. The end-user documentation included with the redistribution, 20 | * if any, must include the following acknowledgment: 21 | * "This product includes software developed by the 22 | * Apache Software Foundation (http://www.apache.org/)." 23 | * Alternately, this acknowledgment may appear in the software itself, 24 | * if and wherever such third-party acknowledgments normally appear. 25 | * 26 | * 4. The names "Apache" and "Apache Software Foundation" must 27 | * not be used to endorse or promote products derived from this 28 | * software without prior written permission. For written 29 | * permission, please contact apache@apache.org. 30 | * 31 | * 5. Products derived from this software may not be called "Apache", 32 | * nor may "Apache" appear in their name, without prior written 33 | * permission of the Apache Software Foundation. 34 | * 35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 46 | * SUCH DAMAGE. 47 | * ==================================================================== 48 | * 49 | * This software consists of voluntary contributions made by many 50 | * individuals on behalf of the Apache Software Foundation. For more 51 | * information on the Apache Software Foundation, please see 52 | * . 53 | * 54 | * Portions of this software are based upon public domain software 55 | * originally written at the National Center for Supercomputing Applications, 56 | * University of Illinois, Urbana-Champaign. 57 | */ 58 | -------------------------------------------------------------------------------- /ivy-settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/main/docs/bundled-signatures.html: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | Bundled Signatures Documentation 20 | 21 | 22 |

Bundled Signatures Documentation

23 | 24 |

The JAR file contains the following signatures and can be used in Ant, Maven, or Gradle using <bundledSignatures>. 25 | All signatures are versioned against the specified JDK version:

26 | 27 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/main/docs/docindex.xsl: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | <xsl:value-of select="name"/> 26 | 27 | 28 |

29 | 30 | 31 | 32 | ( 33 | 34 | ) 35 | 36 |

37 |

38 |

39 | Full name: 40 | 41 | 42 | 43 | : 44 | 45 | : 46 | 47 | 48 |

49 |

Apache Ant

50 |

Task Documentation

51 |

Apache Maven: Mojo Goals

52 |

The minimum required version of Apache Maven is 3.1.0 (since forbiddenapis v3.6); previous versions also run with Maven 2.x.

53 |
    54 | 55 |
56 |

Gradle

57 |

Task Documentation (Javadocs)

58 |

Command Line Interface

59 |

60 | The JAR file can be called as command line tool using 61 | java -jar 62 | . This is the documentation of the CLI executable as printed by itsself: 63 |

64 |
65 |           $ java -jar -.jar --help
66 |           

67 |           
68 |         
69 |

Additional documentation

70 | 74 | 75 | 76 |
77 | 78 | 79 |
  • 80 | 81 | 82 | : 83 | 84 | 85 |
    86 | 87 |
  • 88 |
    89 | 90 |
    91 | -------------------------------------------------------------------------------- /src/main/docs/signatures-syntax.html: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | Syntax of Custom Signatures Files 20 | 21 | 22 |

    Syntax of Custom Signatures Files

    23 | 24 |

    Forbidden API Checker allows to define custom signatures files. Depending on 25 | the type of task (Ant, Maven, or Gradle), you can add them via references to 26 | local files from your project directory. Maven also supports to refer to them using 27 | Maven coordinates.

    28 | 29 |

    The syntax of those files is: Each line that is not empty, does not start with a 30 | # or @ symbol is treated as a signature. The following types 31 | of signatures are supported:

    32 | 33 | 49 | 50 |

    The error message displayed when the signature matches can be given at the end of each 51 | signature line using "@" as separator:

    52 | 53 |
    54 |   java.lang.String @ You are crazy that you disallow strings
    55 | 
    56 | 57 |

    To not repeat the same message after each signature, you can prepend signatures 58 | with a default message. Use a line starting with "@defaultMessage". 59 | 60 |

    61 |   @defaultMessage You are crazy that you disallow substrings
    62 |   java.lang.String#substring(int)
    63 |   java.lang.String#substring(int,int)
    64 | 
    65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/main/docs/xdoc2html.xsl: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | <xsl:value-of select="xdoc:properties/xdoc:title"/> 24 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |

    46 | 47 |
    48 | 49 | 50 |

    51 | 52 |
    53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 |
    74 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/ClassPatternRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis; 18 | 19 | import java.util.Objects; 20 | import java.util.regex.Pattern; 21 | 22 | public final class ClassPatternRule { 23 | 24 | private final Pattern pattern; 25 | private final String glob, message; 26 | 27 | /** Create new rule for class glob and given printout */ 28 | public ClassPatternRule(String glob, String message) { 29 | Objects.requireNonNull(glob, "glob"); 30 | this.glob = glob; 31 | this.pattern = AsmUtils.glob2Pattern(glob); 32 | this.message = message; 33 | } 34 | 35 | /** returns true, if the given class (binary name, dotted) matches this rule. */ 36 | public boolean matches(String className) { 37 | return pattern.matcher(className).matches(); 38 | } 39 | 40 | /** returns the printout using the message and the given class name */ 41 | public String getPrintout(String className) { 42 | return message == null ? className : (className + " [" + message + "]"); 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | final int prime = 31; 48 | int result = 1; 49 | result = prime * result + glob.hashCode(); 50 | result = prime * result + ((message == null) ? 0 : message.hashCode()); 51 | return result; 52 | } 53 | 54 | @Override 55 | public boolean equals(Object obj) { 56 | if (this == obj) return true; 57 | if (obj == null) return false; 58 | if (getClass() != obj.getClass()) return false; 59 | ClassPatternRule other = (ClassPatternRule) obj; 60 | if (!glob.equals(other.glob)) return false; 61 | if (message == null) { 62 | if (other.message != null) return false; 63 | } else if (!message.equals(other.message)) { 64 | return false; 65 | } 66 | return true; 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return "ClassPatternRule [glob=" + glob + ", message=" + message + "]"; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * Parts of this work are licensed to the Apache Software Foundation (ASF) 4 | * under one or more contributor license agreements. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package de.thetaphi.forbiddenapis; 20 | 21 | import java.util.regex.Pattern; 22 | 23 | import org.objectweb.asm.Type; 24 | 25 | public interface Constants { 26 | 27 | final String BS_JDK_NONPORTABLE = "jdk-non-portable"; 28 | 29 | final Pattern JDK_SIG_PATTERN = Pattern.compile("(jdk\\-.*?\\-)(\\d+)(\\.\\d+)?(\\.\\d+)*"); 30 | 31 | final String DEPRECATED_WARN_FAIL_ON_UNRESOLVABLE_SIGNATURES = 32 | "The setting 'failOnUnresolvableSignatures' was deprecated and will be removed in next version. Use 'ignoreSignaturesOfMissingClasses' instead."; 33 | 34 | final Type DEPRECATED_TYPE = Type.getType(Deprecated.class); 35 | final String DEPRECATED_DESCRIPTOR = DEPRECATED_TYPE.getDescriptor(); 36 | 37 | final String LAMBDA_META_FACTORY_INTERNALNAME = "java/lang/invoke/LambdaMetafactory"; 38 | final String LAMBDA_METHOD_NAME_PREFIX = "lambda$"; 39 | 40 | final String SIGNATURE_POLYMORPHIC_PKG_INTERNALNAME = "java/lang/invoke/"; 41 | final String SIGNATURE_POLYMORPHIC_DESCRIPTOR = Type.getMethodDescriptor(Type.getType(Object.class), Type.getType(Object[].class)); 42 | 43 | final String CLASS_CONSTRUCTOR_METHOD_NAME = ""; 44 | final String CONSTRUCTOR_METHOD_NAME = ""; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/ForbiddenApiException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis; 18 | 19 | @SuppressWarnings("serial") 20 | public final class ForbiddenApiException extends Exception { 21 | 22 | public ForbiddenApiException(String msg) { 23 | super(msg); 24 | } 25 | 26 | public ForbiddenApiException(String msg, Throwable cause) { 27 | super(msg, cause); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/ForbiddenViolation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis; 18 | 19 | import java.util.Formatter; 20 | import java.util.Locale; 21 | 22 | import org.objectweb.asm.commons.Method; 23 | 24 | import de.thetaphi.forbiddenapis.Checker.ViolationSeverity; 25 | 26 | public final class ForbiddenViolation implements Comparable { 27 | 28 | /** Separator used to allow multiple description lines per violation. */ 29 | public static final String SEPARATOR = "\n"; 30 | 31 | private int groupId; 32 | public final Method targetMethod; 33 | public final String description; 34 | public final String locationInfo; 35 | public final int lineNo; 36 | public final ViolationSeverity severity; 37 | 38 | ForbiddenViolation(int groupId, String description, String locationInfo, int lineNo, ViolationSeverity severity) { 39 | this(groupId, null, description, locationInfo, lineNo, severity); 40 | } 41 | 42 | ForbiddenViolation(int groupId, Method targetMethod, String description, String locationInfo, int lineNo, ViolationSeverity severity) { 43 | this.groupId = groupId; 44 | this.targetMethod = targetMethod; 45 | this.description = description; 46 | this.locationInfo = locationInfo; 47 | this.lineNo = lineNo; 48 | this.severity = severity; 49 | } 50 | 51 | public void setGroupId(int groupId) { 52 | this.groupId = groupId; 53 | } 54 | 55 | public int getGroupId() { 56 | return groupId; 57 | } 58 | 59 | @SuppressWarnings("resource") 60 | public String format(String className, String source) { 61 | final StringBuilder sb = new StringBuilder(description); 62 | sb.append(SEPARATOR).append(" in ").append(className); 63 | if (source != null) { 64 | if (lineNo >= 0) { 65 | new Formatter(sb, Locale.ENGLISH).format(" (%s:%d)", source, lineNo).flush(); 66 | } else { 67 | new Formatter(sb, Locale.ENGLISH).format(" (%s, %s)", source, locationInfo).flush(); 68 | } 69 | } else { 70 | new Formatter(sb, Locale.ENGLISH).format(" (%s)", locationInfo).flush(); 71 | } 72 | return sb.toString(); 73 | } 74 | 75 | @Override 76 | public int compareTo(ForbiddenViolation other) { 77 | if (this.groupId == other.groupId) { 78 | return Long.signum((long) this.lineNo - (long) other.lineNo); 79 | } else { 80 | return Long.signum((long) this.groupId - (long) other.groupId); 81 | } 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/Logger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis; 18 | 19 | public interface Logger { 20 | void error(String msg); 21 | void warn(String msg); 22 | void info(String msg); 23 | void debug(String msg); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/ParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis; 18 | 19 | @SuppressWarnings("serial") 20 | public final class ParseException extends Exception { 21 | 22 | public ParseException(String msg) { 23 | super(msg); 24 | } 25 | 26 | public ParseException(String msg, Throwable cause) { 27 | super(msg, cause); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/RelatedClassLoadingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis; 18 | 19 | import java.io.IOException; 20 | 21 | @SuppressWarnings("serial") 22 | final class RelatedClassLoadingException extends RuntimeException { 23 | 24 | private final String className; 25 | 26 | public RelatedClassLoadingException(ClassNotFoundException e, String className) { 27 | super(e); 28 | this.className = className; 29 | } 30 | 31 | public RelatedClassLoadingException(IOException e, String className) { 32 | super(e); 33 | this.className = className; 34 | } 35 | 36 | public RelatedClassLoadingException(RuntimeException e, String className) { 37 | super(e); 38 | this.className = className; 39 | } 40 | 41 | public Exception getException() { 42 | return (Exception) getCause(); 43 | } 44 | 45 | public String getClassName() { 46 | return className; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/RelatedClassLookup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis; 18 | 19 | import java.io.IOException; 20 | 21 | public interface RelatedClassLookup { 22 | ClassMetadata lookupRelatedClass(String internalName, String internalNameOrig); 23 | ClassMetadata getClassFromClassLoader(String clazz) throws ClassNotFoundException,IOException; 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/StdIoLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis; 18 | 19 | @SuppressForbidden 20 | public final class StdIoLogger implements Logger { 21 | 22 | public static final Logger INSTANCE = new StdIoLogger(false); 23 | public static final Logger INSTANCE_DEBUG = new StdIoLogger(true); 24 | 25 | private final boolean debug; 26 | 27 | private StdIoLogger(boolean debug) { 28 | this.debug = debug; 29 | } 30 | 31 | @Override 32 | public void error(String msg) { 33 | System.err.println("ERROR: " + msg); 34 | } 35 | 36 | @Override 37 | public void warn(String msg) { 38 | System.err.println("WARNING: " + msg); 39 | } 40 | 41 | @Override 42 | public void info(String msg) { 43 | System.out.println(msg); 44 | } 45 | 46 | @Override 47 | public void debug(String msg) { 48 | if (debug) { 49 | System.err.println("DEBUG: " + msg); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/SuppressForbidden.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis; 18 | 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | import java.lang.annotation.ElementType; 23 | 24 | /** 25 | * Default annotation to suppress forbidden-apis errors inside a whole class, a method, or a field. 26 | * You can define your own annotation and pass a list of suppressing annotation types to the checker, 27 | * this allows to use the feature without compile-time dependencies to forbidden-apis. 28 | */ 29 | @Retention(RetentionPolicy.CLASS) 30 | @Target({ ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE }) 31 | public @interface SuppressForbidden {} 32 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/ant/BundledSignaturesType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis.ant; 18 | 19 | import org.apache.tools.ant.ProjectComponent; 20 | 21 | public final class BundledSignaturesType extends ProjectComponent { 22 | 23 | private String name = null; 24 | private String targetVersion = null; 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | public void setTargetVersion(String targetVersion) { 35 | this.targetVersion = targetVersion; 36 | } 37 | 38 | public String getTargetVersion() { 39 | return targetVersion; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/ant/SeverityOverrideType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis.ant; 18 | 19 | import java.util.Arrays; 20 | import java.util.List; 21 | import java.util.Locale; 22 | 23 | import org.apache.tools.ant.BuildException; 24 | import org.apache.tools.ant.ProjectComponent; 25 | 26 | import de.thetaphi.forbiddenapis.Checker.ViolationSeverity; 27 | 28 | public final class SeverityOverrideType extends ProjectComponent { 29 | 30 | private final StringBuilder signatures = new StringBuilder(); 31 | 32 | ViolationSeverity severity = null; 33 | 34 | List getSignatures() { 35 | return Arrays.asList(signatures.toString().trim().split("\\s*[\r\n]+\\s*")); 36 | } 37 | 38 | public void addText(String signature) { 39 | this.signatures.append('\n').append(signature); 40 | } 41 | 42 | public void setSeverity(String severity) { 43 | try { 44 | this.severity = ViolationSeverity.valueOf(severity.toUpperCase(Locale.ROOT)); 45 | } catch (IllegalArgumentException iae) { 46 | throw new BuildException("Severity is not a valid enum value, use one of " + Arrays.toString(ViolationSeverity.values())); 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/ant/SignaturesResources.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis.ant; 18 | 19 | import org.apache.tools.ant.types.resources.Resources; 20 | 21 | /** Custom implementation of {@link Resources} to allow adding bundled signatures. */ 22 | public final class SignaturesResources extends Resources { 23 | private final AntTask task; 24 | 25 | SignaturesResources(AntTask task) { 26 | this.task = task; 27 | } 28 | 29 | // this is a hack to allow to be added. This just delegates back to task. 30 | public BundledSignaturesType createBundled() { 31 | return task.createBundledSignatures(); 32 | } 33 | 34 | // we also allow to add a severity override in the element. Cool ne? 35 | public SeverityOverrideType createSeverityOverride() { 36 | return task.createSeverityOverride(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/ant/SuppressAnnotationType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis.ant; 18 | 19 | import org.apache.tools.ant.ProjectComponent; 20 | 21 | public final class SuppressAnnotationType extends ProjectComponent { 22 | 23 | private String classname = null; 24 | 25 | public void setClassname(String classname) { 26 | this.classname = classname; 27 | } 28 | 29 | public String getClassname() { 30 | return classname; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/cli/ExitException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis.cli; 18 | 19 | /** 20 | * Used by the CLI to signal process exit with a specific exit code 21 | */ 22 | @SuppressWarnings("serial") 23 | final class ExitException extends Exception { 24 | public final int exitCode; 25 | 26 | public ExitException(int exitCode) { 27 | this(exitCode, null); 28 | } 29 | 30 | public ExitException(int exitCode, String message) { 31 | super(message); 32 | this.exitCode = exitCode; 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/gradle/CheckForbiddenApisExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis.gradle; 18 | 19 | import java.net.URL; 20 | import java.util.ArrayList; 21 | import java.util.LinkedHashSet; 22 | import java.util.List; 23 | import java.util.Set; 24 | 25 | import org.gradle.api.Project; 26 | import org.gradle.api.file.FileCollection; 27 | 28 | /** 29 | * Extension for the ForbiddenApis Gradle Task to store defaults. 30 | * For description of the properties refer to the {@link CheckForbiddenApis} 31 | * task documentation. 32 | * @since 2.0 33 | */ 34 | public class CheckForbiddenApisExtension { 35 | 36 | public CheckForbiddenApisExtension(Project project) { 37 | signaturesFiles = project.files(); 38 | } 39 | 40 | public FileCollection signaturesFiles; 41 | public Set signaturesURLs = new LinkedHashSet<>(); 42 | public List signatures = new ArrayList<>(); 43 | public Set bundledSignatures = new LinkedHashSet<>(), 44 | suppressAnnotations = new LinkedHashSet<>(), 45 | signaturesWithSeveritySuppress = new LinkedHashSet<>(), 46 | signaturesWithSeverityWarn = new LinkedHashSet<>(); 47 | public boolean failOnUnsupportedJava = false, 48 | failOnMissingClasses = true, 49 | failOnUnresolvableSignatures = true, 50 | ignoreFailures = false, 51 | ignoreSignaturesOfMissingClasses = false, 52 | disableClassloadingCache = ForbiddenApisPluginBase.DEFAULT_DISABLE_CLASSLOADING_CACHE; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/gradle/ForbiddenApisPluginBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis.gradle; 18 | 19 | import java.lang.reflect.Field; 20 | import java.lang.reflect.Modifier; 21 | import java.util.ArrayList; 22 | import java.util.Collections; 23 | import java.util.List; 24 | 25 | import org.gradle.api.Plugin; 26 | import org.gradle.api.Project; 27 | import org.gradle.api.logging.Logger; 28 | import org.gradle.api.logging.Logging; 29 | import org.gradle.util.GradleVersion; 30 | 31 | abstract class ForbiddenApisPluginBase implements Plugin { 32 | 33 | private static final Logger LOG = Logging.getLogger(ForbiddenApisPluginBase.class); 34 | 35 | /** Name of the base task that depends on one for every SourceSet. */ 36 | public static final String FORBIDDEN_APIS_TASK_NAME = "forbiddenApis"; 37 | 38 | /** Name of the extension to define defaults for all tasks of this module. */ 39 | public static final String FORBIDDEN_APIS_EXTENSION_NAME = "forbiddenApis"; 40 | 41 | /** 42 | * Default value for {@link CheckForbiddenApis#getDisableClassloadingCache}. 43 | *

    44 | * The default is {@code false}, unless the plugin detects that your build is 45 | * running in the Gradle Daemon (which has this problem), setting the 46 | * default to {@code true} as a consequence. 47 | * @see CheckForbiddenApis#getDisableClassloadingCache 48 | */ 49 | public static final boolean DEFAULT_DISABLE_CLASSLOADING_CACHE = detectAndLogGradleDaemon(); 50 | 51 | /** Minimum Gradle version this plugin requires to run (v3.2). */ 52 | public static final GradleVersion MIN_GRADLE_VERSION = GradleVersion.version("3.2"); 53 | 54 | /** True, if this version of Gradle supports task avoidance API (>=v4.9). */ 55 | public static final boolean TASK_AVOIDANCE_AVAILABLE = GradleVersion.current().compareTo(GradleVersion.version("4.9")) >= 0; 56 | 57 | /** All properties that our ForbiddenApisExtension provides. Used to create convention mapping. */ 58 | protected static final List FORBIDDEN_APIS_EXTENSION_PROPS = determineExtensionProps(); 59 | 60 | /** Java Package that contains the Gradle Daemon (needed to detect it on startup). */ 61 | private static final String GRADLE_DAEMON_PACKAGE = "org.gradle.launcher.daemon."; 62 | 63 | private static List determineExtensionProps() { 64 | final List props = new ArrayList<>(); 65 | for (final Field f : CheckForbiddenApisExtension.class.getDeclaredFields()) { 66 | final int mods = f.getModifiers(); 67 | if (Modifier.isPublic(mods) && !f.isSynthetic() && !Modifier.isStatic(mods)) { 68 | props.add(f.getName()); 69 | } 70 | } 71 | return Collections.unmodifiableList(props); 72 | } 73 | 74 | private static boolean isGradleDaemon() { 75 | // see: http://stackoverflow.com/questions/23265217/how-to-know-whether-you-are-running-inside-a-gradle-daemon 76 | if (System.getProperty("sun.java.command", "").startsWith(GRADLE_DAEMON_PACKAGE)) { 77 | return true; 78 | } 79 | for (StackTraceElement e : Thread.currentThread().getStackTrace()) { 80 | if (e.getClassName().startsWith(GRADLE_DAEMON_PACKAGE)) { 81 | return true; 82 | } 83 | } 84 | return false; 85 | } 86 | 87 | private static boolean detectAndLogGradleDaemon() { 88 | final boolean daemon = isGradleDaemon(); 89 | if (daemon) { 90 | LOG.info("You are running forbidden-apis in the Gradle Daemon; disabling classloading cache by default to work around resource leak."); 91 | } 92 | return daemon; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/maven/CheckMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis.maven; 18 | 19 | import org.apache.maven.plugins.annotations.Mojo; 20 | import org.apache.maven.plugins.annotations.Parameter; 21 | import org.apache.maven.plugins.annotations.LifecyclePhase; 22 | import org.apache.maven.plugins.annotations.ResolutionScope; 23 | 24 | import java.io.File; 25 | import java.util.List; 26 | 27 | /** 28 | * Mojo to check if no project generated class files (compile scope) contain calls to forbidden APIs 29 | * from the project classpath and a list of API signatures (either inline or as pointer to files or bundled signatures). 30 | * At least one signature must be given, using any of the corresponding optional parameters. 31 | *

    32 | * This Mojo exists since version 1.2, replacing the old forbiddenapis:forbiddenapis goal. 33 | * In most cases its enough to rename the goal on update, the older v1.0 properties are still available. 34 | *

    35 | * Since version 2.0 this Mojo defaults to run in the {@code 'verify'} lifecycle phase, before it was done in 36 | * {@code 'process-classes'} phase, which caused problems for some users (especially debugging tests). 37 | * @since 1.2 38 | */ 39 | @Mojo(name = "check", threadSafe = true, requiresProject = true, requiresDependencyResolution = ResolutionScope.COMPILE, defaultPhase = LifecyclePhase.VERIFY) 40 | public final class CheckMojo extends AbstractCheckMojo { 41 | 42 | /** 43 | * Injected compile classpath. 44 | */ 45 | @Parameter(defaultValue = "${project.compileClasspathElements}", readonly = true, required = true) 46 | private List classpathElements; 47 | 48 | /** 49 | * Directory with the class files to check. 50 | */ 51 | @Parameter(required = false, defaultValue = "${project.build.outputDirectory}") 52 | private File classesDirectory; 53 | 54 | @Override 55 | protected List getClassPathElements() { 56 | return this.classpathElements; 57 | } 58 | 59 | @Override 60 | protected File getClassesDirectory() { 61 | return this.classesDirectory; 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/maven/SignaturesArtifact.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis.maven; 18 | 19 | import org.eclipse.aether.artifact.Artifact; 20 | import org.eclipse.aether.artifact.DefaultArtifact; 21 | 22 | /** 23 | * Defines coordinates of a Maven artifact that provides signatures files. 24 | * It may be a plain text file ({@link #path} is not given) or alternatively 25 | * refer to a text file inside a JAR file. For that, define the resource path 26 | * using {@link #path}. 27 | * @since 2.0 28 | */ 29 | public final class SignaturesArtifact { 30 | 31 | /** Artifact's group ID (required) */ 32 | public String groupId; 33 | 34 | /** Artifact's ID (required) */ 35 | public String artifactId; 36 | 37 | /** Version (required) */ 38 | public String version; 39 | 40 | /** Classifier (optional) */ 41 | public String classifier; 42 | 43 | /** 44 | * Type (required; {@code txt} or {@code jar}). 45 | * If the artifact refers to a JAR file, the {@link #path} should be 46 | * given, that identifies the signatures file inside the JAR. 47 | * */ 48 | public String type; 49 | 50 | /** Path to resource inside JAR artifacts. If given, the {@link #type} must be {@code "jar"} or {@code "zip"}. */ 51 | public String path; 52 | 53 | /** Used by the mojo to fetch the artifact */ 54 | Artifact createArtifact() { 55 | if (groupId == null || artifactId == null || version == null || type == null) { 56 | throw new NullPointerException("signaturesArtifact is missing some properties. Required are: groupId, artifactId, version, type"); 57 | } 58 | return new DefaultArtifact(groupId, artifactId, classifier, type, version); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/de/thetaphi/forbiddenapis/maven/TestCheckMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis.maven; 18 | 19 | import org.apache.maven.plugins.annotations.Mojo; 20 | import org.apache.maven.plugins.annotations.Parameter; 21 | import org.apache.maven.plugins.annotations.LifecyclePhase; 22 | import org.apache.maven.plugins.annotations.ResolutionScope; 23 | 24 | import java.io.File; 25 | import java.util.List; 26 | 27 | /** 28 | * Mojo to check if no project generated class files (test scope) contain calls to forbidden APIs 29 | * from the project classpath and a list of API signatures (either inline or as pointer to files or bundled signatures). 30 | * At least one signature must be given, using any of the corresponding optional parameters. 31 | *

    32 | * Since version 2.0 this Mojo defaults to run in the {@code 'verify'} lifecycle phase, before it was done in 33 | * {@code 'process-test-classes'} phase, which caused problems for some users (especially debugging tests). 34 | * @since 1.2 35 | */ 36 | @Mojo(name = "testCheck", threadSafe = true, requiresProject = true, requiresDependencyResolution = ResolutionScope.TEST, defaultPhase = LifecyclePhase.VERIFY) 37 | public final class TestCheckMojo extends AbstractCheckMojo { 38 | 39 | /** 40 | * Injected test classpath. 41 | */ 42 | @Parameter(defaultValue = "${project.testClasspathElements}", readonly = true, required = true) 43 | private List classpathElements; 44 | 45 | /** 46 | * Directory with the class files to check. 47 | */ 48 | @Parameter(required = false, defaultValue = "${project.build.testOutputDirectory}") 49 | private File classesDirectory; 50 | 51 | /** 52 | * The default compiler target version used to expand references to bundled JDK signatures. 53 | * This setting falls back to "targetVersion" if undefined. This can be used to override 54 | * the target version solely used for tests. 55 | * E.g., if you use "jdk-deprecated", it will expand to this version. 56 | * This setting should be identical to the target version used in the compiler plugin. 57 | * @since 1.4 58 | */ 59 | @Parameter(required = false, defaultValue = "${maven.compiler.testTarget}") 60 | private String testTargetVersion; 61 | 62 | /** 63 | * The default compiler release version used to expand references to bundled JDK signatures. 64 | * This setting falls back to "releaseVersion" if undefined. This can be used to override 65 | * the release version solely used for tests. 66 | * E.g., if you use "jdk-deprecated", it will expand to this version. 67 | * This setting should be identical to the release version used in the compiler plugin. 68 | * If given, this setting is used in preference to {@link #testTargetVersion}. 69 | * @since 3.1 70 | */ 71 | @Parameter(required = false, defaultValue = "${maven.compiler.testRelease}") 72 | private String testReleaseVersion; 73 | 74 | @Override 75 | protected List getClassPathElements() { 76 | return this.classpathElements; 77 | } 78 | 79 | @Override 80 | protected File getClassesDirectory() { 81 | return this.classesDirectory; 82 | } 83 | 84 | @Override 85 | protected String getTargetVersion() { 86 | return (testReleaseVersion != null) ? 87 | testReleaseVersion : (testTargetVersion != null) ? testTargetVersion : super.getTargetVersion(); 88 | } 89 | 90 | } -------------------------------------------------------------------------------- /src/main/java/org/gradle/api/tasks/IgnoreEmptyDirectories.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.gradle.api.tasks; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis; 26 | 27 | /** 28 | * Attached to an input property to specify that directories should be ignored 29 | * when snapshotting inputs. Files within directories and subdirectories will be 30 | * snapshot, but the directories themselves will be ignored. Empty directories, 31 | * and directories that contain only empty directories will have no effect on the 32 | * resulting snapshot. 33 | *

    Copy of Gradle 6.8 annotation to allow compilation of {@link CheckForbiddenApis}. 34 | * It is excluded from the JAR file (runtime annotations are still optional at runtime). 35 | */ 36 | @Documented 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @Target({ElementType.METHOD, ElementType.FIELD}) 39 | public @interface IgnoreEmptyDirectories { 40 | } 41 | -------------------------------------------------------------------------------- /src/main/maven/pom-build.xml.template: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | @GROUPID@ 21 | @ARTIFACTID@ 22 | @VERSION@ 23 | @NAME@ 24 | @DESCRIPTION@ 25 | maven-plugin 26 | 27 | 28 | @MAVEN_MIN_VERSION@ 29 | 30 | 31 | 32 | UTF-8 33 | UTF-8 34 | 35 | 36 | 37 | ${injected.build.dir} 38 | ${injected.src.dir} 39 | ${injected.output.dir} 40 | 41 | 42 | org.apache.maven.plugins 43 | maven-plugin-plugin 44 | ${injected.maven-plugin-plugin.version} 45 | 46 | 47 | java-javadoc 48 | java-annotations 49 | 50 | 51 | 52 | 53 | org.apache.maven.plugins 54 | maven-compiler-plugin 55 | ${injected.maven-compiler-plugin.version} 56 | 57 | 58 | 59 | ** 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/main/maven/pom-deploy.xml.template: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | @GROUPID@ 21 | @ARTIFACTID@ 22 | @VERSION@ 23 | @NAME@ 24 | @DESCRIPTION@ 25 | https://github.com/policeman-tools/forbidden-apis 26 | 2013 27 | maven-plugin 28 | 29 | 30 | org.sonatype.oss 31 | oss-parent 32 | 9 33 | 34 | 35 | 36 | 37 | The Apache Software License, Version 2.0 38 | http://www.apache.org/licenses/LICENSE-2.0.txt 39 | 40 | 41 | 42 | 43 | scm:git:https://github.com/policeman-tools/forbidden-apis.git 44 | scm:git:https://github.com/policeman-tools/forbidden-apis.git 45 | https://github.com/policeman-tools/forbidden-apis 46 | 47 | 48 | 49 | Github Issue Tracker 50 | https://github.com/policeman-tools/forbidden-apis/issues 51 | 52 | 53 | 54 | Jenkins 55 | https://jenkins.thetaphi.de/job/Forbidden-APIs/ 56 | 57 | 58 | 59 | 60 | uschindler 61 | Uwe Schindler 62 | https://www.thetaphi.de/ 63 | 64 | architect 65 | developer 66 | 67 | +1 68 | 69 | 70 | rmuir 71 | Robert Muir 72 | 73 | developer 74 | default locale/charset/timezone ghostbuster 75 | 76 | -5 77 | 78 | 79 | 80 | 81 | @MAVEN_MIN_VERSION@ 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/main/maven/settings.xml.template: -------------------------------------------------------------------------------- 1 | 2 | 17 | 20 | 21 | 28 | 29 | mycentral 30 | Maven Central 31 | @REPO@ 32 | central 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/de.thetaphi.forbiddenapis.properties: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | implementation-class=de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin 16 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | check 23 | testCheck 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/antlib.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-1.0.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @defaultMessage Uses default charset 18 | org.apache.commons.io.CopyUtils#copy(byte[],java.io.Writer) 19 | org.apache.commons.io.CopyUtils#copy(java.io.InputStream,java.io.Writer) 20 | org.apache.commons.io.CopyUtils#copy(java.io.Reader,java.io.OutputStream) 21 | org.apache.commons.io.CopyUtils#copy(java.lang.String,java.io.OutputStream) 22 | org.apache.commons.io.IOUtils#toByteArray(java.io.Reader) 23 | org.apache.commons.io.IOUtils#toByteArray(java.lang.String) 24 | org.apache.commons.io.IOUtils#toString(byte[]) 25 | org.apache.commons.io.IOUtils#toString(java.io.InputStream) 26 | 27 | @ignoreUnresolvable 28 | org.apache.commons.io.output.ByteArrayOutputStream#toString() 29 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-1.1.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-1.0 18 | 19 | @defaultMessage Uses default charset 20 | org.apache.commons.io.IOUtils#copy(java.io.InputStream,java.io.Writer) 21 | org.apache.commons.io.IOUtils#copy(java.io.Reader,java.io.OutputStream) 22 | org.apache.commons.io.IOUtils#readLines(java.io.InputStream) 23 | org.apache.commons.io.IOUtils#toCharArray(java.io.InputStream) 24 | org.apache.commons.io.IOUtils#toInputStream(java.lang.String) 25 | org.apache.commons.io.IOUtils#write(byte[],java.io.Writer) 26 | org.apache.commons.io.IOUtils#write(char[],java.io.OutputStream) 27 | org.apache.commons.io.IOUtils#write(java.lang.StringBuffer,java.io.OutputStream) 28 | org.apache.commons.io.IOUtils#write(java.lang.String,java.io.OutputStream) 29 | org.apache.commons.io.IOUtils#writeLines(java.util.Collection,java.lang.String,java.io.OutputStream) 30 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-1.2.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-1.1 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-1.3.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-1.2 18 | 19 | @defaultMessage Uses default charset 20 | org.apache.commons.io.FileUtils#lineIterator(java.io.File) 21 | org.apache.commons.io.FileUtils#readFileToString(java.io.File) 22 | org.apache.commons.io.FileUtils#readLines(java.io.File) 23 | org.apache.commons.io.FileUtils#writeLines(java.io.File,java.util.Collection) 24 | org.apache.commons.io.FileUtils#writeLines(java.io.File,java.util.Collection,java.lang.String) 25 | org.apache.commons.io.FileUtils#writeStringToFile(java.io.File,java.lang.String) 26 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-1.4.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-1.3 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.0.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-1.4 18 | 19 | @defaultMessage Uses default charset 20 | org.apache.commons.io.IOUtils#toInputStream(java.lang.CharSequence) 21 | org.apache.commons.io.IOUtils#write(java.lang.CharSequence,java.io.OutputStream) 22 | org.apache.commons.io.output.WriterOutputStream#(java.io.Writer) 23 | org.apache.commons.io.input.ReaderInputStream#(java.io.Reader) 24 | org.apache.commons.io.FileUtils#write(java.io.File,java.lang.CharSequence) 25 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.1.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.0 18 | 19 | @defaultMessage Uses default charset 20 | org.apache.commons.io.IOUtils#toString(java.net.URI) 21 | org.apache.commons.io.IOUtils#toString(java.net.URL) 22 | org.apache.commons.io.FileUtils#write(java.io.File,java.lang.CharSequence,boolean) 23 | org.apache.commons.io.FileUtils#writeLines(java.io.File,java.util.Collection,boolean) 24 | org.apache.commons.io.FileUtils#writeLines(java.io.File,java.util.Collection,java.lang.String,boolean) 25 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.10.0.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.9.0 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.11.0.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.10.0 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.12.0.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.11.0 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.13.0.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.12.0 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.14.0.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.13.0 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.15.0.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.14.0 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.15.1.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.15.0 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.16.0.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.15.1 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.16.1.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.16.0 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.17.0.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.16.1 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.18.0.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.17.0 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.2.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.1 18 | 19 | @defaultMessage Uses default charset 20 | org.apache.commons.io.input.ReversedLinesFileReader#(java.io.File) 21 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.3.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.2 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.4.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.3 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.5.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.4 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.6.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.5 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.7.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.6 18 | 19 | @defaultMessage Uses default charset 20 | org.apache.commons.io.output.AbstractByteArrayOutputStream#toString() 21 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.8.0.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.7 18 | 19 | @defaultMessage Uses default time zone 20 | org.apache.commons.io.FileUtils#isFileNewer(java.io.File,java.time.chrono.ChronoLocalDate) 21 | org.apache.commons.io.FileUtils#isFileNewer(java.io.File,java.time.chrono.ChronoLocalDate,java.time.LocalTime) 22 | org.apache.commons.io.FileUtils#isFileNewer(java.io.File,java.time.chrono.ChronoLocalDateTime) 23 | org.apache.commons.io.FileUtils#isFileOlder(java.io.File,java.time.chrono.ChronoLocalDate) 24 | org.apache.commons.io.FileUtils#isFileOlder(java.io.File,java.time.chrono.ChronoLocalDate,java.time.LocalTime) 25 | org.apache.commons.io.FileUtils#isFileOlder(java.io.File,java.time.chrono.ChronoLocalDateTime) 26 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/commons-io-unsafe-2.9.0.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @includeBundled commons-io-unsafe-2.8.0 18 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/incr-jdk-unsafe-11-till-20.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | java.net.http.HttpResponse$BodySubscribers#ofFile(**) @ Method is buggy in all Java versions till 20 (does not write all bytes) 16 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/incr-jdk-unsafe-12.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | @defaultMessage Uses default locale 16 | java.text.NumberFormat#getCompactNumberInstance() 17 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/incr-jdk-unsafe-15.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | @defaultMessage Uses default locale 16 | java.lang.String#formatted(java.lang.Object[]) 17 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-1.7.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 1.7 (extracted from build 1.7.0_80). 6 | 7 | @defaultMessage non-public internal runtime class in Java 1.7 8 | 9 | com.sun.corba.se.** 10 | com.sun.imageio.** 11 | com.sun.istack.internal.** 12 | com.sun.java.accessibility.** 13 | com.sun.jmx.** 14 | com.sun.naming.internal.** 15 | com.sun.org.apache.bcel.internal.** 16 | com.sun.org.apache.regexp.internal.** 17 | com.sun.org.apache.xalan.internal.extensions.** 18 | com.sun.org.apache.xalan.internal.lib.** 19 | com.sun.org.apache.xalan.internal.res.** 20 | com.sun.org.apache.xalan.internal.templates.** 21 | com.sun.org.apache.xalan.internal.utils.** 22 | com.sun.org.apache.xalan.internal.xslt.** 23 | com.sun.org.apache.xalan.internal.xsltc.cmdline.** 24 | com.sun.org.apache.xalan.internal.xsltc.compiler.** 25 | com.sun.org.apache.xalan.internal.xsltc.trax.** 26 | com.sun.org.apache.xalan.internal.xsltc.util.** 27 | com.sun.org.apache.xerces.internal.** 28 | com.sun.org.apache.xml.internal.res.** 29 | com.sun.org.apache.xml.internal.security.** 30 | com.sun.org.apache.xml.internal.serializer.utils.** 31 | com.sun.org.apache.xml.internal.utils.** 32 | com.sun.org.apache.xpath.internal.** 33 | com.sun.org.glassfish.** 34 | com.sun.proxy.** 35 | com.sun.script.** 36 | com.sun.xml.internal.** 37 | oracle.jrockit.jfr.** 38 | org.jcp.xml.dsig.internal.** 39 | sun.** 40 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-1.8.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 1.8 (extracted from build 1.8.0_144). 6 | 7 | @defaultMessage non-public internal runtime class in Java 1.8 8 | 9 | com.oracle.webservices.internal.** 10 | com.oracle.xmlns.internal.** 11 | com.sun.activation.registries.** 12 | com.sun.browser.** 13 | com.sun.corba.se.** 14 | com.sun.glass.** 15 | com.sun.imageio.** 16 | com.sun.istack.internal.** 17 | com.sun.java.accessibility.** 18 | com.sun.javafx.** 19 | com.sun.jmx.** 20 | com.sun.media.** 21 | com.sun.media.sound.** 22 | com.sun.naming.internal.** 23 | com.sun.openpisces.** 24 | com.sun.org.apache.bcel.internal.** 25 | com.sun.org.apache.regexp.internal.** 26 | com.sun.org.apache.xalan.internal.extensions.** 27 | com.sun.org.apache.xalan.internal.lib.** 28 | com.sun.org.apache.xalan.internal.res.** 29 | com.sun.org.apache.xalan.internal.templates.** 30 | com.sun.org.apache.xalan.internal.utils.** 31 | com.sun.org.apache.xalan.internal.xslt.** 32 | com.sun.org.apache.xalan.internal.xsltc.cmdline.** 33 | com.sun.org.apache.xalan.internal.xsltc.compiler.** 34 | com.sun.org.apache.xalan.internal.xsltc.trax.** 35 | com.sun.org.apache.xalan.internal.xsltc.util.** 36 | com.sun.org.apache.xerces.internal.** 37 | com.sun.org.apache.xml.internal.res.** 38 | com.sun.org.apache.xml.internal.resolver.helpers.** 39 | com.sun.org.apache.xml.internal.resolver.readers.** 40 | com.sun.org.apache.xml.internal.security.** 41 | com.sun.org.apache.xml.internal.serializer.utils.** 42 | com.sun.org.apache.xml.internal.utils.** 43 | com.sun.org.apache.xpath.internal.** 44 | com.sun.org.glassfish.** 45 | com.sun.pisces.** 46 | com.sun.prism.** 47 | com.sun.proxy.** 48 | com.sun.scenario.** 49 | com.sun.t2k.** 50 | com.sun.webkit.** 51 | com.sun.xml.internal.** 52 | jdk.internal.** 53 | jdk.management.resource.internal.** 54 | jdk.nashorn.internal.** 55 | jdk.nashorn.tools.** 56 | oracle.jrockit.jfr.** 57 | org.jcp.xml.dsig.internal.** 58 | sun.** 59 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-10.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 10 (extracted from build 10). 6 | 7 | @defaultMessage non-public internal runtime class in Java 10 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-11.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 11 (extracted from build 11). 6 | 7 | @defaultMessage non-public internal runtime class in Java 11 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-12.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 12 (extracted from build 12). 6 | 7 | @defaultMessage non-public internal runtime class in Java 12 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-13.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 13 (extracted from build 13). 6 | 7 | @defaultMessage non-public internal runtime class in Java 13 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-14.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 14 (extracted from build 14). 6 | 7 | @defaultMessage non-public internal runtime class in Java 14 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-15.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 15 (extracted from build 15). 6 | 7 | @defaultMessage non-public internal runtime class in Java 15 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-16.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 16 (extracted from build 16). 6 | 7 | @defaultMessage non-public internal runtime class in Java 16 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-17.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 17 (extracted from build 17). 6 | 7 | @defaultMessage non-public internal runtime class in Java 17 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-18.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 18 (extracted from build 18). 6 | 7 | @defaultMessage non-public internal runtime class in Java 18 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-19.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 19 (extracted from build 19). 6 | 7 | @defaultMessage non-public internal runtime class in Java 19 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-20.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 20 (extracted from build 20). 6 | 7 | @defaultMessage non-public internal runtime class in Java 20 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-21.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 21 (extracted from build 21). 6 | 7 | @defaultMessage non-public internal runtime class in Java 21 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-22.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 22 (extracted from build 22). 6 | 7 | @defaultMessage non-public internal runtime class in Java 22 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-23.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 23 (extracted from build 23). 6 | 7 | @defaultMessage non-public internal runtime class in Java 23 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-24.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # This file is no longer autogenerated starting from Java 24 because SecurityManager was removed 16 | # and therefore relevant system properties used to generate the package list. 17 | 18 | @defaultMessage non-public internal runtime class in Java 24 19 | 20 | sun.misc.** 21 | sun.reflect.** 22 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-internal-9.txt: -------------------------------------------------------------------------------- 1 | # This file contains API signatures that are marked as internal in Java. 2 | # It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis: 3 | # $ ant generate-internal 4 | 5 | # This file contains all internal packages listed in Security.getProperty("package.access") of Java version 9 (extracted from build 9). 6 | 7 | @defaultMessage non-public internal runtime class in Java 9 8 | 9 | sun.misc.** 10 | sun.reflect.** 11 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-reflection.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @defaultMessage Reflection usage to work around access flags fails with SecurityManagers and likely will not work anymore on runtime classes in Java 9 18 | 19 | java.lang.reflect.AccessibleObject#setAccessible(java.lang.reflect.AccessibleObject[], boolean) 20 | java.lang.reflect.AccessibleObject#setAccessible(boolean) 21 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-system-out.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | java.lang.System#out @ prints to System.out; should only be used for debugging, not in production code 18 | java.lang.System#err @ prints to System.err; should only be used for debugging, not in production code 19 | java.lang.Thread#dumpStack() @ dumpStack should only be used for debugging, not in production code 20 | java.lang.Throwable#printStackTrace() @ Eclipse auto-generated stubs; exceptions should be correctly bubbled up and handled accordingly 21 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-1.8.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | @includeBundled jdk-unsafe-1.7 18 | 19 | @defaultMessage Uses default time zone 20 | java.time.LocalDateTime#now() 21 | java.time.LocalDate#now() 22 | java.time.LocalTime#now() 23 | java.time.OffsetDateTime#now() 24 | java.time.OffsetTime#now() 25 | java.time.Year#now() 26 | java.time.YearMonth#now() 27 | java.time.MonthDay#now() 28 | java.time.chrono.Chronology#dateNow() 29 | java.time.chrono.HijrahChronology#dateNow() 30 | java.time.chrono.JapaneseChronology#dateNow() 31 | java.time.chrono.MinguoChronology#dateNow() 32 | java.time.chrono.ThaiBuddhistChronology#dateNow() 33 | java.time.chrono.IsoChronology#dateNow() 34 | java.time.chrono.HijrahDate#now() 35 | java.time.chrono.JapaneseDate#now() 36 | java.time.chrono.MinguoDate#now() 37 | java.time.chrono.ThaiBuddhistDate#now() 38 | 39 | @defaultMessage Uses default locale 40 | java.time.format.DateTimeFormatterBuilder#toFormatter() 41 | java.time.format.DateTimeFormatter#ofLocalizedDate(java.time.format.FormatStyle) 42 | java.time.format.DateTimeFormatter#ofLocalizedDateTime(java.time.format.FormatStyle,java.time.format.FormatStyle) 43 | java.time.format.DateTimeFormatter#ofLocalizedDateTime(java.time.format.FormatStyle) 44 | java.time.format.DateTimeFormatter#ofLocalizedTime(java.time.format.FormatStyle) 45 | java.time.format.DateTimeFormatter#ofPattern(java.lang.String) 46 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-10.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # We only include 9 for now. 18 | # TODO: Scan Java 10 API for additional locale/charset/... violations! 19 | @includeBundled jdk-unsafe-9 20 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-11.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 11 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-10 19 | @includeBundled incr-jdk-unsafe-11-till-20 20 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-12.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 12 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-10 19 | @includeBundled incr-jdk-unsafe-11-till-20 20 | @includeBundled incr-jdk-unsafe-12 21 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-13.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 13 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-10 19 | @includeBundled incr-jdk-unsafe-11-till-20 20 | @includeBundled incr-jdk-unsafe-12 21 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-14.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 14 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-10 19 | @includeBundled incr-jdk-unsafe-11-till-20 20 | @includeBundled incr-jdk-unsafe-12 21 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-15.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 15 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-10 19 | @includeBundled incr-jdk-unsafe-11-till-20 20 | @includeBundled incr-jdk-unsafe-12 21 | @includeBundled incr-jdk-unsafe-15 22 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-16.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 16 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-10 19 | @includeBundled incr-jdk-unsafe-11-till-20 20 | @includeBundled incr-jdk-unsafe-12 21 | @includeBundled incr-jdk-unsafe-15 22 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-17.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 17 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-10 19 | @includeBundled incr-jdk-unsafe-11-till-20 20 | @includeBundled incr-jdk-unsafe-12 21 | @includeBundled incr-jdk-unsafe-15 22 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-18.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 18 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-10 19 | @includeBundled incr-jdk-unsafe-11-till-20 20 | @includeBundled incr-jdk-unsafe-12 21 | @includeBundled incr-jdk-unsafe-15 22 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-19.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 19 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-10 19 | @includeBundled incr-jdk-unsafe-11-till-20 20 | @includeBundled incr-jdk-unsafe-12 21 | @includeBundled incr-jdk-unsafe-15 22 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-20.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 20 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-10 19 | @includeBundled incr-jdk-unsafe-11-till-20 20 | @includeBundled incr-jdk-unsafe-12 21 | @includeBundled incr-jdk-unsafe-15 22 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-21.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 21 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-10 19 | # 11-20 removed (see https://github.com/policeman-tools/forbidden-apis/issues/214) 20 | @includeBundled incr-jdk-unsafe-12 21 | @includeBundled incr-jdk-unsafe-15 22 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-22.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 22 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-21 19 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-23.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 23 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-22 19 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-24.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 24 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-23 19 | -------------------------------------------------------------------------------- /src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-unsafe-9.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # These methods and classes should not be used by server classes (unsafe, no charset, no locale,...): 16 | 17 | # TODO: Scan Java 9 API for additional locale/charset/... violations! 18 | @includeBundled jdk-unsafe-1.8 19 | 20 | @defaultMessage Uses default locale 21 | java.util.ResourceBundle#getBundle(java.lang.String,java.lang.Module) 22 | -------------------------------------------------------------------------------- /src/test/antunit/Java7ClassReferences.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/Java7ClassReferences.class -------------------------------------------------------------------------------- /src/test/antunit/Java7ClassReferences.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* The binary class file is packaged together with the source distribution. 18 | */ 19 | 20 | import java.util.*; 21 | 22 | class Java7ClassReferences { 23 | static Integer[][] test() { 24 | Integer.class.getName(); 25 | System.out.println(Integer[].class); 26 | Integer[] arr = new Integer[1]; 27 | arr[0] = new Integer(0); 28 | return new Integer[1][1]; 29 | } 30 | 31 | private Integer field1; 32 | private final Integer[] field2 = null; 33 | 34 | // we forbid the superclass or interface, but concrete instance is used: 35 | public List list1; 36 | public ArrayList list2; 37 | public HashSet set1; 38 | } 39 | -------------------------------------------------------------------------------- /src/test/antunit/Java7DeprecatedAnnotation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/Java7DeprecatedAnnotation.class -------------------------------------------------------------------------------- /src/test/antunit/Java7DeprecatedAnnotation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* The binary class file is packaged together with the source distribution. 18 | */ 19 | 20 | class Java7DeprecatedAnnotation { 21 | 22 | /** @deprecated **/ 23 | public Java7DeprecatedAnnotation() { 24 | new StringBuilder(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/test/antunit/Java7MethodHandles.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/Java7MethodHandles.class -------------------------------------------------------------------------------- /src/test/antunit/Java7MethodHandles.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* The binary class file is packaged together with the source distribution. 18 | */ 19 | 20 | import java.lang.invoke.MethodHandle; 21 | import java.lang.invoke.MethodHandles; 22 | import java.lang.invoke.MethodType; 23 | 24 | class Java7MethodHandles { 25 | static void main(String... args) throws Throwable { 26 | MethodHandle mh = MethodHandles.publicLookup().findVirtual(StringBuilder.class, "append", 27 | MethodType.methodType(StringBuilder.class, int.class)); 28 | StringBuilder result = (StringBuilder) mh.invoke(new StringBuilder(), 1); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/antunit/Java7Reflection.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/Java7Reflection.class -------------------------------------------------------------------------------- /src/test/antunit/Java7Reflection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* The binary class file is packaged together with the source distribution. 18 | */ 19 | 20 | import java.lang.reflect.Field; 21 | import java.lang.reflect.Method; 22 | import java.util.*; 23 | 24 | class Java7Reflection { 25 | static Field test() throws Exception { 26 | Class c = Java7Reflection.class; 27 | Field f = c.getDeclaredField("field1"); 28 | f.setAccessible(true); 29 | 30 | Method m = c.getDeclaredMethod("testMethod"); 31 | m.setAccessible(true); 32 | m.invoke(new Java7Reflection()); 33 | 34 | return f; 35 | } 36 | 37 | private Integer field1; 38 | 39 | private void testMethod() { 40 | // nothing to do here 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/antunit/Java7StaticVsVirtual$X.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/Java7StaticVsVirtual$X.class -------------------------------------------------------------------------------- /src/test/antunit/Java7StaticVsVirtual$Y.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/Java7StaticVsVirtual$Y.class -------------------------------------------------------------------------------- /src/test/antunit/Java7StaticVsVirtual$Z.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/Java7StaticVsVirtual$Z.class -------------------------------------------------------------------------------- /src/test/antunit/Java7StaticVsVirtual.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/Java7StaticVsVirtual.class -------------------------------------------------------------------------------- /src/test/antunit/Java7StaticVsVirtual.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* The binary class file is packaged together with the source distribution. 18 | */ 19 | 20 | import java.util.BitSet; 21 | 22 | public class Java7StaticVsVirtual { 23 | public static final long[] data = new long[] {1, 2, 3, 4}; 24 | 25 | public static void main(String[] args) { 26 | X.valueOf(data).toString(); // Line 26 -- the only violation for static BitSet#valueOf(**) 27 | Y.valueOf(data).toString(); // Line 27 -- should pass 28 | Z.valueOf(data).toString(); // Line 28 -- should pass 29 | Integer.toString(Y.a); // Line 29 -- violation (static field access) 30 | Integer.toString(Z.a); // Line 30 -- should pass (hidden) 31 | new X().get(0); // Line 31 -- violation (virtual methods detected regardles how they are called) 32 | new Y().get(0); // Line 32 -- violation (virtual methods detected regardles how they are called) 33 | new Z().get(0); // Line 33 -- violation (virtual methods detected regardles how they are called) 34 | Integer.toString(new Y().b); // Line 34 -- violation 35 | Integer.toString(new Z().b); // Line 35 -- should pass (hidden) 36 | } 37 | 38 | public static class X extends BitSet { } 39 | 40 | public static class Y extends X { 41 | public static int a; 42 | public int b; 43 | 44 | public static BitSet valueOf(long[] longs) { 45 | return new BitSet(); 46 | } 47 | 48 | @Override 49 | public boolean get(int bit) { 50 | return false; 51 | } 52 | } 53 | 54 | public static class Z extends Y { 55 | public static int a; // hides field in superclass 56 | public int b; // hides field in superclass 57 | 58 | public String goStatic() { 59 | return valueOf(data).toString(); // Line 59 -- should pass 60 | } 61 | public boolean goVirtual() { 62 | return get(0); // Line 62 -- violation (virtual methods detected regardles how they are called) 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/test/antunit/Java8Annotations$ClassFileOnly.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/Java8Annotations$ClassFileOnly.class -------------------------------------------------------------------------------- /src/test/antunit/Java8Annotations$FooBar.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/Java8Annotations$FooBar.class -------------------------------------------------------------------------------- /src/test/antunit/Java8Annotations$InnerClassWithCtorParam.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/Java8Annotations$InnerClassWithCtorParam.class -------------------------------------------------------------------------------- /src/test/antunit/Java8Annotations.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/Java8Annotations.class -------------------------------------------------------------------------------- /src/test/antunit/Java8Annotations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.lang.annotation.Retention; 18 | import java.lang.annotation.RetentionPolicy; 19 | import java.lang.annotation.Target; 20 | import java.lang.annotation.ElementType; 21 | 22 | /* Needs JDK 8 to compile! 23 | * The binary class file is packaged together with the source distribution, 24 | * because it cannot be regenerated on every Java installation! 25 | */ 26 | 27 | @Java8Annotations.FooBar 28 | @Deprecated 29 | class Java8Annotations<@Java8Annotations.FooBar X> { 30 | 31 | @Deprecated 32 | static void test(@FooBar int param1, @FooBar long param2) { 33 | try { 34 | new @FooBar Java8Annotations(); 35 | test(param1, param2); 36 | } catch (@FooBar StackOverflowError e) { 37 | System.out.println(FooBar.class.getName()); 38 | } 39 | } 40 | 41 | final class InnerClassWithCtorParam { 42 | public InnerClassWithCtorParam(@FooBar X param) { 43 | System.out.println(Java8Annotations.this); 44 | System.out.println(param); 45 | } 46 | } 47 | 48 | @Deprecated 49 | public int testField1; 50 | 51 | @FooBar 52 | public int testField2; 53 | 54 | @ClassFileOnly 55 | public StringBuilder testField3; 56 | 57 | @Retention(value=RetentionPolicy.RUNTIME) 58 | @Target({ElementType.TYPE_USE, ElementType.PARAMETER, ElementType.METHOD, ElementType.TYPE}) 59 | static @interface FooBar {} 60 | 61 | @Retention(value=RetentionPolicy.CLASS) 62 | @Target({ElementType.FIELD, ElementType.METHOD}) 63 | static @interface ClassFileOnly {} 64 | } 65 | -------------------------------------------------------------------------------- /src/test/antunit/Java8Closures.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/Java8Closures.class -------------------------------------------------------------------------------- /src/test/antunit/Java8Closures.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.io.Closeable; 18 | import java.util.Arrays; 19 | import java.util.ArrayList; 20 | 21 | /* Needs JDK 8 to compile! 22 | * The binary class file is packaged together with the source distribution, 23 | * because it cannot be regenerated on every Java installation! 24 | */ 25 | 26 | interface Java8Closures extends Closeable { 27 | default void close2() { 28 | new StringBuilder().append("police"); 29 | Arrays.sort(new Integer[0], (Integer a, Integer b) -> a.compareTo(b)); 30 | } 31 | 32 | static void test() { 33 | // use a static method as closure 34 | Arrays.sort(new Float[0], Float::compare); 35 | // use a closure which is implemented by (a,b) -> a.compareTo(b) 36 | Arrays.sort(new Integer[0], Integer::compareTo); 37 | // a thread which creates an ArrayList by its constructor: 38 | new Thread(ArrayList::new).run(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/antunit/OracleInternalRuntime.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/policeman-tools/forbidden-apis/b58e15c677ffe11553564990e32505bb4c87c31e/src/test/antunit/OracleInternalRuntime.class -------------------------------------------------------------------------------- /src/test/antunit/OracleInternalRuntime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import sun.misc.BASE64Encoder; 18 | 19 | /* Needs Sun/Oracle JDK to compile! 20 | * The binary class file is packaged together with the source distribution, 21 | * because it cannot be regenerated on every Java installation! 22 | */ 23 | 24 | class OracleInternalRuntime { 25 | static { 26 | new BASE64Encoder().encode(new byte[0]); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/antunit/TestAnnotations.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Java8Annotations$ClassFileOnly @ Forbidden class-only annotation 24 | Java8Annotations$FooBar @ Forbidden annotation 25 | java.lang.Deprecated @ Deprecated annotation 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | java.lang.Deprecated @ Deprecated annotation 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | java.lang.StringBuilder 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | java.lang.StringBuilder 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Java8Annotations$ClassFileOnly @ Forbidden class-only annotation 69 | Java8Annotations$FooBar @ Forbidden annotation 70 | java.lang.Deprecated @ Deprecated annotation 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | java.lang.StringBuilder 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/test/antunit/TestClassDeclaration.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | java.lang.Object @ Every class is not allowed! 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.objectweb.asm.Opcodes @ demo interface 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/test/antunit/TestClassLoader.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | java.lang.String 23 | # ANT should not be available in classpath! 24 | org.apache.tools.ant.Project 25 | 26 | 27 | 28 | 29 | java.lang.String 30 | # ANT should not be available in classpath, especially if we pass a custom one! 31 | org.apache.tools.ant.Project 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/antunit/TestClassReferences.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | java.lang.Integer @ Forbidden class reference! 24 | java.util.List @ Forbidden class reference! 25 | java.util.AbstractCollection @ Forbidden class reference! 26 | java.util.AbstractSet @ Forbidden class reference! 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/test/antunit/TestCommonsIOSignatures.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/test/antunit/TestFailOnViolation.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | java.awt.Color @ Color is disallowed, thats not bad, because ANT has no colors... 26 | java.lang.String @ You are crazy that you disallow strings 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | java.awt.Color @ Color is disallowed, thats not bad, because ANT has no colors... 36 | java.lang.String @ You are crazy that you disallow strings 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/test/antunit/TestFileSignatures.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | java.util.Locale#ENGLISH @ We are speaking chinese here! 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/test/antunit/TestFinalJAR.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/test/antunit/TestInternalRuntimeCalls.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/test/antunit/TestJava6Reflection.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/test/antunit/TestJava7.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | java.lang.invoke.MethodHandle#invoke(java.lang.Object[]) @ Forbidden signature polymorphic method 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/test/antunit/TestJava8.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | java.io.Closeable @ Police alarm! 24 | java.lang.StringBuilder @ Police alarm! 25 | java.lang.Integer#compareTo(java.lang.Integer) @ Closure alarm! 26 | java.lang.Float#compare(float,float) @ Static closure alarm! 27 | java.util.Arrays#sort(java.lang.Object[],java.util.Comparator) @ Call using closure alarm! 28 | java.util.ArrayList#<init>() @ Closure implemented by constructor! 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/test/antunit/TestStaticVsVirtual.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | java.util.BitSet#valueOf(**) @ Forbidden static method 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | java.util.BitSet#get(int) @ Forbidden virtual method 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Java7StaticVsVirtual$Y#a @ Forbidden static field 51 | Java7StaticVsVirtual$Y#b @ Forbidden instance field 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/test/antunit/dummy.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /src/test/antunit/pom-InclExclSuppress.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | de.thetaphi 21 | forbiddenapi-test2 22 | 0.0-SNAPSHOT 23 | Dummy Project to test annotations and includes/excludes 24 | 25 | 26 | 27 | 28 | ${groupId} 29 | ${artifactId} 30 | ${version} 31 | 32 | . 33 | true 34 | 35 | jdk-system-out 36 | 37 | 40 | 41 | Java8Annotations*.class 42 | 43 | 44 | 45 | Java8Annotations$*.class 46 | 47 | 48 | 49 | Java8Annotations$* 50 | 51 | 52 | 53 | 54 | 55 | check 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/test/antunit/pom-sigArtifacts.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | de.thetaphi 21 | forbiddenapi-test3 22 | 0.0-SNAPSHOT 23 | Dummy Project to test signatures from Maven artifacts 24 | 25 | 26 | 27 | 28 | ${groupId} 29 | ${artifactId} 30 | ${version} 31 | 32 | . 33 | false 34 | 35 | 36 | ${groupId} 37 | ${artifactId} 38 | ${version} 39 | jar 40 | 41 | de/thetaphi/forbiddenapis/signatures/jdk-deprecated-${jdk.version}.txt 42 | 43 | 44 | 45 | 46 | 47 | 48 | check 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/test/antunit/signatures1.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | @defaultMessage You are crazy that you disallow substrings 16 | java.lang.String#substring(int,int) 17 | -------------------------------------------------------------------------------- /src/test/gradle/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // The following properties need to be defined in gradle.properties next to this file: 18 | // - forbiddenRootDir 19 | // - forbiddenClasspath 20 | // - forbiddenTestClasspath 21 | // - forbiddenSourceCompatibility 22 | 23 | buildscript { 24 | dependencies { 25 | classpath fileTree(dir: new File(forbiddenRootDir, 'dist'), include: '*.jar') 26 | } 27 | } 28 | 29 | apply plugin: 'java' 30 | apply plugin: 'de.thetaphi.forbiddenapis' 31 | 32 | if (project.extensions.findByName('java')) { 33 | 34 | java { 35 | sourceCompatibility = JavaVersion.toVersion(forbiddenSourceCompatibility) 36 | } 37 | 38 | } else { 39 | // TODO: Remove this after Gradle 4.10 40 | sourceCompatibility = JavaVersion.toVersion(forbiddenSourceCompatibility) 41 | } 42 | 43 | sourceSets { 44 | main { 45 | compileClasspath = files(forbiddenClasspath.tokenize(File.pathSeparator)) 46 | java { 47 | srcDirs = [new File(forbiddenRootDir, 'src/main/java')] 48 | } 49 | } 50 | main2 { 51 | compileClasspath = files(forbiddenClasspath.tokenize(File.pathSeparator)) 52 | java { 53 | srcDirs = [new File(forbiddenRootDir, 'src/main/java')] 54 | } 55 | } 56 | test { 57 | compileClasspath = files(forbiddenTestClasspath.tokenize(File.pathSeparator)) 58 | java { 59 | srcDirs = [new File(forbiddenRootDir, 'src/test/java')] 60 | } 61 | } 62 | } 63 | 64 | forbiddenApis { 65 | bundledSignatures = [ 'jdk-unsafe', 'jdk-deprecated', 'jdk-non-portable', 'jdk-reflection' ] 66 | signaturesFiles += files(new File(forbiddenRootDir, 'src/tools/signatures/mysignatures.txt')) 67 | failOnUnsupportedJava = false 68 | } 69 | 70 | forbiddenApisMain { 71 | bundledSignatures.add('jdk-internal') 72 | } 73 | 74 | forbiddenApisMain2 { 75 | bundledSignatures += 'jdk-system-out' 76 | } 77 | 78 | forbiddenApisTest { 79 | // keep defaults from "forbiddenApis" above 80 | } 81 | -------------------------------------------------------------------------------- /src/test/java/de/thetaphi/forbiddenapis/AsmUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis; 18 | 19 | import static de.thetaphi.forbiddenapis.AsmUtils.glob2Pattern; 20 | import static de.thetaphi.forbiddenapis.AsmUtils.isGlob; 21 | import static de.thetaphi.forbiddenapis.AsmUtils.isPortableRuntimeClass; 22 | import static de.thetaphi.forbiddenapis.AsmUtils.isRuntimeModule; 23 | import static org.junit.Assert.assertEquals; 24 | import static org.junit.Assert.assertFalse; 25 | import static org.junit.Assert.assertTrue; 26 | 27 | import java.util.ArrayList; 28 | import java.util.regex.Pattern; 29 | 30 | import org.junit.Test; 31 | 32 | public final class AsmUtilsTest { 33 | 34 | @Test 35 | public void testIsGlob() { 36 | assertTrue(isGlob("a.b.c.*")); 37 | assertTrue(isGlob("sun.**")); 38 | assertTrue(isGlob("a?bc.x")); 39 | assertFalse(isGlob(Object.class.getName())); 40 | assertFalse(isGlob(getClass().getName())); 41 | assertFalse(isGlob("sun.misc.Unsafe$1")); 42 | } 43 | 44 | @Test 45 | public void testGlob() { 46 | Pattern pat = glob2Pattern("a.b.c.*"); 47 | assertTrue(pat.matcher("a.b.c.d").matches()); 48 | assertTrue(pat.matcher("a.b.c.def").matches()); 49 | assertFalse(pat.matcher("a.b.c").matches()); 50 | assertFalse(pat.matcher("a.b.c.d.e").matches()); 51 | 52 | pat = glob2Pattern("a.b.c.**"); 53 | assertTrue(pat.matcher("a.b.c.d").matches()); 54 | assertTrue(pat.matcher("a.b.c.def").matches()); 55 | assertTrue(pat.matcher("a.b.c.d.e").matches()); 56 | assertTrue(pat.matcher("a.b.c.d.e.f").matches()); 57 | 58 | pat = glob2Pattern("sun.*.*"); 59 | assertTrue(pat.matcher("sun.misc.Unsafe").matches()); 60 | assertTrue(pat.matcher("sun.misc.Unsafe$1").matches()); 61 | assertFalse(pat.matcher("sun.misc.Unsafe.xy").matches()); 62 | 63 | pat = glob2Pattern("java.**.Array?"); 64 | assertTrue(pat.matcher("java.util.Arrays").matches()); 65 | assertFalse(pat.matcher("java.util.ArrayList").matches()); 66 | assertFalse(pat.matcher("java.util.Array").matches()); 67 | assertTrue(pat.matcher("java.lang.reflect.Arrays").matches()); 68 | } 69 | 70 | @Test 71 | public void testCrazyPatterns() { 72 | // those should not cause havoc: 73 | assertEquals("java\\.\\{.*\\}\\.Array", glob2Pattern("java.{**}.Array").pattern()); 74 | assertEquals("java\\./.*<>\\.Array\\$1", glob2Pattern("java./**<>.Array$1").pattern()); 75 | assertEquals("\\+\\^\\$", glob2Pattern("+^$").pattern()); 76 | } 77 | 78 | @Test 79 | public void testPortableRuntime() { 80 | assertFalse(isPortableRuntimeClass("sun.misc.Unsafe")); 81 | assertFalse(isPortableRuntimeClass("jdk.internal.Asm")); 82 | assertFalse(isPortableRuntimeClass("sun.misc.Unsafe$1")); 83 | assertTrue(isPortableRuntimeClass(Object.class.getName())); 84 | assertTrue(isPortableRuntimeClass(ArrayList.class.getName())); 85 | assertTrue(isPortableRuntimeClass("org.w3c.dom.Document")); 86 | assertFalse(isPortableRuntimeClass(getClass().getName())); 87 | } 88 | 89 | @Test 90 | public void testRuntimeModule() { 91 | assertTrue(isRuntimeModule("java.base")); 92 | assertTrue(isRuntimeModule("java.sql")); 93 | assertTrue(isRuntimeModule("java.xml.ws")); 94 | assertTrue(isRuntimeModule("jdk.nashorn")); 95 | assertFalse(isRuntimeModule(null)); 96 | assertFalse(isRuntimeModule("foo")); 97 | assertFalse(isRuntimeModule("foo.bar")); 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /src/test/java/de/thetaphi/forbiddenapis/SignaturesParserTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.thetaphi.forbiddenapis; 18 | 19 | import static org.junit.Assert.assertEquals; 20 | import static org.junit.Assert.fail; 21 | 22 | import org.junit.Test; 23 | 24 | public final class SignaturesParserTest { 25 | 26 | @Test 27 | public void testTargetVersionFix() throws Exception { 28 | assertEquals("jdk-dummy-1.7", Signatures.fixTargetVersion("jdk-dummy-1.7")); 29 | assertEquals("jdk-dummy-1.7", Signatures.fixTargetVersion("jdk-dummy-7")); 30 | assertEquals("jdk-dummy-1.7", Signatures.fixTargetVersion("jdk-dummy-7.0")); 31 | 32 | assertEquals("jdk-dummy-1.1", Signatures.fixTargetVersion("jdk-dummy-1.1")); 33 | 34 | assertEquals("jdk-dummy-9", Signatures.fixTargetVersion("jdk-dummy-9")); 35 | assertEquals("jdk-dummy-9", Signatures.fixTargetVersion("jdk-dummy-9.0")); 36 | 37 | assertEquals("jdk-dummy-18", Signatures.fixTargetVersion("jdk-dummy-18")); 38 | assertEquals("jdk-dummy-18.3", Signatures.fixTargetVersion("jdk-dummy-18.3")); 39 | assertEquals("jdk-dummy-18.3", Signatures.fixTargetVersion("jdk-dummy-18.03")); 40 | 41 | assertFails("jdk-dummy-0"); 42 | assertFails("jdk-dummy-1"); 43 | 44 | assertFails("jdk-dummy-1.7.1"); 45 | assertFails("jdk-dummy-1.7.1.1"); 46 | assertFails("jdk-dummy-1.7.0.1"); 47 | 48 | assertFails("jdk-dummy-7.1"); 49 | assertFails("jdk-dummy-7.1.1"); 50 | assertFails("jdk-dummy-7.0.1"); 51 | 52 | assertFails("jdk-dummy-1.9"); 53 | assertFails("jdk-dummy-9.0.1"); 54 | assertFails("jdk-dummy-9.0.0.1"); 55 | } 56 | 57 | private void assertFails(String name) { 58 | try { 59 | Signatures.fixTargetVersion(name); 60 | fail("Should fail for: " + name); 61 | } catch (ParseException pe) { 62 | // pass 63 | } 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/tools/gradle-plugin-portal/build.gradle.template: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | plugins { 18 | id "com.gradle.plugin-publish" version "0.11.0" 19 | } 20 | 21 | def publishGroup = '@GROUPID@' 22 | group = '@GROUPID@.ignored' 23 | version = '@VERSION@' 24 | 25 | pluginBundle { 26 | website = 'https://github.com/policeman-tools/forbidden-apis' 27 | vcsUrl = 'https://github.com/policeman-tools/forbidden-apis' 28 | 29 | plugins { 30 | forbiddenApisPlugin { 31 | id = 'de.thetaphi.forbiddenapis' 32 | displayName = 'Policeman\'s Forbidden API Checker' 33 | description = 'Allows to parse Java byte code to find invocations of method/class/field signatures and fail build.' 34 | tags = ['forbiddenapis', 'verification', 'code checker', 'static analysis'] 35 | } 36 | } 37 | 38 | mavenCoordinates { 39 | groupId = publishGroup 40 | artifactId = project.name 41 | } 42 | } 43 | 44 | repositories { 45 | mavenCentral() 46 | mavenLocal() 47 | } 48 | 49 | configurations { 50 | pluginArtifacts.transitive = false 51 | } 52 | 53 | dependencies { 54 | pluginArtifacts group: publishGroup, name: project.name, version: project.version 55 | pluginArtifacts group: publishGroup, name: project.name, version: project.version, classifier: 'sources' 56 | } 57 | 58 | task copyPluginArtifacts(type: Copy) { 59 | group 'Build' 60 | description 'Copies plugin artifacts (from Maven) to local folder for publishing' 61 | from configurations.pluginArtifacts 62 | into libsDir 63 | } 64 | 65 | publishPlugins { 66 | dependsOn('copyPluginArtifacts') 67 | } 68 | 69 | afterEvaluate { 70 | configurations.archives.artifacts.removeAll{ 71 | it.classifier=='javadoc' 72 | } 73 | tasks.withType(Jar) { 74 | enabled = false 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/tools/gradle-plugin-portal/settings.gradle.template: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | rootProject.name = '@ARTIFACTID@' 18 | -------------------------------------------------------------------------------- /src/tools/groovy/generate-deprecated-java7.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import de.thetaphi.forbiddenapis.DeprecatedGen; 18 | 19 | import java.util.zip.ZipEntry; 20 | import java.util.zip.ZipInputStream; 21 | 22 | new DeprecatedGen(properties['build.java.runtime'], new File(properties['java.home'], "lib/rt.jar"), properties['deprecated.output.file'] as File) { 23 | @Override 24 | protected void collectClasses(File source) throws IOException { 25 | new ZipInputStream(new FileInputStream(source)).withStream { 26 | ZipEntry entry; 27 | while ((entry = it.getNextEntry()) != null) { 28 | try { 29 | if (entry.isDirectory()) continue; 30 | if (entry.getName().endsWith(".class")) { 31 | parseClass(it); 32 | } 33 | } finally { 34 | it.closeEntry(); 35 | } 36 | } 37 | } 38 | } 39 | }.run(); 40 | -------------------------------------------------------------------------------- /src/tools/groovy/generate-deprecated-java9.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import de.thetaphi.forbiddenapis.DeprecatedGen; 18 | 19 | import java.nio.file.Files; 20 | import java.nio.file.FileVisitResult; 21 | import java.nio.file.Path; 22 | import java.nio.file.Paths; 23 | import java.nio.file.PathMatcher; 24 | import java.nio.file.SimpleFileVisitor; 25 | import java.nio.file.attribute.BasicFileAttributes; 26 | 27 | new DeprecatedGen(properties['build.java.runtime'], URI.create("jrt:/"), properties['deprecated.output.file'] as File) { 28 | @Override 29 | protected void collectClasses(URI uri) throws IOException { 30 | Path modules = Paths.get(uri).getRoot().resolve('modules'); // needed for Java 9-12 only, but does not hurt! 31 | PathMatcher fileMatcher = modules.getFileSystem().getPathMatcher("glob:/modules/java.**/*.class"); 32 | Files.walkFileTree(modules, new SimpleFileVisitor() { 33 | @Override 34 | public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { 35 | if (fileMatcher.matches(file)) { 36 | // System.out.println(file); 37 | Files.newInputStream(file).withStream { parseClass(it) }; 38 | } 39 | return FileVisitResult.CONTINUE; 40 | } 41 | }); 42 | } 43 | }.run(); 44 | -------------------------------------------------------------------------------- /src/tools/groovy/generate-deprecated.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright Uwe Schindler (Generics Policeman) and others. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import org.apache.tools.ant.BuildException; 18 | 19 | URL objectClassURL = ClassLoader.getSystemClassLoader().getResource("java/lang/Object.class"); 20 | boolean isJava9 = Class.metaClass.respondsTo(Class.class, 'getModule') || 21 | (objectClassURL != null && "jrt".equalsIgnoreCase(objectClassURL.getProtocol())); 22 | 23 | boolean hasRTJar = new File(properties['java.home'], "lib/rt.jar").isFile(); 24 | 25 | String vendor = properties['java.vendor'].toLowerCase(Locale.ROOT); 26 | boolean isOracle = vendor.contains("oracle") || vendor.contains("sun microsystems"); 27 | boolean isDetectedJavaVersion = properties['java.version'].startsWith(properties['build.java.runtime']); 28 | if (!isDetectedJavaVersion) { 29 | isDetectedJavaVersion = properties['java.version'].startsWith('9') && properties['build.java.runtime'] == '1.9'; 30 | } 31 | 32 | if (isOracle && isDetectedJavaVersion && (isJava9 || hasRTJar)) { 33 | String script = isJava9 ? "generate-deprecated-java9.groovy" : "generate-deprecated-java7.groovy"; 34 | evaluate(new File(properties['groovy-tools.dir'], script)); 35 | } else { 36 | throw new BuildException("Regenerating the deprecated signatures files need stock Oracle/Sun JDK, "+ 37 | "but your Java version or operating system is unsupported: " + properties['build.java.info']); 38 | } 39 | -------------------------------------------------------------------------------- /src/tools/signatures/mysignatures.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright Uwe Schindler (Generics Policeman) and others. 2 | # Parts of this work are licensed to the Apache Software Foundation (ASF) 3 | # under one or more contributor license agreements. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | @defaultMessage Read class files with AsmUtils.readAndPatchClass(InputStream) 18 | org.objectweb.asm.ClassReader#(java.io.InputStream) 19 | org.objectweb.asm.ClassReader#(byte[]) 20 | org.objectweb.asm.ClassReader#(byte[],int,int) 21 | org.objectweb.asm.ClassReader#(java.lang.String) 22 | 23 | # Some buggy methods: 24 | java.io.InputStream#available() @ This may return small numbers and relies on underlying implementation 25 | java.io.InputStream#skip(long) @ Relies on underlying implementation -- see https://issues.apache.org/jira/browse/IO-203 and use IOUtils.skipFully(long) --------------------------------------------------------------------------------