当前位置: 首页>>代码示例>>Java>>正文


Java ClassInstance.FieldValue方法代码示例

本文整理汇总了Java中com.squareup.haha.perflib.ClassInstance.FieldValue方法的典型用法代码示例。如果您正苦于以下问题:Java ClassInstance.FieldValue方法的具体用法?Java ClassInstance.FieldValue怎么用?Java ClassInstance.FieldValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.haha.perflib.ClassInstance的用法示例。


在下文中一共展示了ClassInstance.FieldValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: threadName

import com.squareup.haha.perflib.ClassInstance; //导入方法依赖的package包/类
static String threadName(Instance holder) {
  List<ClassInstance.FieldValue> values = classInstanceValues(holder);
  Object nameField = fieldValue(values, "name");
  if (nameField == null) {
    // Sometimes we can't find the String at the expected memory address in the heap dump.
    // See https://github.com/square/leakcanary/issues/417 .
    return "Thread name not available";
  }
  return asString(nameField);
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:11,代码来源:HahaHelper.java

示例2: hasField

import com.squareup.haha.perflib.ClassInstance; //导入方法依赖的package包/类
static boolean hasField(List<ClassInstance.FieldValue> values, String fieldName) {
  for (ClassInstance.FieldValue fieldValue : values) {
    if (fieldValue.getField().getName().equals(fieldName)) {
      //noinspection unchecked
      return true;
    }
  }
  return false;
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:10,代码来源:HahaHelper.java

示例3: findLeakingReference

import com.squareup.haha.perflib.ClassInstance; //导入方法依赖的package包/类
private Instance findLeakingReference(String key, Snapshot snapshot) {
  ClassObj refClass = snapshot.findClass(KeyedWeakReference.class.getName());
  List<String> keysFound = new ArrayList<String>();
  for (Instance instance : refClass.getInstancesList()) {
    List<ClassInstance.FieldValue> values = classInstanceValues(instance);
    String keyCandidate = asString(fieldValue(values, "key"));
    if (keyCandidate.equals(key)) {
      return fieldValue(values, "referent");
    }
    keysFound.add(keyCandidate);
  }
  throw new IllegalStateException(
      "Could not find weak reference with key " + key + " in " + keysFound);
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:15,代码来源:HeapAnalyzer.java

示例4: findTrackedReferences

import com.squareup.haha.perflib.ClassInstance; //导入方法依赖的package包/类
public List<TrackedReference> findTrackedReferences(File heapDumpFile) {
  if (!heapDumpFile.exists()) {
    throw new IllegalArgumentException("File does not exist: " + heapDumpFile);
  }
  try {
    HprofBuffer buffer = new MemoryMappedFileBuffer(heapDumpFile);
    HprofParser parser = new HprofParser(buffer);
    Snapshot snapshot = parser.parse();
    deduplicateGcRoots(snapshot);

    ClassObj refClass = snapshot.findClass(KeyedWeakReference.class.getName());
    List<TrackedReference> references = new ArrayList<>();
    for (Instance weakRef : refClass.getInstancesList()) {
      List<ClassInstance.FieldValue> values = classInstanceValues(weakRef);
      String key = asString(fieldValue(values, "key"));
      String name =
          hasField(values, "name") ? asString(fieldValue(values, "name")) : "(No name field)";
      Instance instance = fieldValue(values, "referent");
      if (instance != null) {
        String className = getClassName(instance);
        List<String> fields = describeFields(instance);
        references.add(new TrackedReference(key, name, className, fields));
      }
    }
    return references;
  } catch (Throwable e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:square,项目名称:leakcanary,代码行数:30,代码来源:HeapAnalyzer.java

示例5: findLeakingReference

import com.squareup.haha.perflib.ClassInstance; //导入方法依赖的package包/类
private Instance findLeakingReference(String key, Snapshot snapshot) {
  ClassObj refClass = snapshot.findClass(KeyedWeakReference.class.getName());
  List<String> keysFound = new ArrayList<>();
  for (Instance instance : refClass.getInstancesList()) {
    List<ClassInstance.FieldValue> values = classInstanceValues(instance);
    String keyCandidate = asString(fieldValue(values, "key"));
    if (keyCandidate.equals(key)) {
      return fieldValue(values, "referent");
    }
    keysFound.add(keyCandidate);
  }
  throw new IllegalStateException(
      "Could not find weak reference with key " + key + " in " + keysFound);
}
 
开发者ID:square,项目名称:leakcanary,代码行数:15,代码来源:HeapAnalyzer.java

示例6: fieldToString

import com.squareup.haha.perflib.ClassInstance; //导入方法依赖的package包/类
static String fieldToString(ClassInstance.FieldValue fieldValue) {
  return fieldToString(fieldValue.getField(), fieldValue.getValue());
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:4,代码来源:HahaHelper.java

示例7: classInstanceValues

import com.squareup.haha.perflib.ClassInstance; //导入方法依赖的package包/类
static List<ClassInstance.FieldValue> classInstanceValues(Instance instance) {
  ClassInstance classInstance = (ClassInstance) instance;
  return classInstance.getValues();
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:5,代码来源:HahaHelper.java


注:本文中的com.squareup.haha.perflib.ClassInstance.FieldValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。