Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
af003e6
feat: universal Java/Android input support and JDK JImage
VillanCh Nov 10, 2026
fdb8d20
feat: compact-cp JImage support, external samples, and fuzz tests
VillanCh Nov 10, 2026
410db9d
fix: contain malformed inputs and add explicit DEX stubs
VillanCh Nov 10, 2026
13467f9
test: cover new DEX policy and container helper branches
VillanCh Nov 10, 2026
81c20e7
feat: recover DEX class failures with diagnostics
VillanCh Nov 10, 2026
2c2fd89
fix: fail closed on incompatible wide initializers
VillanCh Nov 10, 2026
e634f33
fix: bound malformed JImage and ZIP inputs
VillanCh Nov 10, 2026
9f73f51
fix: enforce bounded archive and class parsing
VillanCh Nov 10, 2026
f4aabd5
fix: keep recovered DEX metadata verifier-safe
VillanCh Nov 10, 2026
3ede237
perf: streamline pure Go analysis and CI
VillanCh Nov 11, 2026
5162ff6
perf: cut class analysis fixed-point and rewrite work
VillanCh Nov 12, 2026
1918e92
perf: remove cold-start and lookup overheads
VillanCh Nov 12, 2026
378e4b7
perf: compact DEX reference state and opcode layout
VillanCh Nov 12, 2026
e662262
perf: cut class rewrite and postdom overhead
VillanCh Nov 12, 2026
05d0d83
perf: cut loop analysis and ambient lookup overhead
VillanCh Nov 12, 2026
55da0d2
ci: cut required gate startup and serial package work
VillanCh Nov 12, 2026
ec7e9dc
perf: reduce instrumented CI test overhead
VillanCh Nov 12, 2026
8ddadbc
perf: linearize switch and reaching queries
VillanCh Nov 12, 2026
c843a6b
perf: cache protected loop bodies and reuse dominator state
VillanCh Nov 12, 2026
f8f1ba3
Merge origin/main into feat/universal-input-formats
VillanCh Nov 13, 2026
e98c59a
test: run fuzz seeds and decompile determinism checks
VillanCh Nov 13, 2026
a99575b
perf: cut loop and rewriter allocation churn
VillanCh Nov 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
365 changes: 42 additions & 323 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion .github/workflows/extended.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,31 @@ jobs:
with:
go-version-file: go.mod
cache: true
- uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3
with:
distribution: temurin
java-version: '8'
- name: Retain the Java 8 compiler profile
run: echo "JAVA8_JAVAC=$JAVA_HOME/bin/javac" >> "$GITHUB_ENV"
- uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3
with:
distribution: temurin
java-version: '21'
# Native binding tests parse complete original declarations; no JAR is executed here.
- name: Prepare hash-locked original declaration families
run: python3 scripts/historical_jar_audit.py prepare --cache "$HOME/.m2/repository" --manifest "$RUNNER_TEMP/native-manifest.json"
- run: go test ./... -count=1 -timeout=30m
- name: Full compiler and runtime oracle suite
run: go test ./... -count=1 -timeout=30m
- name: Adversarial and complex archive runtime oracles
run: |
JAVAJIVE_ADVERSARIAL_EVAL=1 go test ./test/adversarial -count=1 -timeout=10m
JAVAJIVE_COMPLEX_JAR_EVAL=1 go test ./test/complexjar -count=1 -timeout=10m
- name: Curated source and runtime oracles
run: |
python3 tools/curated_roundtrip/build_adapter.py --out "$RUNNER_TEMP/javajive-probe"
python3 tools/curated_roundtrip/roundtrip.py --adapter "$RUNNER_TEMP/javajive-probe" \
--out "$RUNNER_TEMP/curated-roundtrip" --allow-trusted-fixture-execution --expected-rows 40
python3 -m unittest ci.task_t28.test_runtime_stack_generation
historical-audit:
name: Historical JAR differential audit (38 targets)
runs-on: ubuntu-22.04
Expand Down
272 changes: 272 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

238 changes: 195 additions & 43 deletions README.md

Large diffs are not rendered by default.

