Fields in java, "not a primitive field" error -



Fields in java, "not a primitive field" error -

i have been working fields parsing class sharedpreferences. worked while settings class not singleton. changed work singleton , not working anymore.

g2asettings settings = g2asettings.getinstance(); field[] fields = g2asettings.class.getdeclaredfields(); (field f : fields) { f.setaccessible(true); seek { if (preferences.contains(f.getname()) && !f.getname().equals("instance")) { f.set(settings, preferences.getboolean(f.getname(), f.getboolean(settings))); //si no lo encuentra, pone el valor por defecto determinado en la clase } else { if (blablabla) { editor.putboolean(f.getname(), true); allpreferencesdisabled = true; } else (*)-----> editor.putboolean(f.getname(), f.getboolean(settings)); } (*)-----> if (!allpreferencesdisabled) allpreferencesdisabled = f.getboolean(settings); } grab (illegalaccessexception e) { e.printstacktrace(); } }

the error reported following:

caused by: java.lang.illegalargumentexception: not primitive field

the error repoted @ lines marked (*) in code.

the fields of g2asettings public , boolean except instance variable g2asettings type variable , private.

i reporting here progress.

extra: post here relevant info of g2asettings class (usual singleton class):

public class g2asettings implements serializable { public boolean {big amount of boolean variables] private static g2asettings instance = null; private synchronized static void createinstance() { if (instance == null) { instance = new g2asettings(); } } public static g2asettings getinstance() { if (instance == null) createinstance(); homecoming instance; } {public getters , setters} }

which field 1 you're on when throws exception? i'd bet money it's instance, said isn't boolean can't phone call getboolean() on it.

your if statement checks if current field not instance before trying boolean value needs before , cover of other logic, since instance never going have boolean value , shouldn't persisted.

java field

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -