Skip to content

Commit

Permalink
Fixed new reference cycles in java.util.concurrent, reduced CycleFind…
Browse files Browse the repository at this point in the history
…er default output.

	Change on 2013/10/30 by tball <tball@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=55870159
  • Loading branch information
tomball committed Nov 1, 2013
1 parent 7b42227 commit 8bb1212
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.io.PrintStream;
import java.util.Collection;
import java.util.List;
import java.util.logging.Logger;

/**
* A tool for finding possible reference cycles in a Java program.
Expand All @@ -39,7 +40,6 @@
public class CycleFinder {

private final Options options;
private final PrintStream outStream;
private final PrintStream errStream;
private int nErrors = 0;
private List<String> errors = Lists.newArrayList();
Expand All @@ -52,17 +52,18 @@ public class CycleFinder {
}
}

public CycleFinder(Options options, PrintStream outStream, PrintStream errStream) {
private static final Logger logger = Logger.getLogger(CycleFinder.class.getName());

public CycleFinder(Options options, PrintStream errStream) {
this.options = options;
this.outStream = outStream;
this.errStream = errStream;
}

private FileASTRequestor newASTRequestor(final TypeCollector typeCollector) {
return new FileASTRequestor() {
@Override
public void acceptAST(String sourceFilePath, CompilationUnit ast) {
outStream.println("acceptAST: " + sourceFilePath);
logger.fine("acceptAST: " + sourceFilePath);
for (IProblem problem : ast.getProblems()) {
if (problem.isError()) {
error(String.format("%s:%s: %s",
Expand Down Expand Up @@ -175,7 +176,7 @@ public static void main(String[] args) throws IOException {
Options.help(true);
}
Options options = Options.parse(args);
CycleFinder finder = new CycleFinder(options, System.out, System.err);
CycleFinder finder = new CycleFinder(options, System.err);
finder.testFileExistence();
finder.exitOnErrors();
List<List<Edge>> cycles = finder.findCycles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/

package java.util.concurrent;

import com.google.j2objc.annotations.Weak;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
import java.util.AbstractQueue;
Expand Down Expand Up @@ -90,6 +93,7 @@ public class ArrayBlockingQueue<E> extends AbstractQueue<E>
* are known not to be any. Allows queue operations to update
* iterator state.
*/
@Weak
transient Itrs itrs = null;

// Internal helper methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/

package java.util.concurrent;

import com.google.j2objc.annotations.WeakOuter;

import java.util.concurrent.locks.*;
import java.util.*;
import java.io.Serializable;
Expand Down Expand Up @@ -1314,6 +1317,7 @@ public Map.Entry<K,V> next() {
}
}

@WeakOuter
final class KeySet extends AbstractSet<K> {
public Iterator<K> iterator() {
return new KeyIterator();
Expand All @@ -1335,6 +1339,7 @@ public void clear() {
}
}

@WeakOuter
final class Values extends AbstractCollection<V> {
public Iterator<V> iterator() {
return new ValueIterator();
Expand All @@ -1353,6 +1358,7 @@ public void clear() {
}
}

@WeakOuter
final class EntrySet extends AbstractSet<Map.Entry<K,V>> {
public Iterator<Map.Entry<K,V>> iterator() {
return new EntryIterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/

package java.util.concurrent;

import com.google.j2objc.annotations.Weak;

import java.util.*;

// BEGIN android-note
Expand Down Expand Up @@ -322,12 +325,16 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
private transient int randomSeed;

/** Lazily initialized key set */
@Weak
private transient KeySet<K> keySet;
/** Lazily initialized entry set */
@Weak
private transient EntrySet<K,V> entrySet;
/** Lazily initialized values collection */
@Weak
private transient Values<V> values;
/** Lazily initialized descending key set */
@Weak
private transient ConcurrentNavigableMap<K,V> descendingMap;

/**
Expand Down Expand Up @@ -2276,6 +2283,7 @@ static final <E> List<E> toList(Collection<E> c) {

static final class KeySet<E>
extends AbstractSet<E> implements NavigableSet<E> {
@Weak
private final ConcurrentNavigableMap<E,?> m;
KeySet(ConcurrentNavigableMap<E,?> map) { m = map; }
public int size() { return m.size(); }
Expand Down Expand Up @@ -2351,6 +2359,7 @@ public NavigableSet<E> descendingSet() {
}

static final class Values<E> extends AbstractCollection<E> {
@Weak
private final ConcurrentNavigableMap<?, E> m;
Values(ConcurrentNavigableMap<?, E> map) {
m = map;
Expand Down Expand Up @@ -2378,6 +2387,7 @@ public void clear() {
}

static final class EntrySet<K1,V1> extends AbstractSet<Map.Entry<K1,V1>> {
@Weak
private final ConcurrentNavigableMap<K1, V1> m;
EntrySet(ConcurrentNavigableMap<K1, V1> map) {
m = map;
Expand Down Expand Up @@ -2463,6 +2473,7 @@ static final class SubMap<K,V> extends AbstractMap<K,V>

// Lazily initialized view holders
private transient KeySet<K> keySetView;
@Weak
private transient Set<Map.Entry<K,V>> entrySetView;
private transient Collection<V> valuesView;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/

package java.util.concurrent;

import com.google.j2objc.annotations.Weak;

import java.util.*;

// BEGIN android-note
Expand Down Expand Up @@ -63,6 +66,7 @@ public class ConcurrentSkipListSet<E>
* element. This field is declared final for the sake of thread
* safety, which entails some ugliness in clone()
*/
@Weak
private final ConcurrentNavigableMap<E,Object> m;

/**
Expand Down

0 comments on commit 8bb1212

Please sign in to comment.