[jira] [Updated] (GROOVY-8939) Additional Methods in StringGroovyMethods

2018-12-25 Thread Paul King (JIRA)


 [ 
https://issues.apache.org/jira/browse/GROOVY-8939?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King updated GROOVY-8939:
--
Description: 
Additional methods can be added in StringGroovyMethods for better API Usage.
{code}
CharSequence takeRight(CharSequence self, int num)
String takeRight(String self, int num)
String takeRight(GString self, int num)
CharSequence takeAfter(CharSequence self, CharSequence searchString)
String takeAfter(String self, CharSequence searchString)
String takeAfter(GString self, CharSequence searchString)
CharSequence takeBefore(CharSequence self, CharSequence searchString)
String takeBefore(GString self, String searchString)
String takeBefore(String self, String searchString)
CharSequence dropRight(CharSequence self, int num)
String dropRight(String self, int num)
String dropRight(GString self, int num)
CharSequence takeBetween(CharSequence self, CharSequence from, CharSequence to)
String takeBetween(String self, CharSequence from, CharSequence to)
String takeBetween(GString self, CharSequence from, CharSequence to)
CharSequence takeBetween(CharSequence self, CharSequence enclosure)
String takeBetween(String self, CharSequence enclosure)
String takeBetween(GString self, CharSequence enclosure)
CharSequence takeBetween(CharSequence self, CharSequence from, CharSequence to, 
int occurrence)
String takeBetween(String self, CharSequence from, CharSequence to, int 
occurrence)
String takeBetween(GString self, CharSequence from, CharSequence to, int 
occurrence)
CharSequence takeBetween(CharSequence self, CharSequence enclosure, int 
occurrence)
String takeBetween(String self, CharSequence enclosure, int occurrence)
String takeBetween(GString self, CharSequence enclosure, int occurrence)
boolean startsWithIgnoreCase(CharSequence self, CharSequence searchString)
boolean endsWithIgnoreCase(CharSequence self, CharSequence searchString)
boolean containsIgnoreCase(CharSequence self, CharSequence searchString)
{code}
 

  was:
Additional methods can be added in StringGroovyMethods for better API Usage.

{{CharSequence takeRight(CharSequence self, int num) }}
{{String takeRight(String self, int num) }}
{{String takeRight(GString self, int num) }}
{{CharSequence takeAfter(CharSequence self, CharSequence searchString) }}
{{String takeAfter(String self, CharSequence searchString) }}
{{String takeAfter(GString self, CharSequence searchString) }}
{{CharSequence takeBefore(CharSequence self, CharSequence searchString) }}
{{String takeBefore(GString self, String searchString) }}
{{String takeBefore(String self, String searchString) }}
{{CharSequence dropRight(CharSequence self, int num) }}
{{String dropRight(String self, int num) }}
{{String dropRight(GString self, int num) }}
{{CharSequence takeBetween(CharSequence self, CharSequence from, CharSequence 
to) }}
{{String takeBetween(String self, CharSequence from, CharSequence to) }}
{{String takeBetween(GString self, CharSequence from, CharSequence to) }}
{{CharSequence takeBetween(CharSequence self, CharSequence enclosure) }}
{{String takeBetween(String self, CharSequence enclosure) }}
{{String takeBetween(GString self, CharSequence enclosure) }}
{{CharSequence takeBetween(CharSequence self, CharSequence from, CharSequence 
to, int occurrence) }}
{{String takeBetween(String self, CharSequence from, CharSequence to, int 
occurrence) }}
{{String takeBetween(GString self, CharSequence from, CharSequence to, int 
occurrence) }}
{{CharSequence takeBetween(CharSequence self, CharSequence enclosure, int 
occurrence) }}
{{String takeBetween(String self, CharSequence enclosure, int occurrence) }}
{{String takeBetween(GString self, CharSequence enclosure, int occurrence) }}
{{boolean startsWithIgnoreCase(CharSequence self, CharSequence searchString) }}
{{boolean endsWithIgnoreCase(CharSequence self, CharSequence searchString) }}
{{boolean containsIgnoreCase(CharSequence self, CharSequence searchString)}}

 

 

 


> Additional Methods in StringGroovyMethods
> -
>
> Key: GROOVY-8939
> URL: https://issues.apache.org/jira/browse/GROOVY-8939
> Project: Groovy
>  Issue Type: Improvement
>Affects Versions: 3.0.0-alpha-4
>Reporter: Adithyan K
>Priority: Minor
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> Additional methods can be added in StringGroovyMethods for better API Usage.
> {code}
> CharSequence takeRight(CharSequence self, int num)
> String takeRight(String self, int num)
> String takeRight(GString self, int num)
> CharSequence takeAfter(CharSequence self, CharSequence searchString)
> String takeAfter(String self, CharSequence searchString)
> String takeAfter(GString self, CharSequence searchString)
> CharSequence takeBefore(CharSequence self, CharSequence searchString)
> String takeBefore(GString self, String searchString)
> String takeBefore(String self, 

[jira] [Commented] (GROOVY-8939) Additional Methods in StringGroovyMethods

2018-12-25 Thread Adithyan K (JIRA)


[ 
https://issues.apache.org/jira/browse/GROOVY-8939?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16728841#comment-16728841
 ] 

Adithyan K commented on GROOVY-8939:


PR created https://github.com/apache/groovy/pull/846

> Additional Methods in StringGroovyMethods
> -
>
> Key: GROOVY-8939
> URL: https://issues.apache.org/jira/browse/GROOVY-8939
> Project: Groovy
>  Issue Type: Improvement
>Affects Versions: 3.0.0-alpha-4
>Reporter: Adithyan K
>Priority: Minor
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> Additional methods can be added in StringGroovyMethods for better API Usage.
> {{CharSequence takeRight(CharSequence self, int num) }}
> {{String takeRight(String self, int num) }}
> {{String takeRight(GString self, int num) }}
> {{CharSequence takeAfter(CharSequence self, CharSequence searchString) }}
> {{String takeAfter(String self, CharSequence searchString) }}
> {{String takeAfter(GString self, CharSequence searchString) }}
> {{CharSequence takeBefore(CharSequence self, CharSequence searchString) }}
> {{String takeBefore(GString self, String searchString) }}
> {{String takeBefore(String self, String searchString) }}
> {{CharSequence dropRight(CharSequence self, int num) }}
> {{String dropRight(String self, int num) }}
> {{String dropRight(GString self, int num) }}
> {{CharSequence takeBetween(CharSequence self, CharSequence from, CharSequence 
> to) }}
> {{String takeBetween(String self, CharSequence from, CharSequence to) }}
> {{String takeBetween(GString self, CharSequence from, CharSequence to) }}
> {{CharSequence takeBetween(CharSequence self, CharSequence enclosure) }}
> {{String takeBetween(String self, CharSequence enclosure) }}
> {{String takeBetween(GString self, CharSequence enclosure) }}
> {{CharSequence takeBetween(CharSequence self, CharSequence from, CharSequence 
> to, int occurrence) }}
> {{String takeBetween(String self, CharSequence from, CharSequence to, int 
> occurrence) }}
> {{String takeBetween(GString self, CharSequence from, CharSequence to, int 
> occurrence) }}
> {{CharSequence takeBetween(CharSequence self, CharSequence enclosure, int 
> occurrence) }}
> {{String takeBetween(String self, CharSequence enclosure, int occurrence) }}
> {{String takeBetween(GString self, CharSequence enclosure, int occurrence) }}
> {{boolean startsWithIgnoreCase(CharSequence self, CharSequence searchString) 
> }}
> {{boolean endsWithIgnoreCase(CharSequence self, CharSequence searchString) }}
> {{boolean containsIgnoreCase(CharSequence self, CharSequence searchString)}}
>  
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] adithyank opened a new pull request #846: GROOVY-8939: Add methods in StringGroovyMethods for better API Usage

2018-12-25 Thread GitBox
adithyank opened a new pull request #846: GROOVY-8939: Add methods in 
StringGroovyMethods for better API Usage
URL: https://github.com/apache/groovy/pull/846
 
 
   Interm PR reviewed https://github.com/adithyank/groovy/pull/1


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Commented] (GROOVY-8939) Additional Methods in StringGroovyMethods

