Skip to content

Conversation

@mcculls
Copy link
Collaborator

@mcculls mcculls commented Oct 27, 2025

What Does This Do

Patch Class.forName instead of ClassLoader.loadClass to inject the define-class glue.

Motivation

Patching Class.forName is safer because it's a static method and will work regardless if there's a custom class-loader that doesn't somehow delegate via one of the loadClass methods. While this is extremely unlikely, switching to Class.forName closes this gap.

Patching Class.forName is very slightly slower (0.5ms) but this only happens once.

@mcculls mcculls added the enhancement New feature or request label Oct 27, 2025
@mcculls mcculls requested a review from a team as a code owner October 27, 2025 21:55
@mcculls mcculls requested review from ygree and removed request for ygree October 27, 2025 21:55
@mcculls mcculls force-pushed the mcculls/inject-via-class-forname branch from 56d1a24 to e45fcda Compare October 27, 2025 21:58
@mcculls mcculls changed the title Inject glue by patching Class.forName Inject defineClass glue by patching Class.forName Oct 27, 2025
@mcculls mcculls merged commit 50c74a4 into main Oct 27, 2025
6 checks passed
@mcculls mcculls deleted the mcculls/inject-via-class-forname branch October 27, 2025 23:14
@github-actions github-actions bot added this to the 0.0.3 milestone Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants