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

25
LINES

< > BotCompany Repo | #1011216 // JavaXClassLoaderWithParent2 - takes certain classes from parent

JavaX fragment (include)

static class JavaXClassLoaderWithParent2 extends JavaXClassLoader {
  ClassLoader virtualParent;
  L<S> classesToSkip; // classes that should be taken from parent

  *(S progID, L<File> files, ClassLoader virtualParent, L<S> classesToSkip) {
    super(progID, files);
    this.virtualParent = virtualParent;
    this.classesToSkip = classesToSkip;
  }
  
  protected Class<?> findClass(S name) throws ClassNotFoundException {
    if (shouldDelegate(name)) {
      Class<?> c = virtualParent.loadClass(name);
      if (c != null) ret c;
    }
    ret super.findClass(name);
  }
    
  bool shouldDelegate(S name) {
    for (S s : classesToSkip)
      if (eq(name, s) || startsWith(name, s + "$"))
        true;
    false;
  }
}

Author comment

Began life as a copy of #1010568

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1011216
Snippet name: JavaXClassLoaderWithParent2 - takes certain classes from parent
Eternal ID of this version: #1011216/4
Text MD5: 6a73ee05e600c611540a0a94b54733f1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-28 22:43:03
Source code size: 750 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 576 / 1343
Version history: 3 change(s)
Referenced in: [show references]