> ## Documentation Index
> Fetch the complete documentation index at: https://uom-demo.vercel.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# java_validator

> [<span className="flex items-center gap-1"><Icon icon="external-link"/>View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/tree/main/services/orchestrator/src/react_agent/custom_tools/java_validator.py)

Java compilation and validation tool using execute\_in\_sandbox.

## react\_agent.custom\_tools.java\_validator.JavaValidationInput Objects

```python theme={null}
class JavaValidationInput(BaseModel)
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/custom_tools/java_validator.py#L43)

Pydantic input model for specifying Java validation parameters.

**Attributes**:

* `source_code` - The Java source code (either schema mapping or query) to compile and run.
* `framework` - The specific Java target framework (e.g., Spring Data MongoDB, Spring Data Neo4j).
* `entry_type_name` - The public class name of the entry point declared in the source code.

#### react\_agent.custom\_tools.java\_validator.compile\_and\_run\_java

```python theme={null}
async def compile_and_run_java(
        source_code: str, framework: JavaFramework, entry_type_name: str,
        runtime: ToolRuntime[Context, State]) -> tuple[str, str | None]
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/custom_tools/java_validator.py#L64)

Compile and execute Java code within an isolated Daytona Sandbox container.

This utility handles the complex orchestration of validating Java code:

1. Fetches the required `pom.xml` configurations for Spring Data.
2. Builds a bash script (`run.sh`) to compile via Maven and execute the specified entry point class.
3. Provisions environment variables and database connection strings.
4. Base64 encodes all payload files to safely transfer them over to the sandbox.
5. Invokes the `execute_in_sandbox` tool.
6. If a query output JSON was produced, it downloads it via `download_file_from_sandbox`.

**Arguments**:

* `source_code` *str* - The raw Java source code to compile and run.
* `framework` *JavaFramework* - The target Java framework (Spring Data MongoDB, Spring Data Neo4j).
* `entry_type_name` *str* - The name of the main class containing the public static void main method.
* `runtime` *ToolRuntime\[Context, State]* - The LangGraph tool runtime containing context and state.

**Returns**:

tuple\[str, str | None]: A tuple containing the standard output/error log of the execution,
and the raw JSON string of the query results (if applicable and successful).

**Raises**:

* `RuntimeError` - If fetching the framework config fails or the sandbox execution throws an exception.

#### react\_agent.custom\_tools.java\_validator.validate\_java\_code

```python theme={null}
@tool("validate_java_code", args_schema=JavaValidationInput)
async def validate_java_code(
        source_code: str, framework: JavaFramework, entry_type_name: str,
        runtime: ToolRuntime[Context, State]) -> Command | str
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/custom_tools/java_validator.py#L281)

LangChain Tool wrapper to execute and evaluate Java code inside a Sandbox.

This tool acts as a bridge between the LangGraph state machine and the low-level sandbox
execution. It calls `compile_and_run_java` and then parses the returned JSON results.
Crucially, it determines whether it is currently validating the "source" query or the
"target" query based on the tool call ID or state comparison, and dynamically issues a
LangGraph `Command` to update the global state with the parsed `QueryValidationResults`.

**Arguments**:

* `source_code` *str* - The Java source code to validate.
* `framework` *JavaFramework* - The target Java framework.
* `entry_type_name` *str* - The entrypoint class name declared in the Java code.
* `runtime` *ToolRuntime\[Context, State]* - Automatically injected runtime context.

**Returns**:

Command | str: A LangGraph state update command containing parsed results and the
execution log, or just the error string if validation fails.
