This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git


The following commit(s) were added to refs/heads/master by this push:
     new 8f75ff6a Add org.apache.bcel.classfile.AttributeTest
8f75ff6a is described below

commit 8f75ff6a5897ab3e6258113f5b43dfb6768c971e
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Oct 30 17:32:29 2026 -0400

    Add org.apache.bcel.classfile.AttributeTest
    
    See invalid PR #405.
---
 .../org/apache/bcel/classfile/AttributeTest.java   | 49 ++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/src/test/java/org/apache/bcel/classfile/AttributeTest.java 
b/src/test/java/org/apache/bcel/classfile/AttributeTest.java
new file mode 100644
index 00000000..f89c3354
--- /dev/null
+++ b/src/test/java/org/apache/bcel/classfile/AttributeTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.bcel.classfile;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link Attribute}.
+ */
+public class AttributeTest {
+
+    @Test
+    public void testReadAttributeInvalidName() {
+        final DataInputStream dataInput = new DataInputStream(new 
ByteArrayInputStream(new byte[] { 0, 0, 0, 0, 0 }));
+        final Constant[] constants = new Constant[1];
+        final ConstantPool constantPool = new ConstantPool(constants);
+        assertThrows(ClassFormatException.class, () -> 
Attribute.readAttribute(dataInput, constantPool));
+    }
+
+    @Test
+    public void testReadAttributeNegativeLength() {
+        final DataInputStream dataInput = new DataInputStream(new 
ByteArrayInputStream(new byte[] { 0, 0, 0, 0, -1 }));
+        final Constant[] constants = new Constant[1];
+        final ConstantPool constantPool = new ConstantPool(constants);
+        assertThrows(ClassFormatException.class, () -> 
Attribute.readAttribute(dataInput, constantPool));
+    }
+}

Reply via email to