Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 20929 Details for
Bug 92398
[compiler] Leverage access rule support in batch compiler
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Add function as '[+-~pattern]' extension to classpath values
patch_org.eclipse.jdt.core_03.txt (text/plain), 29.03 KB, created by
Maxime Daniel
on 2005-05-11 01:54:24 EDT
(
hide
)
Description:
Add function as '[+-~pattern]' extension to classpath values
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2005-05-11 01:54:24 EDT
Size:
29.03 KB
patch
obsolete
>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 10 May 2005 16:59:38 -0000 >@@ -14,6 +14,8 @@ > import java.util.Hashtable; > > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; >+import org.eclipse.jdt.internal.compiler.env.AccessRestriction; >+import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; > import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; > import org.eclipse.jdt.internal.compiler.util.SuffixConstants; > >@@ -24,23 +26,36 @@ > String[] missingPackageHolder = new String[1]; > String encoding; > public int mode; // ability to only consider one kind of files (source vs. binaries), by default use both >+AccessRuleSet accessRuleSet; > > 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) { >+ 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; > this.directoryCache = new Hashtable(11); > this.encoding = encoding; >+ this.accessRuleSet = accessRuleSet; > } > > 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 >+} >+// TODO factorize common parts of ClasspathJar and ClasspathDirectory >+AccessRestriction fetchAccessRestriction(String qualifiedBinaryFileName){ >+ if (this.accessRuleSet == null) >+ return null; >+ return this.accessRuleSet.getViolatedRestriction((qualifiedBinaryFileName.substring(0, >+ qualifiedBinaryFileName.length() - 6) + SUFFIX_STRING_java).toCharArray()); > } >- > 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 +105,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 +139,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 10 May 2005 16:59:38 -0000 >@@ -18,29 +18,42 @@ > import java.util.zip.ZipFile; > > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; >+import org.eclipse.jdt.internal.compiler.env.AccessRestriction; >+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 ClasspathJar implements FileSystem.Classpath { >+public class ClasspathJar implements FileSystem.Classpath, SuffixConstants { > > ZipFile zipFile; > Hashtable packageCache; > boolean closeZipFileAtEnd; >+AccessRuleSet accessRuleSet; > > 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) { > this.zipFile = zipFile; > this.packageCache = null; > this.closeZipFileAtEnd = closeZipFileAtEnd; >-} >+ this.accessRuleSet = accessRuleSet; >+} >+// TODO factorize common parts of ClasspathJar and ClasspathDirectory >+AccessRestriction fetchAccessRestriction(String qualifiedBinaryFileName){ >+ if (this.accessRuleSet == null) >+ return null; >+ return this.accessRuleSet.getViolatedRestriction((qualifiedBinaryFileName.substring(0, >+ qualifiedBinaryFileName.length() - 6) + SUFFIX_STRING_java).toCharArray()); >+} > 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 +95,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 10 May 2005 16:59:38 -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 >@@ -40,50 +48,58 @@ > public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding) { > this(classpathNames, initialFileNames, encoding, null); > } >+// WORK suppress in favor of the constructor that takes a classpath array > 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 +108,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 +175,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 10 May 2005 16:59:39 -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; >@@ -926,6 +929,9 @@ > "org.eclipse.jdt.internal.compiler.batch.messages"; //$NON-NLS-1$ > > public String[] classpaths; >+ // WORK suppress (if not used) >+ FileSystem.Classpath[] checkedClasspaths; >+ // WORK consider the use of an ArrayList instead > public String destinationPath; > public String[] encodings; > public Logger logger; >@@ -1185,9 +1191,13 @@ > final int InsideBootClasspath = 128; > final int InsideMaxProblems = 256; > final int Default = 0; >- String[] bootclasspaths = null; >+ FileSystem.Classpath[] bootclasspaths = null; > int DEFAULT_SIZE_CLASSPATH = 4; > int pathCount = 0; >+ int checkedClasspathsCount = 0; >+ // FileSystem.Classpath currentClasspath = null; >+ String currentClasspathName = null; >+ ArrayList currentRuleSpecs = new ArrayList(DEFAULT_SIZE_CLASSPATH); > int bootclasspathCount = 0; > int index = -1, filesCount = 0, argCount = argv.length; > int mode = Default; >@@ -1264,7 +1274,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; >@@ -1378,6 +1388,7 @@ > || currentArg.equals("-cp")) { //$NON-NLS-1$ //$NON-NLS-2$ > if (pathCount == 0) { > this.classpaths = new String[DEFAULT_SIZE_CLASSPATH]; >+ this.checkedClasspaths = new FileSystem.Classpath[DEFAULT_SIZE_CLASSPATH]; > } > mode = InsideClasspath; > continue; >@@ -1386,7 +1397,7 @@ > if (bootclasspathCount > 0) > throw new InvalidInputException( > Main.bind("configure.duplicateBootClasspath", currentArg)); //$NON-NLS-1$ >- bootclasspaths = new String[DEFAULT_SIZE_CLASSPATH]; >+ bootclasspaths = new FileSystem.Classpath[DEFAULT_SIZE_CLASSPATH]; > mode = InsideBootClasspath; > continue; > } >@@ -1921,40 +1932,168 @@ > 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 needAnotherEntry = 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: >+ state = needAnotherEntry; >+ 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 needAnotherEntry: >+ state = readyToClose; >+ if (mode == InsideClasspath) { >+ int length; >+ if ((length = this.classpaths.length) <= pathCount) { >+ System >+ .arraycopy( >+ this.classpaths, >+ 0, >+ (this.classpaths = new String[length * 2]), >+ 0, length); >+ } >+ this.classpaths[pathCount++] = token; >+ currentClasspathName = token; >+ } else { // inside bootclasspath >+ 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) { >+ 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) { >+ int length; >+ if (mode == InsideClasspath) { >+ if ((length = this.checkedClasspaths.length) <= checkedClasspathsCount) { >+ System >+ .arraycopy( >+ this.checkedClasspaths, >+ 0, >+ (this.checkedClasspaths = new FileSystem.Classpath[length * 2]), >+ 0, length); >+ } >+ this.checkedClasspaths[checkedClasspathsCount++] = currentClasspath; >+ } else { // inside bootclasspath >+ if ((length = bootclasspaths.length) <= bootclasspathCount) { >+ System >+ .arraycopy( >+ bootclasspaths, >+ 0, >+ (bootclasspaths = new FileSystem.Classpath[length * 2]), >+ 0, length); >+ } >+ bootclasspaths[bootclasspathCount++] = currentClasspath; >+ } >+ } else { >+ this.logger.logIncorrectClasspath(currentArg); >+ // WORK refine diagnostic >+ } >+ } 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)) >@@ -2025,12 +2164,25 @@ > 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$ >+ this.classpaths = new String[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; >+ this.classpaths = new String[tokenizer.countTokens() + 1]; >+ this.checkedClasspaths = new FileSystem.Classpath[this.classpaths.length]; >+ while (tokenizer.hasMoreTokens()) { >+ token = tokenizer.nextToken(); >+ this.classpaths[pathCount++] = token; >+ FileSystem.Classpath currentClasspath = FileSystem >+ .getClasspath(token, customEncoding, 0, null); >+ if (currentClasspath != null) { >+ this.checkedClasspaths[checkedClasspathsCount++] = currentClasspath; >+ } else { >+ this.logger.logIncorrectClasspath(token); >+ // should not happen - we go on anyway >+ } >+ } > } > this.classpaths[pathCount++] = System.getProperty("user.dir");//$NON-NLS-1$ > } >@@ -2061,12 +2213,17 @@ > File[][] systemLibrariesJars = getLibrariesFiles(directoriesToCheck); > if (systemLibrariesJars != null) { > int length = getLength(systemLibrariesJars); >- bootclasspaths = new String[length]; >+ bootclasspaths = new FileSystem.Classpath[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(); >+ if ((bootclasspaths[bootclasspathCount] = FileSystem >+ .getClasspath(current[j] >+ .getAbsolutePath(), >+ null, 0, null)) != null) { >+ bootclasspathCount++; >+ } > } > } > } >@@ -2102,22 +2259,20 @@ > newclasspaths, > bootclasspathCount, > pathCount); >- >- if (bootclasspathCount != 0) { >- System.arraycopy( >- bootclasspaths, >- 0, >- newclasspaths, >+ FileSystem.Classpath [] trimmedClasspaths = new FileSystem.Classpath[bootclasspathCount >+ + checkedClasspathsCount]; >+ System.arraycopy( >+ this.checkedClasspaths, > 0, >- bootclasspathCount); >+ trimmedClasspaths, >+ bootclasspathCount, >+ checkedClasspathsCount); >+ for (int i = 0; i < bootclasspathCount;i++){ >+ trimmedClasspaths[i] = bootclasspaths[i]; >+ newclasspaths[i] = bootclasspaths[i].normalizedPath(); > } > 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$ >- } >- } >+ this.checkedClasspaths = trimmedClasspaths; > if (this.destinationPath == null) { > this.generatePackagesStructure = false; > } else if ("none".equals(this.destinationPath)) { //$NON-NLS-1$ >@@ -2351,7 +2506,7 @@ > 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(this.checkedClasspaths, 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.419 >diff -u -r1.419 messages.properties >--- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 9 May 2005 17:05:44 -0000 1.419 >+++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 10 May 2005 16:59:39 -0000 >@@ -92,9 +92,13 @@ > \ \n\ > \ Classpath options:\n\ > \ -cp -classpath <directories and zip/jar files separated by {0}>\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 <directories and zip/jar files separated by {0}>\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 <dir> destination directory (if omitted, no directory is created)\n\ > \ -d none generate no .class files\n\ > \ -encoding <enc> 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 10 May 2005 16:59:39 -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) > */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 92398
:
20782
|
20929
|
20930
|
21413
|
21414
|
21716