Bytecode enhancement using ByteBuddy fails when the class is not available from the provided ClassLoader

Description

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.

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.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created March 28, 2019 at 7:17 PM
Updated April 19, 2019 at 7:32 AM
Resolved April 19, 2019 at 7:32 AM