{"action":"created","issue":{"url":"https://api.github.com/repos/javaslang/javaslang/issues/824","labels_url":"https://api.github.com/repos/javaslang/javaslang/issues/824/labels{/name}","comments_url":"https://api.github.com/repos/javaslang/javaslang/issues/824/comments","events_url":"https://api.github.com/repos/javaslang/javaslang/issues/824/events","html_url":"https://github.com/javaslang/javaslang/issues/824","id":117543736,"number":824,"title":"Stream.append produces StackOverFlow","user":{"login":"danieldietrich","id":743833,"avatar_url":"https://avatars.githubusercontent.com/u/743833?v=3","gravatar_id":"","url":"https://api.github.com/users/danieldietrich","html_url":"https://github.com/danieldietrich","followers_url":"https://api.github.com/users/danieldietrich/followers","following_url":"https://api.github.com/users/danieldietrich/following{/other_user}","gists_url":"https://api.github.com/users/danieldietrich/gists{/gist_id}","starred_url":"https://api.github.com/users/danieldietrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danieldietrich/subscriptions","organizations_url":"https://api.github.com/users/danieldietrich/orgs","repos_url":"https://api.github.com/users/danieldietrich/repos","events_url":"https://api.github.com/users/danieldietrich/events{/privacy}","received_events_url":"https://api.github.com/users/danieldietrich/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/javaslang/javaslang/labels/bug","name":"bug","color":"e11829"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/javaslang/javaslang/milestones/18","html_url":"https://github.com/javaslang/javaslang/milestones/2.0.0","labels_url":"https://api.github.com/repos/javaslang/javaslang/milestones/18/labels","id":1091674,"number":18,"title":"2.0.0","description":"","creator":{"login":"danieldietrich","id":743833,"avatar_url":"https://avatars.githubusercontent.com/u/743833?v=3","gravatar_id":"","url":"https://api.github.com/users/danieldietrich","html_url":"https://github.com/danieldietrich","followers_url":"https://api.github.com/users/danieldietrich/followers","following_url":"https://api.github.com/users/danieldietrich/following{/other_user}","gists_url":"https://api.github.com/users/danieldietrich/gists{/gist_id}","starred_url":"https://api.github.com/users/danieldietrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danieldietrich/subscriptions","organizations_url":"https://api.github.com/users/danieldietrich/orgs","repos_url":"https://api.github.com/users/danieldietrich/repos","events_url":"https://api.github.com/users/danieldietrich/events{/privacy}","received_events_url":"https://api.github.com/users/danieldietrich/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":201,"state":"open","created_at":"2015-04-30T20:29:59Z","updated_at":"2015-11-21T17:33:08Z","due_on":null,"closed_at":null},"comments":12,"created_at":"2015-11-18T09:12:32Z","updated_at":"2015-11-21T23:19:58Z","closed_at":null,"body":"@netzwerg discovered a StackOverflowError: https://github.com/netzwerg/paleo/commit/e962a43fa435aa54211ad17b8c093f5cc0ec0991"},"comment":{"url":"https://api.github.com/repos/javaslang/javaslang/issues/comments/158690009","html_url":"https://github.com/javaslang/javaslang/issues/824#issuecomment-158690009","issue_url":"https://api.github.com/repos/javaslang/javaslang/issues/824","id":158690009,"user":{"login":"danieldietrich","id":743833,"avatar_url":"https://avatars.githubusercontent.com/u/743833?v=3","gravatar_id":"","url":"https://api.github.com/users/danieldietrich","html_url":"https://github.com/danieldietrich","followers_url":"https://api.github.com/users/danieldietrich/followers","following_url":"https://api.github.com/users/danieldietrich/following{/other_user}","gists_url":"https://api.github.com/users/danieldietrich/gists{/gist_id}","starred_url":"https://api.github.com/users/danieldietrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danieldietrich/subscriptions","organizations_url":"https://api.github.com/users/danieldietrich/orgs","repos_url":"https://api.github.com/users/danieldietrich/repos","events_url":"https://api.github.com/users/danieldietrich/events{/privacy}","received_events_url":"https://api.github.com/users/danieldietrich/received_events","type":"User","site_admin":false},"created_at":"2015-11-21T23:19:58Z","updated_at":"2015-11-21T23:19:58Z","body":"A little test program to see what lambda argument capturing does:\r\n\r\n```java\r\npackage test;\r\n\r\nimport java.util.function.Supplier;\r\n\r\npublic class Stream<T> {\r\n\r\n    final T head;\r\n    Stream<T> tail = null;\r\n    Supplier<Stream<T>> tailSupplier;\r\n\r\n    Stream(T head, Supplier<Stream<T>> tailSupplier) {\r\n        this.head = head;\r\n        this.tailSupplier = tailSupplier;\r\n    }\r\n\r\n    Stream<T> append(T element) {\r\n        final Supplier<Stream<T>> localTailSupplier = tailSupplier0();\r\n        return new Stream<>(head, () -> localTailSupplier.get().append(element));\r\n    }\r\n\r\n    Supplier<Stream<T>> tailSupplier0() {\r\n        return () -> tail;\r\n    }\r\n\r\n    Supplier<Stream<T>> tailSupplier1() {\r\n        final Stream<T> localTail = tail;\r\n        return () -> localTail;\r\n    }\r\n\r\n    Supplier<Stream<T>> tailSupplier2() {\r\n        return tailSupplier;\r\n    }\r\n}\r\n```\r\n\r\nRunning `javap -c -v Stream.class` shows the following:\r\n\r\n```java\r\nClassfile /Users/daniel/git/test/target/classes/test/Stream.class\r\n  Last modified Nov 22, 2015; size 2634 bytes\r\n  MD5 checksum 419fde93d46ddf9a6a5fcd2c2c60208f\r\n  Compiled from \"Stream.java\"\r\npublic class test.Stream<T extends java.lang.Object> extends java.lang.Object\r\n  minor version: 0\r\n  major version: 52\r\n  flags: ACC_PUBLIC, ACC_SUPER\r\nConstant pool:\r\n   #1 = Methodref          #13.#52        // java/lang/Object.\"<init>\":()V\r\n   #2 = Fieldref           #6.#53         // test/Stream.tail:Ltest/Stream;\r\n   #3 = Fieldref           #6.#54         // test/Stream.head:Ljava/lang/Object;\r\n   #4 = Fieldref           #6.#55         // test/Stream.tailSupplier:Ljava/util/function/Supplier;\r\n   #5 = Methodref          #6.#56         // test/Stream.tailSupplier0:()Ljava/util/function/Supplier;\r\n   #6 = Class              #57            // test/Stream\r\n   #7 = InvokeDynamic      #0:#63         // #0:get:(Ljava/util/function/Supplier;Ljava/lang/Object;)Ljava/util/function/Supplier;\r\n   #8 = Methodref          #6.#64         // test/Stream.\"<init>\":(Ljava/lang/Object;Ljava/util/function/Supplier;)V\r\n   #9 = InvokeDynamic      #1:#66         // #1:get:(Ltest/Stream;)Ljava/util/function/Supplier;\r\n  #10 = InvokeDynamic      #2:#66         // #2:get:(Ltest/Stream;)Ljava/util/function/Supplier;\r\n  #11 = InterfaceMethodref #68.#69        // java/util/function/Supplier.get:()Ljava/lang/Object;\r\n  #12 = Methodref          #6.#70         // test/Stream.append:(Ljava/lang/Object;)Ltest/Stream;\r\n  #13 = Class              #71            // java/lang/Object\r\n  #14 = Utf8               head\r\n  #15 = Utf8               Ljava/lang/Object;\r\n  #16 = Utf8               Signature\r\n  #17 = Utf8               TT;\r\n  #18 = Utf8               tail\r\n  #19 = Utf8               Ltest/Stream;\r\n  #20 = Utf8               Ltest/Stream<TT;>;\r\n  #21 = Utf8               tailSupplier\r\n  #22 = Utf8               Ljava/util/function/Supplier;\r\n  #23 = Utf8               Ljava/util/function/Supplier<Ltest/Stream<TT;>;>;\r\n  #24 = Utf8               <init>\r\n  #25 = Utf8               (Ljava/lang/Object;Ljava/util/function/Supplier;)V\r\n  #26 = Utf8               Code\r\n  #27 = Utf8               LineNumberTable\r\n  #28 = Utf8               LocalVariableTable\r\n  #29 = Utf8               this\r\n  #30 = Utf8               LocalVariableTypeTable\r\n  #31 = Utf8               (TT;Ljava/util/function/Supplier<Ltest/Stream<TT;>;>;)V\r\n  #32 = Utf8               append\r\n  #33 = Utf8               (Ljava/lang/Object;)Ltest/Stream;\r\n  #34 = Utf8               element\r\n  #35 = Utf8               localTailSupplier\r\n  #36 = Utf8               (TT;)Ltest/Stream<TT;>;\r\n  #37 = Utf8               tailSupplier0\r\n  #38 = Utf8               ()Ljava/util/function/Supplier;\r\n  #39 = Utf8               ()Ljava/util/function/Supplier<Ltest/Stream<TT;>;>;\r\n  #40 = Utf8               tailSupplier1\r\n  #41 = Utf8               localTail\r\n  #42 = Utf8               tailSupplier2\r\n  #43 = Utf8               lambda$tailSupplier1$2\r\n  #44 = Utf8               (Ltest/Stream;)Ltest/Stream;\r\n  #45 = Utf8               lambda$tailSupplier0$1\r\n  #46 = Utf8               ()Ltest/Stream;\r\n  #47 = Utf8               lambda$append$0\r\n  #48 = Utf8               (Ljava/util/function/Supplier;Ljava/lang/Object;)Ltest/Stream;\r\n  #49 = Utf8               <T:Ljava/lang/Object;>Ljava/lang/Object;\r\n  #50 = Utf8               SourceFile\r\n  #51 = Utf8               Stream.java\r\n  #52 = NameAndType        #24:#72        // \"<init>\":()V\r\n  #53 = NameAndType        #18:#19        // tail:Ltest/Stream;\r\n  #54 = NameAndType        #14:#15        // head:Ljava/lang/Object;\r\n  #55 = NameAndType        #21:#22        // tailSupplier:Ljava/util/function/Supplier;\r\n  #56 = NameAndType        #37:#38        // tailSupplier0:()Ljava/util/function/Supplier;\r\n  #57 = Utf8               test/Stream\r\n  #58 = Utf8               BootstrapMethods\r\n  #59 = MethodHandle       #6:#73         // invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;\r\n  #60 = MethodType         #74            //  ()Ljava/lang/Object;\r\n  #61 = MethodHandle       #6:#75         // invokestatic test/Stream.lambda$append$0:(Ljava/util/function/Supplier;Ljava/lang/Object;)Ltest/Stream;\r\n  #62 = MethodType         #46            //  ()Ltest/Stream;\r\n  #63 = NameAndType        #76:#77        // get:(Ljava/util/function/Supplier;Ljava/lang/Object;)Ljava/util/function/Supplier;\r\n  #64 = NameAndType        #24:#25        // \"<init>\":(Ljava/lang/Object;Ljava/util/function/Supplier;)V\r\n  #65 = MethodHandle       #7:#78         // invokespecial test/Stream.lambda$tailSupplier0$1:()Ltest/Stream;\r\n  #66 = NameAndType        #76:#79        // get:(Ltest/Stream;)Ljava/util/function/Supplier;\r\n  #67 = MethodHandle       #6:#80         // invokestatic test/Stream.lambda$tailSupplier1$2:(Ltest/Stream;)Ltest/Stream;\r\n  #68 = Class              #81            // java/util/function/Supplier\r\n  #69 = NameAndType        #76:#74        // get:()Ljava/lang/Object;\r\n  #70 = NameAndType        #32:#33        // append:(Ljava/lang/Object;)Ltest/Stream;\r\n  #71 = Utf8               java/lang/Object\r\n  #72 = Utf8               ()V\r\n  #73 = Methodref          #82.#83        // java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;\r\n  #74 = Utf8               ()Ljava/lang/Object;\r\n  #75 = Methodref          #6.#84         // test/Stream.lambda$append$0:(Ljava/util/function/Supplier;Ljava/lang/Object;)Ltest/Stream;\r\n  #76 = Utf8               get\r\n  #77 = Utf8               (Ljava/util/function/Supplier;Ljava/lang/Object;)Ljava/util/function/Supplier;\r\n  #78 = Methodref          #6.#85         // test/Stream.lambda$tailSupplier0$1:()Ltest/Stream;\r\n  #79 = Utf8               (Ltest/Stream;)Ljava/util/function/Supplier;\r\n  #80 = Methodref          #6.#86         // test/Stream.lambda$tailSupplier1$2:(Ltest/Stream;)Ltest/Stream;\r\n  #81 = Utf8               java/util/function/Supplier\r\n  #82 = Class              #87            // java/lang/invoke/LambdaMetafactory\r\n  #83 = NameAndType        #88:#92        // metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;\r\n  #84 = NameAndType        #47:#48        // lambda$append$0:(Ljava/util/function/Supplier;Ljava/lang/Object;)Ltest/Stream;\r\n  #85 = NameAndType        #45:#46        // lambda$tailSupplier0$1:()Ltest/Stream;\r\n  #86 = NameAndType        #43:#44        // lambda$tailSupplier1$2:(Ltest/Stream;)Ltest/Stream;\r\n  #87 = Utf8               java/lang/invoke/LambdaMetafactory\r\n  #88 = Utf8               metafactory\r\n  #89 = Class              #94            // java/lang/invoke/MethodHandles$Lookup\r\n  #90 = Utf8               Lookup\r\n  #91 = Utf8               InnerClasses\r\n  #92 = Utf8               (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;\r\n  #93 = Class              #95            // java/lang/invoke/MethodHandles\r\n  #94 = Utf8               java/lang/invoke/MethodHandles$Lookup\r\n  #95 = Utf8               java/lang/invoke/MethodHandles\r\n{\r\n  final T head;\r\n    descriptor: Ljava/lang/Object;\r\n    flags: ACC_FINAL\r\n    Signature: #17                          // TT;\r\n\r\n  test.Stream<T> tail;\r\n    descriptor: Ltest/Stream;\r\n    flags:\r\n    Signature: #20                          // Ltest/Stream<TT;>;\r\n\r\n  java.util.function.Supplier<test.Stream<T>> tailSupplier;\r\n    descriptor: Ljava/util/function/Supplier;\r\n    flags:\r\n    Signature: #23                          // Ljava/util/function/Supplier<Ltest/Stream<TT;>;>;\r\n\r\n  test.Stream(T, java.util.function.Supplier<test.Stream<T>>);\r\n    descriptor: (Ljava/lang/Object;Ljava/util/function/Supplier;)V\r\n    flags:\r\n    Code:\r\n      stack=2, locals=3, args_size=3\r\n         0: aload_0\r\n         1: invokespecial #1                  // Method java/lang/Object.\"<init>\":()V\r\n         4: aload_0\r\n         5: aconst_null\r\n         6: putfield      #2                  // Field tail:Ltest/Stream;\r\n         9: aload_0\r\n        10: aload_1\r\n        11: putfield      #3                  // Field head:Ljava/lang/Object;\r\n        14: aload_0\r\n        15: aload_2\r\n        16: putfield      #4                  // Field tailSupplier:Ljava/util/function/Supplier;\r\n        19: return\r\n      LineNumberTable:\r\n        line 11: 0\r\n        line 8: 4\r\n        line 12: 9\r\n        line 13: 14\r\n        line 14: 19\r\n      LocalVariableTable:\r\n        Start  Length  Slot  Name   Signature\r\n            0      20     0  this   Ltest/Stream;\r\n            0      20     1  head   Ljava/lang/Object;\r\n            0      20     2 tailSupplier   Ljava/util/function/Supplier;\r\n      LocalVariableTypeTable:\r\n        Start  Length  Slot  Name   Signature\r\n            0      20     0  this   Ltest/Stream<TT;>;\r\n            0      20     1  head   TT;\r\n            0      20     2 tailSupplier   Ljava/util/function/Supplier<Ltest/Stream<TT;>;>;\r\n    Signature: #31                          // (TT;Ljava/util/function/Supplier<Ltest/Stream<TT;>;>;)V\r\n\r\n  test.Stream<T> append(T);\r\n    descriptor: (Ljava/lang/Object;)Ltest/Stream;\r\n    flags:\r\n    Code:\r\n      stack=5, locals=3, args_size=2\r\n         0: aload_0\r\n         1: invokevirtual #5                  // Method tailSupplier0:()Ljava/util/function/Supplier;\r\n         4: astore_2\r\n         5: new           #6                  // class test/Stream\r\n         8: dup\r\n         9: aload_0\r\n        10: getfield      #3                  // Field head:Ljava/lang/Object;\r\n        13: aload_2\r\n        14: aload_1\r\n        15: invokedynamic #7,  0              // InvokeDynamic #0:get:(Ljava/util/function/Supplier;Ljava/lang/Object;)Ljava/util/function/Supplier;\r\n        20: invokespecial #8                  // Method \"<init>\":(Ljava/lang/Object;Ljava/util/function/Supplier;)V\r\n        23: areturn\r\n      LineNumberTable:\r\n        line 17: 0\r\n        line 18: 5\r\n      LocalVariableTable:\r\n        Start  Length  Slot  Name   Signature\r\n            0      24     0  this   Ltest/Stream;\r\n            0      24     1 element   Ljava/lang/Object;\r\n            5      19     2 localTailSupplier   Ljava/util/function/Supplier;\r\n      LocalVariableTypeTable:\r\n        Start  Length  Slot  Name   Signature\r\n            0      24     0  this   Ltest/Stream<TT;>;\r\n            0      24     1 element   TT;\r\n            5      19     2 localTailSupplier   Ljava/util/function/Supplier<Ltest/Stream<TT;>;>;\r\n    Signature: #36                          // (TT;)Ltest/Stream<TT;>;\r\n\r\n  java.util.function.Supplier<test.Stream<T>> tailSupplier0();\r\n    descriptor: ()Ljava/util/function/Supplier;\r\n    flags:\r\n    Code:\r\n      stack=1, locals=1, args_size=1\r\n         0: aload_0\r\n         1: invokedynamic #9,  0              // InvokeDynamic #1:get:(Ltest/Stream;)Ljava/util/function/Supplier;\r\n         6: areturn\r\n      LineNumberTable:\r\n        line 22: 0\r\n      LocalVariableTable:\r\n        Start  Length  Slot  Name   Signature\r\n            0       7     0  this   Ltest/Stream;\r\n      LocalVariableTypeTable:\r\n        Start  Length  Slot  Name   Signature\r\n            0       7     0  this   Ltest/Stream<TT;>;\r\n    Signature: #39                          // ()Ljava/util/function/Supplier<Ltest/Stream<TT;>;>;\r\n\r\n  java.util.function.Supplier<test.Stream<T>> tailSupplier1();\r\n    descriptor: ()Ljava/util/function/Supplier;\r\n    flags:\r\n    Code:\r\n      stack=1, locals=2, args_size=1\r\n         0: aload_0\r\n         1: getfield      #2                  // Field tail:Ltest/Stream;\r\n         4: astore_1\r\n         5: aload_1\r\n         6: invokedynamic #10,  0             // InvokeDynamic #2:get:(Ltest/Stream;)Ljava/util/function/Supplier;\r\n        11: areturn\r\n      LineNumberTable:\r\n        line 26: 0\r\n        line 27: 5\r\n      LocalVariableTable:\r\n        Start  Length  Slot  Name   Signature\r\n            0      12     0  this   Ltest/Stream;\r\n            5       7     1 localTail   Ltest/Stream;\r\n      LocalVariableTypeTable:\r\n        Start  Length  Slot  Name   Signature\r\n            0      12     0  this   Ltest/Stream<TT;>;\r\n            5       7     1 localTail   Ltest/Stream<TT;>;\r\n    Signature: #39                          // ()Ljava/util/function/Supplier<Ltest/Stream<TT;>;>;\r\n\r\n  java.util.function.Supplier<test.Stream<T>> tailSupplier2();\r\n    descriptor: ()Ljava/util/function/Supplier;\r\n    flags:\r\n    Code:\r\n      stack=1, locals=1, args_size=1\r\n         0: aload_0\r\n         1: getfield      #4                  // Field tailSupplier:Ljava/util/function/Supplier;\r\n         4: areturn\r\n      LineNumberTable:\r\n        line 31: 0\r\n      LocalVariableTable:\r\n        Start  Length  Slot  Name   Signature\r\n            0       5     0  this   Ltest/Stream;\r\n      LocalVariableTypeTable:\r\n        Start  Length  Slot  Name   Signature\r\n            0       5     0  this   Ltest/Stream<TT;>;\r\n    Signature: #39                          // ()Ljava/util/function/Supplier<Ltest/Stream<TT;>;>;\r\n}\r\nSignature: #49                          // <T:Ljava/lang/Object;>Ljava/lang/Object;\r\nSourceFile: \"Stream.java\"\r\nInnerClasses:\r\n     public static final #90= #89 of #93; //Lookup=class java/lang/invoke/MethodHandles$Lookup of class java/lang/invoke/MethodHandles\r\nBootstrapMethods:\r\n  0: #59 invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;\r\n    Method arguments:\r\n      #60 ()Ljava/lang/Object;\r\n      #61 invokestatic test/Stream.lambda$append$0:(Ljava/util/function/Supplier;Ljava/lang/Object;)Ltest/Stream;\r\n      #62 ()Ltest/Stream;\r\n  1: #59 invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;\r\n    Method arguments:\r\n      #60 ()Ljava/lang/Object;\r\n      #65 invokespecial test/Stream.lambda$tailSupplier0$1:()Ltest/Stream;\r\n      #62 ()Ltest/Stream;\r\n  2: #59 invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;\r\n    Method arguments:\r\n      #60 ()Ljava/lang/Object;\r\n      #67 invokestatic test/Stream.lambda$tailSupplier1$2:(Ltest/Stream;)Ltest/Stream;\r\n      #62 ()Ltest/Stream;\r\n```\r\n"}}