Changeset 309 for trunk/openjdk/langtools
- Timestamp:
- Feb 13, 2012, 10:07:12 PM (14 years ago)
- Location:
- trunk/openjdk
- Files:
-
- 11 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/openjdk
- Property svn:mergeinfo changed
/branches/vendor/oracle/openjdk6/b24 (added) merged: 308 /branches/vendor/oracle/openjdk6/current merged: 307
- Property svn:mergeinfo changed
-
trunk/openjdk/langtools/make/netbeans/langtools/build.xml
r278 r309 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <!-- 3 Copyright (c) 2007, 20 08, Oracle and/or its affiliates. All rights reserved.3 Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 4 4 5 5 Redistribution and use in source and binary forms, with or without -
trunk/openjdk/langtools/make/netbeans/langtools/nbproject/project.xml
r278 r309 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <!-- 3 Copyright (c) 2007, 20 08, Oracle and/or its affiliates. All rights reserved.3 Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 4 4 5 5 Redistribution and use in source and binary forms, with or without -
trunk/openjdk/langtools/make/netbeans/langtools/nbproject/standard-context-menu-items.ent
r278 r309 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <!-- 3 Copyright (c) 2007, 20 08, Oracle and/or its affiliates. All rights reserved.3 Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 4 4 5 5 Redistribution and use in source and binary forms, with or without -
trunk/openjdk/langtools/make/netbeans/langtools/nbproject/standard-ide-actions.ent
r278 r309 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <!-- 3 Copyright (c) 2007, 20 08, Oracle and/or its affiliates. All rights reserved.3 Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 4 4 5 5 Redistribution and use in source and binary forms, with or without -
trunk/openjdk/langtools/make/tools/SelectTool/SelectToolTask.java
r278 r309 1 1 /* 2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/langtools/src/share/classes/com/sun/tools/javac/code/Types.java
r278 r309 302 302 } else if (isSubtype(t, s)) { 303 303 return true; 304 } else if (!s.isRaw()) { 304 } 305 else if (t.tag == TYPEVAR) { 306 return isSubtypeUnchecked(t.getUpperBound(), s, warn); 307 } 308 else if (!s.isRaw()) { 305 309 Type t2 = asSuper(t, s.tsym); 306 310 if (t2 != null && t2.isRaw()) { -
trunk/openjdk/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
r278 r309 1 1 /* 2 * Copyright (c) 2005, 20 09, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 26 26 package com.sun.tools.javac.file; 27 27 28 import java.util.Comparator; 28 29 import java.io.ByteArrayOutputStream; 29 30 import java.io.File; … … 111 112 protected boolean ignoreSymbolFile; 112 113 114 protected enum SortFiles implements Comparator<File> { 115 FORWARD { 116 public int compare(File f1, File f2) { 117 return f1.getName().compareTo(f2.getName()); 118 } 119 }, 120 REVERSE { 121 public int compare(File f1, File f2) { 122 return -f1.getName().compareTo(f2.getName()); 123 } 124 }; 125 }; 126 protected SortFiles sortFiles; 127 113 128 /** 114 129 * Register a Context.Factory to create a JavacFileManager. … … 153 168 mmappedIO = options.get("mmappedIO") != null; 154 169 ignoreSymbolFile = options.get("ignore.symbol.file") != null; 170 171 String sf = options.get("sortFiles"); 172 if (sf != null) { 173 sortFiles = (sf.equals("reverse") ? SortFiles.REVERSE : SortFiles.FORWARD); 174 } 175 155 176 } 156 177 … … 242 263 } 243 264 244 /** 245 * Insert all files in subdirectory `subdirectory' of `directory' which end 246 * in one of the extensions in `extensions' into packageSym. 265 266 /** 267 * Insert all files in subdirectory subdirectory of directory directory 268 * which match fileKinds into resultList 247 269 */ 248 270 private void listDirectory(File directory, … … 250 272 Set<JavaFileObject.Kind> fileKinds, 251 273 boolean recurse, 252 ListBuffer<JavaFileObject> l) { 253 Archive archive = archives.get(directory); 254 255 boolean isFile = fsInfo.isFile(directory); 256 257 if (archive != null || isFile) { 258 if (archive == null) { 259 try { 260 archive = openArchive(directory); 261 } catch (IOException ex) { 262 log.error("error.reading.file", 263 directory, getMessage(ex)); 264 return; 274 ListBuffer<JavaFileObject> resultList) { 275 File d = subdirectory.getFile(directory); 276 if (!caseMapCheck(d, subdirectory)) 277 return; 278 279 File[] files = d.listFiles(); 280 if (files == null) 281 return; 282 283 if (sortFiles != null) 284 Arrays.sort(files, sortFiles); 285 286 for (File f: files) { 287 String fname = f.getName(); 288 if (f.isDirectory()) { 289 if (recurse && SourceVersion.isIdentifier(fname)) { 290 listDirectory(directory, 291 new RelativeDirectory(subdirectory, fname), 292 fileKinds, 293 recurse, 294 resultList); 265 295 } 266 } 267 268 List<String> files = archive.getFiles(subdirectory); 269 if (files != null) { 270 for (String file; !files.isEmpty(); files = files.tail) { 271 file = files.head; 272 if (isValidFile(file, fileKinds)) { 273 l.append(archive.getFileObject(subdirectory, file)); 274 } 296 } else { 297 if (isValidFile(fname, fileKinds)) { 298 JavaFileObject fe = 299 new RegularFileObject(this, fname, new File(d, fname)); 300 resultList.append(fe); 275 301 } 276 302 } 277 if (recurse) { 278 for (RelativeDirectory s: archive.getSubdirectories()) { 279 if (subdirectory.contains(s)) { 280 // Because the archive map is a flat list of directories, 281 // the enclosing loop will pick up all child subdirectories. 282 // Therefore, there is no need to recurse deeper. 283 listDirectory(directory, s, fileKinds, false, l); 284 } 303 } 304 } 305 306 /** 307 * Insert all files in subdirectory subdirectory of archive archive 308 * which match fileKinds into resultList 309 */ 310 private void listArchive(Archive archive, 311 RelativeDirectory subdirectory, 312 Set<JavaFileObject.Kind> fileKinds, 313 boolean recurse, 314 ListBuffer<JavaFileObject> resultList) { 315 // Get the files directly in the subdir 316 List<String> files = archive.getFiles(subdirectory); 317 if (files != null) { 318 for (; !files.isEmpty(); files = files.tail) { 319 String file = files.head; 320 if (isValidFile(file, fileKinds)) { 321 resultList.append(archive.getFileObject(subdirectory, file)); 285 322 } 286 323 } 287 } else { 288 File d = subdirectory.getFile(directory); 289 if (!caseMapCheck(d, subdirectory)) 324 } 325 if (recurse) { 326 for (RelativeDirectory s: archive.getSubdirectories()) { 327 if (subdirectory.contains(s)) { 328 // Because the archive map is a flat list of directories, 329 // the enclosing loop will pick up all child subdirectories. 330 // Therefore, there is no need to recurse deeper. 331 listArchive(archive, s, fileKinds, false, resultList); 332 } 333 } 334 } 335 } 336 337 /** 338 * container is a directory, a zip file, or a non-existant path. 339 * Insert all files in subdirectory subdirectory of container which 340 * match fileKinds into resultList 341 */ 342 private void listContainer(File container, 343 RelativeDirectory subdirectory, 344 Set<JavaFileObject.Kind> fileKinds, 345 boolean recurse, 346 ListBuffer<JavaFileObject> resultList) { 347 Archive archive = archives.get(container); 348 if (archive == null) { 349 // archives are not created for directories. 350 if (fsInfo.isDirectory(container)) { 351 listDirectory(container, 352 subdirectory, 353 fileKinds, 354 recurse, 355 resultList); 290 356 return; 291 292 File[] files = d.listFiles(); 293 if (files == null) 357 } 358 359 // Not a directory; either a file or non-existant, create the archive 360 try { 361 archive = openArchive(container); 362 } catch (IOException ex) { 363 log.error("error.reading.file", 364 container, getMessage(ex)); 294 365 return; 295 296 for (File f: files) { 297 String fname = f.getName(); 298 if (f.isDirectory()) { 299 if (recurse && SourceVersion.isIdentifier(fname)) { 300 listDirectory(directory, 301 new RelativeDirectory(subdirectory, fname), 302 fileKinds, 303 recurse, 304 l); 305 } 306 } else { 307 if (isValidFile(fname, fileKinds)) { 308 JavaFileObject fe = 309 new RegularFileObject(this, fname, new File(d, fname)); 310 l.append(fe); 311 } 312 } 313 } 314 } 366 } 367 } 368 listArchive(archive, 369 subdirectory, 370 fileKinds, 371 recurse, 372 resultList); 315 373 } 316 374 … … 407 465 = new RelativeDirectory("META-INF/sym/rt.jar/"); 408 466 409 /** Open a new zip file directory .467 /** Open a new zip file directory, and cache it. 410 468 */ 411 469 protected Archive openArchive(File zipFileName) throws IOException { 412 Archive archive = archives.get(zipFileName); 413 if (archive == null) { 414 File origZipFileName = zipFileName; 415 if (!ignoreSymbolFile && paths.isBootClassPathRtJar(zipFileName)) { 416 File file = zipFileName.getParentFile().getParentFile(); // ${java.home} 417 if (new File(file.getName()).equals(new File("jre"))) 418 file = file.getParentFile(); 419 // file == ${jdk.home} 420 for (String name : symbolFileLocation) 421 file = new File(file, name); 422 // file == ${jdk.home}/lib/ct.sym 423 if (file.exists()) 424 zipFileName = file; 425 } 426 427 try { 428 429 ZipFile zdir = null; 430 431 boolean usePreindexedCache = false; 432 String preindexCacheLocation = null; 433 434 if (!useZipFileIndex) { 435 zdir = new ZipFile(zipFileName); 436 } 437 else { 438 usePreindexedCache = options.get("usezipindex") != null; 439 preindexCacheLocation = options.get("java.io.tmpdir"); 440 String optCacheLoc = options.get("cachezipindexdir"); 441 442 if (optCacheLoc != null && optCacheLoc.length() != 0) { 443 if (optCacheLoc.startsWith("\"")) { 444 if (optCacheLoc.endsWith("\"")) { 445 optCacheLoc = optCacheLoc.substring(1, optCacheLoc.length() - 1); 446 } 447 else { 448 optCacheLoc = optCacheLoc.substring(1); 449 } 470 File origZipFileName = zipFileName; 471 if (!ignoreSymbolFile && paths.isBootClassPathRtJar(zipFileName)) { 472 File file = zipFileName.getParentFile().getParentFile(); // ${java.home} 473 if (new File(file.getName()).equals(new File("jre"))) 474 file = file.getParentFile(); 475 // file == ${jdk.home} 476 for (String name : symbolFileLocation) 477 file = new File(file, name); 478 // file == ${jdk.home}/lib/ct.sym 479 if (file.exists()) 480 zipFileName = file; 481 } 482 483 Archive archive; 484 try { 485 486 ZipFile zdir = null; 487 488 boolean usePreindexedCache = false; 489 String preindexCacheLocation = null; 490 491 if (!useZipFileIndex) { 492 zdir = new ZipFile(zipFileName); 493 } 494 else { 495 usePreindexedCache = options.get("usezipindex") != null; 496 preindexCacheLocation = options.get("java.io.tmpdir"); 497 String optCacheLoc = options.get("cachezipindexdir"); 498 499 if (optCacheLoc != null && optCacheLoc.length() != 0) { 500 if (optCacheLoc.startsWith("\"")) { 501 if (optCacheLoc.endsWith("\"")) { 502 optCacheLoc = optCacheLoc.substring(1, optCacheLoc.length() - 1); 450 503 } 451 452 File cacheDir = new File(optCacheLoc); 453 if (cacheDir.exists() && cacheDir.canWrite()) { 454 preindexCacheLocation = optCacheLoc; 455 if (!preindexCacheLocation.endsWith("/") && 456 !preindexCacheLocation.endsWith(File.separator)) { 457 preindexCacheLocation += File.separator; 458 } 504 else { 505 optCacheLoc = optCacheLoc.substring(1); 506 } 507 } 508 509 File cacheDir = new File(optCacheLoc); 510 if (cacheDir.exists() && cacheDir.canWrite()) { 511 preindexCacheLocation = optCacheLoc; 512 if (!preindexCacheLocation.endsWith("/") && 513 !preindexCacheLocation.endsWith(File.separator)) { 514 preindexCacheLocation += File.separator; 459 515 } 460 516 } 461 517 } 462 463 if (origZipFileName == zipFileName) { 464 if (!useZipFileIndex) { 465 archive = new ZipArchive(this, zdir); 466 } else { 467 archive = new ZipFileIndexArchive(this, 518 } 519 520 if (origZipFileName == zipFileName) { 521 if (!useZipFileIndex) { 522 archive = new ZipArchive(this, zdir); 523 } else { 524 archive = new ZipFileIndexArchive(this, 468 525 ZipFileIndex.getZipFileIndex(zipFileName, 469 526 null, … … 471 528 preindexCacheLocation, 472 529 options.get("writezipindexfiles") != null)); 473 } 530 } 531 } else { 532 if (!useZipFileIndex) { 533 archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix); 474 534 } 475 535 else { 476 if (!useZipFileIndex) { 477 archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix); 478 } 479 else { 480 archive = new ZipFileIndexArchive(this, 536 archive = new ZipFileIndexArchive(this, 481 537 ZipFileIndex.getZipFileIndex(zipFileName, 482 538 symbolFilePrefix, … … 484 540 preindexCacheLocation, 485 541 options.get("writezipindexfiles") != null)); 486 }487 542 } 488 } catch (FileNotFoundException ex) {489 archive = new MissingArchive(zipFileName);490 } catch (IOException ex) {491 if (zipFileName.exists())492 log.error("error.reading.file", zipFileName, getMessage(ex));493 archive = new MissingArchive(zipFileName);494 }495 496 archives.put(origZipFileName, archive); 497 }543 } 544 } catch (FileNotFoundException ex) { 545 archive = new MissingArchive(zipFileName); 546 } catch (IOException ex) { 547 if (zipFileName.exists()) 548 log.error("error.reading.file", zipFileName, getMessage(ex)); 549 archive = new MissingArchive(zipFileName); 550 } 551 552 archives.put(origZipFileName, archive); 498 553 return archive; 499 554 } … … 562 617 563 618 for (File directory : path) 564 listDirectory(directory, subdirectory, kinds, recurse, results); 565 619 listContainer(directory, subdirectory, kinds, recurse, results); 566 620 return results.toList(); 567 621 } … … 606 660 nullCheck(kind); 607 661 if (!sourceOrClass.contains(kind)) 608 throw new IllegalArgumentException("Invalid kind " + kind);662 throw new IllegalArgumentException("Invalid kind: " + kind); 609 663 return getFileForInput(location, RelativeFile.forClass(className, kind)); 610 664 } … … 632 686 633 687 for (File dir: path) { 634 if (dir.isDirectory()) { 635 File f = name.getFile(dir); 636 if (f.exists()) 637 return new RegularFileObject(this, f); 638 } else { 639 Archive a = openArchive(dir); 640 if (a.contains(name)) { 641 return a.getFileObject(name.dirname(), name.basename()); 688 Archive a = archives.get(dir); 689 if (a == null) { 690 if (fsInfo.isDirectory(dir)) { 691 File f = name.getFile(dir); 692 if (f.exists()) 693 return new RegularFileObject(this, f); 694 continue; 642 695 } 643 644 } 645 } 646 696 // Not a directory, create the archive 697 a = openArchive(dir); 698 } 699 // Process the archive 700 if (a.contains(name)) { 701 return a.getFileObject(name.dirname(), name.basename()); 702 } 703 } 647 704 return null; 648 705 } … … 659 716 nullCheck(kind); 660 717 if (!sourceOrClass.contains(kind)) 661 throw new IllegalArgumentException("Invalid kind " + kind);718 throw new IllegalArgumentException("Invalid kind: " + kind); 662 719 return getFileForOutput(location, RelativeFile.forClass(className, kind), sibling); 663 720 } … … 673 730 nullCheck(packageName); 674 731 if (!isRelativeUri(relativeName)) 675 throw new IllegalArgumentException(" relativeName is invalid");732 throw new IllegalArgumentException("Invalid relative name: " + relativeName); 676 733 RelativeFile name = packageName.length() == 0 677 734 ? new RelativeFile(relativeName) … … 807 864 if (path.length() == 0 /* isEmpty() is mustang API */) 808 865 return false; 809 char first = path.charAt(0); 810 return first != '.' && first != '/'; 866 if (!path.equals(uri.getPath())) // implicitly checks for embedded . and .. 867 return false; 868 if (path.startsWith("/") || path.startsWith("./") || path.startsWith("../")) 869 return false; 870 return true; 811 871 } 812 872 -
trunk/openjdk/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java
r278 r309 1 1 /* 2 * Copyright (c) 2003, 20 08, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 273 273 274 274 public void addFile(File file, boolean warn) { 275 File canonFile = fsInfo.getCanonicalFile(file); 276 if (contains(file) || canonicalValues.contains(canonFile)) { 277 /* Discard duplicates and avoid infinite recursion */ 275 if (contains(file)) { 276 // discard duplicates 278 277 return; 279 278 } … … 283 282 if (warn) 284 283 log.warning("path.element.not.found", file); 285 } else if (fsInfo.isFile(file)) { 284 super.add(file); 285 return; 286 } 287 288 File canonFile = fsInfo.getCanonicalFile(file); 289 if (canonicalValues.contains(canonFile)) { 290 /* Discard duplicates and avoid infinite recursion */ 291 return; 292 } 293 294 if (fsInfo.isFile(file)) { 286 295 /* File is an ordinary file. */ 287 296 if (!isArchive(file)) { … … 303 312 304 313 /* Now what we have left is either a directory or a file name 305 conf irming to archive naming convention */314 conforming to archive naming convention */ 306 315 super.add(file); 307 316 canonicalValues.add(canonFile); 308 317 309 if (expandJarClassPaths && fsInfo. exists(file) && fsInfo.isFile(file))318 if (expandJarClassPaths && fsInfo.isFile(file)) 310 319 addJarClassPath(file, warn); 311 320 } -
trunk/openjdk/langtools/test/tools/javac/6889255/T6889255.java
r278 r309 1 1 /* 2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/langtools/test/tools/javac/T6595666.java
r278 r309 1 1 /* 2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 *
Note:
See TracChangeset
for help on using the changeset viewer.