A clean implementation for getTypeParameters' native method version.
[jpf-core.git] / src / peers / gov / nasa / jpf / vm / JPF_gov_nasa_jpf_ConsoleOutputStream.java
1 /*
2  * Copyright (C) 2014, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The Java Pathfinder core (jpf-core) platform is licensed under the
7  * Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  * 
10  *        http://www.apache.org/licenses/LICENSE-2.0. 
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and 
16  * limitations under the License.
17  */
18 package gov.nasa.jpf.vm;
19
20 import gov.nasa.jpf.annotation.MJI;
21 import gov.nasa.jpf.vm.MJIEnv;
22 import gov.nasa.jpf.vm.NativePeer;
23
24 /**
25  * MJI NativePeer class to intercept all System.out and System.err
26  * printing. We handle all of this native, since it's already slow enough
27  */
28 public class JPF_gov_nasa_jpf_ConsoleOutputStream extends NativePeer {
29   
30   /****************************************************************************
31    * these are the native methods we intercept
32    */
33
34   @MJI
35   public void $init____V (MJIEnv env, int objref) {
36     // that's just a dummy because we have no OutputStream, which would cause
37     // an exception in the PrintStream ctor
38   }
39   
40   @MJI
41   public void print__C__V (MJIEnv env, int objref, char c) {
42     env.getVM().print(c);
43   }
44
45   @MJI
46   public void print__D__V (MJIEnv env, int objref, double d) {
47     env.getVM().print(d);
48   }
49
50   @MJI
51   public void print__F__V (MJIEnv env, int objref, float f) {
52     env.getVM().print(f);
53   }
54
55   @MJI
56   public void print__I__V (MJIEnv env, int objref, int i) {
57     env.getVM().print(i);
58   }
59
60   @MJI
61   public void print__J__V (MJIEnv env, int objref, long j) {
62     env.getVM().print(j);
63   }
64
65   @MJI
66   public void print__Ljava_lang_String_2__V (MJIEnv env, int objRef,
67                                                  int strRef) {
68     env.getVM().print(env.getStringObject(strRef));
69   }
70
71   @MJI
72   public void print__Z__V (MJIEnv env, int objref, boolean z) {
73     env.getVM().print(z);
74   }
75
76   @MJI
77   public void println____V (MJIEnv env, int objRef) {
78     env.getVM().println();
79   }
80
81   @MJI
82   public void println__C__V (MJIEnv env, int objref, char c) {
83     env.getVM().print(c);
84     env.getVM().println();
85   }
86
87   @MJI
88   public void println__D__V (MJIEnv env, int objref, double d) {
89     env.getVM().print(d);
90     env.getVM().println();
91   }
92
93   @MJI
94   public void println__F__V (MJIEnv env, int objref, float f) {
95     env.getVM().print(f);
96     env.getVM().println();
97   }
98
99   @MJI
100   public void println__I__V (MJIEnv env, int objref, int i) {
101     env.getVM().print(i);
102     env.getVM().println();
103   }
104
105   @MJI
106   public void println__J__V (MJIEnv env, int objref, long j) {
107     env.getVM().print(j);
108     env.getVM().println();
109   }
110
111   @MJI
112   public void println__Ljava_lang_String_2__V (MJIEnv env, int objRef,
113                                                    int strRef) {
114     env.getVM().println(env.getStringObject(strRef));
115   }
116
117   @MJI
118   public void write__I__V (MJIEnv env, int objRef, int b){
119     env.getVM().print((char)(byte)b);
120   }
121   
122   @MJI
123   public void write___3BII__V (MJIEnv env, int objRef,
124                                       int bufRef, int off, int len){
125     
126   }
127
128   @MJI
129   public void println__Z__V (MJIEnv env, int objref, boolean z) {
130     env.getVM().print(z);
131     env.getVM().println();
132   }
133
134   @MJI
135   public int printf__Ljava_lang_String_2_3Ljava_lang_Object_2__Ljava_io_PrintStream_2
136                    (MJIEnv env, int objref, int fmtRef, int argRef) {
137     env.getVM().print(env.format(fmtRef,argRef));
138     return objref;
139   }
140   
141 }