xref: /aosp_15_r20/external/snakeyaml/src/patches/android/PropertyUtils.patch (revision ac2a7c1bf4e14d82f3bd566dcc2d76d5b42faf34)
1diff --git a/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java b/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java
2index 8afc5761..208c9351 100644
3--- a/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java
4+++ b/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java
5@@ -13,12 +13,7 @@
6  */
7 package org.yaml.snakeyaml.introspector;
8
9-import java.beans.FeatureDescriptor;
10-import java.beans.IntrospectionException;
11-import java.beans.Introspector;
12-import java.beans.PropertyDescriptor;
13 import java.lang.reflect.Field;
14-import java.lang.reflect.Method;
15 import java.lang.reflect.Modifier;
16 import java.util.Collection;
17 import java.util.HashMap;
18@@ -65,47 +60,14 @@ public class PropertyUtils {
19     }
20
21     Map<String, Property> properties = new LinkedHashMap<String, Property>();
22-    boolean inaccessableFieldsExist = false;
23-    if (bAccess == BeanAccess.FIELD) {
24-      for (Class<?> c = type; c != null; c = c.getSuperclass()) {
25+    for (Class<?> c = type; c != null; c = c.getSuperclass()) {
26         for (Field field : c.getDeclaredFields()) {
27-          int modifiers = field.getModifiers();
28-          if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)
29-              && !properties.containsKey(field.getName())) {
30-            properties.put(field.getName(), new FieldProperty(field));
31-          }
32-        }
33-      }
34-    } else {// add JavaBean properties
35-      try {
36-        for (PropertyDescriptor property : Introspector.getBeanInfo(type)
37-            .getPropertyDescriptors()) {
38-          Method readMethod = property.getReadMethod();
39-          if ((readMethod == null || !readMethod.getName().equals("getClass"))
40-              && !isTransient(property)) {
41-            properties.put(property.getName(), new MethodProperty(property));
42-          }
43-        }
44-      } catch (IntrospectionException e) {
45-        throw new YAMLException(e);
46-      }
47-
48-      // add public fields
49-      for (Class<?> c = type; c != null; c = c.getSuperclass()) {
50-        for (Field field : c.getDeclaredFields()) {
51-          int modifiers = field.getModifiers();
52-          if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)) {
53-            if (Modifier.isPublic(modifiers)) {
54-              properties.put(field.getName(), new FieldProperty(field));
55-            } else {
56-              inaccessableFieldsExist = true;
57-            }
58-          }
59-        }
60-      }
61-    }
62-    if (properties.isEmpty() && inaccessableFieldsExist) {
63-      throw new YAMLException("No JavaBean properties found in " + type.getName());
64+            int modifiers = field.getModifiers();
65+            if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)
66+                    && !properties.containsKey(field.getName())) {
67+                properties.put(field.getName(), new FieldProperty(field));
68+             }
69+         }
70     }
71     propertiesCache.put(type, properties);
72     return properties;
73@@ -113,10 +75,6 @@ public class PropertyUtils {
74
75   private static final String TRANSIENT = "transient";
76
77-  private boolean isTransient(FeatureDescriptor fd) {
78-    return Boolean.TRUE.equals(fd.getValue(TRANSIENT));
79-  }
80-
81   public Set<Property> getProperties(Class<? extends Object> type) {
82     return getProperties(type, beanAccess);
83   }
84