in src/main/java/org/apache/bcel/generic/SimpleElementValueGen.java [105:148]
public SimpleElementValueGen(final SimpleElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) {
super(value.getElementValueType(), cpool);
if (!copyPoolEntries) {
// J5ASSERT: Could assert value.stringifyValue() is the same as
// cpool.getConstant(SimpleElementValuevalue.getIndex())
idx = value.getIndex();
} else {
switch (value.getElementValueType()) {
case STRING:
idx = cpool.addUtf8(value.getValueString());
break;
case PRIMITIVE_INT:
idx = cpool.addInteger(value.getValueInt());
break;
case PRIMITIVE_BYTE:
idx = cpool.addInteger(value.getValueByte());
break;
case PRIMITIVE_CHAR:
idx = cpool.addInteger(value.getValueChar());
break;
case PRIMITIVE_LONG:
idx = cpool.addLong(value.getValueLong());
break;
case PRIMITIVE_FLOAT:
idx = cpool.addFloat(value.getValueFloat());
break;
case PRIMITIVE_DOUBLE:
idx = cpool.addDouble(value.getValueDouble());
break;
case PRIMITIVE_BOOLEAN:
if (value.getValueBoolean()) {
idx = cpool.addInteger(1);
} else {
idx = cpool.addInteger(0);
}
break;
case PRIMITIVE_SHORT:
idx = cpool.addInteger(value.getValueShort());
break;
default:
throw new IllegalArgumentException("SimpleElementValueGen class does not know how to copy this type " + super.getElementValueType());
}
}
}