#vulnerable code 
                                public boolean generate(String sourceFilename, String headerFilename, String loadSuffix,
            String baseLoadSuffix, String classPath, Class<?> ... classes) throws IOException {
        try {
            // first pass using a null writer to fill up the IndexedSet objects
            out = new PrintWriter(new Writer() {
                @Override public void write(char[] cbuf, int off, int len) { }
                @Override public void flush() { }
                @Override public void close() { }
            });
            out2 = null;
            callbacks           = new IndexedSet<String>();
            functions           = new IndexedSet<Class>();
            deallocators        = new IndexedSet<Class>();
            arrayDeallocators   = new IndexedSet<Class>();
            jclasses            = new IndexedSet<Class>();
            members             = new HashMap<Class,Set<String>>();
            virtualFunctions    = new HashMap<Class,Set<String>>();
            virtualMembers      = new HashMap<Class,Set<String>>();
            annotationCache     = new HashMap<Method,MethodInformation>();
            mayThrowExceptions  = false;
            usesAdapters        = false;
            passesStrings       = false;
            if (baseLoadSuffix == null || baseLoadSuffix.isEmpty()) {
                for (Class<?> cls : baseClasses) {
                    jclasses.index(cls);
                }
            }
            if (classes(true, true, true, loadSuffix, baseLoadSuffix, classPath, classes)) {
                // second pass with a real writer
                File sourceFile = new File(sourceFilename);
                File sourceDir = sourceFile.getParentFile();
                if (sourceDir != null) {
                    sourceDir.mkdirs();
                }
                out = encoding != null ? new PrintWriter(sourceFile, encoding) : new PrintWriter(sourceFile);
                if (headerFilename != null) {
                    logger.info("Generating " + headerFilename);
                    File headerFile = new File(headerFilename);
                    File headerDir = headerFile.getParentFile();
                    if (headerDir != null) {
                        headerDir.mkdirs();
                    }
                    out2 = encoding != null ? new PrintWriter(headerFile, encoding) : new PrintWriter(headerFile);
                }
                return classes(mayThrowExceptions, usesAdapters, passesStrings, loadSuffix, baseLoadSuffix, classPath, classes);
            } else {
                return false;
            }
        } finally {
            if (out != null) {
                out.close();
            }
            if (out2 != null) {
                out2.close();
            }
        }
    } 
                            #location 35 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                public boolean generate(String sourceFilename, String headerFilename, String loadSuffix,
            String baseLoadSuffix, String classPath, Class<?> ... classes) throws IOException {
        try {
            // first pass using a null writer to fill up the IndexedSet objects
            out = new PrintWriter(new Writer() {
                @Override public void write(char[] cbuf, int off, int len) { }
                @Override public void flush() { }
                @Override public void close() { }
            });
            out2 = null;
            callbacks           = new IndexedSet<String>();
            functions           = new IndexedSet<Class>();
            deallocators        = new IndexedSet<Class>();
            arrayDeallocators   = new IndexedSet<Class>();
            jclasses            = new IndexedSet<Class>();
            members             = new HashMap<Class,Set<String>>();
            virtualFunctions    = new HashMap<Class,Set<String>>();
            virtualMembers      = new HashMap<Class,Set<String>>();
            annotationCache     = new HashMap<Method,MethodInformation>();
            mayThrowExceptions  = false;
            usesAdapters        = false;
            passesStrings       = false;
            if (baseLoadSuffix == null || baseLoadSuffix.isEmpty()) {
                for (Class<?> cls : baseClasses) {
                    jclasses.index(cls);
                }
            }
            if (classes(true, true, true, true, loadSuffix, baseLoadSuffix, classPath, classes)) {
                // second pass with a real writer
                File sourceFile = new File(sourceFilename);
                File sourceDir = sourceFile.getParentFile();
                if (sourceDir != null) {
                    sourceDir.mkdirs();
                }
                out = encoding != null ? new PrintWriter(sourceFile, encoding) : new PrintWriter(sourceFile);
                if (headerFilename != null) {
                    logger.info("Generating " + headerFilename);
                    File headerFile = new File(headerFilename);
                    File headerDir = headerFile.getParentFile();
                    if (headerDir != null) {
                        headerDir.mkdirs();
                    }
                    out2 = encoding != null ? new PrintWriter(headerFile, encoding) : new PrintWriter(headerFile);
                }
                return classes(mayThrowExceptions, usesAdapters, passesStrings, accessesEnums, loadSuffix, baseLoadSuffix, classPath, classes);
            } else {
                return false;
            }
        } finally {
            if (out != null) {
                out.close();
            }
            if (out2 != null) {
                out2.close();
            }
        }
    }