-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex___.html
385 lines (317 loc) · 12.6 KB
/
index___.html
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mandali Thread-safety Analyzer</title>
<style>
body {
font-family: 'Roboto', sans-serif;
line-height: 1.6;
margin: 0;
padding: 20px;
background-color: #1e1e1e;
color: #dcdcdc;
}
h3 {
margin-bottom: 10px;
}
h1 {
font-size: 4em;
/* border-bottom: 2px solid #0c1012; */
/* padding-bottom: 10px; */
}
h2 {
color: #60c67e;
font-size: 3em;
/* margin-top: 20px; */
margin-bottom: 10px;
}
h3 {
font-size: 1.5em;
margin-top: 15px;
margin-bottom: 5px;
}
p {
margin: 10px 0;
}
strong {
color: #60c67e;
}
code {
background-color: #2d2d2d;
padding: 2px 5px;
border-radius: 5px;
font-family: 'Courier New', Courier, monospace;
color: #c5c8c6;
}
pre {
background-color: #2d2d2d;
padding: 15px;
border-radius: 5px;
overflow-x: auto;
border: 1px solid #bdc3c7;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
color: #c5c8c6;
}
.container {
max-width: 1000px;
margin: auto;
background: #333;
border-radius: 10px;
padding: 40px;
}
img {
max-width: 100%;
border-radius: 5px;
margin: 20px 0;
}
/* Responsive Design */
@media (max-width: 600px) {
h1 {
font-size: 2em;
}
h2 {
font-size: 1.75em;
}
h3 {
font-size: 1.25em;
}
}
.feature-box {
background-color: #2d2d2d;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
margin: 20px 0;
display: flex;
align-items: center;
color: #dcdcdc;
}
.feature-box img {
width: 90px;
/* height: 100px; */
margin-right: 50px;
margin-left: 40px;
}
.feature-box h3 {
font-size: 1.5em;
margin: 0;
color: #60c67e;
}
.feature-box p {
margin: 5px 0 0;
}
/* CSS */
.logocontainer {
position: relative;
width: 100%;
height: 50vh;
/* Membuat kontainer setinggi layar */
}
.logocontainer img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-width: 100%;
height: auto;
}
</style>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="logocontainer">
<img width="400" src="logo-removebg-preview.png" alt="Gambar di tengah">
</div>
<img src="log.png"/>
<!-- <h2>Overview</h2>
<p><strong>Mandali</strong> is a library designed to detect potential thread safety issues within Java or Kotlin classes. The name "Mandali" is inspired by the Indonesian words "Man = Aman" (safe) and "Dali = terkenDali" (controlled), symbolizing safety and easy to control.</p>
<p>This library assists in identifying collections that may not be thread-safe in multi-threaded environments, and it automatically detects deadlocks when running. <strong>Note:</strong> This tool does not guarantee thread safety but helps reduce potential thread safety issues.</p> -->
<!--
<h2>Features</h2>
<div class="feature-box">
<img src="logo-item.png" alt="Unsafe Collection Detection Icon">
<div>
<h3>Unsafe Collection Detection</h3>
<p>Mandali can identify commonly unsafe collections in multi-threaded contexts, such as <code>ArrayList</code>, <code>HashMap</code>, and <code>StringBuilder</code>.</p>
</div>
</div>
<div class="feature-box">
<img src="logo-item.png" alt="Thread-safe Alternatives Recommendation Icon">
<div>
<h3>Thread-safe Alternatives Recommendation</h3>
<p>This feature suggests safer alternatives to replace unsafe collections or objects, enhancing the application's thread safety.</p>
</div>
</div>
<div class="feature-box">
<img src="logo-item.png" alt="Deadlock Detection Icon">
<div>
<h3>Deadlock Detection</h3>
<p>Mandali automatically detects deadlocks in the system and provides detailed information on locked threads.</p>
</div>
</div>
<h2>Why do we need a Mandali</h2>
<div class="feature-box">
<img src="logo-item.png" alt="Early Problem Detection Icon">
<div>
<h3>Early Problem Detection</h3>
<p>Mandali proactively identifies unsafe data collections for multi-threading operations, helping to avoid unpredictable program behavior due to thread safety issues.</p>
</div>
</div>
<div class="feature-box">
<img src="logo-item.png" alt="Improved Code Quality Icon">
<div>
<h3>Improved Code Quality</h3>
<p>By using Mandali, you can enhance code quality, making it more stable, reliable, and maintainable.</p>
</div>
</div>
<div class="feature-box">
<img src="logo-item.png" alt="Development Efficiency Icon">
<div>
<h3>Development Efficiency</h3>
<p>Mandali saves time by automatically detecting issues, allowing developers to focus on business logic instead of debugging concurrency problems.</p>
</div>
</div>
<div class="feature-box">
<img src="logo-item.png" alt="Ease of Use Icon" style="margin-bottom: 15%;">
<div>
<h3>Ease of Use</h3>
<h4>Easy Integration</h4>
<p>Mandali can be easily integrated into your project by adding it to the project dependencies.</p>
<h4>Clear Reporting</h4>
<p>The reports generated by Mandali are easy to understand, even for developers not deeply familiar with concurrency concepts.</p>
</div>
</div> -->
<!-- <h2>Features</h2>
<h3>Unsafe Collection Detection</h3>
<p>Mandali can identify commonly unsafe collections in multi-threaded contexts, such as <code>ArrayList</code>, <code>HashMap</code>, and <code>StringBuilder</code>.</p>
<h3>Thread-safe Alternatives Recommendation</h3>
<p>This feature suggests safer alternatives to replace unsafe collections or objects, enhancing the application's thread safety.</p>
<h3>Deadlock Detection</h3>
<p>Mandali automatically detects deadlocks in the system and provides detailed information on locked threads.</p>
<h2>Why do we need a Mandali</h2>
<img src="log.png" alt="Mandali Logo" />
<h3>Early Problem Detection</h3>
<p>Mandali proactively identifies unsafe data collections for multi-threading operations, helping to avoid unpredictable program behavior due to thread safety issues.</p>
<h3>Concrete Improvement Suggestions</h3>
<p>Mandali provides concrete solution suggestions, such as recommending <code>CopyOnWriteArrayList</code> or <code>Collections.synchronizedList</code> when unsafe usage of <code>ArrayList</code> is detected.</p>
<h3>Improved Code Quality</h3>
<p>By using Mandali, you can enhance code quality, making it more stable, reliable, and maintainable.</p>
<h3>Development Efficiency</h3>
<p>Mandali saves time by automatically detecting issues, allowing developers to focus on business logic instead of debugging concurrency problems.</p>
<h3>Ease of Use</h3>
<h4>Easy Integration</h4>
<p>Mandali can be easily integrated into your project by adding it to the project dependencies.</p>
<h4>Clear Reporting</h4>
<p>The reports generated by Mandali are easy to understand, even for developers not deeply familiar with concurrency concepts.</p>
<h4>Focus on Issues</h4>
<p>Mandali is specifically designed to detect thread-safety issues, offering a more specialized tool than general analysis options.</p> -->
<h2>Setup</h2>
<p>To use Mandali, add it to your project using either Gradle or Maven.</p>
<h3>Using Gradle</h3>
<pre><code>repositories {
maven { url 'https://repo.repsy.io/mvn/hangga/repo' }
}
dependencies {
implementation 'io.mandali:mandali:1.0.8-SNAPSHOT'
}</code></pre>
<h3>Using Maven</h3>
<pre><code><repositories>
<repository>
<id>Mandali-repo</id>
<url>https://repo.repsy.io/mvn/hangga/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.mandali</groupId>
<artifactId>mandali</artifactId>
<version>1.0.8-SNAPSHOT</version>
</dependency>
</dependencies></code></pre>
<h2>Basic Usage</h2>
<p>To start the Mandali analysis, simply create an instance of <code>Mandali</code> and call <code>start()</code> on it:</p>
<pre><code>Mandali(this).start()</code></pre>
<p>This command initiates the thread safety analysis on the current instance, inspecting potential issues such as deadlocks or thread-unsafe usage patterns. Typically, this method is used within a test class after each test case to verify the code's thread safety.</p>
<h2>Annotation Usage: <code>@RunMandali</code></h2>
<p>The <code>@RunMandali</code> annotation provides an automated way to activate the Mandali analysis. This annotation should be applied at the class level of a test to trigger the analysis based on the specified options:</p>
<pre><code>// Add annotation here
@RunMandali(showDate = true, detectDeadlock = true)
class MandaliExampleUnitTest {
// Test cases
}</code></pre>
<h3><code>boolean showDate</code></h3>
<p>A <code>Boolean</code> parameter that, when set to <code>true</code>, displays the date and time of the analysis run in the output. <em>Default value: <code>false</code></em>.</p>
<h3><code>boolean detectDeadlock</code></h3>
<p>A <code>Boolean</code> parameter that enables deadlock detection, with <code>false</code> as the default value.</p>
<!-- <h3>Example of Applying <code>@RunMandali</code> Annotation</h3> -->
<h2>Example Test Class</h2>
<p>The following example demonstrates how to structure a test class to check for thread safety issues using the <code>Mandali</code> library. This class simulates potential deadlocks and thread-unsafe scenarios, which are detected and analyzed by Mandali.</p>
<h3>Code Example</h3>
<pre><code>package io.mandali
import org.junit.jupiter.api.Test
import java.lang.Thread.sleep
import kotlin.concurrent.thread
class Account(val name: String, var balance: Int) {
private fun deposit(amount: Int) {
balance += amount
}
private fun withdraw(amount: Int) {
balance -= amount
}
fun transfer(to: Account, amount: Int) {
println("${this.name} tries to transfer $amount to ${to.name}.")
synchronized(this) {
sleep(10) // Simulate processing time
if (balance >= amount) {
withdraw(amount)
synchronized(to) {
to.deposit(amount)
}
}
}
}
}
@RunMandali(showDate = true, detectDeadlock = true)
class MandaliExampleKotlinUnitTest {
@Test
fun `example of deadlock`() {
val account1 = Account("Hangga", 1000)
val account2 = Account("John", 1000)
val account3 = Account("Alice", 2000)
// Transfer from account1 to account2
thread {
account1.transfer(account2, 100)
}.join(10) // as a simulation of the time required
// Transfer from account2 to account1
thread {
account2.transfer(account1, 200)
}.join(20)
// Transfer from account3 to account1
thread {
account3.transfer(account1, 1000)
}.join(500)
Mandali(this).start()
}
val list = ArrayList<Int>()
@Test
fun `example thread-unsafe using HashMap`() {
val map = HashMap<Int, Int>()
val threads = List(10) { index ->
thread {
for (i in 0 until 1000) {
map[i] = index
}
}
}
threads.forEach {
it.join()
}
}
}
</code></pre>
</div>
</body>
</html>