2003/02/22 03:53:09
[org.ibex.core.git] / README
1 ==============================================================================
2 XWT README
3               
4 ______________________________________________________________________________
5 Documentation
6
7 If you're new to XWT, you should read the documentation in the order
8 presented below:
9
10 - README [this file]
11
12       Start here. Includes a map of all other documentation and a
13       description of the directory strucure
14
15 - The XWT home page [http://www.xwt.org/]
16
17 - The XWT tutorial [http://www.xwt.org/tutorial.html]
18
19       Gentle introduction to what XWT is, and how to write
20       .xwt's. Good for anybody who wants to write XWT applications.
21
22 - The XWT reference [http://www.xwt.org/reference.html]
23
24       Precise, technical spec of exactly how XWT works. Assumes
25       familiarity with XWT (ie, you've read the tutorial). This is the
26       authoritative source for how an XWT engine should
27       behave.
28
29
30 ______________________________________________________________________________
31 Directory Structure
32
33 /
34    AUTHORS               - people involved in developing XWT
35    README                - this file
36    COPYING               - copyright information for all files in this distro
37    TM                    - trademark information for XWT
38    ant                   - a unix shell script to launch ant
39    bin/                  - all binary stuff generated by ant builds
40
41    build.xml             - ANT build file
42    Makefile              - build file for gcc 3.3
43
44    lib/                  - any third-party binary stuff needed during the build process
45        javago            - a copy of the javago post-compilation bytecode inliner
46        ant.jar           - the Jakarta project's ANT build tool, including Sun's XML parser
47        netscape.jar      - minimal set of classes required for compiling against Netcape's Applet interfaces
48        msjvm.jar         - minimal set of classes required for compiling against Microsoft's Applet interfaces
49        javasrc.jar       - javasrc, a tool for generating hyperlinked, syntax-colored html from java code
50
51    src/                  - all java source files and xwt sources go here
52        org/
53            bouncycastle/ - the BouncyCastle Crypto Library
54            mozilla/      - a copy of Rhino, the Mozilla JavaScript interpreter
55            xwt/builtin/  - .xwt's and .png's that are essential to bootstrapping the engine
56            xwt/plat/     - platform-specific code
57
58 ______________________________________________________________________________
59 Build Targets
60
61         *** XWT now requires JDK 1.4 or later to build ***
62
63 To build, make sure your $JAVA_HOME points to jdk1.4 or later, and type
64
65     ./ant -Dplat=<platform> <targetname>
66
67 The name of any class in org.xwt.plat is a valid <platform>; here is a
68 list as of 20-Mar-2002:
69
70     Win32         - Windows 95 / NT4 or later
71     Java12        - Any Java 1.2+ compliant JVM
72
73 Valid <target>s are:
74
75     build         - builds a binary for the selected platform
76
77 The following targets do not require that you specify a platform:
78
79     compile       - compiles all .java's to .class'es
80     clean         - empties bin/ and compiled binaries in dist/
81
82
83 ______________________________________________________________________________
84 Building
85
86 - WARNING: Jikes 1.16 has a bug which will cause it to generate
87   corrupt .class files; you must downgrade to 1.15 in order to compile
88   XWT.
89
90 - If you only want to build the JVM version of XWT, delete these three
91   files:
92
93     xwt/src/org/xwt/plat/Win32.java
94     xwt/src/org/xwt/plat/POSIX.java
95     xwt/src/org/xwt/plat/GCJ.java
96
97   This will allow XWT to build correctly *without* gcc 3.1. Otherwise,
98   you must compile and install gcc 3.1.
99
100 - The Win32 native version of XWT can ONLY be built with the very
101   latest pre-release of GCC 3.3.  Run "make gcc-lin" to build a gcc
102   3.3 that targets Linux; run "make gcc-win" to build a gcc 3.3 that
103   targets Win32.
104
105
106
107 ______________________________________________________________________________
108 inet_addr patch
109
110 Index: java/net/natInetAddress.cc
111 ===================================================================
112 RCS file: /cvs/gcc/gcc/libjava/java/net/natInetAddress.cc,v
113 retrieving revision 1.18.18.1
114 diff -u -r1.18.18.1 natInetAddress.cc
115 --- java/net/natInetAddress.cc  4 Mar 2002 20:02:19 -0000       1.18.18.1
116 +++ java/net/natInetAddress.cc  27 May 2002 22:54:40 -0000
117 @@ -9,6 +9,7 @@
118  details.  */
119
120  #include <config.h>
121 +#include <platform.h>
122
123  #ifdef WIN32
124
125 Index: include/win32.h
126 ===================================================================
127 RCS file: /cvs/gcc/gcc/libjava/include/win32.h,v
128 retrieving revision 1.3.8.5
129 diff -u -r1.3.8.5 win32.h
130 --- include/win32.h     24 Apr 2002 01:04:45 -0000      1.3.8.5
131 +++ include/win32.h     27 May 2002 22:54:40 -0000
132 @@ -35,4 +35,8 @@
133     ARRAY and return the exact number of values stored.  */
134  extern int backtrace (void **__array, int __size);
135
136 +// configure cannot correctly detect inet_addr due to Win32's
137 +// oddball header naming scheme
138 +#define HAVE_INET_ADDR
139 +
140  #endif /* __JV_WIN32_H__ */
141
142
143
144 ______________________________________________________________________________
145 Throwable.printStackTrace() patch
146
147 Index: Class.h
148 ===================================================================
149 RCS file: /cvs/gcc/gcc/libjava/java/lang/Class.h,v
150 retrieving revision 1.43
151 diff -u -r1.43 Class.h
152 --- Class.h     21 Dec 2001 19:47:50 -0000      1.43
153 +++ Class.h     24 Apr 2002 03:06:14 -0000
154 @@ -308,6 +308,7 @@
155    friend void _Jv_LayoutVTableMethods (jclass klass);
156    friend void _Jv_SetVTableEntries (jclass, _Jv_VTable *);
157    friend void _Jv_MakeVTable (jclass);
158 +  friend JArray<java::lang::reflect::Method*>* _Jv_GetAllMethods();
159  
160    // Return array class corresponding to element type KLASS, creating it if
161    // necessary.
162 Index: ClassLoader.java
163 ===================================================================
164 RCS file: /cvs/gcc/gcc/libjava/java/lang/ClassLoader.java,v
165 retrieving revision 1.16
166 diff -u -r1.16 ClassLoader.java
167 --- ClassLoader.java    7 Dec 2001 23:34:12 -0000       1.16
168 +++ ClassLoader.java    24 Apr 2002 03:06:14 -0000
169 @@ -577,4 +577,8 @@
170      // Default to returning null.  Derived classes implement this.
171      return null;
172    }
173 +
174 +  static native java.lang.reflect.Method[] getAllMethods();
175 +  static native long[] getAllMethodAddrs();
176 +
177  }
178 Index: Throwable.java
179 ===================================================================
180 RCS file: /cvs/gcc/gcc/libjava/java/lang/Throwable.java,v
181 retrieving revision 1.10
182 diff -u -r1.10 Throwable.java
183 --- Throwable.java      24 Feb 2001 03:52:49 -0000      1.10
184 +++ Throwable.java      24 Apr 2002 03:06:14 -0000
185 @@ -123,21 +123,64 @@
186      printStackTrace (writer);
187    }
188  
189 +  private native static long longFromStackTraceBytes(byte[] stackTrace, int i);
190 +
191    public void printStackTrace (PrintWriter wr)
192    {
193 -    try
194 -      {
195 -       CPlusPlusDemangler cPlusPlusFilter = new CPlusPlusDemangler (wr);
196 -       PrintWriter writer = new PrintWriter (cPlusPlusFilter);
197 -       printRawStackTrace (writer);    
198 -       writer.close ();
199 -       if (cPlusPlusFilter.written == 0) // The demangler has failed...
200 -         printRawStackTrace (wr);
201 +      try
202 +          {
203 +              CPlusPlusDemangler cPlusPlusFilter = new CPlusPlusDemangler (wr);
204 +              PrintWriter writer = new PrintWriter (cPlusPlusFilter);
205 +              printRawStackTrace (writer);     
206 +              writer.close ();
207 +              if (cPlusPlusFilter.written > 0) return;
208 +          }
209 +      catch (Exception e1)
210 +          {
211 +          }
212 +
213 +      wr.println(toString());
214 +      if (stackTrace == null) {
215 +          wr.flush();
216 +          return;
217        }
218 -    catch (Exception e1)
219 -      {
220 -       printRawStackTrace (wr);
221 +      
222 +      long[] allAddrs = ClassLoader.getAllMethodAddrs();
223 +      java.lang.reflect.Method[] meths = ClassLoader.getAllMethods();
224 +      
225 +      // FIXME: assumes little endian
226 +      for(int i=0; i<stackTrace.length; i++) {
227 +          long addr = longFromStackTraceBytes(stackTrace, i);
228 +          if (addr == 0) break;
229 +          
230 +          int whichMethod = -1;
231 +          for(int j=0; j<allAddrs.length; j++) {
232 +              if (allAddrs[j] <= addr &&
233 +                  (whichMethod == -1 || allAddrs[whichMethod] < allAddrs[j])) {
234 +                  whichMethod = j;
235 +              }
236 +          }
237 +          
238 +          if (whichMethod == -1) {
239 +              wr.println("[" + Long.toString(addr, 16) + "]  " + "??");
240 +              continue;
241 +          }
242 +          
243 +          if (meths[whichMethod].getDeclaringClass().getName().equals("gnu.gcj.runtime.FirstThread") &&
244 +              meths[whichMethod].getName().equals("call_main"))
245 +              break;
246 +          
247 +          wr.println("    [" + Long.toString(addr, 16) + "] " +
248 +                     meths[whichMethod].getDeclaringClass().getName() + "." +
249 +                     meths[whichMethod].getName() + "() " +
250 +                     "+" + (addr - allAddrs[whichMethod])
251 +                     );
252 +          
253 +          if (java.lang.Thread.class.isAssignableFrom(meths[whichMethod].getDeclaringClass()) &&
254 +              meths[whichMethod].getName().equals("run"))
255 +              break;
256        }
257 +      wr.flush();
258    }
259  
260    public Throwable ()
261 Index: natClassLoader.cc
262 ===================================================================
263 RCS file: /cvs/gcc/gcc/libjava/java/lang/natClassLoader.cc,v
264 retrieving revision 1.47.8.1
265 diff -u -r1.47.8.1 natClassLoader.cc
266 --- natClassLoader.cc   2 Apr 2002 22:19:55 -0000       1.47.8.1
267 +++ natClassLoader.cc   24 Apr 2002 03:06:14 -0000
268 @@ -40,6 +40,10 @@
269  #include <java/lang/StringBuffer.h>
270  #include <java/io/Serializable.h>
271  #include <java/lang/Cloneable.h>
272 +#include <java/lang/reflect/Method.h>
273 +
274 +#include<java/lang/reflect/Constructor.h>
275 +#include<gcj/method.h>
276  
277  // FIXME: remove these.
278  #define CloneableClass java::lang::Cloneable::class$
279 @@ -347,6 +351,50 @@
280  static jclass loaded_classes[HASH_LEN];
281  
282  // This is the root of a linked list of classes
283 +
284 +JArray<java::lang::reflect::Method*>*
285 +java::lang::ClassLoader::getAllMethods()
286 +{
287 +    return _Jv_GetAllMethods();
288 +}
289 +
290 +JArray<jlong>*
291 +java::lang::ClassLoader::getAllMethodAddrs()
292 +{
293 +    JArray<java::lang::reflect::Method*>* arr = _Jv_GetAllMethods();
294 +    java::lang::reflect::Method** el = (java::lang::reflect::Method**)elements(arr);
295 +    JArray<jlong>* ret = JvNewLongArray(arr->length);
296 +    jlong* retel = (jlong*)elements(ret);
297 +    for(int i=0; i<arr->length; i++)
298 +        retel[i] = (jlong)((unsigned int)(_Jv_FromReflectedMethod (el[i])->ncode));
299 +    return ret;
300 +}
301 +
302 +JArray<java::lang::reflect::Method*>*
303 +_Jv_GetAllMethods()
304 +{
305 +  int numMethods = 0;
306 +
307 +  for(int i=0; i<HASH_LEN; i++)
308 +      for(jclass c = loaded_classes[i]; c; c = c->next)
309 +          numMethods += c->getDeclaredMethods()->length;
310 +
311 +  JArray<java::lang::reflect::Method*>* ret =
312 +    (JArray<java::lang::reflect::Method*>*)
313 +    JvNewObjectArray(numMethods, &java::lang::reflect::Method::class$, NULL);
314 +
315 +  java::lang::reflect::Method** el = (java::lang::reflect::Method**)elements(ret);
316 +
317 +  for(int i=0; i<HASH_LEN; i++)
318 +      for(jclass c = loaded_classes[i]; c; c = c->next) {
319 +          JArray<java::lang::reflect::Method*>* methods = c->getDeclaredMethods();
320 +          jint len = methods->length;
321 +          java::lang::reflect::Method** meths = (java::lang::reflect::Method**)elements(methods);
322 +          for(int j=0; j<len; j++) el[--numMethods] = meths[j];
323 +      }
324 +
325 +  return ret;
326 +}
327  
328  \f
329  
330 Index: natThrowable.cc
331 ===================================================================
332 RCS file: /cvs/gcc/gcc/libjava/java/lang/natThrowable.cc,v
333 retrieving revision 1.11
334 diff -u -r1.11 natThrowable.cc
335 --- natThrowable.cc     7 Feb 2002 19:26:06 -0000       1.11
336 +++ natThrowable.cc     24 Apr 2002 03:06:14 -0000
337 @@ -32,6 +32,7 @@
338  #include <stdio.h>
339  
340  #include <unistd.h>
341 +#include <platform.h>
342  
343  #ifdef HAVE_EXECINFO_H
344  #include <execinfo.h>
345 @@ -102,3 +103,18 @@
346  #endif /* HAVE_BACKTRACE */
347    wr->flush ();
348  }
349 +
350 +// Returns the i^th call address in the stackTrace member, or 0 if i
351 +// is beyond the end of the trace. This has to be done in C++ because
352 +// the addresses in stackTrace are the same width as the platform's
353 +// pointers (which is unknown to Java code), and stackTrace is a
354 +// byte[] using the platform's endianness (which is unknown to Java
355 +// code).
356 +jlong
357 +java::lang::Throwable::longFromStackTraceBytes(jbyteArray stackArr, jint i)
358 +{
359 +    if (i * sizeof(void*) > stackArr->length) return 0;
360 +    unsigned int* stack = (unsigned int*)elements(stackArr);
361 +    return (jlong)stack[i];
362 +}
363 +
364
365
366
367
368