Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-1928

Resolving factory method does not allow method overriding

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.2.1, 2.0.1
    • 2.2.0
    • kernel
    • None
    • Patch Available

    Description

      If a get method is annotated with @Factory then the method cannot be overridden with a method which take different parameters. The system randomly selects one of the several methods with the same name which may or may not take the type which will be provided.

      For example:
      @Persistent(optional = false)
      @Column(name = "STATUS")
      @Externalizer("getName")
      @Factory("valueOf")
      public OrderStatus getStatus()

      { return this.status; }

      public class OrderStatus {
      public static OrderStatus valueOf(final int ordinal)

      { return valueOf(ordinal, OrderStatus.class); }

      public static OrderStatus valueOf(final String name)

      { return valueOf(name, OrderStatus.class); }

      }

      Actual results:
      valueOf(String) may or may not be selected.

      Expected results:
      valueOf(String) should always be selected.

      The provided patches fix this defect by applying the method invocation conversion rules from the Java Language Specification, 3rd Ed. This means that widening primitive, boxing and unboxing conversions are all respected.

      Attachments

        1. OPENJPA-1928-r1061099.patch
          22 kB
          Edward Sargisson
        2. OPENJPA-1928-1.2.1.patch
          22 kB
          Edward Sargisson

        Activity

          People

            curtisr7 Richard G. Curtis
            esargisson Edward Sargisson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: