@Generated Annotation in Java does not work with jakarta

Must-share information (formatted with Markdown):

  • Version:2025.1.0.102418 (Enterprise Edition)
  • how is SonarQube deployed: dont know
  • what are you trying to achieve:
    Exclude Code from analysis via @jakarta.annotation.Generated
  • what have you tried so far to achieve this
@jakarta.annotation.Generated
@Override
public boolean myMethod() {

However, this does not work.
When i do this:

@javax.annotation.Generated
@Override
public boolean myMethod() {

when i do THIS, it does also not work.

import javax.annotation.Generated;

@Generated
@Override
public boolean myMethod() {

it DOES work. But i cant use javax because we already migrated to jakarta.

Hi @renoth,

Of course, we should support the new package. I created SONARJAVA-5404.

Thank you for your feedback,

Alban

Will this fix be applied to the LTS version of SonarQube?

This fix is part of the Java Analyzer 8.11.0.38440. It will be deployed on sonarcloud.io within one or two days. Additionally, it will be included in the upcoming SonarQube Server version 2025.2, which is expected to be released today. However, please note that this fix will not be backported to the bug fix release for the previous SonarQube Server version 2025.1 LTA.

Are you serious? We pay a lot of money for the Enterprise License and you cannot fix this very annoying error that should be fixed in the LTA version since we only use LTA on premise.

Hi @renoth,

I understand your desire to have it resolved in your SonarQube Server 2025.1 LTA environment. I want to assure you that your feedback is valuable, and we take your concerns seriously.

Regarding your request for a backport to the 2025.1 LTA, our primary objective with LTA releases is to maintain maximum stability. Backporting changes, even bug fixes, carries a risk of introducing unforeseen regressions into a stable environment. Therefore, we carefully evaluate each backport request and prioritize critical bug fixes and security patches to minimize this risk.

While the issue you’ve encountered is certainly annoying, it doesn’t currently fall under the category of a critical bug or security vulnerability that warrants a backport to the LTA.

However, I understand that this issue might be significantly impacting your workflow. If it’s a blocker for you, I recommend reaching out to Sonar’s commercial support through your usual channels. They can assess the impact on your specific environment and discuss potential solutions or workarounds. For example, by using sonar.exclusions=**/*Generated.java.

Please understand that as a developer, I don’t have the authority to override the backport policy. I’m focused on delivering the fix in the current and future releases.

We appreciate your understanding and your feedback.

2 Likes

Thanks for the info, customer support already gave the same answer.