Java Code Examples for org.jf.dexlib2.util.ReferenceUtil#getShortMethodDescriptor()
The following examples show how to use
org.jf.dexlib2.util.ReferenceUtil#getShortMethodDescriptor() .
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: ClassDefinition.java From ZjDroid with Apache License 2.0 | 5 votes |
private Set<String> writeDirectMethods(IndentingWriter writer) throws IOException { boolean wroteHeader = false; Set<String> writtenMethods = new HashSet<String>(); Iterable<? extends Method> directMethods; if (classDef instanceof DexBackedClassDef) { directMethods = ((DexBackedClassDef)classDef).getDirectMethods(false); } else { directMethods = classDef.getDirectMethods(); } for (Method method: directMethods) { if (!wroteHeader) { writer.write("\n\n"); writer.write("# direct methods"); wroteHeader = true; } writer.write('\n'); // TODO: check for method validation errors String methodString = ReferenceUtil.getShortMethodDescriptor(method); IndentingWriter methodWriter = writer; if (!writtenMethods.add(methodString)) { writer.write("# duplicate method ignored\n"); methodWriter = new CommentingIndentingWriter(writer); } MethodImplementation methodImpl = method.getImplementation(); if (methodImpl == null) { MethodDefinition.writeEmptyMethodTo(methodWriter, method, options); } else { MethodDefinition methodDefinition = new MethodDefinition(this, method, methodImpl); methodDefinition.writeTo(methodWriter); } } return writtenMethods; }
Example 2
Source File: ClassDefinition.java From zjdroid with Apache License 2.0 | 5 votes |
private Set<String> writeDirectMethods(IndentingWriter writer) throws IOException { boolean wroteHeader = false; Set<String> writtenMethods = new HashSet<String>(); Iterable<? extends Method> directMethods; if (classDef instanceof DexBackedClassDef) { directMethods = ((DexBackedClassDef)classDef).getDirectMethods(false); } else { directMethods = classDef.getDirectMethods(); } for (Method method: directMethods) { if (!wroteHeader) { writer.write("\n\n"); writer.write("# direct methods"); wroteHeader = true; } writer.write('\n'); // TODO: check for method validation errors String methodString = ReferenceUtil.getShortMethodDescriptor(method); IndentingWriter methodWriter = writer; if (!writtenMethods.add(methodString)) { writer.write("# duplicate method ignored\n"); methodWriter = new CommentingIndentingWriter(writer); } MethodImplementation methodImpl = method.getImplementation(); if (methodImpl == null) { MethodDefinition.writeEmptyMethodTo(methodWriter, method, options); } else { MethodDefinition methodDefinition = new MethodDefinition(this, method, methodImpl); methodDefinition.writeTo(methodWriter); } } return writtenMethods; }
Example 3
Source File: ClassDefinition.java From HeyGirl with Apache License 2.0 | 5 votes |
private Set<String> writeDirectMethods(IndentingWriter writer) throws IOException { boolean wroteHeader = false; Set<String> writtenMethods = new HashSet<String>(); Iterable<? extends Method> directMethods; if (classDef instanceof DexBackedClassDef) { directMethods = ((DexBackedClassDef)classDef).getDirectMethods(false); } else { directMethods = classDef.getDirectMethods(); } for (Method method: directMethods) { if (!wroteHeader) { writer.write("\n\n"); writer.write("# direct methods"); wroteHeader = true; } writer.write('\n'); // TODO: check for method validation errors String methodString = ReferenceUtil.getShortMethodDescriptor(method); IndentingWriter methodWriter = writer; if (!writtenMethods.add(methodString)) { writer.write("# duplicate method ignored\n"); methodWriter = new CommentingIndentingWriter(writer); } MethodImplementation methodImpl = method.getImplementation(); if (methodImpl == null) { MethodDefinition.writeEmptyMethodTo(methodWriter, method, options); } else { MethodDefinition methodDefinition = new MethodDefinition(this, method, methodImpl); methodDefinition.writeTo(methodWriter); } } return writtenMethods; }
Example 4
Source File: ClassDefinition.java From ZjDroid with Apache License 2.0 | 5 votes |
private Set<String> writeDirectMethods(IndentingWriter writer) throws IOException { boolean wroteHeader = false; Set<String> writtenMethods = new HashSet<String>(); Iterable<? extends Method> directMethods; if (classDef instanceof DexBackedClassDef) { directMethods = ((DexBackedClassDef)classDef).getDirectMethods(false); } else { directMethods = classDef.getDirectMethods(); } for (Method method: directMethods) { if (!wroteHeader) { writer.write("\n\n"); writer.write("# direct methods"); wroteHeader = true; } writer.write('\n'); // TODO: check for method validation errors String methodString = ReferenceUtil.getShortMethodDescriptor(method); IndentingWriter methodWriter = writer; if (!writtenMethods.add(methodString)) { writer.write("# duplicate method ignored\n"); methodWriter = new CommentingIndentingWriter(writer); } MethodImplementation methodImpl = method.getImplementation(); if (methodImpl == null) { MethodDefinition.writeEmptyMethodTo(methodWriter, method, options); } else { MethodDefinition methodDefinition = new MethodDefinition(this, method, methodImpl); methodDefinition.writeTo(methodWriter); } } return writtenMethods; }
Example 5
Source File: ClassPool.java From ZjDroid with Apache License 2.0 | 4 votes |
public void intern(@Nonnull ClassDef classDef) { PoolClassDef poolClassDef = new PoolClassDef(classDef); PoolClassDef prev = internedItems.put(poolClassDef.getType(), poolClassDef); if (prev != null) { throw new ExceptionWithContext("Class %s has already been interned", poolClassDef.getType()); } typePool.intern(poolClassDef.getType()); typePool.internNullable(poolClassDef.getSuperclass()); typeListPool.intern(poolClassDef.getInterfaces()); stringPool.internNullable(poolClassDef.getSourceFile()); HashSet<String> fields = new HashSet<String>(); for (Field field: poolClassDef.getFields()) { String fieldDescriptor = ReferenceUtil.getShortFieldDescriptor(field); if (!fields.add(fieldDescriptor)) { throw new ExceptionWithContext("Multiple definitions for field %s->%s", poolClassDef.getType(), fieldDescriptor); } fieldPool.intern(field); EncodedValue initialValue = field.getInitialValue(); if (initialValue != null) { DexPool.internEncodedValue(initialValue, stringPool, typePool, fieldPool, methodPool); } annotationSetPool.intern(field.getAnnotations()); } HashSet<String> methods = new HashSet<String>(); for (PoolMethod method: poolClassDef.getMethods()) { String methodDescriptor = ReferenceUtil.getShortMethodDescriptor(method); if (!methods.add(methodDescriptor)) { throw new ExceptionWithContext("Multiple definitions for method %s->%s", poolClassDef.getType(), methodDescriptor); } methodPool.intern(method); internCode(method); internDebug(method); annotationSetPool.intern(method.getAnnotations()); for (MethodParameter parameter: method.getParameters()) { annotationSetPool.intern(parameter.getAnnotations()); } } annotationSetPool.intern(poolClassDef.getAnnotations()); }
Example 6
Source File: ClassDefinition.java From ZjDroid with Apache License 2.0 | 4 votes |
private void writeVirtualMethods(IndentingWriter writer, Set<String> directMethods) throws IOException { boolean wroteHeader = false; Set<String> writtenMethods = new HashSet<String>(); Iterable<? extends Method> virtualMethods; if (classDef instanceof DexBackedClassDef) { virtualMethods = ((DexBackedClassDef)classDef).getVirtualMethods(false); } else { virtualMethods = classDef.getVirtualMethods(); } for (Method method: virtualMethods) { if (!wroteHeader) { writer.write("\n\n"); writer.write("# virtual methods"); wroteHeader = true; } writer.write('\n'); // TODO: check for method validation errors String methodString = ReferenceUtil.getShortMethodDescriptor(method); IndentingWriter methodWriter = writer; if (!writtenMethods.add(methodString)) { writer.write("# duplicate method ignored\n"); methodWriter = new CommentingIndentingWriter(writer); } else if (directMethods.contains(methodString)) { writer.write("# There is both a direct and virtual method with this signature.\n" + "# You will need to rename one of these methods, including all references.\n"); System.err.println(String.format("Duplicate direct+virtual method found: %s->%s", classDef.getType(), methodString)); System.err.println("You will need to rename one of these methods, including all references."); } MethodImplementation methodImpl = method.getImplementation(); if (methodImpl == null) { MethodDefinition.writeEmptyMethodTo(methodWriter, method, options); } else { MethodDefinition methodDefinition = new MethodDefinition(this, method, methodImpl); methodDefinition.writeTo(methodWriter); } } }
Example 7
Source File: ClassPool.java From zjdroid with Apache License 2.0 | 4 votes |
public void intern(@Nonnull ClassDef classDef) { PoolClassDef poolClassDef = new PoolClassDef(classDef); PoolClassDef prev = internedItems.put(poolClassDef.getType(), poolClassDef); if (prev != null) { throw new ExceptionWithContext("Class %s has already been interned", poolClassDef.getType()); } typePool.intern(poolClassDef.getType()); typePool.internNullable(poolClassDef.getSuperclass()); typeListPool.intern(poolClassDef.getInterfaces()); stringPool.internNullable(poolClassDef.getSourceFile()); HashSet<String> fields = new HashSet<String>(); for (Field field: poolClassDef.getFields()) { String fieldDescriptor = ReferenceUtil.getShortFieldDescriptor(field); if (!fields.add(fieldDescriptor)) { throw new ExceptionWithContext("Multiple definitions for field %s->%s", poolClassDef.getType(), fieldDescriptor); } fieldPool.intern(field); EncodedValue initialValue = field.getInitialValue(); if (initialValue != null) { DexPool.internEncodedValue(initialValue, stringPool, typePool, fieldPool, methodPool); } annotationSetPool.intern(field.getAnnotations()); } HashSet<String> methods = new HashSet<String>(); for (PoolMethod method: poolClassDef.getMethods()) { String methodDescriptor = ReferenceUtil.getShortMethodDescriptor(method); if (!methods.add(methodDescriptor)) { throw new ExceptionWithContext("Multiple definitions for method %s->%s", poolClassDef.getType(), methodDescriptor); } methodPool.intern(method); internCode(method); internDebug(method); annotationSetPool.intern(method.getAnnotations()); for (MethodParameter parameter: method.getParameters()) { annotationSetPool.intern(parameter.getAnnotations()); } } annotationSetPool.intern(poolClassDef.getAnnotations()); }
Example 8
Source File: ClassDefinition.java From zjdroid with Apache License 2.0 | 4 votes |
private void writeVirtualMethods(IndentingWriter writer, Set<String> directMethods) throws IOException { boolean wroteHeader = false; Set<String> writtenMethods = new HashSet<String>(); Iterable<? extends Method> virtualMethods; if (classDef instanceof DexBackedClassDef) { virtualMethods = ((DexBackedClassDef)classDef).getVirtualMethods(false); } else { virtualMethods = classDef.getVirtualMethods(); } for (Method method: virtualMethods) { if (!wroteHeader) { writer.write("\n\n"); writer.write("# virtual methods"); wroteHeader = true; } writer.write('\n'); // TODO: check for method validation errors String methodString = ReferenceUtil.getShortMethodDescriptor(method); IndentingWriter methodWriter = writer; if (!writtenMethods.add(methodString)) { writer.write("# duplicate method ignored\n"); methodWriter = new CommentingIndentingWriter(writer); } else if (directMethods.contains(methodString)) { writer.write("# There is both a direct and virtual method with this signature.\n" + "# You will need to rename one of these methods, including all references.\n"); System.err.println(String.format("Duplicate direct+virtual method found: %s->%s", classDef.getType(), methodString)); System.err.println("You will need to rename one of these methods, including all references."); } MethodImplementation methodImpl = method.getImplementation(); if (methodImpl == null) { MethodDefinition.writeEmptyMethodTo(methodWriter, method, options); } else { MethodDefinition methodDefinition = new MethodDefinition(this, method, methodImpl); methodDefinition.writeTo(methodWriter); } } }
Example 9
Source File: ClassPool.java From HeyGirl with Apache License 2.0 | 4 votes |
public void intern(@Nonnull ClassDef classDef) { PoolClassDef poolClassDef = new PoolClassDef(classDef); PoolClassDef prev = internedItems.put(poolClassDef.getType(), poolClassDef); if (prev != null) { throw new ExceptionWithContext("Class %s has already been interned", poolClassDef.getType()); } typePool.intern(poolClassDef.getType()); typePool.internNullable(poolClassDef.getSuperclass()); typeListPool.intern(poolClassDef.getInterfaces()); stringPool.internNullable(poolClassDef.getSourceFile()); HashSet<String> fields = new HashSet<String>(); for (Field field: poolClassDef.getFields()) { String fieldDescriptor = ReferenceUtil.getShortFieldDescriptor(field); if (!fields.add(fieldDescriptor)) { throw new ExceptionWithContext("Multiple definitions for field %s->%s", poolClassDef.getType(), fieldDescriptor); } fieldPool.intern(field); EncodedValue initialValue = field.getInitialValue(); if (initialValue != null) { DexPool.internEncodedValue(initialValue, stringPool, typePool, fieldPool, methodPool); } annotationSetPool.intern(field.getAnnotations()); } HashSet<String> methods = new HashSet<String>(); for (PoolMethod method: poolClassDef.getMethods()) { String methodDescriptor = ReferenceUtil.getShortMethodDescriptor(method); if (!methods.add(methodDescriptor)) { throw new ExceptionWithContext("Multiple definitions for method %s->%s", poolClassDef.getType(), methodDescriptor); } methodPool.intern(method); internCode(method); internDebug(method); annotationSetPool.intern(method.getAnnotations()); for (MethodParameter parameter: method.getParameters()) { annotationSetPool.intern(parameter.getAnnotations()); } } annotationSetPool.intern(poolClassDef.getAnnotations()); }
Example 10
Source File: ClassDefinition.java From HeyGirl with Apache License 2.0 | 4 votes |
private void writeVirtualMethods(IndentingWriter writer, Set<String> directMethods) throws IOException { boolean wroteHeader = false; Set<String> writtenMethods = new HashSet<String>(); Iterable<? extends Method> virtualMethods; if (classDef instanceof DexBackedClassDef) { virtualMethods = ((DexBackedClassDef)classDef).getVirtualMethods(false); } else { virtualMethods = classDef.getVirtualMethods(); } for (Method method: virtualMethods) { if (!wroteHeader) { writer.write("\n\n"); writer.write("# virtual methods"); wroteHeader = true; } writer.write('\n'); // TODO: check for method validation errors String methodString = ReferenceUtil.getShortMethodDescriptor(method); IndentingWriter methodWriter = writer; if (!writtenMethods.add(methodString)) { writer.write("# duplicate method ignored\n"); methodWriter = new CommentingIndentingWriter(writer); } else if (directMethods.contains(methodString)) { writer.write("# There is both a direct and virtual method with this signature.\n" + "# You will need to rename one of these methods, including all references.\n"); System.err.println(String.format("Duplicate direct+virtual method found: %s->%s", classDef.getType(), methodString)); System.err.println("You will need to rename one of these methods, including all references."); } MethodImplementation methodImpl = method.getImplementation(); if (methodImpl == null) { MethodDefinition.writeEmptyMethodTo(methodWriter, method, options); } else { MethodDefinition methodDefinition = new MethodDefinition(this, method, methodImpl); methodDefinition.writeTo(methodWriter); } } }
Example 11
Source File: ClassPool.java From ZjDroid with Apache License 2.0 | 4 votes |
public void intern(@Nonnull ClassDef classDef) { PoolClassDef poolClassDef = new PoolClassDef(classDef); PoolClassDef prev = internedItems.put(poolClassDef.getType(), poolClassDef); if (prev != null) { throw new ExceptionWithContext("Class %s has already been interned", poolClassDef.getType()); } typePool.intern(poolClassDef.getType()); typePool.internNullable(poolClassDef.getSuperclass()); typeListPool.intern(poolClassDef.getInterfaces()); stringPool.internNullable(poolClassDef.getSourceFile()); HashSet<String> fields = new HashSet<String>(); for (Field field: poolClassDef.getFields()) { String fieldDescriptor = ReferenceUtil.getShortFieldDescriptor(field); if (!fields.add(fieldDescriptor)) { throw new ExceptionWithContext("Multiple definitions for field %s->%s", poolClassDef.getType(), fieldDescriptor); } fieldPool.intern(field); EncodedValue initialValue = field.getInitialValue(); if (initialValue != null) { DexPool.internEncodedValue(initialValue, stringPool, typePool, fieldPool, methodPool); } annotationSetPool.intern(field.getAnnotations()); } HashSet<String> methods = new HashSet<String>(); for (PoolMethod method: poolClassDef.getMethods()) { String methodDescriptor = ReferenceUtil.getShortMethodDescriptor(method); if (!methods.add(methodDescriptor)) { throw new ExceptionWithContext("Multiple definitions for method %s->%s", poolClassDef.getType(), methodDescriptor); } methodPool.intern(method); internCode(method); internDebug(method); annotationSetPool.intern(method.getAnnotations()); for (MethodParameter parameter: method.getParameters()) { annotationSetPool.intern(parameter.getAnnotations()); } } annotationSetPool.intern(poolClassDef.getAnnotations()); }
Example 12
Source File: ClassDefinition.java From ZjDroid with Apache License 2.0 | 4 votes |
private void writeVirtualMethods(IndentingWriter writer, Set<String> directMethods) throws IOException { boolean wroteHeader = false; Set<String> writtenMethods = new HashSet<String>(); Iterable<? extends Method> virtualMethods; if (classDef instanceof DexBackedClassDef) { virtualMethods = ((DexBackedClassDef)classDef).getVirtualMethods(false); } else { virtualMethods = classDef.getVirtualMethods(); } for (Method method: virtualMethods) { if (!wroteHeader) { writer.write("\n\n"); writer.write("# virtual methods"); wroteHeader = true; } writer.write('\n'); // TODO: check for method validation errors String methodString = ReferenceUtil.getShortMethodDescriptor(method); IndentingWriter methodWriter = writer; if (!writtenMethods.add(methodString)) { writer.write("# duplicate method ignored\n"); methodWriter = new CommentingIndentingWriter(writer); } else if (directMethods.contains(methodString)) { writer.write("# There is both a direct and virtual method with this signature.\n" + "# You will need to rename one of these methods, including all references.\n"); System.err.println(String.format("Duplicate direct+virtual method found: %s->%s", classDef.getType(), methodString)); System.err.println("You will need to rename one of these methods, including all references."); } MethodImplementation methodImpl = method.getImplementation(); if (methodImpl == null) { MethodDefinition.writeEmptyMethodTo(methodWriter, method, options); } else { MethodDefinition methodDefinition = new MethodDefinition(this, method, methodImpl); methodDefinition.writeTo(methodWriter); } } }