static void smartSet(Field f, O o, O value) throws Exception { f.setAccessible(true); // take care of common case (long to int) if (f.getType() == int.class && value instanceof Long) value = ((Long) value).intValue(); try { f.set(o, value); } catch (Exception e) { try { if (f.getType().getName().equals("main$Concept$Ref")) { f.set(o, nuObject("main$Concept$Ref", o, value)); ret; } if (o.getClass().getName().equals("main$Concept$Ref")) { f.set(o, call(o, "get")); ret; } } catch {} throw e; } }