Search in sources :

Example 1 with ImmutableFieldEncodedValue

use of org.jf.dexlib2.immutable.value.ImmutableFieldEncodedValue in project smali by JesusFreke.

the class BaksmaliWriterTest method testWriteEncodedValue_annotation_withSpaces.

@Test
public void testWriteEncodedValue_annotation_withSpaces() throws IOException {
    BaksmaliWriter writer = new BaksmaliWriter(output);
    writer.writeEncodedValue(new ImmutableAnnotationEncodedValue("Lannotation/type with spaces;", ImmutableSet.of(new ImmutableAnnotationElement("element with spaces 1", new ImmutableFieldEncodedValue(getFieldReferenceWithSpaces())), new ImmutableAnnotationElement("element with spaces 2", new ImmutableMethodEncodedValue(getMethodReferenceWithSpaces())))));
    Assert.assertEquals(".subannotation Lannotation/`type with spaces`;\n" + "    `element with spaces 1` = Ldefining/class/`with spaces`;->`fieldName with spaces`:Lfield/`type with spaces`;\n" + "    `element with spaces 2` = Ldefining/class/`with spaces`;->`methodName with spaces`(" + "L`param with spaces 1`;L`param with spaces 2`;)Lreturn/type/`with spaces`;\n" + ".end subannotation", output.toString());
}
Also used : ImmutableAnnotationElement(org.jf.dexlib2.immutable.ImmutableAnnotationElement) Test(org.junit.Test)

Example 2 with ImmutableFieldEncodedValue

use of org.jf.dexlib2.immutable.value.ImmutableFieldEncodedValue in project smali by JesusFreke.

the class DexFormattedWriterTest method testWriteEncodedValue_annotation.

@Test
public void testWriteEncodedValue_annotation() throws IOException {
    DexFormattedWriter writer = new DexFormattedWriter(output);
    writer.writeEncodedValue(new ImmutableAnnotationEncodedValue("Lannotation/type;", ImmutableSet.of(new ImmutableAnnotationElement("element1", new ImmutableFieldEncodedValue(getFieldReference())), new ImmutableAnnotationElement("element2", new ImmutableMethodEncodedValue(getMethodReference())))));
    Assert.assertEquals("Annotation[Lannotation/type;, " + "element1=Ldefining/class;->fieldName:Lfield/type;, " + "element2=Ldefining/class;->methodName(Lparam1;Lparam2;)Lreturn/type;]", output.toString());
}
Also used : ImmutableAnnotationElement(org.jf.dexlib2.immutable.ImmutableAnnotationElement) Test(org.junit.Test)

Aggregations

ImmutableAnnotationElement (org.jf.dexlib2.immutable.ImmutableAnnotationElement)2 Test (org.junit.Test)2