author | xuelei |
Thu, 10 Nov 2016 15:46:40 +0000 | |
changeset 43212 | 5aa719c66677 |
parent 31096 | a3a697c1edd5 |
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 |
/* |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
4 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
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). |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
46 |
*/ |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
47 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
48 |
(function() { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
49 |
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
|
50 |
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
|
51 |
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
|
52 |
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
|
53 |
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
|
54 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
55 |
// 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
|
56 |
// 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
|
57 |
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
|
58 |
var root = fs.getPath('/'); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
59 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
60 |
var clsToPkg = new HashMap(); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
61 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
62 |
function addToClsToPkg(c, p) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
63 |
if (clsToPkg.containsKey(c)) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
64 |
var val = clsToPkg.get(c); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
65 |
if (val instanceof ArrayList) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
66 |
val.add(p); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
67 |
} else { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
68 |
var al = new ArrayList(); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
69 |
al.add(val); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
70 |
al.add(p); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
71 |
clsToPkg.put(c, al); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
72 |
} |
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 |
clsToPkg.put(c, p); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
75 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
76 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
77 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
78 |
// 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
|
79 |
function getPkgOfCls(c) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
80 |
var val = clsToPkg.get(c); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
81 |
if (val instanceof ArrayList) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
82 |
var count = 1; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
83 |
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
|
84 |
for each (var v in val) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
85 |
print(count + ". " + v); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
86 |
count++; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
87 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
88 |
var choice = parseInt(readLine()); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
89 |
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
|
90 |
print("invalid choice: " + choice); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
91 |
return undefined; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
92 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
93 |
return val.get(choice - 1); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
94 |
} else { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
95 |
return val; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
96 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
97 |
} |
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 |
Files.walk(root).forEach(function(p) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
100 |
if (Files.isRegularFile(p)) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
101 |
var str = p.toString(); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
102 |
if (str.endsWith(".class")) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
103 |
str = str.substring(1); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
104 |
var idx = str.indexOf('/'); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
105 |
if (idx != -1) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
106 |
str = str.substring(idx + 1); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
107 |
if (str.startsWith("java") || |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
108 |
str.startsWith("javax") || |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
109 |
str.startsWith("org")) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
110 |
var lastIdx = str.lastIndexOf('/'); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
111 |
if (lastIdx != -1) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
112 |
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
|
113 |
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
|
114 |
addToClsToPkg(cls, pkg); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
115 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
116 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
117 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
118 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
119 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
120 |
}); |
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 |
var imports = new ArrayList(); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
123 |
var global = this; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
124 |
var oldNoSuchProp = global.__noSuchProperty__; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
125 |
this.__noSuchProperty__ = function(name) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
126 |
'use strict'; |
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 |
if (clsToPkg.containsKey(name)) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
129 |
var pkg = getPkgOfCls(name); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
130 |
if (pkg) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
131 |
var clsName = pkg + "." + name; |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
132 |
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
|
133 |
return global[name] = Java.type(clsName); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
134 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
135 |
} else if (typeof oldNoSuchProp == 'function') { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
136 |
return oldNoSuchProp.call(this, name); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
137 |
} |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
138 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
139 |
if (typeof this == 'undefined') { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
140 |
throw new ReferenceError(name); |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
141 |
} else { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
142 |
return undefined; |
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 |
|
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
146 |
this.autoimports = function() { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
147 |
for each (var im in imports) { |
a3a697c1edd5
8085937: add autoimports sample script to easily explore Java classes in interactive mode
sundar
parents:
diff
changeset
|
148 |
print(im); |
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 |
})(); |