@@ -65,6 +65,12 @@ public class ClassWriter extends ClassVisitor {
6565 */
6666 public static final int COMPUTE_FRAMES = 2 ;
6767
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+
6874 // Note: fields are ordered as in the ClassFile structure, and those related to attributes are
6975 // ordered as in Section 4.7 of the JVMS.
7076
@@ -248,23 +254,39 @@ public ClassWriter(final int flags) {
248254 * @param classReader the {@link ClassReader} used to read the original class. It will be used to
249255 * copy the entire constant pool and bootstrap methods from the original class and also to
250256 * 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
254260 * maximum stack size nor the stack frames will be computed for these methods</i>.
255261 */
256262 public ClassWriter (final ClassReader classReader , final int flags ) {
257263 super (/* latest api = */ Opcodes .ASM9 );
264+ this .flags = flags ;
258265 symbolTable = classReader == null ? new SymbolTable (this ) : new SymbolTable (this , classReader );
259266 if ((flags & COMPUTE_FRAMES ) != 0 ) {
260- this . compute = MethodWriter .COMPUTE_ALL_FRAMES ;
267+ compute = MethodWriter .COMPUTE_ALL_FRAMES ;
261268 } else if ((flags & COMPUTE_MAXS ) != 0 ) {
262- this . compute = MethodWriter .COMPUTE_MAX_STACK_AND_LOCAL ;
269+ compute = MethodWriter .COMPUTE_MAX_STACK_AND_LOCAL ;
263270 } else {
264- this . compute = MethodWriter .COMPUTE_NOTHING ;
271+ compute = MethodWriter .COMPUTE_NOTHING ;
265272 }
266273 }
267274
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+
268290 // -----------------------------------------------------------------------------------------------
269291 // Implementation of the ClassVisitor abstract class
270292 // -----------------------------------------------------------------------------------------------
0 commit comments