Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java: Update JAX-RS annotation inheritance #18137

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

owen-mc
Copy link
Contributor

@owen-mc owen-mc commented Nov 27, 2024

Currrently, our JAX-RS models correctly follow the spec, which says that annotations on classes and interfaces aren't inherited. However, some implementations (like Apache CXF), do allow inheritance of annotations on classes and interfaces. This PR updates our modeling to allow inheritance of those annotations (but only when the class does not have any JAX-RS annotations).

This PR also adds lots of tests.

@github-actions github-actions bot added the Java label Nov 27, 2024
@owen-mc owen-mc changed the title Add more tests demonstrating annotation inheritance Add more tests demonstrating JAX-RS annotation inheritance Nov 29, 2024
@owen-mc owen-mc force-pushed the java/jax-rs-annotation-inheritance branch from 0944ae3 to 12c6f87 Compare December 9, 2024 16:23
@owen-mc owen-mc changed the title Add more tests demonstrating JAX-RS annotation inheritance Update JAX-RS annotation inheritance Jan 7, 2025
@owen-mc owen-mc force-pushed the java/jax-rs-annotation-inheritance branch from 12c6f87 to 9cc614a Compare January 7, 2025 16:45
@owen-mc owen-mc marked this pull request as ready for review January 7, 2025 17:00
@Copilot Copilot bot review requested due to automatic review settings January 7, 2025 17:00
@owen-mc owen-mc requested a review from a team as a code owner January 7, 2025 17:00

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 9 changed files in this pull request and generated no comments.

Files not reviewed (4)
  • java/ql/lib/semmle/code/java/frameworks/JaxWS.qll: Language not supported
  • java/ql/test/library-tests/frameworks/JaxWs/JakartaRs1.java: Evaluated as low risk
  • java/ql/test/library-tests/frameworks/JaxWs/JakartaRs3.java: Evaluated as low risk
  • java/ql/test/library-tests/frameworks/JaxWs/JaxRs1.java: Evaluated as low risk
Comments suppressed due to low confidence (5)

java/ql/test/library-tests/frameworks/JaxWs/JakartaRs4.java:58

  • The @OverRide annotation is repeated. Remove the duplicate annotation.
@Override

java/ql/test/library-tests/frameworks/JaxWs/JaxRsInterface.java:27

  • The comment should be updated to: 'This annotation has no effect according to the JAX-RS specification, as class/interface annotations are not inherited.'
@Path("/resource") // This annotation has no effect, as class/interface annotations are not inherited in jax-rs

java/ql/test/library-tests/frameworks/JaxWs/JaxRs4.java:63

  • The @path annotation with an empty string is unusual and might be a mistake. Consider providing a meaningful path or removing the annotation.
@Path("")

java/ql/test/library-tests/frameworks/JaxWs/JaxRs3.java:34

  • The parameter name for @QueryParam is empty. It should be renamed to a meaningful parameter name.
@QueryParam("")

java/ql/test/library-tests/frameworks/JaxWs/JaxRs3.java:67

  • The parameter name for @QueryParam is empty. It should be renamed to a meaningful parameter name.
@QueryParam("")

Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more

@owen-mc owen-mc changed the title Update JAX-RS annotation inheritance Java: Update JAX-RS annotation inheritance Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant