Skip to content

Commit f5120b7

Browse files
committed
8282056: Clean up com.sun.tools.javac.util.GraphUtils
Reviewed-by: jjg, mcimadamore, vromero
1 parent e336504 commit f5120b7

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/jdk.compiler/share/classes/com/sun/tools/javac/util/Dependencies.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -189,7 +189,7 @@ public abstract static class Node extends GraphUtils.AbstractNode<ClassSymbol, N
189189
super(value);
190190
this.depsByKind = new EnumMap<>(CompletionCause.class);
191191
for (CompletionCause depKind : CompletionCause.values()) {
192-
depsByKind.put(depKind, new ArrayList<Node>());
192+
depsByKind.put(depKind, new ArrayList<>());
193193
}
194194
}
195195

@@ -216,7 +216,7 @@ public GraphUtils.DependencyKind[] getSupportedDependencyKinds() {
216216
}
217217

218218
@Override
219-
public java.util.Collection<? extends Node> getDependenciesByKind(DependencyKind dk) {
219+
public Collection<? extends Node> getDependenciesByKind(DependencyKind dk) {
220220
return depsByKind.get(dk);
221221
}
222222

src/jdk.compiler/share/classes/com/sun/tools/javac/util/GraphUtils.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@ public interface DependencyKind { }
4646
*/
4747
public interface Node<D, N extends Node<D, N>> {
4848
/**
49-
* visitor method.
49+
* Visitor method.
5050
*/
5151
<A> void accept(NodeVisitor<D, N, A> visitor, A arg);
5252
}
@@ -105,7 +105,7 @@ public AbstractNode(D data) {
105105
public abstract DependencyKind[] getSupportedDependencyKinds();
106106

107107
/**
108-
* Get all dependencies of a given kind
108+
* Get all dependencies of a given kind.
109109
*/
110110
public abstract Collection<? extends N> getDependenciesByKind(DependencyKind dk);
111111

@@ -126,7 +126,7 @@ public <A> void accept(NodeVisitor<D, N, A> visitor, A arg) {
126126
}
127127

128128
/**
129-
* This class specialized Node, by adding elements that are required in order
129+
* This class specializes Node, by adding elements that are required in order
130130
* to perform Tarjan computation of strongly connected components.
131131
*/
132132
public abstract static class TarjanNode<D, N extends TarjanNode<D, N>> extends AbstractNode<D, N>
@@ -141,13 +141,14 @@ public TarjanNode(D data) {
141141

142142
public abstract Iterable<? extends N> getAllDependencies();
143143

144+
@Override
144145
public int compareTo(N o) {
145-
return (index < o.index) ? -1 : (index == o.index) ? 0 : 1;
146+
return Integer.compare(index, o.index);
146147
}
147148
}
148149

149150
/**
150-
* Tarjan's algorithm to determine strongly connected components of a
151+
* Tarjan's algorithm to determine strongly connected components (SCCs) of a
151152
* directed graph in linear time. Works on TarjanNode.
152153
*/
153154
public static <D, N extends TarjanNode<D, N>> List<? extends List<? extends N>> tarjan(Iterable<? extends N> nodes) {
@@ -160,10 +161,10 @@ private static class Tarjan<D, N extends TarjanNode<D, N>> {
160161
/** Unique node identifier. */
161162
int index = 0;
162163

163-
/** List of SCCs found fso far. */
164+
/** List of SCCs found so far. */
164165
ListBuffer<List<N>> sccs = new ListBuffer<>();
165166

166-
/** Stack of all reacheable nodes from given root. */
167+
/** Stack of all reachable nodes from given root. */
167168
ListBuffer<N> stack = new ListBuffer<>();
168169

169170
private List<? extends List<? extends N>> findSCC(Iterable<? extends N> nodes) {

0 commit comments

Comments
 (0)