Skip to content

Java: Improve a couple of join-orders #20127

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 3 commits into from
Aug 5, 2025
Merged
Changes from 1 commit
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
Next Next commit
Java: Untangle code a bit to improve join order.
  • Loading branch information
aschackmull committed Jul 25, 2025
commit e3021f4a65bdc3cd47264d8f440e5aa428528b7a
34 changes: 18 additions & 16 deletions java/ql/src/Likely Bugs/Resource Leaks/CloseType.qll
Original file line number Diff line number Diff line change
Expand Up @@ -212,33 +212,35 @@ private LocalVariableDecl getCloseableVariable(CloseableInitExpr cie) {
/**
* A variable on which a "close" method is called, implicitly or explicitly, directly or indirectly.
*/
private predicate closeCalled(Variable v) {
private predicate closeCalled(LocalScopeVariable v) {
// `close()` is implicitly called on variables declared or referenced
// in the resources clause of try-with-resource statements.
exists(TryStmt try | try.getAResourceVariable() = v)
or
// Otherwise, there should be an explicit call to a method whose name contains "close".
exists(MethodCall e |
v = getCloseableVariable(_) or v instanceof Parameter or v instanceof LocalVariableDecl
|
e.getMethod().getName().toLowerCase().matches("%close%") and
exists(VarAccess va | va = v.getAnAccess() |
e.getQualifier() = va or
e.getAnArgument() = va
)
or
// The "close" call could happen indirectly inside a helper method of unknown name.
exists(int i | e.getArgument(i) = v.getAnAccess() |
exists(Parameter p, int j | p.getPosition() = j and p.getCallable() = e.getMethod() |
closeCalled(p) and i = j
or
// The helper method could be iterating over a varargs parameter.
exists(EnhancedForStmt for | for.getExpr() = p.getAnAccess() |
closeCalled(for.getVariable().getVariable())
) and
p.isVarargs() and
j <= i
)
)
or
// The "close" call could happen indirectly inside a helper method of unknown name.
exists(Parameter p |
closeCalled(p) and p.getAnArgument() = v.getAnAccess() and p.getCallable() instanceof Method
)
or
exists(MethodCall e, int i | e.getArgument(i) = v.getAnAccess() |
exists(Parameter p, int j |
p.getPosition() = j and p.getCallable() = e.getMethod().getSourceDeclaration()
|
// The helper method could be iterating over a varargs parameter.
exists(EnhancedForStmt for | for.getExpr() = p.getAnAccess() |
closeCalled(for.getVariable().getVariable())
) and
p.isVarargs() and
j <= i
)
)
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy