2002/07/01 19:45:32
[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 - Javadoc [http://www.xwt.org/javadoc/]
30
31       The org.xwt.* packages are all documented with javadoc. You
32       should start by reading the package summary for org.xwt.Main,
33       and work your way around from there.
34
35 - Javasrc [http://www.xwt.org/javasrc]
36
37       Javasrc generates a syntax-colored and hyperlinked html copy of
38       the XWT source code.
39
40
41 ______________________________________________________________________________
42 Directory Structure
43
44 /
45    README                - this file
46    COPYING               - copyright information for all files in this distro
47    TM                    - trademark information for XWT
48    ant                   - a unix shell script to launch ant
49    bin/                  - all binary stuff generated by ant builds
50    build.xml             - ANT build file
51
52    lib/                  - any third-party binary stuff needed during the build process
53        javago            - a copy of the javago post-compilation bytecode inliner
54        ant.jar           - the Jakarta project's ANT build tool, including Sun's XML parser
55        netscape.jar      - minimal set of classes required for compiling against Netcape's Applet interfaces
56        msjvm.jar         - minimal set of classes required for compiling against Microsoft's Applet interfaces
57        signtool          - the Netscape Object Signing tool, for signing applets
58        signcode.exe      - the Microsoft ActiveX Signing tool, for signing ActiveX controls
59        guidgen.exe       - the Microsoft GUID generator, for generating OLE clsid's
60        cabarc.exe        - the Microsoft CAB file generator, for creating .cab archives
61        javasrc.jar       - javasrc, a tool for generating hyperlinked, syntax-colored html from java code
62
63    src/                  - all java source files and xwt sources go here
64        jazz/             - jazzlib, which XWT currently uses since libgcj's java.util.zip.* is broken
65
66        org/
67            bouncycastle/ - the BouncyCastle Crypto Library
68            gimp/tigert/  - some icons used in XWT Mail, by Tigert Labs
69            mozilla/      - a copy of Rhino, the Mozilla JavaScript interpreter
70
71            xwt/          - the source code for the XWT engine
72                demo/     - the XWT widget sampler
73                chess/    - XWT Chess
74                fonts/    - some XWF fonts
75                mail/     - XWT Mail
76                plat/     - platform abstraction classes for XWT
77                tasks/    - source code for some ANT tasks used in the XWT build process
78                themes/   - some XWT themes
79                util/     - some helper classes
80
81        xwt/standard/     - the XWT standard library
82
83
84
85 ______________________________________________________________________________
86 Build Targets
87
88         *** XWT now requires JDK 1.4 or later to build ***
89
90 To build, make sure your $JAVA_HOME points to jdk1.4 or later, and type
91
92     ./ant -Dplat=<platform> <targetname>
93
94 The name of any class in org.xwt.plat is a valid <platform>; here is a
95 list as of 20-Mar-2002:
96
97     Win32         - Windows 95 / NT4 or later
98     Java2         - Any Java 1.2+ compliant JVM
99
100 Valid <target>s are:
101
102     build         - builds a binary for the selected platform
103
104 The following targets do not require that you specify a platform:
105
106     compile       - compiles all .java's to .class'es
107     clean         - empties bin/ and compiled binaries in dist/
108
109
110 ______________________________________________________________________________
111 Building
112
113 - If you only want to build the JVM version of XWT, delete these three
114   files:
115
116     xwt/src/org/xwt/plat/Win32.java
117     xwt/src/org/xwt/plat/POSIX.java
118     xwt/src/org/xwt/plat/GCJ.java
119
120   This will allow XWT to build correctly *without* gcc 3.1. Otherwise,
121   you must compile and install gcc 3.1.
122
123
124 - The Win32 native version of XWT can ONLY be built with the very
125   latest pre-release of GCC 3.1. You can follow the steps below to
126   create a cross-compiler from linux to Win32.
127
128   If the steps below fail, try adding "-D 20-Mar-2002" to the cvs
129   checkout line; 20-Mar-2002 was the last date on which the compiler
130   was known to work. Please don't do this unless you have attempted
131   without it, however, since it puts additional strain on the gcc cvs
132   server.
133
134   There are also three patches at the end of this file which can be
135   applied to the branch -- the first fixes a bug related to
136   GetFullPathName, the second disables Win32 file locking (so you can
137   view XWT's log files while it is running), and the third makes
138   Throwable.printStackTrace() work.
139
140   # create an install area
141   export CLASSPATH=
142   export PREFIX=/usr/local/gcc
143   export CC=/usr/bin/gcc
144   
145   sudo rm -rf $PREFIX
146   export PATH=$PATH:$PREFIX/bin
147   sudo mkdir $PREFIX
148   sudo mkdir $PREFIX/i686-pc-mingw32/
149   
150   wget http://prdownloads.sourceforge.net/mingw/MinGW-1.1.tar.gz
151   sudo tar -C $PREFIX/i686-pc-mingw32/ -xvzf ~/mingw-gcj/MinGW-1.1.tar.gz
152   
153   wget ftp://ftp.gnu.org/gnu/binutils/binutils-2.11.2.tar.gz
154   tar xzvf binutils-2.11.2.tar.gz
155   cd binutils-2.11.2
156   ./configure --target=i686-pc-mingw32 --prefix=$PREFIX
157   make
158   sudo make install
159   cd ..
160   
161   cvs -d :pserver:anoncvs@subversions.gnu.org:/cvsroot/gcc co -rgcc-3_1-branch gcc
162   mkdir bin
163   cd bin
164   ../gcc/configure \
165                    --prefix=$PREFIX \
166                    --target=i686-pc-mingw32 \
167                    --host=i686-pc-linux-gnu \
168                    --enable-languages=c,c++,java \
169                    --disable-nls \
170                    --with-as=$PREFIX/i686-pc-mingw32/bin/as \
171                    --with-ld=$PREFIX/i686-pc-mingw32/bin/ld \
172                    --with-gnu-ld \
173                    --with-gnu-as \
174                    --enable-libgcj \
175                    --enable-gc-type=boehm \
176                    --disable-shared \
177                    --enable-threads=win32 \
178                    --disable-hash-synchronization \
179                    --disable-interpreter \
180                    --enable-sjlj-exceptions
181   
182   make
183   sudo make install
184
185 - The Linux native version is still experimental. You should configure
186   your compiler with:
187
188   ../gcc/configure \
189                    --prefix=$PREFIX \
190                    --enable-languages=c,c++,java \
191                    --disable-nls \
192                    --enable-libgcj \
193                    --enable-threads=posix \
194                    --enable-hash-synchronization \
195                    --enable-static \
196                    --disable-interpreter
197
198
199 ______________________________________________________________________________
200 Throwable.printStackTrace() patch
201
202 Index: Class.h
203 ===================================================================
204 RCS file: /cvs/gcc/gcc/libjava/java/lang/Class.h,v
205 retrieving revision 1.43
206 diff -u -r1.43 Class.h
207 --- Class.h     21 Dec 2001 19:47:50 -0000      1.43
208 +++ Class.h     24 Apr 2002 03:06:14 -0000
209 @@ -308,6 +308,7 @@
210    friend void _Jv_LayoutVTableMethods (jclass klass);
211    friend void _Jv_SetVTableEntries (jclass, _Jv_VTable *);
212    friend void _Jv_MakeVTable (jclass);
213 +  friend JArray<java::lang::reflect::Method*>* _Jv_GetAllMethods();
214  
215    // Return array class corresponding to element type KLASS, creating it if
216    // necessary.
217 Index: ClassLoader.java
218 ===================================================================
219 RCS file: /cvs/gcc/gcc/libjava/java/lang/ClassLoader.java,v
220 retrieving revision 1.16
221 diff -u -r1.16 ClassLoader.java
222 --- ClassLoader.java    7 Dec 2001 23:34:12 -0000       1.16
223 +++ ClassLoader.java    24 Apr 2002 03:06:14 -0000
224 @@ -577,4 +577,8 @@
225      // Default to returning null.  Derived classes implement this.
226      return null;
227    }
228 +
229 +  static native java.lang.reflect.Method[] getAllMethods();
230 +  static native long[] getAllMethodAddrs();
231 +
232  }
233 Index: Throwable.java
234 ===================================================================
235 RCS file: /cvs/gcc/gcc/libjava/java/lang/Throwable.java,v
236 retrieving revision 1.10
237 diff -u -r1.10 Throwable.java
238 --- Throwable.java      24 Feb 2001 03:52:49 -0000      1.10
239 +++ Throwable.java      24 Apr 2002 03:06:14 -0000
240 @@ -123,21 +123,64 @@
241      printStackTrace (writer);
242    }
243  
244 +  private native static long longFromStackTraceBytes(byte[] stackTrace, int i);
245 +
246    public void printStackTrace (PrintWriter wr)
247    {
248 -    try
249 -      {
250 -       CPlusPlusDemangler cPlusPlusFilter = new CPlusPlusDemangler (wr);
251 -       PrintWriter writer = new PrintWriter (cPlusPlusFilter);
252 -       printRawStackTrace (writer);    
253 -       writer.close ();
254 -       if (cPlusPlusFilter.written == 0) // The demangler has failed...
255 -         printRawStackTrace (wr);
256 +      try
257 +          {
258 +              CPlusPlusDemangler cPlusPlusFilter = new CPlusPlusDemangler (wr);
259 +              PrintWriter writer = new PrintWriter (cPlusPlusFilter);
260 +              printRawStackTrace (writer);     
261 +              writer.close ();
262 +              if (cPlusPlusFilter.written > 0) return;
263 +          }
264 +      catch (Exception e1)
265 +          {
266 +          }
267 +
268 +      wr.println(toString());
269 +      if (stackTrace == null) {
270 +          wr.flush();
271 +          return;
272        }
273 -    catch (Exception e1)
274 -      {
275 -       printRawStackTrace (wr);
276 +      
277 +      long[] allAddrs = ClassLoader.getAllMethodAddrs();
278 +      java.lang.reflect.Method[] meths = ClassLoader.getAllMethods();
279 +      
280 +      // FIXME: assumes little endian
281 +      for(int i=0; i<stackTrace.length; i++) {
282 +          long addr = longFromStackTraceBytes(stackTrace, i);
283 +          if (addr == 0) break;
284 +          
285 +          int whichMethod = -1;
286 +          for(int j=0; j<allAddrs.length; j++) {
287 +              if (allAddrs[j] <= addr &&
288 +                  (whichMethod == -1 || allAddrs[whichMethod] < allAddrs[j])) {
289 +                  whichMethod = j;
290 +              }
291 +          }
292 +          
293 +          if (whichMethod == -1) {
294 +              wr.println("[" + Long.toString(addr, 16) + "]  " + "??");
295 +              continue;
296 +          }
297 +          
298 +          if (meths[whichMethod].getDeclaringClass().getName().equals("gnu.gcj.runtime.FirstThread") &&
299 +              meths[whichMethod].getName().equals("call_main"))
300 +              break;
301 +          
302 +          wr.println("    [" + Long.toString(addr, 16) + "] " +
303 +                     meths[whichMethod].getDeclaringClass().getName() + "." +
304 +                     meths[whichMethod].getName() + "() " +
305 +                     "+" + (addr - allAddrs[whichMethod])
306 +                     );
307 +          
308 +          if (java.lang.Thread.class.isAssignableFrom(meths[whichMethod].getDeclaringClass()) &&
309 +              meths[whichMethod].getName().equals("run"))
310 +              break;
311        }
312 +      wr.flush();
313    }
314  
315    public Throwable ()
316 Index: natClassLoader.cc
317 ===================================================================
318 RCS file: /cvs/gcc/gcc/libjava/java/lang/natClassLoader.cc,v
319 retrieving revision 1.47.8.1
320 diff -u -r1.47.8.1 natClassLoader.cc
321 --- natClassLoader.cc   2 Apr 2002 22:19:55 -0000       1.47.8.1
322 +++ natClassLoader.cc   24 Apr 2002 03:06:14 -0000
323 @@ -40,6 +40,10 @@
324  #include <java/lang/StringBuffer.h>
325  #include <java/io/Serializable.h>
326  #include <java/lang/Cloneable.h>
327 +#include <java/lang/reflect/Method.h>
328 +
329 +#include<java/lang/reflect/Constructor.h>
330 +#include<gcj/method.h>
331  
332  // FIXME: remove these.
333  #define CloneableClass java::lang::Cloneable::class$
334 @@ -347,6 +351,50 @@
335  static jclass loaded_classes[HASH_LEN];
336  
337  // This is the root of a linked list of classes
338 +
339 +JArray<java::lang::reflect::Method*>*
340 +java::lang::ClassLoader::getAllMethods()
341 +{
342 +    return _Jv_GetAllMethods();
343 +}
344 +
345 +JArray<jlong>*
346 +java::lang::ClassLoader::getAllMethodAddrs()
347 +{
348 +    JArray<java::lang::reflect::Method*>* arr = _Jv_GetAllMethods();
349 +    java::lang::reflect::Method** el = (java::lang::reflect::Method**)elements(arr);
350 +    JArray<jlong>* ret = JvNewLongArray(arr->length);
351 +    jlong* retel = (jlong*)elements(ret);
352 +    for(int i=0; i<arr->length; i++)
353 +        retel[i] = (jlong)((unsigned int)(_Jv_FromReflectedMethod (el[i])->ncode));
354 +    return ret;
355 +}
356 +
357 +JArray<java::lang::reflect::Method*>*
358 +_Jv_GetAllMethods()
359 +{
360 +  int numMethods = 0;
361 +
362 +  for(int i=0; i<HASH_LEN; i++)
363 +      for(jclass c = loaded_classes[i]; c; c = c->next)
364 +          numMethods += c->getDeclaredMethods()->length;
365 +
366 +  JArray<java::lang::reflect::Method*>* ret =
367 +    (JArray<java::lang::reflect::Method*>*)
368 +    JvNewObjectArray(numMethods, &java::lang::reflect::Method::class$, NULL);
369 +
370 +  java::lang::reflect::Method** el = (java::lang::reflect::Method**)elements(ret);
371 +
372 +  for(int i=0; i<HASH_LEN; i++)
373 +      for(jclass c = loaded_classes[i]; c; c = c->next) {
374 +          JArray<java::lang::reflect::Method*>* methods = c->getDeclaredMethods();
375 +          jint len = methods->length;
376 +          java::lang::reflect::Method** meths = (java::lang::reflect::Method**)elements(methods);
377 +          for(int j=0; j<len; j++) el[--numMethods] = meths[j];
378 +      }
379 +
380 +  return ret;
381 +}
382  
383  \f
384  
385 Index: natThrowable.cc
386 ===================================================================
387 RCS file: /cvs/gcc/gcc/libjava/java/lang/natThrowable.cc,v
388 retrieving revision 1.11
389 diff -u -r1.11 natThrowable.cc
390 --- natThrowable.cc     7 Feb 2002 19:26:06 -0000       1.11
391 +++ natThrowable.cc     24 Apr 2002 03:06:14 -0000
392 @@ -32,6 +32,7 @@
393  #include <stdio.h>
394  
395  #include <unistd.h>
396 +#include <platform.h>
397  
398  #ifdef HAVE_EXECINFO_H
399  #include <execinfo.h>
400 @@ -102,3 +103,18 @@
401  #endif /* HAVE_BACKTRACE */
402    wr->flush ();
403  }
404 +
405 +// Returns the i^th call address in the stackTrace member, or 0 if i
406 +// is beyond the end of the trace. This has to be done in C++ because
407 +// the addresses in stackTrace are the same width as the platform's
408 +// pointers (which is unknown to Java code), and stackTrace is a
409 +// byte[] using the platform's endianness (which is unknown to Java
410 +// code).
411 +jlong
412 +java::lang::Throwable::longFromStackTraceBytes(jbyteArray stackArr, jint i)
413 +{
414 +    if (i * sizeof(void*) > stackArr->length) return 0;
415 +    unsigned int* stack = (unsigned int*)elements(stackArr);
416 +    return (jlong)stack[i];
417 +}
418 +
419
420
421
422
423