Harmony
  1. Harmony
  2. HARMONY-6063

[classlib][prefs] implement mechanism of loading preference service provider

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0M8
    • Fix Version/s: 5.0M12
    • Component/s: Classlib
    • Labels:
      None

      Description

      implement mechanism of loading preference service provider, make it compatible with RI

        Activity

        Hide
        Regis Xu added a comment -

        the patch implement mechanism of loading service provider of prefs module, which described in spec

        add following files for testing:
        modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesProviderTest.java
        modules/prefs/src/test/resources/config/META-INF/services/java.util.prefs.PreferencesFactory

        also modify build.xml to run the test in a separated vm with different classpath

        Would anyone want to try this?

        Show
        Regis Xu added a comment - the patch implement mechanism of loading service provider of prefs module, which described in spec add following files for testing: modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesProviderTest.java modules/prefs/src/test/resources/config/META-INF/services/java.util.prefs.PreferencesFactory also modify build.xml to run the test in a separated vm with different classpath Would anyone want to try this?
        Hide
        Nathan Beyer added a comment -

        Did you do any tests with the RI to see what exception is thrown when a provider fails? Also, I'd be curious to see if it is thrown during static initialization or at some other time - is the factory loaded at class init or lazily.

        Show
        Nathan Beyer added a comment - Did you do any tests with the RI to see what exception is thrown when a provider fails? Also, I'd be curious to see if it is thrown during static initialization or at some other time - is the factory loaded at class init or lazily.
        Hide
        Regis Xu added a comment -

        The configuration file is:

        $ cat META-INF/services/java.util.prefs.PreferencesFactory

        1. It's comments

        not.exist.provider # mock provider

        The test case is:
        $ cat prefs/TestPrefs.java
        package prefs;

        public class TestPrefs {
        public static void main(String[] args) throws Exception

        { // make sure load from configuration file System.clearProperty("java.util.prefs.PreferencesFactory"); Class.forName("java.util.prefs.Preferences"); }

        }

        RI throw a internal error:
        Exception in thread "main" sun.misc.ServiceConfigurationError: java.util.prefs.PreferencesFactory: Provider not.exist.provider not found
        at sun.misc.Service.fail(Service.java:129)
        at sun.misc.Service.access$000(Service.java:111)
        at sun.misc.Service$LazyIterator.next(Service.java:273)
        at java.util.prefs.Preferences.factory1(Preferences.java:265)
        at java.util.prefs.Preferences.access$000(Preferences.java:208)
        at java.util.prefs.Preferences$2.run(Preferences.java:255)
        at java.util.prefs.Preferences$2.run(Preferences.java:254)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.util.prefs.Preferences.factory(Preferences.java:252)
        at java.util.prefs.Preferences.<clinit>(Preferences.java:210)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:164)
        at prefs.TestPrefs.main(TestPrefs.java:7)

        seems RI load provider when class Preferences loaded

        Show
        Regis Xu added a comment - The configuration file is: $ cat META-INF/services/java.util.prefs.PreferencesFactory It's comments not.exist.provider # mock provider The test case is: $ cat prefs/TestPrefs.java package prefs; public class TestPrefs { public static void main(String[] args) throws Exception { // make sure load from configuration file System.clearProperty("java.util.prefs.PreferencesFactory"); Class.forName("java.util.prefs.Preferences"); } } RI throw a internal error: Exception in thread "main" sun.misc.ServiceConfigurationError: java.util.prefs.PreferencesFactory: Provider not.exist.provider not found at sun.misc.Service.fail(Service.java:129) at sun.misc.Service.access$000(Service.java:111) at sun.misc.Service$LazyIterator.next(Service.java:273) at java.util.prefs.Preferences.factory1(Preferences.java:265) at java.util.prefs.Preferences.access$000(Preferences.java:208) at java.util.prefs.Preferences$2.run(Preferences.java:255) at java.util.prefs.Preferences$2.run(Preferences.java:254) at java.security.AccessController.doPrivileged(Native Method) at java.util.prefs.Preferences.factory(Preferences.java:252) at java.util.prefs.Preferences.<clinit>(Preferences.java:210) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:164) at prefs.TestPrefs.main(TestPrefs.java:7) seems RI load provider when class Preferences loaded
        Hide
        Regis Xu added a comment -

        Hi Nathan,

        Any comments on patch HARMONY-6063.diff?

        Show
        Regis Xu added a comment - Hi Nathan, Any comments on patch HARMONY-6063 .diff?
        Hide
        Nathan Beyer added a comment -

        Whoa ... been a while on this one. Sorry. I'm fine with it. Go ahead and apply it.

        Show
        Nathan Beyer added a comment - Whoa ... been a while on this one. Sorry. I'm fine with it. Go ahead and apply it.
        Hide
        Regis Xu added a comment -

        patch applied at r826579 with minor changes to work with latest build script.

        Show
        Regis Xu added a comment - patch applied at r826579 with minor changes to work with latest build script.
        Hide
        Hudson added a comment -

        Integrated in Harmony-1.5-head-linux-x86_64 #509 (See http://hudson.zones.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/509/)
        Apply patch for : [classlib][prefs] implement mechanism of loading preference service provider

        Minor changes of patch .diff to make it work with latest build script.

        Show
        Hudson added a comment - Integrated in Harmony-1.5-head-linux-x86_64 #509 (See http://hudson.zones.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/509/ ) Apply patch for : [classlib] [prefs] implement mechanism of loading preference service provider Minor changes of patch .diff to make it work with latest build script.

          People

          • Assignee:
            Regis Xu
            Reporter:
            Regis Xu
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development