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

Add static methods to interfaces

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.2
    • specification
    • generic
    • generic



      Name: mc57594 Date: 11/15/99


      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, native threads, symcjit)

      Much of the software I develop extensively uses reflection for the loading of
      classes at runtime. These classes often implement an interface which I use as
      the "contract" to decide whether the class in suitable for loading (it is
      easier to check if it implements an interface rather than if it implements all
      the required methods). To make this less vague, here is an example.

      I have a logging system which loads the required logging classes at runtime
      based on user/sys admin choices. These logging classes must have a constructor
      with a specific signature, a number of instance methods and a number of static
      methods. Here's the problem: You cannot specify constructor signatures, nor
      static methods in an interface.

      The second issue is a stumper. The static method are required to tell a
      configuration utility what properties the logging object needs specified, so I
      want to make this static, and not have to construct an object only to find out
      what information it requires!! If I specify the static methods as non-static
      within the interface, then they can't be implemented as static within any
      derived classes. Nor can I use static final constants for this particular
      task.
      (Review ID: 97779)
      ======================================================================

            gbrachasunw Gilad Bracha (Inactive)
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: