The Artima Developer Community
Sponsored Link

Legacy Design Forum
Designing with Interfaces

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

static abstract kludge

Posted by Paul Heimiller on February 20, 2001 at 4:00 PM

There is another way to simulate static abstract methods. That is to declare an static method on the abstract super class that invokes an exception. Then override the static method on the subclasses. Then when you want to access the subclass method, use reflection to access the static method
(eg.
Class mccClass = this.getClass();
Method method0 = mccClass.getMethod("staticMethod", new Class[0]);
strPrimaryTable = (String) method0.invoke(null, new Object[0]);

I'm not saying this is a good way to do this, but it is a way.




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us