author | rfield |
Thu, 14 Mar 2013 22:54:17 -0700 | |
changeset 16551 | c08f5b2c7232 |
child 28592 | 4f1da6e809b0 |
permissions | -rw-r--r-- |
16551
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
1 |
/* |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
4 |
* |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
8 |
* |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
13 |
* accompanied this code). |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
14 |
* |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
18 |
* |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
21 |
* questions. |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
22 |
*/ |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
23 |
|
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
24 |
/* |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
25 |
@test |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
26 |
@bug 8010010 |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
27 |
@summary NPE generating serializedLambdaName for nested lambda |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
28 |
*/ |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
29 |
|
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
30 |
import java.io.*; |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
31 |
import java.util.Map; |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
32 |
import java.util.HashMap; |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
33 |
|
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
34 |
public class LambdaLambdaSerialized { |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
35 |
|
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
36 |
static int assertionCount = 0; |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
37 |
|
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
38 |
static void assertTrue(boolean cond) { |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
39 |
assertionCount++; |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
40 |
if (!cond) |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
41 |
throw new AssertionError(); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
42 |
} |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
43 |
|
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
44 |
public static void main(String[] args) throws Exception { |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
45 |
try { |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
46 |
// Write lambdas out |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
47 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
48 |
ObjectOutput out = new ObjectOutputStream(baos); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
49 |
LSI<LSI<Map>> ssi = () -> (() -> new HashMap()); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
50 |
write(out, ssi ); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
51 |
out.flush(); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
52 |
out.close(); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
53 |
|
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
54 |
// Read them back |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
55 |
ByteArrayInputStream bais = |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
56 |
new ByteArrayInputStream(baos.toByteArray()); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
57 |
ObjectInputStream in = new ObjectInputStream(bais); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
58 |
readAssert(in, "[X]"); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
59 |
in.close(); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
60 |
} catch (IOException e) { |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
61 |
e.printStackTrace(); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
62 |
throw e; |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
63 |
} |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
64 |
} |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
65 |
|
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
66 |
static void write(ObjectOutput out, LSI<LSI<Map>> lamb) throws IOException { |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
67 |
out.writeObject(lamb); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
68 |
} |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
69 |
|
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
70 |
static void readAssert(ObjectInputStream in, String expected) throws IOException, ClassNotFoundException { |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
71 |
LSI<LSI<Map>> ls = (LSI<LSI<Map>>) in.readObject(); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
72 |
Map result = ls.get().get(); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
73 |
System.out.printf("Result: %s\n", result); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
74 |
} |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
75 |
} |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
76 |
|
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
77 |
interface LSI<T> extends Serializable { |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
78 |
T get(); |
c08f5b2c7232
8010010: NPE generating serializedLambdaName for nested lambda
rfield
parents:
diff
changeset
|
79 |
} |