/**
- * Reads an int array with our encoding
+ * Writes an int array with our encoding
*/
public static void writeIntArray(DataOutputStream s, int[] a) throws IOException {
int len = a.length;
+ /**
+ * Reads an int array with our encoding
+ */
+ public static String[] readStringArray(DataInputStream s) throws IOException {
+ int len = s.readInt();
+ String[] ret = new String[len];
+ for (int i=0; i < len; i++) ret[i] = s.readUTF();
+ return ret;
+ }
+
+
+ /**
+ * Writes an int array with our encoding
+ */
+ public static void writeStringArray(DataOutputStream s, String[] a) throws IOException {
+ if (a == null) {
+ s.writeInt(0);
+ return;
+ }
+ int len = a.length;
+ s.writeInt(len);
+ for (int i=0; i < len; i++) s.writeUTF(a[i]);
+ }
+
/**
* Returns the contents of this file as a String
import org.aspectj.bridge.IMessage;
import org.aspectj.util.*;
+import com.sun.corba.se.internal.util.Utility;
+
//XXX need to use dim in matching
public class WildTypePattern extends TypePattern {
NamePattern[] namePatterns;
protected boolean matchesExactly(ResolvedTypeX type) {
String targetTypeName = type.getName();
+ //System.err.println("match: " + targetTypeName + ", " + knownMatches); //Arrays.asList(importedPrefixes));
+
//XXX hack
- if (knownMatches == null) {
+ if (knownMatches == null && importedPrefixes == null) {
return innerMatchesExactly(targetTypeName);
}
// assumes that prefixes have a dot at the end
for (int i=0, len=importedPrefixes.length; i < len; i++) {
String prefix = importedPrefixes[i];
+ //System.err.println("prefix match? " + prefix + " to " + targetTypeName);
if (targetTypeName.startsWith(prefix)) {
+
if (innerMatchesExactly(targetTypeName.substring(prefix.length()))) {
return true;
}
//??? doing this everytime is not very efficient
char[][] names = splitNames(targetTypeName);
-
-
return innerMatchesExactly(names);
}
}
s.writeBoolean(includeSubtypes);
s.writeInt(dim);
+ //??? storing this information with every type pattern is wasteful of .class
+ // file size. Storing it on enclosing types would be more efficient
+ FileUtil.writeStringArray(s, knownMatches);
+ FileUtil.writeStringArray(s, importedPrefixes);
writeLocation(s);
}
}
boolean includeSubtypes = s.readBoolean();
int dim = s.readInt();
- TypePattern ret = new WildTypePattern(namePatterns, includeSubtypes, dim);
+ WildTypePattern ret = new WildTypePattern(namePatterns, includeSubtypes, dim);
+ ret.knownMatches = FileUtil.readStringArray(s);
+ ret.importedPrefixes = FileUtil.readStringArray(s);
ret.readLocation(context, s);
return ret;
}