Skip to content

Commit

Permalink
Some tweaks to @Initializer annotations in wala.util (#1474)
Browse files Browse the repository at this point in the history
- Remove a couple of `@Nullable` annotations and add `@Initializer`
instead, to better capture the protocol.
- Remove WALA's custom `@Initializer` annotation and use the one from
NullAway's annotations package, which we already depend on.
  • Loading branch information
msridhar authored Nov 26, 2024
1 parent bc3d141 commit 6d62392
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 30 deletions.
24 changes: 0 additions & 24 deletions util/src/main/java/com/ibm/wala/qual/Initializer.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.ibm.wala.util.collections.NonNullSingletonIterator;
import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.graph.NumberedGraph;
import com.uber.nullaway.annotations.Initializer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NoSuchElementException;
Expand All @@ -32,9 +33,10 @@ public abstract class DFSDiscoverTimeIterator<T> extends ArrayList<T> implements
private static final long serialVersionUID = 4238700455408861924L;

/** an enumeration of all nodes to search from */
private @Nullable Iterator<? extends T> roots;
private Iterator<? extends T> roots;

/** subclass constructors must call this! */
@Initializer
protected void init(Iterator<? extends T> nodes) {
roots = nodes;
assert nodes != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
*/
package com.ibm.wala.util.graph.traverse;

import com.ibm.wala.qual.Initializer;
import com.ibm.wala.util.collections.EmptyIterator;
import com.ibm.wala.util.collections.Iterator2Iterable;
import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.graph.Graph;
import com.uber.nullaway.annotations.Initializer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NoSuchElementException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
package com.ibm.wala.util.graph.traverse;

import com.ibm.wala.util.graph.Graph;
import com.uber.nullaway.annotations.Initializer;
import java.util.Iterator;
import org.jspecify.annotations.NullUnmarked;
import org.jspecify.annotations.Nullable;

abstract class GraphDFSDiscoverTimeIterator<T> extends DFSDiscoverTimeIterator<T> {

private static final long serialVersionUID = -5673397879499010863L;

/** the graph being searched */
private @Nullable Graph<T> G;
private Graph<T> G;

@Initializer
protected void init(Graph<T> G, Iterator<? extends T> nodes) {
if (G == null) {
throw new IllegalArgumentException("G is null");
Expand All @@ -30,7 +30,6 @@ protected void init(Graph<T> G, Iterator<? extends T> nodes) {
super.init(nodes);
}

@NullUnmarked
@Override
protected Iterator<? extends T> getConnected(T n) {
return G.getSuccNodes(n);
Expand Down

0 comments on commit 6d62392

Please sign in to comment.