8cd3bf09247c9f35a3a7da5b8cfb95fe8025ec16
[nit.git] / contrib / jwrapper / README.md
1 # JWRAPPER : Extern classes generator from java .class
2 ## Description
3 jwrapper is a code generator that creates Nit extern classes `in "Java"` from .class files.
4
5 ## Installation
6 jwrapper is designed to be installed from the `contrib` directory of Nit repository. (http://www.nitlanguage.org)
7
8 To initiate installation process, use `make` in the `contrib/jwrapper` directory.
9
10 jwrapper relies on `nitcc` that will be automatically compiled from `contrib/nitcc`.
11
12 ## Usage
13 The jwrapper binary can be found under `jwrapper/bin` directory.
14
15 Since jwrapper uses `grep` to find existing libraries, make sure that the environment variable `NIT_DIR` is properly set to your Nit root directory.
16
17 Since jwrapper uses `javap` to extract data from .class files, the JDK7 or higher has to be installed and must be in your `$PATH`. (Older versions of `javap` do not show generic signatures)
18
19 Usage :
20
21         jwrapper [OPTIONS] JAVA_CLASS_FILE NIT_OUTPUT_FILE
22
23 The options are :
24
25 `-a, --with-attributes`
26
27 * It enables extern class attributes generation. For each public attribute, there'll be a Nit attribute of the corresponding type.
28
29 `-c, --comment`
30
31 * When a method contains at least one unknown type, the code generator will comment the whole method and let the client manage it.
32
33 `-w, --wrap`
34
35 * A minimalistic extern class will be created for each unknown type (this is the default behaviour)
36
37 `-h, --help`
38
39 * Print the help message
40
41 Unknown types are types that doesn't have an equivalent in Nit as of yet.
42
43 Jwrapper won't wrap a class that already is in the `lib/android` directory.
44
45 Can't use both -c and -w together, either you comment unknown types or you wrap them.
46
47 ## Limitations
48 jwrapper support for java primitive array is limited to one parameter and the return value.
49
50 If the method contains more than one primitive array parameter, the method will be commented with a `NOT SUPPORTED` notice.
51
52 ## TODO List
53 * Generate static methods on top-level
54 * Extend primitive array support
55 * Enhance static overload support (currently, it suffixes the method name with a number)