1 /*
2 * Copyright (c) 2003, 2013, 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
756 }
757 }
758 return (exceptionProxy != null) ? exceptionProxy : result;
759 }
760
761 /**
762 * Returns an appropriate exception proxy for a mismatching array
763 * annotation where the erroneous array has the specified tag.
764 */
765 private static ExceptionProxy exceptionProxy(int tag) {
766 return new AnnotationTypeMismatchExceptionProxy(
767 "Array with component tag: " + tag);
768 }
769
770 /**
771 * Skips the annotation at the current position in the specified
772 * byte buffer. The cursor of the byte buffer must point to
773 * an "annotation structure" OR two bytes into an annotation
774 * structure (i.e., after the type index).
775 *
776 * @parameter complete true if the byte buffer points to the beginning
777 * of an annotation structure (rather than two bytes in).
778 */
779 private static void skipAnnotation(ByteBuffer buf, boolean complete) {
780 if (complete)
781 buf.getShort(); // Skip type index
782 int numMembers = buf.getShort() & 0xFFFF;
783 for (int i = 0; i < numMembers; i++) {
784 buf.getShort(); // Skip memberNameIndex
785 skipMemberValue(buf);
786 }
787 }
788
789 /**
790 * Skips the annotation member value at the current position in the
791 * specified byte buffer. The cursor of the byte buffer must point to a
792 * "member_value structure."
793 */
794 private static void skipMemberValue(ByteBuffer buf) {
795 int tag = buf.get();
796 skipMemberValue(tag, buf);
|
1 /*
2 * Copyright (c) 2003, 2020, 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
756 }
757 }
758 return (exceptionProxy != null) ? exceptionProxy : result;
759 }
760
761 /**
762 * Returns an appropriate exception proxy for a mismatching array
763 * annotation where the erroneous array has the specified tag.
764 */
765 private static ExceptionProxy exceptionProxy(int tag) {
766 return new AnnotationTypeMismatchExceptionProxy(
767 "Array with component tag: " + tag);
768 }
769
770 /**
771 * Skips the annotation at the current position in the specified
772 * byte buffer. The cursor of the byte buffer must point to
773 * an "annotation structure" OR two bytes into an annotation
774 * structure (i.e., after the type index).
775 *
776 * @param complete true if the byte buffer points to the beginning
777 * of an annotation structure (rather than two bytes in).
778 */
779 private static void skipAnnotation(ByteBuffer buf, boolean complete) {
780 if (complete)
781 buf.getShort(); // Skip type index
782 int numMembers = buf.getShort() & 0xFFFF;
783 for (int i = 0; i < numMembers; i++) {
784 buf.getShort(); // Skip memberNameIndex
785 skipMemberValue(buf);
786 }
787 }
788
789 /**
790 * Skips the annotation member value at the current position in the
791 * specified byte buffer. The cursor of the byte buffer must point to a
792 * "member_value structure."
793 */
794 private static void skipMemberValue(ByteBuffer buf) {
795 int tag = buf.get();
796 skipMemberValue(tag, buf);
|