Enable recognising jakarta.persistence in dead-code queries

This commit is contained in:
Chris Smowton
2025-04-01 16:19:42 +01:00
parent fb6296a564
commit a5a6fd37df
3 changed files with 9 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ import semmle.code.java.deadcode.DeadCode
import semmle.code.java.frameworks.javaee.Persistence
import semmle.code.java.frameworks.JAXB
import semmle.code.java.frameworks.jackson.JacksonSerializability
import semmle.code.java.frameworks.javaee.Persistence
/**
* A field that is from a source file.
@@ -161,10 +162,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()
)

View File

@@ -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
@@ -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