javabackend

package
v0.148.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package javabackend emits deterministic Java 25 source from the typed Go shadow produced by the Go+ front end.

Index

Constants

View Source
const (
	RuntimeABI     = 1
	ArtifactSchema = "goplus.java.artifacts/v1"
	RuntimePackage = "dev.goforge.goplus.runtime"
)

Variables

This section is empty.

Functions

func JavaPackage

func JavaPackage(goPath string) string

JavaPackage reverses an import path's DNS name and preserves path segments: goforge.dev/x/y becomes dev.goforge.x.y.

func RuntimeSources

func RuntimeSources() map[string][]byte

RuntimeSources is the versioned Java runtime ABI used by thin Go+ module jars. Keeping it in generated source makes bootstrap builds reproducible; release packaging compiles the same bytes into goplus-runtime-abi1.jar.

Types

type Artifact

type Artifact struct {
	Path string
	Role Role
	Data []byte
}

Artifact is one deterministic output, with Path relative to Config.Root.

type Config

type Config struct {
	Root             string
	Patterns         []string
	Overlay          map[string][]byte
	Release          int
	Kind             string
	SourceDir        string
	RuntimeSourceDir string
	PackagePrefix    string
	ModuleName       string
	MainPackage      string
	StrongModule     bool
	Bundle           bool
	IncludeTests     bool
	JDKHome          string
	Classpath        []string
	Modulepath       []string
}

Config controls Java source layout and the stable host-language ABI.

type Diagnostic

type Diagnostic struct {
	Pos     token.Position
	Message string
}

Diagnostic is a source-positioned Java portability error.

type Result

type Result struct {
	Artifacts   []Artifact
	Diagnostics []Diagnostic
	ModulePath  string
	ModuleName  string
	MainClass   string
	TestClasses []string
}

Result is the Java artifact set or a list of unsupported-source diagnostics.

func Generate

func Generate(ctx context.Context, cfg Config) (Result, error)

Generate loads the fully lowered Go shadow with go/types and emits Java 25 sources. Unsupported constructs are diagnostics; no partial Java is returned.

type Role

type Role string

Role classifies an emitted artifact.

const (
	RoleSource   Role = "source"
	RoleRuntime  Role = "runtime-source"
	RoleManifest Role = "manifest"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL