Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-5915

[beans] Introspector.getBeanInfo() will exclude public static methods.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.0M6
    • 5.0M6
    • Classlib
    • None

    Description

      Given the following test case,
      import java.beans.BeanInfo;
      import java.beans.Introspector;
      import java.beans.MethodDescriptor;
      import java.beans.PropertyDescriptor;
      public class BeansTest {
      public static void main(String[] args) throws Throwable

      { dumpBean(Empty.class); dumpBean(Static.class); }

      static void dumpBean(final Class cl) throws Throwable {
      System.out.println("Introspecting: " + cl.getName());
      BeanInfo beanInfo = Introspector.getBeanInfo(cl);
      System.out.println(" Properties: ");
      for (PropertyDescriptor p : beanInfo.getPropertyDescriptors())

      { System.out.println(" + " + p.getName()); System.out.println(" - read: " + p.getReadMethod()); System.out.println(" - write: " + p.getReadMethod()); }

      System.out.println(" Methods: ");
      for (MethodDescriptor m : beanInfo.getMethodDescriptors())

      { System.out.println(" + " + m.getName()); System.out.println(" - " + m.getMethod()); }

      }
      }
      class Empty {
      }
      class Static {
      public static String getName()

      { return "static class"; }

      }
      When this test case is run, the output from introspecting the Empty class is identical to that of the output from introspecting the Static class.
      There is no information returned for getName(). If I remove the "static" keyword in the declaration of class Static, then introspection DOES return the "getName()" method.

      Attachments

        1. HARMONY-5915.diff
          5 kB
          Kevin Zhou

        Activity

          People

            qiuxiaox Sean Qiu
            zhoukevin Kevin Zhou
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified