< prev index next >

test/hotspot/jtreg/runtime/cds/CDSMapReader.java

Print this page

280                 } else {
281                     nextLine();
282                 }
283             }
284             return mapFile;
285         } catch (Throwable t) {
286             System.out.println("Error parsing line " + lineCount + ": " + line);
287             throw new RuntimeException(t);
288         } finally {
289             System.out.println("Parsed " + lineCount + " lines in " + fileName);
290             System.out.println("Found " + mapFile.heapObjectCount() + " heap objects ("
291                                + mapFile.stringCount + " strings)");
292             mapFile = null;
293             reader = null;
294             line = null;
295             lineCount = 0;
296         }
297     }
298 
299     private static void mustContain(HashMap<Long, HeapObject> allObjects, Field field, long pointer, boolean isNarrow) {
300         if (allObjects.get(pointer) == null) {
301             throw new RuntimeException((isNarrow ? "narrowOop" : "oop") + " pointer 0x" + Long.toHexString(pointer) +
302                                        " on line " + field.lineCount + " doesn't point to a valid heap object");
303         }
304     }
305 
306     // Check that each oop fields in the HeapObjects must point to a valid HeapObject.
307     public static void validate(MapFile mapFile) {
308         int count1 = 0;
309         int count2 = 0;
310         for (HeapObject heapObject : mapFile.heapObjects) {
311             if (heapObject.fields != null) {
312                 for (Field field : heapObject.fields) {
313                     HeapAddress referentAddress = field.referentAddress;
314                     long oop = referentAddress.oop;
315                     long narrowOop = referentAddress.narrowOop;
316                     // Is this test actually doing something?
317                     //     To see how an invalidate pointer may be found, change oop in the
318                     //     following line to oop+1
319                     if (oop != 0) {
320                         mustContain(mapFile.oopToObject, field, oop, false);

280                 } else {
281                     nextLine();
282                 }
283             }
284             return mapFile;
285         } catch (Throwable t) {
286             System.out.println("Error parsing line " + lineCount + ": " + line);
287             throw new RuntimeException(t);
288         } finally {
289             System.out.println("Parsed " + lineCount + " lines in " + fileName);
290             System.out.println("Found " + mapFile.heapObjectCount() + " heap objects ("
291                                + mapFile.stringCount + " strings)");
292             mapFile = null;
293             reader = null;
294             line = null;
295             lineCount = 0;
296         }
297     }
298 
299     private static void mustContain(HashMap<Long, HeapObject> allObjects, Field field, long pointer, boolean isNarrow) {
300         if (pointer != 0x0 && allObjects.get(pointer) == null) {
301             throw new RuntimeException((isNarrow ? "narrowOop" : "oop") + " pointer 0x" + Long.toHexString(pointer) +
302                                        " on line " + field.lineCount + " doesn't point to a valid heap object");
303         }
304     }
305 
306     // Check that each oop fields in the HeapObjects must point to a valid HeapObject.
307     public static void validate(MapFile mapFile) {
308         int count1 = 0;
309         int count2 = 0;
310         for (HeapObject heapObject : mapFile.heapObjects) {
311             if (heapObject.fields != null) {
312                 for (Field field : heapObject.fields) {
313                     HeapAddress referentAddress = field.referentAddress;
314                     long oop = referentAddress.oop;
315                     long narrowOop = referentAddress.narrowOop;
316                     // Is this test actually doing something?
317                     //     To see how an invalidate pointer may be found, change oop in the
318                     //     following line to oop+1
319                     if (oop != 0) {
320                         mustContain(mapFile.oopToObject, field, oop, false);
< prev index next >