mirror of
https://github.com/github/codeql.git
synced 2026-02-01 15:52:59 +01:00
Java: Performance tweaks
This commit is contained in:
@@ -33,7 +33,7 @@ Callable possibleLivenessCause(Callable c, string reason) {
|
||||
or
|
||||
c.hasName("<clinit>") and
|
||||
reason = "class initialization" and
|
||||
exists(RefType clintedType | c = clintedType.getASupertype*().getACallable() |
|
||||
exists(RefType clintedType | c = clintedType.getAnAncestor().getACallable() |
|
||||
result.getDeclaringType() = clintedType or
|
||||
result.getAnAccessedField().getDeclaringType() = clintedType
|
||||
)
|
||||
@@ -155,7 +155,7 @@ library class SourceClassOrInterface extends ClassOrInterface {
|
||||
*/
|
||||
class LiveClass extends SourceClassOrInterface {
|
||||
LiveClass() {
|
||||
exists(Callable c | c.getDeclaringType().getASupertype*().getSourceDeclaration() = this |
|
||||
exists(Callable c | c.getDeclaringType().getAnAncestor().getSourceDeclaration() = this |
|
||||
isLive(c)
|
||||
)
|
||||
or
|
||||
|
||||
@@ -93,7 +93,7 @@ class SerialVersionUIDField extends ReflectivelyReadField {
|
||||
this.isStatic() and
|
||||
this.isFinal() and
|
||||
this.getType().hasName("long") and
|
||||
this.getDeclaringType().getASupertype*() instanceof TypeSerializable
|
||||
this.getDeclaringType().getAnAncestor() instanceof TypeSerializable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ class DeserializedClass extends ReflectivelyConstructedClass {
|
||||
exists(CastExpr cast, ReadObjectMethod readObject |
|
||||
cast.getExpr().(MethodAccess).getMethod() = readObject
|
||||
|
|
||||
hasSubtype*(cast.getType(), this)
|
||||
hasDescendant(cast.getType(), this)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -315,7 +315,7 @@ class FacesComponentReflectivelyConstructedClass extends ReflectivelyConstructed
|
||||
* Entry point for EJB home interfaces.
|
||||
*/
|
||||
class EJBHome extends Interface, EntryPoint {
|
||||
EJBHome() { this.getASupertype*().hasQualifiedName("javax.ejb", "EJBHome") }
|
||||
EJBHome() { this.getAnAncestor().hasQualifiedName("javax.ejb", "EJBHome") }
|
||||
|
||||
override Callable getALiveCallable() { result = this.getACallable() }
|
||||
}
|
||||
@@ -324,7 +324,7 @@ class EJBHome extends Interface, EntryPoint {
|
||||
* Entry point for EJB object interfaces.
|
||||
*/
|
||||
class EJBObject extends Interface, EntryPoint {
|
||||
EJBObject() { this.getASupertype*().hasQualifiedName("javax.ejb", "EJBObject") }
|
||||
EJBObject() { this.getAnAncestor().hasQualifiedName("javax.ejb", "EJBObject") }
|
||||
|
||||
override Callable getALiveCallable() { result = this.getACallable() }
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import semmle.code.java.frameworks.struts.StrutsActions
|
||||
*/
|
||||
class Struts1ActionEntryPoint extends EntryPoint, Class {
|
||||
Struts1ActionEntryPoint() {
|
||||
this.getASupertype*().hasQualifiedName("org.apache.struts.action", "Action")
|
||||
this.getAnAncestor().hasQualifiedName("org.apache.struts.action", "Action")
|
||||
}
|
||||
|
||||
override Callable getALiveCallable() {
|
||||
@@ -22,7 +22,7 @@ class Struts1ActionEntryPoint extends EntryPoint, Class {
|
||||
result.(Method).overrides+(methodFromAction)
|
||||
)
|
||||
or
|
||||
this.getASupertype*().hasQualifiedName("org.apache.struts.actions", "DispatchAction") and
|
||||
this.getAnAncestor().hasQualifiedName("org.apache.struts.actions", "DispatchAction") and
|
||||
result.(Method).isPublic()
|
||||
or
|
||||
result.(Constructor).getNumberOfParameters() = 0
|
||||
|
||||
@@ -47,7 +47,7 @@ class ServletListenerClass extends ReflectivelyConstructedClass {
|
||||
*/
|
||||
class ServletFilterClass extends ReflectivelyConstructedClass {
|
||||
ServletFilterClass() {
|
||||
this.getASupertype*().hasQualifiedName("javax.servlet", "Filter") and
|
||||
this.getAnAncestor().hasQualifiedName("javax.servlet", "Filter") and
|
||||
// If we have seen any `web.xml` files, this filter will be considered to be live only if it is
|
||||
// referred to as a filter-class in at least one. If no `web.xml` files are found, we assume
|
||||
// that XML extraction was not enabled, and therefore consider all filter classes as live.
|
||||
|
||||
Reference in New Issue
Block a user