/* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved. * * This program and the accompanying materials are made available under * the terms of the Common Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/cpl-v10.html * * $Id: ConstantValueAttribute_info.java,v 1.1.1.1 2004/05/09 16:57:47 vlad_r Exp $ */ package com.vladium.jcd.cls.attribute; import java.io.IOException; import com.vladium.jcd.cls.ClassDef; import com.vladium.jcd.cls.constant.CONSTANT_literal_info; import com.vladium.jcd.lib.UDataInputStream; import com.vladium.jcd.lib.UDataOutputStream; // ---------------------------------------------------------------------------- /** * The ConstantValue attribute is a fixed-length attribute used in the attributes * table of the {@link com.vladium.jcd.cls.Field_info} structures. A ConstantValue * attribute represents the value of a constant field that must be (explicitly or * implicitly) static; that is, the ACC_STATIC bit in the flags item of the * Field_info structure must be set. The field is not required to be final. There * can be no more than one ConstantValue attribute in the attributes table of a * given Field_info structure. The constant field represented by the Field_info * structure is assigned the value referenced by its ConstantValue attribute as * part of its initialization.
* * The ConstantValue attribute has the format *
* ConstantValue_attribute { * u2 attribute_name_index; * u4 attribute_length; * u2 constantvalue_index; * } ** * The value of the constantvalue_index item must be a valid index into the constant * pool table. The constant pool entry at that index must give the constant value * represented by this attribute.
* * The constant pool entry must be of a type appropriate to the field, as shown below: * *
Field Type | Entry Type |
---|---|
long | CONSTANT_Long |
float | CONSTANT_Float |
double | CONSTANT_Double |
int, short, char, byte, boolean | CONSTANT_Integer |
java.lang.String | CONSTANT_String |