Skip to content

Latest commit

 

History

History
18 lines (18 loc) · 645 Bytes

README.md

File metadata and controls

18 lines (18 loc) · 645 Bytes

SafeClassDefiner

Class definer for Java 9+ without using Unsafe.

Why not Unsafe?

Unsafe is slightly faster, but from the name we can understand that it is insecure and can be removed at any time.

Why not MethodHandles.Lookup?

SafeClassDefiner not restricted.

Benchmark results on my computer

JMH Benchmark

Example usage

ClassDefiner classDefiner = ClassDefiner.createSafeClassDefiner();
classDefiner.defineClass(myBytes, classLoader);
classDefiner.defineHiddenClass(myBytes, true, classLoader);

Dependencies

ASM (9.2) for generating empty classes.

Test dependencies

JUnit (5.8.2)