dimanche 19 mars 2017

Can't access Scala private val with reflection

Spark has this BisectingKMeansModel with a root field that I want, but it isn't exposed! I tried to get it through reflection but I get a NoSuchFieldException:

Field rootField = model.getClass().getDeclaredField("root");
rootField.setAccessible(true);
node = (ClusteringTreeNode) rootField.get(model);

I even tried enumerating the fields:

for (Field f : model.getClass().getDeclaredFields()) {
    System.out.println(f.getName());
}

But it isn't listed. I'm not familiar with Scala, what's going on here?





Aucun commentaire:

Enregistrer un commentaire