author | martin |
Wed, 10 Dec 2014 09:23:00 -0800 | |
changeset 28057 | 1a47ceecdba5 |
parent 26240 | 4639082d6375 |
permissions | -rw-r--r-- |
26240
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
1 |
/* |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
4 |
* |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
8 |
* |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
13 |
* accompanied this code). |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
14 |
* |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
18 |
* |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
21 |
* questions. |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
22 |
*/ |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
23 |
|
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
24 |
/** |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
25 |
* JDK-8055796: JSObject and browser JSObject linkers should provide fallback to call underlying Java methods directly |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
26 |
* |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
27 |
* @test |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
28 |
* @option -scripting |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
29 |
* @run |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
30 |
*/ |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
31 |
|
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
32 |
function main() { |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
33 |
var JSObject; |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
34 |
try { |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
35 |
JSObject = Java.type("netscape.javascript.JSObject"); |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
36 |
} catch (e) { |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
37 |
if (e instanceof java.lang.ClassNotFoundException) { |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
38 |
// pass vacuously by emitting the .EXPECTED file content |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
39 |
var str = readFully(__DIR__ + "JDK-8055796_2.js.EXPECTED"); |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
40 |
print(str.substring(0, str.length - 1)); |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
41 |
return; |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
42 |
} else { |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
43 |
fail("unexpected exception on JSObject", e); |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
44 |
} |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
45 |
} |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
46 |
test(JSObject); |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
47 |
} |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
48 |
|
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
49 |
function test(JSObject) { |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
50 |
var bjsobj = new (Java.extend(JSObject))() { |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
51 |
getMember: function(name) { |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
52 |
if (name == "func") { |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
53 |
return function(arg) { |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
54 |
print("func called with " + arg); |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
55 |
} |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
56 |
} |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
57 |
return name.toUpperCase(); |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
58 |
}, |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
59 |
|
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
60 |
getSlot: function(index) { |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
61 |
return index*index; |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
62 |
}, |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
63 |
|
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
64 |
setMember: function(name, value) { |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
65 |
print(name + " set to " + value); |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
66 |
}, |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
67 |
|
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
68 |
setSlot: function(index, value) { |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
69 |
print("[" + index + "] set to " + value); |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
70 |
} |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
71 |
}; |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
72 |
|
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
73 |
print("getMember('foo') =", bjsobj['getMember(String)']('foo')); |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
74 |
print("getSlot(6) =", bjsobj['getSlot(int)'](6)); |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
75 |
bjsobj['setMember(String, Object)']('bar', 'hello'); |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
76 |
bjsobj['setSlot(int, Object)'](10, 42); |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
77 |
} |
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
78 |
|
4639082d6375
8055899: Two nashorn tests fail in 8u40 nightly build with ClassNotFoundException
sundar
parents:
diff
changeset
|
79 |
main(); |