title: MVEL - Error: could not access field in ReflectiveAccessorOptimizer
body: <p>I am newbie to MVEL. Following steps I followed </p>
  
  <p>1) Downloaded latest from <a href="http://mvel.codehaus.org/Downloading+MVEL" rel="nofollow noreferrer">http://mvel.codehaus.org/Downloading+MVEL</a>
   i.e. Download mvel2-2.2.0.jar (JDK 1.5+ required)</p>
  
  <p>2) Created a simple list of custom obj</p>
  
  <pre><code>       class TestMVEL {
      public static void main(String[] p){
          String expr0 = "fruits[1]";
          String expr1 = "System.out.println(fruits[1]);";
          String expr2 = "foreach( f : fruits) { System.out.println(f.getName()); }";  
  
          System.out.println(MVEL.eval(expr0, new Basket()));//prints Fruit{name=Banana}
          MVEL.eval(expr1, new Basket());// prints Fruit{name=Banana}
          MVEL.eval(expr2, new Basket());//error
      }
  }
  class Basket {
     List&lt;Fruit&gt; fruits = new ArrayList&lt;Fruit&gt;();
  
     public List&lt;Fruit&gt; getFruits(){
       fruits.clear();
       fruits.add(new Fruit("Apple"));
       fruits.add(new Fruit("Banana"));
       fruits.add(new Fruit("Orange"));
       return fruits;
     }
  }
  
  class Fruit { 
      private String name; 
      public Fruit(String n){
          name = n;
      }
      public String getName(){
          return name;
      }
      public String toString() {
          return "Fruit{" + "name=" + name + '}';
      }
  }
  </code></pre>
  
  <p>3) Getting below error</p>
  
  <blockquote>
    <p>Exception in thread "main" [Error: f.getName(): Class
    org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer 
    can not access a member of class test.Fruit with modifiers "public"] [Near :
    {... foreach( f : fruits) { System.out.println(f.getName()); } ....}]</p>
  </blockquote>