[antlr-interest] Bug? in 2.7.1: ASTNULLType
gidadoifiok
gidadoifiok at yahoo.com
Thu Jan 17 10:40:44 PST 2002
The doc says:
/** There is only one instance of this class **/
But there is no constructor declared which means a default constructor
is provided. If you do the following:
System.out.println(new ASTNULLType().hashCode());
System.out.println(new ASTNULLType().hashCode());
System.out.println(new ASTNULLType().hashCode());
you will see something like this:
4565111
3615258
2964388
Meaning that it is very possible to create different instances
(where as the intent was only to have one: a singleton)
I suggest the following in ASTNULLType
public class ASTNULLType implements AST {
public static final ASNTNULLType singleton = new ASTNULLType();
private ASTNULLType() { }
Then whereever in code you want to use it, just refer to, e.g.
public static ASTNULLType ASTNULL = ASTNULLType.singleton;
- Gidado
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list