We're updating the issue view to help you get more done. 

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.

Environment

None

Status

Assignee

Gail Badner

Reporter

Gail Badner

Fix versions

backPortable

Backport?

Components

Affects versions

5.4.2
5.3.9

Priority

Major