Java Code Examples for org.apache.bcel.Constants#CONSTANT_NAMES

The following examples show how to use org.apache.bcel.Constants#CONSTANT_NAMES . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConstantPool.java    From ApkToolPlus with Apache License 2.0 6 votes vote down vote up
/**
 * Get constant from constant pool and check whether it has the
 * expected type.
 *
 * @param  index Index in constant pool
 * @param  tag Tag of expected constant, i.e., its type
 * @return Constant value
 * @see    Constant
 * @throws  ClassFormatException
 */
public Constant getConstant(int index, byte tag)
     throws ClassFormatException
{
  Constant c;

  c = getConstant(index);

  if(c == null)
    throw new ClassFormatException("Constant pool at index " + index + " is null.");

  if(c.getTag() == tag)
    return c;
  else
    throw new ClassFormatException("Expected class `" + Constants.CONSTANT_NAMES[tag] + 
		 "' at index " + index + " and got " + c);
}
 
Example 2
Source File: Constant.java    From ApkToolPlus with Apache License 2.0 4 votes vote down vote up
/**
 * @return String representation.
 */  
public String toString() {
  return Constants.CONSTANT_NAMES[tag] + "[" + tag + "]";
}