Assert.assertEquals("I", method.getName());
}
@Test
public void testImplicitMethodLiteral() throws RecognitionException, IOException {
ClassDef classDef = SmaliTestUtils.compileSmali("" +
".class public LHelloWorld;\n" +
".super Ljava/lang/Object;\n" +
".field public static field1:Ljava/lang/reflect/Method; = toString()V\n" +
".field public static field2:Ljava/lang/reflect/Method; = V()V\n" +
".field public static field3:Ljava/lang/reflect/Method; = I()V\n" +
".field public static field4:Ljava/lang/Class; = I");
Map<String, Field> fields = Maps.newHashMap();
for (Field field: classDef.getFields()) {
fields.put(field.getName(), field);
}
Field field = fields.get("field1");
Assert.assertNotNull(field);
Assert.assertNotNull(field.getInitialValue());
Assert.assertEquals(ValueType.METHOD, field.getInitialValue().getValueType());
MethodEncodedValue methodEncodedValue = (MethodEncodedValue)field.getInitialValue();
Assert.assertEquals(classDef.getType(), methodEncodedValue.getValue().getDefiningClass());
Assert.assertEquals("toString", methodEncodedValue.getValue().getName());
field = fields.get("field2");
Assert.assertNotNull(field);
Assert.assertNotNull(field.getInitialValue());
Assert.assertEquals(ValueType.METHOD, field.getInitialValue().getValueType());
methodEncodedValue = (MethodEncodedValue)field.getInitialValue();
Assert.assertEquals(classDef.getType(), methodEncodedValue.getValue().getDefiningClass());
Assert.assertEquals("V", methodEncodedValue.getValue().getName());
field = fields.get("field3");
Assert.assertNotNull(field);
Assert.assertNotNull(field.getInitialValue());
Assert.assertEquals(ValueType.METHOD, field.getInitialValue().getValueType());
methodEncodedValue = (MethodEncodedValue)field.getInitialValue();
Assert.assertEquals(classDef.getType(), methodEncodedValue.getValue().getDefiningClass());
Assert.assertEquals("I", methodEncodedValue.getValue().getName());
field = fields.get("field4");
Assert.assertNotNull(field);
Assert.assertNotNull(field.getInitialValue());