|
23 | 23 |
|
24 | 24 | /*
|
25 | 25 | * @test
|
26 |
| - * @bug 8320360 8330684 8331320 8331655 |
| 26 | + * @bug 8320360 8330684 8331320 8331655 8331940 |
27 | 27 | * @summary Testing ClassFile limits.
|
28 | 28 | * @run junit LimitsTest
|
29 | 29 | */
|
|
35 | 35 | import java.lang.classfile.ClassFile;
|
36 | 36 | import java.lang.classfile.Opcode;
|
37 | 37 | import java.lang.classfile.attribute.CodeAttribute;
|
| 38 | +import java.lang.classfile.attribute.LineNumberInfo; |
| 39 | +import java.lang.classfile.attribute.LineNumberTableAttribute; |
38 | 40 | import java.lang.classfile.constantpool.ConstantPoolException;
|
39 | 41 | import java.lang.classfile.constantpool.IntegerEntry;
|
| 42 | +import java.util.List; |
| 43 | +import jdk.internal.classfile.impl.DirectCodeBuilder; |
40 | 44 | import jdk.internal.classfile.impl.DirectMethodBuilder;
|
41 | 45 | import jdk.internal.classfile.impl.LabelContext;
|
42 | 46 | import jdk.internal.classfile.impl.UnboundAttribute;
|
@@ -161,4 +165,14 @@ public void writeBody(BufWriter b) {
|
161 | 165 | b.writeU2(0);//attributes
|
162 | 166 | }})))).methods().get(0).code().get().elementList());
|
163 | 167 | }
|
| 168 | + |
| 169 | + @Test |
| 170 | + void testLineNumberOutOfBounds() { |
| 171 | + assertThrows(IllegalArgumentException.class, () -> |
| 172 | + ClassFile.of().parse(ClassFile.of().build(ClassDesc.of("LineNumberClass"), cb -> cb.withMethodBody( |
| 173 | + "lineNumberMethod", MethodTypeDesc.of(ConstantDescs.CD_void), 0, cob -> ((DirectCodeBuilder)cob |
| 174 | + .return_()) |
| 175 | + .writeAttribute(LineNumberTableAttribute.of(List.of(LineNumberInfo.of(500, 0)))) |
| 176 | + ))).methods().get(0).code().get().elementList()); |
| 177 | + } |
164 | 178 | }
|
0 commit comments