Skip to content

Java: generalise javax.persistence models to also recognise jakarta.persistence. #19187

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

Merged
merged 7 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions java/ql/lib/change-notes/2025-04-01-jakarta-persistence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* All existing modelling and support for `javax.persistence` now applies to `jakarta.persistence` as well.
4 changes: 2 additions & 2 deletions java/ql/lib/semmle/code/java/deadcode/DeadField.qll
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ class JpaReadField extends ReflectivelyReadField {
this = entity.getAField() and
(
entity.getAccessType() = "field" or
this.hasAnnotation("javax.persistence", "Access")
this.hasAnnotation(getAPersistencePackageName(), "Access")
)
|
not this.hasAnnotation("javax.persistence", "Transient") and
not this.hasAnnotation(getAPersistencePackageName(), "Transient") and
not this.isStatic() and
not this.isFinal()
)
Expand Down
3 changes: 2 additions & 1 deletion java/ql/lib/semmle/code/java/deadcode/EntryPoints.qll
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import semmle.code.java.deadcode.StrutsEntryPoints
import semmle.code.java.deadcode.TestEntryPoints
import semmle.code.java.deadcode.WebEntryPoints
import semmle.code.java.frameworks.javaee.JavaServerFaces
import semmle.code.java.frameworks.javaee.Persistence
import semmle.code.java.frameworks.JAXB
import semmle.code.java.frameworks.JaxWS
import semmle.code.java.JMX
Expand Down Expand Up @@ -395,7 +396,7 @@ class PersistencePropertyMethod extends CallableEntryPoint {
this = e.getACallable() and
(
e.getAccessType() = "property" or
this.hasAnnotation("javax.persistence", "Access")
this.hasAnnotation(getAPersistencePackageName(), "Access")
) and
(
this.getName().matches("get%") or
Expand Down
Loading