JAVA_REMOVE_ANNOTATIONS(7)

πŸ“¦
version 1.3.5 Β· 4 versions
, in fedora 43

πŸ’– java_remove_annotations(7) πŸ’–

okay bestie, buckle up β€” this is the manual page for java_remove_annotations, living under the Java packaging support umbrella. It's a macro that does a little spring cleaning on your Java source files, and honestly? It ate. ✨


🌸 NAME 🌸

java_remove_annotations β€” remove imports and annotations from Java source files πŸ§ΉπŸ’…


✨ SYNOPSIS ✨

%java_remove_annotations [optional flags] <matcher>... [file path]...

matchers go in, file paths go in, chaos gets removed. Simple as.


πŸ¦‹ DESCRIPTION πŸ¦‹

So like. This macro removes import statements and usage of annotations from Java source files. It's giving "I contain multitudes." πŸ’–

It does the exact same thing as java_remove_imports, and on top of that it finds all uses of annotations and matches the content between the '@' symbol and either ending with whitespace or with an opening parenthesis '(' β€” that's the annotation arguments, btw. iykyk. 😌

In case of match, the script also removes the block of parentheses that follows the matched annotation, if it is present. Not me deleting the whole little argument party along with the annotation πŸ’€

Now, file path arguments are handled the following way:

  • Symlinks are ignored. πŸ™ˆ we do not see her, she is not here
  • Regular files are handled regardless of the file name. no name-shaming in this house
  • Directories are traversed recursively and all .java files are handled. we go deep πŸ•³οΈβœ¨

Arguments can be specified in arbitrary order. The vibes are unordered, the behavior is not.


πŸŽ€ Matcher is one of:

  • -n <name> β€” simple class name to be matched against the simple names of imported symbols. Names are matched for exact equality. Can be specified multiple times. (yes bestie, stack them up 🫢)
  • -p <pattern> β€” regex patterns to be matched against imported symbols. Each imported symbol found in the code is matched against each pattern. Can be specified multiple times.

πŸ’œ Optional flags:

  • -s, --strict β€” fail if any of the user provided arguments were redundant. she is not here for your extra unused args, she will call it out 😀

🌈 EXAMPLES 🌈

Example of usage in a .spec file:

%java_remove_annotations src -n Nullable

⭐ Examples of patterns:

  • Annotations present in Java source file:
1) @SuppressWarnings
2) @SuppressFBWarnings(value = {"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
3) @org.junit.Test
4) @org.junit.jupiter.api.Test
  • Names used to match:
Name 'SuppressWarnings' matches 1)
Name 'Test' matches 3), 4).

Name 'junit' does not match anything.
  • Patterns used to match:
Pattern 'SuppressWarnings' matches 1).
Pattern 'Suppress' matches 1), 2).
Pattern 'org[.]junit[.]Test' matches 3).
Pattern 'junit' matches 3), 4).

Pattern '@SuppressWarnings' does not match anything.
Pattern 'EI_EXPOSE_REP' does not match anything.

see how 'junit' eats as a pattern but flops as a name? the way that regex and exact-equality are simply built different πŸ˜­πŸ’…


πŸ“ REPORTING BUGS πŸ“

Bugs should be reported through the issue tracker at GitHub: https://github.com/fedora-java/jurand/issues

found a bug? bestie, do NOT gatekeep it. drop it in the tracker, we're all ears πŸ‘‘πŸ’–

🧚 AUTHOR 🧚

Written by MariΓ‘n Konček. πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯

java_remove_imports(7).


and that's the whole page, no cap β€” this was JAVA_REMOVE_ANNOTATIONS(7) from Java packaging support, dated 2025-07-24. go forth and de-annotate, bestie. slay πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from