From eaa26b83ad7f83df63910284014f84657f0e798f Mon Sep 17 00:00:00 2001 From: brian Date: Fri, 28 May 2004 16:29:48 +0000 Subject: [PATCH] fix Type.equals darcs-hash:20040528162948-24bed-e98684bd0c250a7303052003b9ea99301f98f700.gz --- src/org/ibex/classgen/Type.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/org/ibex/classgen/Type.java b/src/org/ibex/classgen/Type.java index dd73d70..33af24d 100644 --- a/src/org/ibex/classgen/Type.java +++ b/src/org/ibex/classgen/Type.java @@ -19,14 +19,13 @@ public class Type { public static final Type[] NO_ARGS = new Type[0]; - String descriptor; + final String descriptor; - Type() { } Type(String descriptor) { this.descriptor = descriptor; } public final String getDescriptor() { return descriptor; } public int hashCode() { return descriptor.hashCode(); } - public boolean equals(Object o) { return o instanceof Type && ((Type)o).descriptor.equals(descriptor); } + public boolean equals(java.lang.Object o) { return o instanceof Type && ((Type)o).descriptor.equals(descriptor); } public static Type arrayType(Type base) { return arrayType(base,1); } public static Type arrayType(Type base, int dim) { @@ -37,12 +36,14 @@ public class Type { } public static class Object extends Type { - public Object(String s) { + public Object(String s) { super(_initHelper(s)); } + + private static String _initHelper(String s) { if(!s.startsWith("L") || !s.endsWith(";")) s = "L" + s.replace('.','/') + ";"; if(!validDescriptorString(s)) throw new IllegalArgumentException("invalid descriptor string"); - descriptor = s; + return s; } - + public String[] components() { StringTokenizer st = new StringTokenizer(descriptor.substring(1,descriptor.length()-1),"/"); String[] a = new String[st.countTokens()]; @@ -53,7 +54,7 @@ public class Type { public String internalForm() { return descriptor.substring(1,descriptor.length()-1); } // FEATURE: Do a proper check here (invalid chars, etc) - public boolean validDescriptorString(String s) { + static boolean validDescriptorString(String s) { return s.startsWith("L") && s.endsWith(";"); } } -- 1.7.10.4