@@ -815,6 +815,16 @@ interface Engine {
815815 */
816816 Engine with (ClassFileLocator classFileLocator );
817817
818+ /**
819+ * Uses the supplied {@link ClassFileVersion} as a base for resolving multi-release jars, or {@code null}
820+ * if multi-release jars should not be resolved but be treated as regular jar files. This property might
821+ * not be applied if the underlying location mechanism does not supply manual resource resolution.
822+ *
823+ * @param classFileVersion The class file version to use or {@code null}.
824+ * @return A new plugin engine that is equal to this engine but with the supplied class file verion being used.
825+ */
826+ Engine with (@ MaybeNull ClassFileVersion classFileVersion );
827+
818828 /**
819829 * Appends the supplied listener to this engine.
820830 *
@@ -4464,6 +4474,13 @@ class Default extends AbstractBase {
44644474 */
44654475 private final ClassFileLocator classFileLocator ;
44664476
4477+ /**
4478+ * The class file version to use for multi-release jars, or {@code null}.
4479+ */
4480+ @ MaybeNull
4481+ @ HashCodeAndEqualsPlugin .ValueHandling (HashCodeAndEqualsPlugin .ValueHandling .Sort .REVERSE_NULLABILITY )
4482+ private final ClassFileVersion classFileVersion ;
4483+
44674484 /**
44684485 * The listener to use.
44694486 */
@@ -4511,6 +4528,7 @@ protected Default(ByteBuddy byteBuddy, TypeStrategy typeStrategy) {
45114528 typeStrategy ,
45124529 PoolStrategy .Default .FAST ,
45134530 ClassFileLocator .NoOp .INSTANCE ,
4531+ null ,
45144532 Listener .NoOp .INSTANCE ,
45154533 new ErrorHandler .Compound (ErrorHandler .Failing .FAIL_FAST ,
45164534 ErrorHandler .Enforcing .ALL_TYPES_RESOLVED ,
@@ -4526,6 +4544,7 @@ protected Default(ByteBuddy byteBuddy, TypeStrategy typeStrategy) {
45264544 * @param typeStrategy The type strategy to use.
45274545 * @param poolStrategy The pool strategy to use.
45284546 * @param classFileLocator The class file locator to use.
4547+ * @param classFileVersion The class file version to use for multi-release jars, or {@code null}.
45294548 * @param listener The listener to use.
45304549 * @param errorHandler The error handler to use.
45314550 * @param dispatcherFactory The dispatcher factory to use.
@@ -4535,6 +4554,7 @@ protected Default(ByteBuddy byteBuddy,
45354554 TypeStrategy typeStrategy ,
45364555 PoolStrategy poolStrategy ,
45374556 ClassFileLocator classFileLocator ,
4557+ @ MaybeNull ClassFileVersion classFileVersion ,
45384558 Listener listener ,
45394559 ErrorHandler errorHandler ,
45404560 Dispatcher .Factory dispatcherFactory ,
@@ -4543,6 +4563,7 @@ protected Default(ByteBuddy byteBuddy,
45434563 this .typeStrategy = typeStrategy ;
45444564 this .poolStrategy = poolStrategy ;
45454565 this .classFileLocator = classFileLocator ;
4566+ this .classFileVersion = classFileVersion ;
45464567 this .listener = listener ;
45474568 this .errorHandler = errorHandler ;
45484569 this .dispatcherFactory = dispatcherFactory ;
@@ -4613,6 +4634,7 @@ public Engine with(ByteBuddy byteBuddy) {
46134634 typeStrategy ,
46144635 poolStrategy ,
46154636 classFileLocator ,
4637+ classFileVersion ,
46164638 listener ,
46174639 errorHandler ,
46184640 dispatcherFactory ,
@@ -4627,6 +4649,7 @@ public Engine with(TypeStrategy typeStrategy) {
46274649 typeStrategy ,
46284650 poolStrategy ,
46294651 classFileLocator ,
4652+ classFileVersion ,
46304653 listener ,
46314654 errorHandler ,
46324655 dispatcherFactory ,
@@ -4641,6 +4664,7 @@ public Engine with(PoolStrategy poolStrategy) {
46414664 typeStrategy ,
46424665 poolStrategy ,
46434666 classFileLocator ,
4667+ classFileVersion ,
46444668 listener ,
46454669 errorHandler ,
46464670 dispatcherFactory ,
@@ -4655,6 +4679,22 @@ public Engine with(ClassFileLocator classFileLocator) {
46554679 typeStrategy ,
46564680 poolStrategy ,
46574681 new ClassFileLocator .Compound (this .classFileLocator , classFileLocator ),
4682+ classFileVersion ,
4683+ listener ,
4684+ errorHandler ,
4685+ dispatcherFactory ,
4686+ ignoredTypeMatcher );
4687+ }
4688+
4689+ /**
4690+ * {@inheritDoc}
4691+ */
4692+ public Engine with (@ MaybeNull ClassFileVersion classFileVersion ) {
4693+ return new Default (byteBuddy ,
4694+ typeStrategy ,
4695+ poolStrategy ,
4696+ classFileLocator ,
4697+ classFileVersion ,
46584698 listener ,
46594699 errorHandler ,
46604700 dispatcherFactory ,
@@ -4669,6 +4709,7 @@ public Engine with(Listener listener) {
46694709 typeStrategy ,
46704710 poolStrategy ,
46714711 classFileLocator ,
4712+ classFileVersion ,
46724713 new Listener .Compound (this .listener , listener ),
46734714 errorHandler ,
46744715 dispatcherFactory ,
@@ -4683,6 +4724,7 @@ public Engine withoutErrorHandlers() {
46834724 typeStrategy ,
46844725 poolStrategy ,
46854726 classFileLocator ,
4727+ classFileVersion ,
46864728 listener ,
46874729 Listener .NoOp .INSTANCE ,
46884730 dispatcherFactory ,
@@ -4697,6 +4739,7 @@ public Engine withErrorHandlers(List<? extends ErrorHandler> errorHandlers) {
46974739 typeStrategy ,
46984740 poolStrategy ,
46994741 classFileLocator ,
4742+ classFileVersion ,
47004743 listener ,
47014744 new ErrorHandler .Compound (errorHandlers ),
47024745 dispatcherFactory ,
@@ -4711,6 +4754,7 @@ public Engine with(Dispatcher.Factory dispatcherFactory) {
47114754 typeStrategy ,
47124755 poolStrategy ,
47134756 classFileLocator ,
4757+ classFileVersion ,
47144758 listener ,
47154759 errorHandler ,
47164760 dispatcherFactory ,
@@ -4725,6 +4769,7 @@ public Engine ignore(ElementMatcher<? super TypeDescription> matcher) {
47254769 typeStrategy ,
47264770 poolStrategy ,
47274771 classFileLocator ,
4772+ classFileVersion ,
47284773 listener ,
47294774 errorHandler ,
47304775 dispatcherFactory ,
@@ -4755,8 +4800,8 @@ public Summary apply(Source source, Target target, List<? extends Plugin.Factory
47554800 }
47564801 }
47574802 Source .Origin origin = source .read ();
4758- try { // TODO: class file locator.
4759- ClassFileLocator classFileLocator = new ClassFileLocator .Compound (origin .toClassFileLocator (null ), this .classFileLocator );
4803+ try {
4804+ ClassFileLocator classFileLocator = new ClassFileLocator .Compound (origin .toClassFileLocator (classFileVersion ), this .classFileLocator );
47604805 TypePool typePool = poolStrategy .typePool (classFileLocator );
47614806 Manifest manifest = origin .getManifest ();
47624807 listener .onManifest (manifest );
0 commit comments