Java Code Examples for org.jf.dexlib2.iface.reference.StringReference

The following examples show how to use org.jf.dexlib2.iface.reference.StringReference. These examples are extracted from open source projects. 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 Project: atlas   Source File: AtlasFrameworkPropertiesReader.java    License: Apache License 2.0 6 votes vote down vote up
public LinkedHashMap<String,BundleListing.BundleInfo>read(String className,String memberName) throws Exception {

        if (reader!= null) {
            Method method = (Method) reader.read(className, memberName);
            if (method!= null){
                Iterable<? extends Instruction> instructions = method.getImplementation().getInstructions();
                for (Instruction instruction:instructions){
                    if (instruction instanceof ReferenceInstruction){
                        if (((ReferenceInstruction) instruction).getReferenceType()== 0){
                            StringReference s = (StringReference) ((ReferenceInstruction) instruction).getReference();
                            return BundleListingUtil.parseArray(s.getString(), (LinkedHashMap<String, BundleListing.BundleInfo>) map);
                        }
                    }
                }
            }
        }
        return null;
    }
 
Example 2
Source Project: atlas   Source File: ReferenceFormatter.java    License: Apache License 2.0 6 votes vote down vote up
public static void writeReference(IndentingWriter writer, int referenceType,
                                  Reference reference) throws IOException {
    switch (referenceType) {
        case ReferenceType.STRING:
            writeStringReference(writer, ((StringReference)reference).getString());
            return;
        case ReferenceType.TYPE:
            writer.write(((TypeReference)reference).getType());
            return;
        case ReferenceType.METHOD:
            ReferenceUtil.writeMethodDescriptor(writer, (MethodReference) reference);
            return;
        case ReferenceType.FIELD:
            ReferenceUtil.writeFieldDescriptor(writer, (FieldReference)reference);
            return;
        default:
            throw new IllegalStateException("Unknown reference type");
    }
}
 
Example 3
Source Project: JAADAS   Source File: DexPrinter.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void addRegisterAssignmentDebugInfo(
		LocalRegisterAssignmentInformation registerAssignment, Map<Local, Integer> seenRegisters, MethodImplementationBuilder builder) {
	Local local = registerAssignment.getLocal();
	String dexLocalType = SootToDexUtils.getDexTypeDescriptor(local.getType());
	StringReference localName = dexFile.internStringReference(local.getName());
	Register reg = registerAssignment.getRegister();
	int register = reg.getNumber();
	
	Integer beforeRegister = seenRegisters.get(local);
	if (beforeRegister != null)
	{
		if (beforeRegister == register)
			//No change
			return;
		builder.addEndLocal(beforeRegister);
	}
	builder.addStartLocal(register, localName, dexFile.internTypeReference(dexLocalType), dexFile.internStringReference(""));
	seenRegisters.put(local, register);
}
 
Example 4
Source Project: ZjDroid   Source File: ImmutableSetSourceFile.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable @Override public StringReference getSourceFileReference() {
    return sourceFile==null?null:new BaseStringReference() {
        @Nonnull @Override public String getString() {
            return sourceFile;
        }
    };
}
 
Example 5
Source Project: ZjDroid   Source File: ImmutableStartLocal.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable @Override public StringReference getNameReference() {
    return name==null?null:new BaseStringReference() {
        @Nonnull @Override public String getString() {
            return name;
        }
    };
}
 
Example 6
Source Project: ZjDroid   Source File: ImmutableStartLocal.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable @Override public StringReference getSignatureReference() {
    return signature==null?null:new BaseStringReference() {
        @Nonnull @Override public String getString() {
            return signature;
        }
    };
}
 
Example 7
Source Project: ZjDroid   Source File: ImmutableStringReference.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ImmutableStringReference of(@Nonnull StringReference stringReference) {
    if (stringReference instanceof ImmutableStringReference) {
        return (ImmutableStringReference)stringReference;
    }
    return new ImmutableStringReference(stringReference.getString());
}
 
Example 8
Source Project: ZjDroid   Source File: BaseStringReference.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(@Nullable Object o) {
    if (o != null && o instanceof StringReference) {
        return getString().equals(((StringReference)o).getString());
    }
    return false;
}
 
