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 /**
20  * @author Anton V. Karnachuk
21  */
22 
23 /**
24  * Created on 11.04.2005
25  */
26 package org.apache.harmony.jpda.tests.jdwp.Events;
27 
28 import java.io.File;
29 
30 import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
31 import org.apache.harmony.jpda.tests.share.SyncDebuggee;
32 
33 /**
34  * Debuggee for FieldAccessTest and FieldModified unit tests.
35  * Provides access and modification of testIntField field.
36  */
37 public class FieldModification002Debuggee extends SyncDebuggee {
38 
main(String[] args)39     public static void main(String[] args) {
40         runDebuggee(FieldModification002Debuggee.class);
41     }
42 
43     public boolean testBoolField = false;
44     public byte testByteField = 0;
45     public char testCharField = 0;
46     public short testShortField = 0;
47     public int testIntField = 0;
48     public long testLongField = 0;
49     public float testFloatField = 0;
50     public double testDoubleField = 0;
51     public Object testObjectField = null;
52     public Object testThreadField = null;
53     public Object testThreadGroupField = null;
54     public Object testClassField = null;
55     public Object testClassLoaderField = null;
56     public Object testStringField = null;
57     public int [] testIntArrayField = null;
58     public String [] testStringArrayField = null;
59     public Object [] testObjectArrayField = null;
60 
61     /**
62      * This debuggee accesses all class fields and synchronizes with debugger.
63      */
run()64     public void run() {
65 
66         synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
67         logWriter.println("FieldDebuggee started");
68 
69         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
70         testBoolField = true;
71 
72         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
73         testByteField = 'k';
74 
75         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
76         testCharField = 'Q';
77 
78         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
79         testShortField = 127;
80 
81         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
82         testIntField = -1001;
83 
84         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
85         testLongField = 4000000000000000L;
86 
87         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
88         testFloatField = 100*100*100;
89 
90         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
91         testDoubleField = -1.1/100000.999999;
92 
93         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
94         testObjectField = new File("none");
95 
96         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
97         testThreadField = new Thread("myThread001");
98 
99         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
100         testThreadGroupField = new ThreadGroup("MyThreadGroup_000001");
101 
102         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
103         testClassField = System.out.getClass();
104 
105         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
106         testClassLoaderField = this.getClass().getClassLoader();
107 
108         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
109         testStringField = "String=Strong=Strung";
110 
111         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
112         testIntArrayField = new int [] { 1, 2, 3, };
113 
114         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
115         testStringArrayField = new String[] { "abc", "xyz", };
116 
117         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
118         testObjectArrayField = new Object[] { null, null, null, new Long(99), "objobjobj", };
119 
120         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
121         logWriter.println("FieldDebuggee finished");
122     }
123 }
124