test/langtools/tools/javac/api/TestGetElementReference.java
changeset 59285 7799a51dbe30
parent 47216 71c04702a3d5
equal deleted inserted replaced
59284:88502b1cf76f 59285:7799a51dbe30
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    49 import javax.tools.StandardJavaFileManager;
    49 import javax.tools.StandardJavaFileManager;
    50 import javax.tools.ToolProvider;
    50 import javax.tools.ToolProvider;
    51 
    51 
    52 public class TestGetElementReference {
    52 public class TestGetElementReference {
    53 
    53 
       
    54     private static final String JDK_VERSION =
       
    55             Integer.toString(Runtime.getRuntime().version().feature());
       
    56 
    54     public static void main(String... args) throws IOException {
    57     public static void main(String... args) throws IOException {
    55         analyze("TestGetElementReferenceData.java");
    58         analyze("TestGetElementReferenceData.java");
    56         analyze("mod/module-info.java", "mod/api/pkg/Api.java");
    59         analyze("mod/module-info.java", "mod/api/pkg/Api.java");
    57     }
    60     }
    58 
    61 
    64                 for (JavaFileObject f : fm.getJavaFileObjects(source)) {
    67                 for (JavaFileObject f : fm.getJavaFileObjects(source)) {
    65                     files.add(f);
    68                     files.add(f);
    66                 }
    69                 }
    67             }
    70             }
    68             DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
    71             DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
    69             JavacTask ct = (JavacTask) ToolProvider.getSystemJavaCompiler().getTask(null, null, diagnostics, Arrays.asList("-Xjcov"), null, files);
    72             List<String> options = List.of("-Xjcov",
       
    73                                            "--enable-preview",
       
    74                                            "-source", JDK_VERSION);
       
    75             JavacTask ct = (JavacTask) ToolProvider.getSystemJavaCompiler().getTask(null, null, diagnostics, options, null, files);
    70             Trees trees = Trees.instance(ct);
    76             Trees trees = Trees.instance(ct);
    71             CompilationUnitTree cut = ct.parse().iterator().next();
    77             CompilationUnitTree cut = ct.parse().iterator().next();
    72 
    78 
    73             ct.analyze();
    79             ct.analyze();
    74 
    80