Bytecode enhancement using ByteBuddy fails when the class is not available from the provided ClassLoader
Description
Activity
Show:

Former user April 19, 2019 at 7:32 AM
Fixed in 5.3 branch as well.

Former user April 5, 2019 at 8:03 PM
Fixed in master.
When ByteBuddy is used for bytecode enhancement, and
Enhancer#enhance
is used to enhance bytecode that is not available from the providedClassLoader
, enhancement will fail due toIllegalStateException
.This happens because ByteBuddy attempts to locate the bytecode from the
ClassLoader
viaClassLoader.getResourceAsStream
, instead of just using the bytecode provided toEnhancer#enhancer
with theoriginalBytes
argument.When
{{ClassLoader.getResourceAsStream
returnsnull
,net.bytebuddy.dynamic.ClassFileLocator#locate
returns aClassFileLocator.Resolution.Illegal
object.ClassFileLocator.Resolution.Illegal#resolve
ultimately throwsIllegalStateException
.