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

fix: Missing types in JSII assembly, invalid Java code, confusing docs #208

Merged
merged 10 commits into from
Sep 5, 2018

Conversation

RomainMuller
Copy link
Contributor

@RomainMuller RomainMuller commented Aug 31, 2018

  • The new jsii would omit interfaces defined within namespaces because of the way namespaces were processed (using members instead of listing all exports).
  • Some jsii type validations could, in some rare cases, happen too early, attempting to dereference types that hadn't been processed yet.
  • The jsii-pacmak generator for Java could generate property names that were reserved words (e.g: assert).
  • the jsii-pacmak generator for Sphinx would generate confusing (or incorrect) type documentation for entities of array types, and particularly so for arrays of unions.
  • Fix for Java interface proxies do not respect optional arguments in methods #175: interface proxies do not respect optional method arguments

Should probably add (I don't believe I'll be able to do this before I go on holidays 😅):

  • Test surface in jsii-calc or its dependencies that exercise the interface-in-namespace.
  • Test surface in jsii-calc or its dependencies that exercise reserved words of various languages.

Not doing so could cause type checks to fail randomly (assuming the referred-to type has not been
processed just yet by the assembler).
Looking at their properties will only list entities that have an existence in
the Javascript world, which is not the case of interfaces, for example.
The anonymous class generated by the builders included a verbatim field name from the type specification,
which could include Java keywords (such as assert). Appended a $ in front to avoid all collisions there,
while also avoiding to collide with the parent builder's _fields.
@RomainMuller RomainMuller requested a review from eladb August 31, 2018 14:14
The `ref` of array types would not include the [], causing them to render in confusing
ways in the documentation. Additionally, arrays of union types would only have the [] on
the last of the options, which was incorrect. Added parentheses around the possible
element types in order to clarify the situation.
@RomainMuller RomainMuller changed the title fix: Missing types in JSII assembly, invalid Java code fix: Missing types in JSII assembly, invalid Java code, confusing docs Aug 31, 2018
packages/jsii-pacmak/lib/targets/java.ts Show resolved Hide resolved
ts.DiagnosticCategory.Error,
`Unable to resolve type ${jsiiType.base!.fqn} (base type of ${jsiiType.fqn})`);
} else if (spec.isClassType(baseType)) {
jsiiType.initializer = baseType.initializer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am concerned about defer. For example, the fact that you only assign the initializer here looks like a potential race condition. How do I know what order these defer statements actually execution? Now initializer is a moving target!

I am okay with using defer for validation (maybe should be renamed to validate), but it seems very fragile for mutations of the model

Elad Ben-Israel added 3 commits September 5, 2018 09:35
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated PR with coverage to interfaces exported within namespaces

packages/jsii-pacmak/lib/targets/java.ts Show resolved Hide resolved
Elad Ben-Israel added 3 commits September 5, 2018 12:07
When generating java proxy classes for interfaces,
make sure to create an overload for methods that include
optional arguments.
@eladb eladb merged commit b37101f into master Sep 5, 2018
@eladb eladb deleted the rmuller/bug-fixes branch September 5, 2018 09:57
mpiroc added a commit that referenced this pull request Sep 6, 2018
[0.7.2](v0.7.1...v0.7.2) (2018-09-06)

Bug Fixes

* Missing types in JSII assembly, invalid Java code, confusing docs ([#208](#208)) ([b37101f](b37101f)), closes [#175](#175)

Features

* **jsii:** Re-implemented jsii to support --watch and produce better error reporting ([#188](#188)) ([76472be](76472be))
mpiroc added a commit that referenced this pull request Sep 6, 2018
[0.7.2](v0.7.1...v0.7.2) (2018-09-06)

Bug Fixes

* Missing types in JSII assembly, invalid Java code, confusing docs ([#208](#208)) ([b37101f](b37101f)), closes [#175](#175)

Features

* **jsii:** Re-implemented jsii to support --watch and produce better error reporting ([#188](#188)) ([76472be](76472be))
@mpiroc mpiroc mentioned this pull request Sep 6, 2018
mpiroc added a commit that referenced this pull request Sep 6, 2018
* v0.7.2

[0.7.2](v0.7.1...v0.7.2) (2018-09-06)

Bug Fixes

* Missing types in JSII assembly, invalid Java code, confusing docs ([#208](#208)) ([b37101f](b37101f)), closes [#175](#175)

Features

* **jsii:** Re-implemented jsii to support --watch and produce better error reporting ([#188](#188)) ([76472be](76472be))

* Check in changes to tarball expectations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants