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

Fix nsk/jdi test to not require lookup of main thread in order to set the breakpoint used for communication

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 25
    • 25
    • core-svc
    • b20

      The CR is related to JDK-8353955, which is attempting to no longer run all jdk/jdi tests with includevirtualthreads=y, allowing the default to be includevirtualthreads=n, and tests that require includevirtualthreads=y to explicitly specify that need.

      The changes recommended for this CR will reduce the number of tests that need to specify includevirtualthreads=y from about 350 to about 180. It does not make the change to have the default be includevirtualthreads=n, which will be left for JDK-8353955 once all tests are either fixed to work with includevirtualthreads=n or specify the need for includevirtualthreads=y.

      The changes in this PR relate to a common pattern in the nsk/jdi tests:

              String bPointMethod = "methodForCommunication";
              String lineForComm = "lineForComm";

              ThreadReference mainThread = debuggee.threadByNameOrThrow("main");

              BreakpointRequest bpRequest = settingBreakpoint(mainThread,
                                                   debuggeeClass,
                                                   bPointMethod, lineForComm, "zero");

      All tests that do this require includevirtualthreads=y because of the thread lookup. There is no need for mainThread in this code. null can be used instead for a global breakpoint. Once this is done, there is usually no need to run the test with includevirtualthreads=y, although in a few tests there are other calls to thread lookup API that result in the test still needing includevirtualthreads=y.

      I replaced the above code with a call to a new API in JDIBase:

              setupBreakpointForCommunication(debuggeeClass);

      This represents the bulk of the changes in this CR. Some tests had other references to mainThread that then needed to be addressed. For most, the thread was already stored in bpEvent and could be fetched from there:

          breakpointForCommunication();
          ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication()

      There are a couple of tests where the above changes can be applied, but they have other special needs and will be addressed in separate CRs:

      vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter002.java
      vmTestbase/nsk/jdi/EventRequest/disable/disable001.java

            cjplummer Chris Plummer
            cjplummer Chris Plummer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: