Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7900382

Static instrumentation of anonymous classes is incorrect

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P1 P1
    • None
    • jcov_1.1
    • tools
    • x86
    • generic

      Latest version of jcov incorrectly instruments java code containing anonymous inner classes when static instrumentation mode used.
      An example below reproduces the problem:
      -------------------------------------------------------------------------------
      import java.awt.*;
      import java.awt.event.*;


      public class test extends Frame {

          public test() {
      System.out.println("test constructor");
      addWindowListener(new WindowAdapter() {
      public void WindowClosing(WindowEvent e) {
      System.exit(0);
      }
      });
          }

        public static void main(String [] argv) {
          System.out.println("test.main");
          test t = new test();
        }
      }
      --------------------------------------------------------------------------------

      I staticly instrumented the above code and then run it with
      "java javasoft.sqe.jcov.collect.RunMain -output=jcovdemo.data -verbose test"

      The result was:
      ---------------------------------------------------------------------------
      Info: Execute program: test
      test.main
      test constructor
      java.lang.NoClassDefFoundError: test$1
      at test.<init>(test.java:8)
      at test.main(test.java:18)
      at javasoft.sqe.jcov.collect.RunMain.process(RunMain.java:631)
      at javasoft.sqe.jcov.collect.RunMain.main(RunMain.java:698)
      Can't invoke class: exception was throwed::java.lang.NoClassDefFoundError: test$1
      appMain::public static void test.main(java.lang.String[])
      -----------------------------------------------------------------------------

      There were no problems to run jcov with the same code using dynamic instrumentation method.
      Used jcov version from: /usr/local/java/sqe-tools2.1/jcov.jar

            jjg Jonathan Gibbons
            klooney Kevin Looney (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: