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