chaokunyang commented on code in PR #3021:
URL: https://github.com/apache/fory/pull/3021#discussion_r2616293409


##########
java/fory-core/src/main/java/org/apache/fory/meta/ClassDef.java:
##########
@@ -247,17 +248,37 @@ public List<Descriptor> getDescriptors(TypeResolver 
resolver, Class<?> cls) {
       SortedMap<Member, Descriptor> allDescriptorsMap =
           resolver.getFory().getClassResolver().getAllDescriptorsMap(cls, 
true);
       Map<String, Descriptor> descriptorsMap = new HashMap<>();
+      Map<Short, Descriptor> tagToDescriptorMap = new HashMap<>();
+
+      // Build maps for both name-based and tag-based lookups
       for (Map.Entry<Member, Descriptor> e : allDescriptorsMap.entrySet()) {
-        if (descriptorsMap.put(
-                e.getKey().getDeclaringClass().getName() + "." + 
e.getKey().getName(), e.getValue())
-            != null) {
+        String fullName = e.getKey().getDeclaringClass().getName() + "." + 
e.getKey().getName();
+        Descriptor desc = e.getValue();
+        if (descriptorsMap.put(fullName, desc) != null) {
           throw new IllegalStateException("Duplicate key");
         }
+
+        // If the field has @ForyField annotation with tag ID, index by tag ID
+        if (desc.getForyField() != null) {
+          int tagId = desc.getForyField().id();

Review Comment:
   We also need some checks to avoid negative id if it's not -1, and also need 
to a=check duplciate id if it's not -1 too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to