Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #1016892 // heapWalker_pathToGCRootWithFieldNames

JavaX fragment (include)

1  
static L<Pair<Instance, S>> heapWalker_pathToGCRootWithFieldNames(Instance baseInstance) {
2  
  bool debug = false;
3  
  L<Pair<Instance, S>> path = map(func(Instance i) -> Pair<Instance, S> { pair(i, null) }, heapWalker_pathToGCRoot(baseInstance));
4  
  bigLoop: for (int i = 1; i < l(path); i++) {
5  
    long i0 = path.get(i-1).a.getInstanceId();
6  
    Instance i1 = path.get(i).a;
7  
    L<FieldValue> fieldValues;
8  
    if (eq(shortClassName(i1), 'ClassDumpInstance))
9  
      fieldValues = (L<FieldValue>) call(get(i1, 'classDump), 'getStaticFieldValues);
10  
    else
11  
      fieldValues = i1.getFieldValues();
12  
    
13  
    if (debug) {
14  
      print("Fields: " + map(fieldValues, func(FieldValue fv) -> S { fv.getField().getName() }));
15  
      print("Types: " + map className(fieldValues));
16  
      print("Looking for: " + i0);
17  
      print("Instances: " + map(filterByType(ObjectFieldValue.class, fieldValues), func(ObjectFieldValue fv) -> Long { fv.getInstanceId() }));
18  
    }
19  
    for (FieldValue fv : fieldValues)
20  
      if (fv instanceof ObjectFieldValue && ((ObjectFieldValue) fv).getInstanceId() == i0) {
21  
        path.get(i).b = fv.getField().getName();
22  
        continue bigLoop;
23  
      }
24  
  }
25  
  ret path;
26  
}

Author comment

Began life as a copy of #1016889

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1016892
Snippet name: heapWalker_pathToGCRootWithFieldNames
Eternal ID of this version: #1016892/11
Text MD5: 8fc2f4dd6d17cc764d1bf6f2f6e8962d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-06 18:49:30
Source code size: 1205 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 339 / 407
Version history: 10 change(s)
Referenced in: [show references]