com.jd.blockchain.maven.plugins.contract.analysis.util.ContractClassLoader Maven / Gradle / Ivy
The newest version!
package com.jd.blockchain.maven.plugins.contract.analysis.util;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class ContractClassLoader extends ClassLoader {
private final Map classes = new HashMap<>();
private final Map classesBySeparator = new HashMap<>();
public ContractClassLoader(ClassLoader parent) {
super(parent);
}
@Override
protected Class> findClass(String name) throws ClassNotFoundException {
byte[] content = classes.get(name);
if (content != null) {
return defineClass(name, content, 0, content.length);
}
return super.findClass(name);
}
public void add(String className, byte[] content) {
classes.put(className, content);
String classNameBySep = ContractClassLoaderUtil.classNameToSeparator(className);
classesBySeparator.put(classNameBySep, content);
}
public Set classNames() {
return classes.keySet();
}
public Map classes() {
return classes;
}
/**
* return "." to "/" in className
* @return
*/
public Map classesBySeparator() {
return classesBySeparator;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy