本文整理汇总了Java中com.sun.squawk.vm.CID.STRING属性的典型用法代码示例。如果您正苦于以下问题:Java CID.STRING属性的具体用法?Java CID.STRING怎么用?Java CID.STRING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sun.squawk.vm.CID
的用法示例。
在下文中一共展示了CID.STRING属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFieldConstantValue
/**
* Gets the object corresponding to the ConstantValue attribute for a field
* if it has one.
*
* @param fieldType the type of the field currently being loaded
* @param constantValueIndex the index of the ConstantValue attribute
* @return the value of the ConstantValue attribute or null if there is
* no such attribute
*/
private Object getFieldConstantValue(Klass fieldType, int constantValueIndex) {
if (constantValueIndex != 0) {
/*
* Verify that the initial value is of the right klass for the field
*/
switch (fieldType.getSystemID()) {
case CID.LONG: return pool.getEntry(constantValueIndex, ConstantPool.CONSTANT_Long);
case CID.FLOAT: return pool.getEntry(constantValueIndex, ConstantPool.CONSTANT_Float);
case CID.DOUBLE: return pool.getEntry(constantValueIndex, ConstantPool.CONSTANT_Double);
case CID.INT: // fall through ...
case CID.SHORT: // fall through ...
case CID.CHAR: // fall through ...
case CID.BYTE: // fall through ...
case CID.BOOLEAN: return pool.getEntry(constantValueIndex, ConstantPool.CONSTANT_Integer);
case CID.STRING: return pool.getEntry(constantValueIndex, ConstantPool.CONSTANT_String);
default: throw cfr.formatError("invalid ConstantValue attribute value");
}
} else {
return null;
}
}
示例2: serializeFields
/**
* Serialize the symbolic information for a set of fields into a byte buffer.
*
* @param category the category of the fields (must be INSTANCE_FIELDS or STATIC_FIELDS).
* @param fields the set of fields to serialize
* @param types the collection to which the types in the signatures of the fields should be added
*/
private static void serializeFields(int category, ClassFileField[] fields, SquawkVector types) {
Assert.that(category == INSTANCE_FIELDS || category == STATIC_FIELDS);
if (fields.length != 0) {
symbolsBuffer.addUnsignedByte(category);
for (int i = 0; i != fields.length; ++i) {
ClassFileField field = fields[i];
int modifiers = field.getModifiers();
Klass type = field.getType();
membersBuffer.reset();
membersBuffer.addUnsignedShort(modifiers);
membersBuffer.addUnsignedShort(field.getOffset());
membersBuffer.addUtf8(field.getName());
membersBuffer.addUnsignedShort(KlassMetadata.addSignatureType(types, type));
if (Modifier.hasConstant(modifiers)) {
if (type.getSystemID() == CID.STRING) {
membersBuffer.addUtf8(((ClassFileConstantField)field).stringConstantValue);
} else {
long value = ((ClassFileConstantField)field).primitiveConstantValue;
int dataSize = type.getDataSize();
for (int bite = 0; bite != dataSize; ++bite) {
membersBuffer.addUnencodedByte((byte)value);
value = value >> 8;
}
}
}
symbolsBuffer.add(membersBuffer);
}
}
}
示例3: serializeFields
/**
* Serialize the symbolic information for a set of fields into a byte buffer.
*
* @param category the category of the fields (must be INSTANCE_FIELDS or STATIC_FIELDS).
* @param fields the set of fields to serialize
* @param types the collection to which the types in the signatures of the fields should be added
*/
private static void serializeFields(int category, ClassFileField[] fields, SquawkVector types) {
if (false) Assert.that(category == INSTANCE_FIELDS || category == STATIC_FIELDS);
if (fields.length != 0) {
symbolsBuffer.addUnsignedByte(category);
for (int i = 0; i != fields.length; ++i) {
ClassFileField field = fields[i];
int modifiers = field.getModifiers();
Klass type = field.getType();
membersBuffer.reset();
membersBuffer.addUnsignedShort(modifiers);
membersBuffer.addUnsignedShort(field.getOffset());
membersBuffer.addUtf8(field.getName());
membersBuffer.addUnsignedShort(KlassMetadata.addSignatureType(types, type));
if (Modifier.hasConstant(modifiers)) {
if (type.getSystemID() == CID.STRING) {
membersBuffer.addUtf8(((ClassFileConstantField)field).stringConstantValue);
} else {
long value = ((ClassFileConstantField)field).primitiveConstantValue;
int dataSize = type.getDataSize();
for (int bite = 0; bite != dataSize; ++bite) {
membersBuffer.addUnencodedByte((byte)value);
value = value >> 8;
}
}
}
symbolsBuffer.add(membersBuffer);
}
}
}
示例4: getStringConstantValue
/**
* Gets the String constant value of this static field.
*
* @return the value derived from the ConstantValue classfile attribute
* @throws IllegalArgumentException if this field did not have a ConstantValue
* attribute in its class file or if the constant is not a String
*/
public String getStringConstantValue() throws IllegalArgumentException {
if (!hasConstant() || getType().getSystemID() != CID.STRING) {
throw new IllegalArgumentException();
}
return parser().getStringConstantValue();
}