예제 #1
0
 private static void testClassState(
     ExecutionGraph graph, Map<String, Map<String, HeapItem>> classNameToFieldDescriptorToItem) {
   for (Entry<String, Map<String, HeapItem>> fieldDescriptorMapEntry :
       classNameToFieldDescriptorToItem.entrySet()) {
     String className = fieldDescriptorMapEntry.getKey();
     VirtualClass virtualClass = graph.getVM().getClassManager().getVirtualClass(className);
     Map<String, HeapItem> fieldDescriptorToItem = fieldDescriptorMapEntry.getValue();
     for (Entry<String, HeapItem> entry : fieldDescriptorToItem.entrySet()) {
       String fieldDescriptor = entry.getKey();
       String fieldName = fieldDescriptor.split(":")[0];
       VirtualField field = virtualClass.getField(fieldName);
       HeapItem expected = entry.getValue();
       HeapItem actual = graph.getTerminatingFieldConsensus(field);
       testFieldEquals(expected, actual);
     }
   }
 }
예제 #2
0
 private static void setupClassStates(
     ExecutionContext context,
     VirtualMachine vm,
     Map<String, Map<String, HeapItem>> classNameToFieldDescriptorToItem) {
   ClassManager classManager = vm.getClassManager();
   for (Entry<String, Map<String, HeapItem>> entry : classNameToFieldDescriptorToItem.entrySet()) {
     String className = entry.getKey();
     VirtualClass virtualClass = classManager.getVirtualClass(className);
     Map<String, HeapItem> fieldDescriptorToItem = entry.getValue();
     ClassState cState = context.peekClassState(virtualClass);
     for (Entry<String, HeapItem> fieldNameAndTypeToItem : fieldDescriptorToItem.entrySet()) {
       String fieldNameAndType = fieldNameAndTypeToItem.getKey();
       String fieldName = fieldNameAndType.split(":")[0];
       VirtualField field = virtualClass.getField(fieldName);
       HeapItem item = fieldNameAndTypeToItem.getValue();
       cState.pokeField(field, item);
     }
     context.initializeClass(cState, SideEffect.Level.NONE);
   }
 }