< prev index next >

src/java.base/share/native/libjava/check_classname.c

Print this page

177 static char *
178 skip_over_field_signature(char *name, jboolean void_okay,
179                           unsigned int length)
180 {
181     unsigned int array_dim = 0;
182     for (;length > 0;) {
183         switch (name[0]) {
184             case JVM_SIGNATURE_VOID:
185                 if (!void_okay) return 0;
186                 /* FALL THROUGH */
187             case JVM_SIGNATURE_BOOLEAN:
188             case JVM_SIGNATURE_BYTE:
189             case JVM_SIGNATURE_CHAR:
190             case JVM_SIGNATURE_SHORT:
191             case JVM_SIGNATURE_INT:
192             case JVM_SIGNATURE_FLOAT:
193             case JVM_SIGNATURE_LONG:
194             case JVM_SIGNATURE_DOUBLE:
195                 return name + 1;
196 
197             case JVM_SIGNATURE_CLASS: {

198                 /* Skip over the classname, if one is there. */
199                 char *p =
200                     skip_over_fieldname(name + 1, JNI_TRUE, --length);
201                 /* The next character better be a semicolon. */
202                 if (p && p - name - 1 > 0 && p[0] == ';')
203                     return p + 1;
204                 return 0;
205             }
206 
207             case JVM_SIGNATURE_ARRAY:
208                 array_dim++;
209                 /* JVMS 2nd ed. 4.10 */
210                 /*   The number of dimensions in an array is limited to 255 ... */
211                 if (array_dim > 255) {
212                     return 0;
213                 }
214                 /* The rest of what's there better be a legal signature.  */
215                 name++;
216                 length--;
217                 void_okay = JNI_FALSE;

177 static char *
178 skip_over_field_signature(char *name, jboolean void_okay,
179                           unsigned int length)
180 {
181     unsigned int array_dim = 0;
182     for (;length > 0;) {
183         switch (name[0]) {
184             case JVM_SIGNATURE_VOID:
185                 if (!void_okay) return 0;
186                 /* FALL THROUGH */
187             case JVM_SIGNATURE_BOOLEAN:
188             case JVM_SIGNATURE_BYTE:
189             case JVM_SIGNATURE_CHAR:
190             case JVM_SIGNATURE_SHORT:
191             case JVM_SIGNATURE_INT:
192             case JVM_SIGNATURE_FLOAT:
193             case JVM_SIGNATURE_LONG:
194             case JVM_SIGNATURE_DOUBLE:
195                 return name + 1;
196 
197             case JVM_SIGNATURE_CLASS:
198             case JVM_SIGNATURE_INLINE_TYPE: {
199                 /* Skip over the classname, if one is there. */
200                 char *p =
201                     skip_over_fieldname(name + 1, JNI_TRUE, --length);
202                 /* The next character better be a semicolon. */
203                 if (p && p - name - 1 > 0 && p[0] == ';')
204                     return p + 1;
205                 return 0;
206             }
207 
208             case JVM_SIGNATURE_ARRAY:
209                 array_dim++;
210                 /* JVMS 2nd ed. 4.10 */
211                 /*   The number of dimensions in an array is limited to 255 ... */
212                 if (array_dim > 255) {
213                     return 0;
214                 }
215                 /* The rest of what's there better be a legal signature.  */
216                 name++;
217                 length--;
218                 void_okay = JNI_FALSE;
< prev index next >