more IllegalArgument checks
propagate IOExceptions when reading AnalysisScopes from files git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3396 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
b6b5f56ac2
commit
7fdacaef22
|
@ -10,6 +10,8 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.core.tests.cha;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
|
@ -29,7 +31,7 @@ public class SourceMapTest extends WalaTestCase {
|
|||
|
||||
private final static String CLASS_IN_PRIMORDIAL_JAR = "Lcom/ibm/wala/model/SyntheticFactory";
|
||||
|
||||
public void testHello() throws ClassHierarchyException {
|
||||
public void testHello() throws ClassHierarchyException, IOException {
|
||||
AnalysisScope scope = null;
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.HELLO, null, MY_CLASSLOADER);
|
||||
// TODO: it's annoying to have to build a class hierarchy here.
|
||||
|
@ -43,7 +45,7 @@ public class SourceMapTest extends WalaTestCase {
|
|||
assertTrue(sourceFile != null);
|
||||
}
|
||||
|
||||
public void testFromJar() throws ClassHierarchyException {
|
||||
public void testFromJar() throws ClassHierarchyException, IOException {
|
||||
AnalysisScope scope = null;
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.HELLO, null, MY_CLASSLOADER);
|
||||
// TODO: it's annoying to have to build a class hierarchy here.
|
||||
|
|
|
@ -118,7 +118,7 @@ public class CompareToZeroOneCFADriver {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void runApplication(String appJar) throws IllegalArgumentException, CancelException {
|
||||
private static void runApplication(String appJar) throws IllegalArgumentException, CancelException, IOException {
|
||||
Trace.println("=======---------------=============");
|
||||
Trace.println("ANALYZING " + appJar + "\n\n");
|
||||
|
||||
|
|
|
@ -40,8 +40,7 @@ import com.ibm.wala.viz.DotUtil;
|
|||
import com.ibm.wala.viz.GVUtil;
|
||||
|
||||
/**
|
||||
* This simple example WALA application builds a call graph and fires off
|
||||
* ghostview to visualize a DOT representation.
|
||||
* This simple example WALA application builds a call graph and fires off ghostview to visualize a DOT representation.
|
||||
*
|
||||
* @author sfink
|
||||
*/
|
||||
|
@ -50,8 +49,7 @@ public class GVCallGraph {
|
|||
private final static String PS_FILE = "cg.ps";
|
||||
|
||||
/**
|
||||
* Usage: args = "-appJar [jar file name] {-exclusionFile
|
||||
* [exclusionFileName]}" The "jar file name" should be something like
|
||||
* Usage: args = "-appJar [jar file name] {-exclusionFile [exclusionFileName]}" The "jar file name" should be something like
|
||||
* "c:/temp/testdata/java_cup.jar"
|
||||
*
|
||||
* @throws CancelException
|
||||
|
@ -62,8 +60,7 @@ public class GVCallGraph {
|
|||
}
|
||||
|
||||
/**
|
||||
* Usage: args = "-appJar [jar file name] {-exclusionFile
|
||||
* [exclusionFileName]}" The "jar file name" should be something like
|
||||
* Usage: args = "-appJar [jar file name] {-exclusionFile [exclusionFileName]}" The "jar file name" should be something like
|
||||
* "c:/temp/testdata/java_cup.jar"
|
||||
*
|
||||
* @throws CancelException
|
||||
|
@ -76,8 +73,7 @@ public class GVCallGraph {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param appJar
|
||||
* something like "c:/temp/testdata/java_cup.jar"
|
||||
* @param appJar something like "c:/temp/testdata/java_cup.jar"
|
||||
* @throws CancelException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
|
@ -111,16 +107,16 @@ public class GVCallGraph {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param appJar
|
||||
* something like "c:/temp/testdata/java_cup.jar"
|
||||
* @param appJar something like "c:/temp/testdata/java_cup.jar"
|
||||
* @return a call graph
|
||||
* @throws CancelException
|
||||
* @throws IllegalArgumentException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Graph<CGNode> buildPrunedCallGraph(String appJar, File exclusionFile) throws WalaException,
|
||||
IllegalArgumentException, CancelException {
|
||||
AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, exclusionFile != null ? exclusionFile
|
||||
: new File(CallGraphTestUtil.REGRESSION_EXCLUSIONS));
|
||||
IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, exclusionFile != null ? exclusionFile : new File(
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS));
|
||||
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
|
||||
|
@ -132,11 +128,11 @@ public class GVCallGraph {
|
|||
// //
|
||||
com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeZeroCFABuilder(options, new AnalysisCache(), cha, scope);
|
||||
CallGraph cg = builder.makeCallGraph(options, null);
|
||||
|
||||
|
||||
System.err.println(CallGraphStats.getStats(cg));
|
||||
|
||||
Graph<CGNode> g = pruneForAppLoader(cg);
|
||||
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
|
@ -149,11 +145,10 @@ public class GVCallGraph {
|
|||
*
|
||||
* Usage:
|
||||
* <ul>
|
||||
* <li> args[0] : "-appJar"
|
||||
* <li>args[0] : "-appJar"
|
||||
* <li> args[1] : something like "c:/temp/testdata/java_cup.jar" </ul?
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* if command-line is malformed.
|
||||
* @throws UnsupportedOperationException if command-line is malformed.
|
||||
*/
|
||||
public static void validateCommandLine(Properties p) {
|
||||
if (p.get("appJar") == null) {
|
||||
|
|
|
@ -107,8 +107,9 @@ public abstract class AbstractJavaAnalysisAction implements IObjectActionDelegat
|
|||
|
||||
/**
|
||||
* create an analysis scope as the union of a bunch of EclipseProjectPath
|
||||
* @throws IOException
|
||||
*/
|
||||
private static AnalysisScope mergeProjectPaths(Collection<EclipseProjectPath> projectPaths) {
|
||||
private static AnalysisScope mergeProjectPaths(Collection<EclipseProjectPath> projectPaths) throws IOException {
|
||||
AnalysisScope scope = AnalysisScope.createJavaAnalysisScope();
|
||||
|
||||
Collection<Module> seen = HashSetFactory.make();
|
||||
|
@ -121,7 +122,7 @@ public abstract class AbstractJavaAnalysisAction implements IObjectActionDelegat
|
|||
}
|
||||
|
||||
private static void buildScope(ClassLoaderReference loader, Collection<EclipseProjectPath> projectPaths, AnalysisScope scope,
|
||||
Collection<Module> seen) {
|
||||
Collection<Module> seen) throws IOException {
|
||||
for (EclipseProjectPath path : projectPaths) {
|
||||
AnalysisScope pScope = path.toAnalysisScope((File) null);
|
||||
for (Module m : pScope.getModules(loader)) {
|
||||
|
|
|
@ -299,8 +299,10 @@ public class EclipseProjectPath {
|
|||
|
||||
/**
|
||||
* Convert this path to a WALA analysis scope
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public AnalysisScope toAnalysisScope(ClassLoader classLoader, File exclusionsFile) {
|
||||
public AnalysisScope toAnalysisScope(ClassLoader classLoader, File exclusionsFile) throws IOException {
|
||||
AnalysisScope scope = AnalysisScopeReader.readJavaScope(AbstractAnalysisEngine.SYNTHETIC_J2SE_MODEL, exclusionsFile,
|
||||
classLoader);
|
||||
return toAnalysisScope(scope);
|
||||
|
@ -338,11 +340,11 @@ public class EclipseProjectPath {
|
|||
}
|
||||
}
|
||||
|
||||
public AnalysisScope toAnalysisScope(final File exclusionsFile) {
|
||||
public AnalysisScope toAnalysisScope(final File exclusionsFile) throws IOException {
|
||||
return toAnalysisScope(getClass().getClassLoader(), exclusionsFile);
|
||||
}
|
||||
|
||||
public AnalysisScope toAnalysisScope() {
|
||||
public AnalysisScope toAnalysisScope() throws IOException {
|
||||
return toAnalysisScope(getClass().getClassLoader(), null);
|
||||
}
|
||||
|
||||
|
@ -352,7 +354,12 @@ public class EclipseProjectPath {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toAnalysisScope((File) null).toString();
|
||||
try {
|
||||
return toAnalysisScope((File) null).toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return "Error in toString()";
|
||||
}
|
||||
}
|
||||
|
||||
private IPluginModelBase findModel(IProject p) {
|
||||
|
|
|
@ -104,20 +104,6 @@ public class JdtUtil {
|
|||
return className;
|
||||
}
|
||||
|
||||
// public static String getMethodSignature(IMethod method) {
|
||||
// if (method == null) {
|
||||
// throw new IllegalArgumentException("method is null");
|
||||
// }
|
||||
// try {
|
||||
// String methodParamReturnInfo = method.getSignature();
|
||||
// String methodName = method.getElementName();
|
||||
// String methodSignature = methodName + " " + methodParamReturnInfo;
|
||||
// return methodSignature;
|
||||
// } catch (JavaModelException e) {
|
||||
// }
|
||||
// return "";
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return a unique string representing the specified Java element across projects in the workspace. The returned string can be
|
||||
* used as a handle to create JavaElement by 'JavaCore.create(String)'
|
||||
|
@ -135,6 +121,7 @@ public class JdtUtil {
|
|||
return javaElt.getHandleIdentifier();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static IJavaElement createJavaElementFromJdtHandle(String jdtHandle) {
|
||||
return JavaCore.create(jdtHandle);
|
||||
}
|
||||
|
|
|
@ -84,6 +84,9 @@ public class PointsToMap {
|
|||
* If p is unified, returns the representative for p.
|
||||
*/
|
||||
public PointsToSetVariable getPointsToSet(PointerKey p) {
|
||||
if (p == null) {
|
||||
throw new IllegalArgumentException("null p");
|
||||
}
|
||||
if (isImplicit(p)) {
|
||||
throw new IllegalArgumentException("unexpected: shouldn't ask a PointsToMap for an implicit points-to-set: " + p);
|
||||
}
|
||||
|
@ -111,6 +114,9 @@ public class PointsToMap {
|
|||
* record that a particular points-to-set is represented implicitly
|
||||
*/
|
||||
public void recordImplicit(PointerKey key) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("null key");
|
||||
}
|
||||
int i = findOrCreateIndex(key);
|
||||
pointsToSets.set(i, IMPLICIT);
|
||||
}
|
||||
|
|
|
@ -11,10 +11,7 @@
|
|||
package com.ibm.wala.model;
|
||||
|
||||
/**
|
||||
*
|
||||
* A bogus class to support returning "unknown" objects
|
||||
*
|
||||
* @author sfink
|
||||
*/
|
||||
public class SyntheticFactory {
|
||||
|
||||
|
|
|
@ -32,29 +32,29 @@ import com.ibm.wala.util.strings.Atom;
|
|||
|
||||
/**
|
||||
* Reads {@link AnalysisScope} from a text file.
|
||||
*
|
||||
*/
|
||||
public class AnalysisScopeReader {
|
||||
|
||||
private static final ClassLoader MY_CLASSLOADER = AnalysisScopeReader.class.getClassLoader();
|
||||
|
||||
private static final String BASIC_FILE = "primordial.txt";
|
||||
|
||||
public static AnalysisScope readJavaScope(String scopeFileName, File exclusionsFile, ClassLoader javaLoader) {
|
||||
AnalysisScope scope = AnalysisScope.createJavaAnalysisScope();
|
||||
|
||||
public static AnalysisScope readJavaScope(String scopeFileName, File exclusionsFile, ClassLoader javaLoader) throws IOException {
|
||||
AnalysisScope scope = AnalysisScope.createJavaAnalysisScope();
|
||||
return read(scope, scopeFileName, exclusionsFile, javaLoader, CorePlugin.getDefault());
|
||||
}
|
||||
|
||||
private static AnalysisScope readJavaScope(String scopeFileName, File exclusionsFile, ClassLoader javaLoader, Plugin plugIn) {
|
||||
|
||||
private static AnalysisScope readJavaScope(String scopeFileName, File exclusionsFile, ClassLoader javaLoader, Plugin plugIn) throws IOException {
|
||||
AnalysisScope scope = AnalysisScope.createJavaAnalysisScope();
|
||||
return read(scope, scopeFileName, exclusionsFile, javaLoader, plugIn);
|
||||
}
|
||||
|
||||
private static AnalysisScope read(AnalysisScope scope, String scopeFileName, File exclusionsFile, ClassLoader javaLoader, Plugin plugIn) {
|
||||
private static AnalysisScope read(AnalysisScope scope, String scopeFileName, File exclusionsFile, ClassLoader javaLoader,
|
||||
Plugin plugIn) throws IOException {
|
||||
BufferedReader r = null;
|
||||
try {
|
||||
File scopeFile = (plugIn == null) ? FileProvider.getFile(scopeFileName, javaLoader): FileProvider.getFileFromPlugin(plugIn, scopeFileName);
|
||||
File scopeFile = (plugIn == null) ? FileProvider.getFile(scopeFileName, javaLoader) : FileProvider.getFileFromPlugin(plugIn,
|
||||
scopeFileName);
|
||||
assert scopeFile.exists();
|
||||
|
||||
String line;
|
||||
|
@ -67,15 +67,12 @@ public class AnalysisScopeReader {
|
|||
scope.setExclusions(FileOfClasses.createFileOfClasses(exclusionsFile));
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assertions.UNREACHABLE(e.toString());
|
||||
} finally {
|
||||
if (r != null) {
|
||||
try {
|
||||
r.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,34 +123,37 @@ public class AnalysisScopeReader {
|
|||
Assertions.UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param exclusionsFile file holding class hierarchy exclusions. may be null
|
||||
* @param exclusionsFile file holding class hierarchy exclusions. may be null
|
||||
* @throws IOException
|
||||
* @throws IllegalStateException if there are problmes reading wala properties
|
||||
*/
|
||||
public static AnalysisScope makePrimordialScope(File exclusionsFile) {
|
||||
public static AnalysisScope makePrimordialScope(File exclusionsFile) throws IOException {
|
||||
return readJavaScope(BASIC_FILE, exclusionsFile, MY_CLASSLOADER, CorePlugin.getDefault());
|
||||
}
|
||||
|
||||
private static AnalysisScope makePrimordialScope(File exclusionsFile, Plugin plugIn) {
|
||||
|
||||
private static AnalysisScope makePrimordialScope(File exclusionsFile, Plugin plugIn) throws IOException {
|
||||
return readJavaScope(BASIC_FILE, exclusionsFile, MY_CLASSLOADER, plugIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classPath class path to analyze, delimited by File.pathSeparator
|
||||
* @param exclusionsFile file holding class hierarchy exclusions. may be null
|
||||
* @param exclusionsFile file holding class hierarchy exclusions. may be null
|
||||
* @throws IOException
|
||||
* @throws IllegalStateException if there are problems reading wala properties
|
||||
*/
|
||||
public static AnalysisScope makeJavaBinaryAnalysisScope(String classPath, File exclusionsFile) {
|
||||
public static AnalysisScope makeJavaBinaryAnalysisScope(String classPath, File exclusionsFile) throws IOException {
|
||||
return makeJavaBinaryAnalysisScope(classPath, exclusionsFile, CorePlugin.getDefault());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param classPath class path to analyze, delimited by File.pathSeparator
|
||||
* @param exclusionsFile file holding class hierarchy exclusions. may be null
|
||||
* @param exclusionsFile file holding class hierarchy exclusions. may be null
|
||||
* @throws IOException
|
||||
* @throws IllegalStateException if there are problems reading wala properties
|
||||
*/
|
||||
public static AnalysisScope makeJavaBinaryAnalysisScope(String classPath, File exclusionsFile, Plugin plugIn) {
|
||||
public static AnalysisScope makeJavaBinaryAnalysisScope(String classPath, File exclusionsFile, Plugin plugIn) throws IOException {
|
||||
if (classPath == null) {
|
||||
throw new IllegalArgumentException("classPath null");
|
||||
}
|
||||
|
|
|
@ -19,13 +19,10 @@ import com.ibm.wala.util.debug.Assertions;
|
|||
import com.ibm.wala.util.debug.Trace;
|
||||
|
||||
/**
|
||||
*
|
||||
* A relation between non-negative integers
|
||||
*
|
||||
* This implementation uses n IntVectors, to hold the first n y's associated with each x, and then 1 extra vector of SparseIntSet to
|
||||
* hold the remaining ys.
|
||||
*
|
||||
* @author sfink
|
||||
*/
|
||||
public final class BasicNaturalRelation implements IBinaryNaturalRelation {
|
||||
|
||||
|
@ -126,18 +123,14 @@ public final class BasicNaturalRelation implements IBinaryNaturalRelation {
|
|||
* This is performance-critical, so the implementation looks a little ugly in order to help out the compiler with redundancy
|
||||
* elimination.
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return true iff the relation changes as a result of this call.
|
||||
*/
|
||||
public boolean add(int x, int y) throws IllegalArgumentException {
|
||||
if (Assertions.verifyAssertions) {
|
||||
if (x < 0) {
|
||||
throw new IllegalArgumentException("illegal x: " + x);
|
||||
}
|
||||
if (y < 0) {
|
||||
throw new IllegalArgumentException("illegal y: " + y);
|
||||
}
|
||||
if (x < 0) {
|
||||
throw new IllegalArgumentException("illegal x: " + x);
|
||||
}
|
||||
if (y < 0) {
|
||||
throw new IllegalArgumentException("illegal y: " + y);
|
||||
}
|
||||
maxX = Math.max(maxX, x);
|
||||
MutableIntSet delegated = (MutableIntSet) delegateStore.get(x);
|
||||
|
@ -351,6 +344,12 @@ public final class BasicNaturalRelation implements IBinaryNaturalRelation {
|
|||
}
|
||||
|
||||
public void remove(int x, int y) {
|
||||
if (x < 0) {
|
||||
throw new IllegalArgumentException("illegal x: " + x);
|
||||
}
|
||||
if (y < 0) {
|
||||
throw new IllegalArgumentException("illegal y: " + y);
|
||||
}
|
||||
if (usingDelegate(x)) {
|
||||
// TODO: switch representation back to small store?
|
||||
MutableIntSet s = (MutableIntSet) delegateStore.get(x);
|
||||
|
|
|
@ -14,50 +14,35 @@ import com.ibm.wala.util.debug.VerboseAction;
|
|||
|
||||
/**
|
||||
* a relation R(x,y) where x >= 0
|
||||
*
|
||||
* @author sfink
|
||||
*/
|
||||
public interface IBinaryNaturalRelation extends VerboseAction, Iterable<IntPair> {
|
||||
/**
|
||||
* Add (x,y) to the relation
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return true iff the relation changes as a result of this call.
|
||||
*/
|
||||
public abstract boolean add(int x, int y);
|
||||
|
||||
/**
|
||||
* @param x
|
||||
* @return IntSet of y s.t. R(x,y) or null if none.
|
||||
*/
|
||||
public abstract IntSet getRelated(int x);
|
||||
|
||||
/**
|
||||
* @param x
|
||||
* @return number of y s.t. R(x,y)
|
||||
*/
|
||||
public abstract int getRelatedCount(int x);
|
||||
|
||||
/**
|
||||
* @param x
|
||||
* @return true iff there exists pair (x,y) for some y
|
||||
*/
|
||||
public abstract boolean anyRelated(int x);
|
||||
|
||||
/**
|
||||
* @param x
|
||||
* @param y
|
||||
*/
|
||||
public abstract void remove(int x, int y);
|
||||
|
||||
/**
|
||||
*/
|
||||
public abstract void removeAll(int x);
|
||||
|
||||
/**
|
||||
* @param x
|
||||
* @param y
|
||||
* @return true iff (x,y) \in R
|
||||
*/
|
||||
public abstract boolean contains(int x, int y);
|
||||
|
|
|
@ -62,6 +62,9 @@ public class MultiModalIntVector implements IntVector {
|
|||
}
|
||||
|
||||
public MultiModalIntVector(int defaultValue, int initialSize) {
|
||||
if (initialSize <= 0) {
|
||||
throw new IllegalArgumentException("invalid initialSize: " + initialSize);
|
||||
}
|
||||
this.defaultValue = defaultValue;
|
||||
init(initialSize, defaultValue);
|
||||
}
|
||||
|
@ -94,8 +97,8 @@ public class MultiModalIntVector implements IntVector {
|
|||
* @see com.ibm.wala.util.intset.IntVector#get(int)
|
||||
*/
|
||||
public int get(int x) {
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(x >= 0);
|
||||
if (x < 0) {
|
||||
throw new IllegalArgumentException("illegal x: " + x);
|
||||
}
|
||||
int index = x;
|
||||
if (index < byteStore.length) {
|
||||
|
@ -120,8 +123,11 @@ public class MultiModalIntVector implements IntVector {
|
|||
* @see com.ibm.wala.util.intset.IntVector#set(int, int)
|
||||
*/
|
||||
public void set(int x, int value) {
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(x >= 0);
|
||||
if (x < 0) {
|
||||
throw new IllegalArgumentException("illegal x: " + x);
|
||||
}
|
||||
if (x > MAX_SIZE) {
|
||||
throw new IllegalArgumentException("x is too big: " + x);
|
||||
}
|
||||
maxIndex = Math.max(maxIndex, x); // Find out if the new position is bigger than size of the array
|
||||
handleMorph(x, value);
|
||||
|
@ -241,42 +247,6 @@ public class MultiModalIntVector implements IntVector {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see com.ibm.wala.util.intset.IntVector#reportStats()
|
||||
*/
|
||||
public void performVerboseAction() {
|
||||
int length = getStoreLength();
|
||||
Trace.println("size: " + length);
|
||||
Trace.println("occupancy: " + computeOccupancy(length));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the percentage of entries in delegateStore that are non-null
|
||||
*/
|
||||
private double computeOccupancy(int length) {
|
||||
int count1 = 0;
|
||||
int internalLength = length;
|
||||
for (int i = 0; i < internalLength && i < byteStore.length; i++) {
|
||||
if (byteStore[i] != -1) {
|
||||
count1++;
|
||||
}
|
||||
}
|
||||
length -= byteStore.length;
|
||||
for (int i = 0; i < internalLength && i < byteStore.length; i++) {
|
||||
if (shortStore[i] != -1) {
|
||||
count1++;
|
||||
}
|
||||
}
|
||||
length -= shortStore.length;
|
||||
for (int i = 0; i < internalLength && i < intStore.length; i++) {
|
||||
if (intStore[i] != -1) {
|
||||
count1++;
|
||||
}
|
||||
}
|
||||
int count = count1;
|
||||
return (double) count / (double) length;
|
||||
}
|
||||
|
||||
public int getMaxIndex() {
|
||||
return maxIndex;
|
||||
}
|
||||
|
|
|
@ -469,6 +469,9 @@ public class MutableSharedBitVectorIntSet implements MutableIntSet {
|
|||
* @see com.ibm.wala.util.intset.IntSet#isSubset(com.ibm.wala.util.intset.IntSet)
|
||||
*/
|
||||
public boolean isSubset(IntSet that) {
|
||||
if (that == null) {
|
||||
throw new IllegalArgumentException("null that");
|
||||
}
|
||||
if (that instanceof MutableSharedBitVectorIntSet) {
|
||||
return isSubset((MutableSharedBitVectorIntSet) that);
|
||||
} else {
|
||||
|
|
|
@ -350,11 +350,8 @@ public class StringStuff {
|
|||
*
|
||||
* TODO: inefficient; needs tuning.
|
||||
*
|
||||
* @param name
|
||||
* @param start
|
||||
* @param length
|
||||
* @return an ImmutableByteArray that represents the package, or null if it's the unnamed package
|
||||
* @throws IllegalArgumentException if name is null
|
||||
* @throws IllegalArgumentException if name is null or malformed
|
||||
*/
|
||||
public static ImmutableByteArray parseForClass(ImmutableByteArray name, int start, int length) throws IllegalArgumentException {
|
||||
if (name == null) {
|
||||
|
@ -363,6 +360,7 @@ public class StringStuff {
|
|||
if (name.length() == 0) {
|
||||
throw new IllegalArgumentException("invalid class name: zero length");
|
||||
}
|
||||
try {
|
||||
if (parseForPackage(name, start, length) == null) {
|
||||
while (name.b[start] == '[') {
|
||||
start++;
|
||||
|
@ -383,6 +381,9 @@ public class StringStuff {
|
|||
int L = length - (lastSlash - start + 1);
|
||||
return new ImmutableByteArray(name.b, lastSlash + 1, L);
|
||||
}
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new IllegalArgumentException("Malformed name: " + name + " " + start + " " + length);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue