Return-Path: Delivered-To: apmail-jakarta-avalon-dev-archive@jakarta.apache.org Received: (qmail 7390 invoked by uid 500); 12 Aug 2001 11:05:47 -0000 Mailing-List: contact avalon-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: "Avalon Development" Delivered-To: mailing list avalon-dev@jakarta.apache.org Received: (qmail 7379 invoked from network); 12 Aug 2001 11:05:46 -0000 Date: Sun, 12 Aug 2001 21:06:07 +1000 From: Jeff Turner To: avalon-dev@jakarta.apache.org Subject: Type-safe Enum not so type-safe. Message-ID: <20010812210607.A9867@socialchange.net.au> Mail-Followup-To: avalon-dev@jakarta.apache.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.19i X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N A question, mainly for Pete, Enum and ValuedEnum both have public constructors: public Enum( final String name ); public Enum( final String name, final Map map ); public ValuedEnum( final String name, final int value ); public ValuedEnum( final String name, final int value, final Map map ); Because they're public, any class can add more Enum items at any time, so the Enum is not type-safe at all. Possibly a security hazard if anyone was relying on subclasses' type-safety. Since the only time they should ever be called is within a subclass, would it be better to make them protected? This technically breaks backwards-compatibility, but only where the class is being incorrectly used. thanks, --Jeff --------------------------------------------------------------------- To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: avalon-dev-help@jakarta.apache.org