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

17
LINES

< > BotCompany Repo | #1033453 // byteCodePathForClass_forURLClassLoader (return jar or dir)

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

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

static File byteCodePathForClass_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);
      temp InputStream in = inputStreamForFileInDirOrZip(location, name);
      if (in != null) ret location;
    }
    fail(name + " not found in: " + urls);
  }
  
  null;
}

Author comment

Began life as a copy of #1033452

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1033453
Snippet name: byteCodePathForClass_forURLClassLoader (return jar or dir)
Eternal ID of this version: #1033453/1
Text MD5: 987f9858f57f56425e1958472fa18ca5
Transpilation MD5: b466f17e183564b5bac544848f666b05
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:33:55
Source code size: 509 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 138 / 196
Referenced in: [show references]