Albert Cardona <acardona@ini.phys.ethz.ch> writes:
> The idea is not to modify the driver one bit in benefit of uncontroversial
> deployment of my application (TrakEM2 at
> http://www.ini.unizh.ch/~acardona/trackem2.html ). If java was lisp I would
> simply alter the register to replace the InputStream, but it isn't and/or I
> don't know how to use reflection to that extent
Thanks to its reflection API, java is actually lisp. Just a bit less
convenient. This should do the trick:
pg_input_field = PGStream.class.getDeclaredField("pg_input");
pg_input_field.setAccessible(true);
InputStream orig_stream = (InputStream) pg_input_field.get(pg_stream_to_hack);
InputStream counting_stream = new CountingInputStream(orig_stream);
pg_input_field.set(pg_stream_to_hack, counting_stream);
> (I don't know what would happen was I to replace the InputStream
> using reflection once a connection has been created).
As far as I understand the driver you _have to_ replace it after the
connection has been created. Just avoid using it before replace.