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(java): module "<module name>" not found error #1906

Merged
merged 8 commits into from
Aug 19, 2020

Conversation

RomainMuller
Copy link
Contributor

Struct proxies did not trigger loading of their parent module when
passed as a parameter, which then causes the @jsii/kernel type checker
to be unable to locate the struct type definition for checking pruposes,
leading to a crash.

This updatates the JsiiSerializable serialization process to
proactively load the relevant modules (the call is idempotent and short
circuits if the module is known to already be loaded).

Fixes #1904


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Struct proxies did not trigger loading of their parent module when
passed as a parameter, which then causes the `@jsii/kernel` type checker
to be unable to locate the struct type definition for checking pruposes,
leading to a crash.

This updatates the `JsiiSerializable` serialization process to
proactively load the relevant modules (the call is idempotent and short
circuits if the module is known to already be loaded).

Fixes #1904
@RomainMuller RomainMuller added bug This issue is a bug. language/java Related to Java bindings effort/small Small work item – less than a day of effort module/runtime Issues affecting the `jsii-runtime` contribution/core This is a PR that came from AWS. labels Aug 17, 2020
@RomainMuller RomainMuller requested a review from a team August 17, 2020 14:42
@RomainMuller RomainMuller self-assigned this Aug 17, 2020
@RomainMuller RomainMuller added the pr/do-not-merge This PR should not be merged at this time. label Aug 17, 2020
@RomainMuller
Copy link
Contributor Author

Labeled with pr/do-not-merge as I still want to add a similar test in Python & .NET to confirm the bug does not affect them.

/**
* This is a struct, nested within a class. Normal.
*/
export interface NestedStruct {
Copy link
Contributor

Choose a reason for hiding this comment

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

ew... what.

@MrArnoldPalmer
Copy link
Contributor

Was this only triggered by nested structs for some reason?

@RomainMuller
Copy link
Contributor Author

@MrArnoldPalmer yeah - the bottom line is that Java does not issue a create call to the kernel upon initialization, which is where the load for the hosting module happens for other objects (the struct proxies are "pure data" so they don't appear in the JS process before they're actually sent across the boundary).

The nesting might not add to the problem (but I had it to reproduce the original issue discovered, and I reckon this makes it a slightly more hostile pattern - meaning I have more chances to catch more issues with that :D).

class loaders aren't necessarily URLClassLoaders.
@RomainMuller RomainMuller added this to the August Release milestone Aug 19, 2020
@RomainMuller RomainMuller removed the pr/do-not-merge This PR should not be merged at this time. label Aug 19, 2020
@RomainMuller RomainMuller force-pushed the rmuller/java-nested-class-loading branch from 48a4a86 to de747c6 Compare August 19, 2020 14:15
@mergify
Copy link
Contributor

mergify bot commented Aug 19, 2020

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Aug 19, 2020
@mergify
Copy link
Contributor

mergify bot commented Aug 19, 2020

Merging (with squash)...

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 5e460c5
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit d0b9ffd into master Aug 19, 2020
@mergify mergify bot deleted the rmuller/java-nested-class-loading branch August 19, 2020 16:12
@mergify
Copy link
Contributor

mergify bot commented Aug 19, 2020

Merging (with squash)...

@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/small Small work item – less than a day of effort language/java Related to Java bindings module/runtime Issues affecting the `jsii-runtime`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'Module not found' error from JSII kernel in non-typescript languages
3 participants