[
https://issues.jboss.org/browse/JBIDE-22283?page=com.atlassian.jira.plugi...
]
Darryl Miles edited comment on JBIDE-22283 at 7/20/16 4:04 PM:
---------------------------------------------------------------
No the issue is that the "property" name needs to be "return" this is
indeed a valid name.
But the local variable name needs to be called something else (but this is autogenerated
and no mechanism exists to configure it).
The property accessors code would look like:
public void setReturn(Return return_) {
this.autoGeneratedVariableCouldNotCareLessWhatItIsCalled = return_;
}
public Return getReturn() {
return autoGeneratedVariableCouldNotCareLessWhatItIsCalled;
}
Note the problem is not that the property should be renamed to "return_" but
that the unimportant auto-generated local variables get an invalid name. Since it is
valid for a method signature getReturn() and setReturn(Return) and valid for an Object
type to be called "Return".
Does this explain better the problem is not one that can be configured around.
Acceptable fixes would be:
* Allow the local variable name to be configured, independently of the property name.
OR
* Simply apply heuristics if the resulting auto-generated variable names turn out to be
valid java keywords or reserved words. Note you need a process to apply a modification to
the variable name and retest it. You also need to keep a Set<String> of all the
currently allocated local variable names and as one of the tests, check you did not
already use that reserved name as a local variable for some other things. You should
iterate the heuristics.
return // would fail
return_ // would be ok (if iteration is 0)
return_1 // would be ok (if iteration is 1)
return_2 // would be ok (if iteration is 2)
// keep iterating to find a suitable name for maybe 100 times, then give up with error.
etc... the above is an idea of how you would keep trying to generate a local variable name
that could be used that matches all the criteria.
was (Author: dlmiles):
No the issue is that the "property" name needs to be "return" this is
indeed a valid name.
But the local variable name needs to be called something else (but this is autogenerated
and no mechanism exists to configure it).
The property accessors code would look like:
public void setReturn(Return return_) {
this.autoGeneratedVariableCouldNotCareLessWhatItIsCalled = return_;
}
public Return getReturn() {
return autoGeneratedVariableCouldNotCareLessWhatItIsCalled;
}
Note the problem is not that the property should be renamed to "return_" but
that the unimportant auto-generated local variables get an invalid name. Since it is
valid for a method signature getReturn() and setReturn(Return) and valid for an Object
type to be called "Return".
Does this explain better the problem is not one that can be configured around.
Acceptable fixes would be:
* Allow the local variable name to be configured, independently of the property name.
OR
* Simply apply heuristics if the resulting auto-generated variable names turn out to be
valid java keywords or reserved words. Note you need a process to apply a modification to
the variable name and retest it. You also need to keep a Set<String> of all the
currently allocated local variable names and as one of the tests, check you did not
already use that reserved name as a local variable for some other things. You should
iterate the heuristics.
return // would fail
return_ // would be ok (if iteration is 0)
return_1 // would be ok (if iteration is 1)
return_2 // would be ok (if iteration is 2)
// keep iterating to find a suitable name for maybe 100 times, then give up with error.
etc... the above is an idea of how you would keep trying to generate a local variable name
that could be used that matches all the criteria.
reveng *.java emitter does not escape java keyword 'return'
as variable name
----------------------------------------------------------------------------
Key: JBIDE-22283
URL:
https://issues.jboss.org/browse/JBIDE-22283
Project: Tools (JBoss Tools)
Issue Type: Bug
Components: hibernate
Affects Versions: 4.3.x
Environment: Eclipse Mars
Reporter: Darryl Miles
Assignee: Koen Aers
Fix For: 4.4.1.AM2
reveng *.java emitter does not escape java keyword 'return' as variable name
<table name="oc_return_history">
<foreign-key constraint-name="FK_oc_return_history__return_id"
foreign-table="oc_return">
<column-ref local-column="return_id"
foreign-column="return_id"/>
<!-- this breaks the generator trying to name local variable as a java keyword
-->
<many-to-one property="return"/>
</foreign-key>
</table>
The expected output would be:
private Return _return;
but actual output is:
private Return return;
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)