-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetaprogramming in java
56 lines (40 loc) · 1.39 KB
/
metaprogramming in java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
* ASM
library to generate bytecode
* Tabpestry
uses metaprogramming
* Plastic
sort of higher level library thatn ASM for "metaprogramming"
* Extending Methods
** MethodAdvice
Advise method to manage transaction commit
With advise
Declare class with interface PlasticClass, can make plastic method
* With Transformations
somewhat bluring the line between compliation and runtime
* Layers of Concerns
like logging, etc,
can chain advice
* Implement New Methods on the fly
eg you can add a method to get a hashcode for an object to the class
(this could also be done with reflection... but that incures runtime penalty among other things)
* Instantiating
can't just use new, because you'd get the non-plastified version of the class
** instantiation framework
Class.forName("com.ex.something").getConstructor().getInstance
* Testing with Spock
basically, test the behavior not , eg, what methods are invoked ala mocks
* "API != Interface"
API more like a contract
plastic allows you to bind a contract to your classes
* random
programming "Essence"
* callbacks
happen against one instance of the conduit , for all instances of the plastic object
to work around, you generate a conduite per object
* Trinity
** Bytecode manipulation
** Annotations
** Component Architecture
* examples
https://github.com/hlship/plastic-demos
https://howardlweisship.com