1 /* |
1 /* |
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2010, 2014, 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. |
44 |
44 |
45 public class AnnotatedArrayOrder { |
45 public class AnnotatedArrayOrder { |
46 public static void main(String[] args) throws Exception { |
46 public static void main(String[] args) throws Exception { |
47 PrintWriter out = new PrintWriter(System.out, true); |
47 PrintWriter out = new PrintWriter(System.out, true); |
48 JavacTool tool = JavacTool.create(); |
48 JavacTool tool = JavacTool.create(); |
49 StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); |
49 try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) { |
50 File testSrc = new File(System.getProperty("test.src")); |
50 File testSrc = new File(System.getProperty("test.src")); |
51 Iterable<? extends JavaFileObject> f = |
51 Iterable<? extends JavaFileObject> f = |
52 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "AnnotatedArrayOrder.java"))); |
52 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "AnnotatedArrayOrder.java"))); |
53 JavacTask task = tool.getTask(out, fm, null, null, null, f); |
53 JavacTask task = tool.getTask(out, fm, null, null, null, f); |
54 Iterable<? extends CompilationUnitTree> trees = task.parse(); |
54 Iterable<? extends CompilationUnitTree> trees = task.parse(); |
55 out.flush(); |
55 out.flush(); |
56 |
56 |
57 Scanner s = new Scanner(); |
57 Scanner s = new Scanner(); |
58 for (CompilationUnitTree t: trees) |
58 for (CompilationUnitTree t: trees) |
59 s.scan(t, null); |
59 s.scan(t, null); |
60 |
60 } |
61 } |
61 } |
62 |
62 |
63 private static class Scanner extends TreeScanner<Void,Void> { |
63 private static class Scanner extends TreeScanner<Void,Void> { |
64 public Void visitCompilationUnit(CompilationUnitTree node, Void ignore) { |
64 public Void visitCompilationUnit(CompilationUnitTree node, Void ignore) { |
65 super.visitCompilationUnit(node, ignore); |
65 super.visitCompilationUnit(node, ignore); |