{"record":{"id":"752bfc5e95e82386","repo":"apache/cassandra","slug":"java-source-compilation-failed-n","errorCode":null,"errorMessage":"Java source compilation failed:\\n","messagePattern":"Java source compilation failed:\\\\n","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/JavaBasedUDFunction.java","lineNumber":316,"sourceCode":"                                    .append(problem.getMessage())\n                                    .append('\\n');\n                            fullSource = true;\n                        }\n                    }\n                    else\n                    {\n                        problems.append(\"Line \")\n                                .append(Long.toString(ln))\n                                .append(\": \")\n                                .append(problem.getMessage())\n                                .append('\\n');\n                    }\n                }\n\n                if (fullSource)\n                    throw new InvalidRequestException(\"Java source compilation failed:\\n\" + problems + \"\\n generated source:\\n\" + javaSource);\n                else\n                    throw new InvalidRequestException(\"Java source compilation failed:\\n\" + problems);\n            }\n\n            // Verify the UDF bytecode against use of probably dangerous code\n            Set<String> errors = udfByteCodeVerifier.verify(targetClassName, targetClassLoader.classData(targetClassName));\n            String validDeclare = \"not allowed method declared: \" + executeInternalName + '(';\n            for (Iterator<String> i = errors.iterator(); i.hasNext();)\n            {\n                String error = i.next();\n                // we generate a random name of the private, internal execute method, which is detected by the byte-code verifier\n                if (error.startsWith(validDeclare))\n                    i.remove();\n            }\n            if (!errors.isEmpty())\n                throw new InvalidRequestException(\"Java UDF validation failed: \" + errors);\n\n            // Load the class and create a new instance of it\n            Thread thread = Thread.currentThread();\n            ClassLoader orig = thread.getContextClassLoader();","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/JavaBasedUDFunction.java#L298-L334","documentation":"This is the second branch of the same compilation-failure path in JavaBasedUDFunction: when full source is NOT enabled, the exception carries only 'Java source compilation failed:\\n' plus the compiler problems, without the generated source. It means the UDF Java body failed to compile and the server omits generated code from the message.","triggerScenarios":"CREATE FUNCTION with a Java body that fails javac compilation while the cluster is configured without generated-source dumping (fullSource false), so only diagnostics are returned.","commonSituations":"Production clusters (source dump disabled) rejecting UDF bodies; same root causes as the full-source variant: type errors, bad syntax, wrong signatures.","solutions":["Fix the code based on the compiler diagnostics in the message.","If diagnostics are insufficient, temporarily enable showing generated source (cassandra.yaml udf settings / cassandra.u df source logging) to inspect the generated file.","DROP and re-CREATE the function with the corrected body.","Validate the body logic and types offline in plain Java first."],"exampleFix":"// before\nCREATE FUNCTION f(x bigint) RETURNS bigint ... ' return x.substring(1); '\n// after\nCREATE FUNCTION f(x text) RETURNS text ... ' return x.substring(1); '","handlingStrategy":"validation","validationCode":"// compile the body offline first:\n// javac with same types; only run CREATE FUNCTION after clean compile","typeGuard":null,"tryCatchPattern":"try { session.execute(createFunctionDdl); } catch (InvalidRequestException e) { if (e.getMessage().contains(\"Java source compilation failed\")) { /* diagnostics-only message: fix listed problems, optionally enable generated-source dump to debug */ } else throw e; }","preventionTips":["Validate Java syntax and types locally before DDL","Keep a tested snippet library for UDF bodies","Enable generated-source logging in dev clusters to see the full generated code"],"tags":["udf","java","compilation"],"backgroundTag":"schema-validation-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}