Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-7755

JavaUseProvider might attempt to instantiate interfaces or abstract classes

Details

    Description

      If you have a data-sly-use which receives a FQN of an interface or abstract class, the Java Use provider will not make any checks and will try to instantiate it anyway, causing a java.lang.NoSuchMethodException com.example.InterfaceName.<init>().

      This is a problem when your code base normally relies in an adapter factory to get implementation of an interface and the adaptTo returns null, causing sightly to try the java Use provider

      The Java Use provider should not attempt to instantiate blindly classes that it receives.

       

      Attachments

        Activity

          hi radu.cotescu . I think you are familiar with this (says git). would you mind having a look at this and my PR?

          thank you!

          santiagozky Santiago García Pimentel added a comment - hi radu.cotescu . I think you are familiar with this (says git). would you mind having a look at this and my PR? thank you!
          radu Radu Cotescu added a comment -

          santiagozky, the PR looks okay. Could you please provide some tests with it too? You'd have to provide some Java code in [1] (the abstract class or interface) and a test in [2].

          [1] - https://github.com/apache/sling-org-apache-sling-scripting-sightly-testing-content

          [2] - https://github.com/apache/sling-org-apache-sling-scripting-sightly-testing

           

          radu Radu Cotescu added a comment - santiagozky , the PR looks okay. Could you please provide some tests with it too? You'd have to provide some Java code in [1] (the abstract class or interface) and a test in [2] . [1] - https://github.com/apache/sling-org-apache-sling-scripting-sightly-testing-content [2] - https://github.com/apache/sling-org-apache-sling-scripting-sightly-testing  

          radu.cotescu I think I managed 

          santiagozky Santiago García Pimentel added a comment - radu.cotescu I think I managed 

          radu.cotescu would you mind having a look at this when you have some time? 

          thanks!

          santiagozky Santiago García Pimentel added a comment - radu.cotescu  would you mind having a look at this when you have some time?  thanks!
          radu Radu Cotescu added a comment - Applied PRs in: commit 360df4e commit 5169606 commit d41ff5a

          People

            radu Radu Cotescu
            santiagozky Santiago García Pimentel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 20m
                1h 20m