2018-12-25 Thread Adithyan K (JIRA)


[ 
https://issues.apache.org/jira/browse/GROOVY-8939?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16728839#comment-16728839
 ] 

Adithyan K commented on GROOVY-8939:


Interim PR got reviewed [https://github.com/adithyank/groovy/pull/1] and 
changes incorporated

 

> Additional Methods in StringGroovyMethods
> -
>
> Key: GROOVY-8939
> URL: https://issues.apache.org/jira/browse/GROOVY-8939
> Project: Groovy
>  Issue Type: Improvement
>Affects Versions: 3.0.0-alpha-4
>Reporter: Adithyan K
>Priority: Minor
>
> Additional methods can be added in StringGroovyMethods for better API Usage.
> {{CharSequence takeRight(CharSequence self, int num) }}
> {{String takeRight(String self, int num) }}
> {{String takeRight(GString self, int num) }}
> {{CharSequence takeAfter(CharSequence self, CharSequence searchString) }}
> {{String takeAfter(String self, CharSequence searchString) }}
> {{String takeAfter(GString self, CharSequence searchString) }}
> {{CharSequence takeBefore(CharSequence self, CharSequence searchString) }}
> {{String takeBefore(GString self, String searchString) }}
> {{String takeBefore(String self, String searchString) }}
> {{CharSequence dropRight(CharSequence self, int num) }}
> {{String dropRight(String self, int num) }}
> {{String dropRight(GString self, int num) }}
> {{CharSequence takeBetween(CharSequence self, CharSequence from, CharSequence 
> to) }}
> {{String takeBetween(String self, CharSequence from, CharSequence to) }}
> {{String takeBetween(GString self, CharSequence from, CharSequence to) }}
> {{CharSequence takeBetween(CharSequence self, CharSequence enclosure) }}
> {{String takeBetween(String self, CharSequence enclosure) }}
> {{String takeBetween(GString self, CharSequence enclosure) }}
> {{CharSequence takeBetween(CharSequence self, CharSequence from, CharSequence 
> to, int occurrence) }}
> {{String takeBetween(String self, CharSequence from, CharSequence to, int 
> occurrence) }}
> {{String takeBetween(GString self, CharSequence from, CharSequence to, int 
> occurrence) }}
> {{CharSequence takeBetween(CharSequence self, CharSequence enclosure, int 
> occurrence) }}
> {{String takeBetween(String self, CharSequence enclosure, int occurrence) }}
> {{String takeBetween(GString self, CharSequence enclosure, int occurrence) }}
> {{boolean startsWithIgnoreCase(CharSequence self, CharSequence searchString) 
> }}
> {{boolean endsWithIgnoreCase(CharSequence self, CharSequence searchString) }}
> {{boolean containsIgnoreCase(CharSequence self, CharSequence searchString)}}
>  
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8939) Additional Methods in StringGroovyMethods

