Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.ConstantNameAndType


    /** @return name of referenced method/field.
     */
    public String getName( ConstantPoolGen cpg ) {
        ConstantPool cp = cpg.getConstantPool();
        ConstantCP cmr = (ConstantCP) cp.getConstant(index);
        ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
        return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes();
    }
View Full Code Here


  private static Map<String, MethodBinding> methodBindingsByKey= new LinkedHashMap<String, MethodBinding>();

  public static MethodBinding lookup(int index, ConstantPool constantPool)
  {
    ConstantCP methodRef= (ConstantCP) constantPool.getConstant(index);
    ConstantNameAndType nameAndType= (ConstantNameAndType) constantPool.getConstant(methodRef.getNameAndTypeIndex(), Constants.CONSTANT_NameAndType);

    String name= nameAndType.getName(constantPool);
    String signature= nameAndType.getSignature(constantPool);

    return lookup(methodRef.getClass(constantPool), name, signature);
  }
View Full Code Here

    return c;
  }

  private String getFieldName(ConstantFieldref fieldRef)
  {
    ConstantNameAndType nameAndType= (ConstantNameAndType) constantPool.getConstant(fieldRef.getNameAndTypeIndex());
    return nameAndType.getName(constantPool);
  }
View Full Code Here

                  aClasses.put(className, pClassRec);
                  aClassRecords.add(pClassRec);
               }
            }

            ConstantNameAndType cnat = (ConstantNameAndType) iCF
               .getConstantPool().getConstant(
                  ((ConstantMethodref) pEntry).getNameAndTypeIndex());
            pClassRec.addUsedMethod(cnat.getName(iCF.getConstantPool()) + ":"
               + cnat.getSignature(iCF.getConstantPool()));

         }
         else if (pEntry instanceof ConstantInterfaceMethodref)
         {
            ConstantNameAndType cnat = (ConstantNameAndType) iCF
               .getConstantPool().getConstant(
                  ((ConstantInterfaceMethodref) pEntry).getNameAndTypeIndex());
            aInterfaceMethods.add(cnat.getName(iCF.getConstantPool())
               + ":" + cnat.getSignature(iCF.getConstantPool()));
         }
         else if (pEntry instanceof ConstantNameAndType)
         {
             //System.out.println("N&T: " + ((ConstantNameAndType) pEntry).getName(iCF.getConstantPool()) + " sig " + ((ConstantNameAndType) pEntry).getSignature(
               //iCF.getConstantPool()));
View Full Code Here

      {
         throw new TinyVMException("Attempt to use a field from a primitive array " +
                 className + " from class " + iCF.getClassName() + " method " + iFullName);

      }
      ConstantNameAndType cnat = (ConstantNameAndType) iCF.getConstantPool()
         .getConstant(pFieldEntry.getNameAndTypeIndex());
      String pName = cnat.getName(iCF.getConstantPool());
      // First find the actual defining class
      StaticFieldRecord pFieldRecord = pClassRecord.getStaticFieldRecord(pName);
      if (pFieldRecord == null)
      {
          throw new TinyVMException("Failed to locate static field " + pName +
View Full Code Here

      ConstantFieldref pFieldEntry = (ConstantFieldref) pEntry;
      String className = pFieldEntry.getClass(iCF.getConstantPool()).replace(
         '.', '/');
      ClassRecord pClassRecord = getClassRecord(className);
      if (pClassRecord == null) return;
      ConstantNameAndType cnat = (ConstantNameAndType) iCF.getConstantPool()
         .getConstant(pFieldEntry.getNameAndTypeIndex());
      String pName = cnat.getName(iCF.getConstantPool());
      iBinary.markClassUsed(pClassRecord, false);
      StaticFieldRecord pFieldRecord = pClassRecord.getStaticFieldRecord(pName);
      if (pFieldRecord == null)
      {
          throw new TinyVMException("Failed to mark/locate static field " + pName +
View Full Code Here

      {
          throw new TinyVMException("Classfile error: Failed to find class "
            + className);

      }
      ConstantNameAndType cnat = (ConstantNameAndType) iCF.getConstantPool()
         .getConstant(pFieldEntry.getNameAndTypeIndex());
      String pName = cnat.getName(iCF.getConstantPool());
      return pName;

   }
View Full Code Here

            + (pEntry == null? "null" : pEntry.getClass().getName()));
      }
      ConstantCP pMethodEntry = (ConstantCP) pEntry;
      String className = pMethodEntry.getClass(iCF.getConstantPool()).replace(
         '.', '/');
      ConstantNameAndType pNT = (ConstantNameAndType) iCF.getConstantPool()
         .getConstant(pMethodEntry.getNameAndTypeIndex());
      Signature pSig = new Signature(pNT.getName(iCF.getConstantPool()), pNT
         .getSignature(iCF.getConstantPool()));
      if (className.startsWith("["))
      {
          // For arrays we use the methods contained in Object
          className = "java/lang/Object";
View Full Code Here

            + (pEntry == null? "null" : pEntry.getClass().getName()));
      }
      ConstantCP pMethodEntry = (ConstantCP) pEntry;
      String className = pMethodEntry.getClass(iCF.getConstantPool()).replace(
         '.', '/');
      ConstantNameAndType pNT = (ConstantNameAndType) iCF.getConstantPool()
         .getConstant(pMethodEntry.getNameAndTypeIndex());
      Signature pSig = new Signature(pNT.getName(iCF.getConstantPool()), pNT
         .getSignature(iCF.getConstantPool()));
      if (className.startsWith("["))
      {
          // For arrays we use the methods contained in Object
             className = "java/lang/Object";
View Full Code Here

      {
         throw new TinyVMException("Attempt to use a field from a primitive array " +
                 className + " from class " + iCF.getClassName() + " method " + iFullName);

      }
      ConstantNameAndType cnat = (ConstantNameAndType) iCF.getConstantPool()
         .getConstant(pFieldEntry.getNameAndTypeIndex());
      String pName = cnat.getName(iCF.getConstantPool());
      int pOffset = pClassRecord.getInstanceFieldOffset(pName);
      if (pOffset == -1)
      {
         throw new TinyVMException("Error: Didn't find field " + className
            + ":" + pName + " from class " + iCF.getClassName());
      }
      assert pOffset <= TinyVMConstants.MAX_FIELD_OFFSET: "Check: field offset in range";
      TinyVMType fieldType = TinyVMType.tinyVMTypeFromSignature(cnat
         .getSignature(iCF.getConstantPool()));
      // Decide which form of the instruction to use.
      int instruction;
      if ((fieldType.type() == TinyVMType.T_INT_TYPE || fieldType.type() == TinyVMType.T_FLOAT_TYPE ||
              fieldType.type() == TinyVMType.T_REFERENCE_TYPE) && (pOffset & 0x3) == 0)
View Full Code Here

TOP

Related Classes of org.apache.bcel.classfile.ConstantNameAndType

Copyright © 2018 www.massapicom. 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.