If annotations don't help, I don't think there is a way to find out if the argument is null or not.
As for your published code, I think I know what is going on:
onCreate IS activity is marked as @Nullable :
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { final AppCompatDelegate delegate = getDelegate(); delegate.installViewFactory(); delegate.onCreate(savedInstanceState); . .
Although the methods of the ActivityLifecycleCallbacks interface are not : (See Application.java )
public interface ActivityLifecycleCallbacks { void onActivityCreated(Activity activity, Bundle savedInstanceState); void onActivityStarted(Activity activity); void onActivityResumed(Activity activity); void onActivityPaused(Activity activity); void onActivityStopped(Activity activity); void onActivitySaveInstanceState(Activity activity, Bundle outState); void onActivityDestroyed(Activity activity); }
Therefore, apparently, the Kotlin translator processes annotations, but uses Non-Null as the default value, which in my humble opinion is not usual, since it makes sense to consider non-annotated Nullable parameters. However, I can understand this solution in order to get developers to pay attention to the translated code and explicitly decide whether the parameter is Nullable or not.
By the way, remember that there are several annotations
@NonNull and
@Nullable (javax, android, jetbrains ...) I wonβt be surprised if the translator Kotlin recognizes only some of them (but this is just an assumption)
Also, with regard to your code, Java Lint should have given you a warning about your overridden onCreate , stating that you are overriding a method with annotated parameters, and you did not annotate it.