モジュール jdk.scripting.nashorn
パッケージ jdk.nashorn.api.tree
NashornパーサーAPIは、ECMAScriptソース・コードを抽象構文ツリー(AST)およびParserとして表現するためのインタフェースを提供し、ECMAScriptソース・スクリプトを解析します。
パーサーAPIを使用すると、ECMAScriptソースの構文解析ツリーにアクセスするためのJavaコードを記述できます。 スクリプト・ソースは、ファイル、URL、または文字列です。 特に指定のない限り、このパッケージのメソッドのnull引数はNullPointerExceptionをスローします。
import jdk.nashorn.api.tree.*;
import java.io.File;
// Simple example that prints warning on 'with' statements
public class Main {
public static void main(String[] args) throws Exception {
// Create a new parser instance
Parser parser = Parser.create();
File sourceFile = new File(args[0]);
// Parse given source File using parse method.
// Pass a diagnostic listener to print error messages.
CompilationUnitTree cut = parser.parse(sourceFile,
(d) -> { System.out.println(d); });
if (cut != null) {
// call Tree.accept method passing a SimpleTreeVisitor
cut.accept(new SimpleTreeVisitor<Void, Void>() {
// visit method for 'with' statement
public Void visitWith(WithTree wt, Void v) {
// print warning on 'with' statement
System.out.println("Warning: using 'with' statement!");
return null;
}
}, null);
}
}
}
- 導入されたバージョン:
- 9
-
インタフェースのサマリー インタフェース 説明 ArrayAccessTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ArrayLiteralTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。AssignmentTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。BinaryTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。BlockTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。BreakTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。CaseTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。CatchTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ClassDeclarationTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ClassExpressionTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。CompilationUnitTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。CompoundAssignmentTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ConditionalExpressionTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ConditionalLoopTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ContinueTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。DebuggerTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。Diagnostic 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。DiagnosticListener 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。DoWhileLoopTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。EmptyStatementTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ErroneousTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ExportEntryTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ExpressionStatementTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ExpressionTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ForInLoopTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ForLoopTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ForOfLoopTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。FunctionCallTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。FunctionDeclarationTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。FunctionExpressionTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。GotoTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。IdentifierTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。IfTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ImportEntryTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。InstanceOfTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。LabeledStatementTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。LineMap 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。LiteralTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。LoopTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。MemberSelectTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ModuleTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。NewTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ObjectLiteralTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ParenthesizedTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。Parser 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。PropertyTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。RegExpLiteralTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ReturnTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。SpreadTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。StatementTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。SwitchTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。TemplateLiteralTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。ThrowTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。Tree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。TreeVisitor<R,P> 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。TryTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。UnaryTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。VariableTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。WhileLoopTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。WithTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。YieldTree 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。 -
クラスのサマリー クラス 説明 SimpleTreeVisitorES5_1<R,P> 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。SimpleTreeVisitorES6<R,P> 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。 -
列挙型のサマリー 列挙型 説明 Diagnostic.Kind 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。Tree.Kind 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。 -
例外のサマリー 例外 説明 UnknownTreeException 削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。 Nashorn JavaScriptスクリプト・エンジンとAPIおよびjjsツールは、将来のリリースでこれらを削除する目的で非推奨になりました。