This project has been retired
Kotlin Java
Switch branches/tags
validation-01 build-0.2.7907 build-0.2.7903 build-0.2.7902 build-0.2.7901 build-0.2.7899 build-0.2.7898 build-0.2.7897 build-0.2.7896 build-0.2.7895 build-0.2.7894 build-0.2.7893 build-0.2.7892 build-0.2.7891 build-0.2.7889 build-0.2.7888 build-0.2.7887 build-0.2.7886 build-0.2.7885 build-0.2.7884 build-0.2.7883 build-0.2.7882 build-0.2.7880 build-0.2.7879 build-0.2.7878 build-0.2.7877 build-0.2.7876 build-0.2.7875 build-0.2.7874 build-0.2.7873 build-0.2.7872 build-0.2.7871 build-0.2.7870 build-0.2.7869 build-0.2.7868 build-0.2.7867 build-0.2.7866 build-0.2.7865 build-0.2.7864 build-0.2.7863 build-0.2.7862 build-0.2.7861 build-0.2.7860 build-0.2.7859 build-0.2.7858 build-0.2.7857 build-0.2.7856 build-0.2.7855 build-0.2.7854 build-0.2.7853 build-0.2.7852 build-0.2.7851 build-0.2.7850 build-0.2.7849 build-0.2.7847 build-0.2.7846 build-0.2.7845 build-0.2.7844 build-0.2.7843 build-0.2.7842 build-0.2.7841 build-0.2.7840 build-0.2.7839 build-0.2.7838 build-0.2.7837 build-0.2.7836 build-0.2.7835 build-0.2.7834 build-0.2.7833 build-0.2.7832 build-0.2.7831 build-0.2.7830 build-0.2.7829 build-0.2.7828 build-0.2.7827 build-0.2.7826 build-0.2.7825 build-0.2.7824 build-0.2.7823 build-0.2.7822 build-0.2.7821 build-0.2.7820 build-0.2.7819 build-0.2.7818 build-0.2.7817 build-0.2.7816 build-0.2.7815 build-0.2.7814 build-0.2.7813 build-0.2.7812 build-0.2.7811 build-0.2.7810 build-0.2.7809 build-0.2.7808 build-0.2.7807 build-0.2.7806 build-0.2.7805 build-0.2.7804 build-0.2.7803 build-0.2.7802
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


obsolete project

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.


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/]