(rosetta): java not substituting getters in all cases
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 267
- Avg merge
- 1d 25m
- Merged PRs (30d)
- 14
Description
### Describe the bug
Referencing examples [here](https://docs.aws.amazon.com/cdk/api/v1/java/index.html?software/amazon/awscdk/services/apigateway/LambdaRestApi.html), the `root` property access on `LambdaRestApi` is only accessible via getter in generated code but example uses normal property access, IE `api.root`.
### Expected Behavior
This property access should be rendered via a getter function, `api.getRoot()`.
### Current Behavior
Property access is rendered via standard public property access: `api.root`;
### Reproduction Steps
```sh
cdk init --language=java
```
Stack code:
```java
package com.myorg;
import software.constructs.Construct;
import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;
import software.amazon.awscdk.services.apigateway.*;
import software.amazon.awscdk.services.lambda.*;
import software.amazon.awscdk.services.lambda.Runtime;
public class SimV478159965Stack extends Stack {
public SimV478159965Stack(final Construct scope, final String id) {
this(scope, id, null);
}
public SimV478159965Stack(final Construct scope, final String id, final StackProps props) {
super(scope, id, props);
Function backend = Function.Builder.create(this, "myfunction")
.code(Code.fromInline(""))
.handler("index.main")
.runtime(Runtime.NODEJS_16_X)
.build();
LambdaRestApi api = LambdaRestApi.Builder.create(this, "myapi")
.handler(backend)
.proxy(false)
.build();
// Next line breaks compilation
Resource items = api.root.addResource("items");
// The code that defines your stack goes here
// example resource
// final Queue queue = Queue.Builder.create(this, "SimV478159965Queue")
// .visibilityTimeout(Duration.seconds(300))
// .build();
}
}
```
Fails compilation
### Possible Solution
_No response_
### Additional Information/Context
Looks like some context is not setting `convertPropertyToGetter` in this case within the java renderer in jsii-rosetta. Not sure what the exact conditions here are.
### SDK version used
N/A
### Environment details (OS name and version, etc.)
MacOS
Contributor guide
Research direction
Reproduce the issue with `cdk init --language=java` and the provided `LambdaRestApi` example. Start in the jsii-rosetta Java renderer, focusing on where `convertPropertyToGetter` is set; done means the generated access is `api.getRoot()` and the example compiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, typescript
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100