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