57
57
import soot .util .backend .SootASMClassWriter ;
58
58
59
59
/**
60
- * Abstract super-class for ASM-based back-ends. Generates byte-code for everything except the method bodies, as they are dependent on the IR.
61
- *
60
+ * Abstract super-class for ASM-based back-ends. Generates byte-code for everything except the method bodies, as they are
61
+ * dependent on the IR.
62
+ *
62
63
* @author Tobias Hamann, Florian Kuebler, Dominik Helm, Lukas Sommer
63
- *
64
+ *
64
65
*/
65
66
public abstract class AbstractASMBackend {
66
67
@@ -75,11 +76,12 @@ public abstract class AbstractASMBackend {
75
76
76
77
/**
77
78
* Creates a new ASM backend
78
- *
79
+ *
79
80
* @param sc
80
81
* The SootClass that is to be converted into bytecode
81
82
* @param javaVersion
82
- * A particular Java version enforced by the user, may be 0 for automatic detection, must not be lower than necessary for all features used
83
+ * A particular Java version enforced by the user, may be 0 for automatic detection, must not be lower than
84
+ * necessary for all features used
83
85
*/
84
86
public AbstractASMBackend (SootClass sc , int javaVersion ) {
85
87
this .sc = sc ;
@@ -91,8 +93,8 @@ public AbstractASMBackend(SootClass sc, int javaVersion) {
91
93
}
92
94
93
95
if (javaVersion != Options .java_version_default && javaVersion < minVersion ) {
94
- throw new IllegalArgumentException ("Enforced Java version " + translateJavaVersion (javaVersion ) + " too low to support required features ("
95
- + translateJavaVersion (minVersion ) + " required)" );
96
+ throw new IllegalArgumentException ("Enforced Java version " + translateJavaVersion (javaVersion )
97
+ + " too low to support required features (" + translateJavaVersion (minVersion ) + " required)" );
96
98
}
97
99
98
100
javaVersion = Math .max (javaVersion , minVersion );
@@ -126,9 +128,9 @@ public AbstractASMBackend(SootClass sc, int javaVersion) {
126
128
}
127
129
128
130
/**
129
- * Gets the baf body for the given SootMethod. This method will first check whether the method already has a baf body. If not, it will query the
130
- * local cache. If this fails as well, it will construct a new baf body.
131
- *
131
+ * Gets the baf body for the given SootMethod. This method will first check whether the method already has a baf body. If
132
+ * not, it will query the local cache. If this fails as well, it will construct a new baf body.
133
+ *
132
134
* @param method
133
135
* The method for which to obtain a baf body
134
136
* @return The baf body for the given method
@@ -156,7 +158,7 @@ protected BafBody getBafBody(SootMethod method) {
156
158
157
159
/**
158
160
* Determines the minimum Java version required for the bytecode of the given SootClass
159
- *
161
+ *
160
162
* @param sc
161
163
* The SootClass the minimum Java version is to be determined for
162
164
* @return The minimum Java version required for the given SootClass
@@ -211,9 +213,9 @@ private int getMinJavaVersion(SootClass sc) {
211
213
}
212
214
213
215
/**
214
- * Determines the minimum Java version required for the bytecode of the given SootMethod Subclasses should override this method to suit their needs,
215
- * otherwise Java 1.7 is assumed for compatibility with invokeDynamic
216
- *
216
+ * Determines the minimum Java version required for the bytecode of the given SootMethod Subclasses should override this
217
+ * method to suit their needs, otherwise Java 1.7 is assumed for compatibility with invokeDynamic
218
+ *
217
219
* @param sm
218
220
* The SootMethod the minimum Java version is to be determined for
219
221
* @return The minimum Java version required for the given SootMethod
@@ -224,7 +226,7 @@ protected int getMinJavaVersion(SootMethod sm) {
224
226
225
227
/**
226
228
* Outputs the bytecode generated as a class file
227
- *
229
+ *
228
230
* @param os
229
231
* The OutputStream the class file is written to
230
232
*/
@@ -241,7 +243,7 @@ public void generateClassFile(OutputStream os) {
241
243
242
244
/**
243
245
* Outputs the bytecode generated as a textual representation
244
- *
246
+ *
245
247
* @param pw
246
248
* The PrintWriter the textual representation is written to
247
249
*/
@@ -287,9 +289,9 @@ protected void generateByteCode() {
287
289
}
288
290
289
291
/**
290
- * Comparatator that is used to sort the methods before they are written out. This is mainly used to enforce a deterministic output between runs
291
- * which we need for testing.
292
- *
292
+ * Comparatator that is used to sort the methods before they are written out. This is mainly used to enforce a
293
+ * deterministic output between runs which we need for testing.
294
+ *
293
295
* @author Steven Arzt
294
296
*
295
297
*/
@@ -355,7 +357,8 @@ protected void generateMethods() {
355
357
continue ;
356
358
}
357
359
for (AnnotationTag at : va .getAnnotations ()) {
358
- AnnotationVisitor av = mv .visitParameterAnnotation (j , at .getType (), (va .getVisibility () == AnnotationConstants .RUNTIME_VISIBLE ));
360
+ AnnotationVisitor av = mv .visitParameterAnnotation (j , at .getType (),
361
+ (va .getVisibility () == AnnotationConstants .RUNTIME_VISIBLE ));
359
362
generateAnnotationElems (av , at .getElems (), true );
360
363
}
361
364
}
@@ -406,9 +409,9 @@ protected void generateFields() {
406
409
}
407
410
408
411
/**
409
- * Comparatator that is used to sort the inner class references before they are written out. This is mainly used to enforce a deterministic output
410
- * between runs which we need for testing.
411
- *
412
+ * Comparatator that is used to sort the inner class references before they are written out. This is mainly used to enforce
413
+ * a deterministic output between runs which we need for testing.
414
+ *
412
415
* @author Steven Arzt
413
416
*
414
417
*/
@@ -452,7 +455,7 @@ protected void generateAttributes() {
452
455
453
456
/**
454
457
* Emits the bytecode for all attributes of a field
455
- *
458
+ *
456
459
* @param fv
457
460
* The FieldVisitor to emit the bytecode to
458
461
* @param f
@@ -469,7 +472,7 @@ protected void generateAttributes(FieldVisitor fv, SootField f) {
469
472
470
473
/**
471
474
* Emits the bytecode for all attributes of a method
472
- *
475
+ *
473
476
* @param fv
474
477
* The MethodVisitor to emit the bytecode to
475
478
* @param f
@@ -486,7 +489,7 @@ protected void generateAttributes(MethodVisitor mv, SootMethod m) {
486
489
487
490
/**
488
491
* Emits the bytecode for all annotations of a class, field or method
489
- *
492
+ *
490
493
* @param visitor
491
494
* A ClassVisitor, FieldVisitor or MethodVisitor to emit the bytecode to
492
495
* @param host
@@ -512,8 +515,8 @@ protected void generateAnnotations(Object visitor, Host host) {
512
515
}
513
516
}
514
517
/*
515
- * Here TypeAnnotations could be visited potentially. Currently (2015/02/03) they are not supported by the ASM-front-end and their information
516
- * is not accessible.
518
+ * Here TypeAnnotations could be visited potentially. Currently (2015/02/03) they are not supported by the
519
+ * ASM-front-end and their information is not accessible.
517
520
*/
518
521
519
522
// Visit AnnotationDefault on methods
@@ -528,7 +531,7 @@ else if (host instanceof SootMethod && t instanceof AnnotationDefaultTag) {
528
531
529
532
/**
530
533
* Emits the bytecode for the values of an annotation
531
- *
534
+ *
532
535
* @param av
533
536
* The AnnotationVisitor to emit the bytecode to
534
537
* @param elements
@@ -665,7 +668,7 @@ protected void generateClassHeader() {
665
668
666
669
/**
667
670
* Utility method to get the access modifiers of a Host
668
- *
671
+ *
669
672
* @param modVal
670
673
* The bitset representation of the Host's modifiers
671
674
* @param host
@@ -724,7 +727,8 @@ protected static int getModifiers(int modVal, Host host) {
724
727
modifier |= Opcodes .ACC_STRICT ;
725
728
}
726
729
/*
727
- * Retrieve synthetic-modifier. Class not present in source-code but generated by e.g. compiler TODO Do we need both checks?
730
+ * Retrieve synthetic-modifier. Class not present in source-code but generated by e.g. compiler TODO Do we need both
731
+ * checks?
728
732
*/
729
733
if (Modifier .isSynthetic (modVal ) || host .hasTag ("SyntheticTag" )) {
730
734
modifier |= Opcodes .ACC_SYNTHETIC ;
@@ -742,7 +746,7 @@ protected static int getModifiers(int modVal, Host host) {
742
746
743
747
/**
744
748
* Emits the bytecode for the body of a single method Has to be implemented by subclasses to suit their needs
745
- *
749
+ *
746
750
* @param mv
747
751
* The MethodVisitor to emit the bytecode to
748
752
* @param method
0 commit comments