Package net.sf.rej.java.constantpool

Examples of net.sf.rej.java.constantpool.ConstantPool


        this.desc = desc;
        this.accessFlags = accessFlags;
    }

    public void execute() {
        ConstantPool cp = this.cf.getPool();

        int nameIndex = cp.indexOfUtf8(this.fieldName);
        if (nameIndex == -1) {
            nameIndex = cp.optionalAddUtf8(this.fieldName);
            this.createdNameIndex = nameIndex;
        }

        int descIndex = cp.indexOfUtf8(this.desc.getRawDesc());
        if (descIndex == -1) {
            descIndex = cp.optionalAddUtf8(this.desc.getRawDesc());
            this.createdDescIndex = descIndex;
        }

        this.field = fieldFactory.createField(this.cf, this.accessFlags, nameIndex, descIndex);
View Full Code Here


        this.oldSuperIndex = this.cf.getSuperClass();
    }

    public void execute() {
        this.cf.setAccessFlags(this.accessFlags.getValue());
        ConstantPool cp = this.cf.getPool();

        int classIndex = cp.indexOfClassRef(this.className);
        if (classIndex == -1) {
            classIndex = cp.optionalAddClassRef(this.className);
            this.createdPoolIndices.add(classIndex);
        }
        this.cf.setThisClass(classIndex);

        int superIndex = 0;
        if (this.superName != null) {
          superIndex = cp.indexOfClassRef(this.superName);
          if (superIndex == -1) {
            superIndex = cp.optionalAddClassRef(this.superName);
            this.createdPoolIndices.add(superIndex);
          }
        }
        this.cf.setSuperClass(superIndex);

        List<Interface> newInterfaceList = new ArrayList<Interface>();
        newInterfaceList.addAll(this.remainingInterfaces);
        for (int i=0; i < this.newInterfaceNames.size(); i++) {
          String interfaceName = this.newInterfaceNames.get(i);
          int index = cp.indexOfClassRef(interfaceName);
          if (index == -1) {
            index = cp.optionalAddClassRef(interfaceName);
            this.createdPoolIndices.add(index);
          }
          newInterfaceList.add(new Interface(index, cp));
        }
        this.cf.setInterfaces(newInterfaceList);
View Full Code Here

        cf.setMinorVersion(parser.getShortAsInt());
        cf.setMajorVersion(parser.getShortAsInt());

        int contantPoolCount = parser.getShortAsInt();

        ConstantPool pool = new ConstantPool();
        pool.init(contantPoolCount);
        cf.setPool(pool);

        for (int i = 1; i < contantPoolCount; i++) {
            ConstantPoolInfo cpi = ConstantPoolInfo.getCPI(parser, pool);
            pool.set(i, cpi);

            // 8byte types take up two indices
            if (cpi.getType() == ConstantPoolInfo.LONG
                    || cpi.getType() == ConstantPoolInfo.DOUBLE)
                i++;
View Full Code Here

     * Returns the full class name, including the package definition part. For
     * example <code>"net.sf.rej.java.ClassFile"</code>.
     * @return the full name of this class.
     */
    public String getFullClassName() {
        ConstantPool cp = this.pool;
        ConstantPoolInfo cpi = cp.get(this.getThisClass());
        return cpi.getValue();
    }
View Full Code Here

            sd.setOffset(0);

            Instruction inst = cr.getInstruction();
            DecompilationContext dc = cr.getDecompilationContext();
            LocalVariableTableAttribute lvs = dc.getLocalVariableTable();
            ConstantPool pool = dc.getConstantPool();
          sd.drawIndent();
          sd.drawIndent();
            sd.drawInstruction(inst.getMnemonic());
            Parameters params = inst.getParameters();
            for (int i = 0; i < params.getCount(); i++) {
                try {
                    switch (params.getType(i)) {
                        case TYPE_LOCAL_VARIABLE:
                        case TYPE_LOCAL_VARIABLE_WIDE:
                        case TYPE_LOCAL_VARIABLE_READONLY:
                            if (lvs == null) {
                                sd.drawDefault(" " + params.getInt(i));
                            } else {
                                LocalVariable lv = lvs.getLocalVariable(params.getInt(i), cr.getPosition());
                                if (lv == null) {
                                    sd.drawDefault(" " + params.getInt(i));
                                } else {
                                    sd.drawDefault(" " + lv.getName());
                                }
                            }
                            break;
                        case TYPE_CONSTANT_POOL_METHOD_REF: {
                          int index = params.getInt(i);
                            ConstantPoolInfo cpi = pool.get(index);
                            renderMethodRef(sd, ia, (RefInfo) cpi, index);
                            break;
                        }
                        case TYPE_CONSTANT_POOL_FIELD_REF: {
                          int index = params.getInt(i);
                            ConstantPoolInfo cpi = pool.get(index);
                            renderFieldRef(sd, ia, (RefInfo) cpi, index);
                            break;
                        }
                        case TYPE_CONSTANT_POOL_CLASS: {
                          int index = params.getInt(i);
                            ConstantPoolInfo cpi = pool.get(index);
                            renderClassRef(sd, ia, (ClassInfo) cpi, index);
                            break;
                        }
                        case TYPE_CONSTANT_POOL_CONSTANT: {
                           int index = params.getInt(i);
                           ConstantPoolInfo cpi = pool.get(index);
                           renderConstant(sd, cpi, index);
                           break;
                        }
                        case TYPE_LABEL: {
                            Label label = (Label) params.getObject(i);
View Full Code Here

        this.accessFlags = accessFlags;
        this.exceptionNames = exceptionNames;
    }

    public void execute() {
        ConstantPool cp = this.cf.getPool();

        int nameIndex = cp.indexOfUtf8(this.methodName);
        if (nameIndex == -1) {
            nameIndex = cp.optionalAddUtf8(this.methodName);
            this.createdPoolItems.add(nameIndex);
        }

        int descIndex = cp.indexOfUtf8(this.desc.getRawDesc());
        if (descIndex == -1) {
            descIndex = cp.optionalAddUtf8(this.desc.getRawDesc());
            this.createdPoolItems.add(descIndex);
        }

        int codeAttrNameIndex = cp.indexOfUtf8("Code");
        if (codeAttrNameIndex == -1) {
            codeAttrNameIndex = cp.optionalAddUtf8("Code");
            this.createdPoolItems.add(codeAttrNameIndex);
        }

        int exAttrNameIndex = cp.indexOfUtf8("Exceptions");
        if (exAttrNameIndex == -1) {
            exAttrNameIndex = cp.optionalAddUtf8("Exceptions");
            this.createdPoolItems.add(exAttrNameIndex);
        }

        List<ExceptionDescriptor> exceptionList = new ArrayList<ExceptionDescriptor>();
        for (int i=0; i < this.exceptionNames.size(); i++) {
          String exceptionName = this.exceptionNames.get(i);
          int exIndex = cp.indexOfClassRef(exceptionName);
          if (exIndex == -1) {
            exIndex = cp.forceAddClassRef(exceptionName);
                this.createdPoolItems.add(exIndex);
          }
          exceptionList.add(new ExceptionDescriptor(cp, exIndex));
        }
View Full Code Here

  public void undo() {
    for (Instruction inst : this.addedInstructions) {
      this.targetCode.remove(inst);
    }
   
    ConstantPool cp = this.cf.getPool();
    while (cp.size() > this.oldPoolSize) {
      cp.removeLast();
    }
  }
View Full Code Here

  }
 
  public void refresh() {
    try {
      if (this.cf != null) {
        ConstantPool cp = this.cf.getPool();
        this.model.setRowCount(cp.size());
        int i = 0;
        for (ConstantPoolInfo cpi : cp) {
          this.model.setValueAt(String.valueOf(i), i, 0);
          Wrapper<ConstantPoolInfo> wrapper = new Wrapper<ConstantPoolInfo>();
          wrapper.setContent(cpi);
View Full Code Here

      try {
        ClassFile cf = this.project.getClassFile(filename);
        ic.setCf(cf);
        agent.processClass(ic, cf);
       
        ConstantPool cp = cf.getPool();
        for (int i=0; i < cp.size(); i++) {
          ConstantPoolInfo cpi = cp.get(i);
          if (cpi != null) {
            agent.processConstantPoolInfo(ic, cpi);           
          }
        }
View Full Code Here

    public Method createMethod(ByteParser parser, ConstantPool pool) {
        return new Method(parser, pool);
    }

    public Method createMethod(ClassFile cf, AccessFlags accessFlags, int nameIndex, int descIndex, int codeAttrNameIndex, int maxStackSize, int maxLocals, int exAttrNameIndex, List<ExceptionDescriptor> exceptions) {
        ConstantPool cp = cf.getPool();
        Method method = new Method(cp);
        method.setAccessFlags(accessFlags);
        method.setNameIndex(nameIndex);
        method.setDescriptorIndex(descIndex);
        Attributes attributes = new Attributes();
View Full Code Here

TOP

Related Classes of net.sf.rej.java.constantpool.ConstantPool

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.