title: Is it possible to hide or lower access to Inherited Methods in Java?
body: <p>I have a class structure where I would like some methods in a base class to be accessible from classes derived directly from the base class, but not classes derived from derived classes.  According to the Java Language specification it is possible to override access specifications on inherited methods to make them more public, but not more private.  For example, this is the gist of what I need to do, but is illegal:</p>
  
  <pre><code>// Defines myMethod
  public class Base {
      protected void myMethod() {}
  }
  
  // Uses myMethod and then hides it.
  public class DerivedOne extends Base {
      @Override
      private void myMethod();
  }
  
  // can't access myMethod.
  public class DerivedTwo extends DerivedOne {
  
  }
  </code></pre>
  
  <p>Is there any way to accomplish this?</p>
  
  <p>Edited to explain why I would like to do this: </p>
  
  <p>In this case the class structure is a data handling and import structure. It reads in and parses text files full of tabular data and then stores them in a database.  </p>
  
  <p>The base class is the base table class managing the database handling part of it. There is a fair amount of functionality contained in it that is common to all table types - as once they are in the database they become uniform.  </p>
  
  <p>The middle class is specific to the kind of table in the file being parsed, and has the table parsing and import logic.  It needs access to some of the base class's database access functions.  </p>
  
  <p>The top level class is specific to the table and does nothing more than initialize the table's layout in a way the parent classes can understand.  Also users of the base class do not need to see or access the database specific functions which the middle class do.  In essence, I want to reveal these functions only to one level above the base class and no one else.</p>
  
  <p>I ask because, although the code I posted as an example is illegal, there may be some other means to accomplish the same end.  I'm asking if there is.</p>
  
  <p>Perhaps hiding is the wrong way to phrase this - what I really need to do is expose some functionality that should be private to the base class to the class one level up in the hierarchy.  Hiding would accomplish this - but I can see how hiding would be a problem.  Is there another way to do this?</p>