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 160747 Details for
Bug 304081
IJavaProject#isOnClasspath(IJavaElement) returns false for type from referenced JAR
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
patch_304081.txt (text/plain), 9.57 KB, created by
Jay Arthanareeswaran
on 2010-03-03 03:42:40 EST
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Jay Arthanareeswaran
Created:
2010-03-03 03:42:40 EST
Size:
9.57 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/JavaProject.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java,v >retrieving revision 1.429 >diff -u -r1.429 JavaProject.java >--- model/org/eclipse/jdt/internal/core/JavaProject.java 2 Mar 2010 06:46:00 -0000 1.429 >+++ model/org/eclipse/jdt/internal/core/JavaProject.java 3 Mar 2010 08:16:18 -0000 >@@ -2159,44 +2159,17 @@ > return false; > > // then look at resolved entries >- for (int i = 0; i < length; i++) { >- IClasspathEntry rawEntry = rawClasspath[i]; >- switch (rawEntry.getEntryKind()) { >- case IClasspathEntry.CPE_CONTAINER: >- IClasspathContainer container; >- try { >- container = JavaCore.getClasspathContainer(rawEntry.getPath(), this); >- } catch (JavaModelException e) { >- break; >- } >- if (container == null) >- break; >- IClasspathEntry[] containerEntries = container.getClasspathEntries(); >- if (containerEntries == null) >- break; >- // container was bound >- for (int j = 0, containerLength = containerEntries.length; j < containerLength; j++){ >- IClasspathEntry resolvedEntry = containerEntries[j]; >- if (resolvedEntry == null) { >- if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { >- JavaModelManager.getJavaModelManager().verbose_missbehaving_container(this, rawEntry.getPath(), containerEntries); >- } >- return false; >- } >- if (isOnClasspathEntry(elementPath, isFolderPath, isPackageFragmentRoot, resolvedEntry)) >- return true; >- } >- break; >- case IClasspathEntry.CPE_VARIABLE: >- IClasspathEntry resolvedEntry = JavaCore.getResolvedClasspathEntry(rawEntry); >- if (resolvedEntry == null) >- break; >- if (isOnClasspathEntry(elementPath, isFolderPath, isPackageFragmentRoot, resolvedEntry)) >- return true; >- break; >- } >+ IClasspathEntry[] resolvedClasspath = null; >+ try { >+ resolvedClasspath = getResolvedClasspath(); >+ } catch(JavaModelException e){ >+ return false; // Perhaps, not a Java project > } > >+ for (int index = 0; index< resolvedClasspath.length; index++) { >+ if (isOnClasspathEntry(elementPath, isFolderPath, isPackageFragmentRoot, resolvedClasspath[index])) >+ return true; >+ } > return false; > } > >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/ClasspathTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java,v >retrieving revision 1.208 >diff -u -r1.208 ClasspathTests.java >--- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 2 Mar 2010 06:45:42 -0000 1.208 >+++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 3 Mar 2010 08:16:30 -0000 >@@ -89,7 +89,7 @@ > static { > // Names of tests to run: can be "testBugXXXX" or "BugXXXX") > // TESTS_PREFIX = "testClasspathDuplicateExtraAttribute"; >-// TESTS_NAMES = new String[] {"testClasspathValidation42"}; >+// TESTS_NAMES = new String[] {"testBug304081"}; > // TESTS_NUMBERS = new int[] { 23, 28, 38 }; > // TESTS_RANGE = new int[] { 21, 38 }; > } >@@ -4881,7 +4881,7 @@ > */ > public void testNoResourceChange06() throws CoreException { > ILogListener listener = new ILogListener(){ >- private StringBuffer buffer = new StringBuffer(); >+ private final StringBuffer buffer = new StringBuffer(); > public void logging(IStatus status, String plugin) { > this.buffer.append(status); > this.buffer.append('\n'); >@@ -6427,5 +6427,156 @@ > deleteProject("P"); > } > } >+/** >+ * @bug 304081:IJavaProject#isOnClasspath(IJavaElement) returns false for type from referenced JAR >+ * When the JAR, which a variable classpath entry resolves to, references other JAR via >+ * MANIFEST, test that {@link IJavaProject#isOnClasspath(IJavaElement)} returns true >+ * for the referenced classpath entries. >+ * >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=304081" >+ * @throws Exception >+ */ >+public void testBug304081() throws Exception { >+ File libDir = null; >+ try { >+ >+ IJavaProject proj = this.createJavaProject("P", new String[] {}, "bin"); >+ IPath libPath = proj.getResource().getLocation(); >+ JavaCore.setClasspathVariable("MyVar", libPath, null); >+ libDir = new File(libPath.toPortableString()); >+ IClasspathEntry[] classpath = new IClasspathEntry[1]; >+ File libJar = new File(libDir, "variable.jar"); >+ libJar.createNewFile(); >+ >+ addLibrary(proj, "variable.jar", null, new String[0], >+ new String[] { >+ "META-INF/MANIFEST.MF", >+ "Manifest-Version: 1.0\n" + >+ "Class-Path: lib1.jar\n", >+ }, >+ JavaCore.VERSION_1_4); >+ >+ createFile("/P/lib1.jar", ""); >+ >+ classpath[0] = JavaCore.newVariableEntry(new Path( >+ "/MyVar/variable.jar"), null, null); >+ >+ proj.setRawClasspath(classpath, null); >+ waitForAutoBuild(); >+ IProject project = getWorkspaceRoot().getProject("P"); >+ IResource resource = project.getFile("variable.jar"); >+ assertTrue(proj.isOnClasspath(resource)); >+ IJavaElement element = proj.getPackageFragmentRoot(resource); >+ assertTrue(proj.isOnClasspath(element)); >+ >+ resource = project.getFile("lib1.jar"); >+ assertTrue(proj.isOnClasspath(resource)); >+ element = proj.getPackageFragmentRoot(resource); >+ assertTrue(proj.isOnClasspath(element)); >+ } finally { >+ this.deleteProject("P"); >+ JavaCore.removeClasspathVariable("MyVar", null); >+ } >+} >+/** >+ * Additional tests for 304081 >+ * When the JAR, which is in the raw classpath, references other JAR via >+ * MANIFEST, test that {@link IJavaProject#isOnClasspath(IJavaElement)} returns true >+ * for the referenced classpath entries. >+ * >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=304081" >+ * @throws Exception >+ */ >+public void testBug304081a() throws Exception { >+ try { >+ >+ IJavaProject proj = this.createJavaProject("P", new String[] {}, "bin"); >+ IClasspathEntry[] classpath = new IClasspathEntry[1]; >+ >+ addLibrary(proj, "library.jar", null, new String[0], >+ new String[] { >+ "META-INF/MANIFEST.MF", >+ "Manifest-Version: 1.0\n" + >+ "Class-Path: lib1.jar\n", >+ }, >+ JavaCore.VERSION_1_4); >+ createFile("/P/lib1.jar", ""); >+ classpath[0] = JavaCore.newLibraryEntry(new Path("/P/library.jar"), null, null); >+ >+ proj.setRawClasspath(classpath, null); >+ waitForAutoBuild(); >+ IProject project = getWorkspaceRoot().getProject("P"); >+ IResource resource = project.getFile("library.jar"); >+ assertTrue(proj.isOnClasspath(resource)); >+ IJavaElement element = proj.getPackageFragmentRoot(resource); >+ assertTrue(proj.isOnClasspath(element)); >+ >+ resource = project.getFile("lib1.jar"); >+ assertTrue(proj.isOnClasspath(resource)); >+ element = proj.getPackageFragmentRoot(resource); >+ assertTrue(proj.isOnClasspath(element)); >+ } finally { >+ this.deleteProject("P"); >+ } >+} >+/** >+ * Additional tests for 304081 >+ * When the JAR, which is part of a classpath container, references other JAR via >+ * MANIFEST, test that {@link IJavaProject#isOnClasspath(IJavaElement)} returns true >+ * for the referenced classpath entries. >+ * >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=304081" >+ * @throws Exception >+ */ >+public void testBug304081b() throws Exception { >+ File libDir = null; >+ try { >+ >+ IJavaProject proj = this.createJavaProject("P", new String[] {}, "bin"); >+ IClasspathEntry[] classpath = new IClasspathEntry[1]; >+ File libJar = new File(libDir, "container.jar"); >+ >+ addLibrary(proj, "container.jar", null, new String[0], >+ new String[] { >+ "META-INF/MANIFEST.MF", >+ "Manifest-Version: 1.0\n" + >+ "Class-Path: lib1.jar\n", >+ }, >+ JavaCore.VERSION_1_4); >+ createFile("/P/lib1.jar", ""); >+ >+ ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(JavaCore.USER_LIBRARY_CONTAINER_ID); >+ String libraryName = "TestUserLibrary"; >+ IPath containerPath = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID); >+ UserLibraryClasspathContainer containerSuggestion = new UserLibraryClasspathContainer(libraryName); >+ initializer.requestClasspathContainerUpdate(containerPath.append(libraryName), null, containerSuggestion); >+ >+ IEclipsePreferences preferences = new InstanceScope().getNode(JavaCore.PLUGIN_ID); >+ String propertyName = JavaModelManager.CP_USERLIBRARY_PREFERENCES_PREFIX+"TestUserLibrary"; >+ StringBuffer propertyValue = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<userlibrary systemlibrary=\"false\" version=\"1\">\r\n<archive"); >+ propertyValue.append(" path=\"" + libJar.getAbsolutePath()); >+ propertyValue.append("\"/>\r\n</userlibrary>\r\n"); >+ preferences.put(propertyName, propertyValue.toString()); >+ preferences.flush(); >+ >+ classpath[0] = JavaCore.newContainerEntry(containerSuggestion.getPath()); >+ >+ proj.setRawClasspath(classpath, null); >+ waitForAutoBuild(); >+ IProject project = getWorkspaceRoot().getProject("P"); >+ IResource resource = project.getFile("container.jar"); >+ assertTrue(proj.isOnClasspath(resource)); >+ IJavaElement element = proj.getPackageFragmentRoot(resource); >+ assertTrue(proj.isOnClasspath(element)); >+ >+ resource = project.getFile("lib1.jar"); >+ assertTrue(proj.isOnClasspath(resource)); >+ element = proj.getPackageFragmentRoot(resource); >+ assertTrue(proj.isOnClasspath(element)); >+ >+ } finally { >+ this.deleteProject("P"); >+ } >+} > > }
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 304081
: 160747