author | jlahoda |
Thu, 28 Jun 2018 10:05:39 +0200 | |
changeset 50867 | e84038f37713 |
parent 47286 | cd02250e9370 |
permissions | -rw-r--r-- |
31096
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
1 |
# autoimports script requires -scripting mode |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
2 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
3 |
/* |
47286 | 4 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
31096
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
5 |
* |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
6 |
* Redistribution and use in source and binary forms, with or without |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
7 |
* modification, are permitted provided that the following conditions |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
8 |
* are met: |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
9 |
* |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
10 |
* - Redistributions of source code must retain the above copyright |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
11 |
* notice, this list of conditions and the following disclaimer. |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
12 |
* |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
13 |
* - Redistributions in binary form must reproduce the above copyright |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
14 |
* notice, this list of conditions and the following disclaimer in the |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
15 |
* documentation and/or other materials provided with the distribution. |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
16 |
* |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
17 |
* - Neither the name of Oracle nor the names of its |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
18 |
* contributors may be used to endorse or promote products derived |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
19 |
* from this software without specific prior written permission. |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
20 |
* |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
21 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
22 |
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
23 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
24 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
25 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
26 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
27 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
28 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
29 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
30 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
31 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
32 |
*/ |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
33 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
34 |
/* |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
35 |
* It is tedious to import Java classes used in a script. Sometimes it is easier |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
36 |
* use simple names of java classes and have a script auto import Java classes. |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
37 |
* You can load this script at the start of an interactive jjs session or at the |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
38 |
* start of your script. This script defines a __noSuchProperty__ hook to auto |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
39 |
* import Java classes as needed and when they are referred to for the first time |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
40 |
* in your script. You can also call the "autoimports" function to print script |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
41 |
* statements that you need to use in your script, i.e., have the function generate |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
42 |
* a script to import Java classes used by your script so far. After running your |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
43 |
* script, you can call autoimports to get the exact Java imports you need and replace |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
44 |
* the autoimports load with the generated import statements (to avoid costly init of |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
45 |
* the autoimports script). |
47286 | 46 |
* |
47 |
* Example usage of autoimports.js in interactive mode: |
|
48 |
* |
|
49 |
* jjs -scripting autoimports.js - |
|
50 |
* jjs> Vector |
|
51 |
* jjs> [JavaClass java.util.Vector] |
|
31096
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
52 |
*/ |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
53 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
54 |
(function() { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
55 |
var ArrayList = Java.type("java.util.ArrayList"); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
56 |
var HashMap = Java.type("java.util.HashMap"); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
57 |
var Files = Java.type("java.nio.file.Files"); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
58 |
var FileSystems = Java.type("java.nio.file.FileSystems"); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
59 |
var URI = Java.type("java.net.URI"); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
60 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
61 |
// initialize a class to package map by iterating all |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
62 |
// classes available in the system by walking through "jrt fs" |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
63 |
var fs = FileSystems.getFileSystem(URI.create("jrt:/")); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
64 |
var root = fs.getPath('/'); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
65 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
66 |
var clsToPkg = new HashMap(); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
67 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
68 |
function addToClsToPkg(c, p) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
69 |
if (clsToPkg.containsKey(c)) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
70 |
var val = clsToPkg.get(c); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
71 |
if (val instanceof ArrayList) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
72 |
val.add(p); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
73 |
} else { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
74 |
var al = new ArrayList(); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
75 |
al.add(val); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
76 |
al.add(p); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
77 |
clsToPkg.put(c, al); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
78 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
79 |
} else { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
80 |
clsToPkg.put(c, p); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
81 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
82 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
83 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
84 |
// handle collision and allow user to choose package |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
85 |
function getPkgOfCls(c) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
86 |
var val = clsToPkg.get(c); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
87 |
if (val instanceof ArrayList) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
88 |
var count = 1; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
89 |
print("Multiple matches for " + c + ", choose package:"); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
90 |
for each (var v in val) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
91 |
print(count + ". " + v); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
92 |
count++; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
93 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
94 |
var choice = parseInt(readLine()); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
95 |
if (isNaN(choice) || choice < 1 || choice > val.size()) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
96 |
print("invalid choice: " + choice); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
97 |
return undefined; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
98 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
99 |
return val.get(choice - 1); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
100 |
} else { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
101 |
return val; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
102 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
103 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
104 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
105 |
Files.walk(root).forEach(function(p) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
106 |
if (Files.isRegularFile(p)) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
107 |
var str = p.toString(); |
47286 | 108 |
if (str.endsWith(".class") && !str.endsWith("module-info.class")) { |
109 |
str = str.substring("/modules/".length); |
|
31096
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
110 |
var idx = str.indexOf('/'); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
111 |
if (idx != -1) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
112 |
str = str.substring(idx + 1); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
113 |
if (str.startsWith("java") || |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
114 |
str.startsWith("javax") || |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
115 |
str.startsWith("org")) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
116 |
var lastIdx = str.lastIndexOf('/'); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
117 |
if (lastIdx != -1) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
118 |
var pkg = str.substring(0, lastIdx).replaceAll('/', '.'); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
119 |
var cls = str.substring(lastIdx + 1, str.lastIndexOf(".class")); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
120 |
addToClsToPkg(cls, pkg); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
121 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
122 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
123 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
124 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
125 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
126 |
}); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
127 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
128 |
var imports = new ArrayList(); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
129 |
var global = this; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
130 |
var oldNoSuchProp = global.__noSuchProperty__; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
131 |
this.__noSuchProperty__ = function(name) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
132 |
'use strict'; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
133 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
134 |
if (clsToPkg.containsKey(name)) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
135 |
var pkg = getPkgOfCls(name); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
136 |
if (pkg) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
137 |
var clsName = pkg + "." + name; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
138 |
imports.add("var " + name + " = Java.type('" + clsName + "');"); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
139 |
return global[name] = Java.type(clsName); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
140 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
141 |
} else if (typeof oldNoSuchProp == 'function') { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
142 |
return oldNoSuchProp.call(this, name); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
143 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
144 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
145 |
if (typeof this == 'undefined') { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
146 |
throw new ReferenceError(name); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
147 |
} else { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
148 |
return undefined; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
149 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
150 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
151 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
152 |
this.autoimports = function() { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
153 |
for each (var im in imports) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
154 |
print(im); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
155 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
156 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
157 |
})(); |