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


Java Type类代码示例

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


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

示例1: readStringOffsetFromHeapDumpInstance

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
@Test
public void readStringOffsetFromHeapDumpInstance() {
  buffer.setIntsToRead(COUNT_VALUE, OFFSET_VALUE, VALUE_ARRAY_INSTANCE_ID);
  buffer.setStringsToRead("abcdef");

  addStringClassToSnapshotWithFields(snapshot, new Field[]{
          new Field(Type.INT, "count"),
          new Field(Type.INT, "offset"),
          new Field(Type.OBJECT, "value")
  });

  ClassInstance stringInstance = createStringInstance();
  createCharArrayValueInstance();

  String actual = HahaHelper.asString(stringInstance);
  assertTrue(actual.equals("bcdef"));
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:18,代码来源:HahaHelperTest.java

示例2: defaultToZeroStringOffsetWhenHeapDumpInstanceIsMissingOffsetValue

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
@Test
public void defaultToZeroStringOffsetWhenHeapDumpInstanceIsMissingOffsetValue() {
  buffer.setIntsToRead(COUNT_VALUE, VALUE_ARRAY_INSTANCE_ID);
  buffer.setStringsToRead("abcdef");

  addStringClassToSnapshotWithFields(snapshot, new Field[]{
          new Field(Type.INT, "count"),
          new Field(Type.OBJECT, "value")
  });

  ClassInstance stringInstance = createStringInstance();
  createCharArrayValueInstance();

  String actual = HahaHelper.asString(stringInstance);
  assertTrue(actual.equals("abcde"));
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:17,代码来源:HahaHelperTest.java

示例3: defaultToZeroStringOffsetWhenReadingMPreview2HeapDump

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
@Test
public void defaultToZeroStringOffsetWhenReadingMPreview2HeapDump() {
  buffer.setIntsToRead(COUNT_VALUE, OFFSET_VALUE, VALUE_ARRAY_INSTANCE_ID);
  buffer.setStringsToRead("abcdef");

  addStringClassToSnapshotWithFields(snapshot, new Field[]{
          new Field(Type.INT, "count"),
          new Field(Type.INT, "offset"),
          new Field(Type.OBJECT, "value")
  });

  ClassInstance stringInstance = createStringInstance();
  createCharArrayValueInstance_M_Preview2();

  String actual = HahaHelper.asString(stringInstance);
  assertTrue(actual.equals("abcde"));
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:18,代码来源:HahaHelperTest.java

示例4: throwExceptionWhenMissingCharArrayValueForStringInMPreview2HeapDump

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
@Test
public void throwExceptionWhenMissingCharArrayValueForStringInMPreview2HeapDump() {
  buffer.setIntsToRead(COUNT_VALUE, OFFSET_VALUE, VALUE_ARRAY_INSTANCE_ID);
  buffer.setStringsToRead("abcdef");

  addStringClassToSnapshotWithFields(snapshot, new Field[]{
          new Field(Type.INT, "count"),
          new Field(Type.INT, "offset"),
          new Field(Type.OBJECT, "value")
  });

  ClassInstance stringInstance = createStringInstance();
  createObjectValueInstance_M_Preview2();

  try {
    HahaHelper.asString(stringInstance);
    fail("this test should have thrown UnsupportedOperationException");
  }
  catch (UnsupportedOperationException uoe) {
    String message = uoe.getMessage();
    assertTrue(message.equals("Could not find char array in " + stringInstance));
  }
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:24,代码来源:HahaHelperTest.java

示例5: readStringOffsetFromHeapDumpInstance_pre_O

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
@Test public void readStringOffsetFromHeapDumpInstance_pre_O() {
  buffer.setIntsToRead(COUNT_VALUE, OFFSET_VALUE, VALUE_ARRAY_INSTANCE_ID);
  buffer.setStringsToRead("abcdef");

  addStringClassToSnapshotWithFields(snapshot, new Field[]{
          new Field(Type.INT, "count"),
          new Field(Type.INT, "offset"),
          new Field(Type.OBJECT, "value")
  });

  ClassInstance stringInstance = createStringInstance();
  createCharArrayValueInstance();

  String actual = HahaHelper.asString(stringInstance);
  assertTrue(actual.equals("bcdef"));
}
 
开发者ID:square,项目名称:leakcanary,代码行数:17,代码来源:HahaHelperTest.java

示例6: readStringAsByteArrayFromHeapDumpInstance_O

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
@Test public void readStringAsByteArrayFromHeapDumpInstance_O() {
  // O uses default charset UTF-8
  buffer = new FakeHprofBuffer("UTF-8");
  initSnapshot(buffer);

  buffer.setIntsToRead(COUNT_VALUE, VALUE_ARRAY_INSTANCE_ID);
  buffer.setStringsToRead("abcdef");

  addStringClassToSnapshotWithFields_O(snapshot, new Field[]{
      new Field(Type.INT, "count"),
      new Field(Type.OBJECT, "value")
  });

  ClassInstance stringInstance = createStringInstance();
  createByteArrayValueInstance();

  String actual = HahaHelper.asString(stringInstance);
  assertTrue(actual.equals("abcde"));
}
 
开发者ID:square,项目名称:leakcanary,代码行数:20,代码来源:HahaHelperTest.java

示例7: throwExceptionWhenNotArrayValueForString

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
@Test public void throwExceptionWhenNotArrayValueForString() {
  buffer.setIntsToRead(COUNT_VALUE, OFFSET_VALUE, VALUE_ARRAY_INSTANCE_ID);
  buffer.setStringsToRead("abcdef");

  addStringClassToSnapshotWithFields(snapshot, new Field[]{
          new Field(Type.INT, "count"),
          new Field(Type.INT, "offset"),
          new Field(Type.OBJECT, "value")
  });

  ClassInstance stringInstance = createStringInstance();
  createObjectValueInstance();

  try {
    HahaHelper.asString(stringInstance);
    fail("this test should have thrown UnsupportedOperationException");
  } catch (UnsupportedOperationException uoe) {
    String message = uoe.getMessage();
    assertTrue(message.equals("Could not find char array in " + stringInstance));
  }
}
 
开发者ID:square,项目名称:leakcanary,代码行数:22,代码来源:HahaHelperTest.java

示例8: visitClassObj

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
private void visitClassObj(LeakNode node) {
  ClassObj classObj = (ClassObj) node.instance;
  Map<String, Exclusion> ignoredStaticFields =
      excludedRefs.staticFieldNameByClassName.get(classObj.getClassName());
  for (Map.Entry<Field, Object> entry : classObj.getStaticFieldValues().entrySet()) {
    Field field = entry.getKey();
    if (field.getType() != Type.OBJECT) {
      continue;
    }
    String fieldName = field.getName();
    if (fieldName.equals("$staticOverhead")) {
      continue;
    }
    Instance child = (Instance) entry.getValue();
    boolean visit = true;
    if (ignoredStaticFields != null) {
      Exclusion params = ignoredStaticFields.get(fieldName);
      if (params != null) {
        visit = false;
        if (!params.alwaysExclude) {
          enqueue(params, node, child, fieldName, STATIC_FIELD);
        }
      }
    }
    if (visit) {
      enqueue(null, node, child, fieldName, STATIC_FIELD);
    }
  }
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:30,代码来源:ShortestPathFinder.java

示例9: visitArrayInstance

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
private void visitArrayInstance(LeakNode node) {
  ArrayInstance arrayInstance = (ArrayInstance) node.instance;
  Type arrayType = arrayInstance.getArrayType();
  if (arrayType == Type.OBJECT) {
    Object[] values = arrayInstance.getValues();
    for (int i = 0; i < values.length; i++) {
      Instance child = (Instance) values[i];
      enqueue(null, node, child, "[" + i + "]", ARRAY_ENTRY);
    }
  }
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:12,代码来源:ShortestPathFinder.java

示例10: enqueue

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
private void enqueue(Exclusion exclusion, LeakNode parent, Instance child, String referenceName,
    LeakTraceElement.Type referenceType) {
  if (child == null) {
    return;
  }
  if (isPrimitiveOrWrapperArray(child) || isPrimitiveWrapper(child)) {
    return;
  }
  // Whether we want to visit now or later, we should skip if this is already to visit.
  if (toVisitSet.contains(child)) {
    return;
  }
  boolean visitNow = exclusion == null;
  if (!visitNow && toVisitIfNoPathSet.contains(child)) {
    return;
  }
  if (canIgnoreStrings && isString(child)) {
    return;
  }
  if (visitedSet.contains(child)) {
    return;
  }
  LeakNode childNode = new LeakNode(exclusion, child, parent, referenceName, referenceType);
  if (visitNow) {
    toVisitSet.add(child);
    toVisitQueue.add(childNode);
  } else {
    toVisitIfNoPathSet.add(child);
    toVisitIfNoPathQueue.add(childNode);
  }
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:32,代码来源:ShortestPathFinder.java

示例11: isPrimitiveOrWrapperArray

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
public static boolean isPrimitiveOrWrapperArray(Object value) {
  if (!(value instanceof ArrayInstance)) {
    return false;
  }
  ArrayInstance arrayInstance = (ArrayInstance) value;
  if (arrayInstance.getArrayType() != Type.OBJECT) {
    return true;
  }
  return WRAPPER_TYPES.contains(arrayInstance.getClassObj().getClassName());
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:11,代码来源:HahaHelper.java

示例12: defaultToZeroStringOffsetWhenHeapDumpInstanceIsMissingOffsetValue_pre_O

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
@Test public void defaultToZeroStringOffsetWhenHeapDumpInstanceIsMissingOffsetValue_pre_O() {
  buffer.setIntsToRead(COUNT_VALUE, VALUE_ARRAY_INSTANCE_ID);
  buffer.setStringsToRead("abcdef");

  addStringClassToSnapshotWithFields(snapshot, new Field[]{
          new Field(Type.INT, "count"),
          new Field(Type.OBJECT, "value")
  });

  ClassInstance stringInstance = createStringInstance();
  createCharArrayValueInstance();

  String actual = HahaHelper.asString(stringInstance);
  assertTrue(actual.equals("abcde"));
}
 
开发者ID:square,项目名称:leakcanary,代码行数:16,代码来源:HahaHelperTest.java

示例13: isCharArray

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
private static boolean isCharArray(Object value) {
  return value instanceof ArrayInstance && ((ArrayInstance) value).getArrayType() == Type.CHAR;
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:4,代码来源:HahaHelper.java

示例14: createCharArrayValueInstance

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
private void createCharArrayValueInstance() {
  ArrayInstance valueArrayInstance = new ArrayInstance(0, null, Type.CHAR, VALUE_ARRAY_LENGTH, 0);
  snapshot.addInstance(VALUE_ARRAY_INSTANCE_ID, valueArrayInstance);
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:5,代码来源:HahaHelperTest.java

示例15: createCharArrayValueInstance_M_Preview2

import com.squareup.haha.perflib.Type; //导入依赖的package包/类
private void createCharArrayValueInstance_M_Preview2() {
  ArrayInstance valueInstance = new ArrayInstance(0, null, Type.CHAR, VALUE_ARRAY_LENGTH, 0);
  snapshot.addInstance(STRING_INSTANCE_ID + 16, valueInstance);
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:5,代码来源:HahaHelperTest.java


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