[foreign-jextract] [Rev 02] RFR: 8239809: Need API to access attributes
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Fri Feb 28 11:14:53 UTC 2020
On Thu, 27 Feb 2020 23:02:53 GMT, Henry Jen <henryjen at openjdk.org> wrote:
>> The drawback with the API change is that no specialized subclass override, we can add those but seems too much. Cast if really needed should not be a big issue. If there is an elegant way to do that, I would like to know.
>
> /integrate
> The drawback with the API change is that no specialized subclass override, we can add those but seems too much. Cast if really needed should not be a big issue. If there is an elegant way to do that, I would like to know.
We had a similar issue in MemoryLayout API. You can see what we did there; in principle you can add an intermediate, non public, abstract class which uses generic types - e.g.
/* package */ abstract class AbstractDeclaration<X extends AbstractDeclaration<X>> implements Declaration {
public X withAttribute(String, Constable)
}
/* package */ class ScopeDeclarationImpl extends AbstractDeclaration<ScopeDeclarationImpl> { ... }
In practice though, javadoc doesn't work well with this (but fixes are in the works) - so we had to re-define all the methods in the layout subclasses to make javadoc happy.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/33
More information about the panama-dev
mailing list