Home | History | Annotate | Download | only in Events
      1 /*
      2  * Licensed to the Apache Software Foundation (ASF) under one or more
      3  * contributor license agreements.  See the NOTICE file distributed with
      4  * this work for additional information regarding copyright ownership.
      5  * The ASF licenses this file to You under the Apache License, Version 2.0
      6  * (the "License"); you may not use this file except in compliance with
      7  * the License.  You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *
     15  *  See the License for the specific language governing permissions and
     16  *  limitations under the License.
     17  */
     18 
     19 package org.apache.harmony.jpda.tests.jdwp.Events;
     20 
     21 import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
     22 import org.apache.harmony.jpda.tests.share.SyncDebuggee;
     23 
     24 /**
     25  * Debuggee for Breakpoint002Test unit test.
     26  */
     27 public class Breakpoint002Debuggee extends SyncDebuggee {
     28 
     29     int mIntField = 5;
     30     long mLongField = 5l;
     31     Object mObjectField = "this is an object field";
     32 
     33     private void breakpointReturnVoid() {
     34       return;
     35     }
     36 
     37     private int breakpointReturnIntConst() {
     38       return 1;
     39     }
     40 
     41     private long breakpointReturnLongConst() {
     42       return 1l;
     43     }
     44 
     45     private int breakpointReturnIntArg(int arg) {
     46       return arg;
     47     }
     48 
     49     private long breakpointReturnLongArg(long arg) {
     50       return arg;
     51     }
     52 
     53     private Object breakpointReturnObjectArg(Object arg) {
     54       return arg;
     55     }
     56 
     57     private int breakpointIntGetter() {
     58       return mIntField;
     59     }
     60 
     61     private long breakpointLongGetter() {
     62       return mLongField;
     63     }
     64 
     65     private Object breakpointObjectGetter() {
     66       return mObjectField;
     67     }
     68 
     69     private void breakpointIntSetter(int val) {
     70       mIntField = val;
     71     }
     72 
     73     private void breakpointLongSetter(long val) {
     74       mLongField = val;
     75     }
     76 
     77     private void breakpointObjectSetter(Object val) {
     78       mObjectField = val;
     79     }
     80 
     81     private void callSmallMethods() {
     82       logWriter.println("Calling breakpointReturnVoid");
     83       breakpointReturnVoid();
     84 
     85       logWriter.println("Calling breakpointReturnIntConst");
     86       int intConstant = breakpointReturnIntConst();
     87       logWriter.println("intConstant = " + intConstant);
     88 
     89       logWriter.println("Calling breakpointReturnLongConst");
     90       long longConstant = breakpointReturnLongConst();
     91       logWriter.println("longConstant = " + longConstant);
     92 
     93       logWriter.println("Calling breakpointReturnIntArg");
     94       int intArg = breakpointReturnIntArg(5);
     95       logWriter.println("intArg = " + intArg);
     96 
     97       logWriter.println("Calling breakpointReturnLongArg");
     98       long longArg = breakpointReturnLongArg(5l);
     99       logWriter.println("longArg = " + longArg);
    100 
    101       logWriter.println("Calling breakpointReturnLongArg");
    102       Object objectArg = breakpointReturnObjectArg("this is a string argument");
    103       logWriter.println("objectArg = " + objectArg);
    104 
    105       logWriter.println("Calling breakpointIntGetter");
    106       int intField = breakpointIntGetter();
    107       logWriter.println("mIntField = " + intField);
    108 
    109       logWriter.println("Calling breakpointLongGetter");
    110       long longField = breakpointLongGetter();
    111       logWriter.println("mLongField = " + longField);
    112 
    113       logWriter.println("Calling breakpointObjectGetter");
    114       Object objectField = breakpointObjectGetter();
    115       logWriter.println("mObjectField = " + objectField);
    116 
    117       logWriter.println("Calling breakpointIntSetter");
    118       breakpointIntSetter(10);
    119 
    120       logWriter.println("Calling breakpointLongGetter");
    121       breakpointLongSetter(10l);
    122 
    123       logWriter.println("Calling breakpointObjectSetter");
    124       breakpointObjectSetter("this is a new object field value");
    125     }
    126 
    127     public void run() {
    128         synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
    129 
    130         logWriter.println("Breakpoint002Debuggee started");
    131 
    132         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
    133 
    134         callSmallMethods();
    135 
    136         logWriter.println("Breakpoint002Debuggee finished");
    137     }
    138 
    139     public static void main(String[] args) {
    140         runDebuggee(Breakpoint002Debuggee.class);
    141     }
    142 
    143 }
    144