Examples of SignatureAttribute


Examples of javassist.bytecode.SignatureAttribute

   private static SignatureAttribute.ClassSignature getClassSignature(Class clazz)
   {
      CtClass ctclazz = JavassistUtil.getCtClass(clazz);
      ClassFile cf = ctclazz.getClassFile2();
      SignatureAttribute sig = (SignatureAttribute)cf.getAttribute(SignatureAttribute.tag);
      if (sig != null)
      {
         try
         {
            SignatureAttribute.ClassSignature type = SignatureAttribute.toClassSignature(sig.getSignature());
            return type;
         }
         catch (BadBytecode e)
         {
            throw new RuntimeException(e);
View Full Code Here

Examples of javassist.bytecode.SignatureAttribute

      return getMethodSignature(info);
   }
  
   private static SignatureAttribute.MethodSignature getMethodSignature(MethodInfo info)
   {
      SignatureAttribute sig = (SignatureAttribute)info.getAttribute(SignatureAttribute.tag);
      if (sig != null)
      {
         try
         {
            SignatureAttribute.MethodSignature type = SignatureAttribute.toMethodSignature(sig.getSignature());
            return type;
         }
         catch (BadBytecode e)
         {
            throw new RuntimeException(e);
View Full Code Here

Examples of javassist.bytecode.SignatureAttribute

      }
   }

   private void copySignature(MethodInfo src, MethodInfo dest)
   {
      SignatureAttribute attribute = (SignatureAttribute) src.getAttribute(SignatureAttribute.tag);
      if (attribute != null)
      {
         dest.addAttribute(attribute.copy(dest.getConstPool(), new HashMap()));
      }
   }
View Full Code Here

Examples of javassist.bytecode.SignatureAttribute

   private void copySignature(CtMethod src, CtMethod dest)
   {
      javassist.bytecode.MethodInfo srcInfo = src.getMethodInfo2();
      javassist.bytecode.MethodInfo destInfo = dest.getMethodInfo2();
     
      SignatureAttribute sig = (SignatureAttribute)srcInfo.getAttribute(SignatureAttribute.tag);
      if (sig != null)
      {
         destInfo.addAttribute(sig.copy(destInfo.getConstPool(), new HashMap()));
      }
   }
View Full Code Here

Examples of javassist.bytecode.SignatureAttribute

   private void copySignature(CtClass src, CtClass dest)
   {
      ClassFile srcFile = src.getClassFile2();
      ClassFile destFile = dest.getClassFile2();
     
      SignatureAttribute sig = (SignatureAttribute)srcFile.getAttribute(SignatureAttribute.tag);
      if (sig != null)
      {
         destFile.addAttribute(sig.copy(destFile.getConstPool(), new HashMap()));
      }
   }
View Full Code Here

Examples of javassist.bytecode.SignatureAttribute

      setTemporaryWrapperCode(type, wmethod);
      clazz.addMethod(wmethod);
     
      // copy attribute signature
      MethodInfo constructorInfo = constructor.getMethodInfo2();
      SignatureAttribute attribute = (SignatureAttribute) constructorInfo.getAttribute(SignatureAttribute.tag);
      if (attribute != null)
      {
         MethodInfo wrapperInfo = wmethod.getMethodInfo2();
         wrapperInfo.addAttribute(attribute.copy(wrapperInfo.getConstPool(), new HashMap()));
      }
     
      // prepare ForWrapping
      getWrapper().prepareForWrapping(constructor, CONSTRUCTOR_STATUS);
   }
View Full Code Here

Examples of javassist.bytecode.SignatureAttribute

      CtMethod wmethod = CtNewMethod.make(CtClass.voidType, wrapperName, writeParam, null, "{}", clazz);
      wmethod.setModifiers(mod);
      clazz.addMethod(wmethod);
     
      SignatureAttribute ai = (SignatureAttribute) field.getFieldInfo2().getAttribute(SignatureAttribute.tag);
      if (ai != null)
      {
         MethodInfo wrapperInfo = wmethod.getMethodInfo2();
         SignatureAttribute methodAtt = new SignatureAttribute(wrapperInfo.getConstPool(), "(" + ai.getSignature() + ")V");
         wrapperInfo.addAttribute(methodAtt);
      }
     
      return wmethod;
   }
View Full Code Here

Examples of javassist.bytecode.SignatureAttribute

    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);
View Full Code Here

