本文整理汇总了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"));
}
示例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"));
}
示例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"));
}
示例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));
}
}
示例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"));
}
示例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"));
}
示例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));
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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());
}
示例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"));
}
示例13: isCharArray
import com.squareup.haha.perflib.Type; //导入依赖的package包/类
private static boolean isCharArray(Object value) {
return value instanceof ArrayInstance && ((ArrayInstance) value).getArrayType() == Type.CHAR;
}
示例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);
}
示例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);
}