206 changes: 169 additions & 37 deletions README.zh-CN.md

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions ci/requiredci/cancellation_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package requiredci_test

import (
"context"
"errors"
"os"
"path/filepath"
"testing"
"time"

classparser "github.com/yaklang/javajive/classparser"
)

func cancellationOptions(ctx context.Context) classparser.DecompileOptions {
return classparser.DecompileOptions{
Mode: classparser.Precision,
Context: ctx,
Limits: classparser.Limits{
MaxInputBytes: 1 << 20,
MaxReadBytes: 2 << 20,
MaxParseItems: 1 << 16,
MaxOutputBytes: 2 << 20,
MaxDiagnostics: 64,
MaxRequestWork: 4 << 20,
},
EnvSnapshot: map[string]string{},
}
}

func readCancellationFixture(t *testing.T, name string) []byte {
t.Helper()
data, err := os.ReadFile(filepath.Join("..", "..", "classparser", "testdata", "regression", name))
if err != nil {
t.Fatal(err)
}
return data
}

// A canceled request must abort without publishing partial source, and the
// cancellation class must survive the work-budget wrapper.
func TestDecompileCancellationFailsClosed(t *testing.T) {
for _, name := range []string{"FMParser.class", "nondeterministic_loop_structuring.class"} {
data := readCancellationFixture(t, name)

ctx, cancel := context.WithCancel(context.Background())
cancel()
result, err := classparser.DecompileWithOptions(data, cancellationOptions(ctx))
if !errors.Is(err, context.Canceled) {
t.Fatalf("%s pre-canceled: err=%v status=%s", name, err, result.Status)
}
if result.Source != "" {
t.Fatalf("%s pre-canceled: published %d source bytes", name, len(result.Source))
}

ctx, cancel = context.WithCancel(context.Background())
go func() {
time.Sleep(time.Millisecond)
cancel()
}()
result, err = classparser.DecompileWithOptions(data, cancellationOptions(ctx))
cancel()
if !errors.Is(err, context.Canceled) {
t.Fatalf("%s mid-flight: err=%v status=%s", name, err, result.Status)
}
if result.Source != "" {
t.Fatalf("%s mid-flight: published %d source bytes", name, len(result.Source))
}
}
}
98 changes: 98 additions & 0 deletions ci/requiredci/concurrency_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package requiredci_test

import (
"context"
"encoding/json"
"fmt"
"os"
"path/filepath"
"sync"
"testing"

classparser "github.com/yaklang/javajive/classparser"
)

// concurrentFingerprint runs one decompile with request-local policy and
// returns a canonical JSON fingerprint (or the deterministic error text).
func concurrentFingerprint(data []byte) string {
result, err := classparser.DecompileWithOptions(data, classparser.DecompileOptions{
Mode: classparser.Precision,
Context: context.Background(),
Limits: classparser.Limits{
MaxInputBytes: 1 << 20,
MaxReadBytes: 2 << 20,
MaxParseItems: 1 << 16,
MaxOutputBytes: 2 << 20,
MaxDiagnostics: 64,
MaxRequestWork: 4 << 20,
},
EnvSnapshot: map[string]string{},
})
if err != nil {
return "error:" + err.Error()
}
encoded, marshalErr := json.Marshal(result)
if marshalErr != nil {
return "marshal-error:" + marshalErr.Error()
}
return string(encoded)
}

