Java Code Examples for proguard.classfile.ClassConstants#CONSTANT_Utf8
The following examples show how to use
proguard.classfile.ClassConstants#CONSTANT_Utf8 .
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: ConstantPoolEditor.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
/** * Finds or creates a Utf8Constant constant pool entry for the given string. * @return the constant pool index of the Utf8Constant. */ public int addUtf8Constant(String string) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_Utf8) { Utf8Constant utf8Constant = (Utf8Constant)constant; if (utf8Constant.getString().equals(string)) { return index; } } } return addConstant(new Utf8Constant(string)); }
Example 2
Source File: LibraryClassReader.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
private Constant createConstant() { int u1tag = dataInput.readUnsignedByte(); switch (u1tag) { case ClassConstants.CONSTANT_Utf8: return new Utf8Constant(); case ClassConstants.CONSTANT_Integer: return new IntegerConstant(); case ClassConstants.CONSTANT_Float: return new FloatConstant(); case ClassConstants.CONSTANT_Long: return new LongConstant(); case ClassConstants.CONSTANT_Double: return new DoubleConstant(); case ClassConstants.CONSTANT_String: return new StringConstant(); case ClassConstants.CONSTANT_Fieldref: return new FieldrefConstant(); case ClassConstants.CONSTANT_Methodref: return new MethodrefConstant(); case ClassConstants.CONSTANT_InterfaceMethodref: return new InterfaceMethodrefConstant(); case ClassConstants.CONSTANT_Class: return new ClassConstant(); case ClassConstants.CONSTANT_NameAndType: return new NameAndTypeConstant(); default: throw new RuntimeException("Unknown constant type ["+u1tag+"] in constant pool"); } }
Example 3
Source File: ProgramClassReader.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
private Constant createConstant() { int u1tag = dataInput.readUnsignedByte(); switch (u1tag) { case ClassConstants.CONSTANT_Utf8: return new Utf8Constant(); case ClassConstants.CONSTANT_Integer: return new IntegerConstant(); case ClassConstants.CONSTANT_Float: return new FloatConstant(); case ClassConstants.CONSTANT_Long: return new LongConstant(); case ClassConstants.CONSTANT_Double: return new DoubleConstant(); case ClassConstants.CONSTANT_String: return new StringConstant(); case ClassConstants.CONSTANT_Fieldref: return new FieldrefConstant(); case ClassConstants.CONSTANT_Methodref: return new MethodrefConstant(); case ClassConstants.CONSTANT_InterfaceMethodref: return new InterfaceMethodrefConstant(); case ClassConstants.CONSTANT_Class: return new ClassConstant(); case ClassConstants.CONSTANT_NameAndType: return new NameAndTypeConstant(); default: throw new RuntimeException("Unknown constant type ["+u1tag+"] in constant pool"); } }
Example 4
Source File: Utf8Shrinker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Removes all UTF-8 entries that are not marked as being used * from the given constant pool. * @return the new number of entries. */ private int shrinkConstantPool(Constant[] constantPool, int length) { // Create a new index map, if necessary. if (constantIndexMap.length < length) { constantIndexMap = new int[length]; } int counter = 1; boolean isUsed = false; // Shift the used constant pool entries together. for (int index = 1; index < length; index++) { constantIndexMap[index] = counter; Constant constant = constantPool[index]; // Don't update the flag if this is the second half of a long entry. if (constant != null) { isUsed = constant.getTag() != ClassConstants.CONSTANT_Utf8 || Utf8UsageMarker.isUsed(constant); } if (isUsed) { constantPool[counter++] = constant; } } // Clear the remaining constant pool elements. for (int index = counter; index < length; index++) { constantPool[index] = null; } return counter; }
Example 5
Source File: Utf8Constant.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public int getTag() { return ClassConstants.CONSTANT_Utf8; }