JetBrains / java-annotations

Annotations for JVM-based languages.
Apache License 2.0
398 stars 46 forks source link

@CalledFromNative annotation #45

Open amaembo opened 3 years ago

amaembo commented 3 years ago

From https://youtrack.jetbrains.com/issue/IDEA-163737:

A very usefull annotation would be a @CalledFromNative that would be used to mark class methods that are meant to be called from native code. This annotation would allow for suppressing of the "method is never used" inspection and would in general help in clarifying the code. This would especially be useful in Android (Studio) projects that mix java and native code.

realityforge commented 3 years ago

It would also be useful in other contexts such as transpiling to javascript via tools such as J2CL and GWT where java code often exists so it can be called from javascript but may not be invoked from java. Although we mostly just add it to the list of annotations that define entrypoints.

sixcorners commented 3 years ago

Would it make sense to make an Entrypoint annotation that can be used to annotate other annotations that are put on entrypoints? I'm thinking it would go on annotations like org.kohsuke.MetaInfServices and this CalledFromNative annotation. Or maybe it could be used directly on program elements?