Examples of ConstantValue


Examples of com.sun.org.apache.bcel.internal.classfile.ConstantValue

    for(com.sun.org.apache.bcel.internal.classfile.Field fld: fields) {
      final boolean isStatic = (fld.getModifiers() & Modifier.STATIC) != 0;
      final boolean isFinal = (fld.getModifiers() & Modifier.FINAL) != 0;
      StubResolver fldstub = new SimpleResolver(new TypeName(fld.getType().toString())) ;
      if (isStatic && isFinal) {
        ConstantValue cv = fld.getConstantValue();
        Object o ;
        if (cv != null) {
          Constant c = cv.getConstantPool().getConstant(cv.getConstantValueIndex());
          if (c instanceof ConstantObject) {
            o = ((ConstantObject)c).getConstantValue(cv.getConstantPool()) ;
            try {
              o = StdJavaExpressions.cast( this, fldstub, new ConstObj(o)) ;
            } catch (CompilerException e) {
              o = null ;
            }
View Full Code Here

Examples of net.sf.rej.java.attribute.annotations.ConstantValue

        }
        sd.drawDefault("}");
      } else if (ev instanceof ClassInfoValue) {
        sd.drawDefault(ia.getShortName(ev.getValue()));
      } else if (ev instanceof ConstantValue) {
        ConstantValue cv = (ConstantValue)ev;
        drawConstant(sd, cv.getConstantPoolInfo());
      } else if (ev instanceof EnumValue) {
        EnumValue en = (EnumValue)ev;
        sd.drawDefault(ia.getShortName(en.getTypeName()));
        sd.drawDefault(".");
        sd.drawField(en.getConstName());
View Full Code Here

Examples of org.apache.bcel.classfile.ConstantValue

            Field field = fields[i];
            if (field.getName().equals(name) &&
                field.getAccessFlags() == access) {
                String sig = field.getSignature();
                if (type.equals(Utility.signatureToString(sig, false))) {
                    ConstantValue cval = field.getConstantValue();
                    if (cval != null) {
                        int index = cval.getConstantValueIndex();
                        ConstantPool cp = m_curClass.getConstantPool();
                        Constant cnst = cp.getConstant(index);
                        if (cnst instanceof ConstantString) {
                            Object value = ((ConstantString)cnst).
                                getConstantValue(cp);
View Full Code Here

Examples of org.apache.bcel.classfile.ConstantValue

        if( ! nf.getSignature().equals( of.getSignature() ) ) {
          System.out.println( "Field signature changed for " + oldName + "( old: " + of.getSignature() + ", new: " + nf.getSignature() + ")" );
          retval = false;
        }
        // Constant value (may be 'null')
        ConstantValue oldConst = of.getConstantValue();
        ConstantValue newConst = nf.getConstantValue();
        if( oldConst != newConst ) {
          if( null == oldConst ) {
            System.out.println( "Changed constant field to modifiable field " + oldName );
            retval = false;
          }
          else if( null == newConst ) {
            System.out.println( "Changed modifiable field to constant field " + oldName );
            retval = false;
          }
          else if( ! oldConst.toString().equals( newConst.toString() ) ) {
            System.out.println( "Changed " + oldConst.toString() + " to " + newConst.toString() );
            retval = false;
          }
        }
        // Attributes
        Attribute newAttributes[] = nf.getAttributes();
View Full Code Here

Examples of org.apache.bcel.classfile.ConstantValue

        if( ! nf.getSignature().equals( of.getSignature() ) ) {
          System.out.println( "Field signature changed for " + oldName + "( old: " + of.getSignature() + ", new: " + nf.getSignature() + ")" );
          retval = false;
        }
        // Constant value (may be 'null')
        ConstantValue oldConst = of.getConstantValue();
        ConstantValue newConst = nf.getConstantValue();
        if( oldConst != newConst ) {
          if( null == oldConst ) {
            System.out.println( "Changed constant field to modifiable field " + oldName );
            retval = false;
          }
          else if( null == newConst ) {
            System.out.println( "Changed modifiable field to constant field " + oldName );
            retval = false;
          }
          else if( ! oldConst.toString().equals( newConst.toString() ) ) {
            System.out.println( "Changed " + oldConst.toString() + " to " + newConst.toString() );
            retval = false;
          }
        }
        // Attributes
        Attribute newAttributes[] = nf.getAttributes();
View Full Code Here

Examples of org.apache.bcel.classfile.ConstantValue

        return method.getName().startsWith("test");
    }

    @Override
    public void visit(Field field) {
        ConstantValue value = field.getConstantValue();
        if (value == null) {
            return;
        }
        Constant c = getConstantPool().getConstant(value.getConstantValueIndex());

        if (testingEnabled && c instanceof ConstantLong && ((ConstantLong)c).getBytes() == MICROS_PER_DAY_OVERFLOWED_AS_INT) {
            bugReporter.reportBug( new BugInstance(this, "TESTING", HIGH_PRIORITY).addClass(this).addField(this)
                    .addString("Did you mean MICROS_PER_DAY")
                    .addInt(MICROS_PER_DAY_OVERFLOWED_AS_INT)
View Full Code Here

Examples of org.apache.bcel.classfile.ConstantValue

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

Examples of org.apache.bcel.classfile.ConstantValue

        int name_index = cp.addUtf8(name);
        int signature_index = cp.addUtf8(signature);
        if (value != null) {
            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

Examples of org.apache.bcel.classfile.ConstantValue

    public void visitField( Field field ) {
        _out.println();
        _out.println("    field = new FieldGen(" + printFlags(field.getAccessFlags()) + ", "
                + printType(field.getSignature()) + ", \"" + field.getName() + "\", _cp);");
        ConstantValue cv = field.getConstantValue();
        if (cv != null) {
            String value = cv.toString();
            _out.println("    field.setInitValue(" + value + ")");
        }
        _out.println("    _cg.addField(field.getField());");
    }
View Full Code Here

Examples of org.apache.bcel.classfile.ConstantValue

        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());
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.