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

16
LINES

< > BotCompany Repo | #1033452 // inputStreamForClass_forURLClassLoader

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

Libraryless. Click here for Pure Java version (4579L/26K).

static InputStream inputStreamForClass_forURLClassLoader(Class c) ctex {
  if (c == null) null;
  ClassLoader cl = getClassLoader(c);
  
  if (cl cast URLClassLoader) {
    S name = c.getName().replace('.', '/') + ".class";
    var urls = cl.getURLs();
    for (URL url : urls) pcall {
      File location = urlToFile(url);
      try object InputStream in = inputStreamForFileInDirOrZip(location, name);
    }
    fail(name + " not found in: " + urls);
  }
  
  null;
}

Author comment

Began life as a copy of #1012231

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033452
Snippet name: inputStreamForClass_forURLClassLoader
Eternal ID of this version: #1033452/3
Text MD5: 67cb27dcf2e714745c8c9ccbc84ec2ab
Transpilation MD5: dd14250a70c167bc9f2aab0c67435252
Author: stefan
Category: javax / byte code
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-28 18:32:57
Source code size: 484 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 92 / 134
Version history: 2 change(s)
Referenced in: [show references]