Skip to content
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

[Java] Interface implementations aren't annotated #333

Closed
RomainMuller opened this issue Dec 13, 2018 · 2 comments
Closed

[Java] Interface implementations aren't annotated #333

RomainMuller opened this issue Dec 13, 2018 · 2 comments
Assignees
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. language/java Related to Java bindings p0

Comments

@RomainMuller
Copy link
Contributor

The generated implementations for interface types are not annotated with the JSII annotations, resulting in their being handled as Object though the language boundary. This de-facto opts them out of type model validation that could catch issues like the one reported in aws/aws-cdk#1347

@RomainMuller RomainMuller added enhancement language/java Related to Java bindings labels Dec 13, 2018
@srchase srchase added feature-request A feature should be added or improved. and removed enhancement labels Jan 3, 2019
@RomainMuller RomainMuller added this to the Java Support milestone Jul 30, 2019
@fulghum fulghum added p0 effort/small Small work item – less than a day of effort labels Aug 13, 2019
@rix0rrr
Copy link
Contributor

rix0rrr commented Sep 11, 2019

I believe this ticket is saying that proxy classes are generated like this:

    @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
    final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements S3ArtifactsProps {

As opposed to for example Python where it's generated like this:

@jsii.data_type(jsii_type="@aws-cdk/aws-codebuild.S3ArtifactsProps", jsii_struct_bases=[ArtifactsProps], name_mapping={'identifier': 'identifier', 'bucket': 'bucket', 'name': 'name', 'encryption': 'encryption', 'include_build_id': 'includeBuildId', 'package_zip': 'packageZip', 'path': 'path'})
class S3ArtifactsProps(ArtifactsProps):

The difference being the annotation that the object would serialize to a @aws-cdk/aws-codebuild.S3ArtifactsProps struct It is present on classes:

@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.codebuild.$Module.class, fqn = "@aws-cdk/aws-codebuild.CfnProject")
public class CfnProject extends software.amazon.awscdk.core.CfnResource {

However, I don't have enough state to judge the merit or applicability of this issue.

  • Maybe adding the annotation is enough, maybe it isn't?
  • I don't know whether Romain was thinking the validation would be done on the jsii kernel side, or on the Java jsii runtime side (in the latter case, adding the attribute is not enough, and more validation should be added instead).
  • Maybe because the kernel is doing some validation on required properties already (added since this issue was filed), this is no longer applicable?
  • One would assume that since Java is statically typed, such runtime checking should not even be necessary (epsilon bugs in the runtime, which the linked issue was an instance of).

I would recommend waiting until @RomainMuller gets back and asking him whether he thinks this issue should still be solved.

@RomainMuller
Copy link
Contributor Author

This is in fact no longer an issue, as Java started to pass structs by value instead of by reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. language/java Related to Java bindings p0
Projects
None yet
Development

No branches or pull requests

5 participants