Tue, 26 Oct 2010 14:08:49 -0400
6891959: HotSpot should not throw ClassFormatError if a class has a field with '>' and/or '<' in its name
Summary: Class file parser needs to look for and disallow '[' in names.
Reviewed-by: coleenp, never
src/share/vm/classfile/classFileParser.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/classfile/classFileParser.cpp Mon Oct 25 13:31:55 2010 -0400 1.2 +++ b/src/share/vm/classfile/classFileParser.cpp Tue Oct 26 14:08:49 2010 -0400 1.3 @@ -4309,20 +4309,21 @@ 1.4 } 1.5 1.6 1.7 -// Unqualified names may not contain the characters '.', ';', or '/'. 1.8 -// Method names also may not contain the characters '<' or '>', unless <init> or <clinit>. 1.9 -// Note that method names may not be <init> or <clinit> in this method. 1.10 -// Because these names have been checked as special cases before calling this method 1.11 -// in verify_legal_method_name. 1.12 -bool ClassFileParser::verify_unqualified_name(char* name, unsigned int length, int type) { 1.13 +// Unqualified names may not contain the characters '.', ';', '[', or '/'. 1.14 +// Method names also may not contain the characters '<' or '>', unless <init> 1.15 +// or <clinit>. Note that method names may not be <init> or <clinit> in this 1.16 +// method. Because these names have been checked as special cases before 1.17 +// calling this method in verify_legal_method_name. 1.18 +bool ClassFileParser::verify_unqualified_name( 1.19 + char* name, unsigned int length, int type) { 1.20 jchar ch; 1.21 1.22 for (char* p = name; p != name + length; ) { 1.23 ch = *p; 1.24 if (ch < 128) { 1.25 p++; 1.26 - if (ch == '.' || ch == ';') { 1.27 - return false; // do not permit '.' or ';' 1.28 + if (ch == '.' || ch == ';' || ch == '[' ) { 1.29 + return false; // do not permit '.', ';', or '[' 1.30 } 1.31 if (type != LegalClass && ch == '/') { 1.32 return false; // do not permit '/' unless it's class name