eclipse-xtext / eclipse-xtext/xtext
xtend: .java output should not contain org.eclipse.xtend.lib.annotations.Data annotation
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 831
- Forks
- 330
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 12
Description
With Xtend 2.40 from https://github.com/openhab/openhab-core/blob/main/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericThingProvider.xtend is generated GenericThingProvider.java.
As can be seen the input has an org.eclipse.xtend.lib.annotations.Data annotation on an inner class. This annotation impacts how the generated code should look like: all members are final, for each field a getter generated, and toString() and hashCode() for the instance are also generated. Indeed, the generated code with the Data annotation looks as it should be!
However I think the generated .java file itself should not include the Data annotation, that is neither annotate the generated class (inner - QueueContent ) with it, nor import the annotation. The difference is that the annotation is not needed at runtime, so it should not be included in the bytecode.
Besides, the generated code contains:
public QueueContent(final ThingTypeUID thingTypeUID, final String label, final Configuration configuration,
final ThingUID thingUID, final ThingUID bridgeUID, final ThingHandlerFactory thingHandlerFactory) {
super();
From The Java Tutorials > Using the Keyword super:
If a constructor does not explicitly invoke a superclass constructor, the Java compiler automatically inserts a call to the no-argument constructor of the superclass.
So super() here does not harm, but it can safety be skipped, when generating .java files.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked GenericThingProvider.xtend input and compare its generated GenericThingProvider.java output. Check how the inner QueueContent class and constructor are emitted, then verify that the generated Java has no Data annotation or import and does not include the redundant super() call.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100