[
https://issues.apache.org/jira/browse/GROOVY-6396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16013948#comment-16013948
]
Paul King commented on GROOVY-6396:
-----------------------------------
This was debated back and forth over several years before we made the current
call. Our reasoning is as follows.
We basically decided that users using {{[]}} should to some degree not care
whether it is a LinkedList or an ArrayList, it's just a list and the exact kind
is an implementation detail that we might decide to change in the future.
If we did change it to be a LinkedList, we would want to follow Java's
behavior. Our users expected other Lists to behave in the same way.
So the discrepancy with Java was deemed a bug. We allow breaking changes which
fix bugs in minor releases but decided it wasn't appropriate in a point release.
The issue is marked as breaking. Users using only stack operations, e.g. push,
pop won't be affected. It's just when you mix the stack and list behaviors that
the issue arises.
We don't like any breaking changes but the difference with Java was deemed to
be unacceptable too.
> same linkedlist code different behavior between groovy and java
> ---------------------------------------------------------------
>
> Key: GROOVY-6396
> URL: https://issues.apache.org/jira/browse/GROOVY-6396
> Project: Groovy
> Issue Type: Bug
> Components: jdk conflict
> Reporter: boshi
> Assignee: Paul King
> Labels: breaking
> Fix For: 2.5.0-alpha-1
>
>
> I am using `linkedlist` as a stack in groovy
> as doc says, `pop()` take elm from the first
> Stack Method Equivalent Deque Method
> push(e) addFirst(e)
> pop() removeFirst()
> so a `linkedlist` [1,2,3] should pop() 1 2 3
> and it does in Java, but does NOT in groovy. WHY?
> test below
> {code:title=A.java}
> import java.util.*;
>
> public class A{
>
>
> public static void main(String[] args){
>
> String[] x = "1/2/3/".split("/");
> LinkedList <String> stack = new LinkedList<String>(Arrays.asList(x));
> System.out.println(stack.pop());
> }
> }
> {code}
> compile and run
> {noformat}
> $ javac A.java
> $ java A
> 1
> {noformat}
> runing in groovy
> {noformat}
> $ ln -s A.java A.groovy
> $ groovy A.groovy
> 3
> {noformat}
> here is my java and groovy version
> {noformat}
> $ java -version
> java version "1.6.0_51"
> Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
> Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)
> $ groovy -version
> Groovy Version: 2.1.5 JVM: 1.6.0_51 Vendor: Apple Inc. OS: Mac OS X
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)