-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support an easy way to obtain all involved JavaClasses
of a generic signature
#723
Comments
Hi! I'm thinking of giving it a go, could you describe the intended use case, though? I was thinking that perhaps it would be somewhat more useful to be able to write sth like:
WDYT? For this to work, I believe we would need a new Also, since collections are going to be common use cases, probably some shorthand methods like |
This idea originated from Apache Flink where we have annotations for API stability, and we want a rule that makes sure that all types involved in a stable API are marked stable themselves. So we want to express something like
|
@Airblader This is a very specific use case, though, and I'm not sure Also, I just feel that putting all types involved in the declaration of a given type (regardless of their role in that declaration) in one bag is not going to be very useful. I was wondering if it would work for you if you could instead write some variation of In any case, such a rule would still require |
Maybe there's a misunderstanding – we don't need this to be accessible in the Lang API. Having a way to just (easily) get to this information in the Core API is totally fine with me. Apart from that I have no strong preferences.
Of course not. 😬 My example above was heavily simplified, sorry. 😄 We filter the classes further before checking for the annotation, e.g. we only check classes that lie in our |
@crizzis Thanks for the initiative 😃 But this issue really only refers to the core API method as a first step. It does not (yet) involve any rule syntax, that would be a later step for me... I think there are valid use cases to get the set of all involved types and in the Flink case this method could be used in a custom transformer/condition with some filter to only assert app classes. |
Hi, Given a Java Class (example from above, modified)
We want a new (static ?) method Things I'm unsure about:
|
|
sry for the late reply. |
This adds a new method for JavaType which should return all involved raw types of the given instance. This commit only implements this method for ImportedParameterizedType and JavaClass. Issue: TNG#723 Signed-off-by: Leonard Husmann <leonard.husmann@tum.de>
Issue: TNG#723 Signed-off-by: Leonard Husmann <leonard.husmann@tum.de>
Issue: TNG#723 Signed-off-by: Leonard Husmann <leonard.husmann@tum.de>
Issue: TNG#723 Signed-off-by: Leonard Husmann <leonard.husmann@tum.de>
This method returns the union of all raw types involved in the method's return type, all involved raw types of its parameters and its type parameters. Issue: TNG#723 Signed-off-by: Leonard Husmann <leonard.husmann@tum.de>
This commit adds test cases for getAllInvolvedRawTypes() of JavaClass, JavaTypeVariable and JavaWildcardType. This also adds a test case for getAllInvolvedRawTypesInSignature() of JavaCodeUnit. Issue: TNG#723 Signed-off-by: Leonard Husmann <leonard.husmann@tum.de>
Adds a convenience method to quickly determine all `JavaClass`es any `JavaType` depends on. For a complex type, like the parameterized type `Map<? extends Serializable, List<? super Set<String>>>`, this can otherwise be quite tedious and possibly make it necessary to traverse the whole type parameter hierarchy. Issue: TNG#723 Signed-off-by: Leonard Husmann <leonard.husmann@tum.de> Signed-off-by: Peter Gafert <peter.gafert@archunit.org>
Convenience method to find all `JavaClass`es involved in any member's signature. For a field these are only the raw types involved in the field type, for methods and constructors it's the union of all raw types involved in parameter types, return types and type parameters. Issue: TNG#723 Signed-off-by: Leonard Husmann <leonard.husmann@tum.de> Signed-off-by: Peter Gafert <peter.gafert@archunit.org>
Adds a convenience method to quickly determine all `JavaClass`es any `JavaType` depends on. For a complex type, like the parameterized type `Map<? extends Serializable, List<? super Set<String>>>`, this can otherwise be quite tedious and possibly make it necessary to traverse the whole type parameter hierarchy. Issue: TNG#723 Signed-off-by: Leonard Husmann <leonard.husmann@tum.de> Signed-off-by: Peter Gafert <peter.gafert@archunit.org>
Convenience method to find all `JavaClass`es involved in any member's signature. For a field these are only the raw types involved in the field type, for methods and constructors it's the union of all raw types involved in parameter types, return types and type parameters. Issue: TNG#723 Signed-off-by: Leonard Husmann <leonard.husmann@tum.de> Signed-off-by: Peter Gafert <peter.gafert@archunit.org>
There should be an easy way to obtain all
JavaClasses
that are involved in composing a generic type signature.E.g.
Then there should be some API to derive the set of classes
[Map, String, Serializable]
frommethod.getReturnType()
. We already have some logic like this to calculate the dependencies of a class, since all these classes are also dependencies of the generic return type.Open question: How should this method be named and where should it live? Should it be something like
? What would be a good name for this?
The text was updated successfully, but these errors were encountered: