• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ConstantDouble类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: pushByConstant

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
private void pushByConstant(DismantleBytecode dbc, Constant c) {
	
if (c instanceof ConstantInteger)
	push(new Item("I", new Integer(((ConstantInteger) c).getBytes())));
else if (c instanceof ConstantString) {
	int s = ((ConstantString) c).getStringIndex();
	push(new Item("Ljava/lang/String;", getStringFromIndex(dbc, s)));
}
else if (c instanceof ConstantFloat)
	push(new Item("F", new Float(((ConstantInteger) c).getBytes())));
else if (c instanceof ConstantDouble)
	push(new Item("D", new Double(((ConstantDouble) c).getBytes())));
else if (c instanceof ConstantLong)
	push(new Item("J", new Long(((ConstantLong) c).getBytes())));
else
	throw new UnsupportedOperationException("Constant type not expected" );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:OpcodeStack.java


示例2: pushByConstant

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
private void pushByConstant(DismantleBytecode dbc, Constant c) {

        if (c instanceof ConstantClass)
            push(new Item("Ljava/lang/Class;", ((ConstantClass) c).getConstantValue(dbc.getConstantPool())));
        else if (c instanceof ConstantInteger)
            push(new Item("I", Integer.valueOf(((ConstantInteger) c).getBytes())));
        else if (c instanceof ConstantString) {
            int s = ((ConstantString) c).getStringIndex();
            push(new Item("Ljava/lang/String;", getStringFromIndex(dbc, s)));
        } else if (c instanceof ConstantFloat)
            push(new Item("F", Float.valueOf(((ConstantFloat) c).getBytes())));
        else if (c instanceof ConstantDouble)
            push(new Item("D", Double.valueOf(((ConstantDouble) c).getBytes())));
        else if (c instanceof ConstantLong)
            push(new Item("J", Long.valueOf(((ConstantLong) c).getBytes())));
        else
            throw new UnsupportedOperationException("Constant type not expected");
    }
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:19,代码来源:OpcodeStack.java


示例3: pushByConstant

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
private void pushByConstant(DismantleBytecode dbc, Constant c) {

        if (c instanceof ConstantClass)
            push(new Item("Ljava/lang/Class;", ((ConstantClass) c).getConstantValue(dbc.getConstantPool())));
        else if (c instanceof ConstantInteger)
            push(new Item("I", Integer.valueOf(((ConstantInteger) c).getBytes())));
        else if (c instanceof ConstantString) {
            int s = ((ConstantString) c).getStringIndex();
            push(new Item("Ljava/lang/String;", getStringFromIndex(dbc, s)));
        } else if (c instanceof ConstantFloat)
            push(new Item("F", Float.valueOf(((ConstantFloat) c).getBytes())));
        else if (c instanceof ConstantDouble)
            push(new Item("D", Double.valueOf(((ConstantDouble) c).getBytes())));
        else if (c instanceof ConstantLong)
            push(new Item("J", Long.valueOf(((ConstantLong) c).getBytes())));
        else
            throw new UnsupportedOperationException("StaticConstant type not expected");
    }
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:19,代码来源:OpcodeStack.java


示例4: visitLDC2_W

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
// LDC2_W
public void visitLDC2_W(LDC2_W o){
	indexValid(o, o.getIndex());
	Constant c = cpg.getConstant(o.getIndex());
	if (! ( (c instanceof ConstantLong)	||
					(c instanceof ConstantDouble) ) ){
		constraintViolated(o, "Operand of LDC2_W must be CONSTANT_Long or CONSTANT_Double, but is '"+c+"'.");
	}
	try{
		indexValid(o, o.getIndex()+1);
	}
	catch(StaticCodeInstructionOperandConstraintException e){
		throw new AssertionViolatedException("OOPS: Does not BCEL handle that? LDC2_W operand has a problem.");
	}
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:17,代码来源:Pass3aVerifier.java


示例5: CPESSC_Visitor

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
private CPESSC_Visitor(JavaClass _jc){
	jc = _jc;
	cp = _jc.getConstantPool();
	cplen = cp.getLength();

	CONST_Class = org.apache.bcel.classfile.ConstantClass.class;
	/*
          CONST_Fieldref = org.apache.bcel.classfile.ConstantFieldref.class;
	CONST_Methodref = org.apache.bcel.classfile.ConstantMethodref.class;
	CONST_InterfaceMethodref = org.apache.bcel.classfile.ConstantInterfaceMethodref.class;
          */
	CONST_String = org.apache.bcel.classfile.ConstantString.class;
	CONST_Integer = org.apache.bcel.classfile.ConstantInteger.class;
	CONST_Float = org.apache.bcel.classfile.ConstantFloat.class;
	CONST_Long = org.apache.bcel.classfile.ConstantLong.class;
	CONST_Double = org.apache.bcel.classfile.ConstantDouble.class;
	CONST_NameAndType = org.apache.bcel.classfile.ConstantNameAndType.class;
	CONST_Utf8 = org.apache.bcel.classfile.ConstantUtf8.class;

	carrier = new DescendingVisitor(_jc, this);
	carrier.visit();
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:23,代码来源:Pass2Verifier.java


示例6: visitLDC2_W

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 
public void visitLDC2_W(LDC2_W o){
	Constant c = cpg.getConstant(o.getIndex());
	if (c instanceof ConstantLong){
		stack().push(Type.LONG);
	}
	if (c instanceof ConstantDouble){
		stack().push(Type.DOUBLE);
	}
}
 
开发者ID:linchaolong,项目名称:ApkToolPlus,代码行数:11,代码来源:ExecutionVisitor.java


示例7: visitLDC2_W

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
/**
 * Ensures the specific preconditions of the said instruction.
 */
public void visitLDC2_W(LDC2_W o){
	// visitCPInstruction is called first.
	
	Constant c = cpg.getConstant(o.getIndex());
	if 	(!	(	( c instanceof ConstantLong) ||
						( c instanceof ConstantDouble )	)	){
		constraintViolated(o, "Referenced constant should be a CONSTANT_Integer, a CONSTANT_Float or a CONSTANT_String, but is '"+c+"'.");
	}
}
 
开发者ID:linchaolong,项目名称:ApkToolPlus,代码行数:13,代码来源:InstConstraintVisitor.java


示例8: getConstantPool

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
public static Set<Object> getConstantPool(InputStream is, String name) throws ClassFormatException, IOException {
	HashSet<Object> constants = new HashSet<Object>();
	ClassParser parser = new ClassParser(is, name);
	ConstantPool pool = parser.parse().getConstantPool();
	for (Constant constant : pool.getConstantPool()) {
		//Strings used in code are stored using String constant, they are just references to Utf8 constant
		//but we can't use Utf8 constants because they are used to store field/method/class names and signatures too
		if (constant instanceof ConstantString) {
			String string = (String) ((ConstantString) constant).getConstantValue(pool);
			//skip empty string
			if (string.isEmpty()) {
				continue;
			}
			constants.add(string);
		}
		if (constant instanceof ConstantInteger || constant instanceof ConstantLong || constant instanceof ConstantFloat || constant instanceof ConstantDouble) {
			constants.add(((ConstantObject) constant).getConstantValue(pool));
		}
	}
	return constants;
}
 
开发者ID:MCCarbon,项目名称:DecompileTools,代码行数:22,代码来源:ClassFinderHelpers.java


示例9: sawOpcode

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
@Override
public void sawOpcode(int seen) {
    if (state == SEEN_NOTHING) {
        if ((seen == DCONST_0) || (seen == DCONST_1)) {
            constValue = seen - DCONST_0;
            state = SEEN_DCONST;
        } else if ((seen == LDC2_W) || (seen == LDC_W)) {
            state = SEEN_DCONST;
            Constant c = this.getConstantRefOperand();
            if (c instanceof ConstantDouble)
                constValue = ((ConstantDouble) c).getBytes();
            else if (c instanceof ConstantFloat)
                constValue = ((ConstantFloat) c).getBytes();
            else if (c instanceof ConstantLong)
                constValue = ((ConstantLong) c).getBytes();
            else
                state = SEEN_NOTHING;
        }
    } else if (state == SEEN_DCONST) {
        if (seen == INVOKESTATIC) {
            state = SEEN_NOTHING;
            if (getDottedClassConstantOperand().equals("java.lang.Math")) {
                String methodName = getNameConstantOperand();

                if (((constValue == 0.0) && zeroMethods.contains(methodName))
                        || ((constValue == 1.0) && oneMethods.contains(methodName)) || (anyMethods.contains(methodName))) {
                    bugReporter.reportBug(new BugInstance(this, "UM_UNNECESSARY_MATH", LOW_PRIORITY).addClassAndMethod(this)
                            .addSourceLine(this));
                }
            }
        }
        state = SEEN_NOTHING;
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:35,代码来源:UnnecessaryMath.java


示例10: lookupDouble

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
/** 
 * Look for ConstantDouble in ConstantPool.
 *
 * @param n Double number to look for
 * @return index on success, -1 otherwise
 */
public int lookupDouble( double n ) {
    long bits = Double.doubleToLongBits(n);
    for (int i = 1; i < index; i++) {
        if (constants[i] instanceof ConstantDouble) {
            ConstantDouble c = (ConstantDouble) constants[i];
            if (Double.doubleToLongBits(c.getBytes()) == bits) {
                return i;
            }
        }
    }
    return -1;
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:19,代码来源:ConstantPoolGen.java


示例11: addDouble

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
/**
 * Add a new double constant to the ConstantPool, if it is not already in there.
 *
 * @param n Double number to add
 * @return index of entry
 */
public int addDouble( double n ) {
    int ret;
    if ((ret = lookupDouble(n)) != -1) {
        return ret; // Already in CP
    }
    adjustSize();
    ret = index;
    constants[index] = new ConstantDouble(n);
    index += 2; // Wastes one entry according to spec
    return ret;
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:18,代码来源:ConstantPoolGen.java


示例12: addConstant

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
private void addConstant(Element node, int idx) {
    Constant c = cpg.getConstant(idx);
    if (c instanceof ConstantString) {
        node.setAttribute("type", "java.lang.String");
        String valOrig = ((ConstantString) c).getBytes(cpg.getConstantPool());
        String val = "";
        for (int i = 0; i < valOrig.length(); i++) {
            char ch = valOrig.charAt(i);
            val += (ch < ' ' || ch > 'z') ? String.format("\\%03o", new Integer(ch))
                    : ch;
        }
        node.setAttribute("value", val);
        // node.setText(val);
    } else if (c instanceof ConstantClass) {
        ConstantClass cc = (ConstantClass) c;
        String s = (String) cc.getConstantValue(cpg.getConstantPool());
        try {
            s = Utility.signatureToString(s);
        } catch (ClassFormatException ex) {
            s = s.replace("/", ".");
        }
        node.setAttribute("type", s);
    } else if (c instanceof ConstantDouble) {
        node.setAttribute("type", "double");
        node.setAttribute("value",
                java.lang.String.valueOf(((ConstantDouble) c).getBytes()));
    } else if (c instanceof ConstantLong) {
        node.setAttribute("type", "long");
        node.setAttribute("value",
                java.lang.String.valueOf(((ConstantLong) c).getBytes()));
    } else if (c instanceof ConstantFloat) {
        node.setAttribute("type", "float");
        node.setAttribute("value",
                java.lang.String.valueOf(((ConstantFloat) c).getBytes()));
    } else if (c instanceof ConstantInteger) {
        node.setAttribute("type", "int");
        node.setAttribute("value", String.valueOf(((ConstantInteger) c).getBytes()));
    } else {
        node.setAttribute("type", "unknown");
        node.setAttribute("value", c.toString());
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:43,代码来源:ClassToXmlvmProcess.java


示例13: visit

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
public void visit(ConstantDouble obj) {
    visit((Constant) obj);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:BetterVisitor.java


示例14: visitConstantDouble

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
public void visitConstantDouble(ConstantDouble obj) {
    visit(obj);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:BetterVisitor.java


示例15: visit

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
@Override
public void visit(JavaClass obj) {
    compute();
    ConstantPool cp = obj.getConstantPool();
    Constant[] constants = cp.getConstantPool();
    checkConstant: for (int i = 0; i < constants.length; i++) {
        Constant co = constants[i];
        if (co instanceof ConstantDouble || co instanceof ConstantLong)
            i++;
        if (co instanceof ConstantClass) {
            String ref = getClassName(obj, i);
            if ((ref.startsWith("java") || ref.startsWith("org.w3c.dom")) && !defined.contains(ref))
                bugReporter.reportBug(new BugInstance(this, "VR_UNRESOLVABLE_REFERENCE", NORMAL_PRIORITY).addClass(obj)
                        .addString(ref));

        } else if (co instanceof ConstantFieldref) {
            // do nothing until we handle static fields defined in
            // interfaces
        } else if (co instanceof ConstantCP) {
            ConstantCP co2 = (ConstantCP) co;
            String className = getClassName(obj, co2.getClassIndex());

            // System.out.println("checking " + ref);
            if (className.equals(obj.getClassName()) || !defined.contains(className)) {
                // System.out.println("Skipping check of " + ref);
                continue checkConstant;
            }
            ConstantNameAndType nt = (ConstantNameAndType) cp.getConstant(co2.getNameAndTypeIndex());
            String name = ((ConstantUtf8) obj.getConstantPool().getConstant(nt.getNameIndex(), CONSTANT_Utf8)).getBytes();
            String signature = ((ConstantUtf8) obj.getConstantPool().getConstant(nt.getSignatureIndex(), CONSTANT_Utf8))
                    .getBytes();

            try {
                JavaClass target = Repository.lookupClass(className);
                if (!find(target, name, signature))
                    bugReporter.reportBug(new BugInstance(this, "VR_UNRESOLVABLE_REFERENCE", NORMAL_PRIORITY).addClass(obj)
                            .addString(getMemberName(target.getClassName(), name, signature)));

            } catch (ClassNotFoundException e) {
                bugReporter.reportMissingClass(e);
            }
        }

    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:46,代码来源:ResolveAllReferences.java


示例16: visitConstantDouble

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
public void visitConstantDouble(ConstantDouble obj){
	if (obj.getTag() != Constants.CONSTANT_Double){
		throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
	}
	//no indices to check
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:7,代码来源:Pass2Verifier.java


示例17: visitConstantDouble

import org.apache.bcel.classfile.ConstantDouble; //导入依赖的package包/类
public void visitConstantDouble(ConstantDouble obj) {
    tostring = toString(obj);
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:4,代码来源:StringRepresentation.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InlineKeyboardButton类代码示例发布时间:2022-05-22
下一篇:
Java FileToStreamDecoder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap