com.ibm.wala.util.warnings.Warnings类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中com.ibm.wala.util.warnings.Warnings类的一些代码示例,展示了Warnings类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Warnings类的具体详情如下:
包路径:com.ibm.wala.util.warnings.Warnings
类名称:Warnings

Warnings介绍

[英]A global, static dictionary of warnings
[中]全球静态警告词典

代码示例

代码示例来源:origin: uber/NullAway

AnalysisCache cache = new AnalysisCacheImpl();
IClassHierarchy cha = ClassHierarchyFactory.makeWithPhantom(scope);
Warnings.clear();

代码示例来源: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

System.out.println(Warnings.asString());
Warnings.clear();
AnalysisOptions options = new AnalysisOptions();
Iterable<Entrypoint> entrypoints = Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, new String[] { mainClass } );

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

Warnings.add(EntrypointResolutionWarning.create(E));
} else {
 entrypointCallSites.add(call.getCallSite());
throw new IllegalStateException("Could not create a entrypoint callsites: " +   Warnings.asString());

代码示例来源:origin: wala/WALA

/**
 * test that when analyzing Reflect1.main(), there is no warning about
 * "Integer".
 */
@Test
public void testReflect1() throws WalaException, IllegalArgumentException, CancelException, IOException {
 AnalysisScope scope = findOrCreateAnalysisScope();
 IClassHierarchy cha = findOrCreateCHA(scope);
 Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
   TestConstants.REFLECT1_MAIN);
 AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
 Warnings.clear();
 CallGraphTest.doCallGraphs(options, new AnalysisCacheImpl(), cha, scope);
 for (Warning w : Iterator2Iterable.make(Warnings.iterator())) {
  if (w.toString().indexOf("com/ibm/jvm") > 0) {
   continue;
  }
  if (w.toString().indexOf("Integer") >= 0) {
   Assert.assertTrue(w.toString(), false);
  }
 }
}

代码示例来源:origin: wala/WALA

@Test public void testCornerCases() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
 AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
   CallGraphTestUtil.REGRESSION_EXCLUSIONS);
 ClassHierarchy cha = ClassHierarchyFactory.make(scope);
 Iterable<Entrypoint> entrypoints = new AllApplicationEntrypoints(scope, cha);
 AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
 // this speeds up the test
 options.setReflectionOptions(ReflectionOptions.NONE);
 doCallGraphs(options, new AnalysisCacheImpl(), cha, scope);
 // we expect a warning or two about class Abstract1, which has no concrete
 // subclasses
 String ws = Warnings.asString();
 Assert.assertTrue("failed to report a warning about Abstract1", ws.indexOf("cornerCases/Abstract1") > -1);
 // we do not expect a warning about class Abstract2, which has a concrete
 // subclasses
 Assert.assertTrue("reported a warning about Abstract2", ws.indexOf("cornerCases/Abstract2") == -1);
}

代码示例来源:origin: wala/WALA

IClassHierarchy cha = ClassHierarchyFactory.make(scope);
System.out.println(cha.getNumberOfClasses() + " classes");
System.out.println(Warnings.asString());
Warnings.clear();
AnalysisOptions options = new AnalysisOptions();
Iterable<Entrypoint> entrypoints = entryClass != null ? makePublicEntrypoints(cha, entryClass) : Util.makeMainEntrypoints(scope, cha, mainClass);

代码示例来源:origin: wala/WALA

Warnings.add(EntrypointResolutionWarning.create(E));
} else {
 entrypointCallSites.add(call.getCallSite());
throw new IllegalStateException("Could not create a entrypoint callsites: " +   Warnings.asString());

代码示例来源: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

public AndroidAnalysisContext(ISCanDroidOptions options, String exclusions)
    throws IOException, IllegalArgumentException, ClassHierarchyException {
  
  this.options = options;
  scope = AndroidAnalysisScope.setUpAndroidAnalysisScope(options.getClasspath(), exclusions, getClass().getClassLoader(), options.getAndroidLibrary());
  
  cha = ClassHierarchyFactory.make(scope);
  /*
  if (options.classHierarchyWarnings()) {
    // log ClassHierarchy warnings
    for (Warning w : Iterator2Iterable.make(Warnings.iterator())) {
      
    }
  }
  */
  Warnings.clear();
}

代码示例来源: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: wala/WALA

@AfterClass
public static void afterClass() throws Exception {
 Warnings.clear();
 scope = null;
 cha = null;
 cg = null;
 cache = null;
}

代码示例来源: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

@After
public void tearDown() throws Exception {
 Warnings.clear();
 if (ANALYZE_LEAKS) {
  HeapTracer.analyzeLeaks();
 }
}

代码示例来源: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: wala/WALA

@AfterClass
public static void afterClass() throws Exception {
 Warnings.clear();
}
@Test public void test() {

代码示例来源: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

@AfterClass
public static void afterClass() throws Exception {
 Warnings.clear();
 scope = null;
 cha = null;
}

代码示例来源:origin: wala/WALA

Warnings.add(MethodResolutionFailure.moderate(target));
 Warnings.add(MethodResolutionFailure.severe(target));
} else {
 TypeReference[] exceptionTypes = M.getDeclaredExceptions();

代码示例来源:origin: wala/WALA

@AfterClass
public static void afterClass() throws Exception {
 Warnings.clear();
 scope = null;
 cha = null;
 options = null;
 cache = null;
}

相关文章