com.github.andyshao.lang.ClassAssembly Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Gear Show documentation
Show all versions of Gear Show documentation
Enhance and formating the coding of JDK
The newest version!
package com.github.andyshao.lang;
/**
*
* Title:
* Descript:
* Copyright: Copryright(c) Sep 7, 2015
* Encoding:UNIX UTF-8
*
* @author Andy.Shao
*/
@FunctionalInterface
public interface ClassAssembly {
/**Default {@link ClassAssembly}*/
public static final ClassAssembly DEFAULT = new ClassAssembly() {
/**
* assemble
* @param name class name
* @param bs class data
* @return the class
* @param class type
*/
@SuppressWarnings("unchecked")
@Override
public Class assemble(String name , byte[] bs) {
final ClassLoader classLoader = new ClassLoader() {
@Override
protected Class> findClass(String name) throws ClassNotFoundException {
return this.defineClass(name , bs , 0 , bs.length);
}
};
try {
return (Class) classLoader.loadClass(name);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
};
/**
* assemble class
* @param name class name
* @param bs class data
* @return {@link Class}
* @param class type
*/
Class assemble(String name , byte[] bs);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy