<commit_before>package org.jboss.forge.container.services;

import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;

import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;

import net.sf.cglib.proxy.Enhancer;

import org.jboss.forge.container.AddonRegistry;
import org.jboss.forge.container.exception.ContainerException;
import org.jboss.forge.container.impl.Service;

public class RemoteServiceProxyBeanProducerMethod
{
   @Produces
   @Service
   public static Object produceRemoteService(AddonRegistry registry, InjectionPoint ip)
   {
      if (ip == null)
         throw new IllegalStateException(
                  "Cannot perform dynamic lookup of @"
                           + Remote.class.getName()
                           + " instances - they must be injected directly into a field or as a method/constructor parameter.");

      Member member = ip.getMember();
      Class<?> type = null;
      if (member instanceof Method)
      {
         type = ((Method) member).getReturnType();
      }
      else if (member instanceof Field)
      {
         type = ((Field) member).getType();
      }
      else
         throw new ContainerException("Cannot handle producer for non-Field and non-Method member type");

      return Enhancer.create((Class<?>) type, new RemoteServiceProxyBeanCallback(registry, type));
   }
}<commit_msg>Improve error messaging<commit_after>package org.jboss.forge.container.services;

import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;

import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;

import net.sf.cglib.proxy.Enhancer;

import org.jboss.forge.container.AddonRegistry;
import org.jboss.forge.container.exception.ContainerException;
import org.jboss.forge.container.impl.Service;

public class RemoteServiceProxyBeanProducerMethod
{
   @Produces
   @Service
   public static Object produceRemoteService(AddonRegistry registry, InjectionPoint ip)
   {
      if (ip == null)
         throw new IllegalStateException(
                  "Cannot perform dynamic lookup of @"
                           + Remote.class.getName()
                           + " instances - they must be injected directly into a field or as a method/constructor parameter.");

      Member member = ip.getMember();
      Class<?> type = null;
      if (member instanceof Method)
      {
         type = ((Method) member).getReturnType();
      }
      else if (member instanceof Field)
      {
         type = ((Field) member).getType();
      }
      else
         throw new ContainerException("Cannot handle producer for non-Field and non-Method member type: " + member);

      try
      {
         return Enhancer.create((Class<?>) type, new RemoteServiceProxyBeanCallback(registry, type));
      }
      catch (Exception e)
      {
         throw new ContainerException("Failed to proxy bean of type:" + type, e);
      }
   }
}
{'fraction_non_alphanumeric': 0.09609012591119948, 'fraction_numerical': 0.0, 'mean_word_length': 2.816687737041719, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2282693', 'n_tokens_mistral': 817, 'n_tokens_neox': 795, 'n_words': 213}