Examples of javassist.bytecode.SignatureAttribute

        // this will generate the class holding the satic field if is does not
        // already exist. This allows
        // the static field to hold its value accross multiple replacements

        String sig = null;
        SignatureAttribute sat = (SignatureAttribute) m.getAttribute(SignatureAttribute.tag);
        if (sat != null) {
            sig = sat.getSignature();
        }

        String proxyName = StaticFieldClassFactory.getStaticFieldClass(oldClass, m.getName(), m.getDescriptor(), sig);
        try {
            Field fieldFromProxy = loader.loadClass(proxyName).getDeclaredField(m.getName());
View Full Code Here

Examples of net.sf.rej.java.attribute.SignatureAttribute

                ClassFile cf = cdr.getClassFile();
                ClassSignature classSig = null;
               
            boolean displayGenerics = SystemFacade.getInstance().getPreferences().isSettingTrue(Settings.DISPLAY_GENERICS);
                if (displayGenerics) {
                  SignatureAttribute signature = cf.getAttributes().getSignatureAttribute();
                  if (signature != null) {
                    classSig = Signatures.getClassSignature(signature.getSignatureString());
                  }
                }
               
                String access = cf.getAccessString();
                if (access.length() > 0) {
                    sd.drawKeyword(access + " ");
                }

                if (AccessFlags.isEnum(cf.getAccessFlags())) {
                  sd.drawKeyword("enum ");
                } else if (AccessFlags.isAnnotation(cf.getAccessFlags())) {
                  sd.drawKeyword("@interface ");
                } else if (AccessFlags.isInterface(cf.getAccessFlags())) {
                      sd.drawKeyword("interface ");
                } else {
                  sd.drawKeyword("class ");
                }

                sd.drawDefault(cf.getShortClassName());
                String superClass = cf.getSuperClassName();
               
                 if (classSig != null) {
                     renderFormalTypeParameters(sd, ia, classSig.getFormalTypeParameters());
                }
                
                 sd.drawDefault(" ");
               
                if (superClass != null) {
                  boolean displayExtendsObject = SystemFacade.getInstance().getPreferences().isSettingTrue(Settings.DISPLAY_EXTENDS_OBJECT);
                  if (!superClass.equals("java.lang.Object") ||
                    displayExtendsObject) {
                    sd.drawKeyword("extends ");
                    if (classSig == null) {
                      sd.drawDefault(ia.getShortName(superClass));
                    } else {
                      renderGenericJavaType(sd, ia, classSig.getSuperClassSignature());
                    }
                    sd.drawDefault(" ");
                  }
                }

                List interfaces = cf.getInterfaces();
                if (interfaces.size() > 0) {
                    if (AccessFlags.isInterface(cf.getAccessFlags())) {
                      sd.drawKeyword("extends ");
                    } else {
                      sd.drawKeyword("implements ");
                    }
                    if (classSig == null) {
                      for (int i = 0; i < interfaces.size(); i++) {
                        Interface interface0 = (Interface) interfaces.get(i);
                        if (i > 0) {
                          sd.drawDefault(", ");
                        }
                        sd.drawDefault(ia.getShortName(interface0.getName()));
                      }
                    } else {
                      boolean first = true;
                      for (GenericJavaType intf : classSig.getSuperInterfaceSignatures()) {
                        if (first) {
                          first = false;
                        } else {
                          sd.drawDefault(", ");
                        }
                      renderGenericJavaType(sd, ia, intf);                       
                      }
                    }

                    sd.drawDefault(" ");
                }

                sd.drawDefault("{");
            }
        } else if (er instanceof FieldDefRow) {
            FieldDefRow fdr = (FieldDefRow)er;
            Field f = fdr.getField();
        FieldSignature fieldSig = null;
            boolean displayGenerics = SystemFacade.getInstance().getPreferences().isSettingTrue(Settings.DISPLAY_GENERICS);
            if (displayGenerics) {
              SignatureAttribute signature = f.getAttributes().getSignatureAttribute();
              if (signature != null) {
                fieldSig = Signatures.getFieldSignature(signature.getSignatureString());
              }
            }

            sd.drawIndent();
            String access = f.getAccessString();
            if (access.length() > 0) {
                sd.drawKeyword(access + " ");
            }
            JavaType ret = f.getDescriptor().getReturn();
            if (fieldSig == null) {
              if (ret.isPrimitive()) {
                sd.drawKeyword(ret.getType());
              } else {
                sd.drawDefault(ia.getShortName(ret.getType()));
              }
              sd.drawDefault(ret.getDimensions());
            } else {
              renderGenericJavaType(sd, ia, fieldSig.getType());
            }
           
          sd.drawDefault(" ");

            sd.drawField(f.getName());
            ConstantPoolInfo constant = f.getConstant();
            if (constant != null) {
              sd.drawDefault(" = ");
              drawConstant(sd, constant);
            }
            sd.drawDefault(";");
        } else if (er instanceof DeprecatedAnnotationDefRow) {
          sd.drawIndent();
          sd.drawAnnotation("@Deprecated");
        } else if (er instanceof ClassAnnotationDefRow || er instanceof MethodAnnotationDefRow || er instanceof FieldAnnotationDefRow) {
          Annotation ann = null;
          if (er instanceof ClassAnnotationDefRow) {
            ann = ((ClassAnnotationDefRow)er).getAnnotation();
          } else if (er instanceof MethodAnnotationDefRow) {
            sd.drawIndent();
            ann = ((MethodAnnotationDefRow)er).getAnnotation();
          } else {
            sd.drawIndent();
            ann = ((FieldAnnotationDefRow)er).getAnnotation();
          }
         
          sd.drawAnnotation("@" + ia.getShortName(ann.getName()));
          if (ann.getElementValueCount() > 0) {
            sd.drawDefault("(");
            Map<String, ElementValue> elementValues = ann.getElementValues();
            boolean first = true;
            for (Entry<String, ElementValue> entry : elementValues.entrySet()) {
              if (!first) {
                sd.drawDefault(", ");
              } else {
                first = false;
              }
              if (entry.getKey().equals("value") && elementValues.size() == 1) {
                // only one element, named "value", don't show the display name, just show the value
              } else {
                sd.drawDefault(entry.getKey() + "=");
              }
              ElementValue ev = entry.getValue();
              drawElementValue(sd, ev, ia);
            }
            sd.drawDefault(")");
          }
        } else if (er instanceof MethodDefRow) {
            MethodDefRow mdr = (MethodDefRow)er;
          sd.drawIndent();
          if (mdr.isClosing()) {
                sd.drawDefault("}");
            } else {
                Method m = mdr.getMethod();

                MethodSignature methodSig = null;
                boolean displayGenerics = SystemFacade.getInstance().getPreferences().isSettingTrue(Settings.DISPLAY_GENERICS);
                if (displayGenerics) {
                  SignatureAttribute signature = m.getAttributes().getSignatureAttribute();
                  if (signature != null) {
                    methodSig = Signatures.getMethodSignature(signature.getSignatureString());
                  }
                }

                String access = m.getAccessString();
                if (access.length() > 0) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.