Thu, 13 Jan 2011 15:05:09 -0800
Merge
test/tools/javac/meth/InvokeDyn.java | file | annotate | diff | comparison | revisions | |
test/tools/javac/meth/InvokeDynTrans.java | file | annotate | diff | comparison | revisions |
1.1 --- a/make/Makefile Thu Jan 06 20:10:44 2011 -0800 1.2 +++ b/make/Makefile Thu Jan 13 15:05:09 2011 -0800 1.3 @@ -187,7 +187,7 @@ 1.4 clobber: clean 1.5 1.6 # All ant targets of interest 1.7 -ANT_TARGETS = build clean sanity post-sanity diagnostics # for now 1.8 +ANT_TARGETS = build clean sanity post-sanity diagnostics build-all-tools # for now 1.9 1.10 # Create diagnostics log (careful, ant 1.8.0 -diagnostics always does an exit 1) 1.11 $(OUTPUTDIR)/build/ant-diagnostics.log:
2.1 --- a/src/share/bin/launcher.sh-template Thu Jan 06 20:10:44 2011 -0800 2.2 +++ b/src/share/bin/launcher.sh-template Thu Jan 13 15:05:09 2011 -0800 2.3 @@ -26,6 +26,12 @@ 2.4 # 2.5 2.6 mydir="`dirname $0`" 2.7 +case `uname -s` in 2.8 + CYGWIN*) 2.9 + mydir=`cygpath -m $mydir` 2.10 + ;; 2.11 +esac 2.12 + 2.13 mylib="`dirname $mydir`"/lib 2.14 2.15 # By default, put the jar file and its dependencies on the bootclasspath.
3.1 --- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Thu Jan 06 20:10:44 2011 -0800 3.2 +++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Thu Jan 13 15:05:09 2011 -0800 3.3 @@ -266,82 +266,116 @@ 3.4 System.out.println(message); 3.5 } 3.6 3.7 + 3.8 /** 3.9 - * Insert all files in subdirectory `subdirectory' of `directory' which end 3.10 - * in one of the extensions in `extensions' into packageSym. 3.11 + * Insert all files in subdirectory subdirectory of directory directory 3.12 + * which match fileKinds into resultList 3.13 */ 3.14 private void listDirectory(File directory, 3.15 RelativeDirectory subdirectory, 3.16 Set<JavaFileObject.Kind> fileKinds, 3.17 boolean recurse, 3.18 - ListBuffer<JavaFileObject> l) { 3.19 - Archive archive = archives.get(directory); 3.20 + ListBuffer<JavaFileObject> resultList) { 3.21 + File d = subdirectory.getFile(directory); 3.22 + if (!caseMapCheck(d, subdirectory)) 3.23 + return; 3.24 3.25 - boolean isFile = fsInfo.isFile(directory); 3.26 + File[] files = d.listFiles(); 3.27 + if (files == null) 3.28 + return; 3.29 3.30 - if (archive != null || isFile) { 3.31 - if (archive == null) { 3.32 - try { 3.33 - archive = openArchive(directory); 3.34 - } catch (IOException ex) { 3.35 - log.error("error.reading.file", 3.36 - directory, getMessage(ex)); 3.37 - return; 3.38 + if (sortFiles != null) 3.39 + Arrays.sort(files, sortFiles); 3.40 + 3.41 + for (File f: files) { 3.42 + String fname = f.getName(); 3.43 + if (f.isDirectory()) { 3.44 + if (recurse && SourceVersion.isIdentifier(fname)) { 3.45 + listDirectory(directory, 3.46 + new RelativeDirectory(subdirectory, fname), 3.47 + fileKinds, 3.48 + recurse, 3.49 + resultList); 3.50 } 3.51 - } 3.52 - 3.53 - List<String> files = archive.getFiles(subdirectory); 3.54 - if (files != null) { 3.55 - for (String file; !files.isEmpty(); files = files.tail) { 3.56 - file = files.head; 3.57 - if (isValidFile(file, fileKinds)) { 3.58 - l.append(archive.getFileObject(subdirectory, file)); 3.59 - } 3.60 - } 3.61 - } 3.62 - if (recurse) { 3.63 - for (RelativeDirectory s: archive.getSubdirectories()) { 3.64 - if (subdirectory.contains(s)) { 3.65 - // Because the archive map is a flat list of directories, 3.66 - // the enclosing loop will pick up all child subdirectories. 3.67 - // Therefore, there is no need to recurse deeper. 3.68 - listDirectory(directory, s, fileKinds, false, l); 3.69 - } 3.70 - } 3.71 - } 3.72 - } else { 3.73 - File d = subdirectory.getFile(directory); 3.74 - if (!caseMapCheck(d, subdirectory)) 3.75 - return; 3.76 - 3.77 - File[] files = d.listFiles(); 3.78 - if (files == null) 3.79 - return; 3.80 - 3.81 - if (sortFiles != null) 3.82 - Arrays.sort(files, sortFiles); 3.83 - 3.84 - for (File f: files) { 3.85 - String fname = f.getName(); 3.86 - if (f.isDirectory()) { 3.87 - if (recurse && SourceVersion.isIdentifier(fname)) { 3.88 - listDirectory(directory, 3.89 - new RelativeDirectory(subdirectory, fname), 3.90 - fileKinds, 3.91 - recurse, 3.92 - l); 3.93 - } 3.94 - } else { 3.95 - if (isValidFile(fname, fileKinds)) { 3.96 - JavaFileObject fe = 3.97 - new RegularFileObject(this, fname, new File(d, fname)); 3.98 - l.append(fe); 3.99 - } 3.100 + } else { 3.101 + if (isValidFile(fname, fileKinds)) { 3.102 + JavaFileObject fe = 3.103 + new RegularFileObject(this, fname, new File(d, fname)); 3.104 + resultList.append(fe); 3.105 } 3.106 } 3.107 } 3.108 } 3.109 3.110 + /** 3.111 + * Insert all files in subdirectory subdirectory of archive archive 3.112 + * which match fileKinds into resultList 3.113 + */ 3.114 + private void listArchive(Archive archive, 3.115 + RelativeDirectory subdirectory, 3.116 + Set<JavaFileObject.Kind> fileKinds, 3.117 + boolean recurse, 3.118 + ListBuffer<JavaFileObject> resultList) { 3.119 + // Get the files directly in the subdir 3.120 + List<String> files = archive.getFiles(subdirectory); 3.121 + if (files != null) { 3.122 + for (; !files.isEmpty(); files = files.tail) { 3.123 + String file = files.head; 3.124 + if (isValidFile(file, fileKinds)) { 3.125 + resultList.append(archive.getFileObject(subdirectory, file)); 3.126 + } 3.127 + } 3.128 + } 3.129 + if (recurse) { 3.130 + for (RelativeDirectory s: archive.getSubdirectories()) { 3.131 + if (subdirectory.contains(s)) { 3.132 + // Because the archive map is a flat list of directories, 3.133 + // the enclosing loop will pick up all child subdirectories. 3.134 + // Therefore, there is no need to recurse deeper. 3.135 + listArchive(archive, s, fileKinds, false, resultList); 3.136 + } 3.137 + } 3.138 + } 3.139 + } 3.140 + 3.141 + /** 3.142 + * container is a directory, a zip file, or a non-existant path. 3.143 + * Insert all files in subdirectory subdirectory of container which 3.144 + * match fileKinds into resultList 3.145 + */ 3.146 + private void listContainer(File container, 3.147 + RelativeDirectory subdirectory, 3.148 + Set<JavaFileObject.Kind> fileKinds, 3.149 + boolean recurse, 3.150 + ListBuffer<JavaFileObject> resultList) { 3.151 + Archive archive = archives.get(container); 3.152 + if (archive == null) { 3.153 + // archives are not created for directories. 3.154 + if (fsInfo.isDirectory(container)) { 3.155 + listDirectory(container, 3.156 + subdirectory, 3.157 + fileKinds, 3.158 + recurse, 3.159 + resultList); 3.160 + return; 3.161 + } 3.162 + 3.163 + // Not a directory; either a file or non-existant, create the archive 3.164 + try { 3.165 + archive = openArchive(container); 3.166 + } catch (IOException ex) { 3.167 + log.error("error.reading.file", 3.168 + container, getMessage(ex)); 3.169 + return; 3.170 + } 3.171 + } 3.172 + listArchive(archive, 3.173 + subdirectory, 3.174 + fileKinds, 3.175 + recurse, 3.176 + resultList); 3.177 + } 3.178 + 3.179 private boolean isValidFile(String s, Set<JavaFileObject.Kind> fileKinds) { 3.180 JavaFileObject.Kind kind = getKind(s); 3.181 return fileKinds.contains(kind); 3.182 @@ -434,95 +468,92 @@ 3.183 private static final RelativeDirectory symbolFilePrefix 3.184 = new RelativeDirectory("META-INF/sym/rt.jar/"); 3.185 3.186 - /** Open a new zip file directory. 3.187 + /** Open a new zip file directory, and cache it. 3.188 */ 3.189 protected Archive openArchive(File zipFileName) throws IOException { 3.190 - Archive archive = archives.get(zipFileName); 3.191 - if (archive == null) { 3.192 - File origZipFileName = zipFileName; 3.193 - if (!ignoreSymbolFile && paths.isBootClassPathRtJar(zipFileName)) { 3.194 - File file = zipFileName.getParentFile().getParentFile(); // ${java.home} 3.195 - if (new File(file.getName()).equals(new File("jre"))) 3.196 - file = file.getParentFile(); 3.197 - // file == ${jdk.home} 3.198 - for (String name : symbolFileLocation) 3.199 - file = new File(file, name); 3.200 - // file == ${jdk.home}/lib/ct.sym 3.201 - if (file.exists()) 3.202 - zipFileName = file; 3.203 + File origZipFileName = zipFileName; 3.204 + if (!ignoreSymbolFile && paths.isBootClassPathRtJar(zipFileName)) { 3.205 + File file = zipFileName.getParentFile().getParentFile(); // ${java.home} 3.206 + if (new File(file.getName()).equals(new File("jre"))) 3.207 + file = file.getParentFile(); 3.208 + // file == ${jdk.home} 3.209 + for (String name : symbolFileLocation) 3.210 + file = new File(file, name); 3.211 + // file == ${jdk.home}/lib/ct.sym 3.212 + if (file.exists()) 3.213 + zipFileName = file; 3.214 + } 3.215 + 3.216 + Archive archive; 3.217 + try { 3.218 + 3.219 + ZipFile zdir = null; 3.220 + 3.221 + boolean usePreindexedCache = false; 3.222 + String preindexCacheLocation = null; 3.223 + 3.224 + if (!useZipFileIndex) { 3.225 + zdir = new ZipFile(zipFileName); 3.226 } 3.227 + else { 3.228 + usePreindexedCache = options.isSet("usezipindex"); 3.229 + preindexCacheLocation = options.get("java.io.tmpdir"); 3.230 + String optCacheLoc = options.get("cachezipindexdir"); 3.231 3.232 - try { 3.233 + if (optCacheLoc != null && optCacheLoc.length() != 0) { 3.234 + if (optCacheLoc.startsWith("\"")) { 3.235 + if (optCacheLoc.endsWith("\"")) { 3.236 + optCacheLoc = optCacheLoc.substring(1, optCacheLoc.length() - 1); 3.237 + } 3.238 + else { 3.239 + optCacheLoc = optCacheLoc.substring(1); 3.240 + } 3.241 + } 3.242 3.243 - ZipFile zdir = null; 3.244 - 3.245 - boolean usePreindexedCache = false; 3.246 - String preindexCacheLocation = null; 3.247 - 3.248 - if (!useZipFileIndex) { 3.249 - zdir = new ZipFile(zipFileName); 3.250 - } 3.251 - else { 3.252 - usePreindexedCache = options.isSet("usezipindex"); 3.253 - preindexCacheLocation = options.get("java.io.tmpdir"); 3.254 - String optCacheLoc = options.get("cachezipindexdir"); 3.255 - 3.256 - if (optCacheLoc != null && optCacheLoc.length() != 0) { 3.257 - if (optCacheLoc.startsWith("\"")) { 3.258 - if (optCacheLoc.endsWith("\"")) { 3.259 - optCacheLoc = optCacheLoc.substring(1, optCacheLoc.length() - 1); 3.260 - } 3.261 - else { 3.262 - optCacheLoc = optCacheLoc.substring(1); 3.263 - } 3.264 - } 3.265 - 3.266 - File cacheDir = new File(optCacheLoc); 3.267 - if (cacheDir.exists() && cacheDir.canWrite()) { 3.268 - preindexCacheLocation = optCacheLoc; 3.269 - if (!preindexCacheLocation.endsWith("/") && 3.270 - !preindexCacheLocation.endsWith(File.separator)) { 3.271 - preindexCacheLocation += File.separator; 3.272 - } 3.273 + File cacheDir = new File(optCacheLoc); 3.274 + if (cacheDir.exists() && cacheDir.canWrite()) { 3.275 + preindexCacheLocation = optCacheLoc; 3.276 + if (!preindexCacheLocation.endsWith("/") && 3.277 + !preindexCacheLocation.endsWith(File.separator)) { 3.278 + preindexCacheLocation += File.separator; 3.279 } 3.280 } 3.281 } 3.282 + } 3.283 3.284 - if (origZipFileName == zipFileName) { 3.285 - if (!useZipFileIndex) { 3.286 - archive = new ZipArchive(this, zdir); 3.287 - } else { 3.288 - archive = new ZipFileIndexArchive(this, 3.289 + if (origZipFileName == zipFileName) { 3.290 + if (!useZipFileIndex) { 3.291 + archive = new ZipArchive(this, zdir); 3.292 + } else { 3.293 + archive = new ZipFileIndexArchive(this, 3.294 ZipFileIndex.getZipFileIndex(zipFileName, 3.295 null, 3.296 usePreindexedCache, 3.297 preindexCacheLocation, 3.298 options.isSet("writezipindexfiles"))); 3.299 - } 3.300 + } 3.301 + } else { 3.302 + if (!useZipFileIndex) { 3.303 + archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix); 3.304 } 3.305 else { 3.306 - if (!useZipFileIndex) { 3.307 - archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix); 3.308 - } 3.309 - else { 3.310 - archive = new ZipFileIndexArchive(this, 3.311 + archive = new ZipFileIndexArchive(this, 3.312 ZipFileIndex.getZipFileIndex(zipFileName, 3.313 symbolFilePrefix, 3.314 usePreindexedCache, 3.315 preindexCacheLocation, 3.316 options.isSet("writezipindexfiles"))); 3.317 - } 3.318 } 3.319 - } catch (FileNotFoundException ex) { 3.320 - archive = new MissingArchive(zipFileName); 3.321 - } catch (IOException ex) { 3.322 - if (zipFileName.exists()) 3.323 - log.error("error.reading.file", zipFileName, getMessage(ex)); 3.324 - archive = new MissingArchive(zipFileName); 3.325 } 3.326 + } catch (FileNotFoundException ex) { 3.327 + archive = new MissingArchive(zipFileName); 3.328 + } catch (IOException ex) { 3.329 + if (zipFileName.exists()) 3.330 + log.error("error.reading.file", zipFileName, getMessage(ex)); 3.331 + archive = new MissingArchive(zipFileName); 3.332 + } 3.333 3.334 - archives.put(origZipFileName, archive); 3.335 - } 3.336 + archives.put(origZipFileName, archive); 3.337 return archive; 3.338 } 3.339 3.340 @@ -589,8 +620,7 @@ 3.341 ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>(); 3.342 3.343 for (File directory : path) 3.344 - listDirectory(directory, subdirectory, kinds, recurse, results); 3.345 - 3.346 + listContainer(directory, subdirectory, kinds, recurse, results); 3.347 return results.toList(); 3.348 } 3.349 3.350 @@ -659,19 +689,22 @@ 3.351 return null; 3.352 3.353 for (File dir: path) { 3.354 - if (dir.isDirectory()) { 3.355 - File f = name.getFile(dir); 3.356 - if (f.exists()) 3.357 - return new RegularFileObject(this, f); 3.358 - } else { 3.359 - Archive a = openArchive(dir); 3.360 - if (a.contains(name)) { 3.361 - return a.getFileObject(name.dirname(), name.basename()); 3.362 + Archive a = archives.get(dir); 3.363 + if (a == null) { 3.364 + if (fsInfo.isDirectory(dir)) { 3.365 + File f = name.getFile(dir); 3.366 + if (f.exists()) 3.367 + return new RegularFileObject(this, f); 3.368 + continue; 3.369 } 3.370 - 3.371 + // Not a directory, create the archive 3.372 + a = openArchive(dir); 3.373 + } 3.374 + // Process the archive 3.375 + if (a.contains(name)) { 3.376 + return a.getFileObject(name.dirname(), name.basename()); 3.377 } 3.378 } 3.379 - 3.380 return null; 3.381 } 3.382 3.383 @@ -836,8 +869,9 @@ 3.384 return false; 3.385 if (!path.equals(uri.getPath())) // implicitly checks for embedded . and .. 3.386 return false; 3.387 - char first = path.charAt(0); 3.388 - return first != '.' && first != '/'; 3.389 + if (path.startsWith("/") || path.startsWith("./") || path.startsWith("../")) 3.390 + return false; 3.391 + return true; 3.392 } 3.393 3.394 // Convenience method
4.1 --- a/src/share/classes/com/sun/tools/javac/file/Paths.java Thu Jan 06 20:10:44 2011 -0800 4.2 +++ b/src/share/classes/com/sun/tools/javac/file/Paths.java Thu Jan 13 15:05:09 2011 -0800 4.3 @@ -286,9 +286,8 @@ 4.4 } 4.5 4.6 public void addFile(File file, boolean warn) { 4.7 - File canonFile = fsInfo.getCanonicalFile(file); 4.8 - if (contains(file) || canonicalValues.contains(canonFile)) { 4.9 - /* Discard duplicates and avoid infinite recursion */ 4.10 + if (contains(file)) { 4.11 + // discard duplicates 4.12 return; 4.13 } 4.14 4.15 @@ -298,7 +297,17 @@ 4.16 log.warning(Lint.LintCategory.PATH, 4.17 "path.element.not.found", file); 4.18 } 4.19 - } else if (fsInfo.isFile(file)) { 4.20 + super.add(file); 4.21 + return; 4.22 + } 4.23 + 4.24 + File canonFile = fsInfo.getCanonicalFile(file); 4.25 + if (canonicalValues.contains(canonFile)) { 4.26 + /* Discard duplicates and avoid infinite recursion */ 4.27 + return; 4.28 + } 4.29 + 4.30 + if (fsInfo.isFile(file)) { 4.31 /* File is an ordinary file. */ 4.32 if (!isArchive(file)) { 4.33 /* Not a recognized extension; open it to see if 4.34 @@ -322,11 +331,11 @@ 4.35 } 4.36 4.37 /* Now what we have left is either a directory or a file name 4.38 - confirming to archive naming convention */ 4.39 + conforming to archive naming convention */ 4.40 super.add(file); 4.41 canonicalValues.add(canonFile); 4.42 4.43 - if (expandJarClassPaths && fsInfo.exists(file) && fsInfo.isFile(file)) 4.44 + if (expandJarClassPaths && fsInfo.isFile(file)) 4.45 addJarClassPath(file, warn); 4.46 } 4.47
5.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu Jan 06 20:10:44 2011 -0800 5.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu Jan 13 15:05:09 2011 -0800 5.3 @@ -77,6 +77,8 @@ 5.4 protected static final Context.Key<ClassReader> classReaderKey = 5.5 new Context.Key<ClassReader>(); 5.6 5.7 + public static final int INITIAL_BUFFER_SIZE = 0x0fff0; 5.8 + 5.9 Annotate annotate; 5.10 5.11 /** Switch: verbose output. 5.12 @@ -185,7 +187,7 @@ 5.13 5.14 /** The buffer containing the currently read class file. 5.15 */ 5.16 - byte[] buf = new byte[0x0fff0]; 5.17 + byte[] buf = new byte[INITIAL_BUFFER_SIZE]; 5.18 5.19 /** The current input pointer. 5.20 */ 5.21 @@ -2419,8 +2421,14 @@ 5.22 } 5.23 } 5.24 } 5.25 + /* 5.26 + * ensureCapacity will increase the buffer as needed, taking note that 5.27 + * the new buffer will always be greater than the needed and never 5.28 + * exactly equal to the needed size or bp. If equal then the read (above) 5.29 + * will infinitely loop as buf.length - bp == 0. 5.30 + */ 5.31 private static byte[] ensureCapacity(byte[] buf, int needed) { 5.32 - if (buf.length < needed) { 5.33 + if (buf.length <= needed) { 5.34 byte[] old = buf; 5.35 buf = new byte[Integer.highestOneBit(needed) << 1]; 5.36 System.arraycopy(old, 0, buf, 0, old.length);
6.1 --- a/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Thu Jan 06 20:10:44 2011 -0800 6.2 +++ b/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Thu Jan 13 15:05:09 2011 -0800 6.3 @@ -376,7 +376,8 @@ 6.4 new SimpleFileVisitor<Path>() { 6.5 @Override 6.6 public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { 6.7 - if (SourceVersion.isIdentifier(dir.getName().toString())) // JSR 292? 6.8 + Path name = dir.getName(); 6.9 + if (name == null || SourceVersion.isIdentifier(name.toString())) // JSR 292? 6.10 return FileVisitResult.CONTINUE; 6.11 else 6.12 return FileVisitResult.SKIP_SUBTREE;
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/test/tools/javac/6567415/T6567415.java Thu Jan 13 15:05:09 2011 -0800 7.3 @@ -0,0 +1,146 @@ 7.4 +/* 7.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.7 + * 7.8 + * This code is free software; you can redistribute it and/or modify it 7.9 + * under the terms of the GNU General Public License version 2 only, as 7.10 + * published by the Free Software Foundation. 7.11 + * 7.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 7.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 7.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 7.15 + * version 2 for more details (a copy is included in the LICENSE file that 7.16 + * accompanied this code). 7.17 + * 7.18 + * You should have received a copy of the GNU General Public License version 7.19 + * 2 along with this work; if not, write to the Free Software Foundation, 7.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 7.21 + * 7.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 7.23 + * or visit www.oracle.com if you need additional information or have any 7.24 + * questions. 7.25 + */ 7.26 + 7.27 +/* 7.28 + * @test 7.29 + * @bug 6567415 7.30 + * @summary Test to ensure javac does not go into an infinite loop, while 7.31 + * reading a classfile of a specific length. 7.32 + * @compile -XDignore.symbol.file T6567415.java 7.33 + * @run main T6567415 7.34 + * @author ksrini 7.35 + */ 7.36 + 7.37 +import java.io.File; 7.38 +import java.io.FileInputStream; 7.39 +import java.io.FileOutputStream; 7.40 +import java.io.IOException; 7.41 +import java.io.PrintStream; 7.42 +import java.io.RandomAccessFile; 7.43 +import java.nio.ByteBuffer; 7.44 +import java.nio.MappedByteBuffer; 7.45 +import java.nio.channels.FileChannel; 7.46 + 7.47 +/* 7.48 + * this test compiles Bar.java into a classfile and enlarges the file to the 7.49 + * magic file length, then use this mutated file on the classpath to compile 7.50 + * Foo.java which references Bar.java and Ka-boom. QED. 7.51 + */ 7.52 +public class T6567415 { 7.53 + final static String TEST_FILE_NAME = "Bar"; 7.54 + final static String TEST_JAVA = TEST_FILE_NAME + ".java"; 7.55 + final static String TEST_CLASS = TEST_FILE_NAME + ".class"; 7.56 + 7.57 + final static String TEST2_FILE_NAME = "Foo"; 7.58 + final static String TEST2_JAVA = TEST2_FILE_NAME + ".java"; 7.59 + 7.60 + /* 7.61 + * the following is the initial buffer length set in ClassReader.java 7.62 + * thus this value needs to change if ClassReader buf length changes. 7.63 + */ 7.64 + 7.65 + final static int BAD_FILE_LENGTH = 7.66 + com.sun.tools.javac.jvm.ClassReader.INITIAL_BUFFER_SIZE; 7.67 + 7.68 + static void createClassFile() throws IOException { 7.69 + FileOutputStream fos = null; 7.70 + try { 7.71 + fos = new FileOutputStream(TEST_JAVA); 7.72 + PrintStream ps = new PrintStream(fos); 7.73 + ps.println("public class " + TEST_FILE_NAME + " {}"); 7.74 + } finally { 7.75 + fos.close(); 7.76 + } 7.77 + String cmds[] = {TEST_JAVA}; 7.78 + com.sun.tools.javac.Main.compile(cmds); 7.79 + } 7.80 + 7.81 + static void enlargeClassFile() throws IOException { 7.82 + File f = new File(TEST_CLASS); 7.83 + if (!f.exists()) { 7.84 + System.out.println("file not found: " + TEST_CLASS); 7.85 + System.exit(1); 7.86 + } 7.87 + File tfile = new File(f.getAbsolutePath() + ".tmp"); 7.88 + f.renameTo(tfile); 7.89 + 7.90 + RandomAccessFile raf = null; 7.91 + FileChannel wfc = null; 7.92 + 7.93 + FileInputStream fis = null; 7.94 + FileChannel rfc = null; 7.95 + 7.96 + try { 7.97 + raf = new RandomAccessFile(f, "rw"); 7.98 + wfc = raf.getChannel(); 7.99 + 7.100 + fis = new FileInputStream(tfile); 7.101 + rfc = fis.getChannel(); 7.102 + 7.103 + ByteBuffer bb = MappedByteBuffer.allocate(BAD_FILE_LENGTH); 7.104 + rfc.read(bb); 7.105 + bb.rewind(); 7.106 + wfc.write(bb); 7.107 + wfc.truncate(BAD_FILE_LENGTH); 7.108 + } finally { 7.109 + wfc.close(); 7.110 + raf.close(); 7.111 + rfc.close(); 7.112 + fis.close(); 7.113 + } 7.114 + System.out.println("file length = " + f.length()); 7.115 + } 7.116 + 7.117 + static void createJavaFile() throws IOException { 7.118 + FileOutputStream fos = null; 7.119 + try { 7.120 + fos = new FileOutputStream(TEST2_JAVA); 7.121 + PrintStream ps = new PrintStream(fos); 7.122 + ps.println("public class " + TEST2_FILE_NAME + 7.123 + " {" + TEST_FILE_NAME + " b = new " + 7.124 + TEST_FILE_NAME + " ();}"); 7.125 + } finally { 7.126 + fos.close(); 7.127 + } 7.128 + } 7.129 + 7.130 + public static void main(String... args) throws Exception { 7.131 + createClassFile(); 7.132 + enlargeClassFile(); 7.133 + createJavaFile(); 7.134 + Thread t = new Thread () { 7.135 + @Override 7.136 + public void run() { 7.137 + String cmds[] = {"-verbose", "-cp", ".", TEST2_JAVA}; 7.138 + int ret = com.sun.tools.javac.Main.compile(cmds); 7.139 + System.out.println("test compilation returns: " + ret); 7.140 + } 7.141 + }; 7.142 + t.start(); 7.143 + t.join(1000*10); 7.144 + System.out.println(t.getState()); 7.145 + if (t.isAlive()) { 7.146 + throw new RuntimeException("Error: compilation is looping"); 7.147 + } 7.148 + } 7.149 +}
8.1 --- a/test/tools/javac/diags/examples/TypeParameterOnPolymorphicSignature.java Thu Jan 06 20:10:44 2011 -0800 8.2 +++ b/test/tools/javac/diags/examples/TypeParameterOnPolymorphicSignature.java Thu Jan 13 15:05:09 2011 -0800 8.3 @@ -24,8 +24,10 @@ 8.4 // key: compiler.warn.type.parameter.on.polymorphic.signature 8.5 // key: compiler.err.unreported.exception.need.to.catch.or.throw 8.6 8.7 -import java.dyn.InvokeDynamic; 8.8 +import java.dyn.MethodHandle; 8.9 8.10 class TypeParameterOnPolymorphicSignature { 8.11 - { InvokeDynamic.<void>call("",123); } 8.12 + void test(MethodHandle mh) { 8.13 + mh.<void>invokeExact("",123); 8.14 + } 8.15 }
9.1 --- a/test/tools/javac/failover/CheckAttributedTree.java Thu Jan 06 20:10:44 2011 -0800 9.2 +++ b/test/tools/javac/failover/CheckAttributedTree.java Thu Jan 13 15:05:09 2011 -0800 9.3 @@ -252,6 +252,13 @@ 9.4 error("File " + file + " ignored"); 9.5 } 9.6 9.7 + // See CR: 6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout 9.8 + StringWriter sw = new StringWriter(); 9.9 + PrintWriter pw = new PrintWriter(sw); 9.10 + Reporter r = new Reporter(pw); 9.11 + JavacTool tool = JavacTool.create(); 9.12 + StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); 9.13 + 9.14 /** 9.15 * Read a file. 9.16 * @param file the file to be read 9.17 @@ -260,12 +267,8 @@ 9.18 * @throws TreePosTest.ParseException if any errors occur while parsing the file 9.19 */ 9.20 List<Pair<JCCompilationUnit, JCTree>> read(File file) throws IOException, AttributionException { 9.21 - StringWriter sw = new StringWriter(); 9.22 - PrintWriter pw = new PrintWriter(sw); 9.23 - Reporter r = new Reporter(pw); 9.24 JavacTool tool = JavacTool.create(); 9.25 - Charset cs = (encoding == null ? null : Charset.forName(encoding)); 9.26 - StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); 9.27 + r.errors = 0; 9.28 Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file); 9.29 String[] opts = { "-XDshouldStopPolicy=ATTR", "-XDverboseCompilePolicy" }; 9.30 JavacTask task = tool.getTask(pw, fm, r, Arrays.asList(opts), null, files);
10.1 --- a/test/tools/javac/meth/InvokeDyn.java Thu Jan 06 20:10:44 2011 -0800 10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 10.3 @@ -1,64 +0,0 @@ 10.4 -/* 10.5 - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 10.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 - * 10.8 - * This code is free software; you can redistribute it and/or modify it 10.9 - * under the terms of the GNU General Public License version 2 only, as 10.10 - * published by the Free Software Foundation. 10.11 - * 10.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 10.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.15 - * version 2 for more details (a copy is included in the LICENSE file that 10.16 - * accompanied this code). 10.17 - * 10.18 - * You should have received a copy of the GNU General Public License version 10.19 - * 2 along with this work; if not, write to the Free Software Foundation, 10.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.21 - * 10.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 10.23 - * or visit www.oracle.com if you need additional information or have any 10.24 - * questions. 10.25 - */ 10.26 - 10.27 -/* 10.28 - * @test 10.29 - * @bug 6754038 6979327 10.30 - * @summary Generate call sites for method handle 10.31 - * @author jrose 10.32 - * 10.33 - * @library .. 10.34 - * @compile -source 7 -target 7 -XDinvokedynamic -XDallowTransitionalJSR292=no InvokeDyn.java 10.35 - */ 10.36 -//No: @run main/othervm -XX:+EnableInvokeDynamic meth.InvokeDyn 10.37 - 10.38 -/* 10.39 - * Standalone testing: 10.40 - * <code> 10.41 - * $ cd $MY_REPO_DIR/langtools 10.42 - * $ (cd make; make) 10.43 - * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeDyn.java 10.44 - * $ javap -c -classpath dist meth.InvokeDyn 10.45 - * </code> 10.46 - */ 10.47 - 10.48 -package meth; 10.49 - 10.50 -import java.dyn.*; 10.51 - 10.52 -public class InvokeDyn { 10.53 - class CS extends CallSite { 10.54 - CS(Object x, Object y, Object z) { throw new RuntimeException(); } 10.55 - } 10.56 - //@BootstrapMethod(CS.class) //note: requires 6964498 10.57 - void test() throws Throwable { 10.58 - Object x = "hello"; 10.59 - Object ojunk; int ijunk; 10.60 - ojunk = InvokeDynamic.greet(x, "world", 123); 10.61 - ojunk = InvokeDynamic.greet(x, "mundus", 456); 10.62 - ojunk = InvokeDynamic.greet(x, "kosmos", 789); 10.63 - ojunk = (String) InvokeDynamic.cogitate(10.11121, 3.14); 10.64 - //InvokeDynamic.#"yow: what I mean to say is, please treat this one specially"(null); 10.65 - ijunk = (int) InvokeDynamic.invoke("goodbye"); 10.66 - } 10.67 -}
11.1 --- a/test/tools/javac/meth/InvokeDynTrans.java Thu Jan 06 20:10:44 2011 -0800 11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 11.3 @@ -1,59 +0,0 @@ 11.4 -/* 11.5 - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 11.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.7 - * 11.8 - * This code is free software; you can redistribute it and/or modify it 11.9 - * under the terms of the GNU General Public License version 2 only, as 11.10 - * published by the Free Software Foundation. 11.11 - * 11.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 11.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.15 - * version 2 for more details (a copy is included in the LICENSE file that 11.16 - * accompanied this code). 11.17 - * 11.18 - * You should have received a copy of the GNU General Public License version 11.19 - * 2 along with this work; if not, write to the Free Software Foundation, 11.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.21 - * 11.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 11.23 - * or visit www.oracle.com if you need additional information or have any 11.24 - * questions. 11.25 - */ 11.26 - 11.27 -/* 11.28 - * @test 11.29 - * @bug 6754038 6979327 11.30 - * @summary Generate call sites for method handle 11.31 - * @author jrose 11.32 - * 11.33 - * @library .. 11.34 - * @compile/fail/ref=InvokeDynTrans.out -Werror -XDrawDiagnostics -source 7 -target 7 InvokeDynTrans.java 11.35 - */ 11.36 -//No: @run main/othervm -XX:+EnableInvokeDynamic meth.InvokeDyn 11.37 - 11.38 -/* 11.39 - * Standalone testing: 11.40 - * <code> 11.41 - * $ cd $MY_REPO_DIR/langtools 11.42 - * $ (cd make; make) 11.43 - * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeDyn.java 11.44 - * $ javap -c -classpath dist meth.InvokeDyn 11.45 - * </code> 11.46 - */ 11.47 - 11.48 -package meth; 11.49 - 11.50 -import java.dyn.InvokeDynamic; 11.51 - 11.52 -public class InvokeDynTrans { 11.53 - void test() throws Throwable { 11.54 - Object x = "hello"; 11.55 - InvokeDynamic.greet(x, "world", 123); 11.56 - InvokeDynamic.greet(x, "mundus", 456); 11.57 - InvokeDynamic.greet(x, "kosmos", 789); 11.58 - InvokeDynamic.<String>cogitate(10.11121, 3.14); 11.59 - //InvokeDynamic.<void>#"yow: what I mean to say is, please treat this one specially"(null); 11.60 - InvokeDynamic.<int>invoke("goodbye"); 11.61 - } 11.62 -}
12.1 --- a/test/tools/javac/meth/XlintWarn.java Thu Jan 06 20:10:44 2011 -0800 12.2 +++ b/test/tools/javac/meth/XlintWarn.java Thu Jan 13 15:05:09 2011 -0800 12.3 @@ -23,7 +23,7 @@ 12.4 12.5 /* 12.6 * @test 12.7 - * @bug 6999067 12.8 + * @bug 6999067 7010194 12.9 * @summary cast for invokeExact call gets redundant cast to <type> warnings 12.10 * @author mcimadamore 12.11 * 12.12 @@ -34,9 +34,7 @@ 12.13 12.14 class XlintWarn { 12.15 void test(MethodHandle mh) throws Throwable { 12.16 - int i1 = (int)mh.invoke(); 12.17 - int i2 = (int)mh.invokeExact(); 12.18 - int i3 = (int)mh.invokeVarargs(); 12.19 - int i4 = (int)InvokeDynamic.test(); 12.20 + int i1 = (int)mh.invokeExact(); 12.21 + int i2 = (int)mh.invokeVarargs(); 12.22 } 12.23 }
13.1 --- a/test/tools/javac/nio/compileTest/CompileTest.java Thu Jan 06 20:10:44 2011 -0800 13.2 +++ b/test/tools/javac/nio/compileTest/CompileTest.java Thu Jan 13 15:05:09 2011 -0800 13.3 @@ -23,7 +23,7 @@ 13.4 13.5 /** 13.6 * @test 13.7 - * @bug 6906175 6915476 6915497 13.8 + * @bug 6906175 6915476 6915497 7006564 13.9 * @summary Path-based JavaFileManager 13.10 * @compile -g HelloPathWorld.java 13.11 * @run main CompileTest
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/test/tools/javac/processing/filer/TestValidRelativeNames.java Thu Jan 13 15:05:09 2011 -0800 14.3 @@ -0,0 +1,136 @@ 14.4 +/* 14.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.7 + * 14.8 + * This code is free software; you can redistribute it and/or modify it 14.9 + * under the terms of the GNU General Public License version 2 only, as 14.10 + * published by the Free Software Foundation. 14.11 + * 14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14.15 + * version 2 for more details (a copy is included in the LICENSE file that 14.16 + * accompanied this code). 14.17 + * 14.18 + * You should have received a copy of the GNU General Public License version 14.19 + * 2 along with this work; if not, write to the Free Software Foundation, 14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 14.21 + * 14.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 14.23 + * or visit www.oracle.com if you need additional information or have any 14.24 + * questions. 14.25 + */ 14.26 + 14.27 +/* 14.28 + * @test 14.29 + * @bug 6999891 14.30 + * @summary Test valid relative names for Filer.createResource and Filer.getResource 14.31 + * @library ../../lib 14.32 + * @build JavacTestingAbstractProcessor 14.33 + * @compile TestValidRelativeNames.java 14.34 + * @compile/process -processor TestValidRelativeNames -Amode=create java.lang.Object 14.35 + * @compile/process -processor TestValidRelativeNames -Amode=get java.lang.Object 14.36 + */ 14.37 + 14.38 +import java.io.*; 14.39 +import java.util.*; 14.40 +import javax.annotation.processing.*; 14.41 +import javax.lang.model.*; 14.42 +import javax.lang.model.element.*; 14.43 +import javax.tools.Diagnostic; 14.44 +import javax.tools.StandardLocation; 14.45 + 14.46 +@SupportedOptions("mode") 14.47 +public class TestValidRelativeNames extends JavacTestingAbstractProcessor { 14.48 + enum Kind { READER_WRITER, INPUT_OUTPUT_STREAM }; 14.49 + 14.50 + static final String[] validRelativeNames = { 14.51 + "foo", "foo.bar", ".foo", ".foo.bar", "foodir/bar", "foodir/.bar" 14.52 + }; 14.53 + 14.54 + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 14.55 + if (roundEnv.processingOver()) { 14.56 + String mode = options.get("mode"); 14.57 + for (String relativeBase: validRelativeNames) { 14.58 + for (Kind kind: Kind.values()) { 14.59 + if (mode.equals("create")) 14.60 + testCreate(relativeBase, kind); 14.61 + else 14.62 + testGet(relativeBase, kind); 14.63 + } 14.64 + } 14.65 + } 14.66 + 14.67 + return true; 14.68 + } 14.69 + 14.70 + void testCreate(String relativeBase, Kind kind) { 14.71 + String relative = getRelative(relativeBase, kind); 14.72 + System.out.println("test create relative path: " + relative + ", kind: " + kind); 14.73 + try { 14.74 + switch (kind) { 14.75 + case READER_WRITER: 14.76 + try (Writer writer = filer.createResource( 14.77 + StandardLocation.CLASS_OUTPUT, "", relative).openWriter()) { 14.78 + writer.write(relative); 14.79 + } 14.80 + break; 14.81 + 14.82 + case INPUT_OUTPUT_STREAM: 14.83 + try (OutputStream out = filer.createResource( 14.84 + StandardLocation.CLASS_OUTPUT, "", relative).openOutputStream()) { 14.85 + out.write(relative.getBytes()); 14.86 + } 14.87 + break; 14.88 + } 14.89 + } catch (Exception e) { 14.90 + messager.printMessage(Diagnostic.Kind.ERROR, 14.91 + "relative path: " + relative + ", kind: " + kind + ", unexpected exception: " + e); 14.92 + } 14.93 + } 14.94 + 14.95 + void testGet(String relativeBase, Kind kind) { 14.96 + String relative = getRelative(relativeBase, kind); 14.97 + System.out.println("test get relative path: " + relative + ", kind: " + kind); 14.98 + try { 14.99 + switch (kind) { 14.100 + case READER_WRITER: 14.101 + try (Reader reader = new BufferedReader(filer.getResource( 14.102 + StandardLocation.CLASS_OUTPUT, "", relative).openReader(true))) { 14.103 + StringBuilder sb = new StringBuilder(); 14.104 + char[] buf = new char[1024]; 14.105 + int n; 14.106 + while ((n = reader.read(buf, 0, buf.length)) > 0) 14.107 + sb.append(new String(buf, 0, n)); 14.108 + if (!sb.toString().equals(relative)) { 14.109 + messager.printMessage(Diagnostic.Kind.ERROR, "unexpected content: " + sb); 14.110 + } 14.111 + } 14.112 + break; 14.113 + 14.114 + case INPUT_OUTPUT_STREAM: 14.115 + try (InputStream in = new DataInputStream(filer.getResource( 14.116 + StandardLocation.CLASS_OUTPUT, "", relative).openInputStream())) { 14.117 + StringBuilder sb = new StringBuilder(); 14.118 + byte[] buf = new byte[1024]; 14.119 + int n; 14.120 + while ((n = in.read(buf, 0, buf.length)) > 0) 14.121 + sb.append(new String(buf, 0, n)); 14.122 + if (!sb.toString().equals(relative)) { 14.123 + messager.printMessage(Diagnostic.Kind.ERROR, "unexpected content: " + sb); 14.124 + } 14.125 + } 14.126 + break; 14.127 + } 14.128 + } catch (Exception e) { 14.129 + messager.printMessage(Diagnostic.Kind.ERROR, 14.130 + "relative path: " + relative + ", kind: " + kind + ", unexpected exception: " + e); 14.131 + } 14.132 + } 14.133 + 14.134 + String getRelative(String relativeBase, Kind kind) { 14.135 + String suffix = (kind == Kind.READER_WRITER ? "RW" : "IOS"); 14.136 + return relativeBase.replace("foo", "foo" + suffix); 14.137 + } 14.138 +} 14.139 +
15.1 --- a/test/tools/javac/tree/AbstractTreeScannerTest.java Thu Jan 06 20:10:44 2011 -0800 15.2 +++ b/test/tools/javac/tree/AbstractTreeScannerTest.java Thu Jan 13 15:05:09 2011 -0800 15.3 @@ -143,6 +143,13 @@ 15.4 15.5 abstract int test(JCCompilationUnit t); 15.6 15.7 + // See CR: 6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout 15.8 + StringWriter sw = new StringWriter(); 15.9 + PrintWriter pw = new PrintWriter(sw); 15.10 + Reporter r = new Reporter(pw); 15.11 + JavacTool tool = JavacTool.create(); 15.12 + StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); 15.13 + 15.14 /** 15.15 * Read a file. 15.16 * @param file the file to be read 15.17 @@ -151,11 +158,8 @@ 15.18 * @throws TreePosTest.ParseException if any errors occur while parsing the file 15.19 */ 15.20 JCCompilationUnit read(File file) throws IOException, ParseException { 15.21 - StringWriter sw = new StringWriter(); 15.22 - PrintWriter pw = new PrintWriter(sw); 15.23 - Reporter r = new Reporter(pw); 15.24 JavacTool tool = JavacTool.create(); 15.25 - StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); 15.26 + r.errors = 0; 15.27 Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file); 15.28 JavacTask task = tool.getTask(pw, fm, r, Collections.<String>emptyList(), null, files); 15.29 Iterable<? extends CompilationUnitTree> trees = task.parse();
16.1 --- a/test/tools/javac/tree/TreePosTest.java Thu Jan 06 20:10:44 2011 -0800 16.2 +++ b/test/tools/javac/tree/TreePosTest.java Thu Jan 13 15:05:09 2011 -0800 16.3 @@ -249,6 +249,13 @@ 16.4 error("File " + file + " ignored"); 16.5 } 16.6 16.7 + // See CR: 6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout 16.8 + StringWriter sw = new StringWriter(); 16.9 + PrintWriter pw = new PrintWriter(sw); 16.10 + Reporter r = new Reporter(pw); 16.11 + JavacTool tool = JavacTool.create(); 16.12 + StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); 16.13 + 16.14 /** 16.15 * Read a file. 16.16 * @param file the file to be read 16.17 @@ -257,12 +264,8 @@ 16.18 * @throws TreePosTest.ParseException if any errors occur while parsing the file 16.19 */ 16.20 JCCompilationUnit read(File file) throws IOException, ParseException { 16.21 - StringWriter sw = new StringWriter(); 16.22 - PrintWriter pw = new PrintWriter(sw); 16.23 - Reporter r = new Reporter(pw); 16.24 JavacTool tool = JavacTool.create(); 16.25 - Charset cs = (encoding == null ? null : Charset.forName(encoding)); 16.26 - StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); 16.27 + r.errors = 0; 16.28 Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file); 16.29 JavacTask task = tool.getTask(pw, fm, r, Collections.<String>emptyList(), null, files); 16.30 Iterable<? extends CompilationUnitTree> trees = task.parse();