From 9d4538c675ad6240b7fe24ae74bf2d8c61b4cde7 Mon Sep 17 00:00:00 2001 From: Matej Novotny Date: Thu, 14 Sep 2023 16:40:34 +0200 Subject: [PATCH] Code formatting changes due to new formatter/impsort rules --- .../jboss/weld/bean/AbstractClassBean.java | 21 +++--- .../java/org/jboss/weld/bean/ClassBean.java | 5 +- .../events/ProcessManagedBeanImpl.java | 11 ++-- .../events/ProcessSessionBeanImpl.java | 5 +- .../invokable/AbstractInvokerBuilder.java | 18 +++-- .../jboss/weld/invokable/CleanupActions.java | 6 +- .../weld/invokable/InvokerBuilderImpl.java | 4 +- .../org/jboss/weld/invokable/InvokerImpl.java | 4 +- .../weld/invokable/InvokerInfoBuilder.java | 4 +- .../org/jboss/weld/invokable/LookupUtils.java | 13 ++-- .../weld/invokable/MethodHandleUtils.java | 60 +++++++++++------ .../jboss/weld/invokable/PrimitiveUtils.java | 3 +- .../org/jboss/weld/logging/InvokerLogger.java | 2 +- .../weld/metadata/cache/InvokableModel.java | 7 +- .../metadata/cache/MetaAnnotationStore.java | 2 +- .../weld/invokable/Playground_Cleanup.java | 10 +-- .../weld/invokable/Playground_Lookup.java | 10 +-- .../weld/invokable/Playground_Spread.java | 2 +- .../invokable/Playground_Transformation.java | 3 +- .../weld/invokable/Playground_Wrapper.java | 9 +-- .../tests/invokable/BuildCompatExtension.java | 20 ++++-- .../invokable/InvokableMethodBCETest.java | 65 ++++++++++++------- .../tests/invokable/InvokableMethodTest.java | 63 +++++++++++------- .../tests/invokable/ObservingExtension.java | 12 ++-- .../jboss/weld/tests/invokable/SynthBean.java | 7 +- .../invokable/common/InstanceTransformer.java | 4 +- .../invokable/common/InvocationWrapper.java | 2 +- .../tests/invokable/lookup/BeanProducer.java | 12 ++-- .../tests/invokable/lookup/InvokableBean.java | 4 +- .../lookup/InvokableMethodLookupTest.java | 15 +++-- .../lookup/InvokerRegistreringExtension.java | 5 +- .../tests/invokable/lookup/MyQualifier1.java | 6 +- .../tests/invokable/lookup/MyQualifier2.java | 4 +- .../tests/invokable/lookup/MyQualifier3.java | 4 +- .../tests/invokable/lookup/MyQualifier4.java | 4 +- .../tests/invokable/lookup/MyQualifier5.java | 4 +- .../InvokableMethodDetectionTest.java | 1 + .../metadata/ObservingExtension.java | 8 +-- .../BuildExtension.java | 1 + .../InvokableMethodDetectionBCETest.java | 2 +- .../common/ClassLevelDirectDeclaration.java | 2 +- .../common/ClassLevelIndirectDeclaration.java | 2 +- .../common/ClassLevelViaExtension.java | 2 +- .../common/MethodLevelDirectDeclaration.java | 2 +- .../MethodLevelIndirectDeclaration.java | 2 +- .../common/MethodLevelViaExtension.java | 2 +- .../common/TransitivelyInvokable.java | 6 +- .../metadata/common/UnannotatedBean.java | 2 +- .../InvokableMethodHierarchyTest.java | 4 +- .../hierarchy/ObservingExtension.java | 5 +- .../hierarchy/TransitivelyInvokable.java | 7 +- .../transformers/input/AugmentedBean.java | 2 +- .../input/InputTransformerTest.java | 13 ++-- .../input/ObservingExtension.java | 5 +- .../output/ObservingExtension.java | 6 +- .../output/OutputTransformerTest.java | 25 +++---- .../transformers/output/Transformer.java | 1 - .../extension/translator/BeanInfoImpl.java | 9 +-- .../SyntheticComponentBuilderBase.java | 8 +-- 59 files changed, 315 insertions(+), 232 deletions(-) diff --git a/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java b/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java index eb2186a125..40e16d2112 100644 --- a/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java +++ b/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java @@ -16,6 +16,13 @@ */ package org.jboss.weld.bean; +import java.lang.annotation.Annotation; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + import jakarta.enterprise.inject.spi.AnnotatedMethod; import jakarta.enterprise.inject.spi.BeanAttributes; import jakarta.enterprise.inject.spi.Decorator; @@ -23,6 +30,7 @@ import jakarta.enterprise.inject.spi.InjectionTarget; import jakarta.enterprise.inject.spi.Producer; import jakarta.enterprise.invoke.Invokable; + import org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType; import org.jboss.weld.annotated.enhanced.MethodSignature; import org.jboss.weld.annotated.enhanced.jlr.MethodSignatureImpl; @@ -35,13 +43,6 @@ import org.jboss.weld.serialization.spi.BeanIdentifier; import org.jboss.weld.util.Beans; -import java.lang.annotation.Annotation; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - /** * An abstract bean representation common for class-based beans * @@ -210,7 +211,8 @@ private void initInvokableMethods() { } MethodSignature signature = MethodSignatureImpl.of(method); if (!encounteredMethods.contains(signature) && - (hasClassLevelInvokableAnnotation || method.getAnnotations().stream().anyMatch(a -> isInvokableAnnotation(a.annotationType(), metaAnnotationStore)))) { + (hasClassLevelInvokableAnnotation || method.getAnnotations().stream() + .anyMatch(a -> isInvokableAnnotation(a.annotationType(), metaAnnotationStore)))) { invokableMethods.add(method); } encounteredMethods.add(signature); @@ -227,7 +229,8 @@ private void initInvokableMethods() { * @param invokableCandidate annotation class to inspect * @return true if the annotation is considered {@link Invokable}, false otherwise */ - private boolean isInvokableAnnotation(Class invokableCandidate, MetaAnnotationStore metaAnnotationStore) { + private boolean isInvokableAnnotation(Class invokableCandidate, + MetaAnnotationStore metaAnnotationStore) { if (invokableCandidate.equals(Invokable.class)) { return true; } else { diff --git a/impl/src/main/java/org/jboss/weld/bean/ClassBean.java b/impl/src/main/java/org/jboss/weld/bean/ClassBean.java index 03996eb1eb..8e46518666 100644 --- a/impl/src/main/java/org/jboss/weld/bean/ClassBean.java +++ b/impl/src/main/java/org/jboss/weld/bean/ClassBean.java @@ -16,6 +16,8 @@ */ package org.jboss.weld.bean; +import java.util.Collection; + import jakarta.enterprise.inject.spi.AnnotatedMethod; import jakarta.enterprise.inject.spi.Bean; import jakarta.enterprise.inject.spi.BeanManager; @@ -25,8 +27,6 @@ import org.jboss.weld.annotated.slim.SlimAnnotatedType; import org.jboss.weld.manager.BeanManagerImpl; -import java.util.Collection; - /** * Marker for {@link Bean} implementations that are defined by a Java class. * @@ -67,6 +67,7 @@ public interface ClassBean extends WeldBean { /** * Returns a subset of methods of this class bean for which an invoker might be registered. + * * @return a collection of annotated methods for which an invoker can be registered */ Collection> getInvokableMethods(); diff --git a/impl/src/main/java/org/jboss/weld/bootstrap/events/ProcessManagedBeanImpl.java b/impl/src/main/java/org/jboss/weld/bootstrap/events/ProcessManagedBeanImpl.java index 033debe300..627bf80360 100644 --- a/impl/src/main/java/org/jboss/weld/bootstrap/events/ProcessManagedBeanImpl.java +++ b/impl/src/main/java/org/jboss/weld/bootstrap/events/ProcessManagedBeanImpl.java @@ -16,18 +16,19 @@ */ package org.jboss.weld.bootstrap.events; +import java.lang.reflect.Type; +import java.util.Collection; + import jakarta.enterprise.inject.spi.AnnotatedMethod; +import jakarta.enterprise.inject.spi.AnnotatedType; +import jakarta.enterprise.inject.spi.ProcessManagedBean; import jakarta.enterprise.invoke.Invoker; import jakarta.enterprise.invoke.InvokerBuilder; + import org.jboss.weld.bean.ManagedBean; import org.jboss.weld.invokable.InvokerBuilderImpl; import org.jboss.weld.manager.BeanManagerImpl; -import jakarta.enterprise.inject.spi.AnnotatedType; -import jakarta.enterprise.inject.spi.ProcessManagedBean; -import java.lang.reflect.Type; -import java.util.Collection; - public class ProcessManagedBeanImpl extends AbstractProcessClassBean> implements ProcessManagedBean { protected static void fire(BeanManagerImpl beanManager, ManagedBean bean) { diff --git a/impl/src/main/java/org/jboss/weld/bootstrap/events/ProcessSessionBeanImpl.java b/impl/src/main/java/org/jboss/weld/bootstrap/events/ProcessSessionBeanImpl.java index f955a7e905..dd2ef01e0f 100644 --- a/impl/src/main/java/org/jboss/weld/bootstrap/events/ProcessSessionBeanImpl.java +++ b/impl/src/main/java/org/jboss/weld/bootstrap/events/ProcessSessionBeanImpl.java @@ -23,9 +23,9 @@ import jakarta.enterprise.inject.spi.AnnotatedType; import jakarta.enterprise.inject.spi.ProcessSessionBean; import jakarta.enterprise.inject.spi.SessionBeanType; - import jakarta.enterprise.invoke.Invoker; import jakarta.enterprise.invoke.InvokerBuilder; + import org.jboss.weld.bean.SessionBean; import org.jboss.weld.invokable.InvokerBuilderImpl; import org.jboss.weld.logging.BootstrapLogger; @@ -80,6 +80,7 @@ public Collection> getInvokableMethods() { // TODO better exception throw new IllegalArgumentException("Not an invokable method: " + annotatedMethod); } - return new InvokerBuilderImpl<>(getBean().getEjbDescriptor().getBeanClass(), annotatedMethod.getJavaMember(), getBeanManager()); + return new InvokerBuilderImpl<>(getBean().getEjbDescriptor().getBeanClass(), annotatedMethod.getJavaMember(), + getBeanManager()); } } diff --git a/impl/src/main/java/org/jboss/weld/invokable/AbstractInvokerBuilder.java b/impl/src/main/java/org/jboss/weld/invokable/AbstractInvokerBuilder.java index a8a12fff56..a755d76ddc 100644 --- a/impl/src/main/java/org/jboss/weld/invokable/AbstractInvokerBuilder.java +++ b/impl/src/main/java/org/jboss/weld/invokable/AbstractInvokerBuilder.java @@ -1,8 +1,5 @@ package org.jboss.weld.invokable; -import jakarta.enterprise.inject.spi.BeanManager; -import jakarta.enterprise.invoke.InvokerBuilder; - import java.lang.annotation.Annotation; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -12,6 +9,9 @@ import java.lang.reflect.Parameter; import java.lang.reflect.Type; +import jakarta.enterprise.inject.spi.BeanManager; +import jakarta.enterprise.invoke.InvokerBuilder; + // TODO deployment-time validation of configured lookups abstract class AbstractInvokerBuilder implements InvokerBuilder { @@ -47,7 +47,8 @@ public InvokerBuilder setInstanceLookup() { public InvokerBuilder setArgumentLookup(int position) { if (position >= argLookup.length) { // TODO better exception - throw new IllegalArgumentException("Error attempting to set CDI argument lookup for arg number " + position + " while the number of method args is " + argLookup.length); + throw new IllegalArgumentException("Error attempting to set CDI argument lookup for arg number " + position + + " while the number of method args is " + argLookup.length); } argLookup[position] = true; return this; @@ -67,7 +68,8 @@ public InvokerBuilder setInstanceTransformer(Class clazz, String methodNam public InvokerBuilder setArgumentTransformer(int position, Class clazz, String methodName) { if (position >= argTransformers.length) { // TODO better exception - throw new IllegalArgumentException("Error attempting to set an argument lookup. Number of method args: " + argLookup.length + " arg position: " + position); + throw new IllegalArgumentException("Error attempting to set an argument lookup. Number of method args: " + + argLookup.length + " arg position: " + position); } if (argTransformers[position] != null) { // TODO better exception @@ -142,7 +144,8 @@ private boolean requiresCleanup() { if (instanceTransformerMethod.type().parameterCount() == 1) { // no cleanup mh = MethodHandles.filterArguments(mh, 0, instanceTransformerMethod); } else if (instanceTransformerMethod.type().parameterCount() == 2) { // cleanup - instanceTransformerMethod = instanceTransformerMethod.asType(instanceTransformerMethod.type().changeParameterType(1, CleanupActions.class)); + instanceTransformerMethod = instanceTransformerMethod + .asType(instanceTransformerMethod.type().changeParameterType(1, CleanupActions.class)); mh = MethodHandles.collectArguments(mh, 0, instanceTransformerMethod); instanceArguments++; } else { @@ -163,7 +166,8 @@ private boolean requiresCleanup() { if (argTransformerMethod.type().parameterCount() == 1) { // no cleanup mh = MethodHandles.filterArguments(mh, position, argTransformerMethod); } else if (argTransformerMethod.type().parameterCount() == 2) { // cleanup - argTransformerMethod = argTransformerMethod.asType(argTransformerMethod.type().changeParameterType(1, CleanupActions.class)); + argTransformerMethod = argTransformerMethod + .asType(argTransformerMethod.type().changeParameterType(1, CleanupActions.class)); mh = MethodHandles.collectArguments(mh, position, argTransformerMethod); } else { // internal error, this should not pass validation diff --git a/impl/src/main/java/org/jboss/weld/invokable/CleanupActions.java b/impl/src/main/java/org/jboss/weld/invokable/CleanupActions.java index 4d5ec9fb1c..c0edfa0ddf 100644 --- a/impl/src/main/java/org/jboss/weld/invokable/CleanupActions.java +++ b/impl/src/main/java/org/jboss/weld/invokable/CleanupActions.java @@ -1,12 +1,12 @@ package org.jboss.weld.invokable; -import jakarta.enterprise.context.Dependent; -import jakarta.enterprise.inject.Instance; - import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; +import jakarta.enterprise.context.Dependent; +import jakarta.enterprise.inject.Instance; + class CleanupActions implements Consumer { private final List cleanupTasks = new ArrayList<>(); private final List> dependentInstances = new ArrayList<>(); diff --git a/impl/src/main/java/org/jboss/weld/invokable/InvokerBuilderImpl.java b/impl/src/main/java/org/jboss/weld/invokable/InvokerBuilderImpl.java index b96a9c1f14..7503a15cb5 100644 --- a/impl/src/main/java/org/jboss/weld/invokable/InvokerBuilderImpl.java +++ b/impl/src/main/java/org/jboss/weld/invokable/InvokerBuilderImpl.java @@ -1,10 +1,10 @@ package org.jboss.weld.invokable; +import java.lang.reflect.Method; + import jakarta.enterprise.inject.spi.BeanManager; import jakarta.enterprise.invoke.Invoker; -import java.lang.reflect.Method; - public class InvokerBuilderImpl extends AbstractInvokerBuilder> { public InvokerBuilderImpl(Class beanClass, Method method, BeanManager beanManager) { diff --git a/impl/src/main/java/org/jboss/weld/invokable/InvokerImpl.java b/impl/src/main/java/org/jboss/weld/invokable/InvokerImpl.java index 067f1ed4df..cd6a300e1e 100644 --- a/impl/src/main/java/org/jboss/weld/invokable/InvokerImpl.java +++ b/impl/src/main/java/org/jboss/weld/invokable/InvokerImpl.java @@ -1,10 +1,10 @@ package org.jboss.weld.invokable; +import java.lang.invoke.MethodHandle; + import jakarta.enterprise.inject.build.compatible.spi.InvokerInfo; import jakarta.enterprise.invoke.Invoker; -import java.lang.invoke.MethodHandle; - public class InvokerImpl implements Invoker, InvokerInfo { private final MethodHandle mh; diff --git a/impl/src/main/java/org/jboss/weld/invokable/InvokerInfoBuilder.java b/impl/src/main/java/org/jboss/weld/invokable/InvokerInfoBuilder.java index 38f4afae3d..613816c645 100644 --- a/impl/src/main/java/org/jboss/weld/invokable/InvokerInfoBuilder.java +++ b/impl/src/main/java/org/jboss/weld/invokable/InvokerInfoBuilder.java @@ -1,10 +1,10 @@ package org.jboss.weld.invokable; +import java.lang.reflect.Method; + import jakarta.enterprise.inject.build.compatible.spi.InvokerInfo; import jakarta.enterprise.inject.spi.BeanManager; -import java.lang.reflect.Method; - public class InvokerInfoBuilder extends AbstractInvokerBuilder { public InvokerInfoBuilder(Class beanClass, Method method, BeanManager beanManager) { diff --git a/impl/src/main/java/org/jboss/weld/invokable/LookupUtils.java b/impl/src/main/java/org/jboss/weld/invokable/LookupUtils.java index e5c5cdd605..c6ccc46c2a 100644 --- a/impl/src/main/java/org/jboss/weld/invokable/LookupUtils.java +++ b/impl/src/main/java/org/jboss/weld/invokable/LookupUtils.java @@ -1,17 +1,18 @@ package org.jboss.weld.invokable; -import jakarta.enterprise.inject.Default; -import jakarta.enterprise.inject.Instance; -import jakarta.enterprise.inject.spi.BeanManager; -import jakarta.inject.Named; -import org.jboss.weld.inject.WeldInstance; - import java.lang.annotation.Annotation; import java.lang.reflect.Parameter; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; +import jakarta.enterprise.inject.Default; +import jakarta.enterprise.inject.Instance; +import jakarta.enterprise.inject.spi.BeanManager; +import jakarta.inject.Named; + +import org.jboss.weld.inject.WeldInstance; + class LookupUtils { private LookupUtils() { } diff --git a/impl/src/main/java/org/jboss/weld/invokable/MethodHandleUtils.java b/impl/src/main/java/org/jboss/weld/invokable/MethodHandleUtils.java index 86cd1ace6c..61ac07769a 100644 --- a/impl/src/main/java/org/jboss/weld/invokable/MethodHandleUtils.java +++ b/impl/src/main/java/org/jboss/weld/invokable/MethodHandleUtils.java @@ -1,9 +1,5 @@ package org.jboss.weld.invokable; -import jakarta.enterprise.inject.spi.BeanManager; -import jakarta.enterprise.inject.spi.DeploymentException; -import jakarta.enterprise.invoke.Invoker; - import java.lang.annotation.Annotation; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -15,6 +11,10 @@ import java.util.List; import java.util.function.Consumer; +import jakarta.enterprise.inject.spi.BeanManager; +import jakarta.enterprise.inject.spi.DeploymentException; +import jakarta.enterprise.invoke.Invoker; + class MethodHandleUtils { private MethodHandleUtils() { } @@ -47,8 +47,10 @@ private MethodHandleUtils() { } static MethodHandle createMethodHandle(Method method) { - MethodHandles.Lookup lookup = Modifier.isPublic(method.getModifiers()) && Modifier.isPublic(method.getDeclaringClass().getModifiers()) - ? MethodHandles.publicLookup() : MethodHandles.lookup(); + MethodHandles.Lookup lookup = Modifier.isPublic(method.getModifiers()) + && Modifier.isPublic(method.getDeclaringClass().getModifiers()) + ? MethodHandles.publicLookup() + : MethodHandles.lookup(); try { return lookup.unreflect(method); @@ -59,8 +61,10 @@ static MethodHandle createMethodHandle(Method method) { } static MethodHandle createMethodHandle(Constructor constructor) { - MethodHandles.Lookup lookup = Modifier.isPublic(constructor.getModifiers()) && Modifier.isPublic(constructor.getDeclaringClass().getModifiers()) - ? MethodHandles.publicLookup() : MethodHandles.lookup(); + MethodHandles.Lookup lookup = Modifier.isPublic(constructor.getModifiers()) + && Modifier.isPublic(constructor.getDeclaringClass().getModifiers()) + ? MethodHandles.publicLookup() + : MethodHandles.lookup(); try { return lookup.unreflectConstructor(constructor); @@ -70,7 +74,8 @@ static MethodHandle createMethodHandle(Constructor constructor) { } } - static MethodHandle createMethodHandleFromTransformer(Method targetMethod, TransformerMetadata transformer, Class transformationArgType) { + static MethodHandle createMethodHandleFromTransformer(Method targetMethod, TransformerMetadata transformer, + Class transformationArgType) { List matchingMethods = new ArrayList<>(); // transformers must be `public` and may be inherited (if not `static`) for (Method m : transformer.getDeclaringClass().getMethods()) { @@ -120,9 +125,11 @@ static MethodHandle createMethodHandleFromTransformer(Method targetMethod, Trans // if not assignable, then we need to apply a return value transformer which hides the value in an exception MethodHandle throwReturnValue = THROW_VALUE_CARRYING_EXCEPTION; // cast return value of the custom method we use to whatever the original method expects - we'll never use it anyway - throwReturnValue = throwReturnValue.asType(throwReturnValue.type().changeReturnType(targetMethod.getReturnType())); + throwReturnValue = throwReturnValue + .asType(throwReturnValue.type().changeReturnType(targetMethod.getReturnType())); // adapt the parameter type as well, we don't really care what it is, we just store it and throw it - throwReturnValue = throwReturnValue.asType(throwReturnValue.type().changeParameterType(0, result.type().returnType())); + throwReturnValue = throwReturnValue + .asType(throwReturnValue.type().changeParameterType(0, result.type().returnType())); result = MethodHandles.filterReturnValue(result, throwReturnValue); } } @@ -141,43 +148,53 @@ private static void validateTransformerMethod(Method m, TransformerMetadata tran // input transformers need to validate assignability of their return type versus original arg type if (!transformationArgType.isAssignableFrom(m.getReturnType())) { // TODO better exception - throw new DeploymentException("Input transformer " + transformer + " has a return value that is not assignable to expected class: " + transformationArgType); + throw new DeploymentException("Input transformer " + transformer + + " has a return value that is not assignable to expected class: " + transformationArgType); } // instance method is no-param, otherwise its 1-2 with second being Consumer - if (!Modifier.isStatic(m.getModifiers()) ) { + if (!Modifier.isStatic(m.getModifiers())) { if (paramCount != 0) { // TODO better exception - throw new DeploymentException("Non-static input transformers are expected to have zero input parameters! Transformer: " + transformer); + throw new DeploymentException( + "Non-static input transformers are expected to have zero input parameters! Transformer: " + + transformer); } } else { if (paramCount > 2) { // TODO better exception - throw new DeploymentException("Static input transformers can only have one or two parameters. " + transformer); + throw new DeploymentException( + "Static input transformers can only have one or two parameters. " + transformer); } if (paramCount == 2) { // we do not validate type param of Consumer, i.e. if it's exactly Consumer if (!Consumer.class.equals(m.getParameters()[1].getType())) { // TODO better exception - throw new DeploymentException("Static input transformers with two parameters can only have Consumer as their second parameter! " + transformer); + throw new DeploymentException( + "Static input transformers with two parameters can only have Consumer as their second parameter! " + + transformer); } } } } else if (transformer.isOutputTransformer()) { // output transformers need to validate assignability of their INPUT // this also means instance methods need no validation in this regard - if (!Modifier.isStatic(m.getModifiers()) ) { + if (!Modifier.isStatic(m.getModifiers())) { if (paramCount != 0) { // TODO better exception - throw new DeploymentException("Non-static output transformers are expected to have zero input parameters! Transformer: " + transformer); + throw new DeploymentException( + "Non-static output transformers are expected to have zero input parameters! Transformer: " + + transformer); } } else { if (paramCount != 1) { // TODO better exception - throw new DeploymentException("Static output transformers are expected to have one input parameter! Transformer: " + transformer); + throw new DeploymentException( + "Static output transformers are expected to have one input parameter! Transformer: " + transformer); } if (!m.getParameters()[0].getType().isAssignableFrom(transformationArgType)) { // TODO better exception - throw new DeploymentException("Output transformer " + transformer + " parameter is not assignable to the expected type " + transformationArgType); + throw new DeploymentException("Output transformer " + transformer + + " parameter is not assignable to the expected type " + transformationArgType); } } } else { @@ -190,7 +207,8 @@ private static void validateTransformerMethod(Method m, TransformerMetadata tran // OK } else { // TODO better exception - throw new DeploymentException("Invocation wrapper has unexpected parameters " + transformer + "\nExpected param types are: " + transformationArgType + ", Object[], Invoker.class"); + throw new DeploymentException("Invocation wrapper has unexpected parameters " + transformer + + "\nExpected param types are: " + transformationArgType + ", Object[], Invoker.class"); } } } diff --git a/impl/src/main/java/org/jboss/weld/invokable/PrimitiveUtils.java b/impl/src/main/java/org/jboss/weld/invokable/PrimitiveUtils.java index 6afc8d6298..a9f900687a 100644 --- a/impl/src/main/java/org/jboss/weld/invokable/PrimitiveUtils.java +++ b/impl/src/main/java/org/jboss/weld/invokable/PrimitiveUtils.java @@ -14,8 +14,7 @@ private PrimitiveUtils() { Map.entry(long.class, 0L), Map.entry(float.class, 0.0F), Map.entry(double.class, 0.0), - Map.entry(char.class, (char) 0) - ); + Map.entry(char.class, (char) 0)); static boolean hasPrimitive(Class[] types) { for (Class type : types) { diff --git a/impl/src/main/java/org/jboss/weld/logging/InvokerLogger.java b/impl/src/main/java/org/jboss/weld/logging/InvokerLogger.java index f118bdb353..4fd6e9cc56 100644 --- a/impl/src/main/java/org/jboss/weld/logging/InvokerLogger.java +++ b/impl/src/main/java/org/jboss/weld/logging/InvokerLogger.java @@ -12,7 +12,7 @@ * Message IDs: 002000 - 002099 */ @MessageLogger(projectCode = WELD_PROJECT_CODE) -public interface InvokerLogger extends WeldLogger{ +public interface InvokerLogger extends WeldLogger { @Message(id = 2000, value = "TBD {0}", format = Message.Format.MESSAGE_FORMAT) IllegalArgumentException tbd(Object param1); diff --git a/impl/src/main/java/org/jboss/weld/metadata/cache/InvokableModel.java b/impl/src/main/java/org/jboss/weld/metadata/cache/InvokableModel.java index 3ab211acf8..b7341ba603 100644 --- a/impl/src/main/java/org/jboss/weld/metadata/cache/InvokableModel.java +++ b/impl/src/main/java/org/jboss/weld/metadata/cache/InvokableModel.java @@ -1,12 +1,13 @@ package org.jboss.weld.metadata.cache; -import jakarta.enterprise.invoke.Invokable; -import org.jboss.weld.annotated.enhanced.EnhancedAnnotation; - import java.lang.annotation.Annotation; import java.util.Collections; import java.util.Set; +import jakarta.enterprise.invoke.Invokable; + +import org.jboss.weld.annotated.enhanced.EnhancedAnnotation; + public class InvokableModel extends AnnotationModel { private static final Set> META_ANNOTATIONS = Collections.singleton(Invokable.class); diff --git a/impl/src/main/java/org/jboss/weld/metadata/cache/MetaAnnotationStore.java b/impl/src/main/java/org/jboss/weld/metadata/cache/MetaAnnotationStore.java index 3cf3ffe6f0..608198fccd 100644 --- a/impl/src/main/java/org/jboss/weld/metadata/cache/MetaAnnotationStore.java +++ b/impl/src/main/java/org/jboss/weld/metadata/cache/MetaAnnotationStore.java @@ -227,7 +227,7 @@ public InterceptorBindingModel getInterceptorBindingMo *

* Adds the model if it is not present. * - * @param The type + * @param The type * @param annotation The annotation class * @return The invokable model */ diff --git a/impl/src/test/java/org/jboss/weld/invokable/Playground_Cleanup.java b/impl/src/test/java/org/jboss/weld/invokable/Playground_Cleanup.java index e6a332173d..87bc48eb8d 100644 --- a/impl/src/test/java/org/jboss/weld/invokable/Playground_Cleanup.java +++ b/impl/src/test/java/org/jboss/weld/invokable/Playground_Cleanup.java @@ -12,15 +12,16 @@ public static void main(String[] args) throws Throwable { System.out.println("!!!!!!! 2 " + mh.type()); MethodHandle cleanupMethod = mh.type().returnType() == void.class - ? MethodHandleUtils.createMethodHandle(CleanupActions.class.getDeclaredMethod("run", Throwable.class, CleanupActions.class)) - : MethodHandleUtils.createMethodHandle(CleanupActions.class.getDeclaredMethod("run", Throwable.class, Object.class, CleanupActions.class)); + ? MethodHandleUtils.createMethodHandle( + CleanupActions.class.getDeclaredMethod("run", Throwable.class, CleanupActions.class)) + : MethodHandleUtils.createMethodHandle( + CleanupActions.class.getDeclaredMethod("run", Throwable.class, Object.class, CleanupActions.class)); System.out.println("cleanup pre-adapt: " + cleanupMethod.type()); if (mh.type().returnType() != void.class) { cleanupMethod = cleanupMethod.asType(cleanupMethod.type() .changeReturnType(mh.type().returnType()) - .changeParameterType(1, mh.type().returnType()) - ); + .changeParameterType(1, mh.type().returnType())); } System.out.println("cleanup post-adapt: " + cleanupMethod.type()); @@ -34,7 +35,6 @@ public static void main(String[] args) throws Throwable { System.out.println(mh.invoke(cleanup, new Playground_Cleanup(), 42)); } - public String hello(int param) { return "hello_" + param; } diff --git a/impl/src/test/java/org/jboss/weld/invokable/Playground_Lookup.java b/impl/src/test/java/org/jboss/weld/invokable/Playground_Lookup.java index 64c2d9f11a..c00253a214 100644 --- a/impl/src/test/java/org/jboss/weld/invokable/Playground_Lookup.java +++ b/impl/src/test/java/org/jboss/weld/invokable/Playground_Lookup.java @@ -4,14 +4,14 @@ import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Arrays; public class Playground_Lookup { public static void main(String[] args) throws Throwable { - MethodHandle lookupMethod = MethodHandleUtils.createMethodHandle(Playground_Lookup.class.getMethod("lookup", CleanupActions.class)); + MethodHandle lookupMethod = MethodHandleUtils + .createMethodHandle(Playground_Lookup.class.getMethod("lookup", CleanupActions.class)); - Method targetMethod = Playground_Lookup.class.getMethod("hello", CleanupActions.class, Playground_Lookup.class, int.class, long.class, char.class); + Method targetMethod = Playground_Lookup.class.getMethod("hello", CleanupActions.class, Playground_Lookup.class, + int.class, long.class, char.class); boolean isStaticMethod = false; MethodHandle mh = MethodHandleUtils.createMethodHandle(targetMethod); @@ -39,7 +39,7 @@ public static void main(String[] args) throws Throwable { // arguments lookup // backwards iteration for correct construction of the resulting parameter list - boolean[] argumentsLookup = {true, false, true}; + boolean[] argumentsLookup = { true, false, true }; for (int i = argumentsLookup.length - 1; i >= 0; i--) { if (argumentsLookup[i]) { Class type = originalType.parameterType(i + (isStaticMethod ? 1 : 2)); diff --git a/impl/src/test/java/org/jboss/weld/invokable/Playground_Spread.java b/impl/src/test/java/org/jboss/weld/invokable/Playground_Spread.java index c5bac335c4..7b0073e54b 100644 --- a/impl/src/test/java/org/jboss/weld/invokable/Playground_Spread.java +++ b/impl/src/test/java/org/jboss/weld/invokable/Playground_Spread.java @@ -40,7 +40,7 @@ public static void main(String[] args) throws Throwable { } System.out.println("!!!!!!! 4 " + mh.type()); - System.out.println(mh.invoke(new CleanupActions(), new Playground_Spread(), new Object[] {null})); + System.out.println(mh.invoke(new CleanupActions(), new Playground_Spread(), new Object[] { null })); } public String hello(int param) { diff --git a/impl/src/test/java/org/jboss/weld/invokable/Playground_Transformation.java b/impl/src/test/java/org/jboss/weld/invokable/Playground_Transformation.java index 859205c24c..365b9d3ced 100644 --- a/impl/src/test/java/org/jboss/weld/invokable/Playground_Transformation.java +++ b/impl/src/test/java/org/jboss/weld/invokable/Playground_Transformation.java @@ -19,7 +19,8 @@ public static void main(String[] args) throws Throwable { int instanceArguments = isStaticMethod ? 0 : 1; // target instance - Method instanceTransformer = Playground_Transformation.class.getMethod("transformInstance", Playground_Transformation.class, Consumer.class); + Method instanceTransformer = Playground_Transformation.class.getMethod("transformInstance", + Playground_Transformation.class, Consumer.class); if (instanceTransformer != null && !isStaticMethod) { MethodHandle transformer = MethodHandles.lookup().unreflect(instanceTransformer); if (transformer.type().parameterCount() == 1) { // no cleanup diff --git a/impl/src/test/java/org/jboss/weld/invokable/Playground_Wrapper.java b/impl/src/test/java/org/jboss/weld/invokable/Playground_Wrapper.java index 782ee7bb91..9379701469 100644 --- a/impl/src/test/java/org/jboss/weld/invokable/Playground_Wrapper.java +++ b/impl/src/test/java/org/jboss/weld/invokable/Playground_Wrapper.java @@ -1,11 +1,11 @@ package org.jboss.weld.invokable; -import jakarta.enterprise.invoke.Invoker; - import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.util.Arrays; +import jakarta.enterprise.invoke.Invoker; + public class Playground_Wrapper { public static void main(String[] args) throws Throwable { MethodHandle mh = MethodHandleUtils.createMethodHandle(Playground_Wrapper.class.getMethod("hello", Object[].class)); @@ -13,11 +13,12 @@ public static void main(String[] args) throws Throwable { InvokerImpl invoker = new InvokerImpl<>(mh); - MethodHandle mh2 = MethodHandleUtils.createMethodHandle(Playground_Wrapper.class.getMethod("wrap", Playground_Wrapper.class, Object[].class, Invoker.class)); + MethodHandle mh2 = MethodHandleUtils.createMethodHandle( + Playground_Wrapper.class.getMethod("wrap", Playground_Wrapper.class, Object[].class, Invoker.class)); mh = MethodHandles.insertArguments(mh2, 2, invoker); System.out.println("!!!!!!! 2 " + mh.type()); - System.out.println(mh.invoke(new Playground_Wrapper(), new Object[] {42})); + System.out.println(mh.invoke(new Playground_Wrapper(), new Object[] { 42 })); } public static String wrap(Playground_Wrapper instance, Object[] arguments, Invoker invoker) { diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/BuildCompatExtension.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/BuildCompatExtension.java index 5f85729434..a0667a991b 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/BuildCompatExtension.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/BuildCompatExtension.java @@ -1,5 +1,7 @@ package org.jboss.weld.tests.invokable; +import java.util.Collection; + import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.inject.Instance; import jakarta.enterprise.inject.build.compatible.spi.BeanInfo; @@ -12,6 +14,7 @@ import jakarta.enterprise.inject.build.compatible.spi.SyntheticComponents; import jakarta.enterprise.invoke.Invoker; import jakarta.enterprise.lang.model.declarations.MethodInfo; + import org.jboss.weld.tests.invokable.common.ArgTransformer; import org.jboss.weld.tests.invokable.common.ExceptionTransformer; import org.jboss.weld.tests.invokable.common.FooArg; @@ -23,8 +26,6 @@ import org.jboss.weld.tests.invokable.common.TrulyExceptionalBean; import org.junit.Assert; -import java.util.Collection; - public class BuildCompatExtension implements BuildCompatibleExtension { // basic invokers, some with lookup @@ -139,12 +140,14 @@ public void createNoTransformationInvokers(BeanInfo b) { staticNoTransformationInvoker = b.createInvoker(invokableMethod).build(); staticInstanceLookupInvoker = b.createInvoker(invokableMethod).setInstanceLookup().build(); staticArgLookupInvoker = b.createInvoker(invokableMethod).setArgumentLookup(0).setArgumentLookup(1).build(); - staticLookupAllInvoker = b.createInvoker(invokableMethod).setArgumentLookup(0).setArgumentLookup(1).setInstanceLookup().build(); + staticLookupAllInvoker = b.createInvoker(invokableMethod).setArgumentLookup(0).setArgumentLookup(1) + .setInstanceLookup().build(); } else { noTransformationInvoker = b.createInvoker(invokableMethod).build(); instanceLookupInvoker = b.createInvoker(invokableMethod).setInstanceLookup().build(); argLookupInvoker = b.createInvoker(invokableMethod).setArgumentLookup(0).setArgumentLookup(1).build(); - lookupAllInvoker = b.createInvoker(invokableMethod).setArgumentLookup(0).setArgumentLookup(1).setInstanceLookup().build(); + lookupAllInvoker = b.createInvoker(invokableMethod).setArgumentLookup(0).setArgumentLookup(1) + .setInstanceLookup().build(); } } } @@ -271,14 +274,17 @@ public SynthBean create(Instance instance, Parameters parameters) { result.setArgTransformingInvoker(parameters.get(argTransformingInvokerString, Invoker.class)); result.setStaticArgTransformingInvoker(parameters.get(staticArgTransformingInvokerString, Invoker.class)); result.setArgTransformerWithConsumerInvoker(parameters.get(argTransformerWithConsumerInvokerString, Invoker.class)); - result.setStaticArgTransformerWithConsumerInvoker(parameters.get(staticArgTransformerWithConsumerInvokerString, Invoker.class)); + result.setStaticArgTransformerWithConsumerInvoker( + parameters.get(staticArgTransformerWithConsumerInvokerString, Invoker.class)); result.setInstanceTransformerInvoker(parameters.get(instanceTransformerInvokerString, Invoker.class)); - result.setInstanceTransformerWithConsumerInvoker(parameters.get(instanceTransformerWithConsumerInvokerString, Invoker.class)); + result.setInstanceTransformerWithConsumerInvoker( + parameters.get(instanceTransformerWithConsumerInvokerString, Invoker.class)); result.setInstanceTransformerNoParamInvoker(parameters.get(instanceTransformerNoParamInvokerString, Invoker.class)); result.setReturnTransformerInvoker(parameters.get(returnTransformerInvokerString, Invoker.class)); result.setReturnTransformerNoParamInvoker(parameters.get(returnTransformerNoParamInvokerString, Invoker.class)); result.setStaticReturnTransformerInvoker(parameters.get(staticReturnTransformerInvokerString, Invoker.class)); - result.setStaticReturnTransformerNoParamInvoker(parameters.get(staticReturnTransformerNoParamInvokerString, Invoker.class)); + result.setStaticReturnTransformerNoParamInvoker( + parameters.get(staticReturnTransformerNoParamInvokerString, Invoker.class)); result.setExceptionTransformerInvoker(parameters.get(exceptionTransformerInvokerString, Invoker.class)); result.setStaticExceptionTransformerInvoker(parameters.get(staticExceptionTransformerInvokerString, Invoker.class)); result.setInvocationWrapperInvoker(parameters.get(invocationWrapperInvokerString, Invoker.class)); diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/InvokableMethodBCETest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/InvokableMethodBCETest.java index 4a4b6638c5..0647a3cb8f 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/InvokableMethodBCETest.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/InvokableMethodBCETest.java @@ -2,6 +2,7 @@ import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension; import jakarta.inject.Inject; + import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; @@ -48,28 +49,29 @@ public void testSimpleInvokableMethod() { HelperBean.clearDestroyedCounters(); // no transformation invocation, no lookup - Assert.assertEquals("foo1", synthBean.getNoTransformationInvoker().invoke(simpleBean, new Object[]{"foo", 1})); + Assert.assertEquals("foo1", synthBean.getNoTransformationInvoker().invoke(simpleBean, new Object[] { "foo", 1 })); Assert.assertEquals(0, SimpleBean.preDestroyInvoked); Assert.assertEquals(0, HelperBean.timesStringDestroyed); Assert.assertEquals(0, HelperBean.timesIntDestroyed); // no transformation, instance lookup - Assert.assertEquals("foo1", synthBean.getInstanceLookupInvoker().invoke(null, new Object[]{"foo", 1})); + Assert.assertEquals("foo1", synthBean.getInstanceLookupInvoker().invoke(null, new Object[] { "foo", 1 })); Assert.assertEquals(1, SimpleBean.preDestroyInvoked); Assert.assertEquals(0, HelperBean.timesStringDestroyed); Assert.assertEquals(0, HelperBean.timesIntDestroyed); // no transformation, arg lookup (all) - Assert.assertEquals("bar42", synthBean.getArgLookupInvoker().invoke(simpleBean, new Object[]{"blah", null})); + Assert.assertEquals("bar42", synthBean.getArgLookupInvoker().invoke(simpleBean, new Object[] { "blah", null })); Assert.assertEquals(1, SimpleBean.preDestroyInvoked); Assert.assertEquals(1, HelperBean.timesStringDestroyed); Assert.assertEquals(1, HelperBean.timesIntDestroyed); // no transformation, instance lookup and arg lookup (all) - Assert.assertEquals("bar42", synthBean.getLookupAllInvoker().invoke(new SimpleBean(), new Object[]{"blah", null})); + Assert.assertEquals("bar42", synthBean.getLookupAllInvoker().invoke(new SimpleBean(), new Object[] { "blah", null })); Assert.assertEquals(2, SimpleBean.preDestroyInvoked); Assert.assertEquals(2, HelperBean.timesStringDestroyed); - Assert.assertEquals(2, HelperBean.timesIntDestroyed); } + Assert.assertEquals(2, HelperBean.timesIntDestroyed); + } @Test public void testSimpleStaticInvokableMethod() { @@ -77,25 +79,26 @@ public void testSimpleStaticInvokableMethod() { HelperBean.clearDestroyedCounters(); // no transformation invocation, no lookup - Assert.assertEquals("foo1", synthBean.getStaticNoTransformationInvoker().invoke(simpleBean, new Object[]{"foo", 1})); + Assert.assertEquals("foo1", synthBean.getStaticNoTransformationInvoker().invoke(simpleBean, new Object[] { "foo", 1 })); Assert.assertEquals(0, SimpleBean.preDestroyInvoked); Assert.assertEquals(0, HelperBean.timesStringDestroyed); Assert.assertEquals(0, HelperBean.timesIntDestroyed); // no transformation, no instance lookup (configured but skipped, it is a static method) - Assert.assertEquals("foo1", synthBean.getStaticInstanceLookupInvoker().invoke(null, new Object[]{"foo", 1})); + Assert.assertEquals("foo1", synthBean.getStaticInstanceLookupInvoker().invoke(null, new Object[] { "foo", 1 })); Assert.assertEquals(0, SimpleBean.preDestroyInvoked); Assert.assertEquals(0, HelperBean.timesStringDestroyed); Assert.assertEquals(0, HelperBean.timesIntDestroyed); // no transformation, arg lookup (all) - Assert.assertEquals("bar42", synthBean.getStaticArgLookupInvoker().invoke(simpleBean, new Object[]{"blah", null})); + Assert.assertEquals("bar42", synthBean.getStaticArgLookupInvoker().invoke(simpleBean, new Object[] { "blah", null })); Assert.assertEquals(0, SimpleBean.preDestroyInvoked); Assert.assertEquals(1, HelperBean.timesStringDestroyed); Assert.assertEquals(1, HelperBean.timesIntDestroyed); // no transformation, no instance lookup (configured but skipped) and arg lookup (all) - Assert.assertEquals("bar42", synthBean.getStaticLookupAllInvoker().invoke(new SimpleBean(), new Object[]{"blah", null})); + Assert.assertEquals("bar42", + synthBean.getStaticLookupAllInvoker().invoke(new SimpleBean(), new Object[] { "blah", null })); Assert.assertEquals(0, SimpleBean.preDestroyInvoked); Assert.assertEquals(2, HelperBean.timesStringDestroyed); Assert.assertEquals(2, HelperBean.timesIntDestroyed); @@ -107,14 +110,18 @@ public void testArgTransformingInvokableMethod() { String fooArg = "fooArg"; String expected = fooArg + fooArg + ArgTransformer.transformed; - Assert.assertEquals(expected, synthBean.getArgTransformingInvoker().invoke(transformableBean, new Object[]{new FooArg(fooArg), "bar"})); - Assert.assertEquals(expected, synthBean.getStaticArgTransformingInvoker().invoke(null, new Object[]{new FooArg(fooArg), "bar"})); + Assert.assertEquals(expected, + synthBean.getArgTransformingInvoker().invoke(transformableBean, new Object[] { new FooArg(fooArg), "bar" })); + Assert.assertEquals(expected, + synthBean.getStaticArgTransformingInvoker().invoke(null, new Object[] { new FooArg(fooArg), "bar" })); // transformer with Consumer parameter Assert.assertEquals(0, ArgTransformer.runnableExecuted); - Assert.assertEquals(expected, synthBean.getArgTransformerWithConsumerInvoker().invoke(transformableBean, new Object[]{new FooArg(fooArg), "bar"})); + Assert.assertEquals(expected, synthBean.getArgTransformerWithConsumerInvoker().invoke(transformableBean, + new Object[] { new FooArg(fooArg), "bar" })); Assert.assertEquals(1, ArgTransformer.runnableExecuted); - Assert.assertEquals(expected, synthBean.getStaticArgTransformerWithConsumerInvoker().invoke(null, new Object[]{new FooArg(fooArg), "bar"})); + Assert.assertEquals(expected, synthBean.getStaticArgTransformerWithConsumerInvoker().invoke(null, + new Object[] { new FooArg(fooArg), "bar" })); Assert.assertEquals(2, ArgTransformer.runnableExecuted); } @@ -130,21 +137,24 @@ public void testInstanceTransformingInvokableMethod() { // transformer defined on other class targetInstance = new TransformableBean(); Assert.assertFalse(targetInstance.isTransformed()); - Assert.assertEquals(expected, synthBean.getInstanceTransformerInvoker().invoke(targetInstance, new Object[]{new FooArg(fooArg), fooArg})); + Assert.assertEquals(expected, + synthBean.getInstanceTransformerInvoker().invoke(targetInstance, new Object[] { new FooArg(fooArg), fooArg })); Assert.assertTrue(targetInstance.isTransformed()); // transformer defined on other class with Consumer param targetInstance = new TransformableBean(); Assert.assertFalse(targetInstance.isTransformed()); Assert.assertEquals(0, InstanceTransformer.runnableExecuted); - Assert.assertEquals(expected, synthBean.getInstanceTransformerWithConsumerInvoker().invoke(targetInstance, new Object[]{new FooArg(fooArg), fooArg})); + Assert.assertEquals(expected, synthBean.getInstanceTransformerWithConsumerInvoker().invoke(targetInstance, + new Object[] { new FooArg(fooArg), fooArg })); Assert.assertEquals(1, InstanceTransformer.runnableExecuted); Assert.assertTrue(targetInstance.isTransformed()); // transformer on the bean class, no arg method targetInstance = new TransformableBean(); Assert.assertFalse(targetInstance.isTransformed()); - Assert.assertEquals(expected, synthBean.getInstanceTransformerNoParamInvoker().invoke(targetInstance, new Object[]{new FooArg(fooArg), fooArg})); + Assert.assertEquals(expected, synthBean.getInstanceTransformerNoParamInvoker().invoke(targetInstance, + new Object[] { new FooArg(fooArg), fooArg })); Assert.assertTrue(targetInstance.isTransformed()); } @@ -154,12 +164,16 @@ public void testReturnValueTransformingInvokableMethod() { String expected = (fooArg + fooArg).strip(); // transformer defined on other class - Assert.assertEquals(expected, synthBean.getReturnTransformerInvoker().invoke(transformableBean, new Object[]{new FooArg(fooArg), fooArg})); - Assert.assertEquals(expected, synthBean.getStaticReturnTransformerInvoker().invoke(transformableBean, new Object[]{new FooArg(fooArg), fooArg})); + Assert.assertEquals(expected, + synthBean.getReturnTransformerInvoker().invoke(transformableBean, new Object[] { new FooArg(fooArg), fooArg })); + Assert.assertEquals(expected, synthBean.getStaticReturnTransformerInvoker().invoke(transformableBean, + new Object[] { new FooArg(fooArg), fooArg })); // transformer on the result class (String), no arg method - Assert.assertEquals(expected, synthBean.getReturnTransformerNoParamInvoker().invoke(transformableBean, new Object[]{new FooArg(fooArg), fooArg})); - Assert.assertEquals(expected, synthBean.getStaticReturnTransformerNoParamInvoker().invoke(transformableBean, new Object[]{new FooArg(fooArg), fooArg})); + Assert.assertEquals(expected, synthBean.getReturnTransformerNoParamInvoker().invoke(transformableBean, + new Object[] { new FooArg(fooArg), fooArg })); + Assert.assertEquals(expected, synthBean.getStaticReturnTransformerNoParamInvoker().invoke(transformableBean, + new Object[] { new FooArg(fooArg), fooArg })); } @Test @@ -168,8 +182,10 @@ public void testExceptionTransformingInvokableMethod() { String expectedStatic = IllegalStateException.class.getSimpleName(); // exception transformer can only be defined on other class - Assert.assertEquals(expected, synthBean.getExceptionTransformerInvoker().invoke(trulyExceptionalBean, new Object[]{"foo", 42})); - Assert.assertEquals(expectedStatic, synthBean.getStaticExceptionTransformerInvoker().invoke(trulyExceptionalBean, new Object[]{"foo", 42})); + Assert.assertEquals(expected, + synthBean.getExceptionTransformerInvoker().invoke(trulyExceptionalBean, new Object[] { "foo", 42 })); + Assert.assertEquals(expectedStatic, + synthBean.getStaticExceptionTransformerInvoker().invoke(trulyExceptionalBean, new Object[] { "foo", 42 })); } @Test @@ -177,7 +193,8 @@ public void testInvocationWrapperInvokableMethod() { String expected = "foo42foo42"; // invocation wrapper defined on other class - Assert.assertEquals(expected, synthBean.getInvocationWrapperInvoker().invoke(simpleBean, new Object[]{"foo", 42})); - Assert.assertEquals(expected, synthBean.getStaticInvocationWrapperInvoker().invoke(simpleBean, new Object[]{"foo", 42})); + Assert.assertEquals(expected, synthBean.getInvocationWrapperInvoker().invoke(simpleBean, new Object[] { "foo", 42 })); + Assert.assertEquals(expected, + synthBean.getStaticInvocationWrapperInvoker().invoke(simpleBean, new Object[] { "foo", 42 })); } } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/InvokableMethodTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/InvokableMethodTest.java index 84a96fd9ab..b82c9efde9 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/InvokableMethodTest.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/InvokableMethodTest.java @@ -2,13 +2,13 @@ import jakarta.enterprise.inject.spi.Extension; import jakarta.inject.Inject; + import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.BeanArchive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.weld.test.util.Utils; - import org.jboss.weld.tests.invokable.common.ArgTransformer; import org.jboss.weld.tests.invokable.common.FooArg; import org.jboss.weld.tests.invokable.common.HelperBean; @@ -49,25 +49,25 @@ public void testSimpleInvokableMethod() { HelperBean.clearDestroyedCounters(); // no transformation invocation, no lookup - Assert.assertEquals("foo1", extension.getNoTransformationInvoker().invoke(simpleBean, new Object[]{"foo", 1})); + Assert.assertEquals("foo1", extension.getNoTransformationInvoker().invoke(simpleBean, new Object[] { "foo", 1 })); Assert.assertEquals(0, SimpleBean.preDestroyInvoked); Assert.assertEquals(0, HelperBean.timesStringDestroyed); Assert.assertEquals(0, HelperBean.timesIntDestroyed); // no transformation, instance lookup - Assert.assertEquals("foo1", extension.getInstanceLookupInvoker().invoke(null, new Object[]{"foo", 1})); + Assert.assertEquals("foo1", extension.getInstanceLookupInvoker().invoke(null, new Object[] { "foo", 1 })); Assert.assertEquals(1, SimpleBean.preDestroyInvoked); Assert.assertEquals(0, HelperBean.timesStringDestroyed); Assert.assertEquals(0, HelperBean.timesIntDestroyed); // no transformation, arg lookup (all) - Assert.assertEquals("bar42", extension.getArgLookupInvoker().invoke(simpleBean, new Object[]{"blah", null})); + Assert.assertEquals("bar42", extension.getArgLookupInvoker().invoke(simpleBean, new Object[] { "blah", null })); Assert.assertEquals(1, SimpleBean.preDestroyInvoked); Assert.assertEquals(1, HelperBean.timesStringDestroyed); Assert.assertEquals(1, HelperBean.timesIntDestroyed); // no transformation, instance lookup and arg lookup (all) - Assert.assertEquals("bar42", extension.getLookupAllInvoker().invoke(new SimpleBean(), new Object[]{"blah", null})); + Assert.assertEquals("bar42", extension.getLookupAllInvoker().invoke(new SimpleBean(), new Object[] { "blah", null })); Assert.assertEquals(2, SimpleBean.preDestroyInvoked); Assert.assertEquals(2, HelperBean.timesStringDestroyed); Assert.assertEquals(2, HelperBean.timesIntDestroyed); @@ -79,25 +79,26 @@ public void testSimpleStaticInvokableMethod() { HelperBean.clearDestroyedCounters(); // no transformation invocation, no lookup - Assert.assertEquals("foo1", extension.getStaticNoTransformationInvoker().invoke(simpleBean, new Object[]{"foo", 1})); + Assert.assertEquals("foo1", extension.getStaticNoTransformationInvoker().invoke(simpleBean, new Object[] { "foo", 1 })); Assert.assertEquals(0, SimpleBean.preDestroyInvoked); Assert.assertEquals(0, HelperBean.timesStringDestroyed); Assert.assertEquals(0, HelperBean.timesIntDestroyed); // no transformation, no instance lookup (configured but skipped, it is a static method) - Assert.assertEquals("foo1", extension.getStaticInstanceLookupInvoker().invoke(null, new Object[]{"foo", 1})); + Assert.assertEquals("foo1", extension.getStaticInstanceLookupInvoker().invoke(null, new Object[] { "foo", 1 })); Assert.assertEquals(0, SimpleBean.preDestroyInvoked); Assert.assertEquals(0, HelperBean.timesStringDestroyed); Assert.assertEquals(0, HelperBean.timesIntDestroyed); // no transformation, arg lookup (all) - Assert.assertEquals("bar42", extension.getStaticArgLookupInvoker().invoke(simpleBean, new Object[]{"blah", null})); + Assert.assertEquals("bar42", extension.getStaticArgLookupInvoker().invoke(simpleBean, new Object[] { "blah", null })); Assert.assertEquals(0, SimpleBean.preDestroyInvoked); Assert.assertEquals(1, HelperBean.timesStringDestroyed); Assert.assertEquals(1, HelperBean.timesIntDestroyed); // no transformation, no instance lookup (configured but skipped) and arg lookup (all) - Assert.assertEquals("bar42", extension.getStaticLookupAllInvoker().invoke(new SimpleBean(), new Object[]{"blah", null})); + Assert.assertEquals("bar42", + extension.getStaticLookupAllInvoker().invoke(new SimpleBean(), new Object[] { "blah", null })); Assert.assertEquals(0, SimpleBean.preDestroyInvoked); Assert.assertEquals(2, HelperBean.timesStringDestroyed); Assert.assertEquals(2, HelperBean.timesIntDestroyed); @@ -109,14 +110,18 @@ public void testArgTransformingInvokableMethod() { String fooArg = "fooArg"; String expected = fooArg + fooArg + ArgTransformer.transformed; - Assert.assertEquals(expected, extension.getArgTransformingInvoker().invoke(transformableBean, new Object[]{new FooArg(fooArg), "bar"})); - Assert.assertEquals(expected, extension.getStaticArgTransformingInvoker().invoke(null, new Object[]{new FooArg(fooArg), "bar"})); + Assert.assertEquals(expected, + extension.getArgTransformingInvoker().invoke(transformableBean, new Object[] { new FooArg(fooArg), "bar" })); + Assert.assertEquals(expected, + extension.getStaticArgTransformingInvoker().invoke(null, new Object[] { new FooArg(fooArg), "bar" })); // transformer with Consumer parameter Assert.assertEquals(0, ArgTransformer.runnableExecuted); - Assert.assertEquals(expected, extension.getArgTransformerWithConsumerInvoker().invoke(transformableBean, new Object[]{new FooArg(fooArg), "bar"})); + Assert.assertEquals(expected, extension.getArgTransformerWithConsumerInvoker().invoke(transformableBean, + new Object[] { new FooArg(fooArg), "bar" })); Assert.assertEquals(1, ArgTransformer.runnableExecuted); - Assert.assertEquals(expected, extension.getStaticArgTransformerWithConsumerInvoker().invoke(null, new Object[]{new FooArg(fooArg), "bar"})); + Assert.assertEquals(expected, extension.getStaticArgTransformerWithConsumerInvoker().invoke(null, + new Object[] { new FooArg(fooArg), "bar" })); Assert.assertEquals(2, ArgTransformer.runnableExecuted); } @@ -132,21 +137,24 @@ public void testInstanceTransformingInvokableMethod() { // transformer defined on other class targetInstance = new TransformableBean(); Assert.assertFalse(targetInstance.isTransformed()); - Assert.assertEquals(expected, extension.getInstanceTransformerInvoker().invoke(targetInstance, new Object[]{new FooArg(fooArg), fooArg})); + Assert.assertEquals(expected, + extension.getInstanceTransformerInvoker().invoke(targetInstance, new Object[] { new FooArg(fooArg), fooArg })); Assert.assertTrue(targetInstance.isTransformed()); // transformer defined on other class with Consumer param targetInstance = new TransformableBean(); Assert.assertFalse(targetInstance.isTransformed()); Assert.assertEquals(0, InstanceTransformer.runnableExecuted); - Assert.assertEquals(expected, extension.getInstanceTransformerWithConsumerInvoker().invoke(targetInstance, new Object[]{new FooArg(fooArg), fooArg})); + Assert.assertEquals(expected, extension.getInstanceTransformerWithConsumerInvoker().invoke(targetInstance, + new Object[] { new FooArg(fooArg), fooArg })); Assert.assertEquals(1, InstanceTransformer.runnableExecuted); Assert.assertTrue(targetInstance.isTransformed()); // transformer on the bean class, no arg method targetInstance = new TransformableBean(); Assert.assertFalse(targetInstance.isTransformed()); - Assert.assertEquals(expected, extension.getInstanceTransformerNoParamInvoker().invoke(targetInstance, new Object[]{new FooArg(fooArg), fooArg})); + Assert.assertEquals(expected, extension.getInstanceTransformerNoParamInvoker().invoke(targetInstance, + new Object[] { new FooArg(fooArg), fooArg })); Assert.assertTrue(targetInstance.isTransformed()); } @@ -156,12 +164,16 @@ public void testReturnValueTransformingInvokableMethod() { String expected = (fooArg + fooArg).strip(); // transformer defined on other class - Assert.assertEquals(expected, extension.getReturnTransformerInvoker().invoke(transformableBean, new Object[]{new FooArg(fooArg), fooArg})); - Assert.assertEquals(expected, extension.getStaticReturnTransformerInvoker().invoke(transformableBean, new Object[]{new FooArg(fooArg), fooArg})); + Assert.assertEquals(expected, + extension.getReturnTransformerInvoker().invoke(transformableBean, new Object[] { new FooArg(fooArg), fooArg })); + Assert.assertEquals(expected, extension.getStaticReturnTransformerInvoker().invoke(transformableBean, + new Object[] { new FooArg(fooArg), fooArg })); // transformer on the result class (String), no arg method - Assert.assertEquals(expected, extension.getReturnTransformerNoParamInvoker().invoke(transformableBean, new Object[]{new FooArg(fooArg), fooArg})); - Assert.assertEquals(expected, extension.getStaticReturnTransformerNoParamInvoker().invoke(transformableBean, new Object[]{new FooArg(fooArg), fooArg})); + Assert.assertEquals(expected, extension.getReturnTransformerNoParamInvoker().invoke(transformableBean, + new Object[] { new FooArg(fooArg), fooArg })); + Assert.assertEquals(expected, extension.getStaticReturnTransformerNoParamInvoker().invoke(transformableBean, + new Object[] { new FooArg(fooArg), fooArg })); } @Test @@ -170,8 +182,10 @@ public void testExceptionTransformingInvokableMethod() { String expectedStatic = IllegalStateException.class.getSimpleName(); // exception transformer can only be defined on other class - Assert.assertEquals(expected, extension.getExceptionTransformerInvoker().invoke(trulyExceptionalBean, new Object[]{"foo", 42})); - Assert.assertEquals(expectedStatic, extension.getStaticExceptionTransformerInvoker().invoke(trulyExceptionalBean, new Object[]{"foo", 42})); + Assert.assertEquals(expected, + extension.getExceptionTransformerInvoker().invoke(trulyExceptionalBean, new Object[] { "foo", 42 })); + Assert.assertEquals(expectedStatic, + extension.getStaticExceptionTransformerInvoker().invoke(trulyExceptionalBean, new Object[] { "foo", 42 })); } @Test @@ -179,7 +193,8 @@ public void testInvocationWrapperInvokableMethod() { String expected = "foo42foo42"; // invocation wrapper defined on other class - Assert.assertEquals(expected, extension.getInvocationWrapperInvoker().invoke(simpleBean, new Object[]{"foo", 42})); - Assert.assertEquals(expected, extension.getStaticInvocationWrapperInvoker().invoke(simpleBean, new Object[]{"foo", 42})); + Assert.assertEquals(expected, extension.getInvocationWrapperInvoker().invoke(simpleBean, new Object[] { "foo", 42 })); + Assert.assertEquals(expected, + extension.getStaticInvocationWrapperInvoker().invoke(simpleBean, new Object[] { "foo", 42 })); } } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/ObservingExtension.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/ObservingExtension.java index ad1462672e..300d39307c 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/ObservingExtension.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/ObservingExtension.java @@ -1,10 +1,13 @@ package org.jboss.weld.tests.invokable; +import java.util.Collection; + import jakarta.enterprise.event.Observes; import jakarta.enterprise.inject.spi.AnnotatedMethod; import jakarta.enterprise.inject.spi.Extension; import jakarta.enterprise.inject.spi.ProcessManagedBean; import jakarta.enterprise.invoke.Invoker; + import org.jboss.weld.tests.invokable.common.ArgTransformer; import org.jboss.weld.tests.invokable.common.ExceptionTransformer; import org.jboss.weld.tests.invokable.common.FooArg; @@ -16,8 +19,6 @@ import org.jboss.weld.tests.invokable.common.TrulyExceptionalBean; import org.junit.Assert; -import java.util.Collection; - public class ObservingExtension implements Extension { public Invoker getNoTransformationInvoker() { @@ -147,7 +148,6 @@ public class ObservingExtension implements Extension { private Invoker invocationWrapperInvoker; private Invoker staticInvocationWrapperInvoker; - public void createNoTransformationInvokers(@Observes ProcessManagedBean pmb) { Collection> invokableMethods = pmb.getInvokableMethods(); Assert.assertEquals(2, invokableMethods.size()); @@ -156,12 +156,14 @@ public void createNoTransformationInvokers(@Observes ProcessManagedBean a this.argTransformerWithConsumerInvoker = argTransformerWithConsumerInvoker; } - public void setStaticArgTransformerWithConsumerInvoker(Invoker staticArgTransformerWithConsumerInvoker) { + public void setStaticArgTransformerWithConsumerInvoker( + Invoker staticArgTransformerWithConsumerInvoker) { this.staticArgTransformerWithConsumerInvoker = staticArgTransformerWithConsumerInvoker; } @@ -117,7 +119,8 @@ public void setInstanceTransformerInvoker(Invoker instance this.instanceTransformerInvoker = instanceTransformerInvoker; } - public void setInstanceTransformerWithConsumerInvoker(Invoker instanceTransformerWithConsumerInvoker) { + public void setInstanceTransformerWithConsumerInvoker( + Invoker instanceTransformerWithConsumerInvoker) { this.instanceTransformerWithConsumerInvoker = instanceTransformerWithConsumerInvoker; } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/common/InstanceTransformer.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/common/InstanceTransformer.java index 7c37ad32c3..59a8cee3ba 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/common/InstanceTransformer.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/common/InstanceTransformer.java @@ -7,12 +7,12 @@ public class InstanceTransformer { public static int runnableExecuted = 0; - public static TransformableBean transform(TransformableBean bean){ + public static TransformableBean transform(TransformableBean bean) { bean.setTransformed(); return bean; } - public static TransformableBean transform2(TransformableBean bean, Consumer consumer){ + public static TransformableBean transform2(TransformableBean bean, Consumer consumer) { consumer.accept(() -> runnableExecuted++); bean.setTransformed(); return bean; diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/common/InvocationWrapper.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/common/InvocationWrapper.java index b6ab5997ff..0d55703200 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/common/InvocationWrapper.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/common/InvocationWrapper.java @@ -8,7 +8,7 @@ public static Object transform(SimpleBean instance, Object[] arguments, Invoker< Object result1 = invoker.invoke(instance, arguments); Object result2 = invoker.invoke(instance, arguments); if (result1 instanceof String && result2 instanceof String) { - return (String)result1 + result2; + return (String) result1 + result2; } else { throw new AssertionError(); } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/BeanProducer.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/BeanProducer.java index 67441197e1..19ad91895c 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/BeanProducer.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/BeanProducer.java @@ -9,36 +9,36 @@ public class BeanProducer { @Produces @MyQualifier1("foo") @MyQualifier4("binding") - public String produce1 () { + public String produce1() { return MyQualifier1.class.getSimpleName() + MyQualifier4.class.getSimpleName(); } @Produces @MyQualifier2 - public String produce2 () { + public String produce2() { return MyQualifier2.class.getSimpleName(); } @Produces @MyQualifier5 - public String produceAmbig1 () { + public String produceAmbig1() { throw new IllegalStateException("Ambiguous producer should never be invoked"); } @Produces @MyQualifier5 - public String produceAmbig2 () { + public String produceAmbig2() { throw new IllegalStateException("Ambiguous producer should never be invoked"); } @Produces - public String producePlain () { + public String producePlain() { throw new IllegalStateException("No qualifier producer should never be invoked"); } @Produces @ToBeQualifier - public String produceQualified () { + public String produceQualified() { return ToBeQualifier.class.getSimpleName(); } } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/InvokableBean.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/InvokableBean.java index f0d81ea71b..76da4ca561 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/InvokableBean.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/InvokableBean.java @@ -22,11 +22,11 @@ public String unsatisfiedLookup(@MyQualifier3 String a) { return a; } - public String correctLookup (@MyQualifier1("noMatter") @MyQualifier4("binding") String a, @MyQualifier2 String b) { + public String correctLookup(@MyQualifier1("noMatter") @MyQualifier4("binding") String a, @MyQualifier2 String b) { return a + b; } - public String lookupWithRegisteredQualifier (@ToBeQualifier String a) { + public String lookupWithRegisteredQualifier(@ToBeQualifier String a) { return a; } } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/InvokableMethodLookupTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/InvokableMethodLookupTest.java index 2588482b2b..c92885836c 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/InvokableMethodLookupTest.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/InvokableMethodLookupTest.java @@ -8,6 +8,7 @@ import jakarta.enterprise.inject.UnsatisfiedResolutionException; import jakarta.enterprise.inject.spi.Extension; import jakarta.inject.Inject; + import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; @@ -36,21 +37,23 @@ public static Archive getDeployment() { @Test public void testInstanceLookupWithQualifiers() { - Object invokerResult = extension.getInstanceLookupInvoker().invoke(null, new Object[]{}); + Object invokerResult = extension.getInstanceLookupInvoker().invoke(null, new Object[] {}); assertTrue(invokerResult instanceof String); assertEquals(InvokableBean.class.getSimpleName(), invokerResult); } @Test public void testCorrectArgLookupWithQualifiers() { - Object invokerResult = extension.getCorrectLookupInvoker().invoke(bean, new Object[]{null, null}); + Object invokerResult = extension.getCorrectLookupInvoker().invoke(bean, new Object[] { null, null }); assertTrue(invokerResult instanceof String); - assertEquals(MyQualifier1.class.getSimpleName() + MyQualifier4.class.getSimpleName() + MyQualifier2.class.getSimpleName(), invokerResult); + assertEquals( + MyQualifier1.class.getSimpleName() + MyQualifier4.class.getSimpleName() + MyQualifier2.class.getSimpleName(), + invokerResult); } @Test public void testLookupWithRegisteredQualifier() { - Object invokerResult = extension.getLookupWithRegisteredQualifier().invoke(bean, new Object[]{null}); + Object invokerResult = extension.getLookupWithRegisteredQualifier().invoke(bean, new Object[] { null }); assertTrue(invokerResult instanceof String); assertEquals(ToBeQualifier.class.getSimpleName(), invokerResult); } @@ -58,7 +61,7 @@ public void testLookupWithRegisteredQualifier() { @Test public void testUnsatisfiedLookupWithQualifier() { try { - Object invokerResult = extension.getUnsatisfiedLookupInvoker().invoke(bean, new Object[]{null}); + Object invokerResult = extension.getUnsatisfiedLookupInvoker().invoke(bean, new Object[] { null }); fail(); } catch (UnsatisfiedResolutionException e) { // expected @@ -68,7 +71,7 @@ public void testUnsatisfiedLookupWithQualifier() { @Test public void testAmbigLookupWithQualifiers() { try { - Object invokerResult = extension.getAmbiguousLookupInvoker().invoke(bean, new Object[]{null}); + Object invokerResult = extension.getAmbiguousLookupInvoker().invoke(bean, new Object[] { null }); fail(); } catch (AmbiguousResolutionException e) { // expected diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/InvokerRegistreringExtension.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/InvokerRegistreringExtension.java index 585feb1681..2bbf34247b 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/InvokerRegistreringExtension.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/InvokerRegistreringExtension.java @@ -1,14 +1,15 @@ package org.jboss.weld.tests.invokable.lookup; +import java.util.Collection; + import jakarta.enterprise.event.Observes; import jakarta.enterprise.inject.spi.AnnotatedMethod; import jakarta.enterprise.inject.spi.BeforeBeanDiscovery; import jakarta.enterprise.inject.spi.Extension; import jakarta.enterprise.inject.spi.ProcessManagedBean; import jakarta.enterprise.invoke.Invoker; -import org.junit.Assert; -import java.util.Collection; +import org.junit.Assert; public class InvokerRegistreringExtension implements Extension { diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier1.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier1.java index db73bef100..25ca54a356 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier1.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier1.java @@ -1,11 +1,11 @@ package org.jboss.weld.tests.invokable.lookup; -import jakarta.enterprise.util.Nonbinding; -import jakarta.inject.Qualifier; - import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import jakarta.enterprise.util.Nonbinding; +import jakarta.inject.Qualifier; + @Retention(RetentionPolicy.RUNTIME) @Qualifier public @interface MyQualifier1 { diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier2.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier2.java index b5b3cc1161..e62af269d7 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier2.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier2.java @@ -1,10 +1,10 @@ package org.jboss.weld.tests.invokable.lookup; -import jakarta.inject.Qualifier; - import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import jakarta.inject.Qualifier; + @Retention(RetentionPolicy.RUNTIME) @Qualifier public @interface MyQualifier2 { diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier3.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier3.java index 1698e22612..494aeb9135 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier3.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier3.java @@ -1,10 +1,10 @@ package org.jboss.weld.tests.invokable.lookup; -import jakarta.inject.Qualifier; - import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import jakarta.inject.Qualifier; + // no bean with this qualifier is supposed to exist @Retention(RetentionPolicy.RUNTIME) @Qualifier diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier4.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier4.java index 059332ef29..643134c741 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier4.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier4.java @@ -1,10 +1,10 @@ package org.jboss.weld.tests.invokable.lookup; -import jakarta.inject.Qualifier; - import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import jakarta.inject.Qualifier; + @Retention(RetentionPolicy.RUNTIME) @Qualifier public @interface MyQualifier4 { diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier5.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier5.java index e411cf6e0e..e81d0f8c18 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier5.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/lookup/MyQualifier5.java @@ -1,10 +1,10 @@ package org.jboss.weld.tests.invokable.lookup; -import jakarta.inject.Qualifier; - import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import jakarta.inject.Qualifier; + @Retention(RetentionPolicy.RUNTIME) @Qualifier public @interface MyQualifier5 { diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/InvokableMethodDetectionTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/InvokableMethodDetectionTest.java index 098c5e55cb..b42b2d5f88 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/InvokableMethodDetectionTest.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/InvokableMethodDetectionTest.java @@ -2,6 +2,7 @@ import jakarta.enterprise.inject.spi.Extension; import jakarta.inject.Inject; + import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/ObservingExtension.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/ObservingExtension.java index 9caac48068..198cb9324a 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/ObservingExtension.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/ObservingExtension.java @@ -1,11 +1,14 @@ package org.jboss.weld.tests.invokable.metadata; +import java.util.Collection; + import jakarta.enterprise.event.Observes; import jakarta.enterprise.inject.spi.AnnotatedMethod; import jakarta.enterprise.inject.spi.BeforeBeanDiscovery; import jakarta.enterprise.inject.spi.Extension; import jakarta.enterprise.inject.spi.ProcessAnnotatedType; import jakarta.enterprise.inject.spi.ProcessManagedBean; + import org.jboss.weld.tests.invokable.metadata.common.ClassLevelDirectDeclaration; import org.jboss.weld.tests.invokable.metadata.common.ClassLevelIndirectDeclaration; import org.jboss.weld.tests.invokable.metadata.common.ClassLevelViaExtension; @@ -16,8 +19,6 @@ import org.jboss.weld.tests.invokable.metadata.common.TransitivelyInvokable; import org.jboss.weld.tests.invokable.metadata.common.UnannotatedBean; -import java.util.Collection; - public class ObservingExtension implements Extension { private Collection> classDirectMethods; @@ -28,8 +29,6 @@ public class ObservingExtension implements Extension { private Collection> methodExtensionMethods; private Collection> unannotatedBeanMethods; - - public void processBean1(@Observes ProcessManagedBean pmb) { classDirectMethods = pmb.getInvokableMethods(); } @@ -75,7 +74,6 @@ public Collection> getCla return classIndirectMethods; } - public Collection> getMethodDirectMethods() { return methodDirectMethods; } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/buildCompatibleExtension/BuildExtension.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/buildCompatibleExtension/BuildExtension.java index fd878a5f91..0faf3462c3 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/buildCompatibleExtension/BuildExtension.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/buildCompatibleExtension/BuildExtension.java @@ -7,6 +7,7 @@ import jakarta.enterprise.inject.build.compatible.spi.Enhancement; import jakarta.enterprise.inject.build.compatible.spi.MetaAnnotations; import jakarta.enterprise.inject.build.compatible.spi.Registration; + import org.jboss.weld.tests.invokable.metadata.common.ClassLevelDirectDeclaration; import org.jboss.weld.tests.invokable.metadata.common.ClassLevelIndirectDeclaration; import org.jboss.weld.tests.invokable.metadata.common.ClassLevelViaExtension; diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/buildCompatibleExtension/InvokableMethodDetectionBCETest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/buildCompatibleExtension/InvokableMethodDetectionBCETest.java index eefd08ceb2..080d9bd143 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/buildCompatibleExtension/InvokableMethodDetectionBCETest.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/buildCompatibleExtension/InvokableMethodDetectionBCETest.java @@ -1,6 +1,7 @@ package org.jboss.weld.tests.invokable.metadata.buildCompatibleExtension; import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension; + import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; @@ -26,7 +27,6 @@ public static Archive getDeployment() { .addAsServiceProvider(BuildCompatibleExtension.class, BuildExtension.class); } - @Test public void testAnnotationDetected() { // assertions are made through BuildExtension.class diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/ClassLevelDirectDeclaration.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/ClassLevelDirectDeclaration.java index b4c322c170..1587dd53b4 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/ClassLevelDirectDeclaration.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/ClassLevelDirectDeclaration.java @@ -7,7 +7,7 @@ @Invokable public class ClassLevelDirectDeclaration { - public void ping(){ + public void ping() { } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/ClassLevelIndirectDeclaration.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/ClassLevelIndirectDeclaration.java index 71f2af6977..6c1dc916ab 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/ClassLevelIndirectDeclaration.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/ClassLevelIndirectDeclaration.java @@ -6,7 +6,7 @@ @TransitivelyInvokable public class ClassLevelIndirectDeclaration { - public void ping(){ + public void ping() { } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/ClassLevelViaExtension.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/ClassLevelViaExtension.java index cf2a55b7ec..0539422d2c 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/ClassLevelViaExtension.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/ClassLevelViaExtension.java @@ -6,7 +6,7 @@ @DefinitelyNotInvokable // should become @Invokable via extension public class ClassLevelViaExtension { - public void ping(){ + public void ping() { } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/MethodLevelDirectDeclaration.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/MethodLevelDirectDeclaration.java index 7234f886cd..51be133acf 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/MethodLevelDirectDeclaration.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/MethodLevelDirectDeclaration.java @@ -6,7 +6,7 @@ @ApplicationScoped public class MethodLevelDirectDeclaration { - public void ping(){ + public void ping() { } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/MethodLevelIndirectDeclaration.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/MethodLevelIndirectDeclaration.java index 4cbb7d712e..5cb11cdc7e 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/MethodLevelIndirectDeclaration.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/MethodLevelIndirectDeclaration.java @@ -5,7 +5,7 @@ @ApplicationScoped public class MethodLevelIndirectDeclaration { - public void ping(){ + public void ping() { } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/MethodLevelViaExtension.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/MethodLevelViaExtension.java index e8ad4c9f99..a0ec822a60 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/MethodLevelViaExtension.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/MethodLevelViaExtension.java @@ -5,7 +5,7 @@ @ApplicationScoped public class MethodLevelViaExtension { - public void ping(){ + public void ping() { } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/TransitivelyInvokable.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/TransitivelyInvokable.java index 6201c013d8..615bfa27a7 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/TransitivelyInvokable.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/TransitivelyInvokable.java @@ -1,11 +1,11 @@ package org.jboss.weld.tests.invokable.metadata.common; -import jakarta.enterprise.invoke.Invokable; -import jakarta.enterprise.util.AnnotationLiteral; - import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import jakarta.enterprise.invoke.Invokable; +import jakarta.enterprise.util.AnnotationLiteral; + @Invokable @Retention(RetentionPolicy.RUNTIME) public @interface TransitivelyInvokable { diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/UnannotatedBean.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/UnannotatedBean.java index d060a48b4e..67047e73e8 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/UnannotatedBean.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/common/UnannotatedBean.java @@ -6,7 +6,7 @@ @ApplicationScoped public class UnannotatedBean { - public void ping(){ + public void ping() { } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/hierarchy/InvokableMethodHierarchyTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/hierarchy/InvokableMethodHierarchyTest.java index 5ae348769c..9c87ac1646 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/hierarchy/InvokableMethodHierarchyTest.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/hierarchy/InvokableMethodHierarchyTest.java @@ -3,6 +3,7 @@ import jakarta.enterprise.inject.spi.AnnotatedMethod; import jakarta.enterprise.inject.spi.Extension; import jakarta.inject.Inject; + import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; @@ -31,7 +32,8 @@ public void testInvokableMethodDiscovery() { Assert.assertEquals(2, extension.getChildInvokableMethod().size()); for (AnnotatedMethod method : extension.getChildInvokableMethod()) { String methodName = method.getJavaMember().getName(); - Assert.assertTrue(extension.getChildInvokableMethod().toString(), methodName.equals("child") || methodName.equals("commonAncestor")); + Assert.assertTrue(extension.getChildInvokableMethod().toString(), + methodName.equals("child") || methodName.equals("commonAncestor")); } } } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/hierarchy/ObservingExtension.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/hierarchy/ObservingExtension.java index 37852292b6..d323441bdf 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/hierarchy/ObservingExtension.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/hierarchy/ObservingExtension.java @@ -1,17 +1,16 @@ package org.jboss.weld.tests.invokable.metadata.hierarchy; +import java.util.Collection; + import jakarta.enterprise.event.Observes; import jakarta.enterprise.inject.spi.AnnotatedMethod; import jakarta.enterprise.inject.spi.Extension; import jakarta.enterprise.inject.spi.ProcessManagedBean; -import java.util.Collection; - public class ObservingExtension implements Extension { private Collection> childInvokableMethod; - public void processBean1(@Observes ProcessManagedBean pmb) { childInvokableMethod = pmb.getInvokableMethods(); } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/hierarchy/TransitivelyInvokable.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/hierarchy/TransitivelyInvokable.java index 14cf200c2e..7fc3b2bc3c 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/hierarchy/TransitivelyInvokable.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/metadata/hierarchy/TransitivelyInvokable.java @@ -1,12 +1,11 @@ package org.jboss.weld.tests.invokable.metadata.hierarchy; -import jakarta.enterprise.invoke.Invokable; -import jakarta.enterprise.util.AnnotationLiteral; - -import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import jakarta.enterprise.invoke.Invokable; +import jakarta.enterprise.util.AnnotationLiteral; + @Invokable @Retention(RetentionPolicy.RUNTIME) public @interface TransitivelyInvokable { diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/input/AugmentedBean.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/input/AugmentedBean.java index 85539c755a..d41679aea4 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/input/AugmentedBean.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/input/AugmentedBean.java @@ -1,6 +1,6 @@ package org.jboss.weld.tests.invokable.transformers.input; -public class AugmentedBean extends ActualBean{ +public class AugmentedBean extends ActualBean { public AugmentedBean(Integer i) { super(i); } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/input/InputTransformerTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/input/InputTransformerTest.java index f8b69a4a7b..2cd4b6fc77 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/input/InputTransformerTest.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/input/InputTransformerTest.java @@ -2,6 +2,7 @@ import jakarta.enterprise.inject.spi.Extension; import jakarta.inject.Inject; + import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; @@ -32,15 +33,15 @@ public static Archive getDeployment() { public void testArgTransformerAssignability() { Beta result; // test initial state without transformers - result = (Beta) extension.getNoTransformer().invoke(bean, new Object[]{0}); + result = (Beta) extension.getNoTransformer().invoke(bean, new Object[] { 0 }); Assert.assertEquals("0", result.ping()); Assert.assertEquals(Integer.valueOf(0), result.getInteger()); // apply transformers, invoke method params are now String instead of original Number - result = (Beta) extension.getTransformArg1().invoke(bean, new Object[]{"42"}); + result = (Beta) extension.getTransformArg1().invoke(bean, new Object[] { "42" }); Assert.assertEquals("42", result.ping()); Assert.assertEquals(Integer.valueOf(0), result.getInteger()); - result = (Beta) extension.getTransformArg2().invoke(bean, new Object[]{"42"}); + result = (Beta) extension.getTransformArg2().invoke(bean, new Object[] { "42" }); Assert.assertEquals("42", result.ping()); Assert.assertEquals(Integer.valueOf(0), result.getInteger()); } @@ -49,15 +50,15 @@ public void testArgTransformerAssignability() { public void testInstanceTransformerAssignability() { Beta result; // test initial state without transformers - result = (Beta) extension.getNoTransformer().invoke(bean, new Object[]{0}); + result = (Beta) extension.getNoTransformer().invoke(bean, new Object[] { 0 }); Assert.assertEquals("0", result.ping()); Assert.assertEquals(Integer.valueOf(0), result.getInteger()); // apply transformers, instance parameter is now null - result = (Beta) extension.getTransformInstance1().invoke(null, new Object[]{42}); + result = (Beta) extension.getTransformInstance1().invoke(null, new Object[] { 42 }); Assert.assertEquals("42", result.ping()); Assert.assertEquals(Integer.valueOf(100), result.getInteger()); - result = (Beta) extension.getTransformInstance2().invoke(null, new Object[]{42}); + result = (Beta) extension.getTransformInstance2().invoke(null, new Object[] { 42 }); Assert.assertEquals("42", result.ping()); Assert.assertEquals(Integer.valueOf(100), result.getInteger()); } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/input/ObservingExtension.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/input/ObservingExtension.java index a2a7868fd7..6574ca7ebb 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/input/ObservingExtension.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/input/ObservingExtension.java @@ -1,13 +1,14 @@ package org.jboss.weld.tests.invokable.transformers.input; +import java.util.Collection; + import jakarta.enterprise.event.Observes; import jakarta.enterprise.inject.spi.AnnotatedMethod; import jakarta.enterprise.inject.spi.Extension; import jakarta.enterprise.inject.spi.ProcessManagedBean; import jakarta.enterprise.invoke.Invoker; -import org.junit.Assert; -import java.util.Collection; +import org.junit.Assert; public class ObservingExtension implements Extension { diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/output/ObservingExtension.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/output/ObservingExtension.java index 5c66811908..0a56af2be4 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/output/ObservingExtension.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/output/ObservingExtension.java @@ -1,13 +1,14 @@ package org.jboss.weld.tests.invokable.transformers.output; +import java.util.Collection; + import jakarta.enterprise.event.Observes; import jakarta.enterprise.inject.spi.AnnotatedMethod; import jakarta.enterprise.inject.spi.Extension; import jakarta.enterprise.inject.spi.ProcessManagedBean; import jakarta.enterprise.invoke.Invoker; -import org.junit.Assert; -import java.util.Collection; +import org.junit.Assert; public class ObservingExtension implements Extension { @@ -33,6 +34,7 @@ public class ObservingExtension implements Extension { public Invoker getTransformException2() { return transformException2; } + public Invoker getTransformException3() { return transformException3; } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/output/OutputTransformerTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/output/OutputTransformerTest.java index 8a72437910..7eded40861 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/output/OutputTransformerTest.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/output/OutputTransformerTest.java @@ -2,6 +2,7 @@ import jakarta.enterprise.inject.spi.Extension; import jakarta.inject.Inject; + import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; @@ -35,17 +36,17 @@ public static Archive getDeployment() { public void testReturnTypeTransformerAssignability() { Beta betaResult; // test initial state without transformers - betaResult = (Beta) extension.getNoTransformer().invoke(bean, new Object[]{0}); + betaResult = (Beta) extension.getNoTransformer().invoke(bean, new Object[] { 0 }); Assert.assertEquals("0", betaResult.ping()); Assert.assertEquals(Integer.valueOf(0), betaResult.getInteger()); // apply transformers, first one returns Beta, the other just String Object result; - result = extension.getTransformReturnType1().invoke(bean, new Object[]{10}); + result = extension.getTransformReturnType1().invoke(bean, new Object[] { 10 }); Assert.assertTrue(result instanceof Beta); - Assert.assertEquals("42", ((Beta)result).ping()); - Assert.assertEquals(Integer.valueOf(42), ((Beta)result).getInteger()); - result = extension.getTransformReturnType2().invoke(bean, new Object[]{23}); + Assert.assertEquals("42", ((Beta) result).ping()); + Assert.assertEquals(Integer.valueOf(42), ((Beta) result).getInteger()); + result = extension.getTransformReturnType2().invoke(bean, new Object[] { 23 }); Assert.assertTrue(result instanceof String); Assert.assertEquals("230", result.toString()); } @@ -54,17 +55,17 @@ public void testReturnTypeTransformerAssignability() { public void testExceptionTransformerAssignability() { // apply transformers, first one swallows exception and returns Beta Object result; - result = extension.getTransformException1().invoke(exceptionalBean, new Object[]{10}); + result = extension.getTransformException1().invoke(exceptionalBean, new Object[] { 10 }); Assert.assertTrue(result instanceof Beta); - Assert.assertEquals("42", ((Beta)result).ping()); - Assert.assertEquals(Integer.valueOf(42), ((Beta)result).getInteger()); + Assert.assertEquals("42", ((Beta) result).ping()); + Assert.assertEquals(Integer.valueOf(42), ((Beta) result).getInteger()); // second transformer returns a subclas - result = extension.getTransformException2().invoke(exceptionalBean, new Object[]{23}); + result = extension.getTransformException2().invoke(exceptionalBean, new Object[] { 23 }); Assert.assertTrue(result instanceof Gamma); - Assert.assertEquals("42", ((Gamma)result).ping()); - Assert.assertEquals(Integer.valueOf(42), ((Gamma)result).getInteger()); + Assert.assertEquals("42", ((Gamma) result).ping()); + Assert.assertEquals(Integer.valueOf(42), ((Gamma) result).getInteger()); // third transformer returns a completely different type - result = extension.getTransformException3().invoke(exceptionalBean, new Object[]{23}); + result = extension.getTransformException3().invoke(exceptionalBean, new Object[] { 23 }); Assert.assertTrue(result instanceof String); Assert.assertEquals("foobar", result); } diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/output/Transformer.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/output/Transformer.java index 6bcae66148..1a6547e9ac 100644 --- a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/output/Transformer.java +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/transformers/output/Transformer.java @@ -1,6 +1,5 @@ package org.jboss.weld.tests.invokable.transformers.output; - /** * Offers various transformation methods */ diff --git a/weld-lite-extension-translator/src/main/java/org/jboss/weld/lite/extension/translator/BeanInfoImpl.java b/weld-lite-extension-translator/src/main/java/org/jboss/weld/lite/extension/translator/BeanInfoImpl.java index c77b8c195f..72f2151cc4 100644 --- a/weld-lite-extension-translator/src/main/java/org/jboss/weld/lite/extension/translator/BeanInfoImpl.java +++ b/weld-lite-extension-translator/src/main/java/org/jboss/weld/lite/extension/translator/BeanInfoImpl.java @@ -1,6 +1,7 @@ package org.jboss.weld.lite.extension.translator; import java.util.Collection; +import java.util.Collections; import java.util.stream.Collectors; import jakarta.annotation.Priority; @@ -19,11 +20,10 @@ import jakarta.enterprise.lang.model.declarations.FieldInfo; import jakarta.enterprise.lang.model.declarations.MethodInfo; import jakarta.enterprise.lang.model.types.Type; -import org.jboss.weld.lite.extension.translator.util.reflection.AnnotatedTypes; + import org.jboss.weld.bean.ClassBean; import org.jboss.weld.invokable.InvokerInfoBuilder; - -import java.util.Collections; +import org.jboss.weld.lite.extension.translator.util.reflection.AnnotatedTypes; class BeanInfoImpl implements BeanInfo { final jakarta.enterprise.inject.spi.Bean cdiBean; @@ -167,7 +167,8 @@ public Collection invokableMethods() { public InvokerBuilder createInvoker(MethodInfo methodInfo) { if (methodInfo.isConstructor()) { // TODO better exception - throw new IllegalArgumentException("Constructor methods are not valid candidates for Invokers. MethodInfo: " + methodInfo); + throw new IllegalArgumentException( + "Constructor methods are not valid candidates for Invokers. MethodInfo: " + methodInfo); } if (methodInfo instanceof MethodInfoImpl) { // at this point we can be sure it is a Method, not a Constructor, so we cast it diff --git a/weld-lite-extension-translator/src/main/java/org/jboss/weld/lite/extension/translator/SyntheticComponentBuilderBase.java b/weld-lite-extension-translator/src/main/java/org/jboss/weld/lite/extension/translator/SyntheticComponentBuilderBase.java index 46193607a6..7c599183bd 100644 --- a/weld-lite-extension-translator/src/main/java/org/jboss/weld/lite/extension/translator/SyntheticComponentBuilderBase.java +++ b/weld-lite-extension-translator/src/main/java/org/jboss/weld/lite/extension/translator/SyntheticComponentBuilderBase.java @@ -1,13 +1,13 @@ package org.jboss.weld.lite.extension.translator; -import jakarta.enterprise.inject.build.compatible.spi.InvokerInfo; -import jakarta.enterprise.lang.model.AnnotationInfo; -import jakarta.enterprise.lang.model.declarations.ClassInfo; - import java.lang.annotation.Annotation; import java.util.HashMap; import java.util.Map; +import jakarta.enterprise.inject.build.compatible.spi.InvokerInfo; +import jakarta.enterprise.lang.model.AnnotationInfo; +import jakarta.enterprise.lang.model.declarations.ClassInfo; + public class SyntheticComponentBuilderBase> { final Map params = new HashMap<>();