本文整理了Java中com.ibm.wala.util.warnings.Warnings.add()
方法的一些代码示例,展示了Warnings.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Warnings.add()
方法的具体详情如下:
包路径:com.ibm.wala.util.warnings.Warnings
类名称:Warnings
方法名:add
暂无
代码示例来源:origin: com.ibm.wala/com.ibm.wala.core
@Override
protected FileModule makeFile(final File file) {
try {
return new ClassFileModule(file, this);
} catch (InvalidClassFileException e) {
Warnings.add(new Warning(Warning.MODERATE) {
@Override
public String getMsg() {
return "Invalid class file at path " + file.getAbsolutePath();
}
});
return null;
}
}
代码示例来源:origin: wala/WALA
@Override
protected FileModule makeFile(final File file) {
try {
return new ClassFileModule(file, this);
} catch (InvalidClassFileException e) {
Warnings.add(new Warning(Warning.MODERATE) {
@Override
public String getMsg() {
return "Invalid class file at path " + file.getAbsolutePath();
}
});
return null;
}
}
代码示例来源:origin: wala/WALA
/**
* @param interfaces a set of class names
* @return Set of all IClasses that can be loaded corresponding to the class names in the interfaces array; raise warnings if
* classes can not be loaded
*/
private Collection<IClass> array2IClassSet(ImmutableByteArray[] interfaces) {
ArrayList<IClass> result = new ArrayList<>(interfaces.length);
for (ImmutableByteArray name : interfaces) {
IClass klass = null;
klass = loader.lookupClass(TypeName.findOrCreate(name));
if (klass == null) {
Warnings.add(ClassNotFoundWarning.create(name));
} else {
result.add(klass);
}
}
return result;
}
代码示例来源:origin: com.ibm.wala/com.ibm.wala.core
/**
* @param interfaces a set of class names
* @return Set of all IClasses that can be loaded corresponding to the class names in the interfaces array; raise warnings if
* classes can not be loaded
*/
private Collection<IClass> array2IClassSet(ImmutableByteArray[] interfaces) {
ArrayList<IClass> result = new ArrayList<>(interfaces.length);
for (ImmutableByteArray name : interfaces) {
IClass klass = null;
klass = loader.lookupClass(TypeName.findOrCreate(name));
if (klass == null) {
Warnings.add(ClassNotFoundWarning.create(name));
} else {
result.add(klass);
}
}
return result;
}
代码示例来源:origin: wala/WALA
private TypeAbstraction interceptType(TypeAbstraction T) {
TypeReference type = T.getType().getReference();
if (type.equals(TypeReference.JavaIoSerializable)) {
Warnings.add(IgnoreSerializableWarning.create());
return null;
} else {
return T;
}
}
代码示例来源:origin: com.ibm.wala/com.ibm.wala.core
private TypeAbstraction interceptType(TypeAbstraction T) {
TypeReference type = T.getType().getReference();
if (type.equals(TypeReference.JavaIoSerializable)) {
Warnings.add(IgnoreSerializableWarning.create());
return null;
} else {
return T;
}
}
代码示例来源:origin: wala/WALA
Warnings.add(MethodResolutionFailure.moderate(target));
Warnings.add(MethodResolutionFailure.severe(target));
} else {
TypeReference[] exceptionTypes = M.getDeclaredExceptions();
代码示例来源:origin: com.ibm.wala/com.ibm.wala.core
Warnings.add(MethodResolutionFailure.moderate(target));
Warnings.add(MethodResolutionFailure.severe(target));
} else {
TypeReference[] exceptionTypes = M.getDeclaredExceptions();
代码示例来源:origin: wala/WALA
Warnings.add(new Warning() {
代码示例来源:origin: com.ibm.wala/com.ibm.wala.core
Warnings.add(new Warning() {
代码示例来源:origin: com.ibm.wala/com.ibm.wala.core
Warnings.add(new Warning() {
代码示例来源:origin: wala/WALA
Warnings.add(new Warning() {
代码示例来源:origin: com.ibm.wala/com.ibm.wala.core
/**
* @return Collection of IClasses, representing the interfaces this class implements.
*/
protected Collection<IClass> computeAllInterfacesAsCollection() {
Collection<? extends IClass> c = getDirectInterfaces();
Set<IClass> result = HashSetFactory.make();
for (IClass klass : c) {
if (klass.isInterface()) {
result.add(klass);
} else {
Warnings.add(ClassHierarchyWarning.create("expected an interface " + klass));
}
}
// at this point result holds all interfaces the class directly extends.
// now expand to a fixed point.
Set<IClass> last = null;
do {
last = HashSetFactory.make(result);
for (IClass i : last) {
result.addAll(i.getDirectInterfaces());
}
} while (last.size() < result.size());
// now add any interfaces implemented by the super class
IClass sup = null;
sup = getSuperclass();
if (sup != null) {
result.addAll(sup.getAllImplementedInterfaces());
}
return result;
}
代码示例来源:origin: wala/WALA
/**
* @return Collection of IClasses, representing the interfaces this class implements.
*/
protected Collection<IClass> computeAllInterfacesAsCollection() {
Collection<? extends IClass> c = getDirectInterfaces();
Set<IClass> result = HashSetFactory.make();
for (IClass klass : c) {
if (klass.isInterface()) {
result.add(klass);
} else {
Warnings.add(ClassHierarchyWarning.create("expected an interface " + klass));
}
}
// at this point result holds all interfaces the class directly extends.
// now expand to a fixed point.
Set<IClass> last = null;
do {
last = HashSetFactory.make(result);
for (IClass i : last) {
result.addAll(i.getDirectInterfaces());
}
} while (last.size() < result.size());
// now add any interfaces implemented by the super class
IClass sup = null;
sup = getSuperclass();
if (sup != null) {
result.addAll(sup.getAllImplementedInterfaces());
}
return result;
}
代码示例来源:origin: com.ibm.wala/com.ibm.wala.core
protected void processPutStatic(int rval, FieldReference field, IField f) {
PointerKey fKey = getPointerKeyForStaticField(f);
PointerKey rvalKey = getPointerKeyForLocal(rval);
// if (!supportFullPointerFlowGraph &&
// contentsAreInvariant(rval)) {
if (contentsAreInvariant(symbolTable, du, rval)) {
system.recordImplicitPointsToSet(rvalKey);
InstanceKey[] ik = getInvariantContents(rval);
for (InstanceKey element : ik) {
system.newConstraint(fKey, element);
}
} else {
system.newConstraint(fKey, assignOperator, rvalKey);
}
if (DEBUG) {
System.err.println("visitPut class init " + field.getDeclaringClass() + ' ' + field);
}
// side effect of putstatic: may call class initializer
IClass klass = getClassHierarchy().lookupClass(field.getDeclaringClass());
if (klass == null) {
Warnings.add(FieldResolutionFailure.create(field));
} else {
processClassInitializer(klass);
}
}
代码示例来源:origin: wala/WALA
protected void processPutStatic(int rval, FieldReference field, IField f) {
PointerKey fKey = getPointerKeyForStaticField(f);
PointerKey rvalKey = getPointerKeyForLocal(rval);
// if (!supportFullPointerFlowGraph &&
// contentsAreInvariant(rval)) {
if (contentsAreInvariant(symbolTable, du, rval)) {
system.recordImplicitPointsToSet(rvalKey);
InstanceKey[] ik = getInvariantContents(rval);
for (InstanceKey element : ik) {
system.newConstraint(fKey, element);
}
} else {
system.newConstraint(fKey, assignOperator, rvalKey);
}
if (DEBUG) {
System.err.println("visitPut class init " + field.getDeclaringClass() + ' ' + field);
}
// side effect of putstatic: may call class initializer
IClass klass = getClassHierarchy().lookupClass(field.getDeclaringClass());
if (klass == null) {
Warnings.add(FieldResolutionFailure.create(field));
} else {
processClassInitializer(klass);
}
}
代码示例来源:origin: com.ibm.wala/com.ibm.wala.core
public void visitPutInternal(int rval, int ref, boolean isStatic, FieldReference field) {
if (DEBUG) {
System.err.println("visitPut " + field);
}
// skip putfields of primitive type
if (field.getFieldType().isPrimitiveType()) {
return;
}
IField f = getClassHierarchy().resolveField(field);
if (f == null) {
if (DEBUG) {
System.err.println("Could not resolve field " + field);
}
Warnings.add(FieldResolutionFailure.create(field));
return;
}
assert f.getFieldTypeReference().getName().equals(field.getFieldType().getName()) :
"name clash of two fields with the same name but different type: " + f.getReference() + " <=> " + field;
assert isStatic || !symbolTable.isStringConstant(ref) : "put to string constant shouldn't be allowed?";
if (isStatic) {
processPutStatic(rval, field, f);
} else {
processPutField(rval, ref, f);
}
}
代码示例来源:origin: wala/WALA
public void visitPutInternal(int rval, int ref, boolean isStatic, FieldReference field) {
if (DEBUG) {
System.err.println("visitPut " + field);
}
// skip putfields of primitive type
if (field.getFieldType().isPrimitiveType()) {
return;
}
IField f = getClassHierarchy().resolveField(field);
if (f == null) {
if (DEBUG) {
System.err.println("Could not resolve field " + field);
}
Warnings.add(FieldResolutionFailure.create(field));
return;
}
assert f.getFieldTypeReference().getName().equals(field.getFieldType().getName()) :
"name clash of two fields with the same name but different type: " + f.getReference() + " <=> " + field;
assert isStatic || !symbolTable.isStringConstant(ref) : "put to string constant shouldn't be allowed?";
if (isStatic) {
processPutStatic(rval, field, f);
} else {
processPutField(rval, ref, f);
}
}
代码示例来源:origin: wala/WALA
private void recordExceptionTypes(Set<ExceptionHandler> set, IClassLoader loader) {
for (ExceptionHandler handler : set) {
TypeReference t = null;
if (handler.getCatchClass() == null) {
// by convention, in ShrikeCT this means catch everything
t = TypeReference.JavaLangThrowable;
} else if (handler.getCatchClassLoader() instanceof ClassLoaderReference) {
t = ShrikeUtil.makeTypeReference((ClassLoaderReference)handler.getCatchClassLoader(), handler.getCatchClass());
} else {
TypeReference exceptionType = ShrikeUtil.makeTypeReference(loader.getReference(), handler.getCatchClass());
IClass klass = null;
klass = loader.lookupClass(exceptionType.getName());
if (klass == null) {
Warnings.add(ExceptionLoadFailure.create(exceptionType, method));
t = exceptionType;
} else {
t = klass.getReference();
}
}
int instructionIndex = handler.getHandler();
IBasicBlock b = getBlockForInstruction(instructionIndex);
if (!(b instanceof ExceptionHandlerBasicBlock)) {
assert b instanceof ExceptionHandlerBasicBlock : "not exception handler " + b + " index " + instructionIndex;
}
ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) getBlockForInstruction(instructionIndex);
bb.addCaughtExceptionType(t);
}
}
代码示例来源:origin: com.ibm.wala/com.ibm.wala.core
private void recordExceptionTypes(Set<ExceptionHandler> set, IClassLoader loader) {
for (ExceptionHandler handler : set) {
TypeReference t = null;
if (handler.getCatchClass() == null) {
// by convention, in ShrikeCT this means catch everything
t = TypeReference.JavaLangThrowable;
} else if (handler.getCatchClassLoader() instanceof ClassLoaderReference) {
t = ShrikeUtil.makeTypeReference((ClassLoaderReference)handler.getCatchClassLoader(), handler.getCatchClass());
} else {
TypeReference exceptionType = ShrikeUtil.makeTypeReference(loader.getReference(), handler.getCatchClass());
IClass klass = null;
klass = loader.lookupClass(exceptionType.getName());
if (klass == null) {
Warnings.add(ExceptionLoadFailure.create(exceptionType, method));
t = exceptionType;
} else {
t = klass.getReference();
}
}
int instructionIndex = handler.getHandler();
IBasicBlock b = getBlockForInstruction(instructionIndex);
if (!(b instanceof ExceptionHandlerBasicBlock)) {
assert b instanceof ExceptionHandlerBasicBlock : "not exception handler " + b + " index " + instructionIndex;
}
ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) getBlockForInstruction(instructionIndex);
bb.addCaughtExceptionType(t);
}
}
内容来源于网络,如有侵权,请联系作者删除!