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).

static class JavaXClassLoaderWithParent extends JavaXClassLoader {
  ClassLoader virtualParent;

  *(S progID, L<File> files, ClassLoader virtualParent) {
    super(progID, files);
    this.virtualParent = virtualParent;
  }
  
  protected Class<?> findClass(S name) throws ClassNotFoundException {
    if (virtualParent != null && !eq(name, "main") && !name.startsWith("main$")) {
      try {
        ret virtualParent.loadClass(name);
      } catch ClassNotFoundException e {}
    }
    ret super.findClass(name);
  }
  
  public URL findResource(S name) {
    if (virtualParent != null) {
      URL url = virtualParent.getResource(name);
      if (url != null) ret url;
    }
    ret super.findResource(name);
  }
  
  ClassLoader getVirtualParent() { ret virtualParent; }
}
    

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: 530 / 1302
Version history: 7 change(s)
Referenced in: #1011216 - JavaXClassLoaderWithParent2 - takes certain classes from parent
#1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)