当前位置: 首页>>代码示例>>Java>>正文


Java Constants类代码示例

本文整理汇总了Java中org.apache.bcel.Constants的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Constants类属于org.apache.bcel包,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createStream

import org.apache.bcel.Constants; //导入依赖的package包/类
public Stream createStream(Location location, ObjectType type, ConstantPoolGen cpg,
                           RepositoryLookupFailureCallback lookupFailureCallback) {

	Instruction ins = location.getHandle().getInstruction();
	if (ins.getOpcode() != Constants.GETSTATIC)
		return null;

	GETSTATIC getstatic = (GETSTATIC) ins;
	if (!className.equals(getstatic.getClassName(cpg))
	        || !fieldName.equals(getstatic.getName(cpg))
	        || !fieldSig.equals(getstatic.getSignature(cpg)))
		return null;

	return new Stream(location, type.getClassName(), streamBaseClass)
	        .setIgnoreImplicitExceptions(true)
	        .setIsOpenOnCreation(true);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:StaticFieldLoadStreamFactory.java

示例2: instanceEscapes

import org.apache.bcel.Constants; //导入依赖的package包/类
protected boolean instanceEscapes(InvokeInstruction inv, int instanceArgNum) {
	//ConstantPoolGen cpg = getCPG();
	// String className = inv.getClassName(cpg);

	//System.out.print("[Passed as arg="+instanceArgNum+" at " + inv + "]");

	boolean escapes = (inv.getOpcode() == Constants.INVOKESTATIC || instanceArgNum != 0);
	//if (escapes) System.out.print("[Escape at " + inv + " argNum=" + instanceArgNum + "]");

	if (FindOpenStream.DEBUG && escapes) System.out.println("ESCAPE at " + location);

	// Record the fact that this might be a stream escape
	if (stream.getOpenLocation() != null)
		resourceTracker.addStreamEscape(stream, location);

	return escapes;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:StreamFrameModelingVisitor.java

示例3: consumeStack

import org.apache.bcel.Constants; //导入依赖的package包/类
/**
 * Consume stack.  This is a convenience method for instructions
 * where the types of popped operands can be ignored.
 */
protected void consumeStack(Instruction ins) {
	ConstantPoolGen cpg = getCPG();
	BetterTypeFrame frame = getFrame();

	int numWordsConsumed = ins.consumeStack(cpg);
	if (numWordsConsumed == Constants.UNPREDICTABLE)
		throw new AnalysisException("Unpredictable stack consumption", methodGen, ins);
	try {
		while (numWordsConsumed-- > 0) {
			frame.popValue();
		}
	} catch (DataflowAnalysisException e) {
		throw new AnalysisException("Stack underflow", methodGen, ins, e);
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:BetterTypeFrameModelingVisitor.java

示例4: handleStoreInstruction

import org.apache.bcel.Constants; //导入依赖的package包/类
/**
 * Handler for all instructions which pop values from the stack
 * and store them in a local variable.  Note that two locals
 * are stored into for long and double stores.
 */
public void handleStoreInstruction(StoreInstruction obj) {
	try {
		int numConsumed = obj.consumeStack(cpg);
		if (numConsumed == Constants.UNPREDICTABLE) throw new IllegalStateException();

		int index = obj.getIndex();

		// Store values into consecutive locals corresponding
		// to the order in which the values appeared on the stack.
		while (numConsumed-- > 0) {
			Value value = frame.popValue();
			frame.setValue(index++, value);
		}
	} catch (DataflowAnalysisException e) {
		throw new IllegalStateException(e.toString());
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:AbstractFrameModelingVisitor.java

示例5: scanMethod

import org.apache.bcel.Constants; //导入依赖的package包/类
private void scanMethod(Method method, Set<XField> assignableFieldSet) throws ClassNotFoundException {
	MethodGen methodGen = classContext.getMethodGen(method);
	InstructionList il = methodGen.getInstructionList();
	InstructionHandle handle = il.getStart();

	ConstantPoolGen cpg = methodGen.getConstantPool();

	while (handle != null) {
		Instruction ins = handle.getInstruction();
		short opcode = ins.getOpcode();
		if (opcode == Constants.PUTFIELD) {
			PUTFIELD putfield = (PUTFIELD) ins;

			XField instanceField = Hierarchy.findXField(putfield, cpg);
			if (instanceField != null && assignableFieldSet.contains(instanceField)) {
				Set<XField> assignedFieldSetForMethod = getAssignedFieldSetForMethod(method);
				assignedFieldSetForMethod.add(instanceField);
			}
		}

		handle = handle.getNext();
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:AssignedFieldMap.java

示例6: consumeStack

import org.apache.bcel.Constants; //导入依赖的package包/类
/**
 * Consume stack.  This is a convenience method for instructions
 * where the types of popped operands can be ignored.
 */
protected void consumeStack(Instruction ins) {
	ConstantPoolGen cpg = getCPG();
	TypeFrame frame = getFrame();

	int numWordsConsumed = ins.consumeStack(cpg);
	if (numWordsConsumed == Constants.UNPREDICTABLE)
		throw new IllegalStateException("Unpredictable stack consumption for " + ins);
	try {
		while (numWordsConsumed-- > 0) {
			frame.popValue();
		}
	} catch (DataflowAnalysisException e) {
		throw new IllegalStateException("Stack underflow for " + ins + ": " + e.getMessage());
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:TypeFrameModelingVisitor.java

示例7: findXField

import org.apache.bcel.Constants; //导入依赖的package包/类
/**
 * Look up the field referenced by given FieldInstruction,
 * returning it as an {@link XField XField} object.
 *
 * @param fins the FieldInstruction
 * @param cpg  the ConstantPoolGen used by the class containing the instruction
 * @return an XField object representing the field, or null
 *         if no such field could be found
 */
public static XField findXField(FieldInstruction fins, ConstantPoolGen cpg)
        throws ClassNotFoundException {

	String className = fins.getClassName(cpg);
	String fieldName = fins.getFieldName(cpg);
	String fieldSig = fins.getSignature(cpg);

	XField xfield = findXField(className, fieldName, fieldSig);
	short opcode = fins.getOpcode();
	if (xfield != null &&
	        xfield.isStatic() == (opcode == Constants.GETSTATIC || opcode == Constants.PUTSTATIC))
		return xfield;
	else
		return null;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:Hierarchy.java

示例8: checkConsumedAndProducedValues

import org.apache.bcel.Constants; //导入依赖的package包/类
private void checkConsumedAndProducedValues(Instruction ins, ValueNumber[] consumedValueList,
		ValueNumber[] producedValueList) {
	int numConsumed = ins.consumeStack(getCPG());
	int numProduced = ins.produceStack(getCPG());

	if (numConsumed == Constants.UNPREDICTABLE)
		throw new IllegalStateException("Unpredictable stack consumption for " + ins);
	if (numProduced == Constants.UNPREDICTABLE)
		throw new IllegalStateException("Unpredictable stack production for " + ins);

	if (consumedValueList.length != numConsumed) {
		throw new IllegalStateException("Wrong number of values consumed for " + ins +
			": expected " + numConsumed + ", got " + consumedValueList.length);
	}

	if (producedValueList.length != numProduced) {
		throw new IllegalStateException("Wrong number of values produced for " + ins +
			": expected " + numProduced + ", got " + producedValueList.length);
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:ValueNumberFrameModelingVisitor.java

示例9: isPEI

import org.apache.bcel.Constants; //导入依赖的package包/类
/**
 * Return whether or not the given instruction can throw exceptions.
 *
 * @param handle the instruction
 * @return true if the instruction can throw an exception, false otherwise
 */
private boolean isPEI(InstructionHandle handle) {
	Instruction ins = handle.getInstruction();
	short opcode = ins.getOpcode();

	if (!(ins instanceof ExceptionThrower))
		return false;

	// Return instructions can throw exceptions only if the method is synchronized
	if (ins instanceof ReturnInstruction && !methodGen.isSynchronized())
		return false;

	// We're really not interested in exceptions that could hypothetically be
	// thrown by static field accesses.
	if (NO_STATIC_FIELD_EXCEPTIONS &&
	        (opcode == Constants.GETSTATIC || opcode == Constants.PUTSTATIC))
		return false;

	// Exceptions from LDC instructions seem a bit far fetched as well.
	if (NO_LOAD_CONSTANT_EXCEPTIONS &&
	        (opcode == Constants.LDC || opcode == Constants.LDC_W || opcode == Constants.LDC2_W))
		return false;

	return true;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:BetterCFGBuilder2.java

示例10: transferInstruction

import org.apache.bcel.Constants; //导入依赖的package包/类
public void transferInstruction(InstructionHandle handle, BasicBlock basicBlock, LockSet fact)
        throws DataflowAnalysisException {

	Instruction ins = handle.getInstruction();
	short opcode = ins.getOpcode();
	if (opcode == Constants.MONITORENTER || opcode == Constants.MONITOREXIT) {
		ValueNumberFrame frame = vnaDataflow.getFactAtLocation(new Location(handle, basicBlock));

		// NOTE: if the CFG is pruned, there may be unreachable instructions,
		// so make sure frame is valid.
		if (frame.isValid()) {
			int lockNumber = frame.getTopValue().getNumber();
			lockOp(fact, lockNumber, opcode == Constants.MONITORENTER ? 1 : -1);
		}
	} else if ((ins instanceof ReturnInstruction) && isSynchronized && !isStatic) {
		lockOp(fact, vna.getThisValue().getNumber(), -1);
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:LockAnalysis.java

示例11: setUp

import org.apache.bcel.Constants; //导入依赖的package包/类
protected void setUp() throws InvalidSignatureException {
	byteType = new BasicType(Constants.T_BYTE);
	intType = new BasicType(Constants.T_INT);
	stringType = new ClassType("Ljava/lang/String;");
	byteArray1 = new ArrayType(1, byteType);
	byteArray2 = new ArrayType(2, byteType);
	intArray2 = new ArrayType(2, intType);
	stringArray3 = new ArrayType(3, stringType);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:ArrayTypeTest.java

示例12: handleStoreInstruction

import org.apache.bcel.Constants; //导入依赖的package包/类
@Override
public void handleStoreInstruction(StoreInstruction obj) {
    try {
        int numConsumed = obj.consumeStack(cpg);
        if (numConsumed == Constants.UNPREDICTABLE) {
            throw new InvalidBytecodeException("Unpredictable stack consumption");
        }
        int index = obj.getIndex();
        while (numConsumed-- > 0) {
            Taint value = new Taint(getFrame().popValue());
            value.setVariableIndex(index);
            getFrame().setValue(index++, value);
        }
    } catch (DataflowAnalysisException ex) {
        throw new InvalidBytecodeException(ex.toString(), ex);
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:18,代码来源:TaintFrameModelingVisitor.java

示例13: sawOpcode

import org.apache.bcel.Constants; //导入依赖的package包/类
@Override
public void sawOpcode(int seen) {

    if (seen == Constants.INVOKEVIRTUAL && getClassConstantOperand().equals("javax/servlet/http/Cookie")
            && getNameConstantOperand().equals("setMaxAge")) {

        Object maxAge = stack.getStackItem(0).getConstant();
        Integer n = (maxAge instanceof Integer) ? (Integer)maxAge : 0;

        //Max age equal or greater than one year
        if (n >= 31536000) {
            bugReporter.reportBug(new BugInstance(this, "COOKIE_PERSISTENT", Priorities.NORMAL_PRIORITY) //
                    .addClass(this).addMethod(this).addSourceLine(this));
        }
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:17,代码来源:PersistentCookieDetector.java

示例14: sawOpcode

import org.apache.bcel.Constants; //导入依赖的package包/类
@Override
    public void sawOpcode(int seen) {
        //printOpCode(seen);

//        JspSpringEvalDetector: [0039]  ldc   "${expression}"
//        JspSpringEvalDetector: [0041]  ldc   java/lang/String
//        JspSpringEvalDetector: [0043]  aload_2
//        JspSpringEvalDetector: [0044]  aconst_null
//        JspSpringEvalDetector: [0045]  invokestatic   org/apache/jasper/runtime/PageContextImpl.evaluateExpression (Ljava/lang/String;Ljava/lang/Class;Ljavax/servlet/jsp/PageContext;Lorg/apache/jasper/runtime/ProtectedFunctionMapper;)Ljava/lang/Object;
//        JspSpringEvalDetector: [0048]  checkcast
//        JspSpringEvalDetector: [0051]  invokevirtual   org/springframework/web/servlet/tags/EvalTag.setExpression (Ljava/lang/String;)V

        if (seen == Constants.INVOKEVIRTUAL && getClassConstantOperand().equals("org/springframework/web/servlet/tags/EvalTag")
                && getNameConstantOperand().equals("setExpression") && getSigConstantOperand().equals("(Ljava/lang/String;)V")) {

            if (StackUtils.isVariableString(stack.getStackItem(0))) {
                bugReporter.reportBug(new BugInstance(this, JSP_SPRING_EVAL, Priorities.HIGH_PRIORITY) //
                        .addClass(this).addMethod(this).addSourceLine(this));
            }
        }
    }
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:22,代码来源:JspSpringEvalDetector.java

示例15: sawOpcode

import org.apache.bcel.Constants; //导入依赖的package包/类
@Override
public void sawOpcode(int seen) {
    if (seen == Constants.INVOKESTATIC
            && getClassConstantOperand().equals("javax/crypto/Cipher")
            && getNameConstantOperand().equals("getInstance")) {
        OpcodeStack.Item item = stack.getStackItem(getSigConstantOperand().contains(";L") ? 1 : 0);
        if (StackUtils.isConstantString(item)) {
            String cipherValue = (String) item.getConstant();
            // default padding for "RSA" only is PKCS1 so it is not reported
            if (cipherValue.startsWith("RSA/") && cipherValue.endsWith("/NoPadding")) {
                bugReporter.reportBug(new BugInstance(this, RSA_NO_PADDING_TYPE, Priorities.NORMAL_PRIORITY) //
                        .addClass(this).addMethod(this).addSourceLine(this));
            }
        }
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:17,代码来源:RsaNoPaddingDetector.java


注:本文中的org.apache.bcel.Constants类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。