blob: 09b392ba7e721492857e5b25f6d37d75d91bc123 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001# Copyright (C) 2008 The Android Open Source Project
2
3
4- Description -
5---------------
6
7makeLayoutLib generates a library used by the Eclipse graphical layout editor
8to perform layout.
9
10
11
12- Usage -
13---------
14
15 ./makeLayoutLib path/to/android.jar destination.jar
16
17
18
19- Implementation Notes -
20------------------------
21
22The goal of makeLayoutLib is to list all the classes from the input jar and create a new
23jar that only keeps certain classes and create stubs for all their dependencies.
24
25First the input jar is parsed to find all the classes defined.
26
27In the Main(), the following list of classes are hardcoded (TODO config file later):
28- keep all classes that derive from android.view.View.
29- keep all classes in the android.view and android.widget packages (sub-packages excluded).
30- keep specific classes such as android.policy.PhoneLayoutInflater.
31
32For each class to keep, their dependencies are examined using BCEL.
33A dependency is defined as a class needed to instantiate the given class that should be kept,
34directly or indirectly. So a dependency is a class that is used by the input class, that is
35defined in the input jar and that is not part of the current JRE.
36
37Dependencies are computed recursively.
38
39Once all dependencies are found, the final jar can be created.
40There are three kind of classes to write:
41- classes that are to be kept as-is. They are just dumped in the new jar unchanged.
42- classes that are to be kept yet contain native methods or fields.
43- classes that are just dependencies. We don't want to expose their implementation in the final
44 jar.
45
46The implementation of native methods and all methods of mock classes is replaced by a stub
47that throws UnsupportedOperationException.
48
49Incidentally, the access level of native and mock classes needs to be changed in order for
50native methods to be later overridden. Methods that are "final private native" must become
51non-final, non-native and at most protected. Package-default access is changed to public.
52Classes that are final are made non-final. Abstract methods are left untouched.
53
54
55
56----
5720080617 Replace Class
58
59Some classes are basically wrappers over native objects.
60Subclassing doesn't work as most methods are either static or we don't
61control object creation. In this scenario the idea is to be able to
62replace classes in the final jar.
63
64Example: android.graphics.Paint would get renamed to OriginalPaint
65in the generated jar. Then in the bridge we'll introduce a replacement
66Paint class that derives from OriginalPaint.
67
68This won't rename/replace the inner static methods of a given class.
69
70
71