Java Code Examples for org.objectweb.asm.ClassReader#readUTF8()
The following examples show how to use
org.objectweb.asm.ClassReader#readUTF8() .
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: DefaultClassDependenciesAnalyzer.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private Set<String> getClassDependencies(ClassRelevancyFilter filter, ClassReader reader) { Set<String> out = new HashSet<String>(); char[] charBuffer = new char[reader.getMaxStringLength()]; for (int i = 1; i < reader.getItemCount(); i++) { int itemOffset = reader.getItem(i); if (itemOffset > 0 && reader.readByte(itemOffset - 1) == 7) { // A CONSTANT_Class entry, read the class descriptor String classDescriptor = reader.readUTF8(itemOffset, charBuffer); Type type = Type.getObjectType(classDescriptor); while (type.getSort() == Type.ARRAY) { type = type.getElementType(); } if (type.getSort() != Type.OBJECT) { // A primitive type continue; } String name = type.getClassName(); if (filter.isRelevant(name)) { out.add(name); } } } return out; }
Example 2
Source File: ClassDependenciesAnalyzer.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private List<String> getClassDependencies(ClassRelevancyFilter filter, ClassReader reader) { List<String> out = new LinkedList<String>(); char[] charBuffer = new char[reader.getMaxStringLength()]; for (int i = 1; i < reader.getItemCount(); i++) { int itemOffset = reader.getItem(i); if (itemOffset > 0 && reader.readByte(itemOffset - 1) == 7) { // A CONSTANT_Class entry, read the class descriptor String classDescriptor = reader.readUTF8(itemOffset, charBuffer); Type type = Type.getObjectType(classDescriptor); while (type.getSort() == Type.ARRAY) { type = type.getElementType(); } if (type.getSort() != Type.OBJECT) { // A primitive type continue; } String name = type.getClassName(); if (filter.isRelevant(name)) { out.add(name); } } } return out; }
Example 3
Source File: DefaultClassDependenciesAnalyzer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private Set<String> getClassDependencies(ClassRelevancyFilter filter, ClassReader reader) { Set<String> out = new HashSet<String>(); char[] charBuffer = new char[reader.getMaxStringLength()]; for (int i = 1; i < reader.getItemCount(); i++) { int itemOffset = reader.getItem(i); if (itemOffset > 0 && reader.readByte(itemOffset - 1) == 7) { // A CONSTANT_Class entry, read the class descriptor String classDescriptor = reader.readUTF8(itemOffset, charBuffer); Type type = Type.getObjectType(classDescriptor); while (type.getSort() == Type.ARRAY) { type = type.getElementType(); } if (type.getSort() != Type.OBJECT) { // A primitive type continue; } String name = type.getClassName(); if (filter.isRelevant(name)) { out.add(name); } } } return out; }
Example 4
Source File: ClassDependenciesAnalyzer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private List<String> getClassDependencies(ClassRelevancyFilter filter, ClassReader reader) { List<String> out = new LinkedList<String>(); char[] charBuffer = new char[reader.getMaxStringLength()]; for (int i = 1; i < reader.getItemCount(); i++) { int itemOffset = reader.getItem(i); if (itemOffset > 0 && reader.readByte(itemOffset - 1) == 7) { // A CONSTANT_Class entry, read the class descriptor String classDescriptor = reader.readUTF8(itemOffset, charBuffer); Type type = Type.getObjectType(classDescriptor); while (type.getSort() == Type.ARRAY) { type = type.getElementType(); } if (type.getSort() != Type.OBJECT) { // A primitive type continue; } String name = type.getClassName(); if (filter.isRelevant(name)) { out.add(name); } } } return out; }
Example 5
Source File: ModuleTargetAttribute.java From Concurnas with MIT License | 5 votes |
@Override protected Attribute read( final ClassReader classReader, final int offset, final int length, final char[] charBuffer, final int codeOffset, final Label[] labels) { return new ModuleTargetAttribute(classReader.readUTF8(offset, charBuffer)); }
Example 6
Source File: ModuleHashesAttribute.java From Concurnas with MIT License | 5 votes |
@Override protected Attribute read( final ClassReader classReader, final int offset, final int length, final char[] charBuffer, final int codeAttributeOffset, final Label[] labels) { int currentOffset = offset; String hashAlgorithm = classReader.readUTF8(currentOffset, charBuffer); currentOffset += 2; int numModules = classReader.readUnsignedShort(currentOffset); currentOffset += 2; ArrayList<String> moduleList = new ArrayList<>(numModules); ArrayList<byte[]> hashList = new ArrayList<>(numModules); for (int i = 0; i < numModules; ++i) { String module = classReader.readModule(currentOffset, charBuffer); currentOffset += 2; moduleList.add(module); int hashLength = classReader.readUnsignedShort(currentOffset); currentOffset += 2; byte[] hash = new byte[hashLength]; for (int j = 0; j < hashLength; ++j) { hash[j] = (byte) (classReader.readByte(currentOffset) & 0xFF); currentOffset += 1; } hashList.add(hash); } return new ModuleHashesAttribute(hashAlgorithm, moduleList, hashList); }
Example 7
Source File: ModuleTargetAttribute.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
@Override protected Attribute read( final ClassReader classReader, final int offset, final int length, final char[] charBuffer, final int codeOffset, final Label[] labels) { return new ModuleTargetAttribute(classReader.readUTF8(offset, charBuffer)); }
Example 8
Source File: ModuleHashesAttribute.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
@Override protected Attribute read( final ClassReader classReader, final int offset, final int length, final char[] charBuffer, final int codeAttributeOffset, final Label[] labels) { int currentOffset = offset; String hashAlgorithm = classReader.readUTF8(currentOffset, charBuffer); currentOffset += 2; int numModules = classReader.readUnsignedShort(currentOffset); currentOffset += 2; ArrayList<String> moduleList = new ArrayList<String>(numModules); ArrayList<byte[]> hashList = new ArrayList<byte[]>(numModules); for (int i = 0; i < numModules; ++i) { String module = classReader.readModule(currentOffset, charBuffer); currentOffset += 2; moduleList.add(module); int hashLength = classReader.readUnsignedShort(currentOffset); currentOffset += 2; byte[] hash = new byte[hashLength]; for (int j = 0; j < hashLength; ++j) { hash[j] = (byte) (classReader.readByte(currentOffset) & 0xFF); currentOffset += 1; } hashList.add(hash); } return new ModuleHashesAttribute(hashAlgorithm, moduleList, hashList); }
Example 9
Source File: StaticClassWriter.java From allocation-instrumenter with Apache License 2.0 | 5 votes |
String readConstantPoolString(ClassReader cr, int offset, char[] buf) { int cpIndex = cr.getItem(cr.readUnsignedShort(offset)); if (cpIndex == 0) { return null; // throw new RuntimeException("Bad constant pool index"); } return cr.readUTF8(cpIndex, buf); }
Example 10
Source File: ModuleTargetAttribute.java From JReFrameworker with MIT License | 5 votes |
@Override protected Attribute read( final ClassReader classReader, final int offset, final int length, final char[] charBuffer, final int codeOffset, final Label[] labels) { return new ModuleTargetAttribute(classReader.readUTF8(offset, charBuffer)); }
Example 11
Source File: ModuleHashesAttribute.java From JReFrameworker with MIT License | 5 votes |
@Override protected Attribute read( final ClassReader classReader, final int offset, final int length, final char[] charBuffer, final int codeAttributeOffset, final Label[] labels) { int currentOffset = offset; String hashAlgorithm = classReader.readUTF8(currentOffset, charBuffer); currentOffset += 2; int numModules = classReader.readUnsignedShort(currentOffset); currentOffset += 2; ArrayList<String> moduleList = new ArrayList<String>(numModules); ArrayList<byte[]> hashList = new ArrayList<byte[]>(numModules); for (int i = 0; i < numModules; ++i) { String module = classReader.readModule(currentOffset, charBuffer); currentOffset += 2; moduleList.add(module); int hashLength = classReader.readUnsignedShort(currentOffset); currentOffset += 2; byte[] hash = new byte[hashLength]; for (int j = 0; j < hashLength; ++j) { hash[j] = (byte) (classReader.readByte(currentOffset) & 0xFF); currentOffset += 1; } hashList.add(hash); } return new ModuleHashesAttribute(hashAlgorithm, moduleList, hashList); }
Example 12
Source File: ModuleTargetAttribute.java From JReFrameworker with MIT License | 5 votes |
@Override protected Attribute read( final ClassReader classReader, final int offset, final int length, final char[] charBuffer, final int codeOffset, final Label[] labels) { return new ModuleTargetAttribute(classReader.readUTF8(offset, charBuffer)); }
Example 13
Source File: ModuleHashesAttribute.java From JReFrameworker with MIT License | 5 votes |
@Override protected Attribute read( final ClassReader classReader, final int offset, final int length, final char[] charBuffer, final int codeAttributeOffset, final Label[] labels) { int currentOffset = offset; String hashAlgorithm = classReader.readUTF8(currentOffset, charBuffer); currentOffset += 2; int numModules = classReader.readUnsignedShort(currentOffset); currentOffset += 2; ArrayList<String> moduleList = new ArrayList<String>(numModules); ArrayList<byte[]> hashList = new ArrayList<byte[]>(numModules); for (int i = 0; i < numModules; ++i) { String module = classReader.readModule(currentOffset, charBuffer); currentOffset += 2; moduleList.add(module); int hashLength = classReader.readUnsignedShort(currentOffset); currentOffset += 2; byte[] hash = new byte[hashLength]; for (int j = 0; j < hashLength; ++j) { hash[j] = (byte) (classReader.readByte(currentOffset) & 0xFF); currentOffset += 1; } hashList.add(hash); } return new ModuleHashesAttribute(hashAlgorithm, moduleList, hashList); }