-
Notifications
You must be signed in to change notification settings - Fork 77
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
extension API improvements #511
Conversation
api/src/main/java/jakarta/enterprise/lang/model/declarations/ParameterInfo.java
Outdated
Show resolved
Hide resolved
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/BeanInfo.java
Outdated
Show resolved
Hide resolved
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/BeanInfo.java
Outdated
Show resolved
Hide resolved
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/BeanInfo.java
Outdated
Show resolved
Hide resolved
* @return a collection of {@link MethodConfig} objects, never {@code null} | ||
*/ | ||
// TODO specify whether inherited constructors are also included | ||
Collection<MethodConfig> constructors(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No these should just be the declared constructors, inherited ones can be obtained by traversing the super class?
* @return a collection of {@link MethodConfig} objects, never {@code null} | ||
*/ | ||
// TODO specify whether inherited methods are also included | ||
Collection<MethodConfig> methods(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case it may make sense to have declaredMethods()
vs methods()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is something I'm a little ambivalent about. I think we already discussed something similar for annotations and kinda agreed that we'll always return all annotations, including inherited ones. We should probably do the same here.
I'm looking at what Weld does for Portable Extensions (because that seems quite under-documented on the Portable Extensions API side), and it works like this:
- for constructors, returns only constructors declared on this class
- for fields, returns all fields declared on this class and all its superclasses up to and excluding
Object
(which also includesprivate
fields from superclasses) - for methods, returns all methods declared on this class and all its superclasses up to and excluding
Object
(which also includesprivate
methods from superclasses), plus also alldefault
methods from all interfaces directly and indirectly implemented by this class
I guess that kinda sorta makes sense. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense for these methods yes. Although they will be relatively expensive methods to call since materializing all that info could be costly.
Micronaut has an extensive querying API for methods/fields that lets you filter methods prior to materializing the actual equivalent of MethodConfig
https://github.com/micronaut-projects/micronaut-core/blob/3.0.x/inject/src/main/java/io/micronaut/inject/ast/ElementQuery.java
I am not sure if something like this makes sense here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just thinking about it and I've got two little problems with methods from interfaces. We would include abstract
methods from [super]classes, but not from [super]interfaces. Also, we would include all default
methods, even if they potentially clash. It still kinda makes sense, but feels arbitrary. I'll think a bit more about it.
The situation for constructors and fields is rather clear, so I'll draft something and amend the PR.
Also, we already had a bit of querying API in AppArchive
and AppDeployment
. We might be able to bring some of that back for sure, but I don't think this is too big of an issue. Implementations should be able to materialize the collection lazily and memoize the result.
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/FieldConfig.java
Outdated
Show resolved
Hide resolved
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/InjectionPointInfo.java
Outdated
Show resolved
Hide resolved
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/InjectionPointInfo.java
Show resolved
Hide resolved
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/MethodConfig.java
Show resolved
Hide resolved
api/src/main/java/jakarta/enterprise/lang/model/declarations/ParameterInfo.java
Show resolved
Hide resolved
15d42ac
to
e6d7307
Compare
That is specifically: - change the `*Config` types to no longer inherit from the corresponding `*Info` types; instead, they provide an `info()` method - rename `AnnotationConfig` to `DeclarationConfig` for symmetry between `*Info` and `*Config` types - change the annotation transformation methods on `DeclarationConfig` to return `this` to allow fluent usage - allow additional parameter types for `@Enhancement` methods: `DeclarationConfig`, `DeclarationInfo`, `ClassInfo`, `MethodInfo`, and `FieldInfo` (`*Info` types are useful when only collecting information during `@Enhancement`, not modifying anything) - remove useless type parameters from `AnnotationInfo`, `ClassInfo`, `MethodInfo`, `FieldInfo`, `ClassConfig`, `MethodConfig`, `FieldConfig`, `BeanInfo`, and `ObserverInfo`; the `SyntheticBeanBuilder` type still has a type parameter, which remains an open question - add a lot of documentation
e6d7307
to
8a40e2e
Compare
I just added some javadoc to |
That is specifically:
*Config
types to no longer inherit from the corresponding*Info
types; instead, they provide aninfo()
methodAnnotationConfig
toDeclarationConfig
for symmetrybetween
*Info
and*Config
typesDeclarationConfig
to return
this
to allow fluent usage@Enhancement
methods:DeclarationConfig
,DeclarationInfo
,ClassInfo
,MethodInfo
,and
FieldInfo
(*Info
types are useful when only collectinginformation during
@Enhancement
, not modifying anything)AnnotationInfo
,ClassInfo
,MethodInfo
,FieldInfo
,ClassConfig
,MethodConfig
,FieldConfig
,BeanInfo
, andObserverInfo
; theSyntheticBeanBuilder
typestill has a type parameter, which remains an open question