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


Java ConstPool.CONST_Class方法代码示例

本文整理汇总了Java中javassist.bytecode.ConstPool.CONST_Class方法的典型用法代码示例。如果您正苦于以下问题:Java ConstPool.CONST_Class方法的具体用法?Java ConstPool.CONST_Class怎么用?Java ConstPool.CONST_Class使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javassist.bytecode.ConstPool的用法示例。


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

示例1: doLDC

import javassist.bytecode.ConstPool; //导入方法依赖的package包/类
private void doLDC(int index) {
    TypeData[] stackTypes = this.stackTypes;
    int tag = cpool.getTag(index);
    if (tag == ConstPool.CONST_String)
        stackTypes[stackTop++] = new TypeData.ClassName("java.lang.String");
    else if (tag == ConstPool.CONST_Integer)
        stackTypes[stackTop++] = INTEGER;
    else if (tag == ConstPool.CONST_Float)
        stackTypes[stackTop++] = FLOAT;
    else if (tag == ConstPool.CONST_Long) {
        stackTypes[stackTop++] = LONG;
        stackTypes[stackTop++] = TOP;
    }
    else if (tag == ConstPool.CONST_Double) {
        stackTypes[stackTop++] = DOUBLE;
        stackTypes[stackTop++] = TOP;
    }
    else if (tag == ConstPool.CONST_Class)
        stackTypes[stackTop++] = new TypeData.ClassName("java.lang.Class");
    else
        throw new RuntimeException("bad LDC: " + tag);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:23,代码来源:Tracer.java

示例2: evalLDC

import javassist.bytecode.ConstPool; //导入方法依赖的package包/类
private void evalLDC(int index, Frame frame) throws BadBytecode {
    int tag = constPool.getTag(index);
    Type type;
    switch (tag) {
    case ConstPool.CONST_String:
        type = STRING_TYPE;
        break;
    case ConstPool.CONST_Integer:
        type = Type.INTEGER;
        break;
    case ConstPool.CONST_Float:
        type = Type.FLOAT;
        break;
    case ConstPool.CONST_Long:
        type = Type.LONG;
        break;
    case ConstPool.CONST_Double:
        type = Type.DOUBLE;
        break;
    case ConstPool.CONST_Class:
        type = CLASS_TYPE;
        break;
    default:
        throw new BadBytecode("bad LDC [pos = " + lastPos + "]: " + tag);
    }

    simplePush(type, frame);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:29,代码来源:Executor.java

示例3: getClassSignature

import javassist.bytecode.ConstPool; //导入方法依赖的package包/类
@Override
public String getClassSignature(int classIndex) throws InvalidIndexException {
    if (classIndex < 1 || classIndex > this.cp.getSize()) {
        throw new InvalidIndexException(indexOutOfRangeMessage(classIndex));
    }
    if (this.cp.getTag(classIndex) != ConstPool.CONST_Class) {
        throw new InvalidIndexException(entryInvalidMessage(classIndex));
    }
    return internalClassName(this.cp.getClassInfo(classIndex));
}
 
开发者ID:pietrobraione,项目名称:jbse,代码行数:11,代码来源:ClassFileJavassist.java

示例4: getValueFromConstantPool

import javassist.bytecode.ConstPool; //导入方法依赖的package包/类
@Override
public ConstantPoolValue getValueFromConstantPool(int index) throws InvalidIndexException {
    if (index < 1 || index > this.cp.getSize()) {
        throw new InvalidIndexException(indexOutOfRangeMessage(index));
    }
    final int tag = this.cp.getTag(index);
    switch (tag) {
    case ConstPool.CONST_Integer:
        return new ConstantPoolPrimitive(this.cp.getIntegerInfo(index));
    case ConstPool.CONST_Float:
        return new ConstantPoolPrimitive(this.cp.getFloatInfo(index));
    case ConstPool.CONST_Long:
        return new ConstantPoolPrimitive(this.cp.getLongInfo(index));
    case ConstPool.CONST_Double:
        return new ConstantPoolPrimitive(this.cp.getDoubleInfo(index));
    case ConstPool.CONST_String:
        if (this.cpPatches != null && index < this.cpPatches.length && this.cpPatches[index] != null) {
            return this.cpPatches[index];
        }
        return new ConstantPoolString(this.cp.getStringInfo(index));
    case ConstPool.CONST_Class:
        return new ConstantPoolClass(internalClassName(this.cp.getClassInfo(index)));
    case ConstPool.CONST_Utf8:
        return new ConstantPoolUtf8(this.cp.getUtf8Info(index));
    }
    throw new InvalidIndexException(entryInvalidMessage(index));
}
 
开发者ID:pietrobraione,项目名称:jbse,代码行数:28,代码来源:ClassFileJavassist.java

示例5: checkCpPatches

import javassist.bytecode.ConstPool; //导入方法依赖的package包/类
private void checkCpPatches(javassist.bytecode.ConstPool cp, ConstantPoolValue[] cpPatches) 
throws InvalidInputException {
    if (cpPatches == null) {
        return;
    }
    for (int i = 1; i < Math.min(cp.getSize(), cpPatches.length); ++i) {
        if (cpPatches[i] == null) {
            continue;
        }
        final int tag = cp.getTag(i);
        if (tag == ConstPool.CONST_String) {
            continue; //any will fit
        }
        if (tag == ConstPool.CONST_Integer && 
            cpPatches[i] instanceof ConstantPoolPrimitive && 
            ((ConstantPoolPrimitive) cpPatches[i]).getValue() instanceof Integer) {
            continue;
        }
        if (tag == ConstPool.CONST_Long && 
            cpPatches[i] instanceof ConstantPoolPrimitive && 
            ((ConstantPoolPrimitive) cpPatches[i]).getValue() instanceof Long) {
            continue;
        }
        if (tag == ConstPool.CONST_Float && 
            cpPatches[i] instanceof ConstantPoolPrimitive && 
            ((ConstantPoolPrimitive) cpPatches[i]).getValue() instanceof Float) {
            continue;
        }
        if (tag == ConstPool.CONST_Double && 
            cpPatches[i] instanceof ConstantPoolPrimitive && 
            ((ConstantPoolPrimitive) cpPatches[i]).getValue() instanceof Double) {
            continue;
        }
        if (tag == ConstPool.CONST_Utf8 && cpPatches[i] instanceof ConstantPoolString) {
            continue;
        }
        if (tag == ConstPool.CONST_Class && cpPatches[i] instanceof ConstantPoolClass) {
            continue;
        }
        throw new InvalidInputException("ClassFile constructor for anonymous classfile invoked with cpPatches parameter not matching bytecode's constant pool.");
    }
}
 
开发者ID:pietrobraione,项目名称:jbse,代码行数:43,代码来源:ClassFileJavassist.java


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