Annotate function with heavy and/or security impact

Is there an annotation (or any other way) to mark functions with heavy performance and/or security impact in my code so other programmers will be notified some way before using the function.

Of course the functions should be properly documented, but a lot of programmers just use the function list that pops up. It would be nice to have something like the experimental annotations to inform them that they actually should check out the documentation before they use the function. Would be even better to force them to annotate their code like experimental does, only these functions are not experimental but need special attention.

Depending on how evil you feel you can use the @Deprecated annotation to mark special methods and functions. Using the warn level will remind users to suppress the annotation or suffer never ending reminders.

I don’t think abusing the Deprecated annotation is a good way to solve this, but I can’t think of anything else. Well I guess the experimental stuff would work as well, but I don’t think this is good either.

The problem is that the compiler can’t differentiate between the first time this function is used in a context and any later point when the program is recompiled. Something like this would just lead to either a lot of suppressed warnings or so many warnings that they become meaningless.

Maybe a better way to solve this (without annotations or anything like it) would be to put those functions into their own package foo.bar.critical and make them extension functions. This won’t help all the time but it might sometimes remind the user to check it. But this is only possible if you don’t need to access private class members.

Well, I wouldn’t go with deprecation, it already has a very specific meaning and I feel it confusing to use it for another purpose.

I don’t think number of warnings would a problem. Out policy is to keep the code warning free and not by suppressing them as in my experience warnings are very useful. These methods should not be used frequently, that’s the whole point.

Having an annotation like this would actually improve code quality a lot as problematic points are highlighted and that is good for both security and performance.

You could use the new Experimental API marker, so developers have to opt-in to use the function marked as heavy or with a security impact

Here’s an ugly solution.

Add a parameter “thisIsAHeavyFunction” that must be set to a “secret” value that’s buried in the documentation. If the correct value is not used, an exception is thrown.