Skip to content

Add Java contract support to JuLC Playground#28

Open
satran004 wants to merge 2 commits intomainfrom
feat/julc_playground_java_contract
Open

Add Java contract support to JuLC Playground#28
satran004 wants to merge 2 commits intomainfrom
feat/julc_playground_java_contract

Conversation

@satran004
Copy link
Copy Markdown
Member

Summary

  • Add full Java validator support to the playground: compile, test, and evaluate Java smart contracts directly in the browser
  • Disable JRL language support (Java-only for now)
  • Add production hardening: input validation, error sanitization, rate limiter security, configurable CORS, request logging
  • Add implicit stdlib imports so users can reference ContextsLib, Builtins, etc. without explicit import statements
  • Rename JrlPlaygroundServer → JulcPlaygroundServer

What's New

Java Compilation Pipeline

  • Full Java → PIR → UPLC → Blueprint compilation with stdlib auto-discovery
  • Java validator test execution with @param, datum, redeemer encoding and ScriptContext building
  • Expression evaluation endpoint (/api/eval) for quick REPL-style eval
  • Three bundled Java examples: SimpleSpending, VestingValidator, MintingPolicy

Editor Intelligence

  • Java autocomplete with type-aware instance methods and library method discovery
  • Method parameter hints (SignatureHelpProvider) — shows param names/types as you type
  • Hover docs for stdlib and Builtins methods
  • Go-to-definition for user-defined records and sealed interfaces
  • Dual-tab editor (Validator / Library) with library source integration

Production Hardening

  • InputValidator with max-length checks (100KB source, 100KB library, 10KB expression)
  • Error message sanitization — no stack traces or internal details leaked to client
  • Rate limiter only trusts X-Forwarded-For when JULC_BEHIND_PROXY=true
  • Configurable CORS via JULC_CORS_ORIGINS env var
  • Path traversal guard for native image static file serving
  • Request logging middleware with per-endpoint duration tracking
  • Enhanced /api/health with sandbox slot availability
  • AbortController for frontend auto-check to prevent race conditions
  • Frontend error states for failed example/scenario loading
  • Proper 408/429 feedback in UI

Compiler: Implicit Stdlib Imports

  • ImportResolver now adds com.bloxbean.cardano.julc.stdlib and com.bloxbean.cardano.julc.stdlib.lib as implicit wildcard packages (like java.lang.*)
  • Only resolves types registered in knownFqcns (14 stdlib classes) — no risk of unintended captures
  • Replaces the earlier suffix-matching approach that broke existing tests

satran004 and others added 2 commits April 9, 2026 22:15
- Add full Java validator compilation pipeline (Java → PIR → UPLC → Blueprint)
  with library source support and stdlib auto-discovery
- Add Java validator test execution with param/datum/redeemer encoding
  and ScriptContext building via ScenarioContextBuilder
- Add editor intelligence: Java autocomplete, method parameter hints
  (SignatureHelpProvider), hover docs, and go-to-definition for
  user-defined records/sealed interfaces
- Add expression evaluation endpoint (/api/eval) with PlaygroundEvaluator
- Add Java example validators (SimpleSpending, VestingValidator, MintingPolicy)
- Add dual-tab editor (Validator / Library) with library source integration

- Disable JRL language support from playground (Java-only)
- Remove JrlCompiler dependency from all controllers
- Remove transpile endpoint and JRL examples

- Add production hardening:
  - Input validation with max-length checks (InputValidator)
  - Error message sanitization (no stack trace leaks to client)
  - Rate limiter X-Forwarded-For trust only behind proxy (JULC_BEHIND_PROXY)
  - Configurable CORS origins (JULC_CORS_ORIGINS env var)
  - Path traversal guard for native image static file serving
  - Request logging middleware with compilation duration
  - Enhanced /api/health endpoint with sandbox availability
  - AbortController for frontend auto-check race conditions
  - Frontend error states for failed API calls (examples, scenarios)
  - Proper 408/429 error feedback in UI

- Cache LibrarySourceResolver.scanClasspathSources() at startup
- Fix RFC 1918 range check in RateLimiter (172.16-31 not 172.16-39)
- Fix editor tab subscription leak (move cleanup to onDestroy)
- Raise MAX_REQUEST_SIZE from 64KB to 256KB
- Update env var prefix from JRL_ to JULC_ (with JRL_ fallback)
- Update HTML title to "JuLC Playground"

- 26 backend tests (all passing): controllers, sandbox, rate limiter

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant