author | mchung |
Sat, 24 Feb 2018 09:41:42 -0800 | |
changeset 48984 | b5d1fb0701d4 |
parent 47216 | 71c04702a3d5 |
child 50735 | 2f2af62dfac7 |
permissions | -rw-r--r-- |
45044
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
1 |
/* |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
4 |
* |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
8 |
* |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
13 |
* accompanied this code). |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
14 |
* |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
18 |
* |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
21 |
* questions. |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
22 |
*/ |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
23 |
|
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
24 |
/* |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
25 |
* @test |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
26 |
* @bug 8179531 |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
27 |
* @summary Check that ClassLoader.getResource works as expected in the JShell agent. |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
28 |
* @modules jdk.jshell |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
29 |
* @build KullaTesting TestingInputStream |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
30 |
* @run testng GetResourceTest |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
31 |
*/ |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
32 |
|
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
33 |
import jdk.jshell.Snippet; |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
34 |
import static jdk.jshell.Snippet.Status.OVERWRITTEN; |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
35 |
import static jdk.jshell.Snippet.Status.VALID; |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
36 |
import org.testng.annotations.Test; |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
37 |
|
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
38 |
|
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
39 |
@Test |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
40 |
public class GetResourceTest extends KullaTesting { |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
41 |
|
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
42 |
public void checkGetResource() { |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
43 |
assertEval("import java.util.Arrays;"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
44 |
assertEval("boolean match(byte[] data, byte[] snippet) {\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
45 |
" for (int i = 0; i < data.length - snippet.length; i++) {\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
46 |
" if (Arrays.equals(Arrays.copyOfRange(data, i, i + snippet.length), snippet)) {\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
47 |
" return true;\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
48 |
" }\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
49 |
" }\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
50 |
" return false;\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
51 |
"}"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
52 |
assertEval("boolean test() throws Exception {\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
53 |
" Class c = new Object() {}.getClass().getEnclosingClass();\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
54 |
" byte[] data = c.getClassLoader().getResource(c.getName().replace('.', '/') + \".class\").openStream().readAllBytes();\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
55 |
" return match(data, \"check text\".getBytes(\"UTF-8\"));\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
56 |
"}"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
57 |
assertEval("test()", "true"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
58 |
} |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
59 |
|
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
60 |
public void checkRedefine() { |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
61 |
assertEval("import java.util.Arrays;"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
62 |
assertEval("boolean match(byte[] data, byte[] snippet) {\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
63 |
" for (int i = 0; i < data.length - snippet.length; i++) {\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
64 |
" if (Arrays.equals(Arrays.copyOfRange(data, i, i + snippet.length), snippet)) {\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
65 |
" return true;\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
66 |
" }\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
67 |
" }\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
68 |
" return false;\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
69 |
"}"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
70 |
Snippet testMethod = |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
71 |
methodKey(assertEval("boolean test() throws Exception {\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
72 |
" return false;\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
73 |
"}")); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
74 |
assertEval("boolean test() throws Exception {\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
75 |
" Class c = new Object() {}.getClass().getEnclosingClass();\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
76 |
" byte[] data = c.getClassLoader().getResource(c.getName().replace('.', '/') + \".class\").openStream().readAllBytes();\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
77 |
" return match(data, \"updated variant\".getBytes(\"UTF-8\"));\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
78 |
"}", |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
79 |
IGNORE_VALUE, |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
80 |
null, |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
81 |
DiagCheck.DIAG_OK, |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
82 |
DiagCheck.DIAG_OK, |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
83 |
ste(MAIN_SNIPPET, VALID, VALID, false, null), |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
84 |
ste(testMethod, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
85 |
assertEval("test()", "true"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
86 |
} |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
87 |
|
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
88 |
public void checkResourceSize() { |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
89 |
assertEval("import java.net.*;"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
90 |
assertEval("boolean test() throws Exception {\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
91 |
" Class c = new Object() {}.getClass().getEnclosingClass();" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
92 |
" URL url = c.getClassLoader().getResource(c.getName().replace('.', '/') + \".class\");\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
93 |
" URLConnection connection = url.openConnection();\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
94 |
" connection.connect();\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
95 |
" return connection.getContentLength() == connection.getInputStream().readAllBytes().length;\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
96 |
"}"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
97 |
assertEval("test()", "true"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
98 |
} |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
99 |
|
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
100 |
public void checkTimestampCheck() { |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
101 |
assertEval("import java.net.*;"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
102 |
assertEval("import java.time.*;"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
103 |
assertEval("import java.time.format.*;"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
104 |
assertEval("long[] times(Class c) throws Exception {\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
105 |
" URL url = c.getClassLoader().getResource(c.getName().replace('.', '/') + \".class\");\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
106 |
" URLConnection connection = url.openConnection();\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
107 |
" connection.connect();\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
108 |
" return new long[] {connection.getDate(),\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
109 |
" connection.getLastModified()," + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
110 |
" Instant.from(DateTimeFormatter.RFC_1123_DATE_TIME.parse(connection.getHeaderField(\"last-modified\"))).toEpochMilli()};\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
111 |
"}"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
112 |
Snippet testMethod = |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
113 |
methodKey(assertEval("long[] test() throws Exception {\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
114 |
" int i = 0;\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
115 |
" return times(new Object() {}.getClass().getEnclosingClass());\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
116 |
"}")); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
117 |
assertEval("long[] orig = test();"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
118 |
long s = System.currentTimeMillis(); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
119 |
while ((System.currentTimeMillis() - s) < 1000) { //ensure time change: |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
120 |
try { |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
121 |
Thread.sleep(1000); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
122 |
} catch (InterruptedException ex) {} |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
123 |
} |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
124 |
assertEval("long[] test() throws Exception {\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
125 |
" int i = 1;\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
126 |
" return times(new Object() {}.getClass().getEnclosingClass());\n" + |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
127 |
"}", |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
128 |
IGNORE_VALUE, |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
129 |
null, |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
130 |
DiagCheck.DIAG_OK, |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
131 |
DiagCheck.DIAG_OK, |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
132 |
ste(MAIN_SNIPPET, VALID, VALID, false, null), |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
133 |
ste(testMethod, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
134 |
assertEval("long[] nue = test();"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
135 |
assertEval("orig[0] < nue[0]", "true"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
136 |
assertEval("orig[1] < nue[1]", "true"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
137 |
assertEval("orig[0] == orig[2]", "true"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
138 |
assertEval("nue[0] == nue[2]", "true"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
139 |
} |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
140 |
|
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
141 |
public void checkFieldAccess() { |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
142 |
assertEval("import java.net.*;"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
143 |
assertEval("Class c = new Object() {}.getClass().getEnclosingClass();"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
144 |
assertEval("URL url = c.getClassLoader().getResource(c.getName().replace('.', '/') + \".class\");"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
145 |
assertEval("URLConnection connection = url.openConnection();"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
146 |
assertEval("connection.connect();"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
147 |
assertEval("connection.getHeaderFieldKey(0)", "\"content-length\""); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
148 |
assertEval("connection.getHeaderFieldKey(1)", "\"date\""); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
149 |
assertEval("connection.getHeaderFieldKey(2)", "\"last-modified\""); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
150 |
assertEval("connection.getHeaderFieldKey(3)", "null"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
151 |
assertEval("connection.getHeaderField(0) != null", "true"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
152 |
assertEval("connection.getHeaderField(1) != null", "true"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
153 |
assertEval("connection.getHeaderField(2) != null", "true"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
154 |
assertEval("connection.getHeaderField(3) == null", "true"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
155 |
} |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
156 |
|
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
157 |
public void checkGetResources() { |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
158 |
assertEval("import java.net.*;"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
159 |
assertEval("Class c = new Object() {}.getClass().getEnclosingClass();"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
160 |
assertEval("c.getClassLoader().getResources(c.getName().replace('.', '/') + \".class\").hasMoreElements()", "true"); |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
161 |
} |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
162 |
|
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
163 |
} |
7c50549b7744
8179531: JShell: fails to provide bytecode for dynamically created lambdas
jlahoda
parents:
diff
changeset
|
164 |