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


Java Instance.getClassObj方法代码示例

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


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

示例1: rootSuperClassAlwaysIgnored

import com.squareup.haha.perflib.Instance; //导入方法依赖的package包/类
private Exclusion rootSuperClassAlwaysIgnored(Instance child) {
  if (child == null) {
    return null;
  }
  Exclusion matchingParams = null;
  ClassObj superClassObj = child.getClassObj();
  while (superClassObj != null) {
    Exclusion params = excludedRefs.rootClassNames.get(superClassObj.getClassName());
    if (params != null) {
      // true overrides null or false.
      if (matchingParams == null || !matchingParams.alwaysExclude) {
        matchingParams = params;
      }
    }
    superClassObj = superClassObj.getSuperClassObj();
  }
  return matchingParams;
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:19,代码来源:ShortestPathFinder.java

示例2: isString

import com.squareup.haha.perflib.Instance; //导入方法依赖的package包/类
private boolean isString(Instance instance) {
  return instance.getClassObj() != null && instance.getClassObj()
      .getClassName()
      .equals(String.class.getName());
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:6,代码来源:ShortestPathFinder.java

示例3: buildLeakElement

import com.squareup.haha.perflib.Instance; //导入方法依赖的package包/类
private LeakTraceElement buildLeakElement(LeakNode node) {
  if (node.parent == null) {
    // Ignore any root node.
    return null;
  }
  Instance holder = node.parent.instance;

  if (holder instanceof RootObj) {
    return null;
  }
  LeakTraceElement.Type type = node.referenceType;
  String referenceName = node.referenceName;

  LeakTraceElement.Holder holderType;
  String className;
  String extra = null;
  List<String> fields = describeFields(holder);

  className = getClassName(holder);

  if (holder instanceof ClassObj) {
    holderType = CLASS;
  } else if (holder instanceof ArrayInstance) {
    holderType = ARRAY;
  } else {
    ClassObj classObj = holder.getClassObj();
    if (extendsThread(classObj)) {
      holderType = THREAD;
      String threadName = threadName(holder);
      extra = "(named '" + threadName + "')";
    } else if (className.matches(ANONYMOUS_CLASS_NAME_PATTERN)) {
      String parentClassName = classObj.getSuperClassObj().getClassName();
      if (Object.class.getName().equals(parentClassName)) {
        holderType = OBJECT;
        try {
          // This is an anonymous class implementing an interface. The API does not give access
          // to the interfaces implemented by the class. We check if it's in the class path and
          // use that instead.
          Class<?> actualClass = Class.forName(classObj.getClassName());
          Class<?>[] interfaces = actualClass.getInterfaces();
          if (interfaces.length > 0) {
            Class<?> implementedInterface = interfaces[0];
            extra = "(anonymous implementation of " + implementedInterface.getName() + ")";
          } else {
            extra = "(anonymous subclass of java.lang.Object)";
          }
        } catch (ClassNotFoundException ignored) {
        }
      } else {
        holderType = OBJECT;
        // Makes it easier to figure out which anonymous class we're looking at.
        extra = "(anonymous subclass of " + parentClassName + ")";
      }
    } else {
      holderType = OBJECT;
    }
  }
  return new LeakTraceElement(referenceName, type, holderType, className, extra, node.exclusion,
      fields);
}
 
开发者ID:square,项目名称:leakcanary,代码行数:61,代码来源:HeapAnalyzer.java


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