8278863: Add method ClassDesc::ofInternalName

Reviewed-by: jvernee
This commit is contained in:
Adam Sotona 2022-09-20 07:50:03 +00:00
parent 4020ed53dd
commit 0fa7d9e8cd
3 changed files with 61 additions and 0 deletions

View file

@ -58,6 +58,23 @@ class ConstantUtils {
return name;
}
/**
* Validates the correctness of an internal class name.
* In particular checks for the presence of invalid characters in the name.
*
* @param name the class name
* @return the class name passed if valid
* @throws IllegalArgumentException if the class name is invalid
*/
static String validateInternalClassName(String name) {
for (int i=0; i<name.length(); i++) {
char ch = name.charAt(i);
if (ch == ';' || ch == '[' || ch == '.')
throw new IllegalArgumentException("Invalid class name: " + name);
}
return name;
}
/**
* Validates a member name
*