2018-12-25 Thread Adithyan K (JIRA)
Adithyan K created GROOVY-8939:
--

 Summary: Additional Methods in StringGroovyMethods
 Key: GROOVY-8939
 URL: https://issues.apache.org/jira/browse/GROOVY-8939
 Project: Groovy
  Issue Type: Improvement
Affects Versions: 3.0.0-alpha-4
Reporter: Adithyan K


Additional methods can be added in StringGroovyMethods for better API Usage.

{{CharSequence takeRight(CharSequence self, int num) }}
{{String takeRight(String self, int num) }}
{{String takeRight(GString self, int num) }}
{{CharSequence takeAfter(CharSequence self, CharSequence searchString) }}
{{String takeAfter(String self, CharSequence searchString) }}
{{String takeAfter(GString self, CharSequence searchString) }}
{{CharSequence takeBefore(CharSequence self, CharSequence searchString) }}
{{String takeBefore(GString self, String searchString) }}
{{String takeBefore(String self, String searchString) }}
{{CharSequence dropRight(CharSequence self, int num) }}
{{String dropRight(String self, int num) }}
{{String dropRight(GString self, int num) }}
{{CharSequence takeBetween(CharSequence self, CharSequence from, CharSequence 
to) }}
{{String takeBetween(String self, CharSequence from, CharSequence to) }}
{{String takeBetween(GString self, CharSequence from, CharSequence to) }}
{{CharSequence takeBetween(CharSequence self, CharSequence enclosure) }}
{{String takeBetween(String self, CharSequence enclosure) }}
{{String takeBetween(GString self, CharSequence enclosure) }}
{{CharSequence takeBetween(CharSequence self, CharSequence from, CharSequence 
to, int occurrence) }}
{{String takeBetween(String self, CharSequence from, CharSequence to, int 
occurrence) }}
{{String takeBetween(GString self, CharSequence from, CharSequence to, int 
occurrence) }}
{{CharSequence takeBetween(CharSequence self, CharSequence enclosure, int 
occurrence) }}
{{String takeBetween(String self, CharSequence enclosure, int occurrence) }}
{{String takeBetween(GString self, CharSequence enclosure, int occurrence) }}
{{boolean startsWithIgnoreCase(CharSequence self, CharSequence searchString) }}
{{boolean endsWithIgnoreCase(CharSequence self, CharSequence searchString) }}
{{boolean containsIgnoreCase(CharSequence self, CharSequence searchString)}}

 

 

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-8938) Final field caching issues in inherited field.

2018-12-25 Thread Anton Pryamostanov (JIRA)


[ 
https://issues.apache.org/jira/browse/GROOVY-8938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16728794#comment-16728794
 ] 

Anton Pryamostanov commented on GROOVY-8938:


Many thanks for the feedback, guys!
The issue can be closed, there are no immediate actions required.

Once there is time to look on any refactoring (if needed), this can be looked 
again onto.

> Final field caching issues in inherited field.
> --
>
> Key: GROOVY-8938
> URL: https://issues.apache.org/jira/browse/GROOVY-8938
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.5.4
>Reporter: Anton Pryamostanov
>Priority: Critical
>
> Note: **this seems to be a quite major issue**, kindly look at this one with 
> emphasis.
> Please see the below test case:
> SubClass extends the SuperClass and overrides the field "inheritedField".
> {code}
> class OtherClass {
> String otherField
> OtherClass(String otherField) {
> this.otherField = otherField
> }
> String toString() {
> return otherField
> }
> }
> class SuperClass {
> final OtherClass inheritedField = new OtherClass("Super Class String")
> }
> class SubClass extends SuperClass {
> final OtherClass inheritedField = new OtherClass("Sub Class String")
> }
> SuperClass superClass = new SuperClass()
> SubClass subClass = new SubClass()
> assert subClass.inheritedField.toString() == "Sub Class String"
> {code}
> *Actual result*: assertion fails
> *Expected result*: assertion should pass
> *Note*: If "final" modifier is removed, assertion passes as expected.
> This seems an issue with final field caching.
> Assertion error text:
> {code}
> Assertion failed: 
> assert subClass.inheritedField.toString() == "Sub Class String"
>||  |  |
>||  |  false
>||  'Super Class String'
>|Super Class String
>SubClass@5b4b841f
>   at ConsoleScript11.run(ConsoleScript11:18)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-8938) Final field caching issues in inherited field.

2018-12-25 Thread Anton Pryamostanov (JIRA)


[ 
https://issues.apache.org/jira/browse/GROOVY-8938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16728781#comment-16728781
 ] 

Anton Pryamostanov commented on GROOVY-8938:


Hi [~paulk], [~blackdrag], I sent you private message to Slack (in Groovy 
space).
Can you check? Or please suggest non-public way to discuss on this issue (I 
have some considerations that will become clear).

> Final field caching issues in inherited field.
> --
>
> Key: GROOVY-8938
> URL: https://issues.apache.org/jira/browse/GROOVY-8938
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.5.4
>Reporter: Anton Pryamostanov
>Priority: Critical
>
> Note: **this seems to be a quite major issue**, kindly look at this one with 
> emphasis.
> Please see the below test case:
> SubClass extends the SuperClass and overrides the field "inheritedField".
> {code}
> class OtherClass {
> String otherField
> OtherClass(String otherField) {
> this.otherField = otherField
> }
> String toString() {
> return otherField
> }
> }
> class SuperClass {
> final OtherClass inheritedField = new OtherClass("Super Class String")
> }
> class SubClass extends SuperClass {
> final OtherClass inheritedField = new OtherClass("Sub Class String")
> }
> SuperClass superClass = new SuperClass()
> SubClass subClass = new SubClass()
> assert subClass.inheritedField.toString() == "Sub Class String"
> {code}
> *Actual result*: assertion fails
> *Expected result*: assertion should pass
> *Note*: If "final" modifier is removed, assertion passes as expected.
> This seems an issue with final field caching.
> Assertion error text:
> {code}
> Assertion failed: 
> assert subClass.inheritedField.toString() == "Sub Class String"
>||  |  |
>||  |  false
>||  'Super Class String'
>|Super Class String
>SubClass@5b4b841f
>   at ConsoleScript11.run(ConsoleScript11:18)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Closed] (GROOVY-8834) Making "public" - BinaryExpression.leftExpression and similar fields

2018-12-25 Thread Paul King (JIRA)


 [ 
https://issues.apache.org/jira/browse/GROOVY-8834?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King closed GROOVY-8834.
-
Resolution: Not A Problem

As per last comment. I'll close this and we can re-open if we have specific 
improvement suggestions to consider.

> Making "public" - BinaryExpression.leftExpression and similar fields
> 
>
> Key: GROOVY-8834
> URL: https://issues.apache.org/jira/browse/GROOVY-8834
> Project: Groovy
>  Issue Type: Wish
>Reporter: Anton Pryamostanov
>Priority: Major
>  Labels: ast
>
> This is a general request related to AST API.
>  
> Currently BinaryExpression.leftExpression and similar fields are having 
> Private access.
> So to change the value, we need to replace the whole BinaryExpression with 
> new one.
> This is not useful as it requires coding outside of Visitor methods, and I do 
> not see reason why it should be private. It will greatly simplify visitor 
> methods and transformations, if all Expression fields will have Public access.
> Alternatively please add setter methods with Public access.
> List of fields to be changed from Private to Public:
> {code:java}
> ArrayExpression->expressions
> ArrayExpression->sizeExpression
> BitwiseNegationExpression->expression
> BooleanExpression->expression
> CastExpression->expression
> ConstructorCallExpression->arguments
> GStringExpression->strings
> GStringExpression->values
> ListExpression->expressions
> MapExpression->mapEntryExpressions
> MethodPointerExpression->expression
> MethodPointerExpression->methodName
> PropertyExpression->property
> RangeExpression->from
> RangeExpression->to
> SpreadExpression->expression
> SpreadMapExpression->expression
> StaticMethodCallExpression->arguments
> TernaryExpression->booleanExpression
> TernaryExpression->trueExpression
> TernaryExpression->falseExpression
> TupleExpression->expressions
> UnaryMinusExpression->expression
> UnaryPlusExpression->expression{code}
> Note: those fields with "final" modifier should also be made re-assignable.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-8938) Final field caching issues in inherited field.

2018-12-25 Thread Paul King (JIRA)


[ 
https://issues.apache.org/jira/browse/GROOVY-8938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16728687#comment-16728687
 ] 

Paul King commented on GROOVY-8938:
---

As Jochen mentions, the current behavior is mainly for historical reasons. If 
you add a modifier like 'synchronized' to the property, it probably makes sense 
to also add it to the getter but it's less clear for something like final. 
Similarly, there was lots of debate historically around annotations. An 
annotation on a property might make sense to be copied over to the field or 
just the getter or setter or to all places. The current approach has been to 
use a simple copying strategy for all modifiers and annotations. Even though it 
was never seen as ideal we hadn't defined a better approach to date.

> Final field caching issues in inherited field.
> --
>
> Key: GROOVY-8938
> URL: https://issues.apache.org/jira/browse/GROOVY-8938
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.5.4
>Reporter: Anton Pryamostanov
>Priority: Critical
>
> Note: **this seems to be a quite major issue**, kindly look at this one with 
> emphasis.
> Please see the below test case:
> SubClass extends the SuperClass and overrides the field "inheritedField".
> {code}
> class OtherClass {
> String otherField
> OtherClass(String otherField) {
> this.otherField = otherField
> }
> String toString() {
> return otherField
> }
> }
> class SuperClass {
> final OtherClass inheritedField = new OtherClass("Super Class String")
> }
> class SubClass extends SuperClass {
> final OtherClass inheritedField = new OtherClass("Sub Class String")
> }
> SuperClass superClass = new SuperClass()
> SubClass subClass = new SubClass()
> assert subClass.inheritedField.toString() == "Sub Class String"
> {code}
> *Actual result*: assertion fails
> *Expected result*: assertion should pass
> *Note*: If "final" modifier is removed, assertion passes as expected.
> This seems an issue with final field caching.
> Assertion error text:
> {code}
> Assertion failed: 
> assert subClass.inheritedField.toString() == "Sub Class String"
>||  |  |
>||  |  false
>||  'Super Class String'
>|Super Class String
>SubClass@5b4b841f
>   at ConsoleScript11.run(ConsoleScript11:18)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Comment Edited] (GROOVY-8938) Final field caching issues in inherited field.

2018-12-25 Thread Paul King (JIRA)


[ 
https://issues.apache.org/jira/browse/GROOVY-8938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16728687#comment-16728687
 ] 

Paul King edited comment on GROOVY-8938 at 12/25/18 12:02 PM:
--

As Jochen mentions, the current behavior is mainly for historical reasons. If 
you add a modifier like 'synchronized' to the property, it probably makes sense 
to also add it to the getter but it's less clear for something like final. 
Similarly, there was lots of debate historically around annotations. An 
annotation on a property might make sense to be copied over to the field or 
just the getter or setter or to all places. The current approach has been to 
use a simple copying strategy for all modifiers and annotations. Even though it 
was never seen as ideal we hadn't defined a better approach to date. Wrt 
@Immutable though, I think it might not be affected but we'd need to check all 
possible scenarios.


was (Author: paulk):
As Jochen mentions, the current behavior is mainly for historical reasons. If 
you add a modifier like 'synchronized' to the property, it probably makes sense 
to also add it to the getter but it's less clear for something like final. 
Similarly, there was lots of debate historically around annotations. An 
annotation on a property might make sense to be copied over to the field or 
just the getter or setter or to all places. The current approach has been to 
use a simple copying strategy for all modifiers and annotations. Even though it 
was never seen as ideal we hadn't defined a better approach to date.

