Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4275705

swing.UIDefaults.ProxyLazyValue.createValue prints too much

XMLWordPrintable

    • beta
    • generic, x86, sparc
    • generic, solaris_2.6, windows_nt



      Name: sdC67446 Date: 09/27/99


      The method
          public Object createValue(UIDefaults table)
      of class
          javax.swing.UIDefaults.ProxyLazyValue:

      1) does not use input parameter 'table'
      2) prints too much if output value is null
         (see test)

      The doc says:
      --------------------------------------------------
      public UIDefaults.ProxyLazyValue(String c,
                                       String m,
                                       Object[] o)

            Create a LazyValue which will construct an instance when asked.
            Parameters:
                  c - a String specifying the classname of the class
                      containing a static method to be called for instance creation.
                  m - a String specifying the static method to be called on
                      class c.
                  o - an array of Objects to be passed as paramaters to the
                      static method in class c.

      The demo test:
      --------------------------------------------------
      import javax.swing.UIDefaults;

      public class Test {
          static void test(int caseno,
                           String c,
                           String m,
                           Object[] o) {
              System.out.println("=== caseno: "+caseno);
              UIDefaults.ProxyLazyValue plv =
                  new UIDefaults.ProxyLazyValue(c, m, o);
              System.out.println("=== output: "+plv.createValue(new UIDefaults()));
          }

          public static void main(String argv[]) {
              test(1,null,"method",null);
              test(2,"java.lang.Boolean",null,null);
              test(3,"java.lang.Boolean","noMethod",null);
              test(4,"java.lang.String","valueOf",null);
          }
      }

      Output:
      --------------------------------------------------
      === caseno: 1
      Problem creating null with method method and args { : java.lang.NullPointerException
      java.lang.Exception: Stack trace
              at java.lang.Thread.dumpStack(Thread.java:983)
              at javax.swing.UIDefaults$ProxyLazyValue.createValue(UIDefaults.java:620)
              at Test.test(Test.java:11)
              at Test.main(Test.java:15)
      === output: null
      === caseno: 2
      Problem with constructor java.lang.Boolean and args { : and types { : java.lang.NoSuchMethodException
      java.lang.Exception: Stack trace
              at java.lang.Thread.dumpStack(Thread.java:983)
              at javax.swing.UIDefaults$ProxyLazyValue.createValue(UIDefaults.java:613)
              at Test.test(Test.java:11)
              at Test.main(Test.java:16)
      === output: null
      === caseno: 3
      Problem creating java.lang.Boolean with method noMethod and args { : java.lang.NoSuchMethodException
      java.lang.Exception: Stack trace
              at java.lang.Thread.dumpStack(Thread.java:983)
              at javax.swing.UIDefaults$ProxyLazyValue.createValue(UIDefaults.java:620)
              at Test.test(Test.java:11)
              at Test.main(Test.java:17)
      === output: null
      === caseno: 4
      Problem creating java.lang.String with method valueOf and args { : java.lang.NoSuchMethodException
      java.lang.Exception: Stack trace
              at java.lang.Thread.dumpStack(Thread.java:983)
              at javax.swing.UIDefaults$ProxyLazyValue.createValue(UIDefaults.java:620)
              at Test.test(Test.java:11)
              at Test.main(Test.java:18)
      === output: null

      --------------------------------------------------
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: