Skip to content

Commit

Permalink
Fix stackoverflow when trying to decompile a local class that constru…
Browse files Browse the repository at this point in the history
…cts its self.

Example:

class Scratch {
    public static void main(String[] args) {
        record Example() {
            static Example createExample() {
                return new Example();
            }
        }
        Example example = Example.createExample();
    }
}
  • Loading branch information
modmuss50 committed Feb 15, 2024
1 parent 53fa44c commit 7c48b8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
sourceCompatibility = 1.8
targetCompatibility = 1.8

version = '0.2.1'
version = '0.2.2'

def ENV = System.getenv()
version = version + (ENV.GITHUB_ACTIONS ? "" : "+local")
Expand Down
4 changes: 3 additions & 1 deletion src/org/benf/cfr/reader/entities/Method.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ public void markUsedLocalClassType(JavaTypeInstance javaTypeInstance, String sug
javaTypeInstance = javaTypeInstance.getDeGenerifiedType();
if (!(javaTypeInstance instanceof JavaRefTypeInstance))
throw new IllegalStateException("Bad local class Type " + javaTypeInstance.getRawName());
localClasses.put((JavaRefTypeInstance) javaTypeInstance, suggestedName);
if (((JavaRefTypeInstance) javaTypeInstance).getClassFile() == this.classFile)
return; // Recursive local class, can happen if the local class is constructed within its self.
localClasses.put((JavaRefTypeInstance) javaTypeInstance, suggestedName);
}

public void markUsedLocalClassType(JavaTypeInstance javaTypeInstance) {
Expand Down

0 comments on commit 7c48b8c

Please sign in to comment.