Example 9
Source Project: ZjDroid   Source File: InstructionWriter.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull static <StringRef extends StringReference, TypeRef extends TypeReference, FieldRefKey extends FieldReference, MethodRefKey extends MethodReference>
        InstructionWriter<StringRef, TypeRef, FieldRefKey, MethodRefKey>
        makeInstructionWriter(
            @Nonnull DexDataWriter writer,
            @Nonnull StringSection<?, StringRef> stringSection,
            @Nonnull TypeSection<?, ?, TypeRef> typeSection,
            @Nonnull FieldSection<?, ?, FieldRefKey, ?> fieldSection,
            @Nonnull MethodSection<?, ?, ?, MethodRefKey, ?> methodSection) {
    return new InstructionWriter<StringRef, TypeRef, FieldRefKey, MethodRefKey>(
            writer, stringSection, typeSection, fieldSection, methodSection);
}
 
Example 10
Source Project: ZjDroid   Source File: StringPool.java    License: Apache License 2.0 5 votes vote down vote up
@Override public int getItemIndex(@Nonnull StringReference key) {
    Integer index = internedItems.get(key.toString());
    if (index == null) {
        throw new ExceptionWithContext("Item not found.: %s", key.toString());
    }
    return index;
}
 
Example 11
Source Project: ZjDroid   Source File: BuilderClassPool.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable private BuilderStringReference checkStringReference(@Nullable StringReference stringReference) {
    if (stringReference == null) {
        return null;
    }
    try {
        return (BuilderStringReference)stringReference;
    } catch (ClassCastException ex) {
        throw new IllegalStateException("Only StringReference instances returned by " +
                "DexBuilder.internStringReference or DexBuilder.internNullableStringReference may be used.");
    }
}
 
Example 12
Source Project: zjdroid   Source File: ImmutableSetSourceFile.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable @Override public StringReference getSourceFileReference() {
    return sourceFile==null?null:new BaseStringReference() {
        @Nonnull @Override public String getString() {
            return sourceFile;
        }
    };
}
 
Example 13
Source Project: ZjDroid   Source File: BuilderClassPool.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable private BuilderStringReference checkStringReference(@Nullable StringReference stringReference) {
    if (stringReference == null) {
        return null;
    }
    try {
        return (BuilderStringReference)stringReference;
    } catch (ClassCastException ex) {
        throw new IllegalStateException("Only StringReference instances returned by " +
                "DexBuilder.internStringReference or DexBuilder.internNullableStringReference may be used.");
    }
}
 
Example 14
Source Project: zjdroid   Source File: ImmutableStartLocal.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable @Override public StringReference getSignatureReference() {
    return signature==null?null:new BaseStringReference() {
        @Nonnull @Override public String getString() {
            return signature;
        }
    };
}
 
Example 15
Source Project: zjdroid   Source File: ImmutableStringReference.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ImmutableStringReference of(@Nonnull StringReference stringReference) {
    if (stringReference instanceof ImmutableStringReference) {
        return (ImmutableStringReference)stringReference;
    }
    return new ImmutableStringReference(stringReference.getString());
}
 
Example 16
Source Project: zjdroid   Source File: BaseStringReference.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(@Nullable Object o) {
    if (o != null && o instanceof StringReference) {
        return getString().equals(((StringReference)o).getString());
    }
    return false;
}
 
Example 17
Source Project: zjdroid   Source File: InstructionWriter.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull static <StringRef extends StringReference, TypeRef extends TypeReference, FieldRefKey extends FieldReference, MethodRefKey extends MethodReference>
        InstructionWriter<StringRef, TypeRef, FieldRefKey, MethodRefKey>
        makeInstructionWriter(
            @Nonnull DexDataWriter writer,
            @Nonnull StringSection<?, StringRef> stringSection,
            @Nonnull TypeSection<?, ?, TypeRef> typeSection,
            @Nonnull FieldSection<?, ?, FieldRefKey, ?> fieldSection,
            @Nonnull MethodSection<?, ?, ?, MethodRefKey, ?> methodSection) {
    return new InstructionWriter<StringRef, TypeRef, FieldRefKey, MethodRefKey>(
            writer, stringSection, typeSection, fieldSection, methodSection);
}
 
Example 18
Source Project: zjdroid   Source File: StringPool.java    License: Apache License 2.0 5 votes vote down vote up
@Override public int getItemIndex(@Nonnull StringReference key) {
    Integer index = internedItems.get(key.toString());
    if (index == null) {
        throw new ExceptionWithContext("Item not found.: %s", key.toString());
    }
    return index;
}
 
