0 Replies Latest reply on Feb 21, 2006 11:07 AM by FX Hoover

    Autoboxing not working

    FX Hoover Newbie

      Hi!

      I made a Precondition annotation like this

      @PreCondition(condition="i > 1")
      public int check(int i) {
      System.err.println("check");
      return ++i;
      }

      a program finds this annotation an compiles an if-check into the method with CtMethod.insertBefore(...). Theoretically the result is:

      public int check(int i) {
      if(!(i > 1)) throw new RuntimeException("PreCondition failed.....");
      System.err.println("check");
      return ++i;
      }


      it works okay when i use it like above.

      following is not working:

      @PreCondition(condition="(i != null) && (i > 1)")
      public int check(Integer i) { // !!! changed from int to Integer
      System.err.println("check");
      return ++i;
      }

      it says: javassist.CannotCompileException: [source error] invalid types for >

      so the compiler of javassist is not able to do the auto-boxing that java 5.0 does.

      for me this feature is not absolutely necessary yet but its an interesting effect