0 Replies Latest reply: Jul 18, 2008 5:07 PM by 843810 RSS

    Expression evaluation bug in JDB or JDI?

    843810
      In the following example, I can correctly evaluate "n + Fact.fact(2),"
      but "Fact.fact(2) + n " failed.

      ----------------------------
      $cat -n Fact.java
      1     /**
      2     * Simple 10-20 lines test program for the initial JikesRVM/JDWP Google SOC
      3     * work.
      4     */
      5     public class Fact {
      6     
      7     /** The main method.*/
      8     public static void main(String[] args) {
      9     System.out.println("fact(4) = " + fact(4));
      10     }
      11     
      12     /**
      13     * compute the factorial number
      14     *
      15     * @param n the input number.
      16     */
      17     private static int fact(int n) {
      18     if ( n <= 0 ) {
      19     return 1;
      20     } else {
      21     return n * fact( n - 1 );
      22     }
      23     }
      24     }
      $jdb -version
      This is jdb version 1.6 (J2SE version 1.6.0_03)
      $jdb -launch Fact
      Set uncaught java.lang.Throwable
      Set deferred uncaught java.lang.Throwable
      Initializing jdb ...

      VM Started: > No frames on the current call stack

      main[1] stop at Fact:18
      Deferring breakpoint Fact:18.
      It will be set after the class is loaded.
      main[1] cont
      Set deferred breakpoint Fact:18
      Breakpoint hit: "thread=main", Fact.fact(), line=18 bci=0
      18 if ( n <= 0 ) {

      main[1] clear Fact:18
      Removed: breakpoint Fact:18
      main[1] eval n + Fact.fact(2)
      n + Fact.fact(2) = 6
      main[1] eval Fact.fact(2) + n
      Thread has been resumed
      Fact.fact(2) + n = null
      main[1] eval Fact.fact(2) + n
      Thread has been resumed
      Fact.fact(2) + n = null
      main[1] eval n + Fact.fact(2)
      n + Fact.fact(2) = 6
      main[1] cont
      fact(4) = 24
      -----------
      This seems to expose some bug in the JDB or JDI.

      regards,
      BK