1 /*
2 * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
309 * u2 type_name_index;
310 * u2 const_name_index;
311 * } enum_const_value;
312 * u2 class_info_index;
313 * annotation annotation_value;
314 * {
315 * u2 num_values;
316 * member_value values[num_values];
317 * } array_value;
318 * } value;
319 * }
320 *
321 * The member must be of the indicated type. If it is not, this
322 * method returns an AnnotationTypeMismatchExceptionProxy.
323 */
324 @SuppressWarnings("unchecked")
325 public static Object parseMemberValue(Class<?> memberType,
326 ByteBuffer buf,
327 ConstantPool constPool,
328 Class<?> container) {
329 // Note that VMSupport.encodeAnnotation (used by JVMCI) may need to
330 // be updated if new annotation member types are added.
331 Object result = null;
332 int tag = buf.get();
333 switch(tag) {
334 case 'e':
335 return parseEnumValue((Class<? extends Enum<?>>)memberType, buf, constPool, container);
336 case 'c':
337 result = parseClassValue(buf, constPool, container);
338 break;
339 case '@':
340 result = parseAnnotation(buf, constPool, container, true);
341 break;
342 case '[':
343 return parseArray(memberType, buf, constPool, container);
344 default:
345 result = parseConst(tag, buf, constPool);
346 }
347
348 if (result == null) {
349 result = new AnnotationTypeMismatchExceptionProxy(
350 Proxy.isProxyClass(memberType)
|
1 /*
2 * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
309 * u2 type_name_index;
310 * u2 const_name_index;
311 * } enum_const_value;
312 * u2 class_info_index;
313 * annotation annotation_value;
314 * {
315 * u2 num_values;
316 * member_value values[num_values];
317 * } array_value;
318 * } value;
319 * }
320 *
321 * The member must be of the indicated type. If it is not, this
322 * method returns an AnnotationTypeMismatchExceptionProxy.
323 */
324 @SuppressWarnings("unchecked")
325 public static Object parseMemberValue(Class<?> memberType,
326 ByteBuffer buf,
327 ConstantPool constPool,
328 Class<?> container) {
329 Object result = null;
330 int tag = buf.get();
331 switch(tag) {
332 case 'e':
333 return parseEnumValue((Class<? extends Enum<?>>)memberType, buf, constPool, container);
334 case 'c':
335 result = parseClassValue(buf, constPool, container);
336 break;
337 case '@':
338 result = parseAnnotation(buf, constPool, container, true);
339 break;
340 case '[':
341 return parseArray(memberType, buf, constPool, container);
342 default:
343 result = parseConst(tag, buf, constPool);
344 }
345
346 if (result == null) {
347 result = new AnnotationTypeMismatchExceptionProxy(
348 Proxy.isProxyClass(memberType)
|