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 38355 Details for
Bug 133848
-sourcepath should also be supported for jars and zip files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
New patch
patch_133848.txt (text/plain), 16.55 KB, created by
Olivier Thomann
on 2006-04-11 23:26:17 EDT
(
hide
)
Description:
New patch
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2006-04-11 23:26:17 EDT
Size:
16.55 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: batch/org/eclipse/jdt/internal/compiler/batch/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties,v >retrieving revision 1.519 >diff -u -r1.519 messages.properties >--- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 5 Apr 2006 15:27:20 -0000 1.519 >+++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 12 Apr 2006 03:15:11 -0000 >@@ -107,8 +107,8 @@ > \ -bootclasspath <directories and zip/jar files separated by {0}>\n\ > \ specify location for system classes. Each directory or file can\n\ > \ specify access rules for types between ''['' and '']''\n\ >-\ -sourcepath <directories separated by {0}>\n\ >-\ specify location for application sources. Each directory can\n\ >+\ -sourcepath <directories and zip/jar files separated by {0}>\n\ >+\ specify location for application sources. Each directory or file can\n\ > \ specify access rules for types between ''['' and '']''\n\ > \ -extdirs <directories separated by {0}>\n\ > \ specify location for extension zip/jar files\n\ >Index: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java,v >retrieving revision 1.37 >diff -u -r1.37 ClasspathJar.java >--- batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java 28 Mar 2006 20:30:01 -0000 1.37 >+++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java 12 Apr 2006 03:15:09 -0000 >@@ -19,26 +19,23 @@ > > import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; >+import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; > import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; > import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; > > public class ClasspathJar extends ClasspathLocation { > >-private File file; >-private ZipFile zipFile; >-private boolean closeZipFileAtEnd; >-private Hashtable packageCache; >-private char[] normalizedPath; >+protected File file; >+protected ZipFile zipFile; >+protected boolean closeZipFileAtEnd; >+protected Hashtable packageCache; >+protected char[] normalizedPath; > >-public ClasspathJar(File file) throws IOException { >- this(file, true, null); >-} > public ClasspathJar(File file, boolean closeZipFileAtEnd, AccessRuleSet accessRuleSet) { > super(accessRuleSet); > this.file = file; > this.closeZipFileAtEnd = closeZipFileAtEnd; > } >- > public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) { > if (!isPackage(qualifiedPackageName)) > return null; // most common case >@@ -47,7 +44,9 @@ > ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedBinaryFileName); > if (reader != null) return new NameEnvironmentAnswer(reader, > fetchAccessRestriction(qualifiedBinaryFileName)); >- } catch (Exception e) { >+ } catch(ClassFormatException e) { >+ // treat as if class file is missing >+ } catch (IOException e) { > // treat as if class file is missing > } > return null; >Index: batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java,v >retrieving revision 1.37 >diff -u -r1.37 FileSystem.java >--- batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java 28 Mar 2006 20:30:01 -0000 1.37 >+++ batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java 12 Apr 2006 03:15:09 -0000 >@@ -56,18 +56,12 @@ > classPathNames is a collection is Strings representing the full path of each class path > initialFileNames is a collection is Strings, the trailing '.java' will be removed if its not already. > */ >- > public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding) { >- this(classpathNames, initialFileNames, encoding, null); >-} >-public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding, int[] classpathDirectoryModes) { > final int classpathSize = classpathNames.length; > this.classpaths = new Classpath[classpathSize]; > int counter = 0; > for (int i = 0; i < classpathSize; i++) { >- Classpath classpath = getClasspath(classpathNames[i], encoding, >- classpathDirectoryModes == null ? 0 >- : classpathDirectoryModes[i], null); >+ Classpath classpath = getClasspath(classpathNames[i], encoding, null); > try { > classpath.initialize(); > this.classpaths[counter++] = classpath; >@@ -99,21 +93,27 @@ > } > initializeKnownFileNames(initialFileNames); > } >-static Classpath getClasspath(String classpathName, String encoding, >- int classpathDirectoryMode, AccessRuleSet accessRuleSet) { >+static Classpath getClasspath(String classpathName, String encoding, AccessRuleSet accessRuleSet) { >+ return getClasspath(classpathName, encoding, ClasspathLocation.SOURCE | ClasspathLocation.BINARY, accessRuleSet); >+} >+static Classpath getClasspath(String classpathName, String encoding, int mode, AccessRuleSet accessRuleSet) { > Classpath result = null; > File file = new File(convertPathSeparators(classpathName)); > if (file.isDirectory()) { > if (file.exists()) { >- result = new ClasspathDirectory(file, encoding, >- classpathDirectoryMode, accessRuleSet); >+ result = new ClasspathDirectory(file, encoding, mode, accessRuleSet); > } > } else { > String lowercaseClasspathName = classpathName.toLowerCase(); > if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar) > || lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) { >- result = new ClasspathJar(file, true, accessRuleSet); >- // will throw an IOException if file does not exist >+ if (mode == ClasspathLocation.SOURCE) { >+ // will throw an IOException if file does not exist >+ result = new ClasspathSourceJar(file, true, accessRuleSet, encoding); >+ } else { >+ // will throw an IOException if file does not exist >+ result = new ClasspathJar(file, true, accessRuleSet); >+ } > } > } > return result; >Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v >retrieving revision 1.244 >diff -u -r1.244 Main.java >--- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 7 Apr 2006 09:03:37 -0000 1.244 >+++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 12 Apr 2006 03:15:11 -0000 >@@ -1257,16 +1257,13 @@ > "template.restrictedAccess.field", //$NON-NLS-1$ > new String[] {"{0}", "{1}", currentClasspathName}); //$NON-NLS-1$ //$NON-NLS-2$ > AccessRuleSet accessRuleSet = new AccessRuleSet(accessRules, templates); >- FileSystem.Classpath currentClasspath = FileSystem >- .getClasspath(currentClasspathName, >- customEncoding, 0, accessRuleSet); >+ FileSystem.Classpath currentClasspath = FileSystem.getClasspath( >+ currentClasspathName, >+ customEncoding, >+ isSource ? ClasspathLocation.SOURCE : ClasspathLocation.BINARY | ClasspathLocation.SOURCE, >+ accessRuleSet); > if (currentClasspath != null) { > paths.add(currentClasspath); >- if (isSource && currentClasspath instanceof ClasspathDirectory) { >- ((ClasspathDirectory) currentClasspath).mode = >- ClasspathDirectory.SOURCE; >- // TODO may consider adding this attribute to other classpath natures >- } > } else { > this.logger.logIncorrectClasspath(currentClasspathName); > // we go on anyway >@@ -2378,8 +2375,8 @@ > for (int j = 0, max2 = current.length; j < max2; j++) { > FileSystem.Classpath classpath = > FileSystem.getClasspath( >- current[j].getAbsolutePath(), >- null, 0, null); >+ current[j].getAbsolutePath(), >+ null, null); > if (classpath != null) { > bootclasspaths.add(classpath); > } >@@ -2402,14 +2399,14 @@ > String classProp = System.getProperty("java.class.path"); //$NON-NLS-1$ > if ((classProp == null) || (classProp.length() == 0)) { > this.logger.logNoClasspath(); >- classpaths.add(FileSystem.getClasspath(System.getProperty("user.dir"), customEncoding, 0, null));//$NON-NLS-1$ >+ classpaths.add(FileSystem.getClasspath(System.getProperty("user.dir"), customEncoding, null));//$NON-NLS-1$ > } 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); >+ .getClasspath(token, customEncoding, null); > if (currentClasspath != null) { > classpaths.add(currentClasspath); > } else { >@@ -2471,7 +2468,7 @@ > FileSystem.Classpath classpath = > FileSystem.getClasspath( > current[j].getAbsolutePath(), >- null, 0, null); >+ null, null); > if (classpath != null) { > extdirsClasspaths.add(classpath); > } >Index: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathLocation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathLocation.java,v >retrieving revision 1.3 >diff -u -r1.3 ClasspathLocation.java >--- batch/org/eclipse/jdt/internal/compiler/batch/ClasspathLocation.java 6 Dec 2005 16:21:53 -0000 1.3 >+++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathLocation.java 12 Apr 2006 03:15:09 -0000 >@@ -20,9 +20,15 @@ > public abstract class ClasspathLocation implements FileSystem.Classpath, > SuffixConstants { > >- private AccessRuleSet accessRuleSet; >+ public static final int SOURCE = 1; >+ public static final int BINARY = 2; >+ >+ protected int mode; // ability to only consider one kind of files (source vs. binaries), by default use both > >- public ClasspathLocation(AccessRuleSet accessRuleSet) { >+ protected AccessRuleSet accessRuleSet; >+ protected String encoding; // only useful if referenced in the source path >+ >+ protected ClasspathLocation(AccessRuleSet accessRuleSet) { > this.accessRuleSet = accessRuleSet; > } > >@@ -38,7 +44,7 @@ > * @return the first access rule which is violated when accessing a given > * type, or null if none applies > */ >- AccessRestriction fetchAccessRestriction(String qualifiedBinaryFileName) { >+ protected AccessRestriction fetchAccessRestriction(String qualifiedBinaryFileName) { > if (this.accessRuleSet == null) > return null; > char [] qualifiedTypeName = qualifiedBinaryFileName. >Index: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java,v >retrieving revision 1.37 >diff -u -r1.37 ClasspathDirectory.java >--- batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java 28 Mar 2006 20:30:01 -0000 1.37 >+++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java 12 Apr 2006 03:15:09 -0000 >@@ -26,30 +26,16 @@ > private String path; > private Hashtable directoryCache; > private String[] missingPackageHolder = new String[1]; >-private String encoding; >-public int mode; // ability to only consider one kind of files (source vs. binaries), by default use both >- >-public static final int SOURCE = 1; >-public static final int BINARY = 2; > > ClasspathDirectory(File directory, String encoding, int mode, AccessRuleSet accessRuleSet) { > super(accessRuleSet); >- if (mode == 0){ >- this.mode = SOURCE | BINARY; >- } >- else { >- this.mode = mode; >- } >+ 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; > } >- >-ClasspathDirectory(File directory, String encoding) { >- 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 >@@ -112,8 +98,7 @@ > } > if (binaryExists) { > try { >- ClassFileReader reader = ClassFileReader.read(this.path >- + qualifiedBinaryFileName); >+ ClassFileReader reader = ClassFileReader.read(this.path + qualifiedBinaryFileName); > if (reader != null) > return new NameEnvironmentAnswer( > reader, >Index: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathSourceJar.java >=================================================================== >RCS file: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathSourceJar.java >diff -N batch/org/eclipse/jdt/internal/compiler/batch/ClasspathSourceJar.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathSourceJar.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,68 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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 java.io.File; >+import java.io.IOException; >+import java.util.zip.ZipEntry; >+ >+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; >+import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; >+import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; >+import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; >+import org.eclipse.jdt.internal.compiler.util.Util; >+ >+public class ClasspathSourceJar extends ClasspathJar { >+ public ClasspathSourceJar(File file, boolean closeZipFileAtEnd, AccessRuleSet accessRuleSet, String encoding) { >+ super(file, closeZipFileAtEnd, accessRuleSet); >+ this.encoding = encoding; >+ } >+ >+ public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) { >+ if (!isPackage(qualifiedPackageName)) >+ return null; // most common case >+ >+ ZipEntry sourceEntry = this.zipFile.getEntry(qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6) + SUFFIX_STRING_java); >+ if (sourceEntry != null) { >+ ZipEntry binaryEntry = this.zipFile.getEntry(qualifiedBinaryFileName); >+ if (binaryEntry != null) { >+ if (sourceEntry.getTime() > binaryEntry.getTime()) { >+ try { >+ return new NameEnvironmentAnswer(new CompilationUnit(Util.getInputStreamAsCharArray(this.zipFile.getInputStream(sourceEntry), -1, this.encoding), >+ qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6) + SUFFIX_STRING_java, this.encoding), >+ fetchAccessRestriction(qualifiedBinaryFileName)); >+ } catch (IOException e) { >+ // treat as if source file is missing >+ } >+ } else { >+ try { >+ ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedBinaryFileName); >+ if (reader != null) return new NameEnvironmentAnswer(reader, >+ fetchAccessRestriction(qualifiedBinaryFileName)); >+ } catch(ClassFormatException e) { >+ // treat as if class file is missing >+ } catch (IOException e) { >+ // treat as if class file is missing >+ } >+ } >+ } else { >+ try { >+ return new NameEnvironmentAnswer(new CompilationUnit(Util.getInputStreamAsCharArray(this.zipFile.getInputStream(sourceEntry), -1, this.encoding), >+ qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6) + SUFFIX_STRING_java, this.encoding), >+ fetchAccessRestriction(qualifiedBinaryFileName)); >+ } catch (IOException e) { >+ // treat as if source file is missing >+ } >+ } >+ } >+ return null; >+ } >+}
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 133848
:
37664
| 38355 |
38356