Search in sources :

Example 1 with Scope

use of com.sun.source.tree.Scope in project ceylon by eclipse.

the class T6598108 method main.

public static void main(String[] args) throws Exception {
    // NOI18N
    final String bootPath = System.getProperty("sun.boot.class.path");
    final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    assert tool != null;
    final JavacTask ct = (JavacTask) tool.getTask(null, null, null, Arrays.asList("-bootclasspath", bootPath), null, Arrays.asList(new MyFileObject()));
    CompilationUnitTree cut = ct.parse().iterator().next();
    TreePath tp = new TreePath(new TreePath(cut), cut.getTypeDecls().get(0));
    Scope s = Trees.instance(ct).getScope(tp);
    TypeElement type = ct.getElements().getTypeElement("com.sun.java.util.jar.pack.Package.File");
    if (Trees.instance(ct).isAccessible(s, type)) {
        // "false" would be expected here.
        throw new IllegalStateException("");
    }
}
Also used : CompilationUnitTree(com.sun.source.tree.CompilationUnitTree) TreePath(com.sun.source.util.TreePath) Scope(com.sun.source.tree.Scope) TypeElement(javax.lang.model.element.TypeElement) JavaCompiler(javax.tools.JavaCompiler) JavacTask(com.sun.source.util.JavacTask)

Example 2 with Scope

use of com.sun.source.tree.Scope in project ceylon-compiler by ceylon.

the class T6598108 method main.

public static void main(String[] args) throws Exception {
    // NOI18N
    final String bootPath = System.getProperty("sun.boot.class.path");
    final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    assert tool != null;
    final JavacTask ct = (JavacTask) tool.getTask(null, null, null, Arrays.asList("-bootclasspath", bootPath), null, Arrays.asList(new MyFileObject()));
    CompilationUnitTree cut = ct.parse().iterator().next();
    TreePath tp = new TreePath(new TreePath(cut), cut.getTypeDecls().get(0));
    Scope s = Trees.instance(ct).getScope(tp);
    TypeElement type = ct.getElements().getTypeElement("com.sun.java.util.jar.pack.Package.File");
    if (Trees.instance(ct).isAccessible(s, type)) {
        // "false" would be expected here.
        throw new IllegalStateException("");
    }
}
Also used : CompilationUnitTree(com.sun.source.tree.CompilationUnitTree) TreePath(com.sun.source.util.TreePath) Scope(com.sun.source.tree.Scope) TypeElement(javax.lang.model.element.TypeElement) JavaCompiler(javax.tools.JavaCompiler) JavacTask(com.sun.source.util.JavacTask)

Aggregations

CompilationUnitTree (com.sun.source.tree.CompilationUnitTree)2 Scope (com.sun.source.tree.Scope)2 JavacTask (com.sun.source.util.JavacTask)2 TreePath (com.sun.source.util.TreePath)2 TypeElement (javax.lang.model.element.TypeElement)2 JavaCompiler (javax.tools.JavaCompiler)2