{"record":{"id":"99faa7f838903f37","repo":"openjdk/jdk","slug":"source-output-dir-not-set","errorCode":null,"errorMessage":"source output dir not set","messagePattern":"source output dir not set","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"make/langtools/tools/genstubs/GenStubs.java","lineNumber":127,"sourceCode":"                sourcepath = iter.next();\n            else if (arg.startsWith(\"-\"))\n                throw new IllegalArgumentException(arg);\n            else {\n                classes.add(arg);\n                while (iter.hasNext())\n                    classes.add(iter.next());\n            }\n        }\n\n        return run(sourcepath, outdir, classes);\n    }\n\n    public boolean run(String sourcepath, File outdir, List<String> classes) {\n        //System.err.println(\"run: sourcepath:\" + sourcepath + \" outdir:\" + outdir + \" classes:\" + classes);\n        if (sourcepath == null)\n            throw new IllegalArgumentException(\"sourcepath not set\");\n        if (outdir == null)\n            throw new IllegalArgumentException(\"source output dir not set\");\n\n        JavacTool tool = JavacTool.create();\n        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);\n\n        try {\n            fm.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(outdir));\n            fm.setLocation(StandardLocation.SOURCE_PATH, splitPath(sourcepath));\n            List<JavaFileObject> files = new ArrayList<JavaFileObject>();\n            for (String c: classes) {\n                JavaFileObject fo = fm.getJavaFileForInput(\n                        StandardLocation.SOURCE_PATH, c, JavaFileObject.Kind.SOURCE);\n                if (fo == null)\n                    error(\"class not found: \" + c);\n                else\n                    files.add(fo);\n            }\n\n            JavacTask t = tool.getTask(null, fm, null, null, null, files);","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/make/langtools/tools/genstubs/GenStubs.java#L109-L145","documentation":"IllegalArgumentException from GenStubs.run when the output directory is null — generated stub sources are written through the JavaFileManager at StandardLocation.SOURCE_OUTPUT, which must be bound to a real directory. Pure precondition check on the API contract.","triggerScenarios":"Invoking run() with a null outdir — e.g. the Ant task's destdir attribute missing, or the CLI run without -s — after the sourcepath check already passed.","commonSituations":"Custom wrappers around GenStubs computing outdir from a property that was never set (returns null instead of a File).","solutions":["Set the destdir attribute (Ant) or -s option (CLI) to an existing, writable directory.","Null-check and default the outdir in custom driver code before calling run()."],"exampleFix":"<!-- before -->\n<genstubs srcdir=\"${src}\"/>\n\n<!-- after -->\n<genstubs srcdir=\"${src}\" destdir=\"${build.gensrc}\"/>","handlingStrategy":"validation","validationCode":"// guard the precondition before calling run()\nObjects.requireNonNull(outdir, \"source output dir not set\");\nif (!outdir.exists() && !outdir.mkdirs())\n    throw new IllegalArgumentException(\"cannot create output dir: \" + outdir);\nif (!outdir.canWrite())\n    throw new IllegalArgumentException(\"output dir not writable: \" + outdir);","typeGuard":null,"tryCatchPattern":"try {\n    genStubs.run(sourcepath, outdir, classes);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"GenStubs misconfigured: \" + e.getMessage(), e);\n}","preventionTips":["Always set destdir/-s; create and chmod the directory in build setup.","Null-check computed outdir values in custom drivers before calling run()."],"tags":["genstubs","precondition","illegal-argument","build"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}