(ObjectReporter reporter, HeapObject.HeapInstance instance)
| 54 | String className = clazz.getName(); |
| 55 | reporter.whenInstanceOf(className, new Function2<ObjectReporter, HeapObject.HeapInstance, Unit>() { |
| 56 | @Override |
| 57 | public Unit invoke(ObjectReporter reporter, HeapObject.HeapInstance instance) { |
| 58 | HeapField hfName = instance.get(className, "name"); |
| 59 | if (hfName != null) { |
| 60 | String label = hfName.getValue().readAsJavaString(); |
| 61 | reporter.getLabels().add("name=" + label); |
| 62 | } |
| 63 | |
| 64 | // Could be different class loader |
| 65 | if (className.equals(SimpleTask.class.getName())) { |
| 66 | HeapField hfStarted = instance.get(className, "started"); |
| 67 | if (hfStarted != null) { |
| 68 | Long started = hfStarted.getValue().getAsLong(); |
| 69 | if (started != null) { |
| 70 | String label = (started == 0 ? null : new Date(started).toString()); |
| 71 | reporter.getLabels().add("started=" + label); |
| 72 | } |
| 73 | } |
| 74 | HeapField hfDestroyed = instance.get(className, "destroyed"); |
| 75 | if (hfDestroyed != null) { |
| 76 | Boolean destroyed = hfDestroyed.getValue().getAsBoolean(); |
| 77 | if (destroyed != null) |
| 78 | reporter.getLabels().add("destroyed=" + destroyed); |
| 79 | } |
| 80 | } else if (className.equals(TwoStateOwner.class.getName())) { |
| 81 | HeapField hfState = instance.get(className, "state"); |
| 82 | if (hfState != null) { |
| 83 | String state = hfState.getValue().readAsJavaString(); |
| 84 | reporter.getLabels().add("state=" + state); |
| 85 | } |
| 86 | HeapField hfOwned = instance.get(className, "owned"); |
| 87 | if (hfOwned != null) { |
| 88 | Boolean owned = hfOwned.getValue().getAsBoolean(); |
| 89 | reporter.getLabels().add("owned=" + owned); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return null; |
| 94 | } |
| 95 | }); |
| 96 | } |
| 97 | }); |
no test coverage detected