author | bchristi |
Fri, 08 Jan 2016 13:14:30 -0800 | |
changeset 34934 | 7fbff68dbc12 |
parent 31193 | f019295fdeb3 |
permissions | -rw-r--r-- |
31098
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
1 |
/* |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
3 |
* |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
4 |
* Redistribution and use in source and binary forms, with or without |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
5 |
* modification, are permitted provided that the following conditions |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
6 |
* are met: |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
7 |
* |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
8 |
* - Redistributions of source code must retain the above copyright |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
9 |
* notice, this list of conditions and the following disclaimer. |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
10 |
* |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
11 |
* - Redistributions in binary form must reproduce the above copyright |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
12 |
* notice, this list of conditions and the following disclaimer in the |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
13 |
* documentation and/or other materials provided with the distribution. |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
14 |
* |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
15 |
* - Neither the name of Oracle nor the names of its |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
16 |
* contributors may be used to endorse or promote products derived |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
17 |
* from this software without specific prior written permission. |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
18 |
* |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
19 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
20 |
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
21 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
22 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
23 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
24 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
25 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
26 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
27 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
28 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
29 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
30 |
*/ |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
31 |
|
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
32 |
// script helpers to print meta info on Java instances and classes |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
33 |
|
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
34 |
// print instance methods info on a Java object or static methods info of a Java class |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
35 |
function methods(jobj) { |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
36 |
if (! Java.isJavaObject(jobj)) { |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
37 |
throw new TypeError("not a Java object"); |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
38 |
} |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
39 |
|
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
40 |
var isStatic = Java.isType(jobj); |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
41 |
var obj = Object.bindProperties({}, jobj); |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
42 |
for each (var i in obj) { |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
43 |
if (Java.isJavaMethod(i)) { |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
44 |
var str = String(i); |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
45 |
var idx = str.indexOf(' '); |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
46 |
var overloaded = str.substring(0, idx).endsWith("OverloadedDynamicMethod"); |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
47 |
var lastIdx = isStatic? str.lastIndexOf('] on') : str.lastIndexOf(']'); |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
48 |
print(str.substring(idx + 1, lastIdx) + (overloaded? "*" : "")) |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
49 |
} |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
50 |
} |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
51 |
} |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
52 |
|
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
53 |
// print instance field names of a Java object or static field names of a Java class |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
54 |
function fields(jobj) { |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
55 |
if (! Java.isJavaObject(jobj)) { |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
56 |
throw new TypeError("not a Java object"); |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
57 |
} |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
58 |
|
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
59 |
var obj = Object.bindProperties({}, jobj); |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
60 |
for (var i in obj) { |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
61 |
if (! Java.isJavaMethod(obj[i])) { |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
62 |
print(i); |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
63 |
} |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
64 |
} |
e98a3ba5d5da
8086032: Add compiler error tests when syntax extensions are used with --no-syntax-extensions option
sundar
parents:
diff
changeset
|
65 |
} |