@@ -65,6 +65,12 @@ public class ClassWriter extends ClassVisitor {
65
65
*/
66
66
public static final int COMPUTE_FRAMES = 2 ;
67
67
68
+ /**
69
+ * The flags passed to the constructor. Must be zero or more of {@link #COMPUTE_MAXS} and {@link
70
+ * #COMPUTE_FRAMES}.
71
+ */
72
+ private final int flags ;
73
+
68
74
// Note: fields are ordered as in the ClassFile structure, and those related to attributes are
69
75
// ordered as in Section 4.7 of the JVMS.
70
76
@@ -248,23 +254,39 @@ public ClassWriter(final int flags) {
248
254
* @param classReader the {@link ClassReader} used to read the original class. It will be used to
249
255
* copy the entire constant pool and bootstrap methods from the original class and also to
250
256
* copy other fragments of original bytecode where applicable.
251
- * @param flags option flags that can be used to modify the default behavior of this class.Must be
252
- * zero or more of {@link #COMPUTE_MAXS} and {@link #COMPUTE_FRAMES}. <i>These option flags do
253
- * not affect methods that are copied as is in the new class. This means that neither the
257
+ * @param flags option flags that can be used to modify the default behavior of this class. Must
258
+ * be zero or more of {@link #COMPUTE_MAXS} and {@link #COMPUTE_FRAMES}. <i>These option flags
259
+ * do not affect methods that are copied as is in the new class. This means that neither the
254
260
* maximum stack size nor the stack frames will be computed for these methods</i>.
255
261
*/
256
262
public ClassWriter (final ClassReader classReader , final int flags ) {
257
263
super (/* latest api = */ Opcodes .ASM9 );
264
+ this .flags = flags ;
258
265
symbolTable = classReader == null ? new SymbolTable (this ) : new SymbolTable (this , classReader );
259
266
if ((flags & COMPUTE_FRAMES ) != 0 ) {
260
- this . compute = MethodWriter .COMPUTE_ALL_FRAMES ;
267
+ compute = MethodWriter .COMPUTE_ALL_FRAMES ;
261
268
} else if ((flags & COMPUTE_MAXS ) != 0 ) {
262
- this . compute = MethodWriter .COMPUTE_MAX_STACK_AND_LOCAL ;
269
+ compute = MethodWriter .COMPUTE_MAX_STACK_AND_LOCAL ;
263
270
} else {
264
- this . compute = MethodWriter .COMPUTE_NOTHING ;
271
+ compute = MethodWriter .COMPUTE_NOTHING ;
265
272
}
266
273
}
267
274
275
+ // -----------------------------------------------------------------------------------------------
276
+ // Accessors
277
+ // -----------------------------------------------------------------------------------------------
278
+
279
+ /**
280
+ * Returns true if all the given flags were passed to the constructor.
281
+ *
282
+ * @param flags some option flags. Must be zero or more of {@link #COMPUTE_MAXS} and {@link
283
+ * #COMPUTE_FRAMES}.
284
+ * @return true if all the given flags, or more, were passed to the constructor.
285
+ */
286
+ public boolean hasFlags (final int flags ) {
287
+ return (this .flags & flags ) == flags ;
288
+ }
289
+
268
290
// -----------------------------------------------------------------------------------------------
269
291
// Implementation of the ClassVisitor abstract class
270
292
// -----------------------------------------------------------------------------------------------
0 commit comments