/**
 * Class to test what sort of communication between
 * anonymous inner classes and the enclosing
 * method's local variables.
 * This experiment does not explore access to instance/static
 * variables and methods in the outer class.
 * @author Roedy Green
 */

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Outer
   {

   static void osm()
      {
      int oi = 0;
      final int ofi = 1;

      // anonymous inner class
      ActionListener listener = new ActionListener()
         {

         public void actionPerformed( ActionEvent e )
            {
            // anonymous class method can directly
            // see local variable ofi of calling osm method.
            int ifi = ofi;

            // following are illegal, since only final local vars may be accessed
            // int ii = oi;
            // oi = i;
            } // end actionPerformed

         }; // end ActionListener

      } // end osm

   // the rules are the same for outer instance and static methods.
   void oim()
      {
      int oi = 0;
      final int ofi = 1;

      // anonymous inner class
      ActionListener listener = new ActionListener()
         {

         public void actionPerformed( ActionEvent e )
            {
            // anonymous class method can directly
            // see local variable ofi of calling osm method.
            int ifi = ofi;

            // following are illegal, since only final local vars may be accessed
            // int ii = oi;
            // oi = i;
            } // end actionPerformed

         }; // end ActionListener
      }
   } // end Outer