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

27
LINES

< > BotCompany Repo | #1010568 // JavaXClassLoaderWithParent - takes all library classes from parent

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (6754L/40K).

1  
static class JavaXClassLoaderWithParent extends JavaXClassLoader {
2  
  ClassLoader virtualParent;
3  
4  
  *(S progID, L<File> files, ClassLoader virtualParent) {
5  
    super(progID, files);
6  
    this.virtualParent = virtualParent;
7  
  }
8  
  
9  
  protected Class<?> findClass(S name) throws ClassNotFoundException {
10  
    if (virtualParent != null && !eq(name, "main") && !name.startsWith("main$")) {
11  
      try {
12  
        ret virtualParent.loadClass(name);
13  
      } catch ClassNotFoundException e {}
14  
    }
15  
    ret super.findClass(name);
16  
  }
17  
  
18  
  public URL findResource(S name) {
19  
    if (virtualParent != null) {
20  
      URL url = virtualParent.getResource(name);
21  
      if (url != null) ret url;
22  
    }
23  
    ret super.findResource(name);
24  
  }
25  
  
26  
  ClassLoader getVirtualParent() { ret virtualParent; }
27  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1010568
Snippet name: JavaXClassLoaderWithParent - takes all library classes from parent
Eternal ID of this version: #1010568/8
Text MD5: c14344fc0c29afa3a03ad7f0fe73b644
Transpilation MD5: d530578ebedff88ffbdded4b9a6aa8c9
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-05 18:15:24
Source code size: 809 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 531 / 1303
Version history: 7 change(s)
Referenced in: [show references]