java - Read static field of interface via reflection -
i've got interface:
public interface interface { public static final string field1 = "bar"; public static final string field2 = "foo"; ......... }
i'm trying read field name via reflection using code:
field[] fields = interface.class.getfields(); (field f : fields) { ............ }
the problem array has length zero. why?
edit: i'm using proguard , think problem related interface obfuscation.
i running same code have provided , able print name of fields interface.
import java.lang.reflect.field; public class prop { public static void main(string[] args) { field[] fields = interface.class.getfields(); (field f : fields) { system.out.println(f.getname()); } } } interface interface { public static final string field1 = "bar"; public static final string field2 = "foo"; }
ouput:
field1 field2
Comments
Post a Comment