package ex;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.Hashtable;
import java.util.zip.DataFormatException;

import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

@SuppressWarnings("all")
public class BED_Sample {
    IOException ioe;

    public BED_Sample() throws IOException {

    }

    public BED_Sample(String name) throws NamingException {
        Hashtable<String, String> env = new Hashtable<>();
        env.put("name", name);
        DirContext context = new InitialDirContext(env);
    }

    public void doesTheNasty() throws FileNotFoundException, IOException {

    }

    public void doesTheNasty2() throws IOException, FileNotFoundException {

    }

    public void fpJustAwful() throws IOException, Exception {

    }

    private void badThrow() throws SQLException {

    }

    public static void badStatic() throws DataFormatException {

    }

    public final void badFinal() throws ClassNotFoundException {

    }

    public static void doIt() throws SQLException, IOException {
        InputStream is = new FileInputStream("c:\\temp.txt");
    }

    public static void fp() throws Exception {
        InputStream is = new FileInputStream("c:\\temp.txt");
    }

    private void fpThrowField(boolean b) throws IOException {
        if (b) {
            throw ioe;
        } else {
            IOException e = ioe;
            throw ioe;
        }
    }

    static void fpJustThrowIt(boolean permissible, String message) throws IOException {
        IOException e = new FileNotFoundException(message);
        if (!permissible) {
            throw e;
        }
    }

    public Object iAmCreatingAnObject() {
        return new Object() {
            private byte[] iHaveToThrowAnException() throws IOException {
                return BED_Sample.this.iThrowAnException();
            }
        };
    }

    private byte[] iThrowAnException() throws IOException {
        File.createTempFile("foo", "bar");
        return "Test".getBytes("UTF-8");
    }

    private void issue92a() throws InterruptedException {
        System.out.println("test");
    }

    public static void issue92b() throws InterruptedException {
        System.out.println("test");
    }

    public static Process fpInterrupted(String command) throws IOException, InterruptedException {

        Object sync = new Object();
        Process p = Runtime.getRuntime().exec(command);
        synchronized (sync) {
            sync.wait();
        }

        return p;
    }

    static class FPAnonBase {

        FPAnonBase(InputStream is) throws IOException {
            int i = is.read();
        }

        public static FPAnonBase makeAnon(InputStream is) throws IOException {
            return new FPAnonBase(is) {
            };
        }
    }

}

@@ -5,16 +5,17 @@
 age ex;%0A
+%0A
 import j
@@ -207,24 +207,51 @@
 .Hashtable;%0A
+import java.util.Optional;%0A
 import java.
@@ -1838,32 +1838,218 @@
        %7D%0A    %7D%0A%0A
+    private String getHashFromChecksum217(Optional%3CString%3E checksum) throws IOException %7B%0A        return checksum.orElseThrow(() -%3E new IOException(%22Failed to get checksum...%22));%0A    %7D%0A%0A
     public Objec

add BED test as reported in #217