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

Make synthetic class outputs deterministic #52

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
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
19 changes: 13 additions & 6 deletions src/main/java/org/checkerframework/specimin/UnsolvedClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.base.Splitter;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.checkerframework.checker.signature.qual.ClassGetSimpleName;
Expand All @@ -12,14 +13,20 @@
* The reason is that the class file is not in the root directory.
*/
public class UnsolvedClass {
/** Set of methods belongs to the class */
private final Set<UnsolvedMethod> methods;
/**
* Set of methods belongs to the class. Must be a linked set to ensure deterministic iteration
* order when writing files synthetic classes.
*/
private final LinkedHashSet<UnsolvedMethod> methods;

/** The name of the class */
private final @ClassGetSimpleName String className;

/** The fields of this class */
private final Set<String> classFields;
/**
* The fields of this class. Must be a linked set to ensure deterministic iteration order when
* writing files for synthetic classes.
*/
private final LinkedHashSet<String> classFields;

/**
* The name of the package of the class. We rely on the import statements from the source codes to
Expand All @@ -35,9 +42,9 @@ public class UnsolvedClass {
*/
public UnsolvedClass(@ClassGetSimpleName String className, String packageName) {
this.className = className;
this.methods = new HashSet<>();
this.methods = new LinkedHashSet<>();
this.packageName = packageName;
this.classFields = new HashSet<>();
this.classFields = new LinkedHashSet<>();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.wild;
public class Mammal {
public boolean canBreathUnderWater = false;

public String habitat = null;

public boolean canBreathUnderWater = false;
}