2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
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
10 * http://www.apache.org/licenses/LICENSE-2.0.
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.
18 package gov.nasa.jpf.vm;
20 import gov.nasa.jpf.annotation.MJI;
21 import gov.nasa.jpf.vm.MJIEnv;
22 import gov.nasa.jpf.vm.NativePeer;
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
28 public class JPF_gov_nasa_jpf_ConsoleOutputStream extends NativePeer {
30 /****************************************************************************
31 * these are the native methods we intercept
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
41 public void print__C__V (MJIEnv env, int objref, char c) {
46 public void print__D__V (MJIEnv env, int objref, double d) {
51 public void print__F__V (MJIEnv env, int objref, float f) {
56 public void print__I__V (MJIEnv env, int objref, int i) {
61 public void print__J__V (MJIEnv env, int objref, long j) {
66 public void print__Ljava_lang_String_2__V (MJIEnv env, int objRef,
68 env.getVM().print(env.getStringObject(strRef));
72 public void print__Z__V (MJIEnv env, int objref, boolean z) {
77 public void println____V (MJIEnv env, int objRef) {
78 env.getVM().println();
82 public void println__C__V (MJIEnv env, int objref, char c) {
84 env.getVM().println();
88 public void println__D__V (MJIEnv env, int objref, double d) {
90 env.getVM().println();
94 public void println__F__V (MJIEnv env, int objref, float f) {
96 env.getVM().println();
100 public void println__I__V (MJIEnv env, int objref, int i) {
101 env.getVM().print(i);
102 env.getVM().println();
106 public void println__J__V (MJIEnv env, int objref, long j) {
107 env.getVM().print(j);
108 env.getVM().println();
112 public void println__Ljava_lang_String_2__V (MJIEnv env, int objRef,
114 env.getVM().println(env.getStringObject(strRef));
118 public void write__I__V (MJIEnv env, int objRef, int b){
119 env.getVM().print((char)(byte)b);
123 public void write___3BII__V (MJIEnv env, int objRef,
124 int bufRef, int off, int len){
129 public void println__Z__V (MJIEnv env, int objref, boolean z) {
130 env.getVM().print(z);
131 env.getVM().println();
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));