Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.Type


                if (storeLive) {
                    continue;
                }

                TypeFrame typeFrame = typeDataflow.getAnalysis().getFactAtLocation(location);
                Type typeOfValue = null;
                if (typeFrame.isValid() && typeFrame.getStackDepth() > 0) {
                    typeOfValue = typeFrame.getTopValue();
                }

                boolean storeOfNull = false;
                InstructionHandle prevInsHandle = location.getHandle().getPrev();
                if (prevInsHandle != null) {
                    Instruction prevIns = prevInsHandle.getInstruction();
                    boolean foundDeadClassInitialization = false;
                    String initializationOf = null;
                    if (prevIns instanceof ConstantPushInstruction) {
                        continue; // not an interesting dead store
                    } else if (prevIns instanceof GETSTATIC) {
                        GETSTATIC getStatic = (GETSTATIC) prevIns;
                        ConstantPoolGen cpg = methodGen.getConstantPool();
                        foundDeadClassInitialization = getStatic.getFieldName(cpg).startsWith("class$")
                                && getStatic.getSignature(cpg).equals("Ljava/lang/Class;");
                        for (Iterator<Location> j = cfg.locationIterator(); j.hasNext();) {
                            Location location2 = j.next();
                            if (location2.getHandle().getPosition() + 15 == location.getHandle().getPosition()) {
                                Instruction instruction2 = location2.getHandle().getInstruction();
                                if (instruction2 instanceof LDC) {
                                    Object value = ((LDC) instruction2).getValue(methodGen.getConstantPool());
                                    if (value instanceof String) {
                                        String n = (String) value;
                                        if (n.length() > 0) {
                                            initializationOf = ClassName.toSignature(n);
                                        }
                                    }
                                }
                            }
                        }

                    } else if (prevIns instanceof LDC) {
                        LDC ldc = (LDC) prevIns;
                        Type t = ldc.getType(methodGen.getConstantPool());
                        if (t.getSignature().equals("Ljava/lang/Class;")) {
                            Object value = ldc.getValue(methodGen.getConstantPool());
                            if (value instanceof ConstantClass) {
                                ConstantClass v = (ConstantClass) value;
                                initializationOf = ClassName.toSignature(v.getBytes(javaClass.getConstantPool()));
                                foundDeadClassInitialization = true;
View Full Code Here


                                    }
                                    String pattern = "RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED";
                                    if (!isIgnored) {
                                        pattern = "UNKNOWN";
                                    }
                                    Type type = typeDataflow.getAnalysis().getFactAtLocation(location).getTopValue();
                                    int priority = getPriorityForBeingMutable(type);
                                    BugInstance bugInstance = new BugInstance(this, pattern, priority)
                                    .addClassAndMethod(methodGen, sourceFileName).addCalledMethod(methodGen, invoke)
                                    .add(new TypeAnnotation(type)).add(ba);
                                    SourceLineAnnotation where = SourceLineAnnotation.fromVisitedInstruction(classContext,
View Full Code Here

                            TypeFrame frame = typeDataflow.getFactAtLocation(location);
                            if (!frame.isValid()) {
                                // This basic block is probably dead
                                continue;
                            }
                            Type operandType = frame.getTopValue();
                            if (operandType.equals(TopType.instance())) {
                                // unreachable
                                continue;
                            }
                            String sig3 = operandType.getSignature();
                            if (!sig3.equals("Ljava/lang/String;")) {
                                stringAppendState.setSawTaint(handle);
                            }
                        } catch (CheckedAnalysisException e) {
                            stringAppendState.setSawTaint(handle);
View Full Code Here

      // A descriptor is often named signature in BCEL
      checkIndex(obj, obj.getSignatureIndex(), CONST_Utf8);

      String sig  = ((ConstantUtf8) (cp.getConstant(obj.getSignatureIndex()))).getBytes(); // Method's signature(=descriptor)

      Type t;
      Type[] ts; // needed below the try block.
      try{
        t  = Type.getReturnType(sig);
        ts = Type.getArgumentTypes(sig);
      }
      catch (ClassFormatException cfe){
                throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by Method '"+tostring(obj)+"'.");
      }

      // Check if referenced objects exist.
      Type act = t;
      if (act instanceof ArrayType) {
                act = ((ArrayType) act).getBasicType();
            }
      if (act instanceof ObjectType){
        Verifier v = VerifierFactory.getVerifier( ((ObjectType) act).getClassName() );
View Full Code Here

      Object pred = carrier.predecessor();
      if (pred instanceof Field){ //ConstantValue attributes are quite senseless if the predecessor is not a field.
        Field f = (Field) pred;
        // Field constraints have been checked before -- so we are safe using their type information.
        Type field_type = Type.getType(((ConstantUtf8) (cp.getConstant(f.getSignatureIndex()))).getBytes());

        int index = obj.getConstantValueIndex();
        if ((index < 0) || (index >= cplen)){
          throw new ClassConstraintException("Invalid index '"+index+"' used by '"+tostring(obj)+"'.");
        }
        Constant c = cp.getConstant(index);

        if (CONST_Long.isInstance(c) && field_type.equals(Type.LONG)){
          return;
        }
        if (CONST_Float.isInstance(c) && field_type.equals(Type.FLOAT)){
          return;
        }
        if (CONST_Double.isInstance(c) && field_type.equals(Type.DOUBLE)){
          return;
        }
        if (CONST_Integer.isInstance(c) && (field_type.equals(Type.INT) || field_type.equals(Type.SHORT) || field_type.equals(Type.CHAR) || field_type.equals(Type.BYTE) || field_type.equals(Type.BOOLEAN))){
          return;
        }
        if (CONST_String.isInstance(c) && field_type.equals(Type.STRING)){
          return;
        }

        throw new ClassConstraintException("Illegal type of ConstantValue '"+obj+"' embedding Constant '"+c+"'. It is referenced by field '"+tostring(f)+"' expecting a different type: '"+field_type+"'.");
      }
View Full Code Here

              throw new ClassConstraintException("LocalVariableTable '"+tostring(lvt)+"' references a local variable by the name '"+localname+"' which is not a legal Java simple name.");
            }

            checkIndex(lvt, localvariables[i].getSignatureIndex(), CONST_Utf8);
            String localsig  = ((ConstantUtf8) (cp.getConstant(localvariables[i].getSignatureIndex()))).getBytes(); // Local signature(=descriptor)
            Type t;
            try{
              t = Type.getType(localsig);
            }
            catch (ClassFormatException cfe){
              throw new ClassConstraintException("Illegal descriptor (==signature) '"+localsig+"' used by LocalVariable '"+tostring(localvariables[i])+"' referenced by '"+tostring(lvt)+"'.");
View Full Code Here

            TypeFrame frame = typeDataflow.getFactAtLocation(location);
            if (!frame.isValid()) {
                // This basic block is probably dead
                continue;
            }
            Type operandType = frame.getTopValue();

            if (operandType.equals(TopType.instance())) {
                // unreachable
                continue;
            }
            if (!(operandType instanceof ReferenceType)) {
                // Shouldn't happen - illegal bytecode
View Full Code Here

            }

            TypeDataflow typeDataflow = classContext.getTypeDataflow(method);
            TypeFrame frame = typeDataflow.getFactAtLocation(location);
            if (frame.isValid()) {
                Type type = frame.getInstance(ins, classContext.getConstantPoolGen());
                if (type instanceof ReferenceType) {
                    propertySet.setProperty(GeneralWarningProperty.RECEIVER_OBJECT_TYPE, type.toString());
                }
            }
        } catch (DataflowAnalysisException e) {
            // Ignore
        } catch (CFGBuilderException e) {
View Full Code Here

            try {
                if (!c.isArray() && (subtypes2.isSubtype(c, thisClassDescriptor) || subtypes2.isSubtype(thisClassDescriptor, c))) {
                    return;
                }

                Type thisType = Type.getType(thisClassDescriptor.getSignature());
                Type cType = Type.getType(c.getSignature());
                IncompatibleTypes check = IncompatibleTypes.getPriorityForAssumingCompatible(thisType, cType, false);
                int priority = check.getPriority();
                if ("java/lang/Object".equals(getSuperclassName()) && ClassName.isAnonymous(getClassName())) {
                    priority++;
                }
View Full Code Here

    LocalVariableGen[] l = new LocalVariableGen[size];

    for(int i=0; i < size; i++) {
      String           ident = idents[i].getName();
      Variable         entry = (Variable)env.get(ident);
      Type             t     = BasicType.getType((byte)idents[i].getType());
      LocalVariableGen lg    = method.addLocalVariable(ident, t, null, null);
      int              slot  = lg.getIndex();

      entry.setLocalVariable(lg);
      InstructionHandle start = il.getEnd();
View Full Code Here

TOP

Related Classes of org.apache.bcel.generic.Type

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.