use of org.apache.tapestry5.internal.plastic.asm.ClassWriter in project tapestry-5 by apache.
the class ClassCreationHelper method createWriter.
public ClassWriter createWriter(String className, String superClassName, String... interfaceNames) {
String[] interfaceInternalNames = new String[interfaceNames.length];
for (int i = 0; i < interfaceNames.length; i++) {
interfaceInternalNames[i] = PlasticInternalUtils.toInternalName(interfaceNames[i]);
}
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES + ClassWriter.COMPUTE_MAXS);
cw.visit(V1_5, ACC_PUBLIC, PlasticInternalUtils.toInternalName(className), null, PlasticInternalUtils.toInternalName(superClassName), interfaceInternalNames);
return cw;
}
use of org.apache.tapestry5.internal.plastic.asm.ClassWriter in project tapestry-5 by apache.
the class ModuleHashesAttribute method write.
@Override
protected ByteVector write(final ClassWriter classWriter, final byte[] code, final int codeLength, final int maxStack, final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(classWriter.newUTF8(algorithm));
if (modules == null) {
byteVector.putShort(0);
} else {
int numModules = modules.size();
byteVector.putShort(numModules);
for (int i = 0; i < numModules; ++i) {
String module = modules.get(i);
byte[] hash = hashes.get(i);
byteVector.putShort(classWriter.newModule(module)).putShort(hash.length).putByteArray(hash, 0, hash.length);
}
}
return byteVector;
}
use of org.apache.tapestry5.internal.plastic.asm.ClassWriter in project tapestry-5 by apache.
the class ModuleResolutionAttribute method write.
@Override
protected ByteVector write(final ClassWriter classWriter, final byte[] code, final int codeLength, final int maxStack, final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(resolution);
return byteVector;
}
use of org.apache.tapestry5.internal.plastic.asm.ClassWriter in project tapestry-5 by apache.
the class ModuleTargetAttribute method write.
@Override
protected ByteVector write(final ClassWriter classWriter, final byte[] code, final int codeLength, final int maxStack, final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(platform == null ? 0 : classWriter.newUTF8(platform));
return byteVector;
}
use of org.apache.tapestry5.internal.plastic.asm.ClassWriter in project tapestry-5 by apache.
the class ComponentInstantiatorSourceImplTest method createSynthComponentClass.
private void createSynthComponentClass(String name) throws Exception {
ClassWriter cw = helper.createWriter(SYNTH_COMPONENT_CLASSNAME, BASIC_COMPONENT_CLASSNAME, Named.class.getName());
helper.implementPublicConstructor(cw, BASIC_COMPONENT_CLASSNAME);
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "getName", "()Ljava/lang/String;", null, null);
mv.visitCode();
mv.visitLdcInsn(name);
mv.visitInsn(ARETURN);
mv.visitEnd();
cw.visitEnd();
helper.writeFile(cw, SYNTH_COMPONENT_CLASSNAME);
}
Aggregations