Skip to content
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public final class ClassInjector {
*
* @param bytecode the named bytecode to inject
* @return list of injected classes
* @throws IllegalStateException if class injection is not enabled
*/
public static List<Class<?>> injectBootClasses(Map<String, byte[]> bytecode) {
return (List<Class<?>>) classDefiner().apply(bytecode, null);
Expand All @@ -54,6 +55,7 @@ public static List<Class<?>> injectBootClasses(Map<String, byte[]> bytecode) {
* @param bytecode the named bytecode to inject
* @param cl the class-loader to use
* @return list of injected classes
* @throws IllegalStateException if class injection is not enabled
*/
public static List<Class<?>> injectClasses(Map<String, byte[]> bytecode, ClassLoader cl) {
return (List<Class<?>>) classDefiner().apply(bytecode, cl);
Expand All @@ -65,6 +67,7 @@ public static List<Class<?>> injectClasses(Map<String, byte[]> bytecode, ClassLo
* @param bytecode the named bytecode to inject
* @param pd the protection domain to use
* @return list of injected classes
* @throws IllegalStateException if class injection is not enabled
*/
public static List<Class<?>> injectClasses(Map<String, byte[]> bytecode, ProtectionDomain pd) {
return (List<Class<?>>) classDefiner().apply(bytecode, pd);
Expand All @@ -74,7 +77,7 @@ private ClassInjector() {}

private static BiFunction classDefiner() {
if (classDefiner == null) {
throw new UnsupportedOperationException("Class injection not enabled");
throw new IllegalStateException("Class injection not enabled");
}
return classDefiner;
}
Expand All @@ -85,6 +88,7 @@ private static BiFunction classDefiner() {
* Enables class injection via {@link Instrumentation}.
*
* @param inst the instrumentation instance
* @throws UnsupportedOperationException if class injection is not available
*/
public static void enableClassInjection(Instrumentation inst) {
if (classDefiner != null) {
Expand Down