126 * position of the parameters to be checked on the init method. Position 0 127 * corresponds to the first parameter. 128 * 129 * As we are looking for a constructor of an anonymous class, the 130 * classOwnerName parameter must be the name of the method where the 131 * anonymous class is declared. 132 */ 133 void checkInitSymbol( 134 final String classOwnerName, 135 final java.util.List<Integer> paramsToCheck, 136 final java.util.List<String> paramNames) 137 throws IOException { 138 Assert.checkNonNull(paramsToCheck, nonNullParamPositionsMsg); 139 JavaCompiler c = ToolProvider.getSystemJavaCompiler(); 140 try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) { 141 Iterable<? extends JavaFileObject> fos = 142 fm.getJavaFileObjectsFromFiles( 143 Arrays.asList(new File(System.getProperty("test.src"), 144 this.getClass().getName() + ".java"))); 145 java.util.List<String> options = Arrays.asList( 146 "-XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED", 147 "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", 148 "-XaddExports:jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", 149 "-XaddExports:jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", 150 "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", 151 "-d", System.getProperty("user.dir") 152 ); 153 JavacTask task = (JavacTask) c.getTask(null, fm, null, options, null, fos); 154 155 BasicJavacTask impl = (BasicJavacTask)task; 156 Context context = impl.getContext(); 157 final Names names = Names.instance(context); 158 159 task.addTaskListener(new TaskListener() { 160 161 @Override 162 public void started(TaskEvent e) {} 163 164 @Override 165 public void finished(TaskEvent e) { 166 class TheTreeScanner extends TreeScanner { 167 boolean foundAndCorrect = false; 168 169 @Override 170 public void visitMethodDef(JCTree.JCMethodDecl tree) { | 126 * position of the parameters to be checked on the init method. Position 0 127 * corresponds to the first parameter. 128 * 129 * As we are looking for a constructor of an anonymous class, the 130 * classOwnerName parameter must be the name of the method where the 131 * anonymous class is declared. 132 */ 133 void checkInitSymbol( 134 final String classOwnerName, 135 final java.util.List<Integer> paramsToCheck, 136 final java.util.List<String> paramNames) 137 throws IOException { 138 Assert.checkNonNull(paramsToCheck, nonNullParamPositionsMsg); 139 JavaCompiler c = ToolProvider.getSystemJavaCompiler(); 140 try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) { 141 Iterable<? extends JavaFileObject> fos = 142 fm.getJavaFileObjectsFromFiles( 143 Arrays.asList(new File(System.getProperty("test.src"), 144 this.getClass().getName() + ".java"))); 145 java.util.List<String> options = Arrays.asList( 146 "--add-exports", "jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED", 147 "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", 148 "--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", 149 "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", 150 "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", 151 "-d", System.getProperty("user.dir") 152 ); 153 JavacTask task = (JavacTask) c.getTask(null, fm, null, options, null, fos); 154 155 BasicJavacTask impl = (BasicJavacTask)task; 156 Context context = impl.getContext(); 157 final Names names = Names.instance(context); 158 159 task.addTaskListener(new TaskListener() { 160 161 @Override 162 public void started(TaskEvent e) {} 163 164 @Override 165 public void finished(TaskEvent e) { 166 class TheTreeScanner extends TreeScanner { 167 boolean foundAndCorrect = false; 168 169 @Override 170 public void visitMethodDef(JCTree.JCMethodDecl tree) { |