11/*
2- * Copyright (c) 1996,2020 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1996,2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@ abstract public class MemberData<T extends Environment<? extends ToolLogger>> {
4747protected DataVectorAttr <TypeAnnotationData >type_annotAttrVis =null ;
4848protected DataVectorAttr <TypeAnnotationData >type_annotAttrInv =null ;
4949protected AttrData signatureAttr ;
50- protected ELocation attributeLocation =ELocation .UNKNOWN ;
50+ protected ELocation attributeLocation =ELocation .unknown ;
5151
5252public MemberData (ConstantPool pool ,T environment ) {
5353this (pool ,environment ,0 );
@@ -112,6 +112,13 @@ public ConstantPool getPool() {
112112 }
113113
114114public void setSignatureAttr (ConstCell value_cpx ) {
115+ if (this .signatureAttr !=null ) {
116+ CPXAttr cpx = (CPXAttr )signatureAttr ;
117+ if (value_cpx .cpIndex !=cpx .cell .cpIndex ) {
118+ environment .warning ("warn.redeclared.attribute" ,SIGNATURE .parseKey (),
119+ this .attributeLocation .getDescription ());
120+ }
121+ }
115122signatureAttr =new CPXAttr (pool ,EAttribute .ATT_Signature ,value_cpx );
116123 }
117124
@@ -120,12 +127,21 @@ public void setSignatureAttr(ConstCell value_cpx, long position) {
120127CPXAttr cpx = (CPXAttr )signatureAttr ;
121128if (value_cpx .cpIndex !=cpx .cell .cpIndex ) {
122129environment .warning (position ,"warn.redeclared.attribute" ,
123- SIGNATURE .parseKey (),ELocation . ClassFile . toString ());
130+ SIGNATURE .parseKey (),this . attributeLocation . getDescription ());
124131 }
125132 }
126133signatureAttr =new CPXAttr (pool ,EAttribute .ATT_Signature ,value_cpx );
127134 }
128135
136+ /**
137+ * Retrieves the signature attribute associated with this member.
138+ *
139+ * @return the signature attribute, or null if it has not been set
140+ */
141+ public AttrData getSignatureAttr () {
142+ return signatureAttr ;
143+ }
144+
129145
130146protected abstract <D extends DataWriter >DataVector <D >getAttrVector ();
131147
@@ -153,41 +169,44 @@ protected final <D extends DataWriter> DataVector<D> getDataVector(D... extraAtt
153169return attrs ;
154170 }
155171
156- public void addAnnotations (ArrayList <AnnotationData >list ) {
157- for (AnnotationData item :list ) {
158- boolean invisible =item .invisible ;
159-
160- if (item instanceof TypeAnnotationData typeAnnotationData ) {
161- // Type Annotations
162- if (invisible ) {
163- if (type_annotAttrInv ==null ) {
164- type_annotAttrInv =new DataVectorAttr <>(pool ,
165- EAttribute .ATT_RuntimeInvisibleTypeAnnotations );
166- }
167- type_annotAttrInv .add (typeAnnotationData );
168- }else {
169- if (type_annotAttrVis ==null ) {
170- type_annotAttrVis =new DataVectorAttr <>(pool ,
171- EAttribute .ATT_RuntimeVisibleTypeAnnotations );
172- }
173- type_annotAttrVis .add (typeAnnotationData );
174- }
175- }else {
176- // Regular Annotations
177- if (invisible ) {
178- if (annotAttrInv ==null ) {
179- annotAttrInv =new DataVectorAttr <>(pool ,
180- EAttribute .ATT_RuntimeInvisibleAnnotations );
172+ public MemberData <T >addAnnotations (ArrayList <AnnotationData >list ) {
173+ if (list !=null ) {
174+ for (AnnotationData item :list ) {
175+ boolean invisible =item .invisible ;
176+
177+ if (item instanceof TypeAnnotationData typeAnnotationData ) {
178+ // Type Annotations
179+ if (invisible ) {
180+ if (type_annotAttrInv ==null ) {
181+ type_annotAttrInv =new DataVectorAttr <>(pool ,
182+ EAttribute .ATT_RuntimeInvisibleTypeAnnotations );
183+ }
184+ type_annotAttrInv .add (typeAnnotationData );
185+ }else {
186+ if (type_annotAttrVis ==null ) {
187+ type_annotAttrVis =new DataVectorAttr <>(pool ,
188+ EAttribute .ATT_RuntimeVisibleTypeAnnotations );
189+ }
190+ type_annotAttrVis .add (typeAnnotationData );
181191 }
182- annotAttrInv .add (item );
183192 }else {
184- if (annotAttrVis ==null ) {
185- annotAttrVis =new DataVectorAttr <>(pool ,
186- EAttribute .ATT_RuntimeVisibleAnnotations );
193+ // Regular Annotations
194+ if (invisible ) {
195+ if (annotAttrInv ==null ) {
196+ annotAttrInv =new DataVectorAttr <>(pool ,
197+ EAttribute .ATT_RuntimeInvisibleAnnotations );
198+ }
199+ annotAttrInv .add (item );
200+ }else {
201+ if (annotAttrVis ==null ) {
202+ annotAttrVis =new DataVectorAttr <>(pool ,
203+ EAttribute .ATT_RuntimeVisibleAnnotations );
204+ }
205+ annotAttrVis .add (item );
187206 }
188- annotAttrVis .add (item );
189207 }
190208 }
191209 }
210+ return this ;
192211 }
193212}