1 Reply Latest reply on Dec 19, 2009 8:34 AM by Arian Treffer

    javassist.CannotCompileException when using interfaces

    Arian Treffer Newbie

      Hello,

      I could not find a solution for my problem, hopefully someone can help me.

       

      In my project, I am using logging like this:

       

      public interface Logger {
          public void info(String s);  
          public void debug(String s);
      }

      public class LoggerImpl implements Logger {

          // ...

      }

       

      No I want to generate a proxy class that implements Logger, but when I try to compile


      private DynamicProxy dp;
      public void debug (java.lang.String p0) {
          Logger i = (Logger) dp.getImplementation();
          i.debug(p0);
      }

       

      I get "javassist.CannotCompileException: [source error] debug(java.lang.String) not found in dynproxy.test.Logger", whereas

       

      private DynamicProxy dp;
      public void debug (java.lang.String p0) {
           LoggerImpl i = (Logger
      Impl) dp.getImplementation();
           i.debug(p0);
      }

       

      works fine, but is no valid solution for the problem. (The idea is to have a proxy that uses the Logger implementation that is registered with the DynamicProxy object)

       

      So please tell me, what can I do to make it work?