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

The following examples show how to use org.jf.dexlib2.iface.reference.StringReference. 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: DexPrinter.java    From JAADAS with 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 #2
Source File: AtlasFrameworkPropertiesReader.java    From atlas with 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 #3
Source File: ReferenceFormatter.java    From atlas with 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 #4
Source File: ImmutableStringReference.java    From ZjDroid with 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 #5
Source File: StringPool.java    From ZjDroid with 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 #6
Source File: ImmutableStartLocal.java    From ZjDroid with 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 File: BaseStringReference.java    From ZjDroid with 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 #8
Source File: BaseStringReference.java    From ZjDroid with 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 File: ImmutableSetSourceFile.java    From ZjDroid with 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 #10
Source File: BuilderClassPool.java    From ZjDroid with 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 #11
Source File: ImmutableStringReference.java    From ZjDroid with 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 #12
Source File: ImmutableSetSourceFile.java    From zjdroid with 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 File: BuilderClassPool.java    From ZjDroid with 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 File: ImmutableStartLocal.java    From zjdroid with 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 File: ImmutableStringReference.java    From zjdroid with 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 File: BaseStringReference.java    From zjdroid with 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 File: ImmutableStartLocal.java    From ZjDroid with 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 #18
Source File: ImmutableStartLocal.java    From ZjDroid with 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 #19
Source File: ImmutableStartLocal.java    From ZjDroid with 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 #20
Source File: InstructionWriter.java    From zjdroid with 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 #21
Source File: StringPool.java    From zjdroid with 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 #22
Source File: BuilderClassPool.java    From zjdroid with 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 #23
Source File: ImmutableSetSourceFile.java    From ZjDroid with 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 #24
Source File: ImmutableSetSourceFile.java    From HeyGirl with 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 #25
Source File: ImmutableStartLocal.java    From HeyGirl with 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 #26
Source File: ImmutableStringReference.java    From HeyGirl with 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 #27
Source File: InstructionWriter.java    From HeyGirl with 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 #28
Source File: StringPool.java    From HeyGirl with 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 #29
Source File: BuilderClassPool.java    From HeyGirl with 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 #30
Source File: BuilderStartLocal.java    From HeyGirl with 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;
}