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)

1  
static class JavaXClassLoaderWithParent2 extends JavaXClassLoader {
2  
  ClassLoader virtualParent;
3  
  L<S> classesToSkip; // classes that should be taken from parent
4  
5  
  *(S progID, L<File> files, ClassLoader virtualParent, L<S> classesToSkip) {
6  
    super(progID, files);
7  
    this.virtualParent = virtualParent;
8  
    this.classesToSkip = classesToSkip;
9  
  }
10  
  
11  
  protected Class<?> findClass(S name) throws ClassNotFoundException {
12  
    if (shouldDelegate(name)) {
13  
      Class<?> c = virtualParent.loadClass(name);
14  
      if (c != null) ret c;
15  
    }
16  
    ret super.findClass(name);
17  
  }
18  
    
19  
  bool shouldDelegate(S name) {
20  
    for (S s : classesToSkip)
21  
      if (eq(name, s) || startsWith(name, s + "$"))
22  
        true;
23  
    false;
24  
  }
25  
}

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: 578 / 1345
Version history: 3 change(s)
Referenced in: [show references]