* This class is used to weave the bytes of a class into a proxyable class
*/
public final class WovenProxyGenerator
{
public static final byte[] getWovenProxy(byte[] original, String className, ClassLoader loader){
ClassReader cReader = new ClassReader(original);
//Don't weave interfaces, enums or annotations
if((cReader.getAccess() & (ACC_INTERFACE | ACC_ANNOTATION | ACC_ENUM)) != 0)
return null;
//If we are Java 1.6 + compiled then we need to compute stack frames, otherwise
//maxs are fine (and faster)
ClassWriter cWriter = new OSGiFriendlyClassWriter(cReader, AbstractWovenProxyAdapter.IS_AT_LEAST_JAVA_6 ?
ClassWriter.COMPUTE_FRAMES : ClassWriter.COMPUTE_MAXS, loader);
//Wrap our outer layer to add the original SerialVersionUID if it was previously being defaulted
ClassVisitor weavingAdapter = new SyntheticSerialVerUIDAdder(
new WovenProxyAdapter(cWriter, className, loader));
// If we are Java 1.6 + then we need to skip frames as they will be recomputed
cReader.accept(weavingAdapter, AbstractWovenProxyAdapter.IS_AT_LEAST_JAVA_6 ? ClassReader.SKIP_FRAMES : 0);
return cWriter.toByteArray();
}