// Class decompilation must be deterministic and race-free when callers share
// only package-level caches. The race detector turns any unsynchronized cache
// access into a test failure; the repeated fingerprints catch source drift.
func TestConcurrentDecompileDeterministic(t *testing.T) {
fixtures := []struct {
name string
data []byte
}{
{name: "empty", data: []byte{}},
{name: "magic only", data: []byte{0xca, 0xfe, 0xba, 0xbe}},
{name: "zeroed class", data: make([]byte, 64)},
}
for _, path := range []string{
filepath.Join("..", "..", "classparser", "testdata", "regression", "FMParser.class"),
filepath.Join("..", "..", "classparser", "testdata", "regression", "Ser.class"),
} {
data, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
fixtures = append(fixtures, struct {
name string
data []byte
}{name: filepath.Base(path), data: data})
}

want := make([]string, len(fixtures))
for index, fixture := range fixtures {
want[index] = concurrentFingerprint(fixture.data)
if again := concurrentFingerprint(fixture.data); again != want[index] {
t.Fatalf("%s: sequential decompile is nondeterministic", fixture.name)
}
}

const workers = 3
start := make(chan struct{})
failures := make(chan string, workers)
var wait sync.WaitGroup
for worker := 0; worker < workers; worker++ {
wait.Add(1)
go func() {
defer wait.Done()
<-start
for index, fixture := range fixtures {
if got := concurrentFingerprint(fixture.data); got != want[index] {
failures <- fmt.Sprintf("%s: concurrent result differs", fixture.name)
return
}
}
}()
}
close(start)
wait.Wait()
close(failures)
for failure := range failures {
t.Error(failure)
}
}
94 changes: 94 additions & 0 deletions ci/requiredci/determinism_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package requiredci_test

import (
"crypto/sha256"
"fmt"
"os"
"os/exec"
"strings"
"testing"
)

var processDeterminismFixtures = []string{
"FMParser.class",
"nondeterministic_loop_structuring.class",
}

const processDeterminismMarker = "JAVAJIVE_DETERMINISM"

func processDeterminismHash(name string) (string, error) {
data, err := os.ReadFile(filesystemFixturePath(name))
if err != nil {
return "", err
}
sum := sha256.Sum256([]byte(concurrentFingerprint(data)))
return fmt.Sprintf("%s %x", name, sum), nil
}

func filesystemFixturePath(name string) string {
return "../../classparser/testdata/regression/" + name
}

// The child is invoked by TestDecompileDeterministicAcrossProcesses with a
// private environment. A normal full-suite run returns without doing work.
func TestDecompileDeterminismChild(t *testing.T) {
if os.Getenv("JAVAJIVE_DETERMINISM_CHILD") != "1" {
return
}
for _, name := range processDeterminismFixtures {
line, err := processDeterminismHash(name)
if err != nil {
t.Fatal(err)
}
fmt.Printf("%s %s\n", processDeterminismMarker, line)
}
}

// Map iteration order is seeded per process. Re-running the same decompile in
// child processes proves source, diagnostics, records and hashes do not depend
// on that seed, which same-process repetition cannot show.
func TestDecompileDeterministicAcrossProcesses(t *testing.T) {
want := make(map[string]string, len(processDeterminismFixtures))
for _, name := range processDeterminismFixtures {
line, err := processDeterminismHash(name)
if err != nil {
t.Fatal(err)
}
want[name] = line
}
executable, err := os.Executable()
if err != nil {
t.Fatal(err)
}
for run := 0; run < 2; run++ {
command := exec.Command(executable, "-test.run=^TestDecompileDeterminismChild$", "-test.count=1", "-test.timeout=2m")
environment := make([]string, 0, len(os.Environ())+1)
for _, entry := range os.Environ() {
if strings.HasPrefix(entry, "JAVAJIVE_DETERMINISM_CHILD=") {
continue
}
environment = append(environment, entry)
}
command.Env = append(environment, "JAVAJIVE_DETERMINISM_CHILD=1")
output, runErr := command.CombinedOutput()
if runErr != nil {
t.Fatalf("child run %d: %v\n%s", run, runErr, output)
}
seen := map[string]bool{}
for _, line := range strings.Split(string(output), "\n") {
line = strings.TrimSpace(line)
if !strings.HasPrefix(line, processDeterminismMarker+" ") {
continue
}
got := strings.TrimPrefix(line, processDeterminismMarker+" ")
name := strings.SplitN(got, " ", 2)[0]
if expected, ok := want[name]; !ok || got != expected {
t.Fatalf("child run %d %s: got %q want %q", run, name, got, expected)
}
seen[name] = true
}
if len(seen) != len(want) {
t.Fatalf("child run %d: saw %d fixtures, want %d\n%s", run, len(seen), len(want), output)
}
}
}
Loading
Loading