Buggy code:
public class LocalEjbReceiver extends EJBReceiver implements RegistryCollector . Listener < String , List < ClientMapping > > , Service < LocalEjbReceiver > { public static final ServiceName BY_VALUE_SERVICE_NAME = JBOSS . append ( "ejb3" , "localEjbReceiver" , "value" ) ; public static final ServiceName BY_REFERENCE_SERVICE_NAME = JBOSS . append ( "ejb3" , "localEjbReceiver" , "reference" ) ; private static final Object [ ] EMPTY_OBJECT_ARRAY = new Object [ ] { } ; private final List < EJBReceiverContext > contexts = new CopyOnWriteArrayList < EJBReceiverContext > ( ) ; private final InjectedValue < DeploymentRepository > deploymentRepository = new InjectedValue < DeploymentRepository > ( ) ; @ SuppressWarnings ( "rawtypes" ) private final InjectedValue < RegistryCollector > clusterRegistryCollector = new InjectedValue < RegistryCollector > ( ) ; private final LocalEjbReceiver . Listener deploymentListener = new LocalEjbReceiver . Listener ( ) ; private final boolean allowPassByReference ; public LocalEjbReceiver ( final String nodeName , final boolean allowPassByReference ) { } @ Override protected void associate ( final EJBReceiverContext context ) { } @ Override protected void processInvocation ( final EJBClientInvocationContext invocation , final EJBReceiverInvocationContext receiverContext ) throws Exception { } @ Override protected < T > StatefulEJBLocator < T > openSession ( EJBReceiverContext context , Class < T > viewType , String appName , String moduleName , String distinctName , String beanName ) throws IllegalArgumentException { } private Object clone ( final Class < ? > target , final ObjectCloner cloner , final Object object , final boolean allowPassByReference ) { if ( object == null ) { return null ; } <START_BUG> if ( allowPassByReference && ( target . isAssignableFrom ( object . getClass ( ) ) ) ) { <END_BUG> return object ; } return clone ( cloner , object ) ; } private Object clone ( final ObjectCloner cloner , final Object object ) { } @ Override protected boolean exists ( final String appName , final String moduleName , final String distinctName , final String beanName ) { } private EjbDeploymentInformation findBean ( final String appName , final String moduleName , final String distinctName , final String beanName ) { } @ Override public void start ( final StartContext context ) throws StartException { } @ Override public void stop ( final StopContext context ) { } @ Override public LocalEjbReceiver getValue ( ) throws IllegalArgumentException , IllegalStateException { } public InjectedValue < DeploymentRepository > getDeploymentRepository ( ) { } @ Override public void registryAdded ( Registry < String , List < ClientMapping > > registry ) { } @ Override public void registryRemoved ( Registry < String , List < ClientMapping > > registry ) { } @ SuppressWarnings ( "rawtypes" ) public Injector < RegistryCollector > getClusterRegistryCollectorInjector ( ) { } private static class ImmediateResultProducer implements EJBReceiverInvocationContext . ResultProducer { private final Object clonedResult ; public ImmediateResultProducer ( final Object clonedResult ) { } @ Override public Object getResult ( ) throws Exception { } @ Override public void discardResult ( ) { } } private class Listener implements DeploymentRepositoryListener { @ Override public void listenerAdded ( final DeploymentRepository repository ) { } @ Override public void deploymentAvailable ( final DeploymentModuleIdentifier deployment , final ModuleDeployment moduleDeployment ) { } @ Override public void deploymentRemoved ( final DeploymentModuleIdentifier deployment ) { } } private class LocalClusterNodeManager implements ClusterNodeManager { @ Override public String getNodeName ( ) { } @ Override public EJBReceiver getEJBReceiver ( ) { } } }

Fix:
if ( allowPassByReference && ( ( target . isPrimitive ( ) ) || ( target . isAssignableFrom ( object . getClass ( ) ) ) ) ) {