1 /* 2 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package nsk.jdi.LocatableEvent.thread; 25 26 import nsk.share.*; 27 import nsk.share.jpda.*; 28 import nsk.share.jdi.*; 29 30 import com.sun.jdi.*; 31 import com.sun.jdi.event.*; 32 import com.sun.jdi.request.*; 33 34 import java.util.*; 35 import java.io.*; 36 37 /** 38 * The test for the implementation of an object of the type <BR> 39 * LocatableEvent. <BR> 40 * <BR> 41 * The test checks that results of the method <BR> 42 * <code>com.sun.jdi.LocatableEvent.thread()</code> <BR> 43 * complies with its spec. <BR> 44 * <BR> 45 * The cases for testing include all Locatable events. <BR> 46 * The test checks that <BR> 47 * for each type of LocatableEvent received in a debugger, <BR> 48 * a value returned by the method invoked on <BR> 49 * a <type>Event object corresponds to a thread <BR> 50 * which debuggee's counterpart event was generated in. <BR> 51 * <BR> 52 * The test has three phases and works as follows. <BR> 53 * <BR> 54 * In first phase, <BR> 55 * upon launching debuggee's VM which will be suspended, <BR> 56 * a debugger waits for the VMStartEvent within a predefined <BR> 57 * time interval. If no the VMStartEvent received, the test is FAILED. <BR> 58 * Upon getting the VMStartEvent, it makes the request for debuggee's <BR> 59 * ClassPrepareEvent with SUSPEND_EVENT_THREAD, resumes the VM, <BR> 60 * and waits for the event within the predefined time interval. <BR> 61 * If no the ClassPrepareEvent received, the test is FAILED. <BR> 62 * Upon getting the ClassPrepareEvent, <BR> 63 * the debugger sets up the breakpoint with SUSPEND_EVENT_THREAD <BR> 64 * within debuggee's special methodForCommunication(). <BR> 65 * <BR> 66 * In second phase to check Locatable events, <BR> 67 * the debugger and the debuggee perform the following. <BR> 68 * - The debugger resumes the debuggee and waits for the BreakpointEvent.<BR> 69 * - The debuggee creates a number of threads, one for each check case <BR> 70 * and invokes the methodForCommunication to be suspended and <BR> 71 * to inform the debugger with the event. <BR> 72 * - Upon getting the BreakpointEvent, the debugger <BR> 73 * gets ThreadReferences mirroring all tested threads in the debuggee,<BR> 74 * sets up Requests within them to get Events to check up on, <BR> 75 * resumes the debuggee, waits for events, and upon getting them, <BR> 76 * compares ThreadReferences put into Requests to ones from Events; <BR> 77 * if any mismatch, the test FAILED. <BR> 78 * <BR> 79 * Note. To inform each other of needed actions, the debugger and <BR> 80 * and the debuggee use debuggeee's variable "instruction". <BR> 81 * <BR> 82 * In third phase when at the end, <BR> 83 * the debuggee changes the value of the "instruction" <BR> 84 * to inform the debugger of checks finished, and both end. <BR> 85 * <BR> 86 */ 87 88 public class thread001 { 89 90 //----------------------------------------------------- templete section 91 static final int PASSED = 0; 92 static final int FAILED = 2; 93 static final int PASS_BASE = 95; 94 95 //----------------------------------------------------- templete parameters 96 static final String 97 sHeader1 = "\n==> nsk/jdi/LocatableEvent/thread/thread001 ", 98 sHeader2 = "--> debugger: ", 99 sHeader3 = "##> debugger: "; 100 101 //----------------------------------------------------- main method 102 main(String argv[])103 public static void main (String argv[]) { 104 105 int result = run(argv, System.out); 106 107 System.exit(result + PASS_BASE); 108 } 109 run(String argv[], PrintStream out)110 public static int run (String argv[], PrintStream out) { 111 112 int exitCode = new thread001().runThis(argv, out); 113 114 if (exitCode != PASSED) { 115 System.out.println("TEST FAILED"); 116 } 117 return testExitCode; 118 } 119 120 //-------------------------------------------------- log procedures 121 122 private static Log logHandler; 123 log1(String message)124 private static void log1(String message) { 125 logHandler.display(sHeader1 + message); 126 } log2(String message)127 private static void log2(String message) { 128 logHandler.display(sHeader2 + message); 129 } log3(String message)130 private static void log3(String message) { 131 logHandler.complain(sHeader3 + message); 132 } 133 134 // ************************************************ test parameters 135 136 private String debuggeeName = 137 "nsk.jdi.LocatableEvent.thread.thread001a"; 138 139 private String testedClassName = 140 "nsk.jdi.LocatableEvent.thread.TestClass"; 141 142 //====================================================== test program 143 //------------------------------------------------------ common section 144 145 static Debugee debuggee; 146 static ArgumentHandler argsHandler; 147 148 static int waitTime; 149 150 static VirtualMachine vm = null; 151 static EventRequestManager eventRManager = null; 152 static EventQueue eventQueue = null; 153 static EventSet eventSet = null; 154 static EventIterator eventIterator = null; 155 156 static ReferenceType debuggeeClass = null; 157 158 static int testExitCode = PASSED; 159 160 161 class JDITestRuntimeException extends RuntimeException { JDITestRuntimeException(String str)162 JDITestRuntimeException(String str) { 163 super("JDITestRuntimeException : " + str); 164 } 165 } 166 167 //------------------------------------------------------ methods 168 runThis(String argv[], PrintStream out)169 private int runThis (String argv[], PrintStream out) { 170 171 argsHandler = new ArgumentHandler(argv); 172 logHandler = new Log(out, argsHandler); 173 Binder binder = new Binder(argsHandler, logHandler); 174 175 waitTime = argsHandler.getWaitTime() * 60000; 176 177 try { 178 log2("launching a debuggee :"); 179 log2(" " + debuggeeName); 180 if (argsHandler.verbose()) { 181 debuggee = binder.bindToDebugee(debuggeeName + " -vbs"); 182 } else { 183 debuggee = binder.bindToDebugee(debuggeeName); 184 } 185 if (debuggee == null) { 186 log3("ERROR: no debuggee launched"); 187 return FAILED; 188 } 189 log2("debuggee launched"); 190 } catch ( Exception e ) { 191 log3("ERROR: Exception : " + e); 192 log2(" test cancelled"); 193 return FAILED; 194 } 195 196 debuggee.redirectOutput(logHandler); 197 198 vm = debuggee.VM(); 199 200 eventQueue = vm.eventQueue(); 201 if (eventQueue == null) { 202 log3("ERROR: eventQueue == null : TEST ABORTED"); 203 vm.exit(PASS_BASE); 204 return FAILED; 205 } 206 207 log2("invocation of the method runTest()"); 208 switch (runTest()) { 209 210 case 0 : log2("test phase has finished normally"); 211 log2(" waiting for the debuggee to finish ..."); 212 debuggee.waitFor(); 213 214 log2("......getting the debuggee's exit status"); 215 int status = debuggee.getStatus(); 216 if (status != PASS_BASE) { 217 log3("ERROR: debuggee returned UNEXPECTED exit status: " + 218 status + " != PASS_BASE"); 219 testExitCode = FAILED; 220 } else { 221 log2("......debuggee returned expected exit status: " + 222 status + " == PASS_BASE"); 223 } 224 break; 225 226 default : log3("ERROR: runTest() returned unexpected value"); 227 228 case 1 : log3("test phase has not finished normally: debuggee is still alive"); 229 log2("......forcing: vm.exit();"); 230 testExitCode = FAILED; 231 try { 232 vm.exit(PASS_BASE); 233 } catch ( Exception e ) { 234 log3("ERROR: Exception : e"); 235 } 236 break; 237 238 case 2 : log3("test cancelled due to VMDisconnectedException"); 239 log2("......trying: vm.process().destroy();"); 240 testExitCode = FAILED; 241 try { 242 Process vmProcess = vm.process(); 243 if (vmProcess != null) { 244 vmProcess.destroy(); 245 } 246 } catch ( Exception e ) { 247 log3("ERROR: Exception : e"); 248 } 249 break; 250 } 251 252 return testExitCode; 253 } 254 255 256 /* 257 * Return value: 0 - normal end of the test 258 * 1 - ubnormal end of the test 259 * 2 - VMDisconnectedException while test phase 260 */ 261 runTest()262 private int runTest() { 263 264 try { 265 testRun(); 266 267 log2("waiting for VMDeathEvent"); 268 getEventSet(); 269 if (eventIterator.nextEvent() instanceof VMDeathEvent) 270 return 0; 271 272 log3("ERROR: last event is not the VMDeathEvent"); 273 return 1; 274 } catch ( VMDisconnectedException e ) { 275 log3("ERROR: VMDisconnectedException : " + e); 276 return 2; 277 } catch ( Exception e ) { 278 log3("ERROR: Exception : " + e); 279 return 1; 280 } 281 282 } 283 testRun()284 private void testRun() 285 throws JDITestRuntimeException, Exception { 286 287 eventRManager = vm.eventRequestManager(); 288 289 ClassPrepareRequest cpRequest = eventRManager.createClassPrepareRequest(); 290 cpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); 291 cpRequest.addClassFilter(debuggeeName); 292 293 cpRequest.enable(); 294 vm.resume(); 295 getEventSet(); 296 cpRequest.disable(); 297 298 ClassPrepareEvent event = (ClassPrepareEvent) eventIterator.next(); 299 debuggeeClass = event.referenceType(); 300 301 if (!debuggeeClass.name().equals(debuggeeName)) 302 throw new JDITestRuntimeException("** Unexpected ClassName for ClassPrepareEvent **"); 303 304 log2(" received: ClassPrepareEvent for debuggeeClass"); 305 306 String bPointMethod = "methodForCommunication"; 307 String lineForComm = "lineForComm"; 308 BreakpointRequest bpRequest; 309 310 bpRequest = settingBreakpoint(threadByName("main"), 311 debuggeeClass, 312 bPointMethod, lineForComm, "zero"); 313 bpRequest.enable(); 314 315 //------------------------------------------------------ testing section 316 317 log1(" TESTING BEGINS"); 318 319 for (int i = 0; ; i++) { 320 321 vm.resume(); 322 breakpointForCommunication(); 323 324 int instruction = ((IntegerValue) 325 (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); 326 327 if (instruction == 0) { 328 vm.resume(); 329 break; 330 } 331 332 log1(":::::: case: # " + i); 333 334 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part 335 336 String accWatchpointName = "var1"; 337 String modWatchpointName = "var2"; 338 String bpLineName = "breakpointLine"; 339 String bpMethodName = "method"; 340 String awFieldName = "awFieldName"; 341 String mwFieldName = "mwFieldName"; 342 String excName = "method"; 343 String menName = "method"; 344 String mexName = "method"; 345 346 String namesArray = "threadNames"; 347 348 String threadNames[] = { 349 "awThread" , 350 "mwThread" , 351 "bpThread" , 352 "excThread" , 353 "menThread" , 354 "mexThread" , 355 "stThread" 356 }; 357 358 359 EventRequest eRequests[] = new EventRequest[threadNames.length]; 360 int flags = 0; 361 362 ThreadReference eventThreads[] = new ThreadReference[threadNames.length]; 363 364 365 List allThreads = vm.allThreads(); 366 367 log2("......getting: ArrayReference namesRef = (ArrayReference) debuggeeClass.getValue(debuggeeClass.fieldByName(namesArray));"); 368 ArrayReference namesRef = (ArrayReference) 369 debuggeeClass.getValue(debuggeeClass.fieldByName(namesArray)); 370 log2(" namesRef.length() == " + namesRef.length()); 371 372 log2("......getting and chcking up on debuggee threads' names"); 373 for (int n1 = 0; n1 < namesRef.length(); n1++) { 374 375 log2(" String name = ((StringReference) namesRef.getValue(n1)).value();"); 376 String name = ((StringReference) namesRef.getValue(n1)).value(); 377 378 label0: { 379 for (int n2 = 0; n2 < threadNames.length; n2++) { 380 381 if (name.equals(threadNames[n2])) { 382 ListIterator li = allThreads.listIterator(); 383 for (; li.hasNext(); ) { 384 ThreadReference thread = (ThreadReference) li.next(); 385 if (thread.name().equals(name)) { 386 eventThreads[n1] = thread; 387 break; 388 } 389 } 390 break label0; 391 } 392 } 393 testExitCode = FAILED; 394 log3("ERROR: no thread found in the debuggee : " + name); 395 } 396 } 397 if (testExitCode == FAILED) 398 break; 399 400 401 log2("......ReferenceType testClass = (ReferenceType) (vm.classesByName(testedClassName)).get(0);"); 402 ReferenceType testClass = (ReferenceType) (vm.classesByName(testedClassName)).get(0); 403 404 log2("......setting up Requests"); 405 for ( int n3 = 0; n3 < namesRef.length(); n3++) { 406 switch (n3) { 407 case 0: 408 if (vm.canWatchFieldAccess()) { 409 String awName = ( (StringReference) testClass.getValue( 410 testClass.fieldByName(awFieldName))).value(); 411 eRequests[n3] = settingAccessWatchpoint(eventThreads[n3], 412 testClass, awName, threadNames[n3]); 413 eRequests[n3].enable(); 414 flags |= 1; 415 } 416 break; 417 418 case 1: 419 if (vm.canWatchFieldModification() ) { 420 String mwName = ( (StringReference) testClass.getValue( 421 testClass.fieldByName(mwFieldName))).value(); 422 eRequests[n3] = settingModificationWatchpoint(eventThreads[n3], 423 testClass, mwName, threadNames[n3]); 424 eRequests[n3].enable(); 425 flags |= 1<<1; 426 } 427 break; 428 429 case 2: 430 eRequests[n3] = settingBreakpoint(eventThreads[n3], testClass, 431 bpMethodName, bpLineName, threadNames[n3]); 432 eRequests[n3].setSuspendPolicy( EventRequest.SUSPEND_NONE); 433 eRequests[n3].enable(); 434 flags |= 1<<2; 435 break; 436 437 case 3: 438 eRequests[n3] = settingException(eventThreads[n3], debuggeeClass, //testClass, 439 threadNames[n3]); 440 eRequests[n3].enable(); 441 flags |= 1<<3; 442 break; 443 444 case 4: 445 eRequests[n3] = settingMethodEntry(eventThreads[n3], testClass, 446 threadNames[n3]); 447 eRequests[n3].enable(); 448 flags |= 1<<4; 449 break; 450 451 case 5: 452 eRequests[n3] = settingMethodExit(eventThreads[n3], testClass, 453 threadNames[n3]); 454 eRequests[n3].enable(); 455 flags |= 1<<5; 456 break; 457 458 case 6: 459 eRequests[n3] = settingStep(eventThreads[n3], threadNames[n3]); 460 eRequests[n3].enable(); 461 flags |= 1<<6; 462 break; 463 464 default: 465 throw new JDITestRuntimeException("** default case while prepareing requests**"); 466 } 467 } 468 469 log2(":::::::::vm.resume();"); 470 vm.resume(); 471 472 Event event1 = null; 473 String threadName = null; 474 int flagsCopy = flags; 475 String eName = null; 476 477 log2("......getting and checking up on Events"); 478 for (int n4 = 0; n4 < namesRef.length(); n4++) { 479 int flag; 480 int index; 481 getEventSet(); 482 event1 = eventIterator.nextEvent(); 483 484 if (event1 instanceof AccessWatchpointEvent) { 485 eName = "AccessWatchpointEvent"; 486 index = 0; 487 } else if (event1 instanceof ModificationWatchpointEvent ) { 488 eName = "ModificationWatchpointEvent"; 489 index = 1; 490 } else if (event1 instanceof BreakpointEvent ) { 491 eName = "BreakpointEvent"; 492 index = 2; 493 } else if (event1 instanceof ExceptionEvent ) { 494 eName = "ExceptionEvent"; 495 index = 3; 496 } else if (event1 instanceof MethodEntryEvent ) { 497 eName = "MethodEntryEvent"; 498 index = 4; 499 } else if (event1 instanceof MethodExitEvent ) { 500 eName = "MethodExitEvent"; 501 index = 5; 502 } else if (event1 instanceof StepEvent ) { 503 eName = "StepEvent"; 504 index = 6; 505 } else { 506 log3("ERROR: else clause in detecting type of event1"); 507 testExitCode = FAILED; 508 throw new JDITestRuntimeException("** unexpected event **"); 509 } 510 log2("--------> got: " + eName); 511 512 ThreadReference threadRef = ((LocatableEvent) event1).thread(); 513 514 label0: { 515 for (int n5 = 0; n5 < namesRef.length(); n5++) { 516 if (threadRef.equals(eventThreads[n5])) { 517 eventThreads[n5] = null; 518 threadName = threadNames[index]; 519 break label0; 520 } 521 } 522 testExitCode = FAILED; 523 log3("ERROR: event's thread is not equal to any tested"); 524 log3(" thread's name == " + threadRef.name()); 525 } 526 527 flag = 1 << index; 528 if ((flagsCopy & flag) == 0) { 529 log3("ERROR: event duplication: " + eName); 530 testExitCode = FAILED; 531 } else { 532 flagsCopy ^= flag; 533 flags |= flag; 534 } 535 } 536 537 breakpointForCommunication(); 538 539 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 540 } 541 log1(" TESTING ENDS"); 542 return; 543 } 544 threadByName(String name)545 private ThreadReference threadByName(String name) 546 throws JDITestRuntimeException { 547 548 List all = vm.allThreads(); 549 ListIterator li = all.listIterator(); 550 551 for (; li.hasNext(); ) { 552 ThreadReference thread = (ThreadReference) li.next(); 553 if (thread.name().equals(name)) 554 return thread; 555 } 556 throw new JDITestRuntimeException("** Thread IS NOT found ** : " + name); 557 } 558 559 /* 560 * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, 561 * String, String, String) 562 * 563 * It sets up a breakpoint at given line number within a given method in a given class 564 * for a given thread. 565 * 566 * Return value: BreakpointRequest object in case of success 567 * 568 * JDITestRuntimeException in case of an Exception thrown within the method 569 */ 570 settingBreakpoint( ThreadReference thread, ReferenceType testedClass, String methodName, String bpLine, String property)571 private BreakpointRequest settingBreakpoint ( ThreadReference thread, 572 ReferenceType testedClass, 573 String methodName, 574 String bpLine, 575 String property) 576 throws JDITestRuntimeException { 577 578 log2("......setting up a breakpoint:"); 579 log2(" thread: " + thread + "; class: " + testedClass + 580 "; method: " + methodName + "; line: " + bpLine); 581 582 List alllineLocations = null; 583 Location lineLocation = null; 584 BreakpointRequest breakpRequest = null; 585 586 try { 587 Method method = (Method) testedClass.methodsByName(methodName).get(0); 588 589 alllineLocations = method.allLineLocations(); 590 591 int n = 592 ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); 593 if (n > alllineLocations.size()) { 594 log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); 595 } else { 596 lineLocation = (Location) alllineLocations.get(n); 597 try { 598 breakpRequest = eventRManager.createBreakpointRequest(lineLocation); 599 breakpRequest.putProperty("number", property); 600 breakpRequest.addThreadFilter(thread); 601 breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); 602 } catch ( Exception e1 ) { 603 log3("ERROR: inner Exception within settingBreakpoint() : " + e1); 604 breakpRequest = null; 605 } 606 } 607 } catch ( Exception e2 ) { 608 log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); 609 breakpRequest = null; 610 } 611 612 if (breakpRequest == null) { 613 log2(" A BREAKPOINT HAS NOT BEEN SET UP"); 614 throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); 615 } 616 617 log2(" a breakpoint has been set up"); 618 return breakpRequest; 619 } 620 621 getEventSet()622 private void getEventSet() 623 throws JDITestRuntimeException { 624 try { 625 // log2(" eventSet = eventQueue.remove(waitTime);"); 626 eventSet = eventQueue.remove(waitTime); 627 if (eventSet == null) { 628 throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); 629 } 630 // log2(" eventIterator = eventSet.eventIterator;"); 631 eventIterator = eventSet.eventIterator(); 632 } catch ( Exception e ) { 633 throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); 634 } 635 } 636 637 breakpointForCommunication()638 private void breakpointForCommunication() 639 throws JDITestRuntimeException { 640 641 log2("breakpointForCommunication"); 642 getEventSet(); 643 644 if (eventIterator.nextEvent() instanceof BreakpointEvent) 645 return; 646 647 throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); 648 } 649 650 // ============================== test's additional methods 651 settingAccessWatchpoint( ThreadReference thread, ReferenceType testedClass, String fieldName, String property)652 private AccessWatchpointRequest settingAccessWatchpoint ( 653 ThreadReference thread, 654 ReferenceType testedClass, 655 String fieldName, 656 String property) 657 throws JDITestRuntimeException { 658 659 log2("......setting up AccessWatchpoint:"); 660 log2(" thread: " + thread + "; class: " + testedClass + 661 "; fieldName: " + fieldName); 662 663 AccessWatchpointRequest awRequest = null; 664 try { 665 Field field = testedClass.fieldByName(fieldName); 666 awRequest = eventRManager.createAccessWatchpointRequest(field); 667 awRequest.putProperty("number", property); 668 awRequest.addThreadFilter(thread); 669 awRequest.setSuspendPolicy( EventRequest.SUSPEND_NONE); 670 } catch ( Exception e ) { 671 log3("ERROR: ATTENTION: Exception within settingAccessWatchpoint() : " + e); 672 log3(" AN ACCESSWATCHPOINT HAS NOT BEEN SET UP"); 673 throw new JDITestRuntimeException("** FAILURE to set up an AccessWatchpoint **"); 674 } 675 676 log2(" an AccessWatchpoint has been set up"); 677 return awRequest; 678 } 679 settingModificationWatchpoint( ThreadReference thread, ReferenceType testedClass, String fieldName, String property)680 private ModificationWatchpointRequest settingModificationWatchpoint ( 681 ThreadReference thread, 682 ReferenceType testedClass, 683 String fieldName, 684 String property) 685 throws JDITestRuntimeException { 686 687 log2("......setting up ModificationWatchpoint:"); 688 log2(" thread: " + thread + "; class: " + testedClass + 689 "; fieldName: " + fieldName); 690 691 ModificationWatchpointRequest mwRequest = null; 692 try { 693 Field field = testedClass.fieldByName(fieldName); 694 mwRequest = eventRManager.createModificationWatchpointRequest(field); 695 mwRequest.putProperty("number", property); 696 mwRequest.addThreadFilter(thread); 697 mwRequest.setSuspendPolicy( EventRequest.SUSPEND_NONE); 698 } catch ( Exception e ) { 699 log3("ERROR: ATTENTION: Exception within settingModificationWatchpoint() : " + e); 700 log3(" AN ModificationWATCHPOINT HAS NOT BEEN SET UP"); 701 throw new JDITestRuntimeException("** FAILURE to set up an AccessWatchpoint **"); 702 } 703 704 log2(" a ModificationWatchpoint has been set up"); 705 return mwRequest; 706 } 707 settingMethodEntry( ThreadReference thread, ReferenceType testedClass, String property)708 private MethodEntryRequest settingMethodEntry ( ThreadReference thread, 709 ReferenceType testedClass, 710 String property) 711 throws JDITestRuntimeException { 712 713 log2("......setting up MethodEntry:"); 714 log2(" thread: " + thread + "; class: " + testedClass + 715 "; property: " + property); 716 717 MethodEntryRequest menRequest = null; 718 try { 719 menRequest = eventRManager.createMethodEntryRequest(); 720 menRequest.putProperty("number", property); 721 menRequest.addThreadFilter(thread); 722 menRequest.addClassFilter(testedClass); 723 menRequest.setSuspendPolicy( EventRequest.SUSPEND_NONE); 724 } catch ( Exception e ) { 725 log3("ERROR: ATTENTION: Exception within settingMethodEntry() : " + e); 726 log3(" A MethodEntry HAS NOT BEEN SET UP"); 727 throw new JDITestRuntimeException("** FAILURE to set up a MethodEntry **"); 728 } 729 730 log2(" a MethodEntry has been set up"); 731 return menRequest; 732 } 733 settingMethodExit( ThreadReference thread, ReferenceType testedClass, String property)734 private MethodExitRequest settingMethodExit ( ThreadReference thread, 735 ReferenceType testedClass, 736 String property) 737 throws JDITestRuntimeException { 738 739 log2("......setting up MethodExit:"); 740 log2(" thread: " + thread + "; class: " + testedClass + 741 "; property: " + property); 742 743 MethodExitRequest mexRequest = null; 744 try { 745 mexRequest = eventRManager.createMethodExitRequest(); 746 mexRequest.putProperty("number", property); 747 mexRequest.addThreadFilter(thread); 748 mexRequest.addClassFilter(testedClass); 749 mexRequest.setSuspendPolicy( EventRequest.SUSPEND_NONE); 750 } catch ( Exception e ) { 751 log3("ERROR: ATTENTION: Exception within settingMethodExit() : " + e); 752 log3(" A MethodExit HAS NOT BEEN SET UP"); 753 throw new JDITestRuntimeException("** FAILURE to set up a MethodExit **"); 754 } 755 756 log2(" a MethodExit has been set up"); 757 return mexRequest; 758 } 759 settingStep( ThreadReference thread, String property)760 private StepRequest settingStep ( ThreadReference thread, String property) 761 throws JDITestRuntimeException { 762 763 log2("......setting up Step:"); 764 log2(" thread: " + thread + "; property: " + property); 765 766 StepRequest stRequest = null; 767 try { 768 stRequest = eventRManager.createStepRequest(thread, StepRequest.STEP_LINE, StepRequest.STEP_OVER); 769 stRequest.putProperty("number", property); 770 stRequest.addCountFilter(1); 771 stRequest.setSuspendPolicy( EventRequest.SUSPEND_NONE); 772 } catch ( Exception e ) { 773 log3("ERROR: ATTENTION: Exception within settingStep() : " + e); 774 log3(" A Step HAS NOT BEEN SET UP"); 775 throw new JDITestRuntimeException("** FAILURE to set up a Step **"); 776 } 777 778 log2(" a Step has been set up"); 779 return stRequest; 780 } 781 782 settingException( ThreadReference thread, ReferenceType testedClass, String property)783 private ExceptionRequest settingException ( ThreadReference thread, 784 ReferenceType testedClass, 785 String property) 786 throws JDITestRuntimeException { 787 788 log2("......setting up Exception:"); 789 log2(" thread: " + thread + "; class: " + testedClass + 790 "; property: " + property); 791 792 ExceptionRequest excRequest = null; 793 try { 794 excRequest = eventRManager.createExceptionRequest(null, true, true); 795 excRequest.putProperty("number", property); 796 excRequest.addThreadFilter(thread); 797 excRequest.addClassFilter(testedClass); 798 excRequest.setSuspendPolicy( EventRequest.SUSPEND_NONE); 799 } catch ( Exception e ) { 800 log3("ERROR: ATTENTION: Exception within settingException() : " + e); 801 log3(" A Exception HAS NOT BEEN SET UP"); 802 throw new JDITestRuntimeException("** FAILURE to set up a Exception **"); 803 } 804 805 log2(" a Exception has been set up"); 806 return excRequest; 807 } 808 809 } 810