@@ -43,6 +43,7 @@ public final class ClassInjector {
4343 *
4444 * @param bytecode the named bytecode to inject
4545 * @return list of injected classes
46+ * @throws IllegalStateException if the class inject was not enabled first
4647 */
4748 public static List <Class <?>> injectBootClasses (Map <String , byte []> bytecode ) {
4849 return (List <Class <?>>) classDefiner ().apply (bytecode , null );
@@ -54,6 +55,7 @@ public static List<Class<?>> injectBootClasses(Map<String, byte[]> bytecode) {
5455 * @param bytecode the named bytecode to inject
5556 * @param cl the class-loader to use
5657 * @return list of injected classes
58+ * @throws IllegalStateException if the class inject was not enabled first
5759 */
5860 public static List <Class <?>> injectClasses (Map <String , byte []> bytecode , ClassLoader cl ) {
5961 return (List <Class <?>>) classDefiner ().apply (bytecode , cl );
@@ -65,6 +67,7 @@ public static List<Class<?>> injectClasses(Map<String, byte[]> bytecode, ClassLo
6567 * @param bytecode the named bytecode to inject
6668 * @param pd the protection domain to use
6769 * @return list of injected classes
70+ * @throws IllegalStateException if the class inject was not enabled first
6871 */
6972 public static List <Class <?>> injectClasses (Map <String , byte []> bytecode , ProtectionDomain pd ) {
7073 return (List <Class <?>>) classDefiner ().apply (bytecode , pd );
@@ -74,7 +77,7 @@ private ClassInjector() {}
7477
7578 private static BiFunction classDefiner () {
7679 if (classDefiner == null ) {
77- throw new UnsupportedOperationException ("Class injection not enabled" );
80+ throw new IllegalStateException ("Class injection not enabled" );
7881 }
7982 return classDefiner ;
8083 }
@@ -85,6 +88,7 @@ private static BiFunction classDefiner() {
8588 * Enables class injection via {@link Instrumentation}.
8689 *
8790 * @param inst the instrumentation instance
91+ * @throws UnsupportedOperationException if the class injection could not be enabled
8892 */
8993 public static void enableClassInjection (Instrumentation inst ) {
9094 if (classDefiner != null ) {
0 commit comments