Read the input channel and initialize instance data
structure.
for (int i=1;i<constantPoolSize;i++) {
final byte type = buffer.get();
switch(type) {
case ASCIZ:
case UNICODE:
final short length = buffer.getShort();
if (length<0 || length>Short.MAX_VALUE) {
return true;
}
buffer.get(bytes, 0, length);
/* to speed up the process, I am comparing the first few
* bytes to Ljava since all annotations are in the java
* package, the reduces dramatically the number or String
* construction
*/
if (bytes[0]=='L" && bytes[1]=='j" && bytes[2]=='a") {
String stringValue;
if (type==ASCIZ) {
stringValue = new String(bytes, 0, length,"US-ASCII");
} else {
stringValue = new String(bytes, 0, length);
}
if (customScanner != null) {
if (customScanner.isAnnotation(stringValue)) {
return true;
}
} else {
if (AnnotationScanner.isAnnotation(stringValue)) {
return true;
}
}
}
break;
case CLASS:
case STRING:
buffer.getShort();
break;
case FIELDREF:
case METHODREF:
case INTERFACEMETHODREF:
case INTEGER:
case FLOAT:
buffer.position(buffer.position()+4);
break;
case LONG:
case DOUBLE:
buffer.position(buffer.position()+8);
// for long, and double, they use 2 constantPool
i++;
break;
case NAMEANDTYPE:
buffer.getShort();
buffer.getShort();
break;
default:
DOLUtils.getDefaultLogger().severe("Unknow type constant pool " + type + " at position" + i);
break;
}
}
return false;