author | bchristi |
Fri, 08 Jan 2016 13:14:30 -0800 | |
changeset 34934 | 7fbff68dbc12 |
parent 28878 | 838f91fb6e9c |
permissions | -rw-r--r-- |
28878
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
1 |
#// Usage: jjs getclassnpe.js -- <directory> |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
2 |
|
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
3 |
/* |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
4 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
5 |
* |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
6 |
* Redistribution and use in source and binary forms, with or without |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
7 |
* modification, are permitted provided that the following conditions |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
8 |
* are met: |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
9 |
* |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
10 |
* - Redistributions of source code must retain the above copyright |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
11 |
* notice, this list of conditions and the following disclaimer. |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
12 |
* |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
13 |
* - Redistributions in binary form must reproduce the above copyright |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
14 |
* notice, this list of conditions and the following disclaimer in the |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
15 |
* documentation and/or other materials provided with the distribution. |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
16 |
* |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
17 |
* - Neither the name of Oracle nor the names of its |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
18 |
* contributors may be used to endorse or promote products derived |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
19 |
* from this software without specific prior written permission. |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
20 |
* |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
21 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
22 |
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
23 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
24 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
25 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
26 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
27 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
28 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
29 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
30 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
31 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
32 |
*/ |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
33 |
|
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
34 |
/* |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
35 |
* java.lang.Object.getClass() is sometimes used to do null check. This |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
36 |
* obfuscating Object.getClass() check relies on non-related intrinsic |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
37 |
* performance, which is potentially not available everywhere. |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
38 |
* See also http://cr.openjdk.java.net/~shade/scratch/NullChecks.java |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
39 |
* This nashorn script checks for such uses in your .java files in the |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
40 |
* given directory (recursively). |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
41 |
*/ |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
42 |
|
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
43 |
if (arguments.length == 0) { |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
44 |
print("Usage: jjs getclassnpe.js -- <directory>"); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
45 |
exit(1); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
46 |
} |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
47 |
|
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
48 |
// Java types used |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
49 |
var File = Java.type("java.io.File"); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
50 |
var Files = Java.type("java.nio.file.Files"); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
51 |
var StringArray = Java.type("java.lang.String[]"); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
52 |
var ToolProvider = Java.type("javax.tools.ToolProvider"); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
53 |
var MethodInvocationTree = Java.type("com.sun.source.tree.MethodInvocationTree"); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
54 |
var TreeScanner = Java.type("com.sun.source.util.TreeScanner"); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
55 |
|
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
56 |
// parse a specific .java file to check if it uses |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
57 |
// Object.getClass() for null check. |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
58 |
function checkGetClassNPE() { |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
59 |
// get the system compiler tool |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
60 |
var compiler = ToolProvider.systemJavaCompiler; |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
61 |
// get standard file manager |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
62 |
var fileMgr = compiler.getStandardFileManager(null, null, null); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
63 |
// Using Java.to convert script array (arguments) to a Java String[] |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
64 |
var compUnits = fileMgr.getJavaFileObjects( |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
65 |
Java.to(arguments, StringArray)); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
66 |
// create a new compilation task |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
67 |
var task = compiler.getTask(null, fileMgr, null, null, null, compUnits); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
68 |
// subclass SimpleTreeVisitor - to check for obj.getClass(); statements |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
69 |
var GetClassNPEChecker = Java.extend(TreeScanner); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
70 |
|
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
71 |
var visitor = new GetClassNPEChecker() { |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
72 |
lineMap: null, |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
73 |
sourceFile: null, |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
74 |
|
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
75 |
// save compilation unit details for reporting |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
76 |
visitCompilationUnit: function(node, p) { |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
77 |
this.sourceFile = node.sourceFile; |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
78 |
this.lineMap = node.lineMap; |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
79 |
return Java.super(visitor).visitCompilationUnit(node, p); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
80 |
}, |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
81 |
|
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
82 |
// look for "foo.getClass();" expression statements |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
83 |
visitExpressionStatement: function(node, p) { |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
84 |
var expr = node.expression; |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
85 |
if (expr instanceof MethodInvocationTree) { |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
86 |
var name = String(expr.methodSelect.identifier); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
87 |
|
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
88 |
// will match any "getClass" call with zero arguments! |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
89 |
if (name == "getClass" && expr.arguments.size() == 0) { |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
90 |
print(this.sourceFile.getName() |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
91 |
+ " @ " |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
92 |
+ this.lineMap.getLineNumber(node.pos) |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
93 |
+ ":" |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
94 |
+ this.lineMap.getColumnNumber(node.pos)); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
95 |
|
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
96 |
print("\t", node); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
97 |
} |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
98 |
} |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
99 |
} |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
100 |
} |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
101 |
|
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
102 |
for each (var cu in task.parse()) { |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
103 |
cu.accept(visitor, null); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
104 |
} |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
105 |
} |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
106 |
|
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
107 |
// for each ".java" file in the directory (recursively) |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
108 |
function main(dir) { |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
109 |
Files.walk(dir.toPath()). |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
110 |
forEach(function(p) { |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
111 |
var name = p.toFile().absolutePath; |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
112 |
if (name.endsWith(".java")) { |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
113 |
try { |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
114 |
checkGetClassNPE(p.toFile().getAbsolutePath()); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
115 |
} catch (e) { |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
116 |
print(e); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
117 |
} |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
118 |
} |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
119 |
}); |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
120 |
} |
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
121 |
|
838f91fb6e9c
8071989: NashornScriptEngine returns javax.script.ScriptContext instance with insonsistent get/remove methods behavior for undefined attributes
sundar
parents:
diff
changeset
|
122 |
main(new File(arguments[0])); |