> Final field caching issues in inherited field.
> --
>
> Key: GROOVY-8938
> URL: https://issues.apache.org/jira/browse/GROOVY-8938
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.5.4
>Reporter: Anton Pryamostanov
>Priority: Critical
>
> Note: **this seems to be a quite major issue**, kindly look at this one with 
> emphasis.
> Please see the below test case:
> SubClass extends the SuperClass and overrides the field "inheritedField".
> {code}
> class OtherClass {
> String otherField
> OtherClass(String otherField) {
> this.otherField = otherField
> }
> String toString() {
> return otherField
> }
> }
> class SuperClass {
> final OtherClass inheritedField = new OtherClass("Super Class String")
> }
> class SubClass extends SuperClass {
> final OtherClass inheritedField = new OtherClass("Sub Class String")
> }
> SuperClass superClass = new SuperClass()
> SubClass subClass = new SubClass()
> assert subClass.inheritedField.toString() == "Sub Class String"
> {code}
> *Actual result*: assertion fails
> *Expected result*: assertion should pass
> *Note*: If "final" modifier is removed, assertion passes as expected.
> This seems an issue with final field caching.
> Assertion error text:
> {code}
> Assertion failed: 
> assert subClass.inheritedField.toString() == "Sub Class String"
>||  |  |
>||  |  false
>||  'Super Class String'
>|Super Class String
>SubClass@5b4b841f
>   at ConsoleScript11.run(ConsoleScript11:18)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-8938) Final field caching issues in inherited field.

2018-12-25 Thread Jochen Theodorou (JIRA)


[ 
https://issues.apache.org/jira/browse/GROOVY-8938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16728676#comment-16728676
 ] 

Jochen Theodorou commented on GROOVY-8938:
--

[~anton.pryamostanov] why is it "final", because we once said all modifiers 
that on the "property" should be applied to the getter/setter if possible. But 
it is indeed a question of it that should be done for final. Following the 
logic of a field I would say the getter should not be final. But I think that 
will start breaking things in other cases like @Immutable? If we keep the final 
on the method we should fail compilation in your example though... but then how 
would you work around it? By declaring it as field. If you declare it as field, 
then what will
assert subClass.inheritedField.toString() == "Sub Class String"
give you? Afair you would still access the super class and get still a failing 
assert. And of course you could do,
assert subClass.@inheritedField.toString() == "Sub Class String"
but that would work already. 

 

Coming back to your suggestion it looks like a good idea, but it will make 
declaring immutables much more difficult. So before we do a change here I would 
suggest to first ensure the story for these is sound.

 

> Final field caching issues in inherited field.
> --
>
> Key: GROOVY-8938
> URL: https://issues.apache.org/jira/browse/GROOVY-8938
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.5.4
>Reporter: Anton Pryamostanov
>Priority: Critical
>
> Note: **this seems to be a quite major issue**, kindly look at this one with 
> emphasis.
> Please see the below test case:
> SubClass extends the SuperClass and overrides the field "inheritedField".
> {code}
> class OtherClass {
> String otherField
> OtherClass(String otherField) {
> this.otherField = otherField
> }
> String toString() {
> return otherField
> }
> }
> class SuperClass {
> final OtherClass inheritedField = new OtherClass("Super Class String")
> }
> class SubClass extends SuperClass {
> final OtherClass inheritedField = new OtherClass("Sub Class String")
> }
> SuperClass superClass = new SuperClass()
> SubClass subClass = new SubClass()
> assert subClass.inheritedField.toString() == "Sub Class String"
> {code}
> *Actual result*: assertion fails
> *Expected result*: assertion should pass
> *Note*: If "final" modifier is removed, assertion passes as expected.
> This seems an issue with final field caching.
> Assertion error text:
> {code}
> Assertion failed: 
> assert subClass.inheritedField.toString() == "Sub Class String"
>||  |  |
>||  |  false
>||  'Super Class String'
>|Super Class String
>SubClass@5b4b841f
>   at ConsoleScript11.run(ConsoleScript11:18)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)