KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gov > nasa > jpf > jvm > JPF_java_io_PrintStream$


1 //
2
// Copyright (C) 2005 United States Government as represented by the
3
// Administrator of the National Aeronautics and Space Administration
4
// (NASA). All Rights Reserved.
5
//
6
// This software is distributed under the NASA Open Source Agreement
7
// (NOSA), version 1.3. The NOSA has been approved by the Open Source
8
// Initiative. See the file NOSA-1.3-JPF at the top of the distribution
9
// directory tree for the complete NOSA document.
10
//
11
// THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
12
// KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
13
// LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
14
// SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
15
// A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
16
// THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
17
// DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
18
//
19
package gov.nasa.jpf.jvm;
20
21 import gov.nasa.jpf.JPFException;
22 import gov.nasa.jpf.jvm.bytecode.Instruction;
23
24
25 /**
26  * NativePeerDispatcher example (generated by GenPeerDispatcher)
27  */

28 class JPF_java_io_PrintStream$ extends NativePeer {
29   boolean isMethodCondDeterministic (ThreadInfo ti, MethodInfo mi) {
30     boolean ret = false;
31     int mid = mi.getUniqueName().hashCode();
32
33     MJIEnv env = ti.getMJIEnv();
34     int rThis = (mi.isStatic())
35                     ? ci.getClassObjectRef() : ti.getCalleeThis(mi);
36
37     env.setCallEnvironment(mi);
38
39     try {
40       switch (mid) {
41       default:
42         throw new JPFException("no isDeterministic() condition: " +
43                                  mi.getName());
44       }
45     } catch (Throwable JavaDoc x) {
46       x.printStackTrace();
47     }
48
49     return ret;
50   }
51
52   boolean isMethodCondExecutable (ThreadInfo ti, MethodInfo mi) {
53     boolean ret = false;
54     int mid = mi.getUniqueName().hashCode();
55
56     MJIEnv env = ti.getMJIEnv();
57     int rThis = (mi.isStatic())
58                     ? ci.getClassObjectRef() : ti.getCalleeThis(mi);
59
60     env.setCallEnvironment(mi);
61
62     try {
63       switch (mid) {
64       default:
65         throw new JPFException("no isExecutable() condition: " +
66                                  mi.getName());
67       }
68     } catch (Throwable JavaDoc x) {
69       x.printStackTrace();
70     }
71
72     return ret;
73   }
74
75   Instruction executeMethod (ThreadInfo ti, MethodInfo mi) {
76     int iret = 0;
77     long lret = 0;
78     int retSize = 0;
79     String JavaDoc exception = null;
80     int mid = mi.getUniqueName().hashCode();
81
82     MJIEnv env = ti.getMJIEnv();
83     int rThis = (mi.isStatic()) ? ci.getClassObjectRef() : ti.getCalleeThis(
84                                                                     mi);
85     env.setCallEnvironment(mi);
86
87     try {
88       switch (mid) {
89       case -1796256208: // println()
90
retSize = 0;
91         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.println__(env, rThis);
92
93         break;
94
95       case 628854628: // print(Ljava/lang/String;)
96
retSize = 0;
97         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.print__Ljava_lang_String_2(env,
98                                                                             rThis,
99                                                                             ti.peek(0));
100
101         break;
102
103       case 1440870566: // println(Ljava/lang/String;)
104
retSize = 0;
105         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.println__Ljava_lang_String_2(
106               env, rThis, ti.peek(0));
107
108         break;
109
110       case -1166388901: // print(I)
111
retSize = 0;
112         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.print__I(env, rThis,
113                                                           ti.peek(0));
114
115         break;
116
117       case 150633433: // println(I)
118
retSize = 0;
119         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.println__I(env, rThis,
120                                                             ti.peek(0));
121
122         break;
123
124       case -1166388994: // print(F)
125
retSize = 0;
126         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.print__F(env, rThis,
127                                                           Types.intToFloat(
128                                                                 ti.peek(0)));
129
130         break;
131
132       case 150633340: // println(F)
133
retSize = 0;
134         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.println__F(env, rThis,
135                                                             Types.intToFloat(
136                                                                   ti.peek(0)));
137
138         break;
139
140       case -1166388870: // print(J)
141
retSize = 0;
142         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.print__J(env, rThis,
143                                                           ti.longPeek(0));
144
145         break;
146
147       case 150633464: // println(J)
148
retSize = 0;
149         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.println__J(env, rThis,
150                                                             ti.longPeek(0));
151
152         break;
153
154       case -1166389056: // print(D)
155
retSize = 0;
156         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.print__D(env, rThis,
157                                                           Types.longToDouble(
158                                                                 ti.longPeek(0)));
159
160         break;
161
162       case 150633278: // println(D)
163
retSize = 0;
164         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.println__D(env, rThis,
165                                                             Types.longToDouble(
166                                                                   ti.longPeek(0)));
167
168         break;
169
170       case -1166388374: // print(Z)
171
retSize = 0;
172         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.print__Z(env, rThis,
173                                                           Types.intToBoolean(
174                                                                 ti.peek(0)));
175
176         break;
177
178       case 150633960: // println(Z)
179
retSize = 0;
180         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.println__Z(env, rThis,
181                                                             Types.intToBoolean(
182                                                                   ti.peek(0)));
183
184         break;
185
186       case 150633247: // println(C)
187
retSize = 0;
188         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.println__C(env, rThis,
189                                                             (char) ti.peek(0));
190
191         break;
192
193       case -1166389087: // print(C)
194
retSize = 0;
195         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.print__C(env, rThis,
196                                                           (char) ti.peek(0));
197
198         break;
199
200       case 754558870: // write(Ljava/lang/String;)
201
retSize = 0;
202         gov.nasa.jpf.jvm.JPF_java_io_PrintStream.write__Ljava_lang_String_2(env,
203                                                                             rThis,
204                                                                             ti.peek(0));
205
206         break;
207
208       default:
209         return ti.createAndThrowException("java.lang.UnsatisfiedLinkError",
210                                           "cannot find: " + ci.getName() +
211                                           '.' + mi.getName());
212       }
213     } catch (Throwable JavaDoc x) {
214       x.printStackTrace();
215
216       return ti.createAndThrowException(
217                    "java.lang.reflect.InvocationTargetException",
218                    ci.getName() + '.' + mi.getName());
219     }
220
221     if ((exception = env.getException()) != null) {
222       return ti.createAndThrowException(exception);
223     }
224
225     if (env.getRepeat()) {
226       return ti.getPC();
227     }
228
229     ti.removeArguments(mi);
230
231     switch (retSize) {
232     case 0:
233       break; // nothing to return
234

235     case 1:
236       ti.push(iret, mi.isReferenceReturnType());
237
238       break;
239
240     case 2:
241       ti.longPush(lret);
242
243       break;
244     }
245
246     return ti.getPC().getNext();
247   }
248 }
Popular Tags