Java interfaces and clientTypes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Java interfaces and clientTypes

Fuhrmanator
[Apologies to the moderator(s) for trying to post this via email with the wrong address. ]

I have Moose 6.0 and I've used jdt2famix 1.0.2 to generate an MSE file. I'm trying to use Moose to reason about clients of Java interfaces. I would like to find any classes that depend on an interface by any means. I thought using clientTypes was the right thing, except it doesn't work the way I expect in a simple case.
 
For the interface in my example, clientTypes only returns the class that is an implementation of the interface (which makes sense, as they depend on it) but not the client class that uses it via a private static reference (which, to me, doesn't make sense).

For more information, I am able find the client of the interface via structuresWithDeclaredType, so I'm pretty sure it's not information missing in the MSE file (not a jdt2famix bug).

Based on the simple example below, shouldn't clientTypes for ITest return ClassAClient and ConcreteImplementationA rather than just ConcreteImplementationA?

// ITest.java
public interface ITest {

}

// ConcreteImplementationA.java
public class ConcreteImplementationA implements ITest {

}

// ClassAClient.java
public class ClassAClient {
    private static ITest theTest;
    public static void main(String arg[]) {
        theTest = new ConcreteImplementationA();
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Java interfaces and clientTypes

Tudor Girba-2
Hi,

Indeed, clientTypes only returns explicit dependencies like: invocation, access, inheritance. It does not (yet) include structuresWithDeclaredType, behavioursWithDeclaredType or dependencies induced by annotations. We should likely extend the meaning of clientTypes, but that might be a bit difficult to do given that the current implementation depends on the generic MooseQuery.

In the meantime, please simply concatenate structuresWithDeclaredType in your concrete queries. Furthermore, you might also want to take into account all incoming dependencies to any subclass of your interface as they are potentially dependencies to the interface as well (this applies for methods that are included in the interface).

Cheers,
Doru


> On Sep 11, 2016, at 4:42 PM, Fuhrmanator <[hidden email]> wrote:
>
> [Apologies to the moderator(s) for trying to post this via email with the
> wrong address. ]
>
> I have Moose 6.0 and I've used jdt2famix 1.0.2 to generate an MSE file. I'm
> trying to use Moose to reason about clients of Java interfaces. I would like
> to find any classes that depend on an interface by any means. I thought
> using clientTypes was the right thing, except it doesn't work the way I
> expect in a simple case.
>
> For the interface in my example, clientTypes only returns the class that is
> an implementation of the interface (which makes sense, as they depend on it)
> but not the client class that uses it via a private static reference (which,
> to me, doesn't make sense).
>
> For more information, I am able find the client of the interface via
> structuresWithDeclaredType, so I'm pretty sure it's not information missing
> in the MSE file (not a jdt2famix bug).
>
> Based on the simple example below, shouldn't clientTypes for ITest return
> ClassAClient and ConcreteImplementationA rather than just
> ConcreteImplementationA?
>
> // ITest.java
> public interface ITest {
>
> }
>
> // ConcreteImplementationA.java
> public class ConcreteImplementationA implements ITest {
>
> }
>
> // ClassAClient.java
> public class ClassAClient {
>    private static ITest theTest;
>    public static void main(String arg[]) {
>        theTest = new ConcreteImplementationA();
>    }
> }
>
>
>
> --
> View this message in context: http://forum.world.st/Java-interfaces-and-clientTypes-tp4915115.html
> Sent from the Moose mailing list archive at Nabble.com.
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

--
www.tudorgirba.com
www.feenk.com

"Quality cannot be an afterthought."

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Java interfaces and clientTypes

Fuhrmanator
Tudor Girba-2 wrote
In the meantime, please simply concatenate structuresWithDeclaredType in your concrete queries. Furthermore, you might also want to take into account all incoming dependencies to any subclass of your interface as they are potentially dependencies to the interface as well (this applies for methods that are included in the interface).
Thanks for the helpful response. I was also using #clientTypes in the RTMondrian edge builder for simple code. However, I managed to get what I wanted using closures and some examples found with Google (it works, but is less elegant).
Reply | Threaded
Open this post in threaded view
|

Re: Java interfaces and clientTypes

abergel
Hi Cris!

Keep asking question!

Alexandre


> On Sep 11, 2016, at 5:53 PM, Fuhrmanator <[hidden email]> wrote:
>
> Tudor Girba-2 wrote
>> In the meantime, please simply concatenate structuresWithDeclaredType in
>> your concrete queries. Furthermore, you might also want to take into
>> account all incoming dependencies to any subclass of your interface as
>> they are potentially dependencies to the interface as well (this applies
>> for methods that are included in the interface).
>
> Thanks for the helpful response. I was also using #clientTypes in the
> RTMondrian edge builder for simple code. However, I managed to get what I
> wanted using closures and some examples found with Google (it works, but is
> less elegant).
>
>
>
> --
> View this message in context: http://forum.world.st/Java-interfaces-and-clientTypes-tp4915115p4915132.html
> Sent from the Moose mailing list archive at Nabble.com.
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev