Skip to content

Commit

Permalink
8317818: Combinatorial explosion during 'this' escape analysis
Browse files Browse the repository at this point in the history
Reviewed-by: vromero
  • Loading branch information
archiecobbs authored and Vicente Romero committed Oct 12, 2023
1 parent 61ce739 commit 17535c3
Showing 2 changed files with 32 additions and 2 deletions.
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;
}
}
}

1 comment on commit 17535c3

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.