private Object getFieldConstantPoolValue ( final int tag , final char fieldTypeDescriptorFirstChar , final int cpIdx ) throws ClassfileFormatException , IOException { switch ( tag ) { case 1 : // Modified UTF8 case 7 : // Class -- N.B. Unused? Class references do not seem to actually be stored as constant initalizers case 8 : // String // Forward or backward indirect reference to a modified UTF8 entry return getConstantPoolString ( cpIdx ) ; case 3 : // int, short, char, byte, boolean are all represented by Constant_INTEGER final int intVal = cpReadInt ( cpIdx ) ; switch ( fieldTypeDescriptorFirstChar ) { case ' ' : return intVal ; case ' ' : return ( short ) intVal ; case ' ' : return ( char ) intVal ; case ' ' : return ( byte ) intVal ; case ' ' : return intVal != 0 ; default : // Fall through } throw new ClassfileFormatException ( "Unknown Constant_INTEGER type " + fieldTypeDescriptorFirstChar + ", " + "cannot continue reading class. Please report this at " + "https://github.com/classgraph/classgraph/issues" ) ; case 4 : // float return Float . intBitsToFloat ( cpReadInt ( cpIdx ) ) ; case 5 : // long return cpReadLong ( cpIdx ) ; case 6 : // double return Double . longBitsToDouble ( cpReadLong ( cpIdx ) ) ; default : // ClassGraph doesn't expect other types // (N.B. in particular, enum values are not stored in the constant pool, so don't need to be handled) throw new ClassfileFormatException ( "Unknown constant pool tag " + tag + ", " + "cannot continue reading class. Please report this at " + "https://github.com/classgraph/classgraph/issues" ) ; } }
Get a field constant from the constant pool .