TestResolveIdent.java revision 3294:9adfb22ff08f
1263320Sdim/*
2263320Sdim * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
3263320Sdim * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4263320Sdim *
5269012Semaste * This code is free software; you can redistribute it and/or modify it
6263320Sdim * under the terms of the GNU General Public License version 2 only, as
7263320Sdim * published by the Free Software Foundation.
8263320Sdim *
9263320Sdim * This code is distributed in the hope that it will be useful, but WITHOUT
10263320Sdim * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11263320Sdim * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12263320Sdim * version 2 for more details (a copy is included in the LICENSE file that
13263320Sdim * accompanied this code).
14263320Sdim *
15263320Sdim * You should have received a copy of the GNU General Public License version
16263320Sdim * 2 along with this work; if not, write to the Free Software Foundation,
17263320Sdim * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18263320Sdim *
19263320Sdim * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20263320Sdim * or visit www.oracle.com if you need additional information or have any
21263320Sdim * questions.
22263320Sdim */
23263320Sdim
24263320Sdim/**
25263320Sdim * @test
26263320Sdim * @bug     6374357 6308351
27263320Sdim * @summary PackageElement.getEnclosedElements() throws ClassReader$BadClassFileException
28263320Sdim * @author  Peter von der Ah\u00e9
29263320Sdim * @modules jdk.compiler/com.sun.tools.javac.api
30263320Sdim *          jdk.compiler/com.sun.tools.javac.code
31263320Sdim *          jdk.compiler/com.sun.tools.javac.comp
32263320Sdim *          jdk.compiler/com.sun.tools.javac.main
33263320Sdim *          jdk.compiler/com.sun.tools.javac.util
34263320Sdim * @run main TestResolveIdent
35263320Sdim */
36263320Sdim
37263320Sdimimport com.sun.tools.javac.api.JavacTaskImpl;
38263320Sdimimport com.sun.tools.javac.code.Symtab;
39263320Sdimimport com.sun.tools.javac.comp.Modules;
40263320Sdimimport com.sun.tools.javac.main.JavaCompiler;
41263320Sdimimport com.sun.tools.javac.util.List;
42263320Sdimimport java.io.IOException;
43263320Sdimimport javax.tools.ToolProvider;
44263320Sdim
45263320Sdimpublic class TestResolveIdent {
46263320Sdim
47263320Sdim    @SuppressWarnings("deprecation")
48263320Sdim    static Class<?> getDeprecatedClass() {
49263320Sdim        return java.io.StringBufferInputStream.class;
50263320Sdim    }
51263320Sdim
52263320Sdim    public static void main(String[] args) throws IOException {
53263320Sdim        javax.tools.JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
54263320Sdim        JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, null, null, null, null, null);
55263320Sdim        JavaCompiler compiler = JavaCompiler.instance(task.getContext());
56263320Sdim        Symtab syms = Symtab.instance(task.getContext());
57263320Sdim        Modules modules = Modules.instance(task.getContext());
58263320Sdim        modules.enter(List.nil(), null);
59263320Sdim        System.out.println(compiler.resolveIdent(syms.unnamedModule, getDeprecatedClass().getCanonicalName()));
60263320Sdim    }
61263320Sdim
62263320Sdim}
63263320Sdim