java interface fields compiled undesirable modifiers -


i declared following interface:

public interface sqlsyncable {     boolean modified = true;     long id = -1;      static hashmap<string,sqlaction> sqlmodifiers = new hashmap<string,sqlaction>();     static field[] sql_object_fields = null;     static datatype[] transferdatatypes = null; } 

in other classes, set object implement interface, compilation error:

someobject.id = 10  // final field sqlsyncable.id cannot assigned.                     //the static field sqlsyncable.id should accessed in static way. 

lol what? "id" , "modified" not "static final", let see compiled .class file (im inspected in java assemly editor, , in eclipse), , really! every time (does not matter eclipse or java) int complied class of fields have "static final" modifier. why?

if modify interface "abstract class" problem instantly disappears.

...but half solution, java allow 1 of superclass.

why complied interface undesirable modifiers?

by definition, fields of interfaces marked static final.

you should have class surrounding interface if need non-static, non-final members.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -