Source Code Cross Referenced for JPF_java_lang_System.java in  » Code-Analyzer » javapathfinder » gov » nasa » jpf » jvm » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » javapathfinder » gov.nasa.jpf.jvm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        // Copyright (C) 2005 United States Government as represented by the
003:        // Administrator of the National Aeronautics and Space Administration
004:        // (NASA).  All Rights Reserved.
005:        // 
006:        // This software is distributed under the NASA Open Source Agreement
007:        // (NOSA), version 1.3.  The NOSA has been approved by the Open Source
008:        // Initiative.  See the file NOSA-1.3-JPF at the top of the distribution
009:        // directory tree for the complete NOSA document.
010:        // 
011:        // THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
012:        // KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
013:        // LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
014:        // SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
015:        // A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
016:        // THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
017:        // DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
018:        //
019:        package gov.nasa.jpf.jvm;
020:
021:        /**
022:         * MJI NativePeer class for java.lang.System library abstraction
023:         */
024:        public class JPF_java_lang_System {
025:            public static void setErr0(MJIEnv env, int clsObjRef, int streamRef) {
026:                env.setStaticIntField("java.lang.System", "err", streamRef);
027:            }
028:
029:            public static void setIn0(MJIEnv env, int clsObjRef, int streamRef) {
030:                env.setStaticIntField("java.lang.System", "in", streamRef);
031:            }
032:
033:            public static void setOut0(MJIEnv env, int clsObjRef, int streamRef) {
034:                env.setStaticIntField("java.lang.System", "out", streamRef);
035:            }
036:
037:            public static void $clinit(MJIEnv env, int clsObjRef) {
038:                env.setStaticReferenceField("java.lang.System", "out", env
039:                        .newObject("java.io.PrintStream"));
040:                env.setStaticReferenceField("java.lang.System", "err", env
041:                        .newObject("java.io.PrintStream"));
042:            }
043:
044:            // <2do> - now this baby really needs to be fixed. Imagine what it
045:            // does to an app that works with large vectors
046:            public static void arraycopy(MJIEnv env, int clsObjRef,
047:                    int srcArrayRef, int srcIdx, int dstArrayRef, int dstIdx,
048:                    int length) {
049:                int i;
050:
051:                if ((srcArrayRef == -1) || (dstArrayRef == -1)) {
052:                    env.throwException("java.lang.NullPointerException");
053:
054:                    return;
055:                }
056:
057:                if (!env.isArray(srcArrayRef) || !env.isArray(dstArrayRef)) {
058:                    env.throwException("java.lang.ArrayStoreException");
059:
060:                    return;
061:                }
062:
063:                int sts = env.getArrayTypeSize(srcArrayRef);
064:                int dts = env.getArrayTypeSize(dstArrayRef);
065:
066:                if (sts != dts) {
067:                    // not enough, real thing checks types !!
068:                    env.throwException("java.lang.ArrayStoreException");
069:
070:                    return;
071:                }
072:
073:                // ARGHH <2do> pcm - at some point, we should REALLY do this with a block
074:                // operation (saves lots of state, speed if arraycopy is really used)
075:                // we could also use the native checks in that case
076:                int sl = env.getArrayLength(srcArrayRef);
077:                int dl = env.getArrayLength(dstArrayRef);
078:
079:                // <2do> - we need detail messages!
080:                if ((srcIdx < 0) || ((srcIdx + length) > sl)) {
081:                    env
082:                            .throwException("java.lang.ArrayIndexOutOfBoundsException");
083:
084:                    return;
085:                }
086:
087:                if ((dstIdx < 0) || ((dstIdx + length) > dl)) {
088:                    env
089:                            .throwException("java.lang.ArrayIndexOutOfBoundsException");
090:
091:                    return;
092:                }
093:
094:                if (sts == 1) {
095:                    for (i = 0; i < length; i++, srcIdx++, dstIdx++) {
096:                        int v = env.getIntArrayElement(srcArrayRef, srcIdx);
097:                        env.setIntArrayElement(dstArrayRef, dstIdx, v);
098:                    }
099:                } else {
100:                    for (i = 0; i < length; i++, srcIdx++, dstIdx++) {
101:                        long v = env.getLongArrayElement(srcArrayRef, srcIdx);
102:                        env.setLongArrayElement(dstArrayRef, dstIdx, v);
103:                    }
104:                }
105:            }
106:
107:            // <2do> - this break every app which uses time delta thresholds
108:            // (sort of "if ((t2 - t1) > d)"). Ok, we can't deal with
109:            // real time, but we could at least give some SystemState dependent
110:            // increment
111:            public static long currentTimeMillis(MJIEnv env, int clsObjRef) {
112:                return 1L;
113:            }
114:
115:            // <2do> - now this implementation is dangerous if it's called from
116:            // a context where we have subsequent unchecked stack frame access
117:            // (the bytecodes). We better choose a 'exit' flag instead of
118:            // this stack suicide
119:            public static void exit(MJIEnv env, int clsObjRef, int ret) {
120:                KernelState ks = env.getKernelState();
121:                int length = ks.tl.length();
122:
123:                for (int i = 0; i < length; i++) {
124:                    ThreadInfo ti = ks.tl.get(i);
125:
126:                    while (ti.countStackFrames() > 0) {
127:                        ti.popFrame();
128:                    }
129:                }
130:            }
131:
132:            public static void gc(MJIEnv env, int clsObjRef) {
133:                env.getSystemState().activateGC();
134:            }
135:
136:            public static int identityHashCode(MJIEnv env, int clsObjRef,
137:                    int objref) {
138:                return (objref ^ 0xABCD);
139:            }
140:
141:            public static void registerNatives(MJIEnv env, int clsObjRef) {
142:                // ignore
143:            }
144:
145:            /**
146:             * <2do> pcm - replace this with a fixed set of system properties
147:             */
148:            public static int getProperty__Ljava_lang_String_2(MJIEnv env,
149:                    int clsObjRef, int keyRef) {
150:                int r = MJIEnv.NULL;
151:
152:                if (keyRef != MJIEnv.NULL) {
153:                    String k = env.getStringObject(keyRef);
154:                    String v = System.getProperty(k);
155:                    if (v != null) {
156:                        r = env.newString(v);
157:                    }
158:                }
159:
160:                return r;
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.