/*
 * 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
 *
 *      http://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;

import static org.junit.jupiter.api.Assertions.assertThrows;

import java.io.File;
import java.io.FileInputStream;

import org.apache.bcel.classfile.ClassFormatException;
import org.apache.bcel.classfile.ClassParser;
import org.junit.jupiter.api.Test;

public class OssFuzzTestCase {

    @Test
    public void testIssue51989() throws Exception {
        testOssFuzzReproducer("51989");
    }


    @Test
    public void testIssue52168() throws Exception {
        testOssFuzzReproducer("52168");
    }


    private void testOssFuzzReproducer(String issue) throws Exception {
        File reproducerFile = new File("target/test-classes/ossfuzz/issue" + issue + "/Test.class");
        FileInputStream reproducerInputStream = new FileInputStream(reproducerFile);

        ClassParser cp = new ClassParser(reproducerInputStream, "Test");
        assertThrows(ClassFormatException.class, () -> cp.parse());
    }
}

@@ -1217,25 +1217,24 @@
 9%22);%0A    %7D%0A%0A
-%0A
     @Test%0A  
@@ -1330,17 +1330,16 @@
 %0A    %7D%0A%0A
-%0A
     priv
@@ -1369,16 +1369,22 @@
 roducer(
+final 
 String i
@@ -1412,24 +1412,30 @@
 n %7B%0A        
+final 
 File reprodu
@@ -1523,16 +1523,27 @@
         
+try (final 
 FileInpu
@@ -1613,19 +1613,24 @@
 ile)
-;%0A%0A
+) %7B%0A    
         
 Clas
@@ -1625,16 +1625,22 @@
         
+final 
 ClassPar
@@ -1704,16 +1704,20 @@
         
+ 
+   
 assertTh
@@ -1768,16 +1768,26 @@
 rse());%0A
+        %7D%0A
     %7D%0A%7D%0A

Use try-with-resources