0 Replies Latest reply on Sep 14, 2009 11:51 AM by corifeo

    Field access like in GluonJ

    corifeo

      I try to implement a field access as the @Get and @Set Listener-Annotations in GluonJ, directly with Javassist.
      I looked into the source code how GluonJ performs this, but I can't get it running - and don't get the exact point.

      e.g. Class A
      {
      String myString;
      }

      Does anybody know:
      - is it possible to only modify Class A, e.g. by injecting a bytecode method invocation, to 'redirect' every possible access (set/get) on myString? Does GluonJ so? I found snippets like 'constPool.addMethodrefInfo(classIndex, nt); or 'codeConverter2.redirectFieldAccess(superOf, m.getDeclaringClass(), fname);

      - Or is it only possible to substitute the field accesses in specified classes/methods, and GluonJ substitute these brute-force in every class that is processed by the class loader...which is not so elegant, but perhaps the only possibility

      - What are the necessary Javassist invocations to achieve such Listeners? I can't find an according snippet in the tutorial. Is it possible to paste one here?

      Thanks in advance!

      Christian