@@ -338,18 +338,18 @@ public <T> Supplier<InstanceHandle<T>> beanInstanceSupplier(Class<T> type, Annot
338338 if (bean == null ) {
339339 return null ;
340340 }
341+ InjectionPoint injectionPoint = InjectionPointImpl .of (type , qualifiers );
341342 return new Supplier <InstanceHandle <T >>() {
342343 @ Override
343344 public InstanceHandle <T > get () {
344- return beanInstanceHandle (bean , null );
345+ return beanInstanceHandle (bean , null , injectionPoint , null );
345346 }
346347 };
347348 }
348349
349350 @ Override
350351 public <T > InstanceHandle <T > instance (InjectableBean <T > bean ) {
351- Objects .requireNonNull (bean );
352- return beanInstanceHandle (bean , null );
352+ return beanInstanceHandle (Objects .requireNonNull (bean ), null , InjectionPointImpl .EMPTY , null );
353353 }
354354
355355 @ Override
@@ -404,7 +404,7 @@ public <T> InstanceHandle<T> instance(String name) {
404404 Set <InjectableBean <?>> resolvedBeans = beansByName .getValue (name );
405405 return resolvedBeans .size () != 1 ? EagerInstanceHandle .unavailable ()
406406 : (InstanceHandle <T >) beanInstanceHandle (resolvedBeans .iterator ()
407- .next (), null );
407+ .next (), null , InjectionPointImpl . EMPTY , null );
408408 }
409409
410410 @ Override
@@ -552,16 +552,21 @@ private static void addBuiltInBeans(List<InjectableBean<?>> beans, Map<String, L
552552 }
553553
554554 private <T > InstanceHandle <T > instanceHandle (Type type , Annotation ... qualifiers ) {
555- return beanInstanceHandle (getBean (type , qualifiers ), null );
555+ if (qualifiers == null || qualifiers .length == 0 ) {
556+ qualifiers = new Annotation [] { Default .Literal .INSTANCE };
557+ } else {
558+ registeredQualifiers .verify (qualifiers );
559+ }
560+ return beanInstanceHandle (getBean (type , qualifiers ), null , InjectionPointImpl .of (type , qualifiers ), null );
556561 }
557562
558563 static <T > InstanceHandle <T > beanInstanceHandle (InjectableBean <T > bean , CreationalContextImpl <T > parentContext ,
559- boolean resetCurrentInjectionPoint , Consumer <T > destroyLogic ) {
560- return beanInstanceHandle (bean , parentContext , resetCurrentInjectionPoint , destroyLogic , false );
564+ InjectionPoint resetInjectionPoint , Consumer <T > destroyLogic ) {
565+ return beanInstanceHandle (bean , parentContext , resetInjectionPoint , destroyLogic , false );
561566 }
562567
563568 static <T > InstanceHandle <T > beanInstanceHandle (InjectableBean <T > bean , CreationalContextImpl <T > parentContext ,
564- boolean resetCurrentInjectionPoint , Consumer <T > destroyLogic , boolean useParentCreationalContextDirectly ) {
569+ InjectionPoint resetInjectionPoint , Consumer <T > destroyLogic , boolean useParentCreationalContextDirectly ) {
565570 if (bean != null ) {
566571 if (parentContext == null && Dependent .class .equals (bean .getScope ())) {
567572 parentContext = new CreationalContextImpl <>(null );
@@ -573,14 +578,14 @@ static <T> InstanceHandle<T> beanInstanceHandle(InjectableBean<T> bean, Creation
573578 creationalContext = new CreationalContextImpl <>(bean );
574579 }
575580 InjectionPoint prev = null ;
576- if (resetCurrentInjectionPoint ) {
577- prev = InjectionPointProvider .setCurrent (creationalContext , CurrentInjectionPointProvider . EMPTY );
581+ if (resetInjectionPoint != null ) {
582+ prev = InjectionPointProvider .setCurrent (creationalContext , resetInjectionPoint );
578583 }
579584 try {
580585 return new EagerInstanceHandle <>(bean , bean .get (creationalContext ), creationalContext , parentContext ,
581586 destroyLogic );
582587 } finally {
583- if (resetCurrentInjectionPoint ) {
588+ if (resetInjectionPoint != null ) {
584589 InjectionPointProvider .setCurrent (creationalContext , prev );
585590 }
586591 }
@@ -589,17 +594,8 @@ static <T> InstanceHandle<T> beanInstanceHandle(InjectableBean<T> bean, Creation
589594 }
590595 }
591596
592- static <T > InstanceHandle <T > beanInstanceHandle (InjectableBean <T > bean , CreationalContextImpl <T > parentContext ) {
593- return beanInstanceHandle (bean , parentContext , true , null );
594- }
595-
596597 @ SuppressWarnings ("unchecked" )
597598 private <T > InjectableBean <T > getBean (Type requiredType , Annotation ... qualifiers ) {
598- if (qualifiers == null || qualifiers .length == 0 ) {
599- qualifiers = new Annotation [] { Default .Literal .INSTANCE };
600- } else {
601- registeredQualifiers .verify (qualifiers );
602- }
603599 Resolvable resolvable = new Resolvable (requiredType , qualifiers );
604600 Set <InjectableBean <?>> resolvedBeans = resolved .getValue (resolvable );
605601 if (resolvedBeans .isEmpty ()) {
@@ -1055,7 +1051,7 @@ public static ArcContainerImpl instance() {
10551051 <T > EventImpl <T > getEvent (Type eventType , Set <Annotation > eventQualifiers , InjectionPoint ip ) {
10561052 if (eventMocks != null ) {
10571053 AtomicReference <Event <?>> mock = eventMocks .computeIfAbsent (
1058- new TypeAndQualifiers (eventType , eventQualifiers ),
1054+ new TypeAndQualifiers (ip . getType (), ip . getQualifiers () ),
10591055 ArcContainerImpl ::newEventMockReference );
10601056 return new MockableEventImpl <>(eventType , eventQualifiers , ip , mock );
10611057 } else {
0 commit comments