Commit 6468f153 authored by Eric Bruneton's avatar Eric Bruneton

Add a test to make sure ClassWriter.toByteArray() is updated when new ClassWriter fields are added.

parent a331a77f
Pipeline #1391 passed with stage
in 6 minutes and 13 seconds
......@@ -27,12 +27,16 @@
package org.objectweb.asm;
import static;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.objectweb.asm.test.Assertions.assertThat;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Random;
import org.junit.jupiter.api.Test;
......@@ -48,6 +52,52 @@ import org.objectweb.asm.test.AsmTest;
public class ClassWriterTest extends AsmTest {
* Tests that the non-static fields of ClassWriter are the expected ones. This test is designed to
* fail each time new fields are added to ClassWriter, and serves as a reminder to update the
* field reset logic in {@link ClassWriter#toByteArray()}, if needed, each time a new field is
* added.
public void testInstanceFields() {
// IMPORTANT: if this fails, update the string list AND update the logic that resets the
// ClassWriter fields in ClassWriter.toByteArray(), if needed (this logic is used to do a
// ClassReader->ClassWriter round trip to remove the ASM specific instructions due to large
// forward jumps).
new HashSet<String>(
.filter(field -> !Modifier.isStatic(field.getModifiers()))
public void testNewConst() {
ClassWriter classWriter = new ClassWriter(0);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment