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 64934 Details for
Bug 162104
NPE in PackageExplorerContentProvider.getPackageFragmentRoots()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v00.txt (text/plain), 4.27 KB, created by
Frederic Fusier
on 2007-04-25 17:05:33 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2007-04-25 17:05:33 EDT
Size:
4.27 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java,v >retrieving revision 1.123 >diff -u -r1.123 PackageFragmentRoot.java >--- model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java 13 Apr 2007 16:02:15 -0000 1.123 >+++ model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java 25 Apr 2007 21:02:52 -0000 >@@ -583,6 +583,12 @@ > if (rootPathToRawEntries != null) { > rawEntry = (IClasspathEntry) rootPathToRawEntries.get(this.getPath()); > } >+ if (rawEntry == null) { >+ String msg = getKind()== IPackageFragmentRoot.K_BINARY >+ ? Messages.classpath_illegalLibraryPath >+ : Messages.classpath_illegalSourceFolderPath; >+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(msg, new String[] {getPath().toOSString(), project.getElementName()}))); >+ } > return rawEntry; > } > >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java,v >retrieving revision 1.83 >diff -u -r1.83 JavaProjectTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java 10 Apr 2007 13:49:15 -0000 1.83 >+++ src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java 25 Apr 2007 21:02:57 -0000 >@@ -26,6 +26,7 @@ > import org.eclipse.jdt.core.tests.model.ClasspathInitializerTests.DefaultContainerInitializer; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.core.JavaModelManager; >+import org.eclipse.jdt.internal.core.PackageFragmentRoot; > import org.eclipse.jdt.internal.core.UserLibrary; > import org.eclipse.jdt.internal.core.UserLibraryManager; > import org.eclipse.jdt.internal.core.util.Util; >@@ -1041,6 +1042,53 @@ > JavaCore.removeClasspathVariable("MyVar", null); > } > } >+/** >+ * @bug 162104: NPE in PackageExplorerContentProvider.getPackageFragmentRoots() >+ * @test That a JME is thrown when a classpath entry is no longer on the classpath >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=162104" >+ */ >+public void testPackageFragmentRootNullRawEntry() throws CoreException, IOException { >+ File libDir = null; >+ try { >+ String libPath = getExternalPath() + "lib"; >+ JavaCore.setClasspathVariable("MyVar", new Path(libPath), null); >+ IJavaProject proj = this.createJavaProject("P", new String[] {}, "bin"); >+ libDir = new File(libPath); >+ libDir.mkdirs(); >+ final int length = 10; >+ IClasspathEntry[] classpath = new IClasspathEntry[length]; >+ for (int i = 0; i < length; i++){ >+ File libJar = new File(libDir, "lib"+i+".jar"); >+ libJar.createNewFile(); >+ classpath[i] = JavaCore.newVariableEntry(new Path("/MyVar/lib"+i+".jar"), null, null); >+ } >+ proj.setRawClasspath(classpath, null); >+ >+ IPackageFragmentRoot[] roots = proj.getPackageFragmentRoots(); >+ assertEquals("wrong number of entries:", length, roots.length); >+ >+ // remove last classpath entry >+ System.arraycopy(classpath, 0, classpath = new IClasspathEntry[length-1], 0, length-1); >+ proj.setRawClasspath(classpath, null); >+ >+ // verify that JME occurs >+ IPackageFragmentRoot lastRoot = roots[length-1]; >+ String rootPath = ((PackageFragmentRoot)lastRoot).toStringWithAncestors(); >+ try { >+ IClasspathEntry rawEntry = roots[length-1].getRawClasspathEntry(); >+ assertNotNull("We should no longer get a null classpath entry:", rawEntry); >+ } catch (JavaModelException jme) { >+ assertEquals("Unexpected JME exception", >+ "Illegal path for required library: '"+rootPath+"' in project 'P'", jme.getJavaModelStatus().getMessage()); >+ } >+ } finally { >+ if (libDir != null) { >+ org.eclipse.jdt.core.tests.util.Util.delete(libDir); >+ } >+ this.deleteProject("P"); >+ JavaCore.removeClasspathVariable("MyVar", null); >+ } >+} > /* > * Ensures that opening a project update the project references > * (regression test for bug 73253 [model] Project references not set on project open)
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 162104
:
64934
|
65008