proguard.classfile.constant.Utf8Constant Java Examples
The following examples show how to use
proguard.classfile.constant.Utf8Constant.
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: 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 #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: 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 #4
Source File: UsageMarker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { if (shouldBeMarkedAsUsed(utf8Constant)) { markAsUsed(utf8Constant); } }
Example #5
Source File: InterfaceUsageMarker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { if (!usageMarker.isUsed(utf8Constant)) { usageMarker.markAsUsed(utf8Constant); } }
Example #6
Source File: ProgramClass.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public String getString(int constantIndex) { try { return ((Utf8Constant)constantPool[constantIndex]).getString(); } catch (ClassCastException ex) { throw new ClassCastException("Expected Utf8Constant at index ["+constantIndex+"] in class ["+getName()+"], found ["+ex.getMessage()+"]"); } }
Example #7
Source File: ProgramClassReader.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { int u2length = dataInput.readUnsignedShort(); // Read the UTF-8 bytes. byte[] bytes = new byte[u2length]; dataInput.readFully(bytes); utf8Constant.setBytes(bytes); }
Example #8
Source File: StringSharer.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { // Do we have a new string to put into this constant? if (name != null) { // Replace the string, if it's actually the same. if (name.equals(utf8Constant.getString())) { utf8Constant.setString(name); } name = null; } }
Example #9
Source File: InstructionSequenceMatcher.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { Utf8Constant utf8PatternConstant = (Utf8Constant)patternConstant; // Compare the actual strings. matchingConstant = utf8Constant.getString().equals( utf8PatternConstant.getString()); }
Example #10
Source File: LibraryClassReader.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { int u2length = dataInput.readUnsignedShort(); // Read the UTF-8 bytes. byte[] bytes = new byte[u2length]; dataInput.readFully(bytes); utf8Constant.setBytes(bytes); }
Example #11
Source File: ProgramClassWriter.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { byte[] bytes = utf8Constant.getBytes(); dataOutput.writeShort(bytes.length); dataOutput.write(bytes); }
Example #12
Source File: ClassShrinker.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitSignatureAttribute(Clazz clazz, SignatureAttribute signatureAttribute) { Clazz[] referencedClasses = signatureAttribute.referencedClasses; if (referencedClasses != null) { // Go over the generic definitions, superclass and implemented interfaces. String signature = clazz.getString(signatureAttribute.u2signatureIndex); InternalTypeEnumeration internalTypeEnumeration = new InternalTypeEnumeration(signature); StringBuffer newSignatureBuffer = new StringBuffer(); int referencedClassIndex = 0; int newReferencedClassIndex = 0; while (internalTypeEnumeration.hasMoreTypes()) { // Consider the classes referenced by this signature. String type = internalTypeEnumeration.nextType(); int classCount = new DescriptorClassEnumeration(type).classCount(); Clazz referencedClass = referencedClasses[referencedClassIndex]; if (referencedClass == null || usageMarker.isUsed(referencedClass)) { // Append the superclass or interface. newSignatureBuffer.append(type); // Copy the referenced classes. for (int counter = 0; counter < classCount; counter++) { referencedClasses[newReferencedClassIndex++] = referencedClasses[referencedClassIndex++]; } } else { // Skip the referenced classes. referencedClassIndex += classCount; } } if (newReferencedClassIndex < referencedClassIndex) { // Update the signature. ((Utf8Constant)((ProgramClass)clazz).constantPool[signatureAttribute.u2signatureIndex]).setString(newSignatureBuffer.toString()); // Clear the unused entries. while (newReferencedClassIndex < referencedClassIndex) { referencedClasses[newReferencedClassIndex++] = null; } } } }
Example #13
Source File: Utf8UsageMarker.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Marks the given UTF-8 constant pool entry of the given class. */ private void markCpUtf8Entry(Clazz clazz, int index) { markAsUsed((Utf8Constant)((ProgramClass)clazz).getConstant(index)); }
Example #14
Source File: LibraryClassReader.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Returns the string of the Utf8Constant at the specified index in the * reusable constant pool. */ private String getString(int constantIndex) { return ((Utf8Constant)constantPool[constantIndex]).getString(); }
Example #15
Source File: ComparableConstant.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { result = utf8Constant.getString().compareTo(((Utf8Constant)otherConstant).getString()); }
Example #16
Source File: ConstantPoolRemapper.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { // Nothing to do. }
Example #17
Source File: ConstantAdder.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { constantIndex = constantPoolEditor.addUtf8Constant(utf8Constant.getString()); }
Example #18
Source File: SimplifiedVisitor.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { visitAnyConstant(clazz, utf8Constant); }
Example #19
Source File: ClassPrinter.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { println(visitorInfo(utf8Constant) + " Utf8 [" + utf8Constant.getString() + "]"); }
Example #20
Source File: InnerUsageMarker.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { usageMarker.markAsUsed(utf8Constant); }
Example #21
Source File: AbstractClasslVisitor.java From atlas with Apache License 2.0 | 2 votes |
@Override public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) { }
Example #22
Source File: ConstantInstruction.java From java-n-IDE-for-Android with Apache License 2.0 | votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) {}
Example #23
Source File: ConstantVisitor.java From java-n-IDE-for-Android with Apache License 2.0 | votes |
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant);