Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.Field


        final ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
        final ClassParser parser = new ClassParser(bis, "");
        final JavaClass javaClass = parser.parse();
        final Field[] fields = javaClass.getFields();
        for (int i = 0; i < fields.length; i++) {
            final Field field = fields[i];
            if (field != null) {
                final ConstantValue cv = field.getConstantValue();
                if (cv != null) {
                    String cvs = cv.toString();
                    //Remove start and end quotes if field is a String
                    if (cvs.startsWith("\"") && cvs.endsWith("\"")) {
                        cvs = cvs.substring(1, cvs.length() - 1);
                    }
                    sb.append(field.getName());
                    sb.append('=');
                    sb.append(cvs);
                    sb.append(LS);
                }
            }
View Full Code Here


    il.append(_type.STORE(_local.getIndex()));
      }
  }
  else {
      if (classGen.containsField(name) == null) {
    classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
              cpg.addUtf8(signature),
              null, cpg.getConstantPool()));
    il.append(classGen.loadTranslet());
    il.append(DUP);
    il.append(new PUSH(cpg, name));
View Full Code Here

            Util.getJCRefType(NODE_ITERATOR_SIG),
            il.getEnd(), null);

  // Add a new private field if this is the main class
  if (!classGen.isExternal()) {
      final Field iterator =
    new Field(ACC_PRIVATE,
        cpg.addUtf8(iteratorName),
        cpg.addUtf8(NODE_ITERATOR_SIG),
        null, cpg.getConstantPool());
      classGen.addField(iterator);
      iteratorIndex = cpg.addFieldref(classGen.getClassName(),
View Full Code Here

  else {
      String signature = _type.toSignature();

      // Global variables are store in class fields
      if (classGen.containsField(name) == null) {
    classGen.addField(new Field(ACC_PUBLIC,
              cpg.addUtf8(name),
              cpg.addUtf8(signature),
              null, cpg.getConstantPool()));

    // Push a reference to "this" for putfield
View Full Code Here

    il.append(_type.STORE(_local.getIndex()));
      }
  }
  else {
      if (classGen.containsField(name) == null) {
    classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
              cpg.addUtf8(signature),
              null, cpg.getConstantPool()));
    il.append(classGen.loadTranslet());
    il.append(DUP);
    il.append(new PUSH(cpg, name));
View Full Code Here

            Util.getJCRefType(NODE_ITERATOR_SIG),
            il.getEnd(), null);

  // Add a new private field if this is the main class
  if (!classGen.isExternal()) {
      final Field iterator =
    new Field(ACC_PRIVATE,
        cpg.addUtf8(iteratorName),
        cpg.addUtf8(NODE_ITERATOR_SIG),
        null, cpg.getConstantPool());
      classGen.addField(iterator);
      iteratorIndex = cpg.addFieldref(classGen.getClassName(),
View Full Code Here

  // Add a new instance variable for each var in closure
  for (int i = 0; i < length; i++) {
      VariableBase var = ((VariableRefBase) _closureVars.get(i)).getVariable();

      filterGen.addField(new Field(ACC_PUBLIC,
          cpg.addUtf8(var.getEscapedName()),
          cpg.addUtf8(var.getType().toSignature()),
          null, cpg.getConstantPool()));
  }
View Full Code Here

                throw new IllegalArgumentException("type is not String: " + type);
            }
            try {
                String className = obj.getClassName(getCPG());
                String fieldName = obj.getName(getCPG());
                Field field = Hierarchy.findField(className, fieldName);

                if (field != null) {
                    // If the field is final, we'll assume that the String value
                    // is static.
                    if (field.isFinal() && field.isFinal()) {
                        pushValue(staticStringTypeInstance);
                    } else {
                        pushValue(type);
                    }
View Full Code Here

            checkType(type);
            int index = addConstant();
            addAttribute(new ConstantValue(cp.addUtf8("ConstantValue"), 2, index, cp
                    .getConstantPool()));
        }
        return new Field(access_flags, name_index, signature_index, getAttributes(), cp
                .getConstantPool());
    }
View Full Code Here

                if (DEBUG) {
                    System.out.println("\t" + f);
                }
                if (twice.contains(f) && !getNameConstantOperand().startsWith("class$")
                        && !getSigConstantOperand().equals("Ljava/lang/String;")) {
                    Field declaration = findField(getClassConstantOperand(), getNameConstantOperand());
                    /*
                     * System.out.println(f); System.out.println(declaration);
                     * System.out.println(getSigConstantOperand());
                     */
                    if (declaration == null || !declaration.isVolatile()) {
                        bugReporter.reportBug(new BugInstance(this, "DC_DOUBLECHECK", NORMAL_PRIORITY).addClassAndMethod(this)
                                .addField(f).describe("FIELD_ON").addSourceLineRange(this, startPC, endPC));
                    }
                    stage++;
                }
View Full Code Here

TOP

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

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.