This project has been retired
Kotlin Java
Latest commit 43a27b5 Jan 28, 2016 @yole yole Merge pull request #34 from JetBrains/yole-patch-1
Update README.md
Permalink
Failed to load latest commit information.
.idea Add dependency on kotlin-test.jar Dec 25, 2015
android-custom Fix for KT-5293 Compilation breaks : Accidental override, methods hav… Jun 21, 2014
android-sdk-annotations-kotlin-plugin fixing android annotations Feb 28, 2014
commandLineClient Migration to 1.0 beta Oct 20, 2015
idea_runner Fix compilation in kannotator and make idea KAnnotator configuration … Dec 9, 2012
integration_tests fix compilation and remove some unnecessary imports Nov 12, 2015
jdk-custom Add ConcurrentHashMap annotations from idea annotations Jun 5, 2015
kotlinlib/kotlinlib Additional migration fixes (underscore, inline) Oct 20, 2015
lib Tests for annotation loading: refactoring, cleanup Feb 25, 2014
license scene lib added Aug 26, 2013
plugin Remove KotlinSignature from project code, declare it in tests Dec 7, 2015
scene-lib Remove KotlinSignature from project code, declare it in tests Dec 7, 2015
src/org/jetbrains/kannotator Remove KotlinSignature from project code, declare it in tests Dec 7, 2015
test Migrate function type parameter syntax to 1.0 Dec 7, 2015
testData Remove KotlinSignature from project code, declare it in tests Dec 7, 2015
.gitignore Add dependency on kotlin-test.jar Dec 25, 2015
README.md Update README.md Jan 28, 2016
TeamCityBuild.xml Plugin version replace Dec 6, 2012
VerifyAndPublish.xml Verifier URL is always provided from teamcity. Jan 15, 2014
kannotator.iml minor: removing empty obsolete module kannotatorRuntime Feb 25, 2014
manifest.properties stuff for building android annotations Feb 17, 2014
sdk_annotations.xml Add ConcurrentHashMap annotations from idea annotations Jun 5, 2015
update_dependencies.xml IDEA 133.193 Dec 17, 2013

README.md

KAnnotator

Infer @Nullable/@NotNull and other annotations from byte code

What is KAnnotator

If you have a Java library binaries (e.g. jar-files), KAnnotator can analyze them and tell you some information about contracts of the methods in this library. For example:

  • Does this method admit null as a value for this parameter?
  • Does this method ever return null?
  • Does this method mutate this collection passed to it?

Output format

The contracts are represented as annotations on Java method, hence the name of the project. Since libraries under analysis are not under user's control, the annotations can not be added to their code directly, so KAnnotator stores them in one of the two formats:

  • XML-based External annotation definitions supported by IntelliJ IDEA
  • .jaif-files, supported by Checkers Framework

Kotlin and KAnnotator

KAnnotator was originally created to support Kotlin — a JVM-targeted programming language that has null-safety built into its type system. Our experience has shown that external annotations are not a good fit for the Kotlin workflow, so we've removed support for external annotations from Kotlin and added support for platform types instead.

If you're using Kotlin, you do not need KAnnotator

Java 8 and KAnnotator

With JSR 308 and Checkers Framework coming soon, KAnnotator gets another application area: the annotations it infers for Java libraries can be used by Java code checkers to verify Java code that uses these libraries.

Downloads

KAnnotator binaries are available from the github release page

Additionally, IntelliJ IDEA plugin is available though a plugin repository

How to run KAnnotator

KAnnotator can be run by different means:

$ java -jar kannotator-cli.jar
  -f --format=<enum>                - output format: jaif or xml [default XML]
  -n --nullability=<boolean>        - produce nullability annotations [default false]
  -m --mutability=<boolean>         - produce mutability annotations [default false]
  -v --verbose=<boolean>            - be verbose and show progress indicator [default false]
  -c --one-directory-tree=<boolean> - do not create specific subdirectories for each library [default false]
  -o --output-path=<string>         - output path [default annotations/]