8054215: Use com.sun.tools.javac.util.Assert instead of 'assert'
Replaced assert keyword with methods from com.sun.tools.javac.util.Assert Reviewed-by: jfranck
This commit is contained in:
parent
1cf35244f6
commit
0683c8dbb0
@ -31,6 +31,8 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sun.tools.javac.util.Assert;
|
||||
|
||||
/**
|
||||
* The build state class captures the source code and generated artifacts
|
||||
* from a build. There are usually two build states, the previous one (prev),
|
||||
@ -75,7 +77,7 @@ public class BuildState {
|
||||
*/
|
||||
Module findModuleFromPackageName(String pkg) {
|
||||
int cp = pkg.indexOf(':');
|
||||
assert(cp != -1);
|
||||
Assert.check(cp != -1);
|
||||
String mod = pkg.substring(0, cp);
|
||||
return lookupModule(mod);
|
||||
}
|
||||
@ -94,7 +96,7 @@ public class BuildState {
|
||||
for (Map.Entry<String,Package> j : i.packages().entrySet()) {
|
||||
Package p = packages.get(j.getKey());
|
||||
// Check that no two different packages are stored under same name.
|
||||
assert(p == null || p == j.getValue());
|
||||
Assert.check(p == null || p == j.getValue());
|
||||
if (p == null) {
|
||||
p = j.getValue();
|
||||
packages.put(j.getKey(),j.getValue());
|
||||
@ -102,7 +104,7 @@ public class BuildState {
|
||||
for (Map.Entry<String,Source> k : p.sources().entrySet()) {
|
||||
Source s = sources.get(k.getKey());
|
||||
// Check that no two different sources are stored under same name.
|
||||
assert(s == null || s == k.getValue());
|
||||
Assert.check(s == null || s == k.getValue());
|
||||
if (s == null) {
|
||||
s = k.getValue();
|
||||
sources.put(k.getKey(), k.getValue());
|
||||
@ -111,7 +113,7 @@ public class BuildState {
|
||||
for (Map.Entry<String,File> g : p.artifacts().entrySet()) {
|
||||
File f = artifacts.get(g.getKey());
|
||||
// Check that no two artifacts are stored under the same file.
|
||||
assert(f == null || f == g.getValue());
|
||||
Assert.check(f == null || f == g.getValue());
|
||||
if (f == null) {
|
||||
f = g.getValue();
|
||||
artifacts.put(g.getKey(), g.getValue());
|
||||
@ -134,13 +136,13 @@ public class BuildState {
|
||||
for (Map.Entry<String,Package> j : i.packages().entrySet()) {
|
||||
Package p = packages.get(j.getKey());
|
||||
// Check that no two different packages are stored under same name.
|
||||
assert(p == null || p == j.getValue());
|
||||
Assert.check(p == null || p == j.getValue());
|
||||
p = j.getValue();
|
||||
packages.put(j.getKey(),j.getValue());
|
||||
for (Map.Entry<String,File> g : p.artifacts().entrySet()) {
|
||||
File f = artifacts.get(g.getKey());
|
||||
// Check that no two artifacts are stored under the same file.
|
||||
assert(f == null || f == g.getValue());
|
||||
Assert.check(f == null || f == g.getValue());
|
||||
artifacts.put(g.getKey(), g.getValue());
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import com.sun.tools.javac.util.Assert;
|
||||
|
||||
/**
|
||||
* The Package class maintains meta information about a package.
|
||||
@ -83,9 +84,9 @@ public class Package implements Comparable<Package> {
|
||||
|
||||
public Package(Module m, String n) {
|
||||
int c = n.indexOf(":");
|
||||
assert(c != -1);
|
||||
Assert.check(c != -1);
|
||||
String mn = n.substring(0,c);
|
||||
assert(m.name().equals(m.name()));
|
||||
Assert.check(m.name().equals(m.name()));
|
||||
name = n;
|
||||
dirname = n.replace('.', File.separatorChar);
|
||||
if (m.name().length() > 0) {
|
||||
@ -256,7 +257,7 @@ public class Package implements Comparable<Package> {
|
||||
}
|
||||
|
||||
public void setArtifacts(Set<URI> as) {
|
||||
assert(!artifacts.isEmpty());
|
||||
Assert.check(!artifacts.isEmpty());
|
||||
artifacts = new HashMap<>();
|
||||
addArtifacts(as);
|
||||
}
|
||||
|
@ -62,7 +62,8 @@ public class Util {
|
||||
|
||||
public static String justPackageName(String pkgName) {
|
||||
int c = pkgName.indexOf(":");
|
||||
assert(c != -1);
|
||||
if (c == -1)
|
||||
throw new IllegalArgumentException("Expected ':' in package name (" + pkgName + ")");
|
||||
return pkgName.substring(c+1);
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sun.tools.javac.code.Symbol.ClassSymbol;
|
||||
import com.sun.tools.javac.util.Assert;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.Log;
|
||||
import com.sun.tools.javac.util.Name;
|
||||
@ -154,7 +155,7 @@ public class Dependencies {
|
||||
Name n = ((ClassSymbol)e).fullname;
|
||||
Name p = ((ClassSymbol)e).packge().fullname;
|
||||
StringBuffer sb = publicApiPerClass.get(n);
|
||||
assert(sb == null);
|
||||
Assert.check(sb == null);
|
||||
sb = new StringBuffer();
|
||||
PubapiVisitor v = new PubapiVisitor(sb);
|
||||
v.visit(e);
|
||||
|
@ -33,6 +33,7 @@ import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.FileLock;
|
||||
import java.nio.channels.FileLockInterruptionException;
|
||||
import com.sun.tools.javac.util.Assert;
|
||||
import com.sun.tools.sjavac.Log;
|
||||
|
||||
/**
|
||||
@ -130,7 +131,7 @@ public class PortFile {
|
||||
* If so, then we can acquire the tcp/ip port on localhost.
|
||||
*/
|
||||
public int getPort() {
|
||||
assert(containsPortInfo);
|
||||
Assert.check(containsPortInfo);
|
||||
return serverPort;
|
||||
}
|
||||
|
||||
@ -138,7 +139,7 @@ public class PortFile {
|
||||
* If so, then we can acquire the server cookie.
|
||||
*/
|
||||
public long getCookie() {
|
||||
assert(containsPortInfo);
|
||||
Assert.check(containsPortInfo);
|
||||
return serverCookie;
|
||||
}
|
||||
|
||||
@ -146,7 +147,7 @@ public class PortFile {
|
||||
* Store the values into the locked port file.
|
||||
*/
|
||||
public void setValues(int port, long cookie) throws IOException {
|
||||
assert(lock != null);
|
||||
Assert.check(lock != null);
|
||||
rwfile.seek(0);
|
||||
// Write the magic nr that identifes a port file.
|
||||
rwfile.writeInt(magicNr);
|
||||
@ -191,7 +192,7 @@ public class PortFile {
|
||||
* Unlock the port file.
|
||||
*/
|
||||
public void unlock() throws IOException {
|
||||
assert(lock != null);
|
||||
Assert.check(lock != null);
|
||||
lock.release();
|
||||
lock = null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user