MCPcopy Create free account
hub / github.com/core-lib/xjar / findClass

Method findClass

src/main/java/io/xjar/boot/XBootClassLoader.java:69–92  ·  view source on GitHub ↗
(String name)

Source from the content-addressed store, hash-verified

67 }
68
69 @Override
70 protected Class<?> findClass(String name) throws ClassNotFoundException {
71 try {
72 return super.findClass(name);
73 } catch (ClassFormatError e) {
74 String path = name.replace('.', '/').concat(".class");
75 URL url = findResource(path);
76 if (url == null) {
77 throw new ClassNotFoundException(name, e);
78 }
79 try (InputStream in = url.openStream()) {
80 ByteArrayOutputStream bos = new ByteArrayOutputStream();
81 XKit.transfer(in, bos);
82 byte[] bytes = bos.toByteArray();
83 Object resource = getResource.invoke(urlClassPath, path);
84 URL codeSourceURL = (URL) getCodeSourceURL.invoke(resource);
85 CodeSigner[] codeSigners = (CodeSigner[]) getCodeSigners.invoke(resource);
86 CodeSource codeSource = new CodeSource(codeSourceURL, codeSigners);
87 return defineClass(name, bytes, 0, bytes.length, codeSource);
88 } catch (Throwable t) {
89 throw new ClassNotFoundException(name, t);
90 }
91 }
92 }
93
94 private class XBootEnumeration implements Enumeration<URL> {
95 private final Enumeration<URL> enumeration;

Callers

nothing calls this directly

Calls 3

findResourceMethod · 0.95
transferMethod · 0.95
invokeMethod · 0.80

Tested by

no test coverage detected