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

8317818: Combinatorial explosion during 'this' escape analysis #16125

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
@@ -167,7 +167,7 @@ class ThisEscapeAnalyzer extends TreeScanner {

/** Used to terminate recursion in {@link #invokeInvokable invokeInvokable()}.
*/
private final Set<Pair<JCTree, RefSet<Ref>>> invocations = new HashSet<>();
private final Set<Pair<JCMethodDecl, RefSet<Ref>>> invocations = new HashSet<>();

/** Snapshot of {@link #callStack} where a possible 'this' escape occurs.
* If non-null, a 'this' escape warning has been found in the current
@@ -590,7 +590,7 @@ private void invokeInvokable(JCTree site, List<JCExpression> args,
return;

// Stop infinite recursion here
Pair<JCTree, RefSet<Ref>> invocation = Pair.of(site, refs.clone());
Pair<JCMethodDecl, RefSet<Ref>> invocation = Pair.of(methodInfo.declaration, refs.clone());
if (!invocations.add(invocation))
return;

30 changes: 30 additions & 0 deletions test/langtools/tools/javac/warnings/ThisEscape.java
Original file line number Diff line number Diff line change
@@ -617,4 +617,34 @@ public ThisEscapeAssertionError2() {
;
}
}

// Verify no infinite recursion loop occurs (JDK-8317818)
public static class ThisEscapeRecursionExplosion {
private Object obj;
public ThisEscapeRecursionExplosion() {
getObject();
}
private Object getObject() {
if (this.obj == null) {
this.obj = new Object();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
getObject().hashCode();
}
return this.obj;
}
}
}