Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4870484

Class.newInstance() calls old constructor even after hotswapping the class

XMLWordPrintable

    • generic
    • generic

      main.java
      ---------
      public class main {
        public static void main(String[] args) throws Exception {
           for (;;) {
             Object o = t.class.newInstance();
           }
        }
      }


      t.java
      -------
      public class t {
         public t() { System.out.println("HELLO WORLD"); }
      }


      Steps to reproduce:

      1) start the debuggee with

       java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9999 main

      2) attach jdb using

        jdb -attach 9999

      3) in jdb prompt, set breakpoint by

        stop at main:4

      4) in jdb prompt execute 'cont' command 6 or more times

      5) change the line
          System.out.println("HELLO WORLD");
      in t.java as
          System.out.println("new message");

      6) recompile t.java

      7) in jdb prompt, redefine t using
        redefine t ./t.class

      8) after redefine execute "cont" command few times. We don't see the
      new println "new message" output in debuggee as expected. Instead,
      we still see the old message "HELLO WORLD".

      ###@###.### 2003-05-28

            sundar Sundararajan Athijegannathan
            sundar Sundararajan Athijegannathan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: