X-Git-Url: http://git.megacz.com/?p=org.ibex.classgen.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fclassgen%2FType.java;h=33af24d0d2d7b1922839a0da124ad2d10b2f3f87;hp=dd73d70216cfe1bf9b9bbab2ca47a2b61aba3ff6;hb=eaa26b83ad7f83df63910284014f84657f0e798f;hpb=9b8b835136fbb1c781662651ff76bc1d5d849742 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(";"); } }