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

26
LINES

< > BotCompany Repo | #1016892 // heapWalker_pathToGCRootWithFieldNames

JavaX fragment (include)

static L<Pair<Instance, S>> heapWalker_pathToGCRootWithFieldNames(Instance baseInstance) {
  bool debug = false;
  L<Pair<Instance, S>> path = map(func(Instance i) -> Pair<Instance, S> { pair(i, null) }, heapWalker_pathToGCRoot(baseInstance));
  bigLoop: for (int i = 1; i < l(path); i++) {
    long i0 = path.get(i-1).a.getInstanceId();
    Instance i1 = path.get(i).a;
    L<FieldValue> fieldValues;
    if (eq(shortClassName(i1), 'ClassDumpInstance))
      fieldValues = (L<FieldValue>) call(get(i1, 'classDump), 'getStaticFieldValues);
    else
      fieldValues = i1.getFieldValues();
    
    if (debug) {
      print("Fields: " + map(fieldValues, func(FieldValue fv) -> S { fv.getField().getName() }));
      print("Types: " + map className(fieldValues));
      print("Looking for: " + i0);
      print("Instances: " + map(filterByType(ObjectFieldValue.class, fieldValues), func(ObjectFieldValue fv) -> Long { fv.getInstanceId() }));
    }
    for (FieldValue fv : fieldValues)
      if (fv instanceof ObjectFieldValue && ((ObjectFieldValue) fv).getInstanceId() == i0) {
        path.get(i).b = fv.getField().getName();
        continue bigLoop;
      }
  }
  ret path;
}

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: 340 / 407
Version history: 10 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)