You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
implementation(group ="org.jacodb", name ="jacodb-api", version ="1.2.0")
26
+
implementation(group ="org.jacodb", name ="jacodb-core", version ="1.2.0")
27
+
implementation(group ="org.jacodb", name ="jacodb-analysis", version ="1.2.0")
28
+
```
29
+
30
+
or
31
+
32
+
Maven:
33
+
```xml
34
+
<dependencies>
35
+
<dependency>
36
+
<groupId>org.jacodb</groupId>
37
+
<artifactId>jacodb-core</artifactId>
38
+
<verison>1.2.0</verison>
39
+
</dependency>
40
+
<dependency>
41
+
<groupId>org.jacodb</groupId>
42
+
<artifactId>jacodb-api</artifactId>
43
+
<verison>1.2.0</verison>
44
+
</dependency>
45
+
<dependency>
46
+
<groupId>org.jacodb</groupId>
47
+
<artifactId>jacodb-analysis</artifactId>
48
+
<verison>1.2.0</verison>
49
+
</dependency>
50
+
</dependencies>
51
+
```
52
+
53
+
## Concepts
22
54
23
55
API has two levels: the one representing in filesystem (**bytecode** and **classes**) and the one appearing at runtime (**types**).
24
56
@@ -27,6 +59,26 @@ API has two levels: the one representing in filesystem (**bytecode** and **class
27
59
28
60
Both levels are connected to `JcClasspath`. You can't modify **classes** retrieved from pure bytecode. **types** may be constructed manually by generics substitution.
val commonsMath36 =File("commons-math3-3.6.1.jar")
68
120
val buildDir =File("my-project/build/classes/java/main")
@@ -86,13 +138,12 @@ suspend fun findNormalDistribution(): Any {
86
138
println(jcClass.annotations.size)
87
139
88
140
// At this point the database read the method bytecode and return the result.
89
-
return jcClass.methods[0].body()
141
+
return jcClass.methods[0].asmNode()
90
142
}
91
143
```
92
144
93
-
94
-
95
-
Note: the `body` method returns `null` if the to-be-processed JAR-file was changed or removed. Class could be in incomplete environment (i.e super class, interface, return type or parameter of method is not found in classpath) then api will throw `NoClassInClasspathException` at runtime.
145
+
Class could be in incomplete environment (i.e super class, interface, return type or parameter of method is not found in classpath) then api will throw `NoClassInClasspathException` at runtime.
146
+
To fix this install `UnknownClasses` feature into classpath during creation.
96
147
97
148
The database can watch for file system changes in the background and refresh the JAR-files explicitly:
98
149
@@ -117,7 +168,6 @@ Kotlin
117
168
watchFileSystem()
118
169
useProcessJavaRuntime()
119
170
loadByteCode(listOf(lib1, buildDir))
120
-
persistent("")
121
171
}
122
172
123
173
// A user rebuilds the buildDir folder.
@@ -171,6 +221,46 @@ Kotlin
171
221
}
172
222
```
173
223
224
+
## Features
225
+
226
+
Features could be used for whole `JcDatabase` or particular `JcClasspath`
227
+
228
+
### Usages
229
+
230
+
Database feature for searching usages of fields and methods.
231
+
232
+
```kotlin
233
+
val database = jacodb {
234
+
install(Usages)
235
+
}
236
+
```
237
+
238
+
see [more](https://jacodb.org/documentation/database-features/#usages)
239
+
240
+
### Unknown Classes
241
+
242
+
Mocks unknown classes. It's a grace way to handle incomplete classpaths
243
+
244
+
```kotlin
245
+
val database = jacodb {}
246
+
val classpath = database.classpath(listOf(UnknownClasses))
247
+
248
+
val clazz = classpath.findClass("UnknownClasses") // will return `JcClassOrInterface` instance
249
+
```
250
+
251
+
see [more](https://jacodb.org/documentation/classpath-features/#unknownClasses)
252
+
253
+
254
+
### InMemory hierarchy
255
+
256
+
A bit faster hierarchy but consume more RAM memory:
257
+
258
+
```kotlin
259
+
val database = jacodb {
260
+
install(InMemoryHierarchy)
261
+
}
262
+
```
263
+
see [more](https://jacodb.org/documentation/database-features/#inmemoryhierarchy)
0 commit comments