I am trying to get an array from inside a library class, but the field is set as private :((
I used a java decompiler website to see this source of code:
public class MultiMarker
extends NyARPsgBaseClass {
protected PImageSensor _ss;
protected NyARMarkerSystem _ms;
public static final double DEFAULT_CF_THRESHOLD = 0.51;
public static final int DEFAULT_LOST_DELAY = 10;
public static final int THLESHOLD_AUTO = -1;
private ArrayList<Integer> _id_map = new ArrayList(); //<<------- I WANT TO ACCESS THIS
private final PMatrix3D _ps_projection = new PMatrix3D();
private boolean _is_in_begin_end_session = false;
So this is what I had tried following some examples using Java as reference but still variable is NOT VISIBLE. maybe some casting problem...
import java.lang.reflect.*;
import jp.nyatla.nyar4psg.*;
MultiMarker nya;
void setup() {
size(640,360);
nya=new MultiMarker(this, 640, 360, "camera_para.dat", NyAR4PsgConfig.CONFIG_PSG);
nya.addARMarker("patt.hiro", 80);//id=0
nya.addARMarker("patt.kanji", 80);//id=1
try {
MultiMarker.class.getDeclaredField("_id_map").setAccessible(true);
//or
//Field idmap = MultiMarker.class.getDeclaredField("_id_map");
//idmap.setAccessible(true);
// ArrayList<Integer> castTest = idmap.get( ArrayList<Integer>() ); //--error
// ArrayList<Integer> castTest = (ArrayList<Integer>)idmap.get(idmap); //--error
}
catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
println(nya._id_map.size()); //field is not visible
}