Index: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java,v retrieving revision 1.31 diff -u -r1.31 ClasspathDirectory.java --- batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java 23 Feb 2005 02:47:58 -0000 1.31 +++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java 16 May 2005 17:01:14 -0000 @@ -14,10 +14,10 @@ import java.util.Hashtable; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; +import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; -import org.eclipse.jdt.internal.compiler.util.SuffixConstants; -public class ClasspathDirectory implements FileSystem.Classpath, SuffixConstants { +public class ClasspathDirectory extends ClasspathLocation { String path; Hashtable directoryCache; @@ -28,8 +28,14 @@ public static final int SOURCE = 1; public static final int BINARY = 2; -ClasspathDirectory(File directory, String encoding, int mode) { - this.mode = mode; +ClasspathDirectory(File directory, String encoding, int mode, AccessRuleSet accessRuleSet) { + super(accessRuleSet); + if (mode == 0){ + this.mode = SOURCE | BINARY; + } + else { + this.mode = mode; + } this.path = directory.getAbsolutePath(); if (!this.path.endsWith(File.separator)) this.path += File.separator; @@ -38,9 +44,8 @@ } ClasspathDirectory(File directory, String encoding) { - this(directory, encoding, SOURCE | BINARY); // by default consider both sources and binaries + this(directory, encoding, SOURCE | BINARY, null); // by default consider both sources and binaries } - String[] directoryList(String qualifiedPackageName) { String[] dirList = (String[]) this.directoryCache.get(qualifiedPackageName); if (dirList == this.missingPackageHolder) return null; // package exists in another classpath directory or jar @@ -90,19 +95,26 @@ if (sourceExists) { String fullSourcePath = this.path + qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6) + SUFFIX_STRING_java; if (!binaryExists) - return new NameEnvironmentAnswer(new CompilationUnit(null, fullSourcePath, this.encoding), null/* TODO no access restriction*/); - + return new NameEnvironmentAnswer(new CompilationUnit(null, + fullSourcePath, this.encoding), + fetchAccessRestriction(qualifiedBinaryFileName)); String fullBinaryPath = this.path + qualifiedBinaryFileName; long binaryModified = new File(fullBinaryPath).lastModified(); long sourceModified = new File(fullSourcePath).lastModified(); if (sourceModified > binaryModified) - return new NameEnvironmentAnswer(new CompilationUnit(null, fullSourcePath, this.encoding), null/* TODO no access restriction*/); + return new NameEnvironmentAnswer(new CompilationUnit(null, + fullSourcePath, this.encoding), + fetchAccessRestriction(qualifiedBinaryFileName)); } if (binaryExists) { try { - ClassFileReader reader = ClassFileReader.read(this.path + qualifiedBinaryFileName); - if (reader != null) return new NameEnvironmentAnswer(reader, null/* TODO no access restriction*/); - } catch (Exception e) { + ClassFileReader reader = ClassFileReader.read(this.path + + qualifiedBinaryFileName); + if (reader != null) + return new NameEnvironmentAnswer( + reader, + fetchAccessRestriction(qualifiedBinaryFileName)); + } catch (Exception e) { // treat as if file is missing } } @@ -117,4 +129,7 @@ public String toString() { return "ClasspathDirectory " + this.path; //$NON-NLS-1$ } +public String normalizedPath() { + return this.path; +} } Index: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java,v retrieving revision 1.32 diff -u -r1.32 ClasspathJar.java --- batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java 23 Feb 2005 02:47:58 -0000 1.32 +++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java 16 May 2005 17:01:14 -0000 @@ -18,29 +18,32 @@ import java.util.zip.ZipFile; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; +import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; -public class ClasspathJar implements FileSystem.Classpath { +public class ClasspathJar extends ClasspathLocation { ZipFile zipFile; -Hashtable packageCache; boolean closeZipFileAtEnd; +Hashtable packageCache; public ClasspathJar(File file) throws IOException { - this(new ZipFile(file), true); + this(new ZipFile(file), true, null); } -public ClasspathJar(ZipFile zipFile, boolean closeZipFileAtEnd) { +public ClasspathJar(ZipFile zipFile, boolean closeZipFileAtEnd, AccessRuleSet accessRuleSet) { + super(accessRuleSet); this.zipFile = zipFile; - this.packageCache = null; this.closeZipFileAtEnd = closeZipFileAtEnd; -} +} + public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) { if (!isPackage(qualifiedPackageName)) return null; // most common case try { ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedBinaryFileName); - if (reader != null) return new NameEnvironmentAnswer(reader, null /*no access restriction*/); + if (reader != null) return new NameEnvironmentAnswer(reader, + fetchAccessRestriction(qualifiedBinaryFileName)); } catch (Exception e) { // treat as if class file is missing } @@ -82,4 +85,8 @@ public String toString() { return "Classpath for jar file " + this.zipFile.getName(); //$NON-NLS-1$ } +public String normalizedPath(){ + String rawName = this.zipFile.getName(); + return rawName.substring(0, rawName.lastIndexOf('.')); +} } Index: batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java,v retrieving revision 1.31 diff -u -r1.31 FileSystem.java --- batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java 23 Feb 2005 02:47:58 -0000 1.31 +++ batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java 16 May 2005 17:01:14 -0000 @@ -15,6 +15,7 @@ import java.util.zip.ZipFile; import org.eclipse.jdt.core.compiler.CharOperation; +import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; import org.eclipse.jdt.internal.compiler.env.INameEnvironment; import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; import org.eclipse.jdt.internal.compiler.util.SuffixConstants; @@ -31,6 +32,13 @@ * a new name environment without creating a new object. */ void reset(); + /** + * Return a normalized path for file based classpath entries. This is an absolute path + * ending with a file separator for directories, an absolute path deprived from the '.jar' + * (resp. '.zip') extension for jar (resp. zip) files. + * @return a normalized path for file based classpath entries + */ + String normalizedPath(); } /* classPathNames is a collection is Strings representing the full path of each class path @@ -43,47 +51,54 @@ public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding, int[] classpathDirectoryModes) { int classpathSize = classpathNames.length; this.classpaths = new Classpath[classpathSize]; - String[] pathNames = new String[classpathSize]; int problemsOccured = 0; for (int i = 0; i < classpathSize; i++) { - try { - File file = new File(convertPathSeparators(classpathNames[i])); - if (file.isDirectory()) { - if (file.exists()) { - if (classpathDirectoryModes == null){ - this.classpaths[i] = new ClasspathDirectory(file, encoding); - } else { - this.classpaths[i] = new ClasspathDirectory(file, encoding, classpathDirectoryModes[i]); - } - pathNames[i] = ((ClasspathDirectory) this.classpaths[i]).path; - } - } else { - String lowercaseClasspathName = classpathNames[i].toLowerCase(); - if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar) - || lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) { - this.classpaths[i] = this.getClasspathJar(file); // will throw an IOException if file does not exist - pathNames[i] = classpathNames[i].substring(0, classpathNames[i].lastIndexOf('.')); - } - } - } catch (IOException e) { - this.classpaths[i] = null; - } + this.classpaths[i] = getClasspath(classpathNames[i], encoding, + classpathDirectoryModes == null ? 0 + : classpathDirectoryModes[i], null); if (this.classpaths[i] == null) problemsOccured++; } if (problemsOccured > 0) { Classpath[] newPaths = new Classpath[classpathSize - problemsOccured]; - String[] newNames = new String[classpathSize - problemsOccured]; for (int i = 0, current = 0; i < classpathSize; i++) if (this.classpaths[i] != null) { newPaths[current] = this.classpaths[i]; - newNames[current++] = pathNames[i]; } classpathSize = newPaths.length; this.classpaths = newPaths; - pathNames = newNames; } - + initializeKnownFileNames(initialFileNames); +} +FileSystem(Classpath[] classpaths, String[] initialFileNames) { + this.classpaths = classpaths; + initializeKnownFileNames(initialFileNames); +} +static Classpath getClasspath(String classpathName, String encoding, + int classpathDirectoryMode, AccessRuleSet accessRuleSet) { + Classpath result = null; + try { + File file = new File(convertPathSeparators(classpathName)); + if (file.isDirectory()) { + if (file.exists()) { + result = new ClasspathDirectory(file, encoding, + classpathDirectoryMode, accessRuleSet); + } + } else { + String lowercaseClasspathName = classpathName.toLowerCase(); + if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar) + || lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) { + result = new ClasspathJar(new ZipFile(file), true, + accessRuleSet); + // will throw an IOException if file does not exist + } + } + } catch (IOException e) { + // result = null; -- this is already the case + } + return result; +} +private void initializeKnownFileNames(String[] initialFileNames) { this.knownFileNames = new String[initialFileNames.length]; for (int i = initialFileNames.length; --i >= 0;) { String fileName = initialFileNames[i]; @@ -92,20 +107,26 @@ fileName = fileName.substring(0, fileName.lastIndexOf('.')); // remove trailing ".java" fileName = convertPathSeparators(fileName); - for (int j = 0; j < classpathSize; j++) - if (fileName.startsWith(pathNames[j])) - matchingPathName = pathNames[j]; + for (int j = 0; j < classpaths.length; j++){ + String matchCandidate = this.classpaths[j].normalizedPath(); + if (this.classpaths[j] instanceof ClasspathDirectory && + fileName.startsWith(matchCandidate) && + (matchingPathName == null || + matchCandidate.length() < matchingPathName.length())) + matchingPathName = matchCandidate; + } if (matchingPathName == null) this.knownFileNames[i] = fileName; // leave as is... else this.knownFileNames[i] = fileName.substring(matchingPathName.length()); + matchingPathName = null; } } public void cleanup() { for (int i = 0, max = this.classpaths.length; i < max; i++) this.classpaths[i].reset(); } -private String convertPathSeparators(String path) { +private static String convertPathSeparators(String path) { return File.separatorChar == '/' ? path.replace('\\', '/') : path.replace('/', '\\'); @@ -153,7 +174,7 @@ return null; } public ClasspathJar getClasspathJar(File file) throws IOException { - return new ClasspathJar(new ZipFile(file), true); + return new ClasspathJar(new ZipFile(file), true, null); } public boolean isPackage(char[][] compoundName, char[] packageName) { String qualifiedPackageName = new String(CharOperation.concatWith(compoundName, packageName, '/')); Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v retrieving revision 1.195 diff -u -r1.195 Main.java --- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 10 May 2005 14:18:53 -0000 1.195 +++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 16 May 2005 17:01:15 -0000 @@ -23,6 +23,7 @@ import java.io.UnsupportedEncodingException; import java.lang.reflect.Field; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; @@ -45,6 +46,8 @@ import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy; import org.eclipse.jdt.internal.compiler.IProblemFactory; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; +import org.eclipse.jdt.internal.compiler.env.AccessRule; +import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.env.INameEnvironment; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @@ -311,7 +314,7 @@ String.valueOf(time), String.valueOf(((int) (lineCount * 10000.0 / time)) / 10.0) })); } - public void logClasspath(String[] classpaths) { + public void logClasspath(FileSystem.Classpath[] classpaths) { if (classpaths == null) return; if (this.isXml) { final int length = classpaths.length; @@ -320,7 +323,7 @@ this.printTag(CLASSPATHS, null, true, false); for (int i = 0; i < length; i++) { this.parameters.clear(); - String classpath = classpaths[i]; + String classpath = classpaths[i].normalizedPath(); parameters.put(PATH, classpath); File f = new File(classpath); String id = null; @@ -925,7 +928,7 @@ public final static String bundleName = "org.eclipse.jdt.internal.compiler.batch.messages"; //$NON-NLS-1$ - public String[] classpaths; + ArrayList checkedClasspaths; public String destinationPath; public String[] encodings; public Logger logger; @@ -1185,10 +1188,11 @@ final int InsideBootClasspath = 128; final int InsideMaxProblems = 256; final int Default = 0; - String[] bootclasspaths = null; int DEFAULT_SIZE_CLASSPATH = 4; - int pathCount = 0; - int bootclasspathCount = 0; + ArrayList bootclasspaths = new ArrayList(DEFAULT_SIZE_CLASSPATH); + checkedClasspaths = new ArrayList(DEFAULT_SIZE_CLASSPATH); + String currentClasspathName = null; + ArrayList currentRuleSpecs = new ArrayList(DEFAULT_SIZE_CLASSPATH); int index = -1, filesCount = 0, argCount = argv.length; int mode = Default; this.repetitions = 0; @@ -1264,7 +1268,7 @@ currentArg = newCommandLineArgs[index]; customEncoding = null; - if (currentArg.endsWith("]")) { //$NON-NLS-1$ + if (currentArg.endsWith("]") && !(mode == InsideBootClasspath || mode == InsideClasspath) ) { //$NON-NLS-1$ // look for encoding specification int encodingStart = currentArg.indexOf('[') + 1; int encodingEnd = currentArg.length() - 1; @@ -1376,17 +1380,13 @@ } if (currentArg.equals("-classpath") //$NON-NLS-1$ || currentArg.equals("-cp")) { //$NON-NLS-1$ //$NON-NLS-2$ - if (pathCount == 0) { - this.classpaths = new String[DEFAULT_SIZE_CLASSPATH]; - } mode = InsideClasspath; continue; } if (currentArg.equals("-bootclasspath")) {//$NON-NLS-1$ - if (bootclasspathCount > 0) + if (bootclasspaths.size() > 0) throw new InvalidInputException( Main.bind("configure.duplicateBootClasspath", currentArg)); //$NON-NLS-1$ - bootclasspaths = new String[DEFAULT_SIZE_CLASSPATH]; mode = InsideBootClasspath; continue; } @@ -1921,40 +1921,138 @@ mode = Default; continue; } - if (mode == InsideClasspath) { - StringTokenizer tokenizer = new StringTokenizer(currentArg, File.pathSeparator); + if (mode == InsideClasspath || mode == InsideBootClasspath) { + StringTokenizer tokenizer = new StringTokenizer(currentArg, + File.pathSeparator + "[]", true); //$NON-NLS-1$ + // state machine + final int start = 0; + final int readyToClose = 1; + // 'path' 'path1[rule];path2' + final int readyToCloseEndingWithRules = 2; + // 'path[rule]' 'path1;path2[rule]' + final int readyToCloseOrOtherEntry = 3; + // 'path[rule];' 'path;' 'path1;path2;' + final int rulesNeedAnotherRule = 4; + // 'path[rule1;' + final int rulesStart = 5; + // 'path[' 'path1;path2[' + final int rulesReadyToClose = 6; + // 'path[rule' 'path[rule1;rule2' + final int error = 99; + int state = start; + String token = null; while (tokenizer.hasMoreTokens()) { - int length; - if ((length = this.classpaths.length) <= pathCount) { - System.arraycopy( - this.classpaths, - 0, - (this.classpaths = new String[length * 2]), - 0, - length); + token = tokenizer.nextToken(); + if (token.equals(File.pathSeparator)) { + switch (state) { + case readyToClose: + case readyToCloseEndingWithRules: + case readyToCloseOrOtherEntry: + state = readyToCloseOrOtherEntry; + break; + case rulesReadyToClose: + state = rulesNeedAnotherRule; + break; + default: + state = error; + } + } else if (token.equals("[")) { //$NON-NLS-1$ + switch (state) { + case readyToClose: + state = rulesStart; + break; + default: + state = error; + } + } else if (token.equals("]")) { //$NON-NLS-1$ + switch (state) { + case rulesReadyToClose: + state = readyToCloseEndingWithRules; + break; + default: + state = error; + } + + } else // regular word + { + switch (state) { + case start: + case readyToCloseOrOtherEntry: + state = readyToClose; + currentClasspathName = token; + break; + case rulesNeedAnotherRule: + case rulesStart: + state = rulesReadyToClose; + currentRuleSpecs.add(token); + break; + default: + state = error; + } } - this.classpaths[pathCount++] = tokenizer.nextToken(); } - mode = Default; - continue; - } - if (mode == InsideBootClasspath) { - StringTokenizer tokenizer = new StringTokenizer(currentArg, File.pathSeparator); - while (tokenizer.hasMoreTokens()) { - int length; - if ((length = bootclasspaths.length) <= bootclasspathCount) { - System.arraycopy( - bootclasspaths, - 0, - (bootclasspaths = new String[length * 2]), - 0, - length); + if (state == readyToClose + || state == readyToCloseEndingWithRules + || state == readyToCloseOrOtherEntry) { + AccessRule[] accessRules = new AccessRule[currentRuleSpecs + .size()]; + boolean rulesOK = true; + Iterator i = currentRuleSpecs.iterator(); + int j = 0; + while (i.hasNext()) { + String ruleSpec = (String) i.next(); + char key = ruleSpec.charAt(0); + String pattern = ruleSpec.substring(1); + if (pattern.length() > 0) { + switch (key) { + case '+': + accessRules[j++] = new AccessRule(pattern + .toCharArray(), -1); + break; + case '~': + accessRules[j++] = new AccessRule(pattern + .toCharArray(), + IProblem.DiscouragedReference); + break; + case '-': + accessRules[j++] = new AccessRule(pattern + .toCharArray(), + IProblem.ForbiddenReference); + break; + default: + rulesOK = false; + } + } else { + rulesOK = false; + } + } + if (rulesOK) { + AccessRuleSet accessRuleSet = new AccessRuleSet( + accessRules, "{0}"); //$NON-NLS-1$ + FileSystem.Classpath currentClasspath = FileSystem + .getClasspath(currentClasspathName, + customEncoding, 0, accessRuleSet); + if (currentClasspath != null) { + if (mode == InsideClasspath) { + this.checkedClasspaths.add(currentClasspath); + } else { // inside bootclasspath + bootclasspaths.add(currentClasspath); + } + } else { + this.logger.logIncorrectClasspath(currentArg); + // we go on anyway + } + } else { + this.logger.logIncorrectClasspath(currentArg); + // we go on anyway } - bootclasspaths[bootclasspathCount++] = tokenizer.nextToken(); + } else { + this.logger.logIncorrectClasspath(currentArg); + // we go on anyway } mode = Default; continue; - } + } //default is input directory currentArg = currentArg.replace('/', File.separatorChar); if (currentArg.endsWith(File.separator)) @@ -2020,22 +2118,30 @@ (this.filenames = new String[filesCount]), 0, filesCount); - if (pathCount == 0) { + if (checkedClasspaths.size() == 0) { // no user classpath specified. String classProp = System.getProperty("java.class.path"); //$NON-NLS-1$ if ((classProp == null) || (classProp.length() == 0)) { this.logger.logNoClasspath(); //$NON-NLS-1$ - classProp = System.getProperty("user.dir"); //$NON-NLS-1$ } - StringTokenizer tokenizer = new StringTokenizer(classProp, File.pathSeparator); - this.classpaths = new String[tokenizer.countTokens() + 1]; - while (tokenizer.hasMoreTokens()) { - this.classpaths[pathCount++] = tokenizer.nextToken(); + else { + StringTokenizer tokenizer = new StringTokenizer(classProp, File.pathSeparator); + String token; + while (tokenizer.hasMoreTokens()) { + token = tokenizer.nextToken(); + FileSystem.Classpath currentClasspath = FileSystem + .getClasspath(token, customEncoding, 0, null); + if (currentClasspath != null) { + this.checkedClasspaths.add(currentClasspath); + } else { + this.logger.logIncorrectClasspath(token); + // should not happen - we go on anyway + } + } } - this.classpaths[pathCount++] = System.getProperty("user.dir");//$NON-NLS-1$ } - if (bootclasspathCount == 0) { + if (bootclasspaths.size() == 0) { /* no bootclasspath specified * we can try to retrieve the default librairies of the VM used to run * the batch compiler @@ -2060,13 +2166,17 @@ File[] directoriesToCheck = new File[] { new File(javaHomeFile, "lib"), new File(javaHomeFile, "lib/ext")};//$NON-NLS-1$//$NON-NLS-2$ File[][] systemLibrariesJars = getLibrariesFiles(directoriesToCheck); if (systemLibrariesJars != null) { - int length = getLength(systemLibrariesJars); - bootclasspaths = new String[length]; for (int i = 0, max = systemLibrariesJars.length; i < max; i++) { File[] current = systemLibrariesJars[i]; if (current != null) { for (int j = 0, max2 = current.length; j < max2; j++) { - bootclasspaths[bootclasspathCount++] = current[j].getAbsolutePath(); + FileSystem.Classpath classpath = + FileSystem.getClasspath( + current[j].getAbsolutePath(), + null, 0, null); + if (classpath != null) { + bootclasspaths.add(classpath); + } } } } @@ -2084,40 +2194,12 @@ this.showProgress = false; } - if (this.classpaths == null) { - this.classpaths = new String[0]; - } /* * We put the bootclasspath at the beginning of the classpath entries */ - String[] newclasspaths = null; - if ((pathCount + bootclasspathCount) != this.classpaths.length) { - newclasspaths = new String[pathCount + bootclasspathCount]; - } else { - newclasspaths = this.classpaths; - } - System.arraycopy( - this.classpaths, - 0, - newclasspaths, - bootclasspathCount, - pathCount); - - if (bootclasspathCount != 0) { - System.arraycopy( - bootclasspaths, - 0, - newclasspaths, - 0, - bootclasspathCount); - } - this.classpaths = newclasspaths; - for (int i = 0, max = this.classpaths.length; i < max; i++) { - File file = new File(this.classpaths[i]); - if (!file.exists()) { // signal missing classpath entry file - this.logger.logIncorrectClasspath(this.classpaths[i]); //$NON-NLS-1$ - } - } + bootclasspaths.addAll(this.checkedClasspaths); + this.checkedClasspaths = bootclasspaths; + this.checkedClasspaths.trimToSize(); if (this.destinationPath == null) { this.generatePackagesStructure = false; } else if ("none".equals(this.destinationPath)) { //$NON-NLS-1$ @@ -2198,7 +2280,7 @@ } this.logger.logCommandLineArguments(newCommandLineArgs); this.logger.logOptions(this.options); - this.logger.logClasspath(this.classpaths); + this.logger.logClasspath((FileSystem.Classpath[])this.checkedClasspaths.toArray(new FileSystem.Classpath[0])); if (this.repetitions == 0) { this.repetitions = 1; } @@ -2319,18 +2401,6 @@ return result; } - private int getLength(File[][] libraries) { - int sum = 0; - if (libraries != null) { - for (int i = 0, max = libraries.length; i < max; i++) { - final File[] currentFiles = libraries[i]; - if (currentFiles != null) { - sum+= currentFiles.length; - } - } - } - return sum; - } /* * Low-level API performing the actual compilation */ @@ -2351,7 +2421,10 @@ String defaultEncoding = (String) this.options.get(CompilerOptions.OPTION_Encoding); if ("".equals(defaultEncoding)) //$NON-NLS-1$ defaultEncoding = null; //$NON-NLS-1$ - return new FileSystem(this.classpaths, this.filenames, defaultEncoding); + return new FileSystem( + (FileSystem.Classpath[])this.checkedClasspaths.toArray( + new FileSystem.Classpath[0]), + this.filenames); } /* * Low-level API performing the actual compilation Index: batch/org/eclipse/jdt/internal/compiler/batch/messages.properties =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties,v retrieving revision 1.421 diff -u -r1.421 messages.properties --- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 14 May 2005 14:39:07 -0000 1.421 +++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 16 May 2005 17:01:15 -0000 @@ -92,9 +92,13 @@ \ \n\ \ Classpath options:\n\ \ -cp -classpath \n\ -\ specify location for application classes and sources\n\ +\ specify location for application classes and sources. Each\n\ +\ directory or file can specify access rules for types between\n\ +\ ''['' and '']'' (e.g. [-X.java] to deny access to type X)\n\ \ -bootclasspath \n\ -\ specify location for system classes\n\ +\ specify location for system classes. Each directory or file can\n\ +\ specify access rules for types between ''['' and '']'' (e.g. [-X.java]\n\ +\ to deny access to type X)\n\ \ -d destination directory (if omitted, no directory is created)\n\ \ -d none generate no .class files\n\ \ -encoding specify custom encoding for all sources. Each file/directory can override it\n\ Index: compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java,v retrieving revision 1.4 diff -u -r1.4 AccessRuleSet.java --- compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java 17 Apr 2005 17:04:27 -0000 1.4 +++ compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java 16 May 2005 17:01:16 -0000 @@ -25,6 +25,10 @@ public AccessRuleSet(AccessRule[] accessRules) { this.accessRules = accessRules; } + public AccessRuleSet(AccessRule[] accessRules, String messageTemplate) { + this.accessRules = accessRules; + this.messageTemplate = messageTemplate; + } /** * @see java.lang.Object#equals(java.lang.Object) */ Index: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathLocation.java =================================================================== RCS file: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathLocation.java diff -N batch/org/eclipse/jdt/internal/compiler/batch/ClasspathLocation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathLocation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.internal.compiler.batch; + +import org.eclipse.jdt.internal.compiler.env.AccessRestriction; +import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; +import org.eclipse.jdt.internal.compiler.util.SuffixConstants; + +public abstract class ClasspathLocation implements FileSystem.Classpath, + SuffixConstants { + + private AccessRuleSet accessRuleSet; + + public ClasspathLocation(AccessRuleSet accessRuleSet) { + this.accessRuleSet = accessRuleSet; + } + + /** + * Return the first access rule which is violated when accessing a given + * type, or null if no 'non accessible' access rule applies. + * + * @param qualifiedBinaryFileName + * tested type specification, formed as: + * "org/eclipse/jdt/core/JavaCore.class" + * @return the first access rule which is violated when accessing a given + * type, or null if none applies + */ + AccessRestriction fetchAccessRestriction(String qualifiedBinaryFileName) { + if (this.accessRuleSet == null) + return null; + return this.accessRuleSet + .getViolatedRestriction((qualifiedBinaryFileName.substring(0, + qualifiedBinaryFileName.length() - 6) + SUFFIX_STRING_java) + .toCharArray()); + } +}