Example 19
Source Project: zjdroid   Source File: BuilderClassPool.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable private BuilderStringReference checkStringReference(@Nullable StringReference stringReference) {
    if (stringReference == null) {
        return null;
    }
    try {
        return (BuilderStringReference)stringReference;
    } catch (ClassCastException ex) {
        throw new IllegalStateException("Only StringReference instances returned by " +
                "DexBuilder.internStringReference or DexBuilder.internNullableStringReference may be used.");
    }
}
 
Example 20
Source Project: HeyGirl   Source File: ImmutableSetSourceFile.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable @Override public StringReference getSourceFileReference() {
    return sourceFile==null?null:new BaseStringReference() {
        @Nonnull @Override public String getString() {
            return sourceFile;
        }
    };
}
 
Example 21
Source Project: HeyGirl   Source File: ImmutableStartLocal.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable @Override public StringReference getNameReference() {
    return name==null?null:new BaseStringReference() {
        @Nonnull @Override public String getString() {
            return name;
        }
    };
}
 
Example 22
Source Project: HeyGirl   Source File: ImmutableStringReference.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ImmutableStringReference of(@Nonnull StringReference stringReference) {
    if (stringReference instanceof ImmutableStringReference) {
        return (ImmutableStringReference)stringReference;
    }
    return new ImmutableStringReference(stringReference.getString());
}
 
Example 23
Source Project: HeyGirl   Source File: InstructionWriter.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull static <StringRef extends StringReference, TypeRef extends TypeReference, FieldRefKey extends FieldReference, MethodRefKey extends MethodReference>
        InstructionWriter<StringRef, TypeRef, FieldRefKey, MethodRefKey>
        makeInstructionWriter(
            @Nonnull DexDataWriter writer,
            @Nonnull StringSection<?, StringRef> stringSection,
            @Nonnull TypeSection<?, ?, TypeRef> typeSection,
            @Nonnull FieldSection<?, ?, FieldRefKey, ?> fieldSection,
            @Nonnull MethodSection<?, ?, ?, MethodRefKey, ?> methodSection) {
    return new InstructionWriter<StringRef, TypeRef, FieldRefKey, MethodRefKey>(
            writer, stringSection, typeSection, fieldSection, methodSection);
}
 
Example 24
Source Project: HeyGirl   Source File: StringPool.java    License: Apache License 2.0 5 votes vote down vote up
@Override public int getItemIndex(@Nonnull StringReference key) {
    Integer index = internedItems.get(key.toString());
    if (index == null) {
        throw new ExceptionWithContext("Item not found.: %s", key.toString());
    }
    return index;
}
 
Example 25
Source Project: HeyGirl   Source File: BuilderClassPool.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable private BuilderStringReference checkStringReference(@Nullable StringReference stringReference) {
    if (stringReference == null) {
        return null;
    }
    try {
        return (BuilderStringReference)stringReference;
    } catch (ClassCastException ex) {
        throw new IllegalStateException("Only StringReference instances returned by " +
                "DexBuilder.internStringReference or DexBuilder.internNullableStringReference may be used.");
    }
}
 
Example 26
Source Project: HeyGirl   Source File: BuilderStartLocal.java    License: Apache License 2.0 5 votes vote down vote up
public BuilderStartLocal(int register,
                         @Nullable StringReference name,
                         @Nullable TypeReference type,
                         @Nullable StringReference signature) {
    this.register = register;
    this.name = name;
    this.type = type;
    this.signature = signature;
}
 
Example 27
Source Project: ZjDroid   Source File: ImmutableSetSourceFile.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable @Override public StringReference getSourceFileReference() {
    return sourceFile==null?null:new BaseStringReference() {
        @Nonnull @Override public String getString() {
            return sourceFile;
        }
    };
}
 
Example 28
Source Project: ZjDroid   Source File: ImmutableStartLocal.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable @Override public StringReference getNameReference() {
    return name==null?null:new BaseStringReference() {
        @Nonnull @Override public String getString() {
            return name;
        }
    };
}
 
Example 29
Source Project: ZjDroid   Source File: ImmutableStartLocal.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable @Override public StringReference getSignatureReference() {
    return signature==null?null:new BaseStringReference() {
        @Nonnull @Override public String getString() {
            return signature;
        }
    };
}
 
Example 30
Source Project: ZjDroid   Source File: ImmutableStringReference.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ImmutableStringReference of(@Nonnull StringReference stringReference) {
    if (stringReference instanceof ImmutableStringReference) {
        return (ImmutableStringReference)stringReference;
    }
    return new ImmutableStringReference(stringReference.getString());
}