2 Replies Latest reply on Sep 24, 2008 6:00 AM by 807589

    Query on inner classes.....

    807589
      I have an inner classB inside classA.ClassA public and class B is private.With java 1.4.2 the code is compiled without error and with java 1.5 it is not compiling. In class B there is a string variable c which is used in a method, which doesn't belong to class B.
      The error is ----- c is defined in a inaccessible class or interface(only with java 1.5)

      Can anyone clear what's wrong in this?
        • 1. Re: Query on inner classes.....
          807589
          Could you post a minimal example and the exact compiler message?
          • 2. Re: Query on inner classes.....
            807589
            This is in a seprate file, say ObtainChannel.java,

            public class ObtainChannel
            {
            private static final int MAX_IOR_STRING_LENGTH = 4000;
            private static final int MAX_EVENT_CHANNELS = 50;
            static EventChannelInfo[] ChannelList = new EventChannelInfo[MAX_EVENT_CHANNELS];
            static int NumChannels = 0;

            private static class EventChannelInfo
            {
            String fullChannelName; //This is giving the error : it's not accesible
            String channelName; // "
            NamingContext context;// "

            EventChannelInfo(String fullChannelName, String channelName, NamingContext context)
            {
            this.fullChannelName = fullChannelName;
            this.channelName = channelName;
            this.context = context;
            }
            }

            This is another file, say ChanAdmin.java ( this file is using fullChannelName,channelName,context varaible decalred in above class) and throws the following error,

            ChanAdmin.java:202: fullChannelName in ObtainChannel.EventChannelInfo is defined
            in an inaccessible class or interface
            info.channelChoice.add(ObtainChannel.ChannelList.fullChannelName)
            ;



            public class ChanAdmin extends Frame
            {

            private void startAdmin(int xPosition, int yPosition)
            {
            EventChannelHolder eventChannelHolder = new EventChannelHolder();

            // Display a dialog to query operator about which event channel
            // to administer
            IdentifyChannelDialog info = new IdentifyChannelDialog(this, true);
            info.setLocation(50, 50);
            for (int i=0; i < ObtainChannel.NumChannels; i++)
            {
            info.channelChoice.add(ObtainChannel.ChannelList[i].fullChannelName);// It's giving error
            }
            if (ObtainChannel.NumChannels == 0) info.channelChoice.setEnabled(false);
            info.setVisible(true);
            int choice = info.channelChoice.getSelectedIndex();
            info.dispose();
                      
            // Get the event channel either from the naming service or from a file
            // based object reference.
            if (info.fileNameField.getText().length() == 0)
            {
            if (ObtainChannel.NumChannels == 0)
            // Naming service not available and no event channel IOR provided
            Runtime.getRuntime().exit(-1);

            // Use naming service to get event channel
            if (!ObtainChannel.FromNamingService(
            ObtainChannel.ChannelList[choice].context, // It's giving error
            ObtainChannel.ChannelList[choice].channelName, // It's giving error
            eventChannelHolder))
            Runtime.getRuntime().exit(-1);
            }
            else
            {  // Get Event Channel from IOR stored in a file
            if (!ObtainChannel.FromIORFile(orb, eventChannelHolder,
            info.fileNameField.getText()))
            Runtime.getRuntime().exit(-1);
            }

                 
            eventChannelObj = eventChannelHolder.value;

            // Start a thread for updating statistics periodically
            statUpdate = new StatUpdate(this);
            statUpdate.start();

            // Display the administration window
            setLocation(xPosition, yPosition);
            setVisible(true);

            }