optimized checkTypeSig

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1128 379699f6-c40d-0410-875b-85095c16579e
branch_1_1
jochen 26 years ago
parent 4104af6d61
commit d54f47c0a2
  1. 30
      jode/jode/bytecode/TypeSignature.java

@ -204,18 +204,21 @@ public class TypeSignature {
return methodTypeSig.substring(methodTypeSig.lastIndexOf(')')+1); return methodTypeSig.substring(methodTypeSig.lastIndexOf(')')+1);
} }
private static void checkClassName(String clName) /**
throws IllegalArgumentException * Check if there is a valid class name starting at index
* in string typesig and ending with a semicolon.
* @return the index at which the class name ends.
* @exception IllegalArgumentException if there was an illegal character.
* @exception StringIndexOutOfBoundsException if the typesig ended early.
*/
private static int checkClassName(String clName, int i)
throws IllegalArgumentException, StringIndexOutOfBoundsException
{ {
boolean start = true; while (true) {
for (int i=0; i< clName.length(); i++) { char c = clName.charAt(i++);
char c = clName.charAt(i); if (c == ';')
if (c == '/') return i;
start = true; if (c != '/' && !Character.isJavaIdentifierPart(c))
else if (start && Character.isJavaIdentifierStart(c))
start = false;
else if ((start && false /*XXX*/)
|| !Character.isJavaIdentifierPart(c))
throw new IllegalArgumentException("Illegal java class name: " throw new IllegalArgumentException("Illegal java class name: "
+ clName); + clName);
} }
@ -233,10 +236,7 @@ public class TypeSignature {
while (c == '[') while (c == '[')
c = typesig.charAt(index++); c = typesig.charAt(index++);
if (c == 'L') { if (c == 'L') {
int end = typesig.indexOf(';', index); index = checkClassName(typesig, index);
// next instruction throws StringIndexOutOfBounds, if no ; exists.
checkClassName(typesig.substring(index+1, end));
index = end + 1;
} else { } else {
if ("ZBSCIJFD".indexOf(c) == -1) if ("ZBSCIJFD".indexOf(c) == -1)
throw new IllegalArgumentException("Type sig error: "+typesig); throw new IllegalArgumentException("Type sig error: "+typesig);

Loading…
Cancel
Save