Ignore:
Timestamp:
Feb 13, 2012, 10:07:12 PM (14 years ago)
Author:
dmik
Message:

trunk: Merged in openjdk6 b24 from branches/vendor/oracle.

Location:
trunk/openjdk
Files:
11 edited
5 copied

Legend:

Unmodified
Added
Removed
  • trunk/openjdk

  • trunk/openjdk/langtools/make/netbeans/langtools/build.xml

    r278 r309  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<!--
    3  Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
     3 Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
    44
    55 Redistribution and use in source and binary forms, with or without
  • trunk/openjdk/langtools/make/netbeans/langtools/nbproject/project.xml

    r278 r309  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<!--
    3  Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
     3 Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
    44
    55 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  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<!--
    3  Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
     3 Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
    44
    55 Redistribution and use in source and binary forms, with or without
  • trunk/openjdk/langtools/make/netbeans/langtools/nbproject/standard-ide-actions.ent

    r278 r309  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<!--
    3  Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
     3 Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
    44
    55 Redistribution and use in source and binary forms, with or without
  • trunk/openjdk/langtools/make/tools/SelectTool/SelectToolTask.java

    r278 r309  
    11/*
    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.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/langtools/src/share/classes/com/sun/tools/javac/code/Types.java

    r278 r309  
    302302        } else if (isSubtype(t, s)) {
    303303            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()) {
    305309            Type t2 = asSuper(t, s.tsym);
    306310            if (t2 != null && t2.isRaw()) {
  • trunk/openjdk/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java

    r278 r309  
    11/*
    2  * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2626package com.sun.tools.javac.file;
    2727
     28import java.util.Comparator;
    2829import java.io.ByteArrayOutputStream;
    2930import java.io.File;
     
    111112    protected boolean ignoreSymbolFile;
    112113
     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
    113128    /**
    114129     * Register a Context.Factory to create a JavacFileManager.
     
    153168        mmappedIO = options.get("mmappedIO") != null;
    154169        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
    155176    }
    156177
     
    242263    }
    243264
    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
    247269     */
    248270    private void listDirectory(File directory,
     
    250272                               Set<JavaFileObject.Kind> fileKinds,
    251273                               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);
    265295                }
    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);
    275301                }
    276302            }
    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));
    285322                }
    286323            }
    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);
    290356                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));
    294365                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);
    315373    }
    316374
     
    407465            = new RelativeDirectory("META-INF/sym/rt.jar/");
    408466
    409     /** Open a new zip file directory.
     467    /** Open a new zip file directory, and cache it.
    410468     */
    411469    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);
    450503                        }
    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;
    459515                        }
    460516                    }
    461517                }
    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,
    468525                                ZipFileIndex.getZipFileIndex(zipFileName,
    469526                                    null,
     
    471528                                    preindexCacheLocation,
    472529                                    options.get("writezipindexfiles") != null));
    473                     }
     530                }
     531            } else {
     532                if (!useZipFileIndex) {
     533                    archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix);
    474534                }
    475535                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,
    481537                                ZipFileIndex.getZipFileIndex(zipFileName,
    482538                                    symbolFilePrefix,
     
    484540                                    preindexCacheLocation,
    485541                                    options.get("writezipindexfiles") != null));
    486                     }
    487542                }
    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);
    498553        return archive;
    499554    }
     
    562617
    563618        for (File directory : path)
    564             listDirectory(directory, subdirectory, kinds, recurse, results);
    565 
     619            listContainer(directory, subdirectory, kinds, recurse, results);
    566620        return results.toList();
    567621    }
     
    606660        nullCheck(kind);
    607661        if (!sourceOrClass.contains(kind))
    608             throw new IllegalArgumentException("Invalid kind " + kind);
     662            throw new IllegalArgumentException("Invalid kind: " + kind);
    609663        return getFileForInput(location, RelativeFile.forClass(className, kind));
    610664    }
     
    632686
    633687        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;
    642695                }
    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        }
    647704        return null;
    648705    }
     
    659716        nullCheck(kind);
    660717        if (!sourceOrClass.contains(kind))
    661             throw new IllegalArgumentException("Invalid kind " + kind);
     718            throw new IllegalArgumentException("Invalid kind: " + kind);
    662719        return getFileForOutput(location, RelativeFile.forClass(className, kind), sibling);
    663720    }
     
    673730        nullCheck(packageName);
    674731        if (!isRelativeUri(relativeName))
    675             throw new IllegalArgumentException("relativeName is invalid");
     732            throw new IllegalArgumentException("Invalid relative name: " + relativeName);
    676733        RelativeFile name = packageName.length() == 0
    677734            ? new RelativeFile(relativeName)
     
    807864        if (path.length() == 0 /* isEmpty() is mustang API */)
    808865            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;
    811871    }
    812872
  • trunk/openjdk/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java

    r278 r309  
    11/*
    2  * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    273273
    274274        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
    278277                return;
    279278            }
     
    283282                if (warn)
    284283                    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)) {
    286295                /* File is an ordinary file. */
    287296                if (!isArchive(file)) {
     
    303312
    304313            /* Now what we have left is either a directory or a file name
    305                confirming to archive naming convention */
     314               conforming to archive naming convention */
    306315            super.add(file);
    307316            canonicalValues.add(canonFile);
    308317
    309             if (expandJarClassPaths && fsInfo.exists(file) && fsInfo.isFile(file))
     318            if (expandJarClassPaths && fsInfo.isFile(file))
    310319                addJarClassPath(file, warn);
    311320        }
  • trunk/openjdk/langtools/test/tools/javac/6889255/T6889255.java

    r278 r309  
    11/*
    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.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/langtools/test/tools/javac/T6595666.java

    r278 r309  
    11/*
    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.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
Note: See TracChangeset for help on using the changeset viewer.