When ByteBuddy is used for bytecode enhancement, and Enhancer#enhance is used to enhance bytecode that is not available from the provided ClassLoader, enhancement will fail due to IllegalStateException. This happens because ByteBuddy attempts to locate the bytecode from the ClassLoader via ClassLoader.getResourceAsStream, instead of just using the bytecode provided to Enhancer#enhancer with the originalBytes argument. When {{ClassLoader.getResourceAsStream returns null, net.bytebuddy.dynamic.ClassFileLocator#locate returns a ClassFileLocator.Resolution.Illegal object. ClassFileLocator.Resolution.Illegal#resolve ultimately throws IllegalStateException. |