Skip to content
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
7 changes: 5 additions & 2 deletions java/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -758,9 +758,12 @@ very_clean: very-clean
very-clean: clean clean-generated-files
-rm -f TAGS
-rm -rf dcomp_premain.jar dcomp_rt.jar ${DCOMP_RT}
-rm -rf api
-rm -rf daikon/dcomp/std_dcomp_out.diff daikon/dcomp/std_dcomp_out.txt
-rm -rf api/
-rm -rf daikon/chicory/ChicoryTest.inv.out
-rm -rf daikon/chicory/debug/
-rm -rf daikon/dcomp/debug/
-rm -rf daikon/dcomp/DcompTest.log
-rm -rf daikon/dcomp/std_dcomp_out.diff daikon/dcomp/std_dcomp_out.txt

run: all
${JAVA_COMMAND} daikon.Daikon
Expand Down
10 changes: 8 additions & 2 deletions java/daikon/AnnotateNullable.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,15 @@ public static void main(String[] args) throws IOException {
}
}

// Returns null if no corresponding class ppt exists
/**
* Returns the class program point corresponding to an object program point. Returns null if no
* corresponding class ppt exists.
*
* @param object_ppt an object program point
* @return the class program point corresponding to an object program point
*/
private static @Nullable PptTopLevel class_for_object(PptTopLevel object_ppt) {
if (object_ppt.parents.size() == 0) {
if (object_ppt.parents.isEmpty()) {
return null;
}
assert object_ppt.parents.size() == 1 : object_ppt;
Expand Down
12 changes: 6 additions & 6 deletions java/daikon/Daikon.java
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ public static void mainHelper(final String[] args) {
Set<String> dtrace_files = files.dtrace;
Set<File> spinfo_files = files.spinfo;
Set<File> map_files = files.map;
if (server_dir == null && (decls_files.size() == 0) && (dtrace_files.size() == 0)) {
if (server_dir == null && decls_files.isEmpty() && dtrace_files.isEmpty()) {
System.out.println("No .decls or .dtrace files specified");
throw new Daikon.UserError("No .decls or .dtrace files specified");
}
Expand Down Expand Up @@ -1813,7 +1813,7 @@ public static void createUpperPpts(PptMap all_ppts) {
for (PptTopLevel ppt : all_ppts.pptIterable()) {
// System.out.printf("considering ppt %s parents: %s, children: %s%n",
// ppt.name, ppt.parents, ppt.children);
if (ppt.parents.size() == 0) {
if (ppt.parents.isEmpty()) {
ppt.mergeInvs();
}
}
Expand Down Expand Up @@ -2082,7 +2082,7 @@ private static PptMap load_decls_files(Set<File> decl_files) {
debugTrace.fine("Initializing partial order");
}
fileio_progress.clear();
if (!Daikon.dkconfig_quiet && decl_files.size() > 0) {
if (!Daikon.dkconfig_quiet && !decl_files.isEmpty()) {
System.out.print("\r(read ");
System.out.print(StringsPlume.nplural(decl_files.size(), "decls file"));
System.out.println(")");
Expand Down Expand Up @@ -2131,7 +2131,7 @@ private static void load_spinfo_files(Set<File> spinfo_files) {
*/
private static void load_map_files(Set<File> map_files) {
long startTime = System.nanoTime();
if (!PptSplitter.dkconfig_disable_splitting && map_files.size() > 0) {
if (!PptSplitter.dkconfig_disable_splitting && !map_files.isEmpty()) {
System.out.print("Reading map (context) files ");
ContextSplitterFactory.load_mapfiles_into_splitterlist(
map_files, ContextSplitterFactory.dkconfig_granularity);
Expand Down Expand Up @@ -2360,7 +2360,7 @@ private static void process_data(PptMap all_ppts, Set<String> dtrace_files) {
String.format("Finished reading %d samples", FileIO.samples_processed));
}

if (all_ppts.size() == 0) {
if (all_ppts.isEmpty()) {
String message = "No program point declarations were found.";
if (FileIO.omitted_declarations != 0) {
message +=
Expand Down Expand Up @@ -2765,7 +2765,7 @@ public static void undoOpts(PptMap all_ppts) {
}
}

if (vars.size() > 0) {
if (!vars.isEmpty()) {

// Create new equality sets for all of the non-equal vars
List<Equality> newInvs = sliceEquality.createEqualityInvs(vars, eq);
Expand Down
4 changes: 2 additions & 2 deletions java/daikon/DaikonSimple.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static void mainHelper(final String[] args) throws IOException, FileNotFo
Set<File> decls_files = files.decls;
Set<String> dtrace_files = files.dtrace;

if ((decls_files.size() == 0) && (dtrace_files.size() == 0)) {
if (decls_files.isEmpty() && dtrace_files.isEmpty()) {
throw new Daikon.UserError("No .decls or .dtrace files specified");
}

Expand Down Expand Up @@ -594,7 +594,7 @@ private void add(PptTopLevel ppt, ValueTuple vt, int nonce) {
// DaikonSimple will not do this to be consistent.
// The better idea is for Daikon to assert that these valuetuples are
// empty and then skip the sample.
assert vt.size() == 0;
assert vt.isEmpty();
return;
}

Expand Down
2 changes: 1 addition & 1 deletion java/daikon/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public Debug(Class<?> c, Ppt ppt, List<VarInfo> vis) {
VarInfo v = visTracked(vis);
if (v != null) {
set(c, ppt, new VarInfo[] {v});
} else if (vis.size() > 0) {
} else if (!vis.isEmpty()) {
set(c, ppt, new VarInfo[] {vis.get(0)});
} else {
set(c, ppt, null);
Expand Down
10 changes: 5 additions & 5 deletions java/daikon/DynamicConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ public void instantiate_new_views(List<Constant> noncons, List<Constant> non_mis
// the remaining constants and the newly-non constants. Any slices
// between the non-constants and other variables will have already
// been created when those other variables became non-constants.
if (noncons.size() > 0) {
if (!noncons.isEmpty()) {
List<Constant> cons = new ArrayList<>();
cons.addAll(con_list);
cons.addAll(noncons);
Expand All @@ -528,7 +528,7 @@ public void instantiate_new_views(List<Constant> noncons, List<Constant> non_mis
// Create all views over the newly non-missing. Since missing
// vars were not included in any previous views, we must match them
// against all variables.
if (non_missing.size() > 0) {
if (!non_missing.isEmpty()) {
debug.fine("Instantiating non missing in ppt: " + ppt.name());
instantiate_views(non_missing, all_list);
}
Expand Down Expand Up @@ -699,7 +699,7 @@ private void instantiate_views(List<Constant> list1, List<Constant> list2) {
inv.log("Invariant %s destroyed by constant values %s", inv.format(), vals);
}
}
if (slice.invs.size() > 0) {
if (!slice.invs.isEmpty()) {
slice_cnt[slice.arity()]++;
}
inv_cnt[slice.arity()] += slice.invs.size();
Expand Down Expand Up @@ -1096,7 +1096,7 @@ public List<PptSlice> create_constant_invs() {
assert con.val != null : "@AssumeAssertion(nullness): dependent: val when count>0";
slice1.add_val_bu(con.val, mod, con.count);
}
if (slice1.invs.size() > 0) {
if (!slice1.invs.isEmpty()) {
new_views.add(slice1);
}
}
Expand Down Expand Up @@ -1124,7 +1124,7 @@ public List<PptSlice> create_constant_invs() {
: "@AssumeAssertion(nullness): dependent: val != null when count>0";
slice2.add_val_bu(con1.val, con2.val, mod, mod, con1.count);
}
if (slice2.invs.size() > 0) {
if (!slice2.invs.isEmpty()) {
new_views.add(slice2);
}
}
Expand Down
2 changes: 1 addition & 1 deletion java/daikon/FileIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ public static void read_data_trace_record(ParseState state) throws IOException {
throw new Daikon.UserError(message, reader, state.filename);
}

if (state.all_ppts.size() == 0) {
if (state.all_ppts.isEmpty()) {
throw new Daikon.UserError(
"No declarations were provided before the first sample. Perhaps you did not supply"
+ " the proper .decls file to Daikon. (Or, there could be a bug in the front end"
Expand Down
14 changes: 7 additions & 7 deletions java/daikon/MergeInvariants.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public static void mainHelper(String[] args)

// if no decls file was specified
if (decl_file == null) {
if (splitter_files.size() > 0) {
if (!splitter_files.isEmpty()) {
throw new Daikon.UserError(".spinfo files may only be specified along with a .decls file");
}

Expand Down Expand Up @@ -288,11 +288,11 @@ public static void mainHelper(String[] args)

// Skip everything that is not a final exit point
if (!ppt.ppt_name.isExitPoint()) {
assert ppt.children.size() > 0 : ppt;
assert !ppt.children.isEmpty() : ppt;
continue;
}
if (ppt.ppt_name.isCombinedExitPoint()) {
assert ppt.children.size() > 0 : ppt;
assert !ppt.children.isEmpty() : ppt;
continue;
}

Expand All @@ -304,7 +304,7 @@ public static void mainHelper(String[] args)
assert ppt.splitters != null; // because ppt.has_splitters() = true
for (PptSplitter ppt_split : ppt.splitters) {
for (PptTopLevel p : ppt_split.ppts) {
assert p.children.size() == 0 : p;
assert p.children.isEmpty() : p;
}
}
}
Expand Down Expand Up @@ -356,12 +356,12 @@ public static void mainHelper(String[] args)
}

// Make sure at least one child was found
assert ppt.children.size() > 0 : ppt;
assert !ppt.children.isEmpty() : ppt;
if (ppt.has_splitters()) {
assert ppt.splitters != null; // because ppt.has_splitters() = true
for (PptSplitter ppt_split : ppt.splitters) {
for (PptTopLevel p : ppt_split.ppts) {
assert p.children.size() > 0 : p;
assert !p.children.isEmpty() : p;
}
}
}
Expand All @@ -374,7 +374,7 @@ public static void mainHelper(String[] args)
if (debug.isLoggable(FINE)) {
debug.fine("PPT Hierarchy");
for (PptTopLevel ppt : merge_ppts.pptIterable()) {
if (ppt.parents.size() == 0) {
if (ppt.parents.isEmpty()) {
ppt.debug_print_tree(debug, 0, null);
}
}
Expand Down
10 changes: 10 additions & 0 deletions java/daikon/PptMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,16 @@ public int size() {
return nameToPpt.size();
}

/**
* Returns true if this PptMap is empty.
*
* @return true if this PptMap is empty
*/
@Pure
public boolean isEmpty() {
return size() == 0;
}

@SideEffectFree
@Override
public String toString(@GuardSatisfied PptMap this) {
Expand Down
18 changes: 14 additions & 4 deletions java/daikon/PptRelation.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ public int size() {
return parent_to_child_map.size();
}

/**
* Returns true if this PptRelation is empty.
*
* @return true if this PptRelation is empty
*/
@Pure
public boolean isEmpty() {
return parent_to_child_map.isEmpty();
}

@SideEffectFree
@Override
public String toString(@GuardSatisfied PptRelation this) {
Expand Down Expand Up @@ -215,7 +225,7 @@ public PptRelationType getRelationType() {

/** Returns true if this relation's child has children of its own. */
public boolean hasChildren() {
return (child.children.size() > 0);
return !child.children.isEmpty();
}

/**
Expand Down Expand Up @@ -859,7 +869,7 @@ public static void init_hierarchy(PptMap all_ppts) {
if (debug.isLoggable(Level.FINE)) {
debug.fine("PPT Hierarchy");
for (PptTopLevel ppt : all_ppts.pptIterable()) {
if (ppt.parents.size() == 0) {
if (ppt.parents.isEmpty()) {
ppt.debug_print_tree(debug, 0, null);
}
}
Expand Down Expand Up @@ -1019,7 +1029,7 @@ public static void init_hierarchy_new(PptMap all_ppts) {
// happen when there are ppts such as OBJECT or CLASS that don't end up
// with any children (due to the program source or because of ppt filtering).
for (PptTopLevel ppt : all_ppts.pptIterable()) {
if ((ppt.children.size() == 0) && (ppt.equality_view == null)) {
if (ppt.children.isEmpty() && (ppt.equality_view == null)) {
assert ppt.is_object() || ppt.is_class() || ppt.is_enter() : ppt;
ppt.equality_view = new PptSliceEquality(ppt);
ppt.equality_view.instantiate_invariants();
Expand All @@ -1030,7 +1040,7 @@ public static void init_hierarchy_new(PptMap all_ppts) {
if (debug.isLoggable(Level.FINE)) {
debug.fine("PPT Hierarchy");
for (PptTopLevel ppt : all_ppts.pptIterable()) {
if (ppt.parents.size() == 0) {
if (ppt.parents.isEmpty()) {
ppt.debug_print_tree(debug, 0, null);
}
}
Expand Down
6 changes: 3 additions & 3 deletions java/daikon/PptSlice.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void removeInvariant(Invariant inv) {
boolean removed = invs.remove(inv);
assert removed : "inv " + inv + " not in ppt " + name();
Global.falsified_invariants++;
if (invs.size() == 0) {
if (invs.isEmpty()) {
if (Debug.logDetail()) {
log("last invariant removed");
}
Expand All @@ -163,7 +163,7 @@ public void removeInvariants(List<Invariant> to_remove) {
invs.removeAll(to_remove);
assert old_invs_size - invs.size() == to_remove.size();
Global.falsified_invariants += to_remove.size();
if (invs.size() == 0) {
if (invs.isEmpty()) {
if (Debug.logDetail()) {
log("last invariant removed");
}
Expand Down Expand Up @@ -267,7 +267,7 @@ public boolean containsOnlyGuardingPredicates() {

/** Remove the invariants noted in omitTypes. */
public void processOmissions(boolean[] omitTypes) {
if (invs.size() == 0) {
if (invs.isEmpty()) {
return;
}
List<Invariant> toRemove = new ArrayList<>();
Expand Down
Loading