Ejemplo n.º 1
0
 /**
  * Checks that the given string is a valid unqualified name.
  *
  * @param version the class version.
  * @param name the string to be checked.
  * @param msg a message to be used in case of error.
  */
 static void checkUnqualifiedName(int version, final String name, final String msg) {
   if ((version & 0xFFFF) < Opcodes.V1_5) {
     checkIdentifier(name, msg);
   } else {
     for (int i = 0; i < name.length(); ++i) {
       if (".;[/".indexOf(name.charAt(i)) != -1) {
         throw new IllegalArgumentException(
             "Invalid " + msg + " (must be a valid unqualified name): " + name);
       }
     }
   }
 }
Ejemplo n.º 2
0
 /**
  * Checks that the given substring is a valid internal class name.
  *
  * @param name the string to be checked.
  * @param start index of the first character of the identifier (inclusive).
  * @param end index of the last character of the identifier (exclusive). -1 is equivalent to
  *     <tt>name.length()</tt> if name is not <tt>null</tt>.
  * @param msg a message to be used in case of error.
  */
 static void checkInternalName(
     final String name, final int start, final int end, final String msg) {
   int max = end == -1 ? name.length() : end;
   try {
     int begin = start;
     int slash;
     do {
       slash = name.indexOf('/', begin + 1);
       if (slash == -1 || slash > max) {
         slash = max;
       }
       checkIdentifier(name, begin, slash, null);
       begin = slash + 1;
     } while (slash != max);
   } catch (IllegalArgumentException unused) {
     throw new IllegalArgumentException(
         "Invalid " + msg + " (must be a fully qualified class name in internal form): " + name);
   }
 }
Ejemplo n.º 3
0
 /**
  * Checks that the given string is a valid Java identifier.
  *
  * @param name the string to be checked.
  * @param msg a message to be used in case of error.
  */
 static void checkIdentifier(final String name, final String msg) {
   checkIdentifier(name, 0, -1, msg);
 }