use of javassist.bytecode.SignatureAttribute in project newton by muoncore.
the class EnableNewtonRegistrar method makeRepo.
private Class makeRepo(Class param) {
ClassPool defaultClassPool = ClassPool.getDefault();
defaultClassPool.appendClassPath(new LoaderClassPath(param.getClassLoader()));
defaultClassPool.appendClassPath(new LoaderClassPath(MuonEventSourceRepository.class.getClassLoader()));
defaultClassPool.appendSystemPath();
try {
CtClass superInterface = defaultClassPool.getCtClass(MuonEventSourceRepository.class.getName());
String repoName = param.getName() + "Repository";
try {
return Class.forName(repoName);
} catch (ClassNotFoundException e) {
CtClass repositoryInterface = defaultClassPool.makeClass(repoName, superInterface);
ClassFile classFile = repositoryInterface.getClassFile();
String sig = "Ljava/lang/Object;Lio/muoncore/newton/eventsource/muon/MuonEventSourceRepository<L" + getSigName(param) + ";>;";
SignatureAttribute signatureAttribute = new SignatureAttribute(classFile.getConstPool(), sig);
classFile.addAttribute(signatureAttribute);
return repositoryInterface.toClass();
}
} catch (NotFoundException | CannotCompileException e) {
log.error("Unable to register a newton repository", e);
}
return null;
}
use of javassist.bytecode.SignatureAttribute in project fakereplace by fakereplace.
the class FieldReplacementTransformer method copyFieldAttributes.
private static void copyFieldAttributes(FieldInfo oldField, FieldInfo newField) {
AnnotationsAttribute annotations = (AnnotationsAttribute) oldField.getAttribute(AnnotationsAttribute.visibleTag);
SignatureAttribute sigAt = (SignatureAttribute) oldField.getAttribute(SignatureAttribute.tag);
if (annotations != null) {
AttributeInfo newAnnotations = annotations.copy(newField.getConstPool(), Collections.EMPTY_MAP);
newField.addAttribute(newAnnotations);
}
if (sigAt != null) {
AttributeInfo newAnnotations = sigAt.copy(newField.getConstPool(), Collections.EMPTY_MAP);
newField.addAttribute(newAnnotations);
}
}
use of javassist.bytecode.SignatureAttribute in project fakereplace by fakereplace.
the class MethodReplacementTransformer method copyMethodAttributes.
public static void copyMethodAttributes(MethodInfo oldMethod, MethodInfo newMethod) {
AnnotationsAttribute annotations = (AnnotationsAttribute) oldMethod.getAttribute(AnnotationsAttribute.visibleTag);
ParameterAnnotationsAttribute pannotations = (ParameterAnnotationsAttribute) oldMethod.getAttribute(ParameterAnnotationsAttribute.visibleTag);
ExceptionsAttribute exAt = (ExceptionsAttribute) oldMethod.getAttribute(ExceptionsAttribute.tag);
SignatureAttribute sigAt = (SignatureAttribute) oldMethod.getAttribute(SignatureAttribute.tag);
if (annotations != null) {
AttributeInfo newAnnotations = annotations.copy(newMethod.getConstPool(), Collections.EMPTY_MAP);
newMethod.addAttribute(newAnnotations);
}
if (pannotations != null) {
AttributeInfo newAnnotations = pannotations.copy(newMethod.getConstPool(), Collections.EMPTY_MAP);
newMethod.addAttribute(newAnnotations);
}
if (sigAt != null) {
AttributeInfo newAnnotations = sigAt.copy(newMethod.getConstPool(), Collections.EMPTY_MAP);
newMethod.addAttribute(newAnnotations);
}
if (exAt != null) {
AttributeInfo newAnnotations = exAt.copy(newMethod.getConstPool(), Collections.EMPTY_MAP);
newMethod.addAttribute(newAnnotations);
}
}
Aggregations